xen: Introduce arch specific field to XEN_SYSCTL_physinfo
RFC PATCH 1/1 xen: Introduce arch specific field to XEN_SYSCTL_physinfo
From: Oleksandr Tyshchenko <[email protected]>
We need to pass info about maximum supported address space size to the toolstack on Arm in order to properly calculate the base and size of the safe range for the guest. Use p2m_ipa_bits variable which purpose is to hold the bit size of IPAs in P2M tables.
As we change the size of structure bump the interface version.
---
You can find the discussion at:
https://lore.kernel.org/xen-devel/[email protected]/
Another possible option could be to introduce new Arm specific SYSCTL to pass such info. But, it was initially decided to not expand the SYSCTL range and reuse existing which context would fit.
--- tools/include/libxl.h | 7 +++++++ tools/libs/light/libxl.c | 3 +++ tools/libs/light/libxl_arch.h | 5 +++++ tools/libs/light/libxl_arm.c | 7 +++++++ tools/libs/light/libxl_types.idl | 5 +++++ tools/libs/light/libxl_x86.c | 6 ++++++ xen/arch/arm/sysctl.c | 1 + xen/include/public/arch-arm.h | 5 +++++ xen/include/public/arch-x86/xen.h | 2 ++ xen/include/public/sysctl.h | 3 ++- 10 files changed, 43 insertions(+), 1 deletion(-)
tools/include/libxl.h +7 -0
@@ -855,6 +855,13 @@ typedef struct libxl__ctx libxl_ctx;*/ #define LIBXL_HAVE_PHYSINFO_MAX_POSSIBLE_MFN 1 +/* +* LIBXL_HAVE_PHYSINFO_ARCH +* +* If this is defined, libxl_physinfo has a "arch" field. +*/ +#define LIBXL_HAVE_PHYSINFO_ARCH 1 +/* * LIBXL_HAVE_DOMINFO_OUTSTANDING_MEMKB 1 *
tools/libs/light/libxl.c +3 -0
@@ -15,6 +15,7 @@#include "libxl_osdeps.h" #include "libxl_internal.h" +#include "libxl_arch.h" int libxl_ctx_alloc (libxl_ctx **pctx,int version,unsigned flags,xentoollog_logger * lg)
@@ -405,6 +406,8 @@ int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo) physinfo->cap_vmtrace = !!(xcphysinfo.capabilities & XEN_SYSCTL_PHYSCAP_vmtrace); +libxl__arch_get_physinfo (gc, physinfo, &xcphysinfo); +GC_FREE ;return 0 ; }
tools/libs/light/libxl_arch.h +5 -0
@@ -90,6 +90,11 @@ void libxl__arch_update_domain_config(libxl__gc *gc,libxl_domain_config *dst, const libxl_domain_config *src); +_hidden +void libxl__arch_get_physinfo(libxl__gc *gc, +libxl_physinfo *to, +xc_physinfo_t *from); +#if defined(__i386__) || defined(__x86_64__)#define LAPIC_BASE_ADDRESS 0xfee00000
tools/libs/light/libxl_arm.c +7 -0
@@ -1236,6 +1236,13 @@ void libxl__arch_update_domain_config(libxl__gc *gc, { } +void libxl__arch_get_physinfo (libxl__gc *gc, +libxl_physinfo *to, +xc_physinfo_t *from) +{ + to->arch_arm.p2m_ipa_bits = from->arch.p2m_ipa_bits; +} +/* * Local variables: * mode: C
tools/libs/light/libxl_types.idl +5 -0
@@ -1061,6 +1061,11 @@ libxl_physinfo = Struct("physinfo", [ ("cap_shadow", bool), ("cap_iommu_hap_pt_share", bool), ("cap_vmtrace", bool), + + ("arch_arm", Struct(None, [("p2m_ipa_bits", uint32), + ])), + ("arch_x86", Struct(None, [ + ])), ], dir=DIR_OUT) libxl_connectorinfo = Struct("connectorinfo", [
tools/libs/light/libxl_x86.c +6 -0
@@ -882,6 +882,12 @@ void libxl__arch_update_domain_config(libxl__gc *gc, libxl_defbool_val(src->b_info.arch_x86.msr_relaxed)); } +void libxl__arch_get_physinfo (libxl__gc *gc, +libxl_physinfo *to, +xc_physinfo_t *from) +{ +} +/* * Local variables: * mode: C
xen/arch/arm/sysctl.c +1 -0
@@ -15,6 +15,7 @@void arch_do_physinfo (struct xen_sysctl_physinfo *pi) { pi->capabilities |= XEN_SYSCTL_PHYSCAP_hvm | XEN_SYSCTL_PHYSCAP_hap; + pi->arch.p2m_ipa_bits = p2m_ipa_bits; } long arch_do_sysctl(struct xen_sysctl *sysctl,
xen/include/public/arch-arm.h +5 -0
@@ -332,6 +332,11 @@ struct xen_arch_domainconfig {*/ uint32_t clock_frequency; }; + +struct arch_physinfo { +/* Holds the bit size of IPAs in p2m tables. */ +uint32_t p2m_ipa_bits; +};#endif /* __XEN__ || __XEN_TOOLS__ */ struct arch_vcpu_info {
xen/include/public/arch-x86/xen.h +2 -0
@@ -346,6 +346,8 @@ typedef struct xen_msr_entry { } xen_msr_entry_t;DEFINE_XEN_GUEST_HANDLE (xen_msr_entry_t); +struct arch_physinfo { +};#endif /* !__ASSEMBLY__ */ /*
xen/include/public/sysctl.h +2 -1
@@ -35,7 +35,7 @@#include "domctl.h" #include "physdev.h" -#define XEN_SYSCTL_INTERFACE_VERSION 0x00000013 +#define XEN_SYSCTL_INTERFACE_VERSION 0x00000014/* * Read console content from Xen buffer ring.
@@ -120,6 +120,7 @@ struct xen_sysctl_physinfo {uint64_aligned_t outstanding_pages;uint64_aligned_t max_mfn;/* Largest possible MFN on this host */ uint32_t hw_cap[8 ]; +struct arch_physinfo arch; };/*
Signature · 1 line
2.7.4
Quoted 6 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
We need to pass info about maximum supported address space size to the toolstack on Arm in order to properly calculate the base and size of the safe range for the guest. Use
p2m_ipa_bitsvariable which purpose is to hold the bit size of IPAs in P2M tables.
What is "the safe range"?
Quoted 17 lines
xen/include/public/arch-arm.h +5
-0@@ -332,6 +332,11 @@ struct xen_arch_domainconfig {*/ uint32_t clock_frequency; }; + +struct arch_physinfo { +/* Holds the bit size of IPAs in p2m tables. */ +uint32_t p2m_ipa_bits; +};#endif /* __XEN__ || __XEN_TOOLS__ */ struct arch_vcpu_info {
xen/include/public/arch-x86/xen.h typedef struct xen_msr_entry { · line 351
Quoted 6 lines
xen/include/public/arch-x86/xen.h +2
-0@@ -346,6 +346,8 @@ typedef struct xen_msr_entry { } xen_msr_entry_t;DEFINE_XEN_GUEST_HANDLE (xen_msr_entry_t); +struct arch_physinfo { +};#endif /* !__ASSEMBLY__ */
While the term "p2m_ipa_bits" surely isn't arch-agnostic, I wonder whether the expressed information is (the x86 equivalent being hap_paddr_bits, at a guess), and hence whether this really ought to live in an arch-specific sub-struct. If indeed so, please name the struct in a name space clean way, i.e. add xen_ as prefix.
Also please retain a blank line before the #endif. I wonder whether on Arm you wouldn't want to add one at this occasion.
Jan
On 16.08.21 10:33, Jan Beulich wrote:
Hi Jan
Sorry for the late response.
Quoted 8 lines · Oleksandr Tyshchenko
Quoted 6 lines
From: Oleksandr Tyshchenko <[email protected]>
We need to pass info about maximum supported address space size to the toolstack on Arm in order to properly calculate the base and size of the safe range for the guest. Use
p2m_ipa_bitsvariable which purpose is to hold the bit size of IPAs in P2M tables.What is "the safe range"?
It is unallocated (unused) address space which could be safely used by domain for foreign/grant mappings on Arm, I will update description.
Quoted 21 lines
Quoted 21 lines
xen/include/public/arch-arm.h +5
-0@@ -332,6 +332,11 @@ struct xen_arch_domainconfig {*/ uint32_t clock_frequency; }; + +struct arch_physinfo { +/* Holds the bit size of IPAs in p2m tables. */ +uint32_t p2m_ipa_bits; +};#endif /* __XEN__ || __XEN_TOOLS__ */ struct arch_vcpu_info {xen/include/public/arch-x86/xen.h +0
-0@@ -346,6 +346,8 @@ typedef struct xen_msr_entry { } xen_msr_entry_t;DEFINE_XEN_GUEST_HANDLE (xen_msr_entry_t);
Quoted 7 lines
xen/include/public/arch-x86/xen.h typedef struct xen_msr_entry { · line 351
Quoted 3 lines
xen/include/public/arch-x86/xen.h +2
-0+struct arch_physinfo { +};#endif /* !__ASSEMBLY__ */ While the term "
p2m_ipa_bits" surely isn't arch-agnostic, I wonder whether the expressed information is (the x86 equivalent beinghap_paddr_bits, at a guess), and hence whether this really ought to live in an arch-specific sub-struct.
Well, on Arm we calculate the number of the IPA bits based on the number of PA bits when setting Stage 2 address translation.
I might mistake, but what we currently have on Arm is "ipa_bits == pa_bits". So, this means that information we need at the toolstack side isn't really arch-specific and we could probably avoid introducing arch-specific sub-struct by suitable renaming the field (pa_bits, paddr_bits, whatever).
We could even name the field as hap_paddr_bits. Although, I don't know whether the hap_* is purely x86-ism, but I see there are several mentions in the common code (hap_pt_share, use_hap_pt, etc). Any suggestions?
Quoted 2 lines
If indeed so, please name
the struct in a name space clean way, i.e. addxen_as prefix.
ok
Quoted 3 lines
Also please retain a blank line before the #endif. I wonder whether on Arm you wouldn't want to add one at this occasion.
ok
Quoted 3 lines
Jan
Signature · 3 lines
Regards, Oleksandr Tyshchenko
Quoted 38 lines · Oleksandr
Quoted 21 lines · Jan Beulich
Quoted 20 lines · Oleksandr Tyshchenko
xen/include/public/arch-arm.h +5
-0@@ -332,6 +332,11 @@ struct xen_arch_domainconfig {*/ uint32_t clock_frequency; }; + +struct arch_physinfo { +/* Holds the bit size of IPAs in p2m tables. */ +uint32_t p2m_ipa_bits; +};#endif /* __XEN__ || __XEN_TOOLS__ */ struct arch_vcpu_info {xen/include/public/arch-x86/xen.h +0
-0@@ -346,6 +346,8 @@ typedef struct xen_msr_entry { } xen_msr_entry_t;DEFINE_XEN_GUEST_HANDLE (xen_msr_entry_t);Quoted 7 lines
xen/include/public/arch-x86/xen.h typedef struct xen_msr_entry { · line 351
Quoted 3 lines
xen/include/public/arch-x86/xen.h +2
-0+struct arch_physinfo { +};#endif /* !__ASSEMBLY__ */ While the term "
p2m_ipa_bits" surely isn't arch-agnostic, I wonder whether the expressed information is (the x86 equivalent beinghap_paddr_bits, at a guess), and hence whether this really ought to live in an arch-specific sub-struct.Well, on Arm we calculate the number of the IPA bits based on the number of PA bits when setting Stage 2 address translation.
I might mistake, but what we currently have on Arm is "ipa_bits==pa_bits". So, this means that information we need at the toolstack side isn't really arch-specific and
we could probably avoid introducing arch-specific sub-struct by suitable renaming the field (pa_bits,paddr_bits, whatever).
Quoted 4 lines
We could even name the field as
hap_paddr_bits. Although, I don't know whether the hap_* is purely x86-ism, but I see there are several mentions in the common code (hap_pt_share,use_hap_pt, etc). Any suggestions?
Well, HAP or not - there is going to be a limit to a guest's address bits. So I don't see why it would matter whether HAP is an x86-specific term. If you wanted to express the guest nature and distinguish it from "paddr_bits", how about "gaddr_bits" or "gpaddr_bits"?
Jan
On 30.08.21 16:16, Jan Beulich wrote:
Hi Jan
Quoted 38 lines · Oleksandr
Quoted 37 lines · Jan Beulich
Quoted 21 lines · Oleksandr Tyshchenko
Quoted 20 lines
xen/include/public/arch-arm.h +5
-0@@ -332,6 +332,11 @@ struct xen_arch_domainconfig {*/ uint32_t clock_frequency; }; + +struct arch_physinfo { +/* Holds the bit size of IPAs in p2m tables. */ +uint32_t p2m_ipa_bits; +};#endif /* __XEN__ || __XEN_TOOLS__ */ struct arch_vcpu_info {xen/include/public/arch-x86/xen.h +0
-0@@ -346,6 +346,8 @@ typedef struct xen_msr_entry { } xen_msr_entry_t;DEFINE_XEN_GUEST_HANDLE (xen_msr_entry_t);Quoted 7 lines
xen/include/public/arch-x86/xen.h typedef struct xen_msr_entry { · line 351
Quoted 3 lines
xen/include/public/arch-x86/xen.h +2
-0+struct arch_physinfo { +};#endif /* !__ASSEMBLY__ */ While the term "
p2m_ipa_bits" surely isn't arch-agnostic, I wonder whether the expressed information is (the x86 equivalent beinghap_paddr_bits, at a guess), and hence whether this really ought to live in an arch-specific sub-struct.Well, on Arm we calculate the number of the IPA bits based on the number of PA bits when setting Stage 2 address translation.
I might mistake, but what we currently have on Arm is "ipa_bits==pa_bits". So, this means that information we need at the toolstack side isn't really arch-specific and
we could probably avoid introducing arch-specific sub-struct by suitable renaming the field (pa_bits,paddr_bits, whatever).
Quoted 7 lines
Quoted 4 lines
We could even name the field as
hap_paddr_bits. Although, I don't know whether the hap_* is purely x86-ism, but I see there are several mentions in the common code (hap_pt_share,use_hap_pt, etc). Any suggestions?Well, HAP or not - there is going to be a limit to a guest's address bits. So I don't see why it would matter whether HAP is an x86-specific term.
agree
Quoted 3 lines
If you wanted to express the guest nature
and distinguish it from "paddr_bits", how about "gaddr_bits" or "gpaddr_bits"?
ok, both sound fine to me, with a little preference for gpaddr_bits. So, will drop arch-specific sub-struct for the next version.
Thank you.
Quoted 3 lines
Jan
Signature · 3 lines
Regards, Oleksandr Tyshchenko