x86/mm: PV GDT handling cleanup
PATCH 1/1 x86/mm: PV GDT handling cleanup
These are a few bits of cleanup noticed when double checking the PV GDT handling for migration v2.
* Drop write-only 'mfn' variable in set_gdt()
* Hoist page_get_owner() call in alloc_segdesc_page() and unify exit paths
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
CC Keir Fraser <[email protected]>
CC Jan Beulich <[email protected]>
CC Tim Deegan <[email protected]>
--- xen/arch/x86/mm.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
xen/arch/x86/mm.c +8 -12
@@ -545,21 +545,17 @@ static void invalidate_shadow_ldt(struct vcpu *v, int flush)static int alloc_segdesc_page (struct page_info *page) { -struct desc_struct *descs; -int i; - - descs =__map_domain_page (page); +const struct domain *owner =page_get_owner (page); +struct desc_struct *descs =__map_domain_page (page); +unsigned i;for ( i =0 ; i <512 ; i++ ) -if (unlikely (!check_descriptor (page_get_owner (page), &descs[i])) ) - goto fail; +if (unlikely (!check_descriptor (owner, &descs[i])) ) +break ;unmap_domain_page (descs); -return 0 ; - fail: -unmap_domain_page (descs); -return -EINVAL ; +return i ==512 ?0 : -EINVAL ; }
@@ -4382,7 +4378,7 @@ long set_gdt(struct vcpu *v,l1_pgentry_t *pl1e;/* NB. There are 512 8-byte entries per GDT page. */ int i, nr_pages = (entries +511 ) /512 ; -unsigned long mfn, *pfns; +unsigned long *pfns;if ( entries >FIRST_RESERVED_GDT_ENTRY )return -EINVAL ;
@@ -4404,7 +4400,7 @@ long set_gdt(struct vcpu *v,put_page (page); goto fail; } - mfn = frames[i] =page_to_mfn (page); + frames[i] =page_to_mfn (page); }/* Tear down the old GDT. */
Signature · 1 line
1.7.10.4