2021-03-27 20:41:36

by Mateusz Jończyk

[permalink] [raw]
Subject: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

Hello,

There are some netbooks with Intel Atom processors that have 64-bit
support disabled by BIOS. Theoretically, the processor supports 64-bit
operation, but BIOS allows only 32-bit code to run.

I wonder whether the 64-bit mode is really disabled in the CPU or only
hidden in the CPUID flags. If the latter, the computer could be made to
run a 64-bit kernel.

Similarly, there are some Pentium M processors that support PAE
(Physical Address Extensions), but do not show this in CPUID. They could
be made to run distributions that require PAE with the "forcepae" kernel
command line parameter.

I would like to ask people with such netbooks to try to run a 64-bit kernel
with this patch applied.

When a patched 64-bit kernel is run in `qemu-system-i386`, the virtual
machine restarts instantly. Without this patch in such a case a 64-bit
kernel hangs indefinitely (inside .Lno_longmode in head_64.S).


CC: Thomas Gleixner <[email protected]>
CC: Ingo Molnar <[email protected]>
CC: Borislav Petkov <[email protected]>
CC: <[email protected]>

Signed-off-by: Mateusz Jończyk <[email protected]>

---
arch/x86/boot/compressed/head_64.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index e94874f4bbc1..23c376d0b221 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -112,7 +112,7 @@ SYM_FUNC_START(startup_32)

call verify_cpu
testl %eax, %eax
- jnz .Lno_longmode
+ #jnz .Lno_longmode

/*
* Compute the delta between where we were compiled to run at
--
2.25.1


2021-03-27 21:15:15

by Mateusz Jończyk

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

W dniu 27.03.2021 o 21:32, Mateusz Jończyk pisze:
> Hello,
>
> There are some netbooks with Intel Atom processors that have 64-bit
> support disabled by BIOS. Theoretically, the processor supports 64-bit
> operation, but BIOS allows only 32-bit code to run.
>
> I wonder whether the 64-bit mode is really disabled in the CPU or only
> hidden in the CPUID flags. If the latter, the computer could be made to
> run a 64-bit kernel.
>
> Similarly, there are some Pentium M processors that support PAE
> (Physical Address Extensions), but do not show this in CPUID. They could
> be made to run distributions that require PAE with the "forcepae" kernel
> command line parameter.
>
> I would like to ask people with such netbooks to try to run a 64-bit kernel
> with this patch applied.
>
> When a patched 64-bit kernel is run in `qemu-system-i386`, the virtual
> machine restarts instantly. Without this patch in such a case a 64-bit
> kernel hangs indefinitely (inside .Lno_longmode in head_64.S).

I have made two mistakes:
- I left commented out code,
- I have commented out lines with '#'. The code compiled though.

Attaching corrected patch, please excuse me.

Greetings,
Mateusz

Signed-off-by: Mateusz Jończyk <[email protected]>

---
arch/x86/boot/compressed/head_64.S | 2 --
1 file changed, 2 deletions(-)

diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
index e94874f4bbc1..a9f0415da7c2 100644
--- a/arch/x86/boot/compressed/head_64.S
+++ b/arch/x86/boot/compressed/head_64.S
@@ -111,8 +111,6 @@ SYM_FUNC_START(startup_32)
leal rva(boot_stack_end)(%ebp), %esp

call verify_cpu
- testl %eax, %eax
- jnz .Lno_longmode

/*
* Compute the delta between where we were compiled to run at
--
2.25.1

2021-03-27 23:28:51

by Willy Tarreau

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

Hi,

On Sat, Mar 27, 2021 at 10:13:22PM +0100, Mateusz Jonczyk wrote:
> W dniu 27.03.2021 o 21:32, Mateusz Jonczyk pisze:
> > Hello,
> >
> > There are some netbooks with Intel Atom processors that have 64-bit
> > support disabled by BIOS. Theoretically, the processor supports 64-bit
> > operation, but BIOS allows only 32-bit code to run.
> >
> > I wonder whether the 64-bit mode is really disabled in the CPU or only
> > hidden in the CPUID flags. If the latter, the computer could be made to
> > run a 64-bit kernel.
> >
> > Similarly, there are some Pentium M processors that support PAE
> > (Physical Address Extensions), but do not show this in CPUID. They could
> > be made to run distributions that require PAE with the "forcepae" kernel
> > command line parameter.
> >
> > I would like to ask people with such netbooks to try to run a 64-bit kernel
> > with this patch applied.
> >
> > When a patched 64-bit kernel is run in `qemu-system-i386`, the virtual
> > machine restarts instantly. Without this patch in such a case a 64-bit
> > kernel hangs indefinitely (inside .Lno_longmode in head_64.S).
>
> I have made two mistakes:
> - I left commented out code,
> - I have commented out lines with '#'. The code compiled though.
>
> Attaching corrected patch, please excuse me.

FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
32-bit. I had already tried in the past but wanted to give it a try
again in case I'd have missed anything. Sadly it didn't work, I'm
still getting the "requires an x86-64 CPU" message.

Given these machines were really cheap, I've always suspected that they
employ cheaper, low-grade CPUs, possibly having been subject to reduced
tests where x86_64-specific parts were not even verified and might be
defective. This may explain why they forcefully disable long mode there,
but that's just speculation.

Cheers,
Willy

2021-03-28 01:22:05

by Thomas Gleixner

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

On Sun, Mar 28 2021 at 00:25, Willy Tarreau wrote:
> On Sat, Mar 27, 2021 at 10:13:22PM +0100, Mateusz Jonczyk wrote:
> FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
> 32-bit. I had already tried in the past but wanted to give it a try
> again in case I'd have missed anything. Sadly it didn't work, I'm
> still getting the "requires an x86-64 CPU" message.
>
> Given these machines were really cheap, I've always suspected that they
> employ cheaper, low-grade CPUs, possibly having been subject to reduced
> tests where x86_64-specific parts were not even verified and might be
> defective. This may explain why they forcefully disable long mode there,
> but that's just speculation.

There are some of these '32bit only' CPUs out there in the wild which
actually support long mode. Some of them even do not have the long mode
CPUID bit fused out. But whether it works is a different story:

- If the CPUID bit is on, then the chance is high, but it runs out of
spec (guarantee wise)

- If it's off is still might work by some definition of work as they
might have fused off more or there are actual defects in some 64bit
only area which are irrelevant when in 32bit mode.

Even if it could work perfectly fine, the BIOS/SMM/ucode can prevent
switching to long mode.

It's a lost cause.

Thanks,

tglx

2021-03-28 06:22:41

by Willy Tarreau

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

Hi Thomas,

On Sun, Mar 28, 2021 at 03:07:24AM +0200, Thomas Gleixner wrote:
> On Sun, Mar 28 2021 at 00:25, Willy Tarreau wrote:
> > On Sat, Mar 27, 2021 at 10:13:22PM +0100, Mateusz Jonczyk wrote:
> > FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
> > 32-bit. I had already tried in the past but wanted to give it a try
> > again in case I'd have missed anything. Sadly it didn't work, I'm
> > still getting the "requires an x86-64 CPU" message.
> >
> > Given these machines were really cheap, I've always suspected that they
> > employ cheaper, low-grade CPUs, possibly having been subject to reduced
> > tests where x86_64-specific parts were not even verified and might be
> > defective. This may explain why they forcefully disable long mode there,
> > but that's just speculation.
>
> There are some of these '32bit only' CPUs out there in the wild which
> actually support long mode. Some of them even do not have the long mode
> CPUID bit fused out.

Yes, I'm aware of this as well. We might even have talked to the same
"victim" :-)

> But whether it works is a different story:
>
> - If the CPUID bit is on, then the chance is high, but it runs out of
> spec (guarantee wise)
>
> - If it's off is still might work by some definition of work as they
> might have fused off more or there are actual defects in some 64bit
> only area which are irrelevant when in 32bit mode.
>
> Even if it could work perfectly fine, the BIOS/SMM/ucode can prevent
> switching to long mode.
>
> It's a lost cause.

I agree. While I bought this netbook to have a 64-bit CPU and was extremely
disappointed, after seeing that it was not just a matter of "oops we forgot
to enable LM", I concluded that it was pointless to try to go further, as I
would never trust it anyway.

Cheers,
Willy

2021-03-28 12:39:54

by Mateusz Jończyk

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

W dniu 28.03.2021 o 00:25, Willy Tarreau pisze:
> FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
> 32-bit. I had already tried in the past but wanted to give it a try
> again in case I'd have missed anything. Sadly it didn't work, I'm
> still getting the "requires an x86-64 CPU" message.

Thank you. It looks like your bootloader uses the 16-bit kernel boot protocol.
The 16-bit kernel boot code checks for x86_64 presence with a similar message (
inside arch/x86/boot/cpu.c ), which I did not patch out. If you would like to
test again, use the same patched kernel, but change in GRUB: "linux16" to
"linux" and "initrd16" to "initrd" to use the 32-bit boot protocol. Which
distribution and bootloader do you use?

W dniu 28.03.2021 o 03:07, Thomas Gleixner pisze:
> There are some of these '32bit only' CPUs out there in the wild which
> actually support long mode. Some of them even do not have the long mode
> CPUID bit fused out. But whether it works is a different story:
>
>   - If the CPUID bit is on, then the chance is high, but it runs out of
>     spec (guarantee wise)
>
>   - If it's off is still might work by some definition of work as they
>     might have fused off more or there are actual defects in some 64bit
>     only area which are irrelevant when in 32bit mode.

Of course, force enabling x86_64 would require passing a kernel command line
parameter with a prominent warning in documentation, just like with "forcepae".

Greetings,
Mateusz

2021-03-28 13:40:41

by Willy Tarreau

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

On Sun, Mar 28, 2021 at 02:37:55PM +0200, Mateusz Jonczyk wrote:
> W dniu 28.03.2021 o?00:25, Willy Tarreau pisze:
> > FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
> > 32-bit. I had already tried in the past but wanted to give it a try
> > again in case I'd have missed anything. Sadly it didn't work, I'm
> > still getting the "requires an x86-64 CPU" message.
>
> Thank you. It looks like your bootloader uses the 16-bit kernel boot
> protocol. The 16-bit kernel boot code checks for x86_64 presence with a
> similar message ( inside arch/x86/boot/cpu.c ), which I did not patch out.
> If you would like to test again, use the same patched kernel, but change in
> GRUB: "linux16" to "linux" and "initrd16" to "initrd" to use the 32-bit boot
> protocol. Which distribution and bootloader do you use?

I'm using Lilo on an old Slackware. I can patch the 16-bit code myself,
it's no big deal.

> Of course, force enabling x86_64 would require passing a kernel command line
> parameter with a prominent warning in documentation, just like with
> "forcepae".

Sure, but I mean, I suspect that the risk could be higher with very low
priced laptops were crappy chips are to be expected by definition based
on contracts neither you nor me have seen.

I'll try again after patching the 16-bit code, thanks for the suggestion.
Willy

2021-03-28 15:57:00

by Willy Tarreau

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

On Sun, Mar 28, 2021 at 03:30:29PM +0200, Willy Tarreau wrote:
> On Sun, Mar 28, 2021 at 02:37:55PM +0200, Mateusz Jonczyk wrote:
> > W dniu 28.03.2021 o?00:25, Willy Tarreau pisze:
> > > FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
> > > 32-bit. I had already tried in the past but wanted to give it a try
> > > again in case I'd have missed anything. Sadly it didn't work, I'm
> > > still getting the "requires an x86-64 CPU" message.
> >
> > Thank you. It looks like your bootloader uses the 16-bit kernel boot
> > protocol. The 16-bit kernel boot code checks for x86_64 presence with a
> > similar message ( inside arch/x86/boot/cpu.c ), which I did not patch out.
> > If you would like to test again, use the same patched kernel, but change in
> > GRUB: "linux16" to "linux" and "initrd16" to "initrd" to use the 32-bit boot
> > protocol. Which distribution and bootloader do you use?
>
> I'm using Lilo on an old Slackware. I can patch the 16-bit code myself,
> it's no big deal.
>
> > Of course, force enabling x86_64 would require passing a kernel command line
> > parameter with a prominent warning in documentation, just like with
> > "forcepae".
>
> Sure, but I mean, I suspect that the risk could be higher with very low
> priced laptops were crappy chips are to be expected by definition based
> on contracts neither you nor me have seen.
>
> I'll try again after patching the 16-bit code, thanks for the suggestion.

So I added this at the end of get_cpuflags():

set_bit(X86_FEATURE_LM, cpu.flags);

But now it goes further, the screen turns black and after 2 seconds or so
it reboots, it looks like a triple fault late in the init process. No need
to go further on this machine!

Willy

2021-03-28 21:59:55

by Willy Tarreau

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

On Sun, Mar 28, 2021 at 11:14:05PM +0300, Andy Shevchenko wrote:
> On Sunday, March 28, 2021, Willy Tarreau <[email protected]> wrote:
>
> > Hi Thomas,
> >
> > On Sun, Mar 28, 2021 at 03:07:24AM +0200, Thomas Gleixner wrote:
> > > On Sun, Mar 28 2021 at 00:25, Willy Tarreau wrote:
> > > > On Sat, Mar 27, 2021 at 10:13:22PM +0100, Mateusz Jonczyk wrote:
> > > > FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
> > > > 32-bit. I had already tried in the past but wanted to give it a try
> > > > again in case I'd have missed anything. Sadly it didn't work, I'm
> > > > still getting the "requires an x86-64 CPU" message.
> > > >
> > > > Given these machines were really cheap, I've always suspected that they
> > > > employ cheaper, low-grade CPUs, possibly having been subject to reduced
> > > > tests where x86_64-specific parts were not even verified and might be
> > > > defective. This may explain why they forcefully disable long mode
> > there,
> > > > but that's just speculation.
> > >
> > > There are some of these '32bit only' CPUs out there in the wild which
> > > actually support long mode. Some of them even do not have the long mode
> > > CPUID bit fused out.
> >
> > Yes, I'm aware of this as well. We might even have talked to the same
> > "victim" :-)
> >
> > > But whether it works is a different story:
> > >
> > > - If the CPUID bit is on, then the chance is high, but it runs out of
> > > spec (guarantee wise)
> > >
> > > - If it's off is still might work by some definition of work as they
> > > might have fused off more or there are actual defects in some 64bit
> > > only area which are irrelevant when in 32bit mode.
> > >
> > > Even if it could work perfectly fine, the BIOS/SMM/ucode can prevent
> > > switching to long mode.
> > >
> > > It's a lost cause.
> >
> > I agree. While I bought this netbook to have a 64-bit CPU and was extremely
> > disappointed,
>
>
> Where did you get an idea that it had 64-bit SoC from?

It's an N2600, and I bought this laptop because N2600 supports 64-bit
(and do have another mini-itx motherboard at work with the same CPU
on it working pretty well in 64-bit):

https://ark.intel.com/content/www/us/en/ark/products/58916/intel-atom-processor-n2600-1m-cache-1-6-ghz.html

> Atom Based 64-bit ones are Bay Trail, Cherry Trail, Tangier (Merrifield),
> Anniedale (Moorefield) and all based on Skylake family (Apollo Lake,
> Broxton, Gemini Lake, ...).

Well, to be honest, I've never been able to remind (nor sort) all these
totally crazy names. The day someone gives me a mnemotechnic hint to
remind them and their ordering, that will make me reconsider them. For
now they're all "something lake", and I find it particularly difficult
to map them to SKUs.

Cheers,
Willy

2021-03-28 22:20:48

by Thomas Gleixner

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

On Sun, Mar 28 2021 at 23:58, Willy Tarreau wrote:
> On Sun, Mar 28, 2021 at 11:14:05PM +0300, Andy Shevchenko wrote:
>> Where did you get an idea that it had 64-bit SoC from?
>
> It's an N2600, and I bought this laptop because N2600 supports 64-bit
> (and do have another mini-itx motherboard at work with the same CPU
> on it working pretty well in 64-bit):
>
> https://ark.intel.com/content/www/us/en/ark/products/58916/intel-atom-processor-n2600-1m-cache-1-6-ghz.html

I bet that laptop is forced to 32bit via SMM or whatever because IIRC
there was some issue with the graphics drivers for 64 bit windows when
they were hot of the press 10 years ago.

>> Atom Based 64-bit ones are Bay Trail, Cherry Trail, Tangier (Merrifield),
>> Anniedale (Moorefield) and all based on Skylake family (Apollo Lake,
>> Broxton, Gemini Lake, ...).
>
> Well, to be honest, I've never been able to remind (nor sort) all these
> totally crazy names. The day someone gives me a mnemotechnic hint to
> remind them and their ordering, that will make me reconsider them. For
> now they're all "something lake", and I find it particularly difficult
> to map them to SKUs.

It's more than 'lake'. You'd need also a mindmap for trail, ville and
whatever magic endings they have. There is no mnemotechnic hint to map
them into something which makes sense.

I gave up long ago and the only thing I ask for is to provide me the
family/model number instead of the random code name of the day.

Thanks,

tglx

2021-03-29 11:02:14

by Andy Shevchenko

[permalink] [raw]
Subject: Re: Testers wanted: Atom netbooks with x86_64 disabled by BIOS

On Mon, Mar 29, 2021 at 12:58 AM Willy Tarreau <[email protected]> wrote:
>
> On Sun, Mar 28, 2021 at 11:14:05PM +0300, Andy Shevchenko wrote:
> > On Sunday, March 28, 2021, Willy Tarreau <[email protected]> wrote:
> >
> > > Hi Thomas,
> > >
> > > On Sun, Mar 28, 2021 at 03:07:24AM +0200, Thomas Gleixner wrote:
> > > > On Sun, Mar 28 2021 at 00:25, Willy Tarreau wrote:
> > > > > On Sat, Mar 27, 2021 at 10:13:22PM +0100, Mateusz Jonczyk wrote:
> > > > > FWIW I tested on my ASUS 1025C which runs on an Atom N2600 forced to
> > > > > 32-bit. I had already tried in the past but wanted to give it a try
> > > > > again in case I'd have missed anything. Sadly it didn't work, I'm
> > > > > still getting the "requires an x86-64 CPU" message.
> > > > >
> > > > > Given these machines were really cheap, I've always suspected that they
> > > > > employ cheaper, low-grade CPUs, possibly having been subject to reduced
> > > > > tests where x86_64-specific parts were not even verified and might be
> > > > > defective. This may explain why they forcefully disable long mode
> > > there,
> > > > > but that's just speculation.
> > > >
> > > > There are some of these '32bit only' CPUs out there in the wild which
> > > > actually support long mode. Some of them even do not have the long mode
> > > > CPUID bit fused out.
> > >
> > > Yes, I'm aware of this as well. We might even have talked to the same
> > > "victim" :-)
> > >
> > > > But whether it works is a different story:
> > > >
> > > > - If the CPUID bit is on, then the chance is high, but it runs out of
> > > > spec (guarantee wise)
> > > >
> > > > - If it's off is still might work by some definition of work as they
> > > > might have fused off more or there are actual defects in some 64bit
> > > > only area which are irrelevant when in 32bit mode.
> > > >
> > > > Even if it could work perfectly fine, the BIOS/SMM/ucode can prevent
> > > > switching to long mode.
> > > >
> > > > It's a lost cause.
> > >
> > > I agree. While I bought this netbook to have a 64-bit CPU and was extremely
> > > disappointed,
> >
> >
> > Where did you get an idea that it had 64-bit SoC from?
>
> It's an N2600, and I bought this laptop because N2600 supports 64-bit
> (and do have another mini-itx motherboard at work with the same CPU
> on it working pretty well in 64-bit):
>
> https://ark.intel.com/content/www/us/en/ark/products/58916/intel-atom-processor-n2600-1m-cache-1-6-ghz.html

Wow, TIL. :-)

> > Atom Based 64-bit ones are Bay Trail, Cherry Trail, Tangier (Merrifield),
> > Anniedale (Moorefield) and all based on Skylake family (Apollo Lake,
> > Broxton, Gemini Lake, ...).
>
> Well, to be honest, I've never been able to remind (nor sort) all these
> totally crazy names. The day someone gives me a mnemotechnic hint to
> remind them and their ordering, that will make me reconsider them. For
> now they're all "something lake", and I find it particularly difficult
> to map them to SKUs.

It took me a few years to be on trend with those names, that's how
Wikipedia [1] helps.

[1]: https://en.wikipedia.org/wiki/List_of_Intel_Atom_microprocessors

--
With Best Regards,
Andy Shevchenko