Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 916cda1a authored by Martin Schwidefsky's avatar Martin Schwidefsky
Browse files

s390: add a system call for guarded storage



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: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent 093b995e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@
#define HWCAP_S390_VXRS		2048
#define HWCAP_S390_VXRS_BCD	4096
#define HWCAP_S390_VXRS_EXT	8192
#define HWCAP_S390_GS		16384

/* Internal bits, not exposed via elf */
#define HWCAP_INT_SIE		1UL
+3 −6
Original line number Diff line number Diff line
@@ -157,8 +157,8 @@ struct lowcore {
	__u64	stfle_fac_list[32];		/* 0x0f00 */
	__u8	pad_0x1000[0x11b0-0x1000];	/* 0x1000 */

	/* Pointer to vector register save area */
	__u64	vector_save_area_addr;		/* 0x11b0 */
	/* Pointer to the machine check extended save area */
	__u64	mcesad;				/* 0x11b0 */

	/* 64 bit extparam used for pfault/diag 250: defined by architecture */
	__u64	ext_params2;			/* 0x11B8 */
@@ -182,10 +182,7 @@ struct lowcore {

	/* Transaction abort diagnostic block */
	__u8	pgm_tdb[256];			/* 0x1800 */
	__u8	pad_0x1900[0x1c00-0x1900];	/* 0x1900 */

	/* Software defined save area for vector registers */
	__u8	vector_save_area[1024];		/* 0x1c00 */
	__u8	pad_0x1900[0x2000-0x1900];	/* 0x1900 */
} __packed;

#define S390_lowcore (*((struct lowcore *) 0))
+11 −1
Original line number Diff line number Diff line
@@ -58,7 +58,9 @@ union mci {
		u64 ie :  1; /* 32 indirect storage error */
		u64 ar :  1; /* 33 access register validity */
		u64 da :  1; /* 34 delayed access exception */
		u64    :  7; /* 35-41 */
		u64    :  1; /* 35 */
		u64 gs :  1; /* 36 guarded storage registers */
		u64    :  5; /* 37-41 */
		u64 pr :  1; /* 42 tod programmable register validity */
		u64 fc :  1; /* 43 fp control register validity */
		u64 ap :  1; /* 44 ancillary report */
@@ -69,6 +71,14 @@ union mci {
	};
};

#define MCESA_ORIGIN_MASK	(~0x3ffUL)
#define MCESA_LC_MASK		(0xfUL)

struct mcesa {
	u8 vector_save_area[1024];
	u8 guarded_storage_save_area[32];
};

struct pt_regs;

extern void s390_handle_mcck(void);
+5 −0
Original line number Diff line number Diff line
@@ -135,6 +135,8 @@ struct thread_struct {
	struct list_head list;
	/* cpu runtime instrumentation */
	struct runtime_instr_cb *ri_cb;
	struct gs_cb *gs_cb;		/* Current guarded storage cb */
	struct gs_cb *gs_bc_cb;		/* Broadcast guarded storage cb */
	unsigned char trap_tdb[256];	/* Transaction abort diagnose block */
	/*
	 * Warning: 'fpu' is dynamically-sized. It *MUST* be at
@@ -215,6 +217,9 @@ void show_cacheinfo(struct seq_file *m);
/* Free all resources held by a thread. */
extern void release_thread(struct task_struct *);

/* Free guarded storage control block for current */
void exit_thread_gs(void);

/*
 * Return saved PC of a blocked thread.
 */
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#define MACHINE_FLAG_VX		_BITUL(13)
#define MACHINE_FLAG_CAD	_BITUL(14)
#define MACHINE_FLAG_NX		_BITUL(15)
#define MACHINE_FLAG_GS		_BITUL(16)

#define LPP_MAGIC		_BITUL(31)
#define LPP_PFAULT_PID_MASK	_AC(0xffffffff, UL)
@@ -70,6 +71,7 @@ extern void detect_memory_memblock(void);
#define MACHINE_HAS_VX		(S390_lowcore.machine_flags & MACHINE_FLAG_VX)
#define MACHINE_HAS_CAD		(S390_lowcore.machine_flags & MACHINE_FLAG_CAD)
#define MACHINE_HAS_NX		(S390_lowcore.machine_flags & MACHINE_FLAG_NX)
#define MACHINE_HAS_GS		(S390_lowcore.machine_flags & MACHINE_FLAG_GS)

/*
 * Console mode. Override with conmode=
Loading