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 E2BB8F4BB6B for ; Tue, 24 Feb 2026 17:59:09 +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-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EoL0eRhhvpbRBRln03sOpMdPRbyV32Kws7V5NUGwFl0=; b=QULiRlw7dZKRpv1Pn4Td3THbqJ 6odoKFNxQzQ1rOz47cI0wBbIRd5DAKvT+H84/pIoMSRHuP+RxP/jTDxokE2Pegak2tFnlbnCxdMsP AZ51le+Ubcm0aLFWfMXY5MD80GdLVOQ2pt7iGZdc4xtXovypxT7BLpkTIANXppW6+hP24bpSei7D1 O9LfTBFEeATE4S6rMOvCZTeSl02O7QtwA2nGVL7r5yF1aQz2VtEx89mAfQSwp7jHZ9X4qytPLVO3r LQu9J7sPbHr6itZXfdYbrKeTH8OQPGJtHpCN9Xv/T9VazmBbhSBJc1Nm2pdkxg3QB+NpSOHXNj11c lDiy98pA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vuwgT-00000002XjN-1XsM; Tue, 24 Feb 2026 17:58:57 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vuwg8-00000002XIn-0sO7 for linux-arm-kernel@lists.infradead.org; Tue, 24 Feb 2026 17:58:48 +0000 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 24664165C; Tue, 24 Feb 2026 09:58:29 -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 862AA3F59E; Tue, 24 Feb 2026 09:58:30 -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 v5 12/41] KVM: arm64: Use kernel-space partid configuration for hypercalls Date: Tue, 24 Feb 2026 17:56:51 +0000 Message-ID: <20260224175720.2663924-13-ben.horgan@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260224175720.2663924-1-ben.horgan@arm.com> References: <20260224175720.2663924-1-ben.horgan@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260224_095836_337853_CC535BB6 X-CRM114-Status: GOOD ( 11.96 ) 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 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 -- 2.43.0