From nobody Sat Apr 20 04:26:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1567676147; cv=none; d=zoho.com; s=zohoarc; b=RbpGW4g2Oxp+CWQkc6PaC/NhQpEwtwEIgm2ncd5MSV4XDWPUWXlIAdH7a13I4pZg7Ixl9M+D95I9FJaa3p0lcCpV2+oHXXsDXfbMRhdUWArTBVasKm9b/6U1Gm9AK+nirUlxioDfNkFvtIgHtQxb9I0qr9JEKTuedxqM74UW0Uc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567676147; 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:ARC-Authentication-Results; bh=cP2HWNWBQznwtCfVVtnlGMDtIsc4RsiXlju75ZairaM=; b=fitk+iVkjRp0qcQJPQVIiNxY8qoWU+nhxtue9/tPf1jcAUhVMceB7GYo9X3Ku332VsYihNLYwHOYNVmH1+RwV5osWalLZQe0EQFfDI4QVkw49MjNI+p2BBuFQF2/qJ72ZtHJpaAAGc25dhb7+ZxnKRtqcLX7eRQ/FmFcLrpXIJA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1567676147304252.52292992206594; Thu, 5 Sep 2019 02:35:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5oA1-00068u-Pv; Thu, 05 Sep 2019 09:34:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5oA0-00068p-Mt for xen-devel@lists.xenproject.org; Thu, 05 Sep 2019 09:34:36 +0000 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5f4ba462-cfc0-11e9-b299-bc764e2007e4; Thu, 05 Sep 2019 09:34:35 +0000 (UTC) X-Inumbo-ID: 5f4ba462-cfc0-11e9-b299-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1567676075; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=d2TjUGW2maqeaoGEJLkT15uK0agiZulPI2kouKX3pJ4=; b=hJosHIGFSjFTuyw8Afr3oQ2mJWZWMK0g+IrDSJGvT8Bg1hU14LmxJgsC Vd9941KqVc4naT4Dnf6iW3LkdZQpYjMf/EzqlQrMgbTufpK3pmHc+SUxO /lfJw4QytgH4CvEmkvuvaba4omSfPx2pwHeVhvgMFZ71j7LuXYL2eEfUn U=; Authentication-Results: esa5.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 (zoho.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: e0BA+c4MHGF1FgfbwOdla7574CNoFqaXGgbq8sBXIHxbLBJv1UmdMuSsgkA3jiATaiJ75dsgGU +1BnXDktU1itBDvJXBkqnNqisfoam3+P/BKzn00+/HlHOwXlZq91BBFhD2+ZuvOyoLt9WWjtNS EPCEpQLGid4YsB6ihBpg9aUnTxLWDybfLGVJ/NZP6wFypG+blcjPJST/VPO9IMLFRLEjddN6Vm 9CBcf5vIeBn4ar8PuiYY2z0OS0CJdZh2E/iUDlTR7KHO0oQhoj6eN+RjOTL0cBuP7jraH4zvJ+ tuE= X-SBRS: 2.7 X-MesageID: 5353431 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,470,1559534400"; d="scan'208";a="5353431" From: Roger Pau Monne To: Date: Thu, 5 Sep 2019 11:34:16 +0200 Message-ID: <20190905093416.2955-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86/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 , Jan Beulich , Anthony PERARD , Roger Pau Monne 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) 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 the domain builder 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. Fixes: d0c0ba7d3de ('x86/hvm/domain: remove the 'hap_enabled' flag') Signed-off-by: Roger Pau Monn=C3=A9 --- Cc: Paul Durrant --- tools/libxl/libxl.c | 1 + tools/libxl/libxl_arch.h | 4 ++-- tools/libxl/libxl_arm.c | 7 +++++-- tools/libxl/libxl_create.c | 10 ++++++---- tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_x86.c | 15 +++++++++++++-- xen/arch/x86/sysctl.c | 2 ++ xen/include/public/sysctl.h | 4 ++++ 8 files changed, 34 insertions(+), 10 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 =3D !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_p= v); physinfo->cap_hvm_directio =3D !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_directio); + physinfo->cap_hap =3D !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_= hap); =20 GC_FREE; return 0; diff --git a/tools/libxl/libxl_arch.h b/tools/libxl/libxl_arch.h index d624159e53..3f59e790b7 100644 --- a/tools/libxl/libxl_arch.h +++ b/tools/libxl/libxl_arch.h @@ -65,8 +65,8 @@ _hidden int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_t domid, int irq); =20 _hidden -void libxl__arch_domain_create_info_setdefault(libxl__gc *gc, - libxl_domain_create_info *c= _info); +int libxl__arch_domain_create_info_setdefault(libxl__gc *gc, + libxl_domain_create_info *c_= info); =20 _hidden void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 141e159043..b067869154 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1114,8 +1114,8 @@ int libxl__arch_domain_map_irq(libxl__gc *gc, uint32_= t domid, int irq) return xc_domain_bind_pt_spi_irq(CTX->xch, domid, irq, irq); } =20 -void libxl__arch_domain_create_info_setdefault(libxl__gc *gc, - libxl_domain_create_info *c= _info) +int libxl__arch_domain_create_info_setdefault(libxl__gc *gc, + libxl_domain_create_info *c_= info) { /* * Arm guest are now considered as PVH by the toolstack. To allow @@ -1130,6 +1130,9 @@ void libxl__arch_domain_create_info_setdefault(libxl_= _gc *gc, c_info->type =3D LIBXL_DOMAIN_TYPE_PVH; /* All other fields can remain untouched */ } + libxl_defbool_setdefault(&c_info->hap, true); + + return 0; } =20 void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 03ce166f4f..431ead2067 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -30,17 +30,19 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl_domain_create_info *c_info) { + int rc; + if (!c_info->type) { LOG(ERROR, "domain type unspecified"); return ERROR_INVAL; } =20 - libxl__arch_domain_create_info_setdefault(gc, c_info); + rc =3D libxl__arch_domain_create_info_setdefault(gc, c_info); + if (rc) + return rc; =20 - if (c_info->type !=3D LIBXL_DOMAIN_TYPE_PV) { - libxl_defbool_setdefault(&c_info->hap, true); + if (c_info->type !=3D LIBXL_DOMAIN_TYPE_PV) libxl_defbool_setdefault(&c_info->oos, true); - } =20 libxl_defbool_setdefault(&c_info->run_hotplug_scripts, true); libxl_defbool_setdefault(&c_info->driver_domain, false); 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 =3D Struct("physinfo", [ ("cap_hvm", bool), ("cap_pv", bool), ("cap_hvm_directio", bool), # No longer HVM specific + ("cap_hap", bool), ], dir=3DDIR_OUT) =20 libxl_connectorinfo =3D Struct("connectorinfo", [ diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c index c0f88a7eaa..bdc9d9adfe 100644 --- a/tools/libxl/libxl_x86.c +++ b/tools/libxl/libxl_x86.c @@ -620,9 +620,20 @@ int libxl__arch_domain_finalise_hw_description(libxl__= gc *gc, return rc; } =20 -void libxl__arch_domain_create_info_setdefault(libxl__gc *gc, - libxl_domain_create_info *c= _info) +int libxl__arch_domain_create_info_setdefault(libxl__gc *gc, + libxl_domain_create_info *c_= info) { + libxl_physinfo pi; + int rc =3D libxl_get_physinfo(CTX, &pi); + + if (rc) { + LOG(ERROR, "unable to get physinfo"); + return rc; + } + + libxl_defbool_setdefault(&c_info->hap, pi.cap_hap); + + return 0; } =20 void libxl__arch_domain_build_info_setdefault(libxl__gc *gc, diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index c50d910a1c..74ea184087 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 |=3D XEN_SYSCTL_PHYSCAP_pv; if ( iommu_enabled ) pi->capabilities |=3D XEN_SYSCTL_PHYSCAP_directio; + if ( hvm_hap_supported() ) + pi->capabilities |=3D XEN_SYSCTL_PHYSCAP_hap; } =20 long arch_do_sysctl( diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h index 91c48dcae0..6c457625e9 100644 --- a/xen/include/public/sysctl.h +++ b/xen/include/public/sysctl.h @@ -90,6 +90,10 @@ struct xen_sysctl_tbuf_op { /* (x86) 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) +/* (x86) The platform supports Hardware Assisted Paging. */ +#define _XEN_SYSCTL_PHYSCAP_hap 3 +#define XEN_SYSCTL_PHYSCAP_hap (1u<<_XEN_SYSCTL_PHYSCAP_hap) + struct xen_sysctl_physinfo { uint32_t threads_per_core; uint32_t cores_per_socket; --=20 2.22.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel