* Re: [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page()
[not found] ` <Y8ohpDtqI8bPAgRn@ZenIV>
@ 2023-01-20 5:56 ` Al Viro
2023-01-20 7:17 ` Helge Deller
2023-01-23 17:14 ` Fabio M. De Francesco
0 siblings, 2 replies; 7+ messages in thread
From: Al Viro @ 2023-01-20 5:56 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Fabio M. De Francesco, Christoph Hellwig, linux-kernel,
linux-fsdevel, Ira Weiny, linux-parisc
On Fri, Jan 20, 2023 at 05:07:48AM +0000, Al Viro wrote:
> On Fri, Jan 20, 2023 at 04:54:51AM +0000, Matthew Wilcox wrote:
>
> > > Sure, but... there's also this:
> > >
> > > static inline void __kunmap_local(const void *addr)
> > > {
> > > #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> > > kunmap_flush_on_unmap(addr);
> > > #endif
> > > }
> > >
> > > Are you sure that the guts of that thing will be happy with address that is not
> > > page-aligned? I've looked there at some point, got scared of parisc (IIRC)
> > > MMU details and decided not to rely upon that...
> >
> > Ugh, PA-RISC (the only implementor) definitely will flush the wrong
> > addresses. I think we should do this, as having bugs that only manifest
> > on one not-well-tested architecture seems Bad.
> >
> > static inline void __kunmap_local(const void *addr)
> > {
> > #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> > - kunmap_flush_on_unmap(addr);
> > + kunmap_flush_on_unmap(PAGE_ALIGN_DOWN(addr));
> > #endif
> > }
>
> PTR_ALIGN_DOWN(addr, PAGE_SIZE), perhaps?
Anyway, that's a question to parisc folks; I _think_ pdtlb
quietly ignores the lower bits of address, so that part seems
to be safe, but I wouldn't bet upon that. And when I got to
flush_kernel_dcache_page_asm I gave up - it's been a long time
since I've dealt with parisc assembler.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page()
2023-01-20 5:56 ` [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page() Al Viro
@ 2023-01-20 7:17 ` Helge Deller
2023-01-21 8:05 ` Ira Weiny
2023-01-23 17:14 ` Fabio M. De Francesco
1 sibling, 1 reply; 7+ messages in thread
From: Helge Deller @ 2023-01-20 7:17 UTC (permalink / raw)
To: Al Viro, Matthew Wilcox
Cc: Fabio M. De Francesco, Christoph Hellwig, linux-kernel,
linux-fsdevel, Ira Weiny, linux-parisc
On 1/20/23 06:56, Al Viro wrote:
> On Fri, Jan 20, 2023 at 05:07:48AM +0000, Al Viro wrote:
>> On Fri, Jan 20, 2023 at 04:54:51AM +0000, Matthew Wilcox wrote:
>>
>>>> Sure, but... there's also this:
>>>>
>>>> static inline void __kunmap_local(const void *addr)
>>>> {
>>>> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
>>>> kunmap_flush_on_unmap(addr);
>>>> #endif
>>>> }
>>>>
>>>> Are you sure that the guts of that thing will be happy with address that is not
>>>> page-aligned? I've looked there at some point, got scared of parisc (IIRC)
>>>> MMU details and decided not to rely upon that...
>>>
>>> Ugh, PA-RISC (the only implementor) definitely will flush the wrong
>>> addresses. I think we should do this, as having bugs that only manifest
>>> on one not-well-tested architecture seems Bad.
>>>
>>> static inline void __kunmap_local(const void *addr)
>>> {
>>> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
>>> - kunmap_flush_on_unmap(addr);
>>> + kunmap_flush_on_unmap(PAGE_ALIGN_DOWN(addr));
>>> #endif
>>> }
>>
>> PTR_ALIGN_DOWN(addr, PAGE_SIZE), perhaps?
>
> Anyway, that's a question to parisc folks; I _think_ pdtlb
> quietly ignores the lower bits of address, so that part seems
> to be safe, but I wouldn't bet upon that.
No, on PA2.0 (64bit) CPUs the lower bits of the address of pdtlb
encodes the amount of memory (page size) to be flushed, see:
http://ftp.parisc-linux.org/docs/arch/parisc2.0.pdf (page 7-106)
So, the proposed page alignment with e.g. PTR_ALIGN_DON() is needed.
Helge
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page()
2023-01-20 7:17 ` Helge Deller
@ 2023-01-21 8:05 ` Ira Weiny
2023-01-21 10:57 ` Helge Deller
2023-01-21 19:26 ` Al Viro
0 siblings, 2 replies; 7+ messages in thread
From: Ira Weiny @ 2023-01-21 8:05 UTC (permalink / raw)
To: Helge Deller, Al Viro, Matthew Wilcox
Cc: Fabio M. De Francesco, Christoph Hellwig, linux-kernel,
linux-fsdevel, Ira Weiny, linux-parisc
Helge Deller wrote:
> On 1/20/23 06:56, Al Viro wrote:
> > On Fri, Jan 20, 2023 at 05:07:48AM +0000, Al Viro wrote:
> >> On Fri, Jan 20, 2023 at 04:54:51AM +0000, Matthew Wilcox wrote:
> >>
> >>>> Sure, but... there's also this:
> >>>>
> >>>> static inline void __kunmap_local(const void *addr)
> >>>> {
> >>>> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> >>>> kunmap_flush_on_unmap(addr);
> >>>> #endif
> >>>> }
> >>>>
> >>>> Are you sure that the guts of that thing will be happy with address that is not
> >>>> page-aligned? I've looked there at some point, got scared of parisc (IIRC)
> >>>> MMU details and decided not to rely upon that...
> >>>
> >>> Ugh, PA-RISC (the only implementor) definitely will flush the wrong
> >>> addresses. I think we should do this, as having bugs that only manifest
> >>> on one not-well-tested architecture seems Bad.
> >>>
> >>> static inline void __kunmap_local(const void *addr)
> >>> {
> >>> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> >>> - kunmap_flush_on_unmap(addr);
> >>> + kunmap_flush_on_unmap(PAGE_ALIGN_DOWN(addr));
> >>> #endif
> >>> }
> >>
> >> PTR_ALIGN_DOWN(addr, PAGE_SIZE), perhaps?
> >
> > Anyway, that's a question to parisc folks; I _think_ pdtlb
> > quietly ignores the lower bits of address, so that part seems
> > to be safe, but I wouldn't bet upon that.
>
> No, on PA2.0 (64bit) CPUs the lower bits of the address of pdtlb
> encodes the amount of memory (page size) to be flushed, see:
> http://ftp.parisc-linux.org/docs/arch/parisc2.0.pdf (page 7-106)
> So, the proposed page alignment with e.g. PTR_ALIGN_DON() is needed.
>
> Helge
I'm not sure I completely understand.
First, arn't PAGE_ALIGN_DOWN(addr) and PTR_ALIGN_DOWN(addr, PAGE_SIZE) the
same?
align.h
#define PTR_ALIGN_DOWN(p, a) ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
mm.h:
#define PAGE_ALIGN_DOWN(addr) ALIGN_DOWN(addr, PAGE_SIZE)
Did parisc redefine it somewhere I'm not seeing?
Second, if the lower bits encode the amount of memory to be flushed is it
required to return the original value returned from page_address()?
Ira
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page()
2023-01-21 8:05 ` Ira Weiny
@ 2023-01-21 10:57 ` Helge Deller
2023-01-21 19:26 ` Al Viro
1 sibling, 0 replies; 7+ messages in thread
From: Helge Deller @ 2023-01-21 10:57 UTC (permalink / raw)
To: Ira Weiny, Al Viro, Matthew Wilcox
Cc: Fabio M. De Francesco, Christoph Hellwig, linux-kernel,
linux-fsdevel, linux-parisc
On 1/21/23 09:05, Ira Weiny wrote:
> Helge Deller wrote:
>> On 1/20/23 06:56, Al Viro wrote:
>>> On Fri, Jan 20, 2023 at 05:07:48AM +0000, Al Viro wrote:
>>>> On Fri, Jan 20, 2023 at 04:54:51AM +0000, Matthew Wilcox wrote:
>>>>
>>>>>> Sure, but... there's also this:
>>>>>>
>>>>>> static inline void __kunmap_local(const void *addr)
>>>>>> {
>>>>>> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
>>>>>> kunmap_flush_on_unmap(addr);
>>>>>> #endif
>>>>>> }
>>>>>>
>>>>>> Are you sure that the guts of that thing will be happy with address that is not
>>>>>> page-aligned? I've looked there at some point, got scared of parisc (IIRC)
>>>>>> MMU details and decided not to rely upon that...
>>>>>
>>>>> Ugh, PA-RISC (the only implementor) definitely will flush the wrong
>>>>> addresses. I think we should do this, as having bugs that only manifest
>>>>> on one not-well-tested architecture seems Bad.
>>>>>
>>>>> static inline void __kunmap_local(const void *addr)
>>>>> {
>>>>> #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
>>>>> - kunmap_flush_on_unmap(addr);
>>>>> + kunmap_flush_on_unmap(PAGE_ALIGN_DOWN(addr));
>>>>> #endif
>>>>> }
>>>>
>>>> PTR_ALIGN_DOWN(addr, PAGE_SIZE), perhaps?
>>>
>>> Anyway, that's a question to parisc folks; I _think_ pdtlb
>>> quietly ignores the lower bits of address, so that part seems
>>> to be safe, but I wouldn't bet upon that.
>>
>> No, on PA2.0 (64bit) CPUs the lower bits of the address of pdtlb
>> encodes the amount of memory (page size) to be flushed, see:
>> http://ftp.parisc-linux.org/docs/arch/parisc2.0.pdf (page 7-106)
>> So, the proposed page alignment with e.g. PTR_ALIGN_DON() is needed.
>>
>
> I'm not sure I completely understand.
>
> First, arn't PAGE_ALIGN_DOWN(addr) and PTR_ALIGN_DOWN(addr, PAGE_SIZE) the
> same?
Yes, they are.
> align.h
> #define PTR_ALIGN_DOWN(p, a) ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
>
> mm.h:
> #define PAGE_ALIGN_DOWN(addr) ALIGN_DOWN(addr, PAGE_SIZE)
>
> Did parisc redefine it somewhere I'm not seeing?
No, there is nothing special in this regard on parisc.
> Second, if the lower bits encode the amount of memory to be flushed is it
> required to return the original value returned from page_address()?
No.
If the lower bits are zero, then the default page size (4k) is used for the tlb purge.
So, if you simply strip the lower bits (by using PAGE_ALIGN_DOWN() or ALIGN_DOWN())
you are fine.
Helge
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page()
2023-01-21 8:05 ` Ira Weiny
2023-01-21 10:57 ` Helge Deller
@ 2023-01-21 19:26 ` Al Viro
1 sibling, 0 replies; 7+ messages in thread
From: Al Viro @ 2023-01-21 19:26 UTC (permalink / raw)
To: Ira Weiny
Cc: Helge Deller, Matthew Wilcox, Fabio M. De Francesco,
Christoph Hellwig, linux-kernel, linux-fsdevel, linux-parisc
On Sat, Jan 21, 2023 at 12:05:58AM -0800, Ira Weiny wrote:
> First, arn't PAGE_ALIGN_DOWN(addr) and PTR_ALIGN_DOWN(addr, PAGE_SIZE) the
> same?
>
> align.h
> #define PTR_ALIGN_DOWN(p, a) ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
>
> mm.h:
> #define PAGE_ALIGN_DOWN(addr) ALIGN_DOWN(addr, PAGE_SIZE)
... and ALIGN_DOWN ends up with doing bitwise and on the first argument.
Which doesn't work for pointers, thus the separate variant for those
and typecast to unsigned long in it...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page()
2023-01-20 5:56 ` [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page() Al Viro
2023-01-20 7:17 ` Helge Deller
@ 2023-01-23 17:14 ` Fabio M. De Francesco
2023-01-24 20:16 ` Ira Weiny
1 sibling, 1 reply; 7+ messages in thread
From: Fabio M. De Francesco @ 2023-01-23 17:14 UTC (permalink / raw)
To: Matthew Wilcox, Al Viro
Cc: Christoph Hellwig, linux-kernel, linux-fsdevel, Ira Weiny,
linux-parisc
On venerdì 20 gennaio 2023 06:56:01 CET Al Viro wrote:
> On Fri, Jan 20, 2023 at 05:07:48AM +0000, Al Viro wrote:
> > On Fri, Jan 20, 2023 at 04:54:51AM +0000, Matthew Wilcox wrote:
> > > > Sure, but... there's also this:
> > > >
> > > > static inline void __kunmap_local(const void *addr)
> > > > {
> > > > #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> > > >
> > > > kunmap_flush_on_unmap(addr);
> > > >
> > > > #endif
> > > > }
> > > >
> > > > Are you sure that the guts of that thing will be happy with address
that
> > > > is not page-aligned? I've looked there at some point, got scared of
> > > > parisc (IIRC) MMU details and decided not to rely upon that...
> > >
> > > Ugh, PA-RISC (the only implementer) definitely will flush the wrong
> > > addresses. I think we should do this, as having bugs that only manifest
> > > on one not-well-tested architecture seems Bad.
> > >
> > > static inline void __kunmap_local(const void *addr)
> > > {
> > > #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> > >
> > > - kunmap_flush_on_unmap(addr);
> > > + kunmap_flush_on_unmap(PAGE_ALIGN_DOWN(addr));
> > >
> > > #endif
> > > }
> >
> > PTR_ALIGN_DOWN(addr, PAGE_SIZE), perhaps?
>
> Anyway, that's a question to parisc folks; I _think_ pdtlb
> quietly ignores the lower bits of address, so that part seems
> to be safe, but I wouldn't bet upon that. And when I got to
> flush_kernel_dcache_page_asm I gave up - it's been a long time
> since I've dealt with parisc assembler.
There seems to be consensus that __kunmap_local() needs to be fixed for the
parisc case (ARCH_HAS_FLUSH_ON_KUNMAP).
Is anyone doing this task?
If you agree, I could make this change and give proper credits for the tip.
Thank you,
Fabio
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page()
2023-01-23 17:14 ` Fabio M. De Francesco
@ 2023-01-24 20:16 ` Ira Weiny
0 siblings, 0 replies; 7+ messages in thread
From: Ira Weiny @ 2023-01-24 20:16 UTC (permalink / raw)
To: Fabio M. De Francesco, Matthew Wilcox, Al Viro
Cc: Christoph Hellwig, linux-kernel, linux-fsdevel, Ira Weiny,
linux-parisc
Fabio M. De Francesco wrote:
> On venerdì 20 gennaio 2023 06:56:01 CET Al Viro wrote:
> > On Fri, Jan 20, 2023 at 05:07:48AM +0000, Al Viro wrote:
> > > On Fri, Jan 20, 2023 at 04:54:51AM +0000, Matthew Wilcox wrote:
> > > > > Sure, but... there's also this:
> > > > >
> > > > > static inline void __kunmap_local(const void *addr)
> > > > > {
> > > > > #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> > > > >
> > > > > kunmap_flush_on_unmap(addr);
> > > > >
> > > > > #endif
> > > > > }
> > > > >
> > > > > Are you sure that the guts of that thing will be happy with address
> that
> > > > > is not page-aligned? I've looked there at some point, got scared of
> > > > > parisc (IIRC) MMU details and decided not to rely upon that...
> > > >
> > > > Ugh, PA-RISC (the only implementer) definitely will flush the wrong
> > > > addresses. I think we should do this, as having bugs that only manifest
> > > > on one not-well-tested architecture seems Bad.
> > > >
> > > > static inline void __kunmap_local(const void *addr)
> > > > {
> > > > #ifdef ARCH_HAS_FLUSH_ON_KUNMAP
> > > >
> > > > - kunmap_flush_on_unmap(addr);
> > > > + kunmap_flush_on_unmap(PAGE_ALIGN_DOWN(addr));
> > > >
> > > > #endif
> > > > }
> > >
> > > PTR_ALIGN_DOWN(addr, PAGE_SIZE), perhaps?
> >
> > Anyway, that's a question to parisc folks; I _think_ pdtlb
> > quietly ignores the lower bits of address, so that part seems
> > to be safe, but I wouldn't bet upon that. And when I got to
> > flush_kernel_dcache_page_asm I gave up - it's been a long time
> > since I've dealt with parisc assembler.
>
> There seems to be consensus that __kunmap_local() needs to be fixed for the
> parisc case (ARCH_HAS_FLUSH_ON_KUNMAP).
>
> Is anyone doing this task?
I'm not looking at it.
>
> If you agree, I could make this change and give proper credits for the tip.
I think that would be great.
Thanks!
Ira
>
> Thank you,
>
> Fabio
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-01-24 20:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230119153232.29750-1-fmdefrancesco@gmail.com>
[not found] ` <20230119153232.29750-5-fmdefrancesco@gmail.com>
[not found] ` <Y8oWsiNWSXlDNn5i@ZenIV>
[not found] ` <Y8oYXEjunDDAzSbe@casper.infradead.org>
[not found] ` <Y8ocXbztTPbxu3bq@ZenIV>
[not found] ` <Y8oem+z9SN487MIm@casper.infradead.org>
[not found] ` <Y8ohpDtqI8bPAgRn@ZenIV>
2023-01-20 5:56 ` [PATCH v3 4/4] fs/sysv: Replace kmap() with kmap_local_page() Al Viro
2023-01-20 7:17 ` Helge Deller
2023-01-21 8:05 ` Ira Weiny
2023-01-21 10:57 ` Helge Deller
2023-01-21 19:26 ` Al Viro
2023-01-23 17:14 ` Fabio M. De Francesco
2023-01-24 20:16 ` Ira Weiny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox