From: Borislav Petkov <bp@alien8.de>
To: Juergen Gross <jgross@suse.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH v4 13/16] x86: decouple pat and mtrr handling
Date: Sat, 29 Oct 2022 14:15:03 +0200 [thread overview]
Message-ID: <Y10ZR7KtWTdzl6hm@zn.tnic> (raw)
In-Reply-To: <20221004081023.32402-14-jgross@suse.com>
On Tue, Oct 04, 2022 at 10:10:20AM +0200, Juergen Gross wrote:
> diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
> index 66a209f7eb86..ce1f3246a3e3 100644
> --- a/arch/x86/mm/pat/memtype.c
> +++ b/arch/x86/mm/pat/memtype.c
> @@ -43,6 +43,7 @@
> #include <linux/rbtree.h>
>
> #include <asm/cacheflush.h>
> +#include <asm/cacheinfo.h>
> #include <asm/processor.h>
> #include <asm/tlbflush.h>
> #include <asm/x86_init.h>
> @@ -60,41 +61,34 @@
> #undef pr_fmt
> #define pr_fmt(fmt) "" fmt
>
> -static bool __read_mostly pat_bp_initialized;
> static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
> -static bool __initdata pat_force_disabled = !IS_ENABLED(CONFIG_X86_PAT);
> -static bool __read_mostly pat_bp_enabled;
> -static bool __read_mostly pat_cm_initialized;
> +static u64 __read_mostly pat_msr_val;
__ro_after_init perhaps. Looks like this thing gets set only during CPU
init anyway.
...
> +void __init pat_bp_init(void)
> {
> + struct cpuinfo_x86 *c = &boot_cpu_data;
> u64 pat = 0;
Might as well get rid of that local var and use pat_msr_val directly.
>
> - if (pat_cm_initialized)
> - return;
> +#ifndef CONFIG_X86_PAT
> + pr_info_once("x86/PAT: PAT support disabled because CONFIG_X86_PAT is disabled in the kernel.\n");
> +#endif
if (!IS_ENABLED(CONFIG...))
pr_info_once(..)
and one more ifdeffery is gone.
> - if (boot_cpu_has(X86_FEATURE_PAT)) {
> - /*
> - * CPU supports PAT. Set PAT table to be consistent with
> - * PAT MSR. This case supports "nopat" boot option, and
> - * virtual machine environments which support PAT without
> - * MTRRs. In specific, Xen has unique setup to PAT MSR.
> - *
> - * If PAT MSR returns 0, it is considered invalid and emulates
> - * as No PAT.
> - */
> + if (!boot_cpu_has(X86_FEATURE_PAT))
check_for_deprecated_apis: Warning: arch/x86/mm/pat/memtype.c:265: Do not use boot_cpu_has() - use cpu_feature_enabled() instead.
> + pat_disable("PAT not supported by the CPU.");
> + else
> rdmsrl(MSR_IA32_CR_PAT, pat);
> - }
...
> -void pat_init(void)
> -{
> - u64 pat;
> - struct cpuinfo_x86 *c = &boot_cpu_data;
> -
> -#ifndef CONFIG_X86_PAT
> - pr_info_once("x86/PAT: PAT support disabled because CONFIG_X86_PAT is disabled in the kernel.\n");
> -#endif
> + /* Xen PV doesn't allow to set PAT MSR, but all cache modes are fine. */
... all cache modes are supported" perhaps? "fine" sounds weird here.
> + if (pat_disabled || cpu_feature_enabled(X86_FEATURE_XENPV)) {
> + init_cache_modes(pat);
>
Drop that resulting newline here.
> - if (pat_disabled)
> return;
> + }
>
> if ((c->x86_vendor == X86_VENDOR_INTEL) &&
> (((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2022-10-29 12:15 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-04 8:10 [PATCH v4 00/16] x86: make pat and mtrr independent from each other Juergen Gross
2022-10-04 8:10 ` [PATCH v4 01/16] x86/mtrr: add comment for set_mtrr_state() serialization Juergen Gross
2022-10-04 8:10 ` [PATCH v4 02/16] x86/mtrr: remove unused cyrix_set_all() function Juergen Gross
2022-10-20 14:13 ` [tip: x86/cpu] x86/mtrr: Remove " tip-bot2 for Juergen Gross
2022-10-04 8:10 ` [PATCH v4 03/16] x86/mtrr: replace use_intel() with a local flag Juergen Gross
2022-10-21 17:19 ` Borislav Petkov
2022-10-21 18:05 ` Juergen Gross
2022-10-21 18:10 ` Borislav Petkov
2022-10-04 8:10 ` [PATCH v4 04/16] x86/mtrr: rename prepare_set() and post_set() Juergen Gross
2022-10-04 8:10 ` [PATCH v4 05/16] x86/mtrr: split MTRR specific handling from cache dis/enabling Juergen Gross
2022-10-26 9:24 ` Borislav Petkov
2022-10-26 11:42 ` Juergen Gross
2022-10-04 8:10 ` [PATCH v4 06/16] x86: move some code out of arch/x86/kernel/cpu/mtrr Juergen Gross
2022-10-04 8:10 ` [PATCH v4 07/16] x86/mtrr: split generic_set_all() Juergen Gross
2022-10-26 10:37 ` Borislav Petkov
2022-10-26 11:43 ` Juergen Gross
2022-10-26 12:10 ` Borislav Petkov
2022-10-04 8:10 ` [PATCH v4 08/16] x86/mtrr: remove set_all callback from struct mtrr_ops Juergen Gross
2022-10-27 9:18 ` Borislav Petkov
2022-10-04 8:10 ` [PATCH v4 09/16] x86/mtrr: simplify mtrr_bp_init() Juergen Gross
2022-10-27 9:32 ` Borislav Petkov
2022-10-04 8:10 ` [PATCH v4 10/16] x86/mtrr: get rid of mtrr_enabled bool Juergen Gross
2022-10-04 8:10 ` [PATCH v4 11/16] x86/mtrr: let cache_aps_delayed_init replace mtrr_aps_delayed_init Juergen Gross
2022-10-27 12:18 ` Borislav Petkov
2022-10-27 13:08 ` Juergen Gross
2022-10-04 8:10 ` [PATCH v4 12/16] x86/mtrr: add a stop_machine() handler calling only cache_cpu_init() Juergen Gross
2022-10-29 10:07 ` Borislav Petkov
2022-10-04 8:10 ` [PATCH v4 13/16] x86: decouple pat and mtrr handling Juergen Gross
2022-10-29 12:15 ` Borislav Petkov [this message]
2022-10-04 8:10 ` [PATCH v4 14/16] x86: switch cache_ap_init() to hotplug callback Juergen Gross
2022-10-04 8:10 ` [PATCH v4 15/16] x86: do MTRR/PAT setup on all secondary CPUs in parallel Juergen Gross
2022-10-04 8:10 ` [PATCH v4 16/16] x86/mtrr: simplify mtrr_ops initialization Juergen Gross
2022-10-30 12:06 ` Borislav Petkov
2022-10-30 15:05 ` Juergen Gross
2022-10-30 16:39 ` Borislav Petkov
2022-10-30 17:48 ` Borislav Petkov
2022-11-01 9:48 ` Juergen Gross
2022-11-01 10:02 ` Borislav Petkov
2022-10-19 7:18 ` [PATCH v4 00/16] x86: make pat and mtrr independent from each other Juergen Gross
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=Y10ZR7KtWTdzl6hm@zn.tnic \
--to=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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