From: Marc Zyngier <maz@kernel.org>
To: Raghavendra Rao Ananta <rananta@google.com>
Cc: Alexandru Elisei <alexandru.elisei@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Peter Shier <pshier@google.com>,
Ricardo Koller <ricarkol@google.com>,
Oliver Upton <oupton@google.com>,
Reiji Watanabe <reijiw@google.com>,
Jing Zhang <jingzhangos@google.com>,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: Ratelimit error log during guest debug exception
Date: Mon, 23 Aug 2021 22:51:48 +0100 [thread overview]
Message-ID: <1a0dfd2bc950cb84e7344973657c6b23@kernel.org> (raw)
In-Reply-To: <CAJHc60wLPFZ5XFwWVyex5GXr=qm7QWc2yOmkECxLh=L2QnvgWg@mail.gmail.com>
On 2021-08-23 19:13, Raghavendra Rao Ananta wrote:
> On Sat, Aug 21, 2021 at 3:56 AM Marc Zyngier <maz@kernel.org> wrote:
>>
>> On Sat, 21 Aug 2021 00:01:24 +0100,
>> Raghavendra Rao Ananta <rananta@google.com> wrote:
>> >
>> > [1 <text/plain; UTF-8 (7bit)>]
>> > On Fri, Aug 20, 2021 at 2:29 AM Marc Zyngier <maz@kernel.org> wrote:
>> > >
>> > > On Thu, 19 Aug 2021 23:34:06 +0100,
>> > > Raghavendra Rao Ananta <rananta@google.com> wrote:
>> > > >
>> > > > Potentially, the guests could trigger a debug exception that's
>> > > > outside the exception class range.
>> > >
>> > > How? All the exception classes that lead to this functions are already
>> > > handled in the switch/case statement.
>> > >
>> > I guess I didn't think this through. Landing into kvm_handle_guest_debug()
>> > itself is not possible :)
>>
>> Exactly.
>>
>> > > My take on this is that this code isn't reachable, and that it could
>> > > be better rewritten as:
>> > >
>> > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c
>> > > index 6f48336b1d86..ae7ec086827b 100644
>> > > --- a/arch/arm64/kvm/handle_exit.c
>> > > +++ b/arch/arm64/kvm/handle_exit.c
>> > > @@ -119,28 +119,14 @@ 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;
>> > > }
>> > >
>> > This looks better, but do you think we would be compromising on readability?
>>
>> I don't think so. The exit handler table is, on its own, pretty
>> explicit about what we route to this handler, and the comment above
>> the function clearly states that we exit to userspace for all the
>> debug ECs.
>
> Sounds great. I'm happy to send out a patch with you as 'Suggested-by'
> , if you
> are okay with it.
Fire away!
M.
--
Jazz is not dead. It just smells funny...
prev parent reply other threads:[~2021-08-23 21:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-19 22:34 [PATCH] KVM: arm64: Ratelimit error log during guest debug exception Raghavendra Rao Ananta
2021-08-20 9:29 ` Marc Zyngier
[not found] ` <CAJHc60wn7PP1zQ5EKOGQDFbZsf=d9codWTuWbtMT5AHegfbVHw@mail.gmail.com>
2021-08-21 10:56 ` Marc Zyngier
2021-08-23 18:13 ` Raghavendra Rao Ananta
2021-08-23 21:51 ` Marc Zyngier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1a0dfd2bc950cb84e7344973657c6b23@kernel.org \
--to=maz@kernel.org \
--cc=alexandru.elisei@arm.com \
--cc=catalin.marinas@arm.com \
--cc=jingzhangos@google.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oupton@google.com \
--cc=pshier@google.com \
--cc=rananta@google.com \
--cc=reijiw@google.com \
--cc=ricarkol@google.com \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).