Commit 50097710 authored by Michael Holzheu's avatar Michael Holzheu Committed by Pavel Emelyanov

s390:criu: Enable s390 in criu

Add s390 parts to common code files.

Patch history
-------------
v2->v3:

 * Add: Fix big endian byte order checks
Reviewed-by: 's avatarAlice Frosi <alice@linux.vnet.ibm.com>
Signed-off-by: 's avatarMichael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: 's avatarDmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent dc927a20
...@@ -16,6 +16,13 @@ ifeq ($(SRCARCH),arm) ...@@ -16,6 +16,13 @@ ifeq ($(SRCARCH),arm)
ccflags-y += -marm ccflags-y += -marm
endif endif
# We assume that compel code does not change floating point registers.
# On s390 gcc uses fprs to cache gprs. Therefore disable floating point
# with -msoft-float.
ifeq ($(SRCARCH),s390)
ccflags-y += -msoft-float
endif
asflags-y += -D__ASSEMBLY__ asflags-y += -D__ASSEMBLY__
LDS := compel/arch/$(SRCARCH)/scripts/compel-pack.lds.S LDS := compel/arch/$(SRCARCH)/scripts/compel-pack.lds.S
......
...@@ -41,3 +41,9 @@ ccflags-y += $(COMPEL_UAPI_INCLUDES) ...@@ -41,3 +41,9 @@ ccflags-y += $(COMPEL_UAPI_INCLUDES)
ifeq ($(SRCARCH),arm) ifeq ($(SRCARCH),arm)
ccflags-y += -marm ccflags-y += -marm
endif endif
# We assume that compel code does not change floating point registers.
# On s390 gcc uses fprs to cache gprs. Therefore disable floating point
# with -msoft-float.
ifeq ($(SRCARCH),s390)
ccflags-y += -msoft-float
endif
...@@ -68,6 +68,12 @@ static unsigned long elf_hash(const unsigned char *name) ...@@ -68,6 +68,12 @@ static unsigned long elf_hash(const unsigned char *name)
return h; return h;
} }
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define BORD ELFDATA2MSB /* 0x02 */
#else
#define BORD ELFDATA2LSB /* 0x01 */
#endif
static int has_elf_identity(Ehdr_t *ehdr) static int has_elf_identity(Ehdr_t *ehdr)
{ {
/* /*
...@@ -75,12 +81,12 @@ static int has_elf_identity(Ehdr_t *ehdr) ...@@ -75,12 +81,12 @@ static int has_elf_identity(Ehdr_t *ehdr)
*/ */
#if defined(CONFIG_VDSO_32) #if defined(CONFIG_VDSO_32)
static const char elf_ident[] = { static const char elf_ident[] = {
0x7f, 0x45, 0x4c, 0x46, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x45, 0x4c, 0x46, 0x01, BORD, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
#else #else
static const char elf_ident[] = { static const char elf_ident[] = {
0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00, 0x7f, 0x45, 0x4c, 0x46, 0x02, BORD, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}; };
#endif #endif
...@@ -202,17 +208,24 @@ err_oob: ...@@ -202,17 +208,24 @@ err_oob:
return -EFAULT; return -EFAULT;
} }
/* On s390x Hash_t is 64 bit */
#ifdef __s390x__
typedef unsigned long Hash_t;
#else
typedef Word_t Hash_t;
#endif
static void parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load, static void parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load,
struct vdso_symtable *t, uintptr_t dynsymbol_names, struct vdso_symtable *t, uintptr_t dynsymbol_names,
Word_t *hash, Dyn_t *dyn_symtab) Hash_t *hash, Dyn_t *dyn_symtab)
{ {
const char *vdso_symbols[VDSO_SYMBOL_MAX] = { const char *vdso_symbols[VDSO_SYMBOL_MAX] = {
ARCH_VDSO_SYMBOLS ARCH_VDSO_SYMBOLS
}; };
const size_t vdso_symbol_length = sizeof(t->symbols[0].name); const size_t vdso_symbol_length = sizeof(t->symbols[0].name);
Word_t nbucket, nchain; Hash_t nbucket, nchain;
Word_t *bucket, *chain; Hash_t *bucket, *chain;
unsigned int i, j, k; unsigned int i, j, k;
uintptr_t addr; uintptr_t addr;
...@@ -264,7 +277,7 @@ int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t) ...@@ -264,7 +277,7 @@ int vdso_fill_symtable(uintptr_t mem, size_t size, struct vdso_symtable *t)
Dyn_t *dyn_strtab = NULL; Dyn_t *dyn_strtab = NULL;
Dyn_t *dyn_symtab = NULL; Dyn_t *dyn_symtab = NULL;
Dyn_t *dyn_hash = NULL; Dyn_t *dyn_hash = NULL;
Word_t *hash = NULL; Hash_t *hash = NULL;
uintptr_t dynsymbol_names; uintptr_t dynsymbol_names;
uintptr_t addr; uintptr_t addr;
......
...@@ -105,6 +105,22 @@ static int dump_one_netlink_fd(int lfd, u32 id, const struct fd_parms *p) ...@@ -105,6 +105,22 @@ static int dump_one_netlink_fd(int lfd, u32 id, const struct fd_parms *p)
* On 64-bit sk->gsize is multiple to 8 bytes (sizeof(long)), * On 64-bit sk->gsize is multiple to 8 bytes (sizeof(long)),
* so remove the last 4 bytes if they are empty. * so remove the last 4 bytes if they are empty.
*/ */
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
/*
* Big endian swap: Ugly hack for zdtm/static/sk-netlink
*
* For big endian systems:
*
* - sk->groups[0] are bits 32-64
* - sk->groups[1] are bits 0-32
*/
if (ne.n_groups == 2) {
uint32_t tmp = sk->groups[1];
sk->groups[1] = sk->groups[0];
sk->groups[0] = tmp;
}
#endif
if (ne.n_groups && sk->groups[ne.n_groups - 1] == 0) if (ne.n_groups && sk->groups[ne.n_groups - 1] == 0)
ne.n_groups -= 1; ne.n_groups -= 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment