From patchwork Sun Sep 30 08:13:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 147858 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2667055lji; Sun, 30 Sep 2018 02:03:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV62MU5UBfBL3MSctul5vX9iuwysTf+W6aN3B8C7nzG1QsxJYkUsoBmqVdrmBJogRqdl1ML/y X-Received: by 2002:aed:2253:: with SMTP id o19-v6mr4668887qtc.72.1538298193471; Sun, 30 Sep 2018 02:03:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538298193; cv=none; d=google.com; s=arc-20160816; b=FrjAK8CMkmH7u/qcY3//2Mk8v1PYKFnXyTgHv2k+biIv/CnLzxNBH6OB5I1buRp/Ql xKXYrophX4r4UZ6VSG8oUR6kYt4qp7t4wHfp4QudtV1+bBuXXmcq362zH1QfhyLLrZl6 5lgIjQfxuydT5ZqxBVGBNvexUI8y1208gZbX7v9j+ajuT605v4UrAfAjtFElRVVSgVgK cn/OLnpk5FvAXqA6oUAJNKMyXwJvSOx+eVN/lYi+9BKWcf41DHWYxgpRawtgDqGjdcVz QLQaiI+ZIsJOib36MYVWLV/lS1vRjQlBR0oQCwBV+6OCQQhh6h5N81hDEQ79mlHmX9Pg qJMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=s7Bu+uzW3BicMDf2fX0cUiMAdEB7LDlujFfBaRPQ7XI=; b=GfIY8GuGJdLgavmzQvctMdtLN2k8W/CS3F3/LL09YHrxsLtCq1ciGbcCG/IVJfh5u1 4wq7na8okPPn5MC3w4ds80c8BT8uNDhFXE4wY1C/l7KU3zP+am4Www/JVdxKbj7nPcIW qtEThEFd1n9HWohjBYx2T+zfziFI6IQ+XSEzHwV5nokqktAnyPDMRZ8WjmuTOm3YSXhn HHg6ANln06e0UEKgXLb7S6dleT1y8P+1IWyuD6cFDc7BpZyqB3JQPn/J1irFCyjKugB1 0sdolGjdzbvUVbj/xRmeGYj0y9MSHYNPtYkkkn2OlThmB5GTc2Fp3TKbZ4IUSdmTG7Mw Cshw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GXazReh3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r4-v6si2182699qvn.102.2018.09.30.02.03.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 30 Sep 2018 02:03:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GXazReh3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:54498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6XdB-0008FN-0Q for patch@linaro.org; Sun, 30 Sep 2018 05:03:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WsI-0003Bv-Sb for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6WsC-0001I8-QB for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:43 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:34835) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6WsC-0001Ee-0q for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:40 -0400 Received: by mail-wm1-x32a.google.com with SMTP id o18-v6so5779308wmc.0 for ; Sun, 30 Sep 2018 01:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=s7Bu+uzW3BicMDf2fX0cUiMAdEB7LDlujFfBaRPQ7XI=; b=GXazReh38DBoPheP5z0wtJ2eQr7My+9yMYDaJSaiXsvnhwDQLfu/18qw66HTrSsA59 t4l6bCpbEFlfUQtl6YONd+mecJHUkuBOBLLwBnlcdUBqumqFVApqPoF0m8uTIIF7zkhs 4t/ZDOKojea0tHvf01eBd0Shu32n1ekPq2AC9cveyqv70OwOVOzKLZuURc0myP3ZHKrK WOmYNBS+QcKvIn2j/oHSabNr6OHXaRCJvm5BvqapRx5Ctsp2UZSoNd5CHxpkm7H2YnIk h41sDGFUzG2o6KEDd55DC8f5j3WJrYZzRukiElur1lIrAPhZh3kDOvEbzhT4Tu1WMkv+ OCnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=s7Bu+uzW3BicMDf2fX0cUiMAdEB7LDlujFfBaRPQ7XI=; b=XO9bYQMNuMrGcZ/ODE/SNIxJrz/HoCLraeDYGetF6bUImbvfIwwDzLL65O/va6NSTl s227LS9/VdKy/IwEYfZ7iBTYiH5YwOrvWtO+YwtZ0ZZrw28/yuDd6SVEOv2eMm1iRjqQ Y5iJd1DWHNWlJAaUskOZsrSbFyDuInsg3Lx5QQIROIB2KYG6vk2NJ0aq1F0TRP/q9G0O Cl7l1gputc6JaC+OiaGDj79MsODZZw4ndc5f5l1RBowgXVm+kEtGEb5S1zZeRLoY2KJg hVywemfDfKx9KSBdOPasOEiXWzAXj5wqs73rz9KVBhx9BeljNOQSDHjsHYOcaz2lLqzV /sOg== X-Gm-Message-State: ABuFfogmZOUTpl14pm5xhD2An0v9r/NKtNrRuyKF5Np1Y6/wKN5mXBdp nq7brz9lz1hT7SCIO9PpvGKWFixO X-Received: by 2002:a1c:2dc5:: with SMTP id t188-v6mr5708090wmt.94.1538295276844; Sun, 30 Sep 2018 01:14:36 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:14:36 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:13:13 +0200 Message-Id: <1538295197-23704-76-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a Subject: [Qemu-devel] [PULL 75/79] memory: Remove old_mmio accessors 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Now that all the users of old_mmio MemoryRegion accessors have been converted, we can remove the core code support. Signed-off-by: Peter Maydell Message-Id: <20180824170422.5783-2-peter.maydell@linaro.org> Based-on: <20180802174042.29234-1-peter.maydell@linaro.org> Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- docs/devel/memory.txt | 2 -- include/exec/memory.h | 5 ---- memory.c | 63 ++------------------------------------------------- 3 files changed, 2 insertions(+), 68 deletions(-) -- 1.8.3.1 diff --git a/docs/devel/memory.txt b/docs/devel/memory.txt index c1dee12..4fff0d5 100644 --- a/docs/devel/memory.txt +++ b/docs/devel/memory.txt @@ -342,5 +342,3 @@ various constraints can be supplied to control how these callbacks are called: - .impl.unaligned specifies that the *implementation* supports unaligned accesses; if false, unaligned accesses will be emulated by two aligned accesses. - - .old_mmio eases the porting of code that was formerly using - cpu_register_io_memory(). It should not be used in new code. diff --git a/include/exec/memory.h b/include/exec/memory.h index e78a9a4..3a427aa 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -201,11 +201,6 @@ struct MemoryRegionOps { */ bool unaligned; } impl; - - /* If .read and .write are not present, old_mmio may be used for - * backwards compatibility with old mmio registration - */ - const MemoryRegionMmio old_mmio; }; enum IOMMUMemoryRegionAttr { diff --git a/memory.c b/memory.c index b96aec7..d852f11 100644 --- a/memory.c +++ b/memory.c @@ -423,32 +423,6 @@ static int get_cpu_index(void) return -1; } -static MemTxResult memory_region_oldmmio_read_accessor(MemoryRegion *mr, - hwaddr addr, - uint64_t *value, - unsigned size, - signed shift, - uint64_t mask, - MemTxAttrs attrs) -{ - uint64_t tmp; - - tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr); - if (mr->subpage) { - trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, size); - } else if (mr == &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ - trace_memory_region_tb_read(get_cpu_index(), addr, tmp, size); - } else if (TRACE_MEMORY_REGION_OPS_READ_ENABLED) { - hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr); - trace_memory_region_ops_read(get_cpu_index(), mr, abs_addr, tmp, size); - } - memory_region_shift_read_access(value, shift, mask, tmp); - return MEMTX_OK; -} - static MemTxResult memory_region_read_accessor(MemoryRegion *mr, hwaddr addr, uint64_t *value, @@ -502,31 +476,6 @@ static MemTxResult memory_region_read_with_attrs_accessor(MemoryRegion *mr, return r; } -static MemTxResult memory_region_oldmmio_write_accessor(MemoryRegion *mr, - hwaddr addr, - uint64_t *value, - unsigned size, - signed shift, - uint64_t mask, - MemTxAttrs attrs) -{ - uint64_t tmp = memory_region_shift_write_access(value, shift, mask); - - if (mr->subpage) { - trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, size); - } else if (mr == &io_mem_notdirty) { - /* Accesses to code which has previously been translated into a TB show - * up in the MMIO path, as accesses to the io_mem_notdirty - * MemoryRegion. */ - trace_memory_region_tb_write(get_cpu_index(), addr, tmp, size); - } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { - hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr); - trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, size); - } - mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp); - return MEMTX_OK; -} - static MemTxResult memory_region_write_accessor(MemoryRegion *mr, hwaddr addr, uint64_t *value, @@ -1418,16 +1367,12 @@ static MemTxResult memory_region_dispatch_read1(MemoryRegion *mr, mr->ops->impl.max_access_size, memory_region_read_accessor, mr, attrs); - } else if (mr->ops->read_with_attrs) { + } else { return access_with_adjusted_size(addr, pval, size, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_read_with_attrs_accessor, mr, attrs); - } else { - return access_with_adjusted_size(addr, pval, size, 1, 4, - memory_region_oldmmio_read_accessor, - mr, attrs); } } @@ -1499,17 +1444,13 @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr, mr->ops->impl.max_access_size, memory_region_write_accessor, mr, attrs); - } else if (mr->ops->write_with_attrs) { + } else { return access_with_adjusted_size(addr, &data, size, mr->ops->impl.min_access_size, mr->ops->impl.max_access_size, memory_region_write_with_attrs_accessor, mr, attrs); - } else { - return access_with_adjusted_size(addr, &data, size, 1, 4, - memory_region_oldmmio_write_accessor, - mr, attrs); } } From patchwork Sun Sep 30 08:13:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 147857 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2666778lji; Sun, 30 Sep 2018 02:02:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV61FVIPWS+Sm+x9TSspbZjKxPzIiX7DyhTcPeGYBKPnOlB/91p1lSLqx5Yd7YzrwAhwZxDSt X-Received: by 2002:a37:b101:: with SMTP id a1-v6mr4425638qkf.222.1538298175943; Sun, 30 Sep 2018 02:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538298175; cv=none; d=google.com; s=arc-20160816; b=siYTnupfA/jsLxZclxNxjLg/cEBPSiZPNkOZwshPRUKO9rqEmRwWMAnEgPg335aT+X SAz7vR0dxrvBL95KnkkuxGALLm2VP1KJL9YBMvQfPDqC7pWlmcajgXaklYmd0mopVlVC WjegZ17VQtxb+YVBS/86L8gKEfHFCJGnk3XCTcjFw0/4DUGk8FOPAK5LUvaJxC8vtUd4 jTObvRrgP88n9zJQKyjHjuJROKHnDQ+BJ12vtkK3CH02PCxWUY38kWqDGMLwUPswzg6q FIK9gNSXXlNo+gEMnga/kfzTuoFl4CExpAYXCwmXDB92aNseTmocY7kaQJHs2pwHVRVa t8lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=U3OKt6hI7/yB7/5o6VHwnzl7wloM7tC5itIujJtuUXo=; b=OtsH81S0X8xNEO+3pNQNXxwXZayoCj1QEaFH4D9K4MXDzZfL+YF5uTjD9rEewt/FuT mTvN9qRLF6AFavJM691bF4vHbPJRUR+F9o65f9Dwgp9+LqMRQI7tIzfqPzMquhEs/l9d pRLHbRHSORPUAMbVsbxoBF0e7ejJfLYe6Fy+C8aTUBjuRs2A9pPpiYlQ+w1MAd/mk3UY bDpqE1ne3YOmp1/cAF2LMo7yUFY7USdg2hM0p/3RakpWtSzz4qpe5ZmpvE7X3ZEQ+/wN I5c3bB1VoFDkiy0AqYUbMTGpQvLb19csPdgOtvQQky3r2gtoQ0IRnnNjkROCryOfUxZL hsZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="K4Al/Apa"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j9-v6si1171718qvi.159.2018.09.30.02.02.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 30 Sep 2018 02:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="K4Al/Apa"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:54497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6Xct-0008DF-EO for patch@linaro.org; Sun, 30 Sep 2018 05:02:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WsI-0003Bt-Sg for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6WsC-0001HX-3W for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:43 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:43543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6WsB-0001Ey-Lg for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:39 -0400 Received: by mail-wr1-x443.google.com with SMTP id n1-v6so331818wrt.10 for ; Sun, 30 Sep 2018 01:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=U3OKt6hI7/yB7/5o6VHwnzl7wloM7tC5itIujJtuUXo=; b=K4Al/ApaQldf3te6T8iQVDlFWhW676OqyAKvnpZW/EqlnARnzktfgBq6ph69U+T7F6 o0hS6gS8LSwjFjXwhAInXjCrBc//XQyZjEST4KW+CyoHrU4AOaStWHtU5ArC07RUXdBs 8iSw2KN9IRfOW5anG5zOo9oBtf2KqBH218Bkz5aLIYCzLFsOce0eCdco7lh0kXQxLz8C ZTdgfyd4bjBE9+l/IU05Eu+SVwJKM2g3xSzf9PpJJcewZR+KpaJ4ea9fJD4i89/Rv8jV kqMm+w7sWrxkzMvDfZqz/GTskE8VDQ0xFvSDP4qzdBhxudFAIYuATlmj+lsI/yPIaQ5D 9xQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=U3OKt6hI7/yB7/5o6VHwnzl7wloM7tC5itIujJtuUXo=; b=kO74H1eNH86ZqT5sUMbKSnZ8lb27b8kO33p9qqqqDG6xenkvkc1mURfzkSpEnS/Nm0 blJpMHRSihrC+HRoMvdzqZF2oILbzSGlBDxSp3eLTN7jCydIOESv5pRB4uqjPXBhMXHs 8wBGUtYQrSiXLbsBlh0HBJa7jcP+TMU1rSJG0W8iCNum5SKTIezSoqVWkDb8zH4IfMsH 6QzNs+RLN19xrvpY465PDV9KXCJQWCBGYDDkF7uJZogHhhlXrM/fY362Sl+qb2b/osZz uNGYrA5TcBnNxcr8ij12TOOw+ewOI2hS8L49TJNSsD+5mmF0T5q4jXywiyuiY/EtG5hv L0ig== X-Gm-Message-State: ABuFfoii99QNeGEsomwouKOC0CzWN+XEIGkRZA1eq1SjwR0bslEiT4Xj xlnQgfe8YYKzifSzPM5cJ4cRi+XJ X-Received: by 2002:adf:9bcf:: with SMTP id e15-v6mr3524178wrc.240.1538295277727; Sun, 30 Sep 2018 01:14:37 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.14.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:14:37 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:13:14 +0200 Message-Id: <1538295197-23704-77-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::443 Subject: [Qemu-devel] [PULL 76/79] hw/nvram/fw_cfg: Use memberwise copy of MemoryRegionOps struct 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell We've now removed the 'old_mmio' member from MemoryRegionOps, so we can perform the copy as a simple struct copy rather than having to do it via a memberwise copy. Signed-off-by: Peter Maydell Message-Id: <20180824170422.5783-3-peter.maydell@linaro.org> Based-on: <20180802174042.29234-1-peter.maydell@linaro.org> Reviewed-by: Richard Henderson Signed-off-by: Paolo Bonzini --- hw/nvram/fw_cfg.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) -- 1.8.3.1 diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 6de7809..946f765 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -1115,12 +1115,7 @@ static void fw_cfg_mem_realize(DeviceState *dev, Error **errp) sysbus_init_mmio(sbd, &s->ctl_iomem); if (s->data_width > data_ops->valid.max_access_size) { - /* memberwise copy because the "old_mmio" member is const */ - s->wide_data_ops.read = data_ops->read; - s->wide_data_ops.write = data_ops->write; - s->wide_data_ops.endianness = data_ops->endianness; - s->wide_data_ops.valid = data_ops->valid; - s->wide_data_ops.impl = data_ops->impl; + s->wide_data_ops = *data_ops; s->wide_data_ops.valid.max_access_size = s->data_width; s->wide_data_ops.impl.max_access_size = s->data_width; From patchwork Sun Sep 30 08:13:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 147860 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2676221lji; Sun, 30 Sep 2018 02:16:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV61JBVNb1iuOv4pFDAnDVBltHnPUYN7d4YHdRaYBulswEXk/hce4dnzBbC05ZO9zrzm92ZWG X-Received: by 2002:a37:29d8:: with SMTP id p85-v6mr4535112qkp.159.1538298981222; Sun, 30 Sep 2018 02:16:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538298981; cv=none; d=google.com; s=arc-20160816; b=g3Ur2R/JITR76Bxs3qAXDXSB0jD5z1glofJAEQlDH0d2jbNGyWaji8t09hNJtDMQ3U rY2eS4LDWjOI+94t95o8j2t32odqJ+ZjisHRr3wApiqqJb9JKeuTtIk7WSSgZuHOu91A HZ8dborXi34PkanCKY2W3cXfPI29BnAJc/7h8+DSHRhqvj3BJUyThRSjUa+r37aOzOti UUOf/8bQgWDN1M7cmfTc6ccgIT/nqAyAKjK1YTyxEo09wMvHUdW2qqy8KUoXFusivrXR olQEAZhXMXdnjSidNipuyt8qOgzHfwrMtHPxhXrBZmZp/KUErv2D12eogRyJnJsYlROH 6lYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=buC5LJviPdA/F7V106S1+r+e1QDM/Z2f38kkF/0eg8E=; b=N8+bZ55Il3V/fBaj+0fVf3wmeh2xn7eMXbe5mlmlXrKjPzSyFsFVdZrIMF2adWOdCi Ma97jVV4DxFlCO7v3kuE6evVaU/zlkV1EDWv+n2FXeeFSnsKO2Da41gbMa5Omhd7B/mP VGBQ0xqbmc53mNZ0y+/u8Nb6LJ6lF9yICkBKmiyD0ml+he+8YLtzzfFBZ2qEJSdUM460 U8/hJNZFF7LwRwjzD5C4DaaJfGZlDQ3388V1y3D0Pn9v05z/0erbntWkLKLRhnazhdj4 IrtV3mGq7MyrXdanEp8zHuOmT8MeYZPfKj75XgFKK3W1qHjnQrChwiPYftYezKwA2H81 Jb/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VEJSbWze; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s51-v6si3472760qtb.17.2018.09.30.02.16.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 30 Sep 2018 02:16:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VEJSbWze; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:54586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6Xps-00026G-PR for patch@linaro.org; Sun, 30 Sep 2018 05:16:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41931) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WsJ-0003CA-4V for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6WsF-0001JL-4E for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:46 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:46416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6WsC-0001GC-Pn for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:41 -0400 Received: by mail-wr1-x441.google.com with SMTP id z3-v6so10453267wrr.13 for ; Sun, 30 Sep 2018 01:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=buC5LJviPdA/F7V106S1+r+e1QDM/Z2f38kkF/0eg8E=; b=VEJSbWzeYhmd3M8FUavXWAM1AkRQ5wQrW85qeBw+SfQhHjEDFFn+lU1IuunJKeqztb op8dfGtNhHrEwpWl2K1ZkDtAwJN5Vugm1P+nS7C8qKQeQUYrQXMIJqQhAxHuVOmulx6h dgMajueeP83eHkvVNNhshgNfYw0cF9puhbsrxcas/dT3OnRP7rbc2AUZKtUPbr/SbY27 EM/eHx0pmrdykOBrNWpfzuKvifTjUGIO7lahG2hKdJsexO2WCP8tCQZMugRmJGwW7YE0 9jDSJ1/SG0eQkBrTdWlNDYhWCyZ4kypMlYpe87JCqLqdpbHuktQi+7OtQlm2NAN7nLVu Q/rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=buC5LJviPdA/F7V106S1+r+e1QDM/Z2f38kkF/0eg8E=; b=AtU/jVq98Ja7iJ1rWFH0sIAzBz2qTs113nwywUopokZydxFJRK6gKdduxCmOIYV9ZB /34oOYcL60Z2V39/ITSx2oer1lvi6HM+LKNndhBy4gzEyn+k5bu6H8PmicBkNnwWGmgF YVu+BcQ6ybJCah2Ri8+S7qEgm/i8M7YL9oIsBMppqD3HxriyGtjY/HOh8hrqa90/9MR6 KT2ivgE7uXug0pTxlYtmulsCuQSPMLvECOMDiFCjh52T+SHVCbkNbfSv6ozcWSo4CQRy AijVWEIvgQLlJFgvGnC3qtKjdgLqQKDUtvkrvY7Ucqjh1tZ6rpT3o5ZTbgYmO9jRPNnM H51A== X-Gm-Message-State: ABuFfohnzAK6QQBoFOGL2vXbiiMfS8jC3y6Dug4e7aa8pFASRdP9mVxY 8yic+OgaiZlYi/VHB5phOHfNriKN X-Received: by 2002:adf:e0c9:: with SMTP id e9-v6mr3841642wri.199.1538295278592; Sun, 30 Sep 2018 01:14:38 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.14.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:14:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:13:15 +0200 Message-Id: <1538295197-23704-78-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::441 Subject: [Qemu-devel] [PULL 77/79] docs/devel/memory.txt: Document _with_attrs accessors 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell When we added the _with_attrs accessors we forgot to mention them in the documentation. Signed-off-by: Peter Maydell Message-Id: <20180824170422.5783-4-peter.maydell@linaro.org> Based-on: <20180802174042.29234-1-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini --- docs/devel/memory.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) -- 1.8.3.1 diff --git a/docs/devel/memory.txt b/docs/devel/memory.txt index 4fff0d5..42577e1 100644 --- a/docs/devel/memory.txt +++ b/docs/devel/memory.txt @@ -326,8 +326,15 @@ visible as the pci-hole alias clips it to a 0.5GB range. MMIO Operations --------------- -MMIO regions are provided with ->read() and ->write() callbacks; in addition -various constraints can be supplied to control how these callbacks are called: +MMIO regions are provided with ->read() and ->write() callbacks, +which are sufficient for most devices. Some devices change behaviour +based on the attributes used for the memory transaction, or need +to be able to respond that the access should provoke a bus error +rather than completing successfully; those devices can use the +->read_with_attrs() and ->write_with_attrs() callbacks instead. + +In addition various constraints can be supplied to control how these +callbacks are called: - .valid.min_access_size, .valid.max_access_size define the access sizes (in bytes) which the device accepts; accesses outside this range will From patchwork Sun Sep 30 08:13:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 147859 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2668385lji; Sun, 30 Sep 2018 02:05:00 -0700 (PDT) X-Google-Smtp-Source: ACcGV60jdJU33DWI3bmkwmX3vO/6gGCJLyTaDPuSjdfT2CCIQ5ZkFyIeN6/UuGF75A/MIpbcSXq4 X-Received: by 2002:a37:29d8:: with SMTP id p85-v6mr4514948qkp.159.1538298300019; Sun, 30 Sep 2018 02:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538298300; cv=none; d=google.com; s=arc-20160816; b=FiyU6C+MK8KZx9V3vGKqu+JAiXlAMoHZiXSCfhUuTfK1tXySweTC5bObvrFcO1bXAb fbJeA/AYO/K9XoMldNgxJJRt5LZwaAfF+9EMiswQGhysITtiSNrsLnao6qGmI3qW2+pq SpbEk8RcGOkOI7ubDkG330P4NR6Hb/o97o7fmqpfiB9v1Ep0urKxs+YBeGhmBbePk8Z/ 64kz7eE3GCb9H2DX4Rg58OLZexdBkWsA0HXPnISuvpuOvmlvpkDR2TJh+elB8E5syQ58 4/epy05bb0UKh1cScmRMdYtmn4UxVAUxhFpvzlgb0DvUL8VQkR7elv5l9wud6Urpoe0Q d1EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=5hC7REoGT9ZHv4x/d6StiZypiS4LYaMNfKwS1CuqqzE=; b=hiYr4BLjhOYeLJUiAz/bHN8mlelyKb+Zm5cCcb2VWw//2A7ZQ+RvpV3Ett19VGqdpk i/oY5Plj4JFFRyFdZ/m/jejcr/LR1OUG1lJmm/LeSGING1hhQd8yVVW8IzvsNA2QuseI byoDRkGGwdYCFcoU9yUGf9FiHq+eaRxuwhk77WmDrhflLaSyelloWToyF26TZPZXHZTv Tuh30LPfCDZpFCS35ejYbgiQYs+Ess80kx3O7hndXNnr7oxNAQqHBdrggDoimTWJOjTN VcJcDO387AFExeOoUAcGRKAULbmnBwhbC3LfA9ijvkzQbHRm+c7AZUa0XIDBu99Zu1A0 N8mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UrXkIcJY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o14-v6si1691356qvl.177.2018.09.30.02.04.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 30 Sep 2018 02:05:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UrXkIcJY; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:54505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6Xet-0000wq-Gu for patch@linaro.org; Sun, 30 Sep 2018 05:04:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WsJ-0003C9-4I for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6WsF-0001Jc-92 for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:46 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:33810) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6WsC-0001Hb-Uh for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:41 -0400 Received: by mail-wm1-x32e.google.com with SMTP id z25-v6so827785wmf.1 for ; Sun, 30 Sep 2018 01:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5hC7REoGT9ZHv4x/d6StiZypiS4LYaMNfKwS1CuqqzE=; b=UrXkIcJYDoT2ZGD7D2GxJz91MdFDKY63ZqzVyyu6LMvvB74PZmQbeNVoCqmJblt6yz Rn5K6JefYHQxyLb6qEScXivTwPqALBnzKoF0+z8wrRp7eXHhUynVd5UnwcyqTAMEJNPP CEhB3Kriji59qHr0Ca0JiFAJjTWpnVIs/VIeJfGjHrqVskSelPkzumaYe+Zag0vS/zbc va6On8ldrxh4iEUTBvP8rTNEVo2Fe6y9N5V0ZHDXJriORmCG42JqyXB9kZg4oAOvITLk +0vp+xM2YpAtZZMQrw31D5cHOGDly0RQUvHFq5Mpr8rQWR8bxDBdUyP8WMeaFcGlMB2B 1mag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=5hC7REoGT9ZHv4x/d6StiZypiS4LYaMNfKwS1CuqqzE=; b=lVhjMRYtJC3T6PQHJaBCzeLPnFr2RlRT3DpPxNtkhLhUW89kLwSpA94evZo+Z2Z/tq YNJlTSW1HIkRgDbU8wZOS06u7Ws44jh3+oYtiNpdZ48BaeH0BXfO0NzpKitoccvxp+XT g1aZ9FIPdJP/w2a6ZcHVvatJgXm96WSXFZpPBw9b8u+Ae8OuwTOGtrzzyH+2JzQupeBF mSytzXcILuIBHg4n/2n5lFZVJxArot+0cEhslqqycZ9liym7Gq4qTPgKqaeu7joVQKCX VnZGMxWjt6aqtzrkBvMe63Reqn+uc5jaUo9g3ijtowTO/GvvQtk+phbV3ux2g8cw/axK +lDg== X-Gm-Message-State: ABuFfog00LHG0hU6v+dqO14CkO9/Al0IM/DErpC4YDyNRMRa7xzHiNXW qlWBqBawXDdWFnlkAUZOPowVDiw1 X-Received: by 2002:a1c:6a08:: with SMTP id f8-v6mr6079860wmc.49.1538295279436; Sun, 30 Sep 2018 01:14:39 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.14.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:14:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:13:16 +0200 Message-Id: <1538295197-23704-79-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32e Subject: [Qemu-devel] [PULL 78/79] cpus: fix TCG kick timer leak 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée This is an alternative fix to Marc-André's original patch. Reported-by: Marc-André Lureau Suggested-by: Paolo Bonzini Signed-off-by: Alex Bennée Message-Id: <20180927171724.30128-1-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini --- cpus.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 1.8.3.1 diff --git a/cpus.c b/cpus.c index 68f08f5..361678e 100644 --- a/cpus.c +++ b/cpus.c @@ -983,6 +983,8 @@ static void start_tcg_kick_timer(void) if (!tcg_kick_vcpu_timer && CPU_NEXT(first_cpu)) { tcg_kick_vcpu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, kick_tcg_thread, NULL); + } + if (tcg_kick_vcpu_timer && !timer_pending(tcg_kick_vcpu_timer)) { timer_mod(tcg_kick_vcpu_timer, qemu_tcg_next_kick()); } } @@ -990,9 +992,8 @@ static void start_tcg_kick_timer(void) static void stop_tcg_kick_timer(void) { assert(!mttcg_enabled); - if (tcg_kick_vcpu_timer) { + if (tcg_kick_vcpu_timer && timer_pending(tcg_kick_vcpu_timer)) { timer_del(tcg_kick_vcpu_timer); - tcg_kick_vcpu_timer = NULL; } } From patchwork Sun Sep 30 08:13:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 147861 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2677557lji; Sun, 30 Sep 2018 02:18:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63lj6jeNd2pJKUT5zC2DesjWNuXHexXLFqU9UfYV1d84357bsNbI4Cn+NURxf7FtdUayCjN X-Received: by 2002:ad4:4089:: with SMTP id l9-v6mr4692802qvp.160.1538299094062; Sun, 30 Sep 2018 02:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538299094; cv=none; d=google.com; s=arc-20160816; b=bM+FBDlc3hE0VV0smAQyyTDgrH5svFADsVHmxhkqMzReVe40RmLdXivhcK7b3SGMwD CDUWw/OmoSwd7Fs2/i29uTA4a4S73jILV1zw20IL4o2uRMVcvTwVgkFXRNapBRbbyVeF NYUoBIbU1CVIo0c2jmq8jKAvWgs2+S6q6HTJZIi5S/t5rJfP3WEd4E422AOjNOG5p+Pm zmpVRjCSJ/qUy8wE9ERut98oRpjssVy6f7sqMiDM4C6lHqH46xikSD09yNUpqthD6Yw2 t4Jx+nXTvzov1ZA5uPf3VXSACr/tb6JdBjB4k241nCG8RCT0XkyG3XXeaD9uyHQmDTPG 3Tug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=TJ2p0/DjWbH6zUkB3teGgITTkc3xHQ0DS9FGJkroi8U=; b=GWIxFocpUEqm9lDT7rbWoVpzxpQyJAjABkm51etxJQ5OTVblNv4ASCI2W1V5Cw5QGI nbamVsik8HvKxmniu2FESwFxdDfNp/PcZxM2FVzWExprI8eKCGMcGzOvthv5KSbX5uCK lPR/xnBOQkEB03SDmtor1TSQySU4IkUJ/TGIQiiizE1SlvI7uCxlvK8QKasHT8M4bSAk Yugsoe461J6h8E28Qk7WjaKaf0LHbz6SaqY3ghmS2iwtIHLvd9zOzmd7IUwm10ExxBPx t2/L+I4y2p29bZf8cExMjJrf1hGoJ03LS58QyaYIbXz/pU5EcHUKbcDI7Z57Qa4juuSV f3cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CpiuLSpe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l67-v6si2223103qkb.61.2018.09.30.02.18.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 30 Sep 2018 02:18:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=CpiuLSpe; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:54593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6Xrh-0003ox-Ix for patch@linaro.org; Sun, 30 Sep 2018 05:18:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WsQ-0003KJ-BT for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6WsM-0001NS-SM for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:54 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]:46949) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6WsI-0001IX-Tr for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:14:48 -0400 Received: by mail-wr1-x42d.google.com with SMTP id z3-v6so10453314wrr.13 for ; Sun, 30 Sep 2018 01:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=TJ2p0/DjWbH6zUkB3teGgITTkc3xHQ0DS9FGJkroi8U=; b=CpiuLSpe1LGHOCeIrmSpGAfQgJRoL4quOOLSgKjBM37jhrMZNrYjT+MmC8kZHbPAhT q9Wj1iKZSd5gIoHZ1xECAOShLUc9QDK/7oxzJQCpHbevFM+5w9NR323z7DvwfJTVWsmt wOqIcOuInwfkrplanRm2lVdY0Q0SnW6lvBhQMdP2CSUkq2l8ha5owyLj6q3s8DqgCcdu fjlAi1488R+9APlIw2oB+1SaUTXpbDpwvLZOWvtmEb4PTMpBCCe3em9B0VNeX4P1fRWb c9lOM1m6o8gnhPImXp2AqFcvHv3QQuaQB03davftqwSp0G9abPBGs/M0qQPKURTF7frA yzpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=TJ2p0/DjWbH6zUkB3teGgITTkc3xHQ0DS9FGJkroi8U=; b=ho8irD7Sl0SBJSwI7Rn8ra/Y09b/2WSlp3sIhgTHEUab7eXD7ZOFy/01Xmt4TViYVg xR3ZZx1WWHVq0bJQnvEJJEbjaPdE1zczZBpEm7wMhpXMi1SyPpyt7atlRUgYCAO0DVO9 wgjdONRcHYs2mu9cIf65aH9noC9OPbRgTMzWeu9TjeZI7wqXNTzjl8BTw6cU2f/8bRqI OYwmKIl3CmjNgxjSX/IURkKC04Lo4Dr38AG2wp1tBb6nevDcBZL2pemBn1PRgU/mhOWT FXXDRZblbXSzHLj6YhgwnnC2I6e0hpYNxLtjGQ3tK49gdY1Lwa2MV/SyG3Hy/GxCvbgu gFWQ== X-Gm-Message-State: ABuFfoiIApypNb9DbBmHVqj4sYwAACwdpS6UanZLIVS/ki9VonDo8fCW lPQSglBd0JvDf2SPOi3RZH1kk6OQ X-Received: by 2002:adf:fa92:: with SMTP id h18-v6mr125475wrr.74.1538295280577; Sun, 30 Sep 2018 01:14:40 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.14.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:14:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:13:17 +0200 Message-Id: <1538295197-23704-80-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42d Subject: [Qemu-devel] [PULL 79/79] hw/scsi/mptendian: Avoid taking address of fields in packed structs 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Taking the address of a field in a packed struct is a bad idea, because it might not be actually aligned enough for that pointer type (and thus cause a crash on dereference on some host architectures). Newer versions of clang warn about this. Avoid the bug by not using the "modify in place" byte swapping functions. This patch was produced with the following simple spatch script: @@ expression E; @@ -le16_to_cpus(&E); +E = le16_to_cpu(E); @@ expression E; @@ -le32_to_cpus(&E); +E = le32_to_cpu(E); @@ expression E; @@ -le64_to_cpus(&E); +E = le64_to_cpu(E); @@ expression E; @@ -cpu_to_le16s(&E); +E = cpu_to_le16(E); @@ expression E; @@ -cpu_to_le32s(&E); +E = cpu_to_le32(E); @@ expression E; @@ -cpu_to_le64s(&E); +E = cpu_to_le64(E); followed by some minor tidying of overlong lines and bad indent. Signed-off-by: Peter Maydell Message-Id: <20180927134852.21490-1-peter.maydell@linaro.org> Reviewed-by: Fam Zheng Signed-off-by: Paolo Bonzini --- hw/scsi/mptendian.c | 163 ++++++++++++++++++++++++++-------------------------- 1 file changed, 83 insertions(+), 80 deletions(-) -- 1.8.3.1 diff --git a/hw/scsi/mptendian.c b/hw/scsi/mptendian.c index 8ae39a7..79f9973 100644 --- a/hw/scsi/mptendian.c +++ b/hw/scsi/mptendian.c @@ -35,152 +35,155 @@ static void mptsas_fix_sgentry_endianness(MPISGEntry *sge) { - le32_to_cpus(&sge->FlagsLength); + sge->FlagsLength = le32_to_cpu(sge->FlagsLength); if (sge->FlagsLength & MPI_SGE_FLAGS_64_BIT_ADDRESSING) { - le64_to_cpus(&sge->u.Address64); + sge->u.Address64 = le64_to_cpu(sge->u.Address64); } else { - le32_to_cpus(&sge->u.Address32); + sge->u.Address32 = le32_to_cpu(sge->u.Address32); } } static void mptsas_fix_sgentry_endianness_reply(MPISGEntry *sge) { if (sge->FlagsLength & MPI_SGE_FLAGS_64_BIT_ADDRESSING) { - cpu_to_le64s(&sge->u.Address64); + sge->u.Address64 = cpu_to_le64(sge->u.Address64); } else { - cpu_to_le32s(&sge->u.Address32); + sge->u.Address32 = cpu_to_le32(sge->u.Address32); } - cpu_to_le32s(&sge->FlagsLength); + sge->FlagsLength = cpu_to_le32(sge->FlagsLength); } void mptsas_fix_scsi_io_endianness(MPIMsgSCSIIORequest *req) { - le32_to_cpus(&req->MsgContext); - le32_to_cpus(&req->Control); - le32_to_cpus(&req->DataLength); - le32_to_cpus(&req->SenseBufferLowAddr); + req->MsgContext = le32_to_cpu(req->MsgContext); + req->Control = le32_to_cpu(req->Control); + req->DataLength = le32_to_cpu(req->DataLength); + req->SenseBufferLowAddr = le32_to_cpu(req->SenseBufferLowAddr); } void mptsas_fix_scsi_io_reply_endianness(MPIMsgSCSIIOReply *reply) { - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); - cpu_to_le32s(&reply->TransferCount); - cpu_to_le32s(&reply->SenseCount); - cpu_to_le32s(&reply->ResponseInfo); - cpu_to_le16s(&reply->TaskTag); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); + reply->TransferCount = cpu_to_le32(reply->TransferCount); + reply->SenseCount = cpu_to_le32(reply->SenseCount); + reply->ResponseInfo = cpu_to_le32(reply->ResponseInfo); + reply->TaskTag = cpu_to_le16(reply->TaskTag); } void mptsas_fix_scsi_task_mgmt_endianness(MPIMsgSCSITaskMgmt *req) { - le32_to_cpus(&req->MsgContext); - le32_to_cpus(&req->TaskMsgContext); + req->MsgContext = le32_to_cpu(req->MsgContext); + req->TaskMsgContext = le32_to_cpu(req->TaskMsgContext); } void mptsas_fix_scsi_task_mgmt_reply_endianness(MPIMsgSCSITaskMgmtReply *reply) { - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); - cpu_to_le32s(&reply->TerminationCount); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); + reply->TerminationCount = cpu_to_le32(reply->TerminationCount); } void mptsas_fix_ioc_init_endianness(MPIMsgIOCInit *req) { - le32_to_cpus(&req->MsgContext); - le16_to_cpus(&req->ReplyFrameSize); - le32_to_cpus(&req->HostMfaHighAddr); - le32_to_cpus(&req->SenseBufferHighAddr); - le32_to_cpus(&req->ReplyFifoHostSignalingAddr); + req->MsgContext = le32_to_cpu(req->MsgContext); + req->ReplyFrameSize = le16_to_cpu(req->ReplyFrameSize); + req->HostMfaHighAddr = le32_to_cpu(req->HostMfaHighAddr); + req->SenseBufferHighAddr = le32_to_cpu(req->SenseBufferHighAddr); + req->ReplyFifoHostSignalingAddr = + le32_to_cpu(req->ReplyFifoHostSignalingAddr); mptsas_fix_sgentry_endianness(&req->HostPageBufferSGE); - le16_to_cpus(&req->MsgVersion); - le16_to_cpus(&req->HeaderVersion); + req->MsgVersion = le16_to_cpu(req->MsgVersion); + req->HeaderVersion = le16_to_cpu(req->HeaderVersion); } void mptsas_fix_ioc_init_reply_endianness(MPIMsgIOCInitReply *reply) { - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); } void mptsas_fix_ioc_facts_endianness(MPIMsgIOCFacts *req) { - le32_to_cpus(&req->MsgContext); + req->MsgContext = le32_to_cpu(req->MsgContext); } void mptsas_fix_ioc_facts_reply_endianness(MPIMsgIOCFactsReply *reply) { - cpu_to_le16s(&reply->MsgVersion); - cpu_to_le16s(&reply->HeaderVersion); - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCExceptions); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); - cpu_to_le16s(&reply->ReplyQueueDepth); - cpu_to_le16s(&reply->RequestFrameSize); - cpu_to_le16s(&reply->ProductID); - cpu_to_le32s(&reply->CurrentHostMfaHighAddr); - cpu_to_le16s(&reply->GlobalCredits); - cpu_to_le32s(&reply->CurrentSenseBufferHighAddr); - cpu_to_le16s(&reply->CurReplyFrameSize); - cpu_to_le32s(&reply->FWImageSize); - cpu_to_le32s(&reply->IOCCapabilities); - cpu_to_le16s(&reply->HighPriorityQueueDepth); + reply->MsgVersion = cpu_to_le16(reply->MsgVersion); + reply->HeaderVersion = cpu_to_le16(reply->HeaderVersion); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCExceptions = cpu_to_le16(reply->IOCExceptions); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); + reply->ReplyQueueDepth = cpu_to_le16(reply->ReplyQueueDepth); + reply->RequestFrameSize = cpu_to_le16(reply->RequestFrameSize); + reply->ProductID = cpu_to_le16(reply->ProductID); + reply->CurrentHostMfaHighAddr = cpu_to_le32(reply->CurrentHostMfaHighAddr); + reply->GlobalCredits = cpu_to_le16(reply->GlobalCredits); + reply->CurrentSenseBufferHighAddr = + cpu_to_le32(reply->CurrentSenseBufferHighAddr); + reply->CurReplyFrameSize = cpu_to_le16(reply->CurReplyFrameSize); + reply->FWImageSize = cpu_to_le32(reply->FWImageSize); + reply->IOCCapabilities = cpu_to_le32(reply->IOCCapabilities); + reply->HighPriorityQueueDepth = cpu_to_le16(reply->HighPriorityQueueDepth); mptsas_fix_sgentry_endianness_reply(&reply->HostPageBufferSGE); - cpu_to_le32s(&reply->ReplyFifoHostSignalingAddr); + reply->ReplyFifoHostSignalingAddr = + cpu_to_le32(reply->ReplyFifoHostSignalingAddr); } void mptsas_fix_config_endianness(MPIMsgConfig *req) { - le16_to_cpus(&req->ExtPageLength); - le32_to_cpus(&req->MsgContext); - le32_to_cpus(&req->PageAddress); + req->ExtPageLength = le16_to_cpu(req->ExtPageLength); + req->MsgContext = le32_to_cpu(req->MsgContext); + req->PageAddress = le32_to_cpu(req->PageAddress); mptsas_fix_sgentry_endianness(&req->PageBufferSGE); } void mptsas_fix_config_reply_endianness(MPIMsgConfigReply *reply) { - cpu_to_le16s(&reply->ExtPageLength); - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); + reply->ExtPageLength = cpu_to_le16(reply->ExtPageLength); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); } void mptsas_fix_port_facts_endianness(MPIMsgPortFacts *req) { - le32_to_cpus(&req->MsgContext); + req->MsgContext = le32_to_cpu(req->MsgContext); } void mptsas_fix_port_facts_reply_endianness(MPIMsgPortFactsReply *reply) { - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); - cpu_to_le16s(&reply->MaxDevices); - cpu_to_le16s(&reply->PortSCSIID); - cpu_to_le16s(&reply->ProtocolFlags); - cpu_to_le16s(&reply->MaxPostedCmdBuffers); - cpu_to_le16s(&reply->MaxPersistentIDs); - cpu_to_le16s(&reply->MaxLanBuckets); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); + reply->MaxDevices = cpu_to_le16(reply->MaxDevices); + reply->PortSCSIID = cpu_to_le16(reply->PortSCSIID); + reply->ProtocolFlags = cpu_to_le16(reply->ProtocolFlags); + reply->MaxPostedCmdBuffers = cpu_to_le16(reply->MaxPostedCmdBuffers); + reply->MaxPersistentIDs = cpu_to_le16(reply->MaxPersistentIDs); + reply->MaxLanBuckets = cpu_to_le16(reply->MaxLanBuckets); } void mptsas_fix_port_enable_endianness(MPIMsgPortEnable *req) { - le32_to_cpus(&req->MsgContext); + req->MsgContext = le32_to_cpu(req->MsgContext); } void mptsas_fix_port_enable_reply_endianness(MPIMsgPortEnableReply *reply) { - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); } void mptsas_fix_event_notification_endianness(MPIMsgEventNotify *req) { - le32_to_cpus(&req->MsgContext); + req->MsgContext = le32_to_cpu(req->MsgContext); } void mptsas_fix_event_notification_reply_endianness(MPIMsgEventNotifyReply *reply) @@ -188,16 +191,16 @@ void mptsas_fix_event_notification_reply_endianness(MPIMsgEventNotifyReply *repl int length = reply->EventDataLength; int i; - cpu_to_le16s(&reply->EventDataLength); - cpu_to_le32s(&reply->MsgContext); - cpu_to_le16s(&reply->IOCStatus); - cpu_to_le32s(&reply->IOCLogInfo); - cpu_to_le32s(&reply->Event); - cpu_to_le32s(&reply->EventContext); + reply->EventDataLength = cpu_to_le16(reply->EventDataLength); + reply->MsgContext = cpu_to_le32(reply->MsgContext); + reply->IOCStatus = cpu_to_le16(reply->IOCStatus); + reply->IOCLogInfo = cpu_to_le32(reply->IOCLogInfo); + reply->Event = cpu_to_le32(reply->Event); + reply->EventContext = cpu_to_le32(reply->EventContext); /* Really depends on the event kind. This will do for now. */ for (i = 0; i < length; i++) { - cpu_to_le32s(&reply->Data[i]); + reply->Data[i] = cpu_to_le32(reply->Data[i]); } }