|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 07/44] x86/boot: Use percpu pagetables for the idle vcpus
Introduce early_switch_to_idle() to replace the opencoded switching to idle
context in the BSP and AP boot paths, and extend it to switch away from
idle_pg_table[] as well.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
xen/arch/x86/domain.c | 4 +++-
xen/arch/x86/domain_page.c | 2 +-
xen/arch/x86/setup.c | 22 ++++++++++++++++++++--
xen/arch/x86/smpboot.c | 6 ++++--
xen/include/asm-x86/system.h | 1 +
5 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 0ae715d..93e81c0 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -349,7 +349,9 @@ int vcpu_initialise(struct vcpu *v)
else
{
/* Idle domain */
- v->arch.cr3 = __pa(idle_pg_table);
+ v->arch.cr3 = per_cpu(percpu_idle_pt, v->vcpu_id);
+ BUG_ON(!v->arch.cr3); /* Had better be initialised... */
+
rc = 0;
v->arch.msr = ZERO_BLOCK_PTR; /* Catch stray misuses */
}
diff --git a/xen/arch/x86/domain_page.c b/xen/arch/x86/domain_page.c
index 3432a85..8f2bcd4 100644
--- a/xen/arch/x86/domain_page.c
+++ b/xen/arch/x86/domain_page.c
@@ -51,7 +51,7 @@ static inline struct vcpu *mapcache_current_vcpu(void)
if ( (v = idle_vcpu[smp_processor_id()]) == current )
sync_local_execstate();
/* We must now be running on the idle page table. */
- ASSERT(read_cr3() == __pa(idle_pg_table));
+ ASSERT(read_cr3() == this_cpu(percpu_idle_pt));
}
return v;
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 4aff5bd..b8e52cf 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -237,11 +237,29 @@ void __init discard_initial_images(void)
extern char __init_begin[], __init_end[], __bss_start[], __bss_end[];
+void early_switch_to_idle(void)
+{
+ unsigned int cpu = smp_processor_id();
+ struct vcpu *v = idle_vcpu[cpu];
+ unsigned long cr4 = read_cr4();
+
+ set_current(v);
+ per_cpu(curr_vcpu, cpu) = v;
+
+ asm volatile ( "mov %[npge], %%cr4;"
+ "mov %[cr3], %%cr3;"
+ "mov %[pge], %%cr4;"
+ ::
+ [npge] "r" (cr4 & ~X86_CR4_PGE),
+ [cr3] "r" (v->arch.cr3),
+ [pge] "r" (cr4)
+ : "memory" );
+}
+
static void __init init_idle_domain(void)
{
scheduler_init();
- set_current(idle_vcpu[0]);
- this_cpu(curr_vcpu) = current;
+ early_switch_to_idle();
}
void srat_detect_node(int cpu)
diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
index 221d9c7..ae39b48 100644
--- a/xen/arch/x86/smpboot.c
+++ b/xen/arch/x86/smpboot.c
@@ -307,8 +307,10 @@ void start_secondary(void *unused)
/* Critical region without IDT or TSS. Any fault is deadly! */
set_processor_id(cpu);
- set_current(idle_vcpu[cpu]);
- this_cpu(curr_vcpu) = idle_vcpu[cpu];
+ get_cpu_info()->cr4 = XEN_MINIMAL_CR4;
+
+ early_switch_to_idle();
+
rdmsrl(MSR_EFER, this_cpu(efer));
/*
diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h
index 8ac1703..ee57631 100644
--- a/xen/include/asm-x86/system.h
+++ b/xen/include/asm-x86/system.h
@@ -230,6 +230,7 @@ static inline int local_irq_is_enabled(void)
void trap_init(void);
void init_idt_traps(void);
+void early_switch_to_idle(void);
void load_system_tables(void);
void percpu_traps_init(void);
void subarch_percpu_traps_init(void);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |