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]
Message-ID: <0d18816a-c46e-ac7e-b98f-ef3dba1c356e@intel.com>
Date:   Thu, 17 Aug 2023 16:14:32 -0700
From:   Dave Hansen <dave.hansen@...el.com>
To:     Nuno Das Neves <nunodasneves@...ux.microsoft.com>,
        linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org,
        x86@...nel.org, linux-arm-kernel@...ts.infradead.org,
        linux-arch@...r.kernel.org
Cc:     patches@...ts.linux.dev, mikelley@...rosoft.com, kys@...rosoft.com,
        wei.liu@...nel.org, haiyangz@...rosoft.com, decui@...rosoft.com,
        apais@...ux.microsoft.com, Tianyu.Lan@...rosoft.com,
        ssengar@...ux.microsoft.com, mukeshrathor@...rosoft.com,
        stanislav.kinsburskiy@...il.com, jinankjain@...ux.microsoft.com,
        vkuznets@...hat.com, tglx@...utronix.de, mingo@...hat.com,
        bp@...en8.de, dave.hansen@...ux.intel.com, hpa@...or.com,
        will@...nel.org, catalin.marinas@....com
Subject: Re: [PATCH v2 02/15] mshyperv: Introduce hv_get_hypervisor_version
 function

On 8/17/23 15:01, Nuno Das Neves wrote:
> +int hv_get_hypervisor_version(union hv_hypervisor_version_info *info)
> +{
> +	hv_get_vpreg_128(HV_REGISTER_HYPERVISOR_VERSION,
> +			 (struct hv_get_vp_registers_output *)info);
> +
> +	return 0;
> +}
...
> +int hv_get_hypervisor_version(union hv_hypervisor_version_info *info)
> +{
> +	unsigned int hv_max_functions;
> +
> +	hv_max_functions = cpuid_eax(HYPERV_CPUID_VENDOR_AND_MAX_FUNCTIONS);
> +	if (hv_max_functions < HYPERV_CPUID_VERSION) {
> +		pr_err("%s: Could not detect Hyper-V version\n",
> +			__func__);
> +		return -ENODEV;
> +	}
> +
> +	info->eax = cpuid_eax(HYPERV_CPUID_VERSION);
> +	info->ebx = cpuid_ebx(HYPERV_CPUID_VERSION);
> +	info->ecx = cpuid_ecx(HYPERV_CPUID_VERSION);
> +	info->edx = cpuid_edx(HYPERV_CPUID_VERSION);
> +
> +	return 0;
> +}

I can't help but notice that the ARM version does *one* call to the
hardware while the x86 version does CPUID four different times, once to
get *EACH* register and throwing away the other three registers each
time.  Also recall that CPUID is a big, fat architecturally serializing
instruction.  This isn't a fast path, but CPUID is about as slow as you get.

Is there any reason you can't just have an x86 version of
hv_get_vpreg_128() that gets the 128 bits bytes of data that comes back
in the 4 CPUID registers?

That might even let you share some more code.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ