From patchwork Mon Aug 22 23:27:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9294731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8722B607D0 for ; Mon, 22 Aug 2016 23:42:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79AA228B26 for ; Mon, 22 Aug 2016 23:42:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D35628B30; Mon, 22 Aug 2016 23:42:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9BC728B26 for ; Mon, 22 Aug 2016 23:42:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757089AbcHVXmJ (ORCPT ); Mon, 22 Aug 2016 19:42:09 -0400 Received: from mail-co1nam03on0049.outbound.protection.outlook.com ([104.47.40.49]:57312 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755092AbcHVXmE (ORCPT ); Mon, 22 Aug 2016 19:42:04 -0400 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=oWz7k8ZqzYIx1J30KuKS3WtJOZKVc5WSsfQm5vXSJdo=; b=Vz4Z1T/XncULcLAtgPOrC7GjoolpFrUC8E+GKfccv8QwOnSVua8y4wvYkACvqVsiFVH5xJytmK/SBnA96+cA+YISip0HzhNVNRsplwFT7ToZl19w+YFyo+5A998foAe6WWCcTu5qW15TwhE1WHYXyA9Qip27LnvxtlGCmPEYWgA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by BY2PR12MB0664.namprd12.prod.outlook.com (10.163.113.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.587.13; Mon, 22 Aug 2016 23:27:12 +0000 Subject: [RFC PATCH v1 17/28] KVM: SVM: Enable SEV by setting the SEV_ENABLE cpu feature From: Brijesh Singh To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Mon, 22 Aug 2016 19:27:07 -0400 Message-ID: <147190842748.9523.5605997278361096963.stgit@brijesh-build-machine> In-Reply-To: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> References: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR17CA0048.namprd17.prod.outlook.com (10.175.189.34) To BY2PR12MB0664.namprd12.prod.outlook.com (10.163.113.153) X-MS-Office365-Filtering-Correlation-Id: c2e1616b-c51d-476b-a6e7-08d3cae3db44 X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0664; 2:rHdQYmzo3jkvomENO57LySEvWBBLxevumLNnfFS8H7yYE93+GoGmQavLUsLf8h5XSZY3dDOKWnte7hSwAr0YRrGFB2YKcJzOKzZCXO+JKg5k9468G5MnYj1d4fBNrUFwhKJ7URjjlZvNWofaKu50tElYr3XGp+j6gyAQA0lV2seSCOC4FfKJGPUR31q4M2JZ; 3:E/eZi0icn3cyfPAno8ydPx74UyR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MFhe/FPbTu4nMRZsJLYw8NVMJl9w6mw4u1CsQDHvzGmMcZ8FbfWYBY/JDBn6x6okntq6uXLG5jCwbHSZ6IionPBw6yWV1rtUriZSG98ZX+kG69FXVKcM/lmi0ABsV3+gtJnwxiIT8aNiJEVCoDXBKXoQus2AWPv5XSKXfL1VTmw/TwsXOU8v121uCpuigYw+FEYMqYTpjVReM5PzjExlgR9cO2ziwCbSjQdbTMz9FjMpFanWpDxrqkrknvWVhfBFPg988nErgYJkZa6q1mh7/FAowZSBlVdTxQo27ifGKWD9DRra X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BY2PR12MB0664; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0664; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0664; 4:WyFMTUv0uQSR0pcj/3zQh4sG0Usfs8QlwormEvW999xGHHAA+FP2kA1Id7A9Hct61xqqx98i/zV+HorCVJ8hb0Ljg3KlJfw4ISX88rOrWFUNkCToijDbNzAfkbWgpd05HhHZnEMdCV4NSz3frL4tkOpY/DoW8WsFjw+NK4tGum0iC6GCD7zEI1kWX1axs+Xyl1dW4YmDMKh9jHfbrgMhQzVGy0F3DS9VJxXgQfr6OWVYRZaZWxV17V33TeqpC57HxJJ4WgjMFB2XPCQ5fEx8AAy4b/tErguzI/QLpS86zMxAeGuzbBS3Y12ijFvkahKB/mgXJiUhjO6BaddjxU6hf68H5ZbzW7cLLvJnSI4qmriP4w7SUoGEuoAHj1SeaEjpYXADZHhHRUCNrOEwoZ9uccwUTZOfF0AFgxkA1cjAjtIhPNrzmb24SycSsPeHVqk1 X-Forefront-PRVS: 00429279BA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(199003)(189002)(33716001)(68736007)(6116002)(229853001)(7406005)(7416002)(3846002)(50986999)(54356999)(76176999)(586003)(33646002)(83506001)(2201001)(2906002)(19580395003)(86362001)(50466002)(101416001)(2950100001)(5660300001)(575784001)(107886002)(47776003)(7736002)(8676002)(103116003)(9686002)(305945005)(81166006)(81156014)(66066001)(7846002)(105586002)(77096005)(106356001)(5001770100001)(92566002)(19580405001)(189998001)(4001350100001)(97736004)(230700001)(42186005)(23676002)(921003)(1121003)(217873001)(2101003)(83996005)(309714004); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0664; H:[127.0.1.1]; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwNjY0OzIzOitYaHFjUFRUMjc5SEgvRnFZa2p1RnNqZHpQ?= =?utf-8?B?czdqT1pxZjZKMW15a3hDaENBZjJ5L2p3Q0JCd2hVL2dpbFRYdkkxdlJJK0FJ?= =?utf-8?B?TTJ0alU0WGNQWVprb0VMenJ1WmtWcVVTbGdqRFFKd0U4bmtuYWFXZ3ZUTzZD?= =?utf-8?B?WVFKUzEyZ3FLRVF5MFFnU0g5R1JSUjVkTVpRYXhjQmUzLzdtSlJVMGNETmd0?= =?utf-8?B?TVdBK2doQTdDR2wxMklWc0RlUm9DOFdnb1pHUUtKMVhvS3lBYkpuOGdFK0Uy?= =?utf-8?B?ZG11NFFIMGRURThjd2VTMEFqWjRtdzlBRWVCS3BrczBLeU53aGtnVFhnQ1ov?= =?utf-8?B?aGlUYkNYYlFWemE1YVlFY2gxKy9ML243Q2d4bEtFMFZoV2QweFBDOWg1bDJJ?= =?utf-8?B?bGlDWllENXB2TzlXaTRPZXNjSTN3bVFhQU1yUzN2cXpCWklpQXhWcWVnR2g1?= =?utf-8?B?Q21uc3VkY3JtUkVhbFNkZzkyVXliMnM2WDhadmQ1OStSTmpSMmFYQU5LMFBQ?= =?utf-8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BEOmhdbC1EMwnX2ZBSRXQ==; 24:r74EhUNJ3AjIJTuunn0mugFzhfQy+LF4lorb4O7RpgI0GlWYjqlouApT6vUaovqo8KQDqP1x11NGo07qZNeDnM8VxK6EkyYK+wGuAhnX7to=; 7:5t/vpd/gV1g8z8V4iUusm8wefls2T1VKKUK8y5+SHqjU/sdJfT5LECVg5a7H2uzFH84GqdleViorsCxha8+NIrFKNBAML5nW7LB4z50ec2r+egL/jTlhBOHfBqWbDVpI5ELHRbavwkWeDBYe1p68y3gbYD0NGl0VxBUq7p04K1gulH2Orpia+HQwsdDom7OoIB6PwArYfUpJkdfD/YDAI6xBm5Wp16lsmjvNjLB+6lwVAFA49Ozm/jltbPSRVvrp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0664; 20:iQANSj1V8M2cT8p6GbcfhgnCDOydPw7XzxgOs3L3X0b7JJxX7zhfAk1qt5gI4p+y7/7iKGwI+57Cd5jNtcfYGp+tZ4cm2eNRgolYyvYWjtD6pf8NbDA2+LSBxk+akdT5VVwDp9a+jPIdzj2ohiH+9ml1QypcwjiZLzoBgT+ncH8EPDW0c05AeIyYNJbB4c6h22Xw/ke8twHd1M67it9OevMTTBvc1M4wP0PCKS64Fr4+4wNOviIrwIoDHYTNx7iL X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2016 23:27:12.8269 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0664 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Lendacky Modify the SVM cpuid update function to indicate if Secure Encrypted Virtualization (SEV) is active by setting the SEV KVM cpu features bit if SEV is active. SEV is active if Secure Memory Encryption is active in the host and the SEV_ENABLE bit of the VMCB is set. Signed-off-by: Tom Lendacky --- arch/x86/kvm/cpuid.c | 4 +++- arch/x86/kvm/svm.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 3235e0f..d34faea 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -583,7 +583,7 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, entry->edx = 0; break; case 0x80000000: - entry->eax = min(entry->eax, 0x8000001a); + entry->eax = min(entry->eax, 0x8000001f); break; case 0x80000001: entry->edx &= kvm_cpuid_8000_0001_edx_x86_features; @@ -616,6 +616,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, break; case 0x8000001d: break; + case 0x8000001f: + break; /*Add support for Centaur's CPUID instruction*/ case 0xC0000000: /*Just support up to 0xC0000004 now*/ diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 9b59260..211be94 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -43,6 +43,7 @@ #include #include +#include #include "trace.h" #define __ex(x) __kvm_handle_fault_on_reboot(x) @@ -4677,10 +4678,27 @@ static void svm_cpuid_update(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); struct kvm_cpuid_entry2 *entry; + struct vmcb_control_area *ca = &svm->vmcb->control; + struct kvm_cpuid_entry2 *features, *sev_info; /* Update nrips enabled cache */ svm->nrips_enabled = !!guest_cpuid_has_nrips(&svm->vcpu); + /* Check for Secure Encrypted Virtualization support */ + features = kvm_find_cpuid_entry(vcpu, KVM_CPUID_FEATURES, 0); + if (!features) + return; + + sev_info = kvm_find_cpuid_entry(vcpu, 0x8000001f, 0); + if (!sev_info) + return; + + if (ca->nested_ctl & SVM_NESTED_CTL_SEV_ENABLE) { + features->eax |= (1 << KVM_FEATURE_SEV); + cpuid(0x8000001f, &sev_info->eax, &sev_info->ebx, + &sev_info->ecx, &sev_info->edx); + } + if (!kvm_vcpu_apicv_active(vcpu)) return;