Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Russell King | 4baa992 | 2008-08-02 10:55:55 +0100 | [diff] [blame] | 2 | * arch/arm/include/asm/domain.h |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 1999 Russell King. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 5 | * Copyright (c) 2009, Code Aurora Forum. All rights reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | #ifndef __ASM_PROC_DOMAIN_H |
| 12 | #define __ASM_PROC_DOMAIN_H |
| 13 | |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 14 | #ifndef __ASSEMBLY__ |
| 15 | #include <asm/barrier.h> |
| 16 | #endif |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | /* |
| 19 | * Domain numbers |
| 20 | * |
| 21 | * DOMAIN_IO - domain 2 includes all IO only |
| 22 | * DOMAIN_USER - domain 1 includes all user memory only |
| 23 | * DOMAIN_KERNEL - domain 0 includes all kernel memory only |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 24 | * |
| 25 | * The domain numbering depends on whether we support 36 physical |
| 26 | * address for I/O or not. Addresses above the 32 bit boundary can |
| 27 | * only be mapped using supersections and supersections can only |
| 28 | * be set for domain 0. We could just default to DOMAIN_IO as zero, |
| 29 | * but there may be systems with supersection support and no 36-bit |
| 30 | * addressing. In such cases, we want to map system memory with |
| 31 | * supersections to reduce TLB misses and footprint. |
| 32 | * |
| 33 | * 36-bit addressing and supersections are only available on |
| 34 | * CPUs based on ARMv6+ or the Intel XSC3 core. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 35 | * |
| 36 | * We cannot use domain 0 for the kernel on QSD8x50 since the kernel domain |
| 37 | * is set to manager mode when set_fs(KERNEL_DS) is called. Setting domain 0 |
| 38 | * to manager mode will disable the workaround for a cpu bug that can cause an |
| 39 | * invalid fault status and/or tlb corruption (CONFIG_VERIFY_PERMISSION_FAULT). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 41 | #if !defined(CONFIG_IO_36) && !defined(CONFIG_VERIFY_PERMISSION_FAULT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #define DOMAIN_KERNEL 0 |
| 43 | #define DOMAIN_TABLE 0 |
| 44 | #define DOMAIN_USER 1 |
| 45 | #define DOMAIN_IO 2 |
Lennert Buytenhek | 23bdf86 | 2006-03-28 21:00:40 +0100 | [diff] [blame] | 46 | #else |
| 47 | #define DOMAIN_KERNEL 2 |
| 48 | #define DOMAIN_TABLE 2 |
| 49 | #define DOMAIN_USER 1 |
| 50 | #define DOMAIN_IO 0 |
| 51 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | /* |
| 54 | * Domain types |
| 55 | */ |
| 56 | #define DOMAIN_NOACCESS 0 |
| 57 | #define DOMAIN_CLIENT 1 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 58 | #ifdef CONFIG_CPU_USE_DOMAINS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | #define DOMAIN_MANAGER 3 |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 60 | #else |
| 61 | #define DOMAIN_MANAGER 1 |
| 62 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
| 64 | #define domain_val(dom,type) ((type) << (2*(dom))) |
| 65 | |
| 66 | #ifndef __ASSEMBLY__ |
Russell King | 002547b | 2006-06-20 20:46:52 +0100 | [diff] [blame] | 67 | |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 68 | #ifdef CONFIG_CPU_USE_DOMAINS |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 69 | #ifdef CONFIG_EMULATE_DOMAIN_MANAGER_V7 |
| 70 | void emulate_domain_manager_set(u32 domain); |
| 71 | int emulate_domain_manager_data_abort(u32 dfsr, u32 dfar); |
| 72 | int emulate_domain_manager_prefetch_abort(u32 ifsr, u32 ifar); |
| 73 | void emulate_domain_manager_switch_mm( |
| 74 | unsigned long pgd_phys, |
| 75 | struct mm_struct *mm, |
| 76 | void (*switch_mm)(unsigned long pgd_phys, struct mm_struct *)); |
| 77 | |
| 78 | #define set_domain(x) emulate_domain_manager_set(x) |
| 79 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #define set_domain(x) \ |
| 81 | do { \ |
| 82 | __asm__ __volatile__( \ |
| 83 | "mcr p15, 0, %0, c3, c0 @ set domain" \ |
| 84 | : : "r" (x)); \ |
Catalin Marinas | 620879c | 2007-02-05 14:47:46 +0100 | [diff] [blame] | 85 | isb(); \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } while (0) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 87 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | #define modify_domain(dom,type) \ |
| 90 | do { \ |
| 91 | struct thread_info *thread = current_thread_info(); \ |
| 92 | unsigned int domain = thread->cpu_domain; \ |
| 93 | domain &= ~domain_val(dom, DOMAIN_MANAGER); \ |
| 94 | thread->cpu_domain = domain | domain_val(dom, type); \ |
| 95 | set_domain(thread->cpu_domain); \ |
| 96 | } while (0) |
| 97 | |
Russell King | 002547b | 2006-06-20 20:46:52 +0100 | [diff] [blame] | 98 | #else |
| 99 | #define set_domain(x) do { } while (0) |
| 100 | #define modify_domain(dom,type) do { } while (0) |
| 101 | #endif |
| 102 | |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 103 | /* |
| 104 | * Generate the T (user) versions of the LDR/STR and related |
| 105 | * instructions (inline assembly) |
| 106 | */ |
| 107 | #ifdef CONFIG_CPU_USE_DOMAINS |
Catalin Marinas | 4e7682d | 2012-01-25 11:38:13 +0100 | [diff] [blame] | 108 | #define TUSER(instr) #instr "t" |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 109 | #else |
Catalin Marinas | 4e7682d | 2012-01-25 11:38:13 +0100 | [diff] [blame] | 110 | #define TUSER(instr) #instr |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | #endif |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 112 | |
| 113 | #else /* __ASSEMBLY__ */ |
| 114 | |
| 115 | /* |
| 116 | * Generate the T (user) versions of the LDR/STR and related |
| 117 | * instructions |
| 118 | */ |
| 119 | #ifdef CONFIG_CPU_USE_DOMAINS |
Catalin Marinas | 4e7682d | 2012-01-25 11:38:13 +0100 | [diff] [blame] | 120 | #define TUSER(instr) instr ## t |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 121 | #else |
Catalin Marinas | 4e7682d | 2012-01-25 11:38:13 +0100 | [diff] [blame] | 122 | #define TUSER(instr) instr |
Catalin Marinas | 247055a | 2010-09-13 16:03:21 +0100 | [diff] [blame] | 123 | #endif |
| 124 | |
| 125 | #endif /* __ASSEMBLY__ */ |
| 126 | |
| 127 | #endif /* !__ASM_PROC_DOMAIN_H */ |