Commit 7bdda620 authored by Paul Mundt's avatar Paul Mundt

sh: Fix up more 64-bit pgprot truncation on SH-X2 TLB.

Both the store queue API and the PMB remapping take unsigned long for
their pgprot flags, which cuts off the extended protection bits. In the
case of the PMB this isn't really a problem since the cache attribute
bits that we care about are all in the lower 32-bits, but we do it just
to be safe. The store queue remapping on the other hand depends on the
extended prot bits for enabling userspace access to the mappings.
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 49f3bfe9
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/threads.h> #include <linux/threads.h>
#include <asm/page.h>
/* Default "unsigned long" context */ /* Default "unsigned long" context */
typedef unsigned long mm_context_id_t[NR_CPUS]; typedef unsigned long mm_context_id_t[NR_CPUS];
...@@ -71,13 +72,13 @@ struct pmb_entry { ...@@ -71,13 +72,13 @@ struct pmb_entry {
#ifdef CONFIG_PMB #ifdef CONFIG_PMB
/* arch/sh/mm/pmb.c */ /* arch/sh/mm/pmb.c */
long pmb_remap(unsigned long virt, unsigned long phys, long pmb_remap(unsigned long virt, unsigned long phys,
unsigned long size, unsigned long flags); unsigned long size, pgprot_t prot);
void pmb_unmap(unsigned long addr); void pmb_unmap(unsigned long addr);
int pmb_init(void); int pmb_init(void);
bool __in_29bit_mode(void); bool __in_29bit_mode(void);
#else #else
static inline long pmb_remap(unsigned long virt, unsigned long phys, static inline long pmb_remap(unsigned long virt, unsigned long phys,
unsigned long size, unsigned long flags) unsigned long size, pgprot_t prot)
{ {
return -EINVAL; return -EINVAL;
} }
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#define __ASM_CPU_SH4_SQ_H #define __ASM_CPU_SH4_SQ_H
#include <asm/addrspace.h> #include <asm/addrspace.h>
#include <asm/page.h>
/* /*
* Store queues range from e0000000-e3fffffc, allowing approx. 64MB to be * Store queues range from e0000000-e3fffffc, allowing approx. 64MB to be
...@@ -28,7 +29,7 @@ ...@@ -28,7 +29,7 @@
/* arch/sh/kernel/cpu/sh4/sq.c */ /* arch/sh/kernel/cpu/sh4/sq.c */
unsigned long sq_remap(unsigned long phys, unsigned int size, unsigned long sq_remap(unsigned long phys, unsigned int size,
const char *name, unsigned long flags); const char *name, pgprot_t prot);
void sq_unmap(unsigned long vaddr); void sq_unmap(unsigned long vaddr);
void sq_flush_range(unsigned long start, unsigned int len); void sq_flush_range(unsigned long start, unsigned int len);
......
...@@ -100,7 +100,7 @@ static inline void sq_mapping_list_del(struct sq_mapping *map) ...@@ -100,7 +100,7 @@ static inline void sq_mapping_list_del(struct sq_mapping *map)
spin_unlock_irq(&sq_mapping_lock); spin_unlock_irq(&sq_mapping_lock);
} }
static int __sq_remap(struct sq_mapping *map, unsigned long flags) static int __sq_remap(struct sq_mapping *map, pgprot_t prot)
{ {
#if defined(CONFIG_MMU) #if defined(CONFIG_MMU)
struct vm_struct *vma; struct vm_struct *vma;
...@@ -113,7 +113,7 @@ static int __sq_remap(struct sq_mapping *map, unsigned long flags) ...@@ -113,7 +113,7 @@ static int __sq_remap(struct sq_mapping *map, unsigned long flags)
if (ioremap_page_range((unsigned long)vma->addr, if (ioremap_page_range((unsigned long)vma->addr,
(unsigned long)vma->addr + map->size, (unsigned long)vma->addr + map->size,
vma->phys_addr, __pgprot(flags))) { vma->phys_addr, prot)) {
vunmap(vma->addr); vunmap(vma->addr);
return -EAGAIN; return -EAGAIN;
} }
...@@ -135,14 +135,14 @@ static int __sq_remap(struct sq_mapping *map, unsigned long flags) ...@@ -135,14 +135,14 @@ static int __sq_remap(struct sq_mapping *map, unsigned long flags)
* @phys: Physical address of mapping. * @phys: Physical address of mapping.
* @size: Length of mapping. * @size: Length of mapping.
* @name: User invoking mapping. * @name: User invoking mapping.
* @flags: Protection flags. * @prot: Protection bits.
* *
* Remaps the physical address @phys through the next available store queue * Remaps the physical address @phys through the next available store queue
* address of @size length. @name is logged at boot time as well as through * address of @size length. @name is logged at boot time as well as through
* the sysfs interface. * the sysfs interface.
*/ */
unsigned long sq_remap(unsigned long phys, unsigned int size, unsigned long sq_remap(unsigned long phys, unsigned int size,
const char *name, unsigned long flags) const char *name, pgprot_t prot)
{ {
struct sq_mapping *map; struct sq_mapping *map;
unsigned long end; unsigned long end;
...@@ -177,7 +177,7 @@ unsigned long sq_remap(unsigned long phys, unsigned int size, ...@@ -177,7 +177,7 @@ unsigned long sq_remap(unsigned long phys, unsigned int size,
map->sq_addr = P4SEG_STORE_QUE + (page << PAGE_SHIFT); map->sq_addr = P4SEG_STORE_QUE + (page << PAGE_SHIFT);
ret = __sq_remap(map, pgprot_val(PAGE_KERNEL_NOCACHE) | flags); ret = __sq_remap(map, prot);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out; goto out;
...@@ -309,8 +309,7 @@ static ssize_t mapping_store(const char *buf, size_t count) ...@@ -309,8 +309,7 @@ static ssize_t mapping_store(const char *buf, size_t count)
return -EIO; return -EIO;
if (likely(len)) { if (likely(len)) {
int ret = sq_remap(base, len, "Userspace", int ret = sq_remap(base, len, "Userspace", PAGE_SHARED);
pgprot_val(PAGE_SHARED));
if (ret < 0) if (ret < 0)
return ret; return ret;
} else } else
......
...@@ -80,7 +80,7 @@ __ioremap_caller(unsigned long phys_addr, unsigned long size, ...@@ -80,7 +80,7 @@ __ioremap_caller(unsigned long phys_addr, unsigned long size,
if (unlikely(phys_addr >= P1SEG)) { if (unlikely(phys_addr >= P1SEG)) {
unsigned long mapped; unsigned long mapped;
mapped = pmb_remap(addr, phys_addr, size, pgprot_val(pgprot)); mapped = pmb_remap(addr, phys_addr, size, pgprot);
if (likely(mapped)) { if (likely(mapped)) {
addr += mapped; addr += mapped;
phys_addr += mapped; phys_addr += mapped;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/page.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
...@@ -166,12 +167,15 @@ static struct { ...@@ -166,12 +167,15 @@ static struct {
}; };
long pmb_remap(unsigned long vaddr, unsigned long phys, long pmb_remap(unsigned long vaddr, unsigned long phys,
unsigned long size, unsigned long flags) unsigned long size, pgprot_t prot)
{ {
struct pmb_entry *pmbp, *pmbe; struct pmb_entry *pmbp, *pmbe;
unsigned long wanted; unsigned long wanted;
int pmb_flags, i; int pmb_flags, i;
long err; long err;
u64 flags;
flags = pgprot_val(prot);
/* Convert typical pgprot value to the PMB equivalent */ /* Convert typical pgprot value to the PMB equivalent */
if (flags & _PAGE_CACHABLE) { if (flags & _PAGE_CACHABLE) {
......
...@@ -831,7 +831,7 @@ static int __devinit pvr2fb_common_init(void) ...@@ -831,7 +831,7 @@ static int __devinit pvr2fb_common_init(void)
printk(KERN_NOTICE "fb%d: registering with SQ API\n", fb_info->node); printk(KERN_NOTICE "fb%d: registering with SQ API\n", fb_info->node);
pvr2fb_map = sq_remap(fb_info->fix.smem_start, fb_info->fix.smem_len, pvr2fb_map = sq_remap(fb_info->fix.smem_start, fb_info->fix.smem_len,
fb_info->fix.id, pgprot_val(PAGE_SHARED)); fb_info->fix.id, PAGE_SHARED);
printk(KERN_NOTICE "fb%d: Mapped video memory to SQ addr 0x%lx\n", printk(KERN_NOTICE "fb%d: Mapped video memory to SQ addr 0x%lx\n",
fb_info->node, pvr2fb_map); fb_info->node, pvr2fb_map);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment