x86/altp2m: Add xc_altp2m_get_vcpu_p2m_idx
PATCH 1/1 x86/altp2m: Add xc_altp2m_get_vcpu_p2m_idx
This new function returns the active altp2m index form a given vcp.
--- tools/libxc/include/xenctrl.h | 2 ++ tools/libxc/xc_altp2m.c | 25 +++++++++++++++++++++++++ xen/arch/x86/hvm/hvm.c | 24 ++++++++++++++++++++++++ xen/include/public/hvm/hvm_op.h | 11 +++++++++++ 4 files changed, 62 insertions(+)
tools/libxc/include/xenctrl.h +2 -0
@@ -1942,6 +1942,8 @@ int xc_altp2m_get_mem_access(xc_interface *handle, uint32_t domid,int xc_altp2m_change_gfn (xc_interface *handle,uint32_t domid,uint16_t view_id,xen_pfn_t old_gfn,xen_pfn_t new_gfn); +int xc_altp2m_get_vcpu_p2m_idx (xc_interface *handle,uint32_t domid, +uint32_t vcpuid,uint16_t *p2midx);/** * Mem paging operations.
tools/libxc/xc_altp2m.c +25 -0
@@ -352,3 +352,28 @@ int xc_altp2m_get_mem_access(xc_interface *handle, uint32_t domid,xc_hypercall_buffer_free (handle, arg);return rc; } + +int xc_altp2m_get_vcpu_p2m_idx (xc_interface *handle,uint32_t domid, +uint32_t vcpuid,uint16_t *altp2m_idx) +{ +int rc; + +DECLARE_HYPERCALL_BUFFER (xen_hvm_altp2m_op_t, arg); + + arg =xc_hypercall_buffer_alloc (handle, arg,sizeof (*arg)); +if ( arg ==NULL ) +return -1 ; + + arg->version =HVMOP_ALTP2M_INTERFACE_VERSION ; + arg->cmd = HVMOP_altp2m_get_p2m_idx; + arg->domain = domid; + arg->u.get_vcpu_p2m_idx.vcpu_id = vcpuid; + + rc =xencall2 (handle->xcall, __HYPERVISOR_hvm_op, HVMOP_altp2m, +HYPERCALL_BUFFER_AS_ARG (arg)); +if ( !rc ) + *altp2m_idx = arg->u.get_vcpu_p2m_idx.altp2m_idx; + +xc_hypercall_buffer_free (handle, arg); +return rc; +}
xen/arch/x86/hvm/hvm.c +24 -0
@@ -4500,6 +4500,7 @@ static int do_altp2m_op(case HVMOP_altp2m_set_mem_access_multi:case HVMOP_altp2m_get_mem_access:case HVMOP_altp2m_change_gfn: +case HVMOP_altp2m_get_p2m_idx:break ;default :
@@ -4735,6 +4736,29 @@ static int do_altp2m_op(_gfn (a.u.change_gfn.old_gfn), _gfn(a.u.change_gfn.new_gfn));break ; + +case HVMOP_altp2m_get_p2m_idx: + { +struct vcpu *v; + +if ( a.u.get_vcpu_p2m_idx.vcpu_id >= d->max_vcpus ) + { + rc = -EINVAL ; +break ; + } + +if ( !altp2m_active (d) ) + { + rc = -EOPNOTSUPP ; +break ; + } + + v = d->vcpu[a.u.get_vcpu_p2m_idx.vcpu_id]; + a.u.get_vcpu_p2m_idx.altp2m_idx =altp2m_vcpu_idx (v); + rc =__copy_to_guest (arg, &a,1 ) ? -EFAULT :0 ; +break ; + } +default :ASSERT_UNREACHABLE (); }
xen/include/public/hvm/hvm_op.h +11 -0
@@ -304,6 +304,14 @@ struct xen_hvm_altp2m_change_gfn {typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_change_gfn_t); +struct xen_hvm_altp2m_get_vcpu_p2m_idx { +uint32_t vcpu_id; +uint16_t altp2m_idx; +}; +typedef struct xen_hvm_altp2m_get_vcpu_p2m_idx +xen_hvm_altp2m_get_vcpu_p2m_idx_t ; +DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_get_vcpu_p2m_idx_t); +struct xen_hvm_altp2m_op {uint32_t version;/* HVMOP_ALTP2M_INTERFACE_VERSION */ uint32_t cmd;
@@ -332,6 +340,8 @@ struct xen_hvm_altp2m_op {#define HVMOP_altp2m_get_mem_access 12/* Disable altp2m event notifications for a given VCPU */ #define HVMOP_altp2m_vcpu_disable_notify 13 +/* Get the active vcpu p2m index */ +#define HVMOP_altp2m_get_p2m_idx 14domid_t domain;uint16_t pad1;uint32_t pad2;
@@ -347,6 +357,7 @@ struct xen_hvm_altp2m_op {struct xen_hvm_altp2m_set_mem_access_multi set_mem_access_multi;struct xen_hvm_altp2m_suppress_ve suppress_ve;struct xen_hvm_altp2m_vcpu_disable_notify disable_notify; +struct xen_hvm_altp2m_get_vcpu_p2m_idx get_vcpu_p2m_idx;uint8_t pad[64 ]; } u; };
Signature · 6 lines
2.17.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 13 lines
Quoted 1 line
Quoted 1 line · On 06.06.19 at 14:16, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +8
-0@@ -4735,6 +4736,29 @@ static int do_altp2m_op(_gfn (a.u.change_gfn.old_gfn), _gfn(a.u.change_gfn.new_gfn));break ; + +case HVMOP_altp2m_get_p2m_idx: + { +struct vcpu *v; + +if ( a.u.get_vcpu_p2m_idx.vcpu_id >= d->max_vcpus ) + { + rc = -EINVAL ;
xen/arch/x86/hvm/hvm.c static int do_altp2m_op( · line 4756
Quoted 10 lines
xen/arch/x86/hvm/hvm.c +10
-0+break ; + } + +if ( !altp2m_active (d) ) + { + rc = -EOPNOTSUPP ; +break ; + } + + v = d->vcpu[a.u.get_vcpu_p2m_idx.vcpu_id];
Please can you avoid re-introducing this access pattern? We have domain_vcpu() now exactly for this purpose.
xen/include/public/hvm/hvm_op.h struct xen_hvm_altp2m_change_gfn { · line 313
Quoted 13 lines
xen/include/public/hvm/hvm_op.h +7
-0@@ -304,6 +304,14 @@ struct xen_hvm_altp2m_change_gfn {typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_change_gfn_t); +struct xen_hvm_altp2m_get_vcpu_p2m_idx { +uint32_t vcpu_id; +uint16_t altp2m_idx; +}; +typedef struct xen_hvm_altp2m_get_vcpu_p2m_idx +xen_hvm_altp2m_get_vcpu_p2m_idx_t ; +DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_get_vcpu_p2m_idx_t);
What do you need this type and handle for?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 06.06.19 at 14:16, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +13
-0@@ -4735,6 +4736,29 @@ static int do_altp2m_op(_gfn (a.u.change_gfn.old_gfn), _gfn(a.u.change_gfn.new_gfn));break ; + +case HVMOP_altp2m_get_p2m_idx: + { +struct vcpu *v; + +if ( a.u.get_vcpu_p2m_idx.vcpu_id >= d->max_vcpus ) + { + rc = -EINVAL ; +break ; + } + +if ( !altp2m_active (d) ) + {
Quoted 8 lines
xen/arch/x86/hvm/hvm.c static int do_altp2m_op( · line 4756
Quoted 5 lines
xen/arch/x86/hvm/hvm.c +5
-0+ rc = -EOPNOTSUPP ; +break ; + } + + v = d->vcpu[a.u.get_vcpu_p2m_idx.vcpu_id];Please can you avoid re-introducing this access pattern? We have
domain_vcpu()now exactly for this purpose.
Ok, I will use domain_vcpu() in V2.
Quoted 7 lines
Quoted 7 lines
xen/include/public/hvm/hvm_op.h +0
-0@@ -304,6 +304,14 @@ struct xen_hvm_altp2m_change_gfn {typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_change_gfn_t);
Quoted 10 lines
xen/include/public/hvm/hvm_op.h struct xen_hvm_altp2m_change_gfn { · line 313
Quoted 7 lines
xen/include/public/hvm/hvm_op.h +7
-0+struct xen_hvm_altp2m_get_vcpu_p2m_idx { +uint32_t vcpu_id; +uint16_t altp2m_idx; +}; +typedef struct xen_hvm_altp2m_get_vcpu_p2m_idx +xen_hvm_altp2m_get_vcpu_p2m_idx_t ; +DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_get_vcpu_p2m_idx_t);What do you need this type and handle for?
You are right, this is useless here, I will drop it in v2.
Alex
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel