From patchwork Wed Jul 20 05:02:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9238905 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 32971602F0 for ; Wed, 20 Jul 2016 05:14:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23CA420587 for ; Wed, 20 Jul 2016 05:14:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 184A62756B; Wed, 20 Jul 2016 05:14:12 +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_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 10CC220587 for ; Wed, 20 Jul 2016 05:14:11 +0000 (UTC) Received: from localhost ([::1]:60634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjph-0001rR-Or for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jul 2016 01:14:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjiE-0002Hd-6B for qemu-devel@nongnu.org; Wed, 20 Jul 2016 01:06:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPji9-0005L1-Tv for qemu-devel@nongnu.org; Wed, 20 Jul 2016 01:06:25 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:36223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPji7-0004iZ-Pp; Wed, 20 Jul 2016 01:06:21 -0400 Received: by mail-pf0-x242.google.com with SMTP id y134so2685598pfg.3; Tue, 19 Jul 2016 22:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e53C5wxavI9lx7rPfdKl+cUL5DG/A3kJwOIJ8/bCmzs=; b=OuyfG4OhAYyzHcd1aw8WKURzpwmoZt4/hHqgJI2OYg0S/Lzy0RWvfLhDODTelrolfF Jajcikec++tX0Ud5bx64rwPxyfoqbLYgcmh1DCcW08roPd6v80z2/nwgkZYHNTkWFuAa vPYlHeXbrjJIFiyk6zbpCyjNMnkq0pXoS2zCkF4xOfWwn7/wjrBYdeokkHC1gWsEh7Z+ 7uMvaxNrwOiQW84qD0Ya9slIBt2eQNqYs25s2u69yAqYxm/xyNFHX1a4HE6bmknjC9XH SEN9rgFHo8kxQAmKvr+nwxvaFGEWx2pVt9KFdIWakwnHDYvZQ6D2y6QNhBtt/X9tmkhu wKaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e53C5wxavI9lx7rPfdKl+cUL5DG/A3kJwOIJ8/bCmzs=; b=jC+y1R32iH7Mj4A1qO+j1ywEE4Dl6RrxlWFJvjmsENwkV5BQ7RrvoS7RF2SYT9Y/cs 8KCpeW3+eDLsPM5QOd1oMm28SnxDk5gh7WuM7Rj2BEGUSkW+mZv2h86m3rbzIcxl0d3R 5vzfV0qLeMST6FdNE0HO7gwlECoYxksvXzV8kGS5wm/eBswrr6NcFCXKhDYknvAvQoig FwhFeTdhA6nrasm9bwkj8uloNAjifNa7+A/8iHi1rqdFPfgnbXSZYDE6996ynwPrCa/2 TFZWwx6E7/D3GGaNRuXetH6XYsXXg2t+5LlHKtx2OtnkP6d5R+SVcKqJGQy8YiPquPXb F5QQ== X-Gm-Message-State: ALyK8tKvKC2TBjLWOJWvTx+bTzm1k90+ff07K1nN5PAiyUTsmeYrln3c0sZcsxv9cKSu+w== X-Received: by 10.98.112.196 with SMTP id l187mr61784548pfc.59.1468991003168; Tue, 19 Jul 2016 22:03:23 -0700 (PDT) Received: from squirtle.localdomain.localdomain (c-73-225-163-254.hsd1.wa.comcast.net. [73.225.163.254]) by smtp.gmail.com with ESMTPSA id c66sm1031757pfd.24.2016.07.19.22.03.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 22:03:22 -0700 (PDT) From: Andrey Smirnov To: qemu-devel@nongnu.org Date: Tue, 19 Jul 2016 22:02:56 -0700 Message-Id: <1468990980-4598-7-git-send-email-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1468990980-4598-1-git-send-email-andrew.smirnov@gmail.com> References: <1468990980-4598-1-git-send-email-andrew.smirnov@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PATCH v3 06/10] Change signature of cpu_memory_rw_debug() to avoid casting 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: Peter Maydell , kvm@vger.kernel.org, Andrey Smirnov , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change signature of cpu_memory_rw_debug() to expectet void * as a buffer instead of uint8_t * to avoid forcing the caller of the function to do a type cast. Reviewed-by: David Gibson Signed-off-by: Andrey Smirnov --- exec.c | 6 ++++-- hw/i386/kvmvapic.c | 10 +++++----- include/exec/cpu-all.h | 2 +- include/exec/softmmu-semi.h | 8 ++++---- target-arm/arm-semi.c | 2 +- target-arm/kvm64.c | 8 ++++---- target-i386/helper.c | 4 ++-- target-i386/kvm.c | 8 ++++---- target-ppc/kvm.c | 8 ++++---- target-s390x/kvm.c | 6 +++--- target-xtensa/xtensa-semi.c | 6 +++--- 11 files changed, 35 insertions(+), 33 deletions(-) diff --git a/exec.c b/exec.c index e2425c5..f20b216 100644 --- a/exec.c +++ b/exec.c @@ -2436,11 +2436,12 @@ MemoryRegion *get_system_io(void) /* physical memory access (slow version, mainly for debug) */ #if defined(CONFIG_USER_ONLY) int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, - uint8_t *buf, int len, int is_write) + void *b, int len, int is_write) { int l, flags; target_ulong page; void * p; + uint8_t *buf = b; while (len > 0) { page = addr & TARGET_PAGE_MASK; @@ -3617,11 +3618,12 @@ void stq_be_phys(AddressSpace *as, hwaddr addr, uint64_t val) /* 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) + void *b, int len, int is_write) { int l; hwaddr phys_addr; target_ulong page; + uint8_t *buf = b; while (len > 0) { int asidx; diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index 3bf1ddd..c684675 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -261,7 +261,7 @@ instruction_ok: * and update the cached values. */ if (cpu_memory_rw_debug(cs, ip + instr->addr_offset, - (void *)&real_tpr_addr, + &real_tpr_addr, sizeof(real_tpr_addr), 0) < 0) { return -1; } @@ -349,7 +349,7 @@ static int get_kpcr_number(X86CPU *cpu) } QEMU_PACKED kpcr; if (cpu_memory_rw_debug(CPU(cpu), env->segs[R_FS].base, - (void *)&kpcr, sizeof(kpcr), 0) < 0 || + &kpcr, sizeof(kpcr), 0) < 0 || kpcr.self != env->segs[R_FS].base) { return -1; } @@ -388,7 +388,7 @@ static void patch_call(VAPICROMState *s, X86CPU *cpu, target_ulong ip, offset = cpu_to_le32(target - ip - 5); patch_byte(cpu, ip, 0xe8); /* call near */ - cpu_memory_rw_debug(CPU(cpu), ip + 1, (void *)&offset, sizeof(offset), 1); + cpu_memory_rw_debug(CPU(cpu), ip + 1, &offset, sizeof(offset), 1); } static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip) @@ -434,8 +434,8 @@ static void patch_instruction(VAPICROMState *s, X86CPU *cpu, target_ulong ip) break; case 0xc7: /* mov imm32, r/m32 (c7/0) */ patch_byte(cpu, ip, 0x68); /* push imm32 */ - cpu_memory_rw_debug(cs, ip + 6, (void *)&imm32, sizeof(imm32), 0); - cpu_memory_rw_debug(cs, ip + 1, (void *)&imm32, sizeof(imm32), 1); + cpu_memory_rw_debug(cs, ip + 6, &imm32, sizeof(imm32), 0); + cpu_memory_rw_debug(cs, ip + 1, &imm32, sizeof(imm32), 1); patch_call(s, cpu, ip + 5, handlers->set_tpr); break; case 0xff: /* push r/m32 */ diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index b6a7059..ad498d0 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -310,7 +310,7 @@ void dump_opcount_info(FILE *f, fprintf_function cpu_fprintf); #endif /* !CONFIG_USER_ONLY */ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, - uint8_t *buf, int len, int is_write); + void *buf, int len, int is_write); int cpu_exec(CPUState *cpu); diff --git a/include/exec/softmmu-semi.h b/include/exec/softmmu-semi.h index 7eefad8..263aa25 100644 --- a/include/exec/softmmu-semi.h +++ b/include/exec/softmmu-semi.h @@ -14,7 +14,7 @@ static inline uint64_t softmmu_tget64(CPUArchState *env, target_ulong addr) { uint64_t val; - cpu_memory_rw_debug(ENV_GET_CPU(env), addr, (uint8_t *)&val, 8, 0); + cpu_memory_rw_debug(ENV_GET_CPU(env), addr, &val, 8, 0); return tswap64(val); } @@ -22,7 +22,7 @@ static inline uint32_t softmmu_tget32(CPUArchState *env, target_ulong addr) { uint32_t val; - cpu_memory_rw_debug(ENV_GET_CPU(env), addr, (uint8_t *)&val, 4, 0); + cpu_memory_rw_debug(ENV_GET_CPU(env), addr, &val, 4, 0); return tswap32(val); } @@ -43,14 +43,14 @@ static inline void softmmu_tput64(CPUArchState *env, target_ulong addr, uint64_t val) { val = tswap64(val); - cpu_memory_rw_debug(ENV_GET_CPU(env), addr, (uint8_t *)&val, 8, 1); + cpu_memory_rw_debug(ENV_GET_CPU(env), addr, &val, 8, 1); } static inline void softmmu_tput32(CPUArchState *env, target_ulong addr, uint32_t val) { val = tswap32(val); - cpu_memory_rw_debug(ENV_GET_CPU(env), addr, (uint8_t *)&val, 4, 1); + cpu_memory_rw_debug(ENV_GET_CPU(env), addr, &val, 4, 1); } #define put_user_u64(arg, p) ({ softmmu_tput64(env, p, arg) ; 0; }) #define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; }) diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c index 7cac873..bd4bf13 100644 --- a/target-arm/arm-semi.c +++ b/target-arm/arm-semi.c @@ -187,7 +187,7 @@ static void arm_semi_flen_cb(CPUState *cs, target_ulong ret, target_ulong err) /* The size is always stored in big-endian order, extract the value. We assume the size always fit in 32 bits. */ uint32_t size; - cpu_memory_rw_debug(cs, arm_flen_buf(cpu) + 32, (uint8_t *)&size, 4, 0); + cpu_memory_rw_debug(cs, arm_flen_buf(cpu) + 32, &size, 4, 0); size = be32_to_cpu(size); if (is_a64(env)) { env->xregs[0] = size; diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c index 5faa76c..7ba5acd 100644 --- a/target-arm/kvm64.c +++ b/target-arm/kvm64.c @@ -874,8 +874,8 @@ static const uint32_t brk_insn = 0xd4200000; int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) { if (have_guest_debug) { - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) { + if (cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, 4, 0) || + cpu_memory_rw_debug(cs, bp->pc, &brk_insn, 4, 1)) { return -EINVAL; } return 0; @@ -890,9 +890,9 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) static uint32_t brk; if (have_guest_debug) { - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) || + if (cpu_memory_rw_debug(cs, bp->pc, &brk, 4, 0) || brk != brk_insn || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 1)) { + cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, 4, 1)) { return -EINVAL; } return 0; diff --git a/target-i386/helper.c b/target-i386/helper.c index 1c250b8..3e8d86f 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1286,8 +1286,8 @@ int cpu_x86_get_descr_debug(CPUX86State *env, unsigned int selector, index = selector & ~7; ptr = dt->base + index; if ((index + 7) > dt->limit - || cpu_memory_rw_debug(cs, ptr, (uint8_t *)&e1, sizeof(e1), 0) != 0 - || cpu_memory_rw_debug(cs, ptr+4, (uint8_t *)&e2, sizeof(e2), 0) != 0) + || cpu_memory_rw_debug(cs, ptr, &e1, sizeof(e1), 0) != 0 + || cpu_memory_rw_debug(cs, ptr + 4, &e2, sizeof(e2), 0) != 0) return 0; *base = ((e1 >> 16) | ((e2 & 0xff) << 16) | (e2 & 0xff000000)); diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 9327523..46e6a64 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -2911,10 +2911,10 @@ static int kvm_handle_tpr_access(X86CPU *cpu) int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) { - static const uint8_t int3 = 0xcc; + uint8_t int3 = 0xcc; - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 1, 0) || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&int3, 1, 1)) { + if (cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, 1, 0) || + cpu_memory_rw_debug(cs, bp->pc, &int3, 1, 1)) { return -EINVAL; } return 0; @@ -2925,7 +2925,7 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) uint8_t int3; if (cpu_memory_rw_debug(cs, bp->pc, &int3, 1, 0) || int3 != 0xcc || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1)) { + cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, 1, 1)) { return -EINVAL; } return 0; diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 7a8f555..73ac879 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -1454,9 +1454,9 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) /* Mixed endian case is not handled */ uint32_t sc = debug_inst_opcode; - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, + if (cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, sizeof(sc), 0) || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&sc, sizeof(sc), 1)) { + cpu_memory_rw_debug(cs, bp->pc, &sc, sizeof(sc), 1)) { return -EINVAL; } @@ -1467,9 +1467,9 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) { uint32_t sc; - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&sc, sizeof(sc), 0) || + if (cpu_memory_rw_debug(cs, bp->pc, &sc, sizeof(sc), 0) || sc != debug_inst_opcode || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, + cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, sizeof(sc), 1)) { return -EINVAL; } diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 2991bff..565b1b2 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -671,9 +671,9 @@ static const uint8_t diag_501[] = {0x83, 0x24, 0x05, 0x01}; int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) { - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, + if (cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, sizeof(diag_501), 0) || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)diag_501, + cpu_memory_rw_debug(cs, bp->pc, diag_501, sizeof(diag_501), 1)) { return -EINVAL; } @@ -688,7 +688,7 @@ int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp) return -EINVAL; } else if (memcmp(t, diag_501, sizeof(diag_501))) { return -EINVAL; - } else if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, + } else if (cpu_memory_rw_debug(cs, bp->pc, &bp->saved_insn, sizeof(diag_501), 1)) { return -EINVAL; } diff --git a/target-xtensa/xtensa-semi.c b/target-xtensa/xtensa-semi.c index 370e365..ec199ac 100644 --- a/target-xtensa/xtensa-semi.c +++ b/target-xtensa/xtensa-semi.c @@ -202,7 +202,7 @@ void HELPER(simcall)(CPUXtensaState *env) for (i = 0; i < ARRAY_SIZE(name); ++i) { rc = cpu_memory_rw_debug(cs, regs[3] + i, - (uint8_t *)name + i, 1, 0); + &name[i], 1, 0); if (rc != 0 || name[i] == 0) { break; } @@ -247,7 +247,7 @@ void HELPER(simcall)(CPUXtensaState *env) if (target_tv) { cpu_memory_rw_debug(cs, target_tv, - (uint8_t *)target_tvv, sizeof(target_tvv), 0); + target_tvv, sizeof(target_tvv), 0); tv.tv_sec = (int32_t)tswap32(target_tvv[0]); tv.tv_usec = (int32_t)tswap32(target_tvv[1]); } @@ -282,7 +282,7 @@ void HELPER(simcall)(CPUXtensaState *env) argv.argptr[0] = tswap32(regs[3] + offsetof(struct Argv, text)); cpu_memory_rw_debug(cs, - regs[3], (uint8_t *)&argv, sizeof(argv), 1); + regs[3], &argv, sizeof(argv), 1); } break;