Skip to content

Commit 1631487

Browse files
author
Marc Zyngier
committed
Merge branch 'kvm-arm64/misc-5.9' into kvmarm-master/next
Signed-off-by: Marc Zyngier <[email protected]>
2 parents 236a559 + 022c832 commit 1631487

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ static __always_inline u8 kvm_vcpu_trap_get_fault_type(const struct kvm_vcpu *vc
345345
return kvm_vcpu_get_esr(vcpu) & ESR_ELx_FSC_TYPE;
346346
}
347347

348-
static __always_inline bool kvm_vcpu_dabt_isextabt(const struct kvm_vcpu *vcpu)
348+
static __always_inline bool kvm_vcpu_abt_issea(const struct kvm_vcpu *vcpu)
349349
{
350350
switch (kvm_vcpu_trap_get_fault(vcpu)) {
351351
case FSC_SEA:

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ static inline bool fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
444444
valid = kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_DABT_LOW &&
445445
kvm_vcpu_trap_get_fault_type(vcpu) == FSC_FAULT &&
446446
kvm_vcpu_dabt_isvalid(vcpu) &&
447-
!kvm_vcpu_dabt_isextabt(vcpu) &&
447+
!kvm_vcpu_abt_issea(vcpu) &&
448448
!kvm_vcpu_dabt_iss1tw(vcpu);
449449

450450
if (valid) {

arch/arm64/kvm/mmio.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
145145
return -ENOSYS;
146146
}
147147

148-
/* Page table accesses IO mem: tell guest to fix its TTBR */
149-
if (kvm_vcpu_dabt_iss1tw(vcpu)) {
150-
kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
151-
return 1;
152-
}
153-
154148
/*
155149
* Prepare MMIO operation. First decode the syndrome data we get
156150
* from the CPU. Then try if some in-kernel emulation feels

arch/arm64/kvm/mmu.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,18 +2111,15 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
21112111
is_iabt = kvm_vcpu_trap_is_iabt(vcpu);
21122112

21132113
/* Synchronous External Abort? */
2114-
if (kvm_vcpu_dabt_isextabt(vcpu)) {
2114+
if (kvm_vcpu_abt_issea(vcpu)) {
21152115
/*
21162116
* For RAS the host kernel may handle this abort.
21172117
* There is no need to pass the error into the guest.
21182118
*/
2119-
if (!kvm_handle_guest_sea(fault_ipa, kvm_vcpu_get_esr(vcpu)))
2120-
return 1;
2121-
2122-
if (unlikely(!is_iabt)) {
2119+
if (kvm_handle_guest_sea(fault_ipa, kvm_vcpu_get_esr(vcpu)))
21232120
kvm_inject_vabt(vcpu);
2124-
return 1;
2125-
}
2121+
2122+
return 1;
21262123
}
21272124

21282125
trace_kvm_guest_fault(*vcpu_pc(vcpu), kvm_vcpu_get_esr(vcpu),
@@ -2145,12 +2142,23 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
21452142
hva = gfn_to_hva_memslot_prot(memslot, gfn, &writable);
21462143
write_fault = kvm_is_write_fault(vcpu);
21472144
if (kvm_is_error_hva(hva) || (write_fault && !writable)) {
2145+
/*
2146+
* The guest has put either its instructions or its page-tables
2147+
* somewhere it shouldn't have. Userspace won't be able to do
2148+
* anything about this (there's no syndrome for a start), so
2149+
* re-inject the abort back into the guest.
2150+
*/
21482151
if (is_iabt) {
2149-
/* Prefetch Abort on I/O address */
21502152
ret = -ENOEXEC;
21512153
goto out;
21522154
}
21532155

2156+
if (kvm_vcpu_dabt_iss1tw(vcpu)) {
2157+
kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
2158+
ret = 1;
2159+
goto out_unlock;
2160+
}
2161+
21542162
/*
21552163
* Check for a cache maintenance operation. Since we
21562164
* ended-up here, we know it is outside of any memory
@@ -2161,7 +2169,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
21612169
* So let's assume that the guest is just being
21622170
* cautious, and skip the instruction.
21632171
*/
2164-
if (kvm_vcpu_dabt_is_cm(vcpu)) {
2172+
if (kvm_is_error_hva(hva) && kvm_vcpu_dabt_is_cm(vcpu)) {
21652173
kvm_skip_instr(vcpu, kvm_vcpu_trap_il_is32bit(vcpu));
21662174
ret = 1;
21672175
goto out_unlock;

include/trace/events/kvm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
ERSN(NMI), ERSN(INTERNAL_ERROR), ERSN(OSI), ERSN(PAPR_HCALL), \
1818
ERSN(S390_UCONTROL), ERSN(WATCHDOG), ERSN(S390_TSCH), ERSN(EPR),\
1919
ERSN(SYSTEM_EVENT), ERSN(S390_STSI), ERSN(IOAPIC_EOI), \
20-
ERSN(HYPERV)
20+
ERSN(HYPERV), ERSN(ARM_NISV)
2121

2222
TRACE_EVENT(kvm_userspace_exit,
2323
TP_PROTO(__u32 reason, int errno),

0 commit comments

Comments
 (0)