public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/1] s390/mm: fix virtual-physical address confusion for swiotlb
@ 2022-11-07 12:12 Nico Boehr
  2022-11-07 12:12 ` [PATCH v2 1/1] " Nico Boehr
  0 siblings, 1 reply; 4+ messages in thread
From: Nico Boehr @ 2022-11-07 12:12 UTC (permalink / raw)
  To: borntraeger, frankja, imbrenda; +Cc: kvm, linux-s390

v1->v2:
---
* rename addr to vaddr (thanks Christian)

Nico Boehr (1):
  s390/mm: fix virtual-physical address confusion for swiotlb

 arch/s390/include/asm/mem_encrypt.h |  4 ++--
 arch/s390/mm/init.c                 | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.37.3


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

* [PATCH v2 1/1] s390/mm: fix virtual-physical address confusion for swiotlb
  2022-11-07 12:12 [PATCH v2 0/1] s390/mm: fix virtual-physical address confusion for swiotlb Nico Boehr
@ 2022-11-07 12:12 ` Nico Boehr
  2022-11-07 12:13   ` Christian Borntraeger
  2022-11-07 12:29   ` Claudio Imbrenda
  0 siblings, 2 replies; 4+ messages in thread
From: Nico Boehr @ 2022-11-07 12:12 UTC (permalink / raw)
  To: borntraeger, frankja, imbrenda; +Cc: kvm, linux-s390

swiotlb passes virtual addresses to set_memory_encrypted() and
set_memory_decrypted(), but uv_remove_shared() and uv_set_shared()
expect physical addresses. This currently works, because virtual
and physical addresses are the same.

Add virt_to_phys() to resolve the virtual-physical confusion.

Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 arch/s390/include/asm/mem_encrypt.h |  4 ++--
 arch/s390/mm/init.c                 | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/s390/include/asm/mem_encrypt.h b/arch/s390/include/asm/mem_encrypt.h
index 08a8b96606d7..b85e13505a0f 100644
--- a/arch/s390/include/asm/mem_encrypt.h
+++ b/arch/s390/include/asm/mem_encrypt.h
@@ -4,8 +4,8 @@
 
 #ifndef __ASSEMBLY__
 
-int set_memory_encrypted(unsigned long addr, int numpages);
-int set_memory_decrypted(unsigned long addr, int numpages);
+int set_memory_encrypted(unsigned long vaddr, int numpages);
+int set_memory_decrypted(unsigned long vaddr, int numpages);
 
 #endif	/* __ASSEMBLY__ */
 
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index 97d66a3e60fb..d509656c67d7 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -140,25 +140,25 @@ void mark_rodata_ro(void)
 	debug_checkwx();
 }
 
-int set_memory_encrypted(unsigned long addr, int numpages)
+int set_memory_encrypted(unsigned long vaddr, int numpages)
 {
 	int i;
 
 	/* make specified pages unshared, (swiotlb, dma_free) */
 	for (i = 0; i < numpages; ++i) {
-		uv_remove_shared(addr);
-		addr += PAGE_SIZE;
+		uv_remove_shared(virt_to_phys((void *)vaddr));
+		vaddr += PAGE_SIZE;
 	}
 	return 0;
 }
 
-int set_memory_decrypted(unsigned long addr, int numpages)
+int set_memory_decrypted(unsigned long vaddr, int numpages)
 {
 	int i;
 	/* make specified pages shared (swiotlb, dma_alloca) */
 	for (i = 0; i < numpages; ++i) {
-		uv_set_shared(addr);
-		addr += PAGE_SIZE;
+		uv_set_shared(virt_to_phys((void *)vaddr));
+		vaddr += PAGE_SIZE;
 	}
 	return 0;
 }
-- 
2.37.3


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

* Re: [PATCH v2 1/1] s390/mm: fix virtual-physical address confusion for swiotlb
  2022-11-07 12:12 ` [PATCH v2 1/1] " Nico Boehr
@ 2022-11-07 12:13   ` Christian Borntraeger
  2022-11-07 12:29   ` Claudio Imbrenda
  1 sibling, 0 replies; 4+ messages in thread
From: Christian Borntraeger @ 2022-11-07 12:13 UTC (permalink / raw)
  To: Nico Boehr, frankja, imbrenda; +Cc: kvm, linux-s390



Am 07.11.22 um 13:12 schrieb Nico Boehr:
> swiotlb passes virtual addresses to set_memory_encrypted() and
> set_memory_decrypted(), but uv_remove_shared() and uv_set_shared()
> expect physical addresses. This currently works, because virtual
> and physical addresses are the same.
> 
> Add virt_to_phys() to resolve the virtual-physical confusion.
> 
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>

You can keep my RB:

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>

> ---
>   arch/s390/include/asm/mem_encrypt.h |  4 ++--
>   arch/s390/mm/init.c                 | 12 ++++++------
>   2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/s390/include/asm/mem_encrypt.h b/arch/s390/include/asm/mem_encrypt.h
> index 08a8b96606d7..b85e13505a0f 100644
> --- a/arch/s390/include/asm/mem_encrypt.h
> +++ b/arch/s390/include/asm/mem_encrypt.h
> @@ -4,8 +4,8 @@
>   
>   #ifndef __ASSEMBLY__
>   
> -int set_memory_encrypted(unsigned long addr, int numpages);
> -int set_memory_decrypted(unsigned long addr, int numpages);
> +int set_memory_encrypted(unsigned long vaddr, int numpages);
> +int set_memory_decrypted(unsigned long vaddr, int numpages);
>   
>   #endif	/* __ASSEMBLY__ */
>   
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index 97d66a3e60fb..d509656c67d7 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -140,25 +140,25 @@ void mark_rodata_ro(void)
>   	debug_checkwx();
>   }
>   
> -int set_memory_encrypted(unsigned long addr, int numpages)
> +int set_memory_encrypted(unsigned long vaddr, int numpages)
>   {
>   	int i;
>   
>   	/* make specified pages unshared, (swiotlb, dma_free) */
>   	for (i = 0; i < numpages; ++i) {
> -		uv_remove_shared(addr);
> -		addr += PAGE_SIZE;
> +		uv_remove_shared(virt_to_phys((void *)vaddr));
> +		vaddr += PAGE_SIZE;
>   	}
>   	return 0;
>   }
>   
> -int set_memory_decrypted(unsigned long addr, int numpages)
> +int set_memory_decrypted(unsigned long vaddr, int numpages)
>   {
>   	int i;
>   	/* make specified pages shared (swiotlb, dma_alloca) */
>   	for (i = 0; i < numpages; ++i) {
> -		uv_set_shared(addr);
> -		addr += PAGE_SIZE;
> +		uv_set_shared(virt_to_phys((void *)vaddr));
> +		vaddr += PAGE_SIZE;
>   	}
>   	return 0;
>   }

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

* Re: [PATCH v2 1/1] s390/mm: fix virtual-physical address confusion for swiotlb
  2022-11-07 12:12 ` [PATCH v2 1/1] " Nico Boehr
  2022-11-07 12:13   ` Christian Borntraeger
@ 2022-11-07 12:29   ` Claudio Imbrenda
  1 sibling, 0 replies; 4+ messages in thread
From: Claudio Imbrenda @ 2022-11-07 12:29 UTC (permalink / raw)
  To: Nico Boehr; +Cc: borntraeger, frankja, kvm, linux-s390

On Mon,  7 Nov 2022 13:12:21 +0100
Nico Boehr <nrb@linux.ibm.com> wrote:

> swiotlb passes virtual addresses to set_memory_encrypted() and
> set_memory_decrypted(), but uv_remove_shared() and uv_set_shared()
> expect physical addresses. This currently works, because virtual
> and physical addresses are the same.
> 
> Add virt_to_phys() to resolve the virtual-physical confusion.
> 
> Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  arch/s390/include/asm/mem_encrypt.h |  4 ++--
>  arch/s390/mm/init.c                 | 12 ++++++------
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/s390/include/asm/mem_encrypt.h b/arch/s390/include/asm/mem_encrypt.h
> index 08a8b96606d7..b85e13505a0f 100644
> --- a/arch/s390/include/asm/mem_encrypt.h
> +++ b/arch/s390/include/asm/mem_encrypt.h
> @@ -4,8 +4,8 @@
>  
>  #ifndef __ASSEMBLY__
>  
> -int set_memory_encrypted(unsigned long addr, int numpages);
> -int set_memory_decrypted(unsigned long addr, int numpages);
> +int set_memory_encrypted(unsigned long vaddr, int numpages);
> +int set_memory_decrypted(unsigned long vaddr, int numpages);
>  
>  #endif	/* __ASSEMBLY__ */
>  
> diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
> index 97d66a3e60fb..d509656c67d7 100644
> --- a/arch/s390/mm/init.c
> +++ b/arch/s390/mm/init.c
> @@ -140,25 +140,25 @@ void mark_rodata_ro(void)
>  	debug_checkwx();
>  }
>  
> -int set_memory_encrypted(unsigned long addr, int numpages)
> +int set_memory_encrypted(unsigned long vaddr, int numpages)
>  {
>  	int i;
>  
>  	/* make specified pages unshared, (swiotlb, dma_free) */
>  	for (i = 0; i < numpages; ++i) {
> -		uv_remove_shared(addr);
> -		addr += PAGE_SIZE;
> +		uv_remove_shared(virt_to_phys((void *)vaddr));
> +		vaddr += PAGE_SIZE;
>  	}
>  	return 0;
>  }
>  
> -int set_memory_decrypted(unsigned long addr, int numpages)
> +int set_memory_decrypted(unsigned long vaddr, int numpages)
>  {
>  	int i;
>  	/* make specified pages shared (swiotlb, dma_alloca) */
>  	for (i = 0; i < numpages; ++i) {
> -		uv_set_shared(addr);
> -		addr += PAGE_SIZE;
> +		uv_set_shared(virt_to_phys((void *)vaddr));
> +		vaddr += PAGE_SIZE;
>  	}
>  	return 0;
>  }


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

end of thread, other threads:[~2022-11-07 12:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07 12:12 [PATCH v2 0/1] s390/mm: fix virtual-physical address confusion for swiotlb Nico Boehr
2022-11-07 12:12 ` [PATCH v2 1/1] " Nico Boehr
2022-11-07 12:13   ` Christian Borntraeger
2022-11-07 12:29   ` Claudio Imbrenda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox