[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<SN6PR02MB4157DEDFD687C0EF20A2864DD49FA@SN6PR02MB4157.namprd02.prod.outlook.com>
Date: Tue, 20 May 2025 15:27:01 +0000
From: Michael Kelley <mhklinux@...look.com>
To: Peter Zijlstra <peterz@...radead.org>, "x86@...nel.org" <x86@...nel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kys@...rosoft.com" <kys@...rosoft.com>, "haiyangz@...rosoft.com"
<haiyangz@...rosoft.com>, "wei.liu@...nel.org" <wei.liu@...nel.org>,
"decui@...rosoft.com" <decui@...rosoft.com>, "tglx@...utronix.de"
<tglx@...utronix.de>, "mingo@...hat.com" <mingo@...hat.com>, "bp@...en8.de"
<bp@...en8.de>, "dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"hpa@...or.com" <hpa@...or.com>, "luto@...nel.org" <luto@...nel.org>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>
Subject: RE: [PATCH 1/3] x86/mm: Unexport tlb_state_shared
From: Peter Zijlstra <peterz@...radead.org> Sent: Tuesday, May 20, 2025 3:56 AM
>
> Never export data; modules have no business being able to change tlb
> state.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> ---
> arch/x86/hyperv/mmu.c | 9 ++-------
> arch/x86/include/asm/tlbflush.h | 2 ++
> arch/x86/mm/tlb.c | 7 ++++++-
> 3 files changed, 10 insertions(+), 8 deletions(-)
>
> --- a/arch/x86/hyperv/mmu.c
> +++ b/arch/x86/hyperv/mmu.c
> @@ -51,11 +51,6 @@ static inline int fill_gva_list(u64 gva_
> return gva_n - offset;
> }
>
> -static bool cpu_is_lazy(int cpu)
> -{
> - return per_cpu(cpu_tlbstate_shared.is_lazy, cpu);
> -}
> -
> static void hyperv_flush_tlb_multi(const struct cpumask *cpus,
> const struct flush_tlb_info *info)
> {
> @@ -113,7 +108,7 @@ static void hyperv_flush_tlb_multi(const
> goto do_ex_hypercall;
>
> for_each_cpu(cpu, cpus) {
> - if (do_lazy && cpu_is_lazy(cpu))
> + if (do_lazy && cpu_tlbstate_is_lazy(cpu))
> continue;
> vcpu = hv_cpu_number_to_vp_number(cpu);
> if (vcpu == VP_INVAL) {
> @@ -198,7 +193,7 @@ static u64 hyperv_flush_tlb_others_ex(co
>
> flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K;
> nr_bank = cpumask_to_vpset_skip(&flush->hv_vp_set, cpus,
> - info->freed_tables ? NULL : cpu_is_lazy);
> + info->freed_tables ? NULL : cpu_tlbstate_is_lazy);
> if (nr_bank < 0)
> return HV_STATUS_INVALID_PARAMETER;
>
> --- a/arch/x86/include/asm/tlbflush.h
> +++ b/arch/x86/include/asm/tlbflush.h
> @@ -172,6 +172,8 @@ struct tlb_state_shared {
> };
> DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state_shared, cpu_tlbstate_shared);
>
> +bool cpu_tlbstate_is_lazy(int cpu);
> +
> bool nmi_uaccess_okay(void);
> #define nmi_uaccess_okay nmi_uaccess_okay
>
> --- a/arch/x86/mm/tlb.c
> +++ b/arch/x86/mm/tlb.c
> @@ -1322,7 +1322,12 @@ static bool should_trim_cpumask(struct m
> }
>
> DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state_shared, cpu_tlbstate_shared);
> -EXPORT_PER_CPU_SYMBOL(cpu_tlbstate_shared);
FWIW, this EXPORT wasn't there for Hyper-V code. The EXPORT was
added in commit 2f4305b19fe6a, and it's not clear why. That commit
was 2 years before the Hyper-V MMU code started checking the lazy
flag.
> +
> +bool cpu_tlbstate_is_lazy(int cpu)
> +{
> + return per_cpu(cpu_tlbstate_shared.is_lazy, cpu);
> +}
> +EXPORT_SYMBOL_GPL(cpu_tlbstate_is_lazy);
This EXPORT isn't needed for Hyper-V. The Hyper-V MMU code is
never built as a module, even if CONFIG_HYPERV=m. And I can't
see any other reason the EXPORT would be needed.
In any case,
Reviewed-by: Michael Kelley <mhklinux@...look.com>
>
> STATIC_NOPV void native_flush_tlb_multi(const struct cpumask *cpumask,
> const struct flush_tlb_info *info)
>
>
Powered by blists - more mailing lists