All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
To: Avi Kivity <avi@redhat.com>
Cc: mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH v2 1/8] KVM: Fix load_guest_segment_descriptor() to inject page fault
Date: Fri, 12 Feb 2010 09:13:50 +0900	[thread overview]
Message-ID: <4B749D3E.8080207@oss.ntt.co.jp> (raw)
In-Reply-To: <4B72DE06.3020909@redhat.com>

Sorry for being late to reply.
   Japan was a holiday yesterday.

Avi Kivity wrote:
> On 02/10/2010 03:50 AM, Takuya Yoshikawa wrote:
>> This patch injects page fault when reading descriptor in
>> load_guest_segment_descriptor() fails with FAULT.
>>
>> Effects of this injection: This function is used by
>> kvm_load_segment_descriptor() which is necessary for the
>> following instructions.
>>   - mov seg,r/m16
>>   - jmp far
>>   - pop ?s
>> This patch makes it possible to emulate the page faults
>> generated by these instructions. But be sure that unless
>> we change the kvm_load_segment_descriptor()'s ret value
>> propagation this patch has no effect.
>>
>>
>> @@ -4655,6 +4655,7 @@ static int load_guest_segment_descriptor(struct 
>> kvm_vcpu *vcpu, u16 selector,
>>   {
>>       struct descriptor_table dtable;
>>       u16 index = selector>>  3;
>> +    int ret;
>>
>>       get_segment_descriptor_dtable(vcpu, selector,&dtable);
>>
>> @@ -4662,7 +4663,11 @@ static int load_guest_segment_descriptor(struct 
>> kvm_vcpu *vcpu, u16 selector,
>>           kvm_queue_exception_e(vcpu, GP_VECTOR, selector&  0xfffc);
>>           return X86EMUL_PROPAGATE_FAULT;
>>       }
>> -    return kvm_read_guest_virt(dtable.base + index*8, seg_desc, 
>> sizeof(*seg_desc), vcpu);
>> +    ret = kvm_read_guest_virt(dtable.base + index*8, seg_desc, 
>> sizeof(*seg_desc), vcpu);
>> +    if (ret == X86EMUL_PROPAGATE_FAULT)
>> +        kvm_inject_page_fault(vcpu, dtable.base + index*8, 0);
>> +
>> +    return ret;
>>   }
>>    
> 
> If the descriptor table is not aligned, and a descriptor spans two 
> pages, then we might need to inject a page fault at some other address.
> 
> Also, the injection should be done in kvm_read_guest_virt() to avoid 
> duplicating code.
> 
> These instructions however are only emulated in big real mode.  Where 
> did you encounter the need to inject page faults during their emulation?
> 


I did not notice about that, we need not inject page faults for them.
But as Marcelo says in the next mail ...

  parent reply	other threads:[~2010-02-12  0:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-10  1:45 [PATCH v2 0/8] Fix x86 emulator's fault propagations Takuya Yoshikawa
2010-02-10  1:50 ` [PATCH v2 1/8] KVM: Fix load_guest_segment_descriptor() to inject page fault Takuya Yoshikawa
2010-02-10 16:25   ` Avi Kivity
2010-02-10 16:29     ` Marcelo Tosatti
2010-02-12  0:22       ` Takuya Yoshikawa
2010-02-10 16:43     ` Gleb Natapov
2010-02-12  0:19       ` Takuya Yoshikawa
2010-02-12  0:13     ` Takuya Yoshikawa [this message]
2010-02-10  1:53 ` [PATCH v2 2/8] Fix kvm_load_segment_descriptor()'s fault propagation Takuya Yoshikawa
2010-02-10  1:56 ` [PATCH v2 3/8] Fix x86_emulate_insn() to handle faults propagated from kvm_load_segment_descriptor() Takuya Yoshikawa
2010-02-10  2:01 ` [PATCH v2 4/8] X86EMUL macro replacements: from do_fetch_insn_byte() to x86_decode_insn() Takuya Yoshikawa
2010-02-10  2:04 ` [PATCH v2 5/8] X86EMUL macro replacements: x86_emulate_insn() and its helpers Takuya Yoshikawa
2010-02-10  2:07 ` [PATCH v2 6/8] Fix x86_emulate_insn() not to use rc variable for non-X86EMUL values Takuya Yoshikawa
2010-02-10  2:13 ` [PATCH v2 7/8] Fix emulate_sys[call, enter, exit]()'s fault handling Takuya Yoshikawa
2010-02-10  2:16 ` [PATCH v2 8/8] Tiny fix: remove redundant prototype of of load_pdptrs() Takuya Yoshikawa
2010-02-10 15:27 ` [PATCH v2 0/8] Fix x86 emulator's fault propagations Gleb Natapov
2010-02-12  0:42   ` Takuya Yoshikawa
2010-02-10 16:57 ` Avi Kivity
2010-02-10 16:58   ` Gleb Natapov
2010-02-12  0:44     ` Takuya Yoshikawa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B749D3E.8080207@oss.ntt.co.jp \
    --to=yoshikawa.takuya@oss.ntt.co.jp \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.