From patchwork Tue Aug 13 10:05:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13761698 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 6832E1940AB; Tue, 13 Aug 2024 10:06:21 +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=1723543581; cv=none; b=Bt1RsCrdRzazT+XhOV4WjPsmVmiHxHFchvLPvzUlTfE6QzP2CvEN1Vx0nnHBBCHHi2d6+dNkdeYsDXpDppIAwTbkKARVAo8PR+5RQgAdgGT4ItIXEbADAWBehBARH1FTSukDMrxCLzyCUFgnl+Vg8CAi7ooJ7n3wckpzhPkOKmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723543581; c=relaxed/simple; bh=AfD3pkKeWkAMQNzJlwdw56rA+nl7NWbqVY/PrOBr0/8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SBKeVFOb3tkd4ps5EY7BJ7cxlm//w/+P8a6tUFWKLKIDSBNpTH8NVCsIwRRoFUyG/Gghcp0yi6hkBQqAkeQ+nSB3xD7o8UftZks7ZLuFjJjnjDC4MgTS+t10khs3Xsh9iEGH+PB5pmhJogXyyrokWVIUHbtDbz1IwVPXDxUCafs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S/Hi5ZNC; 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="S/Hi5ZNC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E70CDC4AF09; Tue, 13 Aug 2024 10:06:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723543580; bh=AfD3pkKeWkAMQNzJlwdw56rA+nl7NWbqVY/PrOBr0/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S/Hi5ZNC78ltWMqK0mAd5O7HNDtZZBwrjd1jvjh8237CL3RI65HcB7Gz6vN9WTso7 0iZZabJNBIUJ4qip/2xrJfsJ1LQUVN8TMxCU90L3efm7DZANppgHjGFLtCsqmEGExk yIsh0XBw92zGGFqVyb/eIOQGp4WjHYOPeeym3rOZyNZWZWoCLCIwagLIarQEtLrVeJ yPpSOPxTHvCyWBpVVOxoZJb0dzT9A2eU3A5QuKDVlF5DMkwJT962KB8Dp0cqN0v31k W93rMUdw8o9/N4YHFt+Dr3l7RYxHViFxloK4QxBQ2kmIdnLojRymGVHraVhbROVGgT Iekbgqt8usv6g== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sdoPy-003INM-Vi; Tue, 13 Aug 2024 11:06:19 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Joey Gouly , Alexandru Elisei , Anshuman Khandual , Przemyslaw Gaj Subject: [PATCH v3 03/18] arm64: Add system register encoding for PSTATE.PAN Date: Tue, 13 Aug 2024 11:05:25 +0100 Message-Id: <20240813100540.1955263-4-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240813100540.1955263-1-maz@kernel.org> References: <20240813100540.1955263-1-maz@kernel.org> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, joey.gouly@arm.com, alexandru.elisei@arm.com, anshuman.khandual@arm.com, pgaj@cadence.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Although we already have the primitives to set PSTATE.PAN with an immediate, we don't have a way to read the current state nor set it ot an arbitrary value (i.e. we can generally save/restore it). Thankfully, all that is missing for this is the definition for the PAN pseudo system register, here named SYS_PSTATE_PAN. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/sysreg.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index d9d5e07f768d..a2787091d5a0 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -109,6 +109,9 @@ #define set_pstate_ssbs(x) asm volatile(SET_PSTATE_SSBS(x)) #define set_pstate_dit(x) asm volatile(SET_PSTATE_DIT(x)) +/* Register-based PAN access, for save/restore purposes */ +#define SYS_PSTATE_PAN sys_reg(3, 0, 4, 2, 3) + #define __SYS_BARRIER_INSN(CRm, op2, Rt) \ __emit_inst(0xd5000000 | sys_insn(0, 3, 3, (CRm), (op2)) | ((Rt) & 0x1f))