c/r: Add s390 support (resend)
Subsystems (3)
This is a re-send of my latest s390 patches for Oren to pick up. Nothing has changed since the last submission.
PATCH 1/3 s390: Expose a constant for the number of words representing the CRs
In reply to a message not in the archiveWe need to use this value in the checkpoint/restart code and would like to have a constant instead of a magic '3'.
Changelog:
Mar 03:
. Picked up additional use of magic '3' in ptrace.h
--- arch/s390/include/asm/ptrace.h | 4 +++- arch/s390/kernel/compat_ptrace.h | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-)
arch/s390/include/asm/ptrace.h +3 -1
@@ -172,6 +172,8 @@#define NUM_CRS 16#define NUM_ACRS 16 +#define NUM_CR_WORDS 3 +#define FPR_SIZE 8#define FPC_SIZE 4#define FPC_PAD_SIZE 4/* gcc insists on aligning the fpregs */
@@ -334,7 +336,7 @@ struct pt_regs*/ typedef struct { -unsigned long cr[3 ]; +unsigned long cr[NUM_CR_WORDS ]; }per_cr_words ;#define PER_EM_MASK 0xE8000000UL
arch/s390/kernel/compat_ptrace.h +2 -1
@@ -1,10 +1,11 @@ #ifndef _PTRACE32_H #define _PTRACE32_H +#include <asm/ptrace.h> /* needed for NUM_CR_WORDS */ #include "compat_linux.h" /* needed for psw_compat_t */ typedef struct { - __u32 cr[3]; + __u32 cr[NUM_CR_WORDS]; } per_cr_words32; typedef struct {
Signature · 1 line
1.6.1
PATCH 2/3 c/r: Add CR_COPY() macro (v4)
In reply to a message not in the archiveAs suggested by Dave[1], this provides us a way to make the copy-in and copy-out processes symmetric. CR_COPY_ARRAY() provides us a way to do the same thing but for arrays. It's not critical, but it helps us unify the checkpoint and restart paths for some things.
Changelog:
Mar 04:
. Removed semicolons
. Added build-time check for __must_be_array in CR_COPY_ARRAY
Feb 27:
. Changed CR_COPY() to use assignment, eliminating the need
for the CR_COPY_BIT() macro
. Add CR_COPY_ARRAY() macro to help copying register arrays,
etc
. Move the macro definitions inside the CR #ifdef
Feb 25:
. Changed WARN_ON() to BUILD_BUG_ON()
1: https://lists.linux-foundation.org/pipermail/containers/2009-February/015821.html (all the way at the bottom)
--- include/linux/checkpoint.h | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)
include/linux/checkpoint.h +23 -0
@@ -120,6 +120,29 @@ static inline int cr_enabled(void) return 1; } +#define CR_CPT 1 +#define CR_RST 2 + +#define CR_COPY (op, a, b) \ + do { \ + if (op == CR_CPT) \ + a = b; \ + else \ + b = a; \ + } while (0) + +/* Copy @count items from @b to @a if op is CR_CPT (otherwise, +* copy in the reverse direction) +*/ +#define CR_COPY_ARRAY (op, a, b, count) \ + do { \ + BUILD_BUG_ON(sizeof(*a) != sizeof(*b)); \ + if (op == CR_CPT) \ + memcpy(a, b, count * sizeof(*a)); \ + else \ + memcpy(b, a, count * sizeof(*a)); \ + } while (__must_be_array(a) && __must_be_array(b) && 0) +#else /* !CONFIG_CHECKPOINT_RESTART */ static inline void files_deny_checkpointing (struct files_struct *files) {}
Signature · 1 line
1.6.1
PATCH 3/3 c/r: define s390-specific checkpoint-restart code (v7)
In reply to a message not in the archiveImplement the s390 arch-specific checkpoint/restart helpers. This is on top of Oren Laadan's c/r code.
With these, I am able to checkpoint and restart simple programs as per Oren's patch intro. While on x86 I never had to freeze a single task to checkpoint it, on s390 I do need to. That is a prereq for consistent snapshots (esp with multiple processes) anyway so I don't see that as a problem.
Changelog:
Feb 27:
. Add checkpoint_s390.h
. Fixed up save and restore of PSW, with the non-address bits
properly masked out
Feb 25:
. Make checkpoint_hdr.h safe for inclusion in userspace . Replace comment about vsdo code
. Add comment about restoring access registers
. Write and read an empty cr_hdr_head_arch record to appease
code (mktree) that expects it to be there
. Utilize NUM_CR_WORDS in checkpoint_hdr.h
Feb 24:
. Use CR_COPY() to unify the un/loading of cpu and mm state . Fix fprs definition in cr_hdr_cpu
. Remove debug WARN_ON() from checkpoint.c
Feb 23:
. Macro-ize the un/packing of trace flags
. Fix the crash when externally-linked
. Break out the restart functions into restart.c . Remove unneeded s390_enable_sie() call
Jan 30:
. Switched types in cr_hdr_cpu to __u64 etc.
(Per Oren suggestion)
. Replaced direct inclusion of structs in
cr_hdr_cpu with the struct members.
(Per Oren suggestion)
. Also ended up adding a bunch of new things
into restart (mm_segment, ksp, etc) in vain attempt to get code using fpu to not segfault after restart.
--- arch/s390/include/asm/checkpoint_hdr.h | 88 ++++++++++++++++++++++ arch/s390/include/asm/unistd.h | 4 +- arch/s390/kernel/compat_wrapper.S | 12 +++ arch/s390/kernel/syscalls.S | 2 + arch/s390/mm/Makefile | 1 + arch/s390/mm/checkpoint.c | 125 ++++++++++++++++++++++++++++++++ arch/s390/mm/checkpoint_s390.h | 22 ++++++ arch/s390/mm/restart.c | 81 +++++++++++++++++++++ checkpoint/Kconfig | 2 +- 9 files changed, 335 insertions(+), 2 deletions(-) create mode 100644 arch/s390/include/asm/checkpoint_hdr.h create mode 100644 arch/s390/mm/checkpoint.c create mode 100644 arch/s390/mm/checkpoint_s390.h create mode 100644 arch/s390/mm/restart.c
arch/s390/include/asm/checkpoint_hdr.h new file +88 -0
@@ -0,0 +1,88 @@ +#ifndef __ASM_S390_CKPT_HDR_H +#define __ASM_S390_CKPT_HDR_H +/* +* Checkpoint/restart - architecture specific headers s/390 +* +* Copyright IBM Corp. 2009 +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file COPYING in the main directory of the Linux +* distribution for more details. +*/ + +#include <linux/types.h> +#include <asm/ptrace.h> + +#ifdef __KERNEL__ +#include <asm/processor.h> +#else +#include <sys/user.h> +#endif + +#ifdef __s390x__ + +/* +* Notes +* NUM_GPRS defined in <asm/ptrace.h> to be 16 +* NUM_FPRS defined in <asm/ptrace.h> to be 16 +* NUM_APRS defined in <asm/ptrace.h> to be 16 +* NUM_CR_WORDS defined in <asm/ptrace.h> to be 3 +*/ +struct cr_hdr_cpu { +__u64 args[1 ]; +__u64 gprs[NUM_GPRS ]; +__u64 orig_gpr2; +__u16 svcnr; +__u16 ilc; +__u32 acrs[NUM_ACRS ]; +__u64 ieee_instruction_pointer; + +/* psw_t */ +__u64 psw_t_mask; +__u64 psw_t_addr; + +/* s390_fp_regs_t */ +__u32 fpc; +union { +float f; +double d; +__u64 ui; +struct { +__u32 fp_hi; +__u32 fp_lo; + } fp; + } fprs[NUM_FPRS ]; + +/* per_struct */ +__u64 per_control_regs[NUM_CR_WORDS ]; +__u64 starting_addr; +__u64 ending_addr; +__u64 address; +__u16 perc_atmid; +__u8 access_id; +__u8 single_step; +__u8 instruction_fetch; +}; + +struct cr_hdr_mm_context { +unsigned long vdso_base; +int noexec; +int has_pgste; +int alloc_pgste; +unsigned long asce_bits; +unsigned long asce_limit; +}; + +struct cr_hdr_head_arch { +}; + +#ifdef __KERNEL__ +/* Functions for copying to/from the header structs */ +extern void cr_s390_regs (int op,struct cr_hdr_cpu *hh,struct task_struct *t); +extern void cr_s390_mm (int op,struct cr_hdr_mm_context *hh, +struct mm_struct *mm); +#endif + +#endif /* __s390x__ */ + +#endif /* __ASM_S390_CKPT_HDR__H */
arch/s390/include/asm/unistd.h +3 -1
@@ -265,7 +265,9 @@#define __NR_pipe2 325#define __NR_dup3 326#define __NR_epoll_create1 327 -#define NR_syscalls 328 +#define __NR_checkpoint 328 +#define __NR_restart 329 +#define NR_syscalls 330/* * There are some system calls that are not present on 64 bit, some
arch/s390/kernel/compat_wrapper.S +12 -0
@@ -1805,3 +1805,15 @@ compat_sys_keyctl_wrapper: llgfr %r5,%r5 # u32 llgfr %r6,%r6 # u32 jg compat_sys_keyctl # branch to system call + + .globl sys_checkpoint_wrapper +sys_checkpoint_wrapper: + lgfr %r2,%r2 # pid_t + lgfr %r3,%r3 # int + llgfr %r4,%r4 # unsigned long + + .globl sys_restart_wrapper +sys_restart_wrapper: + lgfr %r2,%r2 # int + lgfr %r3,%r3 # int + llgfr %r4,%r4 # unsigned long
arch/s390/kernel/syscalls.S +2 -0
@@ -336,3 +336,5 @@ SYSCALL(sys_inotify_init1,sys_inotify_init1,sys_inotify_init1_wrapper) SYSCALL(sys_pipe2,sys_pipe2,sys_pipe2_wrapper) /* 325 */ SYSCALL(sys_dup3,sys_dup3,sys_dup3_wrapper) SYSCALL(sys_epoll_create1,sys_epoll_create1,sys_epoll_create1_wrapper) +SYSCALL(sys_checkpoint,sys_checkpoint,sys_checkpoint_wrapper) +SYSCALL(sys_restart,sys_restart,sys_restart_wrapper)
arch/s390/mm/Makefile +1 -0
@@ -6,3 +6,4 @@ obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o obj-$(CONFIG_CMM) += cmm.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_PAGE_STATES) += page-states.o +obj-$(CONFIG_CHECKPOINT_RESTART) += checkpoint.o restart.o
arch/s390/mm/checkpoint.c new file +125 -0
125 lines not on this page · raw message
arch/s390/mm/checkpoint_s390.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* Checkpoint/restart - architecture specific support for s390 +* +* Copyright IBM Corp. 2009 +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file COPYING in the main directory of the Linux +* distribution for more details. +*/ + +#ifndef _S390_CHECKPOINT_H +#define _S390_CHECKPOINT_H + +#include <linux/checkpoint_hdr.h> +#include <linux/sched.h> +#include <linux/mm_types.h> + +extern void cr_s390_regs (int op,struct cr_hdr_cpu *hh,struct task_struct *t); +extern void cr_s390_mm (int op,struct cr_hdr_mm_context *hh, +struct mm_struct *mm); + +#endif /* _S390_CHECKPOINT_H */
arch/s390/mm/restart.c new file +81 -0
81 lines not on this page · raw message
checkpoint/Kconfig +1 -1
@@ -1,7 +1,7 @@ config CHECKPOINT_RESTART prompt "Enable checkpoint/restart (EXPERIMENTAL)" def_bool n - depends on X86_32 && EXPERIMENTAL + depends on (X86_32 || (S390 && 64BIT)) && EXPERIMENTAL help Application checkpoint/restart is the ability to save the state of a running application so that it can later resume
Signature · 1 line
1.6.1