LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Define EFLAGS_IF
@ 2007-03-22  3:16 Rusty Russell
  2007-03-22  3:24 ` Rusty Russell
  2007-04-06  0:20 ` [PATCH] Define EFLAGS_IF H. Peter Anvin
  0 siblings, 2 replies; 13+ messages in thread
From: Rusty Russell @ 2007-03-22  3:16 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml - Kernel Mailing List, virtualization, Andi Kleen

There is now more than one place where we use the fact that bit 9 of
eflags is the interrupt-enabled flag, so define EFLAGS_IF.  We make it
512 so it can be used in asm, too.

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

--- a/arch/i386/lguest/lguest.c
+++ b/arch/i386/lguest/lguest.c
@@ -107,9 +107,8 @@ static void fastcall irq_disable(void)
 
 static void fastcall irq_enable(void)
 {
-	/* Linux i386 code expects bit 9 set. */
 	/* FIXME: Check if interrupt pending... */
-	lguest_data.irq_enabled = 512;
+	lguest_data.irq_enabled = EFLAGS_IF;
 }
 
 static void fastcall lguest_load_gdt(const struct Xgt_desc_struct *desc)
@@ -394,7 +393,7 @@ static fastcall void lguest_write_idt_en
 	extern const char start_##name[], end_##name[];		\
 	asm("start_" #name ": " code "; end_" #name ":")
 DEF_LGUEST(cli, "movl $0," LGUEST_IRQ);
-DEF_LGUEST(sti, "movl $512," LGUEST_IRQ);
+DEF_LGUEST(sti, "movl $"__stringify(EFLAGS_IF)"," LGUEST_IRQ);
 DEF_LGUEST(popf, "movl %eax," LGUEST_IRQ);
 DEF_LGUEST(pushf, "movl " LGUEST_IRQ ",%eax");
 DEF_LGUEST(pushf_cli, "movl " LGUEST_IRQ ",%eax; movl $0," LGUEST_IRQ);
===================================================================
--- a/include/asm-i386/irqflags.h
+++ b/include/asm-i386/irqflags.h
@@ -87,6 +87,9 @@ static inline unsigned long __raw_local_
 #endif /* __ASSEMBLY__ */
 #endif /* CONFIG_PARAVIRT */
 
+/* Bit 9 of eflags means interrupts are enabled: a raw int for asm. */
+#define EFLAGS_IF 512
+
 #ifndef __ASSEMBLY__
 #define raw_local_save_flags(flags) \
 		do { (flags) = __raw_local_save_flags(); } while (0)
@@ -96,7 +99,7 @@ static inline unsigned long __raw_local_
 
 static inline int raw_irqs_disabled_flags(unsigned long flags)
 {
-	return !(flags & (1 << 9));
+	return !(flags & EFLAGS_IF);
 }
 
 static inline int raw_irqs_disabled(void)



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

* Re: [PATCH] Define EFLAGS_IF
  2007-03-22  3:16 [PATCH] Define EFLAGS_IF Rusty Russell
@ 2007-03-22  3:24 ` Rusty Russell
  2007-03-22  3:52   ` [PATCH] Use X86_EFLAGS_IF in irqflags.h, lguest Rusty Russell
  2007-04-06  0:20 ` [PATCH] Define EFLAGS_IF H. Peter Anvin
  1 sibling, 1 reply; 13+ messages in thread
From: Rusty Russell @ 2007-03-22  3:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml - Kernel Mailing List, virtualization, Andi Kleen

On Thu, 2007-03-22 at 14:16 +1100, Rusty Russell wrote:
> There is now more than one place where we use the fact that bit 9 of
> eflags is the interrupt-enabled flag, so define EFLAGS_IF.  We make it
> 512 so it can be used in asm, too.

Belay this: there's a X86_EFLAGS_IF in asm/processor.h which we should
use.  Will send patch.

Thanks to Jeremy Fitzhardinge for the clue.

Rusty.



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

* [PATCH] Use X86_EFLAGS_IF in irqflags.h, lguest.
  2007-03-22  3:24 ` Rusty Russell
@ 2007-03-22  3:52   ` Rusty Russell
  2007-03-22  4:03     ` Keith Owens
  0 siblings, 1 reply; 13+ messages in thread
From: Rusty Russell @ 2007-03-22  3:52 UTC (permalink / raw)
  To: Andrew Morton; +Cc: lkml - Kernel Mailing List, virtualization, Andi Kleen

On Thu, 2007-03-22 at 14:24 +1100, Rusty Russell wrote:
> Belay this: there's a X86_EFLAGS_IF in asm/processor.h which we should
> use.  Will send patch.

How's this.  There may be other users, but they're not easy to grep for.

==
Move X86_EFLAGS_IF et al out to a new header: processor-flags.h, so we
can include it from irqflags.h and use it in raw_irqs_disabled_flags().

As a side-effect, we could now use these flags in .S files.

Lguest also modified to use the flags.

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

diff -r bd0a803d9948 include/asm-i386/processor-flags.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/asm-i386/processor-flags.h	Thu Mar 22 14:31:41 2007 +1100
@@ -0,0 +1,26 @@
+#ifndef __ASM_I386_PROCESSOR_FLAGS_H
+#define __ASM_I386_PROCESSOR_FLAGS_H
+/* Various flags defined: can be included from assembler. */
+
+/*
+ * EFLAGS bits
+ */
+#define X86_EFLAGS_CF	0x00000001 /* Carry Flag */
+#define X86_EFLAGS_PF	0x00000004 /* Parity Flag */
+#define X86_EFLAGS_AF	0x00000010 /* Auxillary carry Flag */
+#define X86_EFLAGS_ZF	0x00000040 /* Zero Flag */
+#define X86_EFLAGS_SF	0x00000080 /* Sign Flag */
+#define X86_EFLAGS_TF	0x00000100 /* Trap Flag */
+#define X86_EFLAGS_IF	0x00000200 /* Interrupt Flag */
+#define X86_EFLAGS_DF	0x00000400 /* Direction Flag */
+#define X86_EFLAGS_OF	0x00000800 /* Overflow Flag */
+#define X86_EFLAGS_IOPL	0x00003000 /* IOPL mask */
+#define X86_EFLAGS_NT	0x00004000 /* Nested Task */
+#define X86_EFLAGS_RF	0x00010000 /* Resume Flag */
+#define X86_EFLAGS_VM	0x00020000 /* Virtual Mode */
+#define X86_EFLAGS_AC	0x00040000 /* Alignment Check */
+#define X86_EFLAGS_VIF	0x00080000 /* Virtual Interrupt Flag */
+#define X86_EFLAGS_VIP	0x00100000 /* Virtual Interrupt Pending */
+#define X86_EFLAGS_ID	0x00200000 /* CPUID detection flag */
+
+#endif	/* __ASM_I386_PROCESSOR_FLAGS_H */
diff -r bd0a803d9948 include/asm-i386/irqflags.h
--- a/include/asm-i386/irqflags.h	Thu Mar 22 14:13:31 2007 +1100
+++ b/include/asm-i386/irqflags.h	Thu Mar 22 14:47:21 2007 +1100
@@ -9,6 +9,7 @@
  */
 #ifndef _ASM_IRQFLAGS_H
 #define _ASM_IRQFLAGS_H
+#include <asm/processor-flags.h>
 
 #ifndef __ASSEMBLY__
 static inline unsigned long native_save_fl(void)
@@ -119,7 +120,7 @@ static inline unsigned long __raw_local_
 
 static inline int raw_irqs_disabled_flags(unsigned long flags)
 {
-	return !(flags & (1 << 9));
+	return !(flags & X86_EFLAGS_IF);
 }
 
 static inline int raw_irqs_disabled(void)
diff -r bd0a803d9948 include/asm-i386/processor.h
--- a/include/asm-i386/processor.h	Thu Mar 22 14:13:31 2007 +1100
+++ b/include/asm-i386/processor.h	Thu Mar 22 14:31:58 2007 +1100
@@ -21,6 +21,7 @@
 #include <asm/percpu.h>
 #include <linux/cpumask.h>
 #include <linux/init.h>
+#include <asm/processor-flags.h>
 
 /* flag for disabling the tsc */
 extern int tsc_disable;
@@ -125,27 +126,6 @@ extern void detect_ht(struct cpuinfo_x86
 #else
 static inline void detect_ht(struct cpuinfo_x86 *c) {}
 #endif
-
-/*
- * EFLAGS bits
- */
-#define X86_EFLAGS_CF	0x00000001 /* Carry Flag */
-#define X86_EFLAGS_PF	0x00000004 /* Parity Flag */
-#define X86_EFLAGS_AF	0x00000010 /* Auxillary carry Flag */
-#define X86_EFLAGS_ZF	0x00000040 /* Zero Flag */
-#define X86_EFLAGS_SF	0x00000080 /* Sign Flag */
-#define X86_EFLAGS_TF	0x00000100 /* Trap Flag */
-#define X86_EFLAGS_IF	0x00000200 /* Interrupt Flag */
-#define X86_EFLAGS_DF	0x00000400 /* Direction Flag */
-#define X86_EFLAGS_OF	0x00000800 /* Overflow Flag */
-#define X86_EFLAGS_IOPL	0x00003000 /* IOPL mask */
-#define X86_EFLAGS_NT	0x00004000 /* Nested Task */
-#define X86_EFLAGS_RF	0x00010000 /* Resume Flag */
-#define X86_EFLAGS_VM	0x00020000 /* Virtual Mode */
-#define X86_EFLAGS_AC	0x00040000 /* Alignment Check */
-#define X86_EFLAGS_VIF	0x00080000 /* Virtual Interrupt Flag */
-#define X86_EFLAGS_VIP	0x00100000 /* Virtual Interrupt Pending */
-#define X86_EFLAGS_ID	0x00200000 /* CPUID detection flag */
 
 static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
 					 unsigned int *ecx, unsigned int *edx)
diff -r bd0a803d9948 arch/i386/lguest/interrupts_and_traps.c
--- a/arch/i386/lguest/interrupts_and_traps.c	Thu Mar 22 14:13:31 2007 +1100
+++ b/arch/i386/lguest/interrupts_and_traps.c	Thu Mar 22 14:46:15 2007 +1100
@@ -42,7 +42,7 @@ static void reflect_trap(struct lguest *
 	   (it's always 0, since irqs are enabled when guest is running). */
 	eflags = regs->eflags;
 	get_user(irq_enable, &lg->lguest_data->irq_enabled);
-	eflags |= (irq_enable & 512);
+	eflags |= (irq_enable & X86_EFLAGS_IF);
 
 	push_guest_stack(lg, &gstack, eflags);
 	push_guest_stack(lg, &gstack, regs->cs);
@@ -86,7 +86,7 @@ void maybe_do_interrupt(struct lguest *l
 	/* If they're halted, we re-enable interrupts. */
 	if (lg->halted) {
 		/* Re-enable interrupts. */
-		put_user(512, &lg->lguest_data->irq_enabled);
+		put_user(X86_EFLAGS_IF, &lg->lguest_data->irq_enabled);
 		lg->halted = 0;
 	} else {
 		/* Maybe they have interrupts disabled? */
diff -r bd0a803d9948 arch/i386/lguest/lguest.c
--- a/arch/i386/lguest/lguest.c	Thu Mar 22 14:13:31 2007 +1100
+++ b/arch/i386/lguest/lguest.c	Thu Mar 22 14:26:41 2007 +1100
@@ -107,9 +107,8 @@ static void fastcall irq_disable(void)
 
 static void fastcall irq_enable(void)
 {
-	/* Linux i386 code expects bit 9 set. */
 	/* FIXME: Check if interrupt pending... */
-	lguest_data.irq_enabled = 512;
+	lguest_data.irq_enabled = X86_EFLAGS_IF;
 }
 
 static void fastcall lguest_load_gdt(const struct Xgt_desc_struct *desc)
@@ -394,7 +393,7 @@ static fastcall void lguest_write_idt_en
 	extern const char start_##name[], end_##name[];		\
 	asm("start_" #name ": " code "; end_" #name ":")
 DEF_LGUEST(cli, "movl $0," LGUEST_IRQ);
-DEF_LGUEST(sti, "movl $512," LGUEST_IRQ);
+DEF_LGUEST(sti, "movl $"__stringify(X86_EFLAGS_IF)"," LGUEST_IRQ);
 DEF_LGUEST(popf, "movl %eax," LGUEST_IRQ);
 DEF_LGUEST(pushf, "movl " LGUEST_IRQ ",%eax");
 DEF_LGUEST(pushf_cli, "movl " LGUEST_IRQ ",%eax; movl $0," LGUEST_IRQ);



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

* Re: [PATCH] Use X86_EFLAGS_IF in irqflags.h, lguest. 
  2007-03-22  3:52   ` [PATCH] Use X86_EFLAGS_IF in irqflags.h, lguest Rusty Russell
@ 2007-03-22  4:03     ` Keith Owens
  0 siblings, 0 replies; 13+ messages in thread
From: Keith Owens @ 2007-03-22  4:03 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Andrew Morton, lkml - Kernel Mailing List, virtualization, Andi Kleen

Rusty Russell (on Thu, 22 Mar 2007 14:52:29 +1100) wrote:
>On Thu, 2007-03-22 at 14:24 +1100, Rusty Russell wrote:
>> Belay this: there's a X86_EFLAGS_IF in asm/processor.h which we should
>> use.  Will send patch.
>
>How's this.  There may be other users, but they're not easy to grep for.

One less set of definitions for KDB to create - Thanks.


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

* Re: [PATCH] Define EFLAGS_IF
  2007-03-22  3:16 [PATCH] Define EFLAGS_IF Rusty Russell
  2007-03-22  3:24 ` Rusty Russell
@ 2007-04-06  0:20 ` H. Peter Anvin
  2007-04-06  0:22   ` Jeremy Fitzhardinge
  1 sibling, 1 reply; 13+ messages in thread
From: H. Peter Anvin @ 2007-04-06  0:20 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Andrew Morton, lkml - Kernel Mailing List, virtualization, Andi Kleen

Rusty Russell wrote:
> There is now more than one place where we use the fact that bit 9 of
> eflags is the interrupt-enabled flag, so define EFLAGS_IF.  We make it
> 512 so it can be used in asm, too.

How about defining all the other EFLAGS in one place?

	-hpa

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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06  0:20 ` [PATCH] Define EFLAGS_IF H. Peter Anvin
@ 2007-04-06  0:22   ` Jeremy Fitzhardinge
  2007-04-06  0:29     ` H. Peter Anvin
  0 siblings, 1 reply; 13+ messages in thread
From: Jeremy Fitzhardinge @ 2007-04-06  0:22 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Rusty Russell, virtualization, Andrew Morton, Andi Kleen,
	lkml - Kernel Mailing List

H. Peter Anvin wrote:
> Rusty Russell wrote:
>   
>> There is now more than one place where we use the fact that bit 9 of
>> eflags is the interrupt-enabled flag, so define EFLAGS_IF.  We make it
>> 512 so it can be used in asm, too.
>>     
>
> How about defining all the other EFLAGS in one place?
>   

That patch got dropped, and replaced by one which pulled all the flags
definitions out of <asm/processor.h>

    J

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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06  0:22   ` Jeremy Fitzhardinge
@ 2007-04-06  0:29     ` H. Peter Anvin
  2007-04-06  0:48       ` Andi Kleen
  0 siblings, 1 reply; 13+ messages in thread
From: H. Peter Anvin @ 2007-04-06  0:29 UTC (permalink / raw)
  To: Jeremy Fitzhardinge
  Cc: Rusty Russell, virtualization, Andrew Morton, Andi Kleen,
	lkml - Kernel Mailing List

Jeremy Fitzhardinge wrote:
> 
> That patch got dropped, and replaced by one which pulled all the flags
> definitions out of <asm/processor.h>
> 

Saw that a little too late :)

In general, it would be nice if the various CPU constants were all 
defined in one place, so I'd rather suggest protecting the appropriate 
parts of asm/processor.h with #ifndef __ASSEMBLY__.

	-hpa

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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06  0:29     ` H. Peter Anvin
@ 2007-04-06  0:48       ` Andi Kleen
  2007-04-06  1:06         ` H. Peter Anvin
  0 siblings, 1 reply; 13+ messages in thread
From: Andi Kleen @ 2007-04-06  0:48 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Jeremy Fitzhardinge, Rusty Russell, virtualization,
	Andrew Morton, Andi Kleen, lkml - Kernel Mailing List

On Thu, Apr 05, 2007 at 05:29:52PM -0700, H. Peter Anvin wrote:
> Jeremy Fitzhardinge wrote:
> >
> >That patch got dropped, and replaced by one which pulled all the flags
> >definitions out of <asm/processor.h>
> >
> 
> Saw that a little too late :)
> 
> In general, it would be nice if the various CPU constants were all 
> defined in one place, so I'd rather suggest protecting the appropriate 
> parts of asm/processor.h with #ifndef __ASSEMBLY__.

No processor.h is such a hodgepodge of unrelated stuff that any
splitting up is a good thing.

-Andi

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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06  0:48       ` Andi Kleen
@ 2007-04-06  1:06         ` H. Peter Anvin
  2007-04-06  2:24           ` Rusty Russell
  2007-04-06 10:30           ` Andi Kleen
  0 siblings, 2 replies; 13+ messages in thread
From: H. Peter Anvin @ 2007-04-06  1:06 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Jeremy Fitzhardinge, Rusty Russell, virtualization,
	Andrew Morton, lkml - Kernel Mailing List

Andi Kleen wrote:
> 
> No processor.h is such a hodgepodge of unrelated stuff that any
> splitting up is a good thing.
> 

Fair enough.  However, I'd still like to see the X86_CR* constants 
moved, too (and constants added for at least CR0 as well.)

	-hpa

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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06  1:06         ` H. Peter Anvin
@ 2007-04-06  2:24           ` Rusty Russell
  2007-04-06 10:30           ` Andi Kleen
  1 sibling, 0 replies; 13+ messages in thread
From: Rusty Russell @ 2007-04-06  2:24 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Andi Kleen, Jeremy Fitzhardinge, virtualization, Andrew Morton,
	lkml - Kernel Mailing List

On Thu, 2007-04-05 at 18:06 -0700, H. Peter Anvin wrote:
> Andi Kleen wrote:
> > 
> > No processor.h is such a hodgepodge of unrelated stuff that any
> > splitting up is a good thing.
> > 
> 
> Fair enough.  However, I'd still like to see the X86_CR* constants 
> moved, too (and constants added for at least CR0 as well.)

Agreed.  This was on theory of minimum damage, but since it seems to
have received a warm reception, I'd say moving the rest to
processor-flags.h would be a welcome addition.

Cheers,
Rusty.




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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06  1:06         ` H. Peter Anvin
  2007-04-06  2:24           ` Rusty Russell
@ 2007-04-06 10:30           ` Andi Kleen
  2007-04-06 15:39             ` H. Peter Anvin
  1 sibling, 1 reply; 13+ messages in thread
From: Andi Kleen @ 2007-04-06 10:30 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Andi Kleen, Jeremy Fitzhardinge, Rusty Russell, virtualization,
	Andrew Morton, lkml - Kernel Mailing List

On Thu, Apr 05, 2007 at 06:06:16PM -0700, H. Peter Anvin wrote:
> Andi Kleen wrote:
> >
> >No processor.h is such a hodgepodge of unrelated stuff that any
> >splitting up is a good thing.
> >
> 
> Fair enough.  However, I'd still like to see the X86_CR* constants 
> moved, too (and constants added for at least CR0 as well.)

Send patches then.

-Andi

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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06 10:30           ` Andi Kleen
@ 2007-04-06 15:39             ` H. Peter Anvin
  2007-04-09  1:11               ` Rusty Russell
  0 siblings, 1 reply; 13+ messages in thread
From: H. Peter Anvin @ 2007-04-06 15:39 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Jeremy Fitzhardinge, Rusty Russell, virtualization,
	Andrew Morton, lkml - Kernel Mailing List

Andi Kleen wrote:
> On Thu, Apr 05, 2007 at 06:06:16PM -0700, H. Peter Anvin wrote:
>> Andi Kleen wrote:
>>> No processor.h is such a hodgepodge of unrelated stuff that any
>>> splitting up is a good thing.
>>>
>> Fair enough.  However, I'd still like to see the X86_CR* constants 
>> moved, too (and constants added for at least CR0 as well.)
> 
> Send patches then.

I will, unless Rusty does, first.  No desire to step on each other.

	-hpa

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

* Re: [PATCH] Define EFLAGS_IF
  2007-04-06 15:39             ` H. Peter Anvin
@ 2007-04-09  1:11               ` Rusty Russell
  0 siblings, 0 replies; 13+ messages in thread
From: Rusty Russell @ 2007-04-09  1:11 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Andi Kleen, Jeremy Fitzhardinge, virtualization, Andrew Morton,
	lkml - Kernel Mailing List

On Fri, 2007-04-06 at 08:39 -0700, H. Peter Anvin wrote:
> I will, unless Rusty does, first.  No desire to step on each other.

Oh no, please, after you!

Rusty.



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

end of thread, other threads:[~2007-04-09  1:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22  3:16 [PATCH] Define EFLAGS_IF Rusty Russell
2007-03-22  3:24 ` Rusty Russell
2007-03-22  3:52   ` [PATCH] Use X86_EFLAGS_IF in irqflags.h, lguest Rusty Russell
2007-03-22  4:03     ` Keith Owens
2007-04-06  0:20 ` [PATCH] Define EFLAGS_IF H. Peter Anvin
2007-04-06  0:22   ` Jeremy Fitzhardinge
2007-04-06  0:29     ` H. Peter Anvin
2007-04-06  0:48       ` Andi Kleen
2007-04-06  1:06         ` H. Peter Anvin
2007-04-06  2:24           ` Rusty Russell
2007-04-06 10:30           ` Andi Kleen
2007-04-06 15:39             ` H. Peter Anvin
2007-04-09  1:11               ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).