public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roman Kisel <romank@linux.microsoft.com>
To: hpa@zytor.com
Cc: akpm@linux-foundation.org, apais@microsoft.com,
	benhill@microsoft.com, bhe@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, kai.huang@intel.com,
	kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org,
	mingo@redhat.com, pbonzini@redhat.com,
	romank@linux.microsoft.com, ssengar@microsoft.com,
	sunilmut@microsoft.com, tglx@linutronix.de, vdso@hexbites.dev,
	x86@kernel.org
Subject: Re: [PATCH] x86/reboot: Don't corrupt memory on non-BIOS systems
Date: Fri, 10 Jan 2025 12:51:30 -0800	[thread overview]
Message-ID: <20250110205130.49354-1-romank@linux.microsoft.com> (raw)
In-Reply-To: <35864797-77DF-434C-A912-F4B5FA03E863@zytor.com>

On Thu, 09 Jan 2025 19:23:31 -0800, H. Peter Anvin <hpa@zytor.com> wrote:

[...]

>Which system have you seen where this "corrupts" memory?

These are X86_64 systems that boot off of confguration in DeviceTree,
and neither ACPI, BIOS, nor UEFI are present. The processors start running
in the long mode right off the bat, and the physical memory below 4GiB
is non-RAM or reserved. The systems are virtual machines.

All that makes `*((unsigned short *)__va(0x472)) = mode;` constitue a
stray write and effectively corrupt contents at the address of 0x472
for these virtual systems.

On the physical systems I have had access to, 0x0..0x1000 seems to be
reported as reserved in E820 or UEFI memory map, and that's what the
CPU might need in the 16-bit mode for the brief times it might be used.

Perhaps, `native_machine_emergency_restart` being tailored to the quirks
of the physical hardware cannot absorb some condition around 
`*((unsigned short *)__va(0x472)) = mode;` to make sure it is fine
to write at that address? In the light of that, the callback
`machine_ops.emergency_restart` looks as a safer option.

  reply	other threads:[~2025-01-10 20:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-09 20:43 [PATCH] x86/reboot: Don't corrupt memory on non-BIOS systems Roman Kisel
2025-01-10  3:23 ` H. Peter Anvin
2025-01-10 20:51   ` Roman Kisel [this message]
2025-01-10  3:25 ` H. Peter Anvin
2025-01-10 21:05   ` Roman Kisel
2025-02-25 20:25 ` Ingo Molnar
2025-02-25 20:28   ` H. Peter Anvin
2025-02-25 20:39     ` Ingo Molnar
2025-02-25 20:46       ` H. Peter Anvin

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=20250110205130.49354-1-romank@linux.microsoft.com \
    --to=romank@linux.microsoft.com \
    --cc=akpm@linux-foundation.org \
    --cc=apais@microsoft.com \
    --cc=benhill@microsoft.com \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kai.huang@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=ssengar@microsoft.com \
    --cc=sunilmut@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=vdso@hexbites.dev \
    --cc=x86@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