* [RFC -tip] x86,apic - set cpu_has_apic for discrete apic
@ 2009-07-11 21:29 Cyrill Gorcunov
2009-07-12 0:41 ` Maciej W. Rozycki
0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2009-07-11 21:29 UTC (permalink / raw)
To: Ingo Molnar, Maciej W. Rozycki
Cc: H. Peter Anvin, Thomas Gleixner, Yinghai Lu, LKML
In case of discrete apic (due to hardware or firmware reason)
cpuid may not retrieve cpu_has_apic bit. So for SMP
compiled kernels instead of long check we may set "fake"
cpu_has_apic bit and check only the bit in further code
flow.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
Please review carefully.
arch/x86/kernel/apic/apic.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: linux-2.6.git/arch/x86/kernel/apic/apic.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/apic.c
+++ linux-2.6.git/arch/x86/kernel/apic/apic.c
@@ -1003,6 +1003,20 @@ int __init verify_local_APIC(void)
unsigned int reg0, reg1;
/*
+ * For discrete APIC case cpu_has_apic bit could not
+ * be retrieved via cpuid instruction. Same time
+ * we rely on this bit (mostly for SMP compiled
+ * kernel) and instead of checking the long condition
+ * below all the time we do check for plain cpu_has_apic.
+ *
+ * At this moment all the checks are passed and we've
+ * already complained if there was a BIOS bug. This place
+ * should be safe for such a trick. --cvg
+ */
+ if (smp_found_config && !cpu_has_apic && !disable_apic)
+ set_cpu_cap(&boot_cpu_data, X86_FEATURE_APIC);
+
+ /*
* The version register is read-only in a real APIC.
*/
reg0 = apic_read(APIC_LVR);
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC -tip] x86,apic - set cpu_has_apic for discrete apic
2009-07-11 21:29 [RFC -tip] x86,apic - set cpu_has_apic for discrete apic Cyrill Gorcunov
@ 2009-07-12 0:41 ` Maciej W. Rozycki
2009-07-12 5:52 ` Cyrill Gorcunov
0 siblings, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2009-07-12 0:41 UTC (permalink / raw)
To: Cyrill Gorcunov
Cc: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Yinghai Lu, LKML
On Sun, 12 Jul 2009, Cyrill Gorcunov wrote:
> In case of discrete apic (due to hardware or firmware reason)
> cpuid may not retrieve cpu_has_apic bit. So for SMP
> compiled kernels instead of long check we may set "fake"
> cpu_has_apic bit and check only the bit in further code
> flow.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> ---
>
> Please review carefully.
Sure: how did you test it or plan to do so?
Maciej
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC -tip] x86,apic - set cpu_has_apic for discrete apic
2009-07-12 0:41 ` Maciej W. Rozycki
@ 2009-07-12 5:52 ` Cyrill Gorcunov
2009-07-12 6:31 ` Maciej W. Rozycki
0 siblings, 1 reply; 5+ messages in thread
From: Cyrill Gorcunov @ 2009-07-12 5:52 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Yinghai Lu, LKML
[Maciej W. Rozycki - Sun, Jul 12, 2009 at 01:41:54AM +0100]
| On Sun, 12 Jul 2009, Cyrill Gorcunov wrote:
|
| > In case of discrete apic (due to hardware or firmware reason)
| > cpuid may not retrieve cpu_has_apic bit. So for SMP
| > compiled kernels instead of long check we may set "fake"
| > cpu_has_apic bit and check only the bit in further code
| > flow.
| >
| > Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
| > ---
| >
| > Please review carefully.
|
| Sure: how did you test it or plan to do so?
|
| Maciej
|
Well, I've been using code reading. No real hardware test.
I just don't have such a hardware.
I've a two pretty old laptops will check today if they
are discrete apic based systems.
Also I was thinking about spurious software tests --
ie to set discrete apic manually but actually I don't
think it will help.
And also I hoped that Ingo has a hw farm even with
discrete apic maybe... :)
-- Cyrill
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC -tip] x86,apic - set cpu_has_apic for discrete apic
2009-07-12 5:52 ` Cyrill Gorcunov
@ 2009-07-12 6:31 ` Maciej W. Rozycki
2009-07-12 6:34 ` Cyrill Gorcunov
0 siblings, 1 reply; 5+ messages in thread
From: Maciej W. Rozycki @ 2009-07-12 6:31 UTC (permalink / raw)
To: Cyrill Gorcunov
Cc: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Yinghai Lu, LKML
On Sun, 12 Jul 2009, Cyrill Gorcunov wrote:
> Well, I've been using code reading. No real hardware test.
> I just don't have such a hardware.
Then simulate it! Proofreading is not enough -- the APIC code is too
twisted. Be imaginative -- for example you can clear the APIC bit at the
time CPUID flags are saved for later use with cpu_has_apic() and see if
the code behaves as expected. Sprinkle printk()s here and there to see if
variables are set correctly, whether the right code paths are taken, etc.
Tedious? Well, who said kernel debugging was going to be a piece of cake?
Most of the APIC support code I have written has been run-time tested
like this -- one change at a time. Do you think I have an infinite number
of SMP configurations too? All the clean-ups I worked on last year were
tested with one laptop. I didn't even have a serial port for console
dumps back then.
NAK from me until you've tested it, sorry.
Maciej
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC -tip] x86,apic - set cpu_has_apic for discrete apic
2009-07-12 6:31 ` Maciej W. Rozycki
@ 2009-07-12 6:34 ` Cyrill Gorcunov
0 siblings, 0 replies; 5+ messages in thread
From: Cyrill Gorcunov @ 2009-07-12 6:34 UTC (permalink / raw)
To: Maciej W. Rozycki
Cc: Ingo Molnar, H. Peter Anvin, Thomas Gleixner, Yinghai Lu, LKML
[Maciej W. Rozycki - Sun, Jul 12, 2009 at 07:31:44AM +0100]
| On Sun, 12 Jul 2009, Cyrill Gorcunov wrote:
|
| > Well, I've been using code reading. No real hardware test.
| > I just don't have such a hardware.
|
| Then simulate it! Proofreading is not enough -- the APIC code is too
| twisted. Be imaginative -- for example you can clear the APIC bit at the
| time CPUID flags are saved for later use with cpu_has_apic() and see if
| the code behaves as expected. Sprinkle printk()s here and there to see if
| variables are set correctly, whether the right code paths are taken, etc.
| Tedious? Well, who said kernel debugging was going to be a piece of cake?
|
| Most of the APIC support code I have written has been run-time tested
| like this -- one change at a time. Do you think I have an infinite number
| of SMP configurations too? All the clean-ups I worked on last year were
| tested with one laptop. I didn't even have a serial port for console
| dumps back then.
|
| NAK from me until you've tested it, sorry.
Started to... hope to publish results today!
Thanks Maciej!
|
| Maciej
|
-- Cyrill
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-12 6:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-11 21:29 [RFC -tip] x86,apic - set cpu_has_apic for discrete apic Cyrill Gorcunov
2009-07-12 0:41 ` Maciej W. Rozycki
2009-07-12 5:52 ` Cyrill Gorcunov
2009-07-12 6:31 ` Maciej W. Rozycki
2009-07-12 6:34 ` Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox