From nobody Mon Nov 25 06:55:43 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=1716991689; cv=none; d=zohomail.com; s=zohoarc; b=hzFxDLYEkbhwKO/M91/IDjeSpVrF0oicg+hsONhnxv6RmcCjhbUoM0L7djcE6XzAz2WMiJxAPU9KE++SMMvCFXN/Yc33IDcY1sjAm8yE58sdpJbB6WZl6SfH3z1ZV4fLajh8APb7brZGQUqVD/H2p2SNfKDkXYa+7Xn0FmHPSD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716991689; 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=SBd94eA4iln/cVlahZgqnU8jclbaY3x2Z5M+5XhnNMuf8diJ3+SqeoUSJQdbeSK63Fyaj5o8zu10dlli0i9AP/PS0uNV5DsZ8poxdhAjtagQKZ0hyVoLLrzEoUu2mlGU0Z/CdMYo3aTa0X7wUxaksDnCvJftv22ds8Zh19qsNnA= 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 1716991689129548.132127361386; Wed, 29 May 2024 07:08:09 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.731991.1137778 (Exim 4.92) (envelope-from ) id 1sCJy0-0004UG-3y; Wed, 29 May 2024 14:07:48 +0000 Received: by outflank-mailman (output) from mailman id 731991.1137778; Wed, 29 May 2024 14:07:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sCJy0-0004U9-0l; Wed, 29 May 2024 14:07:48 +0000 Received: by outflank-mailman (input) for mailman id 731991; Wed, 29 May 2024 14:07:46 +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 1sCJxy-0004Fc-6z for xen-devel@lists.xenproject.org; Wed, 29 May 2024 14:07:46 +0000 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [2a00:1450:4864:20::12f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d1ef8959-1dc4-11ef-b4bb-af5377834399; Wed, 29 May 2024 16:07:44 +0200 (CEST) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52ab1d7243fso1309798e87.1 for ; Wed, 29 May 2024 07:07:44 -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 2adb3069b0e04-5297066b233sm1274418e87.135.2024.05.29.07.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 07:07:42 -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: d1ef8959-1dc4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716991664; x=1717596464; 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=FVt1ngxRLYD1k7hvosEvjumaiPvYRKgMOLSuMGarKcuTVZTzSxEeN8rKR1NUZl+mi5 /iZY4xs3MHZOQhUCXrXb+ESynSEjxvPHo/IimW7RSSo8lEJn+T67B8opXVMC4zSHYINu EsbpDLo4z7j+U0l8vKjOsPs2wCs5qNqIYHgItXZzTABZJeNT3hKDi87Sq7XSAW9QbA5j y57EHS3XiQl7ScWMWeaOpfllUYrprMgMrk+EUnw7QumZThyp6W/67ZX/8iu7IYZKovQD 6xDsH8XruihqB3mGeXuQYuQwoc0TteibaikDYPr2UIJWJd9iJYYIigHIUZwyCsUio5r6 f1GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716991664; x=1717596464; 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=XUZoH+llZJFkUagjVEvlOGJPCeA/RUVNzIJbcY5McfXT7XauDkXKKDuQvAeHe7CsjW YRx6QiXQRCfnM6R4T8kZEbIcUVTfIy6+eWrfWM85Z6Qiua57YsQAo0JwCyilC4ezrsQm N4q63+Y3eI3tdP9iu2mq4EOuvCziXn4TW7DtXrGnyG4Kx7kSDQxYdqQwsXV/gzE5I+C9 cqvRbdAzCyGp3e8SBtzD24TA0+v7pmj+rjWwtD5wdcQqYe3MgnrDh4RLjdfe0uHLXzxc KVia15B04xOxkPYQS1nmZC5D4g2j4r07cBk40ASrh1JajFxNyq69Cdr/GoeZUQTrqz6T 7Z8w== X-Forwarded-Encrypted: i=1; AJvYcCV36Yczd0UzPednRoF+T9lucLpAtnG62olT0Qh7cuRv9oHJlq/gz8QGKfofP1647k4Z2CXSjs0LzRRjn3DMx7Lvxz9gPQUTbA4Xm8P6vXs= X-Gm-Message-State: AOJu0YxexOGC/uzxYNQVEBTg5V1VqGN/QonnR6a4NxhaO23mDkwKKc8p SdrwWmzw/OKy2TrQhX1fmqRklb/TfgPHifz/Do1BNgBlxaDv/lYk X-Google-Smtp-Source: AGHT+IGdkBzBgEhHrd1LW9KAGa/cGv5sdiBTlj+GoDqEM5VjT/z9rWbfYzsj/AoEXZVsdTS9qD3Uag== X-Received: by 2002:a05:6512:3b12:b0:51d:2529:7c4d with SMTP id 2adb3069b0e04-52961a82092mr14632029e87.0.1716991663724; Wed, 29 May 2024 07:07:43 -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 v8 2/8] xen: mapcache: Unmap first entries in buckets Date: Wed, 29 May 2024 16:07:33 +0200 Message-Id: <20240529140739.1387692-3-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240529140739.1387692-1-edgar.iglesias@gmail.com> References: <20240529140739.1387692-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716991710961100001 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