Skip to contentSkip to conversation

x86: Fix bogus warning in apic_noop.apic_write()

PATCH In review Thomas Gleixner 2 participants 7 messages Dec 7, 2009 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Fix bogus warning in apic_noop.apic_write()

apic_noop is used to provide dummy apic functions. It's installed when the CPU has no APIC or when the APIC is disabled on the kernel command line.

The apic_noop implementation of apic_write() warns when the CPU has an APIC or when the APIC is not disabled.

That's bogus. The warning should only happen when the CPU has an APIC _AND_ the APIC is not disabled. apic_noop.apic_read() has the correct check.

[ @stable: in <= .32 this typo resides in native_apic_write_dummy(). ]

---
 arch/x86/kernel/apic/apic_noop.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/apic/apic_noop.c +1 -1
Index: linux-2.6/arch/x86/kernel/apic/apic_noop.c
===================================================================
@@ -127,7 +127,7 @@ static u32 noop_apic_read(u32 reg)
 
 static void noop_apic_write(u32 reg, u32 v)
 {
-	WARN_ON_ONCE((cpu_has_apic || !disable_apic));
+	WARN_ON_ONCE((cpu_has_apic && !disable_apic));
 }
 
 struct apic apic_noop = {
#1 lore raw
Commit-ID:  a946d8f11f0da9cfc714248036fcfd3a794d1e27
Gitweb:     http://git.kernel.org/tip/a946d8f11f0da9cfc714248036fcfd3a794d1e27
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:59:46 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 13:16:37 +0100

x86: Fix bogus warning in apic_noop.apic_write()

apic_noop is used to provide dummy apic functions. It's installed when the CPU has no APIC or when the APIC is disabled on the kernel command line.

The apic_noop implementation of apic_write() warns when the CPU has an APIC or when the APIC is not disabled.

That's bogus. The warning should only happen when the CPU has an APIC _AND_ the APIC is not disabled. apic_noop.apic_read() has the correct check.

Cc Cyrill Gorcunov <[email protected]>
Cc <[email protected]> # in <= .32 this typo resides in native_apic_write_dummy()

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic_noop.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/kernel/apic/apic_noop.c +1 -1
index d9acc3b..e31b9ff 100644
@@ -127,7 +127,7 @@ static u32 noop_apic_read(u32 reg)
 
 static void noop_apic_write(u32 reg, u32 v)
 {
-	WARN_ON_ONCE((cpu_has_apic || !disable_apic));
+	WARN_ON_ONCE(cpu_has_apic && !disable_apic);
 }
 
 struct apic apic_noop = {
#2 lore raw
Quoted 20 lines · tip-bot for Thomas Gleixner
Commit-ID:  a946d8f11f0da9cfc714248036fcfd3a794d1e27
Gitweb:     http://git.kernel.org/tip/a946d8f11f0da9cfc714248036fcfd3a794d1e27
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:59:46 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 13:16:37 +0100

x86: Fix bogus warning in apic_noop.apic_write()

apic_noop is used to provide dummy apic functions. It's installed when the CPU has no APIC or when the APIC is disabled on the kernel command line.

The apic_noop implementation of apic_write() warns when the CPU has an APIC or when the APIC is not disabled.

That's bogus. The warning should only happen when the CPU has an APIC _AND_ the APIC is not disabled. apic_noop.apic_read() has the correct check.

Quoted 8 lines
Cc Cyrill Gorcunov <[email protected]>
Cc <[email protected]> # in <= .32 this typo resides in native_apic_write_dummy()

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic_noop.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

...

Hi Thomas, Ingo,

please do not change it. There are still machines without cpu_has_apic bit support so with this patch any attempt to write to 82489DX will success. So the former code has been using "OR" by a purpose, there is no error.

-- Cyrill

#3 lore raw
Quoted 29 lines · Cyrill Gorcunov
Quoted 20 lines · tip-bot for Thomas Gleixner
Commit-ID:  a946d8f11f0da9cfc714248036fcfd3a794d1e27
Gitweb:     http://git.kernel.org/tip/a946d8f11f0da9cfc714248036fcfd3a794d1e27
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:59:46 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 13:16:37 +0100

x86: Fix bogus warning in apic_noop.apic_write()

apic_noop is used to provide dummy apic functions. It's installed when the CPU has no APIC or when the APIC is disabled on the kernel command line.

The apic_noop implementation of apic_write() warns when the CPU has an APIC or when the APIC is not disabled.

That's bogus. The warning should only happen when the CPU has an APIC _AND_ the APIC is not disabled. apic_noop.apic_read() has the correct check.

Quoted 8 lines
Cc Cyrill Gorcunov <[email protected]>
Cc <[email protected]> # in <= .32 this typo resides in native_apic_write_dummy()

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic_noop.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 8 lines

...

Hi Thomas, Ingo,

please do not change it. There are still machines without cpu_has_apic bit support so with this patch any attempt to write to 82489DX will success. So the former code has been using "OR" by a purpose, there is no error.

Err, your warning has the following false positive:

     cpu_has_apic == true and disable_apic == true

Which is crap, as it warns just because someone disabled the APIC on the command line and the kernel did the right thing of installing apic_noop.

And I have a hard time to see how this is related to 82489DX.

Thanks,

tglx

#4 lore raw
Quoted 34 lines · Thomas Gleixner
Quoted 33 lines · Cyrill Gorcunov
Quoted 20 lines · tip-bot for Thomas Gleixner
Commit-ID:  a946d8f11f0da9cfc714248036fcfd3a794d1e27
Gitweb:     http://git.kernel.org/tip/a946d8f11f0da9cfc714248036fcfd3a794d1e27
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:59:46 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 13:16:37 +0100

x86: Fix bogus warning in apic_noop.apic_write()

apic_noop is used to provide dummy apic functions. It's installed when the CPU has no APIC or when the APIC is disabled on the kernel command line.

The apic_noop implementation of apic_write() warns when the CPU has an APIC or when the APIC is not disabled.

That's bogus. The warning should only happen when the CPU has an APIC _AND_ the APIC is not disabled. apic_noop.apic_read() has the correct check.

Quoted 8 lines
Cc Cyrill Gorcunov <[email protected]>
Cc <[email protected]> # in <= .32 this typo resides in native_apic_write_dummy()

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic_noop.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

...

Hi Thomas, Ingo,

Quoted 8 lines
Quoted 4 lines

please do not change it. There are still machines without cpu_has_apic bit support so with this patch any attempt to write to 82489DX will success. So the former code has been using "OR" by a purpose, there is no error.

Err, your warning has the following false positive:

     cpu_has_apic == true and disable_apic == true

This combination impossible at moment (by "impossible" I mean at moment of apic_write action). When apic disabled via boot option cpu_has_apic cleared as well.

static int __init setup_disableapic(char *arg)

{
	disable_apic = 1;
	setup_clear_cpu_cap(X86_FEATURE_APIC);
	return 0;
}

And, btw if some code is trying to write to apic when it's disabled via boot option -- it means the code is buggy and this is not a false positive but rather proper warning.

Thomas, if you've changed this code I suppose you saw some warning triggered, right? Could you pointed me on it?

The idea was exactly to use "OR" here, so any attempts to make WRITE on dosabled apic were captured.

Quoted 6 lines

Which is crap, as it warns just because someone disabled the APIC on the command line and the kernel did the right thing of installing apic_noop.

And I have a hard time to see how this is related to 82489DX.

On 82489DX there is no X86_FEATURE_APIC at all, so cpu_has_apic is never set and disable_apic is the only flag we inspect to find out if we're allowed to operate over apic.

An example you may find in APIC_init_uniprocessor, the first check is done for disable_apic, not cpu_has_apic.

Quoted 5 lines

Thanks,

tglx

-- Cyrill

#5 lore raw
Quoted 55 lines · Cyrill Gorcunov
Quoted 34 lines · Thomas Gleixner
Quoted 33 lines · Cyrill Gorcunov
Quoted 20 lines · tip-bot for Thomas Gleixner
Commit-ID:  a946d8f11f0da9cfc714248036fcfd3a794d1e27
Gitweb:     http://git.kernel.org/tip/a946d8f11f0da9cfc714248036fcfd3a794d1e27
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Mon, 7 Dec 2009 12:59:46 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Mon, 7 Dec 2009 13:16:37 +0100

x86: Fix bogus warning in apic_noop.apic_write()

apic_noop is used to provide dummy apic functions. It's installed when the CPU has no APIC or when the APIC is disabled on the kernel command line.

The apic_noop implementation of apic_write() warns when the CPU has an APIC or when the APIC is not disabled.

That's bogus. The warning should only happen when the CPU has an APIC _AND_ the APIC is not disabled. apic_noop.apic_read() has the correct check.

Quoted 8 lines
Cc Cyrill Gorcunov <[email protected]>
Cc <[email protected]> # in <= .32 this typo resides in native_apic_write_dummy()

LKML-Reference: <[email protected]>

---
 arch/x86/kernel/apic/apic_noop.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

...

Hi Thomas, Ingo,

Quoted 8 lines
Quoted 4 lines

please do not change it. There are still machines without cpu_has_apic bit support so with this patch any attempt to write to 82489DX will success. So the former code has been using "OR" by a purpose, there is no error.

Err, your warning has the following false positive:

     cpu_has_apic == true and disable_apic == true

This combination impossible at moment (by "impossible" I mean at moment of apic_write action). When apic disabled via boot option cpu_has_apic cleared as well.

static int __init setup_disableapic(char *arg)

{
	disable_apic = 1;
	setup_clear_cpu_cap(X86_FEATURE_APIC);
	return 0;
}
Quoted 7 lines

And, btw if some code is trying to write to apic when it's disabled via boot option -- it means the code is buggy and this is not a false positive but rather proper warning.

Thomas, if you've changed this code I suppose you saw some warning triggered, right? Could you pointed me on it?

http://www.kerneloops.org/searchweek.php?search=native_apic_write_dummy

#6 lore raw

On Mon, Dec 07, 2009 at 05:55:37PM +0100, Thomas Gleixner wrote:
...

Quoted 10 lines
Quoted 7 lines

And, btw if some code is trying to write to apic when it's disabled via boot option -- it means the code is buggy and this is not a false positive but rather proper warning.

Thomas, if you've changed this code I suppose you saw some warning triggered, right? Could you pointed me on it?

http://www.kerneloops.org/searchweek.php?search=native_apic_write_dummy

Doh!

The most cases show inapropriate usage of apic->write() operation. set_perf_event_pending() already fixed by 7d42896628202a551ad1107697cd215dc5fca099, intel_init_thermal() fixed as well with 5ce4243dcefbbc43791ffc36e1be55067ceec916

(all was in -tip).

Though throttling code is just buggy and intel_init_thermal() should check if cpu_has_apic. So the former code does exactly what it should -- it catches inapropriate writes.

Thomas, I just don't know -- from my pov, write() is really different from read(), since it implies that APIC changes it behaviour, it could be timer setup, vector setup operation or whatever. I even doubt if enabling IPI in apic-noop is a good idea (since perf code already implemented to check apic presence by Peter and IPI is not called).

Though I'm not insisting, I simply don't have spare time at moment to check all apic_writes() again :(

-- Cyrill