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 ED5B66125 for ; Mon, 5 Dec 2022 18:06:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92936C433C1; Mon, 5 Dec 2022 18:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670263586; bh=JhTgGz1Z9A7cUDoB/pZqakGOGRWVDiTZ8epVjgTbHTU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QbEh5bglS/xuw0rrho1ODNLv/a9LJ6nkVgRfqWLDnjl/ox0kAe2q2ifWJ1qEexTFV BFlfisPqYK/5DriMUMqRfQS2kWDWotNyraHkM4pCrYz8BSQ/RT63TZbO/Xhf5gtqev OIY+nB1zyHaq1HcpNaN+QSN7djRJl8lqqtfz2jgiQ4q608V6ofNbY3kY3cl6pVLZ5N viiA5zXNhAfrQmhTGh2qDE8tJAPDb8uV3Ctu2c4uNgP7B+OkElje2X1cErI38g9Dpr 9vAm6Ny7CFrijf3TC431wAcqVu6CQz9szxdyRyJ1Ss+6k6Pw8Zt5mBE7tvJFVVXKUv MUbI7u+lbp7ug== 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 1p2FrE-00AdiT-KO; Mon, 05 Dec 2022 18:06:24 +0000 Date: Mon, 05 Dec 2022 18:06:24 +0000 Message-ID: <86pmcxlo7z.wl-maz@kernel.org> From: Marc Zyngier To: Mark Brown Cc: Catalin Marinas , Will Deacon , Lorenzo Pieralisi , Mark Rutland , Sami Mujawar , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v2 09/14] KVM: arm64: Hide FEAT_NMI from guests In-Reply-To: <20221112151708.175147-10-broonie@kernel.org> References: <20221112151708.175147-1-broonie@kernel.org> <20221112151708.175147-10-broonie@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/27.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: broonie@kernel.org, catalin.marinas@arm.com, will@kernel.org, lpieralisi@kernel.org, mark.rutland@arm.com, Sami.Mujawar@arm.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, 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 Sat, 12 Nov 2022 15:17:03 +0000, Mark Brown wrote: > > FEAT_NMI is not yet useful to guests pending implementation of vGIC > support. Mask out the feature from the ID register and prevent guests > creating state in ALLINT.ALLINT by activating the trap on write provided > in HCRX_EL2.TALLINT when they are running. There is no trap available > for reads from ALLINT. > > We do not need to check for FEAT_HCRX since it is mandatory since v8.7 > and FEAT_NMI is a v8.8 feature. And yet you check for it in hyp-stub.S after having checked for FEAT_NMI. What gives? > > Signed-off-by: Mark Brown > --- > arch/arm64/kvm/hyp/include/hyp/switch.h | 6 ++++++ > arch/arm64/kvm/sys_regs.c | 1 + > 2 files changed, 7 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h > index 6cbbb6c02f66..89e78c4e5cce 100644 > --- a/arch/arm64/kvm/hyp/include/hyp/switch.h > +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h > @@ -85,6 +85,9 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu) > write_sysreg(ARMV8_PMU_USERENR_MASK, pmuserenr_el0); > } > > + if (cpus_have_final_cap(ARM64_HAS_NMI)) > + sysreg_clear_set_s(SYS_HCRX_EL2, 0, HCRX_EL2_TALLINT); > + Crucially, this is missing a handler for the trap, resulting in a large splat once a guest accesses ALLINT. M. -- Without deviation from the norm, progress is not possible.