[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[QEMU][PATCHv2 5/8] xen: let xen_ram_addr_from_mapcache() return -1 in case of not found entry


  • To: <qemu-devel@xxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Wed, 25 Oct 2023 14:24:18 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mET7kcl9UXXPRp5J6MoXxeoteODqvxROwm3Ecdt2YHM=; b=L54Gsgu9lvYQuOOiRH3Lnd4vuIckJkm63+8Wh8ADL0G84BGqZ+iPu5V9ymyC/QOWjiTpjoEdKG4FacfqYa37ox8EvzDLsVXGCXXtnQZdX9DaDQNKC9ct3o8IZ9k9jphKQBzx8HKzii9rXx9I5G++5gQDDfwKvOADQ3G9ICCIrqmppfP72j1GxAbbmMcuQd+sGhcFxVbQZ11nL86fZ3MNWK+4mh+RGX/Ts5w3ItBCmYycEdhMflVHNxGtVeRViz9u9bFg0xGaQJx4UfhUWfvGw8tLzzvjI8QYMg08FJmog347VQMdnlz2xwmghwGd7ZbXtQSLv1Y4w2S7MeRCq93IKw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HUzVRk8IJpwny3AyZpJiV+E7xu124CDPe2cFG54n9/stCYaP+u5UdG1JBC7hKDjKIj/8LYQaZu3ungmZ5kX3V6XYtCK6x3IsViZwiAk8N9eFOA6wPoC1UzFD4Kr5UIX5wdBo6Ku8AQn7XB8dtTXYnwK4XG2YyE1JYme/8s/Zzuena5mHVqh/tNxRVPiArenrrD2649ErILgcUbPEwrQ1M9U05XOp9rU8/e22VJDS5yNoIf0gFCoGFNmQQEOybv4CuBtBOvLPw6QUHaio0umcAGD7mX/ZzidxmFisr9hscrKTK3A55xNz1Q8UMYUx45/dBrWDm35ZZGS9GuxRM33kjw==
  • Cc: <sstabellini@xxxxxxxxxx>, <vikram.garhwal@xxxxxxx>, <jgross@xxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, "open list:X86 Xen CPUs" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 25 Oct 2023 21:24:52 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Juergen Gross <jgross@xxxxxxxx>

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 <jgross@xxxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 hw/xen/xen-mapcache.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c
index 8115c44c00..8a61c7dde6 100644
--- a/hw/xen/xen-mapcache.c
+++ b/hw/xen/xen-mapcache.c
@@ -404,13 +404,8 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
         }
     }
     if (!found) {
-        fprintf(stderr, "%s, could not find %p\n", __func__, ptr);
-        QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
-            DPRINTF("   "HWADDR_FMT_plx" -> %p is present\n", 
reventry->paddr_index,
-                    reventry->vaddr_req);
-        }
-        abort();
-        return 0;
+        mapcache_unlock();
+        return RAM_ADDR_INVALID;
     }
 
     entry = &mapcache->entry[paddr_index % mapcache->nr_buckets];
@@ -418,8 +413,7 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
         entry = entry->next;
     }
     if (!entry) {
-        DPRINTF("Trying to find address %p that is not in the mapcache!\n", 
ptr);
-        raddr = 0;
+        raddr = RAM_ADDR_INVALID;
     } else {
         raddr = (reventry->paddr_index << MCACHE_BUCKET_SHIFT) +
              ((unsigned long) ptr - (unsigned long) entry->vaddr_base);
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.