2008-10-22 22:26:29 -07:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2009-02-11 10:20:05 -08:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:32:38 +01:00
|
|
|
|
2012-03-28 18:11:12 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2009-09-02 11:49:52 +02:00
|
|
|
|
2010-03-25 14:51:50 +01:00
|
|
|
|
2012-03-28 18:11:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2009-06-01 23:43:10 +05:30
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
x86/tlb_info: get last level TLB entry number of CPU
For 4KB pages, x86 CPU has 2 or 1 level TLB, first level is data TLB and
instruction TLB, second level is shared TLB for both data and instructions.
For hupe page TLB, usually there is just one level and seperated by 2MB/4MB
and 1GB.
Although each levels TLB size is important for performance tuning, but for
genernal and rude optimizing, last level TLB entry number is suitable. And
in fact, last level TLB always has the biggest entry number.
This patch will get the biggest TLB entry number and use it in furture TLB
optimizing.
Accroding Borislav's suggestion, except tlb_ll[i/d]_* array, other
function and data will be released after system boot up.
For all kinds of x86 vendor friendly, vendor specific code was moved to its
specific files.
Signed-off-by: Alex Shi <alex.shi@intel.com>
Link: http://lkml.kernel.org/r/1340845344-27557-2-git-send-email-alex.shi@intel.com
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
2012-06-28 09:02:16 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x86, cpu: Detect more TLB configuration
The Intel Software Developer’s Manual covers few more TLB
configurations exposed as CPUID 2 descriptors:
61H Instruction TLB: 4 KByte pages, fully associative, 48 entries
63H Data TLB: 1 GByte pages, 4-way set associative, 4 entries
76H Instruction TLB: 2M/4M pages, fully associative, 8 entries
B5H Instruction TLB: 4KByte pages, 8-way set associative, 64 entries
B6H Instruction TLB: 4KByte pages, 8-way set associative, 128 entries
C1H Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, 1024 entries
C2H DTLB DTLB: 2 MByte/$MByte pages, 4-way associative, 16 entries
Let's detect them as well.
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: http://lkml.kernel.org/r/1387801018-14499-1-git-send-email-kirill.shutemov@linux.intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-12-23 14:16:58 +02:00
|
|
|
|
2012-06-28 09:02:19 +08:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-04-29 16:04:20 +02:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2009-01-23 17:18:52 -08:00
|
|
|
|
2009-03-12 12:37:34 +00:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-20 15:07:23 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-06 13:46:39 -08:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-09-30 14:38:57 +02:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2011-10-12 17:46:33 -07:00
|
|
|
|
2014-11-04 08:26:42 +00:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-05-09 23:47:42 -07:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
|
|
|
|
|
2014-11-04 08:26:42 +00:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
|
|
|
|
|
2010-12-18 16:30:05 +01:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-07-21 22:40:37 +05:30
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x86: delete __cpuinit usage from all x86 files
The __cpuinit type of throwaway sections might have made sense
some time ago when RAM was more constrained, but now the savings
do not offset the cost and complications. For example, the fix in
commit 5e427ec2d0 ("x86: Fix bit corruption at CPU resume time")
is a good example of the nasty type of bugs that can be created
with improper use of the various __init prefixes.
After a discussion on LKML[1] it was decided that cpuinit should go
the way of devinit and be phased out. Once all the users are gone,
we can then finally remove the macros themselves from linux/init.h.
Note that some harmless section mismatch warnings may result, since
notify_cpu_starting() and cpu_up() are arch independent (kernel/cpu.c)
are flagged as __cpuinit -- so if we remove the __cpuinit from
arch specific callers, we will also get section mismatch warnings.
As an intermediate step, we intend to turn the linux/init.h cpuinit
content into no-ops as early as possible, since that will get rid
of these warnings. In any case, they are temporary and harmless.
This removes all the arch/x86 uses of the __cpuinit macros from
all C files. x86 only had the one __CPUINIT used in assembly files,
and it wasn't paired off with a .previous or a __FINIT, so we can
delete it directly w/o any corresponding additional change there.
[1] https://lkml.org/lkml/2013/5/20/589
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2013-06-18 18:23:59 -04:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
2008-06-21 03:24:19 -07:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
2012-02-12 09:53:57 -08:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
|
|
|
|
|
2012-10-19 10:59:33 +02:00
|
|
|
|
2008-01-30 13:31:33 +01:00
|
|
|
|
2008-08-23 17:47:10 +02:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
|
|
|
|
|
2012-12-20 23:44:23 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
2009-12-16 16:25:42 -08:00
|
|
|
|
2008-03-23 01:03:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-12 17:46:33 -07:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-07-04 13:56:16 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2009-04-21 23:00:24 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:48 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:41 +01:00
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:48 +01:00
|
|
|
|
|
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:48 +01:00
|
|
|
|
|
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:48 +01:00
|
|
|
|
|
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-03-05 15:15:42 +01:00
|
|
|
|
2008-07-29 10:29:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:41 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:48 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-02-09 22:17:39 +09:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:41 +01:00
|
|
|
|
|
|
|
|
|
2009-04-10 15:21:24 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-20 19:51:05 +01:00
|
|
|
|
2013-12-05 17:15:34 +08:00
|
|
|
|
2014-01-20 19:51:05 +01:00
|
|
|
|
2013-12-05 17:15:34 +08:00
|
|
|
|
|
|
|
|
|
2014-10-31 14:58:20 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-05 17:15:34 +08:00
|
|
|
|
|
|
|
|
|
2014-11-14 07:18:17 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-05 17:15:34 +08:00
|
|
|
|
|
|
|
|
|
2008-07-29 10:29:19 -07:00
|
|
|
|
|
|
|
|
|
2014-05-29 11:12:33 -07:00
|
|
|
|
|
|
|
|
|
2008-07-29 10:29:19 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-04-10 15:21:24 -07:00
|
|
|
|
2013-12-05 17:15:34 +08:00
|
|
|
|
2014-10-31 14:58:20 -07:00
|
|
|
|
2014-11-14 07:18:17 -08:00
|
|
|
|
2008-07-29 10:29:19 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-10 15:28:04 -07:00
|
|
|
|
2008-01-30 13:31:48 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-07-29 10:29:20 -07:00
|
|
|
|
2008-01-30 13:31:48 +01:00
|
|
|
|
|
|
|
|
|
2010-05-06 11:45:46 +03:00
|
|
|
|
i387: support lazy restore of FPU state
This makes us recognize when we try to restore FPU state that matches
what we already have in the FPU on this CPU, and avoids the restore
entirely if so.
To do this, we add two new data fields:
- a percpu 'fpu_owner_task' variable that gets written any time we
update the "has_fpu" field, and thus acts as a kind of back-pointer
to the task that owns the CPU. The exception is when we save the FPU
state as part of a context switch - if the save can keep the FPU
state around, we leave the 'fpu_owner_task' variable pointing at the
task whose FP state still remains on the CPU.
- a per-thread 'last_cpu' field, that indicates which CPU that thread
used its FPU on last. We update this on every context switch
(writing an invalid CPU number if the last context switch didn't
leave the FPU in a lazily usable state), so we know that *that*
thread has done nothing else with the FPU since.
These two fields together can be used when next switching back to the
task to see if the CPU still matches: if 'fpu_owner_task' matches the
task we are switching to, we know that no other task (or kernel FPU
usage) touched the FPU on this CPU in the meantime, and if the current
CPU number matches the 'last_cpu' field, we know that this thread did no
other FP work on any other CPU, so the FPU state on the CPU must match
what was saved on last context switch.
In that case, we can avoid the 'f[x]rstor' entirely, and just clear the
CR0.TS bit.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-02-19 13:27:00 -08:00
|
|
|
|
|
|
|
|
|
2010-05-06 11:45:46 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-03 14:12:56 -03:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2009-01-19 00:38:58 +09:00
|
|
|
|
2009-01-19 12:21:28 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-05 15:02:43 -07:00
|
|
|
|
2009-02-08 09:58:39 -05:00
|
|
|
|
|
|
|
|
|
2009-01-19 00:38:58 +09:00
|
|
|
|
2009-03-14 11:19:49 +05:30
|
|
|
|
|
|
|
|
|
2009-02-09 22:17:40 +09:00
|
|
|
|
|
|
|
|
|
2009-09-03 12:27:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-03 14:31:44 -07:00
|
|
|
|
2007-10-11 11:20:03 +02:00
|
|
|
|
2014-02-06 09:41:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-02-09 22:17:40 +09:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
2008-03-10 15:28:04 -07:00
|
|
|
|
2008-03-10 15:28:05 -07:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2009-09-09 19:22:48 +02:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2009-05-04 03:30:15 +04:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2009-05-04 03:30:15 +04:00
|
|
|
|
2009-05-04 03:29:52 +04:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2009-05-04 03:29:52 +04:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2009-09-09 19:22:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-02-18 18:24:18 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2012-03-12 14:55:55 +05:30
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-03-10 15:28:04 -07:00
|
|
|
|
2010-05-06 11:45:46 +03:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-11-12 15:08:46 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-03-23 01:03:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2008-01-30 13:32:08 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2008-03-23 01:03:15 -07:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:31 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:38 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-03-23 01:03:15 -07:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
arch, locking: Ciao arch_mutex_cpu_relax()
The arch_mutex_cpu_relax() function, introduced by 34b133f, is
hacky and ugly. It was added a few years ago to address the fact
that common cpu_relax() calls include yielding on s390, and thus
impact the optimistic spinning functionality of mutexes. Nowadays
we use this function well beyond mutexes: rwsem, qrwlock, mcs and
lockref. Since the macro that defines the call is in the mutex header,
any users must include mutex.h and the naming is misleading as well.
This patch (i) renames the call to cpu_relax_lowlatency ("relax, but
only if you can do it with very low latency") and (ii) defines it in
each arch's asm/processor.h local header, just like for regular cpu_relax
functions. On all archs, except s390, cpu_relax_lowlatency is simply cpu_relax,
and thus we can take it out of mutex.h. While this can seem redundant,
I believe it is a good choice as it allows us to move out arch specific
logic from generic locking primitives and enables future(?) archs to
transparently define it, similarly to System Z.
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Anton Blanchard <anton@samba.org>
Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Bharat Bhushan <r65777@freescale.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chen Liqin <liqin.linux@gmail.com>
Cc: Chris Metcalf <cmetcalf@tilera.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Chris Zankel <chris@zankel.net>
Cc: David Howells <dhowells@redhat.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Cc: Dominik Dingel <dingel@linux.vnet.ibm.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Haavard Skinnemoen <hskinnemoen@gmail.com>
Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Hirokazu Takata <takata@linux-m32r.org>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: James E.J. Bottomley <jejb@parisc-linux.org>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Joe Perches <joe@perches.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Joseph Myers <joseph@codesourcery.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: Lennox Wu <lennox.wu@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Salter <msalter@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Nicolas Pitre <nico@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Qais Yousef <qais.yousef@imgtec.com>
Cc: Qiaowei Ren <qiaowei.ren@intel.com>
Cc: Rafael Wysocki <rafael.j.wysocki@intel.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Richard Kuo <rkuo@codeaurora.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Steven Miao <realmz6@gmail.com>
Cc: Steven Rostedt <srostedt@redhat.com>
Cc: Stratos Karafotis <stratosk@semaphore.gr>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Vasily Kulikov <segoon@openwall.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Vineet Gupta <Vineet.Gupta1@synopsys.com>
Cc: Waiman Long <Waiman.Long@hp.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
Cc: adi-buildroot-devel@lists.sourceforge.net
Cc: linux390@de.ibm.com
Cc: linux-alpha@vger.kernel.org
Cc: linux-am33-list@redhat.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-c6x-dev@linux-c6x.org
Cc: linux-cris-kernel@axis.com
Cc: linux-hexagon@vger.kernel.org
Cc: linux-ia64@vger.kernel.org
Cc: linux@lists.openrisc.net
Cc: linux-m32r-ja@ml.linux-m32r.org
Cc: linux-m32r@ml.linux-m32r.org
Cc: linux-m68k@lists.linux-m68k.org
Cc: linux-metag@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: linux-parisc@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-s390@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: linux-xtensa@linux-xtensa.org
Cc: sparclinux@vger.kernel.org
Link: http://lkml.kernel.org/r/1404079773.2619.4.camel@buesod1.americas.hpqcorp.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2014-06-29 15:09:33 -07:00
|
|
|
|
|
|
|
|
|
2009-09-10 02:53:50 +01:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2012-11-28 11:50:23 -08:00
|
|
|
|
2012-11-28 11:50:30 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-10 02:53:50 +01:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-04-01 16:59:53 -04:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2011-04-01 16:59:53 -04:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2010-11-03 17:06:14 +01:00
|
|
|
|
2013-02-10 01:38:39 -05:00
|
|
|
|
2010-11-03 17:06:14 +01:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-20 21:04:29 -05:00
|
|
|
|
x86, 64bit: Use a #PF handler to materialize early mappings on demand
Linear mode (CR0.PG = 0) is mutually exclusive with 64-bit mode; all
64-bit code has to use page tables. This makes it awkward before we
have first set up properly all-covering page tables to access objects
that are outside the static kernel range.
So far we have dealt with that simply by mapping a fixed amount of
low memory, but that fails in at least two upcoming use cases:
1. We will support load and run kernel, struct boot_params, ramdisk,
command line, etc. above the 4 GiB mark.
2. need to access ramdisk early to get microcode to update that as
early possible.
We could use early_iomap to access them too, but it will make code to
messy and hard to be unified with 32 bit.
Hence, set up a #PF table and use a fixed number of buffers to set up
page tables on demand. If the buffers fill up then we simply flush
them and start over. These buffers are all in __initdata, so it does
not increase RAM usage at runtime.
Thus, with the help of the #PF handler, we can set the final kernel
mapping from blank, and switch to init_level4_pgt later.
During the switchover in head_64.S, before #PF handler is available,
we use three pages to handle kernel crossing 1G, 512G boundaries with
sharing page by playing games with page aliasing: the same page is
mapped twice in the higher-level tables with appropriate wraparound.
The kernel region itself will be properly mapped; other mappings may
be spurious.
early_make_pgtable is using kernel high mapping address to access pages
to set page table.
-v4: Add phys_base offset to make kexec happy, and add
init_mapping_kernel() - Yinghai
-v5: fix compiling with xen, and add back ident level3 and level2 for xen
also move back init_level4_pgt from BSS to DATA again.
because we have to clear it anyway. - Yinghai
-v6: switch to init_level4_pgt in init_mem_mapping. - Yinghai
-v7: remove not needed clear_page for init_level4_page
it is with fill 512,8,0 already in head_64.S - Yinghai
-v8: we need to keep that handler alive until init_mem_mapping and don't
let early_trap_init to trash that early #PF handler.
So split early_trap_pf_init out and move it down. - Yinghai
-v9: switchover only cover kernel space instead of 1G so could avoid
touch possible mem holes. - Yinghai
-v11: change far jmp back to far return to initial_code, that is needed
to fix failure that is reported by Konrad on AMD systems. - Yinghai
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1359058816-7615-12-git-send-email-yinghai@kernel.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
2013-01-24 12:19:52 -08:00
|
|
|
|
2010-05-20 21:04:29 -05:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
|
|
|
|
|
2009-01-30 17:47:53 +09:00
|
|
|
|
2009-01-30 17:47:54 +09:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
|
|
|
|
|
2008-12-11 13:49:59 +01:00
|
|
|
|
|
|
|
|
|
2010-03-25 14:51:51 +01:00
|
|
|
|
2008-12-11 13:49:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-03-25 14:51:51 +01:00
|
|
|
|
2008-12-11 13:49:59 +01:00
|
|
|
|
|
|
|
|
|
2008-03-10 13:11:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-03 15:24:17 +02:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2009-05-07 16:54:11 -07:00
|
|
|
|
2008-01-30 13:31:39 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:40 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:40 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:40 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2009-02-20 23:32:28 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tree-wide: fix comment/printk typos
"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-11-01 15:38:34 -04:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-11-04 15:46:21 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2009-02-20 23:32:28 +01:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2012-02-06 13:03:09 -08:00
|
|
|
|
2009-02-20 23:32:28 +01:00
|
|
|
|
2012-02-06 13:03:09 -08:00
|
|
|
|
2009-02-20 23:32:28 +01:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2008-02-08 04:19:26 -08:00
|
|
|
|
2009-02-20 23:32:28 +01:00
|
|
|
|
2008-02-08 04:19:26 -08:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2009-11-03 10:22:40 +01:00
|
|
|
|
2012-02-14 13:49:48 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:57 +01:00
|
|
|
|
|
|
|
|
|
2008-02-21 05:18:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
|
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-02-21 04:24:40 +01:00
|
|
|
|
2008-01-30 13:31:27 +01:00
|
|
|
|
2008-04-14 00:24:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x86, mpx: On-demand kernel allocation of bounds tables
This is really the meat of the MPX patch set. If there is one patch to
review in the entire series, this is the one. There is a new ABI here
and this kernel code also interacts with userspace memory in a
relatively unusual manner. (small FAQ below).
Long Description:
This patch adds two prctl() commands to provide enable or disable the
management of bounds tables in kernel, including on-demand kernel
allocation (See the patch "on-demand kernel allocation of bounds tables")
and cleanup (See the patch "cleanup unused bound tables"). Applications
do not strictly need the kernel to manage bounds tables and we expect
some applications to use MPX without taking advantage of this kernel
support. This means the kernel can not simply infer whether an application
needs bounds table management from the MPX registers. The prctl() is an
explicit signal from userspace.
PR_MPX_ENABLE_MANAGEMENT is meant to be a signal from userspace to
require kernel's help in managing bounds tables.
PR_MPX_DISABLE_MANAGEMENT is the opposite, meaning that userspace don't
want kernel's help any more. With PR_MPX_DISABLE_MANAGEMENT, the kernel
won't allocate and free bounds tables even if the CPU supports MPX.
PR_MPX_ENABLE_MANAGEMENT will fetch the base address of the bounds
directory out of a userspace register (bndcfgu) and then cache it into
a new field (->bd_addr) in the 'mm_struct'. PR_MPX_DISABLE_MANAGEMENT
will set "bd_addr" to an invalid address. Using this scheme, we can
use "bd_addr" to determine whether the management of bounds tables in
kernel is enabled.
Also, the only way to access that bndcfgu register is via an xsaves,
which can be expensive. Caching "bd_addr" like this also helps reduce
the cost of those xsaves when doing table cleanup at munmap() time.
Unfortunately, we can not apply this optimization to #BR fault time
because we need an xsave to get the value of BNDSTATUS.
==== Why does the hardware even have these Bounds Tables? ====
MPX only has 4 hardware registers for storing bounds information.
If MPX-enabled code needs more than these 4 registers, it needs to
spill them somewhere. It has two special instructions for this
which allow the bounds to be moved between the bounds registers
and some new "bounds tables".
They are similar conceptually to a page fault and will be raised by
the MPX hardware during both bounds violations or when the tables
are not present. This patch handles those #BR exceptions for
not-present tables by carving the space out of the normal processes
address space (essentially calling the new mmap() interface indroduced
earlier in this patch set.) and then pointing the bounds-directory
over to it.
The tables *need* to be accessed and controlled by userspace because
the instructions for moving bounds in and out of them are extremely
frequent. They potentially happen every time a register pointing to
memory is dereferenced. Any direct kernel involvement (like a syscall)
to access the tables would obviously destroy performance.
==== Why not do this in userspace? ====
This patch is obviously doing this allocation in the kernel.
However, MPX does not strictly *require* anything in the kernel.
It can theoretically be done completely from userspace. Here are
a few ways this *could* be done. I don't think any of them are
practical in the real-world, but here they are.
Q: Can virtual space simply be reserved for the bounds tables so
that we never have to allocate them?
A: As noted earlier, these tables are *HUGE*. An X-GB virtual
area needs 4*X GB of virtual space, plus 2GB for the bounds
directory. If we were to preallocate them for the 128TB of
user virtual address space, we would need to reserve 512TB+2GB,
which is larger than the entire virtual address space today.
This means they can not be reserved ahead of time. Also, a
single process's pre-popualated bounds directory consumes 2GB
of virtual *AND* physical memory. IOW, it's completely
infeasible to prepopulate bounds directories.
Q: Can we preallocate bounds table space at the same time memory
is allocated which might contain pointers that might eventually
need bounds tables?
A: This would work if we could hook the site of each and every
memory allocation syscall. This can be done for small,
constrained applications. But, it isn't practical at a larger
scale since a given app has no way of controlling how all the
parts of the app might allocate memory (think libraries). The
kernel is really the only place to intercept these calls.
Q: Could a bounds fault be handed to userspace and the tables
allocated there in a signal handler instead of in the kernel?
A: (thanks to tglx) mmap() is not on the list of safe async
handler functions and even if mmap() would work it still
requires locking or nasty tricks to keep track of the
allocation state there.
Having ruled out all of the userspace-only approaches for managing
bounds tables that we could think of, we create them on demand in
the kernel.
Based-on-patch-by: Qiaowei Ren <qiaowei.ren@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: linux-mm@kvack.org
Cc: linux-mips@linux-mips.org
Cc: Dave Hansen <dave@sr71.net>
Link: http://lkml.kernel.org/r/20141114151829.AD4310DE@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2014-11-14 07:18:29 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-27 14:32:10 +08:00
|
|
|
|
2009-09-16 11:33:40 +02:00
|
|
|
|
2013-07-25 16:54:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-28 18:11:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-02-09 23:08:07 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-28 18:11:12 +01:00
|
|
|
|
|
|
|
|
|
2013-05-09 12:02:29 +02:00
|
|
|
|
2008-10-22 22:26:29 -07:00
|
|
|
|