From patchwork Wed Feb 26 20:22:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11407169 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D404B14E3 for ; Wed, 26 Feb 2020 20:23:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B09D924656 for ; Wed, 26 Feb 2020 20:23:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="MfXV3cRW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B09D924656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j73CU-0003jL-3w; Wed, 26 Feb 2020 20:22:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j73CS-0003j3-Vz for xen-devel@lists.xenproject.org; Wed, 26 Feb 2020 20:22:33 +0000 X-Inumbo-ID: b42031f8-58d5-11ea-94dc-12813bfff9fa Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b42031f8-58d5-11ea-94dc-12813bfff9fa; Wed, 26 Feb 2020 20:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582748547; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u/+RKLhbDk17CKseuXcfqx9TwE1p61mY4ldohohPJuk=; b=MfXV3cRWTTdkA/ZyJ1eOKMBPGnnaTurjFWC6I8yrL0VDmYZwsvXI7Z+b pQrPIHXfJMk7Pi9YPk1LdE1VyzwZyiOeKrXdxkvFmZ4O2szoc7oorSmqb srmFw68vsckgDxo6DmEWA0/DPs8H8KDQutGVP2MtGs0loAvEZL1oFojY8 E=; Authentication-Results: esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.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=esa2.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 (esa2.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=esa2.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 6upkhATuuOwR3xc4+/iry+v3K+MkoJm04izMYWmVr/fyM9xXX69aiyioQSWXlZak1QIYWG3LLw k7b/kO+j+bzcgq5LOxM4yc56XYWWV2uHCsC0uMdUZfzhXV4SQdlMlzSQMLKtUyk5cYNmS+KqBd 2TccL46QR5s8corlm0iUsMZAIQEjIeGe9QKNY8SXqUGkkpbUaA3Eb4NCbObdZLX0jS901EnlxP bIzxpfvFOEdg2asw7VgDweid3hrSQROweVj3DVzlipylAn8a5olCPKtQmiIYWTJ4rQIJg5CWz4 0hM= X-SBRS: 2.7 X-MesageID: 13071942 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,489,1574139600"; d="scan'208";a="13071942" From: Andrew Cooper To: Xen-devel Date: Wed, 26 Feb 2020 20:22:12 +0000 Message-ID: <20200226202221.6555-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200226202221.6555-1-andrew.cooper3@citrix.com> References: <20200226202221.6555-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 01/10] x86/sysctl: Don't return cpu policy data for compiled-out support (2) 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Just as with c/s 96dc77b4b1 for XEN_SYSCTL_get_cpu_policy, XEN_SYSCTL_get_cpu_featureset needs to become conditional. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- tools/misc/xen-cpuid.c | 17 +++++++++++++---- xen/arch/x86/sysctl.c | 17 +++++++++++++---- xen/include/public/sysctl.h | 2 ++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index f55b67640a..36c17bf777 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -251,7 +251,7 @@ static void decode_featureset(const uint32_t *features, } } -static void get_featureset(xc_interface *xch, unsigned int idx) +static int get_featureset(xc_interface *xch, unsigned int idx) { struct fsinfo *f = &featuresets[idx]; @@ -261,8 +261,7 @@ static void get_featureset(xc_interface *xch, unsigned int idx) if ( !f->fs ) err(1, "calloc(, featureset)"); - if ( xc_get_cpu_featureset(xch, idx, &f->len, f->fs) ) - err(1, "xc_get_featureset()"); + return xc_get_cpu_featureset(xch, idx, &f->len, f->fs); } static void dump_info(xc_interface *xch, bool detail) @@ -294,7 +293,17 @@ static void dump_info(xc_interface *xch, bool detail) printf("\nDynamic sets:\n"); for ( i = 0; i < ARRAY_SIZE(featuresets); ++i ) { - get_featureset(xch, i); + if ( get_featureset(xch, i) ) + { + if ( errno == EOPNOTSUPP ) + { + printf("%s featureset not supported by Xen\n", + featuresets[i].name); + continue; + } + + err(1, "xc_get_featureset()"); + } decode_featureset(featuresets[i].fs, featuresets[i].len, featuresets[i].name, detail); diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 59a384023b..7ea8c38797 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -363,11 +363,15 @@ long arch_do_sysctl( case XEN_SYSCTL_get_cpu_featureset: { - static const struct cpuid_policy *const policy_table[] = { + static const struct cpuid_policy *const policy_table[4] = { [XEN_SYSCTL_cpu_featureset_raw] = &raw_cpuid_policy, [XEN_SYSCTL_cpu_featureset_host] = &host_cpuid_policy, +#ifdef CONFIG_PV [XEN_SYSCTL_cpu_featureset_pv] = &pv_max_cpuid_policy, +#endif +#ifdef CONFIG_HVM [XEN_SYSCTL_cpu_featureset_hvm] = &hvm_max_cpuid_policy, +#endif }; const struct cpuid_policy *p = NULL; uint32_t featureset[FSCAPINTS]; @@ -389,12 +393,17 @@ long arch_do_sysctl( /* Look up requested featureset. */ if ( sysctl->u.cpu_featureset.index < ARRAY_SIZE(policy_table) ) + { p = policy_table[sysctl->u.cpu_featureset.index]; - /* Bad featureset index? */ - if ( !p ) - ret = -EINVAL; + if ( !p ) + ret = -EOPNOTSUPP; + } else + /* Bad featureset index? */ + ret = -EINVAL; + + if ( !ret ) cpuid_policy_to_featureset(p, featureset); /* Copy the requested featureset into place. */ diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 4dfba39ed8..3d72fab49f 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -796,6 +796,8 @@ struct xen_sysctl_cpu_levelling_caps { * - Host: The values Xen is using, (after command line overrides, etc). * - PV: Maximum set of features which can be given to a PV guest. * - HVM: Maximum set of features which can be given to a HVM guest. + * May fail with -EOPNOTSUPP if querying for PV or HVM data when support is + * compiled out of Xen. */ struct xen_sysctl_cpu_featureset { #define XEN_SYSCTL_cpu_featureset_raw 0