Messages in this thread | | | From | Arvind Sankar <> | Date | Mon, 12 Oct 2020 12:49:16 -0400 | Subject | Re: [PATCH v4 04/17] x86/acrn: Introduce hypercall interfaces |
| |
On Mon, Oct 12, 2020 at 04:44:31PM +0800, Shuo A Liu wrote: > On Wed 30.Sep'20 at 12:14:03 -0700, Nick Desaulniers wrote: > >On Wed, Sep 30, 2020 at 10:13 AM Peter Zijlstra <peterz@infradead.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). > >> > >> Right, that's what they're trying to achieve. The hypervisor calling > >> convention needs that variable in %r8 (which is somewhat unfortunate). > >> > >> AFAIK this is the first such use in the kernel, but at least the gcc-4.9 > >> (our oldest supported version) claims to support this. > >> > >> So now we need to know if clang will actually do this too.. > > > >Does clang support register local storage? Let's use godbolt.org to find out: > >https://godbolt.org/z/YM45W5 > >Looks like yes. You can even check different GCC versions via the > >dropdown in the top right. > > > >The -ffixed-* flags are less well supported in Clang; they need to be > >reimplemented on a per-backend basis. aarch64 is relatively well > >supported, but other arches not so much IME. > > > >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; > >} > > Yeah, this approach is also mentioned in the changelog. I will change to > this way to follow your preference. With an addtional "r8" clobber what > Arvind mentioned. > > Thanks > shuo
Btw, I noticed that arch/x86/xen/hypercall.h uses register-local variables already for its hypercalls for quite some time, so this wouldn't be unprecedented. [0]
Do these calls also need a memory clobber? The KVM/xen hypercall functions all have one.
Thanks.
[0] e74359028d548 ("xen64: fix calls into hypercall page")
| |