Avi Kivity wrote:
> Nakajima, Jun wrote:
>> The key is the virtual MMU; getting bootstrap/IPI working is
>> straightforward.
> 
> I'm glad to hear you say that.
> 
> 
>> Without NPT or EPT, we need to have an SMP-capable
>> shadow pagetable code. I think one of the most efficient ways is to
>> re-use the code from Xen. The current one is the third generation of
>> the shadow page table, and it works well.
>> 
> 
> I'm fairly certain a rip-it-the-old-and-plug-in-the-new approach would
> be rejected.  Linux development requires incremental patches.

I assumed that the current virutal MMU code was not designed to support
SMP (when you said "there's no need to worry about the mmu"). After
reviewing the code, I think the current code is good enough, especially
in the sense that it emulates writes to guest page tables. Actually the
code at least the emulator is from Xen ;-)

This particular code keeps the shadow page table in sync with the guest
right away, avoiding major incosistencies in the SMP environment.

                spin_lock(&vcpu->kvm->lock);
                r = kvm_mmu_page_fault(vcpu, cr2, error_code);
                if (r < 0) {
                        spin_unlock(&vcpu->kvm->lock);
                        return r;
                }
                if (!r) {
                        spin_unlock(&vcpu->kvm->lock);
                        return 1;
                }

                er = emulate_instruction(vcpu, kvm_run, cr2,
error_code);
                spin_unlock(&vcpu->kvm->lock);

> 
> Getting the kvm mmu to do smp involves the following, as far as I can
> tell: 
> 
> - verifying that all the locking in place is correct
> - make sure that spurious faults (due to races) are handled well
> - install shadow ptes atomically instead of building them
> incrementally 
> - replace local tlb flushes by remote tlb flushes (for cpus that have
> touched the domain, and later, for cpus that have touched the
> pagetable) 

The other thing is how do you detect when the guest page tables become
just data (this is not an SMP issue, though)? If you don't unshadow such
pages, we'll tend to get (frequent) unnecessary #PF. 

These are mostly performance optimization issues, but SMP guests will
use local and IO APICs (and other misc timers), and we'll see more
frequent VM exits in such a guest. We may need to move them to the KVM
side if we see performance issues. 

Jun
---
Intel Open Source Technology Center

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Reply via email to