linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@linux.intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	isaku.yamahata@intel.com, xiaoyao.li@intel.com,
	binbin.wu@linux.intel.com, rick.p.edgecombe@intel.com
Subject: Re: [PATCH 1/7] KVM: Document KVM_MAP_MEMORY ioctl
Date: Fri, 19 Apr 2024 21:57:05 +0800	[thread overview]
Message-ID: <ZiJ4McRA1zqcSCjN@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <CABgObfYNNgpwOWFNmhHED7wL72Gi7sbFi5_ED_B7f-BUO+nrZg@mail.gmail.com>

On Wed, Apr 17, 2024 at 10:37:00PM +0200, Paolo Bonzini wrote:
> On Wed, Apr 17, 2024 at 10:28 PM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Wed, Apr 17, 2024, Paolo Bonzini wrote:
> > > +4.143 KVM_MAP_MEMORY
> > > +------------------------
> > > +
> > > +:Capability: KVM_CAP_MAP_MEMORY
> > > +:Architectures: none
> > > +:Type: vcpu ioctl
> > > +:Parameters: struct kvm_map_memory (in/out)
> > > +:Returns: 0 on success, < 0 on error

The definition of *success* here doesn't align with below comments.
Maybe replace success with a clearer definition, e.g. 0 when all or
part of the pages are processed. < 0 when error and no page is
processed.

> > > +
> > > +Errors:
> > > +
> > > +  ========== ===============================================================
> > > +  EINVAL     The specified `base_address` and `size` were invalid (e.g. not
> > > +             page aligned or outside the defined memory slots).
> >
> > "outside the memslots" should probably be -EFAULT, i.e. keep EINVAL for things
> > that can _never_ succeed.
> >
> > > +  EAGAIN     The ioctl should be invoked again and no page was processed.
> > > +  EINTR      An unmasked signal is pending and no page was processed.
> >
> > I'm guessing we'll want to handle large ranges, at which point we'll likely end
> > up with EAGAIN and/or EINTR after processing at least one page.
> 
> Yes, in that case you get a success (return value of 0), just like read().

[...]

> >
> > > +When the ioctl returns, the input values are updated to point to the
> > > +remaining range.  If `size` > 0 on return, the caller can just issue
> > > +the ioctl again with the same `struct kvm_map_memory` argument.
> >
> > This is likely misleading.  Unless KVM explicitly zeros size on *every* failure,
> > a pedantic reading of this would suggest that userspace can retry and it should
> > eventually succeed.
> 
> Gotcha... KVM explicitly zeros size on every success, but never zeros
> size on a failure.

Thanks,
Yilun

  reply	other threads:[~2024-04-19 14:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-17 15:34 [PATCH v3 0/7] KVM: Guest Memory Pre-Population API Paolo Bonzini
2024-04-17 15:34 ` [PATCH 1/7] KVM: Document KVM_MAP_MEMORY ioctl Paolo Bonzini
2024-04-17 20:28   ` Sean Christopherson
2024-04-17 20:37     ` Paolo Bonzini
2024-04-19 13:57       ` Xu Yilun [this message]
2024-04-17 15:34 ` [PATCH 2/7] KVM: Add KVM_MAP_MEMORY vcpu ioctl to pre-populate guest memory Paolo Bonzini
2024-04-17 19:36   ` Isaku Yamahata
2024-04-17 21:07     ` Sean Christopherson
2024-04-17 21:13       ` Paolo Bonzini
2024-04-19 13:59     ` Xu Yilun
2024-04-19 14:08       ` Sean Christopherson
2024-04-19 14:01   ` Xu Yilun
2024-04-17 15:34 ` [PATCH 3/7] KVM: x86/mmu: Extract __kvm_mmu_do_page_fault() Paolo Bonzini
2024-04-17 19:47   ` Isaku Yamahata
2024-04-17 15:34 ` [PATCH 4/7] KVM: x86/mmu: Make __kvm_mmu_do_page_fault() return mapped level Paolo Bonzini
2024-04-17 15:34 ` [PATCH 5/7] KVM: x86/mmu: Introduce kvm_tdp_map_page() to populate guest memory Paolo Bonzini
2024-04-17 21:24   ` Sean Christopherson
2024-04-17 21:31     ` Paolo Bonzini
2024-04-17 22:26       ` Sean Christopherson
2024-04-17 21:34     ` Sean Christopherson
2024-04-17 21:47       ` Paolo Bonzini
2024-04-17 15:34 ` [PATCH 6/7] KVM: x86: Implement kvm_arch_vcpu_map_memory() Paolo Bonzini
2024-04-17 19:28   ` Isaku Yamahata
2024-04-17 21:37   ` Sean Christopherson
2024-04-17 15:34 ` [PATCH 7/7] KVM: selftests: x86: Add test for KVM_MAP_MEMORY Paolo Bonzini
2024-04-18  0:01 ` [PATCH v3 0/7] KVM: Guest Memory Pre-Population API Edgecombe, Rick P
2024-04-18  0:31   ` Paolo Bonzini
2024-04-18  0:33     ` Edgecombe, Rick P

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=ZiJ4McRA1zqcSCjN@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@linux.intel.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=seanjc@google.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;
as well as URLs for NNTP newsgroup(s).