public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	david@redhat.com
Subject: [PATCH v1 02/13] KVM: x86: mmu: use for_each_shadow_entry_lockless()
Date: Fri,  4 Aug 2017 15:14:17 +0200	[thread overview]
Message-ID: <20170804131428.15844-3-david@redhat.com> (raw)
In-Reply-To: <20170804131428.15844-1-david@redhat.com>

Certainly better to read.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 arch/x86/kvm/mmu.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 9ed26cc..3769613 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3596,8 +3596,8 @@ static bool
 walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr, u64 *sptep)
 {
 	struct kvm_shadow_walk_iterator iterator;
-	u64 sptes[PT64_ROOT_LEVEL], spte = 0ull;
-	int root, leaf;
+	u64 sptes[PT64_ROOT_LEVEL] = { 0 }, spte = 0ull;
+	int level;
 	bool reserved = false;
 
 	if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
@@ -3605,14 +3605,8 @@ walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr, u64 *sptep)
 
 	walk_shadow_page_lockless_begin(vcpu);
 
-	for (shadow_walk_init(&iterator, vcpu, addr),
-		 leaf = root = iterator.level;
-	     shadow_walk_okay(&iterator);
-	     __shadow_walk_next(&iterator, spte)) {
-		spte = mmu_spte_get_lockless(iterator.sptep);
-
-		sptes[leaf - 1] = spte;
-		leaf--;
+	for_each_shadow_entry_lockless(vcpu, addr, iterator, spte) {
+		sptes[iterator.level - 1] = spte;
 
 		if (!is_shadow_present_pte(spte))
 			break;
@@ -3626,10 +3620,11 @@ walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr, u64 *sptep)
 	if (reserved) {
 		pr_err("%s: detect reserved bits on spte, addr 0x%llx, dump hierarchy:\n",
 		       __func__, addr);
-		while (root > leaf) {
+		for (level = PT64_ROOT_LEVEL; level > 0; level--) {
+			if (!sptes[level - 1])
+				continue;
 			pr_err("------ spte 0x%llx level %d.\n",
-			       sptes[root - 1], root);
-			root--;
+			       sptes[level - 1], level);
 		}
 	}
 exit:
-- 
2.9.4

  parent reply	other threads:[~2017-08-04 13:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04 13:14 [PATCH v1 00/13] KVM x86/VMX cleanups David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 01/13] KVM: x86: mmu: returning void in a void function is strange David Hildenbrand
2017-08-04 13:14 ` David Hildenbrand [this message]
2017-08-14 10:21   ` [PATCH v1 02/13] KVM: x86: mmu: use for_each_shadow_entry_lockless() Paolo Bonzini
2017-08-17 10:12     ` David Hildenbrand
2017-08-17 10:23       ` Paolo Bonzini
2017-08-17 10:39         ` David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 03/13] KVM: x86: mmu: free_page can handle NULL David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 04/13] KVM: x86: drop BUG_ON(vcpu->kvm) David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 05/13] KVM: VMX: vmx_vcpu_setup() cannot fail David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 06/13] KVM: x86: no need to inititalize vcpu members to 0 David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 07/13] KVM: VMX: drop enable_ept check from ept_sync_context() David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 08/13] KVM: VMX: call ept_sync_global() with enable_ept only David Hildenbrand
2017-08-14 10:25   ` Paolo Bonzini
2017-08-17 10:06     ` David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 09/13] KVM: VMX: drop unnecessary function declarations David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 10/13] KVM: nVMX: no need to set vcpu->cpu when switching vmcs David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 11/13] KVM: VMX: cleanup init_rmode_identity_map() David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 12/13] KVM: x86: document special identity map address value David Hildenbrand
2017-08-04 13:14 ` [PATCH v1 13/13] KVM: x86: allow setting identity map addr with no vcpus only David Hildenbrand
2017-08-10 17:58 ` [PATCH v1 00/13] KVM x86/VMX cleanups Radim Krčmář
2017-08-14 10:30   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170804131428.15844-3-david@redhat.com \
    --to=david@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox