diff mbox

[v3,2/3] KVM: add converters between pfn_t and kvm_pfn_t

Message ID 20171103011620.21380-3-haozhong.zhang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Haozhong Zhang Nov. 3, 2017, 1:16 a.m. UTC
Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
---
 include/linux/kvm_host.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Dan Williams Nov. 3, 2017, 2:25 a.m. UTC | #1
On Thu, Nov 2, 2017 at 6:16 PM, Haozhong Zhang <haozhong.zhang@intel.com> wrote:
> Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
> ---
>  include/linux/kvm_host.h | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index 6882538eda32..759fe498c89e 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -67,6 +67,9 @@
>  #define KVM_PFN_ERR_HWPOISON   (KVM_PFN_ERR_MASK + 1)
>  #define KVM_PFN_ERR_RO_FAULT   (KVM_PFN_ERR_MASK + 2)
>
> +#define kvm_pfn_to_pfn(x) ((pfn_t){ .val = (x)})
> +#define pfn_to_kvm_pfn(x) ((kvm_pfn_t)((x).val))

Shouldn't this mask off the kvm_pfn_t and  pfn_t specific bits when
converting between the two?
Haozhong Zhang Nov. 3, 2017, 2:39 a.m. UTC | #2
On 11/02/17 19:25 -0700, Dan Williams wrote:
> On Thu, Nov 2, 2017 at 6:16 PM, Haozhong Zhang <haozhong.zhang@intel.com> wrote:
> > Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
> > ---
> >  include/linux/kvm_host.h | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> > index 6882538eda32..759fe498c89e 100644
> > --- a/include/linux/kvm_host.h
> > +++ b/include/linux/kvm_host.h
> > @@ -67,6 +67,9 @@
> >  #define KVM_PFN_ERR_HWPOISON   (KVM_PFN_ERR_MASK + 1)
> >  #define KVM_PFN_ERR_RO_FAULT   (KVM_PFN_ERR_MASK + 2)
> >
> > +#define kvm_pfn_to_pfn(x) ((pfn_t){ .val = (x)})
> > +#define pfn_to_kvm_pfn(x) ((kvm_pfn_t)((x).val))
> 
> Shouldn't this mask off the kvm_pfn_t and  pfn_t specific bits when
> converting between the two?

Yes, I'll fix it.

Thanks,
Haozhong
diff mbox

Patch

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 6882538eda32..759fe498c89e 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -67,6 +67,9 @@ 
 #define KVM_PFN_ERR_HWPOISON	(KVM_PFN_ERR_MASK + 1)
 #define KVM_PFN_ERR_RO_FAULT	(KVM_PFN_ERR_MASK + 2)
 
+#define kvm_pfn_to_pfn(x) ((pfn_t){ .val = (x)})
+#define pfn_to_kvm_pfn(x) ((kvm_pfn_t)((x).val))
+
 /*
  * error pfns indicate that the gfn is in slot but faild to
  * translate it to pfn on host.