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 87A6C25A659 for ; Thu, 9 Oct 2025 12:22:27 +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=1760012548; cv=none; b=r5hoK/UgBsC1JO72w+GWV605GTfcqfU65oStq9nCmVgcrLNv/JB5fMB73TD94jixkjVPPG1EYNheoi3bI1h+VI5pRAN8DS/Z9nEw2B8O4HTGLiv7ueUZoDXeZ7elh79DV+tulWUWgCEtcxRWu8EZ66wntB89q5nrXOHoRjd0ooM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760012548; c=relaxed/simple; bh=Kn6xHKo0JXEWHVTtUBTdlwgV/s4gzg31YRonTQrYxpg=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=BISeIq9/cWHko8LvOqSihgB0N8FPpwUnGVfaSygY78OQPdMBoMmIe08gTY21ywbsVh559ywOroJHL9BZK0P5SsmMKjRElOR/x2WRsgWJE4UKHuVziQXBwF6Fm8o7YWUZbjHYuxcpsAfXkfVtNWdtEeg37NE14S8Tjj6kaUNDmtw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MRSpGCpU; 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="MRSpGCpU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25598C4CEE7; Thu, 9 Oct 2025 12:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760012547; bh=Kn6xHKo0JXEWHVTtUBTdlwgV/s4gzg31YRonTQrYxpg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MRSpGCpUzw2FxBbFoFzcerIr91PVvabn+kickj7IGFCWG2kxJk3eei+cdFhb0F0h/ FKApQDJH7p+A8Jgyn6sXEjmp0R7nggqry9Bi8EFtH3SjlPQ3t7zpzbTAmSrMMnhjIV 0iCVZrl7CRx1l7K9PozSMxy13md7Ww5M38wdQNMYkf0FHdUL5w4umY+ipGTEmQMOis DR7qrN9/w9/At4AqqdWWDI2nMNn86q6YBHJtEMS+hMBjZIwZnIKcGSoaQ9+zt1xmCS 7FIkPNEga5AsuvFdWO61qURmXyQ0M6tKO1PL9aigNIv0UfFYfZsj8wBhkxmU6aq4aX elklVkcplT/lg== 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 1v6pf7-0000000Ccgs-0A6g; Thu, 09 Oct 2025 12:22:25 +0000 Date: Thu, 09 Oct 2025 13:22:24 +0100 Message-ID: <86wm54xo1r.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: <86y0plxvt4.wl-maz@kernel.org> 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> <86y0plxvt4.wl-maz@kernel.org> 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: 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 16:22:31 +0100, Marc Zyngier wrote: > > 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? > > > > > > There are no traps for HCR_EL2. > > > > > >> As a test, I tried forcing this bit before running VCPUs, but > > >> reading it via MRS got a value without it being set. > > > > > > Where did you read that from? > > > > 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, > > > > > > > > If you apply the following change to your guest, does it start > > > behaving? > > > > > > M. > > > > > > diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/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_\@ > > > > > > orr x0, x0, #HCR_E2H > > > .LnVHE_\@: > > > > > > > With this change Guest OS starts the boot process. > > > > [ 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. As an alternative, and in an effort to keep at least VHE guests running on V2 (and other machines suffering from the same situation), I have posted a potential workaround at [1] for the guest to reliably detect the situation. Could you please test it with your setup and report whether this allows you to boot a VHE guest? You will need to patch the guest. Note that this still won't let you recursively virtualise EL2 (the HW can do it, but KVM in the guest doesn't know it), but that's better than nothing. Thanks, M. [1] https://lore.kernel.org/r/20251009121239.29370-1-maz@kernel.org -- Without deviation from the norm, progress is not possible.