public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
       [not found]         ` <[email protected]>
@ 2023-08-07 18:04           ` Helge Deller
  2023-08-07 18:24             ` Jens Axboe
  2023-08-07 18:34             ` Jens Axboe
  0 siblings, 2 replies; 8+ messages in thread
From: Helge Deller @ 2023-08-07 18:04 UTC (permalink / raw)
  To: Christoph Biedl, linux-parisc, io-uring
  Cc: Jens Axboe, Mike Rapoport, Vlastimil Babka

The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
using architecture-provided get_unmapped_area()") to the parisc
implementation of get_unmapped_area() broke glibc's locale-gen
executable when running on parisc.

This patch reverts those architecture-specific changes, and instead
adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
then given to parisc's get_unmapped_area() function.  This is much
cleaner than the previous approach, and we still will get a coherent
addresss.

This patch has no effect on other architectures (SHM_COLOUR is only
defined on parisc), and the liburing testcase stil passes on parisc.

Signed-off-by: Helge Deller <[email protected]>
Reported-by: Christoph Biedl <[email protected]>
Fixes: 32832a407a71 ("io_uring: Fix io_uring mmap() by using architecture-provided get_unmapped_area()")
Fixes: d808459b2e31 ("io_uring: Adjust mapping wrt architecture aliasing requirements")

diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index ca2d537e25b1..9915062d5243 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -27,17 +27,12 @@
 #include <linux/elf-randomize.h>

 /*
- * Construct an artificial page offset for the mapping based on the virtual
+ * Construct an artificial page offset for the mapping based on the physical
  * address of the kernel file mapping variable.
- * If filp is zero the calculated pgoff value aliases the memory of the given
- * address. This is useful for io_uring where the mapping shall alias a kernel
- * address and a userspace adress where both the kernel and the userspace
- * access the same memory region.
  */
-#define GET_FILP_PGOFF(filp, addr)		\
-	((filp ? (((unsigned long) filp->f_mapping) >> 8)	\
-		 & ((SHM_COLOUR-1) >> PAGE_SHIFT) : 0UL)	\
-	  + (addr >> PAGE_SHIFT))
+#define GET_FILP_PGOFF(filp)		\
+	(filp ? (((unsigned long) filp->f_mapping) >> 8)	\
+		 & ((SHM_COLOUR-1) >> PAGE_SHIFT) : 0UL)

 static unsigned long shared_align_offset(unsigned long filp_pgoff,
 					 unsigned long pgoff)
@@ -117,7 +112,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
 	do_color_align = 0;
 	if (filp || (flags & MAP_SHARED))
 		do_color_align = 1;
-	filp_pgoff = GET_FILP_PGOFF(filp, addr);
+	filp_pgoff = GET_FILP_PGOFF(filp);

 	if (flags & MAP_FIXED) {
 		/* Even MAP_FIXED mappings must reside within TASK_SIZE */
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index f4591b912ea8..93db3e4e7b68 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3470,6 +3470,8 @@ static unsigned long io_uring_mmu_get_unmapped_area(struct file *filp,
 	 * - use the kernel virtual address of the shared io_uring context
 	 *   (instead of the userspace-provided address, which has to be 0UL
 	 *   anyway).
+	 * - use the same pgoff which the get_unmapped_area() uses to
+	 *   calculate the page colouring.
 	 * For architectures without such aliasing requirements, the
 	 * architecture will return any suitable mapping because addr is 0.
 	 */
@@ -3478,6 +3480,7 @@ static unsigned long io_uring_mmu_get_unmapped_area(struct file *filp,
 	pgoff = 0;	/* has been translated to ptr above */
 #ifdef SHM_COLOUR
 	addr = (uintptr_t) ptr;
+	pgoff = addr >> PAGE_SHIFT;
 #else
 	addr = 0UL;
 #endif

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

* Re: [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
  2023-08-07 18:04           ` [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc Helge Deller
@ 2023-08-07 18:24             ` Jens Axboe
  2023-08-07 18:27               ` Helge Deller
  2023-08-07 18:34             ` Jens Axboe
  1 sibling, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2023-08-07 18:24 UTC (permalink / raw)
  To: Helge Deller, Christoph Biedl, linux-parisc, io-uring
  Cc: Mike Rapoport, Vlastimil Babka

On 8/7/23 12:04?PM, Helge Deller wrote:
> The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
> using architecture-provided get_unmapped_area()") to the parisc
> implementation of get_unmapped_area() broke glibc's locale-gen
> executable when running on parisc.
> 
> This patch reverts those architecture-specific changes, and instead
> adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
> then given to parisc's get_unmapped_area() function.  This is much
> cleaner than the previous approach, and we still will get a coherent
> addresss.
> 
> This patch has no effect on other architectures (SHM_COLOUR is only
> defined on parisc), and the liburing testcase stil passes on parisc.

What branch is this against? It doesn't apply to my 6.5 io_uring branch,
which is odd as that's where the previous commits went through.

-- 
Jens Axboe


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

* Re: [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
  2023-08-07 18:24             ` Jens Axboe
@ 2023-08-07 18:27               ` Helge Deller
  2023-08-07 18:33                 ` Jens Axboe
  0 siblings, 1 reply; 8+ messages in thread
From: Helge Deller @ 2023-08-07 18:27 UTC (permalink / raw)
  To: Jens Axboe, Christoph Biedl, linux-parisc, io-uring
  Cc: Mike Rapoport, Vlastimil Babka

On 8/7/23 20:24, Jens Axboe wrote:
> On 8/7/23 12:04?PM, Helge Deller wrote:
>> The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
>> using architecture-provided get_unmapped_area()") to the parisc
>> implementation of get_unmapped_area() broke glibc's locale-gen
>> executable when running on parisc.
>>
>> This patch reverts those architecture-specific changes, and instead
>> adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
>> then given to parisc's get_unmapped_area() function.  This is much
>> cleaner than the previous approach, and we still will get a coherent
>> addresss.
>>
>> This patch has no effect on other architectures (SHM_COLOUR is only
>> defined on parisc), and the liburing testcase stil passes on parisc.
>
> What branch is this against? It doesn't apply to my 6.5 io_uring branch,
> which is odd as that's where the previous commits went through.

applies for me on git head / Linux 6.5-rc5

Helge

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

* Re: [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
  2023-08-07 18:27               ` Helge Deller
@ 2023-08-07 18:33                 ` Jens Axboe
  2023-08-07 19:30                   ` Helge Deller
  0 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2023-08-07 18:33 UTC (permalink / raw)
  To: Helge Deller, Christoph Biedl, linux-parisc, io-uring
  Cc: Mike Rapoport, Vlastimil Babka

On 8/7/23 12:27?PM, Helge Deller wrote:
> On 8/7/23 20:24, Jens Axboe wrote:
>> On 8/7/23 12:04?PM, Helge Deller wrote:
>>> The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
>>> using architecture-provided get_unmapped_area()") to the parisc
>>> implementation of get_unmapped_area() broke glibc's locale-gen
>>> executable when running on parisc.
>>>
>>> This patch reverts those architecture-specific changes, and instead
>>> adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
>>> then given to parisc's get_unmapped_area() function.  This is much
>>> cleaner than the previous approach, and we still will get a coherent
>>> addresss.
>>>
>>> This patch has no effect on other architectures (SHM_COLOUR is only
>>> defined on parisc), and the liburing testcase stil passes on parisc.
>>
>> What branch is this against? It doesn't apply to my 6.5 io_uring branch,
>> which is odd as that's where the previous commits went through.
> 
> applies for me on git head / Linux 6.5-rc5

Hmm, maybe something unrelated then. I'll take a look. The patch is
garbled fwiw, but that's nothing new. If you download the raw one from
lore you can see how.

-- 
Jens Axboe


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

* Re: [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
  2023-08-07 18:04           ` [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc Helge Deller
  2023-08-07 18:24             ` Jens Axboe
@ 2023-08-07 18:34             ` Jens Axboe
  2023-08-07 19:33               ` Helge Deller
  1 sibling, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2023-08-07 18:34 UTC (permalink / raw)
  To: Christoph Biedl, linux-parisc, io-uring, Helge Deller
  Cc: Mike Rapoport, Vlastimil Babka


On Mon, 07 Aug 2023 20:04:09 +0200, Helge Deller wrote:
> The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
> using architecture-provided get_unmapped_area()") to the parisc
> implementation of get_unmapped_area() broke glibc's locale-gen
> executable when running on parisc.
> 
> This patch reverts those architecture-specific changes, and instead
> adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
> then given to parisc's get_unmapped_area() function.  This is much
> cleaner than the previous approach, and we still will get a coherent
> addresss.
> 
> [...]

Applied, thanks!

[1/1] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
      commit: ce11a0688e67aae1e9ba6c8843d7e8b7dd791ead

Best regards,
-- 
Jens Axboe




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

* Re: [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
  2023-08-07 18:33                 ` Jens Axboe
@ 2023-08-07 19:30                   ` Helge Deller
  0 siblings, 0 replies; 8+ messages in thread
From: Helge Deller @ 2023-08-07 19:30 UTC (permalink / raw)
  To: Jens Axboe, Christoph Biedl, linux-parisc, io-uring
  Cc: Mike Rapoport, Vlastimil Babka

On 8/7/23 20:33, Jens Axboe wrote:
> On 8/7/23 12:27?PM, Helge Deller wrote:
>> On 8/7/23 20:24, Jens Axboe wrote:
>>> On 8/7/23 12:04?PM, Helge Deller wrote:
>>>> The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
>>>> using architecture-provided get_unmapped_area()") to the parisc
>>>> implementation of get_unmapped_area() broke glibc's locale-gen
>>>> executable when running on parisc.
>>>>
>>>> This patch reverts those architecture-specific changes, and instead
>>>> adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
>>>> then given to parisc's get_unmapped_area() function.  This is much
>>>> cleaner than the previous approach, and we still will get a coherent
>>>> addresss.
>>>>
>>>> This patch has no effect on other architectures (SHM_COLOUR is only
>>>> defined on parisc), and the liburing testcase stil passes on parisc.
>>>
>>> What branch is this against? It doesn't apply to my 6.5 io_uring branch,
>>> which is odd as that's where the previous commits went through.
>>
>> applies for me on git head / Linux 6.5-rc5
>
> Hmm, maybe something unrelated then. I'll take a look. The patch is
> garbled fwiw, but that's nothing new. If you download the raw one from
> lore you can see how.

That's strange. I usually send to the mailing list, and then apply
from patchwork, in this case from here:
https://patchwork.kernel.org/project/linux-parisc/patch/ZNEyGV0jyI8kOOfz@p100/
That worked for me.

Helge

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

* Re: [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
  2023-08-07 18:34             ` Jens Axboe
@ 2023-08-07 19:33               ` Helge Deller
  2023-08-07 19:55                 ` Jens Axboe
  0 siblings, 1 reply; 8+ messages in thread
From: Helge Deller @ 2023-08-07 19:33 UTC (permalink / raw)
  To: Jens Axboe, Christoph Biedl, linux-parisc, io-uring
  Cc: Mike Rapoport, Vlastimil Babka

On 8/7/23 20:34, Jens Axboe wrote:
>
> On Mon, 07 Aug 2023 20:04:09 +0200, Helge Deller wrote:
>> The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
>> using architecture-provided get_unmapped_area()") to the parisc
>> implementation of get_unmapped_area() broke glibc's locale-gen
>> executable when running on parisc.
>>
>> This patch reverts those architecture-specific changes, and instead
>> adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
>> then given to parisc's get_unmapped_area() function.  This is much
>> cleaner than the previous approach, and we still will get a coherent
>> addresss.
>>
>> [...]
>
> Applied, thanks!

That was fast :-)
Actually I had hoped for some more testing from Christoph and other
parisc guys first.
Anyway, since you have a parisc machine in your test ring, you will
notice if something breaks,

What's important:
Please add to the patch:
Cc: [email protected] # 6.4

Thank you!
Helge

> [1/1] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
>        commit: ce11a0688e67aae1e9ba6c8843d7e8b7dd791ead


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

* Re: [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc
  2023-08-07 19:33               ` Helge Deller
@ 2023-08-07 19:55                 ` Jens Axboe
  0 siblings, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2023-08-07 19:55 UTC (permalink / raw)
  To: Helge Deller
  Cc: Christoph Biedl, linux-parisc, io-uring, Mike Rapoport,
	Vlastimil Babka

On Aug 7, 2023, at 12:33 PM, Helge Deller <[email protected]> wrote:
> 
> On 8/7/23 20:34, Jens Axboe wrote:
>> 
>>> On Mon, 07 Aug 2023 20:04:09 +0200, Helge Deller wrote:
>>> The changes from commit 32832a407a71 ("io_uring: Fix io_uring mmap() by
>>> using architecture-provided get_unmapped_area()") to the parisc
>>> implementation of get_unmapped_area() broke glibc's locale-gen
>>> executable when running on parisc.
>>> 
>>> This patch reverts those architecture-specific changes, and instead
>>> adjusts in io_uring_mmu_get_unmapped_area() the pgoff offset which is
>>> then given to parisc's get_unmapped_area() function.  This is much
>>> cleaner than the previous approach, and we still will get a coherent
>>> addresss.
>>> 
>>> [...]
>> 
>> Applied, thanks!
> 
> That was fast :-)
> Actually I had hoped for some more testing from Christoph and other
> parisc guys first.
> Anyway, since you have a parisc machine in your test ring, you will
> notice if something breaks,
> 
> What's important:
> Please add to the patch:
> Cc: [email protected] # 6.4

It’s not going upstream just yet, just easiser to apply for testing on my end. I will test it locally too.

— 
Jens Axboe


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

end of thread, other threads:[~2023-08-07 19:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <[email protected]>
     [not found] ` <[email protected]>
     [not found]   ` <[email protected]>
     [not found]     ` <[email protected]>
     [not found]       ` <[email protected]>
     [not found]         ` <[email protected]>
2023-08-07 18:04           ` [PATCH] io_uring/parisc: Adjust pgoff in io_uring mmap() for parisc Helge Deller
2023-08-07 18:24             ` Jens Axboe
2023-08-07 18:27               ` Helge Deller
2023-08-07 18:33                 ` Jens Axboe
2023-08-07 19:30                   ` Helge Deller
2023-08-07 18:34             ` Jens Axboe
2023-08-07 19:33               ` Helge Deller
2023-08-07 19:55                 ` Jens Axboe

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