From patchwork Tue Jun 19 01:41:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 10472907 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 132F760230 for ; Tue, 19 Jun 2018 02:30:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0099128BED for ; Tue, 19 Jun 2018 02:30:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E773F28C6F; Tue, 19 Jun 2018 02:29:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8BDF428BED for ; Tue, 19 Jun 2018 02:29:59 +0000 (UTC) Received: from localhost ([::1]:38633 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6P8-0001hI-OB for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Jun 2018 22:29:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hr-0001SH-Tl for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hr-0008Lq-2e for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:45:15 -0400 Received: from mail-oi0-x235.google.com ([2607:f8b0:4003:c06::235]:43938) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hq-0008LR-UZ; Mon, 18 Jun 2018 21:45:15 -0400 Received: by mail-oi0-x235.google.com with SMTP id t133-v6so16695364oif.10; Mon, 18 Jun 2018 18:45:14 -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=RFRfs+e+5HIlKSdEH+KaNnrDTCCndMdD1Qd832KxdSs=; b=quLfbyN/Y1MTlmRNYyFAYZGSSnXF6HJY0uodD2tWUEr51tf3cM2zXC1mQfM1TatBEL 0WHYEOzlvaIT9bvhK2urygea1/sOcWJlvm+CpJouiKSN/TdsETY5T/lL8rrDDNDZr/w2 YZMYSbEKhI7kYnaUtecxcJhJgzksOaHbC3WoexpGHbu/NCCc3BR9JIY89GYbNatkqqPo rGrsyZtmQ0gXhLjWcT9WyUzhfMz1szBouzVGc/VfMbfreBVY9+jjPttj/veXXM1BH3oN wQJpIsDTUgNe9Nr4/4Ogsff5J3Uo25WbiSnzz0NpnvDU37GTL0827uz7CxoHkSPsBdVT 9lbg== 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=RFRfs+e+5HIlKSdEH+KaNnrDTCCndMdD1Qd832KxdSs=; b=l4Dp2JcQ343GRI3+fOAwHrYZqun/jyrhuf/5dEirbpqroOPTeQsIwsKL7elEjqVxGU NkoMhq6o/kif0tfDPJpmNPQh3qcpCAwGpBTjoxcZgA8wBKIEGlMVEPRUi9t0rTA05npv SiJm5cgJjOFT85vKLCK0D3OEQcVh/nWRD0KbgRaC7jPn4YbWgfw58OYC4EX+oa/M8Kio CScU3ky2BZC2TQAK52t85U24UeWHMEGQ6XI/YAfv0kh5jnJpxWA3+h3645IHSffv+nB5 BnDTxJnzBB8OxKh8szlJ6fdV2/vw2YWo+KSPNOsK2KEr50vqndcsumwsD9DFfGCoGo+a zyFw== X-Gm-Message-State: APt69E0Mx4MOEWT6rIxwLjdnRb7TJ5jXwbKa3RBWrp/VmAoBFu4AisLt cI2HPESKcpQX4r0e5T4tWSbgrlHG X-Google-Smtp-Source: ADUXVKKO7rfBvrxU/5wLerylo9GsLAOiPqDT0iYIUY6RO0MMp25JJrRhXb6qHbD/qFyETE9ZUtXuuw== X-Received: by 2002:aca:52cb:: with SMTP id g194-v6mr6297797oib.241.1529372713733; Mon, 18 Jun 2018 18:45:13 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id b4-v6sm7199667otf.79.2018.06.18.18.45.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:45:12 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:58 -0500 Message-Id: <20180619014319.28272-33-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::235 Subject: [Qemu-devel] [PATCH 032/113] 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini 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. Reviewed-by: Alexey Kardashevskiy Signed-off-by: Paolo Bonzini (cherry picked from commit ad0c60fa572d4050255b698ecdb67294dd4c0125) Signed-off-by: Michael Roth --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 7c4fb68368..e30155c113 100644 --- a/exec.c +++ b/exec.c @@ -3395,7 +3395,7 @@ void *address_space_map(AddressSpace *as, hwaddr l, xlat; MemoryRegion *mr; void *ptr; - FlatView *fv = address_space_to_flatview(as); + FlatView *fv; if (len == 0) { return NULL; @@ -3403,6 +3403,7 @@ void *address_space_map(AddressSpace *as, l = len; rcu_read_lock(); + fv = address_space_to_flatview(as); mr = flatview_translate(fv, addr, &xlat, &l, is_write); if (!memory_access_is_direct(mr, is_write)) {