From patchwork Tue Mar 1 15:57:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Galvan X-Patchwork-Id: 8466391 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 45FEBC0553 for ; Tue, 1 Mar 2016 15:58:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45B66202E5 for ; Tue, 1 Mar 2016 15:58:07 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 169542014A for ; Tue, 1 Mar 2016 15:58:06 +0000 (UTC) Received: from localhost ([::1]:50520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aamgX-0006Zm-EZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 01 Mar 2016 10:58:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aamgI-0006Uj-FJ for qemu-devel@nongnu.org; Tue, 01 Mar 2016 10:57:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aamgE-0006Cs-3y for qemu-devel@nongnu.org; Tue, 01 Mar 2016 10:57:50 -0500 Received: from mail-qg0-x22b.google.com ([2607:f8b0:400d:c04::22b]:34262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aamgD-0006Cm-Ur for qemu-devel@nongnu.org; Tue, 01 Mar 2016 10:57:46 -0500 Received: by mail-qg0-x22b.google.com with SMTP id b67so145231981qgb.1 for ; Tue, 01 Mar 2016 07:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tallertechnologies.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=wnVUeaWVKh0wABfZ7OSjNV7UpewFqnYS/GQon/Ja8U4=; b=KYljRZm5gskulnirXgWrwT0WReeTmWrC7upx2Ay0AYpcbUeE4BgErZEQb0qrOLlPQX Cr0jA2NMf+6SeWe9c9ZJZm4VWrYLptWFRZzuA7dbrA3Bun4EWDVAv9E4zx+KaOJ+Pvq5 DV7GYCdJHoGnCmMygLcdXg2CorGo7T4hidXn8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=wnVUeaWVKh0wABfZ7OSjNV7UpewFqnYS/GQon/Ja8U4=; b=kC1VgvvqMdcwb/EJl0LVaIe7rthYCSD/WCbatza+Rro9qTX5b3ry2eOKgVk/UQkb8K guPUJ5+mkLEiq5aZAVBEvneUpvK96bYA/HTOzemP0vvXCGeQzAE7FgFYbi1yOw9LJAMn Hekjy8EBRDuDAnzjj6R5YR9LZMU9Xl05DTgVEpUKU0ND4zZHv1Y2XFgCaOoi2KVocNMJ gC6AG9kQkKNN4DYeLb87IEKvF/CNsglph8ZzWMjQmoK9pqi+YCUkp4lWLEQr3ssM+S5f eButoU3dfW+c6ngS9lYqmrpdQ24RZTnfhXibiztcmCKF3DLniNmGJ9Ls9x6nfuck9hay 4CLQ== X-Gm-Message-State: AD7BkJIxh6pPEFGHtTRT1cQ+MNv/JxPG3PO4OmGlIJaFPkQkjDE8CQfHDajcV7/LDEQNCTjQ X-Received: by 10.140.91.115 with SMTP id y106mr27169953qgd.20.1456847865490; Tue, 01 Mar 2016 07:57:45 -0800 (PST) Received: from martin-galvan.dominio.tallertechnologies.com ([200.69.202.173]) by smtp.gmail.com with ESMTPSA id 123sm13109030qhu.22.2016.03.01.07.57.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Mar 2016 07:57:45 -0800 (PST) From: Martin Galvan To: qemu-devel@nongnu.org, peter.maydell@linaro.org, pbonzini@redhat.com, edgar.iglesias@gmail.com, rth@twiddle.net, aurelien@aurel32.net, kraxel@redhat.com, blauwirbel@gmail.com, lcapitulino@redhat.com, armbru@redhat.com, afaerber@suse.de, dmitry@daynix.com Date: Tue, 1 Mar 2016 12:57:27 -0300 Message-Id: <1456847859-4771-1-git-send-email-martin.galvan@tallertechnologies.com> X-Mailer: git-send-email 2.7.1 In-Reply-To: <1456847650-4476-1-git-send-email-martin.galvan@tallertechnologies.com> References: <1456847650-4476-1-git-send-email-martin.galvan@tallertechnologies.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::22b Subject: [Qemu-devel] [PATCH v2 01/13] Use unsigned types for the 'len' argument of all memory read/write functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP --- cpus.c | 2 +- exec.c | 29 +++++++++++++++-------------- include/exec/cpu-all.h | 2 +- include/exec/cpu-common.h | 10 +++++----- include/exec/memory.h | 10 +++++----- kvm-all.c | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) --- 1.9.1 diff --git a/cpus.c b/cpus.c index 9592163..e7aa8cc 100644 --- a/cpus.c +++ b/cpus.c @@ -1602,7 +1602,7 @@ void qmp_memsave(int64_t addr, int64_t size, const char *filename, bool has_cpu, int64_t cpu_index, Error **errp) { FILE *f; - uint32_t l; + size_t l; CPUState *cpu; uint8_t buf[1024]; int64_t orig_addr = addr, orig_size = size; diff --git a/exec.c b/exec.c index c62c439..b5c26d6 100644 --- a/exec.c +++ b/exec.c @@ -2458,9 +2458,10 @@ 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) + uint8_t *buf, size_t len, int is_write) { - int l, flags; + size_t l; + int flags; target_ulong page; void * p; @@ -2517,7 +2518,7 @@ static void invalidate_and_set_dirty(MemoryRegion *mr, hwaddr addr, cpu_physical_memory_set_dirty_range(addr, length, dirty_log_mask); } -static int memory_access_size(MemoryRegion *mr, unsigned l, hwaddr addr) +static hwaddr memory_access_size(MemoryRegion *mr, size_t l, hwaddr addr) { unsigned access_size_max = mr->ops->valid.max_access_size; @@ -2571,7 +2572,7 @@ static bool prepare_mmio_access(MemoryRegion *mr) static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, - int len, hwaddr addr1, + size_t len, hwaddr addr1, hwaddr l, MemoryRegion *mr) { uint8_t *ptr; @@ -2642,7 +2643,7 @@ static MemTxResult address_space_write_continue(AddressSpace *as, hwaddr addr, } MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - const uint8_t *buf, int len) + const uint8_t *buf, size_t len) { hwaddr l; hwaddr addr1; @@ -2664,7 +2665,7 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, /* Called within RCU critical section. */ MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, - int len, hwaddr addr1, hwaddr l, + size_t len, hwaddr addr1, hwaddr l, MemoryRegion *mr) { uint8_t *ptr; @@ -2732,7 +2733,7 @@ MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr, } MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, int len) + MemTxAttrs attrs, uint8_t *buf, size_t len) { hwaddr l; hwaddr addr1; @@ -2752,7 +2753,7 @@ MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, } MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len, bool is_write) + uint8_t *buf, size_t len, bool is_write) { if (is_write) { return address_space_write(as, addr, attrs, (uint8_t *)buf, len); @@ -2762,7 +2763,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, } void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, - int len, int is_write) + size_t len, int is_write) { address_space_rw(&address_space_memory, addr, MEMTXATTRS_UNSPECIFIED, buf, len, is_write); @@ -2812,12 +2813,12 @@ static inline void cpu_physical_memory_write_rom_internal(AddressSpace *as, /* used for ROM loading : can write in RAM and ROM */ void cpu_physical_memory_write_rom(AddressSpace *as, hwaddr addr, - const uint8_t *buf, int len) + const uint8_t *buf, size_t len) { cpu_physical_memory_write_rom_internal(as, addr, buf, len, WRITE_DATA); } -void cpu_flush_icache_range(hwaddr start, int len) +void cpu_flush_icache_range(hwaddr star t, size_t len) { /* * This function should do the same thing as an icache flush that was @@ -3661,14 +3662,14 @@ 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) + uint8_t *buf, size_t len, int is_write) { - int l; + size_t l; hwaddr phys_addr; target_ulong page; while (len > 0) { - int asidx; + hwaddr asidx; MemTxAttrs attrs; page = addr & TARGET_PAGE_MASK; diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 08e5093..c824d5f 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -282,6 +282,6 @@ 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); + uint8_t *buf, size_t len, int is_write); #endif /* CPU_ALL_H */ diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index a0ad2ac..f413387 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -71,14 +71,14 @@ void qemu_ram_unset_idstr(ram_addr_t addr); const char *qemu_ram_get_idstr(RAMBlock *rb); void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, - int len, int is_write); + size_t len, int is_write); static inline void cpu_physical_memory_read(hwaddr addr, - void *buf, int len) + void *buf, size_t len) { cpu_physical_memory_rw(addr, buf, len, 0); } static inline void cpu_physical_memory_write(hwaddr addr, - const void *buf, int len) + const void *buf, size_t len) { cpu_physical_memory_rw(addr, (void *)buf, len, 1); } @@ -125,8 +125,8 @@ void stq_phys(AddressSpace *as, hwaddr addr, uint64_t val); #endif void cpu_physical_memory_write_rom(AddressSpace *as, hwaddr addr, - const uint8_t *buf, int len); -void cpu_flush_icache_range(hwaddr start, int len); + const uint8_t *buf, size_t len); +void cpu_flush_icache_range(hwaddr start, size_t len); extern struct MemoryRegion io_mem_rom; extern struct MemoryRegion io_mem_notdirty; diff --git a/include/exec/memory.h b/include/exec/memory.h index d5284c2..a4d34f1 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1233,7 +1233,7 @@ void address_space_destroy(AddressSpace *as); */ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, - int len, bool is_write); + size_t len, bool is_write); /** * address_space_write: write to address space. @@ -1249,7 +1249,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, */ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - const uint8_t *buf, int len); + const uint8_t *buf, size_t len); /* address_space_ld*: load from an address space * address_space_st*: store to an address space @@ -1384,10 +1384,10 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, /* Internal functions, part of the implementation of address_space_read. */ MemTxResult address_space_read_continue(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, - int len, hwaddr addr1, hwaddr l, + size_t len, hwaddr addr1, size_t l, MemoryRegion *mr); MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, int len); + MemTxAttrs attrs, uint8_t *buf, size_t len); void *qemu_get_ram_ptr(RAMBlock *ram_block, ram_addr_t addr); static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) @@ -1413,7 +1413,7 @@ static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) */ static inline __attribute__((__always_inline__)) MemTxResult address_space_read(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len) + uint8_t *buf, size_t len) { MemTxResult result = MEMTX_OK; hwaddr l, addr1; diff --git a/kvm-all.c b/kvm-all.c index a65e73f..14098b6 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1703,7 +1703,7 @@ void kvm_set_sigmask_len(KVMState *s, unsigned int sigmask_len) } static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direction, - int size, uint32_t count) + size_t size, uint32_t count) { int i; uint8_t *ptr = data;