[lkml]   [2019]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [RFC PATCH v5 4/4] x86/acrn: Add hypercall for ACRN guest

On 2019年04月25日 19:00, Borislav Petkov wrote:
> On Thu, Apr 25, 2019 at 06:16:02PM +0800, Zhao, Yakui wrote:
>> The parameter register for the VMCALL is predefined in ACRN hypervisor. Now
>> the R8 is used to pass the hcall_id.
>> It seems that there is no special constraint for R8~R15.
>> So the explicit register variable is used so that the R8 can be passed.
> If you're going to use the constraint "D" for param1, you can just as
> well do
> "=a" (result)
> everywhere since you have the letter constraint for %rax instead of
> declaring it with "register".
> Also, you can completely get rid of those "register" declarations
> and let gcc have all the freedom to pass in hcall_id and the other
> parameters:
Thanks Borislav for providing the code.

It seems that it is seldom used in kernel although the explicit register
variable is supported by GCC and makes the code look simpler. And it
seems that the explicit register variable is not suppoorted by CLAG.

So the explicit register variable will be removed. I will follow the asm
code from Borislav. Of course one minor change is that the "movq" is
used instead of "mov".

Is this ok?


> unsigned long result;
> asm volatile("mov %[hcall_id], %%r8\n\t"
> "vmcall\n\t"
> : "=a" (result)
> : [hcall_id] "g" (hcall_id)
> : "r8");
> return result;
> and %r8 will be in the clobber list so gcc will reload it if needed.
> gcc turns it into
> 0000000000001040 <main>:
> 1040: 4c 8b 05 e1 2f 00 00 mov 0x2fe1(%rip),%r8 # 4028 <hcall_id>
> 1047: 0f 01 c1 vmcall
> 104a: c3 retq
> 104b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)
> here.

 \ /
  Last update: 2019-04-26 05:21    [W:0.075 / U:8.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site