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: <Zr0itgdmn6LGDFsQ@google.com>
Date: Wed, 14 Aug 2024 14:33:42 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Thorsten Blum <thorsten.blum@...lux.com>
Cc: pbonzini@...hat.com, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, 
	dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com, 
	kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86: Optimize local variable in start_sw_tscdeadline()

On Wed, Aug 14, 2024, Thorsten Blum wrote:
> Change the data type of the local variable this_tsc_khz to u32 because
> virtual_tsc_khz is also declared as u32.

Heh, thought this looked familiar[*].  I'll plan on applying this for 6.12.

[*] https://lore.kernel.org/all/ZT_WBanoip8zhxis@google.com

> Since do_div() casts the divisor to u32 anyway, changing the data type
> of this_tsc_khz to u32 also removes the following Coccinelle/coccicheck
> warning reported by do_div.cocci:
> 
>   WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead
> 
> Compile-tested only.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
>  arch/x86/kvm/lapic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index a7172ba59ad2..40ff955c1859 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -1946,7 +1946,7 @@ static void start_sw_tscdeadline(struct kvm_lapic *apic)
>  	u64 ns = 0;
>  	ktime_t expire;
>  	struct kvm_vcpu *vcpu = apic->vcpu;
> -	unsigned long this_tsc_khz = vcpu->arch.virtual_tsc_khz;
> +	u32 this_tsc_khz = vcpu->arch.virtual_tsc_khz;
>  	unsigned long flags;
>  	ktime_t now;
>  
> -- 
> 2.45.2
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ