runstate/time area registration by (guest) physical address
v5 cover runstate/time area registration by (guest) physical address
Since it was indicated that introducing specific new vCPU ops may be beneficial independent of the introduction of a fully physical- address-based ABI flavor, here we go. There continue to be a few open questions throughout the series, resolving of which was one of the main goals of the earlier postings.
v5 adds one vm-fork specific pre-patch that does simply the introduced code later on. It does also fix a vm-fork bug.
Patches 1 and 6 are missing and Ack from the mem-sharing maintainer.
Whole series will need a Release-Ack.
Thanks, Roger.
Jan Beulich (9):
x86/shim: zap runstate and time area handles during shutdown
domain: GADDR based shared guest area registration alternative -
teardown
domain: update GADDR based runstate guest area
x86: update GADDR based secondary time area x86/mem-sharing: copy GADDR based shared guest areas
domain: map/unmap GADDR based shared guest areas
domain: introduce GADDR based runstate area registration alternative
x86: introduce GADDR based secondary time area registration
alternative
common: convert vCPU info area registration
Roger Pau Monne (1):
mem_sharing/fork: do not attempt to populate vcpu_info page
xen/arch/x86/domain.c | 33 +++ xen/arch/x86/include/asm/domain.h | 3 + xen/arch/x86/include/asm/shared.h | 19 +- xen/arch/x86/mm/mem_sharing.c | 73 +++---- xen/arch/x86/pv/shim.c | 10 +- xen/arch/x86/time.c | 34 +++- xen/arch/x86/x86_64/asm-offsets.c | 2 +- xen/arch/x86/x86_64/domain.c | 36 ++++ xen/arch/x86/x86_64/traps.c | 2 +- xen/common/compat/domain.c | 2 +- xen/common/domain.c | 324 ++++++++++++++++++++++-------- xen/include/public/vcpu.h | 19 ++ xen/include/xen/domain.h | 12 +- xen/include/xen/sched.h | 8 +- xen/include/xen/shared.h | 3 +- 15 files changed, 440 insertions(+), 140 deletions(-)
Signature · 1 line
2.42.0
PATCH v5 1/10 mem_sharing/fork: do not attempt to populate vcpu_info page
Instead let map_vcpu_info() and it's call to get_page_from_gfn() populate the page in the child as needed. Also remove the bogus copy_domain_page(): should be placed before the call to map_vcpu_info(), as the later can update the contents of the vcpu_info page.
Note that this eliminates a bug in copy_vcpu_settings(): The function did allocate a new page regardless of the GFN already having a mapping, thus in particular breaking the case of two vCPU-s having their info areas on the same page.
---
Only build tested.
---
Changes since v4:
- New in this version.
--- xen/arch/x86/mm/mem_sharing.c | 36 ++++++----------------------------- 1 file changed, 6 insertions(+), 30 deletions(-)
xen/arch/x86/mm/mem_sharing.c +6 -30
@@ -1689,48 +1689,24 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)unsigned int i;struct p2m_domain *p2m =p2m_get_hostp2m (cd);int ret = -EINVAL ; +mfn_t vcpu_info_mfn;for ( i =0 ; i < cd->max_vcpus; i++ ) {struct vcpu *d_vcpu = d->vcpu[i];struct vcpu *cd_vcpu = cd->vcpu[i]; -mfn_t vcpu_info_mfn;if ( !d_vcpu || !cd_vcpu )continue ; -/* Copy & map in the vcpu_info page if the guest uses one */ +/* Map in the vcpu_info page if the guest uses one */ vcpu_info_mfn = d_vcpu->vcpu_info_mfn;if ( !mfn_eq (vcpu_info_mfn,INVALID_MFN ) ) { -mfn_t new_vcpu_info_mfn = cd_vcpu->vcpu_info_mfn; - -/* Allocate & map the page for it if it hasn't been already */ -if (mfn_eq (new_vcpu_info_mfn,INVALID_MFN ) ) - { -gfn_t gfn =mfn_to_gfn (d, vcpu_info_mfn); -unsigned long gfn_l =gfn_x (gfn); -struct page_info *page; - -if ( !(page =alloc_domheap_page (cd,0 )) ) -return -ENOMEM ; - - new_vcpu_info_mfn =page_to_mfn (page); -set_gpfn_from_mfn (mfn_x (new_vcpu_info_mfn), gfn_l); - - ret = p2m->set_entry (p2m, gfn, new_vcpu_info_mfn, -PAGE_ORDER_4K , p2m_ram_rw, - p2m->default_access,-1 ); -if ( ret ) -return ret; - - ret =map_vcpu_info (cd_vcpu, gfn_l, -PAGE_OFFSET (d_vcpu->vcpu_info)); -if ( ret ) -return ret; - } - -copy_domain_page (new_vcpu_info_mfn, vcpu_info_mfn); + ret =map_vcpu_info (cd_vcpu,mfn_to_gfn (d, vcpu_info_mfn), +PAGE_OFFSET (d_vcpu->vcpu_info)); +if ( ret ) +return ret; } ret =copy_vpmu (d_vcpu, cd_vcpu);
Signature · 1 line
2.42.0
A message that is not in the archive (sent off-list or not yet received): CABfawhm2XMmfyx7vZvGdLZcot3=Mrrx3T5nS3vUR+Ur9j5mkWg@mail.gmail.com
Re: [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page
Quoted 17 lines · Tamas K Lengyel
Quoted 11 lines · Roger Pau Monne
Instead let
map_vcpu_info()and it's call toget_page_from_gfn()populate the page in the child as needed. Also remove the boguscopy_domain_page(): should be placed before the call tomap_vcpu_info(), as the later can update the contents of thevcpu_infopage.Note that this eliminates a bug in
copy_vcpu_settings(): The function did allocate a new page regardless of the GFN already having a mapping, thus in particular breaking the case of two vCPU-s having their info areas on the same page.Quoted 4 lines
Fixes 41548c5472a3 ('mem_sharing: VM forking')Signed-off-by Roger Pau Monné <[email protected]>---
Only build tested.
Quoted 5 lines
So this will allocate & map a page in, but its content won't be matching that of the parent. Is that not an issue? If there is no state on this page the guest is going to rely on, it looks fine to me. But if the guest may expect a certain state to be already setup on this page we could run into weird issues in the fork, no?
mem_sharing_fork_page() will do the copy from the parent, and this is what gets called from get_page_from_gfn().
map_vcpu_info() might change some of the vcpu_info contents when compared to the parent, but such changes could also happen without the fork, and the guest should be able to handle it just like any update to vcpu_info. There will likely be an spurious event channel upcall injected depending on the delivery method selected by the guest, but again this could also happen without the fork taking place.
Thanks, Roger.
Re: [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page
In reply to Roger Pau MonneHi,
While preparing to commit this series, I have noticed that there are no Acked-by/Reviewed-by from Tamas (or at least not present in my inbox).
@Tamas, can you provide one?
Cheers,
Quoted 80 lines · Roger Pau Monne
Instead let
map_vcpu_info()and it's call toget_page_from_gfn()populate the page in the child as needed. Also remove the boguscopy_domain_page(): should be placed before the call tomap_vcpu_info(), as the later can update the contents of thevcpu_infopage.Note that this eliminates a bug in
copy_vcpu_settings(): The function did allocate a new page regardless of the GFN already having a mapping, thus in particular breaking the case of two vCPU-s having their info areas on the same page.Fixes 41548c5472a3 ('mem_sharing: VM forking')Signed-off-by Roger Pau Monné <[email protected]>---
Only build tested.
---
Changes since v4:
- New in this version.--- xen/arch/x86/mm/mem_sharing.c | 36 ++++++----------------------------- 1 file changed, 6 insertions(+), 30 deletions(-)xen/arch/x86/mm/mem_sharing.c +6
-30@@ -1689,48 +1689,24 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)unsigned int i;struct p2m_domain *p2m =p2m_get_hostp2m (cd);int ret = -EINVAL ; +mfn_t vcpu_info_mfn;for ( i =0 ; i < cd->max_vcpus; i++ ) {struct vcpu *d_vcpu = d->vcpu[i];struct vcpu *cd_vcpu = cd->vcpu[i]; -mfn_t vcpu_info_mfn;if ( !d_vcpu || !cd_vcpu )continue ; -/* Copy & map in the vcpu_info page if the guest uses one */ +/* Map in the vcpu_info page if the guest uses one */ vcpu_info_mfn = d_vcpu->vcpu_info_mfn;if ( !mfn_eq (vcpu_info_mfn,INVALID_MFN ) ) { -mfn_t new_vcpu_info_mfn = cd_vcpu->vcpu_info_mfn; - -/* Allocate & map the page for it if it hasn't been already */ -if (mfn_eq (new_vcpu_info_mfn,INVALID_MFN ) ) - { -gfn_t gfn =mfn_to_gfn (d, vcpu_info_mfn); -unsigned long gfn_l =gfn_x (gfn); -struct page_info *page; - -if ( !(page =alloc_domheap_page (cd,0 )) ) -return -ENOMEM ; - - new_vcpu_info_mfn =page_to_mfn (page); -set_gpfn_from_mfn (mfn_x (new_vcpu_info_mfn), gfn_l); - - ret = p2m->set_entry (p2m, gfn, new_vcpu_info_mfn, -PAGE_ORDER_4K , p2m_ram_rw, - p2m->default_access,-1 ); -if ( ret ) -return ret; - - ret =map_vcpu_info (cd_vcpu, gfn_l, -PAGE_OFFSET (d_vcpu->vcpu_info)); -if ( ret ) -return ret; - } - -copy_domain_page (new_vcpu_info_mfn, vcpu_info_mfn); + ret =map_vcpu_info (cd_vcpu,mfn_to_gfn (d, vcpu_info_mfn), +PAGE_OFFSET (d_vcpu->vcpu_info)); +if ( ret ) +return ret; } ret =copy_vpmu (d_vcpu, cd_vcpu);
Signature · 1 line
Julien Grall
Re: [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page
Quoted 7 lines · Julien Grall
Hi,
While preparing to commit this series, I have noticed that there are no Acked-by/Reviewed-by from Tamas (or at least not present in my inbox).
@Tamas, can you provide one?
I see an "Acked-by" from Tamas two days ago.
-George
Re: [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page
Hi George,
Quoted 10 lines · George Dunlap
Quoted 7 lines · Julien Grall
Hi,
While preparing to commit this series, I have noticed that there are no Acked-by/Reviewed-by from Tamas (or at least not present in my inbox).
@Tamas, can you provide one?
I see an "Acked-by" from Tamas two days ago.
Sadly, it is also not on lore.kernel.org or our xenproject mail archives.
In [1], Tamas pointed out he had some e-mail trouble. So anything sent by Tamas before last Tuesday is not present in my inbox or any mail archives.
Not clear why the Citrix folks received it.
Cheers,
[1] https://lore.kernel.org/all/CABfawhn0vH6rS8-SJQJVZtto2HA61By1bCG3w9bJMJR3x+rXsg@mail.gmail.com/
Signature · 1 line
Julien Grall
A message that is not in the archive (sent off-list or not yet received): CABfawhmyP_y38002v=v1G2p66ZamhGKrj=0Jm1H_-c_j9VQG8Q@mail.gmail.com
Re: [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page
Quoted 12 lines · Tamas K Lengyel
Quoted 11 lines · Roger Pau Monne
Instead let
map_vcpu_info()and it's call toget_page_from_gfn()populate the page in the child as needed. Also remove the boguscopy_domain_page(): should be placed before the call tomap_vcpu_info(), as the later can update the contents of thevcpu_infopage.Note that this eliminates a bug in
copy_vcpu_settings(): The function did allocate a new page regardless of the GFN already having a mapping, thus in particular breaking the case of two vCPU-s having their info areas on the same page.
Quoted 4 lines
Quoted 2 lines
Fixes 41548c5472a3 ('mem_sharing: VM forking')Signed-off-by Roger Pau Monné <[email protected]>Acked-by Tamas K Lengyel <[email protected]>
Thanks, Roger.
Re: [PATCH v5 01/10] mem_sharing/fork: do not attempt to populate vcpu_info page
In reply to Roger Pau MonneQuoted 6 lines · Roger Pau Monne
Instead let
map_vcpu_info()and it's call toget_page_from_gfn()populate the page in the child as needed. Also remove the boguscopy_domain_page(): should be placed before the call tomap_vcpu_info(), as the later can update the contents of thevcpu_infopage.
Quoted 7 lines
Note that this eliminates a bug in
copy_vcpu_settings(): The function did allocate a new page regardless of the GFN already having a mapping, thus in particular breaking the case of two vCPU-s having their info areas on the same page.Fixes 41548c5472a3 ('mem_sharing: VM forking')Signed-off-by Roger Pau Monné <[email protected]>
Re-sending due to mailserver issues:
PATCH v5 2/10 x86/shim: zap runstate and time area handles during shutdown
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
While likely the guest would just re-register the same areas after a possible resume, let's not take this for granted and avoid the risk of otherwise corrupting guest memory.
--- xen/arch/x86/pv/shim.c | 4 ++++ 1 file changed, 4 insertions(+)
xen/arch/x86/pv/shim.c +4 -0
@@ -385,6 +385,10 @@ int pv_shim_shutdown(uint8_t reason)/* Unmap guest vcpu_info pages. */ unmap_vcpu_info (v); +/* Zap runstate and time area handles. */ +set_xen_guest_handle (runstate_guest (v),NULL ); +set_xen_guest_handle (v->arch.time_info_guest,NULL ); +/* Reset the periodic timer to the default value. */ vcpu_set_periodic_timer (v,MILLISECS (10 ));/* Stop the singleshot timer. */
Signature · 1 line
2.42.0
PATCH v5 3/10 domain: GADDR based shared guest area registration alternative - teardown
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary domain cleanup hooks.
--- xen/arch/x86/domain.c | 5 +++++ xen/arch/x86/include/asm/domain.h | 1 + xen/arch/x86/pv/shim.c | 4 +++- xen/common/domain.c | 17 +++++++++++++++++ xen/include/xen/domain.h | 11 +++++++++++ xen/include/xen/sched.h | 1 + 6 files changed, 38 insertions(+), 1 deletion(-)
xen/arch/x86/domain.c +5 -0
@@ -1024,7 +1024,10 @@ int arch_domain_soft_reset(struct domain *d) } for_each_vcpu ( d, v ) + {set_xen_guest_handle (v->arch.time_info_guest,NULL ); +unmap_guest_area (v, &v->arch.time_guest_area); + } exit_put_gfn:put_gfn (d,gfn_x (gfn));
@@ -2381,6 +2384,8 @@ int domain_relinquish_resources(struct domain *d)if ( ret )return ret; +unmap_guest_area (v, &v->arch.time_guest_area); +vpmu_destroy (v); }
xen/arch/x86/include/asm/domain.h +1 -0
@@ -669,6 +669,7 @@ struct arch_vcpu/* A secondary copy of the vcpu time info. */ XEN_GUEST_HANDLE (vcpu_time_info_t) time_info_guest; +struct guest_area time_guest_area;struct arch_vm_event *vm_event;
xen/arch/x86/pv/shim.c +3 -1
@@ -382,8 +382,10 @@ int pv_shim_shutdown(uint8_t reason) for_each_vcpu ( d, v ) { -/* Unmap guest vcpu_info pages. */ +/* Unmap guest vcpu_info page and runstate/time areas. */ unmap_vcpu_info (v); +unmap_guest_area (v, &v->runstate_guest_area); +unmap_guest_area (v, &v->arch.time_guest_area);/* Zap runstate and time area handles. */ set_xen_guest_handle (runstate_guest (v),NULL );
xen/common/domain.c +17 -0
@@ -992,7 +992,10 @@ int domain_kill(struct domain *d)if (cpupool_move_domain (d, cpupool0) )return -ERESTART ; for_each_vcpu ( d, v ) + {unmap_vcpu_info (v); +unmap_guest_area (v, &v->runstate_guest_area); + } d->is_dying = DOMDYING_dead;/* Mem event cleanup has to go here because the rings * have to be put before we call put_domain. */
@@ -1446,6 +1449,7 @@ int domain_soft_reset(struct domain *d, bool resuming) {set_xen_guest_handle (runstate_guest (v),NULL );unmap_vcpu_info (v); +unmap_guest_area (v, &v->runstate_guest_area); } rc =arch_domain_soft_reset (d);
@@ -1597,6 +1601,19 @@ void unmap_vcpu_info(struct vcpu *v)put_page_and_type (mfn_to_page (mfn)); } +/* +* This is only intended to be used for domain cleanup (or more generally only +* with at least the respective vCPU, if it's not the current one, reliably +* paused). +*/ +void unmap_guest_area (struct vcpu *v,struct guest_area *area) +{ +struct domain *d = v->domain; + +if ( v != current ) +ASSERT (atomic_read (&v->pause_count) |atomic_read (&d->pause_count)); +} +int default_initialise_vcpu (struct vcpu *v,XEN_GUEST_HANDLE_PARAM (void ) arg) {struct vcpu_guest_context *ctxt;
xen/include/xen/domain.h +11 -0
@@ -5,6 +5,12 @@#include <xen/types.h> #include <public/xen.h> + +struct guest_area { +struct page_info *pg; +void *map; +}; +#include <asm/domain.h> #include <asm/numa.h>
@@ -77,6 +83,11 @@ void arch_vcpu_destroy(struct vcpu *v);int map_vcpu_info (struct vcpu *v,unsigned long gfn,unsigned int offset);void unmap_vcpu_info (struct vcpu *v); +int map_guest_area (struct vcpu *v,paddr_t gaddr,unsigned int size, +struct guest_area *area, +void (*populate)(void *dst,struct vcpu *v)); +void unmap_guest_area (struct vcpu *v,struct guest_area *area); +struct xen_domctl_createdomain ; int arch_domain_create(struct domain *d, struct xen_domctl_createdomain *config,
xen/include/xen/sched.h +1 -0
@@ -203,6 +203,7 @@ struct vcpu XEN_GUEST_HANDLE(vcpu_runstate_info_compat_t) compat; } runstate_guest;/* guest address */ #endif +struct guest_area runstate_guest_area;unsigned int new_state;/* Has the FPU been initialised? */
Signature · 1 line
2.42.0
PATCH v5 4/10 domain: update GADDR based runstate guest area
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
Before adding a new vCPU operation to register the runstate area by guest-physical address, add code to actually keep such areas up-to-date.
Note that updating of the area will be done exclusively following the model enabled by VMASST_TYPE_runstate_update_flag for virtual-address based registered areas.
Note further that pages aren't marked dirty when written to (matching the handling of space mapped by map_vcpu_info()), on the basis that the registrations are lost anyway across migration (or would need re- populating at the target for transparent migration). Plus the contents of the areas in question have to be deemed volatile in the first place (so saving a "most recent" value is pretty meaningless even for e.g. snapshotting).
--- xen/common/domain.c | 43 ++++++++++++++++++++++++++++++++++++++--- xen/include/xen/sched.h | 2 ++ 2 files changed, 42 insertions(+), 3 deletions(-)
xen/common/domain.c +40 -3
@@ -1644,15 +1644,52 @@ bool update_runstate_area(struct vcpu *v)bool rc;struct guest_memory_policy policy = { };void __user *guest_handle =NULL ; -struct vcpu_runstate_info runstate; +struct vcpu_runstate_info runstate = v->runstate; +struct vcpu_runstate_info *map = v->runstate_guest_area.map; + +if ( map ) + { +uint64_t *pset; +#ifdef CONFIG_COMPAT +struct compat_vcpu_runstate_info *cmap =NULL ; + +if ( v->runstate_guest_area_compat ) + cmap = (void *)map; +#endif + +/* +* NB: No VM_ASSIST(v->domain, runstate_update_flag) check here. +* Always using that updating model. +*/ +#ifdef CONFIG_COMPAT +if ( cmap ) + pset = &cmap->state_entry_time; + else +#endif + pset = &map->state_entry_time; + runstate.state_entry_time |=XEN_RUNSTATE_UPDATE ; +write_atomic (pset, runstate.state_entry_time); +smp_wmb (); + +#ifdef CONFIG_COMPAT +if ( cmap ) +XLAT_vcpu_runstate_info (cmap, &runstate); + else +#endif + *map = runstate; + +smp_wmb (); + runstate.state_entry_time &= ~XEN_RUNSTATE_UPDATE ; +write_atomic (pset, runstate.state_entry_time); + +return true; + }if (guest_handle_is_null (runstate_guest (v)) )return true;update_guest_memory_policy (v, &policy); -memcpy (&runstate, &v->runstate,sizeof (runstate)); -if (VM_ASSIST (v->domain, runstate_update_flag) ) {#ifdef CONFIG_COMPAT
xen/include/xen/sched.h +2 -0
@@ -232,6 +232,8 @@ struct vcpu#ifdef CONFIG_COMPAT /* A hypercall is using the compat ABI? */ bool hcall_compat; +/* Physical runstate area registered via compat ABI? */ +bool runstate_guest_area_compat;#endif #ifdef CONFIG_IOREQ_SERVER
Signature · 1 line
2.42.0
PATCH v5 5/10 x86: update GADDR based secondary time area
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
Before adding a new vCPU operation to register the secondary time area by guest-physical address, add code to actually keep such areas up-to- date.
Note that pages aren't marked dirty when written to (matching the handling of space mapped by map_vcpu_info()), on the basis that the registrations are lost anyway across migration (or would need re- populating at the target for transparent migration). Plus the contents of the areas in question have to be deemed volatile in the first place (so saving a "most recent" value is pretty meaningless even for e.g. snapshotting).
--- xen/arch/x86/time.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
xen/arch/x86/time.c +22 -0
@@ -1566,12 +1566,34 @@ static void __update_vcpu_system_time(struct vcpu *v, int force) v->arch.pv.pending_system_time = _u; } +static void write_time_guest_area (struct vcpu_time_info *map, +const struct vcpu_time_info *src) +{ +/* 1. Update userspace version. */ +write_atomic (&map->version, src->version); +smp_wmb (); + +/* 2. Update all other userspace fields. */ + *map = *src; + +/* 3. Update userspace version again. */ +smp_wmb (); +write_atomic (&map->version,version_update_end (src->version)); +} +bool update_secondary_system_time (struct vcpu *v,struct vcpu_time_info *u) {XEN_GUEST_HANDLE (vcpu_time_info_t) user_u = v->arch.time_info_guest; +struct vcpu_time_info *map = v->arch.time_guest_area.map;struct guest_memory_policy policy = { .nested_guest_mode = false }; +if ( map ) + { +write_time_guest_area (map, u); +return true; + } +if (guest_handle_is_null (user_u) )return true;
Signature · 1 line
2.42.0
PATCH v5 6/10 x86/mem-sharing: copy GADDR based shared guest areas
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
---
Changes since v4:
- Rely on map_guest_area() to populate the child p2m if necessary.
--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)
xen/arch/x86/mm/mem_sharing.c +31 -0
@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);
@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;
@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state, state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ + }domain_unpause (d);
xen/common/domain.c +7 -0
@@ -1601,6 +1601,13 @@ void unmap_vcpu_info(struct vcpu *v)put_page_and_type (mfn_to_page (mfn)); } +int map_guest_area (struct vcpu *v,paddr_t gaddr,unsigned int size, +struct guest_area *area, +void (*populate)(void *dst,struct vcpu *v)) +{ +return -EOPNOTSUPP ; +} +/* * This is only intended to be used for domain cleanup (or more generally only * with at least the respective vCPU, if it's not the current one, reliably
Signature · 1 line
2.42.0
A message that is not in the archive (sent off-list or not yet received): CABfawhnHg3KrGP-hp4_Q8GvSf2nVSVSyK24HKqAGuWp_AtD8-A@mail.gmail.com
Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Quoted 67 lines · Tamas K Lengyel
Quoted 66 lines · Roger Pau Monne
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
Changes since v4:
- Rely onmap_guest_area()to populate the child p2m if necessary.--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)xen/arch/x86/mm/mem_sharing.c +28
-0@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,
Quoted 9 lines
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1983
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ There is no situation where we get an
-ERESTARThere currently. Ismap_guest_areaexpected to run into situations where it fails with that rc?
Yes, there's a spin_trylock() call that will result in map_guest_area() returning -ERESTART.
Quoted 2 lines
If yes we might need a lock in place so we can block until it can succeed.
I'm not sure whether returning -ERESTART can actually happen in map_guest_area() for the fork case: the child domain is still paused at this point, so there can't be concurrent guest hypercalls that would also cause the domain hypercall_deadlock_mutex to be acquired.
The comment was added by Jan, so I cannot be certain about the intention, neither I would like to misinterpret his words. My understanding is that future uses of copy_settings() might indeed need to report -ERESTART, and that it would need to be propagated for proper hypercall continuations at some point.
Thanks, Roger.
Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Hi Roger,
Quoted 1 line · Roger Pau Monné
On Tue, Oct 03, 2023 at 09:53:11AM -0400, Tamas K Lengyel wrote:
Tamas, somehow your e-mails don't show up in my inbox (even if I am CCed) or even on lore.kernel.org/xen-devel. It is not even in my SPAM folder.
Quoted 80 lines
Quoted 67 lines · Roger Pau Monne
Quoted 66 lines
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
Changes since v4:
- Rely onmap_guest_area()to populate the child p2m if necessary.--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)xen/arch/x86/mm/mem_sharing.c +28
-0@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,Quoted 9 lines
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1983
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ There is no situation where we get an
-ERESTARThere currently. Ismap_guest_areaexpected to run into situations where it fails with that rc?Yes, there's a
spin_trylock()call that will result inmap_guest_area()returning-ERESTART.
Quoted 7 lines
Quoted 2 lines
If yes we might need a lock in place so we can block until it can succeed.
I'm not sure whether returning
-ERESTARTcan actually happen inmap_guest_area()for the fork case: the child domain is still paused at this point, so there can't be concurrent guest hypercalls that would also cause the domainhypercall_deadlock_mutexto be acquired.
hypercall_deadlock_mutex is also acquired by domctls. So, I believe, -ERESTART could be returned if the toolstack is also issuing domclt right at the same time as forking.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Quoted 9 lines · Julien Grall
Hi Roger,
Quoted 1 line · Roger Pau Monné
On Tue, Oct 03, 2023 at 09:53:11AM -0400, Tamas K Lengyel wrote:
Tamas, somehow your e-mails don't show up in my inbox (even if I am CCed) or even on lore.kernel.org/xen-devel. It is not even in my SPAM folder.
Thanks, I've switched mailservers, hopefully that resolves the issue.
Quoted 81 lines
Quoted 81 lines
Quoted 68 lines · Roger Pau Monne
Quoted 66 lines
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
Changes since v4:
- Rely onmap_guest_area()to populate the child p2m if necessary.--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)xen/arch/x86/mm/mem_sharing.c +28
-0@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,Quoted 9 lines
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1983
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ There is no situation where we get an
-ERESTARThere currently. Ismap_guest_areaexpected to run into situations where it fails with that rc?Yes, there's a
spin_trylock()call that will result inmap_guest_area()returning-ERESTART.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
If yes we might need a lock in place so we can block until it can succeed.
I'm not sure whether returning
-ERESTARTcan actually happen inmap_guest_area()for the fork case: the child domain is still paused at this point, so there can't be concurrent guest hypercalls that would also cause the domainhypercall_deadlock_mutexto be acquired.
Perhaps turning it into an ASSERT(rc != -ERESTART) is the way to go at this point. If we run into any cases where it trips we can reason it out.
Quoted 3 lines
hypercall_deadlock_mutexis also acquired by domctls. So, I believe,-ERESTARTcould be returned if the toolstack is also issuing domclt right at the same time as forking.
That's not a concern in this path, only toolstack can start the reset so we can assume it can coordinate not to have another toolstack messing with the fork at the same time.
Thanks,
Tamas
Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Quoted 97 lines · Tamas K Lengyel
Quoted 9 lines · Julien Grall
Hi Roger,
Quoted 1 line · Roger Pau Monné
On Tue, Oct 03, 2023 at 09:53:11AM -0400, Tamas K Lengyel wrote:
Tamas, somehow your e-mails don't show up in my inbox (even if I am CCed) or even on lore.kernel.org/xen-devel. It is not even in my SPAM folder.
Thanks, I've switched mailservers, hopefully that resolves the issue.
Quoted 84 lines
Quoted 84 lines
Quoted 68 lines · Roger Pau Monne
Quoted 66 lines
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
Changes since v4:
- Rely onmap_guest_area()to populate the child p2m if necessary.--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)xen/arch/x86/mm/mem_sharing.c +28
-0@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,Quoted 9 lines
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1983
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ There is no situation where we get an
-ERESTARThere currently. Ismap_guest_areaexpected to run into situations where it fails with that rc?Yes, there's a
spin_trylock()call that will result inmap_guest_area()returning-ERESTART.Quoted 2 lines
If yes we might need a lock in place so we can block until it can succeed.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
I'm not sure whether returning
-ERESTARTcan actually happen inmap_guest_area()for the fork case: the child domain is still paused at this point, so there can't be concurrent guest hypercalls that would also cause the domainhypercall_deadlock_mutexto be acquired.Perhaps turning it into an ASSERT(rc !=
-ERESTART) is the way to go at this point. If we run into any cases where it trips we can reason it out.
In order to avoid possibly returning -ERESTART (which should never be seen by hypercall callers) we might want to convert it to -EBUSY and let the caller pick the pieces.
Thanks, Roger.
Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Hi Roger,
Quoted 5 lines · Roger Pau Monné
Quoted 4 lines · Tamas K Lengyel
Quoted 3 lines · Julien Grall
Hi Roger,
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · Roger Pau Monné
Quoted 1 line · Tamas K Lengyel
Tamas, somehow your e-mails don't show up in my inbox (even if I am CCed) or even on lore.kernel.org/xen-devel. It is not even in my SPAM folder.
Thanks, I've switched mailservers, hopefully that resolves the issue.
It did. Thanks!
Quoted 90 lines
Quoted 90 lines
Quoted 89 lines
Quoted 89 lines
Quoted 69 lines · Roger Pau Monne
Quoted 66 lines
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
Changes since v4:
- Rely onmap_guest_area()to populate the child p2m if necessary.--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)xen/arch/x86/mm/mem_sharing.c +28
-0@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,Quoted 9 lines
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1983
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ There is no situation where we get an
-ERESTARThere currently. Ismap_guest_areaexpected to run into situations where it fails with that rc?Yes, there's a
spin_trylock()call that will result inmap_guest_area()returning-ERESTART.Quoted 2 lines
If yes we might need a lock in place so we can block until it can succeed.
I'm not sure whether returning
-ERESTARTcan actually happen inmap_guest_area()for the fork case: the child domain is still paused at this point, so there can't be concurrent guest hypercalls that would also cause the domainhypercall_deadlock_mutexto be acquired.
Quoted 7 lines
Quoted 3 lines
Perhaps turning it into an ASSERT(rc !=
-ERESTART) is the way to go at this point. If we run into any cases where it trips we can reason it out.In order to avoid possibly returning
-ERESTART(which should never be seen by hypercall callers) we might want to convert it to-EBUSYand let the caller pick the pieces.
I realize this is a matter of taste. I think EAGAIN is a better conversion for ERESTART because we effectively want to caller to try again.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Quoted 113 lines · Julien Grall
Hi Roger,
Quoted 5 lines · Roger Pau Monné
Quoted 4 lines · Tamas K Lengyel
Quoted 3 lines · Julien Grall
Hi Roger,
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · Roger Pau Monné
Quoted 1 line · Tamas K Lengyel
Tamas, somehow your e-mails don't show up in my inbox (even if I am CCed) or even on lore.kernel.org/xen-devel. It is not even in my SPAM folder.
Thanks, I've switched mailservers, hopefully that resolves the issue.
It did. Thanks!
Quoted 94 lines
Quoted 93 lines
Quoted 82 lines
Quoted 82 lines
Quoted 69 lines · Roger Pau Monne
Quoted 66 lines
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
Changes since v4:
- Rely onmap_guest_area()to populate the child p2m if necessary.--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)xen/arch/x86/mm/mem_sharing.c +28
-0@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,Quoted 9 lines
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1983
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ There is no situation where we get an
-ERESTARThere currently. Ismap_guest_areaexpected to run into situations where it fails with that rc?Yes, there's a
spin_trylock()call that will result inmap_guest_area()returning-ERESTART.Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
If yes we might need a lock in place so we can block until it can succeed.
I'm not sure whether returning
-ERESTARTcan actually happen inmap_guest_area()for the fork case: the child domain is still paused at this point, so there can't be concurrent guest hypercalls that would also cause the domainhypercall_deadlock_mutexto be acquired.Perhaps turning it into an ASSERT(rc !=
-ERESTART) is the way to go at this point. If we run into any cases where it trips we can reason it out.
Quoted 6 lines
Quoted 3 lines
In order to avoid possibly returning
-ERESTART(which should never be seen by hypercall callers) we might want to convert it to-EBUSYand let the caller pick the pieces.I realize this is a matter of taste. I think EAGAIN is a better conversion for ERESTART because we effectively want to caller to try again.
That's fine with me, but could we leave adding such translation to a further patch?
I would rather modify Jans code as less as possible.
Thanks, Roger.
Re: [PATCH v5 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Quoted 118 lines · Roger Pau Monné
Quoted 117 lines · Julien Grall
Hi Roger,
Quoted 5 lines · Roger Pau Monné
Quoted 4 lines · Tamas K Lengyel
Quoted 3 lines · Julien Grall
Hi Roger,
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines · Roger Pau Monné
Quoted 1 line · Tamas K Lengyel
Tamas, somehow your e-mails don't show up in my inbox (even if I am CCed) or even on lore.kernel.org/xen-devel. It is not even in my SPAM folder.
Thanks, I've switched mailservers, hopefully that resolves the issue.
It did. Thanks!
Quoted 97 lines
Quoted 85 lines
Quoted 85 lines
Quoted 85 lines
Quoted 69 lines · Roger Pau Monne
Quoted 66 lines
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>---
Changes since v4:
- Rely onmap_guest_area()to populate the child p2m if necessary.--- xen/arch/x86/mm/mem_sharing.c | 31 +++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 38 insertions(+)xen/arch/x86/mm/mem_sharing.c +28
-0@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;@@ -1950,7 +1978,10 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state,Quoted 9 lines
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1983
Quoted 5 lines
xen/arch/x86/mm/mem_sharing.c +2
-0state:if ( reset_state ) + { rc =copy_settings (d, pd); +/* TBD: What to do here with -ERESTART? */ There is no situation where we get an
-ERESTARThere currently. Ismap_guest_areaexpected to run into situations where it fails with that rc?Yes, there's a
spin_trylock()call that will result inmap_guest_area()returning-ERESTART.Quoted 2 lines
If yes we might need a lock in place so we can block until it can succeed.
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
I'm not sure whether returning
-ERESTARTcan actually happen inmap_guest_area()for the fork case: the child domain is still paused at this point, so there can't be concurrent guest hypercalls that would also cause the domainhypercall_deadlock_mutexto be acquired.Perhaps turning it into an ASSERT(rc !=
-ERESTART) is the way to go at this point. If we run into any cases where it trips we can reason it out.In order to avoid possibly returning
-ERESTART(which should never be seen by hypercall callers) we might want to convert it to-EBUSYand let the caller pick the pieces.
Quoted 5 lines
Quoted 2 lines
I realize this is a matter of taste. I think EAGAIN is a better conversion for ERESTART because we effectively want to caller to try again.
That's fine with me, but could we leave adding such translation to a further patch?
Wouldn't this mean that -ERESTART could be returned to the caller? If yes, then I think this should be handled here. Otherwise, we will be exposing a value that is not supposed to be exposed.
Cheers,
Signature · 1 line
Julien Grall
PATCH v6 6/10 x86/mem-sharing: copy GADDR based shared guest areas
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
---
Changes since v5:
- Convert -ERESTART to -EAGAIN.
Changes since v4:
- Rely on map_guest_area() to populate the child p2m if necessary.
--- xen/arch/x86/mm/mem_sharing.c | 36 +++++++++++++++++++++++++++++++++++ xen/common/domain.c | 7 +++++++ 2 files changed, 43 insertions(+)
xen/arch/x86/mm/mem_sharing.c +36 -0
@@ -1641,6 +1641,24 @@ static void copy_vcpu_nonreg_state(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)hvm_set_nonreg_state (cd_vcpu, &nrs); } +static int copy_guest_area (struct guest_area *cd_area, +const struct guest_area *d_area, +struct vcpu *cd_vcpu, +const struct domain *d) +{ +unsigned int offset; + +/* Check if no area to map, or already mapped. */ +if ( !d_area->pg || cd_area->pg ) +return 0 ; + + offset =PAGE_OFFSET (d_area->map); +return map_guest_area (cd_vcpu,gfn_to_gaddr ( +mfn_to_gfn (d,page_to_mfn (d_area->pg))) + + offset, +PAGE_SIZE - offset, cd_area,NULL ); +} +static int copy_vpmu (struct vcpu *d_vcpu,struct vcpu *cd_vcpu) {struct vpmu_struct *d_vpmu =vcpu_vpmu (d_vcpu);
@@ -1709,6 +1727,16 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)return ret; } +/* Same for the (physically registered) runstate and time info areas. */ + ret =copy_guest_area (&cd_vcpu->runstate_guest_area, + &d_vcpu->runstate_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_guest_area (&cd_vcpu->arch.time_guest_area, + &d_vcpu->arch.time_guest_area, cd_vcpu, d); +if ( ret ) +return ret; + ret =copy_vpmu (d_vcpu, cd_vcpu);if ( ret )return ret;
@@ -1950,7 +1978,15 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state, state:if ( reset_state ) + { rc =copy_settings (d, pd); +if ( rc == -ERESTART ) +/* +* Translate to -EAGAIN, see TODO comment at top of function about +* hypercall continuations. +*/ + rc = -EAGAIN ; + }domain_unpause (d);
xen/common/domain.c +7 -0
@@ -1601,6 +1601,13 @@ void unmap_vcpu_info(struct vcpu *v)put_page_and_type (mfn_to_page (mfn)); } +int map_guest_area (struct vcpu *v,paddr_t gaddr,unsigned int size, +struct guest_area *area, +void (*populate)(void *dst,struct vcpu *v)) +{ +return -EOPNOTSUPP ; +} +/* * This is only intended to be used for domain cleanup (or more generally only * with at least the respective vCPU, if it's not the current one, reliably
Signature · 1 line
2.42.0
Re: [PATCH v6 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Quoted 10 lines · Roger Pau Monne
From: Jan Beulich <[email protected]>
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, add the necessary fork handling (with the backing function yet to be filled in).
Signed-off-by Jan Beulich <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
Re: [PATCH v6 06/10] x86/mem-sharing: copy GADDR based shared guest areas
In reply to Roger Pau Monnexen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1989
Quoted 13 lines · Roger Pau Monne
xen/arch/x86/mm/mem_sharing.c +8
-0@@ -1950,7 +1978,15 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state, state:if ( reset_state ) + { rc =copy_settings (d, pd); +if ( rc == -ERESTART ) +/* +* Translate to -EAGAIN, see TODO comment at top of function about +* hypercall continuations. +*/ + rc = -EAGAIN ; + }
Are existing callers known to properly handle EAGAIN? I'm worried of the verbosity that was no lost here.
Jan
Re: [PATCH v6 06/10] x86/mem-sharing: copy GADDR based shared guest areas
Quoted 17 lines · Jan Beulich
xen/arch/x86/mm/mem_sharing.c int mem_sharing_fork_reset(struct domain *d, bool reset_state, · line 1989
Quoted 13 lines · Roger Pau Monne
xen/arch/x86/mm/mem_sharing.c +8
-0@@ -1950,7 +1978,15 @@ int mem_sharing_fork_reset(struct domain *d, bool reset_state, state:if ( reset_state ) + { rc =copy_settings (d, pd); +if ( rc == -ERESTART ) +/* +* Translate to -EAGAIN, see TODO comment at top of function about +* hypercall continuations. +*/ + rc = -EAGAIN ; + }Are existing callers known to properly handle EAGAIN? I'm worried of the verbosity that was no lost here.
No idea about the callers using XENMEM_sharing_op_fork_reset, but it did seem the best option rather than leaking -ERESTART to callers. We have no callers of xc_memshr_fork_reset() in the tree.
vm_event_resume() will trigger an assert if mem_sharing_fork_reset() fails with any error code, so doesn't make much difference there if the return is -EAGAIN or -ERESTART.
My initial proposal had -EBUSY IIRC.
Thanks, Roger.
PATCH v5 7/10 domain: map/unmap GADDR based shared guest areas
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
The registration by virtual/linear address has downsides: At least on x86 the access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the areas are inaccessible (and hence cannot be updated by Xen) when in guest-user mode, and for HVM guests they may be inaccessible when Meltdown mitigations are in place. (There are yet more issues.)
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, flesh out the map/unmap functions.
Noteworthy differences from map_vcpu_info():
- areas can be registered more than once (and de-registered),
- remote vCPU-s are paused rather than checked for being down (which in principle can change right after the check),
- the domain lock is taken for a much smaller region.
--- xen/common/domain.c | 92 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-)
xen/common/domain.c +91 -1
@@ -1605,7 +1605,82 @@ int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size,struct guest_area *area, void (*populate)(void *dst, struct vcpu *v)) { -return -EOPNOTSUPP ; + struct domain *d = v->domain; +void *map =NULL ; +struct page_info *pg =NULL ; +int rc =0 ; + +if ( ~gaddr )/* Map (i.e. not just unmap)? */ + { +unsigned long gfn =PFN_DOWN (gaddr); +unsigned int align; +p2m_type_t p2mt; + +if ( gfn !=PFN_DOWN (gaddr + size -1 ) ) +return -ENXIO ; + +#ifdef CONFIG_COMPAT +if (has_32bit_shinfo (d) ) + align = alignof(compat_ulong_t ); + else +#endif + align = alignof(xen_ulong_t ); +if ( !IS_ALIGNED (gaddr, align) ) +return -ENXIO ; + + rc =check_get_page_from_gfn (d,_gfn (gfn), false, &p2mt, &pg); +if ( rc ) +return rc; + +if ( !get_page_type (pg, PGT_writable_page) ) + { +put_page (pg); +return -EACCES ; + } + + map =__map_domain_page_global (pg); +if ( !map ) + { +put_page_and_type (pg); +return -ENOMEM ; + } + map +=PAGE_OFFSET (gaddr); + } + +if ( v != current ) + { +if ( !spin_trylock (&d->hypercall_deadlock_mutex) ) + { + rc = -ERESTART ; + goto unmap; + } + +vcpu_pause (v); + +spin_unlock (&d->hypercall_deadlock_mutex); + } + +domain_lock (d); + +if ( map && populate ) +populate (map, v); + +SWAP (area->pg, pg); +SWAP (area->map, map); + +domain_unlock (d); + +if ( v != current ) +vcpu_unpause (v); + + unmap: +if ( pg ) + { +unmap_domain_page_global (map); +put_page_and_type (pg); + } + +return rc; }/*
@@ -1616,9 +1691,24 @@ int map_guest_area(struct vcpu *v, paddr_t gaddr, unsigned int size,void unmap_guest_area (struct vcpu *v,struct guest_area *area) {struct domain *d = v->domain; +void *map; +struct page_info *pg;if ( v != current )ASSERT (atomic_read (&v->pause_count) |atomic_read (&d->pause_count)); + +domain_lock (d); + map = area->map; + area->map =NULL ; + pg = area->pg; + area->pg =NULL ; +domain_unlock (d); + +if ( pg ) + { +unmap_domain_page_global (map); +put_page_and_type (pg); + } }int default_initialise_vcpu (struct vcpu *v,XEN_GUEST_HANDLE_PARAM (void ) arg)
Signature · 1 line
2.42.0
Re: [PATCH v5 07/10] domain: map/unmap GADDR based shared guest areas
Quoted 13 lines · Roger Pau Monne
From: Jan Beulich <[email protected]>
The registration by virtual/linear address has downsides: At least on x86 the access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the areas are inaccessible (and hence cannot be updated by Xen) when in guest-user mode, and for HVM guests they may be inaccessible when Meltdown mitigations are in place. (There are yet more issues.)
In preparation of the introduction of new vCPU operations allowing to register the respective areas (one of the two is x86-specific) by guest-physical address, flesh out the map/unmap functions.
Quoted 8 lines
Noteworthy differences from
map_vcpu_info():
- areas can be registered more than once (and de-registered),
- remote vCPU-s are paused rather than checked for being down (which in principle can change right after the check),
- the domain lock is taken for a much smaller region.Signed-off-by Jan Beulich <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
PATCH v5 8/10 domain: introduce GADDR based runstate area registration alternative
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
The registration by virtual/linear address has downsides: At least on x86 the access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the area is inaccessible (and hence cannot be updated by Xen) when in guest-user mode.
Introduce a new vCPU operation allowing to register the runstate area by guest-physical address.
An at least theoretical downside to using physically registered areas is that PV then won't see dirty (and perhaps also accessed) bits set in its respective page table entries.
--- xen/arch/x86/x86_64/domain.c | 35 ++++++++++++++++++++++++++++++++ xen/common/domain.c | 39 ++++++++++++++++++++++++++++++++++++ xen/include/public/vcpu.h | 15 ++++++++++++++ 3 files changed, 89 insertions(+)
xen/arch/x86/x86_64/domain.c +35 -0
@@ -12,6 +12,22 @@ CHECK_vcpu_get_physid;#undef xen_vcpu_get_physid +static void cf_check +runstate_area_populate (void *map,struct vcpu *v) +{ +if (is_pv_vcpu (v) ) + v->arch.pv.need_update_runstate_area = false; + + v->runstate_guest_area_compat = true; + +if ( v == current ) + { +struct compat_vcpu_runstate_info *info = map; + +XLAT_vcpu_runstate_info (info, &v->runstate); + } +} +int compat_vcpu_op (int cmd,unsigned int vcpuid,XEN_GUEST_HANDLE_PARAM (void ) arg) {
@@ -58,6 +74,25 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)break ; } +case VCPUOP_register_runstate_phys_area: + { +struct compat_vcpu_register_runstate_memory_area area; + + rc = -EFAULT ; +if (copy_from_guest (&area.addr.p, arg,1 ) ) +break ; + + rc =map_guest_area (v, area.addr.p, +sizeof (struct compat_vcpu_runstate_info ), + &v->runstate_guest_area, + runstate_area_populate); +if ( rc == -ERESTART ) + rc =hypercall_create_continuation (__HYPERVISOR_vcpu_op,"iih" , + cmd, vcpuid, arg); + +break ; + } +case VCPUOP_register_vcpu_time_memory_area: {struct compat_vcpu_register_time_memory_area area = { .addr.p =0 };
xen/common/domain.c +39 -0
@@ -1830,6 +1830,26 @@ bool update_runstate_area(struct vcpu *v)return rc; } +static void cf_check +runstate_area_populate (void *map,struct vcpu *v) +{ +#ifdef CONFIG_PV +if (is_pv_vcpu (v) ) + v->arch.pv.need_update_runstate_area = false; +#endif + +#ifdef CONFIG_COMPAT + v->runstate_guest_area_compat = false; +#endif + +if ( v == current ) + { +struct vcpu_runstate_info *info = map; + + *info = v->runstate; + } +} +long common_vcpu_op (int cmd,struct vcpu *v,XEN_GUEST_HANDLE_PARAM (void ) arg) {long rc =0 ;
@@ -2012,6 +2032,25 @@ long common_vcpu_op(int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)break ; } +case VCPUOP_register_runstate_phys_area: + { +struct vcpu_register_runstate_memory_area area; + + rc = -EFAULT ; +if (copy_from_guest (&area.addr.p, arg,1 ) ) +break ; + + rc =map_guest_area (v, area.addr.p, +sizeof (struct vcpu_runstate_info ), + &v->runstate_guest_area, + runstate_area_populate); +if ( rc == -ERESTART ) + rc =hypercall_create_continuation (__HYPERVISOR_vcpu_op,"iih" , + cmd, vcpuid, arg); + +break ; + } +default : rc = -ENOSYS ;break ;
xen/include/public/vcpu.h +15 -0
@@ -110,6 +110,8 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_runstate_info_t);* runstate.state will always be RUNSTATE_running and * runstate.state_entry_time will indicate the system time at which the * VCPU was last scheduled to run. +* 3. New code wants to prefer VCPUOP_register_runstate_phys_area, and only +* fall back to the operation here for backwards compatibility. * @extra_arg == pointer to vcpu_register_runstate_memory_area structure. */ #define VCPUOP_register_runstate_memory_area 5
@@ -221,6 +223,19 @@ struct vcpu_register_time_memory_area {typedef struct vcpu_register_time_memory_area vcpu_register_time_memory_area_t ;DEFINE_XEN_GUEST_HANDLE (vcpu_register_time_memory_area_t); +/* +* Like the respective VCPUOP_register_*_memory_area, just using the "addr.p" +* field of the supplied struct as a guest physical address (i.e. in GFN space). +* The respective area may not cross a page boundary. Pass ~0 to unregister an +* area. Note that as long as an area is registered by physical address, the +* linear address based area will not be serviced (updated) by the hypervisor. +* +* Note that the area registered via VCPUOP_register_runstate_memory_area will +* be updated in the same manner as the one registered via virtual address PLUS +* VMASST_TYPE_runstate_update_flag engaged by the domain. +*/ +#define VCPUOP_register_runstate_phys_area 14 +#endif /* __XEN_PUBLIC_VCPU_H__ */ /*
Signature · 1 line
2.42.0
Re: [PATCH v5 08/10] domain: introduce GADDR based runstate area registration alternative
Hi,
Quoted 10 lines · Roger Pau Monne
From: Jan Beulich <[email protected]>
The registration by virtual/linear address has downsides: At least on x86 the access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the area is inaccessible (and hence cannot be updated by Xen) when in guest-user mode.
Introduce a new vCPU operation allowing to register the runstate area by guest-physical address.
Quoted 6 lines
An at least theoretical downside to using physically registered areas is that PV then won't see dirty (and perhaps also accessed) bits set in its respective page table entries.
Signed-off-by Jan Beulich <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
PATCH v5 9/10 x86: introduce GADDR based secondary time area registration alternative
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
The registration by virtual/linear address has downsides: The access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the area is inaccessible (and hence cannot be updated by Xen) when in guest-user mode.
Introduce a new vCPU operation allowing to register the secondary time area by guest-physical address.
An at least theoretical downside to using physically registered areas is that PV then won't see dirty (and perhaps also accessed) bits set in its respective page table entries.
--- xen/arch/x86/domain.c | 28 ++++++++++++++++++++++++++++ xen/arch/x86/include/asm/domain.h | 2 ++ xen/arch/x86/time.c | 10 ++++++++++ xen/arch/x86/x86_64/domain.c | 1 + xen/include/public/vcpu.h | 4 ++++ 5 files changed, 45 insertions(+)
xen/arch/x86/domain.c +28 -0
@@ -1529,6 +1529,15 @@ int arch_vcpu_reset(struct vcpu *v)return 0 ; } +static void cf_check +time_area_populate (void *map,struct vcpu *v) +{ +if (is_pv_vcpu (v) ) + v->arch.pv.pending_system_time.version =0 ; + +force_update_secondary_system_time (v, map); +} +long do_vcpu_op (int cmd,unsigned int vcpuid,XEN_GUEST_HANDLE_PARAM (void ) arg) {long rc =0 ;
@@ -1567,6 +1576,25 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)break ; } +case VCPUOP_register_vcpu_time_phys_area: + { +struct vcpu_register_time_memory_area area; + + rc = -EFAULT ; +if (copy_from_guest (&area.addr.p, arg,1 ) ) +break ; + + rc =map_guest_area (v, area.addr.p, +sizeof (vcpu_time_info_t), + &v->arch.time_guest_area, + time_area_populate); +if ( rc == -ERESTART ) + rc =hypercall_create_continuation (__HYPERVISOR_vcpu_op,"iih" , + cmd, vcpuid, arg); + +break ; + } +case VCPUOP_get_physid: {struct vcpu_get_physid cpu_id;
xen/arch/x86/include/asm/domain.h +2 -0
@@ -692,6 +692,8 @@ void domain_cpu_policy_changed(struct domain *d);bool update_secondary_system_time (struct vcpu *,struct vcpu_time_info *); +void force_update_secondary_system_time (struct vcpu *, +struct vcpu_time_info *);void vcpu_show_registers (const struct vcpu *);
xen/arch/x86/time.c +10 -0
@@ -1628,6 +1628,16 @@ void force_update_vcpu_system_time(struct vcpu *v)__update_vcpu_system_time (v,1 ); } +void force_update_secondary_system_time (struct vcpu *v, +struct vcpu_time_info *map) +{ +struct vcpu_time_info u; + +collect_time_info (v, &u); + u.version =-1 ;/* Compensate for version_update_end(). */ +write_time_guest_area (map, &u); +} +static void update_domain_rtc (void ) {struct domain *d;
xen/arch/x86/x86_64/domain.c +1 -0
@@ -115,6 +115,7 @@ compat_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)case VCPUOP_send_nmi:case VCPUOP_get_physid: +case VCPUOP_register_vcpu_time_phys_area: rc =do_vcpu_op (cmd, vcpuid, arg);break ;
xen/include/public/vcpu.h +4 -0
@@ -209,6 +209,9 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_get_physid_t);* segment limit). It can then apply the normal algorithm to compute * system time from the tsc. * +* New code wants to prefer VCPUOP_register_vcpu_time_phys_area, and only +* fall back to the operation here for backwards compatibility. +* * @extra_arg == pointer to vcpu_register_time_info_memory_area structure. */ #define VCPUOP_register_vcpu_time_memory_area 13
@@ -235,6 +238,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_register_time_memory_area_t);* VMASST_TYPE_runstate_update_flag engaged by the domain. */ #define VCPUOP_register_runstate_phys_area 14 +#define VCPUOP_register_vcpu_time_phys_area 15#endif /* __XEN_PUBLIC_VCPU_H__ */
Signature · 1 line
2.42.0
Re: [PATCH v5 09/10] x86: introduce GADDR based secondary time area registration alternative
Hi,
Quoted 10 lines · Roger Pau Monne
From: Jan Beulich <[email protected]>
The registration by virtual/linear address has downsides: The access is expensive for HVM/PVH domains. Furthermore for 64-bit PV domains the area is inaccessible (and hence cannot be updated by Xen) when in guest-user mode.
Introduce a new vCPU operation allowing to register the secondary time area by guest-physical address.
Quoted 6 lines
An at least theoretical downside to using physically registered areas is that PV then won't see dirty (and perhaps also accessed) bits set in its respective page table entries.
Signed-off-by Jan Beulich <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>
For the small change in include/public/vcpu.h:
Cheers,--
Julien Grall
PATCH v5 10/10 common: convert vCPU info area registration
In reply to Roger Pau MonneFrom: Jan Beulich <[email protected]>
Switch to using map_guest_area(). Noteworthy differences from map_vcpu_info():
- remote vCPU-s are paused rather than checked for being down (which in principle can change right after the check),
- the domain lock is taken for a much smaller region,
- the error code for an attempt to re-register the area is now -EBUSY,
- we could in principle permit de-registration when no area was previously registered (which would permit "probing", if necessary for anything).
--- xen/arch/x86/include/asm/shared.h | 19 ++- xen/arch/x86/mm/mem_sharing.c | 20 ++- xen/arch/x86/pv/shim.c | 2 +- xen/arch/x86/time.c | 2 +- xen/arch/x86/x86_64/asm-offsets.c | 2 +- xen/arch/x86/x86_64/traps.c | 2 +- xen/common/compat/domain.c | 2 +- xen/common/domain.c | 204 ++++++++++++------------------ xen/include/xen/domain.h | 3 - xen/include/xen/sched.h | 5 +- xen/include/xen/shared.h | 3 +- 11 files changed, 112 insertions(+), 152 deletions(-)
xen/arch/x86/include/asm/shared.h +13 -6
@@ -26,17 +26,20 @@ static inline void arch_set_##field(struct domain *d, \#define GET_SET_VCPU (type, field) \ static inline type arch_get_##field(const struct vcpu *v) \ { \ + const vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ return !has_32bit_shinfo(v->domain) ? \ - v->vcpu_info->native.arch.field : \ - v->vcpu_info->compat.arch.field; \ + vi->native.arch.field : vi->compat.arch.field; \ } \ static inline void arch_set_##field(struct vcpu *v, \ type val) \ { \ + vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ if ( !has_32bit_shinfo(v->domain) ) \ - v->vcpu_info->native.arch.field = val; \ + vi->native.arch.field = val; \ else \ - v->vcpu_info->compat.arch.field = val; \ + vi->compat.arch.field = val; \ }#else
@@ -57,12 +60,16 @@ static inline void arch_set_##field(struct domain *d, \#define GET_SET_VCPU (type, field) \ static inline type arch_get_##field(const struct vcpu *v) \ { \ - return v->vcpu_info->arch.field; \ + const vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ + return vi->arch.field; \ } \ static inline void arch_set_##field(struct vcpu *v, \ type val) \ { \ - v->vcpu_info->arch.field = val; \ + vcpu_info_t *vi = v->vcpu_info_area.map; \ + \ + vi->arch.field = val; \ }#endif
xen/arch/x86/mm/mem_sharing.c +8 -12
@@ -1705,7 +1705,6 @@ static int copy_vpmu(struct vcpu *d_vcpu, struct vcpu *cd_vcpu)static int copy_vcpu_settings (struct domain *cd,const struct domain *d) {unsigned int i; -struct p2m_domain *p2m =p2m_get_hostp2m (cd);int ret = -EINVAL ;mfn_t vcpu_info_mfn;
@@ -1717,17 +1716,14 @@ static int copy_vcpu_settings(struct domain *cd, const struct domain *d)if ( !d_vcpu || !cd_vcpu )continue ; -/* Map in the vcpu_info page if the guest uses one */ - vcpu_info_mfn = d_vcpu->vcpu_info_mfn; -if ( !mfn_eq (vcpu_info_mfn,INVALID_MFN ) ) - { - ret =map_vcpu_info (cd_vcpu,mfn_to_gfn (d, vcpu_info_mfn), -PAGE_OFFSET (d_vcpu->vcpu_info)); -if ( ret ) -return ret; - } - -/* Same for the (physically registered) runstate and time info areas. */ +/* +* Map the vcpu_info page and the (physically registered) runstate and +* time info areas. +*/ + ret =copy_guest_area (&cd_vcpu->vcpu_info_area, + &d_vcpu->vcpu_info_area, cd_vcpu, d); +if ( ret ) +return ret; ret =copy_guest_area (&cd_vcpu->runstate_guest_area, &d_vcpu->runstate_guest_area, cd_vcpu, d);if ( ret )
xen/arch/x86/pv/shim.c +1 -1
@@ -383,7 +383,7 @@ int pv_shim_shutdown(uint8_t reason) for_each_vcpu ( d, v ) {/* Unmap guest vcpu_info page and runstate/time areas. */ -unmap_vcpu_info (v); +unmap_guest_area (v, &v->vcpu_info_area);unmap_guest_area (v, &v->runstate_guest_area);unmap_guest_area (v, &v->arch.time_guest_area);
xen/arch/x86/time.c +1 -1
@@ -1542,7 +1542,7 @@ static void __update_vcpu_system_time(struct vcpu *v, int force)struct vcpu_time_info *u = &vcpu_info (v, time), _u;const struct domain *d = v->domain; -if ( v->vcpu_info ==NULL ) +if ( !v->vcpu_info_area.map )return ;collect_time_info (v, &_u);
xen/arch/x86/x86_64/asm-offsets.c +1 -1
@@ -53,7 +53,7 @@ void __dummy__(void) OFFSET(VCPU_processor, struct vcpu, processor); OFFSET(VCPU_domain, struct vcpu, domain); - OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info); + OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info_area.map); OFFSET(VCPU_trap_bounce, struct vcpu, arch.pv.trap_bounce); OFFSET(VCPU_thread_flags, struct vcpu, arch.flags); OFFSET(VCPU_event_addr, struct vcpu, arch.pv.event_callback_eip);
xen/arch/x86/x86_64/traps.c +1 -1
@@ -96,7 +96,7 @@ static void _show_registers(if ( context == CTXT_hypervisor )printk (" %pS" ,_p (regs->rip));printk ("\nRFLAGS: %016lx " , regs->rflags); -if ( (context == CTXT_pv_guest) && v && v->vcpu_info ) +if ( (context == CTXT_pv_guest) && v && v->vcpu_info_area.map )printk ("EM: %d " , !!vcpu_info (v, evtchn_upcall_mask));printk ("CONTEXT: %s" , context_names[context]);if ( v && !is_idle_vcpu (v) )
xen/common/compat/domain.c +1 -1
@@ -49,7 +49,7 @@ int compat_common_vcpu_op(int cmd, struct vcpu *v, {case VCPUOP_initialise: { -if ( v->vcpu_info == &dummy_vcpu_info ) +if ( v->vcpu_info_area.map == &dummy_vcpu_info )return -EINVAL ;#ifdef CONFIG_HVM
xen/common/domain.c +83 -121
268 lines not on this page · raw message
xen/include/xen/domain.h +0 -3
@@ -80,9 +80,6 @@ void cf_check free_pirq_struct(void *);int arch_vcpu_create (struct vcpu *v);void arch_vcpu_destroy (struct vcpu *v); -int map_vcpu_info (struct vcpu *v,unsigned long gfn,unsigned int offset); -void unmap_vcpu_info (struct vcpu *v); -int map_guest_area (struct vcpu *v,paddr_t gaddr,unsigned int size,struct guest_area *area,void (*populate)(void *dst,struct vcpu *v));
xen/include/xen/sched.h +1 -4
@@ -176,7 +176,7 @@ struct vcpuint processor; -vcpu_info_t *vcpu_info; +struct guest_area vcpu_info_area;struct domain *domain;
@@ -289,9 +289,6 @@ struct vcpustruct waitqueue_vcpu *waitqueue_vcpu; -/* Guest-specified relocation of vcpu_info. */ -mfn_t vcpu_info_mfn; -struct evtchn_fifo_vcpu *evtchn_fifo;/* vPCI per-vCPU area, used to store data for long running operations. */
xen/include/xen/shared.h +2 -1
@@ -44,6 +44,7 @@ typedef struct vcpu_info vcpu_info_t;extern vcpu_info_t dummy_vcpu_info;#define shared_info (d, field) __shared_info(d, (d)->shared_info, field) -#define vcpu_info (v, field) __vcpu_info(v, (v)->vcpu_info, field) +#define vcpu_info (v, field) \ + __vcpu_info(v, (vcpu_info_t *)(v)->vcpu_info_area.map, field)#endif /* __XEN_SHARED_H__ */
Signature · 1 line
2.42.0
Re: [PATCH v5 10/10] common: convert vCPU info area registration
Hi Roger,
Quoted 12 lines · Roger Pau Monne
From: Jan Beulich <[email protected]>
Switch to using
map_guest_area(). Noteworthy differences frommap_vcpu_info():
- remote vCPU-s are paused rather than checked for being down (which in principle can change right after the check),
- the domain lock is taken for a much smaller region,
- the error code for an attempt to re-register the area is now-EBUSY,
- we could in principle permit de-registration when no area was previously registered (which would permit "probing", if necessary for anything).
Quoted 2 lines
Signed-off-by Jan Beulich <[email protected]>Reviewed-by Roger Pau Monné <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Hi Roger,
Quoted 8 lines · Roger Pau Monne
Since it was indicated that introducing specific new vCPU ops may be beneficial independent of the introduction of a fully physical- address-based ABI flavor, here we go. There continue to be a few open questions throughout the series, resolving of which was one of the main goals of the earlier postings.
Quoted 6 lines
v5 adds one vm-fork specific pre-patch that does simply the introduced code later on. It does also fix a vm-fork bug.
Patches 1 and 6 are missing and Ack from the mem-sharing maintainer.
Whole series will need a Release-Ack.
We agreed in [1] that this series is a good candidate for 4.18, so for the whole series,
[1] https://lore.kernel.org/xen-devel/[email protected]/
Kind regards,
Henry
Quoted 39 lines
Thanks, Roger.
Jan Beulich (9):
x86/shim: zap runstate and time area handles during shutdown
domain: GADDR based shared guest area registration alternative -
teardown
domain: update GADDR based runstate guest area
x86: update GADDR based secondary time area x86/mem-sharing: copy GADDR based shared guest areas
domain: map/unmap GADDR based shared guest areas
domain: introduce GADDR based runstate area registration alternative
x86: introduce GADDR based secondary time area registration
alternative
common: convert vCPU info area registrationRoger Pau Monne (1):
mem_sharing/fork: do not attempt to populatevcpu_infopagexen/arch/x86/domain.c | 33 +++ xen/arch/x86/include/asm/domain.h | 3 + xen/arch/x86/include/asm/shared.h | 19 +- xen/arch/x86/mm/mem_sharing.c | 73 +++---- xen/arch/x86/pv/shim.c | 10 +- xen/arch/x86/time.c | 34 +++- xen/arch/x86/x86_64/asm-offsets.c | 2 +- xen/arch/x86/x86_64/domain.c | 36 ++++ xen/arch/x86/x86_64/traps.c | 2 +- xen/common/compat/domain.c | 2 +- xen/common/domain.c | 324 ++++++++++++++++++++++-------- xen/include/public/vcpu.h | 19 ++ xen/include/xen/domain.h | 12 +- xen/include/xen/sched.h | 8 +- xen/include/xen/shared.h | 3 +- 15 files changed, 440 insertions(+), 140 deletions(-)Signature · 1 line
2.42.0
Hi,
Quoted 13 lines · Henry Wang
Hi Roger,
Quoted 11 lines · Roger Pau Monne
Since it was indicated that introducing specific new vCPU ops may be beneficial independent of the introduction of a fully physical- address-based ABI flavor, here we go. There continue to be a few open questions throughout the series, resolving of which was one of the main goals of the earlier postings.
v5 adds one vm-fork specific pre-patch that does simply the introduced code later on. It does also fix a vm-fork bug.
Quoted 8 lines
Quoted 3 lines
Patches 1 and 6 are missing and Ack from the mem-sharing maintainer.
Whole series will need a Release-Ack.
We agreed in [1] that this series is a good candidate for 4.18, so for the whole series,
Release-acked-by Henry Wang <[email protected]>
I have now committed the series.
Cheers,
Signature · 1 line
Julien Grall
I see this series has been committed. But it's broken in a really fundamental way.
This is a new extension with persistent side effects to an existing part of the guest ABI.
Yet there doesn't appear to be any enumeration that the interface is available to begin with. Requiring the guest to probe subops, and having no way to disable it on a per-domain basis is unacceptable, and has exploded on us more times than I care to count in security fixes alone, and that doesn't even cover the issues Amazon have reported over the years.
Henry: Blocker for 4.18. The absolutely bare minimum necessary to avoid reversion is some kind of positive enumeration that the two new hypercalls are available.
Otherwise I will be #if 0'ing out the new hypercalls before this ABI mistake gets set in stone.
If this were x86-only it would need to be a CPUID flag, but it will need to be something arch-agnostic in this case. The series should not have come without a proper per-domain control and toolstack integration, but everything else can be retrofitted in an emergency.
And on a related note, where is the documentation describing this new feature? Some tests perhaps, or any single implementation of the guest side interface?
This is engineering principles so basic that they do go without saying.
~Andrew
Hi Andrew,
Quoted 2 lines · Andrew Cooper
I see this series has been committed. But it's broken in a really fundamental way.
Thanks for pointing out. But I'd like to understand how I come to only hear about those concerns on the series after committing. Did I miss any thread? Even if this series has been pending for over 6 months, should have I waited longer before committing?
Furthermore, Jan pointed out that this series was discussed recently during the x86 meeting. Did you raise any concern during the call and they were not carried on the ML?
Quoted 9 lines
This is a new extension with persistent side effects to an existing part of the guest ABI.
Yet there doesn't appear to be any enumeration that the interface is available to begin with. Requiring the guest to probe subops, and having no way to disable it on a per-domain basis is unacceptable, and has exploded on us more times than I care to count in security fixes alone, and that doesn't even cover the issues Amazon have reported over the years.
Indeed. But, AFAIR, all those patches got stuck because of diverging opinions between you and you. Can we finally come to an agreement on how to disable/expose a new hypercall/feature so we can move on?
Quoted 4 lines
Henry: Blocker for 4.18. The absolutely bare minimum necessary to avoid reversion is some kind of positive enumeration that the two new hypercalls are available.
So to clarify, you would like both an interface for the guest and the toolstack for 4.18. Is this correct?
Quoted 7 lines
Otherwise I will be #if 0'ing out the new hypercalls before this ABI mistake gets set in stone.
If this were x86-only it would need to be a CPUID flag, but it will need to be something arch-agnostic in this case.
I think we can add two new flags in XENVER_get_features to indicate to the guest that the feature is supported. What do you think?
Quoted 2 lines
The series should not have
come without a proper per-domain control and toolstack integration,
I think this requirement should be written down in a document we can use for future reference and not expect people to remember what may have been said on the ML for previous hypercall addition.
Cheers,
Signature · 1 line
Julien Grall
Quoted 13 lines · Julien Grall
Hi Andrew,
Quoted 2 lines · Andrew Cooper
I see this series has been committed. But it's broken in a really fundamental way.
Thanks for pointing out. But I'd like to understand how I come to only hear about those concerns on the series after committing. Did I miss any thread? Even if this series has been pending for over 6 months, should have I waited longer before committing?
Furthermore, Jan pointed out that this series was discussed recently during the x86 meeting. Did you raise any concern during the call and they were not carried on the ML?
Quoted 3 lines
This is a new extension with persistent side effects to an existing part of the guest ABI.
Quoted 8 lines
Quoted 6 lines
Yet there doesn't appear to be any enumeration that the interface is available to begin with. Requiring the guest to probe subops, and having no way to disable it on a per-domain basis is unacceptable, and has exploded on us more times than I care to count in security fixes alone, and that doesn't even cover the issues Amazon have reported over the years.
Indeed. But, AFAIR, all those patches got stuck because of diverging opinions between you and you. Can we finally come to an agreement on how
The second 'you' was meant to be Jan. I didn't intend to say you were disagreing with yourself.
Cheers,
Signature · 1 line
Julien Grall
Quoted 6 lines · Andrew Cooper
I see this series has been committed. But it's broken in a really fundamental way.
This is a new extension with persistent side effects to an existing part of the guest ABI.
The only change in the ABI is the different return code for multiple attempts to map the vcpu_info page, it used to be -EINVAL and it's -EBUSY now, which seems more descriptive.
The added hypercalls are an extension of the ABI, not not a modification of an existing part. Or maybe I'm not understanding the complaint.
Quoted 3 lines
Yet there doesn't appear to be any enumeration that the interface is available to begin with. Requiring the guest to probe subops, and having no way to disable it on a per-domain basis is unacceptable,
We have never mandated such disables to be part of the series adding the new hypercalls, those have always been retro fitted in case of need. Not saying we shouldn't do it, but it's not something we have asked submitters to do.
Quoted 4 lines
and
has exploded on us more times than I care to count in security fixes alone, and that doesn't even cover the issues Amazon have reported over the years.
That's fine, I can add the enumeration. A CHANGELOG entry should also be added.
Quoted 9 lines
Henry: Blocker for 4.18. The absolutely bare minimum necessary to avoid reversion is some kind of positive enumeration that the two new hypercalls are available.
Otherwise I will be #if 0'ing out the new hypercalls before this ABI mistake gets set in stone.
Quoted 8 lines
If this were x86-only it would need to be a CPUID flag, but it will need to be something arch-agnostic in this case. The series should not have come without a proper per-domain control and toolstack integration, but everything else can be retrofitted in an emergency.
And on a related note, where is the documentation describing this new feature? Some tests perhaps, or any single implementation of the guest side interface?
Not that I know, I was expecting Jan to post that once he gets back from PTO.
I already noted somewhere that I wasn't able to test myself because I couldn't find any Linux side patches to test the feature with, and I didn't have time to write ones myself (was expecting Jan to have the Linux side done already for testing reasons).
Quoted 4 lines
This is engineering principles so basic that they do go without saying.
~Andrew
Quoted 16 lines · Roger Pau Monné
Quoted 6 lines · Andrew Cooper
I see this series has been committed. But it's broken in a really fundamental way.
This is a new extension with persistent side effects to an existing part of the guest ABI.
The only change in the ABI is the different return code for multiple attempts to map the
vcpu_infopage, it used to be-EINVALand it's-EBUSYnow, which seems more descriptive.The added hypercalls are an extension of the ABI, not not a modification of an existing part. Or maybe I'm not understanding the complaint.
Quoted 8 lines
Quoted 3 lines
Yet there doesn't appear to be any enumeration that the interface is available to begin with. Requiring the guest to probe subops, and having no way to disable it on a per-domain basis is unacceptable,
We have never mandated such disables to be part of the series adding the new hypercalls, those have always been retro fitted in case of need. Not saying we shouldn't do it, but it's not something we have asked submitters to do.
I've been thinking about this, and I assume that we would like some kind of tools interface to list supported features by the hypervisor, and then a way to disable them. We could then use such information to level the hypercall interface across a pool of hosts, and make sure it's always the same.
In principle guest should cope with some features/hypercalls not being able on resume, but we all know this is not always the case.
I'm going to punt this, as adding such interface would be too disruptive at this point in the release, and in any case it's unlikely we could reach an agreement on how the interface should look like in a very short time frame.
Roger.
Quoted 17 lines · Roger Pau Monné
Quoted 8 lines · Andrew Cooper
Henry: Blocker for 4.18. The absolutely bare minimum necessary to avoid reversion is some kind of positive enumeration that the two new hypercalls are available.
Otherwise I will be #if 0'ing out the new hypercalls before this ABI mistake gets set in stone.
Quoted 8 lines
If this were x86-only it would need to be a CPUID flag, but it will need to be something arch-agnostic in this case. The series should not have come without a proper per-domain control and toolstack integration, but everything else can be retrofitted in an emergency.
And on a related note, where is the documentation describing this new feature? Some tests perhaps, or any single implementation of the guest side interface?
Quoted 7 lines
Not that I know, I was expecting Jan to post that once he gets back from PTO.
I already noted somewhere that I wasn't able to test myself because I couldn't find any Linux side patches to test the feature with, and I didn't have time to write ones myself (was expecting Jan to have the Linux side done already for testing reasons).
Big new feature, getting merged after RC1 and feature freeze, with no enumeration and no disable.
How did this not set off massive alarm bells?
I was about to say that this is a disaster waiting to happen, except OSSTest has beaten me to it.
This "new feature" managed to regress existing behaviour of something it was trying not to change, and that's in an area that even I wouldn't expect to put in a disable.
I'm very sorely tempted to insist that this gets disabled by default in 4.18. It's clear that it isn't in a fit state, and the absence of any testing whatsoever means it is likely to explode on the first guest kernel which tries to use the new interface.
And to be clear, disabled-by-default is a question for Henry and Henry alone, as the person ultimately responsible for 4.18.
~Andrew
Quoted 7 lines · Andrew Cooper
I see this series has been committed. But it's broken in a really fundamental way.
This is a new extension with persistent side effects to an existing part of the guest ABI.
Quoted 6 lines
Yet there doesn't appear to be any enumeration that the interface is available to begin with. Requiring the guest to probe subops, and having no way to disable it on a per-domain basis is unacceptable, and has exploded on us more times than I care to count in security fixes alone, and that doesn't even cover the issues Amazon have reported over the years.
This has never been a requirement. Plus you had ample time to raise such a request.
Quoted 3 lines
Henry: Blocker for 4.18. The absolutely bare minimum necessary to avoid reversion is some kind of positive enumeration that the two new hypercalls are available.
I disagree; to me this is a nice-to-have, not a requirement.
Quoted 8 lines
Otherwise I will be #if 0'ing out the new hypercalls before this ABI mistake gets set in stone.
If this were x86-only it would need to be a CPUID flag, but it will need to be something arch-agnostic in this case. The series should not have come without a proper per-domain control and toolstack integration, but everything else can be retrofitted in an emergency.
To be honest, had it been clear that you expect a per-domain control, I probably would not have taken on this piece of work.
Quoted 3 lines
And on a related note, where is the documentation describing this new feature? Some tests perhaps, or any single implementation of the guest side interface?
Documentation is as for sibling interfaces - as much or as little as we have in the public headers. I did test all of this with XTF, but I've pretty much given up posting XTF patches, seeing how even XSA tests and alike never made it anywhere.
Jan
Quoted 28 lines · Roger Pau Monne
Since it was indicated that introducing specific new vCPU ops may be beneficial independent of the introduction of a fully physical- address-based ABI flavor, here we go. There continue to be a few open questions throughout the series, resolving of which was one of the main goals of the earlier postings.
v5 adds one vm-fork specific pre-patch that does simply the introduced code later on. It does also fix a vm-fork bug.
Patches 1 and 6 are missing and Ack from the mem-sharing maintainer.
Whole series will need a Release-Ack.
Thanks, Roger.
Jan Beulich (9):
x86/shim: zap runstate and time area handles during shutdown
domain: GADDR based shared guest area registration alternative -
teardown
domain: update GADDR based runstate guest area
x86: update GADDR based secondary time area x86/mem-sharing: copy GADDR based shared guest areas
domain: map/unmap GADDR based shared guest areas
domain: introduce GADDR based runstate area registration alternative
x86: introduce GADDR based secondary time area registration
alternative
common: convert vCPU info area registration
Quoted 2 lines
Roger Pau Monne (1):
mem_sharing/fork: do not attempt to populatevcpu_infopage
Thanks much for picking this up during my absence.
Jan