[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZUPD9NWF4eOXqeiA@google.com>
Date: Thu, 2 Nov 2023 08:44:52 -0700
From: Sean Christopherson <seanjc@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>
Cc: Kai Huang <kai.huang@...el.com>, Xiaoyao Li <xiaoyao.li@...el.com>,
"kvm-riscv@...ts.infradead.org" <kvm-riscv@...ts.infradead.org>,
"mic@...ikod.net" <mic@...ikod.net>,
"liam.merwick@...cle.com" <liam.merwick@...cle.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
Isaku Yamahata <isaku.yamahata@...el.com>,
"viro@...iv.linux.org.uk" <viro@...iv.linux.org.uk>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"david@...hat.com" <david@...hat.com>,
"linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>,
"amoorthy@...gle.com" <amoorthy@...gle.com>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"tabba@...gle.com" <tabba@...gle.com>,
"kvmarm@...ts.linux.dev" <kvmarm@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"oliver.upton@...ux.dev" <oliver.upton@...ux.dev>,
"michael.roth@....com" <michael.roth@....com>,
"chao.p.peng@...ux.intel.com" <chao.p.peng@...ux.intel.com>,
"palmer@...belt.com" <palmer@...belt.com>,
"chenhuacai@...nel.org" <chenhuacai@...nel.org>,
"aou@...s.berkeley.edu" <aou@...s.berkeley.edu>,
"mpe@...erman.id.au" <mpe@...erman.id.au>,
Vishal Annapurve <vannapurve@...gle.com>,
"vbabka@...e.cz" <vbabka@...e.cz>,
"mail@...iej.szmigiero.name" <mail@...iej.szmigiero.name>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"maz@...nel.org" <maz@...nel.org>,
"willy@...radead.org" <willy@...radead.org>,
"dmatlack@...gle.com" <dmatlack@...gle.com>,
"anup@...infault.org" <anup@...infault.org>,
"yu.c.zhang@...ux.intel.com" <yu.c.zhang@...ux.intel.com>,
Yilun Xu <yilun.xu@...el.com>,
"qperret@...gle.com" <qperret@...gle.com>,
"brauner@...nel.org" <brauner@...nel.org>,
"isaku.yamahata@...il.com" <isaku.yamahata@...il.com>,
"ackerleytng@...gle.com" <ackerleytng@...gle.com>,
"jarkko@...nel.org" <jarkko@...nel.org>,
"paul.walmsley@...ive.com" <paul.walmsley@...ive.com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
Wei W Wang <wei.w.wang@...el.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
Subject: Re: [PATCH v13 09/35] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report
faults to userspace
On Thu, Nov 02, 2023, Paolo Bonzini wrote:
> On 11/2/23 10:35, Huang, Kai wrote:
> > IIUC KVM can already handle the case of poisoned
> > page by sending signal to user app:
> >
> > static int kvm_handle_error_pfn(struct kvm_vcpu *vcpu, struct
> > kvm_page_fault *fault) {
> > ...
> >
> > if (fault->pfn == KVM_PFN_ERR_HWPOISON) {
> > kvm_send_hwpoison_signal(fault->slot, fault->gfn);
No, this doesn't work, because that signals the host virtual address
unsigned long hva = gfn_to_hva_memslot(slot, gfn);
send_sig_mceerr(BUS_MCEERR_AR, (void __user *)hva, PAGE_SHIFT, current);
which is the *shared* page.
> > return RET_PF_RETRY;
> > }
> > }
>
> EHWPOISON is not implemented by this series, so it should be left out of the
> documentation.
EHWPOISON *is* implemented. kvm_gmem_get_pfn() returns -EWPOISON as appropriate,
and kvm_faultin_pfn() returns that directly without going through kvm_handle_error_pfn().
kvm_faultin_pfn_private()
|
|-> kvm_gmem_get_pfn()
|
|-> if (folio_test_hwpoison(folio)) {
r = -EHWPOISON;
goto out_unlock;
}
|
|-> 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;
}
|
|-> ret = __kvm_faultin_pfn(vcpu, fault);
if (ret != RET_PF_CONTINUE)
return ret;
if (unlikely(is_error_pfn(fault->pfn)))
return kvm_handle_error_pfn(vcpu, fault);
Powered by blists - more mailing lists