lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z-5ytG_1vnf3uj8t@gmail.com>
Date: Thu, 3 Apr 2025 13:36:20 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Borislav Petkov <bp@...nel.org>
Cc: X86 ML <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
	"Borislav Petkov (AMD)" <bp@...en8.de>,
	Rik van Riel <riel@...riel.com>, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] x86/tlb: Simplify choose_new_asid()


* Borislav Petkov <bp@...nel.org> wrote:

> From: "Borislav Petkov (AMD)" <bp@...en8.de>
> 
> Have it return the two things it does return:
> 
>  - a new ASID and
>  - the need to flush the TLB or not,
> 
> in a struct which fits in a single 32-bit register and whack the IO
> parameters.
> 
> No functional changes.
> 
> Signed-off-by: Borislav Petkov (AMD) <bp@...en8.de>
> ---
>  arch/x86/mm/tlb.c | 63 +++++++++++++++++++++++++----------------------
>  1 file changed, 34 insertions(+), 29 deletions(-)
> 
> diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
> index e459d97ef397..d00ae21d0ee2 100644
> --- a/arch/x86/mm/tlb.c
> +++ b/arch/x86/mm/tlb.c
> @@ -215,16 +215,20 @@ static void clear_asid_other(void)
>  
>  atomic64_t last_mm_ctx_id = ATOMIC64_INIT(1);
>  
> +struct new_asid {
> +	unsigned int asid	: 16;
> +	unsigned int need_flush : 1;
> +};
>  
> -static void choose_new_asid(struct mm_struct *next, u64 next_tlb_gen,
> -			    u16 *new_asid, bool *need_flush)
> +static struct new_asid choose_new_asid(struct mm_struct *next, u64 next_tlb_gen)

Nice!!

Note how the cleaned up return signature not only makes the code easier 
to read, but also helps the compiler generate better code:

  # arch/x86/mm/tlb.o:

   text	   data	    bss	    dec	    hex	filename
   9341	    753	    516	  10610	   2972	tlb.o.before
   9213	    753	    516	  10482	   28f2	tlb.o.after

Personally I also like the non-bool new_asid::need_flush easier to read 
in this 'HW interface' context.

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ