From nobody Mon Feb 9 23:57:55 2026 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=1639606943; cv=none; d=zohomail.com; s=zohoarc; b=CkSrbGDytTtTGymoz5zfrP5qN8c2l2KGXc0OMQXy6WvY+SFSmItL0ng+f27dpn6a5b++l6DBePp2zdqhBA/enGjTZ3iLHtfU6ZOnMs76toPkcnJS2o+FBAbyn38xFnY5jXTtkd8imIcq2FkJc5epAQ18ecvyrukoWsw4gaWa2LQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639606943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4z6Xf46wo0FqPIWQPBE2Z6JpEVgsajI8LIrGEuaejwU=; b=S7flOFuTnFCVnujgfJFvpSAppUPMCh5ln2sz987K+ffmJWYPmk63mQpIRTbpnsQMtUi7mod4uz7B/T3rs2Y5EI47iQ74jvwdFNNIhazzb6epgsE95bbga7cIgunuaV+R2Zjd45RweEI+37dWOQ8jF+E5ZUJaxVLrVGDE8uD2FaI= 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 1639606943444736.8591493534813; Wed, 15 Dec 2021 14:22:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.247620.427022 (Exim 4.92) (envelope-from ) id 1mxcei-0006Mw-4n; Wed, 15 Dec 2021 22:21:48 +0000 Received: by outflank-mailman (output) from mailman id 247620.427022; Wed, 15 Dec 2021 22:21:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mxcei-0006MT-1M; Wed, 15 Dec 2021 22:21:48 +0000 Received: by outflank-mailman (input) for mailman id 247620; Wed, 15 Dec 2021 22:21:46 +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 1mxceg-0005ZJ-Mu for xen-devel@lists.xenproject.org; Wed, 15 Dec 2021 22:21:46 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 62bea4b9-5df5-11ec-9e60-abaf8a552007; Wed, 15 Dec 2021 23:21:45 +0100 (CET) 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: 62bea4b9-5df5-11ec-9e60-abaf8a552007 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1639606904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1sJTP2vFe7TUxYv8fxcjX4sbJWFBPyrCwJr81dmHE5A=; b=QZlKSctVc7MTYak1OnqQnE1rJ+kPqbYcnj8AIElwLlb1oOERCo4OCu1l VsStOEmPf8xgpYShKkK3f8ycDfgs7/2SufZBtXUAoSI0o93s3WI4Sz1CW diN4uXMYqwseUYdZzdrcpCQW6ORzmgWtNKQeof7dioQ5I5j6+z8+Zp5NN s=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: bfkV+bUSFRfie8G58yskNAm4RdSahQqULovzT5f9dhAknp/T5GNtOf8ZeXBSQKfRdy3v1vVCBq lQK2SsfV1r9xKzD0gbdWMD1TfhIb/Wt9qpEZLfSGLNk+aATyywmS8tpmCzl8ElI6mCPdoXxPe+ vuFMuj6LGgeodUm6Lw6ZCCVqS2kQEMxy+r970Wzlq01hhdeuJ05wS0Q0KJSJ9q+1Qhd4HdIgC+ Syt+Kx6eWE3oUW5ox8NazXPJqyPbZLHWRAUvE2I0JW1Xf/ZJArYF4nxOJdso9Q72ECeVqvqvVd kQSH6MxtmU0pvDCYpg3fpFzv X-SBRS: 5.1 X-MesageID: 60126720 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:2F+FPqMM72hx4RrvrR1okMFynXyQoLVcMsEvi/4bfWQNrUp01TEFz TccWWyCPf6LYWDwL48latvgo0MH7JLSn9FmQQto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6UUsxNbVU8En5400s+w7VRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYowuktOhvx NBkj4WbcSc0fbXxsdgHXDANRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YsBqit4uM4/AO4QHt2s75TrYEewnUdbIRKCiCdpwgm9p3J4RR662i 8wxSjVORx38PjB1BFYcLpYgt9imgHf9WmgNwL6SjfV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w6W+rcaV5rReYIsimQD101hICG9Evb0qy lhppQmPH7P+VIssRQb8+xoV5PufZqxz/BICOoqTNKftWvdyQiVxehZhOOP/9SJIUbDH4VmpM VdmsZFaeEZDTJB/LvHCAvTKadd/DFQmprY+ts3zB1WPH9Xg7kL1XYfNu4CeHcGPzWvA/ACZf yhz/sCnRWMU1INYP+2A3EUNtKz3eEixPrdEGc77wdM0nj3sQ+V X-IronPort-AV: E=Sophos;i="5.88,209,1635220800"; d="scan'208";a="60126720" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH v2 3/4] x86/cpuid: Introduce dom0-cpuid command line option Date: Wed, 15 Dec 2021 22:21:14 +0000 Message-ID: <20211215222115.6829-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20211215222115.6829-1-andrew.cooper3@citrix.com> References: <20211215222115.6829-1-andrew.cooper3@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: 1639606944226100001 Specifically, this lets the user opt in to non-default for dom0. Collect all dom0 settings together in dom0_{en,dis}able_feat[], and apply it to dom0's policy when other tweaks are being made. As recalculate_cpuid_policy() is an expensive action, and dom0-cpuid=3D is likely to only be used by the x86 maintainers for development purposes, for= go the recalculation in the general case. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu v2: * Rework almost from scratch, on top of broken-out changes. --- docs/misc/xen-command-line.pandoc | 17 +++++++++++++++++ xen/arch/x86/cpuid.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index f7797ea233f9..383a854dec60 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -801,6 +801,23 @@ Controls for how dom0 is constructed on x86 systems. =20 If using this option is necessary to fix an issue, please report a bug. =20 +### dom0-cpuid + =3D List of comma separated booleans + + Applicability: x86 + +This option allows for fine tuning of the facilities dom0 will use, after +accounting for hardware capabilities and Xen settings as enumerated via CP= UID. + +Options are accepted in positive and negative form, to enable or disable +specific features, but specify both forms of the same option is undefined. +All selections via this mechanism are subject to normal CPU Policy safety = and +dependency logic. + +This option is intended for developers to opt dom0 into non-default featur= es, +and is not intended for use in production circumstances. If using this op= tion +is necessary to fix an issue, please report a bug. + ### dom0-iommu =3D List of [ passthrough=3D, strict=3D, map-inclusive=3D<= bool>, map-reserved=3D, none ] diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index e11f5a3c9a6b..83a80ba6de70 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -116,6 +116,23 @@ static int __init parse_xen_cpuid(const char *s) } custom_param("cpuid", parse_xen_cpuid); =20 +static bool __initdata dom0_cpuid_cmdline; +static uint32_t __initdata dom0_enable_feat[FSCAPINTS]; +static uint32_t __initdata dom0_disable_feat[FSCAPINTS]; + +static void __init _parse_dom0_cpuid(unsigned int feat, bool val) +{ + __set_bit(feat, val ? dom0_enable_feat : dom0_disable_feat); +} + +static int __init parse_dom0_cpuid(const char *s) +{ + dom0_cpuid_cmdline =3D true; + + return parse_cpuid(s, _parse_dom0_cpuid); +} +custom_param("dom0-cpuid", parse_dom0_cpuid); + #define EMPTY_LEAF ((struct cpuid_leaf){}) static void zero_leaves(struct cpuid_leaf *l, unsigned int first, unsigned int last) @@ -768,6 +785,25 @@ void __init init_dom0_cpuid_policy(struct domain *d) */ if ( cpu_has_arch_caps ) p->feat.arch_caps =3D true; + + /* Apply dom0-cpuid=3D command line settings, if provided. */ + if ( dom0_cpuid_cmdline ) + { + uint32_t fs[FSCAPINTS]; + unsigned int i; + + cpuid_policy_to_featureset(p, fs); + + for ( i =3D 0; i < ARRAY_SIZE(fs); ++i ) + { + fs[i] |=3D dom0_enable_feat[i]; + fs[i] &=3D ~dom0_disable_feat[i]; + } + + cpuid_featureset_to_policy(fs, p); + + recalculate_cpuid_policy(d); + } } =20 void guest_cpuid(const struct vcpu *v, uint32_t leaf, --=20 2.11.0