From patchwork Thu Jun 9 14:02:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 865522 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p59E2r8X031544 for ; Thu, 9 Jun 2011 14:02:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757788Ab1FIOCu (ORCPT ); Thu, 9 Jun 2011 10:02:50 -0400 Received: from mail-px0-f179.google.com ([209.85.212.179]:50771 "EHLO mail-px0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757646Ab1FIOCt (ORCPT ); Thu, 9 Jun 2011 10:02:49 -0400 Received: by pxi2 with SMTP id 2so1064063pxi.10 for ; Thu, 09 Jun 2011 07:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding; bh=XEBUSnJ8lJP5i/6+CKkVUirZ915Vr7fV1dA2UYb16Ck=; b=DKersE8VWztxhUJZgHKgBCOhrfGFthqJfoS8nGoMvCtAxVmtl2K+MjipVbjbQsUqWF V6yV852lVfv3LS4dop0rU7mRq8iCPPTox85c0vv7sf0WoLkFq0R8aWL8FbrNZCKNebQn B6nlLfhZi8xFdPrsLKVfr0WiYrENxG3P9VD50= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=mKcisGrvRNqZRDBHSrIIrihrIVOCElwrJ5VloYBGca//pJuP4NUrR925iMMgD1/apj pq8Bz7rmbWFV8iDDLc7gUtdcOuAlyCe6DBD4XTPfbnLOcjbx8k95M1M4xJiOCx1E+Nsk 2iDrwC6B0g7Gd0VIwWIG7ILmMMfBavXithVoQ= Received: by 10.68.48.9 with SMTP id h9mr315135pbn.0.1307628159917; Thu, 09 Jun 2011 07:02:39 -0700 (PDT) Received: from amd (x096101.dynamic.ppp.asahi-net.or.jp [122.249.96.101]) by mx.google.com with ESMTPS id m9sm1430129pbd.71.2011.06.09.07.02.37 (version=SSLv3 cipher=OTHER); Thu, 09 Jun 2011 07:02:39 -0700 (PDT) Date: Thu, 9 Jun 2011 23:02:36 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, mingo@elte.hu Subject: [PATCH 2/4] KVM: MMU: Move some variables into the walk loop Message-Id: <20110609230236.b7d3be2f.takuya.yoshikawa@gmail.com> In-Reply-To: <20110609225949.91cce4a0.takuya.yoshikawa@gmail.com> References: <20110609225949.91cce4a0.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 09 Jun 2011 14:02:53 +0000 (UTC) From: Takuya Yoshikawa This will help us split out the big body of the walk loop later. Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/paging_tmpl.h | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 51e5990..3270789 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -122,11 +122,8 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, { pt_element_t pte; pt_element_t __user *ptep_user; - gfn_t table_gfn; - unsigned index, pt_access, uninitialized_var(pte_access); - gpa_t pte_gpa; + unsigned pt_access, uninitialized_var(pte_access); bool eperm; - int offset; const int write_fault = access & PFERR_WRITE_MASK; const int user_fault = access & PFERR_USER_MASK; const int fetch_fault = access & PFERR_FETCH_MASK; @@ -158,12 +155,11 @@ walk: for (;;) { gfn_t real_gfn; unsigned long host_addr; + unsigned index = PT_INDEX(addr, walker->level); + int offset = index * sizeof(pt_element_t); + gfn_t table_gfn = gpte_to_gfn(pte); + gpa_t pte_gpa = gfn_to_gpa(table_gfn) + offset; - index = PT_INDEX(addr, walker->level); - - table_gfn = gpte_to_gfn(pte); - offset = index * sizeof(pt_element_t); - pte_gpa = gfn_to_gpa(table_gfn) + offset; walker->table_gfn[walker->level - 1] = table_gfn; walker->pte_gpa[walker->level - 1] = pte_gpa; @@ -273,6 +269,8 @@ walk: if (write_fault && unlikely(!is_dirty_gpte(pte))) { int ret; + unsigned index = PT_INDEX(addr, walker->level); + gfn_t table_gfn = walker->table_gfn[walker->level - 1]; trace_kvm_mmu_set_dirty_bit(table_gfn, index, sizeof(pte)); ret = FNAME(cmpxchg_gpte)(vcpu, mmu, ptep_user, index,