lkml.org 
[lkml]   [2020]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 03/17] x86/acrn: Introduce an API to check if a VM is privileged
On Tue, Sep 22, 2020 at 07:42:57PM +0800, shuo.a.liu@intel.com wrote:
> +static u32 acrn_cpuid_base(void)
> +{
> + static u32 acrn_cpuid_base;
> +
> + if (!acrn_cpuid_base && boot_cpu_has(X86_FEATURE_HYPERVISOR))
> + acrn_cpuid_base = hypervisor_cpuid_base("ACRNACRNACRN", 0);
> +
> + return acrn_cpuid_base;
> +}
> +
> +bool acrn_is_privileged_vm(void)
> +{
> + return cpuid_eax(acrn_cpuid_base() | ACRN_CPUID_FEATURES) &

What's that dance and acrn_cpuid_base static thing needed for? Why not
simply:

cpuid_eax(ACRN_CPUID_FEATURES) & ...

?

> + ACRN_FEATURE_PRIVILEGED_VM;
> +}
> +EXPORT_SYMBOL_GPL(acrn_is_privileged_vm);

Also, if you're going to need more of those bit checkers acrn_is_<something>
which look at ACRN_CPUID_FEATURES, just stash CPUID_0x40000001_EAX locally and
use a

acrn_has(ACRN_FEATURE_PRIVILEGED_VM)

which does the bit testing.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette

\
 
 \ /
  Last update: 2020-09-30 10:10    [W:0.390 / U:0.664 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site