From patchwork Mon Apr 18 18:34:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 716161 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3IIZ2Xe028136 for ; Mon, 18 Apr 2011 18:35:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754658Ab1DRSe7 (ORCPT ); Mon, 18 Apr 2011 14:34:59 -0400 Received: from mail-px0-f179.google.com ([209.85.212.179]:40015 "EHLO mail-px0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752458Ab1DRSe6 (ORCPT ); Mon, 18 Apr 2011 14:34:58 -0400 Received: by pxi2 with SMTP id 2so3534592pxi.10 for ; Mon, 18 Apr 2011 11:34:58 -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=Ir8pyVAulG9y7tucccKBsB9AGzrJLnN71P3HIUHHA/8=; b=xOQiYdZMQQjS6TU5rwVY0c750t/A3Y7ZUZKqDpJ920nPcSkywZo3t8agnu/TwQDsIt V4zkbtkt85JD1THVHxUutgmMw7l013DgLl3kU9ilB4zJHCJ7ojPMpqj56IbTwc2Bpa7q k4aWAgXVledvQfMRC3/qgrb8vkYqPNOwLc4q0= 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=NL76WtCwqAYiky4MeCEHVeDbmBn/fU0pqrNF4EK5CQPF2Fy99wIPHP9WrccHEl1Ol7 wmbBi7e6LX7AhzN83WtnAmuQgH30gOa+ifIyuzDaFSHLxRdoldda/TFTxsBhObglumJi yhAp6Z+bpVm1pD2vzkXvEcGibs0cZFL6A8yf4= Received: by 10.68.11.132 with SMTP id q4mr7601677pbb.318.1303151698376; Mon, 18 Apr 2011 11:34:58 -0700 (PDT) Received: from amd (s198099.dynamic.ppp.asahi-net.or.jp [220.157.198.99]) by mx.google.com with ESMTPS id g6sm2450018pbh.59.2011.04.18.11.34.56 (version=SSLv3 cipher=OTHER); Mon, 18 Apr 2011 11:34:57 -0700 (PDT) Date: Tue, 19 Apr 2011 03:34:53 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp Subject: [PATCH 2/3] KVM: MMU: Introduce a helper to read guest pte Message-Id: <20110419033453.ffa856c9.takuya.yoshikawa@gmail.com> In-Reply-To: <20110419033220.e527bcae.takuya.yoshikawa@gmail.com> References: <20110419033220.e527bcae.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0beta2 (GTK+ 2.22.0; 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 (demeter1.kernel.org [140.211.167.41]); Mon, 18 Apr 2011 18:35:02 +0000 (UTC) From: Takuya Yoshikawa This will be optimized later. Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/paging_tmpl.h | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 74f8567..109939a 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -109,6 +109,14 @@ static unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, pt_element_t gpte) return access; } +static int FNAME(read_guest_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, + gfn_t table_gfn, int offset, pt_element_t *ptep) +{ + return kvm_read_guest_page_mmu(vcpu, mmu, table_gfn, ptep, + offset, sizeof(*ptep), + PFERR_USER_MASK | PFERR_WRITE_MASK); +} + /* * Fetch a guest pte for a guest virtual address */ @@ -160,9 +168,7 @@ walk: walker->table_gfn[walker->level - 1] = table_gfn; walker->pte_gpa[walker->level - 1] = pte_gpa; - if (kvm_read_guest_page_mmu(vcpu, mmu, table_gfn, &pte, - offset, sizeof(pte), - PFERR_USER_MASK|PFERR_WRITE_MASK)) { + if (FNAME(read_guest_pte)(vcpu, mmu, table_gfn, offset, &pte)) { present = false; break; }