[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201001000832.GE28786@gate.crashing.org>
Date: Wed, 30 Sep 2020 19:08:32 -0500
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Arvind Sankar <nivedita@...m.mit.edu>
Cc: Nick Desaulniers <ndesaulniers@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Dave Hansen <dave.hansen@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
shuo.a.liu@...el.com, LKML <linux-kernel@...r.kernel.org>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
"H . Peter Anvin" <hpa@...or.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Yu Wang <yu1.wang@...el.com>,
Reinette Chatre <reinette.chatre@...el.com>,
Yakui Zhao <yakui.zhao@...el.com>,
Dan Williams <dan.j.williams@...el.com>,
Fengwei Yin <fengwei.yin@...el.com>,
Zhi Wang <zhi.a.wang@...el.com>,
Zhenyu Wang <zhenyuw@...ux.intel.com>
Subject: Re: [PATCH v4 04/17] x86/acrn: Introduce hypercall interfaces
On Wed, Sep 30, 2020 at 03:59:15PM -0400, Arvind Sankar wrote:
> On Wed, Sep 30, 2020 at 12:14:03PM -0700, Nick Desaulniers wrote:
> > On Wed, Sep 30, 2020 at 10:13 AM Peter Zijlstra <peterz@...radead.org> wrote:
> > >
> > > On Wed, Sep 30, 2020 at 11:10:36AM -0500, Segher Boessenkool wrote:
> > >
> > > > Since this variable is a local register asm, on entry to the asm the
> > > > compiler guarantees that the value lives in the assigned register (the
> > > > "r8" hardware register in this case). This all works completely fine.
> > > > This is the only guaranteed behaviour for local register asm (well,
> > > > together with analogous behaviour for outputs).
>
> How strict is the guarantee? This is an inline function -- could the
> compiler decide to reorder some other code in between the r8 assignment
> and the asm statement when it gets inlined?
Nope. It will be in r8 on entry to the asm. A guarantee is a
guarantee; it is not a "yeah maybe, we'll see".
> > Do we need register local storage here?
> >
> > static inline long bar(unsigned long hcall_id)
> > {
> > long result;
> > asm volatile("movl %1, %%r8d\n\t"
> > "vmcall\n\t"
> > : "=a" (result)
> > : "ir" (hcall_id)
> > : );
> > return result;
> > }
>
> This seems more robust, though you probably need an r8 clobber in there?
Oh, x86 has the operand order inverted, so this should work in fact.
Segher
Powered by blists - more mailing lists