From: Julien Grall Date: Fri, 22 Mar 2019 17:22:43 +0000 (+0000) Subject: xen/arm: mm: Only increment mfn when valid in xen_pt_update X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~2032 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4a53f2c7f9b978f3bb45a8e8861d483c790cbb35;p=xen.git xen/arm: mm: Only increment mfn when valid in xen_pt_update Currently, the MFN will be incremented even if it is invalid. This will result to have a valid MFN after the first iteration. While this is not a major problem today, this will be in the future if the code expect an invalid MFN at every iteration. Such behavior is prevented by avoiding to increment an invalid MFN. Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov Acked-by: Stefano Stabellini --- diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 085a99b976..23e9565ddc 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1024,11 +1024,14 @@ static int xen_pt_update(enum xenmap_operation op, spin_lock(&xen_pt_lock); - for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1)) + for( ; addr < addr_end; addr += PAGE_SIZE ) { rc = xen_pt_update_entry(op, addr, mfn, flags); if ( rc ) break; + + if ( !mfn_eq(mfn, INVALID_MFN) ) + mfn = mfn_add(mfn, 1); } /*