blob: b216a00cac63268d5c8008b16639210964f96291 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Russell King4baa9922008-08-02 10:55:55 +01002 * arch/arm/include/asm/domain.h
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 1999 Russell King.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07005 * Copyright (c) 2009, Code Aurora Forum. All rights reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
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 Howells9f97da72012-03-28 18:30:01 +010014#ifndef __ASSEMBLY__
15#include <asm/barrier.h>
16#endif
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018/*
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 Buytenhek23bdf862006-03-28 21:00:40 +010024 *
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 Huntsman3f2bc4d2011-08-16 17:27:22 -070035 *
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 Torvalds1da177e2005-04-16 15:20:36 -070040 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070041#if !defined(CONFIG_IO_36) && !defined(CONFIG_VERIFY_PERMISSION_FAULT)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#define DOMAIN_KERNEL 0
43#define DOMAIN_TABLE 0
44#define DOMAIN_USER 1
45#define DOMAIN_IO 2
Lennert Buytenhek23bdf862006-03-28 21:00:40 +010046#else
47#define DOMAIN_KERNEL 2
48#define DOMAIN_TABLE 2
49#define DOMAIN_USER 1
50#define DOMAIN_IO 0
51#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53/*
54 * Domain types
55 */
56#define DOMAIN_NOACCESS 0
57#define DOMAIN_CLIENT 1
Catalin Marinas247055a2010-09-13 16:03:21 +010058#ifdef CONFIG_CPU_USE_DOMAINS
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define DOMAIN_MANAGER 3
Catalin Marinas247055a2010-09-13 16:03:21 +010060#else
61#define DOMAIN_MANAGER 1
62#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64#define domain_val(dom,type) ((type) << (2*(dom)))
65
66#ifndef __ASSEMBLY__
Russell King002547b2006-06-20 20:46:52 +010067
Catalin Marinas247055a2010-09-13 16:03:21 +010068#ifdef CONFIG_CPU_USE_DOMAINS
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069#ifdef CONFIG_EMULATE_DOMAIN_MANAGER_V7
70void emulate_domain_manager_set(u32 domain);
71int emulate_domain_manager_data_abort(u32 dfsr, u32 dfar);
72int emulate_domain_manager_prefetch_abort(u32 ifsr, u32 ifar);
73void 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 Torvalds1da177e2005-04-16 15:20:36 -070080#define set_domain(x) \
81 do { \
82 __asm__ __volatile__( \
83 "mcr p15, 0, %0, c3, c0 @ set domain" \
84 : : "r" (x)); \
Catalin Marinas620879c2007-02-05 14:47:46 +010085 isb(); \
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 } while (0)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070087#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
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 King002547b2006-06-20 20:46:52 +010098#else
99#define set_domain(x) do { } while (0)
100#define modify_domain(dom,type) do { } while (0)
101#endif
102
Catalin Marinas247055a2010-09-13 16:03:21 +0100103/*
104 * Generate the T (user) versions of the LDR/STR and related
105 * instructions (inline assembly)
106 */
107#ifdef CONFIG_CPU_USE_DOMAINS
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100108#define TUSER(instr) #instr "t"
Catalin Marinas247055a2010-09-13 16:03:21 +0100109#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100110#define TUSER(instr) #instr
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111#endif
Catalin Marinas247055a2010-09-13 16:03:21 +0100112
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 Marinas4e7682d2012-01-25 11:38:13 +0100120#define TUSER(instr) instr ## t
Catalin Marinas247055a2010-09-13 16:03:21 +0100121#else
Catalin Marinas4e7682d2012-01-25 11:38:13 +0100122#define TUSER(instr) instr
Catalin Marinas247055a2010-09-13 16:03:21 +0100123#endif
124
125#endif /* __ASSEMBLY__ */
126
127#endif /* !__ASM_PROC_DOMAIN_H */