Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754225AbdGXUIU (ORCPT ); Mon, 24 Jul 2017 16:08:20 -0400 Received: from mail-by2nam01on0040.outbound.protection.outlook.com ([104.47.34.40]:32685 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753401AbdGXUFj (ORCPT ); Mon, 24 Jul 2017 16:05:39 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; From: Brijesh Singh To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org Cc: Thomas Gleixner , Borislav Petkov , Joerg Roedel , "Michael S . Tsirkin" , Paolo Bonzini , =?UTF-8?q?=5C=22Radim=20Kr=C4=8Dm=C3=A1=C5=99=5C=22?= , Tom Lendacky , Brijesh Singh Subject: [RFC Part2 PATCH v3 13/26] KVM: SVM: Add KVM_SEV_INIT command Date: Mon, 24 Jul 2017 15:02:50 -0500 Message-Id: <20170724200303.12197-14-brijesh.singh@amd.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170724200303.12197-1-brijesh.singh@amd.com> References: <20170724200303.12197-1-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: DM3PR12CA0049.namprd12.prod.outlook.com (10.161.151.17) To BY2PR12MB0145.namprd12.prod.outlook.com (10.162.82.18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 358302d9-90b7-42bb-be5a-08d4d2cf1273 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: 1;BY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KR/MhUIg1cfjeCU1b6E5XrVpObE/83ZQMGVgIlLFHXICrHmgkitvBahltaAklfjnGqGHuUXuGWvTTyNEaMfy6h9B+gz5h3WZLPBNxuJFO1YLRWENjb//UsQKZbDVuPSlYZidzhpAI8bLO+nlNOyA8ZGOISDgUKuvxP8SF0XE4rGjPOLBRf3vIH8nVp1MsnRzYIBdlLFkdYn8Iiu+srNblt187k6RAtCv6Nz4SRF4qEc7NAXTtTd4scFucHcgPwI8fPFoOGwye+PpGotYxD3Z9YrVf1UKkuc9W3jjr4F7sMCdKDJ2J0hMcmyZpfTTCxCd/hObTWW80N2LdBeWaDakNd87yZ03eVy69Coa2IkRs= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:bnljp3Dsv6tR8KPwwPSco1KkwMOFkKpgJhhyPrF2OZeAyDW5+3Cff8KVoHYGpTyEbjSjpP6MnZ+n4rzln5bWLDyRKCXnSrj1RsWER1xElSnun0Pyywo3+g7pqix/ceHLvqJQLEPrp1+twPUqamevBeXGgVe+LUd8RYXt3tPqkEVTHbb54HMbTDx/XFNP8uONL/4HKOlHtreB6Zw4yhDgSmvKedhXXaP1bxfreCR8pYLcBVwxLWtWm6J1rxRlHZ0+QonZDe96U4PB2RV+9Vdmuf39sTscG5cHwT2wMEg1o7VwLPKSQ94Ev9764B7u6NVfX+xSaQjZTxhrkT/kudE+NYfvYnZ4rQeqOdwz/KNeJqUUBW+WIb8ym52pUuHTEdic+kWUL23A9NjayPAKVc6RcPeVGjon86j1o8ZHTtrwPjzkM5UGH6d2XKPpUl+scBsRg9Qt92lt4uUynPpABmkY/cmFzqNp/wQqIqNjK7ltCN67ECUg8wz59tc5nuqcGWkH X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123564025)(20161123555025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR12MB0145;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR12MB0145; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;4:iXInw3lIzeyX7VVsnrfTlViBiyaAas/WHUuAO9D1Tw?= =?us-ascii?Q?HsGSqHMUJjd0ZHYfuHTq9Ev/2RZNextqElJcptPcztODwN22QD9G06xfXP0x?= =?us-ascii?Q?zT/vNxwCNdcz/ayuGkzmI9QEAOxjKpY1mrHFiz4Op/ver30Bg0zCXALYgTfz?= =?us-ascii?Q?zKsWMiOlcmzpN10UlfU4h95rb/lNXYfsp2RG0wyH2OyFNieszXs/CPtqjY1j?= =?us-ascii?Q?/l1d6VPqUZMG4y3HWKz55U9vc5W+E4ASG4iCyYCUnaDeZg+BKfLuLaNwRsg+?= =?us-ascii?Q?4Wbkv092eOCzlHzGYCobeJsLFRDmgKanHJqDbp3dJxjUT2zJImP8xEBM4Z4o?= =?us-ascii?Q?uK2QmHTd+D7bk0VZI1t36gDVVknMtCzhmQEGEp1ped5h7R5zLeA8DYlc7m4X?= =?us-ascii?Q?maWC7hCarVzbKnP2mMpQCxqqYb948el+/xjtKIMy+93Hy4rfxXJzR6mj+Vx2?= =?us-ascii?Q?iZ8+GfOlsMHBp/9AD/hKYs5nzZ3BsOZQ4fQxof59/NAVtfIz0DAbelV9J4wh?= =?us-ascii?Q?ZxV8/JseMPUlIi1n6TQwpu9aR5jE0GlZ/tKrYgklM10/TNXybf2rMsZ4RSZq?= =?us-ascii?Q?RPVkJYE0VvULMF9FmtPN1CxirOGPP7sB55T7SrtPICQ2QlE723xlzSHC+AzZ?= =?us-ascii?Q?y+9Kb/3AO3msZYFm8xagzlq9cdyN/h8aI5C2wtrn+p2rxOQXn3fBjZPMQc5u?= =?us-ascii?Q?JUCG80/njbT3Jn55MVcxgtZCEyJDdS5Jdggrfyw9SMNJUFuIE0fB7okjAsQw?= =?us-ascii?Q?4wj2trEHpjgw0iLw/3LyG/HFvIVBI6I1cRY5/Vij/e4x0sofe/ERRYougvcz?= =?us-ascii?Q?FSkMw3emQTs04g4r4bR6BTYhElx5barYtXITcZtC+cwelQW7E5WY48hNHIUI?= =?us-ascii?Q?zJ6D+nWaEeNRSgXY4xNA536UH1n9VwRvz5TGIJk8Yi2VV/z0aFDDJ/FOAgiT?= =?us-ascii?Q?gVdFGTAUmMBGSmOcCgt52LQVC3tWIuKhZQSUG4EL+Ld7YudIU4kwHgg2Wjuj?= =?us-ascii?Q?IFF1fDfwvXMACrOKk37CBSnl0oOdNFYqn98ArOY4lH9Wo4jxYUq0CNF/myoM?= =?us-ascii?Q?g7Y03cQ+T2nh5hwzzLRY0ITLp27CBbkiUatBR0cL+a+5YdcPthgcoUL/398M?= =?us-ascii?Q?ebbBTZsx/VAYQmUtHrx34A/XUtpqZl7a2vNwZo0jmvsF7Am1ZBn83s5seifp?= =?us-ascii?Q?xOdVOpt1PKus2m2tXMbfZ+ssSHYh5B20NO?= X-Forefront-PRVS: 0378F1E47A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(39450400003)(39410400002)(39400400002)(39850400002)(39860400002)(39840400002)(189002)(199003)(7350300001)(68736007)(53416004)(105586002)(54906002)(97736004)(50466002)(6486002)(48376002)(2906002)(106356001)(33646002)(6116002)(1076002)(53936002)(3846002)(189998001)(101416001)(6666003)(2950100002)(478600001)(50986999)(76176999)(81156014)(50226002)(38730400002)(47776003)(5003940100001)(86362001)(25786009)(4326008)(36756003)(42186005)(8676002)(81166006)(110136004)(5660300001)(66066001)(7736002)(305945005)(309714004);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0145;H:ubuntu-010236106000.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;23:ZBJaz1TdF/lTFjMgI0YVhvBJ1xEL5C1H9DcVR6LMG?= =?us-ascii?Q?XT0Fx+u7+0pDXliQcJl9DD1cuZZ2OH6z0qWcjRabjPIeRU9jcwjXe2dQ5SpP?= =?us-ascii?Q?3fgjhzZFGu5IXvDkiRZW70Lre+Ihw3fUDkCi6TCKKowcaJ4g6amlgNkULS3c?= =?us-ascii?Q?4Rq2nx7853vSdSGn3sFuwOduK4BKZ30fdtoT7u95yEOcFrSUpk9D4oM6N4DO?= =?us-ascii?Q?MaeDjmd1F8agjzHVh9QHnKXBZmlE6fz3yI0OvDv04LWWXawNbwiO3vnws9Uq?= =?us-ascii?Q?J+XikQlheaCX8QF3TRFhGKuAe3rSqmhf4JMPL5vAJYjOymqaSAJXMwDAtD8p?= =?us-ascii?Q?fZo2O/zt7tz52S5XqF9eU07rOoGevf+MIfYb4RYFXyBgqrU1jOrJESy2JCOT?= =?us-ascii?Q?UQOScCIfmYGnXM73qDjdq8LIwmBryQIHTmYdX8DXpw1Cc8dg044QQEEaVLRY?= =?us-ascii?Q?4h21g1R9zlb7OuszqnYVoGx/490EdwuRpG5tGlW1R5NLkcuDxOl5CG0EFXbp?= =?us-ascii?Q?x9EW9oY4VUAlNiuxjonrGytXgy5RZAuJ6fEbX9OIZBHo7i4AV69H40DR/PhN?= =?us-ascii?Q?xCQNcN5SKBMuUK0sY7yHchfaNZcx/2W7qYOiaa6FjWfR+hZjj4ToH12Ri5Y+?= =?us-ascii?Q?PX4yPsf0WgErDifYg7CyW28OB1TjNBNXLQOvSvOI3wZg7qcdRd7hxZiAvZU3?= =?us-ascii?Q?byI6TBfMbnqce3d8a1+vVsf6CXJVt2Vk0OCc8wewLlrrF1iPwWvoe/Vtx77d?= =?us-ascii?Q?pBGPn0Qpqr7C0YRAMTCd274qWI1ziwhZg4HJb1LnDUjz4LpDHDCbAidIyxEA?= =?us-ascii?Q?HwLqXMZSG1RdoGIv9QWwLuem8LrmpnqLkU6lvZoTI+g9wLL28OukNa5BRwQf?= =?us-ascii?Q?dxSkGvHx2AaCQAhd4hu0JvuW3gWTCQoOmTExI0nldW9OjXYtp300CXrKNTvX?= =?us-ascii?Q?YJtfEn9GcQV9TXS7wdaFDspK9P/gf6JNDRVl7776HNbZShROyX44QEC28c92?= =?us-ascii?Q?w46DN8hm/GEBT6u7U7F/qEkQzUnb4yd3Trq5ajZa0WZo6Wh7Sg5b+jKQEk9h?= =?us-ascii?Q?eQkTAPzBVtWC36FUnnsb0n9LaUtr6PSBqPK0H8qnnurjif8dNLfdtqHsImtc?= =?us-ascii?Q?mCJb+wVx+89DZ2Js9d9UVxVVLNTfHrdt9Mh1P6q+eFAxJg3upn0TaF4c2pmC?= =?us-ascii?Q?sfDARFlkESAoLDBhn+ihH2uSMare7qKVbypidSUoSdDvd0jmH2bVxzEz5xDG?= =?us-ascii?Q?Ql/+nWxcs3iF/xXatr2PpKylIZPT9RF1HXNh7hRQ+zNiEcn78XpaEov9Lbva?= =?us-ascii?B?UT09?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;6:LweGbZer5vUCFxCARSWDn641hSHU3kg6fZYRTR3yG5?= =?us-ascii?Q?3kumXsOqimC1FCceQiDv0m/7rr/j2EZKH9c60Cs+OVTgjoEN2giq15u/iq4D?= =?us-ascii?Q?TED/6s3V85EbV3C1+BiNGJLVA04xy+OpsXRv8DRBd5omJh1OOiqAOuNYBJMA?= =?us-ascii?Q?2JvOJrd50oE6r5mVnY3YucA9xQ+UiOrH53OcrBqzb3k/SFBLbxwZjdXrgSwK?= =?us-ascii?Q?+zOMU0YHHAWtCceIGs/GTccvltd56AWZ3NrYknhHgcGtyfXkne1dte91Qxc5?= =?us-ascii?Q?LXDG6aMwiiI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Dc2TtCYMrJQMeVIGZAD8JBECabzHLDxm/mUnvbk49K4KpslPDB5MLrFXQ4yl4Y0PxlosWLp60OgTwSR24/o+ACROZSOc8VSkxwtPggkN3YCxCahNDCCCl47oaYz6sFKtWi9BGBPlGTEZP8IDxTMnFLqjnnMYyrvRXDbD0D+SYWliI+Wltc0cT7twwaOHHGi7SFGPdpuvZqdMEHj0JG5ubRscETgZA+FZAZpuNX8SZk6koGNkNoAJ+VmAvpHvxAA60mpEM3PcUL/YGnTGYhxkvxltBT/Js9MiQ= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:meiG0mB1UsnQJuMNwsiTchl9pSr4qi6TVbxVZAr5DrZkD7LS62SSLbQC+WyakVW43Mk3/4eVxxwsqt0OQA+TvFqwicQcknCFCkkM1f+DGRa+C6hgbo+5egScZAYOvYUelBD1kPzm7a3Z9kRLnP9JtXapmam6e2yeDPn0/zJhhtn8FoIAp8JBDkgYxBTJT444pVAeCkIE8xOVOa9MuLONbbglkT9wq/Pl72TstFQKpspyQPqZzyG8KQRS2IWMC7F6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2017 20:03:36.6189 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0145 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6081 Lines: 277 The command initializes the SEV firmware and allocate a new ASID for this guest from SEV ASID pool. The firmware must be initialized before we issue guest launch command to create a new encryption context. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 2a5a03a..e99a572 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -321,6 +323,14 @@ enum { /* Secure Encrypted Virtualization */ static unsigned int max_sev_asid; +static unsigned long *sev_asid_bitmap; +static int sev_asid_new(void); +static void sev_asid_free(int asid); + +static bool svm_sev_enabled(void) +{ + return !!max_sev_asid; +} static inline struct kvm_sev_info *to_sev_info(struct kvm *kvm) { @@ -1093,6 +1103,12 @@ static __init void sev_hardware_setup(void) if (!nguests) return; + /* Initialize SEV ASID bitmap */ + sev_asid_bitmap = kcalloc(BITS_TO_LONGS(nguests), + sizeof(unsigned long), GFP_KERNEL); + if (IS_ERR(sev_asid_bitmap)) + return; + max_sev_asid = nguests; } @@ -1184,10 +1200,18 @@ static __init int svm_hardware_setup(void) return r; } +static __exit void sev_hardware_unsetup(void) +{ + kfree(sev_asid_bitmap); +} + static __exit void svm_hardware_unsetup(void) { int cpu; + if (svm_sev_enabled()) + sev_hardware_unsetup(); + for_each_possible_cpu(cpu) svm_cpu_uninit(cpu); @@ -1373,6 +1397,9 @@ static void init_vmcb(struct vcpu_svm *svm) svm->vmcb->control.virt_ext |= VIRTUAL_VMLOAD_VMSAVE_ENABLE_MASK; } + if (sev_guest(svm->vcpu.kvm)) + svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_SEV_ENABLE; + mark_all_dirty(svm->vmcb); enable_gif(svm); @@ -1483,6 +1510,51 @@ static inline int avic_free_vm_id(int id) return 0; } +static int sev_platform_get_state(int *state, int *error) +{ + int ret; + struct sev_data_status *data; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = sev_platform_status(data, error); + if (!ret) + *state = data->state; + + kfree(data); + return ret; +} + +static void sev_firmware_uninit(void) +{ + int rc, state, error; + + rc = sev_platform_get_state(&state, &error); + if (rc) { + pr_err("SEV: failed to get firmware state (%#x)\n", + error); + return; + } + + /* If we are in initialized state then uninitialize it */ + if (state == SEV_STATE_INIT) + sev_platform_shutdown(&error); + +} + +static void sev_vm_destroy(struct kvm *kvm) +{ + int state, error; + + if (!sev_guest(kvm)) + return; + + sev_asid_free(sev_get_asid(kvm)); + sev_firmware_uninit(); +} + static void avic_vm_destroy(struct kvm *kvm) { unsigned long flags; @@ -1503,6 +1575,12 @@ static void avic_vm_destroy(struct kvm *kvm) spin_unlock_irqrestore(&svm_vm_data_hash_lock, flags); } +static void svm_vm_destroy(struct kvm *kvm) +{ + avic_vm_destroy(kvm); + sev_vm_destroy(kvm); +} + static int avic_vm_init(struct kvm *kvm) { unsigned long flags; @@ -5428,6 +5506,112 @@ static void svm_setup_mce(struct kvm_vcpu *vcpu) vcpu->arch.mcg_cap &= 0x1ff; } +static int sev_asid_new(void) +{ + int pos; + + if (!max_sev_asid) + return -EINVAL; + + pos = find_first_zero_bit(sev_asid_bitmap, max_sev_asid); + if (pos >= max_sev_asid) + return -EBUSY; + + set_bit(pos, sev_asid_bitmap); + return pos + 1; +} + +static void sev_asid_free(int asid) +{ + int pos; + + pos = asid - 1; + clear_bit(pos, sev_asid_bitmap); +} + +static int sev_firmware_init(int *error) +{ + int ret, state; + + ret = sev_platform_get_state(&state, error); + if (ret) + return ret; + + /* + * If SEV firmware is in uninitialized state, lets initialize the + * firmware before issuing guest commands. + */ + if (state == SEV_STATE_UNINIT) { + struct sev_data_init *data; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + ret = sev_platform_init(data, error); + kfree(data); + } + + return ret; +} + +static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) +{ + int asid, ret; + struct fd f; + + f = fdget(argp->sev_fd); + if (!f.file) + return -EBADF; + + /* initialize the SEV firmware */ + ret = sev_firmware_init(&argp->error); + if (ret) + goto e_err; + + /* allocate asid from SEV pool */ + ret = -ENOTTY; + asid = sev_asid_new(); + if (asid < 0) { + pr_err("SEV: failed to get free asid\n"); + sev_platform_shutdown(&argp->error); + goto e_err; + } + + sev_set_active(kvm); + sev_set_asid(kvm, asid); + sev_set_fd(kvm, argp->sev_fd); + ret = 0; +e_err: + fdput(f); + return ret; +} + +static int svm_memory_encryption_op(struct kvm *kvm, void __user *argp) +{ + struct kvm_sev_cmd sev_cmd; + int r = -ENOTTY; + + if (copy_from_user(&sev_cmd, argp, sizeof(struct kvm_sev_cmd))) + return -EFAULT; + + mutex_lock(&kvm->lock); + + switch (sev_cmd.id) { + case KVM_SEV_INIT: { + r = sev_guest_init(kvm, &sev_cmd); + break; + } + default: + break; + } + + mutex_unlock(&kvm->lock); + if (copy_to_user(argp, &sev_cmd, sizeof(struct kvm_sev_cmd))) + r = -EFAULT; + return r; +} + static struct kvm_x86_ops svm_x86_ops __ro_after_init = { .cpu_has_kvm_support = has_svm, .disabled_by_bios = is_disabled, @@ -5444,7 +5628,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { .vcpu_reset = svm_vcpu_reset, .vm_init = avic_vm_init, - .vm_destroy = avic_vm_destroy, + .vm_destroy = svm_vm_destroy, .prepare_guest_switch = svm_prepare_guest_switch, .vcpu_load = svm_vcpu_load, @@ -5540,6 +5724,8 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { .deliver_posted_interrupt = svm_deliver_avic_intr, .update_pi_irte = svm_update_pi_irte, .setup_mce = svm_setup_mce, + + .memory_encryption_op = svm_memory_encryption_op, }; static int __init svm_init(void) -- 2.9.4