kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Fuad Tabba <tabba@google.com>
To: kvmarm@lists.cs.columbia.edu
Cc: kernel-team@android.com, kvm@vger.kernel.org, maz@kernel.org,
	pbonzini@redhat.com, will@kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 7/8] KVM: arm64: Trap access to pVM restricted features
Date: Fri, 27 Aug 2021 11:16:08 +0100	[thread overview]
Message-ID: <20210827101609.2808181-8-tabba@google.com> (raw)
In-Reply-To: <20210827101609.2808181-1-tabba@google.com>

Trap accesses to restricted features for VMs running in protected
mode.

Access to feature registers are emulated, and only supported
features are exposed to protected VMs.

Accesses to restricted registers as well as restricted
instructions are trapped, and an undefined exception is injected
into the protected guests, i.e., with EC = 0x0 (unknown reason).
This EC is the one used, according to the Arm Architecture
Reference Manual, for unallocated or undefined system registers
or instructions.

Only affects the functionality of protected VMs. Otherwise,
should not affect non-protected VMs when KVM is running in
protected mode.

Signed-off-by: Fuad Tabba <tabba@google.com>
---
 arch/arm64/kvm/hyp/nvhe/switch.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c
index 41f05bf88f61..fe0c3833ec66 100644
--- a/arch/arm64/kvm/hyp/nvhe/switch.c
+++ b/arch/arm64/kvm/hyp/nvhe/switch.c
@@ -171,8 +171,23 @@ static const exit_handler_fn hyp_exit_handlers[] = {
 	[ESR_ELx_EC_PAC]		= kvm_hyp_handle_ptrauth,
 };
 
+static const exit_handler_fn pvm_exit_handlers[] = {
+	[0 ... ESR_ELx_EC_MAX]		= NULL,
+	[ESR_ELx_EC_CP15_32]		= kvm_hyp_handle_cp15,
+	[ESR_ELx_EC_CP15_64]		= kvm_hyp_handle_cp15,
+	[ESR_ELx_EC_SYS64]		= kvm_handle_pvm_sys64,
+	[ESR_ELx_EC_SVE]		= kvm_handle_pvm_restricted,
+	[ESR_ELx_EC_FP_ASIMD]		= kvm_handle_pvm_fpsimd,
+	[ESR_ELx_EC_IABT_LOW]		= kvm_hyp_handle_iabt_low,
+	[ESR_ELx_EC_DABT_LOW]		= kvm_hyp_handle_dabt_low,
+	[ESR_ELx_EC_PAC]		= kvm_hyp_handle_ptrauth,
+};
+
 const exit_handler_fn *kvm_get_exit_handler_array(struct kvm *kvm)
 {
+	if (unlikely(kvm_vm_is_protected(kvm)))
+		return pvm_exit_handlers;
+
 	return hyp_exit_handlers;
 }
 
-- 
2.33.0.259.gc128427fd7-goog

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  parent reply	other threads:[~2021-08-27 10:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 10:16 [PATCH v5 0/8] KVM: arm64: Fixed features for protected VMs Fuad Tabba
2021-08-27 10:16 ` [PATCH v5 1/8] KVM: arm64: Pass struct kvm to per-EC handlers Fuad Tabba
2021-09-08 12:33   ` Andrew Jones
2021-09-20 13:15   ` Marc Zyngier
2021-09-20 14:08     ` Fuad Tabba
2021-08-27 10:16 ` [PATCH v5 2/8] KVM: arm64: Add missing field descriptor for MDCR_EL2 Fuad Tabba
2021-09-08 12:38   ` Andrew Jones
2021-09-22  9:34     ` Fuad Tabba
2021-08-27 10:16 ` [PATCH v5 3/8] KVM: arm64: Simplify masking out MTE in feature id reg Fuad Tabba
2021-09-08 12:38   ` Andrew Jones
2021-08-27 10:16 ` [PATCH v5 4/8] KVM: arm64: Add trap handlers for protected VMs Fuad Tabba
2021-09-08 12:20   ` Andrew Jones
2021-09-22  9:46     ` Fuad Tabba
2021-08-27 10:16 ` [PATCH v5 5/8] KVM: arm64: Initialize trap registers " Fuad Tabba
2021-08-27 10:16 ` [PATCH v5 6/8] KVM: arm64: Move sanitized copies of CPU features Fuad Tabba
2021-08-27 10:16 ` Fuad Tabba [this message]
2021-08-27 10:16 ` [PATCH v5 8/8] KVM: arm64: Handle protected guests at 32 bits Fuad Tabba

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=20210827101609.2808181-8-tabba@google.com \
    --to=tabba@google.com \
    --cc=kernel-team@android.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=will@kernel.org \
    /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).