From nobody Mon Nov 25 10:24:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716547939; cv=none; d=zohomail.com; s=zohoarc; b=SM3+8L03Gh+VR5RSa9zs7uHgwMyu9ahz6MF+I21/Ayxe9S8OboFWEdK0DvzaxuMZxwXE7H5vB4+0gKlD1ViiTaDYhfVu+cf4pabKhQ1u1gnn2myT9baiP6UMq4oocs6jsYydHb2b/Qi+aARgy5RVmMNAs9c3MDyxzSVWeD/WPFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716547939; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=suqLmt7AH8VX+OrzngkGIik/kesngvj14F2vCYL7OFM=; b=VtycTUqFSwqdgjY13yJ3ckZL+k27mtzWP6l82xQ90B1uVWwPEhZzDRsb2ltxWNQI3HofNOygYwmINoGgQALFDR7vB4mhIIN4mR5MpRBFCD29kS9I0k6WxllhmJOLJ5s4J4HAnurOAp/Ji/S0p7StgD7ToHuEW/rDtla3VQ9BySE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 171654793913223.12190387503847; Fri, 24 May 2024 03:52:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.729311.1134427 (Exim 4.92) (envelope-from ) id 1sASWn-0005vc-WE; Fri, 24 May 2024 10:52:02 +0000 Received: by outflank-mailman (output) from mailman id 729311.1134427; Fri, 24 May 2024 10:52:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sASWn-0005vS-T2; Fri, 24 May 2024 10:52:01 +0000 Received: by outflank-mailman (input) for mailman id 729311; Fri, 24 May 2024 10:52:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sASWn-0005h8-5G for xen-devel@lists.xenproject.org; Fri, 24 May 2024 10:52:01 +0000 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [2a00:1450:4864:20::235]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a55713ff-19bb-11ef-b4bb-af5377834399; Fri, 24 May 2024 12:51:59 +0200 (CEST) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2e95abc7259so6768751fa.3 for ; Fri, 24 May 2024 03:51:59 -0700 (PDT) Received: from gmail.com (213-67-3-247-no600.tbcn.telia.com. [213.67.3.247]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2e95bcf4c32sm1421121fa.66.2024.05.24.03.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 03:51:57 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a55713ff-19bb-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716547919; x=1717152719; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=suqLmt7AH8VX+OrzngkGIik/kesngvj14F2vCYL7OFM=; b=Tg3FNMBboZx20BiYsPxa1SM6q5Vk4G46zzScjpLP00Uqa5Xw8JFsocs6SpaboyuE8K x5LSBxJ05zW32ttuLuYZ8X8rO7kth3g4BqjS2QUhjz9/k1emvqCUDtWRTmzKtwoJSKsn p9yHOGLAze1OWuehrp+z8LQJ2/5YR+fqiani+hbfQMPkhd7P9dsmmW9BW8lYav9O9ECr T/jYD/76s30Em5nSLAF3zgEWjzzSEQHlasRCnLRdEEFhknsCkwBLzgTn7MOT0yPTPJxn ePozly39GugDYgSfHGLOoX0ZCUKxuJQoZMi8DRrilElyzwry8euM4q0Mhg+rHkePZdNy AORQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716547919; x=1717152719; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=suqLmt7AH8VX+OrzngkGIik/kesngvj14F2vCYL7OFM=; b=fN9ym5fCjHRLOSH9dQk7lE5m/6/OkwME3hH9o79RHsGTCD0MbzZRzBW8JfAmauO3Ui j0A0GXpaz3x7mDxPUsbym67ihEJc4SUE52H379yUSff78KjF09LkS1+WlCYR1H6s0LAz ODddyE+ry5YnRgB3wiFFKc9+jJZ2lM7lw60RCh+gMCjbjbRiWCy+KxEPwS7waF5G4z1f 0ubBa67dg9s22Zi/Uz1+8Mr3lyJaY6Dk1lua1wsYWn5KNTuL/mF7eJSQV+G+FBugsStp NLhDrHLukVPUn1cKqcTr5cCG5hqgW4B57wXj61gv+8TnyLSU7b6NmX0XXOGPUok/dpse rdiA== X-Forwarded-Encrypted: i=1; AJvYcCXodxwlhHdV7HpjqiJZgVb/kPpGSuGf/EkVpLIXajx/OndWBhco47CMTt9+sT0+ybp9GV0zsSX02jORvv3BXHkhpKVby22TPGuZKkBB0Ss= X-Gm-Message-State: AOJu0Yz17MvWknYm2bSFxrQptGIGGIpvWElIvj51+1+RpsKgWZ3qUwQi R88ABImeL12PDAu5WQQF2eBRT+Ke4mg5829I+1pzSTzf/kbFTz+z X-Google-Smtp-Source: AGHT+IG7/58L7fP8XfkA17hx/P2HA+GooUSMBu7K0MzZTbJxr4odywyDF44eC1SlJ9lDqF4xGtjtyw== X-Received: by 2002:a2e:8417:0:b0:2e5:751d:4b0f with SMTP id 38308e7fff4ca-2e95b2822ebmr10863631fa.34.1716547918939; Fri, 24 May 2024 03:51:58 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Cc: edgar.iglesias@gmail.com, sstabellini@kernel.org, jgross@suse.com, "Edgar E. Iglesias" , Anthony PERARD , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PATCH v7 2/8] xen: mapcache: Unmap first entries in buckets Date: Fri, 24 May 2024 12:51:46 +0200 Message-Id: <20240524105152.1301842-3-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240524105152.1301842-1-edgar.iglesias@gmail.com> References: <20240524105152.1301842-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716547940984100001 Content-Type: text/plain; charset="utf-8" From: "Edgar E. Iglesias" When invalidating memory ranges, if we happen to hit the first entry in a bucket we were never unmapping it. This was harmless for foreign mappings but now that we're looking to reuse the mapcache for transient grant mappings, we must unmap entries when invalidated. Signed-off-by: Edgar E. Iglesias Reviewed-by: Stefano Stabellini --- hw/xen/xen-mapcache.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index bc860f4373..ec95445696 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -491,18 +491,23 @@ static void xen_invalidate_map_cache_entry_unlocked(M= apCache *mc, return; } entry->lock--; - if (entry->lock > 0 || pentry =3D=3D NULL) { + if (entry->lock > 0) { return; } =20 - pentry->next =3D entry->next; ram_block_notify_remove(entry->vaddr_base, entry->size, entry->size); if (munmap(entry->vaddr_base, entry->size) !=3D 0) { perror("unmap fails"); exit(-1); } + g_free(entry->valid_mapping); - g_free(entry); + if (pentry) { + pentry->next =3D entry->next; + g_free(entry); + } else { + memset(entry, 0, sizeof *entry); + } } =20 typedef struct XenMapCacheData { --=20 2.40.1