mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
916cda1aa1
This adds a new system call to enable the use of guarded storage for user space processes. The system call takes two arguments, a command and pointer to a guarded storage control block: s390_guarded_storage(int command, struct gs_cb *gs_cb); The second argument is relevant only for the GS_SET_BC_CB command. The commands in detail: 0 - GS_ENABLE Enable the guarded storage facility for the current task. The initial content of the guarded storage control block will be all zeros. After the enablement the user space code can use load-guarded-storage-controls instruction (LGSC) to load an arbitrary control block. While a task is enabled the kernel will save and restore the current content of the guarded storage registers on context switch. 1 - GS_DISABLE Disables the use of the guarded storage facility for the current task. The kernel will cease to save and restore the content of the guarded storage registers, the task specific content of these registers is lost. 2 - GS_SET_BC_CB Set a broadcast guarded storage control block. This is called per thread and stores a specific guarded storage control block in the task struct of the current task. This control block will be used for the broadcast event GS_BROADCAST. 3 - GS_CLEAR_BC_CB Clears the broadcast guarded storage control block. The guarded- storage control block is removed from the task struct that was established by GS_SET_BC_CB. 4 - GS_BROADCAST Sends a broadcast to all thread siblings of the current task. Every sibling that has established a broadcast guarded storage control block will load this control block and will be enabled for guarded storage. The broadcast guarded storage control block is used up, a second broadcast without a refresh of the stored control block with GS_SET_BC_CB will not have any effect. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
/*
|
|
* Copyright IBM Corp. 1999, 2009
|
|
*
|
|
* Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
|
|
*/
|
|
|
|
#ifndef __ASM_SWITCH_TO_H
|
|
#define __ASM_SWITCH_TO_H
|
|
|
|
#include <linux/thread_info.h>
|
|
#include <asm/fpu/api.h>
|
|
#include <asm/ptrace.h>
|
|
#include <asm/guarded_storage.h>
|
|
|
|
extern struct task_struct *__switch_to(void *, void *);
|
|
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 { \
|
|
if (prev->mm) { \
|
|
save_fpu_regs(); \
|
|
save_access_regs(&prev->thread.acrs[0]); \
|
|
save_ri_cb(prev->thread.ri_cb); \
|
|
save_gs_cb(prev->thread.gs_cb); \
|
|
} \
|
|
if (next->mm) { \
|
|
update_cr_regs(next); \
|
|
set_cpu_flag(CIF_FPU); \
|
|
restore_access_regs(&next->thread.acrs[0]); \
|
|
restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
|
|
restore_gs_cb(next->thread.gs_cb); \
|
|
} \
|
|
prev = __switch_to(prev,next); \
|
|
} while (0)
|
|
|
|
#endif /* __ASM_SWITCH_TO_H */
|