Re: [PATCH v4 06/11] KVM: VMX: Frame in ENCLS handler for SGX virtualization

Sean Christopherson
2021-04-07T22:17:07Z

On Thu, Apr 08, 2021, Kai Huang wrote:
> +int handle_encls(struct kvm_vcpu *vcpu)
> +{
> + u32 leaf = (u32)vcpu->arch.regs[VCPU_REGS_RAX];

Please use kvm_rax_read(), I've been trying to discourage direct access to the
array. Which is ironic because I'm 100% certain I'm to blame for this. :-)

> +
> + if (!encls_leaf_enabled_in_guest(vcpu, leaf)) {
> + kvm_queue_exception(vcpu, UD_VECTOR);
> + } else if (!sgx_enabled_in_guest_bios(vcpu)) {
> + kvm_inject_gp(vcpu, 0);
> + } else {
> + WARN(1, "KVM: unexpected exit on ENCLS[%u]", leaf);
> + vcpu->run->exit_reason = KVM_EXIT_UNKNOWN;
> + vcpu->run->hw.hardware_exit_reason = EXIT_REASON_ENCLS;
> + return 0;
> + }
> + return 1;
> +}