mbox series

[v3,0/2] Improve handling of stage 2 aborts without instruction decode

Message ID 20191011110709.2764-1-christoffer.dall@arm.com (mailing list archive)
Headers show
Series Improve handling of stage 2 aborts without instruction decode | expand

Message

Christoffer Dall Oct. 11, 2019, 11:07 a.m. UTC
When a guest accesses memory outside the memory slots, KVM usually
bounces the access back to userspace with KVM_EXIT_MMIO.  However, on
arm/arm64 systems, certain load/store instructions did not provide
decoding info for the hypervisor to emulate the instruction, and in this
case KVM has rather rudely returned -ENOSYS and printed a not overly
helpful error message:

  load/store instruction decoding not implemented

This patch series improves the error message and allows userspace to be
notified of this event instead of receiving -ENOSYS, and also allows
userspace to ask KVM to inject an external abort to the guest, which it
can use for any memory access that it either cannot handle.

One remaining case which this patch set does not address is if the guest
accesses an in-kernel emulated device, such as the VGIC, but using a
load/store instruction which doesn't provide decode info.  With these
patches, this will return to userspace for it to handle, but there's no
way for userspace to return the decoding information to KVM and have KVM
complete the access to the in-kernel emulated device.  I have no plans
to address this limitation.

Changes since v2:
 - Cleanup inconsistent use of has_ in patch 2 and allow injecting
   SError and external abort simultaenously with a single call to set
   VCPU events.

Changes since v1:
 - Rebased on v5.4-rc2
 - Fixed some documentation and coding nit in review of v1

Christoffer Dall (2):
  KVM: arm/arm64: Allow reporting non-ISV data aborts to userspace
  KVM: arm/arm64: Allow user injection of external data aborts

 Documentation/virt/kvm/api.txt       | 55 +++++++++++++++++++++++++++-
 arch/arm/include/asm/kvm_arm.h       |  1 +
 arch/arm/include/asm/kvm_emulate.h   |  5 +++
 arch/arm/include/asm/kvm_host.h      |  8 ++++
 arch/arm/include/uapi/asm/kvm.h      |  3 +-
 arch/arm/kvm/guest.c                 | 10 +++++
 arch/arm64/include/asm/kvm_emulate.h |  5 +++
 arch/arm64/include/asm/kvm_host.h    |  8 ++++
 arch/arm64/include/uapi/asm/kvm.h    |  3 +-
 arch/arm64/kvm/guest.c               | 10 +++++
 arch/arm64/kvm/inject_fault.c        |  4 +-
 include/uapi/linux/kvm.h             |  8 ++++
 virt/kvm/arm/arm.c                   | 22 +++++++++++
 virt/kvm/arm/mmio.c                  |  9 ++++-
 14 files changed, 145 insertions(+), 6 deletions(-)

Comments

Marc Zyngier Oct. 20, 2019, 10:25 a.m. UTC | #1
Hi Christoffer,

On Fri, 11 Oct 2019 12:07:04 +0100,
Christoffer Dall <christoffer.dall@arm.com> wrote:
> 
> When a guest accesses memory outside the memory slots, KVM usually
> bounces the access back to userspace with KVM_EXIT_MMIO.  However, on
> arm/arm64 systems, certain load/store instructions did not provide
> decoding info for the hypervisor to emulate the instruction, and in this
> case KVM has rather rudely returned -ENOSYS and printed a not overly
> helpful error message:
> 
>   load/store instruction decoding not implemented
> 
> This patch series improves the error message and allows userspace to be
> notified of this event instead of receiving -ENOSYS, and also allows
> userspace to ask KVM to inject an external abort to the guest, which it
> can use for any memory access that it either cannot handle.
> 
> One remaining case which this patch set does not address is if the guest
> accesses an in-kernel emulated device, such as the VGIC, but using a
> load/store instruction which doesn't provide decode info.  With these
> patches, this will return to userspace for it to handle, but there's no
> way for userspace to return the decoding information to KVM and have KVM
> complete the access to the in-kernel emulated device.  I have no plans
> to address this limitation.

You had some pending comments on patch 2, and you seem to indicate
that you would respin the series. Do you have plans to do so in the
coming days? I'd like to put that series into -next, but I can either
wait for your respin, or queue it as it is and apply fixes on top.

Please let me know what you prefer.

Thanks,

	M.
Christoffer Dall Oct. 21, 2019, 1:37 p.m. UTC | #2
On Sun, Oct 20, 2019 at 11:25:24AM +0100, Marc Zyngier wrote:
> Hi Christoffer,
> 
> On Fri, 11 Oct 2019 12:07:04 +0100,
> Christoffer Dall <christoffer.dall@arm.com> wrote:
> > 
> > When a guest accesses memory outside the memory slots, KVM usually
> > bounces the access back to userspace with KVM_EXIT_MMIO.  However, on
> > arm/arm64 systems, certain load/store instructions did not provide
> > decoding info for the hypervisor to emulate the instruction, and in this
> > case KVM has rather rudely returned -ENOSYS and printed a not overly
> > helpful error message:
> > 
> >   load/store instruction decoding not implemented
> > 
> > This patch series improves the error message and allows userspace to be
> > notified of this event instead of receiving -ENOSYS, and also allows
> > userspace to ask KVM to inject an external abort to the guest, which it
> > can use for any memory access that it either cannot handle.
> > 
> > One remaining case which this patch set does not address is if the guest
> > accesses an in-kernel emulated device, such as the VGIC, but using a
> > load/store instruction which doesn't provide decode info.  With these
> > patches, this will return to userspace for it to handle, but there's no
> > way for userspace to return the decoding information to KVM and have KVM
> > complete the access to the in-kernel emulated device.  I have no plans
> > to address this limitation.
> 
> You had some pending comments on patch 2, and you seem to indicate
> that you would respin the series. Do you have plans to do so in the
> coming days? I'd like to put that series into -next, but I can either
> wait for your respin, or queue it as it is and apply fixes on top.
> 

I think those for v2 and this is v3 which should address those concerns.
Did I miss something or manage to confuse mysel here?

Thanks,

    Christoffer
Marc Zyngier Oct. 21, 2019, 1:59 p.m. UTC | #3
On 2019-10-21 14:37, Christoffer Dall wrote:
> On Sun, Oct 20, 2019 at 11:25:24AM +0100, Marc Zyngier wrote:
>> Hi Christoffer,
>>
>> On Fri, 11 Oct 2019 12:07:04 +0100,
>> Christoffer Dall <christoffer.dall@arm.com> wrote:
>> >
>> > When a guest accesses memory outside the memory slots, KVM usually
>> > bounces the access back to userspace with KVM_EXIT_MMIO.  However, 
>> on
>> > arm/arm64 systems, certain load/store instructions did not provide
>> > decoding info for the hypervisor to emulate the instruction, and 
>> in this
>> > case KVM has rather rudely returned -ENOSYS and printed a not 
>> overly
>> > helpful error message:
>> >
>> >   load/store instruction decoding not implemented
>> >
>> > This patch series improves the error message and allows userspace 
>> to be
>> > notified of this event instead of receiving -ENOSYS, and also 
>> allows
>> > userspace to ask KVM to inject an external abort to the guest, 
>> which it
>> > can use for any memory access that it either cannot handle.
>> >
>> > One remaining case which this patch set does not address is if the 
>> guest
>> > accesses an in-kernel emulated device, such as the VGIC, but using 
>> a
>> > load/store instruction which doesn't provide decode info.  With 
>> these
>> > patches, this will return to userspace for it to handle, but 
>> there's no
>> > way for userspace to return the decoding information to KVM and 
>> have KVM
>> > complete the access to the in-kernel emulated device.  I have no 
>> plans
>> > to address this limitation.
>>
>> You had some pending comments on patch 2, and you seem to indicate
>> that you would respin the series. Do you have plans to do so in the
>> coming days? I'd like to put that series into -next, but I can 
>> either
>> wait for your respin, or queue it as it is and apply fixes on top.
>>
>
> I think those for v2 and this is v3 which should address those 
> concerns.
> Did I miss something or manage to confuse mysel here?

Gah! No, it looks like the mistake is mine. I've mixed the two series 
in my
Inbox, and the result is a total brain-fart. Ignore me.

I'll queue these patches ASAP.

Thanks,

         M.