mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

- Add machine variable capacity information to /proc/sysinfo. - Limit the waste of page tables and always align vmalloc area size and base address on segment boundary. - Fix a memory leak when an attempt to register interruption sub class (ISC) for the adjunct-processor (AP) guest failed. - Reset response code AP_RESPONSE_INVALID_GISA to understandable by guest AP_RESPONSE_INVALID_ADDRESS in response to a failed interruption sub class (ISC) registration attempt. - Improve reaction to adjunct-processor (AP) AP_RESPONSE_OTHERWISE_CHANGED response code when enabling interrupts on behalf of a guest. - Fix incorrect sysfs 'status' attribute of adjunct-processor (AP) queue device bound to the vfio_ap device driver when the mediated device is attached to a guest, but the queue device is not passed through. - Rework struct ap_card to hold the whole adjunct-processor (AP) card hardware information. As result, all the ugly bit checks are replaced by simple evaluations of the required bit fields. - Improve handling of some weird scenarios between service element (SE) host and SE guest with adjunct-processor (AP) pass-through support. - Change local_ctl_set_bit() and local_ctl_clear_bit() so they return the previous value of the to be changed control register. This is useful if a bit is only changed temporarily and the previous content needs to be restored. - The kernel starts with machine checks disabled and is expected to enable it once trap_init() is called. However the implementation allows machine checks early. Consistently enable it in trap_init() only. - local_mcck_disable() and local_mcck_enable() assume that machine checks are always enabled. Instead implement and use local_mcck_save() and local_mcck_restore() to disable machine checks and restore the previous state. - Modification of floating point control (FPC) register of a traced process using ptrace interface may lead to corruption of the FPC register of the tracing process. Fix this. - kvm_arch_vcpu_ioctl_set_fpu() allows to set the floating point control (FPC) register in vCPU, but may lead to corruption of the FPC register of the host process. Fix this. - Use READ_ONCE() to read a vCPU floating point register value from the memory mapped area. This avoids that, depending on code generation, a different value is tested for validity than the one that is used. - Get rid of test_fp_ctl(), since it is quite subtle to use it correctly. Instead copy a new floating point control register value into its save area and test the validity of the new value when loading it. - Remove superfluous save_fpu_regs() call. - Remove s390 support for ARCH_WANTS_DYNAMIC_TASK_STRUCT. All machines provide the vector facility since many years and the need to make the task structure size dependent on the vector facility does not exist. - Remove the "novx" kernel command line option, as the vector code runs without any problems since many years. - Add the vector facility to the z13 architecture level set (ALS). All hypervisors support the vector facility since many years. This allows compile time optimizations of the kernel. - Get rid of MACHINE_HAS_VX and replace it with cpu_has_vx(). As result, the compiled code will have less runtime checks and less code. - Convert pgste_get_lock() and pgste_set_unlock() ASM inlines to C. - Convert the struct subchannel spinlock from pointer to member. -----BEGIN PGP SIGNATURE----- iI0EABYIADUWIQQrtrZiYVkVzKQcYivNdxKlNrRb8AUCZZxnchccYWdvcmRlZXZA bGludXguaWJtLmNvbQAKCRDNdxKlNrRb8PyGAP9Z0Z1Pm3hPf24M4FgY5uuRqBHo VoiuohOZRGONwifnsgEAmN/3ba/7d/j0iMwpUdUFouiqtwTUihh15wYx1sH2IA8= =F6YD -----END PGP SIGNATURE----- Merge tag 's390-6.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux Pull s390 updates from Alexander Gordeev: - Add machine variable capacity information to /proc/sysinfo. - Limit the waste of page tables and always align vmalloc area size and base address on segment boundary. - Fix a memory leak when an attempt to register interruption sub class (ISC) for the adjunct-processor (AP) guest failed. - Reset response code AP_RESPONSE_INVALID_GISA to understandable by guest AP_RESPONSE_INVALID_ADDRESS in response to a failed interruption sub class (ISC) registration attempt. - Improve reaction to adjunct-processor (AP) AP_RESPONSE_OTHERWISE_CHANGED response code when enabling interrupts on behalf of a guest. - Fix incorrect sysfs 'status' attribute of adjunct-processor (AP) queue device bound to the vfio_ap device driver when the mediated device is attached to a guest, but the queue device is not passed through. - Rework struct ap_card to hold the whole adjunct-processor (AP) card hardware information. As result, all the ugly bit checks are replaced by simple evaluations of the required bit fields. - Improve handling of some weird scenarios between service element (SE) host and SE guest with adjunct-processor (AP) pass-through support. - Change local_ctl_set_bit() and local_ctl_clear_bit() so they return the previous value of the to be changed control register. This is useful if a bit is only changed temporarily and the previous content needs to be restored. - The kernel starts with machine checks disabled and is expected to enable it once trap_init() is called. However the implementation allows machine checks early. Consistently enable it in trap_init() only. - local_mcck_disable() and local_mcck_enable() assume that machine checks are always enabled. Instead implement and use local_mcck_save() and local_mcck_restore() to disable machine checks and restore the previous state. - Modification of floating point control (FPC) register of a traced process using ptrace interface may lead to corruption of the FPC register of the tracing process. Fix this. - kvm_arch_vcpu_ioctl_set_fpu() allows to set the floating point control (FPC) register in vCPU, but may lead to corruption of the FPC register of the host process. Fix this. - Use READ_ONCE() to read a vCPU floating point register value from the memory mapped area. This avoids that, depending on code generation, a different value is tested for validity than the one that is used. - Get rid of test_fp_ctl(), since it is quite subtle to use it correctly. Instead copy a new floating point control register value into its save area and test the validity of the new value when loading it. - Remove superfluous save_fpu_regs() call. - Remove s390 support for ARCH_WANTS_DYNAMIC_TASK_STRUCT. All machines provide the vector facility since many years and the need to make the task structure size dependent on the vector facility does not exist. - Remove the "novx" kernel command line option, as the vector code runs without any problems since many years. - Add the vector facility to the z13 architecture level set (ALS). All hypervisors support the vector facility since many years. This allows compile time optimizations of the kernel. - Get rid of MACHINE_HAS_VX and replace it with cpu_has_vx(). As result, the compiled code will have less runtime checks and less code. - Convert pgste_get_lock() and pgste_set_unlock() ASM inlines to C. - Convert the struct subchannel spinlock from pointer to member. * tag 's390-6.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (24 commits) Revert "s390: update defconfigs" s390/cio: make sch->lock spinlock pointer a member s390: update defconfigs s390/mm: convert pgste locking functions to C s390/fpu: get rid of MACHINE_HAS_VX s390/als: add vector facility to z13 architecture level set s390/fpu: remove "novx" option s390/fpu: remove ARCH_WANTS_DYNAMIC_TASK_STRUCT support KVM: s390: remove superfluous save_fpu_regs() call s390/fpu: get rid of test_fp_ctl() KVM: s390: use READ_ONCE() to read fpc register value KVM: s390: fix setting of fpc register s390/ptrace: handle setting of fpc register correctly s390/nmi: implement and use local_mcck_save() / local_mcck_restore() s390/nmi: consistently enable machine checks in trap_init() s390/ctlreg: return old register contents when changing bits s390/ap: handle outband SE bind state change s390/ap: store TAPQ hwinfo in struct ap_card s390/vfio-ap: fix sysfs status attribute for AP queue devices s390/vfio-ap: improve reaction to response code 07 from PQAP(AQIC) command ...
126 lines
4.2 KiB
C
126 lines
4.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* In-kernel FPU support functions
|
|
*
|
|
*
|
|
* Consider these guidelines before using in-kernel FPU functions:
|
|
*
|
|
* 1. Use kernel_fpu_begin() and kernel_fpu_end() to enclose all in-kernel
|
|
* use of floating-point or vector registers and instructions.
|
|
*
|
|
* 2. For kernel_fpu_begin(), specify the vector register range you want to
|
|
* use with the KERNEL_VXR_* constants. Consider these usage guidelines:
|
|
*
|
|
* a) If your function typically runs in process-context, use the lower
|
|
* half of the vector registers, for example, specify KERNEL_VXR_LOW.
|
|
* b) If your function typically runs in soft-irq or hard-irq context,
|
|
* prefer using the upper half of the vector registers, for example,
|
|
* specify KERNEL_VXR_HIGH.
|
|
*
|
|
* If you adhere to these guidelines, an interrupted process context
|
|
* does not require to save and restore vector registers because of
|
|
* disjoint register ranges.
|
|
*
|
|
* Also note that the __kernel_fpu_begin()/__kernel_fpu_end() functions
|
|
* includes logic to save and restore up to 16 vector registers at once.
|
|
*
|
|
* 3. You can nest kernel_fpu_begin()/kernel_fpu_end() by using different
|
|
* struct kernel_fpu states. Vector registers that are in use by outer
|
|
* levels are saved and restored. You can minimize the save and restore
|
|
* effort by choosing disjoint vector register ranges.
|
|
*
|
|
* 5. To use vector floating-point instructions, specify the KERNEL_FPC
|
|
* flag to save and restore floating-point controls in addition to any
|
|
* vector register range.
|
|
*
|
|
* 6. To use floating-point registers and instructions only, specify the
|
|
* KERNEL_FPR flag. This flag triggers a save and restore of vector
|
|
* registers V0 to V15 and floating-point controls.
|
|
*
|
|
* Copyright IBM Corp. 2015
|
|
* Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
|
|
*/
|
|
|
|
#ifndef _ASM_S390_FPU_API_H
|
|
#define _ASM_S390_FPU_API_H
|
|
|
|
#include <linux/preempt.h>
|
|
#include <asm/asm-extable.h>
|
|
#include <asm/fpu/internal.h>
|
|
|
|
void save_fpu_regs(void);
|
|
void load_fpu_regs(void);
|
|
void __load_fpu_regs(void);
|
|
|
|
/**
|
|
* sfpc_safe - Set floating point control register safely.
|
|
* @fpc: new value for floating point control register
|
|
*
|
|
* Set floating point control register. This may lead to an exception,
|
|
* since a saved value may have been modified by user space (ptrace,
|
|
* signal return, kvm registers) to an invalid value. In such a case
|
|
* set the floating point control register to zero.
|
|
*/
|
|
static inline void sfpc_safe(u32 fpc)
|
|
{
|
|
asm volatile("\n"
|
|
"0: sfpc %[fpc]\n"
|
|
"1: nopr %%r7\n"
|
|
".pushsection .fixup, \"ax\"\n"
|
|
"2: lghi %[fpc],0\n"
|
|
" jg 0b\n"
|
|
".popsection\n"
|
|
EX_TABLE(1b, 2b)
|
|
: [fpc] "+d" (fpc)
|
|
: : "memory");
|
|
}
|
|
|
|
#define KERNEL_FPC 1
|
|
#define KERNEL_VXR_V0V7 2
|
|
#define KERNEL_VXR_V8V15 4
|
|
#define KERNEL_VXR_V16V23 8
|
|
#define KERNEL_VXR_V24V31 16
|
|
|
|
#define KERNEL_VXR_LOW (KERNEL_VXR_V0V7|KERNEL_VXR_V8V15)
|
|
#define KERNEL_VXR_MID (KERNEL_VXR_V8V15|KERNEL_VXR_V16V23)
|
|
#define KERNEL_VXR_HIGH (KERNEL_VXR_V16V23|KERNEL_VXR_V24V31)
|
|
|
|
#define KERNEL_VXR (KERNEL_VXR_LOW|KERNEL_VXR_HIGH)
|
|
#define KERNEL_FPR (KERNEL_FPC|KERNEL_VXR_LOW)
|
|
|
|
struct kernel_fpu;
|
|
|
|
/*
|
|
* Note the functions below must be called with preemption disabled.
|
|
* Do not enable preemption before calling __kernel_fpu_end() to prevent
|
|
* an corruption of an existing kernel FPU state.
|
|
*
|
|
* Prefer using the kernel_fpu_begin()/kernel_fpu_end() pair of functions.
|
|
*/
|
|
void __kernel_fpu_begin(struct kernel_fpu *state, u32 flags);
|
|
void __kernel_fpu_end(struct kernel_fpu *state, u32 flags);
|
|
|
|
|
|
static inline void kernel_fpu_begin(struct kernel_fpu *state, u32 flags)
|
|
{
|
|
preempt_disable();
|
|
state->mask = S390_lowcore.fpu_flags;
|
|
if (!test_cpu_flag(CIF_FPU))
|
|
/* Save user space FPU state and register contents */
|
|
save_fpu_regs();
|
|
else if (state->mask & flags)
|
|
/* Save FPU/vector register in-use by the kernel */
|
|
__kernel_fpu_begin(state, flags);
|
|
S390_lowcore.fpu_flags |= flags;
|
|
}
|
|
|
|
static inline void kernel_fpu_end(struct kernel_fpu *state, u32 flags)
|
|
{
|
|
S390_lowcore.fpu_flags = state->mask;
|
|
if (state->mask & flags)
|
|
/* Restore FPU/vector register in-use by the kernel */
|
|
__kernel_fpu_end(state, flags);
|
|
preempt_enable();
|
|
}
|
|
|
|
#endif /* _ASM_S390_FPU_API_H */
|