Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 69575d38 authored by Shane Wang's avatar Shane Wang Committed by H. Peter Anvin
Browse files

x86, intel_txt: clean up the impact on generic code, unbreak non-x86



Move tboot.h from asm to linux to fix the build errors of intel_txt
patch on non-X86 platforms. Remove the tboot code from generic code
init/main.c and kernel/cpu.c.

Signed-off-by: default avatarShane Wang <shane.wang@intel.com>
Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent 62a3207b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -178,6 +178,10 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING
config ARCH_SUPPORTS_DEBUG_PAGEALLOC
	def_bool y

config HAVE_INTEL_TXT
	def_bool y
	depends on EXPERIMENTAL && DMAR && ACPI

# Use the generic interrupt handling code in kernel/irq/:
config GENERIC_HARDIRQS
	bool
+1 −2
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#include <linux/init.h>
#include <linux/pm.h>
#include <linux/efi.h>
#include <linux/tboot.h>
#include <acpi/reboot.h>
#include <asm/io.h>
#include <asm/apic.h>
@@ -24,8 +25,6 @@
# include <asm/iommu.h>
#endif

#include <asm/tboot.h>

/*
 * Power off function, if any
 */
+1 −2
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@

#include <linux/percpu.h>
#include <linux/crash_dump.h>
#include <linux/tboot.h>

#include <video/edid.h>

@@ -145,8 +146,6 @@ struct boot_params __initdata boot_params;
struct boot_params boot_params;
#endif

#include <asm/tboot.h>

/*
 * Machine setup..
 */
+1 −1
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@
#include <linux/bootmem.h>
#include <linux/err.h>
#include <linux/nmi.h>
#include <linux/tboot.h>

#include <asm/acpi.h>
#include <asm/desc.h>
@@ -62,7 +63,6 @@
#include <asm/vmi.h>
#include <asm/apic.h>
#include <asm/setup.h>
#include <asm/tboot.h>
#include <asm/uv/uv.h>
#include <linux/mc146818rtc.h>

+47 −11
Original line number Diff line number Diff line
@@ -22,11 +22,14 @@
#include <linux/dma_remapping.h>
#include <linux/init_task.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <linux/dmar.h>
#include <linux/cpu.h>
#include <linux/pfn.h>
#include <linux/mm.h>
#include <linux/tboot.h>

#include <asm/trampoline.h>
#include <asm/processor.h>
@@ -36,7 +39,6 @@
#include <asm/fixmap.h>
#include <asm/proto.h>
#include <asm/setup.h>
#include <asm/tboot.h>
#include <asm/e820.h>
#include <asm/io.h>

@@ -154,13 +156,10 @@ static int map_tboot_pages(unsigned long vaddr, unsigned long start_pfn,
	return 0;
}

void tboot_create_trampoline(void)
static void tboot_create_trampoline(void)
{
	u32 map_base, map_size;

	if (!tboot_enabled())
		return;

	/* Create identity map for tboot shutdown code. */
	map_base = PFN_DOWN(tboot->tboot_base);
	map_size = PFN_UP(tboot->tboot_size);
@@ -295,21 +294,58 @@ void tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
	tboot_shutdown(acpi_shutdown_map[sleep_state]);
}

int tboot_wait_for_aps(int num_aps)
static atomic_t ap_wfs_count;

static int tboot_wait_for_aps(int num_aps)
{
	unsigned long timeout;

	timeout = AP_WAIT_TIMEOUT*HZ;
	while (atomic_read((atomic_t *)&tboot->num_in_wfs) != num_aps &&
	       timeout) {
		mdelay(1);
		timeout--;
	}

	if (timeout)
		pr_warning("tboot wait for APs timeout\n");

	return !(atomic_read((atomic_t *)&tboot->num_in_wfs) == num_aps);
}

static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
			unsigned long action, void *hcpu)
{
	switch (action) {
	case CPU_DYING:
		atomic_inc(&ap_wfs_count);
		if (num_online_cpus() == 1)
			if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
				return NOTIFY_BAD;
		break;
	}
	return NOTIFY_OK;
}

static struct notifier_block tboot_cpu_notifier __cpuinitdata =
{
	.notifier_call = tboot_cpu_callback,
};

static __init int tboot_late_init(void)
{
	if (!tboot_enabled())
		return 0;

	timeout = jiffies + AP_WAIT_TIMEOUT*HZ;
	while (atomic_read((atomic_t *)&tboot->num_in_wfs) != num_aps &&
	       time_before(jiffies, timeout))
		cpu_relax();
	tboot_create_trampoline();

	return time_before(jiffies, timeout) ? 0 : 1;
	atomic_set(&ap_wfs_count, 0);
	register_hotcpu_notifier(&tboot_cpu_notifier);
	return 0;
}

late_initcall(tboot_late_init);

/*
 * TXT configuration registers (offsets from TXT_{PUB, PRIV}_CONFIG_REGS_BASE)
 */
Loading