Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp530272imi; Fri, 22 Jul 2022 04:23:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vGlakY3zlbmA9cL/cGsVAmFrSC9wsHx6pnhY/LTvFoPdHIRIOkJnlh7usOb2a5XFhGqoMy X-Received: by 2002:a17:907:2ccb:b0:72b:52bb:fd51 with SMTP id hg11-20020a1709072ccb00b0072b52bbfd51mr102784ejc.118.1658489037426; Fri, 22 Jul 2022 04:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658489037; cv=none; d=google.com; s=arc-20160816; b=IePWhuagH1cX9IO4gXwQwxE/9i2nhknm07wPbgt+uJxpjzGcxTny90UtsPm9gpp8In fPg5lmD8RJX6Dqs/42qhO073tt8EDrLv9g/3gUmT6DO6GrIKNJK55L9el9GXEDnzUcIb DMYlGjjBJDNHXZ8Ez6q7ztUNZSkdFlYQ4DbEZoR3+P2ZqvDWMUfNgNhGJwKP0vDTX1QS TC1OzHdpT5aY/kGCeMy48cC6Fk2smXMjvBtkugMwdwxN3kUM1AzMD3ihONi2fuQFNgA3 7ToOgEO85yVhxSW2OjJhPYR0GGjxbLgxM6AATpCHdU2ZqK/cY5wl27ewi73k77Tax623 pyYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=bWMt6DrO+QpBB8jeoqRLaRrtD7zLY5M5syjYMGmYEtY=; b=ZCCiND97cq0qkFiYqhU6znV2ZEDaEORjbv72JyZ72g7S5ifrF2BbVyMDwZAP3i0Sql D2wD20ZJH0XU8xfPfb7WlaIcw2k52SUGgSgacowIVQMmTLQd1DOw8epAD+w3pjUgCleY b4slMgfaR2KkvzKPbDVQD/xZh0JE/qD0NGkEG0zeWzRwAqPZFSFG57IHS2nlXdK5mwMX bDfQRJOA70hvTlII6VRRqUL/cDLoolIVhSrdBJ3SOCbUE6E1ErWxQ9BkkQ+wHsDVdD3w 3Ue3yqrgjqnFKN6WXX1TvRh8EWN0CZmfe9H8Y281YI+6y3osbRZIk4qGIULoKRhUKap+ rNgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="Lhtr/bas"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a0564021e8a00b0043a7b67ce58si6583445edf.107.2022.07.22.04.23.32; Fri, 22 Jul 2022 04:23:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="Lhtr/bas"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234088AbiGVLQk (ORCPT + 99 others); Fri, 22 Jul 2022 07:16:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229671AbiGVLQj (ORCPT ); Fri, 22 Jul 2022 07:16:39 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6904049B5E for ; Fri, 22 Jul 2022 04:16:37 -0700 (PDT) Date: Fri, 22 Jul 2022 12:16:29 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1658488596; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bWMt6DrO+QpBB8jeoqRLaRrtD7zLY5M5syjYMGmYEtY=; b=Lhtr/basSfJ7soT0J6Z9kSRdSByaPWd/Q/wvSTsFIqpuD2HM2bD7yOHAHq26QrBiiVP69r iXiApSpbGWW7FcvvN/pp5eKGKPxWRgh8WoSWcG0oS+vH7yzNvYkzLxzEsMHuxwj9Y7J7hg s15kMJaK4m3UqyuT0c4Phm9u+xPLcDY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Kalesh Singh Cc: maz@kernel.org, mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com, tabba@google.com, will@kernel.org, qperret@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, vincenzo.frascino@arm.com, mhiramat@kernel.org, ast@kernel.org, drjones@redhat.com, wangkefeng.wang@huawei.com, elver@google.com, keirf@google.com, yuzenghui@huawei.com, ardb@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, android-mm@google.com, kernel-team@android.com Subject: Re: [PATCH v5 16/17] KVM: arm64: Introduce pkvm_dump_backtrace() Message-ID: References: <20220721055728.718573-1-kaleshsingh@google.com> <20220721055728.718573-17-kaleshsingh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220721055728.718573-17-kaleshsingh@google.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kalesh, On Wed, Jul 20, 2022 at 10:57:27PM -0700, Kalesh Singh wrote: [...] > +/* > + * pkvm_dump_backtrace - Dump the protected nVHE HYP backtrace. > + * > + * @hyp_offset: hypervisor offset, used for address translation. > + * > + * Dumping of the pKVM HYP backtrace is done by reading the > + * stack addresses from the shared stacktrace buffer, since the > + * host cannot direclty access hyperviosr memory in protected > + * mode. > + */ > +static void pkvm_dump_backtrace(unsigned long hyp_offset) > +{ > + unsigned long *stacktrace_entry > + = (unsigned long *)this_cpu_ptr_nvhe_sym(pkvm_stacktrace); > + unsigned long va_mask, pc; > + > + va_mask = GENMASK_ULL(vabits_actual - 1, 0); > + > + kvm_err("Protected nVHE HYP call trace:\n"); This and the footer printks should be put in respective helpers to share between pKVM and non-pKVM backtrace implementations. I imagine users will invariably bake some pattern matching to scrape traces, and it should be consistent between both flavors. > + /* The stack trace is terminated by a null entry */ > + for (; *stacktrace_entry; stacktrace_entry++) { At the point we're dumping the backtrace we know that EL2 has already soiled itself, so we shouldn't explicitly depend on it providing NULL terminators. I believe this loop should have an explicit range && NULL check. -- Thanks, Oliver