public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/3] Implement emulator_write_phys()
Date: Mon, 27 Aug 2007 20:47:17 +0300	[thread overview]
Message-ID: <46D30E25.1090607@qumranet.com> (raw)
In-Reply-To: <1188236391.6364.14.camel@squirrel>

Anthony Liguori wrote:
> On Mon, 2007-08-27 at 20:26 +0300, Avi Kivity wrote:
>   
>> Anthony Liguori wrote:
>>     
>>> On Mon, 2007-08-27 at 18:45 +0300, Avi Kivity wrote:
>>>   
>>>       
>>>> Anthony Liguori wrote:
>>>>     
>>>>         
>>>>> Since a hypercall may span two pages and is a gva, we need a function to write
>>>>> to a gva that may span multiple pages.  emulator_write_phys() seems like the
>>>>> logical choice for this.
>>>>>
>>>>> @@ -962,8 +962,35 @@ static int emulator_write_std(unsigned long addr,
>>>>>  			      unsigned int bytes,
>>>>>  			      struct kvm_vcpu *vcpu
>>>>>       
>>>>>           
>>>> I think that emulator_write_emulated(), except for being awkwardly 
>>>> named, should do the job.  We have enough APIs.
>>>>
>>>> But!  We may not overwrite the hypercall instruction while a vcpu may be 
>>>> executing, since there's no atomicity guarantee for code fetch.  We have 
>>>> to to be out of guest mode while writing that insn.
>>>>     
>>>>         
>>> Hrm, good catch.
>>>
>>> How can we get out of guest mode given SMP guest support?
>>>
>>>   
>>>       
>> kvm_flush_remote_tlbs() is something that can be generalized.  
>> Basically, you set a bit in each vcpu and send an IPI to take them out.
>>
>> But that's deadlock prone and complex.  Maybe you can just take 
>> kvm->lock, zap the mmu and the flush tlbs, and patch the instruction at 
>> your leisure, as no vcpu will be able to map memory until the lock is 
>> released.
>>     
>
> This works for shadow paging but not necessarily with NPT.  

NPT will have tlb and 2nd level pagetable flushing (to support memory 
unplug, ballooning, guest swapping, and the like) so it's safe to assume 
that it will continue to work.


> Do code
> fetches really not respect atomic writes?  We could switch to a 32-bit
> atomic operation and that should result in no worse than the code being
> patched twice.
>   

I think they don't respect it (the data cache and insn cache and fetch 
pipeline are very separated for performance reasons, so it's not 
unexpected).

I think the Intel manual has some guidelines on self-modifying code.

-- 
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

      parent reply	other threads:[~2007-08-27 17:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-27 15:16 [PATCH 0/3] KVM paravirtualization framework Anthony Liguori
2007-08-27 15:16 ` [PATCH 1/3] Implement emulator_write_phys() Anthony Liguori
2007-08-27 15:16   ` [PATCH 2/3] Refactor hypercall infrastructure Anthony Liguori
2007-08-27 15:16     ` [PATCH 3/3] KVM paravirt-ops implementation Anthony Liguori
     [not found]     ` <11882278082826-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-08-27 16:06       ` [PATCH 2/3] Refactor hypercall infrastructure Avi Kivity
     [not found]         ` <46D2F680.9060100-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-27 17:29           ` Anthony Liguori
2007-08-27 15:45   ` [PATCH 1/3] Implement emulator_write_phys() Avi Kivity
2007-08-27 17:23     ` Anthony Liguori
2007-08-27 17:26       ` Avi Kivity
     [not found]         ` <1188236391.6364.14.camel@squirrel>
2007-08-27 17:47           ` Avi Kivity [this message]

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=46D30E25.1090607@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox