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 48685C87FD3 for ; Wed, 6 Aug 2025 17:14:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=q2UrxrNUyUG7YRjFMzzxoHd5jZWWKR8To7Q26VBhe+c=; b=CypndXwjIGDTBCJYZM8afc7tc0 qowZ28kOxVXzOSCihq0L0Bjr8TVcHN1xVnnRr4s1HkT67TALf0WG84TZBm6LdMxcUYB0SBhVlVnhI FmN1jyE9YckWnCXYwM0zR3ubjYjGZxXU/yT1uuXdytLxcuBTiGMGM/oFbcClaBCC5abs6hbZ07W6b jgAE3yFVSasBCfaYgx4HtCzKRdL8gDxJU0D2PpzQBy/owL04VNot/1OWWHrtfxDYwYxDrcs4qy4Ty Cm0b1QrjMpnsmdtTNCPxRgY7B8YUZ77iMBgJACRczknxQHTrXvAbfQKb71nSkeyI6+q3BLNwvvMMW VIxxm15A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1ujhin-0000000Frn6-3MQt; Wed, 06 Aug 2025 17:14:37 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1ujheY-0000000FrAO-1OQx for linux-arm-kernel@lists.infradead.org; Wed, 06 Aug 2025 17:10:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D521A5C6A28; Wed, 6 Aug 2025 17:10:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79002C4CEE7; Wed, 6 Aug 2025 17:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754500213; bh=KC18PkgeIXM5gTZVIz69jI5Goanj7HtMUTRlzjO5+w4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IE2yFYh/cEZc/FXrCrt2zf5Xd6VHBZ/yQDjkULkyXasQ8qrnqiegr0lh2Iddzv6o7 nzeG2B0HydxZ/o0FFBAn0QjGUatWZ/kg/oUfA0JU6mPLD4XMslQWe3Q/st4aKyvl4D 6L6Aq9JgXtX11k/GpLzcD8oPIT8uWACo+vLjMAp6YyTg2xRltGtpgZ29zCQtVWOuMC IOWqAqFbfBc2ZX6SrNuDjmmW8AAvzFZzeA4S/wgS/ebEP42wUh4ni+L9ZYLyd7AIWp SXojmJyPHwtm7natqKHlruFT+iaGBnak4Awb/Xr5vvFS4VMFiABsJoJCk/n2R/D6CB tqYouBl/9ommg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ujheU-004ZmT-PP; Wed, 06 Aug 2025 18:10:11 +0100 Date: Wed, 06 Aug 2025 18:10:10 +0100 Message-ID: <86a54c9y19.wl-maz@kernel.org> From: Marc Zyngier To: Andrew Jones Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Will Deacon , Mark Rutland , jackabt@amazon.com Subject: Re: [PATCH] KVM: arm64: selftest: Add standalone test checking for KVM's own UUID In-Reply-To: <20250722-87ac9d7e0b27cf7c67a4fbd3@orel> References: <20250721155136.892255-1-maz@kernel.org> <20250722-87ac9d7e0b27cf7c67a4fbd3@orel> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: ajones@ventanamicro.com, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, will@kernel.org, mark.rutland@arm.com, jackabt@amazon.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250806_101014_451061_3DC0F6BC X-CRM114-Status: GOOD ( 28.43 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 22 Jul 2025 10:18:10 +0100, Andrew Jones wrote: > > Hi Marc, > > On Mon, Jul 21, 2025 at 04:51:36PM +0100, Marc Zyngier wrote: > > Tinkering with UUIDs is a perilious task, and the KVM UUID gets > > broken at times. In order to spot this early enough, add a selftest > > that will shout if the expected value isn't found. > > > > Signed-off-by: Marc Zyngier > > Link: https://lore.kernel.org/r/20250721130558.50823-1-jackabt.amazon@gmail.com > > --- > > tools/testing/selftests/kvm/Makefile.kvm | 1 + > > tools/testing/selftests/kvm/arm64/kvm-uuid.c | 67 ++++++++++++++++++++ > > 2 files changed, 68 insertions(+) > > create mode 100644 tools/testing/selftests/kvm/arm64/kvm-uuid.c > > > > diff --git a/tools/testing/selftests/kvm/Makefile.kvm b/tools/testing/selftests/kvm/Makefile.kvm > > index ce817a975e50a..e1eb1ba238a2a 100644 > > --- a/tools/testing/selftests/kvm/Makefile.kvm > > +++ b/tools/testing/selftests/kvm/Makefile.kvm > > @@ -167,6 +167,7 @@ TEST_GEN_PROGS_arm64 += arm64/vgic_irq > > TEST_GEN_PROGS_arm64 += arm64/vgic_lpi_stress > > TEST_GEN_PROGS_arm64 += arm64/vpmu_counter_access > > TEST_GEN_PROGS_arm64 += arm64/no-vgic-v3 > > +TEST_GEN_PROGS_arm64 += arm64/kvm-uuid > > TEST_GEN_PROGS_arm64 += access_tracking_perf_test > > TEST_GEN_PROGS_arm64 += arch_timer > > TEST_GEN_PROGS_arm64 += coalesced_io_test > > diff --git a/tools/testing/selftests/kvm/arm64/kvm-uuid.c b/tools/testing/selftests/kvm/arm64/kvm-uuid.c > > new file mode 100644 > > index 0000000000000..89d9c8b182ae5 > > --- /dev/null > > +++ b/tools/testing/selftests/kvm/arm64/kvm-uuid.c > > @@ -0,0 +1,67 @@ > > +#include > > +#include > > +#include > > +#include > > + > > +#include "processor.h" > > + > > +/* > > + * Do NOT redefine these constants, or try to replace them with some > > + * "common" version. They are hardcoded here to detect any potential > > + * breakage happening in the rest of the kernel. > > + * > > + * KVM UID value: 28b46fb6-2ec5-11e9-a9ca-4b564d003a74 > > + */ > > +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_0 0xb66fb428U > > +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_1 0xe911c52eU > > +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_2 0x564bcaa9U > > +#define ARM_SMCCC_VENDOR_HYP_UID_KVM_REG_3 0x743a004dU > > + > > +static void guest_code(void) > > +{ > > + struct arm_smccc_res res = {}; > > + > > + smccc_hvc(ARM_SMCCC_VENDOR_HYP_CALL_UID_FUNC_ID, 0, 0, 0, 0, 0, 0, 0, &res); > > + > > + __GUEST_ASSERT(res.a0 != SMCCC_RET_NOT_SUPPORTED, "a0 = %lx\n", res.a0); > > Should this check res.a0 == SMCCC_RET_SUCCESS instead? Sorry for the delay, but now that I'm awake, it is obvious this doesn't work at all. A0-A3 contain the full UID. While checking for A0 != NOT_SUPPORTED is valid, checking for A0 == SUCCESS cannot work on KVM (we'd get 0xb66fb428 instead of 0). So actually, this assertion is meaningless, and I'm dropping it. Thanks, M. -- Without deviation from the norm, progress is not possible.