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 EF7171FC0FC; Mon, 2 Mar 2026 18:15:39 +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=1772475340; cv=none; b=mfHnZ+WL2rqs4sip32b+rF4gr942Nz1mJ3wI9X+IBVqGKoUaQA/fty8u1VDwjDuCnp8fsWyd/vybZQzM2zVnP9Hpl48MqqYuvahcI8OpN1XvFazWnk52HipwNgaRvIqotlAffniqm53Dl6yjJbA6YLx5+JCK/6AALd3+GYkBaoc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772475340; c=relaxed/simple; bh=n0j3s+Jv9EfYcZg7WCG66qjQA0IbWq3aYDUwX+zmmpY=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=mrTSeXW90PGEGjv12kjr/8jDZiojtMyrJTcc3ePsj69vMpZIet1+tRrJcvpHUZTgtewuwtxYSJP3ds9LZxcugxB+LF1BKG+pl9ZBTmyQAbn/6Es5hU7ywkKeLzku1yTLG1lNkt0zfHu4uHJ+LOSvnHdlSfuLNe+ZR/Zz3N6QMtY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mfs6dP63; 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="Mfs6dP63" 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) Precedence: bulk X-Mailing-List: linux-doc@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: 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 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.