From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D88CF290BB0 for ; Wed, 30 Jul 2025 12:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753878266; cv=none; b=st2NNj5gv/vQBekpMk2jd7lRhAzgwE8MD+r9WovoqqgW8QED2wIJLLU04XAXUnAr3nzoWNHXTOksCyA5aEtZcDLXPwhT68L5cAlKedk/EuAeDZoI7FIobXSM0mAMIwKoy/aOVHtTsoFtckSOqEuRVSYlkGnRFNca8F6AqD/lO1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753878266; c=relaxed/simple; bh=NIU5+mW5WCvb9Wr9XZk3UOr5DSlgNeTvZCeVJvySs7c=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=T8KCIHA0//ZsIcaJGuzVzkHHTsx0ZS4QRK14d8+vxudG1iVuPnSewR2aEudzL6/BzyJQrZZQ3AWFPllmRZmHWSTsTdK5xYQ8YvbodPqtnGVGDauqxxtWj+Az0ca+x1xKhi+UHO9OQN6f/S5QGi80dff2tBg5HTd/rSZ5f7jz7JI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rWySNvrK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rWySNvrK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EE64C4CEF5; Wed, 30 Jul 2025 12:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753878266; bh=NIU5+mW5WCvb9Wr9XZk3UOr5DSlgNeTvZCeVJvySs7c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rWySNvrKl9K55GhIHtcVG0z/lJHv90+3bBaoj69K77C5m4aLQQCV2ib7StrIu0wGn ZKoZpAkvHQBSLrjPX2N++M4PVPvy0qYpwqm+tDkRm1eVIEZWeKaWN32VjA6rnPgKlc s+M3BUV29+RgFmeUzC1fqcYvMsU/7PvPL02KmU/5HPiTR276ulxiexVXUZAXD2Pv3Z /dkzxOSb09jcDKBRzAaXLElbxXi5Y8GbVAlQMw1LK77PuDEcGznPu//+YwuycywmzT CgX7MIIaNXyxKe1dhYL0vxppZ0ThyIqe6uzJskNwfTRVAgWWXEljNqiNNV80yAuPZ9 gmZkIp6ua+U6Q== 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 1uh5r6-002cHO-DD; Wed, 30 Jul 2025 13:24:24 +0100 Date: Wed, 30 Jul 2025 13:24:24 +0100 Message-ID: <861ppx9893.wl-maz@kernel.org> From: Marc Zyngier To: Itaru Kitayama Cc: kvmarm@lists.linux.dev Subject: Re: KVM selftest for L2 guest execution fails In-Reply-To: References: 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) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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: itaru.kitayama@linux.dev, kvmarm@lists.linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 30 Jul 2025 07:44:48 +0100, Itaru Kitayama wrote: > > Hi, > My small kvm sefltest tested on the kvmarm/next with NV2+VHE on FVP fails: > > # ./arm64/test5 > Random seed: 0x6b8b4567 > ==== Test Assertion Failure ==== > lib/kvm_util.c:1746: !ret > pid=257 tid=257 errno=11 - Resource temporarily unavailable > sh: line 1: addr2line: command not found > KVM_RUN failed, rc: -1 errno: 11 (Resource temporarily unavailable) > > Below is the test code, am I doing still wrong? Quite a lot is wrong there. > > Thanks, > Itaru. > > // SPDX-License-Identifier: GPL-2.0-only > > #include "test_util.h" > #include "kvm_util.h" > #include "processor.h" > #include "ucall.h" > > #define GUEST_SYNC_VAL 0x1234 > #define UCALL_GPA 0x500000 > > static void l1_guest_code(void) > { > /* > * Set up HCR_EL2 to enable virtualization and nested support: > * - HCR_EL2.VM = 1 (enable stage-2 translation) > * - HCR_EL2.NV = 1 (trap to EL2 on guest HVC, SMC, WFI, etc.) > * - HCR_EL2.TGE = 1 (trap general exceptions in EL1 to EL2) You really want to read the spec again -- this is not what this means. > */ > uint64_t hcr = (1UL << 0) | // VM > (1UL << 27) | // TGE > (1UL << 31); // NV - You enable S2 translation, and yet don't setup anything related to it - You have TGE set, and yet (try to) return to EL1 - You set NV, and yet don't have a VNCR_EL2 populated I don't know what you are trying to do here, but this is pretty badly thought out. I'd suggest you start by having a simple L2, without making use of NV at all in the guest. You will still have to have a stage-2 and a correct HCR_EL2 configuration -- none of which is as trivial as this test suggests. Once that is actually working, you can go wild and enable NV. But not before. M. -- Without deviation from the norm, progress is not possible.