From: Michael Schierl <schierlm@gmx.de>
To: Michael Kelley <mhklinux@outlook.com>,
Jean DELVARE <jdelvare@suse.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Early kernel panic in dmi_decode when running 32-bit kernel on Hyper-V on Windows 11
Date: Fri, 19 Apr 2024 22:47:06 +0200 [thread overview]
Message-ID: <938f6eda-f62c-457f-bc42-b2d12fc6e2c7@gmx.de> (raw)
In-Reply-To: <SN6PR02MB415733CB1854317C980C3F18D40D2@SN6PR02MB4157.namprd02.prod.outlook.com>
Hello,
Am 19.04.2024 um 18:36 schrieb Michael Kelley:
>> I still want to understand why 32-bit Linux is taking an oops during
>> boot while 64-bit Linux does not.
>
> The difference is in this statement in dmi_save_devices():
>
> count = (dm->length - sizeof(struct dmi_header)) / 2;
>
> On a 64-bit system, count is 0xFFFFFFFE. That's seen as a
> negative value, and the "for" loop does not do any iterations. So
> nothing bad happens.
>
> But on a 32-bit system, count is 0x7FFFFFFE. That's a big
> positive number, and the "for" loop iterates to non-existent
> memory as Michael Schierl originally described.
>
> I don't know the "C" rules for mixed signed and unsigned
> expressions, and how they differ on 32-bit and 64-bit systems.
> But that's the cause of the different behavior.
Probably lots of implementation defined behaviour here. But when looking
at gcc 12.2 for x86/amd64 architecture (which is the version in Debian),
it is at least apparent from the assembly listing:
https://godbolt.org/z/he7MfcWfE
First of all (this gets me every time): sizeof(int) is 4 on both 32-and
64-bit, unlike sizeof(uintptr_t), which is 8 on 64-bit.
Both 32-bit and 64-bit versions zero-extend the value of dm->length from
8 bits to 32 bits (or actually native bitlength as the upper 32 bits of
rax get set to zero whenever eax is assigned), and then the subtraction
and shifting (division) happen as native unsigend type, taking only the
lowest 32 bits of the result as value for count. In the 64-bit case one
of the extra leading 1 bits from the subtraction gets shifted into the
MSB of the result, while in the 32-bit case it remains empty.
When using long instead of int (64-bit signed integer, as I assumed when
looking at the code for the first time), the result would be
0x7FFF_FFFF_FFFF_FFFE on 64-bits, as no truncations happens, and the
behavior would be the same. This clearly shows that I am mentally still
in the 32-bit era, perhaps that explains why I like 32-bit kernels over
64-bit ones so much :D
> Regardless of the 32-bit vs. 64-bit behavior, the DMI blob is malformed,
> almost certainly as created by Hyper-V. I'll see if I can bring this to
> the attention of one of my previous contacts on the Hyper-V team.
Thanks,
Michael
next prev parent reply other threads:[~2024-04-19 20:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-13 13:06 Early kernel panic in dmi_decode when running 32-bit kernel on Hyper-V on Windows 11 Michael Schierl
2024-04-15 3:17 ` Michael Kelley
2024-04-15 21:03 ` Michael Schierl
2024-04-15 23:31 ` Michael Kelley
2024-04-16 21:24 ` Michael Schierl
2024-04-16 23:20 ` Michael Kelley
2024-04-17 9:43 ` Jean DELVARE
2024-04-17 15:51 ` Michael Kelley
2024-04-17 21:08 ` Michael Schierl
2024-04-17 22:34 ` Michael Kelley
2024-04-19 16:36 ` Michael Kelley
2024-04-19 20:47 ` Michael Schierl [this message]
2024-04-19 22:32 ` Michael Kelley
2024-05-02 17:02 ` Michael Kelley
2024-05-03 9:49 ` Jean DELVARE
2024-04-15 20:15 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=938f6eda-f62c-457f-bc42-b2d12fc6e2c7@gmx.de \
--to=schierlm@gmx.de \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=jdelvare@suse.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhklinux@outlook.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox