lkml.org 
[lkml]   [2020]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 04/17] x86/acrn: Introduce hypercall interfaces
From
Date
On 9/27/20 3:51 AM, Greg Kroah-Hartman wrote:
>> +static inline long acrn_hypercall0(unsigned long hcall_id)
>> +{
>> + register long r8 asm("r8");
>> + long result;
>> +
>> + /* Nothing can come between the r8 assignment and the asm: */
>> + r8 = hcall_id;
>> + asm volatile("vmcall\n\t"
>> + : "=a" (result)
>> + : "r" (r8)
>> + : );
> What keeps an interrupt from happening between the r8 assignment and the
> asm: ?

It's probably better phrased something like: "No other C code can come
between this r8 assignment and the inline asm". An interrupt would
actually be fine in there because interrupts save and restore all
register state, including r8.

The problem (mentioned in the changelog) is that gcc does not let you
place data directly into r8. But, it does allow you to declare a
register variable that you can assign to use r8. There might be a
problem if a function calls was in between and clobber the register,
thus the "nothing can come between" comment.

The comment is really intended to scare away anyone from adding printk()'s.

More information about these register variables is here:

> https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables

Any better ideas for comments would be greatly appreciated. It has 4 or
5 copies so I wanted it to be succinct.

\
 
 \ /
  Last update: 2020-09-27 17:38    [W:0.198 / U:2.336 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site