All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 2/4] PF: Move architecture specifics to the backends
@ 2013-07-08 11:50 ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2013-07-08 11:50 UTC (permalink / raw)
  To: Dominik Dingel
  Cc: Gleb Natapov, Paolo Bonzini, Christian Borntraeger,
	Heiko Carstens, Martin Schwidefsky, Xiantao Zhang,
	Alexander Graf, Christoffer Dall, Ralf Baechle, kvm, linux-s390,
	linux-mm, linux-kernel

On 2013-07-05 21:55, Dominik Dingel wrote:
> Current common codes uses PAGE_OFFSET to indicate a bad host virtual 
> address.
> As this check won't work on architectures that don't map kernel and
> user memory
> into the same address space (e.g. s390), it is moved into architcture
> specific
> code.
>
> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> ---
>  arch/arm/include/asm/kvm_host.h     |  8 ++++++++
>  arch/ia64/include/asm/kvm_host.h    |  3 +++
>  arch/mips/include/asm/kvm_host.h    |  6 ++++++
>  arch/powerpc/include/asm/kvm_host.h |  8 ++++++++
>  arch/s390/include/asm/kvm_host.h    | 12 ++++++++++++
>  arch/x86/include/asm/kvm_host.h     |  8 ++++++++
>  include/linux/kvm_host.h            |  8 --------
>  7 files changed, 45 insertions(+), 8 deletions(-)

[...]

> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index a63d83e..210f493 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -85,14 +85,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
>  	return pfn == KVM_PFN_NOSLOT;
>  }
>
> -#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> -#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> -
> -static inline bool kvm_is_error_hva(unsigned long addr)
> -{
> -	return addr >= PAGE_OFFSET;
> -}
> -
>  #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
>
>  static inline bool is_error_page(struct page *page)

Nit: This breaks arm64. I suppose the patches have been created before 
the arm64 code got merged, so I'd expect the next version of this series 
to deal with arm64 as well.

Thanks,

         M.
-- 
Fast, cheap, reliable. Pick two.

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

* Re: [PATCH 2/4] PF: Move architecture specifics to the backends
@ 2013-07-08 11:50 ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2013-07-08 11:50 UTC (permalink / raw)
  To: Dominik Dingel
  Cc: Gleb Natapov, Paolo Bonzini, Christian Borntraeger,
	Heiko Carstens, Martin Schwidefsky, Xiantao Zhang,
	Alexander Graf, Christoffer Dall, Ralf Baechle, kvm, linux-s390,
	linux-mm, linux-kernel

On 2013-07-05 21:55, Dominik Dingel wrote:
> Current common codes uses PAGE_OFFSET to indicate a bad host virtual 
> address.
> As this check won't work on architectures that don't map kernel and
> user memory
> into the same address space (e.g. s390), it is moved into architcture
> specific
> code.
>
> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> ---
>  arch/arm/include/asm/kvm_host.h     |  8 ++++++++
>  arch/ia64/include/asm/kvm_host.h    |  3 +++
>  arch/mips/include/asm/kvm_host.h    |  6 ++++++
>  arch/powerpc/include/asm/kvm_host.h |  8 ++++++++
>  arch/s390/include/asm/kvm_host.h    | 12 ++++++++++++
>  arch/x86/include/asm/kvm_host.h     |  8 ++++++++
>  include/linux/kvm_host.h            |  8 --------
>  7 files changed, 45 insertions(+), 8 deletions(-)

[...]

> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index a63d83e..210f493 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -85,14 +85,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
>  	return pfn == KVM_PFN_NOSLOT;
>  }
>
> -#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> -#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> -
> -static inline bool kvm_is_error_hva(unsigned long addr)
> -{
> -	return addr >= PAGE_OFFSET;
> -}
> -
>  #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
>
>  static inline bool is_error_page(struct page *page)

Nit: This breaks arm64. I suppose the patches have been created before 
the arm64 code got merged, so I'd expect the next version of this series 
to deal with arm64 as well.

Thanks,

         M.
-- 
Fast, cheap, reliable. Pick two.

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

* Re: [PATCH 2/4] PF: Move architecture specifics to the backends
@ 2013-07-08 11:50 ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2013-07-08 11:50 UTC (permalink / raw)
  To: Dominik Dingel
  Cc: Gleb Natapov, Paolo Bonzini, Christian Borntraeger,
	Heiko Carstens, Martin Schwidefsky, Xiantao Zhang,
	Alexander Graf, Christoffer Dall, Ralf Baechle, kvm, linux-s390,
	linux-mm, linux-kernel

On 2013-07-05 21:55, Dominik Dingel wrote:
> Current common codes uses PAGE_OFFSET to indicate a bad host virtual 
> address.
> As this check won't work on architectures that don't map kernel and
> user memory
> into the same address space (e.g. s390), it is moved into architcture
> specific
> code.
>
> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> ---
>  arch/arm/include/asm/kvm_host.h     |  8 ++++++++
>  arch/ia64/include/asm/kvm_host.h    |  3 +++
>  arch/mips/include/asm/kvm_host.h    |  6 ++++++
>  arch/powerpc/include/asm/kvm_host.h |  8 ++++++++
>  arch/s390/include/asm/kvm_host.h    | 12 ++++++++++++
>  arch/x86/include/asm/kvm_host.h     |  8 ++++++++
>  include/linux/kvm_host.h            |  8 --------
>  7 files changed, 45 insertions(+), 8 deletions(-)

[...]

> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index a63d83e..210f493 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -85,14 +85,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
>  	return pfn == KVM_PFN_NOSLOT;
>  }
>
> -#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> -#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> -
> -static inline bool kvm_is_error_hva(unsigned long addr)
> -{
> -	return addr >= PAGE_OFFSET;
> -}
> -
>  #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
>
>  static inline bool is_error_page(struct page *page)

Nit: This breaks arm64. I suppose the patches have been created before 
the arm64 code got merged, so I'd expect the next version of this series 
to deal with arm64 as well.

Thanks,

         M.
-- 
Fast, cheap, reliable. Pick two.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH 2/4] PF: Move architecture specifics to the backends
  2013-07-05 20:55   ` Dominik Dingel
@ 2013-07-07  9:20     ` Gleb Natapov
  -1 siblings, 0 replies; 9+ messages in thread
From: Gleb Natapov @ 2013-07-07  9:20 UTC (permalink / raw)
  To: Dominik Dingel
  Cc: Paolo Bonzini, Christian Borntraeger, Heiko Carstens,
	Martin Schwidefsky, Xiantao Zhang, Alexander Graf,
	Christoffer Dall, Marc Zyngier, Ralf Baechle, kvm, linux-s390,
	linux-mm, linux-kernel

On Fri, Jul 05, 2013 at 10:55:52PM +0200, Dominik Dingel wrote:
> Current common codes uses PAGE_OFFSET to indicate a bad host virtual address.
> As this check won't work on architectures that don't map kernel and user memory
> into the same address space (e.g. s390), it is moved into architcture specific
> code.
> 
> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> ---
>  arch/arm/include/asm/kvm_host.h     |  8 ++++++++
>  arch/ia64/include/asm/kvm_host.h    |  3 +++
>  arch/mips/include/asm/kvm_host.h    |  6 ++++++
>  arch/powerpc/include/asm/kvm_host.h |  8 ++++++++
>  arch/s390/include/asm/kvm_host.h    | 12 ++++++++++++
>  arch/x86/include/asm/kvm_host.h     |  8 ++++++++
>  include/linux/kvm_host.h            |  8 --------
>  7 files changed, 45 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
> index 7d22517..557c2a1 100644
> --- a/arch/arm/include/asm/kvm_host.h
> +++ b/arch/arm/include/asm/kvm_host.h
> @@ -74,6 +74,14 @@ struct kvm_arch {
>  	struct vgic_dist	vgic;
>  };
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
> +
Instead of changing every arch I prefer to add
#ifndef KVM_HVA_ERR_BAD
#dndif
around this code in the common header and define different version for
s390 only.

A question bellow.

>  #define KVM_NR_MEM_OBJS     40
>  
>  /*
> diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
> index 989dd3f..d3afa6f 100644
> --- a/arch/ia64/include/asm/kvm_host.h
> +++ b/arch/ia64/include/asm/kvm_host.h
> @@ -486,6 +486,9 @@ struct kvm_arch {
>  	unsigned long irq_states[KVM_IOAPIC_NUM_PINS];
>  };
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
>  union cpuid3_t {
>  	u64 value;
>  	struct {
> diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
> index 4d6fa0b..3a0a3f7 100644
> --- a/arch/mips/include/asm/kvm_host.h
> +++ b/arch/mips/include/asm/kvm_host.h
> @@ -34,7 +34,13 @@
>  #define KVM_NR_PAGE_SIZES	1
>  #define KVM_PAGES_PER_HPAGE(x)	1
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
>  
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
>  
>  /* Special address that contains the comm page, used for reducing # of traps */
>  #define KVM_GUEST_COMMPAGE_ADDR     0x0
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index af326cd..be5d7f4 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -273,6 +273,14 @@ struct kvm_arch {
>  #endif
>  };
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
> +
>  /*
>   * Struct for a virtual core.
>   * Note: entry_exit_count combines an entry count in the bottom 8 bits
> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
> index 3238d40..1588882 100644
> --- a/arch/s390/include/asm/kvm_host.h
> +++ b/arch/s390/include/asm/kvm_host.h
> @@ -274,6 +274,18 @@ struct kvm_arch{
>  	int css_support;
>  };
>  
> +#define KVM_HVA_ERR_BAD		(-1UL)
> +#define KVM_HVA_ERR_RO_BAD	(-1UL)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	/*
> +	 * on s390, this check is not needed as kernel and user memory
> +	 * is not mapped into the same address space
> +	 */
> +	return false;
> +}
> +
Can gfn_to_hva() ever return error hva on S390? Currently error hva is
returned if gfn is outside of any slot or slot is invalid.

>  extern int sie64a(struct kvm_s390_sie_block *, u64 *);
>  extern char sie_exit;
>  #endif
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index f87f7fc..07e8570 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -96,6 +96,14 @@
>  
>  #define ASYNC_PF_PER_VCPU 64
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
> +
>  struct kvm_vcpu;
>  struct kvm;
>  struct kvm_async_pf;
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index a63d83e..210f493 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -85,14 +85,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
>  	return pfn == KVM_PFN_NOSLOT;
>  }
>  
> -#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> -#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> -
> -static inline bool kvm_is_error_hva(unsigned long addr)
> -{
> -	return addr >= PAGE_OFFSET;
> -}
> -
>  #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
>  
>  static inline bool is_error_page(struct page *page)
> -- 
> 1.8.2.2

--
			Gleb.

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

* Re: [PATCH 2/4] PF: Move architecture specifics to the backends
@ 2013-07-07  9:20     ` Gleb Natapov
  0 siblings, 0 replies; 9+ messages in thread
From: Gleb Natapov @ 2013-07-07  9:20 UTC (permalink / raw)
  To: Dominik Dingel
  Cc: Paolo Bonzini, Christian Borntraeger, Heiko Carstens,
	Martin Schwidefsky, Xiantao Zhang, Alexander Graf,
	Christoffer Dall, Marc Zyngier, Ralf Baechle, kvm, linux-s390,
	linux-mm, linux-kernel

On Fri, Jul 05, 2013 at 10:55:52PM +0200, Dominik Dingel wrote:
> Current common codes uses PAGE_OFFSET to indicate a bad host virtual address.
> As this check won't work on architectures that don't map kernel and user memory
> into the same address space (e.g. s390), it is moved into architcture specific
> code.
> 
> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> ---
>  arch/arm/include/asm/kvm_host.h     |  8 ++++++++
>  arch/ia64/include/asm/kvm_host.h    |  3 +++
>  arch/mips/include/asm/kvm_host.h    |  6 ++++++
>  arch/powerpc/include/asm/kvm_host.h |  8 ++++++++
>  arch/s390/include/asm/kvm_host.h    | 12 ++++++++++++
>  arch/x86/include/asm/kvm_host.h     |  8 ++++++++
>  include/linux/kvm_host.h            |  8 --------
>  7 files changed, 45 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
> index 7d22517..557c2a1 100644
> --- a/arch/arm/include/asm/kvm_host.h
> +++ b/arch/arm/include/asm/kvm_host.h
> @@ -74,6 +74,14 @@ struct kvm_arch {
>  	struct vgic_dist	vgic;
>  };
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
> +
Instead of changing every arch I prefer to add
#ifndef KVM_HVA_ERR_BAD
#dndif
around this code in the common header and define different version for
s390 only.

A question bellow.

>  #define KVM_NR_MEM_OBJS     40
>  
>  /*
> diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
> index 989dd3f..d3afa6f 100644
> --- a/arch/ia64/include/asm/kvm_host.h
> +++ b/arch/ia64/include/asm/kvm_host.h
> @@ -486,6 +486,9 @@ struct kvm_arch {
>  	unsigned long irq_states[KVM_IOAPIC_NUM_PINS];
>  };
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
>  union cpuid3_t {
>  	u64 value;
>  	struct {
> diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
> index 4d6fa0b..3a0a3f7 100644
> --- a/arch/mips/include/asm/kvm_host.h
> +++ b/arch/mips/include/asm/kvm_host.h
> @@ -34,7 +34,13 @@
>  #define KVM_NR_PAGE_SIZES	1
>  #define KVM_PAGES_PER_HPAGE(x)	1
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
>  
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
>  
>  /* Special address that contains the comm page, used for reducing # of traps */
>  #define KVM_GUEST_COMMPAGE_ADDR     0x0
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index af326cd..be5d7f4 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -273,6 +273,14 @@ struct kvm_arch {
>  #endif
>  };
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
> +
>  /*
>   * Struct for a virtual core.
>   * Note: entry_exit_count combines an entry count in the bottom 8 bits
> diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
> index 3238d40..1588882 100644
> --- a/arch/s390/include/asm/kvm_host.h
> +++ b/arch/s390/include/asm/kvm_host.h
> @@ -274,6 +274,18 @@ struct kvm_arch{
>  	int css_support;
>  };
>  
> +#define KVM_HVA_ERR_BAD		(-1UL)
> +#define KVM_HVA_ERR_RO_BAD	(-1UL)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	/*
> +	 * on s390, this check is not needed as kernel and user memory
> +	 * is not mapped into the same address space
> +	 */
> +	return false;
> +}
> +
Can gfn_to_hva() ever return error hva on S390? Currently error hva is
returned if gfn is outside of any slot or slot is invalid.

>  extern int sie64a(struct kvm_s390_sie_block *, u64 *);
>  extern char sie_exit;
>  #endif
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index f87f7fc..07e8570 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -96,6 +96,14 @@
>  
>  #define ASYNC_PF_PER_VCPU 64
>  
> +#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> +#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> +
> +static inline bool kvm_is_error_hva(unsigned long addr)
> +{
> +	return addr >= PAGE_OFFSET;
> +}
> +
>  struct kvm_vcpu;
>  struct kvm;
>  struct kvm_async_pf;
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index a63d83e..210f493 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -85,14 +85,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
>  	return pfn == KVM_PFN_NOSLOT;
>  }
>  
> -#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
> -#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
> -
> -static inline bool kvm_is_error_hva(unsigned long addr)
> -{
> -	return addr >= PAGE_OFFSET;
> -}
> -
>  #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
>  
>  static inline bool is_error_page(struct page *page)
> -- 
> 1.8.2.2

--
			Gleb.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH 2/4] PF: Move architecture specifics to the backends
  2013-07-05 20:55 [RFC PATCH v2 0/4] Enable async page faults on s390 Dominik Dingel
@ 2013-07-05 20:55   ` Dominik Dingel
  0 siblings, 0 replies; 9+ messages in thread
From: Dominik Dingel @ 2013-07-05 20:55 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, Heiko Carstens, Martin Schwidefsky,
	Xiantao Zhang, Alexander Graf, Christoffer Dall, Marc Zyngier,
	Ralf Baechle, kvm, linux-s390, linux-mm, linux-kernel,
	Dominik Dingel

Current common codes uses PAGE_OFFSET to indicate a bad host virtual address.
As this check won't work on architectures that don't map kernel and user memory
into the same address space (e.g. s390), it is moved into architcture specific
code.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
---
 arch/arm/include/asm/kvm_host.h     |  8 ++++++++
 arch/ia64/include/asm/kvm_host.h    |  3 +++
 arch/mips/include/asm/kvm_host.h    |  6 ++++++
 arch/powerpc/include/asm/kvm_host.h |  8 ++++++++
 arch/s390/include/asm/kvm_host.h    | 12 ++++++++++++
 arch/x86/include/asm/kvm_host.h     |  8 ++++++++
 include/linux/kvm_host.h            |  8 --------
 7 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 7d22517..557c2a1 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -74,6 +74,14 @@ struct kvm_arch {
 	struct vgic_dist	vgic;
 };
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 #define KVM_NR_MEM_OBJS     40
 
 /*
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 989dd3f..d3afa6f 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -486,6 +486,9 @@ struct kvm_arch {
 	unsigned long irq_states[KVM_IOAPIC_NUM_PINS];
 };
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
 union cpuid3_t {
 	u64 value;
 	struct {
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index 4d6fa0b..3a0a3f7 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -34,7 +34,13 @@
 #define KVM_NR_PAGE_SIZES	1
 #define KVM_PAGES_PER_HPAGE(x)	1
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
 
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
 
 /* Special address that contains the comm page, used for reducing # of traps */
 #define KVM_GUEST_COMMPAGE_ADDR     0x0
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index af326cd..be5d7f4 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -273,6 +273,14 @@ struct kvm_arch {
 #endif
 };
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 /*
  * Struct for a virtual core.
  * Note: entry_exit_count combines an entry count in the bottom 8 bits
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 3238d40..1588882 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -274,6 +274,18 @@ struct kvm_arch{
 	int css_support;
 };
 
+#define KVM_HVA_ERR_BAD		(-1UL)
+#define KVM_HVA_ERR_RO_BAD	(-1UL)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	/*
+	 * on s390, this check is not needed as kernel and user memory
+	 * is not mapped into the same address space
+	 */
+	return false;
+}
+
 extern int sie64a(struct kvm_s390_sie_block *, u64 *);
 extern char sie_exit;
 #endif
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index f87f7fc..07e8570 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -96,6 +96,14 @@
 
 #define ASYNC_PF_PER_VCPU 64
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 struct kvm_vcpu;
 struct kvm;
 struct kvm_async_pf;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index a63d83e..210f493 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -85,14 +85,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
 	return pfn == KVM_PFN_NOSLOT;
 }
 
-#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
-#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
-
-static inline bool kvm_is_error_hva(unsigned long addr)
-{
-	return addr >= PAGE_OFFSET;
-}
-
 #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
 
 static inline bool is_error_page(struct page *page)
-- 
1.8.2.2


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

* [PATCH 2/4] PF: Move architecture specifics to the backends
@ 2013-07-05 20:55   ` Dominik Dingel
  0 siblings, 0 replies; 9+ messages in thread
From: Dominik Dingel @ 2013-07-05 20:55 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, Heiko Carstens, Martin Schwidefsky,
	Xiantao Zhang, Alexander Graf, Christoffer Dall, Marc Zyngier,
	Ralf Baechle, kvm, linux-s390, linux-mm, linux-kernel,
	Dominik Dingel

Current common codes uses PAGE_OFFSET to indicate a bad host virtual address.
As this check won't work on architectures that don't map kernel and user memory
into the same address space (e.g. s390), it is moved into architcture specific
code.

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
---
 arch/arm/include/asm/kvm_host.h     |  8 ++++++++
 arch/ia64/include/asm/kvm_host.h    |  3 +++
 arch/mips/include/asm/kvm_host.h    |  6 ++++++
 arch/powerpc/include/asm/kvm_host.h |  8 ++++++++
 arch/s390/include/asm/kvm_host.h    | 12 ++++++++++++
 arch/x86/include/asm/kvm_host.h     |  8 ++++++++
 include/linux/kvm_host.h            |  8 --------
 7 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h
index 7d22517..557c2a1 100644
--- a/arch/arm/include/asm/kvm_host.h
+++ b/arch/arm/include/asm/kvm_host.h
@@ -74,6 +74,14 @@ struct kvm_arch {
 	struct vgic_dist	vgic;
 };
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 #define KVM_NR_MEM_OBJS     40
 
 /*
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 989dd3f..d3afa6f 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -486,6 +486,9 @@ struct kvm_arch {
 	unsigned long irq_states[KVM_IOAPIC_NUM_PINS];
 };
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
 union cpuid3_t {
 	u64 value;
 	struct {
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index 4d6fa0b..3a0a3f7 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -34,7 +34,13 @@
 #define KVM_NR_PAGE_SIZES	1
 #define KVM_PAGES_PER_HPAGE(x)	1
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
 
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
 
 /* Special address that contains the comm page, used for reducing # of traps */
 #define KVM_GUEST_COMMPAGE_ADDR     0x0
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index af326cd..be5d7f4 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -273,6 +273,14 @@ struct kvm_arch {
 #endif
 };
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 /*
  * Struct for a virtual core.
  * Note: entry_exit_count combines an entry count in the bottom 8 bits
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index 3238d40..1588882 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -274,6 +274,18 @@ struct kvm_arch{
 	int css_support;
 };
 
+#define KVM_HVA_ERR_BAD		(-1UL)
+#define KVM_HVA_ERR_RO_BAD	(-1UL)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	/*
+	 * on s390, this check is not needed as kernel and user memory
+	 * is not mapped into the same address space
+	 */
+	return false;
+}
+
 extern int sie64a(struct kvm_s390_sie_block *, u64 *);
 extern char sie_exit;
 #endif
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index f87f7fc..07e8570 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -96,6 +96,14 @@
 
 #define ASYNC_PF_PER_VCPU 64
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 struct kvm_vcpu;
 struct kvm;
 struct kvm_async_pf;
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index a63d83e..210f493 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -85,14 +85,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
 	return pfn == KVM_PFN_NOSLOT;
 }
 
-#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
-#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
-
-static inline bool kvm_is_error_hva(unsigned long addr)
-{
-	return addr >= PAGE_OFFSET;
-}
-
 #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
 
 static inline bool is_error_page(struct page *page)
-- 
1.8.2.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* [PATCH 2/4] PF: Move architecture specifics to the backends
  2013-06-10 12:03 [RFC PATCH 0/4] Enable async page faults on s390 Dominik Dingel
@ 2013-06-10 12:03   ` Dominik Dingel
  0 siblings, 0 replies; 9+ messages in thread
From: Dominik Dingel @ 2013-06-10 12:03 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, Heiko Carstens, Martin Schwidefsky, kvm,
	linux-s390, linux-mm, linux-kernel, Dominik Dingel

Current common code use PAGE_OFFSET to indicate a bad host virtual address.
This works for x86 but not necessarily on other architectures. So the check
is moved into architecture specific code.

Todo:
 - apply to other architectures when applicable

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
---
 arch/s390/include/asm/kvm_host.h | 12 ++++++++++++
 arch/x86/include/asm/kvm_host.h  |  8 ++++++++
 include/linux/kvm_host.h         |  8 --------
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index deb1990..e014bba 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -277,6 +277,18 @@ struct kvm_arch{
 	int css_support;
 };
 
+#define KVM_HVA_ERR_BAD		(-1UL)
+#define KVM_HVA_ERR_RO_BAD	(-1UL)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	/*
+	 * on s390, this check is not needed as kernel and user memory
+	 * is not mapped into the same address space
+	 */
+	return false;
+}
+
 extern int sie64a(struct kvm_s390_sie_block *, u64 *);
 extern unsigned long sie_exit_addr;
 #endif
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 4979778..5ed7c83 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -94,6 +94,14 @@
 
 #define ASYNC_PF_PER_VCPU 64
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 extern raw_spinlock_t kvm_lock;
 extern struct list_head vm_list;
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index c139582..9bd29ef 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -84,14 +84,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
 	return pfn == KVM_PFN_NOSLOT;
 }
 
-#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
-#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
-
-static inline bool kvm_is_error_hva(unsigned long addr)
-{
-	return addr >= PAGE_OFFSET;
-}
-
 #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
 
 static inline bool is_error_page(struct page *page)
-- 
1.8.1.6


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

* [PATCH 2/4] PF: Move architecture specifics to the backends
@ 2013-06-10 12:03   ` Dominik Dingel
  0 siblings, 0 replies; 9+ messages in thread
From: Dominik Dingel @ 2013-06-10 12:03 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini
  Cc: Christian Borntraeger, Heiko Carstens, Martin Schwidefsky, kvm,
	linux-s390, linux-mm, linux-kernel, Dominik Dingel

Current common code use PAGE_OFFSET to indicate a bad host virtual address.
This works for x86 but not necessarily on other architectures. So the check
is moved into architecture specific code.

Todo:
 - apply to other architectures when applicable

Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
---
 arch/s390/include/asm/kvm_host.h | 12 ++++++++++++
 arch/x86/include/asm/kvm_host.h  |  8 ++++++++
 include/linux/kvm_host.h         |  8 --------
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index deb1990..e014bba 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -277,6 +277,18 @@ struct kvm_arch{
 	int css_support;
 };
 
+#define KVM_HVA_ERR_BAD		(-1UL)
+#define KVM_HVA_ERR_RO_BAD	(-1UL)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	/*
+	 * on s390, this check is not needed as kernel and user memory
+	 * is not mapped into the same address space
+	 */
+	return false;
+}
+
 extern int sie64a(struct kvm_s390_sie_block *, u64 *);
 extern unsigned long sie_exit_addr;
 #endif
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 4979778..5ed7c83 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -94,6 +94,14 @@
 
 #define ASYNC_PF_PER_VCPU 64
 
+#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
+#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
+
+static inline bool kvm_is_error_hva(unsigned long addr)
+{
+	return addr >= PAGE_OFFSET;
+}
+
 extern raw_spinlock_t kvm_lock;
 extern struct list_head vm_list;
 
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index c139582..9bd29ef 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -84,14 +84,6 @@ static inline bool is_noslot_pfn(pfn_t pfn)
 	return pfn == KVM_PFN_NOSLOT;
 }
 
-#define KVM_HVA_ERR_BAD		(PAGE_OFFSET)
-#define KVM_HVA_ERR_RO_BAD	(PAGE_OFFSET + PAGE_SIZE)
-
-static inline bool kvm_is_error_hva(unsigned long addr)
-{
-	return addr >= PAGE_OFFSET;
-}
-
 #define KVM_ERR_PTR_BAD_PAGE	(ERR_PTR(-ENOENT))
 
 static inline bool is_error_page(struct page *page)
-- 
1.8.1.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-07-08 11:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-08 11:50 [PATCH 2/4] PF: Move architecture specifics to the backends Marc Zyngier
2013-07-08 11:50 ` Marc Zyngier
2013-07-08 11:50 ` Marc Zyngier
  -- strict thread matches above, loose matches on Subject: below --
2013-07-05 20:55 [RFC PATCH v2 0/4] Enable async page faults on s390 Dominik Dingel
2013-07-05 20:55 ` [PATCH 2/4] PF: Move architecture specifics to the backends Dominik Dingel
2013-07-05 20:55   ` Dominik Dingel
2013-07-07  9:20   ` Gleb Natapov
2013-07-07  9:20     ` Gleb Natapov
2013-06-10 12:03 [RFC PATCH 0/4] Enable async page faults on s390 Dominik Dingel
2013-06-10 12:03 ` [PATCH 2/4] PF: Move architecture specifics to the backends Dominik Dingel
2013-06-10 12:03   ` Dominik Dingel

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.