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 590FCC25B75 for ; Mon, 3 Jun 2024 13:10:51 +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=40lc4IjuGygiTAO2zjUNL8CVx0EccF/fQ6RQygnvMzE=; b=k62eOyXTBYWMK8 gqVzAKpSpE/W6quJ/YlcQj38SdYOhXN/pOHTD5GPnlpVUbXlL+TqTdq7Wi2X+vwG3B78PSh7Ly7D+ 544DCBIMdUUpyCrMRQmTHx/fsVFOaokA3KMzE3pp5E/ejhthU06u/6j+5hUSrjCKblqaKFE9MlWQV mvfMuAkpdavcLb5IF6U2S6MRseTQ7KdupCDXtEgruxAIXgPo4bXLvItVtN8ID/Z4bXOVgzX01gaLM 2VUtmRk8tf34ktN6N/7ZxHuf1z63fFMvqeipy2+G7ZIBgpjHmXGLusBvd6MbguRHBaxexDNa2Y4WU tGy/7TsNkxD/hXTJFpYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sE7ST-0000000GrGQ-0iYa; Mon, 03 Jun 2024 13:10:41 +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 1sE7SQ-0000000GrEd-0gTU for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2024 13:10:39 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 22F6060DED; Mon, 3 Jun 2024 13:10:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D258C2BD10; Mon, 3 Jun 2024 13:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717420236; bh=/U+/VxmSixKZ9uDr/+sYfe+DKCQqxNMHObH457JSDVY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=niL7G3teA3ZpMeqqGERZKifChBdGxIzUii/571g4IMuK3na3aK3RTt6aCs1ybtmCO UKc4dyis8hBygdPykI50IiqTFGRS0ZXt6jRGdCfFSc/H+ot84DL/s2xneWGftP4jPP 4b1Ca1+KzFwHMykS1fnN3a2OAisg588BzCMtiNlz8wXarV5HdrvdfsGcYpLmBwzup1 sfMIb5/8cnGMSyR9pRyMPsxU8ny/BCccFbwk4iPziTv0Kozei1Sn3hUc1dREPYceqi 81bHSmEvOL1fGpoomE1LgjXElTMyGHFjf1UW7IOIBRjPPQ1SDuR166XvtMRWV62XtP IcGkkCZfLVg7A== Date: Mon, 3 Jun 2024 14:10:32 +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 v3 09/12] KVM: arm64: VHE: Add test module for hyp kCFI Message-ID: <20240603131031.GB18991@willie-the-truck> References: <20240510112645.3625702-1-ptosi@google.com> <20240510112645.3625702-10-ptosi@google.com> <20240513172120.GA29051@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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_061038_336366_991255D0 X-CRM114-Status: GOOD ( 28.61 ) 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:26:31PM +0100, Pierre-Cl=E9ment Tosi wrote: > On Mon, May 13, 2024 at 06:21:21PM +0100, Will Deacon wrote: > > On Fri, May 10, 2024 at 12:26:38PM +0100, Pierre-Cl=E9ment Tosi wrote: > > > diff --git a/arch/arm64/include/asm/kvm_cfi.h b/arch/arm64/include/as= m/kvm_cfi.h > > > new file mode 100644 > > > index 000000000000..13cc7b19d838 > > > --- /dev/null > > > +++ b/arch/arm64/include/asm/kvm_cfi.h > > > @@ -0,0 +1,36 @@ > > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > > +/* > > > + * Copyright (C) 2024 - Google Inc > > > + * Author: Pierre-Cl=E9ment Tosi > > > + */ > > > + > > > +#ifndef __ARM64_KVM_CFI_H__ > > > +#define __ARM64_KVM_CFI_H__ > > > + > > > +#include > > > +#include > > > + > > > +#ifdef CONFIG_HYP_SUPPORTS_CFI_TEST > > > + > > > +int kvm_cfi_test_register_host_ctxt_cb(void (*cb)(void)); > > > +int kvm_cfi_test_register_guest_ctxt_cb(void (*cb)(void)); > > = > > Hmm, I tend to think this indirection is a little over the top for a te= st > > module that only registers a small handful of handlers: > > = > > > +static int set_param_mode(const char *val, const struct kernel_param= *kp, > > > + int (*register_cb)(void (*)(void))) > > > +{ > > > + unsigned int *mode =3D kp->arg; > > > + int err; > > > + > > > + err =3D param_set_uint(val, kp); > > > + if (err) > > > + return err; > > > + > > > + switch (*mode) { > > > + case 0: > > > + return register_cb(NULL); > > > + case 1: > > > + return register_cb(hyp_trigger_builtin_cfi_fault); > > > + case 2: > > > + return register_cb((void *)hyp_cfi_builtin2module_test_target); > > > + case 3: > > > + return register_cb(trigger_module2builtin_cfi_fault); > > > + case 4: > > > + return register_cb(trigger_module2module_cfi_fault); > > > + default: > > > + return -EINVAL; > > > + } > > > +} > > = > > Why not just have a hyp selftest that runs through all of this behind a > > static key? I think it would simplify the code quite a bit, and you cou= ld > > move the registration and indirection logic. > = > I agree that the code would be simpler but note that the resulting tests = would > have a more limited coverage compared to what this currently implements. = In > particular, they would likely miss issues with the failure path itself (e= .g. > [1]) as the synchronous exception would need to be "handled" to let the s= elftest > complete. OTOH, that would have the benefit of not triggering a kernel pa= nic, > making the test easier to integrate into existing CI suites. > = > However, as the original request for those tests [2] was specifically abo= ut > testing the failure path, I've held off from modifying the test module (i= n v4) > until I get confirmation that Marc would be happy with your suggestion. > = > [1]: https://lore.kernel.org/kvmarm/20240529121251.1993135-2-ptosi@google= .com/ > [2]: https://lore.kernel.org/kvmarm/867ci10zv6.wl-maz@kernel.org/ In which case, I think I'd drop the tests for now because I think the cure is worse than the disease with the current implementation. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel