From: Sean Christopherson <seanjc@google.com>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
isaku.yamahata@intel.com, binbin.wu@linux.intel.com,
rick.p.edgecombe@intel.com
Subject: Re: [PATCH 5/6] KVM: x86: Implement kvm_arch_vcpu_pre_fault_memory()
Date: Wed, 12 Jun 2024 14:02:57 -0700 [thread overview]
Message-ID: <ZmoNAQmwIH5tigyv@google.com> (raw)
In-Reply-To: <d5a6e125-bff4-4d82-ae65-b99d9cb10e90@intel.com>
On Mon, Apr 22, 2024, Xiaoyao Li wrote:
> On 4/19/2024 4:59 PM, Paolo Bonzini wrote:
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index 10e90788b263..a045b23964c0 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> > @@ -4647,6 +4647,78 @@ int kvm_tdp_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
> > return direct_page_fault(vcpu, fault);
> > }
> > +static int kvm_tdp_map_page(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code,
> > + u8 *level)
Align parameters:
static int kvm_tdp_map_page(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code,
u8 *level)
> > +{
> > + int r;
> > +
> > + /* Restrict to TDP page fault. */
This is fairly obvious from the code, what might not be obvious is _why_. I'm
also ok dropping the comment entirely, but it's easy enough to provide a hint to
the reader.
> > + if (vcpu->arch.mmu->page_fault != kvm_tdp_page_fault)
> > + return -EOPNOTSUPP;
> > +
> > +retry:
> > + r = __kvm_mmu_do_page_fault(vcpu, gpa, error_code, true, NULL, level);
> > + if (r < 0)
> > + return r;
> > +
> > + switch (r) {
> > + case RET_PF_RETRY:
> > + if (signal_pending(current))
> > + return -EINTR;
> > + cond_resched();
> > + goto retry;
Rather than a goto+retry from inside a switch statement, what about:
int r;
/*
* Pre-faulting a GPA is supported only non-nested TDP, as indirect
* MMUs map either GVAs or L2 GPAs, not L1 GPAs.
*/
if (vcpu->arch.mmu->page_fault != kvm_tdp_page_fault)
return -EOPNOTSUPP;
do {
if (signal_pending(current))
return -EINTR;
cond_resched();
r = kvm_mmu_do_page_fault(vcpu, gpa, error_code, true, NULL, level);
} while (r == RET_PF_RETRY);
switch (r) {
case RET_PF_FIXED:
case RET_PF_SPURIOUS:
break;
case RET_PF_EMULATE:
return -ENOENT;
case RET_PF_CONTINUE:
case RET_PF_INVALID:
case RET_PF_RETRY:
default:
WARN_ON_ONCE(r >= 0);
return -EIO;
}
return 0;
next prev parent reply other threads:[~2024-06-12 21:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 8:59 [PATCH v4 0/6] KVM: Guest Memory Pre-Population API Paolo Bonzini
2024-04-19 8:59 ` [PATCH 1/6] KVM: Document KVM_PRE_FAULT_MEMORY ioctl Paolo Bonzini
2024-04-22 17:55 ` Isaku Yamahata
2024-04-19 8:59 ` [PATCH 2/6] KVM: Add KVM_PRE_FAULT_MEMORY vcpu ioctl to pre-populate guest memory Paolo Bonzini
2024-04-22 5:39 ` Binbin Wu
2024-04-24 16:05 ` Paolo Bonzini
2024-04-22 7:19 ` Binbin Wu
2024-04-22 18:00 ` Isaku Yamahata
2024-04-19 8:59 ` [PATCH 3/6] KVM: x86/mmu: Extract __kvm_mmu_do_page_fault() Paolo Bonzini
2024-04-22 8:46 ` Xiaoyao Li
2024-06-12 20:47 ` Sean Christopherson
2024-04-19 8:59 ` [PATCH 4/6] KVM: x86/mmu: Make __kvm_mmu_do_page_fault() return mapped level Paolo Bonzini
2024-04-19 8:59 ` [PATCH 5/6] KVM: x86: Implement kvm_arch_vcpu_pre_fault_memory() Paolo Bonzini
2024-04-22 15:37 ` Xiaoyao Li
2024-06-12 21:02 ` Sean Christopherson [this message]
2024-04-19 8:59 ` [PATCH 6/6] KVM: selftests: x86: Add test for KVM_PRE_FAULT_MEMORY Paolo Bonzini
2024-04-22 17:50 ` Isaku Yamahata
2024-04-23 15:18 ` Xiaoyao Li
2024-04-24 1:59 ` Xiaoyao Li
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=ZmoNAQmwIH5tigyv@google.com \
--to=seanjc@google.com \
--cc=binbin.wu@linux.intel.com \
--cc=isaku.yamahata@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=xiaoyao.li@intel.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