All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: kvm@vger.kernel.org, Ram Pai <linuxram@us.ibm.com>,
	kvm-ppc@vger.kernel.org,
	Alex Williamson <alex.williamson@redhat.com>,
	Alistair Popple <alistair@popple.id.au>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH kernel 1/5] vfio/spapr_tce: Simplify page contained test
Date: Fri, 08 Jun 2018 03:32:36 +0000	[thread overview]
Message-ID: <20180608033236.GN3344@umbus.fritz.box> (raw)
In-Reply-To: <20180607084420.29513-2-aik@ozlabs.ru>

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

On Thu, Jun 07, 2018 at 06:44:16PM +1000, Alexey Kardashevskiy wrote:
> The test function takes a page struct pointer which is not used by
> either of two callers in any other way, make it simple and just pass
> a physical address there.
> 
> This should cause no behavioral change now but later we may start
> supporting host addresses for memory devices which are not backed
> with page structs.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  drivers/vfio/vfio_iommu_spapr_tce.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 759a5bd..2c4a048 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -249,8 +249,9 @@ static void tce_iommu_userspace_view_free(struct iommu_table *tbl,
>  	decrement_locked_vm(mm, cb >> PAGE_SHIFT);
>  }
>  
> -static bool tce_page_is_contained(struct page *page, unsigned page_shift)
> +static bool tce_page_is_contained(unsigned long hpa, unsigned page_shift)
>  {
> +	struct page *page = pfn_to_page(hpa >> PAGE_SHIFT);
>  	/*
>  	 * Check that the TCE table granularity is not bigger than the size of
>  	 * a page we just found. Otherwise the hardware can get access to
> @@ -549,7 +550,6 @@ static long tce_iommu_build(struct tce_container *container,
>  		enum dma_data_direction direction)
>  {
>  	long i, ret = 0;
> -	struct page *page;
>  	unsigned long hpa;
>  	enum dma_data_direction dirtmp;
>  
> @@ -560,8 +560,7 @@ static long tce_iommu_build(struct tce_container *container,
>  		if (ret)
>  			break;
>  
> -		page = pfn_to_page(hpa >> PAGE_SHIFT);
> -		if (!tce_page_is_contained(page, tbl->it_page_shift)) {
> +		if (!tce_page_is_contained(hpa, tbl->it_page_shift)) {
>  			ret = -EPERM;
>  			break;
>  		}
> @@ -595,7 +594,6 @@ static long tce_iommu_build_v2(struct tce_container *container,
>  		enum dma_data_direction direction)
>  {
>  	long i, ret = 0;
> -	struct page *page;
>  	unsigned long hpa;
>  	enum dma_data_direction dirtmp;
>  
> @@ -615,8 +613,7 @@ static long tce_iommu_build_v2(struct tce_container *container,
>  		if (ret)
>  			break;
>  
> -		page = pfn_to_page(hpa >> PAGE_SHIFT);
> -		if (!tce_page_is_contained(page, tbl->it_page_shift)) {
> +		if (!tce_page_is_contained(hpa, tbl->it_page_shift)) {
>  			ret = -EPERM;
>  			break;
>  		}

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org,
	Alex Williamson <alex.williamson@redhat.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Ram Pai <linuxram@us.ibm.com>,
	kvm@vger.kernel.org, Alistair Popple <alistair@popple.id.au>
Subject: Re: [RFC PATCH kernel 1/5] vfio/spapr_tce: Simplify page contained test
Date: Fri, 8 Jun 2018 13:32:36 +1000	[thread overview]
Message-ID: <20180608033236.GN3344@umbus.fritz.box> (raw)
In-Reply-To: <20180607084420.29513-2-aik@ozlabs.ru>

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

On Thu, Jun 07, 2018 at 06:44:16PM +1000, Alexey Kardashevskiy wrote:
> The test function takes a page struct pointer which is not used by
> either of two callers in any other way, make it simple and just pass
> a physical address there.
> 
> This should cause no behavioral change now but later we may start
> supporting host addresses for memory devices which are not backed
> with page structs.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  drivers/vfio/vfio_iommu_spapr_tce.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 759a5bd..2c4a048 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -249,8 +249,9 @@ static void tce_iommu_userspace_view_free(struct iommu_table *tbl,
>  	decrement_locked_vm(mm, cb >> PAGE_SHIFT);
>  }
>  
> -static bool tce_page_is_contained(struct page *page, unsigned page_shift)
> +static bool tce_page_is_contained(unsigned long hpa, unsigned page_shift)
>  {
> +	struct page *page = pfn_to_page(hpa >> PAGE_SHIFT);
>  	/*
>  	 * Check that the TCE table granularity is not bigger than the size of
>  	 * a page we just found. Otherwise the hardware can get access to
> @@ -549,7 +550,6 @@ static long tce_iommu_build(struct tce_container *container,
>  		enum dma_data_direction direction)
>  {
>  	long i, ret = 0;
> -	struct page *page;
>  	unsigned long hpa;
>  	enum dma_data_direction dirtmp;
>  
> @@ -560,8 +560,7 @@ static long tce_iommu_build(struct tce_container *container,
>  		if (ret)
>  			break;
>  
> -		page = pfn_to_page(hpa >> PAGE_SHIFT);
> -		if (!tce_page_is_contained(page, tbl->it_page_shift)) {
> +		if (!tce_page_is_contained(hpa, tbl->it_page_shift)) {
>  			ret = -EPERM;
>  			break;
>  		}
> @@ -595,7 +594,6 @@ static long tce_iommu_build_v2(struct tce_container *container,
>  		enum dma_data_direction direction)
>  {
>  	long i, ret = 0;
> -	struct page *page;
>  	unsigned long hpa;
>  	enum dma_data_direction dirtmp;
>  
> @@ -615,8 +613,7 @@ static long tce_iommu_build_v2(struct tce_container *container,
>  		if (ret)
>  			break;
>  
> -		page = pfn_to_page(hpa >> PAGE_SHIFT);
> -		if (!tce_page_is_contained(page, tbl->it_page_shift)) {
> +		if (!tce_page_is_contained(hpa, tbl->it_page_shift)) {
>  			ret = -EPERM;
>  			break;
>  		}

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <david@gibson.dropbear.id.au>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: kvm@vger.kernel.org, Ram Pai <linuxram@us.ibm.com>,
	kvm-ppc@vger.kernel.org,
	Alex Williamson <alex.williamson@redhat.com>,
	Alistair Popple <alistair@popple.id.au>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH kernel 1/5] vfio/spapr_tce: Simplify page contained test
Date: Fri, 8 Jun 2018 13:32:36 +1000	[thread overview]
Message-ID: <20180608033236.GN3344@umbus.fritz.box> (raw)
In-Reply-To: <20180607084420.29513-2-aik@ozlabs.ru>

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

On Thu, Jun 07, 2018 at 06:44:16PM +1000, Alexey Kardashevskiy wrote:
> The test function takes a page struct pointer which is not used by
> either of two callers in any other way, make it simple and just pass
> a physical address there.
> 
> This should cause no behavioral change now but later we may start
> supporting host addresses for memory devices which are not backed
> with page structs.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  drivers/vfio/vfio_iommu_spapr_tce.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 759a5bd..2c4a048 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -249,8 +249,9 @@ static void tce_iommu_userspace_view_free(struct iommu_table *tbl,
>  	decrement_locked_vm(mm, cb >> PAGE_SHIFT);
>  }
>  
> -static bool tce_page_is_contained(struct page *page, unsigned page_shift)
> +static bool tce_page_is_contained(unsigned long hpa, unsigned page_shift)
>  {
> +	struct page *page = pfn_to_page(hpa >> PAGE_SHIFT);
>  	/*
>  	 * Check that the TCE table granularity is not bigger than the size of
>  	 * a page we just found. Otherwise the hardware can get access to
> @@ -549,7 +550,6 @@ static long tce_iommu_build(struct tce_container *container,
>  		enum dma_data_direction direction)
>  {
>  	long i, ret = 0;
> -	struct page *page;
>  	unsigned long hpa;
>  	enum dma_data_direction dirtmp;
>  
> @@ -560,8 +560,7 @@ static long tce_iommu_build(struct tce_container *container,
>  		if (ret)
>  			break;
>  
> -		page = pfn_to_page(hpa >> PAGE_SHIFT);
> -		if (!tce_page_is_contained(page, tbl->it_page_shift)) {
> +		if (!tce_page_is_contained(hpa, tbl->it_page_shift)) {
>  			ret = -EPERM;
>  			break;
>  		}
> @@ -595,7 +594,6 @@ static long tce_iommu_build_v2(struct tce_container *container,
>  		enum dma_data_direction direction)
>  {
>  	long i, ret = 0;
> -	struct page *page;
>  	unsigned long hpa;
>  	enum dma_data_direction dirtmp;
>  
> @@ -615,8 +613,7 @@ static long tce_iommu_build_v2(struct tce_container *container,
>  		if (ret)
>  			break;
>  
> -		page = pfn_to_page(hpa >> PAGE_SHIFT);
> -		if (!tce_page_is_contained(page, tbl->it_page_shift)) {
> +		if (!tce_page_is_contained(hpa, tbl->it_page_shift)) {
>  			ret = -EPERM;
>  			break;
>  		}

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-06-08  3:32 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07  8:44 [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100 Alexey Kardashevskiy
2018-06-07  8:44 ` Alexey Kardashevskiy
2018-06-07  8:44 ` Alexey Kardashevskiy
2018-06-07  8:44 ` [RFC PATCH kernel 1/5] vfio/spapr_tce: Simplify page contained test Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-08  3:32   ` David Gibson [this message]
2018-06-08  3:32     ` David Gibson
2018-06-08  3:32     ` David Gibson
2018-06-07  8:44 ` [RFC PATCH kernel 2/5] powerpc/iommu_context: Change referencing in API Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07  8:44 ` [RFC PATCH kernel 3/5] powerpc/iommu: Do not pin memory of a memory device Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07  8:44 ` [RFC PATCH kernel 4/5] vfio_pci: Allow mapping extra regions Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07 17:04   ` Alex Williamson
2018-06-07 17:04     ` Alex Williamson
2018-06-07 17:04     ` Alex Williamson
2018-06-07  8:44 ` [RFC PATCH kernel 5/5] vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] [10de:1db1] subdriver Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07  8:44   ` Alexey Kardashevskiy
2018-06-07 17:04   ` Alex Williamson
2018-06-07 17:04     ` Alex Williamson
2018-06-07 17:04     ` Alex Williamson
2018-06-08  3:09     ` Alexey Kardashevskiy
2018-06-08  3:09       ` Alexey Kardashevskiy
2018-06-08  3:09       ` Alexey Kardashevskiy
2018-06-08  3:35       ` Alex Williamson
2018-06-08  3:35         ` Alex Williamson
2018-06-08  3:35         ` Alex Williamson
2018-06-08  3:52         ` Alexey Kardashevskiy
2018-06-08  3:52           ` Alexey Kardashevskiy
2018-06-08  3:52           ` Alexey Kardashevskiy
2018-06-08  4:34           ` Alex Williamson
2018-06-08  4:34             ` Alex Williamson
2018-06-08  4:34             ` Alex Williamson
2018-06-07 17:04 ` [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100 Alex Williamson
2018-06-07 17:04   ` Alex Williamson
2018-06-07 17:04   ` Alex Williamson
2018-06-07 21:54   ` Benjamin Herrenschmidt
2018-06-07 21:54     ` Benjamin Herrenschmidt
2018-06-07 21:54     ` Benjamin Herrenschmidt
2018-06-07 22:15     ` Alex Williamson
2018-06-07 22:15       ` Alex Williamson
2018-06-07 22:15       ` Alex Williamson
2018-06-07 23:20       ` Benjamin Herrenschmidt
2018-06-07 23:20         ` Benjamin Herrenschmidt
2018-06-07 23:20         ` Benjamin Herrenschmidt
2018-06-08  0:34         ` Alex Williamson
2018-06-08  0:34           ` Alex Williamson
2018-06-08  0:34           ` Alex Williamson
2018-06-08  0:58           ` Benjamin Herrenschmidt
2018-06-08  0:58             ` Benjamin Herrenschmidt
2018-06-08  0:58             ` Benjamin Herrenschmidt
2018-06-08  1:18             ` Alex Williamson
2018-06-08  1:18               ` Alex Williamson
2018-06-08  1:18               ` Alex Williamson
2018-06-08  3:08       ` Alexey Kardashevskiy
2018-06-08  3:08         ` Alexey Kardashevskiy
2018-06-08  3:08         ` Alexey Kardashevskiy
2018-06-08  3:44         ` Alex Williamson
2018-06-08  3:44           ` Alex Williamson
2018-06-08  3:44           ` Alex Williamson
2018-06-08  4:14           ` Alexey Kardashevskiy
2018-06-08  4:14             ` Alexey Kardashevskiy
2018-06-08  4:14             ` Alexey Kardashevskiy
2018-06-08  5:03             ` Alex Williamson
2018-06-08  5:03               ` Alex Williamson
2018-06-08  5:03               ` Alex Williamson
2018-07-10  4:10               ` Alexey Kardashevskiy
2018-07-10  4:10                 ` Alexey Kardashevskiy
2018-07-10  4:10                 ` Alexey Kardashevskiy
2018-07-10 22:37                 ` Alex Williamson
2018-07-10 22:37                   ` Alex Williamson
2018-07-10 22:37                   ` Alex Williamson
2018-07-11  9:26                   ` Alexey Kardashevskiy
2018-07-11  9:26                     ` Alexey Kardashevskiy
2018-07-11  9:26                     ` Alexey Kardashevskiy
2018-07-30  8:58                     ` Alexey Kardashevskiy
2018-07-30  8:58                       ` Alexey Kardashevskiy
2018-07-30  8:58                       ` Alexey Kardashevskiy
2018-07-30 16:29                       ` Alex Williamson
2018-07-30 16:29                         ` Alex Williamson
2018-07-30 16:29                         ` Alex Williamson
2018-07-31  4:03                         ` Alexey Kardashevskiy
2018-07-31  4:03                           ` Alexey Kardashevskiy
2018-07-31  4:03                           ` Alexey Kardashevskiy
2018-07-31 14:29                           ` Alex Williamson
2018-07-31 14:29                             ` Alex Williamson
2018-07-31 14:29                             ` Alex Williamson
2018-08-01  8:37                             ` Alexey Kardashevskiy
2018-08-01  8:37                               ` Alexey Kardashevskiy
2018-08-01  8:37                               ` Alexey Kardashevskiy
2018-08-01 16:16                               ` Alex Williamson
2018-08-01 16:16                                 ` Alex Williamson
2018-08-01 16:16                                 ` Alex Williamson
2018-08-08  8:39                                 ` Alexey Kardashevskiy
2018-08-08  8:39                                   ` Alexey Kardashevskiy
2018-08-08  8:39                                   ` Alexey Kardashevskiy
2018-08-09  4:21                                   ` Alexey Kardashevskiy
2018-08-09  4:21                                     ` Alexey Kardashevskiy
2018-08-09  4:21                                     ` Alexey Kardashevskiy
2018-08-09 14:06                                     ` Alex Williamson
2018-08-09 14:06                                       ` Alex Williamson
2018-08-09 14:06                                       ` Alex Williamson

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=20180608033236.GN3344@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=aik@ozlabs.ru \
    --cc=alex.williamson@redhat.com \
    --cc=alistair@popple.id.au \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=linuxram@us.ibm.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.