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]
Date:   Thu, 14 Jul 2022 19:12:00 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Linus Torvalds <torvalds@...ux-foundation.org>,
        Boris Petkov <bp@...en8.de>
Cc:     Guenter Roeck <linux@...ck-us.net>,
        Peter Zijlstra <peterz@...radead.org>,
        Thadeu Lima de Souza Cascardo <cascardo@...onical.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Naresh Kamboju <naresh.kamboju@...aro.org>,
        Florian Fainelli <f.fainelli@...il.com>,
        kvm list <kvm@...r.kernel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        stable <stable@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Pavel Machek <pavel@...x.de>,
        Jon Hunter <jonathanh@...dia.com>,
        Sudip Mukherjee <sudipm.mukherjee@...il.com>,
        Slade Watkins <slade@...dewatkins.com>, patches@...nelci.org,
        Sean Christopherson <seanjc@...gle.com>,
        Shuah Khan <shuah@...nel.org>, Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>, X86 ML <x86@...nel.org>,
        lkft-triage@...ts.linaro.org,
        Alex Bennée <alex.bennee@...aro.org>,
        "H. Peter Anvin" <hpa@...or.com>,
        Anders Roxell <anders.roxell@...aro.org>
Subject: Re: [PATCH 5.15 00/78] 5.15.55-rc1 review

On 7/14/22 19:02, Linus Torvalds wrote:
> And guess what? The code could just use roundup_pow_of_two(), which is
> designed exactly like ilog2() to be used for compile-time constant
> values.
> 
> So the code should just use
> 
>      #define FASTOP_SIZE roundup_pow_of_two(FASTOP_LENGTH)
> 
> and be a lot more legible, wouldn't it?
> 
> Because I don't think there is anything magical about the length
> "8/16/32". It's purely "aligned and big enough to contain
> FASTOP_LENGTH".

roundup_pow_of_two unfortunately is not enough for stringizing 
FASTOP_SIZE into an asm statement. :(

	#define __FOP_FUNC(name) \
	        ".align " __stringify(FASTOP_SIZE) " \n\t" \
	        ".type " name ", @function \n\t" \
	        name ":\n\t" \
	        ASM_ENDBR

The shifts are what we came up with for the SETCC thunks when ENDBR and 
SLS made them grew beyond 4 bytes; Peter's patch is reusing the trick 
for the fastop thunks.

> Because I don't think there is anything magical about the length
> "8/16/32". It's purely "aligned and big enough to contain
> FASTOP_LENGTH".

I agree with that, it's only limited to 8/16/32 to keep the macro to a 
decent size.

> And then the point of that
> 
>     static_assert(FASTOP_LENGTH <= FASTOP_SIZE);
> 
> just goes away, because there are no subtle math issues there any more.
> 
> In fact, the remaining question is just "where did the 7 come from" in
> 
>     #define FASTOP_LENGTH (7 + ENDBR_INSN_SIZE + RET_LENGTH)

The 7 is an upper limit to the length of the code between endbr and ret.
There's no particular reason to limit to 7, but it allows using an 
alignment of 8 in the smallest case (no thunks, no SLS, no endbr) where 
you just have ".align 8; ...; ret".

Paolo

Powered by blists - more mailing lists