Skip to contentSkip to conversation

x86: Misc fixlets

PATCH In review Borislav Petkov 3 participants 13 messages Mar 4, 2013 – Apr 3, 2013

Subsystems (3)
lore
Share & tools
lore

Borislav Petkov

author maintainer
#0 lore raw

cover x86: Misc fixlets

From: Borislav Petkov <[email protected]>

Hi guys,

below a couple of minor fixlets and cleanups which have accumulated in the last months.

Thanks.

Borislav Petkov (5):
x86, smpboot: Remove unused variable
x86: Drop KERNEL_IMAGE_START
x86-64, docs, mm: Add vsyscall range to virtual address space layout x86, msr: Unify variable names
x86, quirks: Shut-up a long-standing gcc warning

 Documentation/x86/x86_64/mm.txt      |  4 +++-
 arch/x86/include/asm/msr.h           | 14 +++++++-------
 arch/x86/include/asm/page_64_types.h |  1 -
 arch/x86/kernel/head64.c             |  6 +++---
 arch/x86/kernel/quirks.c             | 18 +++++++++++-------
 arch/x86/kernel/smpboot.c            |  3 +--
 6 files changed, 25 insertions(+), 21 deletions(-)
Signature · 1 line
1.8.1.3.535.ga923c31
author maintainer
#1 lore raw

PATCH 1/5 x86, smpboot: Remove unused variable

From: Borislav Petkov <[email protected]>

The cpuinfo_x86 ptr is unused now. Drop it. Got obsolete by 69fb3676df33 ("x86 idle: remove mwait_idle() and "idle=mwait" cmdline param") removing its only user.

---
 arch/x86/kernel/smpboot.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/smpboot.c +1 -2
index a6ceaedc396a..9f190a2a00e9 100644
@@ -1365,9 +1365,8 @@ static inline void mwait_play_dead(void)
 	unsigned int eax, ebx, ecx, edx;
 	unsigned int highest_cstate = 0;
 	unsigned int highest_subcstate = 0;
-	int i;
 	void *mwait_ptr;
-	struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info);
+	int i;
 
 	if (!this_cpu_has(X86_FEATURE_MWAIT))
 		return;
Signature · 1 line
1.8.1.3.535.ga923c31
#2 lore raw

[tip:x86/urgent] x86, smpboot: Remove unused variable

x86, smpboot: Remove unused variable
Commit-ID:  576cfb404c9cab728e9462ea713f3422679d5cf7
Gitweb:     http://git.kernel.org/tip/576cfb404c9cab728e9462ea713f3422679d5cf7
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 4 Mar 2013 21:16:16 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 5 Mar 2013 15:26:45 -0800

x86, smpboot: Remove unused variable

The cpuinfo_x86 ptr is unused now. Drop it. Got obsolete by 69fb3676df33 ("x86 idle: remove mwait_idle() and "idle=mwait" cmdline param") removing its only user.

[ hpa: fixes gcc warning ]

---
 arch/x86/kernel/smpboot.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kernel/smpboot.c +1 -2
index a6ceaed..9f190a2 100644
@@ -1365,9 +1365,8 @@ static inline void mwait_play_dead(void)
 	unsigned int eax, ebx, ecx, edx;
 	unsigned int highest_cstate = 0;
 	unsigned int highest_subcstate = 0;
-	int i;
 	void *mwait_ptr;
-	struct cpuinfo_x86 *c = __this_cpu_ptr(&cpu_info);
+	int i;
 
 	if (!this_cpu_has(X86_FEATURE_MWAIT))
 		return;
author maintainer
#3 lore raw

PATCH 2/5 x86: Drop KERNEL_IMAGE_START

In reply to Borislav Petkov

We have KERNEL_IMAGE_START and __START_KERNEL_map which both contain the start of the kernel text mapping's virtual address. Remove the prior one which has been replicated a lot less times around the tree.

No functionality change.

---
 arch/x86/include/asm/page_64_types.h | 1 -
 arch/x86/kernel/head64.c             | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/include/asm/page_64_types.h +0 -1
index 8b491e66eaa8..6c896fbe21db 100644
@@ -48,6 +48,5 @@
  * arch/x86/kernel/head_64.S), and it is mapped here:
  */
 #define KERNEL_IMAGE_SIZE	(512 * 1024 * 1024)
-#define KERNEL_IMAGE_START	_AC(0xffffffff80000000, UL)
 
 #endif /* _ASM_X86_PAGE_64_DEFS_H */
arch/x86/kernel/head64.c +3 -3
index c5e403f6d869..101ac1a9263e 100644
@@ -144,10 +144,10 @@ void __init x86_64_start_kernel(char * real_mode_data)
 	 * Build-time sanity checks on the kernel image and module
 	 * area mappings. (these are purely build-time and produce no code)
 	 */
-	BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START);
-	BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE);
+	BUILD_BUG_ON(MODULES_VADDR < __START_KERNEL_map);
+	BUILD_BUG_ON(MODULES_VADDR - __START_KERNEL_map < KERNEL_IMAGE_SIZE);
 	BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
-	BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0);
+	BUILD_BUG_ON((__START_KERNEL_map & ~PMD_MASK) != 0);
 	BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
 	BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
 	BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
Signature · 1 line
1.8.1.3.535.ga923c31
#4 lore raw

[tip:x86/cleanups] x86: Drop KERNEL_IMAGE_START

x86: Drop KERNEL_IMAGE_START
Commit-ID:  8e3c2a8cf647e2f3a1e9d38009b0d1c02145822f
Gitweb:     http://git.kernel.org/tip/8e3c2a8cf647e2f3a1e9d38009b0d1c02145822f
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 4 Mar 2013 21:16:17 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 2 Apr 2013 16:03:29 -0700

x86: Drop KERNEL_IMAGE_START

We have KERNEL_IMAGE_START and __START_KERNEL_map which both contain the start of the kernel text mapping's virtual address. Remove the prior one which has been replicated a lot less times around the tree.

No functionality change.

---
 arch/x86/include/asm/page_64_types.h | 1 -
 arch/x86/kernel/head64.c             | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)
arch/x86/include/asm/page_64_types.h +0 -1
index 8b491e6..6c896fb 100644
@@ -48,6 +48,5 @@
  * arch/x86/kernel/head_64.S), and it is mapped here:
  */
 #define KERNEL_IMAGE_SIZE	(512 * 1024 * 1024)
-#define KERNEL_IMAGE_START	_AC(0xffffffff80000000, UL)
 
 #endif /* _ASM_X86_PAGE_64_DEFS_H */
arch/x86/kernel/head64.c +3 -3
index c5e403f..101ac1a9 100644
@@ -144,10 +144,10 @@ void __init x86_64_start_kernel(char * real_mode_data)
 	 * Build-time sanity checks on the kernel image and module
 	 * area mappings. (these are purely build-time and produce no code)
 	 */
-	BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START);
-	BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE);
+	BUILD_BUG_ON(MODULES_VADDR < __START_KERNEL_map);
+	BUILD_BUG_ON(MODULES_VADDR - __START_KERNEL_map < KERNEL_IMAGE_SIZE);
 	BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE);
-	BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0);
+	BUILD_BUG_ON((__START_KERNEL_map & ~PMD_MASK) != 0);
 	BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0);
 	BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL));
 	BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) ==
author maintainer
#5 lore raw

PATCH 3/5 x86-64, docs, mm: Add vsyscall range to virtual address space layout

In reply to Borislav Petkov

Add the end of the virtual address space to its layout documentation.

---
 Documentation/x86/x86_64/mm.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/x86/x86_64/mm.txt +3 -1
index d6498e3cd713..881582f75c9c 100644
@@ -13,7 +13,9 @@ ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
 ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
 ... unused hole ...
 ffffffff80000000 - ffffffffa0000000 (=512 MB)  kernel text mapping, from phys 0
-ffffffffa0000000 - fffffffffff00000 (=1536 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1525 MB) module mapping space
+ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
+ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
 
 The direct mapping covers all memory in the system up to the highest
 memory address (this means in some cases it can also include PCI memory
Signature · 1 line
1.8.1.3.535.ga923c31
#6 lore raw

Re: [PATCH 3/5] x86-64, docs, mm: Add vsyscall range to virtual address space layout

Quoted 13 lines · Borislav Petkov

Add the end of the virtual address space to its layout documentation.

---
 Documentation/x86/x86_64/mm.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/x86/x86_64/mm.txt +0 -0
index d6498e3cd713..881582f75c9c 100644

Documentation/x86/x86_64/mm.txt ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole · line 21

Quoted 10 lines
Documentation/x86/x86_64/mm.txt +3 -1
@@ -13,7 +13,9 @@ ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
 ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
 ... unused hole ...
 ffffffff80000000 - ffffffffa0000000 (=512 MB)  kernel text mapping, from phys 0
-ffffffffa0000000 - fffffffffff00000 (=1536 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1525 MB) module mapping space
+ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
+ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
 
 The direct mapping covers all memory in the system up to the highest
 memory address (this means in some cases it can also include PCI memory

vsyscalls are only 4k. Am I missing something obvious her?

author maintainer
#7 lore raw

Re: [PATCH 3/5] x86-64, docs, mm: Add vsyscall range to virtual address space layout

Quoted 1 line · Andy Lutomirski

vsyscalls are only 4k. Am I missing something obvious her?

Right, but we're reserving 5 level2 pages for this, i.e. 5*512*4K = 10M. I.e., each level2 page contains 512 ptes, each pointing to a 4K page.

arch/x86/kernel/head_64.S:

...
NEXT_PAGE(level2_fixmap_pgt)

	.fill	506,8,0
	.quad	level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
	/* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
	.fill	5,8,0

NEXT_PAGE(level1_fixmap_pgt)

	.fill	512,8,0
Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#8 lore raw

[tip:x86/cleanups] x86-64, docs, mm: Add vsyscall range to virtual address space layout

In reply to Borislav Petkov
x86-64, docs, mm: Add vsyscall range to virtual address space layout
Commit-ID:  aca91bfc67fe356544eb1cfc483c09b27ce49fa9
Gitweb:     http://git.kernel.org/tip/aca91bfc67fe356544eb1cfc483c09b27ce49fa9
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 4 Mar 2013 21:16:18 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 2 Apr 2013 16:03:31 -0700

x86-64, docs, mm: Add vsyscall range to virtual address space layout

Add the end of the virtual address space to its layout documentation.

---
 Documentation/x86/x86_64/mm.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/x86/x86_64/mm.txt +3 -1
index d6498e3..881582f 100644
@@ -13,7 +13,9 @@ ffffe90000000000 - ffffe9ffffffffff (=40 bits) hole
 ffffea0000000000 - ffffeaffffffffff (=40 bits) virtual memory map (1TB)
 ... unused hole ...
 ffffffff80000000 - ffffffffa0000000 (=512 MB)  kernel text mapping, from phys 0
-ffffffffa0000000 - fffffffffff00000 (=1536 MB) module mapping space
+ffffffffa0000000 - ffffffffff5fffff (=1525 MB) module mapping space
+ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls
+ffffffffffe00000 - ffffffffffffffff (=2 MB) unused hole
 
 The direct mapping covers all memory in the system up to the highest
 memory address (this means in some cases it can also include PCI memory
author maintainer
#9 lore raw

PATCH 4/5 x86, msr: Unify variable names

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

Make sure all MSR-accessing primitives which split MSR values in two 32-bit parts have their variables called 'low' and 'high' for consistence with the rest of the code and for ease of staring.

---
 arch/x86/include/asm/msr.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/include/asm/msr.h +7 -7
index 9264802e2824..cb7502852acb 100644
@@ -137,11 +137,11 @@ static inline unsigned long long native_read_pmc(int counter)
  * pointer indirection), this allows gcc to optimize better
  */
 
-#define rdmsr(msr, val1, val2)					\
+#define rdmsr(msr, low, high)					\
 do {								\
 	u64 __val = native_read_msr((msr));			\
-	(void)((val1) = (u32)__val);				\
-	(void)((val2) = (u32)(__val >> 32));			\
+	(void)((low) = (u32)__val);				\
+	(void)((high) = (u32)(__val >> 32));			\
 } while (0)
 
 static inline void wrmsr(unsigned msr, unsigned low, unsigned high)
@@ -162,12 +162,12 @@ static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high)
 }
 
 /* rdmsr with exception handling */
-#define rdmsr_safe(msr, p1, p2)					\
+#define rdmsr_safe(msr, low, high)				\
 ({								\
 	int __err;						\
 	u64 __val = native_read_msr_safe((msr), &__err);	\
-	(*p1) = (u32)__val;					\
-	(*p2) = (u32)(__val >> 32);				\
+	(*low) = (u32)__val;					\
+	(*high) = (u32)(__val >> 32);				\
 	__err;							\
 })
 
@@ -208,7 +208,7 @@ do {                                                            \
 #define wrmsrl_safe(msr, val) wrmsr_safe((msr), (u32)(val),		\
 					     (u32)((val) >> 32))
 
-#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2))
+#define write_tsc(low, high) wrmsr(MSR_IA32_TSC, (low), (high))
 
 #define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0)
 
Signature · 1 line
1.8.1.3.535.ga923c31
#10 lore raw

[tip:x86/cleanups] x86, msr: Unify variable names

x86, msr: Unify variable names
Commit-ID:  1423bed239415edd1562c25be8a7408858fdbb19
Gitweb:     http://git.kernel.org/tip/1423bed239415edd1562c25be8a7408858fdbb19
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 4 Mar 2013 21:16:19 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 2 Apr 2013 16:03:32 -0700

x86, msr: Unify variable names

Make sure all MSR-accessing primitives which split MSR values in two 32-bit parts have their variables called 'low' and 'high' for consistence with the rest of the code and for ease of staring.

---
 arch/x86/include/asm/msr.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/include/asm/msr.h +7 -7
index 9264802..cb75028 100644
@@ -137,11 +137,11 @@ static inline unsigned long long native_read_pmc(int counter)
  * pointer indirection), this allows gcc to optimize better
  */
 
-#define rdmsr(msr, val1, val2)					\
+#define rdmsr(msr, low, high)					\
 do {								\
 	u64 __val = native_read_msr((msr));			\
-	(void)((val1) = (u32)__val);				\
-	(void)((val2) = (u32)(__val >> 32));			\
+	(void)((low) = (u32)__val);				\
+	(void)((high) = (u32)(__val >> 32));			\
 } while (0)
 
 static inline void wrmsr(unsigned msr, unsigned low, unsigned high)
@@ -162,12 +162,12 @@ static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high)
 }
 
 /* rdmsr with exception handling */
-#define rdmsr_safe(msr, p1, p2)					\
+#define rdmsr_safe(msr, low, high)				\
 ({								\
 	int __err;						\
 	u64 __val = native_read_msr_safe((msr), &__err);	\
-	(*p1) = (u32)__val;					\
-	(*p2) = (u32)(__val >> 32);				\
+	(*low) = (u32)__val;					\
+	(*high) = (u32)(__val >> 32);				\
 	__err;							\
 })
 
@@ -208,7 +208,7 @@ do {                                                            \
 #define wrmsrl_safe(msr, val) wrmsr_safe((msr), (u32)(val),		\
 					     (u32)((val) >> 32))
 
-#define write_tsc(val1, val2) wrmsr(MSR_IA32_TSC, (val1), (val2))
+#define write_tsc(low, high) wrmsr(MSR_IA32_TSC, (low), (high))
 
 #define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0)
 
author maintainer
#11 lore raw

PATCH 5/5 x86, quirks: Shut-up a long-standing gcc warning

In reply to Borislav Petkov

From: Borislav Petkov <[email protected]>

So gcc nags about those since forever in randconfig builds.

arch/x86/kernel/quirks.c: In function ‘ati_ixp4x0_rev’:
arch/x86/kernel/quirks.c:361:4: warning: ‘b’ is used uninitialized in this function [-Wuninitialized] arch/x86/kernel/quirks.c: In function ‘ati_force_enable_hpet’:
arch/x86/kernel/quirks.c:367:4: warning: ‘d’ may be used uninitialized in this function [-Wuninitialized] arch/x86/kernel/quirks.c:357:6: note: ‘d’ was declared here arch/x86/kernel/quirks.c:407:21: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized]

This function quirk is called on a SB400 chipset only anyway so the distant possibility of a PCI access failing becomes almost impossible there. Even if it did fail, then something else more serious is the problem.

So zero-out the variables so that gcc shuts up but do a coarse check on the PCI accesses at the end and signal whether any of them had an error. They shouldn't but in case they do, we'll at least know and we can address it.

---
 arch/x86/kernel/quirks.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
arch/x86/kernel/quirks.c +11 -7
index 26ee48a33dc4..04ee1e2e4c02 100644
@@ -354,18 +354,22 @@ static void ati_force_hpet_resume(void)
 
 static u32 ati_ixp4x0_rev(struct pci_dev *dev)
 {
-	u32 d;
-	u8  b;
+	int err = 0;
+	u32 d = 0;
+	u8  b = 0;
 
-	pci_read_config_byte(dev, 0xac, &b);
+	err = pci_read_config_byte(dev, 0xac, &b);
 	b &= ~(1<<5);
-	pci_write_config_byte(dev, 0xac, b);
-	pci_read_config_dword(dev, 0x70, &d);
+	err |= pci_write_config_byte(dev, 0xac, b);
+	err |= pci_read_config_dword(dev, 0x70, &d);
 	d |= 1<<8;
-	pci_write_config_dword(dev, 0x70, d);
-	pci_read_config_dword(dev, 0x8, &d);
+	err |= pci_write_config_dword(dev, 0x70, d);
+	err |= pci_read_config_dword(dev, 0x8, &d);
 	d &= 0xff;
 	dev_printk(KERN_DEBUG, &dev->dev, "SB4X0 revision 0x%x\n", d);
+
+	WARN_ON_ONCE(err);
+
 	return d;
 }
 
Signature · 1 line
1.8.1.3.535.ga923c31
#12 lore raw

[tip:x86/cleanups] x86, quirks: Shut-up a long-standing gcc warning

x86, quirks: Shut-up a long-standing gcc warning
Commit-ID:  73f460408ca9b6e917f32c89c9a85c586f17f732
Gitweb:     http://git.kernel.org/tip/73f460408ca9b6e917f32c89c9a85c586f17f732
Author:     Borislav Petkov <[email protected]>
AuthorDate: Mon, 4 Mar 2013 21:16:20 +0100
Committer:  H. Peter Anvin <[email protected]>
CommitDate: Tue, 2 Apr 2013 16:03:34 -0700

x86, quirks: Shut-up a long-standing gcc warning

So gcc nags about those since forever in randconfig builds.

arch/x86/kernel/quirks.c: In function ‘ati_ixp4x0_rev’:
arch/x86/kernel/quirks.c:361:4: warning: ‘b’ is used uninitialized in this function [-Wuninitialized] arch/x86/kernel/quirks.c: In function ‘ati_force_enable_hpet’:
arch/x86/kernel/quirks.c:367:4: warning: ‘d’ may be used uninitialized in this function [-Wuninitialized] arch/x86/kernel/quirks.c:357:6: note: ‘d’ was declared here arch/x86/kernel/quirks.c:407:21: warning: ‘val’ may be used uninitialized in this function [-Wuninitialized]

This function quirk is called on a SB400 chipset only anyway so the distant possibility of a PCI access failing becomes almost impossible there. Even if it did fail, then something else more serious is the problem.

So zero-out the variables so that gcc shuts up but do a coarse check on the PCI accesses at the end and signal whether any of them had an error. They shouldn't but in case they do, we'll at least know and we can address it.

---
 arch/x86/kernel/quirks.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
arch/x86/kernel/quirks.c +11 -7
index 26ee48a..04ee1e2 100644
@@ -354,18 +354,22 @@ static void ati_force_hpet_resume(void)
 
 static u32 ati_ixp4x0_rev(struct pci_dev *dev)
 {
-	u32 d;
-	u8  b;
+	int err = 0;
+	u32 d = 0;
+	u8  b = 0;
 
-	pci_read_config_byte(dev, 0xac, &b);
+	err = pci_read_config_byte(dev, 0xac, &b);
 	b &= ~(1<<5);
-	pci_write_config_byte(dev, 0xac, b);
-	pci_read_config_dword(dev, 0x70, &d);
+	err |= pci_write_config_byte(dev, 0xac, b);
+	err |= pci_read_config_dword(dev, 0x70, &d);
 	d |= 1<<8;
-	pci_write_config_dword(dev, 0x70, d);
-	pci_read_config_dword(dev, 0x8, &d);
+	err |= pci_write_config_dword(dev, 0x70, d);
+	err |= pci_read_config_dword(dev, 0x8, &d);
 	d &= 0xff;
 	dev_printk(KERN_DEBUG, &dev->dev, "SB4X0 revision 0x%x\n", d);
+
+	WARN_ON_ONCE(err);
+
 	return d;
 }