Skip to contentSkip to conversation

x86 fixes

GIT PULL Ingo Molnar 3 participants 8 messages Mar 27, 2008

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

Linus, please pull the latest x86 git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git for-linus

Thanks,

Ingo

------------------>
Andrew Morton (1):
x86: ptrace.c: fix defined-but-unused warnings

Christoph Lameter (1):
x86: stricter check in follow_huge_addr()

Florian Fainelli (1):
rdc321x: GPIO routines bugfixes

Ingo Molnar (1):
x86: fix prefetch workaround

Jeremy Fitzhardinge (2):
xen: fix RMW when unmasking events
xen: fix UP setup of shared_info

Marcin Slusarz (1):
x86, documentation: nmi_watchdog=2 works on x86_64

 Documentation/nmi_watchdog.txt              |    3 +-
 arch/x86/kernel/ptrace.c                    |  169 ++++++++++++-----------
 arch/x86/mach-rdc321x/gpio.c                |  199 ++++++++++++++++++++-------
 arch/x86/mach-rdc321x/platform.c            |    2 +
 arch/x86/mm/fault.c                         |    3 +-
 arch/x86/mm/hugetlbpage.c                   |    2 +-
 arch/x86/xen/enlighten.c                    |   47 ++++---
 arch/x86/xen/xen-asm.S                      |    9 +-
 include/asm-x86/mach-rdc321x/gpio.h         |    9 +-
 include/asm-x86/mach-rdc321x/rdc321x_defs.h |    8 +-
 10 files changed, 287 insertions(+), 164 deletions(-)
Documentation/nmi_watchdog.txt +1 -2
index c025a45..757c729 100644
@@ -23,8 +23,7 @@ kernel debugging options, such as Kernel Stack Meter or Kernel Tracer,
 may implicitly disable the NMI watchdog.]
 
 For x86-64, the needed APIC is always compiled in, and the NMI watchdog is
-always enabled with I/O-APIC mode (nmi_watchdog=1). Currently, local APIC
-mode (nmi_watchdog=2) does not work on x86-64.
+always enabled with I/O-APIC mode (nmi_watchdog=1).
 
 Using local APIC (nmi_watchdog=2) needs the first performance register, so
 you can't use it for other purposes (such as high precision performance
arch/x86/kernel/ptrace.c +85 -84

187 lines not on this page · raw message

arch/x86/mach-rdc321x/gpio.c +151 -48

242 lines not on this page · raw message

arch/x86/mach-rdc321x/platform.c +2 -0
index dda6024..a037041 100644
@@ -62,6 +62,8 @@ static struct platform_device *rdc321x_devs[] = {
 
 static int __init rdc_board_setup(void)
 {
+	rdc321x_gpio_setup();
+
 	return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
 }
 
arch/x86/mm/fault.c +2 -1
index fdc6674..c0c82bc 100644
@@ -92,7 +92,8 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
 	unsigned char *max_instr;
 
 #ifdef CONFIG_X86_32
-	if (!(__supported_pte_mask & _PAGE_NX))
+	/* Catch an obscure case of prefetch inside an NX page: */
+	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
 		return 0;
 #endif
 
arch/x86/mm/hugetlbpage.c +1 -1
index 4fbafb4..0b3d567 100644
@@ -178,7 +178,7 @@ follow_huge_addr(struct mm_struct *mm, unsigned long address, int write)
 
 	page = &pte_page(*pte)[vpfn % (HPAGE_SIZE/PAGE_SIZE)];
 
-	WARN_ON(!PageCompound(page));
+	WARN_ON(!PageHead(page));
 
 	return page;
 }
arch/x86/xen/enlighten.c +26 -21

87 lines not on this page · raw message

arch/x86/xen/xen-asm.S +7 -2
index 1a43b60..6b71904 100644
@@ -33,12 +33,17 @@
 	events, then enter the hypervisor to get them handled.
  */
 ENTRY(xen_irq_enable_direct)
-	/* Clear mask and test pending */
-	andw $0x00ff, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_pending
+	/* Unmask events */
+	movb $0, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_mask
+
 	/* Preempt here doesn't matter because that will deal with
 	   any pending interrupts.  The pending check may end up being
 	   run on the wrong CPU, but that doesn't hurt. */
+
+	/* Test for pending */
+	testb $0xff, PER_CPU_VAR(xen_vcpu_info)+XEN_vcpu_info_pending
 	jz 1f
+
 2:	call check_events
 1:
 ENDPATCH(xen_irq_enable_direct)
include/asm-x86/mach-rdc321x/gpio.h +5 -4
index db31b92..acce0b7 100644
@@ -5,19 +5,20 @@ extern int rdc_gpio_get_value(unsigned gpio);
 extern void rdc_gpio_set_value(unsigned gpio, int value);
 extern int rdc_gpio_direction_input(unsigned gpio);
 extern int rdc_gpio_direction_output(unsigned gpio, int value);
-
+extern int rdc_gpio_request(unsigned gpio, const char *label);
+extern void rdc_gpio_free(unsigned gpio);
+extern void __init rdc321x_gpio_setup(void);
 
 /* Wrappers for the arch-neutral GPIO API */
 
 static inline int gpio_request(unsigned gpio, const char *label)
 {
-	/* Not yet implemented */
-	return 0;
+	return rdc_gpio_request(gpio, label);
 }
 
 static inline void gpio_free(unsigned gpio)
 {
-	/* Not yet implemented */
+	rdc_gpio_free(gpio);
 }
 
 static inline int gpio_direction_input(unsigned gpio)
include/asm-x86/mach-rdc321x/rdc321x_defs.h +7 -1
index 838ba8f..c8e9c8b 100644
@@ -3,4 +3,10 @@
 /* General purpose configuration and data registers */
 #define RDC3210_CFGREG_ADDR     0x0CF8
 #define RDC3210_CFGREG_DATA     0x0CFC
-#define RDC_MAX_GPIO		0x3A
+
+#define RDC321X_GPIO_CTRL_REG1	0x48
+#define RDC321X_GPIO_CTRL_REG2	0x84
+#define RDC321X_GPIO_DATA_REG1	0x4c
+#define RDC321X_GPIO_DATA_REG2	0x88
+
+#define RDC321X_MAX_GPIO	58
#1 lore raw
Quoted 3 lines · Ingo Molnar

Ingo Molnar (1):
x86: fix prefetch workaround

...

arch/x86/mm/fault.c static int is_prefetch(struct pt_regs *regs, unsigned long addr, · line 98

Quoted 13 lines
arch/x86/mm/fault.c +2 -1
index fdc6674..c0c82bc 100644
@@ -92,7 +92,8 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
 	unsigned char *max_instr;
 
 #ifdef CONFIG_X86_32
-	if (!(__supported_pte_mask & _PAGE_NX))
+	/* Catch an obscure case of prefetch inside an NX page: */
+	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
 		return 0;
 #endif

Ingo, this patch makes no sense.

Two reasons:

- "error_code & 16" is senseless. Use PF_INSTR instead, which actually tells the reader something.

- this piece of crap code is immediately followed by

	/* If it was a exec fault on NX page, ignore */
	if (error_code & PF_INSTR)
		return 0;

which uses that *right* and readable PF_INSTR #define, and also shows that the newly modified code is totally insane (ie: if the new code triggers, then it would have returned 0 later _anyway_)

So I think it's just crap. I think it's duplication from the merging of the x86 code, and I think that the fact that the new code didn't use the right #define helper means that people didn't see that it was crap.

I pulled it, but this needs some resolution. The code makes no sense. Should that #ifdef and the code inside of it just be removed entirely?

Linus

#2 lore raw
Quoted 37 lines · Linus Torvalds
Quoted 3 lines · Ingo Molnar

Ingo Molnar (1):
x86: fix prefetch workaround

...

arch/x86/mm/fault.c static int is_prefetch(struct pt_regs *regs, unsigned long addr, · line 98

Quoted 13 lines
arch/x86/mm/fault.c +2 -1
index fdc6674..c0c82bc 100644
@@ -92,7 +92,8 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
 	unsigned char *max_instr;
 
 #ifdef CONFIG_X86_32
-	if (!(__supported_pte_mask & _PAGE_NX))
+	/* Catch an obscure case of prefetch inside an NX page: */
+	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
 		return 0;
 #endif

Ingo, this patch makes no sense.

Two reasons:

- "error_code & 16" is senseless. Use PF_INSTR instead, which actually tells the reader something.

- this piece of crap code is immediately followed by

	/* If it was a exec fault on NX page, ignore */
	if (error_code & PF_INSTR)
		return 0;

which uses that *right* and readable PF_INSTR #define, and also shows that the newly modified code is totally insane (ie: if the new code triggers, then it would have returned 0 later _anyway_)

Quoted 7 lines

So I think it's just crap. I think it's duplication from the merging of the x86 code, and I think that the fact that the new code didn't use the right #define helper means that people didn't see that it was crap.

I pulled it, but this needs some resolution. The code makes no sense. Should that #ifdef and the code inside of it just be removed entirely?

Sorry, this was my fault, I eliminated the ifdef within the X86_32 block but didn't go further. Think the below is correct:

arch/x86/mm/fault.c +1 -7
index c0c82bc..6f5df93 100644
@@ -91,14 +91,8 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
 	int prefetch = 0;
 	unsigned char *max_instr;
 
-#ifdef CONFIG_X86_32
 	/* Catch an obscure case of prefetch inside an NX page: */
-	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
-		return 0;
-#endif
-
-	/* If it was a exec fault on NX page, ignore */
-	if (error_code & PF_INSTR)
+	if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
 		return 0;
 
 	instr = (unsigned char *)convert_ip_to_linear(current, regs);
#3 lore raw

arch/x86/mm/fault.c static int is_prefetch(struct pt_regs *regs, unsigned long addr, · line 96

Quoted 10 lines · Harvey Harrison
arch/x86/mm/fault.c +1 -7
-#ifdef CONFIG_X86_32
 	/* Catch an obscure case of prefetch inside an NX page: */
-	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
-		return 0;
-#endif
-
-	/* If it was a exec fault on NX page, ignore */
-	if (error_code & PF_INSTR)
+	if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
 		return 0;

heh, did the exact same cleanup :)

i suspect we would be fine with a simple:

if (error_code & PF_INSTR)
return 0;

because if we get a fault on an instruction fetch then it clearly cannot be a prefetch erratum ... The NX condition simply comes from a cautious 32-bit workaround. (on 64-bit we always have NX - at least on AMD which has this erratum.)

and thus the currently pulled code is not incorrect, just ugly and nonsensical.

Ingo

#4 lore raw
Quoted 5 lines · Ingo Molnar

i suspect we would be fine with a simple:

if (error_code & PF_INSTR)
return 0;

Quoted 7 lines

because if we get a fault on an instruction fetch then it clearly cannot be a prefetch erratum ... The NX condition simply comes from a cautious 32-bit workaround. (on 64-bit we always have NX - at least on AMD which has this erratum.)

and thus the currently pulled code is not incorrect, just ugly and nonsensical.

i.e. the patch below, which is even simpler. The comments were a bit confusing as well - in this function we decide whether to ignore a fault, so returning 0 means we do _not_ ignore a fault (but process it to the bitter end most likely).

Ingo

-------------->
Subject: x86: prefetch fix #2
From: Ingo Molnar <[email protected]>
Date: Thu Mar 27 21:29:09 CET 2008

Linus noticed a second bug and an uncleanliness:

- we'd return on any instruction fetch fault

- we'd use both the value of 16 and the PF_INSTR symbol which are the same and make no sense

the cleanup nicely unifies this piece of logic.

---
 arch/x86/mm/fault.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
arch/x86/mm/fault.c +4 -7
Index: linux-x86.q/arch/x86/mm/fault.c
===================================================================
@@ -103,13 +103,10 @@ static int is_prefetch(struct pt_regs *r
 	int prefetch = 0;
 	unsigned char *max_instr;
 
-#ifdef CONFIG_X86_32
-	/* Catch an obscure case of prefetch inside an NX page: */
-	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
-		return 0;
-#endif
-
-	/* If it was a exec fault on NX page, ignore */
+	/*
+	 * If it was a exec (instruction fetch) fault on NX page, then
+	 * do not ignore the fault:
+	 */
 	if (error_code & PF_INSTR)
 		return 0;
 
#5 lore raw
Quoted 12 lines
 arch/x86/mm/fault.c |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Index: linux-x86.q/arch/x86/mm/fault.c
===================================================================

arch/x86/mm/fault.c +0 -1
@@ -103,13 +103,10 @@ static int is_prefetch(struct pt_regs *r
 	int prefetch = 0;
 	unsigned char *max_instr;
 
-#ifdef CONFIG_X86_32

arch/x86/mm/fault.c static int is_prefetch(struct pt_regs *r · line 109

Quoted 10 lines
arch/x86/mm/fault.c +4 -6
-	/* Catch an obscure case of prefetch inside an NX page: */
-	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
-		return 0;
-#endif
-
-	/* If it was a exec fault on NX page, ignore */
+	/*
+	 * If it was a exec (instruction fetch) fault on NX page, then
+	 * do not ignore the fault:
+	 */

How about:
If it was an exec (instruction fetch) fault, it cannot be a prefetch
fault.

arch/x86/mm/fault.c static int is_prefetch(struct pt_regs *r · line 112

Quoted 4 lines
arch/x86/mm/fault.c +0 -0
 	if (error_code & PF_INSTR)
 		return 0;
 

Cheers,

Harvey

#6 lore raw
In reply to Linus Torvalds
Quoted 9 lines · Linus Torvalds

Review

Quoted 6 lines

#ifdef CONFIG_X86_32

(quoted diff) +2 -1
-	if (!(__supported_pte_mask & _PAGE_NX))
+	/* Catch an obscure case of prefetch inside an NX page: */
+	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
 		return 0;
 #endif

Ingo, this patch makes no sense.

Quoted 4 lines

Two reasons:

- "error_code & 16" is senseless. Use PF_INSTR instead, which actually tells the reader something.

yeah - sorry - the '16' was a blast from the past, i just took the old 2.6.24 condition on the 32-bit side which didnt use PF_INSTR (PF_INSTR came in as a cleanup during the unification), and when the confirmation came that this fixed the crash i sent the pull request. That's how this nonsensical mixing happened, and that's why i missed the 'if (error_code & PF_INSTR)' branch.

The patch below (ontop of the tree) is a first cut at fixing all these problems - but i'd wait at least 24 hours with applying this to let it be tested through - it affects both 32-bit and 64-bit. The fix further cleans up this codepath and removes an #ifdef.

Ingo

------------------------>
Subject: x86: prefetch fix #2
From: Ingo Molnar <[email protected]>
Date: Thu Mar 27 21:29:09 CET 2008

Linus noticed a second bug and an uncleanliness:

- we'd return on any instruction fetch fault

- we'd use both the value of 16 and the PF_INSTR symbol which are the same and make no sense

the cleanup nicely unifies this piece of logic.

---
 arch/x86/mm/fault.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
arch/x86/mm/fault.c +4 -8
Index: linux-x86.q/arch/x86/mm/fault.c
===================================================================
@@ -103,14 +103,10 @@ static int is_prefetch(struct pt_regs *r
 	int prefetch = 0;
 	unsigned char *max_instr;
 
-#ifdef CONFIG_X86_32
-	/* Catch an obscure case of prefetch inside an NX page: */
-	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
-		return 0;
-#endif
-
-	/* If it was a exec fault on NX page, ignore */
-	if (error_code & PF_INSTR)
+	/*
+	 * Catch an obscure case of prefetch inside an NX page:
+	 */
+	if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
 		return 0;
 
 	instr = (unsigned char *)convert_ip_to_linear(current, regs);
#7 lore raw
Quoted 4 lines · Ingo Molnar

The patch below (ontop of the tree) is a first cut at fixing all these problems - but i'd wait at least 24 hours with applying this to let it be tested through - it affects both 32-bit and 64-bit. The fix further cleans up this codepath and removes an #ifdef.

scratch that 24 hours - the patch is obviously correct as it only removes the nonsensical bits that get duplicated below anyway.

Linus, please pull the latest x86 git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86.git for-linus

Thanks,

Ingo

------------------>
Ingo Molnar (1):
x86: prefetch fix #2

 arch/x86/mm/fault.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
arch/x86/mm/fault.c +4 -7
index c0c82bc..ec08d83 100644
@@ -91,13 +91,10 @@ static int is_prefetch(struct pt_regs *regs, unsigned long addr,
 	int prefetch = 0;
 	unsigned char *max_instr;
 
-#ifdef CONFIG_X86_32
-	/* Catch an obscure case of prefetch inside an NX page: */
-	if ((__supported_pte_mask & _PAGE_NX) && (error_code & 16))
-		return 0;
-#endif
-
-	/* If it was a exec fault on NX page, ignore */
+	/*
+	 * If it was a exec (instruction fetch) fault on NX page, then
+	 * do not ignore the fault:
+	 */
 	if (error_code & PF_INSTR)
 		return 0;