From nobody Sun May 5 18:05:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520239119483850.3742432240737; Mon, 5 Mar 2018 00:38:39 -0800 (PST) Received: from localhost ([::1]:47813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esldm-0005GW-Gm for importer@patchew.org; Mon, 05 Mar 2018 03:38:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35077) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslcC-0004LK-Dw for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eslcA-0004N6-Ey for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:00 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:40586) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eslcA-0004Mf-7x; Mon, 05 Mar 2018 03:36:58 -0500 Received: by mail-wr0-x241.google.com with SMTP id o76so16280144wrb.7; Mon, 05 Mar 2018 00:36:58 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id y23sm13206739wra.9.2018.03.05.00.36.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 00:36:56 -0800 (PST) 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=RhclJi7/t4KTVM8o9+C5BDkL4/aXTSeub6+kKz2AD/0=; b=aYIOANV7X9lh7jtZrJb3iAKVHNJRQ64aTDKSy2ylKQp2nh4d++LyiPeuy0qk5K9h6B c9g/Ni5CkMNzInEQCzZXs2W1OhA3rz93FBXIFnoiP1dODXDXjWzw6DIw1oDG0UR4bEMx HnQXCRQN1pJnonpSN2vBdrz7eunQ/z7X+oWohtwNbzjkKbug4qdo30B5XzsO/R4D8gAi zVl2sN6FNSceUK64RY+EIPcNgjK0vpc3Cb3IyzsyMnuDDSJ7a7SVoyyP/NICaMF9BWAG jDpcRU41dsnbbrDI3O3PlxoBu1xdic+kx5EvDSTaFClfn5We9VKGUdEvecU1laVsw7E8 LPKg== 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=RhclJi7/t4KTVM8o9+C5BDkL4/aXTSeub6+kKz2AD/0=; b=QshNFAt9ncpVWOnfEVEB63/F+0Ew5wbHcbioWDKnTXdz3AM3qv1pNh/mdhI11t/YjJ 3EVCh2sdZQM5qL34O2WH/gNkRhsF9Wap4nFpxbByVIud1nHGZBRKOn3Jimda2C+lcZ0G ODnWZCGZCdlKrefehYoLh8bJ9uDkPDvpHxT7D7Z7T+oBYURCe2xM6/TbuMd9P2AGE7NQ 0/vhEA8aY+bek7VbxcPLeIuk9XWhULAsKEGDWXXjYsPeBge4LuHFt+FI8hfT7l/imbyl 51t31CuUFfp4CfA3+pMjiS9v1MCAxYRwC4VOVblzZRVetZejaySewiMuQb9fN+pPsRai 2FjA== X-Gm-Message-State: APf1xPDlx/xXsQ3DHfWHwHiOn0B29WaGPeVmKHEBkR40aIiKu8xTbhrM T5NfWiazs08NS8gurCbh7k5VdBYT X-Google-Smtp-Source: AG47ELtn1aqhQJ2cz9eBqUL8UlMQtNkoYP16RY3oeYHAQzesgg20Gt2iMv5DWx7TD6iZKFkamqlWpw== X-Received: by 10.223.209.11 with SMTP id a11mr11999763wri.122.1520239016815; Mon, 05 Mar 2018 00:36:56 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Mar 2018 09:36:49 +0100 Message-Id: <20180305083655.6186-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com> References: <20180305083655.6186-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH 1/7] openpic_kvm: drop address_space_to_flatview call 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: Alexey Kardashevskiy , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The MemoryListener is registered on address_space_memory, there is not much to assert. This currently works because the callback is invoked only once when the listener is registered, but section->fv is the _new_ FlatView, not the old one on later calls and that would break. This confines address_space_to_flatview to exec.c and memory.c. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Acked-by: David Gibson Reviewed-by: Alexey Kardashevskiy --- hw/intc/openpic_kvm.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c index fa83420254..39a6f369c5 100644 --- a/hw/intc/openpic_kvm.c +++ b/hw/intc/openpic_kvm.c @@ -124,10 +124,6 @@ static void kvm_openpic_region_add(MemoryListener *lis= tener, uint64_t reg_base; int ret; =20 - if (section->fv !=3D address_space_to_flatview(&address_space_memory))= { - abort(); - } - /* Ignore events on regions that are not us */ if (section->mr !=3D &opp->mem) { return; --=20 2.14.3 From nobody Sun May 5 18:05:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520239259542510.9149130434565; Mon, 5 Mar 2018 00:40:59 -0800 (PST) Received: from localhost ([::1]:47832 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslfu-0007Zg-Cp for importer@patchew.org; Mon, 05 Mar 2018 03:40:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslcC-0004LL-M8 for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eslcB-0004O8-Kt for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:00 -0500 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]:34274) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eslcB-0004NF-DN; Mon, 05 Mar 2018 03:36:59 -0500 Received: by mail-wr0-x244.google.com with SMTP id o8so4775544wra.1; Mon, 05 Mar 2018 00:36:59 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id y23sm13206739wra.9.2018.03.05.00.36.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 00:36:57 -0800 (PST) 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=ISttXQbQlAcdnVrjRiRoNVQzLiZf1+zqEphedqD+Y44=; b=teTEilNpKX/zYcxq588WeWG2zF6pkhehBBi2QbSvTdVhizhOCuCBweWtHIk6VGXq6p /VpofnKh5WQx43ySAlUtZRzKgYaGHTadmkApUvq8yNAcVM5qTse/W//2y4md6HaINnfM Exz1taXK3WzHRbWuaO8vcNXf3TpcE7rauU8GnPuTMJQAG8XJsQESWZASgr8uvrEuNjEO 5k9ATDDKXActCBVE53jYZZluv78ZFBYMFoLcl4dP8apSVe4u4/P6QCRRnBrfMJsDHSjr l+uSa2Fr6YQPUBF/zCnZdRarOmm5Gq6GjbWu4FE8T1Urd4Z6dJf4ePUL/ZAkwKMkHVC/ AKkQ== 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=ISttXQbQlAcdnVrjRiRoNVQzLiZf1+zqEphedqD+Y44=; b=bTwAvFKHyRE6euDFmrZdp1pR8UxRSW7nJGIt6g1Ht+Eg4i8kvHmpYr9C8ZUz/qsRUa Y29FK+M8W+BAeJN/zbEoiFCKEDQGRoRYHhq0XcLpLwRS/QDSSTa/qYvaeiXvskqpnhsk SUGkCelEYIhEvab+0TP4S7+NpijOyuSnXDse+n5qAepAjr0iOLSm3tXdYWd4pBz+GYVN kQINN3PcnSaU/bjOxe/XEMJFee4zHDZafwixHYbb+uoePzGNlLwwxlfSYl4tMOeDykU1 AO4sAWQ0oTth/psQ6N+pMeGVfrt4fwDJwubPPwTv0A20Qs2APnIAjGch07QRRY5ujoQq EUzw== X-Gm-Message-State: APf1xPC3NdQSdoeKswIianVGyFr2fDBDpYyWmx0ui2QHGsoD9vzGksTz xajPelLI7QJDOEb/N8jPjKA4fgXt X-Google-Smtp-Source: AG47ELumnKHdhSfjd6wnO9V6imMME6MhjWYNDcKkADzmmCxT3T9SQFzl+bfRZw88Xe8D4sz49MzrVg== X-Received: by 10.223.185.53 with SMTP id k50mr11523381wrf.78.1520239018073; Mon, 05 Mar 2018 00:36:58 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Mar 2018 09:36:50 +0100 Message-Id: <20180305083655.6186-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com> References: <20180305083655.6186-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::244 Subject: [Qemu-devel] [PATCH 2/7] memory: inline some performance-sensitive 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: Alexey Kardashevskiy , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These accessors are called from inlined functions, and the call sequence is much more expensive than just inlining the access. Move the struct declaration to memory-internal.h so that exec.c and memory.c can both use an inline function. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Reviewed-by: Alexey Kardashevskiy --- include/exec/memory-internal.h | 13 +++++++++---- include/exec/memory.h | 22 +++++++++++++++++++++- memory.c | 30 ------------------------------ 3 files changed, 30 insertions(+), 35 deletions(-) diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index 4162474fd5..6a5ee42d36 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -21,7 +21,15 @@ #define MEMORY_INTERNAL_H =20 #ifndef CONFIG_USER_ONLY -typedef struct AddressSpaceDispatch AddressSpaceDispatch; +static inline AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) +{ + return fv->dispatch; +} + +static inline AddressSpaceDispatch *address_space_to_dispatch(AddressSpace= *as) +{ + return flatview_to_dispatch(address_space_to_flatview(as)); +} =20 extern const MemoryRegionOps unassigned_mem_ops; =20 @@ -31,9 +39,6 @@ bool memory_region_access_valid(MemoryRegion *mr, hwaddr = addr, void flatview_add_to_dispatch(FlatView *fv, MemoryRegionSection *section); AddressSpaceDispatch *address_space_dispatch_new(FlatView *fv); void address_space_dispatch_compact(AddressSpaceDispatch *d); - -AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as); -AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv); void address_space_dispatch_free(AddressSpaceDispatch *d); =20 void mtree_print_dispatch(fprintf_function mon, void *f, diff --git a/include/exec/memory.h b/include/exec/memory.h index fff9b1d871..6c8e394675 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -326,7 +326,27 @@ struct AddressSpace { QTAILQ_ENTRY(AddressSpace) address_spaces_link; }; =20 -FlatView *address_space_to_flatview(AddressSpace *as); +typedef struct AddressSpaceDispatch AddressSpaceDispatch; +typedef struct FlatRange FlatRange; + +/* Flattened global view of current active memory hierarchy. Kept in sort= ed + * order. + */ +struct FlatView { + struct rcu_head rcu; + unsigned ref; + FlatRange *ranges; + unsigned nr; + unsigned nr_allocated; + struct AddressSpaceDispatch *dispatch; + MemoryRegion *root; +}; + +static inline FlatView *address_space_to_flatview(AddressSpace *as) +{ + return atomic_rcu_read(&as->current_map); +} + =20 /** * MemoryRegionSection: describes a fragment of a #MemoryRegion diff --git a/memory.c b/memory.c index c7f6588452..78d07aa51d 100644 --- a/memory.c +++ b/memory.c @@ -210,8 +210,6 @@ static bool memory_region_ioeventfd_equal(MemoryRegionI= oeventfd a, && !memory_region_ioeventfd_before(b, a); } =20 -typedef struct FlatRange FlatRange; - /* Range of memory in the global map. Addresses are absolute. */ struct FlatRange { MemoryRegion *mr; @@ -222,19 +220,6 @@ struct FlatRange { bool readonly; }; =20 -/* Flattened global view of current active memory hierarchy. Kept in sort= ed - * order. - */ -struct FlatView { - struct rcu_head rcu; - unsigned ref; - FlatRange *ranges; - unsigned nr; - unsigned nr_allocated; - struct AddressSpaceDispatch *dispatch; - MemoryRegion *root; -}; - typedef struct AddressSpaceOps AddressSpaceOps; =20 #define FOR_EACH_FLAT_RANGE(var, view) \ @@ -322,21 +307,6 @@ static void flatview_unref(FlatView *view) } } =20 -FlatView *address_space_to_flatview(AddressSpace *as) -{ - return atomic_rcu_read(&as->current_map); -} - -AddressSpaceDispatch *flatview_to_dispatch(FlatView *fv) -{ - return fv->dispatch; -} - -AddressSpaceDispatch *address_space_to_dispatch(AddressSpace *as) -{ - return flatview_to_dispatch(address_space_to_flatview(as)); -} - static bool can_merge(FlatRange *r1, FlatRange *r2) { return int128_eq(addrrange_end(r1->addr), r2->addr.start) --=20 2.14.3 From nobody Sun May 5 18:05:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520239349302179.53838430225005; Mon, 5 Mar 2018 00:42:29 -0800 (PST) Received: from localhost ([::1]:47842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslhU-0000OS-Ja for importer@patchew.org; Mon, 05 Mar 2018 03:42:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslcD-0004Ld-Rc for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eslcC-0004PJ-Vb for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:01 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:42955) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eslcC-0004OP-Or; Mon, 05 Mar 2018 03:37:00 -0500 Received: by mail-wr0-x242.google.com with SMTP id k9so16250484wre.9; Mon, 05 Mar 2018 00:37:00 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id y23sm13206739wra.9.2018.03.05.00.36.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 00:36:58 -0800 (PST) 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=BLEr+kfoHVoZFjt/6KbncBfLMl00pPPN9dHIx7HqKk0=; b=aSokHvihAICxKTARwHXDlSVMahQ6SMDfnocbpzbhh2pLpJ38IReQXP3bCxfOx5ktk8 WIVf+8kJsE/hsO2CVZ2GE5zddJpG+cw+1SkjTZfbMB7vJC+RluSBzFPuLEpCV2iGXGzB wNbrYaW1aJAGXMC5qLOQPybTdQzuR3qj32ySxur1ULFJMln8+ohMWY+gUDdsBB7SX2YP pXVfO+Du+2ePbHPZ8h10jUIUEwCtHdjrf/7c/qqQEawI1ao2k0CfoulwYXvBu1MpFJ3O UGvEC78fbeJLM9P0XCCR3DEiVv+NGeo/4ny13lhqL51XNH8idfdwEmzVE9HxcsDDnK83 6c/w== 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=BLEr+kfoHVoZFjt/6KbncBfLMl00pPPN9dHIx7HqKk0=; b=YZPEDkFuiVJQLytfFCvnKdKqJp6xM3+1DxpQPReBacT+rDDeBLVFeH5H7zyrpYUZLf i/FOkUUKh2KEIpwNm00SiOe7tB5if8/0FhLxXaPTWzja4uTFhzxnDXyo/ehHFtO4t8iN UAxDwwxsgZQG9WRy/XiI9td1gDrzYfE8nv8OzI1F9GfQsuzgWXq4UB6XTSrIarE7ndej vnAVruUQEhw3e3XHkhAyHZxd6JqNtK91cE15k9qAUt6VLNbw0OgM7cOhgRqDkn3Q5KPN fEIz0g7iiFaA0qUUjzlq348Rfjw59gfX0RmUFfHFoMuSZN04mXVqR8dBtPD8OFjAg5Sz wQVw== X-Gm-Message-State: APf1xPDLvZVP5ewiyy1i3pkfN/3C4wokbszm2/LtdDGrY/xXWa/jL4c/ ZUTMSg/lhMcH7QitoM8VdnfweFLX X-Google-Smtp-Source: AG47ELuYRob+uOmGdsRlsBIpvlXcWXCxqqueawhHFtLv/O4vkix42DemR5HUQIPUuPEAcB7KLTborA== X-Received: by 10.223.181.152 with SMTP id c24mr12785277wre.233.1520239019323; Mon, 05 Mar 2018 00:36:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Mar 2018 09:36:51 +0100 Message-Id: <20180305083655.6186-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com> References: <20180305083655.6186-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH 3/7] address_space_write: address_space_to_flatview needs RCU lock 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: Alexey Kardashevskiy , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" address_space_write is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_write to address_space_write. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Reviewed-by: Alexey Kardashevskiy --- exec.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/exec.c b/exec.c index e8d7b335b6..0b74b58d45 100644 --- a/exec.c +++ b/exec.c @@ -3074,6 +3074,7 @@ static MemTxResult flatview_write_continue(FlatView *= fv, hwaddr addr, return result; } =20 +/* Called from RCU critical section. */ static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs at= trs, const uint8_t *buf, int len) { @@ -3082,25 +3083,14 @@ static MemTxResult flatview_write(FlatView *fv, hwa= ddr addr, MemTxAttrs attrs, MemoryRegion *mr; MemTxResult result =3D MEMTX_OK; =20 - if (len > 0) { - rcu_read_lock(); - l =3D len; - mr =3D flatview_translate(fv, addr, &addr1, &l, true); - result =3D flatview_write_continue(fv, addr, attrs, buf, len, - addr1, l, mr); - rcu_read_unlock(); - } + l =3D len; + mr =3D flatview_translate(fv, addr, &addr1, &l, true); + result =3D flatview_write_continue(fv, addr, attrs, buf, len, + addr1, l, mr); =20 return result; } =20 -MemTxResult address_space_write(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, - const uint8_t *buf, int len) -{ - return flatview_write(address_space_to_flatview(as), addr, attrs, buf,= len); -} - /* Called within RCU critical section. */ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, @@ -3209,6 +3199,23 @@ MemTxResult address_space_rw(AddressSpace *as, hwadd= r addr, addr, attrs, buf, len, is_write); } =20 +MemTxResult address_space_write(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, + const uint8_t *buf, int len) +{ + MemTxResult result =3D MEMTX_OK; + FlatView *fv; + + if (len > 0) { + rcu_read_lock(); + fv =3D address_space_to_flatview(as); + result =3D flatview_write(fv, addr, attrs, buf, len); + rcu_read_unlock(); + } + + return result; +} + void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write) { --=20 2.14.3 From nobody Sun May 5 18:05:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520239264665376.02364565190885; Mon, 5 Mar 2018 00:41:04 -0800 (PST) Received: from localhost ([::1]:47833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslfz-0007eI-E0 for importer@patchew.org; Mon, 05 Mar 2018 03:40:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslcF-0004N0-Qd for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eslcE-0004R8-DW for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:03 -0500 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:46339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eslcE-0004Pz-4H; Mon, 05 Mar 2018 03:37:02 -0500 Received: by mail-wr0-x241.google.com with SMTP id m12so16255060wrm.13; Mon, 05 Mar 2018 00:37:01 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id y23sm13206739wra.9.2018.03.05.00.36.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 00:37:00 -0800 (PST) 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=QDD/+sQSKr2e19czaoMFvf6+0WUNfZwGrf1Qbc5YR1g=; b=EX8je3hKV9xaaGj1F6k/hdMgvfJf+4HuvXQyw7AZTKedNK1RvKFNd8LJ95koEHSnBj I9PnC+dQZIqy3y2yJGnC2RtdOwViPyBXkJTWaQ1xjvvfqluG0I6EtoBWhhvezAK2eDIo o8YQqY4UvipeJQuLW70Rmn6X9gB19OarzSHpCy9kTMh3Hoqom7IFfuw9+PVsTwoDdpfB 30JYufqhN3j3/C2hjEXx3Srwq7DXmI3pMXqd0qeovxD9w3dNEI0ycDHqA2GRvBzwk4Oo 5XldazJAbsRBwKLTGpdE9ZPji82YdK/V4VyvU6bTJBinWDIQjAOnURDJysIf/GHMC/fi Hmhg== 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=QDD/+sQSKr2e19czaoMFvf6+0WUNfZwGrf1Qbc5YR1g=; b=kPBCYnhPyvDQwWqBKMRzzbSPfbTrIZwYcCUML/XKKMtIfDKq9vcEkeOVrVP6l4ceGS ItRJXNUwtLhlr3WWAEl2C8WWgLmWRQ8hJ370Z2PjlZ9Hz0ozkVoaHWaLLv74K5JaVP8G ZJIcRTeb9Cr6luEUaqLKfSKuZ13ZGy9sEvvWsioALpa5d7GBLWp6XmaVoK6ROG1GyTAz XT0+NqahbGj6aq4xubDmrJQDKIVbzUtc+fPq/ZKPZK+82EsPGjptOWtEGayyOSpvgXsF 2UKojLOw9rC9X/RALo0cNDFw2TL6X6/lqGuK0CRtcQAvw7jnzNH64N+fRzT/qeKAi9RL 6J3g== X-Gm-Message-State: APf1xPCHVmlKXc2TqmDopcb86TGTYsWffkRMZ2wNnC21TudpZ1PLKFUL td1cPuj3xV1Z2qPvUbXu8o3zo2Y5 X-Google-Smtp-Source: AG47ELtyUPQz5vR/Xkn+3jmZbw2qzRGfaA3q7kL1BWF2/GmM3lDxjaQea9ZoXYrIzjAI/+gSYFEHFA== X-Received: by 10.223.193.69 with SMTP id w5mr10970469wre.42.1520239020767; Mon, 05 Mar 2018 00:37:00 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Mar 2018 09:36:52 +0100 Message-Id: <20180305083655.6186-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com> References: <20180305083655.6186-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PATCH 4/7] address_space_read: address_space_to_flatview needs RCU lock 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: Alexey Kardashevskiy , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" address_space_read is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_read_full to address_space_read's constant size fast path and address_space_read_full. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Reviewed-by: Alexey Kardashevskiy --- exec.c | 44 ++++++++++++++++++++++++++++---------------- include/exec/memory.h | 25 ++++++++++--------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/exec.c b/exec.c index 0b74b58d45..55b7452bd7 100644 --- a/exec.c +++ b/exec.c @@ -2612,6 +2612,8 @@ static const MemoryRegionOps watch_mem_ops =3D { }, }; =20 +static MemTxResult flatview_read(FlatView *fv, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int = len); static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs at= trs, const uint8_t *buf, int len); static bool flatview_access_valid(FlatView *fv, hwaddr addr, int len, @@ -3161,24 +3163,18 @@ MemTxResult flatview_read_continue(FlatView *fv, hw= addr addr, return result; } =20 -MemTxResult flatview_read_full(FlatView *fv, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, int len) +/* Called from RCU critical section. */ +static MemTxResult flatview_read(FlatView *fv, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int len) { hwaddr l; hwaddr addr1; MemoryRegion *mr; - MemTxResult result =3D MEMTX_OK; - - if (len > 0) { - rcu_read_lock(); - l =3D len; - mr =3D flatview_translate(fv, addr, &addr1, &l, false); - result =3D flatview_read_continue(fv, addr, attrs, buf, len, - addr1, l, mr); - rcu_read_unlock(); - } =20 - return result; + l =3D len; + mr =3D flatview_translate(fv, addr, &addr1, &l, false); + return flatview_read_continue(fv, addr, attrs, buf, len, + addr1, l, mr); } =20 static MemTxResult flatview_rw(FlatView *fv, hwaddr addr, MemTxAttrs attrs, @@ -3199,6 +3195,22 @@ MemTxResult address_space_rw(AddressSpace *as, hwadd= r addr, addr, attrs, buf, len, is_write); } =20 +MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int le= n) +{ + MemTxResult result =3D MEMTX_OK; + FlatView *fv; + + if (len > 0) { + rcu_read_lock(); + fv =3D address_space_to_flatview(as); + result =3D flatview_read(fv, addr, attrs, buf, len); + rcu_read_unlock(); + } + + return result; +} + MemTxResult address_space_write(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const uint8_t *buf, int len) diff --git a/include/exec/memory.h b/include/exec/memory.h index 6c8e394675..54ff81fbd1 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -1894,13 +1894,12 @@ void address_space_unmap(AddressSpace *as, void *bu= ffer, hwaddr len, =20 =20 /* Internal functions, part of the implementation of address_space_read. = */ +MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, int le= n); MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, int len, hwaddr addr1, hwaddr l, MemoryRegion *mr); - -MemTxResult flatview_read_full(FlatView *fv, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, int len); void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr); =20 static inline bool memory_access_is_direct(MemoryRegion *mr, bool is_write) @@ -1919,25 +1918,28 @@ static inline bool memory_access_is_direct(MemoryRe= gion *mr, bool is_write) * * Return a MemTxResult indicating whether the operation succeeded * or failed (eg unassigned memory, device rejected the transaction, - * IOMMU fault). + * IOMMU fault). Called within RCU critical section. * - * @fv: #FlatView to be accessed + * @as: #AddressSpace to be accessed * @addr: address within that address space * @attrs: memory transaction attributes * @buf: buffer with the data transferred */ static inline __attribute__((__always_inline__)) -MemTxResult flatview_read(FlatView *fv, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len) +MemTxResult address_space_read(AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, uint8_t *buf, + int len) { MemTxResult result =3D MEMTX_OK; hwaddr l, addr1; void *ptr; MemoryRegion *mr; + FlatView *fv; =20 if (__builtin_constant_p(len)) { if (len) { rcu_read_lock(); + fv =3D address_space_to_flatview(as); l =3D len; mr =3D flatview_translate(fv, addr, &addr1, &l, false); if (len =3D=3D l && memory_access_is_direct(mr, false)) { @@ -1950,18 +1952,11 @@ MemTxResult flatview_read(FlatView *fv, hwaddr addr= , MemTxAttrs attrs, rcu_read_unlock(); } } else { - result =3D flatview_read_full(fv, addr, attrs, buf, len); + result =3D address_space_read_full(as, addr, attrs, buf, len); } return result; } =20 -static inline MemTxResult address_space_read(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, uint8_t *bu= f, - int len) -{ - return flatview_read(address_space_to_flatview(as), addr, attrs, buf, = len); -} - /** * address_space_read_cached: read from a cached RAM region * --=20 2.14.3 From nobody Sun May 5 18:05:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520239126940217.35910625127678; Mon, 5 Mar 2018 00:38:46 -0800 (PST) Received: from localhost ([::1]:47814 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1esldu-0005LJ-3C for importer@patchew.org; Mon, 05 Mar 2018 03:38:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslcG-0004NT-C8 for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eslcF-0004T4-Jz for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:04 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:40588) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eslcF-0004Rn-Dq; Mon, 05 Mar 2018 03:37:03 -0500 Received: by mail-wr0-x242.google.com with SMTP id o76so16280456wrb.7; Mon, 05 Mar 2018 00:37:03 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id y23sm13206739wra.9.2018.03.05.00.37.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 00:37:01 -0800 (PST) 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=89YcEWylgMMEp0xmHw1e/4h52Ti1rK2gOMzo7Fad6gQ=; b=JxE9Wy00rzZNgNiKjxDmbO6ULbc1rL7nZkU+eawmqL+wtVvLnaOjpBUx8fs7Rj5mLH nfiekwBZXu+iFv/rZaGKK5jkDSfMdq2WlFEbbeIx/Ubqw227BPzBAl8oCHOdnfSp8FBx TMlxtrt5sWqJQk5VaMMPz5CYRI8od4vHs5IIZb8cC8BMVyOU4jbqCvIT98qVLnXU2aMz sTkCBpUB0qL6ngUu6YzsdIbx7O/KcsvcUfy11mfyw7miE/Jb3uQ74J7WKkUantv7FAOL 83ycGM84rOMNvzGtPdx1FQtCewtMeeNpIjp4T+2AHFtqqgsQ3TyV+TCEUJbE2r2bq3Iw FPCg== 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=89YcEWylgMMEp0xmHw1e/4h52Ti1rK2gOMzo7Fad6gQ=; b=tHsbQ9wlmRqCIJoAzEaNz2ODtdNMe/sFxaZvtJVKWwYpU9qWgOIPgv9COv7rJG66Ec P8nWvcMyRJtcWqkBui3lwxUmAZ+wVDgFCx++bdnpoMd5mvWY2y1UWkoYjNIqYx5JZ+cr ZLmqD/jZhzXl3voZKBHff5se2P+XI341M+Iqc41lkA2zJKbQ0WOlZdNN+XVqzIyQ0LWX ubqw4ZJd1tagPHtJJ6xzMe3q259tv93FqP8lQ/vd7ERiA3uXPMq3oLl374Zm5CpHwhIS B6gE7DmDXLY2KfVxXl+CBlenhQ93o4fBfcElr8lUB8gKfCifcZmF7tGa2gjUAF/zcjEh o0eA== X-Gm-Message-State: APf1xPAnR7f8iqNe5QXMceQWcQx/NKOz/6FaJCICE0mEupcp43an0bBv 3nXIKw57V6vhawkMcR3XmqN8ZQPF X-Google-Smtp-Source: AG47ELulIJ/K3guPueXra3iVUuttVM6VX0UgCy0WsCjvxAJyM3m94jepwXBLPmnQJFuK+4/dENPfpg== X-Received: by 10.223.135.136 with SMTP id b8mr11675675wrb.72.1520239022003; Mon, 05 Mar 2018 00:37:02 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Mar 2018 09:36:53 +0100 Message-Id: <20180305083655.6186-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com> References: <20180305083655.6186-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [PATCH 5/7] address_space_access_valid: address_space_to_flatview needs RCU lock 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: Alexey Kardashevskiy , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" address_space_access_valid is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, push the rcu_read_lock/unlock pair up from flatview_access_valid to address_space_access_valid. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Reviewed-by: Alexey Kardashevskiy --- exec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/exec.c b/exec.c index 55b7452bd7..177583c2ee 100644 --- a/exec.c +++ b/exec.c @@ -3391,7 +3391,6 @@ static bool flatview_access_valid(FlatView *fv, hwadd= r addr, int len, MemoryRegion *mr; hwaddr l, xlat; =20 - rcu_read_lock(); while (len > 0) { l =3D len; mr =3D flatview_translate(fv, addr, &xlat, &l, is_write); @@ -3406,15 +3405,20 @@ static bool flatview_access_valid(FlatView *fv, hwa= ddr addr, int len, len -=3D l; addr +=3D l; } - rcu_read_unlock(); return true; } =20 bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write) { - return flatview_access_valid(address_space_to_flatview(as), - addr, len, is_write); + FlatView *fv; + bool result; + + rcu_read_lock(); + fv =3D address_space_to_flatview(as); + result =3D flatview_access_valid(fv, addr, len, is_write); + rcu_read_unlock(); + return result; } =20 static hwaddr --=20 2.14.3 From nobody Sun May 5 18:05:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520239450841111.02671113882445; Mon, 5 Mar 2018 00:44:10 -0800 (PST) Received: from localhost ([::1]:47849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslj7-0001m1-Un for importer@patchew.org; Mon, 05 Mar 2018 03:44:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslcH-0004Of-Pi for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eslcG-0004VC-VN for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:05 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:39250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eslcG-0004Tl-Ok; Mon, 05 Mar 2018 03:37:04 -0500 Received: by mail-wm0-x244.google.com with SMTP id i3so13698189wmi.4; Mon, 05 Mar 2018 00:37:04 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id y23sm13206739wra.9.2018.03.05.00.37.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 00:37:02 -0800 (PST) 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=b9au6Bz5trrEEsaT+D8yfYVFu77Dm718I7mlEyVY4vw=; b=o7LGFajFx61mQ9M2NMcRZOqk0eZxuZjIQNRHTuODG3WbnJR5GWLzZ+KbABTDbYdtg/ hk2HvluhLsg8/Jloc6tBg13W6KAZUWynEr7/0zAxCU9BGPqBZ43b7WiSaPrPdKOoSjcv CLvbhyxOvNXYCSbHeucwU66DMRjJnfgF6eJnD5FGK8RR64o3dV8tfo0R9qWrHE3c+Yqb c343BRmBtwMoaCLMrtBKCg9V/tbkeeBSIqIR9r+PhBlHnODLZmPvsEe2/js816dMUBL4 ytzi5+up+1J2yMh9efdcCsorOCFkKD/alGzEoWOu6V3zQwfKDm0yxjMv/h4ZTFnFIue0 HRpA== 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=b9au6Bz5trrEEsaT+D8yfYVFu77Dm718I7mlEyVY4vw=; b=irepREHafWyVzCwTIQJi7u4azESZfgMokLrVq7MFuyEzxAvua2v4dtVCX/HS+tc9n/ JX68ANDDkKQJlrdFef6lL6SGEPz6SiADD3n5Yln13Teb+6IRomNhE4Ho6aJcdjfyaUGQ /Pcxh+V9S06jhNkxI1dWYe1mVO7QU692TP67fZT4S7vsHw2maKiHGw9bq+2uhDDdiMMz Lu9/WOTXwW1aH/vxaNAdyzOAmE2L3oWhxLCT5s7g6oRdG2IdrOabpk/P5zS/uC0N6f3F pF9Js/VDw/J33eFmK9qv8SvhcnjsOu0ee+ThEq3nFhErOWEWMZHxK+KSVabmv3ZyxU1I Tbng== X-Gm-Message-State: AElRT7GlFNJUuc+n9ENkMccUKg0pDMRs2eZdarHx0/9vN1Ra+B2rFmi9 K4793916JA7ACILjss/osFlHYutL X-Google-Smtp-Source: AG47ELvQSvuGp1kgvojmp0DzGVreUm6AvG8TVeNaM747Rv9bejfqbDcGYA5XDy8FpQwuJvislSZqHw== X-Received: by 10.28.124.5 with SMTP id x5mr7032787wmc.11.1520239023359; Mon, 05 Mar 2018 00:37:03 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Mar 2018 09:36:54 +0100 Message-Id: <20180305083655.6186-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com> References: <20180305083655.6186-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH 6/7] address_space_map: address_space_to_flatview needs RCU lock 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: Alexey Kardashevskiy , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" address_space_map is calling address_space_to_flatview but it can be called outside the RCU lock. The function itself is calling rcu_read_lock/rcu_read_unlock, just in the wrong place, so the fix is easy. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Reviewed-by: Alexey Kardashevskiy --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 177583c2ee..070eaff3e7 100644 --- a/exec.c +++ b/exec.c @@ -3464,7 +3464,7 @@ void *address_space_map(AddressSpace *as, hwaddr l, xlat; MemoryRegion *mr; void *ptr; - FlatView *fv =3D address_space_to_flatview(as); + FlatView *fv; =20 if (len =3D=3D 0) { return NULL; @@ -3472,6 +3472,7 @@ void *address_space_map(AddressSpace *as, =20 l =3D len; rcu_read_lock(); + fv =3D address_space_to_flatview(as); mr =3D flatview_translate(fv, addr, &xlat, &l, is_write); =20 if (!memory_access_is_direct(mr, is_write)) { --=20 2.14.3 From nobody Sun May 5 18:05:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520239527555512.2574745853024; Mon, 5 Mar 2018 00:45:27 -0800 (PST) Received: from localhost ([::1]:47859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslkM-0002a8-RN for importer@patchew.org; Mon, 05 Mar 2018 03:45:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eslcL-0004SU-7X for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eslcI-0004Wb-5F for qemu-devel@nongnu.org; Mon, 05 Mar 2018 03:37:09 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:36484) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eslcH-0004VO-UR; Mon, 05 Mar 2018 03:37:06 -0500 Received: by mail-wr0-x243.google.com with SMTP id v111so16273268wrb.3; Mon, 05 Mar 2018 00:37:05 -0800 (PST) Received: from donizetti.lan (94-36-191-219.adsl-ull.clienti.tiscali.it. [94.36.191.219]) by smtp.gmail.com with ESMTPSA id y23sm13206739wra.9.2018.03.05.00.37.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Mar 2018 00:37:04 -0800 (PST) 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=ylDaqhu8Zl+oCVUd3dftlvTOZpfwNWDirFMToPM5T6g=; b=CM3AGQvE723rzTdZG6Y3e81OSrfBhXRhZTIqBru+d2K7nzFtn44W23hET18wf7+f9i kAJsmcoqkq/LPY6aeezKveS2uK7HjxGtwlBWh3KeJPJnCpI/2g4QUFNWmVT0X4jI6Wkr iuGti3+GaeP+8/ApczwgJaxyybidu0H4YdgcwE0Ml/T/nRzL/3AmTqR17YC2vD4CUqj7 cEbi2aYQdjYcTq70kcuJpLd4feBxZbcaC2G3vqEZhQPh5w/bgcMIWOY9/B5iaTOB+7xp F9EnlXrwqPzWytWlBIvAgtpNtikhFNXq2/dSqZ/fpaTkU5BPGA7JYBsl1FQ/HR/A6xQB so9w== 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=ylDaqhu8Zl+oCVUd3dftlvTOZpfwNWDirFMToPM5T6g=; b=tj4fhh554pm/DXAU1O72MJ7s+o3XnAXjIpg0OIMtKpftATl+tECu9vEJk5FTidIZ6Q sb2XHQ5P5/ThIrALd+Ts2IvezLiF2Kxb4zDim/6T3Ui56ourWA50McdYpBzLeuKDn/vp 9cgoXie+pUa5yh1wMnu0SIySBbETUcahNaBhCZPD5rJwRPVW5x8yM8FlDyeWqc8bUiWB 6OhCH/mzGPk18R/Ekk5AmvXjFCzP8sd06i1pGVLKuF7ucjJKz6Kmp3Y6J8M6Bmv9d/vs 6NOwCxgTK3VVaSP7pdJrK7San3nAMYNxid7sKk8z0Zu+vzpeBe2t6T4+a6wCFgO2RHlP zdQw== X-Gm-Message-State: APf1xPDok9Jyov0vKKZ9zhvYUOkYDB5bVa7vl8VPMo3O8YqRsaGv0lYL ej/dtakroVGvVgBJrML3obzXyUO6 X-Google-Smtp-Source: AG47ELte5su32H35F4DW3ik4vw9osmViFTroX5S1hqg6zIMvMMjjjxlnWyzR1osbuGAUKmjCTDNHVA== X-Received: by 10.223.156.147 with SMTP id d19mr12495904wre.272.1520239024580; Mon, 05 Mar 2018 00:37:04 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 5 Mar 2018 09:36:55 +0100 Message-Id: <20180305083655.6186-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180305083655.6186-1-pbonzini@redhat.com> References: <20180305083655.6186-1-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH 7/7] address_space_rw: address_space_to_flatview needs RCU lock 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: Alexey Kardashevskiy , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" address_space_rw is calling address_space_to_flatview but it can be called outside the RCU lock. To fix it, transform flatview_rw into address_space_rw, since flatview_rw is otherwise unused. Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini Reviewed-by: Alexey Kardashevskiy --- exec.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/exec.c b/exec.c index 070eaff3e7..8a99114c69 100644 --- a/exec.c +++ b/exec.c @@ -3177,24 +3177,6 @@ static MemTxResult flatview_read(FlatView *fv, hwadd= r addr, addr1, l, mr); } =20 -static MemTxResult flatview_rw(FlatView *fv, hwaddr addr, MemTxAttrs attrs, - uint8_t *buf, int len, bool is_write) -{ - if (is_write) { - return flatview_write(fv, addr, attrs, (uint8_t *)buf, len); - } else { - return flatview_read(fv, addr, attrs, (uint8_t *)buf, len); - } -} - -MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, - MemTxAttrs attrs, uint8_t *buf, - int len, bool is_write) -{ - return flatview_rw(address_space_to_flatview(as), - addr, attrs, buf, len, is_write); -} - MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, uint8_t *buf, int le= n) { @@ -3228,6 +3210,16 @@ MemTxResult address_space_write(AddressSpace *as, hw= addr addr, return result; } =20 +MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs att= rs, + uint8_t *buf, int len, bool is_write) +{ + if (is_write) { + return address_space_write(as, addr, attrs, buf, len); + } else { + return address_space_read_full(as, addr, attrs, buf, len); + } +} + void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write) { --=20 2.14.3