From patchwork Mon May 6 12:37:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 795005 Delivered-To: patch@linaro.org Received: by 2002:adf:a453:0:b0:34e:ceec:bfcd with SMTP id e19csp901574wra; Mon, 6 May 2024 05:39:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWx0y5k4pI2Rm3RdwiX38/Lz8G/P4kjq4h3HpHA0YeWT9j5zQHq39IKlYgcmmFwpuLdUetnsrnmQK/GDc/LNi4V X-Google-Smtp-Source: AGHT+IFv2D49bccFPaqX/gjXlw/ly6Df8wAAAz9ClIlV7j+l6j1vyZCOicoUqsYpZ9XRZo/Qkv6s X-Received: by 2002:ad4:5aea:0:b0:6a0:cbe9:d73f with SMTP id c10-20020ad45aea000000b006a0cbe9d73fmr11973851qvh.19.1714999188493; Mon, 06 May 2024 05:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714999188; cv=none; d=google.com; s=arc-20160816; b=hY6GrJbrLthrvoToLf/FxyUIYh3rm+T/4XfZc13mJQ3+VnBequUQFJ4Yvu//+TeH5n CRsdCjjYmfjveJpodFRO5aJFLfWBIGZYjtHZ+F2UJqR9SUo0ePH0G5l9dnEGVvz//z4S epjUe8XMGxo3NN609kUWrPFhmfpCe+TNg7VINgU4hs+Vd0mQkwX/8TDoh6xkOHoUY3UM BUQN1UAcxounvUDb7iEYzj5IHtk9xDElLGMojnuMHyrUTNQKfjXmNUfTaMPwR4Cax+Ac lvQKfLTIRsdfZ9jziilrqhYcl36o6rtKlKsgsLLAIKBL6J+CnMWrXgJgxnBByE9Wk7dI L7kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vPkYetppSsjPcJRijyPbZW3TmA+wkAdtU1ccC5YsPog=; fh=r37zqqRgjl0vgMOE1d+sAKg5pRPdQEMjopPj8TtvHIU=; b=Tvn750yqGsSxMPep/kQMbkF/FSJ2modG6sMaSnkqXxbqy5XFNunr43/wp/re4WsTat OHWbyuQItZme6hEGT8fVYQCEzHfbBMXiaDmKRb9TPC5HlXUC0BjO6x6MyzuSnEMsRUID cL+KHAUG0nyHoF8V1mcVmorr42fhy9j1RGKAaHO6AZsnKeRlBPnJDhBfEOHW3pPK6Dvo qDI1oAhk1dow+PxZpyEcPQbIunuowODo/gjw3uea7MQ4eUeccwkHmNjeW6TyOcxBoA1L 3JhOTXfrtXD/rSETQx442P4Z0GdjHGzwX9ALtk3nGg0dHppq/fe2le+dWTel7Qtz3VLm iOmA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hf0bccvL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a8-20020a056214062800b006993d828d7fsi9089641qvx.259.2024.05.06.05.39.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 May 2024 05:39:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hf0bccvL; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3xd3-0005La-IN; Mon, 06 May 2024 08:39:37 -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 1s3xd0-000535-OG for qemu-devel@nongnu.org; Mon, 06 May 2024 08:39:35 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3xcy-0002BF-Lj for qemu-devel@nongnu.org; Mon, 06 May 2024 08:39:34 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-41ba1ba5592so12617735e9.1 for ; Mon, 06 May 2024 05:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714999171; x=1715603971; 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=vPkYetppSsjPcJRijyPbZW3TmA+wkAdtU1ccC5YsPog=; b=hf0bccvLPsJ3T279ELV5hRP8x7mJNaqgetWH4sWKJ3kiFIjq8zl5+LEZN6xiSL4OIm yqqg0CQ9dUDdzLOflj9mtJ2v+v8y/Nq0MEOJmH/I3gAWx0O1hG2LAQW2BGo03dp0Aq85 8KsGN2tN0XzaDCPkQQ984aoYx9bXIkeR973M41V7+WlzIUD6pmgfSTx4Rp2ziF7A+g8R BbY6B6r3D/vIjGvDV5W0a1ugO7Vdv9rdkhhpbtBRYssj3EQ3tvTeT8X0M7KtQvfYM+eV np+7equ/PqWRmdi4TCORQEV3J1QXYln/mR6XzS4OENmo5FOKEZg1Z0XQ6LgVj4HPetVu xntw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714999171; x=1715603971; 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=vPkYetppSsjPcJRijyPbZW3TmA+wkAdtU1ccC5YsPog=; b=BPoHyhZRJB5IStndVvoia/+qVZOhQfXVexyqT33xSzLh08eEFa2EM1OOdVCyzQF0BY KthQKxJMkyNVJBX9i6sigDU907PhGy7Sm1QiZ/QJJwpCpAUGfbL439UvCOZCyto7yuK0 aO8Cqf5x+I0d/2KVRzKZcC88tKqSaHS6xF1KbE9Ma5i089xZ/79yzg1qRegSPNYJ1sTw zgWeBI8dThxX+raBxXiqmlf1NqFYkfg5jwQxJ/W3nr0AVbeWf8KwyB1KigUM4Lwz1FvL yvarajInVj6dgiNr3aCg9zXP+QavyhUXmA9f3wFE3RyYYYLC4zWapsXLswCsYOSUhJpJ /V4w== X-Gm-Message-State: AOJu0YzYgODdqrzYXptT2gxtPnAVPdakFky2drdwFPrrcoxp1plqb9hC bvOryzIqChZdM22Lf80LeXNQaNNxFuD7P2ErJZkHs4CcFkBfNcf90qEV8/I20E/WKieTRl4anyb k X-Received: by 2002:a05:600c:4f02:b0:41b:d973:24c1 with SMTP id l2-20020a05600c4f0200b0041bd97324c1mr9426655wmq.12.1714999170931; Mon, 06 May 2024 05:39:30 -0700 (PDT) Received: from m1x-phil.lan ([176.187.211.4]) by smtp.gmail.com with ESMTPSA id bg5-20020a05600c3c8500b0041bbec72670sm16031875wmb.39.2024.05.06.05.39.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 May 2024 05:39:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Juergen Gross , Stefano Stabellini , "Edgar E . Iglesias" , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= Subject: [PULL 17/28] xen: let xen_ram_addr_from_mapcache() return -1 in case of not found entry Date: Mon, 6 May 2024 14:37:17 +0200 Message-ID: <20240506123728.65278-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240506123728.65278-1-philmd@linaro.org> References: <20240506123728.65278-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Juergen Gross Today xen_ram_addr_from_mapcache() will either abort() or return 0 in case it can't find a matching entry for a pointer value. Both cases are bad, so change that to return an invalid address instead. Signed-off-by: Juergen Gross Reviewed-by: Stefano Stabellini Message-Id: <20231005181629.4046-5-vikram.garhwal@amd.com> Signed-off-by: Edgar E. Iglesias Reviewed-by: Alex Bennée Reviewed-by: Edgar E. Iglesias Message-ID: <20240430164939.925307-3-edgar.iglesias@gmail.com> [PMD: Keep xen_ram_addr_from_mapcache_not_found trace event] Signed-off-by: Philippe Mathieu-Daudé --- hw/xen/xen-mapcache.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 7f59080ba7..7771c6cb91 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -395,12 +395,8 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) } if (!found) { trace_xen_ram_addr_from_mapcache_not_found(ptr); - QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { - trace_xen_ram_addr_from_mapcache_found(reventry->paddr_index, - reventry->vaddr_req); - } - abort(); - return 0; + mapcache_unlock(); + return RAM_ADDR_INVALID; } entry = &mapcache->entry[paddr_index % mapcache->nr_buckets]; @@ -409,7 +405,7 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) } if (!entry) { trace_xen_ram_addr_from_mapcache_not_in_cache(ptr); - raddr = 0; + raddr = RAM_ADDR_INVALID; } else { raddr = (reventry->paddr_index << MCACHE_BUCKET_SHIFT) + ((unsigned long) ptr - (unsigned long) entry->vaddr_base);