mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
s390/acrs: cleanup access register handling
save_access_regs() and restore_access_regs() are only available by including switch_to.h. This is done by a couple of C files, which have nothing to do with switch_to(), but only need these functions. Move both functions to a new header file and improve the implementation: - Get rid of typedef - Add memory access instrumentation support - Use long displacement instructions lamy/stamy instead of lam/stam - all current users end up with better code because of this Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
parent
f78bcb2e26
commit
304103736b
38
arch/s390/include/asm/access-regs.h
Normal file
38
arch/s390/include/asm/access-regs.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
|
/*
|
||||||
|
* Copyright IBM Corp. 1999, 2024
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ASM_S390_ACCESS_REGS_H
|
||||||
|
#define __ASM_S390_ACCESS_REGS_H
|
||||||
|
|
||||||
|
#include <linux/instrumented.h>
|
||||||
|
#include <asm/sigcontext.h>
|
||||||
|
|
||||||
|
struct access_regs {
|
||||||
|
unsigned int regs[NUM_ACRS];
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline void save_access_regs(unsigned int *acrs)
|
||||||
|
{
|
||||||
|
struct access_regs *regs = (struct access_regs *)acrs;
|
||||||
|
|
||||||
|
instrument_write(regs, sizeof(*regs));
|
||||||
|
asm volatile("stamy 0,15,%[regs]"
|
||||||
|
: [regs] "=QS" (*regs)
|
||||||
|
:
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void restore_access_regs(unsigned int *acrs)
|
||||||
|
{
|
||||||
|
struct access_regs *regs = (struct access_regs *)acrs;
|
||||||
|
|
||||||
|
instrument_read(regs, sizeof(*regs));
|
||||||
|
asm volatile("lamy 0,15,%[regs]"
|
||||||
|
:
|
||||||
|
: [regs] "QS" (*regs)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* __ASM_S390_ACCESS_REGS_H */
|
@ -10,26 +10,13 @@
|
|||||||
|
|
||||||
#include <linux/thread_info.h>
|
#include <linux/thread_info.h>
|
||||||
#include <asm/fpu/api.h>
|
#include <asm/fpu/api.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/ptrace.h>
|
#include <asm/ptrace.h>
|
||||||
#include <asm/guarded_storage.h>
|
#include <asm/guarded_storage.h>
|
||||||
|
|
||||||
extern struct task_struct *__switch_to(void *, void *);
|
extern struct task_struct *__switch_to(void *, void *);
|
||||||
extern void update_cr_regs(struct task_struct *task);
|
extern void update_cr_regs(struct task_struct *task);
|
||||||
|
|
||||||
static inline void save_access_regs(unsigned int *acrs)
|
|
||||||
{
|
|
||||||
typedef struct { int _[NUM_ACRS]; } acrstype;
|
|
||||||
|
|
||||||
asm volatile("stam 0,15,%0" : "=Q" (*(acrstype *)acrs));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void restore_access_regs(unsigned int *acrs)
|
|
||||||
{
|
|
||||||
typedef struct { int _[NUM_ACRS]; } acrstype;
|
|
||||||
|
|
||||||
asm volatile("lam 0,15,%0" : : "Q" (*(acrstype *)acrs));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define switch_to(prev, next, last) do { \
|
#define switch_to(prev, next, last) do { \
|
||||||
/* save_fpu_regs() sets the CIF_FPU flag, which enforces \
|
/* save_fpu_regs() sets the CIF_FPU flag, which enforces \
|
||||||
* a restore of the floating point / vector registers as \
|
* a restore of the floating point / vector registers as \
|
||||||
|
@ -24,10 +24,10 @@
|
|||||||
#include <linux/tty.h>
|
#include <linux/tty.h>
|
||||||
#include <linux/personality.h>
|
#include <linux/personality.h>
|
||||||
#include <linux/binfmts.h>
|
#include <linux/binfmts.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/ucontext.h>
|
#include <asm/ucontext.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <asm/lowcore.h>
|
#include <asm/lowcore.h>
|
||||||
#include <asm/switch_to.h>
|
|
||||||
#include <asm/vdso.h>
|
#include <asm/vdso.h>
|
||||||
#include <asm/fpu/api.h>
|
#include <asm/fpu/api.h>
|
||||||
#include "compat_linux.h"
|
#include "compat_linux.h"
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <asm/asm-extable.h>
|
#include <asm/asm-extable.h>
|
||||||
#include <linux/memblock.h>
|
#include <linux/memblock.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
|
#include <asm/fpu/api.h>
|
||||||
#include <asm/diag.h>
|
#include <asm/diag.h>
|
||||||
#include <asm/ebcdic.h>
|
#include <asm/ebcdic.h>
|
||||||
#include <asm/ipl.h>
|
#include <asm/ipl.h>
|
||||||
@ -31,7 +33,6 @@
|
|||||||
#include <asm/sclp.h>
|
#include <asm/sclp.h>
|
||||||
#include <asm/facility.h>
|
#include <asm/facility.h>
|
||||||
#include <asm/boot_data.h>
|
#include <asm/boot_data.h>
|
||||||
#include <asm/switch_to.h>
|
|
||||||
#include "entry.h"
|
#include "entry.h"
|
||||||
|
|
||||||
#define decompressor_handled_param(param) \
|
#define decompressor_handled_param(param) \
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <linux/seccomp.h>
|
#include <linux/seccomp.h>
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
#include <trace/syscall.h>
|
#include <trace/syscall.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/page.h>
|
#include <asm/page.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <asm/unistd.h>
|
#include <asm/unistd.h>
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
#include <asm/ucontext.h>
|
#include <asm/ucontext.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/lowcore.h>
|
#include <asm/lowcore.h>
|
||||||
#include <asm/switch_to.h>
|
|
||||||
#include <asm/vdso.h>
|
#include <asm/vdso.h>
|
||||||
#include "entry.h"
|
#include "entry.h"
|
||||||
|
|
||||||
|
@ -36,11 +36,11 @@
|
|||||||
#include <linux/sched/task_stack.h>
|
#include <linux/sched/task_stack.h>
|
||||||
#include <linux/crash_dump.h>
|
#include <linux/crash_dump.h>
|
||||||
#include <linux/kprobes.h>
|
#include <linux/kprobes.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/asm-offsets.h>
|
#include <asm/asm-offsets.h>
|
||||||
#include <asm/ctlreg.h>
|
#include <asm/ctlreg.h>
|
||||||
#include <asm/pfault.h>
|
#include <asm/pfault.h>
|
||||||
#include <asm/diag.h>
|
#include <asm/diag.h>
|
||||||
#include <asm/switch_to.h>
|
|
||||||
#include <asm/facility.h>
|
#include <asm/facility.h>
|
||||||
#include <asm/ipl.h>
|
#include <asm/ipl.h>
|
||||||
#include <asm/setup.h>
|
#include <asm/setup.h>
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/pgtable.h>
|
#include <linux/pgtable.h>
|
||||||
#include <linux/bitfield.h>
|
#include <linux/bitfield.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/fault.h>
|
#include <asm/fault.h>
|
||||||
#include <asm/gmap.h>
|
#include <asm/gmap.h>
|
||||||
#include "kvm-s390.h"
|
#include "kvm-s390.h"
|
||||||
#include "gaccess.h"
|
#include "gaccess.h"
|
||||||
#include <asm/switch_to.h>
|
|
||||||
|
|
||||||
union asce {
|
union asce {
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/bitmap.h>
|
#include <linux/bitmap.h>
|
||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/asm-offsets.h>
|
#include <asm/asm-offsets.h>
|
||||||
#include <asm/dis.h>
|
#include <asm/dis.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <asm/sclp.h>
|
#include <asm/sclp.h>
|
||||||
#include <asm/isc.h>
|
#include <asm/isc.h>
|
||||||
#include <asm/gmap.h>
|
#include <asm/gmap.h>
|
||||||
#include <asm/switch_to.h>
|
|
||||||
#include <asm/nmi.h>
|
#include <asm/nmi.h>
|
||||||
#include <asm/airq.h>
|
#include <asm/airq.h>
|
||||||
#include <asm/tpi.h>
|
#include <asm/tpi.h>
|
||||||
|
@ -33,12 +33,12 @@
|
|||||||
#include <linux/pgtable.h>
|
#include <linux/pgtable.h>
|
||||||
#include <linux/mmu_notifier.h>
|
#include <linux/mmu_notifier.h>
|
||||||
|
|
||||||
|
#include <asm/access-regs.h>
|
||||||
#include <asm/asm-offsets.h>
|
#include <asm/asm-offsets.h>
|
||||||
#include <asm/lowcore.h>
|
#include <asm/lowcore.h>
|
||||||
#include <asm/stp.h>
|
#include <asm/stp.h>
|
||||||
#include <asm/gmap.h>
|
#include <asm/gmap.h>
|
||||||
#include <asm/nmi.h>
|
#include <asm/nmi.h>
|
||||||
#include <asm/switch_to.h>
|
|
||||||
#include <asm/isc.h>
|
#include <asm/isc.h>
|
||||||
#include <asm/sclp.h>
|
#include <asm/sclp.h>
|
||||||
#include <asm/cpacf.h>
|
#include <asm/cpacf.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user