2016-10-28 18:53:12

by Michal Necasek

[permalink] [raw]
Subject: Re: 4.8.2 not booting in 32-bit VM without I/O-APIC


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: [email protected]
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
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


2016-10-28 19:02:43

by Thomas Gleixner

[permalink] [raw]
Subject: Re: 4.8.2 not booting in 32-bit VM without I/O-APIC

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.

Gah. Sorry, misunderstood you. Lemme stare in the code.

Thanks,

tglx

2016-10-28 19:37:32

by Thomas Gleixner

[permalink] [raw]
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();

2016-10-29 10:18:18

by Borislav Petkov

[permalink] [raw]
Subject: Re: 4.8.2 not booting in 32-bit VM without I/O-APIC

On Fri, Oct 28, 2016 at 09:34:53PM +0200, Thomas Gleixner wrote:
> 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().

> 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();

FWIW, I got another user's confirmation that this works with his
virtual box:

https://bugzilla.suse.com/show_bug.cgi?id=1006417#c32
https://bugzilla.suse.com/show_bug.cgi?id=1006417#c33

Thanks.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.

Subject: [tip:x86/urgent] x86/smpboot: Init apic mapping before usage

Commit-ID: 0c524f819683e9f1c165d571256a9023b56f1f0c
Gitweb: http://git.kernel.org/tip/0c524f819683e9f1c165d571256a9023b56f1f0c
Author: Thomas Gleixner <[email protected]>
AuthorDate: Sat, 29 Oct 2016 13:42:42 +0200
Committer: Thomas Gleixner <[email protected]>
CommitDate: Sat, 29 Oct 2016 13:58:07 +0200

x86/smpboot: Init apic mapping before usage

The recent changes, which forced the registration of the boot cpu on UP
systems, which do not have ACPI tables, have been fixed for systems w/o
local APIC, but left a wreckage for systems which have neither ACPI nor
mptables, but the CPU has an APIC, e.g. virtualbox.

The boot process crashes in prefill_possible_map() as it wants to register
the boot cpu, which needs to access the local apic, but the local APIC is
not yet mapped.

There is no reason why init_apic_mapping() can't be invoked before
prefill_possible_map(). So instead of playing another silly early mapping
game, as the ACPI/mptables code does, we just move init_apic_mapping()
before the call to prefill_possible_map().

In hindsight, I should have noticed that combination earlier.

Sorry for the churn (also in stable)!

Fixes: ff8560512b8d ("x86/boot/smp: Don't try to poke disabled/non-existent APIC")
Reported-and-debugged-by: Michal Necasek <[email protected]>
Reported-and-tested-by: Wolfgang Bauer <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Borislav Petkov <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1610282114380.5053@nanos
Signed-off-by: Thomas Gleixner <[email protected]>
---
arch/x86/kernel/setup.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index bbfbca5..7be097e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1221,11 +1221,16 @@ void __init setup_arch(char **cmdline_p)
*/
get_smp_config();

+ /*
+ * Systems w/o ACPI and mptables might not have it mapped the local
+ * APIC yet, but it prefill_possible_map() might need to access it.
+ */
+ init_apic_mappings();
+
prefill_possible_map();

init_cpu_to_node();

- init_apic_mappings();
io_apic_init_mappings();

kvm_guest_init();

Subject: [tip:x86/urgent] x86/smpboot: Init apic mapping before usage

Commit-ID: 1e90a13d0c3dc94512af1ccb2b6563e8297838fa
Gitweb: http://git.kernel.org/tip/1e90a13d0c3dc94512af1ccb2b6563e8297838fa
Author: Thomas Gleixner <[email protected]>
AuthorDate: Sat, 29 Oct 2016 13:42:42 +0200
Committer: Thomas Gleixner <[email protected]>
CommitDate: Sat, 29 Oct 2016 14:00:46 +0200

x86/smpboot: Init apic mapping before usage

The recent changes, which forced the registration of the boot cpu on UP
systems, which do not have ACPI tables, have been fixed for systems w/o
local APIC, but left a wreckage for systems which have neither ACPI nor
mptables, but the CPU has an APIC, e.g. virtualbox.

The boot process crashes in prefill_possible_map() as it wants to register
the boot cpu, which needs to access the local apic, but the local APIC is
not yet mapped.

There is no reason why init_apic_mapping() can't be invoked before
prefill_possible_map(). So instead of playing another silly early mapping
game, as the ACPI/mptables code does, we just move init_apic_mapping()
before the call to prefill_possible_map().

In hindsight, I should have noticed that combination earlier.

Sorry for the churn (also in stable)!

Fixes: ff8560512b8d ("x86/boot/smp: Don't try to poke disabled/non-existent APIC")
Reported-and-debugged-by: Michal Necasek <[email protected]>
Reported-and-tested-by: Wolfgang Bauer <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Borislav Petkov <[email protected]>
Cc: [email protected]
Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1610282114380.5053@nanos
Signed-off-by: Thomas Gleixner <[email protected]>
---
arch/x86/kernel/setup.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index bbfbca5..9c337b0 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1221,11 +1221,16 @@ void __init setup_arch(char **cmdline_p)
*/
get_smp_config();

+ /*
+ * Systems w/o ACPI and mptables might not have it mapped the local
+ * APIC yet, but prefill_possible_map() might need to access it.
+ */
+ init_apic_mappings();
+
prefill_possible_map();

init_cpu_to_node();

- init_apic_mappings();
io_apic_init_mappings();

kvm_guest_init();