Linus Torvalds
9f2a5128b9
Merge tag 'for-linus-4.14c-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
...
Pull xen fixes from Juergen Gross:
- avoid a warning when compiling with clang
- consider read-only bits in xen-pciback when writing to a BAR
- fix a boot crash of pv-domains
* tag 'for-linus-4.14c-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
xen/mmu: Call xen_cleanhighmap() with 4MB aligned for page tables mapping
xen-pciback: relax BAR sizing write value check
x86/xen: clean up clang build warning
2017-09-29 12:24:28 -07:00
Andrey Ryabinin
196bd485ee
x86/asm: Use register variable to get stack pointer value
...
Currently we use current_stack_pointer() function to get the value
of the stack pointer register. Since commit:
f5caf621ee
("x86/asm: Fix inline asm call constraints for Clang")
... we have a stack register variable declared. It can be used instead of
current_stack_pointer() function which allows to optimize away some
excessive "mov %rsp, %<dst>" instructions:
-mov %rsp,%rdx
-sub %rdx,%rax
-cmp $0x3fff,%rax
-ja ffffffff810722fd <ist_begin_non_atomic+0x2d>
+sub %rsp,%rax
+cmp $0x3fff,%rax
+ja ffffffff810722fa <ist_begin_non_atomic+0x2a>
Remove current_stack_pointer(), rename __asm_call_sp to current_stack_pointer
and use it instead of the removed function.
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com >
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: http://lkml.kernel.org/r/20170929141537.29167-1-aryabinin@virtuozzo.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-29 19:39:44 +02:00
Josh Poimboeuf
520a13c530
x86/asm: Fix inline asm call constraints for GCC 4.4
...
The kernel test bot (run by Xiaolong Ye) reported that the following commit:
f5caf621ee
("x86/asm: Fix inline asm call constraints for Clang")
is causing double faults in a kernel compiled with GCC 4.4.
Linus subsequently diagnosed the crash pattern and the buggy commit and found that
the issue is with this code:
register unsigned int __asm_call_sp asm("esp");
#define ASM_CALL_CONSTRAINT "+r" (__asm_call_sp)
Even on a 64-bit kernel, it's using ESP instead of RSP. That causes GCC
to produce the following bogus code:
ffffffff8147461d: 89 e0 mov %esp,%eax
ffffffff8147461f: 4c 89 f7 mov %r14,%rdi
ffffffff81474622: 4c 89 fe mov %r15,%rsi
ffffffff81474625: ba 20 00 00 00 mov $0x20,%edx
ffffffff8147462a: 89 c4 mov %eax,%esp
ffffffff8147462c: e8 bf 52 05 00 callq ffffffff814c98f0 <copy_user_generic_unrolled>
Despite the absurdity of it backing up and restoring the stack pointer
for no reason, the bug is actually the fact that it's only backing up
and restoring the lower 32 bits of the stack pointer. The upper 32 bits
are getting cleared out, corrupting the stack pointer.
So change the '__asm_call_sp' register variable to be associated with
the actual full-size stack pointer.
This also requires changing the __ASM_SEL() macro to be based on the
actual compiled arch size, rather than the CONFIG value, because
CONFIG_X86_64 compiles some files with '-m32' (e.g., realmode and vdso).
Otherwise Clang fails to build the kernel because it complains about the
use of a 64-bit register (RSP) in a 32-bit file.
Reported-and-Bisected-and-Tested-by: kernel test robot <xiaolong.ye@intel.com >
Diagnosed-by: Linus Torvalds <torvalds@linux-foundation.org >
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: LKP <lkp@01.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Matthias Kaehlcke <mka@chromium.org >
Cc: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Fixes: f5caf621ee
("x86/asm: Fix inline asm call constraints for Clang")
Link: http://lkml.kernel.org/r/20170928215826.6sdpmwtkiydiytim@treble
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-29 13:15:44 +02:00
Kees Cook
564c9cc84e
locking/refcounts, x86/asm: Use unique .text section for refcount exceptions
...
Using .text.unlikely for refcount exceptions isn't safe because gcc may
move entire functions into .text.unlikely (e.g. in6_dev_dev()), which
would cause any uses of a protected refcount_t function to stay inline
with the function, triggering the protection unconditionally:
.section .text.unlikely,"ax",@progbits
.type in6_dev_get, @function
in6_dev_getx:
.LFB4673:
.loc 2 4128 0
.cfi_startproc
...
lock; incl 480(%rbx)
js 111f
.pushsection .text.unlikely
111: lea 480(%rbx), %rcx
112: .byte 0x0f, 0xff
.popsection
113:
This creates a unique .text..refcount section and adds an additional
test to the exception handler to WARN in the case of having none of OF,
SF, nor ZF set so we can see things like this more easily in the future.
The double dot for the section name keeps it out of the TEXT_MAIN macro
namespace, to avoid collisions and so it can be put at the end with
text.unlikely to keep the cold code together.
See commit:
cb87481ee8
("kbuild: linker script do not match C names unless LD_DEAD_CODE_DATA_ELIMINATION is configured")
... which matches C names: [a-zA-Z0-9_] but not ".".
Reported-by: Mike Galbraith <efault@gmx.de >
Signed-off-by: Kees Cook <keescook@chromium.org >
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org >
Cc: Elena <elena.reshetova@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: linux-arch <linux-arch@vger.kernel.org >
Fixes: 7a46ec0e2f
("locking/refcounts, x86/asm: Implement fast refcount overflow protection")
Link: http://lkml.kernel.org/r/1504382986-49301-2-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-28 09:45:05 +02:00
Miguel Bernal Marin
30c23f29d2
locking/x86: Use named operands in rwsem.h
...
Since GCC version 3.1 it is possible to specify input and output
operands using symbolic names, which can be referenced within the
assembler code.
Converting to named operands makes it easier to understand and maintain
the code in the future.
Update operands in asm/rwsem.h accordingly.
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: http://lkml.kernel.org/r/20170925230349.18834-1-miguel.bernal.marin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-28 09:43:15 +02:00
Masami Hiramatsu
a8976fc84b
kprobes/x86: Remove addressof() operators
...
The following commit:
54a7d50b92
("x86: mark kprobe templates as character arrays, not single characters")
changed optprobe_template_* to arrays, so we can remove the addressof()
operators from those symbols.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com >
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com >
Cc: David S . Miller <davem@davemloft.net >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: http://lkml.kernel.org/r/150304469798.17009.15886717935027472863.stgit@devbox
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-28 09:23:03 +02:00
Ingo Molnar
8474c532b5
Merge branch 'WIP.x86/fpu' into x86/fpu, because it's ready
...
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-26 10:17:43 +02:00
Eric Biggers
e63e5d5c15
x86/fpu: Introduce validate_xstate_header()
...
Move validation of user-supplied xstate_header into a helper function,
in preparation of calling it from both the ptrace and sigreturn syscall
paths.
The new function also considers it to be an error if *any* reserved bits
are set, whereas before we were just clearing most of them silently.
This should reduce the chance of bugs that fail to correctly validate
user-supplied XSAVE areas. It also will expose any broken userspace
programs that set the other reserved bits; this is desirable because
such programs will lose compatibility with future CPUs and kernels if
those bits are ever used for anything. (There shouldn't be any such
programs, and in fact in the case where the compacted format is in use
we were already validating xfeatures. But you never know...)
Signed-off-by: Eric Biggers <ebiggers@google.com >
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Kees Cook <keescook@chromium.org >
Cc: Kevin Hao <haokexin@gmail.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Michael Halcrow <mhalcrow@google.com >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Wanpeng Li <wanpeng.li@hotmail.com >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Cc: kernel-hardening@lists.openwall.com
Link: http://lkml.kernel.org/r/20170924105913.9157-2-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-26 09:43:45 +02:00
Ingo Molnar
369a036de2
x86/fpu: Rename fpu__activate_fpstate_read/write() to fpu__prepare_[read|write]()
...
As per the new nomenclature we don't 'activate' the FPU state
anymore, we initialize it. So drop the _activate_fpstate name
from these functions, which were a bit of a mouthful anyway,
and name them:
fpu__prepare_read()
fpu__prepare_write()
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-26 09:43:44 +02:00
Ingo Molnar
2ce03d850b
x86/fpu: Rename fpu__activate_curr() to fpu__initialize()
...
Rename this function to better express that it's all about
initializing the FPU state of a task which goes hand in hand
with the fpu::initialized field.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-33-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-26 09:43:44 +02:00
Ingo Molnar
e4a81bfcaa
x86/fpu: Rename fpu::fpstate_active to fpu::initialized
...
The x86 FPU code used to have a complex state machine where both the FPU
registers and the FPU state context could be 'active' (or inactive)
independently of each other - which enabled features like lazy FPU restore.
Much of this complexity is gone in the current code: now we basically can
have FPU-less tasks (kernel threads) that don't use (and save/restore) FPU
state at all, plus full FPU users that save/restore directly with no laziness
whatsoever.
But the fpu::fpstate_active still carries bits of the old complexity - meanwhile
this flag has become a simple flag that shows whether the FPU context saving
area in the thread struct is initialized and used, or not.
Rename it to fpu::initialized to express this simplicity in the name as well.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-30-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-26 09:43:36 +02:00
Ingo Molnar
685c930d6e
x86/fpu: Remove fpu__current_fpstate_write_begin/end()
...
These functions are not used anymore, so remove them.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Bobby Powers <bobbypowers@gmail.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-29-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-26 09:42:20 +02:00
Thomas Gleixner
2cffad7bad
x86/irq: Simplify hotplug vector accounting
...
Before a CPU is taken offline the number of active interrupt vectors on the
outgoing CPU and the number of vectors which are available on the other
online CPUs are counted and compared. If the active vectors are more than
the available vectors on the other CPUs then the CPU hot-unplug operation
is aborted. This again uses loop based search and is inaccurate.
The bitmap matrix allocator has accurate accounting information and can
tell exactly whether the vector space is sufficient or not.
Emit a message when the number of globaly reserved (unallocated) vectors is
larger than the number of available vectors after offlining a CPU because
after that point request_irq() might fail.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213156.351193962@linutronix.de
2017-09-25 20:52:02 +02:00
Thomas Gleixner
2db1f959d9
x86/vector: Handle managed interrupts proper
...
Managed interrupts need to reserve interrupt vectors permanently, but as
long as the interrupt is deactivated, the vector should not be active.
Reserve a new system vector, which can be used to initially initialize
MSI/DMAR/IOAPIC entries. In that situation the interrupts are disabled in
the corresponding MSI/DMAR/IOAPIC devices. So the vector should never be
sent to any CPU.
When the managed interrupt is started up, a real vector is assigned from
the managed vector space and configured in MSI/DMAR/IOAPIC.
This allows a clear separation of inactive and active modes and simplifies
the final decisions whether the global vector space is sufficient for CPU
offline operations.
The vector space can be reserved even on offline CPUs and will survive CPU
offline/online operations.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213156.104616625@linutronix.de
2017-09-25 20:52:01 +02:00
Thomas Gleixner
ba224feac8
x86/vector: Untangle internal state from irq_cfg
...
The vector management state is not required to live in irq_cfg. irq_cfg is
only relevant for the depending irq domains (IOAPIC, DMAR, MSI ...).
The seperation of the vector management status allows to direct a shut down
interrupt to a special shutdown vector w/o confusing the internal state of
the vector management.
Preparatory change for the rework of managed interrupts and the global
vector reservation scheme.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213155.683712356@linutronix.de
2017-09-25 20:51:59 +02:00
Thomas Gleixner
8d1e3dca7d
x86/vector: Add tracepoints for vector management
...
Add tracepoints for analysing the new vector management
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213155.357986795@linutronix.de
2017-09-25 20:51:58 +02:00
Thomas Gleixner
0fa115da40
x86/irq/vector: Initialize matrix allocator
...
Initialize the matrix allocator and add the proper accounting points to the
code.
No functional change, just preparation.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213155.108410660@linutronix.de
2017-09-25 20:51:56 +02:00
Thomas Gleixner
9f9e3bb1cf
x86/apic: Add replacement for cpu_mask_to_apicid()
...
As preparation for replacing the vector allocator, provide a new function
which takes a cpu number instead of a cpu mask to calculate/lookup the
resulting APIC destination id.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
2017-09-25 20:51:56 +02:00
Thomas Gleixner
3534be05e4
x86/ioapic: Mark legacy vectors at reallocation time
...
When the legacy PIC vectors are taken over by the IO APIC the current
vector assignement code is tricked to reuse the vector by allocating the
apic data in the early boot process. This can be avoided by marking the
allocation as legacy PIC take over. Preparatory patch for further cleanups.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213154.700501979@linutronix.de
2017-09-25 20:51:54 +02:00
Thomas Gleixner
ef9e56d894
x86/ioapic: Remove obsolete post hotplug update
...
With single CPU affinities the post SMP boot vector update is pointless as
it will just leave the affinities on the same vectors and the same CPUs.
Remove it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213154.308697243@linutronix.de
2017-09-25 20:51:52 +02:00
Thomas Gleixner
7854f82293
x86/vector: Rename used_vectors to system_vectors
...
used_vectors is a nisnomer as it only has the system vectors which are
excluded from the regular vector allocation marked. It's not what the name
suggests storage for the actually used vectors.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213154.150209009@linutronix.de
2017-09-25 20:51:52 +02:00
Thomas Gleixner
c1d1ee9ac1
x86/apic: Get rid of apic->target_cpus
...
The target_cpus() callback of the apic struct is not really useful. Some
APICs return cpu_online_mask and others cpus_all_mask. The latter is bogus
as it does not take holes in the cpus_possible_mask into account.
Replace it with cpus_online_mask which makes the most sense and remove the
callback.
The usage sites will be removed in a later step anyway, so get rid of it
now to have incremental changes.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213154.070850916@linutronix.de
2017-09-25 20:51:51 +02:00
Thomas Gleixner
72f48a3850
x86/apic: Reorganize struct apic
...
struct apic has just grown over time by adding function pointers in random
places. Reorganize it so it becomes more cache line friendly.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.913642524@linutronix.de
2017-09-25 20:51:51 +02:00
Thomas Gleixner
83a105229c
x86/apic: Move common APIC callbacks
...
Move more apic struct specific functions out of the header and the apic
management code into the common source file.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.834421893@linutronix.de
2017-09-25 20:51:50 +02:00
Thomas Gleixner
6406350583
x86/apic: Sanitize 32/64bit APIC callbacks
...
The 32bit and the 64bit implementation of default_cpu_present_to_apicid()
and default_check_phys_apicid_present() are exactly the same, but
implemented and located differently.
Move them to common apic code and get rid of the pointless difference.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.757329991@linutronix.de
2017-09-25 20:51:50 +02:00
Thomas Gleixner
1da91779e1
x86/apic: Move APIC noop specific functions
...
Move more inlines to the place where they belong.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.677743545@linutronix.de
2017-09-25 20:51:49 +02:00
Thomas Gleixner
0801bbaac0
x86/apic: Move probe32 specific APIC functions
...
The apic functions which are used in probe_32.c are implemented as inlines
or in apic.c. There is no reason to have them at random places.
Move them to the actual usage site and make them static.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.596768194@linutronix.de
2017-09-25 20:51:49 +02:00
Thomas Gleixner
57e0aa4461
x86/apic: Sanitize return value of check_apicid_used()
...
The check is boolean, but the function returns unsigned long for no value.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.516730518@linutronix.de
2017-09-25 20:51:49 +02:00
Thomas Gleixner
727657e620
x86/apic: Sanitize return value of apic.set_apic_id()
...
The set_apic_id() callback returns an unsigned long value which is handed
in to apic_write() as the value argument u32.
Adjust the return value so it returns u32 right away.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.437208268@linutronix.de
2017-09-25 20:51:48 +02:00
Thomas Gleixner
981c2eac1c
x86/apic: Deinline x2apic functions
...
These inline functions are used in both the cluster and the physical x2apic
code to fill in the function pointers of the apic structure. That means the
code is generated twice for no reason.
Move it to a C code and reuse it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213153.358954066@linutronix.de
2017-09-25 20:51:48 +02:00
Thomas Gleixner
e4ae4c8ea7
Merge branch 'irq/core' into x86/apic
...
Pick up the dependencies for the vector management rework series.
2017-09-25 20:39:01 +02:00
Thomas Gleixner
7249164346
genirq/irqdomain: Update irq_domain_ops.activate() signature
...
The irq_domain_ops.activate() callback has no return value and no way to
tell the function that the activation is early.
The upcoming changes to support a reservation scheme which allows to assign
interrupt vectors on x86 only when the interrupt is actually requested
requires:
- A return value, so activation can fail at request_irq() time
- Information that the activate invocation is early, i.e. before
request_irq().
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Tested-by: Juergen Gross <jgross@suse.com >
Tested-by: Yu Chen <yu.c.chen@intel.com >
Acked-by: Juergen Gross <jgross@suse.com >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Tony Luck <tony.luck@intel.com >
Cc: Marc Zyngier <marc.zyngier@arm.com >
Cc: Alok Kataria <akataria@vmware.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net >
Cc: Steven Rostedt <rostedt@goodmis.org >
Cc: Christoph Hellwig <hch@lst.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Paolo Bonzini <pbonzini@redhat.com >
Cc: Rui Zhang <rui.zhang@intel.com >
Cc: "K. Y. Srinivasan" <kys@microsoft.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Dan Williams <dan.j.williams@intel.com >
Cc: Len Brown <lenb@kernel.org >
Link: https://lkml.kernel.org/r/20170913213152.848490816@linutronix.de
2017-09-25 20:38:24 +02:00
Dou Liyang
af5768507c
x86/timers: Make recalibrate_cpu_khz() void
...
recalibrate_cpu_khz() is called from powernow K7 and Pentium 4/Xeon
CPU freq driver. It recalibrates cpu frequency in case of SMP = n
and doesn't need to return anything.
Mark it void, also remove the #else branch.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Link: https://lkml.kernel.org/r/1500003247-17368-2-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:22:44 +02:00
Dou Liyang
eb496063c9
x86/timers: Move the simple udelay calibration to tsc.h
...
Commit dd759d93f4
("x86/timers: Add simple udelay calibration") adds
an static function in x86 boot-time initializations.
But, this function is actually related to TSC, so it should be maintained
in tsc.c, not in setup.c.
Move simple_udelay_calibration() from setup.c to tsc.c and rename it to
tsc_early_delay_calibrate for more readability.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Link: https://lkml.kernel.org/r/1500003247-17368-1-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:22:44 +02:00
Dou Liyang
b371ae0d4a
x86/apic: Remove init_bsp_APIC()
...
init_bsp_APIC() which works for the virtual wire mode is used in ISA irq
initialization at boot time.
With the new APIC interrupt delivery mode scheme, which initializes the
APIC before the first interrupt is expected, init_bsp_APIC() is not longer
required and can be removed.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: yinghai@kernel.org
Cc: bhe@redhat.com
Link: https://lkml.kernel.org/r/1505293975-26005-13-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:12:37 +02:00
Dou Liyang
34fba3e6b1
x86/init: Add intr_mode_init to x86_init_ops
...
X86 and XEN initialize interrupt delivery mode in different way.
To avoid conditionals, add a new x86_init_ops function which defaults to
the standard function and can be overridden by the early XEN platform code.
[ tglx: Folded the XEN part which was a separate patch to preserve
bisectability ]
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: yinghai@kernel.org
Cc: bhe@redhat.com
Link: https://lkml.kernel.org/r/1505293975-26005-10-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:03:17 +02:00
Dou Liyang
0c759131ae
x86/apic: Unify interrupt mode setup for UP system
...
In UniProcessor kernel with UP_LATE_INIT=y, the interrupt delivery mode is
initialized in up_late_init().
Use the new unified apic_intr_mode_init() function and remove
APIC_init_uniprocessor().
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: yinghai@kernel.org
Cc: bhe@redhat.com
Link: https://lkml.kernel.org/r/1505293975-26005-8-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:03:16 +02:00
Dou Liyang
4f45ed9f84
x86/apic: Mark the apic_intr_mode extern for sanity check cleanup
...
Calling native_smp_prepare_cpus() to prepare for SMP bootup, does some
sanity checking, enables APIC mode and disables SMP feature.
Now, APIC mode setup has been unified to apic_intr_mode_init(), some sanity
checks are redundant and need to be cleanup.
Mark the apic_intr_mode extern to refine the switch and remove the
redundant sanity check.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: yinghai@kernel.org
Cc: bhe@redhat.com
Link: https://lkml.kernel.org/r/1505293975-26005-7-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:03:16 +02:00
Dou Liyang
4b1244b45c
x86/apic: Move logical APIC ID away from apic_bsp_setup()
...
apic_bsp_setup() sets and returns logical APIC ID for initializing
cpu0_logical_apicid in a SMP-capable system.
The id has nothing to do with the initialization of local APIC and I/O
APIC. And apic_bsp_setup() should be called for interrupt mode setup only.
Move the id setup into a separate helper function for cleanup and mark
apic_bsp_setup() void.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: yinghai@kernel.org
Cc: bhe@redhat.com
Link: https://lkml.kernel.org/r/1505293975-26005-5-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:03:15 +02:00
Dou Liyang
4b1669e8d1
x86/apic: Prepare for unifying the interrupt delivery modes setup
...
There are three places which initialize the interrupt delivery modes:
1) init_bsp_APIC() which is called early might setup the through-local-APIC
virtual wire mode on non SMP systems.
2) In an SMP-capable system, native_smp_prepare_cpus() tries to switch to
symmetric I/O model.
3) In UP system with UP_LATE_INIT=y, the local APIC and I/O APIC are set up
in smp_init().
There is no technical reason to make these initializations at random places
and run the kernel with the potentially wrong mode through the early boot
stage, but it has a problematic side effect: The late switch to symmetric
I/O mode causes dump-capture kernel to hang when the kernel command line
option 'notsc' is active.
Provide a new function to unify that three positions. Preparatory patch to
initialize an interrupt mode directly.
Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: yinghai@kernel.org
Cc: bhe@redhat.com
Link: https://lkml.kernel.org/r/1505293975-26005-3-git-send-email-douly.fnst@cn.fujitsu.com
2017-09-25 15:03:14 +02:00
Ville Syrjälä
5ac751d9e6
x86: Don't cast away the __user in __get_user_asm_u64()
...
Don't cast away the __user in __get_user_asm_u64() on x86-32.
Prevents sparse getting upset.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Benjamin LaHaise <bcrl@kvack.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Link: http://lkml.kernel.org/r/20170912164000.13745-1-ville.syrjala@linux.intel.com
2017-09-25 09:36:16 +02:00
Eric Biggers
d5c8028b47
x86/fpu: Reinitialize FPU registers if restoring FPU state fails
...
Userspace can change the FPU state of a task using the ptrace() or
rt_sigreturn() system calls. Because reserved bits in the FPU state can
cause the XRSTOR instruction to fail, the kernel has to carefully
validate that no reserved bits or other invalid values are being set.
Unfortunately, there have been bugs in this validation code. For
example, we were not checking that the 'xcomp_bv' field in the
xstate_header was 0. As-is, such bugs are exploitable to read the FPU
registers of other processes on the system. To do so, an attacker can
create a task, assign to it an invalid FPU state, then spin in a loop
and monitor the values of the FPU registers. Because the task's FPU
registers are not being restored, sometimes the FPU registers will have
the values from another process.
This is likely to continue to be a problem in the future because the
validation done by the CPU instructions like XRSTOR is not immediately
visible to kernel developers. Nor will invalid FPU states ever be
encountered during ordinary use --- they will only be seen during
fuzzing or exploits. There can even be reserved bits outside the
xstate_header which are easy to forget about. For example, the MXCSR
register contains reserved bits, which were not validated by the
KVM_SET_XSAVE ioctl until commit a575813bfe
("KVM: x86: Fix load
damaged SSEx MXCSR register").
Therefore, mitigate this class of vulnerability by restoring the FPU
registers from init_fpstate if restoring from the task's state fails.
We actually used to do this, but it was (perhaps unwisely) removed by
commit 9ccc27a5d2
("x86/fpu: Remove error return values from
copy_kernel_to_*regs() functions"). This new patch is also a bit
different. First, it only clears the registers, not also the bad
in-memory state; this is simpler and makes it easier to make the
mitigation cover all callers of __copy_kernel_to_fpregs(). Second, it
does the register clearing in an exception handler so that no extra
instructions are added to context switches. In fact, we *remove*
instructions, since previously we were always zeroing the register
containing 'err' even if CONFIG_X86_DEBUG_FPU was disabled.
Signed-off-by: Eric Biggers <ebiggers@google.com >
Reviewed-by: Rik van Riel <riel@redhat.com >
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Dmitry Vyukov <dvyukov@google.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Kevin Hao <haokexin@gmail.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Michael Halcrow <mhalcrow@google.com >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Wanpeng Li <wanpeng.li@hotmail.com >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Cc: kernel-hardening@lists.openwall.com
Link: http://lkml.kernel.org/r/20170922174156.16780-4-ebiggers3@gmail.com
Link: http://lkml.kernel.org/r/20170923130016.21448-27-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-25 09:26:38 +02:00
Andi Kleen
03eaec81ac
x86/fpu: Turn WARN_ON() in context switch into WARN_ON_FPU()
...
copy_xregs_to_kernel checks if the alternatives have been already
patched.
This WARN_ON() is always executed in every context switch.
All the other checks in fpu internal.h are WARN_ON_FPU(), but
this one is plain WARN_ON(). I assume it was forgotten to switch it.
So switch it to WARN_ON_FPU() too to avoid some unnecessary code
in the context switch, and a potentially expensive cache line miss for the
global variable.
Signed-off-by: Andi Kleen <ak@linux.intel.com >
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170329062605.4970-1-andi@firstfloor.org
Link: http://lkml.kernel.org/r/20170923130016.21448-24-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:35 +02:00
Rik van Riel
0852b37417
x86/fpu: Add FPU state copying quirk to handle XRSTOR failure on Intel Skylake CPUs
...
On Skylake CPUs I noticed that XRSTOR is unable to deal with states
created by copyout_from_xsaves() if the xstate has only SSE/YMM state, and
no FP state. That is, xfeatures had XFEATURE_MASK_SSE set, but not
XFEATURE_MASK_FP.
The reason is that part of the SSE/YMM state lives in the MXCSR and
MXCSR_FLAGS fields of the FP state.
Ensure that whenever we copy SSE or YMM state around, the MXCSR and
MXCSR_FLAGS fields are also copied around.
Signed-off-by: Rik van Riel <riel@redhat.com >
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Borislav Petkov <bp@suse.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170210085445.0f1cc708@annuminas.surriel.com
Link: http://lkml.kernel.org/r/20170923130016.21448-22-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:34 +02:00
Ingo Molnar
99dc26bda2
x86/fpu: Remove struct fpu::fpregs_active
...
The previous changes paved the way for the removal of the
fpu::fpregs_active state flag - we now only have the
fpu::fpstate_active and fpu::last_cpu fields left.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-21-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:34 +02:00
Ingo Molnar
6cf4edbe05
x86/fpu: Decouple fpregs_activate()/fpregs_deactivate() from fpu->fpregs_active
...
The fpregs_activate()/fpregs_deactivate() are currently called in such a pattern:
if (!fpu->fpregs_active)
fpregs_activate(fpu);
...
if (fpu->fpregs_active)
fpregs_deactivate(fpu);
But note that it's actually safe to call them without checking the flag first.
This further decouples the fpu->fpregs_active flag from actual FPU logic.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-20-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:34 +02:00
Ingo Molnar
f1c8cd0176
x86/fpu: Change fpu->fpregs_active users to fpu->fpstate_active
...
We want to simplify the FPU state machine by eliminating fpu->fpregs_active,
and we can do that because the two state flags (::fpregs_active and
::fpstate_active) are set essentially together.
The old lazy FPU switching code used to make a distinction - but there's
no lazy switching code anymore, we always switch in an 'eager' fashion.
Do this by first changing all substantial uses of fpu->fpregs_active
to fpu->fpstate_active and adding a few debug checks to double check
our assumption is correct.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-19-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:34 +02:00
Ingo Molnar
b3a163081c
x86/fpu: Simplify fpu->fpregs_active use
...
The fpregs_active() inline function is pretty pointless - in almost
all the callsites it can be replaced with a direct fpu->fpregs_active
access.
Do so and eliminate the extra layer of obfuscation.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-16-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:33 +02:00
Ingo Molnar
6d7f7da553
x86/fpu: Flip the parameter order in copy_*_to_xstate()
...
Make it more consistent with regular memcpy() semantics, where the destination
argument comes first.
No change in functionality.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-15-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:33 +02:00
Ingo Molnar
7b9094c688
x86/fpu: Remove 'kbuf' parameter from the copy_user_to_xstate() API
...
No change in functionality.
Cc: Andrew Morton <akpm@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Eric Biggers <ebiggers3@gmail.com >
Cc: Fenghua Yu <fenghua.yu@intel.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Oleg Nesterov <oleg@redhat.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com >
Link: http://lkml.kernel.org/r/20170923130016.21448-14-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:33 +02:00