From nobody Mon Nov 25 11:31:53 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=1715874514; cv=none; d=zohomail.com; s=zohoarc; b=ED/IVEjyuKcaw0YtbgBilI7wa5g5ztIIpdzLRf6EBs3ZmwvOlesOop9xTd1gRgagjJs2UdOc4M9mSkqJmhW6pd+Lm10mx5AmfNALLJg8ZZSlkF2USKIdY/8Qh/dHNpLTmdD99WrXNQ2UchE6QmqBh5XBCJ7j6W2scSvmi9OeY0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715874514; 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=CyHOEjDjBicoz+gaN5uM8S0USxnRvM5Qs6qfDT436lRNVziYxa4e2CMZxs1Cb4mYns/hVoFuj5btoFKmAC6GHwe/XThM8r1/JER6Gxs91BM/tfDucuKYbh1VCWahPaa9HN0d3JvjSDSXey/PyceQFhdVVwTBeUUXOhB3jHAmeTQ= 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 1715874514496256.89581795842867; Thu, 16 May 2024 08:48:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.723474.1128351 (Exim 4.92) (envelope-from ) id 1s7dL6-0008Uw-BB; Thu, 16 May 2024 15:48:16 +0000 Received: by outflank-mailman (output) from mailman id 723474.1128351; Thu, 16 May 2024 15:48:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s7dL6-0008Up-72; Thu, 16 May 2024 15:48:16 +0000 Received: by outflank-mailman (input) for mailman id 723474; Thu, 16 May 2024 15:48:14 +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 1s7dL4-0008G5-Kp for xen-devel@lists.xenproject.org; Thu, 16 May 2024 15:48:14 +0000 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [2a00:1450:4864:20::32d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b3daf367-139b-11ef-b4bb-af5377834399; Thu, 16 May 2024 17:48:13 +0200 (CEST) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42016c8daa7so31427305e9.2 for ; Thu, 16 May 2024 08:48:13 -0700 (PDT) Received: from gmail.com ([213.0.35.158]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-420193b0903sm135397305e9.47.2024.05.16.08.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 08:48:11 -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: b3daf367-139b-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715874492; x=1716479292; 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=aho6bzCe+jDxNs4ys9vUT726OAdpjtZWNUfY80B3aVOIwdymqUwl2YyBOKYtA3Gh70 SKtQzIib9/xxdPHaI1fKpD2STAPKLCPmbtA1N52qlyLQlb4R3htuz1HsbVOzQg8h1IDd wPglEJE7s6b7lIagoemGctAfZl6jQd6Mj9ScDgllSVk9vaCAT/vE3yEOWiZ3QrAwUReF DBvYhzwABOteiJQz0onRLbgs9Gc1JlwFj6T1Yj7BHn9VaYjNWck/sKqFaBMnnjrUu9vE gbFIst0ELd9NvA3nPNJXgC9xg08m2ohknXWReJ+AYHJ5Zy3m+vVnqKxQD9l9P5YHbaKo C+Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715874492; x=1716479292; 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=GRsrSdnR84iZGK98B+bMxOdD617Bk5gB9erpadPna3HHrOpmFE68EjgqYQ3Sj6o5z1 CddrzOs2hTwPFAusqcp1LIYFxSliBQfsP934FWllMgk5scSuKssl4LKg4sVQ1/n2iR0U yrEYwq5e5vol5RS4OjVQ0kYf1MS2UTH6uHTlSOmczk4ipb0jcIWKqWTM4YpRniVrwcPv Ziex6xe4XM+MLnBh0YrZV3vncV1kDsxTWhUcjDAaPszmsGuYQU1cGYm5gwroiR76XxI6 4PpaFJQnCYNgEMK6ycFiHwqhl/6THa+hSZ+T74voDU4/LGBhmY3ftbSaRGT27SNgyb5X EaUw== X-Forwarded-Encrypted: i=1; AJvYcCVxsFHXRuhZS219ix2H84yIBOuk2oJAT4SNX1ZTGas5vT93vuJxVRtiJ+LVoNh+JjjXYJmzqbWsGKX5atGUTfQLl3wM7TvKGCJSqnfHgcA= X-Gm-Message-State: AOJu0Yy74WKXIGLFaT8hn2ntdCiLYAOxFNwUwbNbIQY9vW+cRGh19kF6 4hdMRXKinhk2/LvfBrLpQukl1/2j2UvFA8mTJTho2gpIqu3sPXt8 X-Google-Smtp-Source: AGHT+IFjr0fT67BiVLzPhzx72CFQaxGN4vZsogPbdN+2UbY4Li7I/8td4kLMOJN0uGIq1S8SJxxrwg== X-Received: by 2002:a05:600c:154e:b0:41f:e959:9053 with SMTP id 5b1f17b1804b1-41fead6ae10mr166768825e9.38.1715874492348; Thu, 16 May 2024 08:48:12 -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 v6 2/8] xen: mapcache: Unmap first entries in buckets Date: Thu, 16 May 2024 17:47:58 +0200 Message-Id: <20240516154804.1114245-3-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240516154804.1114245-1-edgar.iglesias@gmail.com> References: <20240516154804.1114245-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1715874516064100001 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