On Tue, Apr 13, 2010 at 10:35:53AM +0300, Avi Kivity wrote:
> On 04/13/2010 10:26 AM, Gleb Natapov wrote:
> >On Tue, Apr 13, 2010 at 10:24:40AM +0300, Avi Kivity wrote:
> >>On 04/13/2010 10:21 AM, Gleb Natapov wrote:
> >>>May be I am missing something here, but it seams we can call
> >>>kvm_mmu_pte_write() directly from emulator_cmpxchg_emulated()
> >>>instead of passing mmu_only down to emulator_write_emulated_onepage()
> >>>and call it there.
> >>>
> >>>
> >>>@@ -3460,7 +3444,9 @@ static int emulator_cmpxchg_emulated(unsigned long
> >>>addr,
> >>> if (!exchanged)
> >>> return X86EMUL_CMPXCHG_FAILED;
> >>>
> >>>- return __emulator_write_emulated(addr, new, bytes, vcpu, true);
> >>>+ kvm_mmu_pte_write(vcpu, gpa, new, bytes, 1);
> >>>+
> >>>+ return X86EMUL_CONTINUE;
> >>>
> >>The written range might cross a page boundary, which
> >>kvm_mmu_pte_write() is not prepared to handle.
> >>
> >Don't we emulate exchange as write in this case?
> >
> > if (((gpa + bytes - 1)& PAGE_MASK) != (gpa& PAGE_MASK))
> > goto emul_write;
>
> We do, but that's unrelated. We still have to invalidate potential
> ptes on both pages
>
The code path executed in case of cmpxchg crossing page boundary is not
touched by the patch as far as I can see. In this case
emulator_write_emulated() is executed with mmu_only false and
kvm_mmu_pte_write() is called from emulator_write_phys().
--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html