From nobody Tue Feb 10 02:48:49 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501604791919933.928435494181; Tue, 1 Aug 2017 09:26:31 -0700 (PDT) Received: from localhost ([::1]:43623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dca03-0003XF-20 for importer@patchew.org; Tue, 01 Aug 2017 12:26:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcZrc-0004Q8-7m for qemu-devel@nongnu.org; Tue, 01 Aug 2017 12:17:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcZrZ-0007EO-0e for qemu-devel@nongnu.org; Tue, 01 Aug 2017 12:17:44 -0400 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:35886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dcZrY-0007Dm-Pp for qemu-devel@nongnu.org; Tue, 01 Aug 2017 12:17:40 -0400 Received: by mail-wr0-x243.google.com with SMTP id y67so1805045wrb.3 for ; Tue, 01 Aug 2017 09:17:40 -0700 (PDT) Received: from 640k.lan (94-39-192-75.adsl-ull.clienti.tiscali.it. [94.39.192.75]) by smtp.gmail.com with ESMTPSA id u187sm1724160wmd.26.2017.08.01.09.17.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 09:17: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=5y8GqD8hUQJYEKWx+xjpCmGF8ViKUgWCtwfbxEhBSc0=; b=PiW9P3D5bQWheFt74J3lyYDkchNEp3pC4ru/SZD2z2a1w7gRO2RAj3yEjo9iaECf34 tvRIX51AHkJ0+XUNgt818zNyNwHz4+1muicKTq6d7/vxPsMkdXT1psCpSu++heHI/SgI EwGwGiHl90JhKftasCx5P9Tcli7+qxEesAHPzYxs1+o2kyVmPu0K3/ojqz0NtIp6I/jP bTyz5ArHvGyBbpt4JAqVzIgOIALAuWVovTXL+3m/XipW/yuLPUu8CjgXTrcYllYdw70I DQxCTmr7dVGis02dH0I0scKcGu9SQRvCePkWcl8CIJ6D6OZurT3hCyfx5ry/P8hTf2nX GuzA== 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=5y8GqD8hUQJYEKWx+xjpCmGF8ViKUgWCtwfbxEhBSc0=; b=BlTuDCLV0AzI7bx1qPHLXCMEmXV/+OFSjQM1o9v4Xy2qTKcdGWOtego6HFpVVBNQrL FFf4XjUgoVIVcMDH2uoU5OoUipI7HRVhiQeOXs6Uw99oj9rmvPIcAj9eANEhBSZO0TFF WfnjMzrgv5hJwwSTaU6v+GWNN4afjUGWC2MNnKyZUFRFEfZhEHyC+vLY9FaZdUmm331H +Z7wjR8L1zyDSUuu/uLmGZauzPheByN5XEshpHqRBMC1zjWZjHZbEvNi/+x3n109npz4 tVGWIORlMnqd3niqtxcVcpcXwY34uaJ2MpQGBdhuCYtOPVNFC71cAv5dvZ32uOl+9vFV jFBA== X-Gm-Message-State: AIVw1111F45L2HJT2CLrRXj+RU8xscta1IO5AUwGO4M8sBMI+ZefwxhA 8zIXXRSFuJjwF4W7spE= X-Received: by 10.223.136.178 with SMTP id f47mr17935543wrf.250.1501604259446; Tue, 01 Aug 2017 09:17:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 1 Aug 2017 18:17:16 +0200 Message-Id: <1501604245-33460-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501604245-33460-1-git-send-email-pbonzini@redhat.com> References: <1501604245-33460-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:400c:c0c::243 Subject: [Qemu-devel] [PULL 08/17] exec: Add lock parameter to qemu_ram_ptr_length 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: Anthony PERARD 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" From: Anthony PERARD Commit 04bf2526ce87f21b32c9acba1c5518708c243ad0 (exec: use qemu_ram_ptr_length to access guest ram) start using qemu_ram_ptr_length instead of qemu_map_ram_ptr, but when used with Xen, the behavior of both function is different. They both call xen_map_cache, but one with "lock", meaning the mapping of guest memory is never released implicitly, and the second one without, which means, mapping can be release later, when needed. In the context of address_space_{read,write}_continue, the ptr to those mapping should not be locked because it is used immediatly and never used again. The lock parameter make it explicit in which context qemu_ram_ptr_length is called. Signed-off-by: Anthony PERARD Message-Id: <20170726165326.10327-1-anthony.perard@citrix.com> Reviewed-by: Stefano Stabellini Signed-off-by: Paolo Bonzini --- exec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/exec.c b/exec.c index 01ac21e..d20c34c 100644 --- a/exec.c +++ b/exec.c @@ -2203,7 +2203,7 @@ void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_= t addr) * Called within RCU critical section. */ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr, - hwaddr *size) + hwaddr *size, bool lock) { RAMBlock *block =3D ram_block; if (*size =3D=3D 0) { @@ -2222,10 +2222,10 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_bloc= k, ram_addr_t addr, * In that case just map the requested area. */ if (block->offset =3D=3D 0) { - return xen_map_cache(addr, *size, 1, true); + return xen_map_cache(addr, *size, lock, lock); } =20 - block->host =3D xen_map_cache(block->offset, block->max_length, 1,= true); + block->host =3D xen_map_cache(block->offset, block->max_length, 1,= lock); } =20 return ramblock_ptr(block, addr); @@ -2947,7 +2947,7 @@ static MemTxResult address_space_write_continue(Addre= ssSpace *as, hwaddr addr, } } else { /* RAM case */ - ptr =3D qemu_ram_ptr_length(mr->ram_block, addr1, &l); + ptr =3D qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); memcpy(ptr, buf, l); invalidate_and_set_dirty(mr, addr1, l); } @@ -3038,7 +3038,7 @@ MemTxResult address_space_read_continue(AddressSpace = *as, hwaddr addr, } } else { /* RAM case */ - ptr =3D qemu_ram_ptr_length(mr->ram_block, addr1, &l); + ptr =3D qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); memcpy(buf, ptr, l); } =20 @@ -3349,7 +3349,7 @@ void *address_space_map(AddressSpace *as, =20 memory_region_ref(mr); *plen =3D address_space_extend_translation(as, addr, len, mr, xlat, l,= is_write); - ptr =3D qemu_ram_ptr_length(mr->ram_block, xlat, plen); + ptr =3D qemu_ram_ptr_length(mr->ram_block, xlat, plen, true); rcu_read_unlock(); =20 return ptr; --=20 1.8.3.1