linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Trim guest debug exception handling
@ 2021-08-23 22:39 Raghavendra Rao Ananta
  2021-08-26 10:37 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Raghavendra Rao Ananta @ 2021-08-23 22:39 UTC (permalink / raw)
  To: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose
  Cc: Catalin Marinas, Will Deacon, Peter Shier, Ricardo Koller,
	Oliver Upton, Reiji Watanabe, Jing Zhang, Raghavendra Rao Anata,
	linux-arm-kernel, kvmarm, linux-kernel

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 <maz@kernel.org>
Signed-off-by: Raghavendra Rao Ananta <rananta@google.com>
---
 arch/arm64/kvm/handle_exit.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
index 04ebab299aa4..275a27368a04 100644
--- a/arch/arm64/kvm/handle_exit.c
+++ b/arch/arm64/kvm/handle_exit.c
@@ -113,34 +113,20 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu)
  * guest and host are using the same debug facilities it will be up to
  * userspace to re-inject the correct exception for guest delivery.
  *
- * @return: 0 (while setting vcpu->run->exit_reason), -1 for error
+ * @return: 0 (while setting vcpu->run->exit_reason)
  */
 static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu)
 {
 	struct kvm_run *run = vcpu->run;
 	u32 esr = kvm_vcpu_get_esr(vcpu);
-	int ret = 0;
 
 	run->exit_reason = KVM_EXIT_DEBUG;
 	run->debug.arch.hsr = esr;
 
-	switch (ESR_ELx_EC(esr)) {
-	case ESR_ELx_EC_WATCHPT_LOW:
+	if (ESR_ELx_EC(esr) == ESR_ELx_EC_WATCHPT_LOW)
 		run->debug.arch.far = vcpu->arch.fault.far_el2;
-		fallthrough;
-	case ESR_ELx_EC_SOFTSTP_LOW:
-	case ESR_ELx_EC_BREAKPT_LOW:
-	case ESR_ELx_EC_BKPT32:
-	case ESR_ELx_EC_BRK64:
-		break;
-	default:
-		kvm_err("%s: un-handled case esr: %#08x\n",
-			__func__, (unsigned int) esr);
-		ret = -1;
-		break;
-	}
 
-	return ret;
+	return 0;
 }
 
 static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu)
-- 
2.33.0.rc2.250.ged5fa647cd-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: arm64: Trim guest debug exception handling
  2021-08-23 22:39 [PATCH] KVM: arm64: Trim guest debug exception handling Raghavendra Rao Ananta
@ 2021-08-26 10:37 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2021-08-26 10:37 UTC (permalink / raw)
  To: Raghavendra Rao Ananta, Alexandru Elisei, Suzuki K Poulose, James Morse
  Cc: Jing Zhang, Catalin Marinas, Reiji Watanabe, kvmarm, Peter Shier,
	Oliver Upton, linux-kernel, Will Deacon, Ricardo Koller,
	linux-arm-kernel

On Mon, 23 Aug 2021 22:39:40 +0000, Raghavendra Rao Ananta wrote:
> 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.
> 
> [...]

Applied to next, thanks!

[1/1] KVM: arm64: Trim guest debug exception handling
      commit: 8ce8a6fce9bfd3fcabe230ad104e2caf08b2e58d

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-26 10:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23 22:39 [PATCH] KVM: arm64: Trim guest debug exception handling Raghavendra Rao Ananta
2021-08-26 10:37 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).