From: Robert Hoo <robert.hu@linux.intel.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Greg Thelen <gthelen@google.com>,
David Matlack <dmatlack@google.com>,
Ben Gardon <bgardon@google.com>,
Mingwei Zhang <mizhang@google.com>
Subject: Re: [PATCH 1/5] KVM: x86/mmu: Don't attempt to map leaf if target TDP MMU SPTE is frozen
Date: Wed, 14 Dec 2022 19:57:56 +0800 [thread overview]
Message-ID: <0595da5ddc9084d3fceb4a6efd4b9f407e2aaddb.camel@linux.intel.com> (raw)
In-Reply-To: <20221213033030.83345-2-seanjc@google.com>
On Tue, 2022-12-13 at 03:30 +0000, Sean Christopherson wrote:
> Hoist the is_removed_spte() check above the "level == goal_level"
> check
> when walking SPTEs during a TDP MMU page fault to avoid attempting to
> map
> a leaf entry if said entry is frozen by a different task/vCPU.
>
> ------------[ cut here ]------------
> WARNING: CPU: 3 PID: 939 at arch/x86/kvm/mmu/tdp_mmu.c:653
> kvm_tdp_mmu_map+0x269/0x4b0
> Modules linked in: kvm_intel
> CPU: 3 PID: 939 Comm: nx_huge_pages_t Not tainted 6.1.0-rc4+ #67
> Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0
> 02/06/2015
> RIP: 0010:kvm_tdp_mmu_map+0x269/0x4b0
> RSP: 0018:ffffc9000068fba8 EFLAGS: 00010246
> RAX: 00000000000005a0 RBX: ffffc9000068fcc0 RCX: 0000000000000005
> RDX: ffff88810741f000 RSI: ffff888107f04600 RDI: ffffc900006a3000
> RBP: 060000010b000bf3 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 000ffffffffff000 R12: 0000000000000005
> R13: ffff888113670000 R14: ffff888107464958 R15: 0000000000000000
> FS: 00007f01c942c740(0000) GS:ffff888277cc0000(0000)
> knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000000000000 CR3: 0000000117013006 CR4: 0000000000172ea0
> Call Trace:
> <TASK>
> kvm_tdp_page_fault+0x10c/0x130
> kvm_mmu_page_fault+0x103/0x680
> vmx_handle_exit+0x132/0x5a0 [kvm_intel]
> vcpu_enter_guest+0x60c/0x16f0
> kvm_arch_vcpu_ioctl_run+0x1e2/0x9d0
> kvm_vcpu_ioctl+0x271/0x660
> __x64_sys_ioctl+0x80/0xb0
> do_syscall_64+0x2b/0x50
> entry_SYSCALL_64_after_hwframe+0x46/0xb0
> </TASK>
> ---[ end trace 0000000000000000 ]---
>
> Fixes: 63d28a25e04c ("KVM: x86/mmu: simplify kvm_tdp_mmu_map flow
> when guest has to retry")
> Cc: Robert Hoo <robert.hu@linux.intel.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/mmu/tdp_mmu.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c
> index 764f7c87286f..b740f38fedcc 100644
> --- a/arch/x86/kvm/mmu/tdp_mmu.c
> +++ b/arch/x86/kvm/mmu/tdp_mmu.c
> @@ -1162,9 +1162,6 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu,
> struct kvm_page_fault *fault)
> if (fault->nx_huge_page_workaround_enabled)
> disallowed_hugepage_adjust(fault,
> iter.old_spte, iter.level);
>
> - if (iter.level == fault->goal_level)
> - break;
> -
> /*
> * If SPTE has been frozen by another thread, just give
> up and
> * retry, avoiding unnecessary page table allocation
> and free.
> @@ -1172,6 +1169,9 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu,
> struct kvm_page_fault *fault)
> if (is_removed_spte(iter.old_spte))
> goto retry;
>
> + if (iter.level == fault->goal_level)
> + break;
> +
> /* Step down into the lower level page table if it
> exists. */
> if (is_shadow_present_pte(iter.old_spte) &&
> !is_large_pte(iter.old_spte))
Reviewed-by: Robert Hoo <robert.hu@linux.intel.com>
next prev parent reply other threads:[~2022-12-14 11:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-13 3:30 [PATCH 0/5] KVM: x86/mmu: TDP MMU fixes for 6.2 Sean Christopherson
2022-12-13 3:30 ` [PATCH 1/5] KVM: x86/mmu: Don't attempt to map leaf if target TDP MMU SPTE is frozen Sean Christopherson
2022-12-14 11:57 ` Robert Hoo [this message]
2022-12-13 3:30 ` [PATCH 2/5] KVM: x86/mmu: Map TDP MMU leaf SPTE iff target level is reached Sean Christopherson
2022-12-13 3:30 ` [PATCH 3/5] KVM: x86/mmu: Re-check under lock that TDP MMU SP hugepage is disallowed Sean Christopherson
2022-12-14 11:58 ` Robert Hoo
2022-12-15 0:11 ` Sean Christopherson
2022-12-15 6:26 ` Robert Hoo
2022-12-13 3:30 ` [PATCH 4/5] KVM: x86/mmu: Don't install TDP MMU SPTE if SP has unexpected level Sean Christopherson
2022-12-13 17:59 ` David Matlack
2022-12-13 18:15 ` Sean Christopherson
2022-12-20 18:24 ` David Matlack
2022-12-13 3:30 ` [PATCH 5/5] KVM: x86/mmu: Move kvm_tdp_mmu_map()'s prolog and epilog to its caller Sean Christopherson
2022-12-20 17:53 ` David Matlack
2022-12-21 18:32 ` Sean Christopherson
2022-12-29 19:51 ` David Matlack
2022-12-29 21:06 ` Paolo Bonzini
2023-01-03 22:21 ` David Matlack
2022-12-14 12:01 ` [PATCH 0/5] KVM: x86/mmu: TDP MMU fixes for 6.2 Robert Hoo
2022-12-14 15:48 ` Sean Christopherson
2022-12-23 17:32 ` 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=0595da5ddc9084d3fceb4a6efd4b9f407e2aaddb.camel@linux.intel.com \
--to=robert.hu@linux.intel.com \
--cc=bgardon@google.com \
--cc=dmatlack@google.com \
--cc=gthelen@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mizhang@google.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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