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: <20231121090041.abqwtkbzzwxq22ke@box.shutemov.name>
Date:   Tue, 21 Nov 2023 12:00:41 +0300
From:   "Kirill A. Shutemov" <kirill@...temov.name>
To:     Uros Bizjak <ubizjak@...il.com>
Cc:     Borislav Petkov <bp@...en8.de>, x86@...nel.org,
        linux-kernel@...r.kernel.org,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...nel.org>,
        "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] x86/mm/encrypt: Use %a asm operand modifier to obtain
 %rip-relative address

On Mon, Nov 20, 2023 at 08:58:29PM +0100, Uros Bizjak wrote:
> On Mon, Nov 20, 2023 at 6:15 PM Borislav Petkov <bp@...en8.de> wrote:
> >
> > On Mon, Nov 20, 2023 at 04:33:50PM +0100, Uros Bizjak wrote:
> > > The "a" asm operand modifier substitutes a memory reference, with the
> > > actual operand treated as address.  For x86_64, when a symbol is
> > > provided, the "a" modifier emits "sym(%rip)" instead of "sym".
> > >
> > > Clang allows only "i" and "r" operand constraints with an "a" modifier,
> > > so the patch normalizes the modifier/constraint pair to "a"/"i"
> >
> > s/the patch normalizes/normalize/
> >
> > > which is consistent between both compilers.
> > >
> > > No functional change intended.
> > >
> > > Suggested-by: Linus Torvalds <torvalds@...ux-foundation.org>
> > > Cc: Dave Hansen <dave.hansen@...ux.intel.com>
> > > Cc: Andy Lutomirski <luto@...nel.org>
> > > Cc: Peter Zijlstra <peterz@...radead.org>
> > > Cc: Thomas Gleixner <tglx@...utronix.de>
> > > Cc: Ingo Molnar <mingo@...nel.org>
> > > Cc: Borislav Petkov <bp@...en8.de>
> > > Cc: "H. Peter Anvin" <hpa@...or.com>
> > > Signed-off-by: Uros Bizjak <ubizjak@...il.com>
> > > ---
> > >  arch/x86/mm/mem_encrypt_identity.c | 16 ++++------------
> > >  1 file changed, 4 insertions(+), 12 deletions(-)
> > >
> > > diff --git a/arch/x86/mm/mem_encrypt_identity.c b/arch/x86/mm/mem_encrypt_identity.c
> > > index d73aeb16417f..6a351fdd1b39 100644
> > > --- a/arch/x86/mm/mem_encrypt_identity.c
> > > +++ b/arch/x86/mm/mem_encrypt_identity.c
> > > @@ -346,9 +346,7 @@ void __init sme_encrypt_kernel(struct boot_params *bp)
> > >        * We're running identity mapped, so we must obtain the address to the
> > >        * SME encryption workarea using rip-relative addressing.
> > >        */
> > > -     asm ("lea sme_workarea(%%rip), %0"
> > > -          : "=r" (workarea_start)
> > > -          : "p" (sme_workarea));
> > > +     asm ("lea %a1, %0" : "=r" (workarea_start) : "i" (sme_workarea));
> >
> > Yeah, I saw that particular subthread today.
> >
> > Are you sure this "a" modifier DTRT with all gcc version we support?
> >
> > I.e., from 5.1 onwards...
> 
> Yes [1].
> 
> [1] https://godbolt.org/z/aWe7b16rT

But Clang generates RIP-relative load only starting from version 15.
Clange 11 claimed to be supported.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ