PAGE_KERNEL_RO
Subsystems (2)
drivers/firewire/ohci.c now needs PAGE_KERNEL_RO, but many architectures don't implement it. Broke my sparc64 build.
Quoted 2 lines · Andrew Morton
drivers/firewire/ohci.cnow needsPAGE_KERNEL_RO, but many architectures don't implement it. Broke my sparc64 build.
Some architectures actually cannot implement it even... at least some variants of powerpc MMUs don't have a combination of protection bits that allow a kernel-only RO mapping (yeah odd).
Cheers,
Ben.
On Jan 13 Benjamin Herrenschmidt wrote at linux-arch:
Quoted 7 lines · Andrew Morton
Quoted 2 lines
drivers/firewire/ohci.cnow needsPAGE_KERNEL_RO, but many architectures don't implement it. Broke my sparc64 build.Some architectures actually cannot implement it even... at least some variants of powerpc MMUs don't have a combination of protection bits that allow a kernel-only RO mapping (yeah odd).
The simplest perceivable fix, to disable firewire-ohci on architectures which don't have PAGE_KERNEL_RO, would be bad since there are actually sparc64 machines with these controllers.
As far as I can tell, the new RO mapping in firewire-ohci can as well be an r/w mapping. We just never need to write at these virtual addresses. So, should we just change the driver to map it r/w when we can't have PAGE_KERNEL_RO, or for simplicity on all architectures?
Signature · 3 lines
Stefan Richter -=====-==-== ---= -==-= http://arcgraph.de/sr/
Quoted 19 lines · Marc Gauthier
Quoted 9 lines · Stefan Richter
On Jan 13 Benjamin Herrenschmidt wrote at linux-arch:
Quoted 7 lines · Andrew Morton
Quoted 2 lines
drivers/firewire/ohci.cnow needsPAGE_KERNEL_RO, but many architectures don't implement it. Broke my sparc64 build.Some architectures actually cannot implement it even... at least some variants of powerpc MMUs don't have a combination of protection bits that allow a kernel-only RO mapping (yeah odd).
Quoted 8 lines
The simplest perceivable fix, to disable firewire-ohci on architectures which don't have
PAGE_KERNEL_RO, would be bad since there are actually sparc64 machines with these controllers.As far as I can tell, the new RO mapping in firewire-ohci can as well be an r/w mapping. We just never need to write at these virtual addresses. So, should we just change the driver to map it r/w when we can't have
PAGE_KERNEL_RO, or for simplicity on all architectures?
Quoted 7 lines
What do I know... Is a simple:
#ifndef PAGE_KERNEL_RO #define PAGE_KERNEL_RO PAGE_KERNEL #endifin
drivers/firewire/ohci.ctoo hacky?
--8<---------------------------------------------------------------->8--
firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO, e.g. sparc
PAGE_KERNEL_RO is not available on all architectures, so its use in the new AR code broke compilation on sparc64.
Because the R/O mapping is only used to catch drivers that try to write to the reception buffer and not actually required for correct operation, we can just use a normal PAGE_KERNEL mapping where _RO is not available.
Thanks to Stefan Richter and Marc Gauthier <[email protected]> for suggesting this fix.
drivers/firewire/ohci.c +8 -0
@@ -91,6 +91,14 @@ struct descriptor {#define MAX_AR_PACKET_SIZE (16 + MAX_ASYNC_PAYLOAD + 4)#define AR_WRAPAROUND_PAGES DIV_ROUND_UP(MAX_AR_PACKET_SIZE, PAGE_SIZE) +/* +* For archs where PAGE_KERNEL_RO is not supported; +* mapping the AR buffers readonly for the CPU is just a debugging aid. +*/ +#ifndef PAGE_KERNEL_RO +#define PAGE_KERNEL_RO PAGE_KERNEL +#endif +struct ar_context {struct fw_ohci *ohci;struct page *pages[AR_BUFFERS ];
Quoted 46 lines · Clemens Ladisch
Quoted 19 lines · Marc Gauthier
Quoted 9 lines · Stefan Richter
On Jan 13 Benjamin Herrenschmidt wrote at linux-arch:
Quoted 7 lines · Andrew Morton
Quoted 2 lines
drivers/firewire/ohci.cnow needsPAGE_KERNEL_RO, but many architectures don't implement it. Broke my sparc64 build.Some architectures actually cannot implement it even... at least some variants of powerpc MMUs don't have a combination of protection bits that allow a kernel-only RO mapping (yeah odd).
Quoted 8 lines
The simplest perceivable fix, to disable firewire-ohci on architectures which don't have
PAGE_KERNEL_RO, would be bad since there are actually sparc64 machines with these controllers.As far as I can tell, the new RO mapping in firewire-ohci can as well be an r/w mapping. We just never need to write at these virtual addresses. So, should we just change the driver to map it r/w when we can't have
PAGE_KERNEL_RO, or for simplicity on all architectures?Quoted 7 lines
What do I know... Is a simple:
#ifndef PAGE_KERNEL_RO #define PAGE_KERNEL_RO PAGE_KERNEL #endifin
drivers/firewire/ohci.ctoo hacky?--8<---------------------------------------------------------------->8--
firewire: ohci: fix compilation on arches withoutPAGE_KERNEL_RO, e.g. sparc
PAGE_KERNEL_ROis not available on all architectures, so its use in the new AR code broke compilation on sparc64.Because the R/O mapping is only used to catch drivers that try to write to the reception buffer and not actually required for correct operation, we can just use a normal
PAGE_KERNELmapping where_ROis not available.Thanks to Stefan Richter and Marc Gauthier <[email protected]> for suggesting this fix.
Signed-off-by Clemens Ladisch <[email protected]>
drivers/firewire/ohci.c struct descriptor { · line 100
Quoted 10 lines
drivers/firewire/ohci.c +7
-0@@ -91,6 +91,14 @@ struct descriptor {#define MAX_AR_PACKET_SIZE (16 + MAX_ASYNC_PAYLOAD + 4)#define AR_WRAPAROUND_PAGES DIV_ROUND_UP(MAX_AR_PACKET_SIZE, PAGE_SIZE) +/* +* For archs where PAGE_KERNEL_RO is not supported; +* mapping the AR buffers readonly for the CPU is just a debugging aid. +*/ +#ifndef PAGE_KERNEL_RO +#define PAGE_KERNEL_RO PAGE_KERNEL +#endif
This might cause interesting issues on sparc64 if it ever acquired a PAGE_KERNEL_RO. Sparc64 has extern pgprot_t for it's PAGE_KERNEL types rather than #defines, so the #ifdef check wouldn't see this.
I think either PAGE_PROT_RO becomes part of our arch API (so all architectures are forced to add it), or, if it's not part of the API, ohci isn't entitled to use it. The latter seems simplest since you have no real use for write protection anyway.
James
Quoted 33 lines · James Bottomley
Quoted 17 lines · Clemens Ladisch
firewire: ohci: fix compilation on arches without
PAGE_KERNEL_RO, e.g. sparc
PAGE_KERNEL_ROis not available on all architectures, so its use in the new AR code broke compilation on sparc64.Because the R/O mapping is only used to catch drivers that try to write to the reception buffer and not actually required for correct operation, we can just use a normal
PAGE_KERNELmapping where_ROis not available.Thanks to Stefan Richter and Marc Gauthier <[email protected]> for suggesting this fix.
Signed-off-by Clemens Ladisch <[email protected]>drivers/firewire/ohci.c struct descriptor { · line 100
Quoted 10 lines
drivers/firewire/ohci.c +7
-0@@ -91,6 +91,14 @@ struct descriptor {#define MAX_AR_PACKET_SIZE (16 + MAX_ASYNC_PAYLOAD + 4)#define AR_WRAPAROUND_PAGES DIV_ROUND_UP(MAX_AR_PACKET_SIZE, PAGE_SIZE) +/* +* For archs where PAGE_KERNEL_RO is not supported; +* mapping the AR buffers readonly for the CPU is just a debugging aid. +*/ +#ifndef PAGE_KERNEL_RO +#define PAGE_KERNEL_RO PAGE_KERNEL +#endif This might cause interesting issues on sparc64 if it ever acquired a
PAGE_KERNEL_RO. Sparc64 has externpgprot_tfor it'sPAGE_KERNELtypes rather than #defines, so the #ifdef check wouldn't see this.
Quoted 4 lines
I think either
PAGE_PROT_RObecomes part of our arch API (so all architectures are forced to add it), or, if it's not part of the API, ohci isn't entitled to use it. The latter seems simplest since you have no real use for write protection anyway.
--8<---------------------------------------------------------------->8--
firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO
PAGE_KERNEL_RO is not available on all architectures, so its use in the new AR code broke compilation on sparc64.
Because the read-only mapping was just a debugging aid, just use PAGE_KERNEL instead.
drivers/firewire/ohci.c +1 -1
@@ -961,7 +961,7 @@ static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci,for (i =0 ; i <AR_WRAPAROUND_PAGES ; i++) pages[AR_BUFFERS + i] = ctx->pages[i]; ctx->buffer =vm_map_ram (pages,AR_BUFFERS +AR_WRAPAROUND_PAGES , --1 ,PAGE_KERNEL_RO ); +-1 ,PAGE_KERNEL );if (!ctx->buffer) goto out_of_memory;