Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Bernhard Kaindl <bk@suse.de>, Andi Kleen <ak@linux.intel.com>
Cc: Li Fei <fei1.li@intel.com>,
	Jiaqing Zhao <jiaqing.zhao@linux.intel.com>,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86/mtrr: Check if fixed-range MTRR exists in `mtrr_save_fixed_ranges`
Date: Fri,  9 May 2025 08:56:12 +0000	[thread overview]
Message-ID: <20250509085612.2236222-2-jiaqing.zhao@linux.intel.com> (raw)

When suspending, `save_processor_state` calls `mtrr_save_fixed_ranges`
to save fixed-range MTRRs. On platforms without MTRR or fixed-range
MTRR support, accessing MTRR MSRs triggers unchecked MSR access error.
Make sure fixed-range MTRR is supported before access to prevent such
error.

Fixes: 3ebad5905609 ("[PATCH] x86: Save and restore the fixed-range MTRRs of the BSP when suspending")
Cc: stable@vger.kernel.org
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
---
 arch/x86/kernel/cpu/mtrr/generic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c
index e2c6b471d230..ca37b374d1b0 100644
--- a/arch/x86/kernel/cpu/mtrr/generic.c
+++ b/arch/x86/kernel/cpu/mtrr/generic.c
@@ -593,7 +593,7 @@ static void get_fixed_ranges(mtrr_type *frs)
 
 void mtrr_save_fixed_ranges(void *info)
 {
-	if (boot_cpu_has(X86_FEATURE_MTRR))
+	if (boot_cpu_has(X86_FEATURE_MTRR) && mtrr_state.have_fixed)
 		get_fixed_ranges(mtrr_state.fixed_ranges);
 }
 
-- 
2.43.0


             reply	other threads:[~2025-05-09  8:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-09  8:56 Jiaqing Zhao [this message]
2025-05-09 10:44 ` [PATCH] x86/mtrr: Check if fixed-range MTRR exists in `mtrr_save_fixed_ranges` Borislav Petkov

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=20250509085612.2236222-2-jiaqing.zhao@linux.intel.com \
    --to=jiaqing.zhao@linux.intel.com \
    --cc=ak@linux.intel.com \
    --cc=bk@suse.de \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fei1.li@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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