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