Received: by 10.223.185.116 with SMTP id b49csp1344041wrg; Fri, 23 Feb 2018 16:55:19 -0800 (PST) X-Google-Smtp-Source: AH8x225HKUqZjkBfItM/9gOcmZO85f23VyUl7SII4uQDRm30n85Oe1HGt4UhCSNuy+P6e7NqBVGk X-Received: by 2002:a17:902:bf0c:: with SMTP id bi12-v6mr3391382plb.143.1519433719098; Fri, 23 Feb 2018 16:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519433719; cv=none; d=google.com; s=arc-20160816; b=pxM+UN62IV016EIV1R7nqcnjK8WGDyz/og/6yqQYs1vO8f/fsb9hYp43P7VBJANMTy UzaLHh18cT7EdJTbXpDQb++91X3lXTXF9C18tzyeJr7pwfh/05KIwjCeQL98HGetWB/Z jQxtLvr0PQwHR+oSRiPwvsYEVY1SqfkRadlCgvK5MmNG4oNm+O6djI7flMeyv/l+pQhU iZjICYtM6JWyXH3Fh62MXnbez34rjoNtQWQoyVX1BDiuWOYbJnwH1wsNeWizEeoA376C RlKUDbD4K6+mM8JmDzZIbhgBq9t1MQ6IWsamDU7X3ulNLzxVl71CUOOWiuBIFPrsdpIO CiFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=AvKsWEJ0udTjhRVCG05eXWkOAbe2U1BFZAwbzvv/xV0=; b=BzfThCnMO6I9OXcBdxpdmDkKjfiLfnbsJVDvQz2dXwWEsovKabnHoKihOdxaKh65J2 kxotjXDjPCOWfRKxD+M0bRWJDnByBmdjkl5eE96hOMQfL1xVfEdRrayN9JoRnkg6Xwdn wNd7Nn1mgznOOLO2QcRpU9PnK17XSiPmr+FZvHXbvG/teR4PrY7dgD8b2VjprVnZzOnp iqMWRWxySYIlZkTBJ97Krm9/3aERXP4wxbhkdEPEL837nIYCNBwDXJg8hI9aXBy+rIFJ EgtRxC+kyrj9ypM/VFs82hTOSdw+flydtOFVAEoHeQ8gRTDYyaNHDHjFtZa5caOF/zef Yf6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TRoRh2Ni; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si2187885pgo.107.2018.02.23.16.55.04; Fri, 23 Feb 2018 16:55:19 -0800 (PST) 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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=TRoRh2Ni; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752788AbeBXAwe (ORCPT + 99 others); Fri, 23 Feb 2018 19:52:34 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52427 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752681AbeBXAwb (ORCPT ); Fri, 23 Feb 2018 19:52:31 -0500 Received: by mail-wm0-f67.google.com with SMTP id t3so7660164wmc.2; Fri, 23 Feb 2018 16:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=AvKsWEJ0udTjhRVCG05eXWkOAbe2U1BFZAwbzvv/xV0=; b=TRoRh2Nin1fhmDEJ63CxjcOC0k/AN48PEn3PPTX4zef6oiKM52XeGnZqjOfdrp8Y6i D97oqgoj6o2K6KCLV9MazggL2rqcS1YnrULDE/UYvyZwS/aFpZ9bMFBwiTjQsGqCMtre UIYF5yEacGo7bsP/+cl+EQaa8JBYogj1eI3zK1qf9/aVldG232JZeE0jz9khuIahd9Q4 /fdI9CeSshmbiqkXLrMZL2YgEt3s/8/Grw3qo9UOySrji5Or0jr8tr/kfMmgM3HdVYPH PpdhtSGPSOYKK0I52pMVraEZ/JHRz/G9ph7Oayq9yNfY0cFXTtrA0Og1GN0WGqsbcXuG Q/wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=AvKsWEJ0udTjhRVCG05eXWkOAbe2U1BFZAwbzvv/xV0=; b=Yq1mIB8/+7pJ6skXQt9rUIJcEDIpV5cdbMNVQ2B0SOr+3pcdnfGdt8lbc62gZXf27x TLipLvQ5DkfeSY6sg5+0JTWb4auipUFkaeQPZaBRZ7uJ1+Td9/bompuEo4wTRh2TXuNp tk6YBgG6iPZkXCk8wQNKvFpMlLHpg8Zqa5uwhYYaKGE8x7XisDYkrm/9TInSHtscqUSZ rN/cOTYJPftuF4rzysQm48Yr3icGaeDvOoIIy/SZIBM7696Hne2RB5o3twKlh8oss/PK im/vgZL+t6wwYb5BCF8GUWp7uzxldO4egP4lVJgdnv+qbbjy9g8VM1Rk1ECFbATZ1bXF IOZg== X-Gm-Message-State: APf1xPBIZFAmMZDZZ2vfQqaYLdsl4zw8s3ftUfvboVAx6Uh4ciKZJTAS zgjkQWzNoBA4qXrFea1CobRt/QYn X-Received: by 10.28.63.81 with SMTP id m78mr3367088wma.102.1519433549733; Fri, 23 Feb 2018 16:52:29 -0800 (PST) Received: from 640k.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id r1sm3418982wmg.22.2018.02.23.16.52.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 16:52:27 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: David Woodhouse , KarimAllah Ahmed Subject: [PATCH] KVM: VMX: expose the host's ARCH_CAPABILITIES MSR to userspace Date: Sat, 24 Feb 2018 01:52:26 +0100 Message-Id: <1519433546-33879-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the new MSR feature framework to expose the ARCH_CAPABILITIES MSR to userspace. This way, userspace can access the capabilities even if it does not have the permissions to read MSRs. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/vmx.c | 12 +++++++++++- arch/x86/kvm/x86.c | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 130fca0ea1bf..99689061e11e 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3228,7 +3228,17 @@ static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu, static int vmx_get_msr_feature(struct kvm_msr_entry *msr) { - return 1; + switch (msr->index) { + case MSR_IA32_ARCH_CAPABILITIES: + if (!boot_cpu_has(X86_FEATURE_ARCH_CAPABILITIES)) + return 1; + rdmsrl(msr->index, msr->data); + break; + default: + return 1; + } + + return 0; } /* diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 54b4ed55945b..e9a8cc9e3b2b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1054,6 +1054,7 @@ bool kvm_rdpmc(struct kvm_vcpu *vcpu) * can be used by a hypervisor to validate requested CPU features. */ static u32 msr_based_features[] = { + MSR_IA32_ARCH_CAPABILITIES, MSR_F10H_DECFG, }; -- 1.8.3.1