lkml.org 
[lkml]   [2016]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] KVM: nVMX: expose INS/OUTS information support
From
Date


On 05/09/2016 11:19, Yury Norov wrote:
>> >
>> > +static inline bool cpu_has_vmx_basic_inout(void)
> inline is useless. See Documentation/CodingStyle, Chapter 15

No, it's not. See Documentation/CodingStyle, Chapter 15: "While the use
of inlines can be appropriate (for example as a means of replacing
macros, see Chapter 12), it very often is not".

>> > +{
>> > + return (((u64)vmcs_config.basic_cap << 32) & VMX_BASIC_INOUT);
> You can shift VMX_BASIC_INOUT (at compile time) and avoid the shifting of
> vmcs_config.basic_cap at runtime.

Not really since VMX_BASIC_INOUT comes from the processor manual.

It's ironic that your first remark places a lot of trust in the
compiler, while the second places none. The compiler is happy to
optimize away the left-shift/bitwise-AND pair to this:

movq %rdi, %rax
shrq $22, %rax
andl $1, %eax

where 22 is the order of VMX_BASIC_INOUT's only set bit, minus 32.

Paolo

\
 
 \ /
  Last update: 2016-09-17 09:58    [W:0.054 / U:0.096 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site