From patchwork Tue Nov 1 15:54:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9407609 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 62C42600C8 for ; Tue, 1 Nov 2016 16:10:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 540952998E for ; Tue, 1 Nov 2016 16:10:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E4D29992; Tue, 1 Nov 2016 16:10:41 +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 099F22998E for ; Tue, 1 Nov 2016 16:10:40 +0000 (UTC) Received: from localhost ([::1]:48969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1be3-0002IN-7Y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Nov 2016 12:10:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57558) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1bOC-00066w-Sd for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:54:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1bO8-00040M-1k for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:54:16 -0400 Received: from mail-by2nam01on0048.outbound.protection.outlook.com ([104.47.34.48]:28325 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1bO7-000405-PG for qemu-devel@nongnu.org; Tue, 01 Nov 2016 11:54:11 -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=++H+fJfnb7TMpo3R6+4Hhj8IEgAu7+K0kpdhp/0c5z0=; b=LBxH4S7AkbeQt4p/E4Y6yTT8xkhpAFEl79hndDcihzbo9JGfzDNR63qAOvKtqeZna3a6WzLHa1L5vZLvkAm6kJNR211HWxF3CrncJefh8XVxRA9Oqwnk7M8XWGXDzofkjAD4pFy6+5DbG7rZZemJd9YMKjzX7iCI/J2+AAXpldE= 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.693.12; Tue, 1 Nov 2016 15:54:09 +0000 From: Brijesh Singh To: , , , , , , , , , Date: Tue, 1 Nov 2016 11:54:06 -0400 Message-ID: <147801564680.18237.14482964919097131701.stgit@brijesh-build-machine> In-Reply-To: <147801550845.18237.12915616525154608660.stgit@brijesh-build-machine> References: <147801550845.18237.12915616525154608660.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR18CA0044.namprd18.prod.outlook.com (10.173.208.30) To BY2PR12MB0664.namprd12.prod.outlook.com (10.163.113.153) X-MS-Office365-Filtering-Correlation-Id: 6bbbb9ca-d84e-47c0-c596-08d4026f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p0UarLfC0FRrQtgnoB7NbpFy8/JZogbI+8/Dkk64WR9+Io1pXTK5c4YZSaMt70CcfeQMGFPOaMbOe1tveiHd0ZtEOr1fxUl6kvadxQWJHxboXduLw9mgISrm6/PzpIbPGctH+IoRV7tg20DmfaDzMoXexpk4NihEqc/8S4ux0A== X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0664; 31:JJgTyO1VFbiBOJBy2RDTkndsCR4C1F42y0K4SVCLpU/5Ohz6TUeplvCzp8ySlFu+a1jmjGqB5eZDsSxVEZEyM0uJskJjBQ9R/6d6RcvoG2RI0W1Ot5ejQGq64Fb0K/Q/MCZWLda9/hj9O7QNcFxBuTkfoQqnx04FlsbXySoVggNrAZRAgfbeIlfUaR/Qfmhf56AOwshN/kQ3oxhmRaVxHuex4qKcwkV1CSMpnKJtmjC2OGEzPhjzeXJot/sDlRVGFo8MmRPS6Ii39/YbF4I4cA==; 20:5uwi3MmF+RZrJz0gS6U/CsUOwf36MDeWFJJXwr8Zw3qgDb1dM57s6jmPccoWkbAtu59T6WAg+e+DgAw727MWRsQ5PyVZAOdQaxCC/ZfKblRb1zBCj9Bwzk2DtTF9AHIiTGNfSRnW4Mp88YgsFRzsiNOJfKCHbUUZ3jKeU2JWfL7KWXljcJwVblQnaPbHTq3qx9ylTsdnhCB1aNWh7r3dAq/YLoRhLJEtWUIZztQ+DBYYkm3eVB+BM2w81GfoqXWRlostn/WINYY1HaC89NzvFBrasQPILHE9E6qs9qRuRZwC5zXQvloNhZAaBexjlfekSxN/4sC7FtN7OLHo4RMvSfon/kluTH2nalfF3LFLHJok9d1zgHzeqw2UXRJB1q7XoSR0nxrSdD15mbPJxr7slwkwrEnxE9uI8mYl20hcYMAMlrw3H74ZEGAdyOJlU7axypJPfxcN/XbbiRNcA0MyoE5n/817e+L3/QdP5fADjWho1Hyg+/jzn2cBazLVo1Ze 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:XREH0RMDBYUCoHj88DCJ/m3QOXefS+Qb6BSL13JWdlJNB/Gy/ZqONfAnQjWUCfgwzSP4NoMVQHPL2kielS5bTLrwKNPIrwhEbqPdjIv2UwCsLjTueR2qoN4BVLm9EX3scV3/dxS4nEtUHD0y8CUB5+FmsqcIak5xAXPtibKrB/Xd+EB+yxk122g6Q8IW3TFctWwKJRi7+UN2aOYw9LJU124bXumJt2aDttaO3sBrnffkQCh/FcFxWEVNmsYTZHJSQW2SulUisK2kUlA55MzolgLgE2ZtnqOxNC0NecuQ9nO3M9R8AqA2F5zHGsuJVDikWCaL9uYWdx51ibGtgrbQxt6Gcbrd2L/lFnWSlVB9UbRx22QEDp0/aKXRJUObJXdJK3mu1Uc/MNnnG8AIHEfrsUs2B4uBvn60wwjyWJICvd/NXrX4ag/KQQExxYMbI4SY85zyWeiDw3SDhks/QYN9GA== X-Forefront-PRVS: 01136D2D90 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(189002)(199003)(81156014)(305945005)(81166006)(7416002)(6116002)(3846002)(101416001)(6666003)(47776003)(2950100002)(33716001)(50986999)(76176999)(54356999)(8676002)(230700001)(106356001)(105586002)(42186005)(86362001)(97736004)(5001770100001)(586003)(77096005)(2201001)(19580405001)(19580395003)(229853001)(4326007)(189998001)(66066001)(7846002)(50466002)(4001350100001)(33646002)(103116003)(83506001)(2906002)(5660300001)(92566002)(23676002)(9686002)(68736007)(7736002)(921003)(217873001)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0664; H:[127.0.1.1]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook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5LYp9gBHYR1ZA9KwwfNWvmln5EmLNH2PDpvNrNfSBENJUWcSYdzBTwRIYO7J1iSPvniJroE=; 20:9+TfptaWpAFK6y/mN+aic7wyxJoTwu1iH7coFsOQfxLELS2VPbu8JlYGNtjOuXoP0ijN9IBAcBwzi9Il1fWLYd+WGz023L5OiqoWmcVujZuishCvvYeF39f8ZUfcPFPeWwqCAYvFqKiW9tPAcYguut6Z5c57aWsvtwVbA0S6sKVB/Nz78Y55fW6/RiyiiPb+lPkETkGcjP6kICBbehmmb13n/c3Bc5y7zqabYfKZiimB/8WFeBGSdltSjCjAiGw+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2016 15:54:09.2084 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0664 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.34.48 Subject: [Qemu-devel] [RFC PATCH v3 13/18] sev: add 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: , Cc: brijesh.ksingh@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The command is used to decrypt a page of guest memory for debug. The command will be used by qemu monitor dump and gdbserver to access the guest memory for debug purposes. A typical usage look like: cpu_physical_memory_rw_debug cpu_physical_memory_rw_debug_internal sev_debug_decrypt Signed-off-by: Brijesh Singh --- sev.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/sev.c b/sev.c index ff9266a..f690a86 100644 --- a/sev.c +++ b/sev.c @@ -329,6 +329,28 @@ err: } static int +sev_debug_decrypt(SEVState *s, uint8_t *dst, const uint8_t *src, uint32_t len) +{ + int ret; + struct kvm_sev_dbg_decrypt *dbg; + + dbg = g_malloc0(sizeof(*dbg)); + if (!dbg) { + return 1; + } + + dbg->src_addr = (unsigned long)src; + dbg->dst_addr = (unsigned long)dst; + dbg->length = len; + + ret = sev_ioctl(KVM_SEV_DBG_DECRYPT, dbg); + DPRINTF("SEV: DBG_DECRYPT src %#lx dst %#lx len %#x\n", + (uint64_t)src, (uint64_t)dst, len); + g_free(dbg); + return ret; +} + +static int sev_mem_write(uint8_t *dst, const uint8_t *src, uint32_t len, MemTxAttrs attrs) { SEVState *s = kvm_memory_encryption_get_handle(); @@ -348,9 +370,9 @@ sev_mem_read(uint8_t *dst, const uint8_t *src, uint32_t len, MemTxAttrs attrs) { SEVState *s = kvm_memory_encryption_get_handle(); - assert(s != NULL && s->state != SEV_STATE_INVALID); + assert(attrs.debug || (s != NULL && s->state != SEV_STATE_INVALID)); - return 0; + return sev_debug_decrypt(s, dst, src, len); } static int @@ -453,7 +475,7 @@ sev_guest_mem_dec(void *handle, uint8_t *dst, const uint8_t *src, uint32_t len) assert(s != NULL && s->state != SEV_STATE_INVALID); /* use SEV debug command to decrypt memory */ - return 1; + return sev_debug_decrypt((SEVState *)handle, dst, src, len); } int