From nobody Mon Nov 25 05:20:02 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=1718228109; cv=pass; d=zohomail.com; s=zohoarc; b=lp81qoRUChT+IkMy052vF5Zz/V2AwM9TV9/R5eSJBRoyf3n9mYBWat6tZfJe9lhVLeWJYNNVgBzV9++CrRh9l67rXIMlrIGhRsrP6E02FzyPKLNy1ydJ1G/rcaaRb6bbQ0FQ75B3WWC/N3jcNEI1gQt4hLwXNQwxKYPljANOI3Q= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718228109; 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=jO4UHVrqZMP3djoXDVI4YZ6oy2MK9x1fZiqbu8aBG/Y=; b=bPLGXMSwKxC7WmG798YBpEuKYDuKiWtuUzDxmtucGRHai9YSxnUm69quqgfiVxdrOzM1tjtqcBac0iqeIcml+SIBScvL6N1EUSvEGisj7DOUC9N8HHlnOnElCuXr7drQ3akIcQ6FYT2xTU7sM8ZYWJ7fAR/457Zeu/OfLapAHsU= 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 1718228109895302.9952683110712; Wed, 12 Jun 2024 14:35:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sHVcQ-0006ge-3b; Wed, 12 Jun 2024 17:34:58 -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 1sHVcO-0006gS-LA for qemu-devel@nongnu.org; Wed, 12 Jun 2024 17:34:56 -0400 Received: from mail-mw2nam10on2071.outbound.protection.outlook.com ([40.107.94.71] helo=NAM10-MW2-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 1sHVcM-0003oF-Hh for qemu-devel@nongnu.org; Wed, 12 Jun 2024 17:34:56 -0400 Received: from SJ0PR03CA0187.namprd03.prod.outlook.com (2603:10b6:a03:2ef::12) by DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Wed, 12 Jun 2024 21:29:49 +0000 Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:a03:2ef:cafe::6b) by SJ0PR03CA0187.outlook.office365.com (2603:10b6:a03:2ef::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.20 via Frontend Transport; Wed, 12 Jun 2024 21:29:49 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) 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:29:48 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) 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:47 -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:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c/fgsgFE8JBsc9yQZGX59NotLq0hADlBIVKD0IJrKDvoxGg8K8x7Mn+3M3+73VuJqkyY4fgvlo+RQUxdF+2CzcQNlow+oHXxhFO2ZxMYwVyKfczVqFsjubBkfMULF3rQ6tZIX0IwQPC+VluvzV3mlHOOWQHxqkbAf3L77iC29GrFR2Yf55zdM/2IC6s+mJaHjwoNWjE73ySxAeFI/pJ/HCIb8rar5gMzyPuFMzWvR4NSRkvi8C20w3trBBY3nftQ/wObqm2LPi2nY+gumo3NE7nhKu9jfMdKi0CqiscUNwjfnJfCj2l/wcaZTFfJRkobHNn13GnH0z6bhPvzN3KPTA== 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=jO4UHVrqZMP3djoXDVI4YZ6oy2MK9x1fZiqbu8aBG/Y=; b=W2rAZHEqYIgDJgCYFjBzfCBgoXQvUcxDiTtnOcM6lhgIXsJBTmJEf8hyBMW7MK2IWtJ+OLcdJFt3nlcOrD5H/URAI7zeaKZLDaCiemCMjaclXUHvqnv5nf7wyMoN0uxg1gO3WfAGIqMPXT1NkKJq2eAfvuGd/DSuw5vHAH+GVK63jLJofG78dWeUFqYjObZSVNRNzDJczaZBv8zLcFh94KybL5WCXyle17MjR9zoploKBjguztwyBMY4KSpImYCeNSjIUknZwNySWzbfKdZImrTXisMktXu1o9KTtwDTTR8Pmddzt8M2jdLxWl0Wafmq+mQuWL3I5dirdjl17TwYyg== 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=jO4UHVrqZMP3djoXDVI4YZ6oy2MK9x1fZiqbu8aBG/Y=; b=hoX5PMgVYcAkjC3mjUipzJ1t/mQkY108f2zFYO+lSvetnHUCP1eX+e8bJQEmQcKhtZPDHoHBlcgL/pje2ITfcVaN609K/7m0o4Bl1yBqX2VUnN40pUq3jtLZNGIP84Tlgu4aIhjt2/Dc5LuYinR+Dtug9zwNyFiDKG8qYuBEfjk= 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=SATLEXMB03.amd.com; pr=C From: Stefano Stabellini To: CC: , , , , "Edgar E. Iglesias" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 1/5] xen: mapcache: Make MCACHE_BUCKET_SHIFT runtime configurable Date: Wed, 12 Jun 2024 16:29:36 -0500 Message-ID: <20240612212940.2178248-1-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 (SATLEXMB03.amd.com: stefano.stabellini@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ5PEPF000001CC:EE_|DS0PR12MB7726:EE_ X-MS-Office365-Filtering-Correlation-Id: 7ecc0ff9-e20b-44a1-1ee2-08dc8b26c9d4 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?azJtOE1MNEl2enU0MDFjdjdWOEJRSWpOYzd5T29IUnRTRTIraDNKVTl6U2ZL?= =?utf-8?B?dDE3d2RHNFBHK0RuOEVCRHlCUytwQXZucFpvVm96NVMyMVRtaHloT3MzM2pJ?= =?utf-8?B?bjJQbCtBMWQ4RFQwK25yV1M0amJnYnkzSkFlWnJJb1lUSVZOeThLZW92dzEv?= =?utf-8?B?amtsUFozTk41NGdTWVV1WjZtdGw4aUY0elpmY3lQdVlsQnBKUThTYVVXS3BC?= =?utf-8?B?U0ZYMXkzaGIwTXIxWStPTDRIZnl2aWN4bUFrMStwTjlPV0F2NDlXQ2tRYUQv?= =?utf-8?B?VkFRRE9TVnk3aXRtd2NqeFV3Z0h4eXRXbzFheHlNQkI3ZUpwTU9lK0dUV242?= =?utf-8?B?dW9kSm9tMmIzVHNlSExkWndvMm4xMGRDTWZXZkVneTU5MURLU01sUEkwZTNS?= =?utf-8?B?REorS2VIaXVMNlJQRURnNno2QnkwSjNsWXBQdngxN0JVWndEcTU2bktmRXJP?= =?utf-8?B?QzcvZ2N6cjEzTk9ZYS9ja0drdTRQMEZKb3J5L2ZDNm8yRlAvZXBJeWZqblB4?= =?utf-8?B?Z29yUzZqRGZxM0FLUk9MRXJBaHhTNzFwcmcyUVlZVnpQZXhIR3dUNkErb2Np?= =?utf-8?B?d2Y3NzJKVjZkcHJoa21oaEUrTjdTeHlkeG9ISXBkUGVYUlcvQ0lwY2N1YjJp?= =?utf-8?B?NENFa01CRlptZFFRN3BDdnVTbXU0UERjTG5SVXJuRlZMSkluMVhUbkJNRnNU?= =?utf-8?B?WlNaZDBaMytuR1F6VHhoUHlLSWU5Qlk2RnU5cm42N1N1U0Q2eCtkOHdsamNs?= =?utf-8?B?aWdUS0t0TG0rQ0lnUHYvL2FDZk5zQ0VXVGcxN0ZWeVVPRlhrSXYxNnpuNW1m?= =?utf-8?B?NnRHb0plM0YyUzRtRVlYTEpRenRpYjNsTXdPQ1NYdjFJZVF4dmd6OEZHNmx1?= =?utf-8?B?aDFsY1p1b2prRVErRmhwNU1mY0lDYTkzT01xOVZkTzZDK3NUNHk4WlRDTCt4?= =?utf-8?B?cEs1TVpNY3lIMTJscE1pM1l5bVMvd3lOaitscFpqdm54UExJQzJDRHc1Q3BN?= =?utf-8?B?ZkZZQks0L0VlSENrU2owazBKclVDc2hQb0lickFHU0hSSGVaNXZ5NmpEQTJi?= =?utf-8?B?TWsyaUtGNHdKRFI1aWxnYUtYUEJXNVBiYXBhNUtxTnB6TkdaRnNTcUxPVzZC?= =?utf-8?B?VEhBd3JMdzROR0JnMEo3OWdBYnRCZ1g3bkM1N2lpSmdXdEZTZ3doSGRSc2dx?= =?utf-8?B?S2pvYTRQcUVSTC8rME1IMlp6RUlzWXROVkYydE5YWmMrN1ZEZVQwdzIwZU12?= =?utf-8?B?c2tReGlOb2xtL0Rvc3JHd2FyaHR3SmNJL1NFZFBmdjQ2MXhISW0vRmV0ekx6?= =?utf-8?B?MlVjWjRySEc1M0gzeVhhei9FbElDdERMamN5TklSZEs5dnN4b0h0aHpXZTJB?= =?utf-8?B?UFY5MXRiVjRFdUVENjVHb0NhZFlESUxrcFg2b2oybk5zVitFSGRsRG5VRFh5?= =?utf-8?B?K3RjK2dmeTNrWWZNTEswcXo2TEFUN3R1QVc2QitqK09TbENUZ2dJRUdJYW9E?= =?utf-8?B?R1VHYWEvVCtDK2JBdmJYZjZhQVk4YWY2c2lUaDJZWTFxUnFHTHdnUlFXMFB3?= =?utf-8?B?QTdnRjRRUlRKRzc4RDAzcmJYWThzRkFlenNoTlRiNk10ZldWVGhNcEF6d0J3?= =?utf-8?B?TFV3OENpVW8vZVpLNmVFRlpya08xWVM3dXZIRVZ1dmViVjlJYmhXT3FEMWEv?= =?utf-8?B?SGJFLzdaTG9BUloxdXVHeEpkTldsSi9wU2k2bDZoNmxWVjdHN0RpOHVxZFMr?= =?utf-8?B?RlBlOGRLU0U2am01ZVQ1MTNOTFE1Y1ZJYkN6cUErYzJLUWVWbGQ3K24xcmh0?= =?utf-8?B?TFEvSHZySS81b3JBeG5jVmNRVERvem1iTkJZRjl0aCtWcElJREVtZ0FPbU8r?= =?utf-8?B?Qmx1U2IvZURNRG16MXkrVzFZbmxHT2tiS0wweFBMTEJwR0E9PQ==?= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.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:29:48.7470 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ecc0ff9-e20b-44a1-1ee2-08dc8b26c9d4 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7726 Received-SPF: permerror client-ip=40.107.94.71; envelope-from=stefano.stabellini@amd.com; helo=NAM10-MW2-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, RCVD_IN_MSPIKE_H2=-0.001, 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: 1718228110629100001 From: "Edgar E. Iglesias" Make MCACHE_BUCKET_SHIFT runtime configurable per cache instance. Signed-off-by: Edgar E. Iglesias Reviewed-by: Stefano Stabellini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/xen/xen-mapcache.c | 54 ++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index fa6813b1ad..bc860f4373 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -23,13 +23,10 @@ =20 =20 #if HOST_LONG_BITS =3D=3D 32 -# define MCACHE_BUCKET_SHIFT 16 # define MCACHE_MAX_SIZE (1UL<<31) /* 2GB Cap */ #else -# define MCACHE_BUCKET_SHIFT 20 # define MCACHE_MAX_SIZE (1UL<<35) /* 32GB Cap */ #endif -#define MCACHE_BUCKET_SIZE (1UL << MCACHE_BUCKET_SHIFT) =20 /* This is the size of the virtual address space reserve to QEMU that will= not * be use by MapCache. @@ -65,7 +62,8 @@ typedef struct MapCache { /* For most cases (>99.9%), the page address is the same. */ MapCacheEntry *last_entry; unsigned long max_mcache_size; - unsigned int mcache_bucket_shift; + unsigned int bucket_shift; + unsigned long bucket_size; =20 phys_offset_to_gaddr_t phys_offset_to_gaddr; QemuMutex lock; @@ -95,11 +93,14 @@ static inline int test_bits(int nr, int size, const uns= igned long *addr) =20 static MapCache *xen_map_cache_init_single(phys_offset_to_gaddr_t f, void *opaque, + unsigned int bucket_shift, unsigned long max_size) { unsigned long size; MapCache *mc; =20 + assert(bucket_shift >=3D XC_PAGE_SHIFT); + mc =3D g_new0(MapCache, 1); =20 mc->phys_offset_to_gaddr =3D f; @@ -108,12 +109,14 @@ static MapCache *xen_map_cache_init_single(phys_offse= t_to_gaddr_t f, =20 QTAILQ_INIT(&mc->locked_entries); =20 + mc->bucket_shift =3D bucket_shift; + mc->bucket_size =3D 1UL << bucket_shift; mc->max_mcache_size =3D max_size; =20 mc->nr_buckets =3D (((mc->max_mcache_size >> XC_PAGE_SHIFT) + - (1UL << (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)) - 1) >> - (MCACHE_BUCKET_SHIFT - XC_PAGE_SHIFT)); + (1UL << (bucket_shift - XC_PAGE_SHIFT)) - 1) >> + (bucket_shift - XC_PAGE_SHIFT)); =20 size =3D mc->nr_buckets * sizeof(MapCacheEntry); size =3D (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1); @@ -126,6 +129,13 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void= *opaque) { struct rlimit rlimit_as; unsigned long max_mcache_size; + unsigned int bucket_shift; + + if (HOST_LONG_BITS =3D=3D 32) { + bucket_shift =3D 16; + } else { + bucket_shift =3D 20; + } =20 if (geteuid() =3D=3D 0) { rlimit_as.rlim_cur =3D RLIM_INFINITY; @@ -146,7 +156,9 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void = *opaque) } } =20 - mapcache =3D xen_map_cache_init_single(f, opaque, max_mcache_size); + mapcache =3D xen_map_cache_init_single(f, opaque, + bucket_shift, + max_mcache_size); setrlimit(RLIMIT_AS, &rlimit_as); } =20 @@ -195,7 +207,7 @@ static void xen_remap_bucket(MapCache *mc, entry->valid_mapping =3D NULL; =20 for (i =3D 0; i < nb_pfn; i++) { - pfns[i] =3D (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT))= + i; + pfns[i] =3D (address_index << (mc->bucket_shift - XC_PAGE_SHIFT)) = + i; } =20 /* @@ -266,8 +278,8 @@ static uint8_t *xen_map_cache_unlocked(MapCache *mc, bool dummy =3D false; =20 tryagain: - address_index =3D phys_addr >> MCACHE_BUCKET_SHIFT; - address_offset =3D phys_addr & (MCACHE_BUCKET_SIZE - 1); + address_index =3D phys_addr >> mc->bucket_shift; + address_offset =3D phys_addr & (mc->bucket_size - 1); =20 trace_xen_map_cache(phys_addr); =20 @@ -294,14 +306,14 @@ tryagain: return mc->last_entry->vaddr_base + address_offset; } =20 - /* size is always a multiple of MCACHE_BUCKET_SIZE */ + /* size is always a multiple of mc->bucket_size */ if (size) { cache_size =3D size + address_offset; - if (cache_size % MCACHE_BUCKET_SIZE) { - cache_size +=3D MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCK= ET_SIZE); + if (cache_size % mc->bucket_size) { + cache_size +=3D mc->bucket_size - (cache_size % mc->bucket_siz= e); } } else { - cache_size =3D MCACHE_BUCKET_SIZE; + cache_size =3D mc->bucket_size; } =20 entry =3D &mc->entry[address_index % mc->nr_buckets]; @@ -422,7 +434,7 @@ static ram_addr_t xen_ram_addr_from_mapcache_single(Map= Cache *mc, void *ptr) trace_xen_ram_addr_from_mapcache_not_in_cache(ptr); raddr =3D RAM_ADDR_INVALID; } else { - raddr =3D (reventry->paddr_index << MCACHE_BUCKET_SHIFT) + + raddr =3D (reventry->paddr_index << mc->bucket_shift) + ((unsigned long) ptr - (unsigned long) entry->vaddr_base); } mapcache_unlock(mc); @@ -585,8 +597,8 @@ static uint8_t *xen_replace_cache_entry_unlocked(MapCac= he *mc, hwaddr address_index, address_offset; hwaddr test_bit_size, cache_size =3D size; =20 - address_index =3D old_phys_addr >> MCACHE_BUCKET_SHIFT; - address_offset =3D old_phys_addr & (MCACHE_BUCKET_SIZE - 1); + address_index =3D old_phys_addr >> mc->bucket_shift; + address_offset =3D old_phys_addr & (mc->bucket_size - 1); =20 assert(size); /* test_bit_size is always a multiple of XC_PAGE_SIZE */ @@ -595,8 +607,8 @@ static uint8_t *xen_replace_cache_entry_unlocked(MapCac= he *mc, test_bit_size +=3D XC_PAGE_SIZE - (test_bit_size % XC_PAGE_SIZE); } cache_size =3D size + address_offset; - if (cache_size % MCACHE_BUCKET_SIZE) { - cache_size +=3D MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCKET_S= IZE); + if (cache_size % mc->bucket_size) { + cache_size +=3D mc->bucket_size - (cache_size % mc->bucket_size); } =20 entry =3D &mc->entry[address_index % mc->nr_buckets]; @@ -609,8 +621,8 @@ static uint8_t *xen_replace_cache_entry_unlocked(MapCac= he *mc, return NULL; } =20 - address_index =3D new_phys_addr >> MCACHE_BUCKET_SHIFT; - address_offset =3D new_phys_addr & (MCACHE_BUCKET_SIZE - 1); + address_index =3D new_phys_addr >> mc->bucket_shift; + address_offset =3D new_phys_addr & (mc->bucket_size - 1); =20 trace_xen_replace_cache_entry_dummy(old_phys_addr, new_phys_addr); =20 --=20 2.25.1