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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 49C1BC25B75 for ; Mon, 3 Jun 2024 14:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PvAydcJybNNwPIM8b+XAs95IHzm5jaHyKktlYZMgK8Y=; b=LhAb7/kqHSwd0v T8mvcC0/AMzmjODOowQeBM6HSzNFmwudFwAmv6awitfD77wNwIh6tgrK2ePmCxpxAOjUlF2GAvCFa 0+J/87LhiXsVWEXkQlP1y/2+fu8mJZTWrPQUJ0X7LYlPIiZbKGqpMCsfYMdkzoMbw6FAi4kyH3G7c fxU/QmviKseMQnx4WtAZdjHDh9GRQwH5sI0K8Xe/2TabYNPt2YtRAPckZUtWekIOb1XyDSv7b53so geS5+4d91Sg05occuZfdyeq1DLtT+9EUsfzyEgnSmCzlNxvnm/2Z8YOjYrFZieMh9u670jWCJrmGu E0pkqzuX1DJSq5gbZ8AA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sE8yv-0000000H8ik-1Ow1; Mon, 03 Jun 2024 14:48:17 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sE8ys-0000000H8hz-1xQx for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2024 14:48:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A860460C31; Mon, 3 Jun 2024 14:48:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1D6AC2BD10; Mon, 3 Jun 2024 14:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717426093; bh=xwGJmu9SlDByMFEBw2+2znkb1UCEFJsO/NYkF0iLi88=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u9O7LWSEsZVIpSxOytjrDzW8s/QSrtPlgqRsgA55OaQpA46OK5C4zTZ+q6gsyRQsT 52NHRVuDbG4ydteWD8zOcFJdF/vm29R9+XVPBDoDE+a8itHby4HeQBrIHAP/AZujS5 iIgNqvS8hwEI+O4fSnvU6gSprlfO3Q16VXqTGSzdXFMWTVajiT/+fQRA4JORDapHLH jciky5/A0yft6YY0BiVOmx/WR8DtWNBSnOqmsoHRjFxhGwEft9rLFLZcNQMhaSmQXp x0tTPIL3qNbHSwFp7s1u5b77EkD+iUOcfsUKq9cTX2LkqYIIv9miGkjjZ5Lna2RoNN YGEmjFjm86Cgg== Date: Mon, 3 Jun 2024 15:48:08 +0100 From: Will Deacon To: =?iso-8859-1?Q?Pierre-Cl=E9ment?= Tosi Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Marc Zyngier , Oliver Upton , Suzuki K Poulose , Vincent Donnefort Subject: Re: [PATCH v4 11/13] KVM: arm64: Improve CONFIG_CFI_CLANG error message Message-ID: <20240603144808.GL19151@willie-the-truck> References: <20240529121251.1993135-1-ptosi@google.com> <20240529121251.1993135-12-ptosi@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240529121251.1993135-12-ptosi@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240603_074814_581740_7EB20E2C X-CRM114-Status: GOOD ( 18.54 ) 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-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, May 29, 2024 at 01:12:17PM +0100, Pierre-Cl=E9ment Tosi wrote: > For kCFI, the compiler encodes in the immediate of the BRK (which the > CPU places in ESR_ELx) the indices of the two registers it used to hold > (resp.) the function pointer and expected type. Therefore, the kCFI > handler must be able to parse the contents of the register file at the > point where the exception was triggered. > = > To achieve this, introduce a new hypervisor panic path that first stores > the CPU context in the per-CPU kvm_hyp_ctxt before calling (directly or > indirectly) hyp_panic() and execute it from all EL2 synchronous > exception handlers i.e. > = > - call it directly in host_el2_sync_vect (__kvm_hyp_host_vector, EL2t&h) > - call it directly in el2t_sync_invalid (__kvm_hyp_vector, EL2t) > - set ELR_EL2 to it in el2_sync (__kvm_hyp_vector, EL2h), which ERETs > = > Teach hyp_panic() to decode the kCFI ESR and extract the target and type > from the saved CPU context. In VHE, use that information to panic() with > a specialized error message. In nVHE, only report it if the host (EL1) > has access to the saved CPU context i.e. iff CONFIG_NVHE_EL2_DEBUG=3Dy, > which aligns with the behavior of CONFIG_PROTECTED_NVHE_STACKTRACE. > = > Signed-off-by: Pierre-Cl=E9ment Tosi > --- > arch/arm64/kvm/handle_exit.c | 30 +++++++++++++++++++++++-- > arch/arm64/kvm/hyp/entry.S | 24 +++++++++++++++++++- > arch/arm64/kvm/hyp/hyp-entry.S | 2 +- > arch/arm64/kvm/hyp/include/hyp/switch.h | 4 ++-- > arch/arm64/kvm/hyp/nvhe/host.S | 2 +- > arch/arm64/kvm/hyp/vhe/switch.c | 26 +++++++++++++++++++-- > 6 files changed, 79 insertions(+), 9 deletions(-) This quite a lot of work just to print out some opaque type numbers when CONFIG_NVHE_EL2_DEBUG=3Dy. Is it really worth it? How would I use this information to debug an otherwise undebuggable kcfi failure at EL2? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel