Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2068230pxb; Mon, 23 Aug 2021 11:16:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBsqYKGQuzg56QM+BeZ4QFKLwGFhFreBgiOL7qsDA2n3dwUaj6lz8vSTgR9tJ9+Yigemdr X-Received: by 2002:a17:906:fb91:: with SMTP id lr17mr36845674ejb.110.1629742597603; Mon, 23 Aug 2021 11:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629742597; cv=none; d=google.com; s=arc-20160816; b=Cjww72SPNWc/QLxP+zw94EgGhvxtfTLsFTaiVxX76lip7WJJaMhRwdb01I0JF9Qhci bQdckNuMTf0JTdtG6j8Il052ZCHPSUIprHS0p+AP9y9MiEqN/LeypTKqNeOqlCU8G1t9 EUh3ojUJZKQWeAxPceYKAXJcvr6FLzSv3KJ8dlRypdV3G+ogfCswNQLwuFUK26b3j5d+ Cjnj80hc3P0bfIoJUj1yJicY52XSfab+CH4nuHFRK7OCt9ZqteG6YHhs0hfdJun5LNTh +5fXhzCoVy+ze9PPbQYfiLnYnwjx1JLHO5dDvdk6bo8Nk/dMZCvMLCNXBuM7FINJAIDJ c/uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Fjnl2HoYdek4bDGF8q9Dry5mE5i47mO6qIdMvDvvKlM=; b=xxFzfKYq823imeFqrY7XzSWriCkOdGC2fwn1b6Vp++POatoxl7i53eFb1bPh9mWpyN GSzqP7cgXwE/1wEVcWtX7TAFMCnbN8av4D5N6FgKpA8WOmZ83UoljPK9BAOkKxVIE046 +pTro+hkVmeqBUwyfEB/5nGb/5JEq55ziJW75zUnnbxvgTMZKpsw6kRQZKIUWVnZJQMj 7oatglFUniqye8SAroDmlDymK5CCTXBO0OnTGkWvUf9c3Obj0P6shRfkH19gZcO5j5yV eiilDtJCiaNPE3UoRzKBIxvlec+0GZw9D6FSg4KyNAsqYyRU/VQhb7scUUln1zlG7L79 WQMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rkOROyK3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m17si538256edp.513.2021.08.23.11.16.13; Mon, 23 Aug 2021 11:16: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; dkim=pass header.i=@google.com header.s=20161025 header.b=rkOROyK3; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231979AbhHWSOC (ORCPT + 99 others); Mon, 23 Aug 2021 14:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230018AbhHWSOB (ORCPT ); Mon, 23 Aug 2021 14:14:01 -0400 Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE70C061575 for ; Mon, 23 Aug 2021 11:13:18 -0700 (PDT) Received: by mail-ua1-x933.google.com with SMTP id t26so8351919uao.12 for ; Mon, 23 Aug 2021 11:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Fjnl2HoYdek4bDGF8q9Dry5mE5i47mO6qIdMvDvvKlM=; b=rkOROyK355oHhZhcMezcHUuraKV+r8dH72LpjR0rMOGKx/c8PmrsjE6aKKDRwc6Glo DwJv8HlO8xF1ZgHYaY6q7X0VAt7oGIO0iK7TkIHYAfu8BObbdaEnlcFGTtL1MGvk7lTZ d6kgwuAAk0+YPLJoO3ZoZIt6dCSdivZkS+6cZER8pbUCt/ZqPseQXCHe7vFccJ7Eih0F qMqsGhd1C0wBqTFmGeaLBsnkic1URH+w3RmP1GML7Atu9n+UB+VkZAdD7mqxD2ZBdgGQ bkSbFomnuORLEJhk9fcbSWnKGB83p5gqTCOaIp3lHAoLbccdmFXglyZ6DU9dIXizEQsL HtJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Fjnl2HoYdek4bDGF8q9Dry5mE5i47mO6qIdMvDvvKlM=; b=H+QHakKOvF1fftSj6YdnXUQIhqyZwIBnOuRmOLaIsYfVDlaP8oznD3K1JrcRRofz0+ KVnjsj3wKzolXQtX/f/kFQeS8RXEYLL3jro8IVVbS8iua7OhA3vl8/sXGxmxJQ9jy8+a 8JIHZHfEGYI4kRH6dWO3RQ6du8qz4EHAk8WjwoOuWbjbAzvdNSapRt3S9UQoHyetkVhr 8RBUBmEgUiITzfGmHzLTOwbRqhLeJkAt9FABov1kCL3/tZ8seZc3XDc9kx8n7H4bKCrh FAdOSTpAQw7WcQuM0HHdSaUGgtErgCgNC01/DRSVA6ETXEYFM8pOtLN6dZpo8dP4P2oe 2Kyw== X-Gm-Message-State: AOAM532kEzuj45GAhxlFTcZoLBqDNrHnN2k7kxFI4AZD2fEG/hFt7qf8 7AVQ9QHChqYJXGwO7kaLW/fnC/AoW8XOXtlea/wM2g== X-Received: by 2002:ab0:344e:: with SMTP id a14mr7018853uaq.23.1629742397652; Mon, 23 Aug 2021 11:13:17 -0700 (PDT) MIME-Version: 1.0 References: <20210819223406.1132426-1-rananta@google.com> <87sfz4qx9r.wl-maz@kernel.org> <875yvzqd5d.wl-maz@kernel.org> In-Reply-To: <875yvzqd5d.wl-maz@kernel.org> From: Raghavendra Rao Ananta Date: Mon, 23 Aug 2021 11:13:06 -0700 Message-ID: Subject: Re: [PATCH] KVM: arm64: Ratelimit error log during guest debug exception To: Marc Zyngier 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards, Raghavendra > > M. > > -- > Without deviation from the norm, progress is not possible.