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
Ingo Molnar
59dffa4edb
x86/fpu: Remove 'ubuf' parameter from the copy_kernel_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-13-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:33 +02:00
Ingo Molnar
79fecc2b75
x86/fpu: Split copy_user_to_xstate() into copy_kernel_to_xstate() & copy_user_to_xstate()
...
Similar to:
x86/fpu: Split copy_xstate_to_user() into copy_xstate_to_kernel() & copy_xstate_to_user()
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-12-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:32 +02:00
Ingo Molnar
56583c9a14
x86/fpu: Clarify parameter names in the copy_xstate_to_*() methods
...
Right now there's a confusing mixture of 'offset' and 'size' parameters:
- __copy_xstate_to_*() input parameter 'end_pos' not not really an offset,
but the full size of the copy to be performed.
- input parameter 'count' to copy_xstate_to_*() shadows that of
__copy_xstate_to_*()'s 'count' parameter name - but the roles
are different: the first one is the total number of bytes to
be copied, while the second one is a partial copy size.
To unconfuse all this, use a consistent set of parameter names:
- 'size' is the partial copy size within a single xstate component
- 'size_total' is the total copy requested
- 'offset_start' is the requested starting offset.
- 'offset' is the offset within an xstate component.
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-9-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:32 +02:00
Ingo Molnar
d7eda6c99c
x86/fpu: Clean up parameter order in the copy_xstate_to_*() APIs
...
Parameter ordering is weird:
int copy_xstate_to_kernel(unsigned int pos, unsigned int count, void *kbuf, struct xregs_state *xsave);
int copy_xstate_to_user(unsigned int pos, unsigned int count, void __user *ubuf, struct xregs_state *xsave);
'pos' and 'count', which are attributes of the destination buffer, are listed before the destination
buffer itself ...
List them after the primary arguments instead.
This makes the code more similar to regular memcpy() variant APIs.
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-6-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:31 +02:00
Ingo Molnar
a69c158fb3
x86/fpu: Remove 'kbuf' parameter from the copy_xstate_to_user() APIs
...
The 'kbuf' parameter is unused in the _user() side of the API, remove it.
This simplifies the code and makes it easier to think about.
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-5-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:31 +02:00
Ingo Molnar
4d981cf2d9
x86/fpu: Remove 'ubuf' parameter from the copy_xstate_to_kernel() APIs
...
The 'ubuf' parameter is unused in the _kernel() side of the API, remove it.
This simplifies the code and makes it easier to think about.
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-4-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:31 +02:00
Ingo Molnar
f0d4f30a7f
x86/fpu: Split copy_xstate_to_user() into copy_xstate_to_kernel() & copy_xstate_to_user()
...
copy_xstate_to_user() is a weird API - in part due to a bad API inherited
from the regset APIs.
But don't propagate that bad API choice into the FPU code - so as a first
step split the API into kernel and user buffer handling routines.
(Also split the xstate_copyout() internal helper.)
The split API is a dumb duplication that should be obviously correct, the
real splitting will be done in the next patch.
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-3-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:30 +02:00
Ingo Molnar
656f083116
x86/fpu: Rename copyin_to_xsaves()/copyout_from_xsaves() to copy_user_to_xstate()/copy_xstate_to_user()
...
The 'copyin/copyout' nomenclature needlessly departs from what the modern FPU code
uses, which is:
copy_fpregs_to_fpstate()
copy_fpstate_to_sigframe()
copy_fregs_to_user()
copy_fxregs_to_kernel()
copy_fxregs_to_user()
copy_kernel_to_fpregs()
copy_kernel_to_fregs()
copy_kernel_to_fxregs()
copy_kernel_to_xregs()
copy_user_to_fregs()
copy_user_to_fxregs()
copy_user_to_xregs()
copy_xregs_to_kernel()
copy_xregs_to_user()
I.e. according to this pattern, the following rename should be done:
copyin_to_xsaves() -> copy_user_to_xstate()
copyout_from_xsaves() -> copy_xstate_to_user()
or, if we want to be pedantic, denote that that the user-space format is ptrace:
copyin_to_xsaves() -> copy_user_ptrace_to_xstate()
copyout_from_xsaves() -> copy_xstate_to_user_ptrace()
But I'd suggest the shorter, non-pedantic name.
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-2-mingo@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 13:04:30 +02:00
Uros Bizjak
3c52b5c643
x86/asm: Remove unnecessary \n\t in front of CC_SET() from asm templates
...
There is no need for \n\t in front of CC_SET(), as the macro already includes these two.
Signed-off-by: Uros Bizjak <ubizjak@gmail.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/20170906151808.5634-1-ubizjak@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-24 11:19:01 +02:00
Josh Poimboeuf
f5caf621ee
x86/asm: Fix inline asm call constraints for Clang
...
For inline asm statements which have a CALL instruction, we list the
stack pointer as a constraint to convince GCC to ensure the frame
pointer is set up first:
static inline void foo()
{
register void *__sp asm(_ASM_SP);
asm("call bar" : "+r" (__sp))
}
Unfortunately, that pattern causes Clang to corrupt the stack pointer.
The fix is easy: convert the stack pointer register variable to a global
variable.
It should be noted that the end result is different based on the GCC
version. With GCC 6.4, this patch has exactly the same result as
before:
defconfig defconfig-nofp distro distro-nofp
before 9820389 9491555 8816046 8516940
after 9820389 9491555 8816046 8516940
With GCC 7.2, however, GCC's behavior has changed. It now changes its
behavior based on the conversion of the register variable to a global.
That somehow convinces it to *always* set up the frame pointer before
inserting *any* inline asm. (Therefore, listing the variable as an
output constraint is a no-op and is no longer necessary.) It's a bit
overkill, but the performance impact should be negligible. And in fact,
there's a nice improvement with frame pointers disabled:
defconfig defconfig-nofp distro distro-nofp
before 9796316 9468236 9076191 8790305
after 9796957 9464267 9076381 8785949
So in summary, while listing the stack pointer as an output constraint
is no longer necessary for newer versions of GCC, it's still needed for
older versions.
Suggested-by: Andrey Ryabinin <aryabinin@virtuozzo.com >
Reported-by: Matthias Kaehlcke <mka@chromium.org >
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Alexander Potapenko <glider@google.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Arnd Bergmann <arnd@arndb.de >
Cc: Dmitriy Vyukov <dvyukov@google.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: http://lkml.kernel.org/r/3db862e970c432ae823cf515c52b54fec8270e0e.1505942196.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-23 15:06:20 +02:00
Colin Ian King
51a9a8284e
x86/xen: clean up clang build warning
...
In the case where sizeof(maddr) != sizeof(long) p is initialized and
never read and clang throws a warning on this. Move declaration of
p to clean up the clang build warning:
warning: Value stored to 'p' during its initialization is never read
Signed-off-by: Colin Ian King <colin.king@canonical.com >
Reviewed-by: Juergen Gross <jgross@suse.com >
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com >
2017-09-21 12:34:03 -04:00
Andy Lutomirski
52a2af400c
x86/mm/64: Stop using CR3.PCID == 0 in ASID-aware code
...
Putting the logical ASID into CR3's PCID bits directly means that we
have two cases to consider separately: ASID == 0 and ASID != 0.
This means that bugs that only hit in one of these cases trigger
nondeterministically.
There were some bugs like this in the past, and I think there's
still one in current kernels. In particular, we have a number of
ASID-unware code paths that save CR3, write some special value, and
then restore CR3. This includes suspend/resume, hibernate, kexec,
EFI, and maybe other things I've missed. This is currently
dangerous: if ASID != 0, then this code sequence will leave garbage
in the TLB tagged for ASID 0. We could potentially see corruption
when switching back to ASID 0. In principle, an
initialize_tlbstate_and_flush() call after these sequences would
solve the problem, but EFI, at least, does not call this. (And it
probably shouldn't -- initialize_tlbstate_and_flush() is rather
expensive.)
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bpetkov@suse.de >
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/cdc14bbe5d3c3ef2a562be09a6368ffe9bd947a6.1505663533.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-17 18:59:08 +02:00
Andy Lutomirski
47061a24e2
x86/mm: Factor out CR3-building code
...
Current, the code that assembles a value to load into CR3 is
open-coded everywhere. Factor it out into helpers build_cr3() and
build_cr3_noflush().
This makes one semantic change: __get_current_cr3_fast() was wrong
on SME systems. No one noticed because the only caller is in the
VMX code, and there are no CPUs with both SME and VMX.
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bpetkov@suse.de >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Tom Lendacky <Thomas.Lendacky@amd.com >
Link: http://lkml.kernel.org/r/ce350cf11e93e2842d14d0b95b0199c7d881f527.1505663533.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-17 18:59:08 +02:00
Linus Torvalds
9db59599ae
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
...
Pull more KVM updates from Paolo Bonzini:
- PPC bugfixes
- RCU splat fix
- swait races fix
- pointless userspace-triggerable BUG() fix
- misc fixes for KVM_RUN corner cases
- nested virt correctness fixes + one host DoS
- some cleanups
- clang build fix
- fix AMD AVIC with default QEMU command line options
- x86 bugfixes
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (28 commits)
kvm: nVMX: Handle deferred early VMLAUNCH/VMRESUME failure properly
kvm: vmx: Handle VMLAUNCH/VMRESUME failure properly
kvm: nVMX: Remove nested_vmx_succeed after successful VM-entry
kvm,mips: Fix potential swait_active() races
kvm,powerpc: Serialize wq active checks in ops->vcpu_kick
kvm: Serialize wq active checks in kvm_vcpu_wake_up()
kvm,x86: Fix apf_task_wake_one() wq serialization
kvm,lapic: Justify use of swait_active()
kvm,async_pf: Use swq_has_sleeper()
sched/wait: Add swq_has_sleeper()
KVM: VMX: Do not BUG() on out-of-bounds guest IRQ
KVM: Don't accept obviously wrong gsi values via KVM_IRQFD
kvm: nVMX: Don't allow L2 to access the hardware CR8
KVM: trace events: update list of exit reasons
KVM: async_pf: Fix #DF due to inject "Page not Present" and "Page Ready" exceptions simultaneously
KVM: X86: Don't block vCPU if there is pending exception
KVM: SVM: Add irqchip_split() checks before enabling AVIC
KVM: Add struct kvm_vcpu pointer parameter to get_enable_apicv()
KVM: SVM: Refactor AVIC vcpu initialization into avic_init_vcpu()
KVM: x86: fix clang build
...
2017-09-15 15:43:55 -07:00
Suravee Suthikulpanit
b2a05feff2
KVM: Add struct kvm_vcpu pointer parameter to get_enable_apicv()
...
Modify struct kvm_x86_ops.arch.apicv_active() to take struct kvm_vcpu
pointer as parameter in preparation to subsequent changes.
Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com >
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com >
2017-09-13 18:29:06 +02:00
Joerg Roedel
98152b83e0
KVM: x86: Remove .get_pkru() from kvm_x86_ops
...
The commit
9dd21e104bc ('KVM: x86: simplify handling of PKRU')
removed all users and providers of that call-back, but
didn't remove it. Remove it now.
Signed-off-by: Joerg Roedel <jroedel@suse.de >
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com >
2017-09-13 15:33:04 +02:00
Vitaly Kuznetsov
1278f58cde
x86/hyper-v: Remove duplicated HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED definition
...
Commits:
7dcf90e9e0 ("PCI: hv: Use vPCI protocol version 1.2")
628f54cc64 ("x86/hyper-v: Support extended CPU ranges for TLB flush hypercalls")
added the same definition and they came in through different trees.
Fix the duplication.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com >
Cc: Haiyang Zhang <haiyangz@microsoft.com >
Cc: K. Y. Srinivasan <kys@microsoft.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Stephen Hemminger <sthemmin@microsoft.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: devel@linuxdriverproject.org
Link: http://lkml.kernel.org/r/20170911150620.3998-1-vkuznets@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-13 11:29:46 +02:00
Juergen Gross
87930019c7
x86/paravirt: Remove no longer used paravirt functions
...
With removal of lguest some of the paravirt functions are no longer
needed:
->read_cr4()
->store_idt()
->set_pmd_at()
->set_pud_at()
->pte_update()
Remove them.
Signed-off-by: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: akataria@vmware.com
Cc: boris.ostrovsky@oracle.com
Cc: chrisw@sous-sol.org
Cc: jeremy@goop.org
Cc: rusty@rustcorp.com.au
Cc: virtualization@lists.linux-foundation.org
Cc: xen-devel@lists.xenproject.org
Link: http://lkml.kernel.org/r/20170904102527.25409-1-jgross@suse.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-09-13 10:55:15 +02:00
Linus Torvalds
680352bda5
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
...
Pull x86 fixes from Ingo Molnar:
"Two fixes: dead code removal, plus a SME memory encryption fix on
32-bit kernels that crashed Xen guests"
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/cpu: Remove unused and undefined __generic_processor_info() declaration
x86/mm: Make the SME mask a u64
2017-09-12 11:34:39 -07:00