From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD667C4338F for ; Mon, 23 Aug 2021 21:54:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96BC4611CB for ; Mon, 23 Aug 2021 21:54:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 96BC4611CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:Cc:To:From :Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZUCIrZlPlFQVco3IrDfGj7GgnFgMhfRMvxDGJAJxxVE=; b=cXCzpbIgVHZHiVz6HEUKdRcGzZ g7+IjgW6oQY/552aBirz0NVr2ZTEtgps9vbAN2U82N6Hypn80rSh9KIOJDA1RbBqHdvMnfX8H9NTk 0LToHStpUDPkBg6VieJUU2zpVYcCqy0AagJfbQu3ioVrsInxCML6aqdoAVU+VumZdnDoMDMCq4WtI OWzJcLFDMlNxzFDOvejZFy+1zs+EGRkPv3Rnnu5r1LUr0QwjSiFy6bVHaN6rzCaNq1uxe7sB8MUq+ MVK8zdKZ2vntV7M03pTn2SJdBXAi0bqC7iMR1rREvMGLIuBFpq+GCwrNWiWfdzHlTNL+QllUOLOD5 y7dig0aw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIHrG-000lxr-FR; Mon, 23 Aug 2021 21:51:54 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mIHrC-000lx7-PU for linux-arm-kernel@lists.infradead.org; Mon, 23 Aug 2021 21:51:52 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51466611CB; Mon, 23 Aug 2021 21:51:50 +0000 (UTC) Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mIHrA-006lhN-7D; Mon, 23 Aug 2021 22:51:48 +0100 MIME-Version: 1.0 Date: Mon, 23 Aug 2021 22:51:48 +0100 From: Marc Zyngier To: Raghavendra Rao Ananta Cc: Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , 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 In-Reply-To: References: <20210819223406.1132426-1-rananta@google.com> <87sfz4qx9r.wl-maz@kernel.org> <875yvzqd5d.wl-maz@kernel.org> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <1a0dfd2bc950cb84e7344973657c6b23@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: rananta@google.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, pshier@google.com, ricarkol@google.com, oupton@google.com, reijiw@google.com, jingzhangos@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210823_145150_917947_527CE6B2 X-CRM114-Status: GOOD ( 26.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-08-23 19:13, Raghavendra Rao Ananta wrote: > On Sat, Aug 21, 2021 at 3:56 AM Marc Zyngier wrote: >> >> On Sat, 21 Aug 2021 00:01:24 +0100, >> Raghavendra Rao Ananta wrote: >> > >> > [1 ] >> > On Fri, Aug 20, 2021 at 2:29 AM Marc Zyngier wrote: >> > > >> > > On Thu, 19 Aug 2021 23:34:06 +0100, >> > > Raghavendra Rao Ananta 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... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel