Re: [PATCH 5/5] KVM: arm64: Disable privileged hypercalls after pKVM finalisation
flat view
From: Marc Zyngier <maz@kernel.org>
Date: 2021-09-23 13:13:17
Also in:
kvmarm
On Thu, 23 Sep 2021 14:02:11 +0100, Will Deacon [off-list ref] wrote:
On Thu, Sep 23, 2021 at 01:56:21PM +0100, Marc Zyngier wrote:quoted
On Thu, 23 Sep 2021 12:22:56 +0100, Will Deacon [off-list ref] wrote:
[...]
quoted
quoted
static void handle_host_hcall(struct kvm_cpu_context *host_ctxt) { DECLARE_REG(unsigned long, id, host_ctxt, 0); + unsigned long hcall_min = 0; hcall_t hfn; + if (static_branch_unlikely(&kvm_protected_mode_initialized)) + hcall_min = __KVM_HOST_SMCCC_FUNC___pkvm_prot_finalize; + id -= KVM_HOST_SMCCC_ID(0); - if (unlikely(id >= ARRAY_SIZE(host_hcall))) + if (unlikely(id < hcall_min || id >= ARRAY_SIZE(host_hcall)))So I can still issue a pkvm_prot_finalize after finalisation? Seems odd. As hcall_min has to be inclusive, you probably want it to be set to __KVM_HOST_SMCCC_FUNC___pkvm_host_share_hyp once protected.Yeah, I ended up addresing that one in the previous patch. The problem is that we need to allow pkvm_prot_finalize to be called on each CPU, so I think we'd end up having an extra "really finalize damnit!" call to be issued _once_ after each CPU is done with the finalisation if we want to lock it down. The approach I took instead is to make pkvm_prot_finalize return -EBUSY if it's called on a CPU where it's already been called.
Ah, I see. Serves me right for reading patches out of order. Finalise is of course per-CPU, and the static key global. Epic fail. Probably deserves a comment, because I'm surely going to jump at that again in three months. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel