From patchwork Tue Sep 13 14:49:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9329399 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 BDD426048F for ; Tue, 13 Sep 2016 16:05:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE7E6290C9 for ; Tue, 13 Sep 2016 16:05:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A296429217; Tue, 13 Sep 2016 16:05:25 +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 3935E290C9 for ; Tue, 13 Sep 2016 16:05:25 +0000 (UTC) Received: from localhost ([::1]:49857 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjqD6-0006MM-AK for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Sep 2016 12:05:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55102) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpXs-0004o4-MH for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:22:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjpXn-0002i2-VN for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:22:48 -0400 Received: from mail-sn1nam01on0068.outbound.protection.outlook.com ([104.47.32.68]:12992 helo=NAM01-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpXn-0002fi-Oz for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:22:43 -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=pkwzZElME4NCrTpa56N7lTnIHtRkQhsFbzkFRXIFnsQ=; b=XYDs6iis0RIMn69Cpc6UvWw2kBMcXigsZ7O36oCV2LlJkoo4dXPNpsNFLASO6cXAffQ/Ci2VMoiFap/QjmDnWRYmcaqqPYHqFXYWZClmvn8naDBDqDD9DKdaZvdt09rr9toyf2sEo8jEZpz4iZfFEB22bswfLkrodDYQZwhVcUM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by BY2PR12MB0662.namprd12.prod.outlook.com (10.163.113.151) 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:50:01 +0000 From: Brijesh Singh To: , , , , , , , , Date: Tue, 13 Sep 2016 10:49:58 -0400 Message-ID: <147377819796.11859.6252067260196813810.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: CY1PR20CA0043.namprd20.prod.outlook.com (10.163.250.11) To BY2PR12MB0662.namprd12.prod.outlook.com (10.163.113.151) X-MS-Office365-Filtering-Correlation-Id: 452a0df1-4f84-4ad0-211e-08d3dbe53e19 X-Microsoft-Exchange-Diagnostics: 1;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YgXx0u0PVLL9BGOaVFKBX7qUILfjtnO4TFCk3CNt2vWT6DtyhoJiAmvBzFUu26kvu3enTU3CNyNo0k0wt4knenvCVo1bAgaNw1mLfc= X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0662; 31:9eGkjzZvYl/wC1fMMjkm+eJB3PAZ/Yi3w8WMdbdd8klIce4MlD77us/W9HzKd+s8T0IoyxDGBzNX0Pr2BmBOw4u4S0O2JKZunDwpXmNf2kfQtT0rXw8F5O4n03hbiK4aDt3uGESQ02/+oA7vWIrK9DMlJzDYHDEoLUc+bctwQCK3dUanN8yfQg55GYQOn27MZkQzJYAWLyQwKtHhSLWvHRQHlgaqQnE8FU3vdN9etpk=; 20:7Pwl2GgTkjiV0KjCbxAWuyBXm53zSOlXYQwvkk1p3it+bdrgVnApFR+9kxt9bsxYSi6CN/FBp5D0O9hC2kAscDgoOoZbNiLRIsu/7mP30lLfoAqvDRKvhWR5hm9KEGtIgEzKvA/O/Vk+HXCa/mvGiUtU0XFJD1Yq3Cvit/diyHbEiiut0CTqOQCCBlaLgJ6S2Wu5YxOoWLeT905Foohld6aoftGp4DkO1KfXjJJSag9rSyJlFGy3LIz8crpvCuV8JFGF8er6eowFJKSEAVKJWDE1U23B8Yi0WaxiOcsFkL85sVga2IMy7WT9t2N1J9nIDY7ZQo48a8u+IBwv6QTsPx88t9asfsuiZCG3KjD6vr9JDz6g8DrOLrWYj19xT2bZ41IUKkrddlzP/pIDzEsPMlfqjyNINd50Y53BJCyPAiNUJfiPWrWEtGlzdvZU9UW15JC6JMSzJRweEwnaHQuYE4Lnc1AhnTrSzGSCCRVOm29Ry4I21h8nST9853/Ivq8+ 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:BY2PR12MB0662; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0662; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0662; 4:DD61H4kUXNC9RE8A7ha4UqH+4o1V0slkiVEdjYoeWC/QvKgBnv8RJqC9e12eHiOjGSAFi7FO5TGYI4RSguC0vfJgsRUIH6uMPxRPFUqKRhiVRh3Cvwp2HGWN2AoNk+qDrIFrKDMyNyvEs/x5E388sZ74oLxgDP0GLVHIa8wO56JZEsRk6xUf0n1n1z0nNXyGKf0KCmjICh++IFOardLWsOSnpZ3mbk926QV17pc83qpWNLVR+WMiNAEa+qYg/8p0GeS6Ia177MQCR3CeftNfO+ClO+mY2GcBahbvuDY1pTxCSfCLT9hjdY+769Iuy6vH0X/cqZz0aUWArL/KMDWv//4BuriAprj3pTb3kvUSRYv3JTkDrl1RN7nMHlSyjOEFwWS+XdzZ61uyofP2vSYPk3Dr94ZS67ea3vFQczvj39QN9XdMKgd5Nq5K1Lk38xJ6 X-Forefront-PRVS: 0064B3273C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(199003)(189002)(2906002)(19580395003)(19580405001)(81166006)(81156014)(7846002)(68736007)(92566002)(86362001)(305945005)(107886002)(7736002)(8676002)(47776003)(83506001)(9686002)(4001350100001)(33716001)(2201001)(66066001)(189998001)(50466002)(42186005)(106356001)(76176999)(54356999)(50986999)(23676002)(101416001)(33646002)(103116003)(105586002)(229853001)(5001770100001)(586003)(5660300001)(230700001)(6116002)(2950100001)(3846002)(77096005)(97736004)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0662; 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?MTtCWTJQUjEyTUIwNjYyOzIzOlhlRU5iKzZROTRWR3Eyai9HRG9NRjRSdG5B?= =?utf-8?B?SndtOW9wdW1FYkJTRXV1YVFhY1J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XQnkRMfyyN7+Qu1rUVuZaq97VQd4La8wvuv7K/g8K7THwbi62hIZoNbG7GJvdTD5YojJCCTvGi44ncKrcL1elGk0vZ3M/5NWti/Gv56cx+7wxoIHbuFMAwVnYgEXDaGpzsk0ZPAhB3UiGlF0FSU086nA==; 5:z2Bd/bpJkoysWdJx9i3EDAk/C08gbBNH94Saw7LiWN0MtYaSRxp1Y171IH3DKxITnesns8pTWqfQaF0vxq4s5Y4ztHoahQYIMMSgG/sAtZKihnbqOOduHOd0YgtRH4SYPnXfYVjUeVd3HjNB34u+7A==; 24:tb/VeeBRFCs2CLZfgEWf1Dlc0FV6WYt08hC43opL8YN9VafwCfVhG3J5iWzij1RU+JsKHQts9723rAgpQCiGxjmwcSI3qtC6z2o2neCFZV8=; 7:GZZFNNzp7/Ww0cYkCCGxxUzQk7fszg9SrtFLTQmdHJTf8lOl/UPhdG5gnsP47Edh4NZxwZXpnbddXcvMDcpXypRq4tiiNoLQO9qMtaJhKK2LHPo7jY9L2j4Q96qEXxDUMi4B5gtmaokd0r2FgKD34OoNcQLLDKnvJHKNemy7PDmBF2qYDlKZlmOw9hJEIWIJvKo8ZuUAR31kBx6f1hHS1IdqHxfG4HHWuoKT81sF/1sd4geXs6Cai0aHfAhkba4N SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0662; 20:maXc+yPE83RXilOLCjN0EVcxDteddjTARXuECvMsap2/wokpTS0O/nH5ioARZviAaSZAPO8Lc+cH9WSmskDicC+DUSRbP7AxTf75Ra6mdrlY6GRsoyjDHAZmAyBlIockdS6MUGwJ6EdZ+R6QZudc9hpp+6Gwd55oqjqcMBiW5OjNbU3vTqldCn4xkvVp41F4rixT+uev1LXjqmtaFw+Ezoqi/LVLOeewuhZUDe83AjO1+E8f1XQbJPxNIjXLoc1J X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2016 14:50:01.8744 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0662 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.32.68 X-Mailman-Approved-At: Tue, 13 Sep 2016 11:45:47 -0400 Subject: [Qemu-devel] [RFC PATCH v1 19/22] exec: set debug attribute in SEV-enabled guest 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 When debug version of physical memory read APIs are called on SEV guest then set the MemTxAttrs.sev_debug attribute to indicate that memory read/write is requested for debug purposes. On SEV guest, the memory region read/write callback will check this attribute and if its set then it will use SEV DEBUG DECRYPT/ENCRYPT commands to read/write into guest memory. Signed-off-by: Brijesh Singh --- exec.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 604bd05..b1df25d 100644 --- a/exec.c +++ b/exec.c @@ -3773,7 +3773,11 @@ void cpu_physical_memory_rw_debug(hwaddr addr, uint8_t *buf, { MemTxAttrs attrs; - attrs = MEMTXATTRS_UNSPECIFIED; + if (kvm_sev_enabled()) { + attrs = MEMTXATTRS_SEV_DEBUG; + } else { + attrs = MEMTXATTRS_UNSPECIFIED; + } address_space_rw(&address_space_memory, addr, attrs, buf, len, is_write); } @@ -3793,6 +3797,11 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, page = addr & TARGET_PAGE_MASK; phys_addr = cpu_get_phys_page_attrs_debug(cpu, page, &attrs); asidx = cpu_asidx_from_attrs(cpu, attrs); + + if (kvm_sev_enabled()) { + attrs = MEMTXATTRS_SEV_DEBUG; + } + /* if no physical page mapped, return an error */ if (phys_addr == -1) return -1;