public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0 of 5] xen+x86: misc fixes
@ 2008-05-23 13:10 Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 1 of 5] xen: use hypercall rather than clts Jeremy Fitzhardinge
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2008-05-23 13:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

Hi Ingo,

This series is just some small miscellaneous x86 and Xen fixes.
There's nothing urgent here.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1 of 5] xen: use hypercall rather than clts
  2008-05-23 13:10 [PATCH 0 of 5] xen+x86: misc fixes Jeremy Fitzhardinge
@ 2008-05-23 13:10 ` Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 2 of 5] xen: use new sched_op Jeremy Fitzhardinge
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2008-05-23 13:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

Xen will trap and emulate clts, but its better to use a hypercall.
Also, xenner doesn't handle clts.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/xen/enlighten.c        |   28 ++++++++++++++++++++++++++--
 include/asm-x86/xen/hypercall.h |    7 +++++++
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -607,6 +607,30 @@
 	xen_mc_issue(PARAVIRT_LAZY_MMU);
 }
 
+static void xen_clts(void)
+{
+	struct multicall_space mcs;
+
+	mcs = xen_mc_entry(0);
+
+	MULTI_fpu_taskswitch(mcs.mc, 0);
+
+	xen_mc_issue(PARAVIRT_LAZY_CPU);
+}
+
+static void xen_write_cr0(unsigned long cr0)
+{
+	struct multicall_space mcs;
+
+	/* Only pay attention to cr0.TS; everything else is
+	   ignored. */
+	mcs = xen_mc_entry(0);
+
+	MULTI_fpu_taskswitch(mcs.mc, (cr0 & X86_CR0_TS) != 0);
+
+	xen_mc_issue(PARAVIRT_LAZY_CPU);
+}
+
 static void xen_write_cr2(unsigned long cr2)
 {
 	x86_read_percpu(xen_vcpu)->arch.cr2 = cr2;
@@ -978,10 +1002,10 @@
 	.set_debugreg = xen_set_debugreg,
 	.get_debugreg = xen_get_debugreg,
 
-	.clts = native_clts,
+	.clts = xen_clts,
 
 	.read_cr0 = native_read_cr0,
-	.write_cr0 = native_write_cr0,
+	.write_cr0 = xen_write_cr0,
 
 	.read_cr4 = native_read_cr4,
 	.read_cr4_safe = native_read_cr4_safe,
diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -315,6 +315,13 @@
 }
 
 static inline void
+MULTI_fpu_taskswitch(struct multicall_entry *mcl, int set)
+{
+	mcl->op = __HYPERVISOR_fpu_taskswitch;
+	mcl->args[0] = set;
+}
+
+static inline void
 MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va,
 			pte_t new_val, unsigned long flags)
 {



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2 of 5] xen: use new sched_op
  2008-05-23 13:10 [PATCH 0 of 5] xen+x86: misc fixes Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 1 of 5] xen: use hypercall rather than clts Jeremy Fitzhardinge
@ 2008-05-23 13:10 ` Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 3 of 5] x86: use symbolic constant in stts() Jeremy Fitzhardinge
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2008-05-23 13:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

Use the new sched_op hypercall, mainly because xenner doesn't support
the old one.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/xen/enlighten.c        |    6 ++++--
 include/asm-x86/xen/hypercall.h |    4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -254,7 +254,7 @@
 static void xen_safe_halt(void)
 {
 	/* Blocking includes an implicit local_irq_enable(). */
-	if (HYPERVISOR_sched_op(SCHEDOP_block, 0) != 0)
+	if (HYPERVISOR_sched_op(SCHEDOP_block, NULL) != 0)
 		BUG();
 }
 
@@ -1139,11 +1139,13 @@
 
 static void xen_reboot(int reason)
 {
+	struct sched_shutdown r = { .reason = reason };
+
 #ifdef CONFIG_SMP
 	smp_send_stop();
 #endif
 
-	if (HYPERVISOR_sched_op(SCHEDOP_shutdown, reason))
+	if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
 		BUG();
 }
 
diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -176,9 +176,9 @@
 }
 
 static inline int
-HYPERVISOR_sched_op(int cmd, unsigned long arg)
+HYPERVISOR_sched_op(int cmd, void *arg)
 {
-	return _hypercall2(int, sched_op, cmd, arg);
+	return _hypercall2(int, sched_op_new, cmd, arg);
 }
 
 static inline long



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3 of 5] x86: use symbolic constant in stts()
  2008-05-23 13:10 [PATCH 0 of 5] xen+x86: misc fixes Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 1 of 5] xen: use hypercall rather than clts Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 2 of 5] xen: use new sched_op Jeremy Fitzhardinge
@ 2008-05-23 13:10 ` Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 4 of 5] xen: allow some cr4 updates Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 5 of 5] xen: don't worry about preempt during xen_irq_enable() Jeremy Fitzhardinge
  4 siblings, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2008-05-23 13:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 include/asm-x86/system.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-x86/system.h b/include/asm-x86/system.h
--- a/include/asm-x86/system.h
+++ b/include/asm-x86/system.h
@@ -293,7 +293,7 @@
 
 #endif/* CONFIG_PARAVIRT */
 
-#define stts() write_cr0(8 | read_cr0())
+#define stts() write_cr0(read_cr0() | X86_CR0_TS)
 
 #endif /* __KERNEL__ */
 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4 of 5] xen: allow some cr4 updates
  2008-05-23 13:10 [PATCH 0 of 5] xen+x86: misc fixes Jeremy Fitzhardinge
                   ` (2 preceding siblings ...)
  2008-05-23 13:10 ` [PATCH 3 of 5] x86: use symbolic constant in stts() Jeremy Fitzhardinge
@ 2008-05-23 13:10 ` Jeremy Fitzhardinge
  2008-05-23 13:10 ` [PATCH 5 of 5] xen: don't worry about preempt during xen_irq_enable() Jeremy Fitzhardinge
  4 siblings, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2008-05-23 13:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

The guest can legitimately change things like cr4.OSFXSR and
OSXMMEXCPT, so let it.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/xen/enlighten.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -648,8 +648,10 @@
 
 static void xen_write_cr4(unsigned long cr4)
 {
-	/* Just ignore cr4 changes; Xen doesn't allow us to do
-	   anything anyway. */
+	cr4 &= ~X86_CR4_PGE;
+	cr4 &= ~X86_CR4_PSE;
+
+	native_write_cr4(cr4);
 }
 
 static unsigned long xen_read_cr3(void)



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5 of 5] xen: don't worry about preempt during xen_irq_enable()
  2008-05-23 13:10 [PATCH 0 of 5] xen+x86: misc fixes Jeremy Fitzhardinge
                   ` (3 preceding siblings ...)
  2008-05-23 13:10 ` [PATCH 4 of 5] xen: allow some cr4 updates Jeremy Fitzhardinge
@ 2008-05-23 13:10 ` Jeremy Fitzhardinge
  4 siblings, 0 replies; 6+ messages in thread
From: Jeremy Fitzhardinge @ 2008-05-23 13:10 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: LKML

When enabling interrupts, we don't need to worry about preemption,
because we either enter with interrupts disabled - so no preemption -
or the caller is confused and is re-enabling interrupts on some
indeterminate processor.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/xen/enlighten.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -235,13 +235,13 @@
 {
 	struct vcpu_info *vcpu;
 
-	/* There's a one instruction preempt window here.  We need to
-	   make sure we're don't switch CPUs between getting the vcpu
-	   pointer and updating the mask. */
-	preempt_disable();
+	/* We don't need to worry about being preempted here, since
+	   either a) interrupts are disabled, so no preemption, or b)
+	   the caller is confused and is trying to re-enable interrupts
+	   on an indeterminate processor. */
+
 	vcpu = x86_read_percpu(xen_vcpu);
 	vcpu->evtchn_upcall_mask = 0;
-	preempt_enable_no_resched();
 
 	/* Doesn't matter if we get preempted here, because any
 	   pending event will get dealt with anyway. */



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-05-23 13:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-23 13:10 [PATCH 0 of 5] xen+x86: misc fixes Jeremy Fitzhardinge
2008-05-23 13:10 ` [PATCH 1 of 5] xen: use hypercall rather than clts Jeremy Fitzhardinge
2008-05-23 13:10 ` [PATCH 2 of 5] xen: use new sched_op Jeremy Fitzhardinge
2008-05-23 13:10 ` [PATCH 3 of 5] x86: use symbolic constant in stts() Jeremy Fitzhardinge
2008-05-23 13:10 ` [PATCH 4 of 5] xen: allow some cr4 updates Jeremy Fitzhardinge
2008-05-23 13:10 ` [PATCH 5 of 5] xen: don't worry about preempt during xen_irq_enable() Jeremy Fitzhardinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox