From patchwork Tue Sep 13 14:47:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9329337 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 22BCD607FD for ; Tue, 13 Sep 2016 15:46:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1383F289BE for ; Tue, 13 Sep 2016 15:46:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 083F128D40; Tue, 13 Sep 2016 15:46:28 +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 8539D28D37 for ; Tue, 13 Sep 2016 15:46:27 +0000 (UTC) Received: from localhost ([::1]:49739 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpuk-0007fz-MR for patchwork-qemu-devel@patchwork.kernel.org; Tue, 13 Sep 2016 11:46:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpVV-00032O-Ht for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:20:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjpVQ-0006R4-Ee for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:20:21 -0400 Received: from mail-by2nam01on0082.outbound.protection.outlook.com ([104.47.34.82]:59298 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjpVQ-0006PS-6f for qemu-devel@nongnu.org; Tue, 13 Sep 2016 11:20:16 -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=FSIuu2eJq/5s5edGGwVSHH7SwquK+urJMuE+p5NFMGA=; b=XbisuYa6B95fSIK8VGoiplupB2WJKsb6u76chSx6tkEP2fYiNuUKhKtxQn6JNctOBkIj2ZRkFxnOaggwxS/HAd8m8P0vIoWkFmPmLpsiCVX6Ki1wenEDErAJ9ZUgbRAX/1zvE8hbCVJ28RXCxdWQzvJJ3SNjdEUajTz2vIDoro0= 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:47:10 +0000 From: Brijesh Singh To: , , , , , , , , Date: Tue, 13 Sep 2016 10:47:05 -0400 Message-ID: <147377802496.11859.1153343750199560484.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: BY2PR1001CA0037.namprd10.prod.outlook.com (10.164.163.175) To BY2PR12MB0662.namprd12.prod.outlook.com (10.163.113.151) X-MS-Office365-Filtering-Correlation-Id: 3b219bb7-0012-4c6d-4961-08d3dbe4d7f4 X-Microsoft-Exchange-Di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NJo1frR14OsGdwnKL/eYHeltqKCCYLEbByGj1FQcYDHM+HMVdPScEYBfmgarx7VdwPJDIcvvTg+fAkzhC1NLkkolotzYizu1nY2Apzs0LAZIYADb8Zcnm03KDRuc9qWECxNaLkHnZcUAzoRdD8towFaAdIiZ7aykGSaRith6Hcz361Afc2SXR6qOGaBje/88EHGI/yUnyu/JkPHUXC84q9SpEuZhLQEvJUOWZwDAf3DOJNn78FYUkxXPw 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-Forefront-PRVS: 0064B3273C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(199003)(189002)(33646002)(229853001)(105586002)(103116003)(106356001)(50466002)(42186005)(76176999)(50986999)(23676002)(54356999)(101416001)(2950100001)(97736004)(3846002)(77096005)(6116002)(5001770100001)(586003)(5660300001)(230700001)(92566002)(107886002)(7846002)(68736007)(305945005)(7736002)(8676002)(2906002)(81166006)(81156014)(19580395003)(19580405001)(86362001)(2201001)(189998001)(575784001)(66066001)(33716001)(9686002)(83506001)(47776003)(4001350100001)(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?MTtCWTJQUjEyTUIwNjYyOzIzOlVrL0tQb1dITXIzeXQwbHFoRXVaVmZvTzhP?= =?utf-8?B?UDI5dWI1M1ZEeFNxU3hXeG9hTDZwU0FLSmtZclpXd2FMaDVLN09WdU1HdHUz?= =?utf-8?B?VHRXQ2hyT1R4cmc2N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mNXNIQzp9JJ7EkHYr0NRuGuNEnj/z9xGqewdNUgqLDKDwkPIF9zFlPA3KSBt36fxGkQDdABHh6CDM+wm8f2YR6adDDPUTKwez899F4N2KgODGQO6Oew6AnqWVqA7NB81gF8ZA7NfDQ==; 5:Y7IiNTbBbfXssW+k1OtdT56pUJbocbVef91WVPEbzdPjRYP5tB/WdjnECJmfYhQeM56TqlvNNv3gDfgXOEQ1kS2vrNPRD4U2t/UQlaBXBsRKfrRO01lOnEkuHN148yk2ZGeC4b5yAxa7bRtqL36GdA==; 24:Y1jVd0hLcdJPa/xqh1cYoRJKmqU1C1EcgNBdRLXfk55QOKyxC/l2QlMTw1yxYKj2bg5H4/3hW49CN18qjpZ80ufzcsKIWGD+Jae6DToqqJY=; 7:cbzyfpl3C4WmZDoKRWYjHp+iYag9VkoRHEay6hbm290rRcteAtm/db4eBgLS1oBAfmI97Lz2pF+AG+o9rciDeMF3apJl7rcwbMvRC6Xfj3u78b7SrryfCwBbyKdJ7DXZvXr/j3lmRjwMerPJeLzkvdnF9feG9y9lYhSGHKno3Ffn49LtQlujwAaPJoP+N5ibrfF4OulN7id2ke7sUqnxA5tHf0FD9vIdZh0i9nx6pD/19xWnYcuWOt95aITBtBWN SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0662; 20:Fwn9VfCosSwVBJNyPizGaLa3RxC5LQgNldPwB8oJsMWooG08Jv4av0ZjrwQNotXsETnTMQ1UjvfGIyi71k0gXFpMvF1OdHbwqcqXhpihfHzCLKJDCn1Gxin15/RewFVp+uhYkJtS0Hmku4HHHdQ3LzU7YKShLr/e8ELcZV8FTguZMzUAjy087Z2Y+Lth5NM7grCzYLegPySeWsNkPe7T8YXTVBh+bTNQwH7v1hGZ4yQI8CB6Etjr+12GEYwrjAll X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2016 14:47:10.6074 (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.34.82 X-Mailman-Approved-At: Tue, 13 Sep 2016 11:45:46 -0400 Subject: [Qemu-devel] [RFC PATCH v1 02/22] cpu-common: add debug version of physical memory read/write 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 patch adds the following new APIs: - cpu_physical_memory_read_debug - cpu_physical_memory_write_debug These API's can be used when reading/writing guest physical memory for debugging purposes. In next patch will update the hmp monitor memory dump commands (xp, info mem, info tlb etc) to use this API instead of cpu_physical_memory_read() to access the guest physical memory. The idea behind this patch is that in case of SEV-enabled guest we need a method to identify whether the memory access is for debug purposes. If all the debug access requests are done through these API's then we can create/set special sev specific MemTxAttrs to indicate that RAM access is for debugg purposes and use SEV debug commands to read and write guest memory for debug purposes. Signed-off-by: Brijesh Singh --- exec.c | 10 ++++++++++ include/exec/cpu-common.h | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/exec.c b/exec.c index d0f45b4..604bd05 100644 --- a/exec.c +++ b/exec.c @@ -3768,6 +3768,16 @@ void stq_be_phys(AddressSpace *as, hwaddr addr, uint64_t val) address_space_stq_be(as, addr, val, MEMTXATTRS_UNSPECIFIED, NULL); } +void cpu_physical_memory_rw_debug(hwaddr addr, uint8_t *buf, + int len, int is_write) +{ + MemTxAttrs attrs; + + attrs = MEMTXATTRS_UNSPECIFIED; + + address_space_rw(&address_space_memory, addr, attrs, buf, len, is_write); +} + /* virtual memory access for debug (includes writing to ROM) */ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, uint8_t *buf, int len, int is_write) diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 952bcfe..1ebd9aa 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -61,6 +61,8 @@ const char *qemu_ram_get_idstr(RAMBlock *rb); void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write); +void cpu_physical_memory_rw_debug(hwaddr addr, uint8_t *buf, + int len, int is_write); static inline void cpu_physical_memory_read(hwaddr addr, void *buf, int len) { @@ -71,6 +73,16 @@ static inline void cpu_physical_memory_write(hwaddr addr, { cpu_physical_memory_rw(addr, (void *)buf, len, 1); } +static inline void cpu_physical_memory_read_debug(hwaddr addr, + void *buf, int len) +{ + cpu_physical_memory_rw_debug(addr, buf, len, 0); +} +static inline void cpu_physical_memory_write_debug(hwaddr addr, + const void *buf, int len) +{ + cpu_physical_memory_rw_debug(addr, (void *)buf, len, 1); +} void *cpu_physical_memory_map(hwaddr addr, hwaddr *plen, int is_write);