From: Jan Beulich Date: Fri, 8 Jan 2021 15:49:23 +0000 (+0100) Subject: x86/p2m: avoid unnecessary calls of write_p2m_entry_pre() hook X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1180 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=570065b9d5a8a00c5c1aab9e13e9e1ad3e35ce7d;p=xen.git x86/p2m: avoid unnecessary calls of write_p2m_entry_pre() hook When shattering a large page, we first construct the new page table page and only then hook it up. The "pre" hook in this case does nothing, for the page starting out all blank. Avoid 512 calls into shadow code in this case by passing in INVALID_GFN, indicating the page being updated is (not yet) associated with any GFN. (The alternative to this change would be to actually pass in a correct GFN, which can't be all the same on every loop iteration.) Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 5fa0d30ce7..848773e1cd 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -134,7 +134,7 @@ static int write_p2m_entry(struct p2m_domain *p2m, unsigned long gfn, paging_lock(d); - if ( p2m->write_p2m_entry_pre ) + if ( p2m->write_p2m_entry_pre && gfn != gfn_x(INVALID_GFN) ) p2m->write_p2m_entry_pre(d, gfn, p, new, level); oflags = l1e_get_flags(*p); @@ -290,7 +290,8 @@ p2m_next_level(struct p2m_domain *p2m, void **table, { new_entry = l1e_from_pfn(pfn | (i << ((level - 1) * PAGETABLE_ORDER)), flags); - rc = write_p2m_entry(p2m, gfn, l1_entry + i, new_entry, level); + rc = write_p2m_entry(p2m, gfn_x(INVALID_GFN), l1_entry + i, + new_entry, level); if ( rc ) { unmap_domain_page(l1_entry);