Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755426AbdGXULn (ORCPT ); Mon, 24 Jul 2017 16:11:43 -0400 Received: from mail-dm3nam03on0066.outbound.protection.outlook.com ([104.47.41.66]:3232 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754123AbdGXUHq (ORCPT ); Mon, 24 Jul 2017 16:07:46 -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 21/26] KVM: SVM: Add support for SEV DEBUG_ENCRYPT command Date: Mon, 24 Jul 2017 15:02:58 -0500 Message-Id: <20170724200303.12197-22-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: 7d9b1ffd-5f55-48f4-a2e3-08d4d2cf1888 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-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kH2Ee4PjErP9k+EtUv6axmCNpSQtSRywG6MQHz/Q/Rh31JvgxPJhlwQfmiPVjwTipZoW2mdCVfasD2QaPD37iN2XhEH90Q+O4KUUWiiqVznTF2OxOTAsWOCUk/KXwutUExZRrOvNazzr899/x/JgXEiAs3OaLHzZLM1IiyNV09YCWh/gmsPeujjkgeX+jf3TPzCq5BfNrx55BrrsxmJvbRC5bMhbWx9ttRMVqnBqWy4sYH4NFZZ0qTkw9vnndKMqU34Plx1XMADRqXdey3l85hIt2oO4gJNK4O8O4zMRSk/YCPp54mQlI8VeYfniqAvl4sJzQv10UdAqldCn+K6TauNTN5jlKdcLplD0tasQtAn/DIfojqOdPdkv/NE/bnrTWOSLuxYX8/ijzknUHkvCubNhKZtTKTY= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:WOsbB2WKEw49HY/rVJ5HRLmcGv5MBRkV2nvpKldxuxaq5UZlzujToZ6YLWNj/YeGwDmgJRu7WcVo4bRXx+KjfMHoy7hcKQn9fbd40dMZj4BzOPc4p47AhrSrkaF9yBD71BShmL66r7SQsQ6e6iFDxnms94D6t5SXULwX16EwImwqYRKW1fdZwJQEuU3u6XfaclIEn2FgFscH+XFGqCdm4cqsrkOcw5OoiK76LlGbhcmlo61+mlB5M8p5YKlJgqSwIHZ8IF0JqHStMPckU35cD2qXIeBuGlndzyF9+CJQp89KKH3Gbfh4Ke5yINO7SdJQDmt/2muSWAkijpAT25AKtWflS8N4Lu5j1Hty4YxWzG7NN7tBaLqqxvW3RzBR9V6nPA34Z7fQ/JHCaJp05Zc/YHagLkTPtEkrllZMqUDKD/8zzVtbJAo9F42585rS7Cn0zs/epfSfHgI8zjicE9Pdes6ESKQ6U38pVq8I7opYyhmBES0iY8ZzyxC2fBns2s9d 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:M5p6GJw4uCLkqjpHGRMUVnlHEkfsUNKPFBEmDLdyFA?= =?us-ascii?Q?c1F2fFsQSdAQMpfFccE+nw/PqlolDUabQKlz8i7cgjxl0y0OLKdd/cVwfU2N?= =?us-ascii?Q?BuyjOL/GRyk3B+e6pfMMxT84FxBe8q+P/idOI6AUmcotEQ9QtkCEYL8vJOdF?= =?us-ascii?Q?lAC5bszyL6ynnaaSbOurECc5l7Q2z6K4Lel/mx7PRQ9Lc/c3vDWt8bpEX8F+?= =?us-ascii?Q?8z1P9NEBhn3cGsPD9W5ciBIb5C85SWf2AXI1TaQE9vUAEgS+UCo0uMqVM7Hs?= =?us-ascii?Q?n9H3OetlJdUDBGvR8mEkqZS9o5IrUS8VhnuheY5GX5jnZzDA3vsSy/n8+dxo?= =?us-ascii?Q?KKutunxZYOem6jnJOYPUPoWSF1q5gjuqUzAoDj8WW0pNzliw3NT7zDYiFlbj?= =?us-ascii?Q?O7SgcqceDICyJuDPnm23JLGusXnKnOOATpzUXYCldTlJc0Z48mXiS3TiSZQw?= =?us-ascii?Q?EQWvu8xzslJpOEMb0VM1evd03a98jA5XBz/cFjoHNa7JMkhTrMHgRPYr8er+?= =?us-ascii?Q?rkZFhd9kkiX1fxxpI5LtZxiY5QbsbnGYuLItrhxcY0fpv/Yx7smS9+g3mQVs?= =?us-ascii?Q?Kh2JOrVA8zR1jwUrgi5vO5DpUnv60aYm/Ov0IhbIb9VzarUMmLO7ZpMC+lT2?= =?us-ascii?Q?8PLqP9OI7fqFuUrpGCz5ZdR6R7qVMDKrJwhubZVTPg6afQ+9HLxqeg1GmNme?= =?us-ascii?Q?3p0wgd3wT7xhayc58qLyfqSZIPavuxVnAu4nEXstWASUcjIfAUUsHg35q9bo?= =?us-ascii?Q?+AaK8HN8aR3B5x+gWNJ38Rmp2VHzvkJtfdJwAHPqty+L8y46FhiTvccrN6g2?= =?us-ascii?Q?3tY6kGzK4Hs3g+4f9EYxUcF1LZmssZzI4c6S6y6RrHVGreZNqPE1R6F5D1Bh?= =?us-ascii?Q?gk1r1rSV8XU4RBfuGzpmjzfaacbsCZyxQEwb3D/kRbCfwPYK7oBKNujST0q/?= =?us-ascii?Q?aqTYIy5vssptrPFDYxNRlM6CybhZZaWjkffQRR0SL034JcP338r2EZ/WXhGw?= =?us-ascii?Q?+4IDCkuT6Z1fx+OhvY+eO4UeJL42CnUCT2FXFKnJytMJzQMp2mvdYEZEy/md?= =?us-ascii?Q?+oQdQtN+LjNwfgrKDnl5NvWk+dgoLf+eHAF6cxILbwpGJ2DwuBtlx3qt01/j?= =?us-ascii?Q?1uhC/uph2JFaygVYKEd3TMKoCZZrVn0hXsrs36nxNDO35sxyrZxHD+TZcdYR?= =?us-ascii?Q?VijL0SDEMsZyz/8VKRf0UcWly4GdlK3CnL?= 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:w7M1VMV0MAaBvMBZgfJqhp7dEVlYIh4Xfclq99rEW?= =?us-ascii?Q?zSr07+hF5NJDV6QK/MFDeEcq+EUi+pKb8Tigt+X13nNIN53ODQ7VaEn7lcG2?= =?us-ascii?Q?EpdVfD+pbWfgrKgNPwPL47BcQ/tvvlW8nTdYie1zxJysqBn8/BADck9njJ3H?= =?us-ascii?Q?Q6QW8F5l1JONvPgxXX397MFh5UN2JfkVveH9RjgtSaErg6omn/K1vSARrwsf?= =?us-ascii?Q?8optPvfvPOd/XY+LQx+mQFz7YWDSVSLSlG6DDCGzGu8brwkxg4fc1UyGB5ME?= =?us-ascii?Q?0Ag2oh23hj0Aio5ecGpvaHvmz3WI4BjjvCIazBPbB04728ZiA2VBTJ64hfJC?= =?us-ascii?Q?NpgQloJLmvGFsq6Z7J2Cqk/mJTupwwwlKv+W2LI1ty/epM0HuJvkncyAjfgD?= =?us-ascii?Q?CoDGQJjnuwpV4xEqhoYz14RaMRvIQJ692kmoEnFglTEQ9+Ura8V4f6XWuFD0?= =?us-ascii?Q?n5o69SDTiMF3ufvWCJomUyMCx6a/HsNafcNKb9sL4ItIiU4KzlhCQPAfyTRj?= =?us-ascii?Q?n8g6QQs+tucfED4ruPPuPIU2oJqKS4FW35WKRLrAqK4ieXMEroNdbGBzOWFJ?= =?us-ascii?Q?QaRKoH0n8qbodRyiXyZu2Y0AaBndibgMxSxfBcLTkRcXfAM3V9jTCKaxX7Yi?= =?us-ascii?Q?rjyPIW0Mdp4KEoWkCqOwheS3K6m+z39z4g3Pw650FfGLkWUaf102/aWxzUwJ?= =?us-ascii?Q?8mCcpRAC1ALCHzvFyxzE/FoHOorDKunHXJl6vGvNdoGqseSrkhKPC3rfpwn5?= =?us-ascii?Q?73QrA8yEtVD1MVYsEw5Tst+MpU6aPuLdd9N8bzNzH+GqZvlCT9x6XjyNvUs5?= =?us-ascii?Q?lE4n2cvx4kxUv5ax94E7gn/egbu1eThGQL8Xdrc/AqHB04M0jTsPy8Z2HX68?= =?us-ascii?Q?tf0nlALiNjPf1Si51cjIcJJ4J8EJ6n1Su+SvsWoP46XLhIV0foH4z1obLPgY?= =?us-ascii?Q?s5dVwq2NmMeXEvGljCNQcUuNeZ7sYcYHOSRJwxwTb8bVyq8p2OoPR9AvPwfG?= =?us-ascii?Q?XJ27ooTkF7xNzGifeWLSI7sNXUuXZBUtha3M8BDb4Fq9FvFRTTx23vpH6LSU?= =?us-ascii?Q?jHgcxJmJi72mCj26khY3mQPzXwB8Kw0j4IuCzePKucxRMOYhHxHnascdFML/?= =?us-ascii?Q?UX650iaW5yrWqAV2COLte00UWbg3FQqWUZxvbqLwrzLbGVoF2l4NFkA5DpdJ?= =?us-ascii?Q?BEy2JIBs28Q6R15vvc14DY9WgAJGlu1iPsfJK3pXrdoiM3BHlW3cF9Nbay4q?= =?us-ascii?Q?jhw1gdf3QAEHmboe9xouBSIlwDmQxkZdZ76NdCm?= X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR12MB0145;6:33f8zJJCcx4eDXBa/Fj25c9OptxxsJx0crzRvuOpoD?= =?us-ascii?Q?Kros1Jh01KQf8qf/dSA4emqDIVpqZAZc4puvGRm8LSYqQAf1/lASFiBb3b8U?= =?us-ascii?Q?VOBYTsK0DBSomPrn6/K++YUC9N9g1TXw9rmPnxGfWeozFyyKZ6hR6wBtWP2O?= =?us-ascii?Q?F6xYYm9SgFkdt1vy6qdplrdFmw0yZraV0dlXACN9i9eichkJUWm5mQp76S/9?= =?us-ascii?Q?wjEvsb+8eD72X/RNbBapt0vOk8ULt3W9GkrUabNlle9uDOd6q4Dq3s/WO/iV?= =?us-ascii?Q?pSPf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UXbfSYhl/AaaCLx2dfo1vsIibFQP1wvk5Dxwq+Y9YrO9xqziAkWttK1OKL+k3NNJnKGrInKNbADHGvD4hwfEFLUw3jVIa++Tu86AETKaeU7fS0YY1Uko6xXYs/rRr4UOr+xZnvy1njpPm9wnoxQeb37Vbx+9Vx9nk8E8yxop+gFonQz4uGOm08WS8xtOaq4OJbC5oiImWqeWlAmAXd6/QhJghMBos8ofQDOD1Cm/sN6owPr1lGaorHeBbLQ2wy5SGU3oeF005EKHeyfMgI4PdyPg1F++xhnv6kTfRJzQ3ro= X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0145;20:HmKSv/cTaxxTulYP0RQs/ZjxWuZ1E/beEmqsEgh+M5LkI/84eHuC2PHMTphOgGvINhwUSVLtm5CnpcIcCkul4rBVCb5kvFdvQpvPbdSeXPavP9CLUumnwtCRiQABw2x+uNKI8DC78kHrS1tmowQT75rCnyszfZkhXr6UeH09OJf3zyprhtKAK6f7zy7eVfP6BeD+Gp8ajR0codG++w8hs2vB8vL+uJHcacP2f5rZVuQw622wsdJKNP1G7yfB9njf X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jul 2017 20:03:46.8222 (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: 5432 Lines: 203 The command copies a plain text into guest memory and encrypts it using the VM encryption key. The command will be used for debug purposes (e.g setting breakpoint through gdbserver) Signed-off-by: Brijesh Singh --- arch/x86/kvm/svm.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 933384a..75dcaa9 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -6214,6 +6214,176 @@ static int sev_dbg_decrypt(struct kvm *kvm, struct kvm_sev_cmd *argp) return ret; } +static int __sev_dbg_enc(struct kvm *kvm, unsigned long __user vaddr, + unsigned long paddr, unsigned long __user dst_vaddr, + unsigned long dst_paddr, int size, int *error) +{ + struct page *src_tpage = NULL; + struct page *dst_tpage = NULL; + int ret, len = size; + + /* + * Debug encrypt command works with 16-byte aligned inputs. Function + * handles the alingment issue as below: + * + * case 1 + * If source buffer is not 16-byte aligned then we copy the data from + * source buffer into a PAGE aligned intermediate (src_tpage) buffer + * and use this intermediate buffer as source buffer + * + * case 2 + * If destination buffer or length is not 16-byte aligned then: + * - decrypt portion of destination buffer into intermediate buffer + * (dst_tpage) + * - copy the source data into intermediate buffer + * - use the intermediate buffer as source buffer + */ + + /* If source is not aligned (case 1) */ + if (!IS_ALIGNED(vaddr, 16)) { + src_tpage = alloc_page(GFP_KERNEL); + if (!src_tpage) + return -ENOMEM; + + if (copy_from_user(page_address(src_tpage), + (uint8_t *)vaddr, size)) { + __free_page(src_tpage); + return -EFAULT; + } + paddr = __sme_page_pa(src_tpage); + + /* flush the caches to ensure that DRAM has recent contents */ + clflush_cache_range(page_address(src_tpage), PAGE_SIZE); + } + + /* If destination buffer or length is not aligned (case 2) */ + if (!IS_ALIGNED(dst_vaddr, 16) || !IS_ALIGNED(size, 16)) { + int dst_offset; + + dst_tpage = alloc_page(GFP_KERNEL); + if (!dst_tpage) { + ret = -ENOMEM; + goto e_free; + } + + /* decrypt destination buffer into intermediate buffer */ + ret = __sev_dbg_dec(kvm, + round_down(dst_paddr, 16), + 0, + (unsigned long)page_address(dst_tpage), + __sme_page_pa(dst_tpage), + round_up(size, 16), + error); + if (ret) + goto e_free; + + dst_offset = dst_paddr & 15; + + /* + * modify the intermediate buffer with data from source + * buffer. + */ + if (src_tpage) + memcpy(page_address(dst_tpage) + dst_offset, + page_address(src_tpage), size); + else { + if (copy_from_user(page_address(dst_tpage) + dst_offset, + (void *) vaddr, size)) { + ret = -EFAULT; + goto e_free; + } + } + + + /* use intermediate buffer as source */ + paddr = __sme_page_pa(dst_tpage); + + /* flush the caches to ensure that DRAM gets recent updates */ + clflush_cache_range(page_address(dst_tpage), PAGE_SIZE); + + /* now we have length and destination buffer aligned */ + dst_paddr = round_down(dst_paddr, 16); + len = round_up(size, 16); + } + + ret = __sev_dbg_enc_dec(kvm, paddr, dst_paddr, len, error, true); +e_free: + if (src_tpage) + __free_page(src_tpage); + if (dst_tpage) + __free_page(dst_tpage); + return ret; +} + +static int sev_dbg_encrypt(struct kvm *kvm, struct kvm_sev_cmd *argp) +{ + unsigned long vaddr, vaddr_end, dst_vaddr, next_vaddr; + struct kvm_sev_dbg debug; + int ret, size; + + if (!sev_guest(kvm)) + return -ENOTTY; + + if (copy_from_user(&debug, (void *)argp->data, + sizeof(struct kvm_sev_dbg))) + return -EFAULT; + + size = debug.length; + vaddr = debug.src_addr; + vaddr_end = vaddr + size; + dst_vaddr = debug.dst_addr; + + for (; vaddr < vaddr_end; vaddr = next_vaddr) { + unsigned long n; + int s_off, d_off, len; + struct page **srcpage, **dstpage; + + /* lock the user memory */ + srcpage = sev_pin_memory(vaddr & PAGE_MASK, PAGE_SIZE, &n, 0); + if (!srcpage) + return -EFAULT; + + dstpage = sev_pin_memory(dst_vaddr & PAGE_MASK, PAGE_SIZE, + &n, 1); + if (!dstpage) { + sev_unpin_memory(srcpage, n); + return -EFAULT; + } + + /* flush the caches to ensure that DRAM has recent contents */ + sev_clflush_pages(srcpage, 1); + sev_clflush_pages(dstpage, 1); + + /* + * since user buffer may not be page aligned, calculate the + * offset within the page. + */ + s_off = vaddr & ~PAGE_MASK; + d_off = dst_vaddr & ~PAGE_MASK; + len = min_t(size_t, (PAGE_SIZE - s_off), size); + + ret = __sev_dbg_enc(kvm, + vaddr, + __sme_page_pa(srcpage[0]) + s_off, + dst_vaddr, + __sme_page_pa(dstpage[0]) + d_off, + len, &argp->error); + + /* unlock the user memory */ + sev_unpin_memory(srcpage, 1); + sev_unpin_memory(dstpage, 1); + + if (ret) + goto err; + + next_vaddr = vaddr + len; + dst_vaddr = dst_vaddr + len; + size -= len; + } +err: + return ret; +} + static int svm_memory_encryption_op(struct kvm *kvm, void __user *argp) { struct kvm_sev_cmd sev_cmd; @@ -6253,6 +6423,10 @@ static int svm_memory_encryption_op(struct kvm *kvm, void __user *argp) r = sev_dbg_decrypt(kvm, &sev_cmd); break; } + case KVM_SEV_DBG_ENCRYPT: { + r = sev_dbg_encrypt(kvm, &sev_cmd); + break; + } default: break; } -- 2.9.4