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: Paul Mundt <lethal@linux-sh.org>
This commit is contained in:
parent
49f3bfe933
commit
7bdda6209f
6 changed files with 18 additions and 13 deletions
|
@ -33,6 +33,7 @@
|
|||
#ifndef __ASSEMBLY__
|
||||
#include <linux/errno.h>
|
||||
#include <linux/threads.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
/* Default "unsigned long" context */
|
||||
typedef unsigned long mm_context_id_t[NR_CPUS];
|
||||
|
@ -71,13 +72,13 @@ struct pmb_entry {
|
|||
#ifdef CONFIG_PMB
|
||||
/* arch/sh/mm/pmb.c */
|
||||
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);
|
||||
int pmb_init(void);
|
||||
bool __in_29bit_mode(void);
|
||||
#else
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#define __ASM_CPU_SH4_SQ_H
|
||||
|
||||
#include <asm/addrspace.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
/*
|
||||
* Store queues range from e0000000-e3fffffc, allowing approx. 64MB to be
|
||||
|
@ -28,7 +29,7 @@
|
|||
|
||||
/* arch/sh/kernel/cpu/sh4/sq.c */
|
||||
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_flush_range(unsigned long start, unsigned int len);
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ static inline void sq_mapping_list_del(struct sq_mapping *map)
|
|||
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)
|
||||
struct vm_struct *vma;
|
||||
|
@ -113,7 +113,7 @@ static int __sq_remap(struct sq_mapping *map, unsigned long flags)
|
|||
|
||||
if (ioremap_page_range((unsigned long)vma->addr,
|
||||
(unsigned long)vma->addr + map->size,
|
||||
vma->phys_addr, __pgprot(flags))) {
|
||||
vma->phys_addr, prot)) {
|
||||
vunmap(vma->addr);
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
@ -135,14 +135,14 @@ static int __sq_remap(struct sq_mapping *map, unsigned long flags)
|
|||
* @phys: Physical address of mapping.
|
||||
* @size: Length of mapping.
|
||||
* @name: User invoking mapping.
|
||||
* @flags: Protection flags.
|
||||
* @prot: Protection bits.
|
||||
*
|
||||
* 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
|
||||
* the sysfs interface.
|
||||
*/
|
||||
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;
|
||||
unsigned long end;
|
||||
|
@ -177,7 +177,7 @@ unsigned long sq_remap(unsigned long phys, unsigned int size,
|
|||
|
||||
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))
|
||||
goto out;
|
||||
|
||||
|
@ -309,8 +309,7 @@ static ssize_t mapping_store(const char *buf, size_t count)
|
|||
return -EIO;
|
||||
|
||||
if (likely(len)) {
|
||||
int ret = sq_remap(base, len, "Userspace",
|
||||
pgprot_val(PAGE_SHARED));
|
||||
int ret = sq_remap(base, len, "Userspace", PAGE_SHARED);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
} else
|
||||
|
|
|
@ -80,7 +80,7 @@ __ioremap_caller(unsigned long phys_addr, unsigned long size,
|
|||
if (unlikely(phys_addr >= P1SEG)) {
|
||||
unsigned long mapped;
|
||||
|
||||
mapped = pmb_remap(addr, phys_addr, size, pgprot_val(pgprot));
|
||||
mapped = pmb_remap(addr, phys_addr, size, pgprot);
|
||||
if (likely(mapped)) {
|
||||
addr += mapped;
|
||||
phys_addr += mapped;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <asm/system.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/pgtable.h>
|
||||
#include <asm/page.h>
|
||||
#include <asm/mmu.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/mmu_context.h>
|
||||
|
@ -166,12 +167,15 @@ static struct {
|
|||
};
|
||||
|
||||
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;
|
||||
unsigned long wanted;
|
||||
int pmb_flags, i;
|
||||
long err;
|
||||
u64 flags;
|
||||
|
||||
flags = pgprot_val(prot);
|
||||
|
||||
/* Convert typical pgprot value to the PMB equivalent */
|
||||
if (flags & _PAGE_CACHABLE) {
|
||||
|
|
|
@ -831,7 +831,7 @@ static int __devinit pvr2fb_common_init(void)
|
|||
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,
|
||||
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",
|
||||
fb_info->node, pvr2fb_map);
|
||||
|
|
Loading…
Reference in a new issue