From nobody Mon Feb 9 17:22:48 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79E37374182; Tue, 3 Feb 2026 21:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770155111; cv=none; b=YZkrqx2F9Osxe550mOIiPYiUeutxFUVIPLwfEXHl0GO8Fah1vtYfN06FiKWrQRjMxWK2wUIxufhyE6ZgGG+hNvgJzS41UMydOyXCtXh5o3EoMJyXb82PIYiBGDb9uDcT1Y6o/oejHs46PbJUPJ+uwgFsHHWd36IRVIj632MwcxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770155111; c=relaxed/simple; bh=9osoHH2oNr4PCT5h7cxXVlOZ67jY7PCppJ8b8zWTWcY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iNjpWWjnIgZS+bClkITXXHQQi6M4JKGMFPeNIEfiLWLHuveNKPt4n1cWuIiHt9L8rAP5nHRgqh2jDNyVA0FODfFcaQ7kslVBqFSmeekKNDbbNk/GjcCCnTbWoafjbwglZf8OTkE2BKB3AYibsomHDFBZ61uytygVMIgQl3bnA5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BA443339; Tue, 3 Feb 2026 13:45:03 -0800 (PST) Received: from e134344.cambridge.arm.com (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8F17E3F778; Tue, 3 Feb 2026 13:45:04 -0800 (PST) From: Ben Horgan To: ben.horgan@arm.com 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, maz@kernel.org, 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: [PATCH v4 12/41] KVM: arm64: Use kernel-space partid configuration for hypercalls Date: Tue, 3 Feb 2026 21:43:13 +0000 Message-ID: <20260203214342.584712-13-ben.horgan@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260203214342.584712-1-ben.horgan@arm.com> References: <20260203214342.584712-1-ben.horgan@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 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/h= yp-main.c index a7c689152f68..b25a5ddb9cf0 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -635,6 +635,15 @@ static void handle_host_hcall(struct kvm_cpu_context *= host_ctxt) unsigned long hcall_min =3D 0; hcall_t hfn; =20 + if (system_supports_mpam()) { + u64 mask =3D MPAM1_EL1_PARTID_D | MPAM1_EL1_PARTID_I | + MPAM1_EL1_PMG_D | MPAM1_EL1_PMG_I; + u64 val =3D 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 --=20 2.43.0