[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/PV: fold redundant calls to adjust_guest_l<N>e()
commit 2039ebfd59eef01176f5d26e83654f8bfbe0a949 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Mon Jan 11 14:51:39 2021 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Jan 11 14:51:39 2021 +0100 x86/PV: fold redundant calls to adjust_guest_l<N>e() At least from an abstract perspective it is quite odd for us to compare adjusted old and unadjusted new page table entries when determining whether the fast path can be used. This is largely benign because FASTPATH_FLAG_WHITELIST covers most of the flags which the adjustments may set, and the flags getting set don't affect the outcome of get_page_from_l<N>e(). There's one exception: 32-bit L3 entries get _PAGE_RW set, but get_page_from_l3e() doesn't allow linear page tables to be created at this level for such guests. Apart from this _PAGE_RW is unused by get_page_from_l<N>e() (for N > 1), and hence forcing the bit on early has no functional effect. The main reason for the change, however, is that adjust_guest_l<N>e() aren't exactly cheap - both in terms of pure code size and because each one has at least one evaluate_nospec() by way of containing is_pv_32bit_domain() conditionals. Call the functions once ahead of the fast path checks, instead of twice after. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> --- xen/arch/x86/mm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 79acf20c4e..63e9fae919 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -2195,10 +2195,11 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, l1_pgentry_t nl1e, nl1e = l1e_from_page(page, l1e_get_flags(nl1e)); } + nl1e = adjust_guest_l1e(nl1e, pt_dom); + /* Fast path for sufficiently-similar mappings. */ if ( !l1e_has_changed(ol1e, nl1e, ~FASTPATH_FLAG_WHITELIST) ) { - nl1e = adjust_guest_l1e(nl1e, pt_dom); rc = UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, preserve_ad); if ( page ) @@ -2223,7 +2224,6 @@ static int mod_l1_entry(l1_pgentry_t *pl1e, l1_pgentry_t nl1e, if ( page ) put_page(page); - nl1e = adjust_guest_l1e(nl1e, pt_dom); if ( unlikely(!UPDATE_ENTRY(l1, pl1e, ol1e, nl1e, gl1mfn, pt_vcpu, preserve_ad)) ) { @@ -2275,10 +2275,11 @@ static int mod_l2_entry(l2_pgentry_t *pl2e, return -EINVAL; } + nl2e = adjust_guest_l2e(nl2e, d); + /* Fast path for sufficiently-similar mappings. */ if ( !l2e_has_changed(ol2e, nl2e, ~FASTPATH_FLAG_WHITELIST) ) { - nl2e = adjust_guest_l2e(nl2e, d); if ( UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, mfn, vcpu, preserve_ad) ) return 0; return -EBUSY; @@ -2287,7 +2288,6 @@ static int mod_l2_entry(l2_pgentry_t *pl2e, if ( unlikely((rc = get_page_from_l2e(nl2e, mfn, d, 0)) < 0) ) return rc; - nl2e = adjust_guest_l2e(nl2e, d); if ( unlikely(!UPDATE_ENTRY(l2, pl2e, ol2e, nl2e, mfn, vcpu, preserve_ad)) ) { @@ -2337,10 +2337,11 @@ static int mod_l3_entry(l3_pgentry_t *pl3e, return -EINVAL; } + nl3e = adjust_guest_l3e(nl3e, d); + /* Fast path for sufficiently-similar mappings. */ if ( !l3e_has_changed(ol3e, nl3e, ~FASTPATH_FLAG_WHITELIST) ) { - nl3e = adjust_guest_l3e(nl3e, d); rc = UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, mfn, vcpu, preserve_ad); return rc ? 0 : -EFAULT; } @@ -2350,7 +2351,6 @@ static int mod_l3_entry(l3_pgentry_t *pl3e, return rc; rc = 0; - nl3e = adjust_guest_l3e(nl3e, d); if ( unlikely(!UPDATE_ENTRY(l3, pl3e, ol3e, nl3e, mfn, vcpu, preserve_ad)) ) { @@ -2399,10 +2399,11 @@ static int mod_l4_entry(l4_pgentry_t *pl4e, return -EINVAL; } + nl4e = adjust_guest_l4e(nl4e, d); + /* Fast path for sufficiently-similar mappings. */ if ( !l4e_has_changed(ol4e, nl4e, ~FASTPATH_FLAG_WHITELIST) ) { - nl4e = adjust_guest_l4e(nl4e, d); rc = UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, mfn, vcpu, preserve_ad); return rc ? 0 : -EFAULT; } @@ -2412,7 +2413,6 @@ static int mod_l4_entry(l4_pgentry_t *pl4e, return rc; rc = 0; - nl4e = adjust_guest_l4e(nl4e, d); if ( unlikely(!UPDATE_ENTRY(l4, pl4e, ol4e, nl4e, mfn, vcpu, preserve_ad)) ) { -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |