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 6933A2F3607 for ; Wed, 8 Oct 2025 15:22:34 +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=1759936954; cv=none; b=k+AhZmcmeiXDEubYEtz0v7I5Rv2tdE4Je4x5GbvwyFtXN6bTc7iZtJgEQ8+t8oi441JFqLp6lUsGeMwKFPIlKIx5rkOUwEVN+6dvSz5z0PTXoUwJAJCgJ1fYma15wPNNMXLLpZxe91xMxbVbYFhRhPSwdGlwjCj3tY/6YwjV8OU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759936954; c=relaxed/simple; bh=w24pNi2bHHfGA5EziVFh2Wen8X598y8wA70XLCZwCvo=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=M/uehiZ6yG4t8EPMfWkA6KuA/jjQRJrn803+6cSd1OTxXQxn1HmJ2TKaT+yuwziC6acWeuQyGkcs4drDv3MhCREJMjHjYl0FCWdEHL6oIcaHF26aRor47ZPJfFcFgIOuVqxZ+cdY+geQlGxLUI+FWbaCFhylA9jmX3SWOIidRO4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=k9i1pYNi; 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="k9i1pYNi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA370C4CEE7; Wed, 8 Oct 2025 15:22:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1759936953; bh=w24pNi2bHHfGA5EziVFh2Wen8X598y8wA70XLCZwCvo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=k9i1pYNiSeNXhLN6YP9QKC/OZOxnentlVFTYoihZ74ERjbO4LFED2zinxoVYrbkoN fQAWKyK5TnRt5Tael2BQwbxLTJIFG/Q+Sf0jAuHKBTzlvWjxt6bOyQlgTTWTooJqDW 2LiBtkJaikLrPk7DdUW5l2c0sirHWwx/hxb0bsJ2EOe0SS4YIORId8ToAj6aP4eJub KEwwDkz+89tZ4eNE8fxxUpbie5bvt/TDbT+2ueVtQEyZG1Tu2tdsTbsjK244Vum/QQ /sVbZ7PUZCYIRiMJ9NRDfWJJTyKQScovqLav8tcxH2XFJco1uUHuu2DEGvOYmd9Rey t65XmhGDn58PA== 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.98.2) (envelope-from ) id 1v6Vzr-0000000CNzu-2kAb; Wed, 08 Oct 2025 15:22:31 +0000 Date: Wed, 08 Oct 2025 16:22:31 +0100 Message-ID: <86y0plxvt4.wl-maz@kernel.org> From: Marc Zyngier To: Jan Kotas Cc: Oliver Upton , "kvmarm@lists.linux.dev" Subject: Re: KVM NV + SVE host OS warning In-Reply-To: <15A85F2B-1A0C-4FA7-9FE4-EEC2203CC09E@global.cadence.com> References: <799DD5E5-8BC2-47B3-A919-33429D3FB2F1@global.cadence.com> <865xd61tt5.wl-maz@kernel.org> <864isq1r66.wl-maz@kernel.org> <25C5E00D-62BC-4188-8642-21913446B32C@global.cadence.com> <1271032F-41BB-4896-AAED-8660D5459E7D@global.cadence.com> <864is9zqs9.wl-maz@kernel.org> <677A529C-B3D7-4BD1-BEED-D8414D961BBD@global.cadence.com> <86zfa1y58i.wl-maz@kernel.org> <15A85F2B-1A0C-4FA7-9FE4-EEC2203CC09E@global.cadence.com> 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=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: jank@cadence.com, oliver.upton@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, 08 Oct 2025 14:43:29 +0100, Jan Kotas wrote: > >> > >> Is it possible to trap/emulate HCR_EL2, and make sure E2H is always 1, > >> in cases when only KVM_ARM_VCPU_HAS_EL2 is set? > >> Would that help? > >=20 > > There are no traps for HCR_EL2. > >=20 > >> As a test, I tried forcing this bit before running VCPUs, but > >> reading it via MRS got a value without it being set. > >=20 > > Where did you read that from? >=20 > I checked the X1 register, after: mrs x1, hcr_el2 in __check_hvhe. That's too late. At this point, the write to HCR_EL2 will have already occurred, >=20 >=20 > > If you apply the following change to your guest, does it start > > behaving? > >=20 > > M. > >=20 > > diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/as= m/el2_setup.h > > index 46033027510cc..392c9f4016f2e 100644 > > --- a/arch/arm64/include/asm/el2_setup.h > > +++ b/arch/arm64/include/asm/el2_setup.h > > @@ -34,7 +34,7 @@ > > mrs_s x1, SYS_ID_AA64MMFR4_EL1 > > sbfx x1, x1, #ID_AA64MMFR4_EL1_E2H0_SHIFT, #ID_AA64MMFR4_EL1_E2H0_WIDTH > > cmp x1, #0 > > - b.ge .LnVHE_\@ > > +// b.ge .LnVHE_\@ > >=20 > > orr x0, x0, #HCR_E2H > > .LnVHE_\@: > >=20 >=20 > With this change Guest OS starts the boot process. >=20 > [ 0.000000] CPU features: detected: Virtualization Host Extensions > [ 6.998696] SMP: Total of 4 processors activated. > [ 7.257045] CPU: All CPU(s) started at EL2 > [ 185.781062] SVE: maximum available vector length 16 bytes per vector > [ 186.104159] SVE: default vector length 16 bytes per vector Great. That confirms my suspicion that we cannot advertise VHE on CPUs that do not have FEAT_FGT. Oh well. I'll post a patch to forbid VHE guests on these machines. > I also observed something interesting. > When PSCI method is set to HVC, I get a kernel panic. > This wasn=E2=80=99t a problem in all other test cases. Well, that's completely expected. HVC is handled by EL2. You run at EL2. You end-up calling yourself, which you don't really expect. SMC is the way for EL2 guests, as if they were on bare-metal. > On a side note, thank you for giving me some pointers. > With HAS_EL2_E2H the original Guest OS boots fine in nVHE. >=20 > [ 0.204744] CPU: All CPU(s) started at EL2 > [ 18.483737] SVE: maximum available vector length 16 bytes per vector > [ 18.500959] SVE: default vector length 16 bytes per vector > [ 25.999475] kvm [1]: Hyp nVHE mode initialized successfully Yup. I'll kill the ability to run VHE guests on crappy old HW then. Thanks for giving it a go! M. --=20 Without deviation from the norm, progress is not possible.