lkml.org 
[lkml]   [2019]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC PATCH 05/13] kvm: Add #PF injection for KVM XO
From
Date
On 03/10/19 23:23, Rick Edgecombe wrote:
> + if (!vcpu->arch.gva_available)
> + return 0;

Please return RET_PF_* constants, RET_PF_EMULATE here.

> + if (error_code & PFERR_WRITE_MASK)
> + fault_error_code |= X86_PF_WRITE;
> +
> + fault.vector = PF_VECTOR;
> + fault.error_code_valid = true;
> + fault.error_code = fault_error_code;
> + fault.nested_page_fault = false;
> + fault.address = vcpu->arch.gva_val;
> + fault.async_page_fault = true;

Not an async page fault.

> + kvm_inject_page_fault(vcpu, &fault);
> +
> + return 1;

Here you would return RET_PF_RETRY - you've injected the page fault and
all that's left to do is reenter execution of the vCPU.

[...]

> + if (unlikely(vcpu->arch.xo_fault)) {
> + /*
> + * If not enough information to inject the fault,
> + * emulate to figure it out and emulate the PF.
> + */
> + if (!try_inject_exec_only_pf(vcpu, error_code))
> + return RET_PF_EMULATE;
> +
> + return 1;
> + }

Returning 1 is wrong, it's also RET_PF_EMULATE. If you change
try_inject_exec_only_pf return values to RET_PF_*, you can simply return
the value of try_inject_exec_only_pf(vcpu, error_code).

That said, I wonder if it's better to just handle this in
handle_ept_violation. Basically, if bits 5:3 of the exit qualification
are 100 you can bypass the whole mmu.c page fault handling and just
inject an exec-only page fault.

Thanks,

Paolo

\
 
 \ /
  Last update: 2019-10-04 09:44    [W:0.157 / U:36.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site