From: Miguel Luis <miguel.luis@oracle.com>
To: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
Oliver Upton <oliver.upton@linux.dev>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev
Cc: miguel.luis@oracle.com
Subject: [PATCH v2 2/2] arm64/kvm: Fine grain _EL2 system registers list that affect nested virtualization
Date: Mon, 25 Sep 2023 16:20:57 +0000 [thread overview]
Message-ID: <20230925162057.27548-3-miguel.luis@oracle.com> (raw)
In-Reply-To: <20230925162057.27548-1-miguel.luis@oracle.com>
Some _EL1 registers got included in the _EL2 ranges, which are not
affected by NV. Remove them, fine grain the ranges to exclusively
include the _EL2 ones and fold SPSR/ELR _EL2 registers into the
existing range.
Signed-off-by: Miguel Luis <miguel.luis@oracle.com>
---
arch/arm64/kvm/emulate-nested.c | 44 ++++++++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c
index 9ced1bf0c2b7..f6d0c87803f4 100644
--- a/arch/arm64/kvm/emulate-nested.c
+++ b/arch/arm64/kvm/emulate-nested.c
@@ -649,14 +649,46 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = {
SR_TRAP(SYS_APGAKEYHI_EL1, CGT_HCR_APK),
/* All _EL2 registers */
SR_RANGE_TRAP(sys_reg(3, 4, 0, 0, 0),
- sys_reg(3, 4, 3, 15, 7), CGT_HCR_NV),
+ sys_reg(3, 4, 4, 0, 1), CGT_HCR_NV),
/* Skip the SP_EL1 encoding... */
- SR_TRAP(SYS_SPSR_EL2, CGT_HCR_NV),
- SR_TRAP(SYS_ELR_EL2, CGT_HCR_NV),
- SR_RANGE_TRAP(sys_reg(3, 4, 4, 1, 1),
- sys_reg(3, 4, 10, 15, 7), CGT_HCR_NV),
+ SR_RANGE_TRAP(sys_reg(3, 4, 4, 3, 0),
+ sys_reg(3, 4, 10, 6, 7), CGT_HCR_NV),
+ /*
+ * Note that the spec. describes a group of MEC registers
+ * whose access should not trap, therefore skip the following:
+ * MECID_A0_EL2, MECID_A1_EL2, MECID_P0_EL2,
+ * MECID_P1_EL2, MECIDR_EL2, VMECID_A_EL2,
+ * VMECID_P_EL2.
+ */
SR_RANGE_TRAP(sys_reg(3, 4, 12, 0, 0),
- sys_reg(3, 4, 14, 15, 7), CGT_HCR_NV),
+ sys_reg(3, 4, 12, 1, 1), CGT_HCR_NV),
+ /* ICH_AP0R<m>_EL2 */
+ SR_RANGE_TRAP(SYS_ICH_AP0R0_EL2,
+ SYS_ICH_AP0R3_EL2, CGT_HCR_NV),
+ /* ICH_AP1R<m>_EL2 */
+ SR_RANGE_TRAP(SYS_ICH_AP1R0_EL2,
+ SYS_ICH_AP1R3_EL2, CGT_HCR_NV),
+ SR_RANGE_TRAP(sys_reg(3, 4, 12, 9, 5),
+ sys_reg(3, 4, 12, 11, 7), CGT_HCR_NV),
+ /* ICH_LR<m>_EL2 */
+ SR_RANGE_TRAP(SYS_ICH_LR0_EL2,
+ SYS_ICH_LR7_EL2, CGT_HCR_NV),
+ SR_RANGE_TRAP(SYS_ICH_LR8_EL2,
+ SYS_ICH_LR15_EL2, CGT_HCR_NV),
+ SR_RANGE_TRAP(sys_reg(3, 4, 13, 0, 1),
+ sys_reg(3, 4, 13, 0, 7), CGT_HCR_NV),
+ /* AMEVCNTVOFF0<n>_EL2 */
+ SR_RANGE_TRAP(sys_reg(3, 4, 13, 8, 0),
+ sys_reg(3, 4, 13, 8, 7), CGT_HCR_NV),
+ SR_RANGE_TRAP(sys_reg(3, 4, 13, 9, 0),
+ sys_reg(3, 4, 13, 9, 7), CGT_HCR_NV),
+ /* AMEVCNTVOFF1<n>_EL2 */
+ SR_RANGE_TRAP(sys_reg(3, 4, 13, 10, 0),
+ sys_reg(3, 4, 13, 10, 7), CGT_HCR_NV),
+ SR_RANGE_TRAP(sys_reg(3, 4, 13, 11, 0),
+ sys_reg(3, 4, 13, 11, 7), CGT_HCR_NV),
+ SR_RANGE_TRAP(sys_reg(3, 4, 14, 0, 3),
+ sys_reg(3, 4, 14, 5, 2), CGT_HCR_NV),
/* All _EL02, _EL12 registers */
SR_RANGE_TRAP(sys_reg(3, 5, 0, 0, 0),
sys_reg(3, 5, 10, 15, 7), CGT_HCR_NV),
--
2.39.2
next prev parent reply other threads:[~2023-09-25 16:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 16:20 [PATCH v2 0/2] Fine grain sysregs allowed to trap for nested virtualization Miguel Luis
2023-09-25 16:20 ` [PATCH v2 1/2] arm64: Add missing _EL12 encodings Miguel Luis
2023-09-28 9:39 ` Eric Auger
2023-09-28 9:59 ` Miguel Luis
2023-09-25 16:20 ` Miguel Luis [this message]
2023-09-29 15:08 ` [PATCH v2 2/2] arm64/kvm: Fine grain _EL2 system registers list that affect nested virtualization Eric Auger
2023-10-02 13:36 ` Miguel Luis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230925162057.27548-3-miguel.luis@oracle.com \
--to=miguel.luis@oracle.com \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).