From patchwork Thu Sep 22 14:52:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9345511 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 182BB6077A for ; Thu, 22 Sep 2016 15:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 087392AB8E for ; Thu, 22 Sep 2016 15:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F08C42ABA9; Thu, 22 Sep 2016 15:16:02 +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 C67E72ABA5 for ; Thu, 22 Sep 2016 15:16:01 +0000 (UTC) Received: from localhost ([::1]:50069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5jE-0007ia-T2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 22 Sep 2016 11:16:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45753) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5MU-0000Ay-4v for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:52:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn5MO-0007Wy-Vo for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:52:29 -0400 Received: from mail-sn1nam02on0058.outbound.protection.outlook.com ([104.47.36.58]:20695 helo=NAM02-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn5MO-0007WK-OF for qemu-devel@nongnu.org; Thu, 22 Sep 2016 10:52:24 -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=G4ze2jRtW3AmLRd6prfcau1+9QtFzmTQ6U8dtOKQ85Y=; b=EgidRNKTFek/OF49r81tWVHC/307AAG0y/7zmIKaCWl695aSw5N/iIxTPLWMSp9R8vB+tprKImEzMCL9az3UziTLXJ6cB+o9HJYXGrGsGtFMwI1rBtN+XZTeIIfzS8R0z3NDgWu5/sFMCmEN9dNovcuD0duj+Yx9V2saTNIDAgQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by CY1PR12MB0665.namprd12.prod.outlook.com (10.163.238.150) 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:52:22 +0000 From: Brijesh Singh To: , , , , , , , , Date: Thu, 22 Sep 2016 10:52:20 -0400 Message-ID: <147455594057.8519.18153674804012845873.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: SN1PR0501CA0030.namprd05.prod.outlook.com (10.163.126.168) To CY1PR12MB0665.namprd12.prod.outlook.com (10.163.238.150) X-MS-Office365-Filtering-Correlation-Id: 00950cd5-1547-4253-f565-08d3e2f80f99 X-Microsoft-Exchange-Diagn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2NuN0dDFJ2mVmvy4FiccOrj95TcU=; 20:+s9WpOUBbpQ7EtRy4ktbDIZhkQNiFQTJGRDFaGUELRmtAJp/u54Prj7O+WUlmyYQJoXM6R6XSr8ybm4f+MTBDifEMoWjqcI2ZVXh9yPXQiMncIi459TSIe6jhTqTK1AMBdrh0lZoIW/dRR6h3bjEbzc+AXE6IzFcEu4AMniWjjDEHemWhgeSZ6ZANwyJiCT08fhUCxEOu+ejT8Zg7L+PfAL8/uwx1Nj1ZUFyDcOfEv4ZrtXn3d2tnPPVWMdPdVfFnzJx3yFegLE2NR8HRqcJ2yJWPfbjfmilGWDyiYkXNBb9SZCTnafxfS02BVrTgmC4D1JhYvOp23boxX79xtXRGVjuWaEv5sy1ZK74z2X5W9cM6zgUrDTCO0467GU9lcX6I/tIbRVG9n/SfdG5sWx+boX5dj7evBYXrmeVVn/dNFO1ymOJPikvavlQD6DURvuxwfALv7Ja32W8mc1NeZr8QZISuJ/eKX6bH1G7EDAkEo/1Xwy3uZlRb5Rc0Kalqlbv 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:CY1PR12MB0665; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0665; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0665; 4:+6r8fpOE2QK/l04BGM7cwWusBHYvvfghzP1jqBpZBNGPW7vULJ8C31FDJdbxvJmM1yxzSFV8XhA2uVuToxGSsMo7P7xTsJd0lAVE53Ui0qp9PVVLl4Bz5dF2/3KJnLpmVuFPxR02GnhN6MKpO53kshQu/GhOCQVUl2DYZpKsU8WpHoT6WJlXHmpkxTayCAUL9xXSkW7iO/sbBF1E/5YZKLZ1l8397Taf9uM6g/2Qjd3fVSpDuPA68Ef3Hz1zl9zS2lrX/6ljO1JV4Td6Bn1/mrsbrFiMQlrcEC4GmJn/H/PM691dqsY/obsfTGgA5tFdTnO7pE31OvT/6LWmkItk6k7fqylkKvQDgLG6UQNlGu2MBaS77obpGKc2nduoGg4I7TARiI36qufwOVx8ij38cPj4XZlAWpWgzHzusOuIW/5QrVk40pXVqqrcdN49l+7O X-Forefront-PRVS: 0073BFEF03 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6049001)(6009001)(7916002)(199003)(189002)(77096005)(229853001)(103116003)(19580395003)(305945005)(47776003)(33716001)(19580405001)(23676002)(105586002)(189998001)(7736002)(83506001)(33646002)(92566002)(8676002)(230700001)(106356001)(81156014)(107886002)(6116002)(9686002)(81166006)(76176999)(2201001)(97736004)(5001770100001)(42186005)(86362001)(68736007)(2906002)(50986999)(66066001)(3846002)(54356999)(5660300001)(50466002)(101416001)(4001350100001)(2950100001)(7846002)(586003)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0665; 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?MTtDWTFQUjEyTUIwNjY1OzIzOktkeUZRV24zVXdTc0ZBbHZER1VwZXpMNnJQ?= =?utf-8?B?WjYxOTdSRWdpYVRFci8wVnRqSExVeDF4ekd6TlB5eE5wbXJCelIvRWllbzhl?= =?utf-8?B?RWdoTWxrcTcyME15bkVnOEI5bDdxR1l2ZzZzZ1ltODBZNGF3Z214aUNsTnZD?= =?utf-8?B?UmZLdHFCYkQ4UHpxQ0x2eHRZRDFtWUJueHI0RmNwdWJURWNpaElKTVRSWWlw?= =?utf-8?B?bHNKSUJJL2l5ZWVYYW1lSmVYV2FrKzhFRnNRZyt3Z1VlYU5yTUxFVDJGZ3pm?= =?utf-8?B?Ly8ydnN6bm96eFJ3cDczWXJlQ3FpVWZ5OWx0aVk5QWJadnNFaVlWZVhHSVlk?= =?utf-8?B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e7R3iBIa/IEbx5NgleMcdCm9sI9f4TDxwfLjMB+kjfVAze3M1nGXF/kISqZlHOS1I+ZXx4XkJnisteTIQ90uzeh1phoeYkC/0b3FEPh1f5U=; 7:jVBTdHlH5MzAT+Kd1NJ7gb+gl2bk71r74fRFHbgsrwHzeAZOvRsK7UVBARx5Zi8aJOFFNx5YW7HCKvy+PkuWY0LuHW02pfkndnXDu6n3kA3lrZi3D8HkKctRj0eIZ2BuV0zYGZLr4Xe+OduCMaIEiPrBYNelnTZc655NP144jF4SD1AXJi5cZ2xttr3LT0z803eKdg/kHnXWYJkJTgLANADteKA9tuOsrSY4nE7wd9KC4tFajsvaGSHlcsAdzmOTx9KGGRl2FqwZ2yPXxlYZYcgS7XPelKlTEbLHdHmHcNdSdVzjsExYnsXrCVzJEe4Z SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0665; 20:aTOgV6PeKieTOxoZVIf4AvvsxnUdgj6PvNO1M5bQJrnwgwmgsocPevheQwNWfFI2jHINHZwRzGCxBr3eqEz2moC1vQ4N5nevw+C3eAB+4S59D1c7Kik4ujM/S/zov5kz4vQPCbjO2nq/3LpYwZ6kuXAnABzwqu1ss/qgDrColUZUOkXuuGSlZ5p4VVEAwNyKsqxxJVyriQWTn1Q7rVAtkuCvczs6n+KnydBxxr3IzlbL8H6898rqzXMlbeGtykfP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2016 14:52:22.6433 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0665 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.36.58 Subject: [Qemu-devel] [RFC PATCH v2 03/16] exec: add debug version of physical memory read and write apis 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 - cpu_physical_memory_rw_debug - ldl_phys_debug - ldq_phys_debug The idea behind this patch is that if all the qemu monitor memory dumps and gdbserver accesses are done through these common APIs then in future we can define some kind of global debug policy to control debug behavior. Signed-off-by: Brijesh Singh Reviewed-by: Paolo Bonzini --- exec.c | 32 ++++++++++++++++++++++++++++++++ include/exec/cpu-common.h | 15 +++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/exec.c b/exec.c index 0989933..9d0128e 100644 --- a/exec.c +++ b/exec.c @@ -3105,6 +3105,30 @@ uint32_t ldl_phys(AddressSpace *as, hwaddr addr) return address_space_ldl(as, addr, MEMTXATTRS_UNSPECIFIED, NULL); } +uint32_t ldl_phys_debug(CPUState *cpu, hwaddr addr) +{ + MemTxAttrs attrs = MEMTXATTRS_DEBUG; + int asidx = cpu_asidx_from_attrs(cpu, attrs); + uint32_t val; + + cpu_physical_memory_rw_debug_internal(cpu->cpu_ases[asidx].as, + addr, (void *) &val, + 4, attrs, READ_DATA); + return tswap32(val); +} + +uint64_t ldq_phys_debug(CPUState *cpu, hwaddr addr) +{ + MemTxAttrs attrs = MEMTXATTRS_DEBUG; + int asidx = cpu_asidx_from_attrs(cpu, attrs); + uint64_t val; + + cpu_physical_memory_rw_debug_internal(cpu->cpu_ases[asidx].as, + addr, (void *) &val, + 8, attrs, READ_DATA); + return val; +} + uint32_t ldl_le_phys(AddressSpace *as, hwaddr addr) { return address_space_ldl_le(as, addr, MEMTXATTRS_UNSPECIFIED, NULL); @@ -3615,6 +3639,14 @@ 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) +{ + cpu_physical_memory_rw_debug_internal(&address_space_memory, addr, + buf, len, MEMTXATTRS_DEBUG, + is_write ? WRITE_DATA : READ_DATA); +} + /* 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 520dae0..90598d4 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,19 @@ 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); +} +uint32_t ldl_phys_debug(CPUState *cpu, hwaddr addr); +uint64_t ldq_phys_debug(CPUState *cpu, hwaddr addr); + void *cpu_physical_memory_map(hwaddr addr, hwaddr *plen, int is_write);