From patchwork Thu Sep 22 14: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: 9345513 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 D5A0B6077A for ; Thu, 22 Sep 2016 15:17:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C538B2AB8E for ; Thu, 22 Sep 2016 15:17:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B79D42ABA8; Thu, 22 Sep 2016 15:17:47 +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 3A50D2AB8E for ; Thu, 22 Sep 2016 15:17:43 +0000 (UTC) Received: from localhost ([::1]:50075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5ks-0000rJ-9X for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Sep 2016 11:17:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5OD-0002EI-Od for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5O7-0008Il-Ri for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:54:16 -0400 Received: from mail-sn1nam02on0073.outbound.protection.outlook.com ([104.47.36.73]:59712 helo=NAM02-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5O7-0008Ig-Jm for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10: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=cc2a4Z/AR6l3clUh0S6G8IysMtlWpqTJzX8p/jgjjmg=; b=eR9hS/MC7wL/f46uFHzLUwJ7hfOYqGc0KfxUN7SD8ViKaN5aXpjokIIW9OVq+fpq6DHIvXgdFwoEKUiTPrJy69h4NItVaL6Dv2xc7vxjYNvI1zTOpWWvpGiIg6zjswo+zv7i8G3mPANn9qr6JoBoE+VfNGSdHa7/LSQ3oc2EGrE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by SN1PR12MB0671.namprd12.prod.outlook.com (10.163.208.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.629.8; Thu, 22 Sep 2016 14:54:09 +0000 From: Brijesh Singh To: , , , , , , , , Date: Thu, 22 Sep 2016 10:54:06 -0400 Message-ID: <147455604632.8519.10029974563674880855.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: CY1PR08CA0035.namprd08.prod.outlook.com (10.163.94.173) To SN1PR12MB0671.namprd12.prod.outlook.com (10.163.208.29) X-MS-Office365-Filtering-Correlation-Id: 5abc0366-db1f-40d3-39c0-08d3e2f84f4d X-Micro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vgmk6/9FlKXfEos8sgG4jwLJ4wHjzZqLYSh+HFcdPiyQQY2fbV8ys8Xpk4uqFHTyxVbUn4cNx1FCrUMtc1UK8nFKkMhDHJDBHZ0MsH0/vGOKMsulwA/t006m5M6bQHZlgv39BjeH2fL+Y447B2HNJHk7m7nqxb3ijuMoCrTgvWzuDV+itTguaxk1ofq7GizkAtlviDyaqN4BMmDgKc38VDVuvGW/U7yLN+Jin46JpqPoAUUaGT4XnhdI4FoicWDzV9apyyw 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)(10201501046)(3002001)(6055026); SRVR:SN1PR12MB0671; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0671; X-Forefront-PRVS: 0073BFEF03 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(189002)(199003)(230700001)(81166006)(81156014)(5001770100001)(68736007)(7736002)(105586002)(97736004)(8676002)(66066001)(42186005)(33716001)(47776003)(7846002)(189998001)(101416001)(4001350100001)(305945005)(77096005)(5660300001)(229853001)(54356999)(106356001)(50466002)(76176999)(50986999)(2906002)(92566002)(19580395003)(586003)(2950100001)(33646002)(2201001)(103116003)(6116002)(9686002)(3846002)(575784001)(86362001)(107886002)(19580405001)(83506001)(23676002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0671; 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?MTtTTjFQUjEyTUIwNjcxOzIzOmtGeFpKRlY2K0hUc2plUEw0ZFhiWlltNVQv?= =?utf-8?B?ZkRaa3g3STlySElPZ1lCcXNJSlhQMmQ3b2kvMlRkQTIyV21VRlVBNHpvdm5D?= =?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KFfJwrCxf5oBo+tJ7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2016 14:54:09.2853 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0671 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.36.73 Subject: [Qemu-devel] [RFC PATCH v2 13/16] sev: add DEBUG_ENCRYPT 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 encrypt a region of guest memory for debug. See docs/amd-memory-encryption.txt for command parameters detail The command will be used by gdbserver when writing the data into guest memory for debug purposes (e.g setting breakpoint) A typical usage looks like: cpu_memory_rw_debug cpu_physical_memory_rw_debug_internal sev_debug_encrypt Signed-off-by: Brijesh Singh --- sev.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/sev.c b/sev.c index c0f6ae4..8a07c0d 100644 --- a/sev.c +++ b/sev.c @@ -1100,18 +1100,38 @@ sev_debug_decrypt(SEVState *s, uint8_t *dst, const uint8_t *src, uint32_t len) } static int +sev_debug_encrypt(SEVState *s, uint8_t *dst, const uint8_t *src, uint32_t len) +{ + int ret; + struct kvm_sev_dbg_encrypt *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_ENCRYPT, dbg); + DPRINTF("SEV: debug encrypt src %#lx dst %#lx len %#x\n", + (unsigned long)src, (unsigned long)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(); assert(s != NULL); + assert(attrs.debug || s->state != SEV_STATE_RUNNING); if (s->state == SEV_STATE_LAUNCHING) { memcpy(dst, src, len); return sev_launch_update(s, dst, len); } - return 0; + return sev_debug_encrypt(s, dst, src, len); } static int