lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 2 Nov 2020 15:37:07 +0100
From:   Borislav Petkov <bp@...en8.de>
To:     shuo.a.liu@...el.com
Cc:     linux-kernel@...r.kernel.org, x86@...nel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "H . Peter Anvin" <hpa@...or.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Sean Christopherson <sean.j.christopherson@...el.com>,
        Yu Wang <yu1.wang@...el.com>,
        Reinette Chatre <reinette.chatre@...el.com>,
        Yin Fengwei <fengwei.yin@...el.com>,
        Dave Hansen <dave.hansen@...el.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Zhi Wang <zhi.a.wang@...el.com>,
        Zhenyu Wang <zhenyuw@...ux.intel.com>
Subject: Re: [PATCH v5 03/17] x86/acrn: Introduce an API to check if a VM is
 privileged

On Mon, Oct 19, 2020 at 02:17:49PM +0800, shuo.a.liu@...el.com wrote:
> +bool acrn_is_privileged_vm(void)
> +{
> +	return cpuid_eax(acrn_cpuid_base() | ACRN_CPUID_FEATURES) &
> +			 ACRN_FEATURE_PRIVILEGED_VM;

I asked in the previous review why that acrn_cpuid_base() is used here,
you said that the base might vary. Looking at hypervisor_cpuid_base(),
it searches in the range [0x40000000, 0x40010000] with an 0x100 offset.

So you're saying that ACRN_CPUID_FEATURES is the first leaf beyond the
base. Close?

If so, why isn't the code doing this?

	return cpuid_eax(acrn_cpuid_base() + 1)...

and why doesn't it have a comment above it explaining that the base can
change and it needs to be discovered each time?

> +EXPORT_SYMBOL_GPL(acrn_is_privileged_vm);

Also, that acrn_is_privileged_vm() silly helper is used only once and
I don't like the exported symbols pollution we're doing. So make that
function give you the eax of ACRN_CPUID_FEATURES and callers can do
their testing themselves.

When it turns out that code patterns get repeated, you can then
aggregate stuff into a helper.

Thx.

-- 
Regards/Gruss,
    Boris.

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ