From patchwork Wed Jul 20 05:02:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 9238897 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 9ED82602F0 for ; Wed, 20 Jul 2016 05:08:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92905275A2 for ; Wed, 20 Jul 2016 05:08:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 870D42787C; Wed, 20 Jul 2016 05:08:55 +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 060DF275A2 for ; Wed, 20 Jul 2016 05:08:55 +0000 (UTC) Received: from localhost ([::1]:60596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjkb-0004Ik-Tt for patchwork-qemu-devel@patchwork.kernel.org; Wed, 20 Jul 2016 01:08:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjfN-0007yO-3a for qemu-devel@nongnu.org; Wed, 20 Jul 2016 01:03:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bPjfK-0004gi-Nx for qemu-devel@nongnu.org; Wed, 20 Jul 2016 01:03:28 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:36226) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bPjfK-0004ft-Dv; Wed, 20 Jul 2016 01:03:26 -0400 Received: by mail-pf0-x242.google.com with SMTP id y134so2685670pfg.3; Tue, 19 Jul 2016 22:03:26 -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=ZG1nui5Dx5kEltxPtjo2o95ox7FNOAixynO6/0NliSo=; b=aADzO5tNNwVCjBzbFjbhKKIhLI+3NGCtFFhfj0xX8biiYAwOZfIOgiscCaG48ZOBlt ixH2iaI1MfHw+G21nDcSl4jsXmFN/oyMZYkaLWP3T7l9+oX4iATNiSaRJt2KNQ8RV4TF 2bX3GGGDVJEqxGiNTOGUvi1elQnx4g7eWnB5T4spLYkSJG3tVwz8gSSLoSYedjVk4ldx N61lQb9W3KdpnKXobvQduw5nKRvxiUHYXmerIRw6Xq+F2EfXjXKaf5xIACquqfQtyho0 mW/gCwjf4a3W439oWXexUV8oh+lWF7ldUeonzfTtkAc6vEFePmcW8AQ45z4YS2YZcCqK rZBw== 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=ZG1nui5Dx5kEltxPtjo2o95ox7FNOAixynO6/0NliSo=; b=ZuN5k/Twn24xH4CVrjupGVm5Kcmyj99exooNLjPGNDZJAIZM8sAcdDqKjTmhyZhlx1 QkuVdRWTGxVCsAsNd/x3gM1L+h3Pu3IWlaq8KA2VlAhuDwsmrR6k2F7tiFu80RoSUy2f ojX14zyQSHul9L2LPnM6wPL2AXzPcHzZvmZLmcAdlczr0caOoYoOkS0f5ToBkX/B/6Gx Cs+mIpq6NTgfnfkGTKCCQmsiozfAF4VHQ7O6MD4+No/To12EmkF97Q6recaQ9oRvfpql CpxZ9xuWoE7ojp0b8uRV5MLUi32GcmSHXlSpjwOWJkddz9nXHEWzaOtf6IYl5KVsjxmM qP+Q== X-Gm-Message-State: ALyK8tIAGZajsy8Uu/UucxviY2sWXzvuJ6E4lRAbSrRjQciJ8AC4CvHn8SKtVnKjao+NWw== X-Received: by 10.98.103.70 with SMTP id b67mr61880046pfc.30.1468991005280; Tue, 19 Jul 2016 22:03:25 -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.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 22:03:24 -0700 (PDT) From: Andrey Smirnov To: qemu-devel@nongnu.org Date: Tue, 19 Jul 2016 22:02:58 -0700 Message-Id: <1468990980-4598-9-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 08/10] Convert address_space_rw to use MemoryAccessType 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 Convert address_space_rw() to use MemoryAccessType following the conversion of cpu_memory_rw_debug(). Signed-off-by: Andrey Smirnov Reviewed-by: David Gibson --- exec.c | 14 +++++++++----- include/exec/memory.h | 7 +++++-- kvm-all.c | 8 +++++--- scripts/coverity-model.c | 9 +++++++-- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/exec.c b/exec.c index 995ff60..5557cc9 100644 --- a/exec.c +++ b/exec.c @@ -2726,12 +2726,16 @@ 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, int len, + MemoryAccessType access_type) { - if (is_write) { + switch (access_type) { + case MEM_DATA_STORE: return address_space_write(as, addr, attrs, buf, len); - } else { + case MEM_DATA_LOAD: return address_space_read(as, addr, attrs, buf, len); + default: + abort(); } } @@ -2739,7 +2743,7 @@ void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write) { address_space_rw(&address_space_memory, addr, MEMTXATTRS_UNSPECIFIED, - buf, len, is_write); + buf, len, is_write ? MEM_DATA_STORE : MEM_DATA_LOAD); } enum write_rom_type { @@ -3651,7 +3655,7 @@ int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr, } else { address_space_rw(cpu->cpu_ases[asidx].as, phys_addr, MEMTXATTRS_UNSPECIFIED, - buf, l, 0); + buf, l, access_type); } len -= l; buf += l; diff --git a/include/exec/memory.h b/include/exec/memory.h index 7851ca9..da56c0e 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -22,6 +22,7 @@ #define DIRTY_MEMORY_NUM 3 /* num of dirty bits */ #include "exec/cpu-common.h" +#include "qom/cpu.h" #ifndef CONFIG_USER_ONLY #include "exec/hwaddr.h" #endif @@ -1284,11 +1285,13 @@ void address_space_destroy(AddressSpace *as); * @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred - * @is_write: indicates the transfer direction + * @access_type: indicates the transfer direction (only valid values + * are MEM_DATA_LOAD for data reads and MEM_DATA_STORE for data + * writes) */ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, - int len, bool is_write); + int len, MemoryAccessType access_type); /** * address_space_write: write to address space. diff --git a/kvm-all.c b/kvm-all.c index a88f917..ed45a95 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1767,11 +1767,12 @@ static void kvm_handle_io(uint16_t port, MemTxAttrs attrs, void *data, int direc { int i; uint8_t *ptr = data; + MemoryAccessType access_type = + (direction == KVM_EXIT_IO_OUT) ? MEM_DATA_STORE : MEM_DATA_LOAD; for (i = 0; i < count; i++) { address_space_rw(&address_space_io, port, attrs, - ptr, size, - direction == KVM_EXIT_IO_OUT); + ptr, size, access_type); ptr += size; } } @@ -1947,7 +1948,8 @@ int kvm_cpu_exec(CPUState *cpu) run->mmio.phys_addr, attrs, run->mmio.data, run->mmio.len, - run->mmio.is_write); + run->mmio.is_write ? + MEM_DATA_STORE : MEM_DATA_LOAD); ret = 0; break; case KVM_EXIT_IRQ_WINDOW_OPEN: diff --git a/scripts/coverity-model.c b/scripts/coverity-model.c index ee5bf9d..c5603b5 100644 --- a/scripts/coverity-model.c +++ b/scripts/coverity-model.c @@ -68,13 +68,18 @@ static void __bufread(uint8_t *buf, ssize_t len) } MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len, bool is_write) + uint8_t *buf, int len, + MemoryAccessType access_type) { MemTxResult result; // TODO: investigate impact of treating reads as producing // tainted data, with __coverity_tainted_data_argument__(buf). - if (is_write) __bufread(buf, len); else __bufwrite(buf, len); + if (access_type == MEM_DATA_STORE) { + __bufread(buf, len); + } else { + __bufwrite(buf, len); + } return result; }