From nobody Mon May 6 14:17:49 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1582651943; cv=none; d=zohomail.com; s=zohoarc; b=RN5R5XDh6ekdcguIgfwy9utb+w8CGDKj3LLlFawxxZ1sURxLRnxKGEFFtyWh+pa6tBS/GpFKiWmZU2GD0x6mPWFWqphO5zw4LnA6mkxfFOTx5hKVdUB+yiMv2PLQOhDi2Rbcj31N+p+Fl9qXJTsXRni8Ysz3GvBLlIj4a8gp76Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582651943; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=DQHe+LB471NYXUHTZN7hujsfV7V/R+IFN2RT/4cXuCw=; b=HZttaS/XKN8WAIj3sPkDf8gB0E6ejedRdAP6HrX/VldP8ZFC/90kNi0cFONUC64W/fwEkYvFyhswln2eeOnu/PWG3I+G7880JyukVe7mR+DV4hX4tVqFzUremzuAQg9wVYaFhL6J5UUWAKtVN5x3n/XA13n/ul6fKlxZwauvdmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1582651943800908.3584439718976; Tue, 25 Feb 2020 09:32:23 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6e3X-0006wR-6W; Tue, 25 Feb 2020 17:31:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j6e3W-0006wE-I8 for xen-devel@lists.xenproject.org; Tue, 25 Feb 2020 17:31:38 +0000 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id acda6404-57f4-11ea-a490-bc764e2007e4; Tue, 25 Feb 2020 17:31:37 +0000 (UTC) X-Inumbo-ID: acda6404-57f4-11ea-a490-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582651897; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cNlO/PBRWz4sAvTFEtAoZ5fHdc7j8xdF8DKNOxjwkDc=; b=Cv2VxJbk+qwT9NfIbt+fLmi6vssfgmFyp8GagSp6T6e0M8lMiVCPjFTo FKNa1L+QIiSa9EQAaGUAOT5DDuutuAnP9KZ7TWMVSTyvHdjgdFH5nW7P7 WNNGO95aIcwOGcf9TGYdfhJXIWcg7qRfrZanDvJBGcoMhsKLGzpo7r5KY I=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 58j0mvkJ9QG9wy00ore+90V72X8y/PX4MzBCjuK2YolR52+jokV4hG2LYFc7yKQZT8+5Sf+GMC h2oqpWGRwPpmGkAZVOFLK7Q8x+nbcWGqI43n+cRucLx9fUxYzXGXhTxN1Bic/ApLGjamFHQpEJ bTOoOWuOWe3IKKy6XQfTbP14d8GhNA6E2QYcRaiJwxSd38sBCKWYNBfmUjAC7WY6Ug1z/7RAih z7VDBbGb8Wu9BzZzoKRVKdvYz/CcqOK1bo0g3viSaz0rb5sn9AYiuhGqkcEkfr8yv1YElyBEnq S/c= X-SBRS: 2.7 X-MesageID: 13614986 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,484,1574139600"; d="scan'208";a="13614986" From: Andrew Cooper To: Xen-devel Date: Tue, 25 Feb 2020 17:31:33 +0000 Message-ID: <20200225173133.3632-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/sysctl: Don't return cpu policy data for compiled-out support X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Policy objects aren't tiny, and the derivation logic isn't trivial. We are about to increase the number of policy objects, so take this opportunity to drop logic and storage space based on CONFIG_{PV,HVM}. Start by causing XEN_SYSCTL_get_cpu_policy to fail with -EOPNOTSUPP when requesting data for a compiled-out subsystem. Update xen-cpuid to cope and continue to further system policies, seeing as the indicies are interleaved. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- tools/misc/xen-cpuid.c | 9 +++++++++ xen/arch/x86/sysctl.c | 20 +++++++++++++++----- xen/include/public/sysctl.h | 2 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 7726c4ed3c..f55b67640a 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -480,7 +480,16 @@ int main(int argc, char **argv) =20 if ( xc_get_system_cpu_policy(xch, i, &nr_leaves, leaves, &nr_msrs, msrs) ) + { + if ( errno =3D=3D EOPNOTSUPP ) + { + printf("%s policy not supported by Xen\n", + sys_policies[i]); + continue; + } + err(1, "xc_get_system_cpu_policy(, %s,,)", sys_policie= s[i]); + } =20 print_policy(sys_policies[i], leaves, nr_leaves, msrs, nr_msrs); diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 4a76f0f47f..59a384023b 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -33,7 +33,7 @@ #include #include =20 -const struct cpu_policy system_policies[] =3D { +const struct cpu_policy system_policies[6] =3D { [ XEN_SYSCTL_cpu_policy_raw ] =3D { &raw_cpuid_policy, &raw_msr_policy, @@ -42,22 +42,26 @@ const struct cpu_policy system_policies[] =3D { &host_cpuid_policy, &host_msr_policy, }, +#ifdef CONFIG_PV [ XEN_SYSCTL_cpu_policy_pv_max ] =3D { &pv_max_cpuid_policy, &pv_max_msr_policy, }, - [ XEN_SYSCTL_cpu_policy_hvm_max ] =3D { - &hvm_max_cpuid_policy, - &hvm_max_msr_policy, - }, [ XEN_SYSCTL_cpu_policy_pv_default ] =3D { &pv_max_cpuid_policy, &pv_max_msr_policy, }, +#endif +#ifdef CONFIG_HVM + [ XEN_SYSCTL_cpu_policy_hvm_max ] =3D { + &hvm_max_cpuid_policy, + &hvm_max_msr_policy, + }, [ XEN_SYSCTL_cpu_policy_hvm_default ] =3D { &hvm_max_cpuid_policy, &hvm_max_msr_policy, }, +#endif }; =20 struct l3_cache_info { @@ -426,6 +430,12 @@ long arch_do_sysctl( array_index_nospec(sysctl->u.cpu_policy.index, ARRAY_SIZE(system_policies))]; =20 + if ( !policy->cpuid || !policy->msr ) + { + ret =3D -EOPNOTSUPP; + break; + } + /* Process the CPUID leaves. */ if ( guest_handle_is_null(sysctl->u.cpu_policy.cpuid_policy) ) sysctl->u.cpu_policy.nr_leaves =3D CPUID_MAX_SERIALISED_LEAVES; diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 7e43bfe1bd..4dfba39ed8 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -1051,6 +1051,8 @@ struct xen_sysctl_set_parameter { * experimental features outside of security support. * - Default_*: Default set of features a PV or HVM guest can use. This = is * the security supported set. + * May fail with -EOPNOTSUPP if querying for PV or HVM data when support is + * compiled out of Xen. */ struct xen_sysctl_cpu_policy { #define XEN_SYSCTL_cpu_policy_raw 0 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel