From nobody Mon Nov 25 05:27:05 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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1718227859; cv=pass; d=zohomail.com; s=zohoarc; b=Hfri74H6vxPe3jS0Lb8CT90IEmmvxkXLcw/xPQbjdONmQMiBLGigfb01XaReUGT/IYLKB82xaz2OIu35oeQiBAFthughoTwdJRQg3FchjseSUB9REgowCqTcUWRhpoOOmtKECU+GgcDv9DayMZ/s1DElGyetq5XC2fDQo7B90kE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718227859; h=Content-Type: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=2mJ+jql/EDqUybJTnjb/85JYlMFA6jZ7hOjOjsOzvs8=; b=QDJ1lHXMNkja/0E7oo8u2K7D8SfF0+CbntVMrXnvZ+2ZZ6PFtThMOpQk4Pxcb5/4aOws0tcJzXpssGNStOUYXbgDe+JY4zCDTh9XKJwRqq+ecSODe2rpmn2aEDZah2JAdJ/qHxWSQO5I/YjU7BK1r1KOmF9+ad/pLr58c7B+rE4= ARC-Authentication-Results: i=2; 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; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718227859442674.1617106125128; Wed, 12 Jun 2024 14:30:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHVXv-0001aY-BW; Wed, 12 Jun 2024 17:30:19 -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 1sHVXr-0001Tv-RM for qemu-devel@nongnu.org; Wed, 12 Jun 2024 17:30:17 -0400 Received: from mail-bn8nam12on20621.outbound.protection.outlook.com ([2a01:111:f403:2418::621] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sHVXp-0002oN-3Q for qemu-devel@nongnu.org; Wed, 12 Jun 2024 17:30:15 -0400 Received: from DM6PR21CA0014.namprd21.prod.outlook.com (2603:10b6:5:174::24) by CH3PR12MB7499.namprd12.prod.outlook.com (2603:10b6:610:142::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20; Wed, 12 Jun 2024 21:30:01 +0000 Received: from DS1PEPF00017095.namprd03.prod.outlook.com (2603:10b6:5:174:cafe::41) by DM6PR21CA0014.outlook.office365.com (2603:10b6:5:174::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.17 via Frontend Transport; Wed, 12 Jun 2024 21:30:01 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017095.mail.protection.outlook.com (10.167.17.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Wed, 12 Jun 2024 21:30:01 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 12 Jun 2024 16:29:59 -0500 Received: from smtp.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Wed, 12 Jun 2024 16:29:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X5JVm2Q4fbxL61dIGUq0HECnSoZEdAc/dt+zPqPgWWjrHjUeDHfT5jaik0xHslOPF5er5uoScMG7r2d1bEdUH5z6xJsk89KOYwz7gZlMGVWlsDyAR4VYUqpZHrhuzxZ9JDaHL7ngkeOKWgnoFup1O4EXOANb7+/q0xjcMyANtoXL0f91qP6UtmyCrqsz3LOfcpYnPcjLSaG0VFFzt3/23IS0zm59/Y7MOO4cWfPpaq/g4OZ5XuGy51ZUlaePhX35JBOH4GIWdFRlWy9c8QrHvCi8kOf4EvSpwBke9q7H0wvV816GYHz3ACj8xR707JJfVMRf214K55jNV1BlMXM7qA== 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=2mJ+jql/EDqUybJTnjb/85JYlMFA6jZ7hOjOjsOzvs8=; b=Sscn61tOa1TTOltVUnQxFjdcwo7s8q6kZLbdqmXTeaoarqL6OHxt/5LpbIfvjMKyv5/8RqtCC9IrJJOW9z0jvFa63t4vNFv6f6PpWb6RvA8U4/Hv8nvXbWi7aK9ZxO4qL19FRWPhLtfkFtpGEknZxyL4Ts1SPce4FPQ/1mRl0pqTTYIRAYS69nlMykkJayNDbr+hsVZvk0r1XzvqlMT10WbSofeYbqq7oaHBXA8dD04UbNs96CS2ZM8AeEtIhZQ/NK170vu70uBL3Q9MkDFfgsnqrnJtsB6Z7mlLYykMIBTqE7SHBUy4qYbmGY7fmfQxu58qzEShnj10wzTdkF9n4A== 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 (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2mJ+jql/EDqUybJTnjb/85JYlMFA6jZ7hOjOjsOzvs8=; b=pNdYgATeHKFi1Yp8QqDLXMoq11IB1seHvah7purc7hUJW0N6VY+AMv06bSGY6UtpXGwxUfhUJXLdfVnjTfzqXkQHdj2sZNAmW1AU66j0lYYBjl4TTBX21jW44bFMIGTsgOFOb6BMZu2u4bKKYm9WRZ5zh+NyKghD8A5QsYXpW8E= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; 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 (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C From: Stefano Stabellini To: CC: , , , , "Edgar E. Iglesias" , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 3/5] xen: mapcache: Pass the ram_addr offset to xen_map_cache() Date: Wed, 12 Jun 2024 16:29:38 -0500 Message-ID: <20240612212940.2178248-3-stefano.stabellini@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: None (SATLEXMB04.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017095:EE_|CH3PR12MB7499:EE_ X-MS-Office365-Filtering-Correlation-Id: 945c847c-f031-464d-f621-08dc8b26d143 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230034|376008|1800799018|82310400020|36860700007; X-Microsoft-Antispam-Message-Info: =?utf-8?B?b0lYSjB2VHV6N0xEZ3EwcDVZUHV4b1BHVFFRQlBXTTdBeVBycHE4RUhhZExh?= =?utf-8?B?MUw1N2N3MWF4TjRXdm0yRmc2U1pueWQ3aFZKbVRHWkZnY0VSb3luVjg1RjNY?= =?utf-8?B?bHVVeThpelBha1dWU090eWIxdkRDanVIRFVzNzFiQTdTUzROcjN3aGdUYUNm?= =?utf-8?B?cWVhTE9OU0Q5M1R0MVNtdlBZQWx5aDd4RVY2Vjh5cGlpNDBhNU1tRjhYQzQ1?= =?utf-8?B?ODBnc3NKanljZU5vbFBCcXJkYWdHRTNFVEVlbEUySER4VkNDN0p4VVJqc0xo?= =?utf-8?B?dmN1WWx3Y0RLblhBN2g2OTRnN1NrUElvT3gvQlZ4czZGbmVZRmlrTTF0eTFN?= =?utf-8?B?aEFmSzBUVTBXQmxrK3A0dEhaRjh5eXdkQy8zbzczWjVuU1FyY3B0dUU1LzRT?= =?utf-8?B?SHlxbm84U0VlR1JGd3pleVFBdFhmL24zSytobVRrejR5QXEwbkIxMzdTVHRv?= =?utf-8?B?OVhZcEVpeGUrR3drbkloM1lYdDhVQ2RyWGtkQzRkTURYSzNuN3U4bVRRQ1pt?= =?utf-8?B?OG42eTBkWUdBc0c1b29RTEpITFk3UTBSd04rNnYxQX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BlTWFwME5zK1o5dk5RbG44NkFHcEJ4ZTlLU0ZJcndNdEd2S3E2?= =?utf-8?B?MThhTllYREk3N2pTcEZyMXlQWlNMaDlqRi9iaHYvQzVidkNVZlF4SFVFbmpv?= =?utf-8?B?OTNVQ1RnbzdpZENFeklMZTdXWDNGdkhjMCtZUVNXRklkMjdRRHJoaEM5TTFp?= =?utf-8?B?M0Y1b09kNmdlbEVVcnhJN0dFNTYrMkRVd1V6MVFKVHFDY3c2eDZXNXBUQlNL?= =?utf-8?B?ZUVUa0N1YWVneE8wT0orazVxdmdCUGxJMzYrK2xYQmNnSXhmOXIwMnRFbTk4?= =?utf-8?B?Yk5TdHo0c2JGbjUycStpdkdnUnBPMWY0ZmRHa2tUWkVnSFBORTlUS0hEY0ph?= =?utf-8?B?bXBYdHc5YURlRU5rL1hUWW4wcFBCMTBpY29LVmlvU2I4dFBsWk44ak51WUpr?= =?utf-8?B?SkhjTjVabHNlaVV3dmt4TlZGeVRRcXQ1dGpWTE1IRmJWWkE9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230034)(376008)(1800799018)(82310400020)(36860700007); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2024 21:30:01.2709 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 945c847c-f031-464d-f621-08dc8b26d143 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017095.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7499 Received-SPF: permerror client-ip=2a01:111:f403:2418::621; envelope-from=stefano.stabellini@amd.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.143, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @amd.com) X-ZM-MESSAGEID: 1718227861439100003 From: "Edgar E. Iglesias" Pass the ram_addr offset to xen_map_cache. This is in preparation for adding grant mappings that need to compute the address within the RAMBlock. No functional changes. Signed-off-by: Edgar E. Iglesias Reviewed-by: David Hildenbrand Reviewed-by: Stefano Stabellini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/xen/xen-mapcache.c | 16 +++++++++++----- include/sysemu/xen-mapcache.h | 2 ++ system/physmem.c | 9 +++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index ec95445696..a07c47b0b1 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -167,7 +167,8 @@ static void xen_remap_bucket(MapCache *mc, void *vaddr, hwaddr size, hwaddr address_index, - bool dummy) + bool dummy, + ram_addr_t ram_offset) { uint8_t *vaddr_base; xen_pfn_t *pfns; @@ -266,6 +267,7 @@ static void xen_remap_bucket(MapCache *mc, =20 static uint8_t *xen_map_cache_unlocked(MapCache *mc, hwaddr phys_addr, hwaddr size, + ram_addr_t ram_offset, uint8_t lock, bool dma, bool is_wri= te) { MapCacheEntry *entry, *pentry =3D NULL, @@ -337,14 +339,16 @@ tryagain: if (!entry) { entry =3D g_new0(MapCacheEntry, 1); pentry->next =3D entry; - xen_remap_bucket(mc, entry, NULL, cache_size, address_index, dummy= ); + xen_remap_bucket(mc, entry, NULL, cache_size, address_index, dummy, + ram_offset); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index !=3D address_index || entry->size !=3D cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { - xen_remap_bucket(mc, entry, NULL, cache_size, address_index, d= ummy); + xen_remap_bucket(mc, entry, NULL, cache_size, address_index, d= ummy, + ram_offset); } } =20 @@ -391,13 +395,15 @@ tryagain: =20 uint8_t *xen_map_cache(MemoryRegion *mr, hwaddr phys_addr, hwaddr size, + ram_addr_t ram_addr_offset, uint8_t lock, bool dma, bool is_write) { uint8_t *p; =20 mapcache_lock(mapcache); - p =3D xen_map_cache_unlocked(mapcache, phys_addr, size, lock, dma, is_= write); + p =3D xen_map_cache_unlocked(mapcache, phys_addr, size, ram_addr_offse= t, + lock, dma, is_write); mapcache_unlock(mapcache); return p; } @@ -632,7 +638,7 @@ static uint8_t *xen_replace_cache_entry_unlocked(MapCac= he *mc, trace_xen_replace_cache_entry_dummy(old_phys_addr, new_phys_addr); =20 xen_remap_bucket(mc, entry, entry->vaddr_base, - cache_size, address_index, false); + cache_size, address_index, false, old_phys_addr); if (!test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { diff --git a/include/sysemu/xen-mapcache.h b/include/sysemu/xen-mapcache.h index 1ec9e66752..b5e3ea1bc0 100644 --- a/include/sysemu/xen-mapcache.h +++ b/include/sysemu/xen-mapcache.h @@ -19,6 +19,7 @@ typedef hwaddr (*phys_offset_to_gaddr_t)(hwaddr phys_offs= et, void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque); uint8_t *xen_map_cache(MemoryRegion *mr, hwaddr phys_addr, hwaddr size, + ram_addr_t ram_addr_offset, uint8_t lock, bool dma, bool is_write); ram_addr_t xen_ram_addr_from_mapcache(void *ptr); @@ -37,6 +38,7 @@ static inline void xen_map_cache_init(phys_offset_to_gadd= r_t f, static inline uint8_t *xen_map_cache(MemoryRegion *mr, hwaddr phys_addr, hwaddr size, + ram_addr_t ram_addr_offset, uint8_t lock, bool dma, bool is_write) diff --git a/system/physmem.c b/system/physmem.c index b7847db1a2..33d09f7571 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2231,13 +2231,14 @@ static void *qemu_ram_ptr_length(RAMBlock *block, r= am_addr_t addr, */ if (xen_mr_is_memory(block->mr)) { return xen_map_cache(block->mr, block->offset + addr, - len, lock, lock, - is_write); + len, block->offset, + lock, lock, is_write); } =20 block->host =3D xen_map_cache(block->mr, block->offset, - block->max_length, 1, - lock, is_write); + block->max_length, + block->offset, + 1, lock, is_write); } =20 return ramblock_ptr(block, addr); --=20 2.25.1