From patchwork Wed Mar 8 20:51:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9611973 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 4EDAA6016C for ; Wed, 8 Mar 2017 21:25:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4118E2863B for ; Wed, 8 Mar 2017 21:25:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 361222863F; Wed, 8 Mar 2017 21:25:42 +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 3A91A2863B for ; Wed, 8 Mar 2017 21:25:40 +0000 (UTC) Received: from localhost ([::1]:58516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clj5X-0005SZ-8w for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Mar 2017 16:25:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clj4m-00056U-60 for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:24:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clj4j-0005Cm-02 for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:24:52 -0500 Received: from mail-by2nam01on0051.outbound.protection.outlook.com ([104.47.34.51]:27136 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1clj4i-0005Cf-Ka for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:24:48 -0500 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=XbIjfZrn2XuBKsQ8zY5l4tNKSGzBlisuKIdQT6gMfAw=; b=n6+LFm2MacTMCHTqNpUfGjjp/HR0ypU16z37PzltWuC+pHZq678fMxm9CtxDimTuLSkGv8bQ3/HAMTrkrNTN+jujHhb5xJjxoCD0VUQNd2dl5djLBqixjXfmPLgPs+G1/0ZVsdBtupfWvRFZCmyUlihFVK+FRbuNrj5+lmyR2mw= Authentication-Results: amd.com; dkim=none (message not signed) header.d=none;amd.com; dmarc=none action=none header.from=amd.com; Received: from [127.0.1.1] (165.204.77.1) by BN6PR12MB1604.namprd12.prod.outlook.com (10.172.22.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Wed, 8 Mar 2017 20:51:52 +0000 From: Brijesh Singh To: , , , , , , , , Date: Wed, 8 Mar 2017 15:51:48 -0500 Message-ID: <148900630884.27090.10960732348509149156.stgit@brijesh-build-machine> In-Reply-To: <148900626714.27090.1616990932333159904.stgit@brijesh-build-machine> References: <148900626714.27090.1616990932333159904.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CY4PR13CA0020.namprd13.prod.outlook.com (10.168.161.158) To BN6PR12MB1604.namprd12.prod.outlook.com (10.172.22.23) X-MS-Office365-Filtering-Correlation-Id: 5b87706f-cc9c-4392-da00-08d46664f3b3 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081); SRVR:BN6PR12MB1604; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1604; 3:I8wKqEwlr5b1mFY4XnB/N/f1dpNbFcFYIUJ37z4NqK7Eqx8Dhj4wQc5vL0mGBdbXnbDojI/4XjWOVfx623LPwKhRmgwCAWJZAyV70L2REkB71O3+uTlXxYwZyQkhoM276rxCOSzSbCtrQqhfewjosmFNNz5s+7Q7870Y+H6bZOxrh/zrVkeqzY/SX5WWBCPk8nepVdBJ1QlKG8lMyvcMWW/R2wPReFaomgpRPML8GLpdKq4t75A8cEMoNC1MFBREmHN97RPBd9ucLwH5KmPI5BP5inCxAKn2ROkTOLm1MbM=; 25:5JNaRUUQmO7wbdb9ur6/LLYBvvHrlSXGIHFRajb0DQP72XOiywzhIE8SUo/cyoBNZYUxtiBIrzX2iMG4rq3ZJEafeNU08qyrri0cE0aYfOX5wCZqhBe/GOPiqnDBdqKyaZExoSfO+HSW55wmS6xAHey9QLgron1FxjK29lB9I5dHclGSOKIxxJqkkMsWB2nFuAXzKWKtIjWOtDEYA/TXRftKwigPIUkHGSR0VjuU49NuVPoeSHJCm6AICPHW6pHKeYJEIq/QLlRZ23AXY3c847ALLPNtlY1JjPgXVGhh/hTw7BHjBpeHKCMLjHeg6TfqKypdCKP8RuOaFq7iogZpCj6OvXk0c/ARlGY2HjRXez77FnwJJpZ9jzId9/t9Gj5AioARphoGdPU5RXe4Ve06HVeKv2JLynpSkkgJVtvWKb66/ox7ryPgpTaPC30+IIbJ X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1604; 31:B6kS6mh/8s4GyoMPjGGcdFn9Be6HaNKMj2pWRl+WaYMRU2ZDgKaiXtIws8gRKmOUC+nzk8jYLYNh9A2atgof56T7csPsJpMjTkQPWmLEKCEQUM6/g2b2swrphuRhMuMS/Y/4aFv7l1Ioa7Rtrv1v6k5VtB4t+6QttohbnKqqvelWQkhyopFBjZmP6VAneKJo38qqIkz56tau8ALlGckMQqpcuT4PE9nRPiWg7V2kWSQ=; 20:oiMNDP8kC1jJ98NQmJg+g2zZ626pZ+LZ8ZGAp1g4/3O3/0FuJTr+sNzrrPRPKl4NL5Cex77K5+az+6N12ta1m3lVcWGjvs62h3zyVuchMajjtevW4S+VUc6Xe96/YgOdLEPVGmYMtRXtRNDf7L/h9SYRfDEdhfQ060a27/yqe4wGnc/A2ZaxPOu5poWTdLEwj2eMLpz+ihXmbPuwDhZQzq/qaWG9gAKi9HYvHiWinbmUaLvu9MRa9ifsv0f1u7AxMGZTpyTrvnHcxuhCgufcCkK8duZMqCOOUTYxoetyJ3/M51Z9N3yNX466pTmnQXtNJnW0IS4MGSIKum8PjCdyNliksIIGbxb/hebtxEzxZVwJgN48/b7FxTTO3SKExBaac5I/MEhS4maCVbTx3Nf8Plr1uA+qlHHiGqy8gL6qUsxT7GnBKK4p53vR+0NGfKdiydxBQz/0Ag5BNk+tAphv6JpZdYg1+lzJzVLUAnpP1Q2PWIWG0kjL8m9VcAy7Ipm5 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123558025)(20161123560025)(20161123555025)(20161123564025)(6072148); SRVR:BN6PR12MB1604; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1604; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1604; 4:SrswVfoz31xLlUt4hMKx7Qo6tDI9o2LEyxLdpnDhyPCtuBxKwDHXgrNgoM8SEgIymHV+9gGreTKOLTCLuhApVBOJqCSRHVjI2Y4Jtk+qG6lNLOUvAPVFD1Nu4xuiwBCByBkPti43BPk0vah/rd5CC4ozvkyKumWgVKWfED0OcXLh8Ug2CTZQOXP2JaWSAyIQMo/qPFBrMG4bSJU6plarZZW2Z3X/j4iUWeDUh0P9bI9Q6NnDVjZVCSAdtgBTqqHhF+jNqOuryiDHt/F9b5LnGuUHvHAK9vF/jVPFFfYVFXE6mnIKERdQyH3SuZ6kYTt1CYSV/zKHo9AmjPm6bsn5TnOIo2W0FkPHSsZFSucTEd+S/YdloXusRAweJxGCusHuZMpaCgrlzqe79qn14lSHcoMNiP8ATLXbDioBAhULx7BLMEiONlRXcolkd2NV4z3bP6Phl5HlqEEVIUHOPwqmbRH1cDfIa80fKwjpyq5rSyGEOFy093ONRAB2nj1hJ2DpGt+u34kVfLMljezwFBvftbl3MeyFNq4ygzEqZ/UyaALO27RfHUh4DJ/WL7bZF1sGopZHcxCYrxswfA0o7ZaH3WSki4i1+5kpT5Ng7AIAfQzLM3wnYkgoHVpCJEYwIEujF5FLSxUsTmft6eMEujOhaet0OPLPaxXzIemI+oEONiU= X-Forefront-PRVS: 02408926C4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(39860400002)(39840400002)(39410400002)(39850400002)(39450400003)(575784001)(230700001)(83506001)(86362001)(6486002)(5660300001)(33646002)(4326008)(76176999)(2201001)(53936002)(103116003)(77096006)(50466002)(90366009)(189998001)(8676002)(81166006)(7736002)(25786008)(42186005)(54906002)(54356999)(9686003)(33716001)(3846002)(2950100002)(6116002)(6666003)(2906002)(47776003)(38730400002)(66066001)(305945005)(23676002)(50986999)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1604; H:[127.0.1.1]; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxNjA0OzIzOjF0WnM4dHNxdkpGTDhXeDMvRzBXd3F6OEp3?= =?utf-8?B?Y0VLU3lsWDdFQmRMdWhrSlNQM0ltMGVxK3hpV1g5WHQ5eHJ3SlpPWHh3eUpP?= =?utf-8?B?RFNyZ2YxaDlzaHJLTWN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4QOBzE+ogm0kjGIrBd/QPYKZGKldgmkOkyzFX9nuB23T1iSjbcZbN52g+N13tQx+rbcC9Ew2QqFjpN11uAv3upe/IOuGxdpOHpSPQWWbOCmohI/ElaZAepTVyjFQR5EFPVI+co7tZUC9BbkcfLkS0P72vfpCt0dKoogvBOgJGdM=; 24:BsXApTVv6n6sIfImKBL9L4gE/cfPFm+qlJOjF7ra4oYs+0LiUptxxVhwxQ2tcLGCnIrjyLs2o3+gfzXnZ6NtpsrhlAqkKixCQmyyIE/2E6Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1604; 7:ndB4gH24LCdSoEgjV3BvojrjEGGLMu4iIw3XJgtM6VR1+GJzLF2VrZMonC9HBJCLJye7i6S9gq9fIpb3e1BTQC4Bbv4zXOe4yX6oDkpXf5PJCmMvfma/FG1m4vDXDOAlkmM4eb0wuFPwwAfnKfOmMTEpYTzgoLmHiEuxh0xqCr5Fp4S+XZv6GPSm5bX6jKToLUzM3CBuzPzpDJWb/HOMjCq3GGjfpFvAFSHsedy6XfURarG7g20oJI9Nfmy4wOM1/mCE1xTxvF3SanKKokotwHbRhaiYU5QK6DJHdvjlC/DCtNs/HmMs07DclFvrUf7b9yurlfK5uKHYxYwpmv+SjA==; 20:ZEVb25YEM5KlYEhT/VMK9TxwqGGoBWMyrY4sX1xRxciw05xQZzdosdP3XqVqUrpLlnQ+OLEQMaYOJts6k8KETKK4QVAUOIKCjYEpY/Jy4DlCwd+zGFXZHyCiKewt94jT9qE6gqykJ1Hxo+wjh8N6naJAOwfL5i+AMotvkd8oM3DYMyv+bbBCET+FcWgIorRvuZ5ZSSbhcmjdPsBinS66Q2ZDgf41Xr2foOsLZLdbMHOohKrpqKMxfKO6zwMtsy4o X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2017 20:51:52.6245 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1604 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.34.51 Subject: [Qemu-devel] [RFC PATCH v4 04/20] exec: add debug version of physical memory read and write api 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: , Cc: Thomas.Lendacky@amd.com, brijesh.singh@amd.com 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 48ae29c..772a959 100644 --- a/exec.c +++ b/exec.c @@ -3326,6 +3326,38 @@ static inline MemoryRegion *address_space_translate_cached( #define RCU_READ_UNLOCK() ((void)0) #include "memory_ldst.inc.c" +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; +} + +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 b62f0d8..4a9c842 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -74,11 +74,26 @@ size_t qemu_ram_pagesize_largest(void); 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) { cpu_physical_memory_rw(addr, buf, len, 0); } +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); + static inline void cpu_physical_memory_write(hwaddr addr, const void *buf, int len) {