Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1300524pxb; Fri, 20 Aug 2021 02:34:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIJczXCJqx7zGIHRI1Bar3nhX55xA5wWJ0dnTugaKL2ULIWvllMR48Th+jx/B1/GjQK1IU X-Received: by 2002:a17:906:30d8:: with SMTP id b24mr20586068ejb.358.1629452058917; Fri, 20 Aug 2021 02:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629452058; cv=none; d=google.com; s=arc-20160816; b=lax+oDEHWK74pXs+VzCB0BW52/sT1nVoBOOoT/BFmtiegLjEh26IO+A4cqjOyE2QC+ YT0p1ASdqp3ChOrzyLWkh6Xr2lJ8PuC4mQqC0uAlWX+GUL1vVoG+FRGDDKPKIfH6Sq1N Js4bvSjUtb7GODjIqF1+sdSbX2wir+KCmX557M6UQNNexfSX73I8wa9/K59KR9T1NoGv +4CjUxOTzXkcdhqaJCp+lwBR3WOHGCu5Wj7Z5CDBv62mGvQgCrugt5IXCzyExjpi8cxS bUc52Frfcf+vxhvSlYO4jKT2Y890bmx4LVunnfbWzgm6CGXlXt2hQX0JfI7lFSi7qT8K B0xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date; bh=YZI3Mg86KmtbNCWO3RM8ajrI2AO58nF47Zbn0WVmcrE=; b=YhEWOgpNz8SJ+TRZ674Ym8Lc9O6Y+Mu+pRMTuuzGXoe8uPIFVhKWSQ6hUedIr1lNZE MjG7+9KrMg3W9BsjqNV+3SDOQa0sJ6tIIE/oddsyTJaa5a0Y5qYG0Fu5ytaiDmIe97qU uC9ZPaiywfaf3bn5Y7Yj9yHQCZlwQEfB48QeBCkhVVptjBckkCx1gG9j9oWbIskP8Hr/ h9SsbhCZjKOdMeNtumqcuXk2QmXGI1q8Zdf4cHOqlTnego0d/9f3vaYS5AvZ3KbdZGME vjUI999OqLufIyrNRuP2fIJ3CqbZ9nwadhYrLkMaBapgpNmEh3npwBGa/sOOPznuHcaJ 5HBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z25si6476040eje.188.2021.08.20.02.33.56; Fri, 20 Aug 2021 02:34:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236602AbhHTJad (ORCPT + 99 others); Fri, 20 Aug 2021 05:30:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:36614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236378AbhHTJac (ORCPT ); Fri, 20 Aug 2021 05:30:32 -0400 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 532976112E; Fri, 20 Aug 2021 09:29:55 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) 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 1mH0qX-0069Z8-8X; Fri, 20 Aug 2021 10:29:53 +0100 Date: Fri, 20 Aug 2021 10:29:52 +0100 Message-ID: <87sfz4qx9r.wl-maz@kernel.org> 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: <20210819223406.1132426-1-rananta@google.com> References: <20210819223406.1132426-1-rananta@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > This could lead to an excessive syslog flooding. Hence, ratelimit > the error message. > > Signed-off-by: Raghavendra Rao Ananta > --- > arch/arm64/kvm/handle_exit.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > index 04ebab299aa4..c7cec7ffe93c 100644 > --- a/arch/arm64/kvm/handle_exit.c > +++ b/arch/arm64/kvm/handle_exit.c > @@ -134,7 +134,7 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu) > case ESR_ELx_EC_BRK64: > break; > default: > - kvm_err("%s: un-handled case esr: %#08x\n", > + kvm_pr_unimpl("%s: un-handled case esr: %#08x\n", > __func__, (unsigned int) esr); > ret = -1; > break; 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; } static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu) Thanks, M. -- Without deviation from the norm, progress is not possible.