]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/mtrr: Check if fixed-range MTRRs exist in mtrr_save_fixed_ranges()
authorJiaqing Zhao <jiaqing.zhao@linux.intel.com>
Fri, 9 May 2025 17:06:33 +0000 (17:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:05:10 +0000 (11:05 +0100)
commit92322500c1aa1b55d3e2ecaffef344977bdc2fcc
treead44a765be8b65661c7f80c453e435817a8f2c89
parent3319b48d1ba2d60a31d7f034669d5ccf8d6aefbc
x86/mtrr: Check if fixed-range MTRRs exist in mtrr_save_fixed_ranges()

[ Upstream commit 824c6384e8d9275d4ec7204f3f79a4ac6bc10379 ]

When suspending, save_processor_state() calls mtrr_save_fixed_ranges()
to save fixed-range MTRRs.

On platforms without fixed-range MTRRs like the ACRN hypervisor which
has removed fixed-range MTRR emulation, accessing these MSRs will
trigger an unchecked MSR access error. Make sure fixed-range MTRRs are
supported before access to prevent such error.

Since mtrr_state.have_fixed is only set when MTRRs are present and
enabled, checking the CPU feature flag in mtrr_save_fixed_ranges() is
unnecessary.

Fixes: 3ebad5905609 ("[PATCH] x86: Save and restore the fixed-range MTRRs of the BSP when suspending")
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/20250509170633.3411169-2-jiaqing.zhao@linux.intel.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kernel/cpu/mtrr/generic.c