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 | |
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')
-rw-r--r-- | arch/arc/Kconfig | 1 | ||||
-rw-r--r-- | arch/arc/include/asm/io.h | 2 | ||||
-rw-r--r-- | arch/arc/include/asm/page.h | 3 | ||||
-rw-r--r-- | arch/arc/mm/ioremap.c | 48 |
4 files changed, 42 insertions, 12 deletions
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index cd4ad61c4c14..2dab40dd8161 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig | |||
@@ -25,6 +25,7 @@ config ARC | |||
25 | select HAVE_ARCH_KGDB | 25 | select HAVE_ARCH_KGDB |
26 | select HAVE_ARCH_TRACEHOOK | 26 | select HAVE_ARCH_TRACEHOOK |
27 | select HAVE_GENERIC_HARDIRQS | 27 | select HAVE_GENERIC_HARDIRQS |
28 | select HAVE_IOREMAP_PROT | ||
28 | select HAVE_IRQ_WORK | 29 | select HAVE_IRQ_WORK |
29 | select HAVE_KPROBES | 30 | select HAVE_KPROBES |
30 | select HAVE_KRETPROBES | 31 | select HAVE_KRETPROBES |
diff --git a/arch/arc/include/asm/io.h b/arch/arc/include/asm/io.h index d20051bbbf02..473424d7528b 100644 --- a/arch/arc/include/asm/io.h +++ b/arch/arc/include/asm/io.h | |||
@@ -16,6 +16,8 @@ | |||
16 | #define PCI_IOBASE ((void __iomem *)0) | 16 | #define PCI_IOBASE ((void __iomem *)0) |
17 | 17 | ||
18 | extern void __iomem *ioremap(unsigned long physaddr, unsigned long size); | 18 | extern void __iomem *ioremap(unsigned long physaddr, unsigned long size); |
19 | extern void __iomem *ioremap_prot(phys_addr_t offset, unsigned long size, | ||
20 | unsigned long flags); | ||
19 | extern void iounmap(const void __iomem *addr); | 21 | extern void iounmap(const void __iomem *addr); |
20 | 22 | ||
21 | #define ioremap_nocache(phy, sz) ioremap(phy, sz) | 23 | #define ioremap_nocache(phy, sz) ioremap(phy, sz) |
diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h index dfe1f8a95f1d..bdf546104551 100644 --- a/arch/arc/include/asm/page.h +++ b/arch/arc/include/asm/page.h | |||
@@ -48,6 +48,8 @@ typedef unsigned long pgtable_t; | |||
48 | #define __pgd(x) ((pgd_t) { (x) }) | 48 | #define __pgd(x) ((pgd_t) { (x) }) |
49 | #define __pgprot(x) ((pgprot_t) { (x) }) | 49 | #define __pgprot(x) ((pgprot_t) { (x) }) |
50 | 50 | ||
51 | #define pte_pgprot(x) __pgprot(pte_val(x)) | ||
52 | |||
51 | #else /* !STRICT_MM_TYPECHECKS */ | 53 | #else /* !STRICT_MM_TYPECHECKS */ |
52 | 54 | ||
53 | typedef unsigned long pte_t; | 55 | typedef unsigned long pte_t; |
@@ -60,6 +62,7 @@ typedef unsigned long pgtable_t; | |||
60 | #define pgprot_val(x) (x) | 62 | #define pgprot_val(x) (x) |
61 | #define __pte(x) (x) | 63 | #define __pte(x) (x) |
62 | #define __pgprot(x) (x) | 64 | #define __pgprot(x) (x) |
65 | #define pte_pgprot(x) (x) | ||
63 | 66 | ||
64 | #endif | 67 | #endif |
65 | 68 | ||
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 | { |