From patchwork Tue Sep 13 14:48:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9329355 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 8CD4C6077F for ; Tue, 13 Sep 2016 15:56:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E1DC293DC for ; Tue, 13 Sep 2016 15:56:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 721A929424; Tue, 13 Sep 2016 15:56:59 +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 lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CAF23293DC for ; Tue, 13 Sep 2016 15:56:58 +0000 (UTC) Received: from localhost ([::1]:49788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjq4v-00083E-8G for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Sep 2016 11:56:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpX1-000438-T7 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:22:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjpWw-00019I-UX for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:21:55 -0400 Received: from mail-cys01nam02on0087.outbound.protection.outlook.com ([104.47.37.87]:4928 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpWw-00017w-Kh for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:21:50 -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=iEQ4FGiWZwRpSpcK3oSO/8oDyWMsy2A00a/OvDT0C/w=; b=QwE3q/W3Qxe71HLTpYAnzKFCSmshoMTq/aEK+tvXfLtDn14rkHZz4nsNGfOQ604fJZbLsl5PmG0sg3U8k2h1pqKB63Gb5xjaEHhsU+bVONtCj+r5yEF9DJ+TF8JLgHGuNZRxKM6r9v7gEX1d7Jx9rZWIfuTgeerBWlZbP7YWFM4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by BY2PR12MB0661.namprd12.prod.outlook.com (10.163.113.150) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.619.10; Tue, 13 Sep 2016 14:48:33 +0000 From: Brijesh Singh To: , , , , , , , , Date: Tue, 13 Sep 2016 10:48:27 -0400 Message-ID: <147377810767.11859.4668503556528840901.stgit@brijesh-build-machine> In-Reply-To: <147377800565.11859.4411044563640180545.stgit@brijesh-build-machine> References: <147377800565.11859.4411044563640180545.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR0401CA0014.namprd04.prod.outlook.com (10.162.114.152) To BY2PR12MB0661.namprd12.prod.outlook.com (10.163.113.150) X-MS-Office365-Filtering-Correlation-Id: 6ceb2f98-2825-420d-1435-08d3dbe5099b X-Microsoft-Exchange-Diag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ZPiR9BYZgV5Y6uBhHNOqzNLYgjK4o5Rbh6xyrG8BTQAoZMbE3z5LQ0p1juN7dD1AsNht5zo1L575KSu2AebExTsbgN1M+LPYGuXAnHzooQ2kRLP44n36x6tkkOQns8qMWTRRiYhlNixSiPsUCWJL0YdeNIRnSf53mPDqrjJCBwo= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 31:IwfoRgcJW+c2Ed3VqRXyRdONLQWPSgzC9vLyQJBPWRDJcIJ50C3yzMJz441ZvGqC5S/liwmWNspr21ZKV3Jn7ZrTlprbZ1K+Ayz6TeavvWeEsd4sV5P2W1EvINQi+m4aOwFULrrYqI3xfQvxeq0Tt+MyUpdkeKvSQpGDLrvvOPVcFvgipVSx/3iMbeW18AFoRLzn328zPh2HvD7t++q359Y7S/Y7a1hTziMKwOVE7kw=; 20:31EToIfKeB0sNgeohFr318cCAdRDO+KDgXDeLO/rdFnYZh6oUS2JDelauKmI1L4dgibPcRMQf8+WYWx47frG+LKAhQgqmJpaqsesIvmlg3ItFbpQw1LpEk6QDXIeHU/gpYWKnp3W5g6DKmTJGOxp7Zoud+q8L6GBq32oeegcVCy6+6g0dFYUUpr3q3e7JLaoVx7kHgNjt0ctNKoo0iPUmbrTIeMwUYyGg/+0T8zZcnop/VsgH7JaogWl2gYkLEUHa2519VeCcaJmMyNvpve9V0uzhITqbvV97F3z+uAqzdzr1wJ3qi1GNmjdpvvJN0IYqOg1EQ82mJ5dOhVZ6+gRHBh0YrM2eJ7YlGAm8s5umliJa9cGLsb1q6fmHXYTvGALzlh8LD8PHE5Ge/u+tk3SdE1l9lEwxAUU+JTWSDj8Uy9mRegz9p0n7oQbIA8uMUV/QdMj0qqO1GtL/r4srZQyYJQMptcUtMIvbu0wfDqQeRvzmiXtVI2SndfZhah4rmLR 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)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:BY2PR12MB0661; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0661; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 4:4rpqiesj36mqM0r4VDVQe9gHpTtEmq5mPxaLfxDE751S/bizq77HT0oAIm1XJMbK0/M+62JSTcbwGWK/7w2W9MASdkqqYI/Ex+SdU9Ns6wGA2Vq2CcIKPovrVJ7cYXmNWqpeB86oPkom4oGSqBvmvTvtJURJcGQv3bL7q4v0bfkFQzSoqlTwbWcUXQnljCbXv3s3VdKXcCFNmpSxnTk2Q7qc0X3cXBPBLiCCqTbshDh3/PaU+J45pyLuIhpX6kUkeDhnCMc1iSi1ny03gNohhZ3C+Lfu4nmqZonQWdV/uKYRv5faNTEFTpP27v+3pi8X/vx1gYPk+swHh+8u+6AVaJwrBFKExSjpq/ZBqWYhiDOBBk0GUuw1X1a1Hw3qif5mWQU0XgxeuuV2LUxNRT4x576L+YnKFJohvEtOoBU7J58O4kHELB7FTWb9ib/f/Dnz X-Forefront-PRVS: 0064B3273C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(209900001)(199003)(189002)(83506001)(15395725005)(66066001)(50466002)(92566002)(5660300001)(23676002)(9686002)(103116003)(47776003)(2201001)(3846002)(19580395003)(7736002)(107886002)(86362001)(19580405001)(106356001)(230700001)(6116002)(229853001)(7846002)(586003)(42186005)(81166006)(68736007)(4001350100001)(33646002)(81156014)(101416001)(15975445007)(97736004)(77096005)(54356999)(305945005)(8676002)(5001770100001)(2950100001)(76176999)(33716001)(50986999)(2906002)(189998001)(105586002)(217873001)(6606295002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0661; 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?MT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Zko1WmlvUFJHT3l0dDk3N21rckpJbWU4cmMr?= =?utf-8?Q?96GsTNscTN3Eo?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 6:zqdi3LV/x63qEsgVvgUC7DmeNWC92w4p61WPnZ7taqmE82O5HS7DI5Y+PvnNmNThQ659jNwBtp5Tan1FMv5vHTgaMScLOCcQeWqzTxP86VSd+tgvP1VSoD45oeFEnjyW0ZVMWiNIrTe4qd6UtdmHObFtcDKMsc4cBbRFwrEQzYGWf8FMcXFEK7BSf66aVWk7TXDhVmkbZPnr9qTidYRgOxMBo5jGJGl/5mj5Ep3A1h/Re/UGHu4C8pTYXm8fxsc4qIcnma5dfnXOpvhBjVahfOrQM2N9QBIn0R0jndrVNgR/ENzkj0/XGo2vY77wie1yAkCJYUMl7LAYFi/ETNDqng==; 5:3LL820w/Lb+7He/WTkCIN3re1O5g6QhDBcGscJ6Adx56CIaZz3MJD+2tSD4mkXfJx1ZufMBVnUsetbtmuRyUeBhOOmyU5JE//7EXdlvL9fIi1+kRrNu6eNtHPvySMYQl81L+8wDx7TF4w1PE8doh4w==; 24:9UE9sHDjQpzcpEEVh6tNAqB0bFioUuezXpzNEyTkoRGbLPYXll0O32z6jENEfw7tSuZdsYqVXDaGZH7KG4HZTUROIUP6ioze5zyBi4ap0P8=; 7:hAcfqcg+sVyI5HiGCi1sTv9xgiX1/ce/IHTmqJAHvc5DCbIPXq3JogrHMz08v6bcc+V/BbNI4MTDqKfusf1Uu4s9w8VTiApeu9h5fDKhdUiKvMAI8MwklXUUizec42d4qPECdd+exrGk7rIGUC1P4ho4yAFO7A5LiTuaxOU8MApYFuhh+lXZqiZ+f0vb8TxMAjfY9CCzyy9pZpjQJGAL/azhcwMv26sqHrIV02QuC+DVnjQ7Dg1qkAEx2KD6+nC0 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 20:tpSCGRlRMfUl/mR2uVPBpE607btEjgO7eeRdRZw3aY3P19/XvQYGVz0Vgei502/gYoNHesegpijzx6Io0Zl7VUviSRUJ8H/MS4MkuR5SXzWk1t4zB2CcmSyqOjaC5YQvLpTnmgM/4/Ujhd9Tfruu6Q9n6AesGnpaSOQmEW95tAVgj4vEWYI5Ww4Tyw0xiXfoBXXssfVVZaUGyWdfcVEyVEQ41eVUaudGxE+5IVgu+0ZZhrlxscwwDqKWVSxsDaF0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2016 14:48:33.2173 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0661 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.87 X-Mailman-Approved-At: Tue, 13 Sep 2016 11:45:47 -0400 Subject: [Qemu-devel] [RFC PATCH v1 10/22] sev: add SEV debug decrypt command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The SEV DEBUG_DECRYPT command is used for decrypting a guest memory for the debugging purposes. Note that debugging is permitting only when guest policy allows it. For more information see [1], section 7.1 [1] http://support.amd.com/TechDocs/55766_SEV-KM%20API_Spec.pdf The following KVM RFC patches defines and implements this command http://marc.info/?l=kvm&m=147190852423972&w=2 http://marc.info/?l=kvm&m=147191068524579&w=2 Signed-off-by: Brijesh Singh --- include/sysemu/sev.h | 10 ++++++++++ sev.c | 23 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h index ab03c5d..5872c3e 100644 --- a/include/sysemu/sev.h +++ b/include/sysemu/sev.h @@ -55,4 +55,14 @@ int kvm_sev_guest_finish(void); */ int kvm_sev_guest_measurement(uint8_t *measurement); +/** + * kvm_sev_dbg_decrypt - decrypt the guest memory for debugging purposes + * @src - guest memory address + * @dest - host memory address where the decrypted data should be copied + * @length - length of memory region + * + * Returns: 0 on success and dest will contains the decrypted data + */ +int kvm_sev_dbg_decrypt(uint8_t *dest, const uint8_t *src, uint32_t len); + #endif diff --git a/sev.c b/sev.c index 055ed83..c7031d3 100644 --- a/sev.c +++ b/sev.c @@ -432,3 +432,26 @@ int kvm_sev_guest_measurement(uint8_t *out) return 0; } + +int kvm_sev_dbg_decrypt(uint8_t *dst, const uint8_t *src, uint32_t len) +{ + int ret; + struct kvm_sev_dbg_decrypt decrypt; + struct kvm_sev_issue_cmd input; + + decrypt.src_addr = (unsigned long)src; + decrypt.dst_addr = (unsigned long)dst; + decrypt.length = len; + + input.cmd = KVM_SEV_DBG_DECRYPT; + input.opaque = (unsigned long)&decrypt; + ret = kvm_vm_ioctl(kvm_state, KVM_SEV_ISSUE_CMD, &input); + if (ret) { + fprintf(stderr, "SEV: dbg_decrypt failed ret=%d(%#010x)\n", + ret, input.ret_code); + return 1; + } + + DPRINTF("SEV: DBG_DECRYPT dst %p src %p sz %d\n", dst, src, len); + return 0; +}