Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2817957pxb; Tue, 13 Apr 2021 10:51:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+cjvK2tiECFx21cV9hz4FYqwewi3350RUABOr9KHpTIWo2sH5jXQu8EajKpDk+C9AyVF/ X-Received: by 2002:aa7:c9c8:: with SMTP id i8mr35620180edt.193.1618336315915; Tue, 13 Apr 2021 10:51:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618336315; cv=none; d=google.com; s=arc-20160816; b=beuzoHKN+FW0ClK7Mv5Xe4MGACvoTRD3zRxLetxkAiyLNxF2vkmeiaIczY9B0Cyzk7 3AqTUjJrALUCZNxlQvb0G02Qf8Pr5AWlwOPTd7rZ2ztvCNmnNQgVHYJwSxf8xabPAl+R rCOpBaDbnamI+l4ETfWFtw1/GUDRsWWYUaaJI98IuK2LBJE5NfldvM3psqB6tE8u8iLB 7oB6QKWuOkdPY5Ek+0CboQN5mTNDVIF4JbRTZ2HKh9RSLzXTvP9jWc4+tnjklAwXRjlv Nodvm72lkkzG2WWgvNefqeGJMWpdyPHCG+jOvf9G8GZunUzn4LrCYJ7NJ+Ls4U7X7pjT kNmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=T1/+pxwOIYBMLawW9LxG6HUvWrXK++Jmrxahabnl8/8=; b=GawGA34buVUALr218TQhXa7eAwEnaxyWRqQy3UoyD5JNZgAQig8NbjYHMxsp4MAsfO A7VBEhzkk67MWc/xa6bka7sPRYUntZNwGmHG2ox50+HVv106Lm9yZ+TIATqSiWGY5RVZ cJHjeASxe7zPU+7JjV/g7RMsM1/2zHXJQ7dobgJPwhmStze5skor+JY2EUYCbL4nm5so Jx2S9VUbr4MarwWGdg90QpnYkHHWguGFVBNpdacqJpwR850kf+HNzixmx/k6GIoFIpgK EaRQS+1SGXrXFPtTmvzcn/11tcKzcmPXoWFXI7LtPU/HKwc6H5C4PS+z2WSUJ+fjDWqT Gqgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=INXQsZa7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h17si10773066edb.593.2021.04.13.10.51.31; Tue, 13 Apr 2021 10:51:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=INXQsZa7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345663AbhDMM1o (ORCPT + 99 others); Tue, 13 Apr 2021 08:27:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29657 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345558AbhDMM1Q (ORCPT ); Tue, 13 Apr 2021 08:27:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618316816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T1/+pxwOIYBMLawW9LxG6HUvWrXK++Jmrxahabnl8/8=; b=INXQsZa7mbXTTLbuXz79XEm/z8ih837UQP9j0zjqzcWM+lPZb96UoXddWYqO9T57kR5pqt DJUfgNdLgf86V8/QlhPCr5idJ/JYnjMi6mAB8ZbObH72jvnx27Y9qsz+O7h4lWgRFiBteM SKkACSYclJ87DatXUfK1f0xEmq8Bj/k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-512-aoV2_RPoMy2DDbJIB71_pg-1; Tue, 13 Apr 2021 08:26:55 -0400 X-MC-Unique: aoV2_RPoMy2DDbJIB71_pg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E5FFBA40CA; Tue, 13 Apr 2021 12:26:53 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.195.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED7060C04; Tue, 13 Apr 2021 12:26:51 +0000 (UTC) From: Vitaly Kuznetsov To: kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Wanpeng Li , Jim Mattson , Siddharth Chandrasekaran , linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org Subject: [PATCH RFC 06/22] KVM: x86: hyper-v: Honor HV_MSR_VP_INDEX_AVAILABLE privilege bit Date: Tue, 13 Apr 2021 14:26:14 +0200 Message-Id: <20210413122630.975617-7-vkuznets@redhat.com> In-Reply-To: <20210413122630.975617-1-vkuznets@redhat.com> References: <20210413122630.975617-1-vkuznets@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HV_X64_MSR_VP_INDEX is only available to guest when HV_MSR_VP_INDEX_AVAILABLE bit is exposed. Note, writing to HV_X64_MSR_VP_INDEX is only available from the host so kvm_hv_set_msr() doesn't need an additional check. Signed-off-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 7fdd9b9c50d6..07f1fc8575e5 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1514,6 +1514,10 @@ static int kvm_hv_get_msr(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata, switch (msr) { case HV_X64_MSR_VP_INDEX: + if (unlikely(!host && !(hv_vcpu->cpuid_cache.features_eax & + HV_MSR_VP_INDEX_AVAILABLE))) + return 1; + data = hv_vcpu->vp_index; break; case HV_X64_MSR_EOI: -- 2.30.2