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: <20200625061544.GC2141@linux.intel.com>
Date:   Wed, 24 Jun 2020 23:15:44 -0700
From:   Sean Christopherson <sean.j.christopherson@...el.com>
To:     Peter Xu <peterx@...hat.com>
Cc:     linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        Paolo Bonzini <pbonzini@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>
Subject: Re: [PATCH 1/2] KVM: X86: Move ignore_msrs handling upper the stack

On Mon, Jun 22, 2020 at 06:04:41PM -0400, Peter Xu wrote:
> MSR accesses can be one of:
> 
>   (1) KVM internal access,
>   (2) userspace access (e.g., via KVM_SET_MSRS ioctl),
>   (3) guest access.
> 
> The ignore_msrs was previously handled by kvm_get_msr_common() and
> kvm_set_msr_common(), which is the bottom of the msr access stack.  It's
> working in most cases, however it could dump unwanted warning messages to dmesg
> even if kvm get/set the msrs internally when calling __kvm_set_msr() or
> __kvm_get_msr() (e.g. kvm_cpuid()).  Ideally we only want to trap cases (2)
> or (3), but not (1) above.
> 
> To achieve this, move the ignore_msrs handling upper until the callers of
> __kvm_get_msr() and __kvm_set_msr().  To identify the "msr missing" event, a
> new return value (KVM_MSR_RET_INVALID==2) is used for that.

IMO, kvm_cpuid() is simply buggy.  If KVM attempts to access a non-existent
MSR then it darn well should warn.

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 8a294f9747aa..7ef7283011d6 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1013,7 +1013,8 @@ bool kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx,
                *ebx = entry->ebx;
                *ecx = entry->ecx;
                *edx = entry->edx;
-               if (function == 7 && index == 0) {
+               if (function == 7 && index == 0 && (*ebx | (F(RTM) | F(HLE))) &&
+                   (vcpu->arch.arch_capabilities & ARCH_CAP_TSX_CTRL_MSR)) {
                        u64 data;
                        if (!__kvm_get_msr(vcpu, MSR_IA32_TSX_CTRL, &data, true) &&
                            (data & TSX_CTRL_CPUID_CLEAR))

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ