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: <20240618102434.GDZnFgYsJHTGibyuX1@fat_crate.local>
Date: Tue, 18 Jun 2024 12:24:34 +0200
From: Borislav Petkov <bp@...en8.de>
To: Sean Christopherson <seanjc@...gle.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/3] KVM: SVM: Use compound literal in lieu of
 __maybe_unused rdmsr() param

On Mon, Jun 17, 2024 at 02:04:32PM -0700, Sean Christopherson wrote:
> When reading MSR_TSC_AUX, which is effectively a 32-bit value, use a
> compound literal to consume/ignore the upper 32 bits instead of a "maybe"
> unused local variable.  While (ab)using a compound literal to discard an
> unused output is unusual, it's perfectly legal as compound literals are
> valid, modifiable l-values in C99 and beyond.
> 
> No functional change intended.
> 
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
>  arch/x86/kvm/svm/svm.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index cf285472fea6..69c0dea5cc0d 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -678,11 +678,8 @@ static int svm_hardware_enable(void)
>  	 * Since Linux does not change the value of TSC_AUX once set, prime the
>  	 * TSC_AUX field now to avoid a RDMSR on every vCPU run.
>  	 */
> -	if (boot_cpu_has(X86_FEATURE_V_TSC_AUX)) {
> -		u32 __maybe_unused msr_hi;
> -
> -		rdmsr(MSR_TSC_AUX, sev_es_host_save_area(sd)->tsc_aux, msr_hi);
> -	}
> +	if (boot_cpu_has(X86_FEATURE_V_TSC_AUX))

You can switch to cpu_feature_enabled() while you're here.

> +		rdmsr(MSR_TSC_AUX, sev_es_host_save_area(sd)->tsc_aux, (u32){0});
>  
>  	return 0;
>  }
> -- 

Right, slick, but I'd argue that before it was better because __maybe_unused was
actually documenting why that var is there.

(u32){} looks a bit more cryptic but meh, ok, I guess.

With those three applied, I only get

arch/x86/kvm/kvm.o: warning: objtool: .text+0x0: unreachable instruction
arch/x86/kvm/kvm.o: warning: objtool: .text+0x4: unreachable instruction

now on a randconfig which is attached.

When built with clang tho:

$  clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1

gcc is fine.

Thx.

-- 
Regards/Gruss,
    Boris.

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

View attachment "23-38-38-randconfig-x86_64-4642.cfg" of type "text/plain" (217969 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ