diff options
author | Mark Rutland <mark.rutland@arm.com> | 2017-02-20 07:30:11 -0500 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2017-03-07 09:50:45 -0500 |
commit | f050fe7a9164945dd1c28be05bf00e8cfb082ccf (patch) | |
tree | a5b6a432b0371828356fd8e56ef71e488e1467a2 /arch/arm/kvm/handle_exit.c | |
parent | 370a0ec1819990f8e2a93df7cc9c0146980ed45f (diff) |
arm: KVM: Survive unknown traps from guests
Currently we BUG() if we see a HSR.EC value we don't recognise. As
configurable disables/enables are added to the architecture (controlled
by RES1/RES0 bits respectively), with associated synchronous exceptions,
it may be possible for a guest to trigger exceptions with classes that
we don't recognise.
While we can't service these exceptions in a manner useful to the guest,
we can avoid bringing down the host. Per ARM DDI 0406C.c, all currently
unallocated HSR EC encodings are reserved, and per ARM DDI
0487A.k_iss10775, page G6-4395, EC values within the range 0x00 - 0x2c
are reserved for future use with synchronous exceptions, and EC values
within the range 0x2d - 0x3f may be used for either synchronous or
asynchronous exceptions.
The patch makes KVM handle any unknown EC by injecting an UNDEFINED
exception into the guest, with a corresponding (ratelimited) warning in
the host dmesg. We could later improve on this with with a new (opt-in)
exit to the host userspace.
Cc: Dave Martin <dave.martin@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'arch/arm/kvm/handle_exit.c')
-rw-r--r-- | arch/arm/kvm/handle_exit.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c index 4e40d1955e35..96af65a30d78 100644 --- a/arch/arm/kvm/handle_exit.c +++ b/arch/arm/kvm/handle_exit.c | |||
@@ -79,7 +79,19 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run) | |||
79 | return 1; | 79 | return 1; |
80 | } | 80 | } |
81 | 81 | ||
82 | static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu, struct kvm_run *run) | ||
83 | { | ||
84 | u32 hsr = kvm_vcpu_get_hsr(vcpu); | ||
85 | |||
86 | kvm_pr_unimpl("Unknown exception class: hsr: %#08x\n", | ||
87 | hsr); | ||
88 | |||
89 | kvm_inject_undefined(vcpu); | ||
90 | return 1; | ||
91 | } | ||
92 | |||
82 | static exit_handle_fn arm_exit_handlers[] = { | 93 | static exit_handle_fn arm_exit_handlers[] = { |
94 | [0 ... HSR_EC_MAX] = kvm_handle_unknown_ec, | ||
83 | [HSR_EC_WFI] = kvm_handle_wfx, | 95 | [HSR_EC_WFI] = kvm_handle_wfx, |
84 | [HSR_EC_CP15_32] = kvm_handle_cp15_32, | 96 | [HSR_EC_CP15_32] = kvm_handle_cp15_32, |
85 | [HSR_EC_CP15_64] = kvm_handle_cp15_64, | 97 | [HSR_EC_CP15_64] = kvm_handle_cp15_64, |
@@ -98,13 +110,6 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) | |||
98 | { | 110 | { |
99 | u8 hsr_ec = kvm_vcpu_trap_get_class(vcpu); | 111 | u8 hsr_ec = kvm_vcpu_trap_get_class(vcpu); |
100 | 112 | ||
101 | if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) || | ||
102 | !arm_exit_handlers[hsr_ec]) { | ||
103 | kvm_err("Unknown exception class: hsr: %#08x\n", | ||
104 | (unsigned int)kvm_vcpu_get_hsr(vcpu)); | ||
105 | BUG(); | ||
106 | } | ||
107 | |||
108 | return arm_exit_handlers[hsr_ec]; | 113 | return arm_exit_handlers[hsr_ec]; |
109 | } | 114 | } |
110 | 115 | ||