From patchwork Thu Sep 22 14:53:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9345507 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 289F56077A for ; Thu, 22 Sep 2016 15:12:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19D0D2ABA8 for ; Thu, 22 Sep 2016 15:12:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D8452ABAA; Thu, 22 Sep 2016 15:12:58 +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 79E812ABA8 for ; Thu, 22 Sep 2016 15:12:57 +0000 (UTC) Received: from localhost ([::1]:50045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5gG-0004FT-Jy for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Sep 2016 11:12:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5O2-00022W-W6 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5Ny-0008FZ-EL for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:06 -0400 Received: from mail-bn3nam01on0071.outbound.protection.outlook.com ([104.47.33.71]:7098 helo=NAM01-BN3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5Ny-0008F8-7p for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:02 -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=N2/+GrVm6dKlj87EgEV4W/9Wx4SXQQ1ugWZxctujAfg=; b=L5fHCpooKDxD5aqjvIvpK4JAnxWNUj2q9fuHgv+NOUcUpketnJT6oll303uyvKWUV9uljpFcXJWJqFv7JuHROxokMcgsJrVQ6wZKOpucZ4p6SPuWD1Uc+k46/y3gohKp1feA1jcscEXz0XLmM74kj5W+UrOTxZFArLBtlGBvKNQ= 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_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Thu, 22 Sep 2016 14:54:00 +0000 From: Brijesh Singh To: , , , , , , , , Date: Thu, 22 Sep 2016 10:53:56 -0400 Message-ID: <147455603651.8519.12363755021277774810.stgit@brijesh-build-machine> In-Reply-To: <147455590865.8519.11191009507297313736.stgit@brijesh-build-machine> References: <147455590865.8519.11191009507297313736.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BY2PR1001CA0015.namprd10.prod.outlook.com (10.164.163.153) To BY2PR12MB0661.namprd12.prod.outlook.com (10.163.113.150) X-MS-Office365-Filtering-Correlation-Id: b95ba100-e6db-44e0-5262-08d3e2f849cd X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 2:zwS/YrNxliiwdgA14N12QAVF3Mx9VSKWJpiUN96JoY4z4M99s4ykX0BGN+sJPoYtJqf569mQ6r3Q8iTKBzDW7/sFmgdEoGlDacIMhAHztaphRYS6ycNMx+Ki8vaFX2q4XRMWDunTX5KPzl6ZHbUascibhuMbucaZQ2uHsHj1D61ACv4cNkE2EovQ8xWMB8We; 3:1/ZF3sjUHripRsfvaOZvfXzupl5IPYeXjmxY17QipvHhtHjTUXzl5AWXegAkLHRMRofjs42nL2kaGkNdblwkXGuTrIMCbACqTjpV8gx6XwcT9rRMqPYsJAaQoUkWwhsZ; 25:RK3ugi5BqXNhIgWBalPbt21/mqVX/svQwHnrB7dyyN+WatN+b5taAGcHsfdyWeWEZnFi4qJrZwly6WarQF8CVrgH2lTqRzHGKnOIRj0AgXzQeq3S8ulycb+29Md3jHX9aF5yKTuclgrM0mG8cRmaKfPaup2UyCcZIxIKpQ58JOfjJv8rgj3dHBg6RDIWNfFb3ygZOrz14rzSyWFEX9nJ3UstgkOiuuLF1CL4lAhMMoavttU3mdu7M2+yNCP6JQX5I4acposPQnePI1qLlXTIa01chS/bwj1efzjmgkxOglwMB654NRNUTocr8hXflg99ioLY3YyUgZmH0MKL0syQ86swpQYW/54AOGaH7VXGvqAlfCiCxlLH/5wYQAfQNVzCMP0oTYH0/9mHcfRGp4+Rw1VytjIp/BKqq7XpMNgFYZU= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR12MB0661; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 31:F0QmG/0D6ZZiBVgj8H3UhpNfZWgic6J387R+YoJvNsROytS7DLezv55b6xU5KtGLaGG8bpjqzHAT5ghtfWPX7LWS++2GrnxYSQ2KM/hjYemgAgFeZMjzmpNcds6ai0C3bfnYvzwh1OKSHIC5daO7EaW9S6xwKRXnrvhPmlJZsOOBzkLRA7EF2iGhF3z44xZDxmjixOtSWG2Ckj/5xvGu4rpL+dkEgBgU/8nf+0DAJZ4=; 20:syEKmXFVibm/z+OYjQ6It3ETWtf1r2gto2I9LEd2B1ox/qv7L81eam9UdexPd9+hSHPx3rHfiWjDMGoT1NVaQraXo/aVO325MpZ3a4G7G+5woyPFoU3souyv0xF1ak2qkDnMDUjFm2MwNDwWB55tuYrABL+LqEvcU+e6R+TBV+3qpN1MCYKTAZQCqoQYZbRJPtANLlSg9EI89PAvijU357RWOppIZXN5ZzHY2AgUO5MKzP8/Aq0SFC6hYkCMx6So5D7PLjhb9Y9EzTYL86mebnQadT+Z8Is8dhiD43VVcQXkNAFS5YwrkqHu/P+FGmsP9kIE9bL3GWXEuipZGB31ZWaS7pwX/xVIbkqHsSWDqx+WIUrjjLLtwLoinJ6Jh1Rney/XdJhieqUkVgr756fTCIn2Kc4BYZpSlH2ythAvJzsJsLvYUNTHhdR8IaPYCDlvqNcKRuxzgNSLXy5eld/YmjL7PCFm2rUOpunWHt+Bvsod8QxwVT/KqlPWsgbABc9d 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:BY2PR12MB0661; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0661; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 4:nKNc66X8Op0KdfL0mB7AG/fiP/Uf8NA9apjoJBQr1xjirHmc9v6ojiW1NfniHMgyVgCYOkUMWqU++zSBWFYo4R4Iz6jOlWv6uC/AXwHS6zT/eFjxUpT/Lc/eAgvMHBDPqG61DYLDyJtXwUnfEKKat1JBzjh5t1KiABalLoKVX2oC+1+NmA3qhP+GCg6JorRLRKkS+VIMjWcx6X+IXtG1ZyoDx9cnsVMvAxJvNadhJorq95fwBCa95TDJk+EFpMgFzCz3oyfZs0C1jsdx/x66r+1psYhdKfXtheyOndblcocvF+f6E31N3kqyd0DEpeuFZB/8bY+OfSALT3nGOHlv6WiLWP7am8yYHVXuGzDjRe6O3RP/aMHya/Xr0eNtU0XImLl6o7i36H6zwvQ5Wg5QtsNJrSIsQOEpkuqrhbru7MQ/9Maq7XgxLkf7Lhf1XiTc X-Forefront-PRVS: 0073BFEF03 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(189002)(199003)(6116002)(107886002)(19580395003)(83506001)(105586002)(68736007)(42186005)(2950100001)(4001350100001)(81166006)(305945005)(2201001)(97736004)(101416001)(189998001)(19580405001)(77096005)(2906002)(106356001)(33716001)(92566002)(7846002)(9686002)(7736002)(586003)(3846002)(33646002)(23676002)(8676002)(86362001)(575784001)(229853001)(50466002)(81156014)(47776003)(66066001)(5001770100001)(5660300001)(50986999)(54356999)(103116003)(230700001)(76176999)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0661; H:[127.0.1.1]; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwNjYxOzIzOjVPVlI1TTYyZ3ROMnhmai9zcFV2MzNKRnF5?= =?utf-8?B?cHdFcWVHZGhCU2hlQ1pxVWQwNEhrejRsZk83OUFHRm5CRXpKSVpVTWt2UTVl?= =?utf-8?B?YXRlTUYwR00yVjR0STRMU09DanFDK0h4Tjd5eG0yQ0psOThnR0dzdTF5N3Jn?= =?utf-8?B?NXU3Q0N6MDhpVmNsRWMvUnNDdTc0dEZlajA2RE5wQm13SnVlRDM2NXVLN2g1?= =?utf-8?B?QmNURkZQcXlzN2svY2pIdkhSaUcwZGN4S0pHcUJnWlV3VUxwQkEwTTBDaWda?= =?utf-8?B?Rjc5d0dJMGU1cWVCK3Y5TDBESUhzOU9ud2IxWWNPUmtXZ2RlOGdzU3F2VTFQ?= =?utf-8?B?d3h3alBwc01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z5gZxA==; 24:5NDMonROwpU6cdAykWNfNkNw6PkN/yW7DqvF6i0shGfhB0vClicD6ytLcKKVqkFRMrwY4I7KOU1a66eGggoNjHiUHj8s84DcELI+RL/ETnk=; 7:yaAL10KbjaPqC8jrMutsAzi/eBzpW0cyKKRwNkuV+cHL4viXlCxE5CbsPPKTltqvranPoXHEHp4uljoVL+0inyY+PwNDc6g12Q4fWR5LXJ9CPeV343n9BcYUVjNxmiT5sWCXUFj/lQjCgplMX/RpGix1Skhu4F3IJTtNyErlxWy/l1qdISjjEN19bTLrk30eNp2Vc6f4hicwU/vksbIFYskyDdLMJgZceZzsgFjudG8OpmhWuToBrXfrO6vPyW9/Z/tD8iVTnFXwAmbhLE02f/ziiVNZaha+6TyWuPH/nW1wY/BQQ+amNXVP3lZnWA0S SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0661; 20:SJrajXDgGdVP8Guq1KJxT3mhN0ZjL0G88hGD/4l5S0tPcWMO8X3zhmMBW1dEtjWOedM8duHHK8boLplLAqoGCUjcOHB37YC3V8seh3w0kIMQga3zkw9KI4KicprCdNEIBNTiMuD+d5AfF6lVYFlOg6Tn0e/62NpjWqNwWelv8P8nIdJlVXDVSd4FjCWvQ6hy5pau0YGuXpKAX2NHeIBNm7pEmCt8jnQeECl4RGQNukFCJ5Ks4Ld6cm31sprZ+W2x X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2016 14:54:00.1876 (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.33.71 Subject: [Qemu-devel] [RFC PATCH v2 12/16] 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: , 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. See docs/amd-memory-encryption.txt for command parameters detail. 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sev.c b/sev.c index 21c491c..c0f6ae4 100644 --- a/sev.c +++ b/sev.c @@ -1082,6 +1082,24 @@ sev_guest_launch_finish(void *handle) } 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)); + 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(); @@ -1102,9 +1120,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); + assert(attrs.debug || s->state != SEV_STATE_RUNNING); - // fill in the code in next patches - return 0; + return sev_debug_decrypt(s, dst, src, len); } void