diff options
author | Gilad Ben-Yossef <gilad@benyossef.com> | 2013-01-22 06:18:45 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 12:46:11 -0500 |
commit | 4368902bb90f0e208387f336c3fce0e6b2a110fc (patch) | |
tree | 70d3927c8cd38e32a969ea340ec370ebeb16f30c /arch/arc/mm | |
parent | 8c2f4a8dd0e0fc9dcaf14c768544039eddfa7375 (diff) |
ARC: Add support for ioremap_prot API
Implement ioremap_prot() to allow mapping IO memory with variable
protection
via TLB.
Implementing this allows the /dev/mem driver to use its generic access()
VMA callback, which in turn allows ptrace to examine data in memory
mapped regions mapped via /dev/mem, such as Arc DCCM.
The end result is that it is possible to examine values of variables
placed into DCCM in user space programs via GDB.
CC: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
CC: Noam Camus <noamc@ezchip.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Diffstat (limited to 'arch/arc/mm')
-rw-r--r-- | arch/arc/mm/ioremap.c | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/arch/arc/mm/ioremap.c b/arch/arc/mm/ioremap.c index 52518b6d0f28..3e5c92c79936 100644 --- a/arch/arc/mm/ioremap.c +++ b/arch/arc/mm/ioremap.c | |||
@@ -16,25 +16,49 @@ | |||
16 | 16 | ||
17 | void __iomem *ioremap(unsigned long paddr, unsigned long size) | 17 | void __iomem *ioremap(unsigned long paddr, unsigned long size) |
18 | { | 18 | { |
19 | unsigned long vaddr; | 19 | unsigned long end; |
20 | struct vm_struct *area; | ||
21 | unsigned long off, end; | ||
22 | const pgprot_t prot = PAGE_KERNEL_NO_CACHE; | ||
23 | 20 | ||
24 | /* Don't allow wraparound or zero size */ | 21 | /* Don't allow wraparound or zero size */ |
25 | end = paddr + size - 1; | 22 | end = paddr + size - 1; |
26 | if (!size || (end < paddr)) | 23 | if (!size || (end < paddr)) |
27 | return NULL; | 24 | return NULL; |
28 | 25 | ||
29 | /* If the region is h/w uncached, nothing special needed */ | 26 | /* If the region is h/w uncached, avoid MMU mappings */ |
30 | if (paddr >= ARC_UNCACHED_ADDR_SPACE) | 27 | if (paddr >= ARC_UNCACHED_ADDR_SPACE) |
31 | return (void __iomem *)paddr; | 28 | return (void __iomem *)paddr; |
32 | 29 | ||
30 | return ioremap_prot(paddr, size, PAGE_KERNEL_NO_CACHE); | ||
31 | } | ||
32 | EXPORT_SYMBOL(ioremap); | ||
33 | |||
34 | /* | ||
35 | * ioremap with access flags | ||
36 | * Cache semantics wise it is same as ioremap - "forced" uncached. | ||
37 | * However unline vanilla ioremap which bypasses ARC MMU for addresses in | ||
38 | * ARC hardware uncached region, this one still goes thru the MMU as caller | ||
39 | * might need finer access control (R/W/X) | ||
40 | */ | ||
41 | void __iomem *ioremap_prot(phys_addr_t paddr, unsigned long size, | ||
42 | unsigned long flags) | ||
43 | { | ||
44 | void __iomem *vaddr; | ||
45 | struct vm_struct *area; | ||
46 | unsigned long off, end; | ||
47 | pgprot_t prot = __pgprot(flags); | ||
48 | |||
49 | /* Don't allow wraparound, zero size */ | ||
50 | end = paddr + size - 1; | ||
51 | if ((!size) || (end < paddr)) | ||
52 | return NULL; | ||
53 | |||
33 | /* An early platform driver might end up here */ | 54 | /* An early platform driver might end up here */ |
34 | if (!slab_is_available()) | 55 | if (!slab_is_available()) |
35 | return NULL; | 56 | return NULL; |
36 | 57 | ||
37 | /* Mappings have to be page-aligned, page-sized */ | 58 | /* force uncached */ |
59 | prot = pgprot_noncached(prot); | ||
60 | |||
61 | /* Mappings have to be page-aligned */ | ||
38 | off = paddr & ~PAGE_MASK; | 62 | off = paddr & ~PAGE_MASK; |
39 | paddr &= PAGE_MASK; | 63 | paddr &= PAGE_MASK; |
40 | size = PAGE_ALIGN(end + 1) - paddr; | 64 | size = PAGE_ALIGN(end + 1) - paddr; |
@@ -45,17 +69,17 @@ void __iomem *ioremap(unsigned long paddr, unsigned long size) | |||
45 | area = get_vm_area(size, VM_IOREMAP); | 69 | area = get_vm_area(size, VM_IOREMAP); |
46 | if (!area) | 70 | if (!area) |
47 | return NULL; | 71 | return NULL; |
48 | |||
49 | area->phys_addr = paddr; | 72 | area->phys_addr = paddr; |
50 | vaddr = (unsigned long)area->addr; | 73 | vaddr = (void __iomem *)area->addr; |
51 | if (ioremap_page_range(vaddr, vaddr + size, paddr, prot)) { | 74 | if (ioremap_page_range((unsigned long)vaddr, |
52 | vfree(area->addr); | 75 | (unsigned long)vaddr + size, paddr, prot)) { |
76 | vunmap((void __force *)vaddr); | ||
53 | return NULL; | 77 | return NULL; |
54 | } | 78 | } |
55 | |||
56 | return (void __iomem *)(off + (char __iomem *)vaddr); | 79 | return (void __iomem *)(off + (char __iomem *)vaddr); |
57 | } | 80 | } |
58 | EXPORT_SYMBOL(ioremap); | 81 | EXPORT_SYMBOL(ioremap_prot); |
82 | |||
59 | 83 | ||
60 | void iounmap(const void __iomem *addr) | 84 | void iounmap(const void __iomem *addr) |
61 | { | 85 | { |