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: <87ed2bsvjx.fsf@redhat.com>
Date: Fri, 13 Dec 2024 11:53:54 +0100
From: Vitaly Kuznetsov <vkuznets@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini
 <pbonzini@...hat.com>, Sean Christopherson <seanjc@...gle.com>, Jarkko
 Sakkinen <jarkko@...nel.org>
Cc: kvm@...r.kernel.org, linux-sgx@...r.kernel.org,
 linux-kernel@...r.kernel.org, Maxim Levitsky <mlevitsk@...hat.com>, Hou
 Wenlong <houwenlong.hwl@...group.com>, Xiaoyao Li <xiaoyao.li@...el.com>,
 Kechen Lu <kechenl@...dia.com>, Oliver Upton <oliver.upton@...ux.dev>,
 Binbin Wu <binbin.wu@...ux.intel.com>, Yang Weijiang
 <weijiang.yang@...el.com>, Robert Hoo <robert.hoo.linux@...il.com>
Subject: Re: [PATCH v3 01/57] KVM: x86: Use feature_bit() to clear
 CONSTANT_TSC when emulating CPUID

Sean Christopherson <seanjc@...gle.com> writes:

> When clearing CONSTANT_TSC during CPUID emulation due to a Hyper-V quirk,
> use feature_bit() instead of SF() to ensure the bit is actually cleared.
> SF() evaluates to zero if the _host_ doesn't support the feature.  I.e.
> KVM could keep the bit set if userspace advertised CONSTANT_TSC despite
> it not being supported in hardware.

FWIW, I would strongly discourage such setups, all sorts of weird hangs
will likely be observed with Windows guests if TSC rate actually
changes.

>
> Note, translating from a scattered feature to a the hardware version is
> done by __feature_translate(), not SF().  The sole purpose of SF() is to
> check kernel support for the scattered feature, *before* translation.
>
> Cc: Vitaly Kuznetsov <vkuznets@...hat.com>
> Signed-off-by: Sean Christopherson <seanjc@...gle.com>
> ---
>  arch/x86/kvm/cpuid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 097bdc022d0f..776f24408fa3 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -1630,7 +1630,7 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
>  				*ebx &= ~(F(RTM) | F(HLE));
>  		} else if (function == 0x80000007) {
>  			if (kvm_hv_invtsc_suppressed(vcpu))
> -				*edx &= ~SF(CONSTANT_TSC);
> +				*edx &= ~feature_bit(CONSTANT_TSC);
>  		}
>  	} else {
>  		*eax = *ebx = *ecx = *edx = 0;

Reviewed-by: Vitaly Kuznetsov <vkuznets@...hat.com>

-- 
Vitaly


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ