Received: by 10.223.176.5 with SMTP id f5csp216197wra; Tue, 30 Jan 2018 10:20:12 -0800 (PST) X-Google-Smtp-Source: AH8x224kIJtrCxxlXXhtRa+9zjoBzS8JQl/ibAyGk0OI69ZXmVV/KCkqDUMeWvqnGoVfFlwyeRkr X-Received: by 10.99.171.12 with SMTP id p12mr24808399pgf.304.1517336412568; Tue, 30 Jan 2018 10:20:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517336412; cv=none; d=google.com; s=arc-20160816; b=sYYtrIpiGyjThvL9u+YU2ggXVu8AHEVZy21+45PJhAceEh1WLDULs2pPEJ1V1ucbk5 v4Pocv6mUhVKF0LPFCd1a5yMx3g9eGC6u0lqVe+hS1cfpXMswbDpbO/q5ng8heZezaht E4x1bJdRmC/NjzKbC0Xfgr6Vm85Tfl3OXS6YQ8/UhwNIBw2iNlU7c3TTwX3vlpnbPUJy Q6/Irx27NuzPwQxlCXf7/ZKmE3yBcbWs6HIIsPA5Mqu84rnhc+3oQPMEzr1+fJuvRVE0 0DpRU8LHhpCkgouZuyqfgodk5h4pCE1pcsHNP4XezCpIx/4Qn2ElBq9XfcU3/oB2jJJ7 m6FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=L1HmhnpgwwvBoNwAh63egUQRw03Th3oZ1y3r/qKKCKI=; b=nW51WTg7mMNHbR6pnoSWMDCmVBk/v2hm10f167TmbDpHkP/lVFcVSSjZ80sRaBz2qm jrUOdQkpFNkAb1qn446ZBM8jxH7FWtK0tzfdHQ5eJGMVQktERqxm2nxIjU36JhxvNizi rclso7Xj6bX9T3NGtDAcQRsSsVL4WRR95A8PkIWvM3iSQ1LzNILPG1e/5AcZ2Ble9uqT 6cVkc7fNN+KXtEyLsNICahitZmv3X8LSorC0yIfxX7kGx1T3rzbxrDQkScSNk+sa0/ii 0jEWxuQFeZXtenvnrG2rGby99SfOn4ftWmnFRbVdhk9xDiDrYYwm5EuF7u6s9RRFTMOb HsUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=uYMn4umH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e2si279964pgu.420.2018.01.30.10.19.27; Tue, 30 Jan 2018 10:20:12 -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=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=uYMn4umH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753648AbeA3RdV (ORCPT + 99 others); Tue, 30 Jan 2018 12:33:21 -0500 Received: from mail-sn1nam02on0071.outbound.protection.outlook.com ([104.47.36.71]:21856 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752518AbeA3RdC (ORCPT ); Tue, 30 Jan 2018 12:33:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=L1HmhnpgwwvBoNwAh63egUQRw03Th3oZ1y3r/qKKCKI=; b=uYMn4umHmV0AzYU2TeLzjFFnjiwQET1GMmW5x2gQWa4O8QLlVwOjPGvmvCpOHKYgrOat3+4iYPRaNA5WyF5Bx4PI33ZKtVAMkeAXW8v71KvbNWECxRvQxm3uYZtcURKzOLjSUkTQEzMccEWu5CmjnElTk0dEoZWcPsgobBbTCOc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Janakarajan.Natarajan@amd.com; Received: from gi-joe.amd.com (165.204.77.1) by BN6PR12MB1362.namprd12.prod.outlook.com (10.168.228.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Tue, 30 Jan 2018 17:32:57 +0000 From: Janakarajan Natarajan To: kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Paolo Bonzini , Radim Krcmar , Len Brown , Kyle Huey , Tom Lendacky , Borislav Petkov , Grzegorz Andrejczuk , Kan Liang , Janakarajan Natarajan Subject: [PATCH v4 3/3] x86/kvm: Expose AMD Core Perf Extension flag to guests Date: Tue, 30 Jan 2018 11:32:43 -0600 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR10CA0015.namprd10.prod.outlook.com (10.172.33.25) To BN6PR12MB1362.namprd12.prod.outlook.com (10.168.228.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 467758a9-8df7-432f-d54b-08d568078159 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:BN6PR12MB1362; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1362;3:GEC702txW1zK3gVjeLQ+jN2S5vEo3et7yT4OK3t3cx32bHQdGw6Gcb7rY8T8f5g5hNIy5b61KZ2a3EewS1Y1XtIwSeWza5ufnzYrnJUkokHFh7dKq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JvX3iTE+jT99DiAAy9LlUl2SZ5vXLuCE9I4vM6gJPghpBXY3ozJC1BFAW+N0wW4rh3XoEoRKwmszO3g4X9w+vxQ3rsz/Zk0Q9JRZhIbrWYUp7vYua1/YbVMdt1wNTPkP871srikXZYzuYxnIs7fby3UzAQZNzgbw7jjL8UQog031OIeVjZVDRntpJucugiP3ozc94wp3y2fJ6z8mf7BGm4kwM;4:QcnP3FZt45gOjdyIXYatXiv5oIcdzjHXtMJn8UoQAlnhntCbBv1F3IG3BKIVOSRt4Jsn/HfVfLFyrso+yzxqIVC6RZ7qZJN0SCuKLNU5xO+1mXETeQ+DCwICc6ecXFUHptm4KCPGeaTmLz+FHR0BkrHJw8tFYqaAs5QGKwUhJdTjH6PQ/iSSXG/Hns5KiwkuVtoD3gKok+P+PNzczI5UR11rA7mUTNOlKIpqgqjPQEQtyeYPlok/Y7I8Jtktw2bqVwOqTanpHAXUqAOrFZ5xld/E0XgbA7FKrf7VmWOcR/EVpq2oRvdDRSWqE14mJTJJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(3231101)(944501161)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041288)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(6072148)(201708071742011);SRVR:BN6PR12MB1362;BCL:0;PCL:0;RULEID:;SRVR:BN6PR12MB1362; X-Forefront-PRVS: 0568F32D91 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39380400002)(376002)(366004)(346002)(39860400002)(396003)(189003)(199004)(6116002)(47776003)(53936002)(66066001)(316002)(2906002)(118296001)(7416002)(54906003)(386003)(72206003)(52116002)(478600001)(16586007)(59450400001)(25786009)(305945005)(5660300001)(26005)(76176011)(3846002)(7696005)(6666003)(7736002)(97736004)(4326008)(51416003)(53416004)(36756003)(6486002)(68736007)(50226002)(2950100002)(106356001)(8676002)(8936002)(81156014)(186003)(81166006)(105586002)(48376002)(16526019)(86362001)(50466002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1362;H:gi-joe.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR12MB1362;23:YfYwOLTvt6EJUqibrX6VHFff0G5rsp1Iamv9x1Zyk?= =?us-ascii?Q?YH9cMDszQjr57ixtc/xHHOjVdQLB1qQKFcMZwl563V1np8sW1n0t3INiP7Ll?= =?us-ascii?Q?E/d4njKPcRe2ay6mEjvNs9s+RlC5TDwGKUGw+sfXQ5v2rkHPTLIk3k+5t6KX?= =?us-ascii?Q?obE+PhNGa87MzQnSyT1mWPhyYlsSYEJ3Ret4hkOcVeEGUqMtSXlC6G+jsO6/?= =?us-ascii?Q?EWM/pXYLEt5B0RhPp3WgZJr+/0cGQSZnRm1PcHOsTcH1LVQxitiv0AQFGTU5?= =?us-ascii?Q?0yqU3bjQx+kWKCaLu/0y7nq5gS3nFBtLmptgFgHwZawh26vZeWFRV2OujaM3?= =?us-ascii?Q?nRT24nZxPCThSXqNmC+M8ezYjz9542MdOKSaStdBJfWmU6MVy3+1nYUdaMAQ?= =?us-ascii?Q?+txzxQcYHzXkvPDIddfW/BDixEPyLdDA0+3SGr1/7UUj0KgKDRWb+UfWY5Kz?= =?us-ascii?Q?/XFe/g4MkqmSZtsICBGBAE6tGYtUcKyRIpQ6n5Q9IilB5SO84/G4vy44MJnb?= =?us-ascii?Q?JCIyg6u6x291yUBUC86K2+rMLN6CVrC8O0evu4CI81VM4SnlbKBCisDPg5Pn?= =?us-ascii?Q?dDh/6TAOY8jY755WwldQ/21L39c28KyI4VnSZKHh5owK7EeJJ8D+kd+1x2az?= =?us-ascii?Q?TD1oM3JekuU103xhH/qZJgLmB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A0X/LSR7IjiFF3WY7b5qxU9xSztB8HSd2m96LpQmUNKszTUsQD/OyWlrmSjv52/0Yh5dNN4oFJYy8JUp7mewDCSRnZOA+70ElvS5FclWxR51aIgGfVLV3pZIcOmOvu5w34yZ+MgH+kWlThAzvhdkxvc6Q9ei54x2s=;24:YJdtIAfRHTM40Q0BTodgGkmJPzDSWksfcmcms6p8Bu4mKFPorXcs0AeiZU5Pdb4enhWLGwgoP3rIIOtnxhV/wR+wlbqZA5kVQPVNABwFbwY=;7:DCcP2Egjtah73O10Pyot/Y2Tbl/Fk/E24yD+e70f2kPBFZ3emsjdoJFbconQVezL7PJVcruwHs/LDkSbk6aw/ETUJfpy19OQrKLnl3NI4Tzvwwu3lAmitIZINfdE2T6Q8mB59HgbxR1ROyhgubVjuH7n5kIMPEowbXq8VsFKM5FA+wtGXdAbJdn9iUAaWWE1S8vTomsiWiIUTrmm53PVvnlHg/O7X41OtfrZDecIOknXdz1G0/LcZayzZbOCsQLP SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1362;20:ksguM6xK+fxxCo4HI2Nz1B/kqVHDjGq9yc4f+3cWMrXnD5PmIRpDYBnnKe2us5bglTXIBeiuAV7a7BIfk9FvA9FXOti5Nj3k7Qunet4Uc0Tu4KfF+VaCV5JwFOHu9ZvUFWd0SlBvSONZw6pgxZhnzH7T4p62k3rIUIepyZoDquOdBDOVkJyvZgzzfqIbu+YWgiE1vrJpJm6uVi5//xbzI+tEVIXFCBXoS3aFzD7HAnMcnH49bKjWhqu9PClJ75cU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2018 17:32:57.4969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 467758a9-8df7-432f-d54b-08d568078159 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1362 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose the AMD Core Perf Extension flag to the guests. Signed-off-by: Janakarajan Natarajan --- arch/x86/kvm/cpuid.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 0099e10..8c95a7c 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -55,6 +55,11 @@ bool kvm_mpx_supported(void) } EXPORT_SYMBOL_GPL(kvm_mpx_supported); +bool perf_ext_supported(void) +{ + return boot_cpu_has(X86_FEATURE_PERFCTR_CORE); +} + u64 kvm_supported_xcr0(void) { u64 xcr0 = KVM_SUPPORTED_XCR0 & host_xcr0; @@ -327,6 +332,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, unsigned f_invpcid = kvm_x86_ops->invpcid_supported() ? F(INVPCID) : 0; unsigned f_mpx = kvm_mpx_supported() ? F(MPX) : 0; unsigned f_xsaves = kvm_x86_ops->xsaves_supported() ? F(XSAVES) : 0; + unsigned f_perfext = perf_ext_supported() ? F(PERFCTR_CORE) : 0; /* cpuid 1.edx */ const u32 kvm_cpuid_1_edx_x86_features = @@ -365,7 +371,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ | F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) | F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) | - 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM); + 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM) | f_perfext; /* cpuid 0xC0000001.edx */ const u32 kvm_cpuid_C000_0001_edx_x86_features = -- 2.7.4