Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753737AbdGXUIu (ORCPT ); Mon, 24 Jul 2017 16:08:50 -0400 Received: from mail-by2nam01on0080.outbound.protection.outlook.com ([104.47.34.80]:6848 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753179AbdGXUGh (ORCPT ); Mon, 24 Jul 2017 16:06:37 -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 16/26] KVM: SVM: Add support for SEV LAUNCH_UPDATE_DATA command Date: Mon, 24 Jul 2017 15:02:53 -0500 Message-Id: <20170724200303.12197-17-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: f5d6642c-87e9-4482-42bd-08d4d2cf14be 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-Diag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j4HAD0mwwVnki2xFrFsIQ58r8WHcJRJTsHN+QyppIjlyCrCK1oB8sGakFIdw7BZA0UUWgD9cq8CFpEDSpRNGsinAclcwkFVkq6tHXwu5JXyu39Pw+U8SujYGwy+qQKEirsVzdf3jK4nkjx7ZNNf/Mv881CwK9U0gCB4YWwR3e1yiFPTeqdw+WppG8O5d6loMA7yB6PgHF8EjYDEjutsWeRv+4T9r/7AX3hcWorHHLir+6QxQjYa6o6nRwF3mR0XYKumSqA2MSQBV27p5BFxX/GqDfJcmyE15YBvVYVvXS2ZuYBUPEN+lum7VIlgsaVidfh7mdoF8ACE/+VALCMFtb5hPaWm5G0pmxPaxPlqtgg2eiqPbjOYX52gCZBw4Xm6knT2gE= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:fFz1X/a3OSZE2J33i/aB0NDvZe9A4uWKrZCx467FLfQ0e4ij1tjtIc+8mTpEPnVNhsAf/20GRAcT1g/ZL+nCpcc5XnvYV1bT7SiY2UQ7EKbZ+AgrA6+ztOqSJ6+dLH0muLkSbZ9b3ol97ui2MaZB2EAG9HDEEAL0JvD52Fa/6FVCP8KsO2VfW3vJFKrt+Z/wr6LdYcJFwRGznh5OmyqxjYzFuHG3gbdtxhs0iA+F6jcqSQq+8O9/6UoMcZtIj2zPcstdHcEED5H4qAcxW8HoeUEmma9bRAHCugV4sM9AKqaRIvyW+nPruYn0xTc92S1QLBj1Gq/pb2IK71oCae41hzIh6F99a4oOaTXJapm9fmksW5lbQDiVblygLUUcogQ19demaGSh6KMEl5oglteoKVgzimQzpk528VJ2QtcQDb0AywXCVcXZ0irKym32GErbxnjPXFlkhDSSUJvYtORSxqxZAcTeczq++YA/WZYlaruiVtuhkSiBmODxdjL8YJyN 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:Ty2aoa+s0ycS2GutrTgvmsYR1IRNCfId7E+iSlHhSe?= =?us-ascii?Q?SZQKN1rG8romnAKThW4lHLVMWqYDPhQZ/BB7UefiPYt2i9itOCqCB8LH4Glg?= =?us-ascii?Q?mkQSpw8k9F/+4HQwyRXqrrQW/jG40TC9cQZcLuMSOLs1Kssdyv6tZoV0WtFx?= =?us-ascii?Q?JDXqughpvutg7aGBbOKalGP8lN2H0TIymqdg74jo/VzPgMhLuXm/hFariy4l?= =?us-ascii?Q?jocT5DTKsg8uAE6TbY8ql6xFws3j737uSjO/qkcyaKC7rsF9jUQLNsbcOXqH?= =?us-ascii?Q?JGEClkv7/q8Hq0GsxnjRk5Csml1IR3GsmdkWN459i28GBbVQplxigclAcve2?= =?us-ascii?Q?cPkWd4GJmMcYWc328OtK23zTjLEtZSyx1//bDGWMvnY/fAWyAMMNeBBcPwty?= =?us-ascii?Q?v3Y+xrdE6O/F96lqWZnebwY3AayTkmmDIQS1j0oxuYyX5tMvZ6OD6IuBZwHH?= =?us-ascii?Q?Vfiyv4OEV4ZKvtsMhSNo8B9rC00d1/a0cypYcNTAFzqOM0tJFWoz2HMwVnp2?= =?us-ascii?Q?0M9XfTJ5vFgZhCaPtL/ONQWw5G7VgoHIHi0pHvbGGm8WtFrZL3mPo+GjZ9S7?= =?us-ascii?Q?5FEb43xch8Hlqw7xSyiHzwsfaPemU17ac9oUhD1XlfbdYY+G7KSFtwwZtp5E?= =?us-ascii?Q?XQ3FfU9TCkhjUCOnB42ptUG2BCYCaBtSt6wXnXheWnzNwEhmxHQW7M8eE7zr?= =?us-ascii?Q?9sHbDkj9Piv4bGEw85zhVeOTFjX6jrQ9jzd4z4S4v6WvozvIXoyDfnBvojjv?= =?us-ascii?Q?5oCeezztfuR93zeRFzQ1Fp+HbGl84jGiqd8vt1o8PMMH9+Us5qmcmbGeywif?= =?us-ascii?Q?MuFgqVfot26Xef6EKcM+nvFDfT1zDp+gQtgxWH/jWMk5WtqNX4RQMc/9SlyY?= =?us-ascii?Q?N5ejGLS/FyNbdXhiz0I52Z44uWIMFpDmxOKvqkJIZhFYkeS3CltPIr7QboKG?= =?us-ascii?Q?u+wUCTxQHZZlQy0TV4Jv1M35XlN0FhBI0zlOgYjSYEmXDj7FUSbfSNESst+2?= =?us-ascii?Q?NXUZhtsnpmVGtsftZiyBlnY487q5bQs1bXuc/WZz2d0k04Pxcxjr21knN2yy?= =?us-ascii?Q?oT49zPnu7SY47VsTxUNJMb2QenLmiMtT1VkIrPJ6aT47BWxl1KBlxmfIWf+r?= =?us-ascii?Q?Av31TiAKFmwCvXvLzzQnxL+Re8bT9H+bS9MOnjYa/zr7nTeEF1IhoEgxKTWv?= =?us-ascii?Q?JFBn1XI2/Cufa3Xau3B2er9fjU7iYu52UQ?= 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);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:DmKwYxAY/loqwajo5GTu+x4G1xbnZ/UZ70IQ8fdrN?= =?us-ascii?Q?f7Y8yoonx46m7plVm40m3LoJAofXLlDlgVKniK3ojYfPd1nmci84p3O+rp66?= =?us-ascii?Q?TSIlyQXBV8DFaEVLY00H5inRAuP9ICNsLOWd9yk3uu1p+nfKW/wNtlHIdAYQ?= =?us-ascii?Q?0bUTIcVaMn/3189YMmqXgceIv05tVdAAu65GTF1jzkQNegIhz4YgeiDep+WS?= =?us-ascii?Q?J4/Gm650jMiAFh7zVu8HyGW1oAplNEb1ZPQ6m/fex2CI9Vg0hWoNWVBWX6EW?= =?us-ascii?Q?JfQ+svTd1qsgbedXRGEXMkJoCHaxeprh+4o5yY3iwO1quK29VJZeX9HbdvW/?= =?us-ascii?Q?xzsQnrYTilkb2LgMzPWVq5eG0UlutCuc00FaQxCA15NR8AKBKh/+jwTZiGDv?= =?us-ascii?Q?Il8LnM5iuL42oWfxyX5zVpAGR2w27tz2JMYaNooTakrSJZlxoIti6ij7g+mz?= =?us-ascii?Q?dfgcu2eBfYArUO2Xc1ngX1KRbaAc0mp5MQ+vVNeMiGf936uUh+JhnmpVTFJ8?= =?us-ascii?Q?Cp7GF/uXRI7o+O1NYXfIzHTqNyJqxfJZYqO86KrPaQdgACVn+RiQ+S5oy02j?= =?us-ascii?Q?pyIkQWr4xMQ0YJQJPZP9ojlxVBPqThz1piwxOpDjyPdr1gU02oONTUxye6SC?= =?us-ascii?Q?/RTEqYFUUieMSnL+rotl6s/M3GYrLj9ZJQAhj4IY07n8I/MIUDvsuIxP1IEi?= =?us-ascii?Q?PPWS54hbq06M8qRnKwqh+PCjs0MtorjdQ+bx3aN27jnvuZAFCFdj2Q4A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/OoMhsNLSE5m8fQ0Jgyog4Xd0a8va3gEjXTd3+ZQJrTs8f05k16ORdhiEr1KlTT4a7QsHgCkYpd5FHiNMVlGUskXH20BUJrhaBPsNCf5EhhU+akUS90/vsGm7RplxuR5Ls105941iE8wPpdE+xIK6o7aAxuCHvki/l/csWv+rK2DdBFBtm9QbqaNOBSXFW0LbrXDZYK4yhxz32WYRQkXEOSGes/3G5/wiRitnXlzQsfaN63jZtwq0U0rJH4tavfwiihVp9P2B5fx83gxfSRms= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:0VEjtGfHLn/WTKx4WCFKUCkYPqKSLFf339x7dF75hNASuROkeH3ez7iamm6gXImBLNj1hpLvPpMzBbUlYmFgvt2QnDcXoNPpg4IEylfS+mtt9qL8x3K+1jbTQFZ5JQydxtyoCTiuheMGwSNlXthx7UwxY3zX4ekHQrkrSeA8xh5388xo/dlxrSm2iQP1vymF6KkkgTXlE5gua4WV/JL5RoKS4M6/z/SzTf+bD2//p8vBN+QseKCy7aZxHLx8N4Sy X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2017 20:03:40.4627 (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: 5233 Lines: 207 The command is used for encrypting the guest memory region using the VM encryption key (VEK) created during LAUNCH_START. Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 3e325578..91b070f 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include @@ -331,6 +333,7 @@ static int sev_asid_new(void); static void sev_asid_free(int asid); static void sev_deactivate_handle(struct kvm *kvm, int *error); static void sev_decommission_handle(struct kvm *kvm, int *error); +#define __sme_page_pa(x) __sme_set(page_to_pfn(x) << PAGE_SHIFT) static bool svm_sev_enabled(void) { @@ -5796,6 +5799,164 @@ static int sev_launch_start(struct kvm *kvm, struct kvm_sev_cmd *argp) return ret; } +static struct page **sev_pin_memory(unsigned long uaddr, unsigned long ulen, + unsigned long *n, int write) +{ + unsigned long npages, pinned, size; + struct page **pages; + int first, last; + + /* Get number of pages */ + first = (uaddr & PAGE_MASK) >> PAGE_SHIFT; + last = ((uaddr + ulen - 1) & PAGE_MASK) >> PAGE_SHIFT; + npages = (last - first + 1); + + /* Avoid using vmalloc for smaller buffer */ + size = npages * sizeof(struct page *); + if (size > PAGE_SIZE) + pages = vmalloc(size); + else + pages = kmalloc(size, GFP_KERNEL); + + if (!pages) + return NULL; + + /* pin the user virtual address */ + pinned = get_user_pages_fast(uaddr, npages, write ? FOLL_WRITE : 0, + pages); + if (pinned != npages) { + pr_err("failed to pin %ld pages (got %ld)\n", npages, pinned); + goto err; + } + + *n = npages; + return pages; +err: + if (pinned > 0) + release_pages(pages, pinned, 0); + kvfree(pages); + + return NULL; +} + +static void sev_unpin_memory(struct page **pages, unsigned long npages) +{ + release_pages(pages, npages, 0); + kvfree(pages); +} + +static void sev_clflush_pages(struct page *pages[], unsigned long npages) +{ + uint8_t *page_virtual; + unsigned long i; + + if (npages == 0 || pages == NULL) + return; + + for (i = 0; i < npages; i++) { + page_virtual = kmap_atomic(pages[i]); + clflush_cache_range(page_virtual, PAGE_SIZE); + kunmap_atomic(page_virtual); + } +} + +static int get_num_contig_pages(int idx, struct page **inpages, + unsigned long npages) +{ + int i = idx + 1, pages = 1; + unsigned long paddr, next_paddr; + + /* find the number of contiguous pages starting from idx */ + paddr = __sme_page_pa(inpages[idx]); + while (i < npages) { + next_paddr = __sme_page_pa(inpages[i++]); + if ((paddr + PAGE_SIZE) == next_paddr) { + pages++; + paddr = next_paddr; + continue; + } + break; + } + + return pages; +} + +static int sev_launch_update_data(struct kvm *kvm, struct kvm_sev_cmd *argp) +{ + unsigned long vaddr, vaddr_end, next_vaddr, npages, size; + struct kvm_sev_launch_update_data params; + struct sev_data_launch_update_data *data; + struct page **inpages; + int i, ret, pages; + + if (!sev_guest(kvm)) + return -ENOTTY; + + if (copy_from_user(¶ms, (void *)argp->data, + sizeof(struct kvm_sev_launch_update_data))) + return -EFAULT; + + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + vaddr = params.address; + size = params.length; + vaddr_end = vaddr + size; + + /* lock the user memory */ + inpages = sev_pin_memory(vaddr, size, &npages, 1); + if (!inpages) { + ret = -ENOMEM; + goto e_free; + } + + /* + * invalidate the cache to ensure that DRAM has recent content before + * calling the SEV commands. + */ + sev_clflush_pages(inpages, npages); + + for (i = 0; vaddr < vaddr_end; vaddr = next_vaddr, i += pages) { + int offset, len; + + /* + * since user buffer may not be page aligned, calculate the + * offset within the page. + */ + offset = vaddr & (PAGE_SIZE - 1); + + /* + * calculate the number of pages that can be encrypted in one go + */ + pages = get_num_contig_pages(i, inpages, npages); + + len = min_t(size_t, ((pages * PAGE_SIZE) - offset), size); + + data->handle = sev_get_handle(kvm); + data->length = len; + data->address = __sme_page_pa(inpages[i]) + offset; + ret = sev_issue_cmd(kvm, SEV_CMD_LAUNCH_UPDATE_DATA, data, + &argp->error); + if (ret) + goto e_unpin; + + size -= len; + next_vaddr = vaddr + len; + } +e_unpin: + /* content of memory is updated, mark pages dirty */ + for (i = 0; i < npages; i++) { + set_page_dirty_lock(inpages[i]); + mark_page_accessed(inpages[i]); + } + /* unlock the user pages */ + sev_unpin_memory(inpages, npages); +e_free: + kfree(data); + return ret; +} + static int svm_memory_encryption_op(struct kvm *kvm, void __user *argp) { struct kvm_sev_cmd sev_cmd; @@ -5815,6 +5976,10 @@ static int svm_memory_encryption_op(struct kvm *kvm, void __user *argp) r = sev_launch_start(kvm, &sev_cmd); break; } + case KVM_SEV_LAUNCH_UPDATE_DATA: { + r = sev_launch_update_data(kvm, &sev_cmd); + break; + } default: break; } -- 2.9.4