All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: [patch] KVM: paravirtual guest support
Date: Tue, 09 Jan 2007 12:13:56 +0200	[thread overview]
Message-ID: <45A36AE4.6000904@qumranet.com> (raw)
In-Reply-To: <20070109093354.GA10318-X9Un+BFzKDI@public.gmane.org>

Ingo Molnar wrote:
> Subject: [patch] KVM: paravirtual guest support
> From: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
>
> this enables a CONFIG_PARAVIRT Linux guest kernel to establish a 
> hypercall API to a KVM host. If successfully registered, then the Linux 
> guest will optimize a few things like its interrupt controller, io-delay 
> and it also registers its cr3-cache structures with the host. (but the 
> host will not touch those, just yet)
>
> (this is fully backwards compatible - if the WRMSR fails then the Linux
> guest continues to execute as a native kernel.)
>
> Signed-off-by: Ingo Molnar <mingo-X9Un+BFzKDI@public.gmane.org>
> ---
> +			/*
> +			 * Cache-hit: we load the cached host-CR3 value.
> +			 * This never causes any VM exit. (if it does then the
> +			 * hypervisor could do nothing with this instruction
> +			 * and the guest OS would be aborted)
> +			 */
> +			asm volatile("movl %0, %%cr3"
> +				: : "r" (cache->entry[idx].host_cr3));
> +			goto out;
> +		}
> +	}
> +
> +	/*
> +	 * Cache-miss. Load the guest-cr3 value into cr3, which will
> +	 * cause a VM exit to the hypervisor, which then loads the
> +	 * host cr3 value and updates the cr3_cache.
> +	 */
> +	asm volatile("movl %0, %%cr3" : : "r" (guest_cr3));
> +out:
> +	put_cpu_var(para_state);
> +}
> +
>   

There's a problem here.  A cache-hit cr3 is an hpa, while a cache-miss 
cr3 is a gpa.  The two could alias:

/* pseudoassembler */

guest:
  mov $0x1234, %cr3 /* cache miss */

host:
  creates shadow for 0x1234 at 0x5678
  set cr3 cache entry: $0x1234 -> 0x5678

guest:
  mov $0x5678, %cr3 /* cache miss */
  vmx accepts that as a cached cr3 equivalent to the guest's 0x1234, 
whereas a 0x5678 gpa cr3 was intended.

The only solution I see is to use the hypercall API on a cache miss.  
Once the guest indicates it wants to use the cr3 cache, set_cr3() should 
fault, and cr3 should only be accepted from the hypercall.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
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

  parent reply	other threads:[~2007-01-09 10:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-09  9:33 [patch] KVM: paravirtual guest support Ingo Molnar
     [not found] ` <20070109093354.GA10318-X9Un+BFzKDI@public.gmane.org>
2007-01-09  9:41   ` Ingo Molnar
2007-01-09 10:13   ` Avi Kivity [this message]
     [not found]     ` <45A36AE4.6000904-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-01-09 10:46       ` Ingo Molnar

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=45A36AE4.6000904@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=mingo-X9Un+BFzKDI@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 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.