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] [day] [month] [year] [list]
Message-ID: <25d4aa73-ee2c-9890-164a-89fddcbe133e@oracle.com>
Date:   Tue, 4 Oct 2022 15:46:36 -0400
From:   Boris Ostrovsky <boris.ostrovsky@...cle.com>
To:     Juergen Gross <jgross@...e.com>, linux-kernel@...r.kernel.org,
        x86@...nel.org
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>, xen-devel@...ts.xenproject.org
Subject: Re: [PATCH v2 1/3] xen/pv: allow pmu msr accesses to cause GP


On 10/4/22 4:43 AM, Juergen Gross wrote:
>   
>   bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err)
>   {
> -	if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {
> -		if (is_amd_pmu_msr(msr)) {
> -			if (!xen_amd_pmu_emulate(msr, val, 1))
> -				*val = native_read_msr_safe(msr, err);
> -			return true;
> -		}
> -	} else {
> -		int type, index;
> +	int type, index;
> +	bool emulated;
>   
> -		if (is_intel_pmu_msr(msr, &type, &index)) {
> -			if (!xen_intel_pmu_emulate(msr, val, type, index, 1))
> -				*val = native_read_msr_safe(msr, err);
> -			return true;
> -		}
> +	if (is_amd_pmu_msr(msr))
> +		emulated = xen_amd_pmu_emulate(msr, val, 1);
> +	else if (is_intel_pmu_msr(msr, &type, &index))
> +		emulated = xen_intel_pmu_emulate(msr, val, type, index, 1);
> +	else
> +		return false;
> +
> +	if (!emulated) {


You can factor this out even further I think by moving if/elseif/esle into a separate routine and then have 'if (!xen_emulate_pmu_msr(msr, val, 1))' (and pass zero from pmu_msr_write())


-boris



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ