Re: [PATCH v7 6/9] vmx: spp: Set up SPP paging table at vmentry/vmexit

From: Paolo Bonzini
Date: Thu Nov 21 2019 - 05:18:58 EST


On 19/11/19 09:49, Yang Weijiang wrote:
> + if (spte & PT_SPP_MASK) {
> + fault_handled = true;
> + vcpu->run->exit_reason = KVM_EXIT_SPP;
> + vcpu->run->spp.addr = gva;
> + kvm_skip_emulated_instruction(vcpu);

Do you really want to skip the current instruction? Who will do the write?

> + pr_info("SPP - SPPT entry missing! gfn = 0x%llx\n", gfn);

Please replace pr_info with a tracepoint.

> + slot = gfn_to_memslot(vcpu->kvm, gfn);
> + if (!slot)
> + return -EFAULT;

You want either a goto to the misconfig case, so that there is a warn

> + spp_info.base_gfn = gfn;
> + spp_info.npages = 1;
> +
> + spin_lock(&vcpu->kvm->mmu_lock);
> + ret = kvm_spp_get_permission(vcpu->kvm, &spp_info);
> + if (ret == 1) {

Can you clarify when ret will not be 1? In this case you already have a
slot, so it seems to me that you do not need to go through
kvm_spp_get_permission and you can just test "if
(kvm->arch.spp_active)". But then, spp_active should be 1 if you get
here, I think?

> + pr_alert("SPP - SPPT Misconfiguration!\n");
> + return 0;


pr_alert not needed since you've just warned.

Paolo