libxl: choose a sane default for HAP
v2 cover libxl: choose a sane default for HAP
Hello,
First patch is a preparatory change to also make use of the physcaps on ARM, second patch introduces a new physcap (HAP) in order for the toolstack to decide whether to use HAP if the user hasn't made a selection.
The series can also be found at:
git://xenbits.xen.org/people/royger/xen.git hap_info_v2
Thanks, Roger.
Roger Pau Monne (2):
sysctl: report existing physcaps on ARM
sysctl/libxl: choose a sane default for HAP
tools/libxl/libxl.c | 1 + tools/libxl/libxl_create.c | 8 +++++++- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_info.c | 5 +++-- xen/arch/arm/sysctl.c | 5 ++++- xen/arch/x86/sysctl.c | 4 ++-- xen/common/sysctl.c | 2 ++ xen/include/public/sysctl.h | 10 +++++++--- 8 files changed, 27 insertions(+), 9 deletions(-)
Signature · 7 lines
2.22.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 1/2 sysctl: report existing physcaps on ARM
Current physcaps in XEN_SYSCTL_physinfo are only used by x86, albeit the capabilities themselves are not x86 specific.
This patch adds support for also reporting the current capabilities on ARM hardware. Note that on ARM PHYSCAP_hvm is always reported, and setting PHYSCAP_directio has been moved to common code since the same logic to set it is used by x86 and ARM.
---
Changes since v1:
- New in this version.
--- xen/arch/arm/sysctl.c | 5 ++++- xen/arch/x86/sysctl.c | 2 -- xen/common/sysctl.c | 2 ++ xen/include/public/sysctl.h | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-)
xen/arch/arm/sysctl.c +4 -1
@@ -12,7 +12,10 @@#include <xen/hypercall.h> #include <public/sysctl.h> -void arch_do_physinfo (struct xen_sysctl_physinfo *pi) { } +void arch_do_physinfo (struct xen_sysctl_physinfo *pi) +{ + pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm; +}long arch_do_sysctl (struct xen_sysctl *sysctl,XEN_GUEST_HANDLE_PARAM (xen_sysctl_t) u_sysctl)
xen/arch/x86/sysctl.c +0 -2
@@ -163,8 +163,6 @@ 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 ( iommu_enabled ) - pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio; } long arch_do_sysctl(
xen/common/sysctl.c +2 -0
@@ -267,6 +267,8 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) pi->cpu_khz = cpu_khz; pi->max_mfn =get_upper_mfn_bound ();arch_do_physinfo (pi); +if ( iommu_enabled ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio;if (copy_to_guest (u_sysctl, op,1 ) ) ret = -EFAULT ;
xen/include/public/sysctl.h +3 -3
@@ -81,13 +81,13 @@ struct xen_sysctl_tbuf_op {* Get physical information about the host machine */ /* XEN_SYSCTL_physinfo */ -/* (x86) The platform supports HVM guests. */ +/* The platform supports HVM guests. */ #define _XEN_SYSCTL_PHYSCAP_hvm 0#define XEN_SYSCTL_PHYSCAP_hvm (1u<<_XEN_SYSCTL_PHYSCAP_hvm) -/* (x86) The platform supports PV guests. */ +/* The platform supports PV guests. */ #define _XEN_SYSCTL_PHYSCAP_pv 1#define XEN_SYSCTL_PHYSCAP_pv (1u<<_XEN_SYSCTL_PHYSCAP_pv) -/* (x86) The platform supports direct access to I/O devices with IOMMU. */ +/* 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)struct xen_sysctl_physinfo {
Signature · 7 lines
2.22.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 1/2] sysctl: report existing physcaps on ARM
Quoted 14 lines
-----Original Message-----
From: Xen-devel <[email protected]> On Behalf Of Roger Pau Monne
Sent: 05 September 2019 14:27
To: [email protected]
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; Tim (Xen.org) <[email protected]>; Julien Grall <[email protected]>; Jan Beulich <[email protected]>; Volodymyr Babchuk <[email protected]>; Roger Pau Monne <[email protected]>
Subject: [Xen-devel] [PATCH v2 1/2] sysctl: report existing physcaps on ARMCurrent physcaps in
XEN_SYSCTL_physinfoare only used by x86, albeit the capabilities themselves are not x86 specific.
Quoted 6 lines
This patch adds support for also reporting the current capabilities on ARM hardware. Note that on ARM
PHYSCAP_hvmis always reported, and settingPHYSCAP_directiohas been moved to common code since the same logic to set it is used by x86 and ARM.Signed-off-by Roger Pau Monné <[email protected]>
Quoted 77 lines
---
Changes since v1:
- New in this version.--- xen/arch/arm/sysctl.c | 5 ++++- xen/arch/x86/sysctl.c | 2 -- xen/common/sysctl.c | 2 ++ xen/include/public/sysctl.h | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-)xen/arch/arm/sysctl.c +4
-1@@ -12,7 +12,10 @@#include <xen/hypercall.h> #include <public/sysctl.h> -void arch_do_physinfo (struct xen_sysctl_physinfo *pi) { } +void arch_do_physinfo (struct xen_sysctl_physinfo *pi) +{ + pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm; +}long arch_do_sysctl (struct xen_sysctl *sysctl,XEN_GUEST_HANDLE_PARAM (xen_sysctl_t) u_sysctl)xen/arch/x86/sysctl.c +0
-2@@ -163,8 +163,6 @@ 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 ( iommu_enabled ) - pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio; } long arch_do_sysctl(xen/common/sysctl.c +2
-0@@ -267,6 +267,8 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) pi->cpu_khz = cpu_khz; pi->max_mfn =get_upper_mfn_bound ();arch_do_physinfo (pi); +if ( iommu_enabled ) + pi->capabilities |= XEN_SYSCTL_PHYSCAP_directio;if (copy_to_guest (u_sysctl, op,1 ) ) ret = -EFAULT ;xen/include/public/sysctl.h +3
-4@@ -81,13 +81,13 @@ struct xen_sysctl_tbuf_op {* Get physical information about the host machine */ /* XEN_SYSCTL_physinfo */ -/* (x86) The platform supports HVM guests. */ +/* The platform supports HVM guests. */ #define _XEN_SYSCTL_PHYSCAP_hvm 0#define XEN_SYSCTL_PHYSCAP_hvm (1u<<_XEN_SYSCTL_PHYSCAP_hvm) -/* (x86) The platform supports PV guests. */ +/* The platform supports PV guests. */ #define _XEN_SYSCTL_PHYSCAP_pv 1#define XEN_SYSCTL_PHYSCAP_pv (1u<<_XEN_SYSCTL_PHYSCAP_pv) -/* (x86) The platform supports direct access to I/O devices with IOMMU. */ +/* 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)struct xen_sysctl_physinfo { --2.22.0
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Jan Beulich
Acked-byRe: [Xen-devel] [PATCH v2 1/2] sysctl: report existing physcaps on ARM
Quoted 6 lines · Paul Durrant
Quoted 6 lines
From: Xen-devel <[email protected]> On Behalf Of Roger Pau Monne
Sent: 05 September 2019 14:27Current physcaps in
XEN_SYSCTL_physinfoare only used by x86, albeit the capabilities themselves are not x86 specific.
Quoted 8 lines
Quoted 6 lines
This patch adds support for also reporting the current capabilities on ARM hardware. Note that on ARM
PHYSCAP_hvmis always reported, and settingPHYSCAP_directiohas been moved to common code since the same logic to set it is used by x86 and ARM.Signed-off-by Roger Pau Monné <[email protected]>Reviewed-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 sysctl/libxl: choose a sane default for HAP
In reply to Roger Pau MonneCurrent 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.
Note that on ARM hardware HAP capability is always reported since it's a required feature in order to run Xen.
---
Cc: Paul Durrant <[email protected]>
---
Changes since v1:
- Also report HAP capability for ARM.
- Print hap capability in xl info.
--- tools/libxl/libxl.c | 1 + tools/libxl/libxl_create.c | 8 +++++++- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_info.c | 5 +++-- xen/arch/arm/sysctl.c | 2 +- xen/arch/x86/sysctl.c | 2 ++ xen/include/public/sysctl.h | 4 ++++ 7 files changed, 19 insertions(+), 4 deletions(-)
tools/libxl/libxl.c +1 -0
@@ -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 ;
tools/libxl/libxl_create.c +7 -1
@@ -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); }
tools/libxl/libxl_types.idl +1 -0
@@ -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", [
tools/xl/xl_info.c +3 -2
@@ -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);
xen/arch/arm/sysctl.c +1 -1
@@ -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,
xen/arch/x86/sysctl.c +2 -0
@@ -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(
xen/include/public/sysctl.h +4 -0
@@ -90,6 +90,10 @@ 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) +struct xen_sysctl_physinfo {uint32_t threads_per_core;uint32_t cores_per_socket;
Signature · 7 lines
2.22.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAP
Quoted 23 lines
-----Original Message-----
From: Roger Pau Monne <[email protected]>
Sent: 05 September 2019 14:27
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Anthony Perard <[email protected]>; Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Jan Beulich <[email protected]>; Julien Grall <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim (Xen.org) <[email protected]>; Volodymyr Babchuk <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAPCurrent 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.
Quoted 5 lines
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é <[email protected]>
LGTM
Quoted 120 lines
---
Cc: Paul Durrant <[email protected]>
---
Changes since v1:
- Also report HAP capability for ARM.
- Print hap capability in xl info.--- tools/libxl/libxl.c | 1 + tools/libxl/libxl_create.c | 8 +++++++- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_info.c | 5 +++-- xen/arch/arm/sysctl.c | 2 +- xen/arch/x86/sysctl.c | 2 ++ xen/include/public/sysctl.h | 4 ++++ 7 files changed, 19 insertions(+), 4 deletions(-)tools/libxl/libxl.c +1
-0@@ -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 ;tools/libxl/libxl_create.c +7
-1@@ -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); }tools/libxl/libxl_types.idl +1
-0@@ -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", [tools/xl/xl_info.c +3
-2@@ -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);xen/arch/arm/sysctl.c +1
-1@@ -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,xen/arch/x86/sysctl.c +2
-0@@ -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(xen/include/public/sysctl.h +4
-1@@ -90,6 +90,10 @@ 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) +struct xen_sysctl_physinfo {uint32_t threads_per_core;uint32_t cores_per_socket; --
Quoted 1 line
2.22.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Jan Beulich
Acked-byRe: [Xen-devel] [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAP
Quoted 17 lines · Paul Durrant
Quoted 17 lines
From: Roger Pau Monne <[email protected]>
Sent: 05 September 2019 14:27Current 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.Note that on ARM hardware HAP capability is always reported since it's a required feature in order to run Xen.
Quoted 6 lines
Quoted 2 lines
Fixes d0c0ba7d3de ('x86/hvm/domain: remove the 'hap_enabled' flag')Signed-off-by Roger Pau Monné <[email protected]>LGTM
Reviewed-by Paul Durrant <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAP
In reply to Paul DurrantQuoted 92 lines
-----Original Message-----
From: Xen-devel <[email protected]> On Behalf Of Paul Durrant
Sent: 05 September 2019 14:52
To: Roger Pau Monne <[email protected]>; [email protected]
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; Julien Grall <[email protected]>; Jan Beulich <[email protected]>; Anthony Perard <[email protected]>; Ian Jackson <[email protected]>; Volodymyr Babchuk <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAPQuoted 9 lines
-----Original Message-----
From: Roger Pau Monne <[email protected]>
Sent: 05 September 2019 14:27
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Anthony Perard <[email protected]>; Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Jan Beulich <[email protected]>; Julien Grall <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim (Xen.org) <[email protected]>; Volodymyr BabchukQuoted 14 lines
Paul Durrant <[email protected]>
Subject: [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAPCurrent 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.Quoted 5 lines
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é <[email protected]>LGTM
Reviewed-by Paul Durrant <[email protected]>Quoted 47 lines
---
Cc: Paul Durrant <[email protected]>
---
Changes since v1:
- Also report HAP capability for ARM.
- Print hap capability in xl info.--- tools/libxl/libxl.c | 1 + tools/libxl/libxl_create.c | 8 +++++++- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_info.c | 5 +++-- xen/arch/arm/sysctl.c | 2 +- xen/arch/x86/sysctl.c | 2 ++ xen/include/public/sysctl.h | 4 ++++ 7 files changed, 19 insertions(+), 4 deletions(-)tools/libxl/libxl.c +1
-0@@ -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 ;tools/libxl/libxl_create.c +7
-1@@ -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); }
Quoted 9 lines
tools/libxl/libxl_types.idl libxl_physinfo = Struct("physinfo", [ · line 1028
Quoted 9 lines
tools/libxl/libxl_types.idl +1
-0@@ -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),
Actually Julien's review of one of my patches points out that this idl change should be accompanied by an associated LIBXL_HAVE_CAP_HAP definition.
Paul
Quoted 62 lines
Quoted 62 lines
tools/libxl/libxl_types.idl +0
-0], dir=DIR_OUT) libxl_connectorinfo = Struct("connectorinfo", [tools/xl/xl_info.c +3
-2@@ -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);xen/arch/arm/sysctl.c +1
-1@@ -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,xen/arch/x86/sysctl.c +2
-0@@ -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(xen/include/public/sysctl.h +4
-0@@ -90,6 +90,10 @@ 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) +struct xen_sysctl_physinfo {uint32_t threads_per_core;
Quoted 8 lines
Quoted 3 lines
xen/include/public/sysctl.h +0
-1uint32_t cores_per_socket; --2.22.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAP
Quoted 92 lines · Paul Durrant
Quoted 92 lines
-----Original Message-----
From: Xen-devel <[email protected]> On Behalf Of Paul Durrant
Sent: 05 September 2019 14:52
To: Roger Pau Monne <[email protected]>; [email protected]
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; Julien Grall <[email protected]>; Jan Beulich <[email protected]>; Anthony Perard <[email protected]>; Ian Jackson <[email protected]>; Volodymyr Babchuk <[email protected]>; Roger Pau Monne <[email protected]>
Subject: Re: [Xen-devel] [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAPQuoted 9 lines
-----Original Message-----
From: Roger Pau Monne <[email protected]>
Sent: 05 September 2019 14:27
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Anthony Perard <[email protected]>; Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Jan Beulich <[email protected]>; Julien Grall <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim (Xen.org) <[email protected]>; Volodymyr BabchukQuoted 14 lines
Paul Durrant <[email protected]>
Subject: [PATCH v2 2/2] sysctl/libxl: choose a sane default for HAPCurrent 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.Quoted 5 lines
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é <[email protected]>LGTM
Reviewed-by Paul Durrant <[email protected]>Quoted 47 lines
---
Cc: Paul Durrant <[email protected]>
---
Changes since v1:
- Also report HAP capability for ARM.
- Print hap capability in xl info.--- tools/libxl/libxl.c | 1 + tools/libxl/libxl_create.c | 8 +++++++- tools/libxl/libxl_types.idl | 1 + tools/xl/xl_info.c | 5 +++-- xen/arch/arm/sysctl.c | 2 +- xen/arch/x86/sysctl.c | 2 ++ xen/include/public/sysctl.h | 4 ++++ 7 files changed, 19 insertions(+), 4 deletions(-)tools/libxl/libxl.c +1
-0@@ -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 ;tools/libxl/libxl_create.c +7
-1@@ -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); }
Quoted 11 lines
Quoted 9 lines
tools/libxl/libxl_types.idl libxl_physinfo = Struct("physinfo", [ · line 1028
Quoted 9 lines
tools/libxl/libxl_types.idl +1
-0@@ -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),Actually Julien's review of one of my patches points out that this idl change should be accompanied by an associated
LIBXL_HAVE_CAP_HAPdefinition.
Ouch, yes, I always forget those. I will add now, and keep your RB and Jan's Ack unless any of you tell me otherwise.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel