Message ID | 10b1b71d918b7d7315b49b5932497d094f767a1e.1648561546.git.tamas.lengyel@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/3] x86/mem_sharing: option to enforce fork starting with empty p2m | expand |
On 29.03.2022 16:03, Tamas K Lengyel wrote: > The fork's physmap should only be populated with select special pages during > the setup of the fork. The rest of the fork's physmap should only be populated > as needed after the fork is complete. Add a field to specify when the fork is > complete so fork_page() can determine whether it's time to start adding entries > to the physmap. > > Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com> Acked-by: Jan Beulich <jbeulich@suse.com>
On Tue, Mar 29, 2022 at 11:51 AM Jan Beulich <jbeulich@suse.com> wrote: > > On 29.03.2022 16:03, Tamas K Lengyel wrote: > > The fork's physmap should only be populated with select special pages during > > the setup of the fork. The rest of the fork's physmap should only be populated > > as needed after the fork is complete. Add a field to specify when the fork is > > complete so fork_page() can determine whether it's time to start adding entries > > to the physmap. > > > > Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com> > > Acked-by: Jan Beulich <jbeulich@suse.com> Thanks! After further consideration I'll drop this and the empty_p2m patch from the series as there is a corner-case with PAE-mode guests which doesn't play nice with enforcing a start with an empty p2m. Working around that issue leads to a cascading changeset which ultimately isn't a worthwhile effort. Tamas
diff --git a/xen/arch/x86/include/asm/hvm/domain.h b/xen/arch/x86/include/asm/hvm/domain.h index 22a17c36c5..7078d041bd 100644 --- a/xen/arch/x86/include/asm/hvm/domain.h +++ b/xen/arch/x86/include/asm/hvm/domain.h @@ -32,6 +32,7 @@ struct mem_sharing_domain { bool enabled; + bool fork_complete; bool block_interrupts; bool empty_p2m; diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index ef67285a98..bfde342a38 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1555,7 +1555,7 @@ int mem_sharing_fork_page(struct domain *d, gfn_t gfn, bool unsharing) p2m_type_t p2mt; struct page_info *page; - if ( !mem_sharing_is_fork(d) ) + if ( !d->arch.hvm.mem_sharing.fork_complete ) return -ENOENT; if ( !unsharing ) @@ -1862,6 +1862,7 @@ static int fork(struct domain *cd, struct domain *d, uint16_t flags) if ( !(rc = copy_settings(cd, d, empty_p2m)) ) { + cd->arch.hvm.mem_sharing.fork_complete = true; cd->arch.hvm.mem_sharing.block_interrupts = block_interrupts; if ( (cd->arch.hvm.mem_sharing.empty_p2m = empty_p2m) )
The fork's physmap should only be populated with select special pages during the setup of the fork. The rest of the fork's physmap should only be populated as needed after the fork is complete. Add a field to specify when the fork is complete so fork_page() can determine whether it's time to start adding entries to the physmap. Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com> --- v2: replace previous patch that set parent to dom_cow as a placeholder --- xen/arch/x86/include/asm/hvm/domain.h | 1 + xen/arch/x86/mm/mem_sharing.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)