Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2210954pxb; Mon, 23 Aug 2021 14:53:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLejI//+SNVzWzFt4PG+UYH5docFDoDDOLbWuSdlLaBv53H/RJgFclcvl/3hCsVEao3aVy X-Received: by 2002:a92:d848:: with SMTP id h8mr22770706ilq.230.1629755617975; Mon, 23 Aug 2021 14:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629755617; cv=none; d=google.com; s=arc-20160816; b=MnOq6jx6+QK8fgqdpbLiBKcvceDIjkri0j64DuBG4vwEqV0sVeEVim9lq+U2XcZpDf /APf0G7Vd6PA3TBv/OOrm/jesI103oWlFAgxQW6dNJxo2cWpPPobiuYJM2G38bWf7MPD i//Mxz85vlFt1AmBsS2MahNvJqwPuZWGa5DttCi0nN7h3PLzNdrLxYMWOolhDmIeeTnL caYDY5Jl6MDshFooDuydN6t0BY+3rqAlfIHH9+4ex63qao14BZ11bCGq93BQo2Cm5wIL 2K5+zBx2mNjNhbw2tpakHTAYP5qOEUMnFgiG/KrB44Vm8+suA/01RU8qHPtPikFHB/sF rG7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version; bh=jisbZOJmFH6Gx1Q6DxdwcNugnKXRg+62WaPHszbQ8i0=; b=zNh1J5wJp1AcgjDiCOzBrzVydFB2KLmUOGgBMjYs7jOYIUrOn81Kf1eMOrkDcXC5KM Lav1TOf/CRk2U4BCzRb4oe/6lYXyhRjmOQZY8qQWJtqHqVHhdsM5nWB6rGKV01NdmKjj 6504xmRwNQOtNzr/5z/PqgC4wVTIkG02IVcfF6F40++kalcS3oLwoi7uj8sLSNQs2gha wyEErFst/eB6ioqLEK/Ak2ZywdPSOw2Ifz1mlINFx9Hn0FC3Sy/WjQQmBfRPtGEmJD7v 7MATFrZM7iYHLFpkqE71n51M5QeGZ0sfejNx7BiMBvSWgZ1sdXHDuOgvg1XJpCpZbuMs O7Yw== 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 l13si14643577jaq.11.2021.08.23.14.53.25; Mon, 23 Aug 2021 14:53:37 -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 S233001AbhHWVwe (ORCPT + 99 others); Mon, 23 Aug 2021 17:52:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:47072 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbhHWVwd (ORCPT ); Mon, 23 Aug 2021 17:52:33 -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 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 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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...