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 1E3F52EAD09; Tue, 27 Jan 2026 10:52:50 +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=1769511170; cv=none; b=VS3HUmY9K1OjxjNkNxbuSMH8MxD654BsylLHhv6MXSzylC1DDtyEgU+DOQNL0WnbWiPFw878uXQYxLcgCBszmsvfdAWDuTYBx/ht25zsSSu38v2resVu2+7rLvYNDXCLDIw789YvHxHklLJ3FWpdqmpAuYoCLiftia0UfVCDVeU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769511170; c=relaxed/simple; bh=3uI6G9ZvC3u/E2KG8h5NTQdenE0/m47znmeLe/doxxE=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=Yw+wP2/Y1ukTZz5ADVZet4fhXIaVU5D84As6r5xnIeegL/icbOvqaKxXGBP+keDFEmnqvN5l3FonhRuk8rAv4skj5o1+5fU2GaIJQ2dYrGIsVat0GwbsbduD0uYl1MfykU5KIkgWiK7a6FGmsbhibjckxNukXWw+k+/teEfPpfA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kV/A8pzt; 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="kV/A8pzt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF69CC116C6; Tue, 27 Jan 2026 10:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769511170; bh=3uI6G9ZvC3u/E2KG8h5NTQdenE0/m47znmeLe/doxxE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kV/A8pztnh9TRJM7t1K6pxMPJ6/E8bDxvMk9rlwTcPeOYI4akD/earpK4leBDTGJG K3F1dEW+Su7jTuuvBCfXIs/Z7EoreCmuHWsJRG1iKX6lM12AvqMmY8nVUQ+roDDlFT r5F8vmwbhzmyACuivpND3jCx604C4unyEHpFFQY2D/9LroF1/7nsWKR1S3wAXd933L 6as3fCnQzgXRcAzRkWGnJP+HHlcBqxXS+uSXk2wKHqMH2cdtv99wbWC/KVBnwWHbFf yMXjlLB8EA+lb+Ga8aFEkMnCfb9Ip+qQLrJ70DH7RCDleUAWw6gzxUomgCunaGALLr jk2cnFES4CjCw== 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 1vkggh-000000060we-2UUN; Tue, 27 Jan 2026 10:52:47 +0000 Date: Tue, 27 Jan 2026 10:52:47 +0000 Message-ID: <86ecnbba4g.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Will Deacon , Catalin Marinas Subject: Re: [PATCH 05/20] KVM: arm64: Extend unified RESx handling to runtime sanitisation In-Reply-To: References: <20260126121655.1641736-1-maz@kernel.org> <20260126121655.1641736-6-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: kvm@vger.kernel.org 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: tabba@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, will@kernel.org, catalin.marinas@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 26 Jan 2026 19:15:00 +0000, Fuad Tabba wrote: > > Hi Marc, > > On Mon, 26 Jan 2026 at 12:17, Marc Zyngier wrote: > > > > Add a new helper to retrieve the RESx values for a given system > > register, and use it for the runtime sanitisation. > > > > This results in slightly better code generation for a fairly hot > > path in the hypervisor. > > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/include/asm/kvm_host.h | 13 +++++++++++++ > > arch/arm64/kvm/emulate-nested.c | 10 +--------- > > arch/arm64/kvm/nested.c | 13 ++++--------- > > 3 files changed, 18 insertions(+), 18 deletions(-) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > > index a7e4cd8ebf56f..9dca94e4361f0 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -635,6 +635,19 @@ struct kvm_sysreg_masks { > > struct resx mask[NR_SYS_REGS - __SANITISED_REG_START__]; > > }; > > > > +#define kvm_get_sysreg_resx(k, sr) \ > > + ({ \ > > + struct kvm_sysreg_masks *__masks; \ > > + struct resx __resx = {}; \ > > + \ > > + __masks = (k)->arch.sysreg_masks; \ > > + if (likely(__masks && \ > > + sr >= __SANITISED_REG_START__ && \ > > + sr < NR_SYS_REGS)) \ > > + __resx = __masks->mask[sr - __SANITISED_REG_START__]; \ > > + __resx; \ > > + }) > > + > > This now covers all registers that need to be sanitized, not just > VNCR-backed ones now. Only kvm_get_sysreg_res0() was previously limited to VNCR-registers, and that was a bug found by Zenghui. What I'm trying to do here is to concentrate the decision about accessing the masks in a single place that is safe to use from any context. > > nit: wouldn't it be better to capture sr in a local variable rather > than reuse it? It is an enum, but it would make checkpatch feel > slightly better :) Indeed, this macro is pretty horrible, and needs some tidying up. I'll have a look at pimping it up ;-) > > Reviewed-by: Fuad Tabba Thanks! M. -- Without deviation from the norm, progress is not possible.