linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: 4.8.2 not booting in 32-bit VM without I/O-APIC
@ 2016-10-28 18:30 Michal Necasek
  2016-10-28 18:38 ` Thomas Gleixner
  0 siblings, 1 reply; 9+ messages in thread
From: Michal Necasek @ 2016-10-28 18:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: prarit, ville.syrjala, tglx, michael.thayer, frank.mehnert,
	knut.osmundsen


   Hi Thomas,

 In case you haven't had a chance to take a look yet... 

 We had to dig a bit because the problem introduced by commit 2a51fe08 (arch/x86: Handle non enumerated CPU after physical hotplug) <1> is not fixed for us by commit ff856051 (arch/x86: Handle non enumerated CPU after physical hotplug) <2>.

 To recap, after the initial commit, systems with no local APIC panicked <4> early during boot. That showed up for us in VirtualBox, but not surprisingly, physical systems are also affected <3>. The second patch fixes systems with no local APIC, but not systems which have no ACPI MADT (or no ACPI), no MP tables, yet do have an APIC.

 The core problem is init ordering. In setup_arch() in arch/x86/kernel/setup.c, prefill_possible_map() is called *before* init_apic_mappings(). On typical modern systems, the local APIC will be set up either through ACPI or MP tables by the time prefill_possible_map() runs, but it is incorrect to assume that the APIC must be initialized by the time prefill_possible_map() is entered. That's why the APIC callbacks aren't no-ops there, they simply haven't been set up yet.

 I suspect that either init_apic_mappings() needs to be called earlier or the initial fix from commit 2a51fe08 needs to be done later.


     Regards,
        Michal

<1>
https://patchwork.kernel.org/patch/9366095/
<2>
https://patchwork.kernel.org/patch/9390349/
<3> 
https://bugs.archlinux.org/task/51506
<4>
Using APIC driver default
ACPI: PM-Timer IO Port: 0x4008
BUG: unable to handle kernel paging request at ffffc020
IP: [<c8045e0d>] native_apic_mem_read+0xd/0x10
*pde = 08b8a063
*pte = 00000000
Oops: 0000 [#1] SMP
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Not tainted 4.9.0-040900rc1-generic
#201610151630
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox
12/01/2006
task: c89fda80 task.stack: c89f8000
EIP: 0060:[<c8045e0d>] EFLAGS: 00210046 CPU: 0
EIP is at native_apic_mem_read+0xd/0x10
EAX: ffffc020 EBX: ffffffff ECX: c89f9f40 EDX: fffff000
ESI: c8b8d000 EDI: c8b89400 EBP: c89f9f88 ESP: c89f9f84
  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
CR0: 80050033 CR2: ffffc020 CR3: 08b8c000 CR4: 00040690
Stack:
  c8040eb6 c89f9fb8 c8accc5e c89f9fb8 c8b8d000 c8ac424a 33120000 00000000
  35888000 00000000 00033120 00000000 c80ba5f7 00000000 00000000 00000000
  00000000 00174f46 00174f46 0008f800 c8b8d800 08e34003 c8abe7f5 c88f4b62
Call Trace:
  [<c8040eb6>] ? hard_smp_processor_id+0x16/0x30
  [<c8accc5e>] ? prefill_possible_map+0x16/0x137
  [<c8ac424a>] ? setup_arch+0xaf3/0xbdf
  [<c80ba5f7>] ? vprintk_default+0x37/0x40
  [<c8abe7f5>] ? start_kernel+0x8d/0x3d7
Code: a1 d8 89 b9 c8 5d c3 66 90 66 90 66 90 90 8b 0d b0 f5 a0 c8 8d 84
08 00 d0 ff ff 89 10 c3 8b 15 b0 f5 a0 c8 8d 84 10 00 d0 ff ff <8b> 00 c3
8b 15 20 94 9a c8 53 89 c3 b8 30 00 00 00 ff 52 78 3c
EIP: [<c8045e0d>]
native_apic_mem_read+0xd/0x10
  SS:ESP 0068:c89f9f84
CR2: 00000000ffffc020
---[ end trace f68728a0d3053b52 ]---


----- Original Message -----
From: tglx@linutronix.de
To: michal.necasek@oracle.com
Cc: michael.thayer@oracle.com, frank.mehnert@oracle.com, knut.osmundsen@oracle.com
Sent: Monday, October 24, 2016 9:39:45 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: Re: 4.8.2 not booting in 32-bit VM without I/O-APIC

On Mon, 24 Oct 2016, Michal Necasek wrote:
> 
>  To explain a bit, disabling the I/O APIC also prevents the MP tables
> from being created in the VirtualBox VM (historical reasons) and there
> will likewise be no ACPI MADT.
>
>  I believe the panic is triggered when neither ACPI nor MPS does any CPU
> discovery. Then the local APIC isn't mapped and prefill_possible_map()
> will page fault and panic because num_processors is zero and it just
> assumes that the local APIC is present and accessible.

> On systems with no MP tables, 'acpi=off' or 'nolapic' kernel arguments
> trigger the same panic. I didn't find a way to prevent Linux from looking
> at the MP tables if they're present.

Hmm. In both cases we should end up with apic == apic_noop() so any access
to the apic should not result in a panic. I'll have a look.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: 4.8.2 not booting in 32-bit VM without I/O-APIC
@ 2016-10-28 18:52 Michal Necasek
  2016-10-28 19:00 ` Thomas Gleixner
  0 siblings, 1 reply; 9+ messages in thread
From: Michal Necasek @ 2016-10-28 18:52 UTC (permalink / raw)
  To: tglx
  Cc: prarit, ville.syrjala, michael.thayer, knut.osmundsen,
	frank.mehnert, linux-kernel


     Hi Thomas,

 Sorry if I wasn't clear. No, it doesn't work for us. The ff8560512b8d commit fixes the APIC poking on machines where there is no local APIC available (and thus fixes the committer's machine), but it doesn't work in our case, where there is a local APIC but no I/O APIC, no ACPI MADT, and no MP tables. 

 In other words, for us boot_cpu_has(X86_FEATURE_APIC) is true but the APIC has not been set up yet because init_apic_mappings() hasn't been run.


    Regards,
       Michal

----- Original Message -----
From: tglx@linutronix.de
To: michal.necasek@oracle.com
Cc: linux-kernel@vger.kernel.org, prarit@redhat.com, ville.syrjala@linux.intel.com, michael.thayer@oracle.com, frank.mehnert@oracle.com, knut.osmundsen@oracle.com
Sent: Friday, October 28, 2016 8:41:46 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: Re: 4.8.2 not booting in 32-bit VM without I/O-APIC

On Fri, 28 Oct 2016, Michal Necasek wrote: 

> I suspect that either init_apic_mappings() needs to be called earlier or
> the initial fix from commit 2a51fe08 needs to be done later.

Linus tree has a fix for this:

ff8560512b8d x86/boot/smp: Don't try to poke disabled/non-existent APIC

It's on the way to stable as well. Can you try whether that works for you?

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: 4.8.2 not booting in 32-bit VM without I/O-APIC
@ 2016-11-03 20:02 Michal Necasek
  2016-11-10 14:21 ` Michael Thayer
  0 siblings, 1 reply; 9+ messages in thread
From: Michal Necasek @ 2016-11-03 20:02 UTC (permalink / raw)
  To: tglx
  Cc: prarit, ville.syrjala, michael.thayer, frank.mehnert,
	knut.osmundsen, linux-kernel


    Hi Thomas,

 Sorry for the delay. I can confirm that the problem is fixed in 4.9.0-rc3 and prefill_possible_map no longer crashes (as it did in 4.9.0-rc2). Thank you!

 Just a side question, is the previous fix in commit ff8560512b (x86/boot/smp: Don't try to poke disabled/non-existent APIC) actually still required or would the no-op APIC driver take care of it?

    Regards,
      Michal

----- Original Message -----
From: tglx@linutronix.de
To: michal.necasek@oracle.com
Cc: prarit@redhat.com, ville.syrjala@linux.intel.com, michael.thayer@oracle.com, knut.osmundsen@oracle.com, frank.mehnert@oracle.com, linux-kernel@vger.kernel.org
Sent: Friday, October 28, 2016 9:37:31 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: Re: 4.8.2 not booting in 32-bit VM without I/O-APIC

On Fri, 28 Oct 2016, Thomas Gleixner wrote:

> On Fri, 28 Oct 2016, Michal Necasek wrote:
> > 
> >  Sorry if I wasn't clear. No, it doesn't work for us. The ff8560512b8d
> > commit fixes the APIC poking on machines where there is no local APIC
> > available (and thus fixes the committer's machine), but it doesn't work
> > in our case, where there is a local APIC but no I/O APIC, no ACPI MADT,
> > and no MP tables.
> 
> > In other words, for us boot_cpu_has(X86_FEATURE_APIC) is true but the
> > APIC has not been set up yet because init_apic_mappings() hasn't been
> > run.

Right. That mapping setup is an utter trainwreck as we do it from multiple
places, but there is no reason why we can't move it before the call to
prefill_possible_map().

Thanks,

	tglx

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index bbfbca5fea0c..b59fdba3cbdf 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1221,11 +1221,13 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	get_smp_config();
 
+	/* Make sure apic is mapped before prefill_possible_map() */
+	init_apic_mappings();
+
 	prefill_possible_map();
 
 	init_cpu_to_node();
 
-	init_apic_mappings();
 	io_apic_init_mappings();
 
 	kvm_guest_init();

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

end of thread, other threads:[~2016-11-10 17:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-28 18:30 4.8.2 not booting in 32-bit VM without I/O-APIC Michal Necasek
2016-10-28 18:38 ` Thomas Gleixner
2016-10-28 18:52 Michal Necasek
2016-10-28 19:00 ` Thomas Gleixner
2016-10-28 19:34   ` Thomas Gleixner
2016-10-29 10:18     ` Borislav Petkov
2016-11-03 20:02 Michal Necasek
2016-11-10 14:21 ` Michael Thayer
2016-11-10 17:18   ` Thomas Gleixner

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).