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 25E83EB3624 for ; Mon, 2 Mar 2026 18:15:46 +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=5jxRt3B+AdYvPnzRzs3IVfidBsKzyCOgtVxmU2NODGY=; b=FsAu/a2CqyhN7Mzqz4crec6O0s eaerLGgp4JzLy4cbl6hGx20qrt0VURvgAG29ansOmt/69FbJ2Zrk8tqa8MF+mX1NmhyE3UbK6Y4Dk 82VOBfWUAGwrhOccgC27wpTz4ahCOHPV+XeQOsllgTbf+b8PWqLVtAf7zTwXpQSE7NH6sxDHEM0JT kox4KKJMs3PoenBjvQJWuLjxYJXglqmU+Yq4vut5SPfEfNicY4UW1Y+6tHPZ6ajzzqpwDJicH+CgB WJ+myTglONLNjXDW1s2M3nypb69Gi+B+1wAYNB+tVdqinosn/lyYNUi1RzUp36BAtpny1ugdJ3hvW bTuSWmng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vx7nx-0000000DfQS-2itS; Mon, 02 Mar 2026 18:15:41 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vx7nw-0000000DfQL-2PJe for linux-arm-kernel@lists.infradead.org; Mon, 02 Mar 2026 18:15:40 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id E696F60008; Mon, 2 Mar 2026 18:15:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E8BDC19423; Mon, 2 Mar 2026 18:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772475339; bh=n0j3s+Jv9EfYcZg7WCG66qjQA0IbWq3aYDUwX+zmmpY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Mfs6dP63MQRqvFkP3VWM9bMGpb4DOCqjTpPenI6LAdbuNLXyunRWwgwj5wbvOR/FH ovy6+HXn2OLIIzdtg/qtNWlDBgguf9wveNIe3TtO2X7lQR8gOMeJ4NsH7fZBtqJyxx X8Q4z2sEt0gcEcNsSIO8prhFGAbnxmVyt+EJL9gRjlCrTPODa+YzT6AP1O8sf2dmyB WnUHc3d+4RDH+r6dTp17LHlRiaKQ9Moh8L/0SqZdat1T4YmNAa+B6sTYYQHRniEFxf Ks515h9ZCAxjHNLS90nUZ9eetOskJcrIu1Zjsk8Amd+WrhpAUrJCQWBfaxhYB/brbG YuR6o6KJQuAnA== 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 1vx7ns-0000000FMBu-3kY4; Mon, 02 Mar 2026 18:15:37 +0000 Date: Mon, 02 Mar 2026 18:15:36 +0000 Message-ID: <86jyvu85dj.wl-maz@kernel.org> From: Marc Zyngier To: Ben Horgan Cc: amitsinght@marvell.com, baisheng.gao@unisoc.com, baolin.wang@linux.alibaba.com, carl@os.amperecomputing.com, dave.martin@arm.com, david@kernel.org, dfustini@baylibre.com, fenghuay@nvidia.com, gshan@redhat.com, james.morse@arm.com, jonathan.cameron@huawei.com, kobak@nvidia.com, lcherian@marvell.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, peternewman@google.com, punit.agrawal@oss.qualcomm.com, quic_jiles@quicinc.com, reinette.chatre@intel.com, rohit.mathew@arm.com, scott@os.amperecomputing.com, sdonthineni@nvidia.com, tan.shaopeng@fujitsu.com, xhao@linux.alibaba.com, catalin.marinas@arm.com, will@kernel.org, corbet@lwn.net, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, kvmarm@lists.linux.dev, zengheng4@huawei.com, linux-doc@vger.kernel.org, Shaopeng Tan Subject: Re: [PATCH v5 12/41] KVM: arm64: Use kernel-space partid configuration for hypercalls In-Reply-To: <20260224175720.2663924-13-ben.horgan@arm.com> References: <20260224175720.2663924-1-ben.horgan@arm.com> <20260224175720.2663924-13-ben.horgan@arm.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) 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: ben.horgan@arm.com, amitsinght@marvell.com, baisheng.gao@unisoc.com, baolin.wang@linux.alibaba.com, carl@os.amperecomputing.com, dave.martin@arm.com, david@kernel.org, dfustini@baylibre.com, fenghuay@nvidia.com, gshan@redhat.com, james.morse@arm.com, jonathan.cameron@huawei.com, kobak@nvidia.com, lcherian@marvell.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, peternewman@google.com, punit.agrawal@oss.qualcomm.com, quic_jiles@quicinc.com, reinette.chatre@intel.com, rohit.mathew@arm.com, scott@os.amperecomputing.com, sdonthineni@nvidia.com, tan.shaopeng@fujitsu.com, xhao@linux.alibaba.com, catalin.marinas@arm.com, will@kernel.org, corbet@lwn.net, oupton@kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, kvmarm@lists.linux.dev, zengheng4@huawei.com, linux-doc@vger.kernel.org, tan.shaopeng@jp.fujitsu.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 Tue, 24 Feb 2026 17:56:51 +0000, Ben Horgan wrote: > > On nVHE systems whether or not MPAM is enabled, EL2 continues to use > partid-0 for hypercalls, even when the host may have configured its kernel > threads to use a different partid. 0 may have been assigned to another > task. Copy the EL1 MPAM register to EL2. This ensures hypercalls use the > same partid as the kernel thread does on the host. > > Tested-by: Gavin Shan > Tested-by: Shaopeng Tan > Tested-by: Peter Newman > Tested-by: Zeng Heng > Reviewed-by: Shaopeng Tan > Reviewed-by: Jonathan Cameron > Signed-off-by: Ben Horgan > --- > Changes since v2: > Use mask > Use read_sysreg_el1 to cope with hvhe > > Changes since v3: > Set MPAM2_EL2.MPAMEN to 1 as we rely on that before and after > --- > arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c > index e7790097db93..80e71eeddc03 100644 > --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c > +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c > @@ -638,6 +638,15 @@ static void handle_host_hcall(struct kvm_cpu_context *host_ctxt) > unsigned long hcall_min = 0; > hcall_t hfn; > > + if (system_supports_mpam()) { > + u64 mask = MPAM1_EL1_PARTID_D | MPAM1_EL1_PARTID_I | > + MPAM1_EL1_PMG_D | MPAM1_EL1_PMG_I; > + u64 val = MPAM2_EL2_MPAMEN | (read_sysreg_el1(SYS_MPAM1) & mask); > + > + write_sysreg_s(val, SYS_MPAM2_EL2); > + isb(); > + } > + > /* > * If pKVM has been initialised then reject any calls to the > * early "privileged" hypercalls. Note that we cannot reject It is extremely debatable whether this is desirable: - pKVM really shouldn't be influenced by what the host does, which means reserving PARTIDs and indirecting what the host sees. This can be deferred until pKVM is actually useful upstream. - repeatedly hammering that register plus an ISB on the hot path of a hypercall is a sure way to make things worse than they should be, and that should be fixed now. Do you really expect the EL1 settings to change on a regular basis? If so, I'd rather you use a specific host hypercall, or even a trap to propagate the EL1 configuration. If not, just set it as part of the KVM init and be done with it. Thanks, M. -- Without deviation from the norm, progress is not possible.