All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Tiejun Chen <tiejun.chen@intel.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH] kvm: x86: vmx: remove MMIO_GEN_MASK
Date: Tue, 18 Nov 2014 11:15:09 +0100	[thread overview]
Message-ID: <546B1C2D.3030001@redhat.com> (raw)
In-Reply-To: <1416302078-6324-1-git-send-email-tiejun.chen@intel.com>



On 18/11/2014 10:14, Tiejun Chen wrote:
> Actually MMIO_MAX_GEN is same as MMIO_GEN_MASK, and
> especially in all cases we already AND this so its
> also unnecessary to generate such a WARN_ON().
> 
> Signed-off-by: Tiejun Chen <tiejun.chen@intel.com>

Good idea, but I actually prefer keeping MMIO_GEN_MASK since it is often
used together with an "&".

Then, the WARN_ON is better written as

-	WARN_ON(gen > MMIO_MAX_GEN);
+	WARN_ON(gen & ~MMIO_GEN_MASK);

Paolo

> ---
>  arch/x86/kvm/mmu.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index ac1c4de..7712345 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -213,15 +213,12 @@ EXPORT_SYMBOL_GPL(kvm_mmu_set_mmio_spte_mask);
>  #define MMIO_GEN_SHIFT			20
>  #define MMIO_GEN_LOW_SHIFT		10
>  #define MMIO_GEN_LOW_MASK		((1 << MMIO_GEN_LOW_SHIFT) - 2)
> -#define MMIO_GEN_MASK			((1 << MMIO_GEN_SHIFT) - 1)
>  #define MMIO_MAX_GEN			((1 << MMIO_GEN_SHIFT) - 1)
>  
>  static u64 generation_mmio_spte_mask(unsigned int gen)
>  {
>  	u64 mask;
>  
> -	WARN_ON(gen > MMIO_MAX_GEN);
> -
>  	mask = (gen & MMIO_GEN_LOW_MASK) << MMIO_SPTE_GEN_LOW_SHIFT;
>  	mask |= ((u64)gen >> MMIO_GEN_LOW_SHIFT) << MMIO_SPTE_GEN_HIGH_SHIFT;
>  	return mask;
> @@ -240,7 +237,7 @@ static unsigned int get_mmio_spte_generation(u64 spte)
>  
>  static unsigned int kvm_current_mmio_generation(struct kvm *kvm)
>  {
> -	return kvm_memslots(kvm)->generation & MMIO_GEN_MASK;
> +	return kvm_memslots(kvm)->generation & MMIO_MAX_GEN;
>  }
>  
>  static void mark_mmio_spte(struct kvm *kvm, u64 *sptep, u64 gfn,
> 

      reply	other threads:[~2014-11-18 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-18  9:14 [PATCH] kvm: x86: vmx: remove MMIO_GEN_MASK Tiejun Chen
2014-11-18 10:15 ` Paolo Bonzini [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=546B1C2D.3030001@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=tiejun.chen@intel.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 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.