[lkml]   [2010]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH 31/38] KVM: fix load_guest_segment_descriptor() to return X86EMUL_*
    From: Takuya Yoshikawa <>

    This patch fixes load_guest_segment_descriptor() to return
    X86EMUL_PROPAGATE_FAULT when it tries to access the descriptor
    table beyond the limit of it: suggested by Marcelo.

    I have checked current callers of this helper function,
    - kvm_load_segment_descriptor()
    - kvm_task_switch()
    and confirmed that this patch will change nothing in the
    upper layers if we do not change the handling of this
    return value from load_guest_segment_descriptor().

    Next step: Although fixing the kvm_task_switch() to handle the
    propagated faults properly seems difficult, and maybe not worth
    it because TSS is not used commonly these days, we can fix
    kvm_load_segment_descriptor(). By doing so, the injected #GP
    becomes possible to be handled by the guest. The only problem
    for this is how to differentiate this fault from the page faults
    generated by kvm_read_guest_virt(). We may have to split this
    function to achive this goal.

    Signed-off-by: Takuya Yoshikawa <>
    Signed-off-by: Marcelo Tosatti <>
    arch/x86/kvm/x86.c | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)

    diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
    index 0bf3df5..01f0b03 100644
    --- a/arch/x86/kvm/x86.c
    +++ b/arch/x86/kvm/x86.c
    @@ -4663,7 +4663,7 @@ static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,

    if (dtable.limit < index * 8 + 7) {
    kvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc);
    - return 1;
    return kvm_read_guest_virt(dtable.base + index*8, seg_desc, sizeof(*seg_desc), vcpu);

     \ /
      Last update: 2010-02-16 11:43    [W:0.021 / U:0.980 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site