Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3130063yba; Mon, 8 Apr 2019 11:48:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqCQLshp9WD8VHvmBE6nYz/tQ+oGv1wCSwMpMvPZIO20py+5lBo6uQNrtquFqiEHLfRWfB X-Received: by 2002:a17:902:9a4c:: with SMTP id x12mr32186574plv.157.1554749293253; Mon, 08 Apr 2019 11:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554749293; cv=none; d=google.com; s=arc-20160816; b=jxpw3Al6iqDyOa2EkMvawrJmztpn/dPdMYghKqCV8dg5Nl+o2IezIey4H0i/QTnJIt 5MEzpFVVsDMxb1hu8h74+ZcuXUEtzDE6dTLAI58bEG/Unwz81moIqxYKpG3XhthZ6RHH jmpa7q+k+gnjczTlovvs3I7ReCZrtwn6O4UPx4GdkbFEseUo26hhYlS6v3lc250Moi5i vVzZcAiZZXsvZ5espOEMxQ22whV6VasIqbeatEVZzMwsEasRVX2bz+ZTTozvisLA/4t8 1IQfbibMNmt5Prn3vCTPXqPwcdWuUNCAwTWGYQdKU1f0+F2c60YXvqgqUhBknIK22J6S sKnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=X+3CYrOsxHB3+vJRZw+E+r6sVCDYU09wUkWiLXShzj8=; b=l9+Qu7EeWuykdBRRjVXmwABkYwNMS9fbYobO+Ax9maGmz0seYycyZW20jSz+kJCRbO h2X32o4mewRYTZcWdq5b8jQdaoRBbpPBknBTXiiJfouKLuJVhIZi9euU1uZnArzuXTWc YSTuhMLI3jRWnEYz0KLv+VO1z1ZmJTyoasH+GgHOXN+17m8gBsJn1INpNRAeoZP42hyF c9Ya8LB7vFDSfAI2FNegUK09mTqwMANltvO+nBLmtg4ykOjM0xBnZManpaxTCFn7b1I1 +sYZUBlti799SH+JdsmI4qYHDu2iZ8PUIQ4V2FuVdtx7iVP/BQcxGP0IdhDab6pDmegX oLcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k193si26942688pga.319.2019.04.08.11.47.57; Mon, 08 Apr 2019 11:48:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729367AbfDHRsH (ORCPT + 99 others); Mon, 8 Apr 2019 13:48:07 -0400 Received: from mga02.intel.com ([134.134.136.20]:17704 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726373AbfDHRsG (ORCPT ); Mon, 8 Apr 2019 13:48:06 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2019 10:48:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,326,1549958400"; d="scan'208";a="336034025" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by fmsmga005.fm.intel.com with ESMTP; 08 Apr 2019 10:48:05 -0700 Date: Mon, 8 Apr 2019 10:48:05 -0700 From: Sean Christopherson To: Xiaoyao Li Cc: Thomas Gleixner , Fenghua Yu , Ingo Molnar , Borislav Petkov , H Peter Anvin , Dave Hansen , Paolo Bonzini , Ashok Raj , Peter Zijlstra , Kalle Valo , Michael Chan , Ravi V Shankar , linux-kernel , x86 , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v6 12/20] kvm/vmx: Emulate MSR TEST_CTL Message-ID: <20190408174805.GJ25880@linux.intel.com> References: <1554326526-172295-1-git-send-email-fenghua.yu@intel.com> <1554326526-172295-13-git-send-email-fenghua.yu@intel.com> <423f329a8e194d799c6c41470266a04a9f90bc84.camel@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <423f329a8e194d799c6c41470266a04a9f90bc84.camel@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 08, 2019 at 05:54:25PM +0800, Xiaoyao Li wrote: > On Fri, 2019-04-05 at 14:30 +0200, Thomas Gleixner wrote: > > On Wed, 3 Apr 2019, Fenghua Yu wrote: > > > @@ -1663,6 +1663,12 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct > > > msr_data *msr_info) > > > u32 index; > > > > > > switch (msr_info->index) { > > > + case MSR_TEST_CTL: > > > + if (!msr_info->host_initiated && > > > + !(vcpu->arch.core_capability & CORE_CAP_SPLIT_LOCK_DETECT)) > > > > Errm? If the MSR_TEST_CTL is exposed to the guest via CPUID then the > > rdmsr() in the guest is not supposed to fail just because > > CORE_CAP_SPLIT_LOCK_DETECT is not set. > > you're right. > > > vmx->msr_test_ctl holds the proper value, which is either 0 or > > CORE_CAP_SPLIT_LOCK_DETECT until more bits are supported. > > > > So the chek needs to be guest_cpuid_has(X86_FEATURE_CORE_CAPABILITY). > > I don't think so. There is no dependecy between > guest_cpuid_has(X86_FEATURE_CORE_CAPABILITY) and MSR_TEST_CTL. > guest_cpuid_has(X86_FEATURE_CORE_CAPABILITY) only indicates that guest has MSR > CORE_CAPABILITY. > > Due to the fact that MSR_TEST_CTL is emulated with vmx->msr_test_ctl. I think it > 's ok to always let userspace or guest to read MSR_TEST_CTL, it just returns the > emulated value. Like you said, " vmx->msr_test_ctl holds the proper value, which > is either 0 or CORE_CAP_SPLIT_LOCK_DETECT until more bits are supported." Assuming the next version implements "vmx->msr_test_ctl_mask", KVM should inject #GP if the guest attempts RDMSR(MSR_TEST_CTL) and the mask is zero. It stands to reason that a kernel can only reasonably assume the MSR exists if the (virtual) CPU supports at least one feature enabled via MSR_TEST_CTL.