Skip to contentSkip to conversation

: PVH: smp changes

RFC PATCH In review Mukesh Rathor 2 participants 4 messages Aug 16, 2012 – Aug 22, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 5/8 : PVH: smp changes

---
 arch/x86/xen/smp.c |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)
arch/x86/xen/smp.c +25 -8
index cdf269d..017d7fa 100644
@@ -68,9 +68,11 @@ static void __cpuinit cpu_bringup(void)
 	touch_softlockup_watchdog();
 	preempt_disable();
 
-	xen_enable_sysenter();
-	xen_enable_syscall();
-
+	/* PVH runs in ring 0 and allows us to do native syscalls. Yay! */
+	if (!xen_pvh_domain()) {
+		xen_enable_sysenter();
+		xen_enable_syscall();
+	}
 	cpu = smp_processor_id();
 	smp_store_cpu_info(cpu);
 	cpu_data(cpu).x86_max_cores = 1;
@@ -230,10 +232,11 @@ static void __init xen_smp_prepare_boot_cpu(void)
 	BUG_ON(smp_processor_id() != 0);
 	native_smp_prepare_boot_cpu();
 
-	/* We've switched to the "real" per-cpu gdt, so make sure the
-	   old memory can be recycled */
-	make_lowmem_page_readwrite(xen_initial_gdt);
-
+	if (!xen_pvh_domain()) {
+		/* We've switched to the "real" per-cpu gdt, so make sure the
+		 * old memory can be recycled */
+		make_lowmem_page_readwrite(xen_initial_gdt);
+	}
 	xen_filter_cpu_maps();
 	xen_setup_vcpu_info_placement();
 }
@@ -312,6 +315,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 
 	memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
 
+	if (!xen_pvh_domain()) {
 		ctxt->user_regs.ds = __USER_DS;
 		ctxt->user_regs.es = __USER_DS;
 
@@ -339,7 +343,20 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 					(unsigned long)xen_hypervisor_callback;
 		ctxt->failsafe_callback_eip = 
 					(unsigned long)xen_failsafe_callback;
-
+	} else {
+		ctxt->user_regs.ds = __KERNEL_DS;
+		ctxt->user_regs.es = 0;
+		ctxt->user_regs.gs = 0;
+
+		ctxt->gdt_frames[0] = (unsigned long)gdt;
+		ctxt->gdt_ents = (unsigned long)(GDT_SIZE - 1);
+
+		/* Note: PVH is not supported on x86_32. */
+#ifdef __x86_64__
+		ctxt->gs_base_user = (unsigned long)
+		                         per_cpu(irq_stack_union.gs_base, cpu);
+#endif
+	}
 	ctxt->user_regs.cs = __KERNEL_CS;
 	ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
 
Signature · 1 line
1.7.2.3
#1 lore raw
Quoted 9 lines · Mukesh Rathor
---
 arch/x86/xen/smp.c |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)
arch/x86/xen/smp.c +0 -0
index cdf269d..017d7fa 100644

arch/x86/xen/smp.c static void __cpuinit cpu_bringup(void) · line 72

Quoted 8 lines
arch/x86/xen/smp.c +2 -3
@@ -68,9 +68,11 @@ static void __cpuinit cpu_bringup(void)
 	touch_softlockup_watchdog();
 	preempt_disable();
 
-	xen_enable_sysenter();
-	xen_enable_syscall();
-
+	/* PVH runs in ring 0 and allows us to do native syscalls. Yay! */
+	if (!xen_pvh_domain()) {

Can this be gated on X86_FEATURE_BLAH, with appropriate masking for the PV vs PVH cases.

Looks like enable_sysenter actually does that already, maybe enable_syscall could too?

Quoted 7 lines
arch/x86/xen/smp.c +3 -0
+		xen_enable_sysenter();
+		xen_enable_syscall();
+	}
 	cpu = smp_processor_id();
 	smp_store_cpu_info(cpu);
 	cpu_data(cpu).x86_max_cores = 1;

arch/x86/xen/smp.c static void __init xen_smp_prepare_boot_cpu(void) · line 235

Quoted 8 lines
arch/x86/xen/smp.c +1 -4
@@ -230,10 +232,11 @@ static void __init xen_smp_prepare_boot_cpu(void)
 	BUG_ON(smp_processor_id() != 0);
 	native_smp_prepare_boot_cpu();
 
-	/* We've switched to the "real" per-cpu gdt, so make sure the
-	   old memory can be recycled */
-	make_lowmem_page_readwrite(xen_initial_gdt);
-
+	if (!xen_pvh_domain()) {

XENFEAT_writable_pagetalbes, I think? And possibly pushed down into make_lowmem_page_readwrite?

Quoted 16 lines
arch/x86/xen/smp.c +5 -0
+		/* We've switched to the "real" per-cpu gdt, so make sure the
+		 * old memory can be recycled */
+		make_lowmem_page_readwrite(xen_initial_gdt);
+	}
 	xen_filter_cpu_maps();
 	xen_setup_vcpu_info_placement();
 }
@@ -312,6 +315,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 
 	memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
 
+	if (!xen_pvh_domain()) {
 		ctxt->user_regs.ds = __USER_DS;
 		ctxt->user_regs.es = __USER_DS;
 

arch/x86/xen/smp.c cpu_initialize_context(unsigned int cpu, struct task_struct *idle) · line 349

Quoted 8 lines
arch/x86/xen/smp.c +4 -1
@@ -339,7 +343,20 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
 					(unsigned long)xen_hypervisor_callback;
 		ctxt->failsafe_callback_eip = 
 					(unsigned long)xen_failsafe_callback;
-
+	} else {
+		ctxt->user_regs.ds = __KERNEL_DS;
+		ctxt->user_regs.es = 0;
+		ctxt->user_regs.gs = 0;

Not __KERNEL_DS for es too?

Not sure about gs -- shouldn't that point to some per-cpu segment or something? Maybe that happens somewhere else? (in which case a comment?)

arch/x86/xen/smp.c cpu_initialize_context(unsigned int cpu, struct task_struct *idle) · line 355

Quoted 6 lines
arch/x86/xen/smp.c +6 -0
+
+		ctxt->gdt_frames[0] = (unsigned long)gdt;
+		ctxt->gdt_ents = (unsigned long)(GDT_SIZE - 1);
+
+		/* Note: PVH is not supported on x86_32. */
+#ifdef __x86_64__

ITYM CONFIG_X86_64?

Quoted 7 lines
arch/x86/xen/smp.c +4 -0
+		ctxt->gs_base_user = (unsigned long)
+		                         per_cpu(irq_stack_union.gs_base, cpu);
+#endif
+	}
 	ctxt->user_regs.cs = __KERNEL_CS;
 	ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
 
#2 lore raw
Quoted 11 lines · On Fri, 17 Aug 2012 10:42:11 +0100 Ian Campbell <[email protected]> wrote:

arch/x86/xen/smp.c cpu_initialize_context(unsigned int cpu, struct task_struct *idle) · line 349

Quoted 9 lines
(quoted diff) +0 -0
@@ -339,7 +343,20 @@ cpu_initialize_context(unsigned int cpu,
 struct task_struct *idle) (unsigned long)xen_hypervisor_callback;
 		ctxt->failsafe_callback_eip = 
 					(unsigned

long)xen_failsafe_callback; -

arch/x86/xen/smp.c +4 -0
+	} else {
+		ctxt->user_regs.ds = __KERNEL_DS;
+		ctxt->user_regs.es = 0;
+		ctxt->user_regs.gs = 0;

Not __KERNEL_DS for es too?

64bit, es ignored, right?

Quoted 3 lines

Not sure about gs -- shouldn't that point to some per-cpu segment or something? Maybe that happens somewhere else? (in which case a comment?)

Gets set later. comment good idea.

Quoted 8 lines

arch/x86/xen/smp.c cpu_initialize_context(unsigned int cpu, struct task_struct *idle) · line 355

Quoted 6 lines
arch/x86/xen/smp.c +6 -0
+
+		ctxt->gdt_frames[0] = (unsigned long)gdt;
+		ctxt->gdt_ents = (unsigned long)(GDT_SIZE - 1);
+
+		/* Note: PVH is not supported on x86_32. */
+#ifdef __x86_64__

ITYM CONFIG_X86_64?

Yup.

#3 lore raw
Quoted 15 lines · Mukesh Rathor
Quoted 11 lines · On Fri, 17 Aug 2012 10:42:11 +0100 Ian Campbell <[email protected]> wrote:

arch/x86/xen/smp.c cpu_initialize_context(unsigned int cpu, struct task_struct *idle) · line 349

Quoted 9 lines
(quoted diff) +0 -0
@@ -339,7 +343,20 @@ cpu_initialize_context(unsigned int cpu,
 struct task_struct *idle) (unsigned long)xen_hypervisor_callback;
 		ctxt->failsafe_callback_eip = 
 					(unsigned

long)xen_failsafe_callback; -

arch/x86/xen/smp.c +4 -0
+	} else {
+		ctxt->user_regs.ds = __KERNEL_DS;
+		ctxt->user_regs.es = 0;
+		ctxt->user_regs.gs = 0;

Not __KERNEL_DS for es too?

Quoted 1 line

64bit, es ignored, right?

Not 100% sure, the limit certainly is but the base and the privilege level might not be?

The reason I mentioned it was that I could see in the !pvh case:

                ctxt->user_regs.es = __USER_DS;

Ian.