All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: kvm_is_visible_gfn can be boolean
@ 2015-11-14  3:21 Yaowei Bai
  2015-11-14  3:21 ` [PATCH 2/2] KVM: kvm_para_has_feature " Yaowei Bai
  2015-11-14 10:07 ` [PATCH 1/2] KVM: kvm_is_visible_gfn " Amos Jianjun Kong
  0 siblings, 2 replies; 4+ messages in thread
From: Yaowei Bai @ 2015-11-14  3:21 UTC (permalink / raw)
  To: gleb, pbonzini; +Cc: kvm, linux-kernel

This patch makes kvm_is_visible_gfn return bool due to this particular
function only using either one or zero as its return value.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
---
 include/linux/kvm_host.h | 2 +-
 virt/kvm/kvm_main.c      | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 5706a21..4436539 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -623,7 +623,7 @@ int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
 int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
 struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
-int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
+bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
 unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn);
 void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
 
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 484079e..73cbb41 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1164,15 +1164,15 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_memslot(struct kvm_vcpu *vcpu, gfn_t gfn
 	return __gfn_to_memslot(kvm_vcpu_memslots(vcpu), gfn);
 }
 
-int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
+bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
 {
 	struct kvm_memory_slot *memslot = gfn_to_memslot(kvm, gfn);
 
 	if (!memslot || memslot->id >= KVM_USER_MEM_SLOTS ||
 	      memslot->flags & KVM_MEMSLOT_INVALID)
-		return 0;
+		return false;
 
-	return 1;
+	return true;
 }
 EXPORT_SYMBOL_GPL(kvm_is_visible_gfn);
 
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] KVM: kvm_para_has_feature can be boolean
  2015-11-14  3:21 [PATCH 1/2] KVM: kvm_is_visible_gfn can be boolean Yaowei Bai
@ 2015-11-14  3:21 ` Yaowei Bai
  2015-11-14 10:07 ` [PATCH 1/2] KVM: kvm_is_visible_gfn " Amos Jianjun Kong
  1 sibling, 0 replies; 4+ messages in thread
From: Yaowei Bai @ 2015-11-14  3:21 UTC (permalink / raw)
  To: gleb, pbonzini; +Cc: kvm, linux-kernel

This patch makes kvm_para_has_feature return bool due to this
particular function only using either one or zero as its return
value.

No functional change.

Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
---
 include/linux/kvm_para.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
index 00a97bb..35e568f 100644
--- a/include/linux/kvm_para.h
+++ b/include/linux/kvm_para.h
@@ -4,10 +4,8 @@
 #include <uapi/linux/kvm_para.h>
 
 
-static inline int kvm_para_has_feature(unsigned int feature)
+static inline bool kvm_para_has_feature(unsigned int feature)
 {
-	if (kvm_arch_para_features() & (1UL << feature))
-		return 1;
-	return 0;
+	return !!(kvm_arch_para_features() & (1UL << feature));
 }
 #endif /* __LINUX_KVM_PARA_H */
-- 
1.9.1




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] KVM: kvm_is_visible_gfn can be boolean
  2015-11-14  3:21 [PATCH 1/2] KVM: kvm_is_visible_gfn can be boolean Yaowei Bai
  2015-11-14  3:21 ` [PATCH 2/2] KVM: kvm_para_has_feature " Yaowei Bai
@ 2015-11-14 10:07 ` Amos Jianjun Kong
  2015-11-16  2:37   ` Yaowei Bai
  1 sibling, 1 reply; 4+ messages in thread
From: Amos Jianjun Kong @ 2015-11-14 10:07 UTC (permalink / raw)
  To: Yaowei Bai; +Cc: gleb, Paolo Bonzini, kvm, open list, Alexander Graf

On Sat, Nov 14, 2015 at 11:21 AM, Yaowei Bai
<baiyaowei@cmss.chinamobile.com> wrote:
> This patch makes kvm_is_visible_gfn return bool due to this particular
> function only using either one or zero as its return value.
>
> No functional change.
>
> Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>

Hi Yaowei,

> ---
>  include/linux/kvm_host.h | 2 +-
>  virt/kvm/kvm_main.c      | 6 +++---
>  2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 5706a21..4436539 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -623,7 +623,7 @@ int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
>  int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
>  int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
>  struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
> -int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
> +bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
>  unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn);
>  void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 484079e..73cbb41 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -1164,15 +1164,15 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_memslot(struct kvm_vcpu *vcpu, gfn_t gfn
>         return __gfn_to_memslot(kvm_vcpu_memslots(vcpu), gfn);
>  }
>
> -int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
> +bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
>  {
>         struct kvm_memory_slot *memslot = gfn_to_memslot(kvm, gfn);
>
>         if (!memslot || memslot->id >= KVM_USER_MEM_SLOTS ||
>               memslot->flags & KVM_MEMSLOT_INVALID)
> -               return 0;
> +               return false;
>
> -       return 1;
> +       return true;
>  }
>  EXPORT_SYMBOL_GPL(kvm_is_visible_gfn);


kvm_is_visible_gfn() is also used in arch/powerpc/kvm/book3s_pr.c:

static int kvmppc_visible_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
{
......
        if (unlikely(mp_pa) && unlikely((mp_pa & KVM_PAM) == (gpa & KVM_PAM))) {
                return 1;
        }

        return kvm_is_visible_gfn(vcpu->kvm, gpa >> PAGE_SHIFT);
}

Do we still need to update that function?

Thanks, Amos

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] KVM: kvm_is_visible_gfn can be boolean
  2015-11-14 10:07 ` [PATCH 1/2] KVM: kvm_is_visible_gfn " Amos Jianjun Kong
@ 2015-11-16  2:37   ` Yaowei Bai
  0 siblings, 0 replies; 4+ messages in thread
From: Yaowei Bai @ 2015-11-16  2:37 UTC (permalink / raw)
  To: Amos Jianjun Kong; +Cc: gleb, Paolo Bonzini, kvm, open list, Alexander Graf

On Sat, Nov 14, 2015 at 06:07:51PM +0800, Amos Jianjun Kong wrote:
> On Sat, Nov 14, 2015 at 11:21 AM, Yaowei Bai
> <baiyaowei@cmss.chinamobile.com> wrote:
> > This patch makes kvm_is_visible_gfn return bool due to this particular
> > function only using either one or zero as its return value.
> >
> > No functional change.
> >
> > Signed-off-by: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
> 
> Hi Yaowei,

Hi,

> 
> > ---
> >  include/linux/kvm_host.h | 2 +-
> >  virt/kvm/kvm_main.c      | 6 +++---
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> > index 5706a21..4436539 100644
> > --- a/include/linux/kvm_host.h
> > +++ b/include/linux/kvm_host.h
> > @@ -623,7 +623,7 @@ int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
> >  int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
> >  int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
> >  struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
> > -int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
> > +bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
> >  unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn);
> >  void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
> >
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > index 484079e..73cbb41 100644
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -1164,15 +1164,15 @@ struct kvm_memory_slot *kvm_vcpu_gfn_to_memslot(struct kvm_vcpu *vcpu, gfn_t gfn
> >         return __gfn_to_memslot(kvm_vcpu_memslots(vcpu), gfn);
> >  }
> >
> > -int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
> > +bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn)
> >  {
> >         struct kvm_memory_slot *memslot = gfn_to_memslot(kvm, gfn);
> >
> >         if (!memslot || memslot->id >= KVM_USER_MEM_SLOTS ||
> >               memslot->flags & KVM_MEMSLOT_INVALID)
> > -               return 0;
> > +               return false;
> >
> > -       return 1;
> > +       return true;
> >  }
> >  EXPORT_SYMBOL_GPL(kvm_is_visible_gfn);
> 
> 
> kvm_is_visible_gfn() is also used in arch/powerpc/kvm/book3s_pr.c:
> 
> static int kvmppc_visible_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
> {
> ......
>         if (unlikely(mp_pa) && unlikely((mp_pa & KVM_PAM) == (gpa & KVM_PAM))) {
>                 return 1;
>         }
> 
>         return kvm_is_visible_gfn(vcpu->kvm, gpa >> PAGE_SHIFT);
> }
> 
> Do we still need to update that function?

OK, i'll send another patch to update it, thanks.

> 
> Thanks, Amos



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-16  2:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-14  3:21 [PATCH 1/2] KVM: kvm_is_visible_gfn can be boolean Yaowei Bai
2015-11-14  3:21 ` [PATCH 2/2] KVM: kvm_para_has_feature " Yaowei Bai
2015-11-14 10:07 ` [PATCH 1/2] KVM: kvm_is_visible_gfn " Amos Jianjun Kong
2015-11-16  2:37   ` Yaowei Bai

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.