From: Jan Beulich Date: Thu, 5 Sep 2019 07:56:42 +0000 (+0200) Subject: x86/shadow: don't enable shadow mode with too small a shadow allocation (part 2) X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~1668 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8b25551baa3307af0aa1ef8f7f43403f01c2c5d7;p=xen.git x86/shadow: don't enable shadow mode with too small a shadow allocation (part 2) Commit 2634b997af ("x86/shadow: don't enable shadow mode with too small a shadow allocation") was incomplete: The adjustment done there to shadow_enable() is also needed in shadow_one_bit_enable(). The (new) problem report was (apparently) a failed PV guest migration followed by another migration attempt for that same guest. Disabling log-dirty mode after the first one had left a couple of shadow pages allocated (perhaps something that also wants fixing), and hence the second enabling of log-dirty mode wouldn't have allocated anything further. Reported-by: James Wang Signed-off-by: Jan Beulich Acked-by: Tim Deegan --- diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 9463794059..bc9d41d38b 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -2864,7 +2864,8 @@ static int shadow_one_bit_enable(struct domain *d, u32 mode) mode |= PG_SH_enable; - if ( d->arch.paging.shadow.total_pages == 0 ) + if ( d->arch.paging.shadow.total_pages < + sh_min_allocation(d) + d->arch.paging.shadow.p2m_pages ) { /* Init the shadow memory allocation if the user hasn't done so */ if ( shadow_set_allocation(d, 1, NULL) != 0 )