From: Andrew Cooper Subject: [PATCH] x86/mm: PV GDT handling cleanup Date: Wed, 20 May 2015 15:31:46 +0100 Message-ID: <1432132306-22928-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Keir Fraser , Jan Beulich , Tim Deegan List-Id: xen-devel@lists.xenproject.org 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 CC: Keir Fraser CC: Jan Beulich CC: Tim Deegan --- xen/arch/x86/mm.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 5fe08df..74e146d 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -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. */ -- 1.7.10.4