On Tue, 22 Sept 2026 at 15:19, Lorenzo Stoakes (ARM) <[email protected]> wrote: > > Currently kvm_s2_fault_pin_pfn() handles a poisoned page directly by > sending a SIGBUS signal itself. > > This is an odd place to do it, the caller should decide what to do with > errors, so move the handling to the sole caller, user_mem_abort(). > > This lays the foundation for stage 2 pre-faulting which, arising from a > synthetic fault, should not send a signal. > > In order to do so, check to see if user_mem_abort()'s caller has set result > - i.e. whether it wants to be informed about the outcome of the fault > handling. > > If it does, then it is implied that it should handle the -EHWPOISON error > itself. This is the case for pre-faulting. > > Otherwise this is real hardware, so send the signal. > > No functional change intended. > > Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
Reviewed-by: Fuad Tabba <[email protected]> Cheers, /fuad > --- > arch/arm64/kvm/mmu.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > index 221ea069f9bb..2576b967d20e 100644 > --- a/arch/arm64/kvm/mmu.c > +++ b/arch/arm64/kvm/mmu.c > @@ -2016,10 +2016,8 @@ static int kvm_s2_fault_pin_pfn(const struct > kvm_s2_fault_desc *s2fd, > kvm_s2_fault_is_write(s2fd) ? > FOLL_WRITE : 0, > &s2vi->map_writable, &s2vi->page); > if (unlikely(is_error_noslot_pfn(s2vi->pfn))) { > - if (s2vi->pfn == KVM_PFN_ERR_HWPOISON) { > - kvm_send_hwpoison_signal(s2fd->hva, > __ffs(s2vi->vma_pagesize)); > - return 0; > - } > + if (s2vi->pfn == KVM_PFN_ERR_HWPOISON) > + return -EHWPOISON; > return -EFAULT; > } > > @@ -2261,6 +2259,13 @@ static int user_mem_abort(const struct > kvm_s2_fault_desc *s2fd, > * get block mapping for device MMIO region. > */ > ret = kvm_s2_fault_pin_pfn(s2fd, &s2vi); > + if (ret == -EHWPOISON) { > + /* If result is specified, let the caller handle this. */ > + if (result) > + return -EHWPOISON; > + kvm_send_hwpoison_signal(s2fd->hva, __ffs(s2vi.vma_pagesize)); > + return 0; > + } > if (ret != 1) > return ret; > > > -- > 2.55.0 >

