From nobody Mon Feb 9 07:19:34 2026 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 940312F43 for ; Thu, 9 Jan 2025 20:43:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736455435; cv=none; b=VfEHizWXCZywbg7VJH1XkE+UgPg5er23QBr/YPYOCTWEuMJKR8BaG2CD9V27oRjgb2/6alMV2rUw7ex3fYhwq+S61gu4SESzVsjqP7s4oAeoWmtGXnemeWo8x84AVaLo5HOGvs0KW7ddEK4LQZOR5T1foEnLSyWm4nwFHxVaqC4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736455435; c=relaxed/simple; bh=dCnZfNZez7KZRO+hgUDSNaCg6a2wlXCDgC20aEPvL0U=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=M284Y1vMYpNa9PhACJSV/FgD16qjuRDE/90oqFcgVpjAr+RUlXP5/nLte7koNbZCXCksKfINofPJgmrP1FvCCGMR3sRS33UfcH33TkyyXQOqP61aDms7YQuI31eUc8KZPH6qohrAmjopSC5W0Bj1ndJwxlA7Hc6EXMVnRktDldY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=r9UD/Hxf; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="r9UD/Hxf" Received: from romank-3650.corp.microsoft.com (unknown [131.107.160.188]) by linux.microsoft.com (Postfix) with ESMTPSA id E9088203E3A0; Thu, 9 Jan 2025 12:43:53 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E9088203E3A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1736455434; bh=DNtiKUrg2I8eMiYBTAfCC4kQ4CcsXP5QSfLW9XAHSt4=; h=From:To:Cc:Subject:Date:From; b=r9UD/HxfPsSh+XMCNN7ZcrEvhQRQyLX5hHaQlQ7aW/Mzed3QM1HwLILDvPAmsux0F Y1gFJgtKCkTsHXcnf+GxR3fDDi8zORmbPo/BP286EfwPSWlF8oV7t0vnmqjJZ9Y8xY c/BTVvLqYpgLgmhqhQII+z0tEDR4ZhPljdCTIwgg= From: Roman Kisel To: akpm@linux-foundation.org, bhe@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, kai.huang@intel.com, kirill.shutemov@linux.intel.com, mingo@redhat.com, pbonzini@redhat.com, tglx@linutronix.de, x86@kernel.org, linux-kernel@vger.kernel.org Cc: apais@microsoft.com, benhill@microsoft.com, ssengar@microsoft.com, sunilmut@microsoft.com, vdso@hexbites.dev Subject: [PATCH] x86/reboot: Don't corrupt memory on non-BIOS systems Date: Thu, 9 Jan 2025 12:43:52 -0800 Message-Id: <20250109204352.1720337-1-romank@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" native_machine_emergency_restart() writes unconditionally to the physical address of 0x472 to pass the warm reboot flags to BIOS. The BIOS reads this on booting to bypass memory test and do the warm boot. On the non-BIOS systems, other means have to be employed, and this write is a memory corruption. Fix that by moving the offending write into the case where the machine is rebooted via BIOS. Signed-off-by: Roman Kisel --- arch/x86/kernel/reboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 615922838c51..6eec8653493f 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c @@ -637,9 +637,8 @@ static void native_machine_emergency_restart(void) =20 tboot_shutdown(TB_SHUTDOWN_REBOOT); =20 - /* Tell the BIOS if we want cold or warm reboot */ + /* Tell the firmware if we want cold or warm reboot */ mode =3D reboot_mode =3D=3D REBOOT_WARM ? 0x1234 : 0; - *((unsigned short *)__va(0x472)) =3D mode; =20 /* * If an EFI capsule has been registered with the firmware then @@ -681,6 +680,7 @@ static void native_machine_emergency_restart(void) break; =20 case BOOT_BIOS: + *((unsigned short *)__va(0x472)) =3D mode; machine_real_restart(MRR_BIOS); =20 /* We're probably dead after this, but... */ base-commit: eea6e4b4dfb8859446177c32961c96726d0117be --=20 2.34.1