From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20400D2D8F7 for ; Tue, 27 Jan 2026 10:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TqcocRxJ004DQ8OQDmK/VD91TGjnh8QAYnSuWwIjVUE=; b=Jyb/BjlCQnr4y033ZW1z6xAV5g ACuGcrI+QlQcnAx1cFg/Vi9+W0BMJbKJZXkNc0iS3IedUrDTLdreKdhe3Qn5/WgA+nB/pkYoEbxOj afsNh4lp2Wk3TcQLIxqfuKhd5eMqyijnXutqwWFvl/hSSg2vpYThZUukjsQ3xun9GlJkcBQCdaZBD TCIxvs/P+KZ5VAXwkHypalIKIDjjpdk28wZyIqb9KeVyNgJeibfQnB2no0cdBv0VLr240a9aGHik2 N2FhQzxFadYPS82rcBaC7W41vnG5D6pLdTgAX+i4syqLcL08sYADi76psjurQscBp/yl5P16UJx8N qTdXEizg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vkggm-0000000E6EB-0ecE; Tue, 27 Jan 2026 10:52:52 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vkggl-0000000E6E4-0y7T for linux-arm-kernel@lists.infradead.org; Tue, 27 Jan 2026 10:52:51 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 52DE460097; Tue, 27 Jan 2026 10:52:50 +0000 (UTC) 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) 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 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.