From: Sean Christopherson <seanjc@google.com>
To: isaku.yamahata@intel.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
isaku.yamahata@gmail.com, Michael Roth <michael.roth@amd.com>,
Paolo Bonzini <pbonzini@redhat.com>,
erdemaktas@google.com, Sagi Shahar <sagis@google.com>,
David Matlack <dmatlack@google.com>,
Kai Huang <kai.huang@intel.com>,
Zhi Wang <zhi.wang.linux@gmail.com>,
chen.bo@intel.com, linux-coco@lists.linux.dev,
Chao Peng <chao.p.peng@linux.intel.com>,
Ackerley Tng <ackerleytng@google.com>,
Vishal Annapurve <vannapurve@google.com>,
Yuan Yao <yuan.yao@linux.intel.com>,
Jarkko Sakkinen <jarkko@kernel.org>,
Xu Yilun <yilun.xu@intel.com>,
Quentin Perret <qperret@google.com>,
wei.w.wang@intel.com, Fuad Tabba <tabba@google.com>
Subject: Re: [RFC PATCH 3/6] KVM: guest_memfd, x86: MEMORY_FAULT exit with hw poisoned page
Date: Wed, 13 Sep 2023 10:37:24 -0700 [thread overview]
Message-ID: <ZQHzVOIsesTTysgf@google.com> (raw)
In-Reply-To: <36f6fae6cd7aaba3b0fc18f10981bbba2c30b979.1694599703.git.isaku.yamahata@intel.com>
On Wed, Sep 13, 2023, isaku.yamahata@intel.com wrote:
> From: Isaku Yamahata <isaku.yamahata@intel.com>
>
> When resolving kvm page fault and hwpoisoned page is given, KVM exit
> with HWPOISONED flag so that user space VMM, e.g. qemu, handle it.
>
> - Add a new flag POISON to KVM_EXIT_MEMORY_FAULT to indicate the page is
> poisoned.
> - Make kvm_gmem_get_pfn() return hwpoison state by -EHWPOISON when the
> folio is hw-poisoned.
> - When page is hw-poisoned on faulting in private gmem, return
> KVM_EXIT_MEMORY_FAULT with HWPOISONED flag.
>
> Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
> ---
...
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
> index eb900344a054..48329cb44415 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -527,7 +527,8 @@ struct kvm_run {
> } notify;
> /* KVM_EXIT_MEMORY_FAULT */
> struct {
> -#define KVM_MEMORY_EXIT_FLAG_PRIVATE (1ULL << 3)
> +#define KVM_MEMORY_EXIT_FLAG_PRIVATE BIT_ULL(3)
> +#define KVM_MEMORY_EXIT_FLAG_HWPOISON BIT_ULL(4)
Rather than add a flag, I think we should double down on returning -1 + errno
when exiting with vcpu->run->exit_reason == KVM_EXIT_MEMORY_FAULT, as is being
proposed in Anish's series for accelerating UFFD-like behavior in KVM[*].
Then KVM can simply return -EFAULT or -EHWPOISON to communicate why KVM is
existing at a higher level, and let the kvm_run structure provide the finer
details about the access itself. E.g. kvm_faultin_pfn_private() can simply
propagate the return value from kvm_gmem_get_pfn() without having to identify
*why* kvm_gmem_get_pfn() failed.
static int kvm_faultin_pfn_private(struct kvm_vcpu *vcpu,
struct kvm_page_fault *fault)
{
int max_order, r;
if (!kvm_slot_can_be_private(fault->slot)) {
kvm_mmu_prepare_memory_fault_exit(vcpu, fault);
return -EFAULT;
}
r = kvm_gmem_get_pfn(vcpu->kvm, fault->slot, fault->gfn, &fault->pfn,
&max_order);
if (r) {
kvm_mmu_prepare_memory_fault_exit(vcpu, fault);
return r;
}
...
}
[*] https://lore.kernel.org/all/20230908222905.1321305-5-amoorthy@google.com
next prev parent reply other threads:[~2023-09-13 17:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 10:48 [RFC PATCH 0/6] KVM: gmem: Implement error_remove_page isaku.yamahata
2023-09-13 10:48 ` [RFC PATCH 1/6] KVM: guest_memfd: Add config to show the capability to handle error page isaku.yamahata
2023-09-13 16:16 ` Sean Christopherson
2023-09-13 10:48 ` [RFC PATCH 2/6] KVM: guestmem_fd: Make error_remove_page callback to unmap guest memory isaku.yamahata
2023-09-13 16:28 ` Sean Christopherson
2023-09-13 10:48 ` [RFC PATCH 3/6] KVM: guest_memfd, x86: MEMORY_FAULT exit with hw poisoned page isaku.yamahata
2023-09-13 17:37 ` Sean Christopherson [this message]
2023-09-13 10:48 ` [RFC PATCH 4/6] KVM: guest_memfd: Implemnet bmap inode operation isaku.yamahata
2023-09-13 17:46 ` Sean Christopherson
2023-09-13 10:48 ` [RFC PATCH 5/6] KVM: selftests: Add selftest for guest_memfd() fibmap isaku.yamahata
2023-09-13 10:48 ` [RFC PATCH 6/6] KVM: X86: Allow KVM gmem hwpoison test cases isaku.yamahata
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=ZQHzVOIsesTTysgf@google.com \
--to=seanjc@google.com \
--cc=ackerleytng@google.com \
--cc=chao.p.peng@linux.intel.com \
--cc=chen.bo@intel.com \
--cc=dmatlack@google.com \
--cc=erdemaktas@google.com \
--cc=isaku.yamahata@gmail.com \
--cc=isaku.yamahata@intel.com \
--cc=jarkko@kernel.org \
--cc=kai.huang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=qperret@google.com \
--cc=sagis@google.com \
--cc=tabba@google.com \
--cc=vannapurve@google.com \
--cc=wei.w.wang@intel.com \
--cc=yilun.xu@intel.com \
--cc=yuan.yao@linux.intel.com \
--cc=zhi.wang.linux@gmail.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).