From nobody Sun Nov 24 20:23:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1720782194; cv=none; d=zohomail.com; s=zohoarc; b=bcm19br/8EeV0sW3Afjl+96e1/MJmSQ7j69yxOhvU2yQCNcq8qoPMYQy4aBBRIXG93NnjDnLHPq5/61CrD/yNZcqojVt+1omj1h1ouQ9x2b5Olr0gtMxG5Kyc6w4kbrUIGeGhDVkRko4qqjuDGAOSneNty3MtD4nibjzHtChRgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1720782194; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=87DPAAbyBmLAKm4ynt726DGnnWSE+Fbpy4sTffFQKUw=; b=YUhJRuXjx/j0Mpp7uy9ri0IXtH7XiZ+3RqWZWZKz9mvlHO2c/ESJai0dukuuM4fQYK0hPZUoUFH/PAQxUztuaGCeM9vWOxcQ+YPo66NyV+b0OYF/q/Aggy2RAktwn/lXPpqWDrwkqPgoybrx1E0Z/+eMFd43MbK2f2OvqMfzKu4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1720782194154415.2723695015085; Fri, 12 Jul 2024 04:03:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sSE36-0000NK-FB; Fri, 12 Jul 2024 07:02:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sSE31-00007v-Vm for qemu-devel@nongnu.org; Fri, 12 Jul 2024 07:02:44 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sSE2z-0003b2-AB for qemu-devel@nongnu.org; Fri, 12 Jul 2024 07:02:43 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52e99060b41so1982023e87.2 for ; Fri, 12 Jul 2024 04:02:40 -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-52eb9077a9asm1235370e87.297.2024.07.12.04.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jul 2024 04:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720782159; x=1721386959; darn=nongnu.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=87DPAAbyBmLAKm4ynt726DGnnWSE+Fbpy4sTffFQKUw=; b=HqEhfnTAquJF3CqI5KBIEdJRWEv7wLgZI2pP2jfoIoef9AcQTyTxNExmzjjBYCFExM JyJbovX09wdxbtlswPaWm8ulSqh3Q2LsahaJs0AzS3WvLlId+7cbLY0xoG6eL+u1uQxw B5k9gvjLDP+s1bW8vgbdBTtOEkuPqPpGKAtMwtwJ6ozqpUmHhjAwt+ntXeI5lfzk3FQz ALO5ALH18FnqDMouWUgXO0kaWM6ORN0WszgeAF6Mxnx8ZaQMB+dS1evEoRjYXtBBsX6Y wjI/DLB4ypSuo1E0h+6GzNmFqyfPwPsNAxFHI13sD7hC0ZmgUaYXJgnE1BqkTPPHMiYA OdqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720782159; x=1721386959; 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=87DPAAbyBmLAKm4ynt726DGnnWSE+Fbpy4sTffFQKUw=; b=vJuK7y9kZgjVQrTBaLq19BRj+7M9U/vISMTHbGGHkJctlyPR54AwIW/Ba6p+lTMCKf wajkQgZNbqQ/RRy/F6mStVEo96Ec7t28YC0cw0Q5kjYgPm3pzLz6YoqpXIw9SXYDyZcV 909aXlGOFw5h01lGBXOXegtQCWAw50oS6P6n5uZRyUBMd0G2qvRh+sN+9C63EIRu1e0W 470rG7aASRI45IJpd3TRqMEBnU972qmKssqua63vOjufpJtkP7bpMoNI+wA0iAR5uwmM Ub9ZZ0tB7vvOtk+INHHcJua8VQNsVz9aVutT0BvDPvq1HFOdbMwZMQ2SphYDIIuedMNE EIkQ== X-Gm-Message-State: AOJu0Yybw6MIWYMy/ZwQ8uiDeYlzPQSNHSwpL95aCMvhnFpcVnF5M5SP ytgrFFG9fs9a3PggOxIyZQEs3lzZ6oXna2eEkrS3g2HfG0gyepmn08kqfCm4 X-Google-Smtp-Source: AGHT+IHoNb9jo3zc5r2b5ZN1+E6PEQXJq2jaR175xDg5jGcIkz9qmG3zee/NjIb1VzoUbFJp/vxmXw== X-Received: by 2002:ac2:5f99:0:b0:52c:86de:cb61 with SMTP id 2adb3069b0e04-52eb9990fedmr6120031e87.10.1720782158364; Fri, 12 Jul 2024 04:02:38 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Cc: sstabellini@kernel.org, anthony@xenproject.org, paul@xen.org, alex.bennee@linaro.org, peter.maydell@linaro.org, richard.henderson@linaro.org, edgar.iglesias@amd.com, Anthony PERARD , "Edgar E. Iglesias" , xen-devel@lists.xenproject.org Subject: [PULL v1 3/3] xen: mapcache: Fix unmapping of first entries in buckets Date: Fri, 12 Jul 2024 13:02:30 +0200 Message-ID: <20240712110230.4098056-4-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712110230.4098056-1-edgar.iglesias@gmail.com> References: <20240712110230.4098056-1-edgar.iglesias@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=edgar.iglesias@gmail.com; helo=mail-lf1-x12f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1720782195277116600 Content-Type: text/plain; charset="utf-8" From: "Edgar E. Iglesias" This fixes the clobbering of the entry->next pointer when unmapping the first entry in a bucket of a mapcache. Fixes: 123acd816d ("xen: mapcache: Unmap first entries in buckets") Reported-by: Anthony PERARD Signed-off-by: Edgar E. Iglesias Reviewed-by: Anthony PERARD Reviewed-by: Stefano Stabellini --- hw/xen/xen-mapcache.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 5f23b0adbe..18ba7b1d8f 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -597,7 +597,17 @@ static void xen_invalidate_map_cache_entry_unlocked(Ma= pCache *mc, pentry->next =3D entry->next; g_free(entry); } else { - memset(entry, 0, sizeof *entry); + /* + * Invalidate mapping but keep entry->next pointing to the rest + * of the list. + * + * Note that lock is already zero here, otherwise we don't unmap. + */ + entry->paddr_index =3D 0; + entry->vaddr_base =3D NULL; + entry->valid_mapping =3D NULL; + entry->flags =3D 0; + entry->size =3D 0; } } =20 --=20 2.43.0