From patchwork Tue Sep 10 15:25:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11139759 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 3097E14E5 for ; Tue, 10 Sep 2019 15:28:20 +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 F2E6D208E4 for ; Tue, 10 Sep 2019 15:28:19 +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="CRWlN9yJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2E6D208E4 Authentication-Results: mail.kernel.org; dmarc=none (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 1i7i1u-0003V1-AD; Tue, 10 Sep 2019 15:26:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7i1s-0003Uw-Og for xen-devel@lists.xenproject.org; Tue, 10 Sep 2019 15:26:04 +0000 X-Inumbo-ID: 4cbe473c-d3df-11e9-b299-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4cbe473c-d3df-11e9-b299-bc764e2007e4; Tue, 10 Sep 2019 15:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568129164; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=G+LyxJ72ElCcOa0mijx+Aps3mlNirvlkQTuU/FPJ7Hw=; b=CRWlN9yJqeSE4jv7pvG4EcWrko0tn9s9oGTqhzLrzavqpzJkAoB1oAQX F1lf6Zo9I9mGwf7teggF3XgCr8oZEWjx7z/t2/XizCkbBsPqHlRKIMcRV MeV065JlT+ShGhX2Iqfo/88o9pt47owlZFhAc2dE5+6uxtPoRfQMGZYG3 o=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@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 ~all" Received-SPF: None (esa3.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=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: rMDDvcHZwQE5FuTcbMVaZdQ6plGKW1u01bJpYlOD7EdpuI6NNEetPNVtdsxO+q07cuAzLokaP+ qgPLzSj5EaoXwITYaTkvgEX1T8pRyn02ZgRzEQYx5+s1FE2tiaOpJWESOABMaYZP+Nnwq5d6pc S/GRGWQq7SoQom7qQfAxUP5Ph+YSAufqYk3mfDsJzczuhuhxFa7Qt5aIgU0Tgk9mp+c8WcT9lG bw0S0EftDxuhfvudMDAnZYk3foHnvv52IJYDUA8GXlKhvC9jg1hWrhMqfrHbomnxVkvFIL7nZ3 Gpw= X-SBRS: 2.7 X-MesageID: 5385269 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,489,1559534400"; d="scan'208";a="5385269" From: Roger Pau Monne To: Date: Tue, 10 Sep 2019 17:25:37 +0200 Message-ID: <20190910152538.36921-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 1/2] sysctl/libxl: choose a sane default for HAP 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: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Paul Durrant , Christian Lindig , Jan Beulich , David Scott , Anthony PERARD , Volodymyr Babchuk , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Current libxl code will always enable Hardware Assisted Paging (HAP), expecting that the hypervisor will fallback to shadow if HAP is not available. With the changes to DOMCTL_createdomain that's not the case any longer, and the hypervisor will raise an error if HAP is not available instead of silently falling back to shadow. In order to keep the previous functionality report whether HAP is available or not in XEN_SYSCTL_physinfo, so that the toolstack can select a sane default if there's no explicit user selection of whether HAP should be used. Note that on ARM hardware HAP capability is always reported since it's a required feature in order to run Xen. Fixes: d0c0ba7d3de ('x86/hvm/domain: remove the 'hap_enabled' flag') Signed-off-by: Roger Pau Monné Reviewed-by: Paul Durrant Acked-by: Jan Beulich Acked-by: Julien Grall Acked-by: Ian Jackson Acked-by: Christian Lindig --- Cc: Paul Durrant --- Changes since v3: - Add ocaml flags. Changes since v2: - Add a LIBXL_HAVE_PHYSINFO_CAP_HAP for compatibility. Changes since v1: - Also report HAP capability for ARM. - Print hap capability in xl info. --- tools/libxl/libxl.c | 1 + tools/libxl/libxl.h | 7 +++++++ tools/libxl/libxl_create.c | 8 +++++++- tools/libxl/libxl_types.idl | 1 + tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/xl/xl_info.c | 5 +++-- xen/arch/arm/sysctl.c | 2 +- xen/arch/x86/sysctl.c | 2 ++ xen/include/public/sysctl.h | 5 ++++- 10 files changed, 28 insertions(+), 5 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index ec71574e99..5c0fcf320e 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -399,6 +399,7 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo) physinfo->cap_pv = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_pv); physinfo->cap_hvm_directio = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio); + physinfo->cap_hap = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hap); GC_FREE; return 0; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 9bacfb97f0..3ff67792a7 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -394,6 +394,13 @@ */ #define LIBXL_HAVE_EXTENDED_VKB 1 +/* + * LIBXL_HAVE_PHYSINFO_CAP_HAP indicates that libxl_physinfo has a cap_hap + * field that indicates whether the hardware supports Hardware Assisted + * Paging. + */ +#define LIBXL_HAVE_PHYSINFO_CAP_HAP 1 + /* * libxl ABI compatibility * diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 79e010da72..3b45065597 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -38,7 +38,13 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl__arch_domain_create_info_setdefault(gc, c_info); if (c_info->type != LIBXL_DOMAIN_TYPE_PV) { - libxl_defbool_setdefault(&c_info->hap, true); + libxl_physinfo info; + int rc = libxl_get_physinfo(CTX, &info); + + if (rc) + return rc; + + libxl_defbool_setdefault(&c_info->hap, info.cap_hap); libxl_defbool_setdefault(&c_info->oos, true); } diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index b61399ce36..9e1f8515d3 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -1025,6 +1025,7 @@ libxl_physinfo = Struct("physinfo", [ ("cap_hvm", bool), ("cap_pv", bool), ("cap_hvm_directio", bool), # No longer HVM specific + ("cap_hap", bool), ], dir=DIR_OUT) libxl_connectorinfo = Struct("connectorinfo", [ diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index e544ef84da..a5e77c943a 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -107,6 +107,7 @@ type physinfo_cap_flag = | CAP_HVM | CAP_PV | CAP_DirectIO + | CAP_hap type physinfo = { diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index 5a35000761..e92256654b 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -92,6 +92,7 @@ type physinfo_cap_flag = | CAP_HVM | CAP_PV | CAP_DirectIO + | CAP_hap type physinfo = { threads_per_core : int; cores_per_socket : int; diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index 46d9c9f712..aa6724bc7f 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -210,11 +210,12 @@ static void output_physinfo(void) info.hw_cap[4], info.hw_cap[5], info.hw_cap[6], info.hw_cap[7] ); - maybe_printf("virt_caps :%s%s%s%s\n", + maybe_printf("virt_caps :%s%s%s%s%s\n", info.cap_pv ? " pv" : "", info.cap_hvm ? " hvm" : "", info.cap_hvm && info.cap_hvm_directio ? " hvm_directio" : "", - info.cap_pv && info.cap_hvm_directio ? " pv_directio" : "" + info.cap_pv && info.cap_hvm_directio ? " pv_directio" : "", + info.cap_hap ? " hap" : "" ); vinfo = libxl_get_version_info(ctx); diff --git a/xen/arch/arm/sysctl.c b/xen/arch/arm/sysctl.c index 92ac99c928..f87944e847 100644 --- a/xen/arch/arm/sysctl.c +++ b/xen/arch/arm/sysctl.c @@ -14,7 +14,7 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) { - pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm; + pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm | XEN_SYSCTL_PHYSCAP_hap; } long arch_do_sysctl(struct xen_sysctl *sysctl, diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 7ec6174e6b..5777a05ffc 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -163,6 +163,8 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm; if ( IS_ENABLED(CONFIG_PV) ) pi->capabilities |= XEN_SYSCTL_PHYSCAP_pv; + if ( hvm_hap_supported() ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_hap; } long arch_do_sysctl( diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 5401f9c2fe..d4b455619c 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -90,9 +90,12 @@ struct xen_sysctl_tbuf_op { /* The platform supports direct access to I/O devices with IOMMU. */ #define _XEN_SYSCTL_PHYSCAP_directio 2 #define XEN_SYSCTL_PHYSCAP_directio (1u<<_XEN_SYSCTL_PHYSCAP_directio) +/* The platform supports Hardware Assisted Paging. */ +#define _XEN_SYSCTL_PHYSCAP_hap 3 +#define XEN_SYSCTL_PHYSCAP_hap (1u<<_XEN_SYSCTL_PHYSCAP_hap) /* Max XEN_SYSCTL_PHYSCAP_* constant. Used for ABI checking. */ -#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_directio +#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_hap struct xen_sysctl_physinfo { uint32_t threads_per_core; From patchwork Tue Sep 10 15:25:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11139757 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 C147E14E5 for ; Tue, 10 Sep 2019 15:27:58 +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 9BCD3208E4 for ; Tue, 10 Sep 2019 15:27:58 +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="TeMRbDfL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BCD3208E4 Authentication-Results: mail.kernel.org; dmarc=none (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 1i7i2C-0003WQ-Jq; Tue, 10 Sep 2019 15:26:24 +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 1i7i2A-0003WD-OZ for xen-devel@lists.xenproject.org; Tue, 10 Sep 2019 15:26:22 +0000 X-Inumbo-ID: 57326888-d3df-11e9-ac1f-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 57326888-d3df-11e9-ac1f-12813bfff9fa; Tue, 10 Sep 2019 15:26:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568129181; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ylcwdcYp+xWOR66oc1BDb4M2clo4ux5Vb68W36Cay68=; b=TeMRbDfLPGNifZlhNC7555hvX1GmBgz3MWQQwemnurIPVtm+fYHgr4af O2W/rLitxLjUcPnmyMSTQ1IWr7i3+u710KApVSkQtg97YGgV26rUPaiBr KtserEuKcY6XlmbXS8mB79BH0iz+iY4g2RCghrh1q/FLyyfAAlOWPVmr9 0=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@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 ~all" Received-SPF: None (esa1.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=esa1.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: LHsPI+ikT3p7ZW3C5n0bX+jwRNtElJgpYRQ619w/izoBhgRuEeLvtWCGluov8IObsdbS5PUBKx 1IXWs2SJSuTYZmI8KUHB8RmkxfzOuxTWUhcTnT9pLwp8Ap6yB6GTAG28B0zxxUyG9bkiNriUNv xnWX/roZEr3Iyv0ulIF18TjRVVa0mkuWXH3lkAlMIs5UazaCP3fY20m/+DW56zHDcLFpFfwltI Urtu5c0QWTtFt7AZroGRdAsGSGPfGFGtZYaXUF7rNTxlkaB5gNCBgPzYjCdKxrZJJlHSmO4H2m C2o= X-SBRS: 2.7 X-MesageID: 5432766 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,489,1559534400"; d="scan'208";a="5432766" From: Roger Pau Monne To: Date: Tue, 10 Sep 2019 17:25:38 +0200 Message-ID: <20190910152538.36921-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190910152538.36921-1-roger.pau@citrix.com> References: <20190910152538.36921-1-roger.pau@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 2/2] sysctl: report shadow paging capability 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: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Christian Lindig , Jan Beulich , David Scott , Anthony PERARD , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Report whether shadow paging is supported by the hypervisor, since it can be disabled at build time. Requested-by: Andrew Cooper Signed-off-by: Roger Pau Monné Acked-by: Jan Beulich Acked-by: Ian Jackson --- NB: I'm not sure the added check in libxl__domain_create_info_setdefault is that useful, or if it could be better placed somewhere else. --- Changes since v3: - New in this version. --- tools/libxl/libxl.c | 2 ++ tools/libxl/libxl.h | 6 ++++++ tools/libxl/libxl_create.c | 5 +++++ tools/libxl/libxl_types.idl | 1 + tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/xl/xl_info.c | 5 +++-- xen/arch/x86/sysctl.c | 2 ++ xen/include/public/sysctl.h | 5 ++++- 9 files changed, 25 insertions(+), 3 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 5c0fcf320e..57073c06d5 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -400,6 +400,8 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo) physinfo->cap_hvm_directio = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio); physinfo->cap_hap = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_hap); + physinfo->cap_shadow = + !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_shadow); GC_FREE; return 0; diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 3ff67792a7..e8f5ebe929 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -401,6 +401,12 @@ */ #define LIBXL_HAVE_PHYSINFO_CAP_HAP 1 +/* + * LIBXL_HAVE_PHYSINFO_CAP_HAP indicates that libxl_physinfo has a cap_shadow + * field that indicates whether software implemented paging is supported. + */ +#define LIBXL_HAVE_PHYSINFO_CAP_SHADOW 1 + /* * libxl ABI compatibility * diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 3b45065597..47f10da465 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -44,6 +44,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, if (rc) return rc; + if (!info.cap_hap && !info.cap_shadow) { + LOG(ERROR, "neither hap nor shadow paging available"); + return ERROR_INVAL; + } + libxl_defbool_setdefault(&c_info->hap, info.cap_hap); libxl_defbool_setdefault(&c_info->oos, true); } diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 9e1f8515d3..6f431baec2 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -1026,6 +1026,7 @@ libxl_physinfo = Struct("physinfo", [ ("cap_pv", bool), ("cap_hvm_directio", bool), # No longer HVM specific ("cap_hap", bool), + ("cap_shadow", bool), ], dir=DIR_OUT) libxl_connectorinfo = Struct("connectorinfo", [ diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index a5e77c943a..9f56e1df1a 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -108,6 +108,7 @@ type physinfo_cap_flag = | CAP_PV | CAP_DirectIO | CAP_hap + | CAP_shadow type physinfo = { diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli index e92256654b..e06c53d0fa 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -93,6 +93,7 @@ type physinfo_cap_flag = | CAP_PV | CAP_DirectIO | CAP_hap + | CAP_shadow type physinfo = { threads_per_core : int; cores_per_socket : int; diff --git a/tools/xl/xl_info.c b/tools/xl/xl_info.c index aa6724bc7f..148c4740ae 100644 --- a/tools/xl/xl_info.c +++ b/tools/xl/xl_info.c @@ -210,12 +210,13 @@ static void output_physinfo(void) info.hw_cap[4], info.hw_cap[5], info.hw_cap[6], info.hw_cap[7] ); - maybe_printf("virt_caps :%s%s%s%s%s\n", + maybe_printf("virt_caps :%s%s%s%s%s%s\n", info.cap_pv ? " pv" : "", info.cap_hvm ? " hvm" : "", info.cap_hvm && info.cap_hvm_directio ? " hvm_directio" : "", info.cap_pv && info.cap_hvm_directio ? " pv_directio" : "", - info.cap_hap ? " hap" : "" + info.cap_hap ? " hap" : "", + info.cap_shadow ? " shadow" : "" ); vinfo = libxl_get_version_info(ctx); diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 5777a05ffc..50be0c722a 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -165,6 +165,8 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi) pi->capabilities |= XEN_SYSCTL_PHYSCAP_pv; if ( hvm_hap_supported() ) pi->capabilities |= XEN_SYSCTL_PHYSCAP_hap; + if ( IS_ENABLED(CONFIG_SHADOW_PAGING) ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_shadow; } long arch_do_sysctl( diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index d4b455619c..e324442f92 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -93,9 +93,12 @@ struct xen_sysctl_tbuf_op { /* The platform supports Hardware Assisted Paging. */ #define _XEN_SYSCTL_PHYSCAP_hap 3 #define XEN_SYSCTL_PHYSCAP_hap (1u<<_XEN_SYSCTL_PHYSCAP_hap) +/* The platform supports software paging. */ +#define _XEN_SYSCTL_PHYSCAP_shadow 4 +#define XEN_SYSCTL_PHYSCAP_shadow (1u<<_XEN_SYSCTL_PHYSCAP_shadow) /* Max XEN_SYSCTL_PHYSCAP_* constant. Used for ABI checking. */ -#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_hap +#define XEN_SYSCTL_PHYSCAP_MAX XEN_SYSCTL_PHYSCAP_shadow struct xen_sysctl_physinfo { uint32_t threads_per_core;