public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
	kvm@vger.kernel.org, Gleb Natapov <gleb@redhat.com>
Subject: Re: [PATCH 7/8] KVM: Optimize kvm_read_cr[04]_bits()
Date: Fri, 05 Feb 2010 09:26:39 +0100	[thread overview]
Message-ID: <4B6BD63F.1000009@web.de> (raw)
In-Reply-To: <1264080712-3981-8-git-send-email-avi@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1864 bytes --]

Avi Kivity wrote:
> 'mask' is always a constant, so we can check whether it includes a bit that
> might be owned by the guest very cheaply, and avoid the decache call.  Saves
> a few hundred bytes of module text.

-no-kvm-irqchip -smp 2 is broken for my Linux guests since this commit.
Their user space applications receive #UD and things fall apart.

Jan

> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/kvm_cache_regs.h |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_regs.h
> index 6b419a3..5a109c6 100644
> --- a/arch/x86/kvm/kvm_cache_regs.h
> +++ b/arch/x86/kvm/kvm_cache_regs.h
> @@ -1,6 +1,9 @@
>  #ifndef ASM_KVM_CACHE_REGS_H
>  #define ASM_KVM_CACHE_REGS_H
>  
> +#define KVM_POSSIBLE_CR0_GUEST_BITS X86_CR0_TS
> +#define KVM_POSSIBLE_CR4_GUEST_BITS X86_CR4_PGE
> +
>  static inline unsigned long kvm_register_read(struct kvm_vcpu *vcpu,
>  					      enum kvm_reg reg)
>  {
> @@ -40,7 +43,8 @@ static inline u64 kvm_pdptr_read(struct kvm_vcpu *vcpu, int index)
>  
>  static inline ulong kvm_read_cr0_bits(struct kvm_vcpu *vcpu, ulong mask)
>  {
> -	if (mask & vcpu->arch.cr0_guest_owned_bits)
> +	ulong tmask = mask & KVM_POSSIBLE_CR0_GUEST_BITS;
> +	if (tmask & vcpu->arch.cr0_guest_owned_bits)
>  		kvm_x86_ops->decache_cr0_guest_bits(vcpu);
>  	return vcpu->arch.cr0 & mask;
>  }
> @@ -52,7 +56,8 @@ static inline ulong kvm_read_cr0(struct kvm_vcpu *vcpu)
>  
>  static inline ulong kvm_read_cr4_bits(struct kvm_vcpu *vcpu, ulong mask)
>  {
> -	if (mask & vcpu->arch.cr4_guest_owned_bits)
> +	ulong tmask = mask & KVM_POSSIBLE_CR4_GUEST_BITS;
> +	if (tmask & vcpu->arch.cr4_guest_owned_bits)
>  		kvm_x86_ops->decache_cr4_guest_bits(vcpu);
>  	return vcpu->arch.cr4 & mask;
>  }



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]

  reply	other threads:[~2010-02-05  8:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-21 13:31 [PATCH 0/8] cr0/cr4/efer/fpu miscellaneous bits Avi Kivity
2010-01-21 13:31 ` [PATCH 1/8] KVM: Allow kvm_load_guest_fpu() even when !vcpu->fpu_active Avi Kivity
2010-01-21 13:31 ` [PATCH 2/8] KVM: Drop kvm_{load,put}_guest_fpu() exports Avi Kivity
2010-01-21 13:31 ` [PATCH 3/8] KVM: Activate fpu on clts Avi Kivity
2010-01-23 18:56   ` Marcelo Tosatti
2010-01-24  7:20     ` Avi Kivity
2010-02-02  8:16   ` Paolo Bonzini
2010-02-03 10:23     ` Gleb Natapov
2010-02-04 13:05     ` Avi Kivity
2010-02-04 13:11       ` Gleb Natapov
2010-02-04 17:56         ` Avi Kivity
2010-02-07 12:25           ` Avi Kivity
2010-01-21 13:31 ` [PATCH 4/8] KVM: Add a helper for checking if the guest is in protected mode Avi Kivity
2010-01-21 13:31 ` [PATCH 5/8] KVM: Move cr0/cr4/efer related helpers to x86.h Avi Kivity
2010-01-21 13:31 ` [PATCH 6/8] KVM: Rename vcpu->shadow_efer to efer Avi Kivity
2010-01-21 13:31 ` [PATCH 7/8] KVM: Optimize kvm_read_cr[04]_bits() Avi Kivity
2010-02-05  8:26   ` Jan Kiszka [this message]
2010-02-07 12:05     ` Avi Kivity
2010-02-07 12:33       ` Jan Kiszka
2010-02-07 12:37         ` Avi Kivity
2010-02-07 13:20           ` Jan Kiszka
2010-01-21 13:31 ` [PATCH 8/8] KVM: trace guest fpu loads and unloads Avi Kivity
2010-01-23 19:02 ` [PATCH 0/8] cr0/cr4/efer/fpu miscellaneous bits Marcelo Tosatti

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=4B6BD63F.1000009@web.de \
    --to=jan.kiszka@web.de \
    --cc=avi@redhat.com \
    --cc=gleb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox