common/mem_access: merged mem_access setting interfaces
PATCH v2 1/1 common/mem_access: merged mem_access setting interfaces
xc_altp2m_set_mem_access() and xc_set_mem_access() end up doing the same thing in the hypervisor, but the former is a HVMOP and the latter a DOMCTL. Since nobody is currently using, or has stated intent to use, this functionality specifically as an HVMOP, this patch removes the HVMOP while adding an extra parameter to the more flexible DOMCTL variant, in which the altp2m view can be transmitted (0 for the default view, or when altp2m is disabled). The xen-access test has been updated in the process.
---
Changes since V1:
- Removed XEN_DOMCTL_INTERFACE_VERSION bump (as the "x86: remove PVHv1 code" already does this for this release).
- Replaced uint16_t pad; with uint16_t pad[3]; as suggested by Tamas.
--- tools/libxc/include/xenctrl.h | 10 +++------- tools/libxc/xc_altp2m.c | 25 ------------------------- tools/libxc/xc_mem_access.c | 14 +++++++++----- tools/tests/xen-access/xen-access.c | 25 ++++++++----------------- xen/arch/x86/hvm/hvm.c | 10 ---------- xen/common/mem_access.c | 4 ++-- xen/include/public/hvm/hvm_op.h | 15 +-------------- xen/include/public/memory.h | 2 ++ 8 files changed, 25 insertions(+), 80 deletions(-)
tools/libxc/include/xenctrl.h +3 -7
@@ -1923,9 +1923,6 @@ int xc_altp2m_destroy_view(xc_interface *handle, domid_t domid,/* Switch all vCPUs of the domain to the specified altp2m view */ int xc_altp2m_switch_to_view (xc_interface *handle,domid_t domid,uint16_t view_id); -int xc_altp2m_set_mem_access (xc_interface *handle,domid_t domid, -uint16_t view_id,xen_pfn_t gfn, -xenmem_access_t access);int xc_altp2m_change_gfn (xc_interface *handle,domid_t domid,uint16_t view_id,xen_pfn_t old_gfn,xen_pfn_t new_gfn);
@@ -1956,9 +1953,8 @@ int xc_mem_paging_load(xc_interface *xch, domid_t domain_id,* Allowed types are XENMEM_access_default, XENMEM_access_n, any combination of * XENMEM_access_ + (rwx), and XENMEM_access_rx2rw */ -int xc_set_mem_access (xc_interface *xch,domid_t domain_id, -xenmem_access_t access,uint64_t first_pfn, -uint32_t nr); +int xc_set_mem_access (xc_interface *xch,domid_t domain_id,uint16_t view_id, +xenmem_access_t access,uint64_t first_pfn,uint32_t nr);/* * Set an array of pages to their respective access in the access array.
@@ -1966,7 +1962,7 @@ int xc_set_mem_access(xc_interface *xch, domid_t domain_id,* The same allowed access types as for xc_set_mem_access() apply. */ int xc_set_mem_access_multi (xc_interface *xch,domid_t domain_id, -uint8_t *access,uint64_t *pages, +uint16_t view_id,uint8_t *access,uint64_t *pages,uint32_t nr);/*
tools/libxc/xc_altp2m.c +0 -25
@@ -163,31 +163,6 @@ int xc_altp2m_switch_to_view(xc_interface *handle, domid_t domid,return rc; } -int xc_altp2m_set_mem_access (xc_interface *handle,domid_t domid, -uint16_t view_id,xen_pfn_t gfn, -xenmem_access_t access) -{ -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_set_mem_access; - arg->domain = domid; - arg->u.set_mem_access.view = view_id; - arg->u.set_mem_access.hvmmem_access = access; - arg->u.set_mem_access.gfn = gfn; - - rc =xencall2 (handle->xcall, __HYPERVISOR_hvm_op, HVMOP_altp2m, -HYPERCALL_BUFFER_AS_ARG (arg)); - -xc_hypercall_buffer_free (handle, arg); -return rc; -} -int xc_altp2m_change_gfn (xc_interface *handle,domid_t domid,uint16_t view_id,xen_pfn_t old_gfn,xen_pfn_t new_gfn)
tools/libxc/xc_mem_access.c +9 -5
@@ -25,17 +25,19 @@int xc_set_mem_access (xc_interface *xch,domid_t domain_id, +uint16_t view_id,xenmem_access_t access,uint64_t first_pfn,uint32_t nr) {xen_mem_access_op_t mao = { - .op = XENMEM_access_op_set_access, - .domid = domain_id, - .access = access, - .pfn = first_pfn, - .nr = nr + .op = XENMEM_access_op_set_access, + .domid = domain_id, + .access = access, + .pfn = first_pfn, + .nr = nr, + .view_id = view_id };return do_memory_op (xch, XENMEM_access_op, &mao,sizeof (mao));
@@ -43,6 +45,7 @@ int xc_set_mem_access(xc_interface *xch,int xc_set_mem_access_multi (xc_interface *xch,domid_t domain_id, +uint16_t view_id,uint8_t *access,uint64_t *pages,uint32_t nr)
@@ -59,6 +62,7 @@ int xc_set_mem_access_multi(xc_interface *xch, .access = XENMEM_access_default + 1, /* Invalid value */ .pfn = ~0UL, /* Invalid GFN */ .nr = nr, + .view_id = view_id, }; if ( xc_hypercall_bounce_pre(xch, pages) ||
tools/tests/xen-access/xen-access.c +8 -17
@@ -475,9 +475,6 @@ int main(int argc, char *argv[])/* With altp2m we just create a new, restricted view of the memory */ if ( memaccess && altp2m ) { -xen_pfn_t gfn =0 ; -unsigned long perm_set =0 ; - rc =xc_altp2m_set_domain_state ( xch, domain_id,1 );if ( rc <0 ) {
@@ -495,15 +492,9 @@ int main(int argc, char *argv[])DPRINTF ("altp2m view created with id %u\n" , altp2m_view_id);DPRINTF ("Setting altp2m mem_access permissions.. " ); -for (; gfn < xenaccess->max_gpfn; ++gfn) - { - rc =xc_altp2m_set_mem_access ( xch, domain_id, altp2m_view_id, gfn, - default_access); -if ( !rc ) - perm_set++; - } - -DPRINTF ("done! Permissions set on %lu pages.\n" , perm_set); + rc =xc_set_mem_access (xch, domain_id, altp2m_view_id, default_access, +0 , xenaccess->max_gpfn); +DPRINTF ("done!" ); rc =xc_altp2m_switch_to_view ( xch, domain_id, altp2m_view_id );if ( rc <0 )
@@ -523,14 +514,14 @@ int main(int argc, char *argv[])if ( memaccess && !altp2m ) {/* Set the default access type and convert all pages to it */ - rc =xc_set_mem_access (xch, domain_id, default_access, ~0ull ,0 ); + rc =xc_set_mem_access (xch, domain_id,0 , default_access, ~0ull ,0 );if ( rc <0 ) {ERROR ("Error %d setting default mem access type\n" , rc); goto exit; } - rc =xc_set_mem_access (xch, domain_id, default_access,START_PFN , + rc =xc_set_mem_access (xch, domain_id,0 , default_access,START_PFN , (xenaccess->max_gpfn -START_PFN ) );if ( rc <0 )
@@ -606,8 +597,8 @@ int main(int argc, char *argv[]) rc =xc_altp2m_set_domain_state (xch, domain_id,0 ); rc =xc_monitor_singlestep (xch, domain_id,0 ); }else { - rc =xc_set_mem_access (xch, domain_id, XENMEM_access_rwx, ~0ull ,0 ); - rc =xc_set_mem_access (xch, domain_id, XENMEM_access_rwx,START_PFN , + rc =xc_set_mem_access (xch, domain_id,0 , XENMEM_access_rwx, ~0ull ,0 ); + rc =xc_set_mem_access (xch, domain_id,0 , XENMEM_access_rwx,START_PFN , (xenaccess->max_gpfn -START_PFN ) ); }
@@ -685,7 +676,7 @@ int main(int argc, char *argv[]) }else if ( default_access != after_first_access ) { - rc =xc_set_mem_access (xch, domain_id, after_first_access, + rc =xc_set_mem_access (xch, domain_id,0 , after_first_access, req.u.mem_access.gfn,1 );if (rc <0 ) {
xen/arch/x86/hvm/hvm.c +0 -10
@@ -4343,7 +4343,6 @@ static int do_altp2m_op(case HVMOP_altp2m_create_p2m:case HVMOP_altp2m_destroy_p2m:case HVMOP_altp2m_switch_p2m: -case HVMOP_altp2m_set_mem_access:case HVMOP_altp2m_change_gfn:break ;default :
@@ -4451,15 +4450,6 @@ static int do_altp2m_op( rc =p2m_switch_domain_altp2m_by_id (d, a.u.view.view);break ; -case HVMOP_altp2m_set_mem_access: -if ( a.u.set_mem_access.pad ) - rc = -EINVAL ; -else - rc =p2m_set_mem_access (d,_gfn (a.u.set_mem_access.gfn),1 ,0 ,0 , - a.u.set_mem_access.hvmmem_access, - a.u.set_mem_access.view); -break ; -case HVMOP_altp2m_change_gfn:if ( a.u.change_gfn.pad1 || a.u.change_gfn.pad2 ) rc = -EINVAL ;
xen/common/mem_access.c +2 -2
@@ -67,7 +67,7 @@ int mem_access_memop(unsigned long cmd,break ; rc =p2m_set_mem_access (d,_gfn (mao.pfn), mao.nr, start_iter, -MEMOP_CMD_MASK , mao.access,0 ); +MEMOP_CMD_MASK , mao.access, mao.view_id);if ( rc >0 ) {ASSERT (!(rc &MEMOP_CMD_MASK ));
@@ -78,7 +78,7 @@ int mem_access_memop(unsigned long cmd,case XENMEM_access_op_set_access_multi: rc =p2m_set_mem_access_multi (d, mao.pfn_list, mao.access_list, mao.nr, - start_iter,MEMOP_CMD_MASK ,0 ); + start_iter,MEMOP_CMD_MASK , mao.view_id);if ( rc >0 ) {ASSERT (!(rc &MEMOP_CMD_MASK ));
xen/include/public/hvm/hvm_op.h +1 -14
@@ -219,18 +219,6 @@ struct xen_hvm_altp2m_view {typedef struct xen_hvm_altp2m_view xen_hvm_altp2m_view_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_view_t); -struct xen_hvm_altp2m_set_mem_access { -/* view */ -uint16_t view; -/* Memory type */ -uint16_t hvmmem_access;/* xenmem_access_t */ -uint32_t pad; -/* gfn */ -uint64_t gfn; -}; -typedef struct xen_hvm_altp2m_set_mem_access xen_hvm_altp2m_set_mem_access_t ; -DEFINE_XEN_GUEST_HANDLE (xen_hvm_altp2m_set_mem_access_t); -struct xen_hvm_altp2m_change_gfn {/* view */ uint16_t view;
@@ -258,7 +246,7 @@ struct xen_hvm_altp2m_op {#define HVMOP_altp2m_destroy_p2m 5/* Switch view for an entire domain */ #define HVMOP_altp2m_switch_p2m 6 -/* Notify that a page of memory is to have specific access types */ +/* Deprecated by XENMEM_access_op_set_access */ #define HVMOP_altp2m_set_mem_access 7/* Change a p2m entry to have a different gfn->mfn mapping */ #define HVMOP_altp2m_change_gfn 8
@@ -269,7 +257,6 @@ struct xen_hvm_altp2m_op {struct xen_hvm_altp2m_domain_state domain_state;struct xen_hvm_altp2m_vcpu_enable_notify enable_notify;struct xen_hvm_altp2m_view view; -struct xen_hvm_altp2m_set_mem_access set_mem_access;struct xen_hvm_altp2m_change_gfn change_gfn;uint8_t pad[64 ]; } u;
xen/include/public/memory.h +2 -0
@@ -444,6 +444,8 @@ struct xen_mem_access_op {/* xenmem_access_t */ uint8_t access;domid_t domid; +uint16_t view_id; +uint16_t pad[3 ];/* * Number of pages for set op (or size of pfn_list for * XENMEM_access_op_set_access_multi)
Signature · 7 lines
1.9.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 9 lines · Razvan Cojocaru
xc_altp2m_set_mem_access()andxc_set_mem_access()end up doing the same thing in the hypervisor, but the former is a HVMOP and the latter a DOMCTL. Since nobody is currently using, or has stated intent to use, this functionality specifically as an HVMOP, this patch removes the HVMOP while adding an extra parameter to the more flexible DOMCTL variant, in which the altp2m view can be transmitted (0 for the default view, or when altp2m is disabled). The xen-access test has been updated in the process.Signed-off-by Razvan Cojocaru <[email protected]>
I am sorry to be awkward here, but as this patch stands, it definitely breaks the original usecase altp2m was introduced for. Therefore, I don't it is appropriate to take in this form.
The problem is that the current permissions are too coarse-grained.
Intel's use case needs all hypercalls usable by the guest, as the agent is entirely in-guest. (It also occurs to me that scenario might be useful to develop within.)
Bitdefenders use case needs vmfunc usable by the guest, but all alteration of view permissions must be restricted to a more privileged entity.
Tamas' usecase is (IIRC) entirely behind the back of the guest.
As a result, the two choices needed are "can a guest configure/use vmfunc", and "can a guest alter its own view permissions".
These should cater to all usecases, as far as I understand.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 25 lines · Andrew Cooper
Quoted 9 lines · Razvan Cojocaru
xc_altp2m_set_mem_access()andxc_set_mem_access()end up doing the same thing in the hypervisor, but the former is a HVMOP and the latter a DOMCTL. Since nobody is currently using, or has stated intent to use, this functionality specifically as an HVMOP, this patch removes the HVMOP while adding an extra parameter to the more flexible DOMCTL variant, in which the altp2m view can be transmitted (0 for the default view, or when altp2m is disabled). The xen-access test has been updated in the process.Signed-off-by Razvan Cojocaru <[email protected]>I am sorry to be awkward here, but as this patch stands, it definitely breaks the original usecase altp2m was introduced for. Therefore, I don't it is appropriate to take in this form.
The problem is that the current permissions are too coarse-grained.
Intel's use case needs all hypercalls usable by the guest, as the agent is entirely in-guest. (It also occurs to me that scenario might be useful to develop within.)
Bitdefenders use case needs vmfunc usable by the guest, but all alteration of view permissions must be restricted to a more privileged entity.
Quoted 7 lines
Tamas' usecase is (IIRC) entirely behind the back of the guest.
As a result, the two choices needed are "can a guest configure/use vmfunc", and "can a guest alter its own view permissions".
These should cater to all usecases, as far as I understand.
Alright, but in that case I'm not sure how to proceed with this. Would returning to the previous form of the patch (adding another HVMOP + solving the compat issues) work? Or are you proposing an altogether different mechanism, alongside which this merge would work?
As for Intel's use case, we've unfortunately had no reply from Ravi Sahita (CCd on the discussion even before V1 was sent). If somebody knows other email addresses we should use, please CC them.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 15 lines · Andrew Cooper
Quoted 9 lines · Razvan Cojocaru
xc_altp2m_set_mem_access()andxc_set_mem_access()end up doing the same thing in the hypervisor, but the former is a HVMOP and the latter a DOMCTL. Since nobody is currently using, or has stated intent to use, this functionality specifically as an HVMOP, this patch removes the HVMOP while adding an extra parameter to the more flexible DOMCTL variant, in which the altp2m view can be transmitted (0 for the default view, or when altp2m is disabled). The xen-access test has been updated in the process.Signed-off-by Razvan Cojocaru <[email protected]>I am sorry to be awkward here, but as this patch stands, it definitely breaks the original usecase altp2m was introduced for. Therefore, I don't it is appropriate to take in this form.
Quoted 5 lines
The problem is that the current permissions are too coarse-grained.
Intel's use case needs all hypercalls usable by the guest, as the agent is entirely in-guest. (It also occurs to me that scenario might be useful to develop within.)
Actually upon reading this again:
https://lists.xenproject.org/archives/html/xen-devel/2015-06/msg01319.html
it doesn't look like Intel's use case is for entirely in-guest agents (although granted that's a possiblity):
"The altp2m capability allows for para-virtualized guest software agent within or across domains to be able to enforce memory introspection policies in an efficient manner. Altp2m also allows para-virtualized guest agent components to be isolated within an HVM (in terms of guest physical memory) for secure VM introspection as well as various other security and privacy usages that require efficient memory isolation."
I could be misreading this, but "para-virtualized guest agent components" sound more like a different domain than a typical in-HVM-guest application.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 30 lines · Andrew Cooper
Quoted 1 line · Razvan Cojocaru
xc_altp2m_set_mem_access()andxc_set_mem_access()end up doing the samething
Quoted 1 line
in the hypervisor, but the former is a HVMOP and the latter a DOMCTL.
Since
Quoted 1 line
nobody is currently using, or has stated intent to use, this
functionality
Quoted 1 line
specifically as an HVMOP, this patch removes the HVMOP while adding an
extra
Quoted 1 line
parameter to the more flexible DOMCTL variant, in which the altp2m view
can be
Quoted 4 lines
transmitted (0 for the default view, or when altp2m is disabled). The xen-access test has been updated in the process.
Signed-off-by Razvan Cojocaru <[email protected]>I am sorry to be awkward here, but as this patch stands, it definitely breaks the original usecase altp2m was introduced for. Therefore, I don't it is appropriate to take in this form.
The problem is that the current permissions are too coarse-grained.
Intel's use case needs all hypercalls usable by the guest, as the agent is entirely in-guest. (It also occurs to me that scenario might be useful to develop within.)
Bitdefenders use case needs vmfunc usable by the guest, but all alteration of view permissions must be restricted to a more privileged entity.
Quoted 8 lines
Tamas' usecase is (IIRC) entirely behind the back of the guest.
As a result, the two choices needed are "can a guest configure/use vmfunc", and "can a guest alter its own view permissions".
These should cater to all usecases, as far as I understand.
So I have an outstanding patch that addressed this issue, at least
partially: https://patchwork.kernel.org/patch/9284861. It was part of a larger series that didn't yet make it to upstream but it doesn't depend on anything in that series so we could take it out. The goal with that patch was to be able to indicate how the default altp2m should behave, ie. mixed internal-external use, or purely external. If there is a need for a third option that would specify that only the #VE call should be enabled from within the guest, that could probably be added.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
xen/include/public/memory.h struct xen_mem_access_op { · line 448
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 10:50, <[email protected]> wrote:
xen/include/public/memory.h +2
-0@@ -444,6 +444,8 @@ struct xen_mem_access_op {/* xenmem_access_t */ uint8_t access;domid_t domid; +uint16_t view_id; +uint16_t pad[3 ];
Irrespective of Andrew's valid general objection, the change above wouldn't be valid either: How would you guarantee compatibility with old callers? Other than in e.g. domctl/sysctl there's no interface version here which can be bumped, so simply adding fields to a structure and re-using an existing sub-op won't do.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 15 lines · Jan Beulich
xen/include/public/memory.h struct xen_mem_access_op { · line 448
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 10:50, <[email protected]> wrote:
xen/include/public/memory.h +2
-0@@ -444,6 +444,8 @@ struct xen_mem_access_op {/* xenmem_access_t */ uint8_t access;domid_t domid; +uint16_t view_id; +uint16_t pad[3 ];Irrespective of Andrew's valid general objection, the change above wouldn't be valid either: How would you guarantee compatibility with old callers? Other than in e.g. domctl/sysctl there's no interface version here which can be bumped, so simply adding fields to a structure and re-using an existing sub-op won't do.
I wouldn't - I thought simply bumping the DOMCTL version macro would be enough, but obviously I could just add other DOMCTLs and return an error for the old ones.
In any case, back when I've added xc_set_mem_access_multi() I've also modified struct xen_mem_access_op in the same manner:
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 17 lines · Razvan Cojocaru
Quoted 15 lines · Jan Beulich
xen/include/public/memory.h struct xen_mem_access_op { · line 448
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 10:50, <[email protected]> wrote:
xen/include/public/memory.h +2
-0@@ -444,6 +444,8 @@ struct xen_mem_access_op {/* xenmem_access_t */ uint8_t access;domid_t domid; +uint16_t view_id; +uint16_t pad[3 ];Irrespective of Andrew's valid general objection, the change above wouldn't be valid either: How would you guarantee compatibility with old callers? Other than in e.g. domctl/sysctl there's no interface version here which can be bumped, so simply adding fields to a structure and re-using an existing sub-op won't do.
Quoted 8 lines
I wouldn't - I thought simply bumping the DOMCTL version macro would be enough, but obviously I could just add other DOMCTLs and return an error for the old ones.
In any case, back when I've added
xc_set_mem_access_multi()I've also modified structxen_mem_access_opin the same manner:
Oh, nevermind, I think you're referring to the fact that I had back then added members to the end of the structure, and so the old layout had remained compatible. Point taken.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:16, <[email protected]> wrote:
Quoted 17 lines · Razvan Cojocaru
Quoted 15 lines · Jan Beulich
xen/include/public/memory.h struct xen_mem_access_op { · line 448
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 10:50, <[email protected]> wrote:
xen/include/public/memory.h +2
-0@@ -444,6 +444,8 @@ struct xen_mem_access_op {/* xenmem_access_t */ uint8_t access;domid_t domid; +uint16_t view_id; +uint16_t pad[3 ];Irrespective of Andrew's valid general objection, the change above wouldn't be valid either: How would you guarantee compatibility with old callers? Other than in e.g. domctl/sysctl there's no interface version here which can be bumped, so simply adding fields to a structure and re-using an existing sub-op won't do.
Quoted 3 lines
Quoted 3 lines
I wouldn't - I thought simply bumping the DOMCTL version macro would be enough, but obviously I could just add other DOMCTLs and return an error for the old ones.
I miss the connection to domctl here - this is a mem-op, isn't it?
Quoted 10 lines
Quoted 4 lines
In any case, back when I've added
xc_set_mem_access_multi()I've also modified structxen_mem_access_opin the same manner:http://xenbits.xenproject.org/gitweb/?p=xen.git;a=commitdiff;h=1ef5056bd6274e
cbe065387b6cf45657d6d700cdOh, nevermind, I think you're referring to the fact that I had back then added members to the end of the structure, and so the old layout had remained compatible. Point taken.
Not just that - there you've also introduced a new sub-op.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 19 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:16, <[email protected]> wrote:
Quoted 17 lines · Razvan Cojocaru
Quoted 15 lines · Jan Beulich
xen/include/public/memory.h struct xen_mem_access_op { · line 448
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 10:50, <[email protected]> wrote:
xen/include/public/memory.h +2
-0@@ -444,6 +444,8 @@ struct xen_mem_access_op {/* xenmem_access_t */ uint8_t access;domid_t domid; +uint16_t view_id; +uint16_t pad[3 ];Irrespective of Andrew's valid general objection, the change above wouldn't be valid either: How would you guarantee compatibility with old callers? Other than in e.g. domctl/sysctl there's no interface version here which can be bumped, so simply adding fields to a structure and re-using an existing sub-op won't do.
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
I wouldn't - I thought simply bumping the DOMCTL version macro would be enough, but obviously I could just add other DOMCTLs and return an error for the old ones.
I miss the connection to domctl here - this is a mem-op, isn't it?
Yes, sorry, I meant mem-ops.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
In any case, back when I've added
xc_set_mem_access_multi()I've also modified structxen_mem_access_opin the same manner:
Quoted 8 lines
Quoted 6 lines
http://xenbits.xenproject.org/gitweb/?p=xen.git;a=commitdiff;h=1ef5056bd6274e
cbe065387b6cf45657d6d700cdOh, nevermind, I think you're referring to the fact that I had back then added members to the end of the structure, and so the old layout had remained compatible. Point taken.
Not just that - there you've also introduced a new sub-op.
Yes, but by modifying the structure for use with XENMEM_access_op_set_access_multi, it's now also changed for, e.g., XENMEM_access_op_set_access - since it's common to them. Other than the place where the new data has been added, I believe that the same critique would apply to the old patch, unless I'm misunderstanding something.
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:48, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:16, <[email protected]> wrote:
Quoted 4 lines · Razvan Cojocaru
In any case, back when I've added
xc_set_mem_access_multi()I've also modified structxen_mem_access_opin the same manner:http://xenbits.xenproject.org/gitweb/?p=xen.git;a=commitdiff;h=1ef5056bd6274e
cbe065387b6cf45657d6d700cdOh, nevermind, I think you're referring to the fact that I had back then added members to the end of the structure, and so the old layout had remained compatible. Point taken.
Quoted 8 lines
Quoted 1 line
Not just that - there you've also introduced a new sub-op.
Yes, but by modifying the structure for use with
XENMEM_access_op_set_access_multi, it's now also changed for, e.g.,XENMEM_access_op_set_access- since it's common to them. Other than the place where the new data has been added, I believe that the same critique would apply to the old patch, unless I'm misunderstanding something.
Indeed, strictly speaking that change wasn't really okay either, as someone passing the smaller structure near the end of a page might get -EFAULT back. So we're trying to do better this time ...
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 24 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:48, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:16, <[email protected]> wrote:
Quoted 4 lines · Razvan Cojocaru
In any case, back when I've added
xc_set_mem_access_multi()I've also modified structxen_mem_access_opin the same manner:http://xenbits.xenproject.org/gitweb/?p=xen.git;a=commitdiff;h=1ef5056bd6274e
cbe065387b6cf45657d6d700cdOh, nevermind, I think you're referring to the fact that I had back then added members to the end of the structure, and so the old layout had remained compatible. Point taken.
Quoted 8 lines
Quoted 1 line
Not just that - there you've also introduced a new sub-op.
Yes, but by modifying the structure for use with
XENMEM_access_op_set_access_multi, it's now also changed for, e.g.,XENMEM_access_op_set_access- since it's common to them. Other than the place where the new data has been added, I believe that the same critique would apply to the old patch, unless I'm misunderstanding something.
Quoted 3 lines
Indeed, strictly speaking that change wasn't really okay either, as someone passing the smaller structure near the end of a page might get
-EFAULTback. So we're trying to do better this time ...
Two question remain to be answered then:
1. How should this proceed? Andrew's comment, taken together with Tamas' last patch ("altp2m: Allow specifying external-only use-case") would seem to imply that the best way forward is to revert to the previous patch which duplicates the xc_set_mem_access_multi()'s mem-op with xc_altp2m_set_mem_access_multi()'s HVMOP (with the compat code to be worked out). Is there a consensus on this?
2. What is the best way to avoid incompatibilities such as the one mentioned? For example, in this case, should I have deprecated XENMEM_access_op_set_access and XENMEM_access_op_set_access_multi and added XENMEM_access_op_set_access2 and XENMEM_access_op_set_access2? Or do you have something different in mind?
Thanks,
Razvan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 40 lines · Razvan Cojocaru
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:48, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:16, <[email protected]> wrote:
Quoted 4 lines · Razvan Cojocaru
In any case, back when I've added
xc_set_mem_access_multi()I've also modified structxen_mem_access_opin the same manner:commitdiff;h=1ef5056bd6274e
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
cbe065387b6cf45657d6d700cdOh, nevermind, I think you're referring to the fact that I had back
then
Quoted 12 lines
Quoted 11 lines
Quoted 4 lines
Quoted 2 lines
added members to the end of the structure, and so the old layout had remained compatible. Point taken.
Not just that - there you've also introduced a new sub-op.
Yes, but by modifying the structure for use with
XENMEM_access_op_set_access_multi, it's now also changed for, e.g.,XENMEM_access_op_set_access- since it's common to them. Other than the place where the new data has been added, I believe that the same critique would apply to the old patch, unless I'm misunderstanding something.Quoted 3 lines
Indeed, strictly speaking that change wasn't really okay either, as someone passing the smaller structure near the end of a page might get
-EFAULTback. So we're trying to do better this time ...Two question remain to be answered then:
1. How should this proceed? Andrew's comment, taken together with Tamas' last patch ("altp2m: Allow specifying external-only use-case") would seem to imply that the best way forward is to revert to the previous patch which duplicates the xc_set_mem_access_multi()'s mem-op with xc_altp2m_set_mem_access_multi()'s HVMOP (with the compat code to be worked out). Is there a consensus on this?
Quoted 6 lines
2. What is the best way to avoid incompatibilities such as the one mentioned? For example, in this case, should I have deprecated
XENMEM_access_op_set_accessandXENMEM_access_op_set_access_multiand addedXENMEM_access_op_set_access2andXENMEM_access_op_set_access2? Or do you have something different in mind?
IMHO deprecating the old memops shouldn't be needed. The code on the hypervisor side all lands in the same spot, so keeping both memops (and the hvmop) in place should add no extra work from a maintenance perspective.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 32 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 21:20, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:48, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · On 20.03.17 at 17:16, <[email protected]> wrote:
Quoted 4 lines · Razvan Cojocaru
In any case, back when I've added
xc_set_mem_access_multi()I've also modified structxen_mem_access_opin the same manner:http://xenbits.xenproject.org/gitweb/?p=xen.git;a=commitdiff;h=1ef5056bd6274e
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
cbe065387b6cf45657d6d700cdOh, nevermind, I think you're referring to the fact that I had back then added members to the end of the structure, and so the old layout had remained compatible. Point taken.
Quoted 8 lines
Quoted 1 line
Not just that - there you've also introduced a new sub-op.
Yes, but by modifying the structure for use with
XENMEM_access_op_set_access_multi, it's now also changed for, e.g.,XENMEM_access_op_set_access- since it's common to them. Other than the place where the new data has been added, I believe that the same critique would apply to the old patch, unless I'm misunderstanding something.Quoted 3 lines
Indeed, strictly speaking that change wasn't really okay either, as someone passing the smaller structure near the end of a page might get
-EFAULTback. So we're trying to do better this time ...
Quoted 8 lines
Two question remain to be answered then:
1. How should this proceed? Andrew's comment, taken together with Tamas' last patch ("altp2m: Allow specifying external-only use-case") would seem to imply that the best way forward is to revert to the previous patch which duplicates the xc_set_mem_access_multi()'s mem-op with xc_altp2m_set_mem_access_multi()'s HVMOP (with the compat code to be worked out). Is there a consensus on this?
To reach consensus we first need to get a firm understanding of the requirements of all interested parties. With Ravi not responding, I've added Paul in the hopes that he may be able to track down who in Intel is currently able to represent their altp2m intentions.
Quoted 5 lines
2. What is the best way to avoid incompatibilities such as the one mentioned? For example, in this case, should I have deprecated
XENMEM_access_op_set_accessandXENMEM_access_op_set_access_multiand addedXENMEM_access_op_set_access2andXENMEM_access_op_set_access2? Or do you have something different in mind?
Indeed it looks like there would be no way around introducing a new sub-op. We should then take the opportunity and make it extensible from the beginning, unless we all agree to it not being a problem to possibly have to introduce further new sub- ops down the road. Whether such introduction implies deprecation of the old ones is a separate decision.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel