From nobody Fri Oct 31 09:42:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1749662600; cv=none; d=zohomail.com; s=zohoarc; b=NPbDW52KoteEIKpPHaGgnQ7PKo+fFFEiZkTKSf5Xak+H2psEcLeN/XqfWmXQVxSYI0xCgCZxVRIy7Bk8NWWv9vaQJARnJw0hNH/KYggr0l/j3lvVALXsBFlz3kNg/UiOk76ALL2Rp8kbXEOnqngqeTnp93VIYhuuMdOC1T6rnsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1749662600; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zMkLljSK+j8EobhNDyMcdRH/ZodKoaJMWOo2vFrOTRM=; b=SCXSgtK29QLrMDVhNJlg6vVY8qSLQAGTQvcb+1f5GPpW2hYLzEL8404EOKgOoGFP1GSs6BKCWHAyGPJokM6unsKchWdwIdY7AIIgWs1LUY9C4OShm21K+TRuWnepDs2Sv8jygCCf5Yx8g0+m40/wEt8tloH7RoZKpkodfuT2HRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 174966260002998.8877076379174; Wed, 11 Jun 2025 10:23:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1011974.1390542 (Exim 4.92) (envelope-from ) id 1uPPAE-0004BH-80; Wed, 11 Jun 2025 17:23:02 +0000 Received: by outflank-mailman (output) from mailman id 1011974.1390542; Wed, 11 Jun 2025 17:23:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uPPAD-0004AE-Vh; Wed, 11 Jun 2025 17:23:01 +0000 Received: by outflank-mailman (input) for mailman id 1011974; Wed, 11 Jun 2025 17:23:01 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uPPAD-0002dK-Cf for xen-devel@lists.xenproject.org; Wed, 11 Jun 2025 17:23:01 +0000 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [2a00:1450:4864:20::432]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b986bea8-46e8-11f0-a307-13f23c93f187; Wed, 11 Jun 2025 19:23:00 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3a53359dea5so110481f8f.0 for ; Wed, 11 Jun 2025 10:23:00 -0700 (PDT) Received: from localhost (112.pool92-178-7.dynamic.orange.es. [92.178.7.112]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-3a532464f20sm15936533f8f.98.2025.06.11.10.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jun 2025 10:22:59 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b986bea8-46e8-11f0-a307-13f23c93f187 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1749662580; x=1750267380; darn=lists.xenproject.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=zMkLljSK+j8EobhNDyMcdRH/ZodKoaJMWOo2vFrOTRM=; b=oZnV1tEqvqKmVyqlm4To2KRWRRy3SPWSTLk9IZVimu38g53McYSeS+Z7pzGW06Y1dL dd5kFFuI3AtyDUYunlR0kvRRpcJrV2SrWmI3Rqr0sgK5DqAUuUZx+CWNbhycdCE9kpx7 mBVtEsSVIWaLHZfztLt9lUbwxaKIqm2TFxIpA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749662580; x=1750267380; 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=zMkLljSK+j8EobhNDyMcdRH/ZodKoaJMWOo2vFrOTRM=; b=N6zuw2n8MiwN5IYtOJCxuucTVFcGoYvA2o+PMbvHcZwSw2U12eSOVreYAMDaF+P/ix uadhV3h2/1KTV/tTQrzvUjZtIC5Y/6eOpgXt9irZS5nDoR3brP+B9drvk3O5ex1PiP/m KjPyQEvEAV8v0O2rq1KebHpNsY7fI6kTku1DFPe53vwkvP1/OmpXxCe30rgdp8ucuFBw O5/sWH5qNvQ2bQ8Pipj0xVWbMfa8BCYJ65dOITMnuKMxosGBF+AqNWhGFYBVPsylHydt 8Yc0catJkX7tYwdaQz8KAi9ZPu2N1Tnp3eT4dExh6q+eaY8iJwXPjzlGFVQiRaUK3u7g TP8A== X-Gm-Message-State: AOJu0YxQ6RLFKI4pHzsKkatO8GP6UIDnujdnpUnsxdyMqe7lAxqs9vEN aHSszo61jIdW3qUhms+xOtiAauw6vXSpEvAzdeLOV5o13ud+We9PmMtZtZ4fQBTA5ZpuqeWiDnn JicmY X-Gm-Gg: ASbGnctDlHeJ2zL0iAC/TRN6FBT1lrnHVh9aIY0kOuYEx+gULYL1IGsvsqscZV2+bfG OgX/H1YoeUgZXILqpZai7l4EzOTjfF6mpyCp55XV4AfTAciq/k5pNAQYFU163z9Cg8cHF21fTR1 xo4BgZffCI82bTxRp6Wa7CAj9vKZ+uIZ0Ms3bDscE57VObCiQNLtndnL4H/rlQWeipqWFVKO0IT cM8ZDedqzq7gGpLcZZgaD0Js8BEOKyRPd+G5vaviJVxpvhCu9zQVekKCWr9Np3yA2ocMCCvUab1 GjRaPosqmTasLIUro5kdJh5l47Jr3rJQ/c+Vc3s8ytuwrBDS9p9yQ364wnxWVah75qdLtaUwInm RqD8O10p1y1626Jgrm533o1qYG+tXltr2ka0= X-Google-Smtp-Source: AGHT+IFmm8Vnv/fFfhO6OHaQrYoRlOpgApD7blxzSW+d/IiH0RcBar5N6eB71msoXWKCHbg6AhxmIA== X-Received: by 2002:a05:6000:4383:b0:3a4:f6c4:355a with SMTP id ffacd0b85a97d-3a558a534f7mr3477043f8f.57.1749662579917; Wed, 11 Jun 2025 10:22:59 -0700 (PDT) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Oleksii Kurochko , Community Manager , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 8/8] pdx: introduce a command line option for offset compression Date: Wed, 11 Jun 2025 19:16:36 +0200 Message-ID: <20250611171636.5674-9-roger.pau@citrix.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611171636.5674-1-roger.pau@citrix.com> References: <20250611171636.5674-1-roger.pau@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1749662602244116600 Allow controlling whether to attempt PDX compression, and which algorithm to use to calculate the coefficients. Document the option and also add a CHANGELOG entry for the newly added feature. Note the work has been originally done to cope with the new Intel Sapphire/Granite Rapids, however the compression is not explicitly tied to Intel or x86, and hence could be helpful on other architectures. Signed-off-by: Roger Pau Monn=C3=A9 --- CHANGELOG.md | 3 +++ docs/misc/xen-command-line.pandoc | 22 ++++++++++++++++++ xen/common/pdx.c | 38 +++++++++++++++++++++++++++---- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23215a8cc1e6..48327f03078f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ The format is based on [Keep a Changelog](https://keepach= angelog.com/en/1.0.0/) table or foreign memory. =20 ### Added + - Introduce new PDX compression algorithm to cope with Intel Sapphire and + Granite Rapids having sparse memory maps. + - On x86: - Option to attempt to fixup p2m page-faults on PVH dom0. - Resizable BARs is supported for PVH dom0. diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index b0eadd2c5d58..06819576a06b 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -2072,6 +2072,28 @@ for all of them (`true`), only for those subject to = XPTI (`xpti`) or for those not subject to XPTI (`no-xpti`). The feature is used only in case INVPCID is supported and not disabled via `invpcid=3Dfalse`. =20 +###=C2=A0pdx-compress +> `=3D |=C2=A0auto | fast | slow` + +> Default: `auto` + +Only relevant when hypervisor is build with PFN PDX offset compression +`CONFIG_PDX_OFFSET_COMPRESSION`. + +Controls whether Xen will engage in PFN compression, and which algorithm w= ill +be used to calculate the compression coefficients: + +* `auto`: default choice, attempt fast calculation of compression + coefficients, if that's not successful fallback to slow calculation. + +* `fast`: only attempt fast calculation of coefficients, if it fails PFN P= DX + compression will be disabled. + +* `slow`: only attempt slow calculation of coefficients, if it fails PFN P= DX + compression will be disabled. + +Note `pdx-compress=3Dtrue` is equivalent to `pdx-compress=3Dauto`. + ### ple_gap > `=3D ` =20 diff --git a/xen/common/pdx.c b/xen/common/pdx.c index feabdcded804..5fd01305a7be 100644 --- a/xen/common/pdx.c +++ b/xen/common/pdx.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -468,11 +469,40 @@ STATIC void __init pfn_offset_sanitize_ranges(void) } =20 #ifdef __XEN__ +static enum { + PDX_AUTO, /* Fast first, fallback to slow if fast is not successful. */ + PDX_NO, /* Do not attempt compression. */ + PDX_FAST, /* Only attempt fast calculation of compression parameters. = */ + PDX_SLOW, /* Only attempt slow calculation of compression parameters. = */ +} compress_mode __initdata; + +static int __init cf_check parse_pdx_param(const char *arg) +{ + int val; + + if ( !arg ) + return -EINVAL; + + if ( (val =3D parse_bool(arg, NULL)) !=3D -1 ) + compress_mode =3D val ? PDX_AUTO : PDX_NO; + else if ( !strcmp(arg, "auto") ) + compress_mode =3D PDX_AUTO; + else if ( !strcmp(arg, "fast") ) + compress_mode =3D PDX_FAST; + else if ( !strcmp(arg, "slow") ) + compress_mode =3D PDX_SLOW; + else + return -EINVAL; + + return 0; +} +custom_param("pdx-compress", parse_pdx_param); + bool __init pfn_pdx_compression_setup(paddr_t base) { - bool use_slow =3D false; + bool use_slow =3D compress_mode =3D=3D PDX_SLOW; =20 - if ( nr <=3D 1 ) + if ( nr <=3D 1 || compress_mode =3D=3D PDX_NO ) return false; =20 if ( nr > ARRAY_SIZE(ranges) ) @@ -507,11 +537,11 @@ bool __init pfn_pdx_compression_setup(paddr_t base) dprintk(XENLOG_DEBUG, "Find PFN compression coefficients using %s algorithm = failed\n", use_slow ? "slow" : "fast"); - if ( use_slow ) + if ( compress_mode =3D=3D PDX_FAST || use_slow ) return false; } =20 - if ( use_slow ) + if ( compress_mode =3D=3D PDX_FAST || use_slow ) break; } =20 --=20 2.49.0