@@ -1002,12 +1002,18 @@ Specifying exception.has_esr on a system that does not support it will return
10021002-EINVAL. Setting anything other than the lower 24bits of exception.serror_esr
10031003will return -EINVAL.
10041004
1005+ It is not possible to read back a pending external abort (injected via
1006+ KVM_SET_VCPU_EVENTS or otherwise) because such an exception is always delivered
1007+ directly to the virtual CPU).
1008+
1009+
10051010struct kvm_vcpu_events {
10061011 struct {
10071012 __u8 serror_pending;
10081013 __u8 serror_has_esr;
1014+ __u8 ext_dabt_pending;
10091015 /* Align it to 8 bytes */
1010- __u8 pad[6 ];
1016+ __u8 pad[5 ];
10111017 __u64 serror_esr;
10121018 } exception;
10131019 __u32 reserved[12];
@@ -1051,9 +1057,23 @@ contain a valid state and shall be written into the VCPU.
10511057
10521058ARM/ARM64:
10531059
1060+ User space may need to inject several types of events to the guest.
1061+
10541062Set the pending SError exception state for this VCPU. It is not possible to
10551063'cancel' an Serror that has been made pending.
10561064
1065+ If the guest performed an access to I/O memory which could not be handled by
1066+ userspace, for example because of missing instruction syndrome decode
1067+ information or because there is no device mapped at the accessed IPA, then
1068+ userspace can ask the kernel to inject an external abort using the address
1069+ from the exiting fault on the VCPU. It is a programming error to set
1070+ ext_dabt_pending after an exit which was not either KVM_EXIT_MMIO or
1071+ KVM_EXIT_ARM_NISV. This feature is only available if the system supports
1072+ KVM_CAP_ARM_INJECT_EXT_DABT. This is a helper which provides commonality in
1073+ how userspace reports accesses for the above cases to guests, across different
1074+ userspace implementations. Nevertheless, userspace can still emulate all Arm
1075+ exceptions by manipulating individual registers using the KVM_SET_ONE_REG API.
1076+
10571077See KVM_GET_VCPU_EVENTS for the data structure.
10581078
10591079
@@ -4471,6 +4491,39 @@ Hyper-V SynIC state change. Notification is used to remap SynIC
44714491event/message pages and to enable/disable SynIC messages/events processing
44724492in userspace.
44734493
4494+ /* KVM_EXIT_ARM_NISV */
4495+ struct {
4496+ __u64 esr_iss;
4497+ __u64 fault_ipa;
4498+ } arm_nisv;
4499+
4500+ Used on arm and arm64 systems. If a guest accesses memory not in a memslot,
4501+ KVM will typically return to userspace and ask it to do MMIO emulation on its
4502+ behalf. However, for certain classes of instructions, no instruction decode
4503+ (direction, length of memory access) is provided, and fetching and decoding
4504+ the instruction from the VM is overly complicated to live in the kernel.
4505+
4506+ Historically, when this situation occurred, KVM would print a warning and kill
4507+ the VM. KVM assumed that if the guest accessed non-memslot memory, it was
4508+ trying to do I/O, which just couldn't be emulated, and the warning message was
4509+ phrased accordingly. However, what happened more often was that a guest bug
4510+ caused access outside the guest memory areas which should lead to a more
4511+ meaningful warning message and an external abort in the guest, if the access
4512+ did not fall within an I/O window.
4513+
4514+ Userspace implementations can query for KVM_CAP_ARM_NISV_TO_USER, and enable
4515+ this capability at VM creation. Once this is done, these types of errors will
4516+ instead return to userspace with KVM_EXIT_ARM_NISV, with the valid bits from
4517+ the HSR (arm) and ESR_EL2 (arm64) in the esr_iss field, and the faulting IPA
4518+ in the fault_ipa field. Userspace can either fix up the access if it's
4519+ actually an I/O access by decoding the instruction from guest memory (if it's
4520+ very brave) and continue executing the guest, or it can decide to suspend,
4521+ dump, or restart the guest.
4522+
4523+ Note that KVM does not skip the faulting instruction as it does for
4524+ KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state
4525+ if it decides to decode and emulate the instruction.
4526+
44744527 /* Fix the size of the union. */
44754528 char padding[256];
44764529 };
0 commit comments