Skip to content

Commit 8ce8a6f

Browse files
rananta468Marc Zyngier
authored andcommitted
KVM: arm64: Trim guest debug exception handling
The switch-case for handling guest debug exception covers all the debug exception classes, but functionally, doesn't do anything with them other than ESR_ELx_EC_WATCHPT_LOW. Moreover, even though handled well, the 'default' case could be confusing from a security point of view, stating that the guests' actions can potentially flood the syslog. But in reality, the code is unreachable. Hence, trim down the function to only handle the case with ESR_ELx_EC_WATCHPT_LOW with a simple 'if' check. Suggested-by: Marc Zyngier <[email protected]> Signed-off-by: Raghavendra Rao Ananta <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6e73bc9 commit 8ce8a6f

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

arch/arm64/kvm/handle_exit.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,34 +113,20 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu)
113113
* guest and host are using the same debug facilities it will be up to
114114
* userspace to re-inject the correct exception for guest delivery.
115115
*
116-
* @return: 0 (while setting vcpu->run->exit_reason), -1 for error
116+
* @return: 0 (while setting vcpu->run->exit_reason)
117117
*/
118118
static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu)
119119
{
120120
struct kvm_run *run = vcpu->run;
121121
u32 esr = kvm_vcpu_get_esr(vcpu);
122-
int ret = 0;
123122

124123
run->exit_reason = KVM_EXIT_DEBUG;
125124
run->debug.arch.hsr = esr;
126125

127-
switch (ESR_ELx_EC(esr)) {
128-
case ESR_ELx_EC_WATCHPT_LOW:
126+
if (ESR_ELx_EC(esr) == ESR_ELx_EC_WATCHPT_LOW)
129127
run->debug.arch.far = vcpu->arch.fault.far_el2;
130-
fallthrough;
131-
case ESR_ELx_EC_SOFTSTP_LOW:
132-
case ESR_ELx_EC_BREAKPT_LOW:
133-
case ESR_ELx_EC_BKPT32:
134-
case ESR_ELx_EC_BRK64:
135-
break;
136-
default:
137-
kvm_err("%s: un-handled case esr: %#08x\n",
138-
__func__, (unsigned int) esr);
139-
ret = -1;
140-
break;
141-
}
142128

143-
return ret;
129+
return 0;
144130
}
145131

146132
static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)