public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] lguest: fix sense if IF flag on interrupt injection
@ 2007-07-20 12:11 Rusty Russell
  2007-07-20 12:12 ` [PATCH 2/3] lguest: trivial: We now have asm/processor-flags.h, so use it Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2007-07-20 12:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml - Kernel Mailing List, virtualization

The sense of the IF bit is backwards in the host interrupt handling.

This means we always save "IF=1" on the stack when injecting an
interrupt.  It turns out this is almost always correct (unless the
guest is taking a page fault in an interrupt due to an unpopulated
vmalloc mapping), so went unnoticed.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 drivers/lguest/interrupts_and_traps.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -r 209f5cd5cda5 drivers/lguest/interrupts_and_traps.c
--- a/drivers/lguest/interrupts_and_traps.c	Fri Jul 20 14:53:40 2007 +1000
+++ b/drivers/lguest/interrupts_and_traps.c	Fri Jul 20 21:34:06 2007 +1000
@@ -38,12 +38,12 @@ static void set_guest_interrupt(struct l
 		ss = lg->regs->ss;
 	}
 
-	/* We use IF bit in eflags to indicate whether irqs were disabled
-	   (it's always 0, since irqs are enabled when guest is running). */
+	/* We use IF bit in eflags to indicate whether irqs were enabled
+	   (it's always 1, since irqs are enabled when guest is running). */
 	eflags = lg->regs->eflags;
-	if (get_user(irq_enable, &lg->lguest_data->irq_enabled))
-		irq_enable = 0;
-	eflags |= (irq_enable & X86_EFLAGS_IF);
+	if (get_user(irq_enable, &lg->lguest_data->irq_enabled) == 0
+	    && !(irq_enable & X86_EFLAGS_IF))
+		eflags &= ~X86_EFLAGS_IF;
 
 	push_guest_stack(lg, &gstack, eflags);
 	push_guest_stack(lg, &gstack, lg->regs->cs);



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

* [PATCH 2/3] lguest: trivial: We now have asm/processor-flags.h, so use it.
  2007-07-20 12:11 [PATCH 1/3] lguest: fix sense if IF flag on interrupt injection Rusty Russell
@ 2007-07-20 12:12 ` Rusty Russell
  2007-07-20 12:15   ` [PATCH 3/3] lguest: override sched_clock Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2007-07-20 12:12 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml - Kernel Mailing List, virtualization

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff -r f41cd1b8d7ef drivers/lguest/lguest_asm.S
--- a/drivers/lguest/lguest_asm.S	Fri Jul 20 13:46:40 2007 +1000
+++ b/drivers/lguest/lguest_asm.S	Fri Jul 20 14:17:04 2007 +1000
@@ -2,9 +2,7 @@
 #include <linux/lguest.h>
 #include <asm/asm-offsets.h>
 #include <asm/thread_info.h>
-
-/* FIXME: Once asm/processor-flags.h goes in, include that */
-#define X86_EFLAGS_IF 0x00000200
+#include <asm/processor-flags.h>
 
 /*
  * This is where we begin: we have a magic signature which the launcher looks



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

* [PATCH 3/3] lguest: override sched_clock
  2007-07-20 12:12 ` [PATCH 2/3] lguest: trivial: We now have asm/processor-flags.h, so use it Rusty Russell
@ 2007-07-20 12:15   ` Rusty Russell
  0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2007-07-20 12:15 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml - Kernel Mailing List, virtualization

Guests currently use the default scheduler clock: this means they
always use jiffies even if TSC is actually available.  It doesn't make
any noticeable difference here, but it's a better thing to do.

Also remove commented-out asm/sched-clock.h from -mm tree.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 drivers/lguest/lguest.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff -r d9973bf15010 drivers/lguest/lguest.c
--- a/drivers/lguest/lguest.c	Fri Jul 20 21:40:49 2007 +1000
+++ b/drivers/lguest/lguest.c	Fri Jul 20 22:08:10 2007 +1000
@@ -39,7 +39,6 @@
 #include <asm/e820.h>
 #include <asm/mce.h>
 #include <asm/io.h>
-//#include <asm/sched-clock.h>
 
 /* Declarations for definitions in lguest_guest.S */
 extern char lguest_noirq_start[], lguest_noirq_end[];
@@ -57,6 +56,7 @@ struct lguest_data lguest_data = {
 	.blocked_interrupts = { 1 }, /* Block timer interrupts */
 };
 struct lguest_device_desc *lguest_devices;
+static cycle_t clock_base;
 
 static enum paravirt_lazy_mode lazy_mode;
 static void lguest_lazy_mode(enum paravirt_lazy_mode mode)
@@ -363,6 +363,11 @@ static struct clocksource lguest_clock =
 	.read		= lguest_clock_read,
 };
 
+static unsigned long long lguest_sched_clock(void)
+{
+	return cyc2ns(&lguest_clock, lguest_clock_read() - clock_base);
+}
+
 /* We also need a "struct clock_event_device": Linux asks us to set it to go
  * off some time in the future.  Actually, James Morris figured all this out, I
  * just applied the patch. */
@@ -439,6 +444,7 @@ static void lguest_time_init(void)
 		lguest_clock.mult = (((u64)NSEC_PER_SEC<<8)/ACTHZ) << 8;
 		lguest_clock.mask = CLOCKSOURCE_MASK(32);
 	}
+	clock_base = lguest_clock_read();
 	clocksource_register(&lguest_clock);
 
 	/* We can't set cpumask in the initializer: damn C limitations! */
@@ -584,6 +590,7 @@ __init void lguest_init(void *boot)
 	paravirt_ops.time_init = lguest_time_init;
 	paravirt_ops.set_lazy_mode = lguest_lazy_mode;
 	paravirt_ops.wbinvd = lguest_wbinvd;
+	paravirt_ops.sched_clock = lguest_sched_clock;
 
 	hcall(LHCALL_LGUEST_INIT, __pa(&lguest_data), 0, 0);
 



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

end of thread, other threads:[~2007-07-20 12:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-20 12:11 [PATCH 1/3] lguest: fix sense if IF flag on interrupt injection Rusty Russell
2007-07-20 12:12 ` [PATCH 2/3] lguest: trivial: We now have asm/processor-flags.h, so use it Rusty Russell
2007-07-20 12:15   ` [PATCH 3/3] lguest: override sched_clock Rusty Russell

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