[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5e75d8ed-6950-1c16-02eb-1894b90bfffc@suse.com>
Date: Wed, 12 Apr 2023 12:25:01 +0200
From: Juergen Gross <jgross@...e.com>
To: Borislav Petkov <bp@...en8.de>
Cc: linux-kernel@...r.kernel.org, x86@...nel.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Michael Kelley <mikelley@...rosoft.com>
Subject: Re: [PATCH v5 07/15] x86/mtrr: replace vendor tests in MTRR code
On 12.04.23 10:45, Borislav Petkov wrote:
> On Sat, Apr 01, 2023 at 08:36:44AM +0200, Juergen Gross wrote:
>> Modern CPUs all share the same MTRR interface implemented via
>> generic_mtrr_ops.
>>
>> At several places in MTRR code this generic interface is deduced via
>> is_cpu(INTEL) tests, which is only working due to X86_VENDOR_INTEL
>> being 0 (the is_cpu() macro is testing mtrr_if->vendor, which isn't
>> explicitly set in generic_mtrr_ops).
>>
>> Fix that by replacing the is_cpu(INTEL) tests with testing for mtrr_if
>> to be &generic_mtrr_ops.
>
> Replace with:
>
> "Test the generic CPU feature X86_FEATURE_MTRR instead."
>
>> diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c
>> index 1c19d67ddab3..46aae69d259e 100644
>> --- a/arch/x86/kernel/cpu/mtrr/mtrr.c
>> +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c
>> @@ -108,14 +108,12 @@ static int have_wrcomb(void)
>> /* This function returns the number of variable MTRRs */
>> static void __init set_num_var_ranges(bool use_generic)
>> {
>> - unsigned long config = 0, dummy;
>> + unsigned long config, dummy;
>>
>> if (use_generic)
>> rdmsr(MSR_MTRRcap, config, dummy);
>> - else if (is_cpu(AMD) || is_cpu(HYGON))
>> - config = 2;
>> - else if (is_cpu(CYRIX) || is_cpu(CENTAUR))
>> - config = 8;
>> + else
>> + config = mtrr_if->var_regs;
>>
>> num_var_ranges = config & MTRR_CONFIG_NUM_VAR_MASK;
>> }
>
> From previous review which you've missed to incorporate:
>
> "Since you're touching this function, you might simply expand its body in
> its only call site in mtrr_bp_init(), put a comment above the expanded
> code and remove that function.
>
> That is, if we're going to do the ->var_regs thing."
>
Oh, sorry. Will do it.
Juergen
Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3099 bytes)
Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)
Powered by blists - more mailing lists