New hppa-linux-user target
cover New hppa-linux-user target
This is a linux-user only port, emulating a 32-bit only version of a pa-2.0 cpu. This is good enough to do well with both the gcc and glibc testsuites. Helge Deller has provided invaluable assistance testing with a more complete debian chroot.
What's missing:
* Space registers. Since Linux sets them all equal (for a flat address space) and uses them like address-space identifiers, we can simply set them all to 0 and ignore them.
* Architecture subsets. There's no markup for running a pure pa1.0 or pa1.1 cpu. I happily accept everything up to pa2.0 at the moment.
* Wide mode. While I have pa2.0 instructions, I don't support running in 64-bit mode. Since neither the linux kernel nor glibc support a 64-bit userland, it would be a lot more work than just adding the insns.
* Multimedia instructions. These are tied to wide mode, so...
When squashing the patches down from my development tree, I wanted to preserve Helge's contributions, so the linux-user part is more patches than I would normally have preserved.
r~
Helge Deller (3):
linux-user: Handle TIOCSTART and TIOCSTOP
linux-user: Add SIOCGPGRP, SIOCGSTAMP, SIOCGSTAMPNS
linux-user: Add some hppa ioctls
Richard Henderson (23):
Revert "Remove remainders of HPPA backend"
linux-user: Support stack-grows-up in elfload.c
linux-user: Handle ERFKILL and EHWPOISON
linux-user: Handle more IPV6 sockopts
linux-user: Add HPPA socket.h definitions
linux-user: Add HPPA syscall numbers
linux-user: Add HPPA termbits.h
linux-user: Add HPPA target_syscall.h
linux-user: Add HPPA definitions to syscall_defs.h
linux-user: Add HPPA target_structs.h
linux-user: Add HPPA target_signal.h and target_cpu.h
linux-user: Add HPPA signal handling
linux-user: Add HPPA startup and main loop
target-hppa: Add softfloat specializations
target-hppa: Add framework and enable compilation
target-hppa: Add nullification framework
target-hppa: Implement basic arithmetic
target-hppa: Implement branches
target-hppa: Implement linux-user gateway page
target-hppa: Implement shifts and deposits
target-hppa: Implement loads and stores
target-hppa: Implement system and memory-management insns
target-hppa: Implement floating-point insns
configure | 7 +- default-configs/hppa-linux-user.mak | 1 + disas.c | 2 + disas/Makefile.objs | 1 + disas/hppa.c | 2832 +++++++++++++++++++++++++ fpu/softfloat-specialize.h | 20 +- linux-user/alpha/target_syscall.h | 2 + linux-user/elfload.c | 259 ++- linux-user/errno_defs.h | 3 + linux-user/hppa/sockbits.h | 97 + linux-user/hppa/syscall_nr.h | 353 ++++ linux-user/hppa/target_cpu.h | 35 + linux-user/hppa/target_signal.h | 29 + linux-user/hppa/target_structs.h | 54 + linux-user/hppa/target_syscall.h | 237 +++ linux-user/hppa/termbits.h | 219 ++ linux-user/ioctls.h | 8 + linux-user/main.c | 185 +- linux-user/mips/target_syscall.h | 5 + linux-user/mips64/target_syscall.h | 5 + linux-user/qemu.h | 3 + linux-user/signal.c | 191 +- linux-user/socket.h | 2 + linux-user/syscall.c | 41 +- linux-user/syscall_defs.h | 154 +- linux-user/syscall_types.h | 6 + target-hppa/Makefile.objs | 1 + target-hppa/cpu-qom.h | 52 + target-hppa/cpu.c | 165 ++ target-hppa/cpu.h | 144 ++ target-hppa/gdbstub.c | 111 + target-hppa/helper.c | 137 ++ target-hppa/helper.h | 66 + target-hppa/op_helper.c | 570 +++++ target-hppa/translate.c | 3946 +++++++++++++++++++++++++++++++++++ 35 files changed, 9864 insertions(+), 79 deletions(-) create mode 100644 default-configs/hppa-linux-user.mak create mode 100644 disas/hppa.c create mode 100644 linux-user/hppa/sockbits.h create mode 100644 linux-user/hppa/syscall_nr.h create mode 100644 linux-user/hppa/target_cpu.h create mode 100644 linux-user/hppa/target_signal.h create mode 100644 linux-user/hppa/target_structs.h create mode 100644 linux-user/hppa/target_syscall.h create mode 100644 linux-user/hppa/termbits.h create mode 100644 target-hppa/Makefile.objs create mode 100644 target-hppa/cpu-qom.h create mode 100644 target-hppa/cpu.c create mode 100644 target-hppa/cpu.h create mode 100644 target-hppa/gdbstub.c create mode 100644 target-hppa/helper.c create mode 100644 target-hppa/helper.h create mode 100644 target-hppa/op_helper.c create mode 100644 target-hppa/translate.c
Signature · 1 line
2.9.3
PATCH 1/26 Revert "Remove remainders of HPPA backend"
This reverts commit d41f3c3cc7a5fb9de144cc4022da14a9ff010671.
--- configure | 5 + disas.c | 2 + disas/Makefile.objs | 1 + disas/hppa.c | 2832 +++++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 4 +- 5 files changed, 2842 insertions(+), 2 deletions(-) create mode 100644 disas/hppa.c
configure +5 -0
@@ -511,6 +511,8 @@ elif check_define __arm__ ; then cpu="arm" elif check_define __aarch64__ ; then cpu="aarch64" +elif check_define __hppa__ ; then + cpu="hppa" else cpu=$(uname -m) fi
@@ -6104,6 +6106,9 @@ for i in $ARCH $TARGET_BASE_ARCH ; do cris) disas_config "CRIS" ;; + hppa) + disas_config "HPPA" + ;; i386|x86_64|x32) disas_config "I386" ;;
disas.c +2 -0
@@ -310,6 +310,8 @@ void disas(FILE *out, void *code, unsigned long size) print_insn = print_insn_m68k;#elif defined(__s390__) print_insn = print_insn_s390; +#elif defined(__hppa__) + print_insn = print_insn_hppa;#elif defined(__ia64__) print_insn = print_insn_ia64;#endif
disas/Makefile.objs +1 -0
@@ -9,6 +9,7 @@ libvixldir = $(SRC_PATH)/disas/libvixl # versions do not. arm-a64.o-cflags := -I$(libvixldir) -Wno-sign-compare common-obj-$(CONFIG_CRIS_DIS) += cris.o +common-obj-$(CONFIG_HPPA_DIS) += hppa.o common-obj-$(CONFIG_I386_DIS) += i386.o common-obj-$(CONFIG_IA64_DIS) += ia64.o common-obj-$(CONFIG_M68K_DIS) += m68k.o
disas/hppa.c new file +2832 -0
2,832 lines not on this page · raw message
linux-user/syscall_defs.h +2 -2
@@ -2375,8 +2375,8 @@ struct target_flock {struct target_flock64 {short l_type;short l_whence; -#if defined(TARGET_PPC ) || defined(TARGET_X86_64 ) \ - || defined(TARGET_MIPS ) || defined(TARGET_SPARC ) \ +#if defined(TARGET_PPC ) || defined(TARGET_X86_64 ) || defined(TARGET_MIPS ) \ + || defined(TARGET_SPARC ) || defined(TARGET_HPPA ) \ || defined(TARGET_MICROBLAZE ) || defined(TARGET_TILEGX )int __pad;#endif
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH 01/26] Revert "Remove remainders of HPPA backend"
Quoted 1 line · Richard Henderson
This reverts commit
d41f3c3cc7a5fb9de144cc4022da14a9ff010671.
Missing signed-off-by.
Quoted 14 lines
--- configure | 5 + disas.c | 2 + disas/Makefile.objs | 1 + disas/hppa.c | 2832 +++++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 4 +- 5 files changed, 2842 insertions(+), 2 deletions(-) create mode 100644 disas/hppa.cconfigure +0
-0
configure elif check_define __arm__ ; then · line 518
Quoted 8 lines
configure +2
-0@@ -511,6 +511,8 @@ elif check_define __arm__ ; then cpu="arm" elif check_define __aarch64__ ; then cpu="aarch64" +elif check_define __hppa__ ; then + cpu="hppa" else cpu=$(uname -m) fi
This if-ladder is for detecting hppa host CPUs, so you don't want it for just adding the hppa target support. Or do you clean this up later in the series so that this commit is a pure revert?
thanks
-- PMM
Re: [Qemu-devel] [PATCH 01/26] Revert "Remove remainders of HPPA backend"
Quoted 4 lines · Peter Maydell
Quoted 1 line · Richard Henderson
This reverts commit
d41f3c3cc7a5fb9de144cc4022da14a9ff010671.Missing signed-off-by.
Oops.
Quoted 10 lines
configure elif check_define __arm__ ; then · line 518
Quoted 5 lines
configure +2
-0+elif check_define __hppa__ ; then + cpu="hppa" else cpu=$(uname -m) fiThis if-ladder is for detecting hppa host CPUs, so you don't want it for just adding the hppa target support. Or do you clean this up later in the series so that this commit is a pure revert?
I do remove this again in patch 18 (target-hppa: Add framework and enable compilation). So, yes, this is pure revert.
r~
PATCH 2/26 linux-user: Support stack-grows-up in elfload.c
In reply to Richard HendersonHPPA is a (the) stack-grows-up target, and supporting that requires rearranging how we compute addresses while laying out the initial program stack. In addition, hppa32 requires 64-byte stack alignment so parameterize that as well.
--- linux-user/elfload.c | 235 +++++++++++++++++++++++++++++++++++++-------------- linux-user/main.c | 13 +-- linux-user/qemu.h | 3 + 3 files changed, 180 insertions(+), 71 deletions(-)
linux-user/elfload.c +170 -65
@@ -1231,6 +1231,14 @@ static inline void init_thread(struct target_pt_regs *regs,#define ELF_HWCAP 0#endif +#ifndef STACK_GROWS_DOWN +#define STACK_GROWS_DOWN 1 +#endif + +#ifndef STACK_ALIGNMENT +#define STACK_ALIGNMENT 16 +#endif +#ifdef TARGET_ABI32 #undef ELF_CLASS#define ELF_CLASS ELFCLASS32
@@ -1374,45 +1382,78 @@ static abi_ulong copy_elf_strings(int argc, char **argv, char *scratch, abi_ulong p, abi_ulong stack_limit) { char *tmp; -int len, offset; +int len, i;abi_ulong top = p;if (!p) {return 0 ;/* bullet-proofing */ } - offset = ((p -1 ) %TARGET_PAGE_SIZE ) +1 ; +if (STACK_GROWS_DOWN ) { +int offset = ((p -1 ) %TARGET_PAGE_SIZE ) +1 ; +for (i = argc -1 ; i >=0 ; --i) { + tmp = argv[i]; +if (!tmp) { +fprintf (stderr,"VFS: argc is wrong" ); +exit (-1 ); + } + len =strlen (tmp) +1 ; + tmp += len; -while (argc-- >0 ) { - tmp = argv[argc]; -if (!tmp) { -fprintf (stderr,"VFS: argc is wrong" ); -exit (-1 ); +if (len > (p - stack_limit)) { +return 0 ; + } +while (len) { +int bytes_to_copy = (len > offset) ? offset : len; + tmp -= bytes_to_copy; + p -= bytes_to_copy; + offset -= bytes_to_copy; + len -= bytes_to_copy; + +memcpy_fromfs (scratch + offset, tmp, bytes_to_copy); + +if (offset ==0 ) { +memcpy_to_target (p, scratch, top - p); + top = p; + offset =TARGET_PAGE_SIZE ; + } + } } - len =strlen (tmp) +1 ; - tmp += len; - -if (len > (p - stack_limit)) { -return 0 ; +if (p != top) { +memcpy_to_target (p, scratch + offset, top - p); } -while (len) { -int bytes_to_copy = (len > offset) ? offset : len; - tmp -= bytes_to_copy; - p -= bytes_to_copy; - offset -= bytes_to_copy; - len -= bytes_to_copy; - -memcpy_fromfs (scratch + offset, tmp, bytes_to_copy); - -if (offset ==0 ) { -memcpy_to_target (p, scratch, top - p); - top = p; - offset =TARGET_PAGE_SIZE ; + }else { +int remaining =TARGET_PAGE_SIZE - (p %TARGET_PAGE_SIZE ); +for (i =0 ; i < argc; ++i) { + tmp = argv[i]; +if (!tmp) { +fprintf (stderr,"VFS: argc is wrong" ); +exit (-1 ); + } + len =strlen (tmp) +1 ; +if (len > (stack_limit - p)) { +return 0 ; + } +while (len) { +int bytes_to_copy = (len > remaining) ? remaining : len; + +memcpy_fromfs (scratch + (p - top), tmp, bytes_to_copy); + + tmp += bytes_to_copy; + remaining -= bytes_to_copy; + p += bytes_to_copy; + len -= bytes_to_copy; + +if (remaining ==0 ) { +memcpy_to_target (top, scratch, p - top); + top = p; + remaining =TARGET_PAGE_SIZE ; + } } } - } -if (offset) { -memcpy_to_target (p, scratch + offset, top - p); +if (p != top) { +memcpy_to_target (top, scratch, p - top); + } }return p;
@@ -1447,11 +1488,15 @@ static abi_ulong setup_arg_pages(struct linux_binprm *bprm, }/* We reserve one extra page at the top of the stack as guard. */ -target_mprotect (error, guard,PROT_NONE ); - - info->stack_limit = error + guard; - -return info->stack_limit + size -sizeof (void *); +if (STACK_GROWS_DOWN ) { +target_mprotect (error, guard,PROT_NONE ); + info->stack_limit = error + guard; +return info->stack_limit + size -sizeof (void *); + }else { +target_mprotect (error + size, guard,PROT_NONE ); + info->stack_limit = error + size; +return error; + } }/* Map and zero the bss. We need to explicitly zero any fractional pages
@@ -1529,7 +1574,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, struct image_info *interp_info) {abi_ulong sp; -abi_ulong sp_auxv; +abi_ulong u_argc, u_argv, u_envp, u_auxv;int size;int i;abi_ulong u_rand_bytes;
@@ -1558,10 +1603,25 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, k_platform =ELF_PLATFORM ;if (k_platform) {size_t len =strlen (k_platform) +1 ; - sp -= (len + n -1 ) & ~(n -1 ); - u_platform = sp; -/* FIXME - check return value of memcpy_to_target() for failure */ -memcpy_to_target (sp, k_platform, len); +if (STACK_GROWS_DOWN ) { + sp -= (len + n -1 ) & ~(n -1 ); + u_platform = sp; +/* FIXME - check return value of memcpy_to_target() for failure */ +memcpy_to_target (sp, k_platform, len); + }else { +memcpy_to_target (sp, k_platform, len); + u_platform = sp; + sp += len +1 ; + } + } + +/* Provide 16 byte alignment for the PRNG, and basic alignment for +* the argv and envp pointers. +*/ +if (STACK_GROWS_DOWN ) { + sp =QEMU_ALIGN_DOWN (sp,16 ); + }else { + sp =QEMU_ALIGN_UP (sp,16 ); }/*
@@ -1571,15 +1631,17 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,for (i =0 ; i <16 ; i++) { k_rand_bytes[i] =rand (); } - sp -=16 ; - u_rand_bytes = sp; -/* FIXME - check return value of memcpy_to_target() for failure */ -memcpy_to_target (sp, k_rand_bytes,16 ); +if (STACK_GROWS_DOWN ) { + sp -=16 ; + u_rand_bytes = sp; +/* FIXME - check return value of memcpy_to_target() for failure */ +memcpy_to_target (sp, k_rand_bytes,16 ); + }else { +memcpy_to_target (sp, k_rand_bytes,16 ); + u_rand_bytes = sp; + sp +=16 ; + } -/* -* Force 16 byte _final_ alignment here for generality. -*/ - sp = sp &~ (abi_ulong )15 ; size = (DLINFO_ITEMS +1 ) *2 ;if (k_platform) size +=2 ;
@@ -1592,20 +1654,31 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, size += envc + argc +2 ; size +=1 ;/* argc itself */ size *= n; -if (size &15 ) - sp -=16 - (size &15 ); + +/* Allocate space and finalize stack alignment for entry now. */ +if (STACK_GROWS_DOWN ) { + u_argc =QEMU_ALIGN_DOWN (sp - size,STACK_ALIGNMENT ); + sp = u_argc; + }else { + u_argc = sp; + sp =QEMU_ALIGN_UP (sp + size,STACK_ALIGNMENT ); + } + + u_argv = u_argc + n; + u_envp = u_argv + (argc +1 ) * n; + u_auxv = u_envp + (envc +1 ) * n; + info->saved_auxv = u_auxv; + info->arg_start = u_argv; + info->arg_end = u_argv + argc * n;/* This is correct because Linux defines * elf_addr_t as Elf32_Off / Elf64_Off */ #define NEW_AUX_ENT (id, val) do { \ - sp -= n; put_user_ual(val, sp); \ - sp -= n; put_user_ual(id, sp); \ + put_user_ual(id, u_auxv); u_auxv += n; \ + put_user_ual(val, u_auxv); u_auxv += n; \ } while(0) - sp_auxv = sp; -NEW_AUX_ENT (AT_NULL ,0 ); -/* There must be exactly DLINFO_ITEMS entries here. */ NEW_AUX_ENT (AT_PHDR , (abi_ulong)(info->load_addr + exec->e_phoff));NEW_AUX_ENT (AT_PHENT , (abi_ulong)(sizeof (struct elf_phdr )));
@@ -1626,8 +1699,9 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,NEW_AUX_ENT (AT_HWCAP2 , (abi_ulong )ELF_HWCAP2 );#endif -if (k_platform) +if (u_platform) {NEW_AUX_ENT (AT_PLATFORM , u_platform); + }#ifdef ARCH_DLINFO /* * ARCH_DLINFO must come last so platform specific code can enforce
@@ -1635,14 +1709,29 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,*/ ARCH_DLINFO ;#endif +NEW_AUX_ENT (AT_NULL ,0 );#undef NEW_AUX_ENT - info->saved_auxv = sp; - info->auxv_len = sp_auxv - sp; + info->auxv_len = u_argv - info->saved_auxv; + +put_user_ual (argc, u_argc); + + p = info->arg_strings; +for (i =0 ; i < argc; ++i) { +put_user_ual (p, u_argv); + u_argv += n; + p +=target_strlen (p) +1 ; + } +put_user_ual (0 , u_argv); + + p = info->env_strings; +for (i =0 ; i < envc; ++i) { +put_user_ual (p, u_envp); + u_envp += n; + p +=target_strlen (p) +1 ; + } +put_user_ual (0 , u_envp); - sp =loader_build_argptr (envc, argc, sp, p,0 ); -/* Check the right amount of stack was allocated for auxvec, envp & argv. */ -assert (sp_auxv - sp == size);return sp; }
@@ -2213,12 +2302,28 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) bprm->p =setup_arg_pages (bprm, info); scratch =g_new0 (char,TARGET_PAGE_SIZE ); - bprm->p =copy_elf_strings (1 , &bprm->filename, scratch, - bprm->p, info->stack_limit); - bprm->p =copy_elf_strings (bprm->envc, bprm->envp, scratch, - bprm->p, info->stack_limit); - bprm->p =copy_elf_strings (bprm->argc, bprm->argv, scratch, - bprm->p, info->stack_limit); +if (STACK_GROWS_DOWN ) { + bprm->p =copy_elf_strings (1 , &bprm->filename, scratch, + bprm->p, info->stack_limit); + info->file_string = bprm->p; + bprm->p =copy_elf_strings (bprm->envc, bprm->envp, scratch, + bprm->p, info->stack_limit); + info->env_strings = bprm->p; + bprm->p =copy_elf_strings (bprm->argc, bprm->argv, scratch, + bprm->p, info->stack_limit); + info->arg_strings = bprm->p; + }else { + info->arg_strings = bprm->p; + bprm->p =copy_elf_strings (bprm->argc, bprm->argv, scratch, + bprm->p, info->stack_limit); + info->env_strings = bprm->p; + bprm->p =copy_elf_strings (bprm->envc, bprm->envp, scratch, + bprm->p, info->stack_limit); + info->file_string = bprm->p; + bprm->p =copy_elf_strings (1 , &bprm->filename, scratch, + bprm->p, info->stack_limit); + } +g_free (scratch);if (!bprm->p) {
linux-user/main.c +7 -6
@@ -4172,15 +4172,16 @@ int main(int argc, char **argv, char **envp)qemu_log ("start_brk 0x" TARGET_ABI_FMT_lx"\n" , info->start_brk);qemu_log ("end_code 0x" TARGET_ABI_FMT_lx"\n" , info->end_code); -qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , - info->start_code); -qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , - info->start_data); +qemu_log ("start_code 0x" TARGET_ABI_FMT_lx"\n" , info->start_code); +qemu_log ("start_data 0x" TARGET_ABI_FMT_lx"\n" , info->start_data);qemu_log ("end_data 0x" TARGET_ABI_FMT_lx"\n" , info->end_data); -qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , - info->start_stack); +qemu_log ("start_stack 0x" TARGET_ABI_FMT_lx"\n" , info->start_stack);qemu_log ("brk 0x" TARGET_ABI_FMT_lx"\n" , info->brk);qemu_log ("entry 0x" TARGET_ABI_FMT_lx"\n" , info->entry); +qemu_log ("argv_start 0x" TARGET_ABI_FMT_lx"\n" , info->arg_start); +qemu_log ("env_start 0x" TARGET_ABI_FMT_lx"\n" , + info->arg_end + (abi_ulong )sizeof (abi_ulong)); +qemu_log ("auxv_start 0x" TARGET_ABI_FMT_lx"\n" , info->saved_auxv); }target_set_brk (info->brk);
linux-user/qemu.h +3 -0
@@ -48,6 +48,9 @@ struct image_info {abi_ulong auxv_len;abi_ulong arg_start;abi_ulong arg_end; +abi_ulong arg_strings; +abi_ulong env_strings; +abi_ulong file_string;uint32_t elf_flags;int personality;#ifdef CONFIG_USE_FDPIC
Signature · 1 line
2.9.3
PATCH 3/26 linux-user: Handle TIOCSTART and TIOCSTOP
In reply to Richard HendersonFrom: Helge Deller <[email protected]>
Some architectures (ppc, alpha, sparc, parisc, sh and xtensa) define the BSD TIOCSTART and TIOCSTOP ioctls in their kernel headers to provide compatibility to other operating systems.
Those ioctls are not implemented in Linux, nevertheless, bash will use this ioctl if it's available on those architectures.
To avoid false warnings, add code to simply ignore those ioctls.
Message-Id: <20161206152403.GA6651@ls3530>
--- linux-user/ioctls.h | 5 +++++ linux-user/syscall.c | 6 ++++++ 2 files changed, 11 insertions(+)
linux-user/ioctls.h +5 -0
@@ -422,3 +422,8 @@ MK_PTR(MK_STRUCT(STRUCT_rtentry))) IOCTL_SPECIAL(SIOCDELRT, IOC_W, do_ioctl_rt, MK_PTR(MK_STRUCT(STRUCT_rtentry))) + +#ifdef TARGET_TIOCSTART + IOCTL_IGNORE(TIOCSTART) + IOCTL_IGNORE(TIOCSTOP) +#endif
linux-user/syscall.c +6 -0
@@ -5453,6 +5453,8 @@ static IOCTLEntry ioctl_entries[] = { { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, #define IOCTL_SPECIAL(cmd, access, dofn, ...) \ { TARGET_ ## cmd, cmd, #cmd, access, dofn, { __VA_ARGS__ } }, +#define IOCTL_IGNORE(cmd) \ + { TARGET_ ## cmd, 0, #cmd }, #include "ioctls.h" { 0, 0, }, };
@@ -5484,6 +5486,10 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg)#endif if (ie->do_ioctl) {return ie->do_ioctl (ie, buf_temp, fd, cmd, arg); + }else if (!ie->host_cmd) { +/* Some architectures define BSD ioctls in their headers +that are not implemented in Linux. */ +return -TARGET_ENOSYS ; }switch (arg_type[0 ]) {
Signature · 1 line
2.9.3
PATCH 4/26 linux-user: Add SIOCGPGRP, SIOCGSTAMP, SIOCGSTAMPNS
In reply to Richard HendersonFrom: Helge Deller <[email protected]>
Mirror syscall_defs.h for the element type of struct timeval and struct timespec, even though that's not 100% accurate for each guest.
--- linux-user/ioctls.h | 3 +++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 6 ++++++ 3 files changed, 13 insertions(+)
linux-user/ioctls.h +3 -0
@@ -164,6 +164,9 @@ IOCTL(SIOCSRARP, IOC_W, MK_PTR(MK_STRUCT(STRUCT_arpreq))) IOCTL(SIOCGRARP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_arpreq))) IOCTL(SIOCGIWNAME, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_char_ifreq))) + IOCTL(SIOCGPGRP, IOC_R, MK_PTR(TYPE_INT)) /* pid_t */ + IOCTL(SIOCGSTAMP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval))) + IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec))) IOCTL(CDROMPAUSE, 0, TYPE_NULL)IOCTL (CDROMSTART ,0 ,TYPE_NULL )
linux-user/syscall_defs.h +4 -0
@@ -930,9 +930,13 @@ struct target_pollfd {#if defined(TARGET_ALPHA ) || defined(TARGET_MIPS ) || defined(TARGET_SH4 )#define TARGET_SIOCATMARK TARGET_IOR('s', 7, int) +#define TARGET_SIOCGPGRP TARGET_IOR('s', 9, pid_t)#else #define TARGET_SIOCATMARK 0x8905 +#define TARGET_SIOCGPGRP 0x8904#endif +#define TARGET_SIOCGSTAMP 0x8906/* Get stamp (timeval) */ +#define TARGET_SIOCGSTAMPNS 0x8907/* Get stamp (timespec) */ /* Networking ioctls */ #define TARGET_SIOCADDRT 0x890B/* add routing table entry */
linux-user/syscall_types.h +6 -0
@@ -14,6 +14,12 @@ STRUCT(serial_icounter_struct,STRUCT (sockaddr, TYPE_SHORT, MK_ARRAY(TYPE_CHAR, 14)) +STRUCT (timeval, + MK_ARRAY(TYPE_LONG, 2)) + +STRUCT (timespec, + MK_ARRAY(TYPE_LONG, 2)) + STRUCT(rtentry, TYPE_ULONG, MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), MK_STRUCT(STRUCT_sockaddr), TYPE_SHORT, TYPE_SHORT, TYPE_ULONG, TYPE_PTRVOID, TYPE_SHORT, TYPE_PTRVOID,
Signature · 1 line
2.9.3
PATCH 5/26 linux-user: Handle ERFKILL and EHWPOISON
In reply to Richard HendersonWith definitions for generic, alpha and mips taken from 4.9-rc2.
--- linux-user/alpha/target_syscall.h | 2 ++ linux-user/errno_defs.h | 3 +++ linux-user/mips/target_syscall.h | 5 +++++ linux-user/mips64/target_syscall.h | 5 +++++ linux-user/syscall.c | 6 ++++++ 5 files changed, 21 insertions(+)
linux-user/alpha/target_syscall.h +2 -0
@@ -235,6 +235,8 @@ struct target_pt_regs {#define TARGET_ENOTRECOVERABLE 137#undef TARGET_ERFKILL#define TARGET_ERFKILL 138 +#undef TARGET_EHWPOISON +#define TARGET_EHWPOISON 139// For sys_osf_getsysinfo #define TARGET_GSI_UACPROC 8
linux-user/errno_defs.h +3 -0
@@ -140,6 +140,9 @@#define TARGET_EOWNERDEAD 130/* Owner died */ #define TARGET_ENOTRECOVERABLE 131/* State not recoverable */ +#define TARGET_ERFKILL 132/* Operation not possible due to RF-kill */ +#define TARGET_EHWPOISON 133/* Memory page has hardware error */ +/* QEMU internal, not visible to the guest. This is returned when a * system call should be restarted, to tell the main loop that it * should wind the guest PC backwards so it will re-execute the syscall
linux-user/mips/target_syscall.h +5 -0
@@ -221,6 +221,11 @@ struct target_pt_regs {#undef TARGET_ENOTRECOVERABLE#define TARGET_ENOTRECOVERABLE 166/* State not recoverable */ +#undef TARGET_ERFKILL +#define TARGET_ERFKILL 167 +#undef TARGET_EHWPOISON +#define TARGET_EHWPOISON 168 +#undef TARGET_EDQUOT#define TARGET_EDQUOT 1133/* Quota exceeded */
linux-user/mips64/target_syscall.h +5 -0
@@ -218,6 +218,11 @@ struct target_pt_regs {#undef TARGET_ENOTRECOVERABLE#define TARGET_ENOTRECOVERABLE 166/* State not recoverable */ +#undef TARGET_ERFKILL +#define TARGET_ERFKILL 167 +#undef TARGET_EHWPOISON +#define TARGET_EHWPOISON 168 +#undef TARGET_EDQUOT#define TARGET_EDQUOT 1133/* Quota exceeded */
linux-user/syscall.c +6 -0
@@ -798,6 +798,12 @@ static uint16_t host_to_target_errno_table[ERRNO_TABLE_SIZE] = { #ifdef ENOMSG [ENOMSG ] =TARGET_ENOMSG , #endif +#ifdef ERKFILL + [ERFKILL ] =TARGET_ERFKILL , +#endif +#ifdef EHWPOISON + [EHWPOISON] = TARGET_EHWPOISON, +#endif };static inline int host_to_target_errno (int err)
Signature · 1 line
2.9.3
PATCH 6/26 linux-user: Handle more IPV6 sockopts
In reply to Richard HendersonAll of the ones added have an "int" parameter that needs no more adjustment to pass on to the host.
--- linux-user/syscall.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
linux-user/syscall.c +27 -2
@@ -2811,10 +2811,35 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,break ;case SOL_IPV6 :switch (optname) { -case IPV6_MTU_DISCOVER : -case IPV6_MTU :case IPV6_V6ONLY :case IPV6_RECVPKTINFO : +case IPV6_2292PKTINFO : +case IPV6_RECVHOPLIMIT : +case IPV6_2292HOPLIMIT : +case IPV6_RECVRTHDR : +case IPV6_2292RTHDR : +case IPV6_RECVHOPOPTS : +case IPV6_2292HOPOPTS : +case IPV6_RECVDSTOPTS : +case IPV6_2292DSTOPTS : +case IPV6_TCLASS : +case IPV6_RECVTCLASS : +case IPV6_RECVPATHMTU : +case IPV6_TRANSPARENT : +case IPV6_RECVORIGDSTADDR : +case IPV6_UNICAST_HOPS : +case IPV6_MULTICAST_HOPS : +case IPV6_MULTICAST_LOOP : +case IPV6_UNICAST_IF : +case IPV6_MULTICAST_IF : +case IPV6_ROUTER_ALERT : +case IPV6_MTU_DISCOVER : +case IPV6_MTU : +case IPV6_RECVERR : +case IPV6_ADDR_PREFERENCES : +case IPV6_MINHOPCOUNT : +case IPV6_DONTFRAG : +case IPV6_AUTOFLOWLABEL : val =0 ;if (optlen <sizeof (uint32_t )) {return -TARGET_EINVAL ;
Signature · 1 line
2.9.3
PATCH 8/26 linux-user: Add HPPA socket.h definitions
In reply to Richard HendersonSplit this out into a "cpu/sockbits.h" file now,
like we ought to do for all of the other targets.
--- linux-user/hppa/sockbits.h | 97 ++++++++++++++++++++++++++++++++++++++++++++++ linux-user/socket.h | 2 + 2 files changed, 99 insertions(+) create mode 100644 linux-user/hppa/sockbits.h
linux-user/hppa/sockbits.h new file +97 -0
@@ -0,0 +1,97 @@ +#define TARGET_SOL_SOCKET 0xffff + +#define TARGET_SO_DEBUG 0x0001 +#define TARGET_SO_REUSEADDR 0x0004 +#define TARGET_SO_KEEPALIVE 0x0008 +#define TARGET_SO_DONTROUTE 0x0010 +#define TARGET_SO_BROADCAST 0x0020 +#define TARGET_SO_LINGER 0x0080 +#define TARGET_SO_OOBINLINE 0x0100 +#define TARGET_SO_REUSEPORT 0x0200 +#define TARGET_SO_SNDBUF 0x1001 +#define TARGET_SO_RCVBUF 0x1002 +#define TARGET_SO_SNDBUFFORCE 0x100a +#define TARGET_SO_RCVBUFFORCE 0x100b +#define TARGET_SO_SNDLOWAT 0x1003 +#define TARGET_SO_RCVLOWAT 0x1004 +#define TARGET_SO_SNDTIMEO 0x1005 +#define TARGET_SO_RCVTIMEO 0x1006 +#define TARGET_SO_ERROR 0x1007 +#define TARGET_SO_TYPE 0x1008 +#define TARGET_SO_PROTOCOL 0x1028 +#define TARGET_SO_DOMAIN 0x1029 +#define TARGET_SO_PEERNAME 0x2000 +#define TARGET_SO_NO_CHECK 0x400b +#define TARGET_SO_PRIORITY 0x400c +#define TARGET_SO_BSDCOMPAT 0x400e +#define TARGET_SO_PASSCRED 0x4010 +#define TARGET_SO_PEERCRED 0x4011 +#define TARGET_SO_TIMESTAMP 0x4012 +#define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP +#define TARGET_SO_TIMESTAMPNS 0x4013 +#define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS + +#define TARGET_SO_SECURITY_AUTHENTICATION 0x4016 +#define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 0x4017 +#define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 0x4018 + +#define TARGET_SO_BINDTODEVICE 0x4019 +#define TARGET_SO_ATTACH_FILTER 0x401a +#define TARGET_SO_DETACH_FILTER 0x401b +#define TARGET_SO_GET_FILTER TARGET_SO_ATTACH_FILTER +#define TARGET_SO_ACCEPTCONN 0x401c +#define TARGET_SO_PEERSEC 0x401d +#define TARGET_SO_PASSSEC 0x401e +#define TARGET_SO_MARK 0x401f +#define TARGET_SO_TIMESTAMPING 0x4020 +#define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING +#define TARGET_SO_RXQ_OVFL 0x4021 +#define TARGET_SO_WIFI_STATUS 0x4022 +#define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS +#define TARGET_SO_PEEK_OFF 0x4023 +#define TARGET_SO_NOFCS 0x4024 +#define TARGET_SO_LOCK_FILTER 0x4025 +#define TARGET_SO_SELECT_ERR_QUEUE 0x4026 +#define TARGET_SO_BUSY_POLL 0x4027 +#define TARGET_SO_MAX_PACING_RATE 0x4028 +#define TARGET_SO_BPF_EXTENSIONS 0x4029 +#define TARGET_SO_INCOMING_CPU 0x402A +#define TARGET_SO_ATTACH_BPF 0x402B +#define TARGET_SO_DETACH_BPF TARGET_SO_DETACH_FILTER + +#define TARGET_SO_ATTACH_REUSEPORT_CBPF 0x402C +#define TARGET_SO_ATTACH_REUSEPORT_EBPF 0x402D + +#define TARGET_SO_CNX_ADVICE 0x402E + +/** sock_type - Socket types - default values +* +* +* @SOCK_STREAM - stream (connection) socket +* @SOCK_DGRAM - datagram (conn.less) socket +* @SOCK_RAW - raw socket +* @SOCK_RDM - reliably-delivered message +* @SOCK_SEQPACKET - sequential packet socket +* @SOCK_DCCP - Datagram Congestion Control Protocol socket +* @SOCK_PACKET - linux specific way of getting packets at the dev level. +* For writing rarp and other similar things on the user +* level. +* @SOCK_CLOEXEC - sets the close-on-exec (FD_CLOEXEC) flag. +* @SOCK_NONBLOCK - sets the O_NONBLOCK file status flag. +*/ +enum sock_type { +TARGET_SOCK_STREAM =1 , +TARGET_SOCK_DGRAM =2 , +TARGET_SOCK_RAW =3 , +TARGET_SOCK_RDM =4 , +TARGET_SOCK_SEQPACKET =5 , +TARGET_SOCK_DCCP =6 , +TARGET_SOCK_PACKET =10 , +TARGET_SOCK_CLOEXEC =010000000 , +TARGET_SOCK_NONBLOCK =0x40000000 , +}; + +#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) +#define TARGET_SOCK_TYPE_MASK 0xf/* Covers up to TARGET_SOCK_MAX-1. */ + +#define ARCH_HAS_SOCKET_TYPES 1
linux-user/socket.h +2 -0
@@ -205,6 +205,8 @@#define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)#define TARGET_SOCK_TYPE_MASK 0xf/* Covers up to TARGET_SOCK_MAX-1. */ +#elif defined(TARGET_HPPA ) +#include <hppa/sockbits.h> #else #if defined(TARGET_SPARC )
Signature · 1 line
2.9.3
PATCH 9/26 linux-user: Add HPPA syscall numbers
In reply to Richard Henderson--- linux-user/hppa/syscall_nr.h | 353 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 353 insertions(+) create mode 100644 linux-user/hppa/syscall_nr.h
linux-user/hppa/syscall_nr.h new file +353 -0
@@ -0,0 +1,353 @@ +/* +* This file contains the system call numbers. +*/ + +#define TARGET_NR_restart_syscall 0 +#define TARGET_NR_exit 1 +#define TARGET_NR_fork 2 +#define TARGET_NR_read 3 +#define TARGET_NR_write 4 +#define TARGET_NR_open 5 +#define TARGET_NR_close 6 +#define TARGET_NR_waitpid 7 +#define TARGET_NR_creat 8 +#define TARGET_NR_link 9 +#define TARGET_NR_unlink 10 +#define TARGET_NR_execve 11 +#define TARGET_NR_chdir 12 +#define TARGET_NR_time 13 +#define TARGET_NR_mknod 14 +#define TARGET_NR_chmod 15 +#define TARGET_NR_lchown 16 +#define TARGET_NR_socket 17 +#define TARGET_NR_stat 18 +#define TARGET_NR_lseek 19 +#define TARGET_NR_getpid 20 +#define TARGET_NR_mount 21 +#define TARGET_NR_bind 22 +#define TARGET_NR_setuid 23 +#define TARGET_NR_getuid 24 +#define TARGET_NR_stime 25 +#define TARGET_NR_ptrace 26 +#define TARGET_NR_alarm 27 +#define TARGET_NR_fstat 28 +#define TARGET_NR_pause 29 +#define TARGET_NR_utime 30 +#define TARGET_NR_connect 31 +#define TARGET_NR_listen 32 +#define TARGET_NR_access 33 +#define TARGET_NR_nice 34 +#define TARGET_NR_accept 35 +#define TARGET_NR_sync 36 +#define TARGET_NR_kill 37 +#define TARGET_NR_rename 38 +#define TARGET_NR_mkdir 39 +#define TARGET_NR_rmdir 40 +#define TARGET_NR_dup 41 +#define TARGET_NR_pipe 42 +#define TARGET_NR_times 43 +#define TARGET_NR_getsockname 44 +#define TARGET_NR_brk 45 +#define TARGET_NR_setgid 46 +#define TARGET_NR_getgid 47 +#define TARGET_NR_signal 48 +#define TARGET_NR_geteuid 49 +#define TARGET_NR_getegid 50 +#define TARGET_NR_acct 51 +#define TARGET_NR_umount2 52 +#define TARGET_NR_getpeername 53 +#define TARGET_NR_ioctl 54 +#define TARGET_NR_fcntl 55 +#define TARGET_NR_socketpair 56 +#define TARGET_NR_setpgid 57 +#define TARGET_NR_send 58 +#define TARGET_NR_uname 59 +#define TARGET_NR_umask 60 +#define TARGET_NR_chroot 61 +#define TARGET_NR_ustat 62 +#define TARGET_NR_dup2 63 +#define TARGET_NR_getppid 64 +#define TARGET_NR_getpgrp 65 +#define TARGET_NR_setsid 66 +#define TARGET_NR_pivot_root 67 +#define TARGET_NR_sgetmask 68 +#define TARGET_NR_ssetmask 69 +#define TARGET_NR_setreuid 70 +#define TARGET_NR_setregid 71 +#define TARGET_NR_mincore 72 +#define TARGET_NR_sigpending 73 +#define TARGET_NR_sethostname 74 +#define TARGET_NR_setrlimit 75 +#define TARGET_NR_getrlimit 76 +#define TARGET_NR_getrusage 77 +#define TARGET_NR_gettimeofday 78 +#define TARGET_NR_settimeofday 79 +#define TARGET_NR_getgroups 80 +#define TARGET_NR_setgroups 81 +#define TARGET_NR_sendto 82 +#define TARGET_NR_symlink 83 +#define TARGET_NR_lstat 84 +#define TARGET_NR_readlink 85 +#define TARGET_NR_uselib 86 +#define TARGET_NR_swapon 87 +#define TARGET_NR_reboot 88 +#define TARGET_NR_mmap2 89 +#define TARGET_NR_mmap 90 +#define TARGET_NR_munmap 91 +#define TARGET_NR_truncate 92 +#define TARGET_NR_ftruncate 93 +#define TARGET_NR_fchmod 94 +#define TARGET_NR_fchown 95 +#define TARGET_NR_getpriority 96 +#define TARGET_NR_setpriority 97 +#define TARGET_NR_recv 98 +#define TARGET_NR_statfs 99 +#define TARGET_NR_fstatfs 100 +#define TARGET_NR_stat64 101 +#define TARGET_NR_socketcall 102 +#define TARGET_NR_syslog 103 +#define TARGET_NR_setitimer 104 +#define TARGET_NR_getitimer 105 +#define TARGET_NR_capget 106 +#define TARGET_NR_capset 107 +#define TARGET_NR_pread64 108 +#define TARGET_NR_pwrite64 109 +#define TARGET_NR_getcwd 110 +#define TARGET_NR_vhangup 111 +#define TARGET_NR_fstat64 112 +#define TARGET_NR_vfork 113 +#define TARGET_NR_wait4 114 +#define TARGET_NR_swapoff 115 +#define TARGET_NR_sysinfo 116 +#define TARGET_NR_shutdown 117 +#define TARGET_NR_fsync 118 +#define TARGET_NR_madvise 119 +#define TARGET_NR_clone 120 +#define TARGET_NR_setdomainname 121 +#define TARGET_NR_sendfile 122 +#define TARGET_NR_recvfrom 123 +#define TARGET_NR_adjtimex 124 +#define TARGET_NR_mprotect 125 +#define TARGET_NR_sigprocmask 126 +#define TARGET_NR_create_module 127 +#define TARGET_NR_init_module 128 +#define TARGET_NR_delete_module 129 +#define TARGET_NR_get_kernel_syms 130 +#define TARGET_NR_quotactl 131 +#define TARGET_NR_getpgid 132 +#define TARGET_NR_fchdir 133 +#define TARGET_NR_bdflush 134 +#define TARGET_NR_sysfs 135 +#define TARGET_NR_personality 136 +#define TARGET_NR_afs_syscall 137/* Syscall for Andrew File System */ +#define TARGET_NR_setfsuid 138 +#define TARGET_NR_setfsgid 139 +#define TARGET_NR__llseek 140 +#define TARGET_NR_getdents 141 +#define TARGET_NR__newselect 142 +#define TARGET_NR_flock 143 +#define TARGET_NR_msync 144 +#define TARGET_NR_readv 145 +#define TARGET_NR_writev 146 +#define TARGET_NR_getsid 147 +#define TARGET_NR_fdatasync 148 +#define TARGET_NR__sysctl 149 +#define TARGET_NR_mlock 150 +#define TARGET_NR_munlock 151 +#define TARGET_NR_mlockall 152 +#define TARGET_NR_munlockall 153 +#define TARGET_NR_sched_setparam 154 +#define TARGET_NR_sched_getparam 155 +#define TARGET_NR_sched_setscheduler 156 +#define TARGET_NR_sched_getscheduler 157 +#define TARGET_NR_sched_yield 158 +#define TARGET_NR_sched_get_priority_max 159 +#define TARGET_NR_sched_get_priority_min 160 +#define TARGET_NR_sched_rr_get_interval 161 +#define TARGET_NR_nanosleep 162 +#define TARGET_NR_mremap 163 +#define TARGET_NR_setresuid 164 +#define TARGET_NR_getresuid 165 +#define TARGET_NR_sigaltstack 166 +#define TARGET_NR_query_module 167 +#define TARGET_NR_poll 168 +#define TARGET_NR_nfsservctl 169 +#define TARGET_NR_setresgid 170 +#define TARGET_NR_getresgid 171 +#define TARGET_NR_prctl 172 +#define TARGET_NR_rt_sigreturn 173 +#define TARGET_NR_rt_sigaction 174 +#define TARGET_NR_rt_sigprocmask 175 +#define TARGET_NR_rt_sigpending 176 +#define TARGET_NR_rt_sigtimedwait 177 +#define TARGET_NR_rt_sigqueueinfo 178 +#define TARGET_NR_rt_sigsuspend 179 +#define TARGET_NR_chown 180 +#define TARGET_NR_setsockopt 181 +#define TARGET_NR_getsockopt 182 +#define TARGET_NR_sendmsg 183 +#define TARGET_NR_recvmsg 184 +#define TARGET_NR_semop 185 +#define TARGET_NR_semget 186 +#define TARGET_NR_semctl 187 +#define TARGET_NR_msgsnd 188 +#define TARGET_NR_msgrcv 189 +#define TARGET_NR_msgget 190 +#define TARGET_NR_msgctl 191 +#define TARGET_NR_shmat 192 +#define TARGET_NR_shmdt 193 +#define TARGET_NR_shmget 194 +#define TARGET_NR_shmctl 195 +#define TARGET_NR_getpmsg 196 +#define TARGET_NR_putpmsg 197 +#define TARGET_NR_lstat64 198 +#define TARGET_NR_truncate64 199 +#define TARGET_NR_ftruncate64 200 +#define TARGET_NR_getdents64 201 +#define TARGET_NR_fcntl64 202 +#define TARGET_NR_attrctl 203 +#define TARGET_NR_acl_get 204 +#define TARGET_NR_acl_set 205 +#define TARGET_NR_gettid 206 +#define TARGET_NR_readahead 207 +#define TARGET_NR_tkill 208 +#define TARGET_NR_sendfile64 209 +#define TARGET_NR_futex 210 +#define TARGET_NR_sched_setaffinity 211 +#define TARGET_NR_sched_getaffinity 212 +#define TARGET_NR_set_thread_area 213 +#define TARGET_NR_get_thread_area 214 +#define TARGET_NR_io_setup 215 +#define TARGET_NR_io_destroy 216 +#define TARGET_NR_io_getevents 217 +#define TARGET_NR_io_submit 218 +#define TARGET_NR_io_cancel 219 +#define TARGET_NR_alloc_hugepages 220 +#define TARGET_NR_free_hugepages 221 +#define TARGET_NR_exit_group 222 +#define TARGET_NR_lookup_dcookie 223 +#define TARGET_NR_epoll_create 224 +#define TARGET_NR_epoll_ctl 225 +#define TARGET_NR_epill_wait 226 +#define TARGET_NR_remap_file_pages 227 +#define TARGET_NR_semtimedop 228 +#define TARGET_NR_mq_open 229 +#define TARGET_NR_mq_unlink 230 +#define TARGET_NR_mq_timedsend 231 +#define TARGET_NR_mq_timedreceive 232 +#define TARGET_NR_mq_notify 233 +#define TARGET_NR_mq_getsetattr 234 +#define TARGET_NR_waitid 235 +#define TARGET_NR_fadvise64_64 236 +#define TARGET_NR_set_tid_address 237 +#define TARGET_NR_setxattr 238 +#define TARGET_NR_lsetxattr 239 +#define TARGET_NR_fsetxattr 240 +#define TARGET_NR_getxattr 241 +#define TARGET_NR_lgetxattr 242 +#define TARGET_NR_fgetxattr 243 +#define TARGET_NR_listxattr 244 +#define TARGET_NR_llistxattr 245 +#define TARGET_NR_flistxattr 246 +#define TARGET_NR_removexattr 247 +#define TARGET_NR_lremovexattr 248 +#define TARGET_NR_fremovexattr 249 +#define TARGET_NR_timer_create 250 +#define TARGET_NR_timer_settime 251 +#define TARGET_NR_timer_gettime 252 +#define TARGET_NR_timer_getoverrun 253 +#define TARGET_NR_timer_delete 254 +#define TARGET_NR_clock_settime 255 +#define TARGET_NR_clock_gettime 256 +#define TARGET_NR_clock_getres 257 +#define TARGET_NR_clock_nanosleep 258 +#define TARGET_NR_tgkill 259 +#define TARGET_NR_mbind 260 +#define TARGET_NR_get_mempolicy 261 +#define TARGET_NR_set_mempolicy 262 +#define TARGET_NR_vserver 263 +#define TARGET_NR_add_key 264 +#define TARGET_NR_request_key 265 +#define TARGET_NR_keyctl 266 +#define TARGET_NR_ioprio_set 267 +#define TARGET_NR_ioprio_get 268 +#define TARGET_NR_inotify_init 269 +#define TARGET_NR_inotify_add_watch 270 +#define TARGET_NR_inotify_rm_watch 271 +#define TARGET_NR_migrate_pages 272 +#define TARGET_NR_pselect6 273 +#define TARGET_NR_ppoll 274 +#define TARGET_NR_openat 275 +#define TARGET_NR_mkdirat 276 +#define TARGET_NR_mknotat 277 +#define TARGET_NR_fchownat 278 +#define TARGET_NR_futimesat 279 +#define TARGET_NR_fstatat64 280 +#define TARGET_NR_unlinkat 281 +#define TARGET_NR_renameat 282 +#define TARGET_NR_linkat 283 +#define TARGET_NR_symlinkat 284 +#define TARGET_NR_readlinkat 285 +#define TARGET_NR_fchmodat 286 +#define TARGET_NR_faccessat 287 +#define TARGET_NR_unshare 288 +#define TARGET_NR_set_robust_list 289 +#define TARGET_NR_get_robust_list 290 +#define TARGET_NR_splice 291 +#define TARGET_NR_sync_file_range 292 +#define TARGET_NR_tee 293 +#define TARGET_NR_vmsplice 294 +#define TARGET_NR_move_pages 295 +#define TARGET_NR_getcpu 296 +#define TARGET_NR_epoll_pwait 297 +#define TARGET_NR_statfs64 298 +#define TARGET_NR_fstatfs64 299 +#define TARGET_NR_kexec_load 300 +#define TARGET_NR_utimensat 301 +#define TARGET_NR_signalfd 302 +#define TARGET_NR_timerfd 303 +#define TARGET_NR_eventfd 304 +#define TARGET_NR_fallocate 305 +#define TARGET_NR_timerfd_create 306 +#define TARGET_NR_timerfd_settime 307 +#define TARGET_NR_timerfd_gettime 308 +#define TARGET_NR_signalfd4 309 +#define TARGET_NR_eventfd2 310 +#define TARGET_NR_epoll_create1 311 +#define TARGET_NR_dup3 312 +#define TARGET_NR_pipe2 313 +#define TARGET_NR_inotify_init1 314 +#define TARGET_NR_preadv 315 +#define TARGET_NR_pwritev 316 +#define TARGET_NR_rt_tgsigqueueinfo 317 +#define TARGET_NR_perf_event_open 318 +#define TARGET_NR_recvmmsg 319 +#define TARGET_NR_accept4 320 +#define TARGET_NR_prlimit64 321 +#define TARGET_NR_fanotify_init 322 +#define TARGET_NR_fanotify_mark 323 +#define TARGET_NR_clock_adjtime 324 +#define TARGET_NR_name_to_handle_at 325 +#define TARGET_NR_open_by_handle_at 326 +#define TARGET_NR_syncfs 327 +#define TARGET_NR_setns 328 +#define TARGET_NR_sendmmsg 329 +#define TARGET_NR_process_vm_readv 330 +#define TARGET_NR_process_vm_writev 331 +#define TARGET_NR_kcmp 332 +#define TARGET_NR_finit_module 333 +#define TARGET_NR_sched_setattr 334 +#define TARGET_NR_sched_getattr 335 +#define TARGET_NR_utimes 336 +#define TARGET_NR_renameat2 337 +#define TARGET_NR_seccomp 338 +#define TARGET_NR_getrandom 339 +#define TARGET_NR_memfd_create 340 +#define TARGET_NR_bpf 341 +#define TARGET_NR_execveat 342 +#define TARGET_NR_membarrier 343 +#define TARGET_NR_userfaultfd 344 +#define TARGET_NR_mlock2 345 +#define TARGET_NR_copy_file_range 346 +#define TARGET_NR_preadv2 347 +#define TARGET_NR_pwritev2 348
Signature · 1 line
2.9.3
PATCH 10/26 linux-user: Add HPPA termbits.h
In reply to Richard Henderson--- linux-user/hppa/termbits.h | 219 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 linux-user/hppa/termbits.h
linux-user/hppa/termbits.h new file +219 -0
@@ -0,0 +1,219 @@ +/* from asm/termbits.h */ + +#define TARGET_NCCS 19 + +struct target_termios { +unsigned int c_iflag;/* input mode flags */ +unsigned int c_oflag;/* output mode flags */ +unsigned int c_cflag;/* control mode flags */ +unsigned int c_lflag;/* local mode flags */ +unsigned char c_line;/* line discipline */ +unsigned char c_cc[TARGET_NCCS ];/* control characters */ +}; + +/* c_iflag bits */ +#define TARGET_IGNBRK 0000001 +#define TARGET_BRKINT 0000002 +#define TARGET_IGNPAR 0000004 +#define TARGET_PARMRK 0000010 +#define TARGET_INPCK 0000020 +#define TARGET_ISTRIP 0000040 +#define TARGET_INLCR 0000100 +#define TARGET_IGNCR 0000200 +#define TARGET_ICRNL 0000400 +#define TARGET_IUCLC 0001000 +#define TARGET_IXON 0002000 +#define TARGET_IXANY 0004000 +#define TARGET_IXOFF 0010000 +#define TARGET_IMAXBEL 0040000 +#define TARGET_IUTF8 0100000 + +/* c_oflag bits */ +#define TARGET_OPOST 0000001 +#define TARGET_OLCUC 0000002 +#define TARGET_ONLCR 0000004 +#define TARGET_OCRNL 0000010 +#define TARGET_ONOCR 0000020 +#define TARGET_ONLRET 0000040 +#define TARGET_OFILL 0000100 +#define TARGET_OFDEL 0000200 +#define TARGET_NLDLY 0000400 +#define TARGET_NL0 0000000 +#define TARGET_NL1 0000400 +#define TARGET_CRDLY 0003000 +#define TARGET_CR0 0000000 +#define TARGET_CR1 0001000 +#define TARGET_CR2 0002000 +#define TARGET_CR3 0003000 +#define TARGET_TABDLY 0014000 +#define TARGET_TAB0 0000000 +#define TARGET_TAB1 0004000 +#define TARGET_TAB2 0010000 +#define TARGET_TAB3 0014000 +#define TARGET_XTABS 0014000 +#define TARGET_BSDLY 0020000 +#define TARGET_BS0 0000000 +#define TARGET_BS1 0020000 +#define TARGET_VTDLY 0040000 +#define TARGET_VT0 0000000 +#define TARGET_VT1 0040000 +#define TARGET_FFDLY 0100000 +#define TARGET_FF0 0000000 +#define TARGET_FF1 0100000 + +/* c_cflag bit meaning */ +#define TARGET_CBAUD 0010017 +#define TARGET_B0 0000000/* hang up */ +#define TARGET_B50 0000001 +#define TARGET_B75 0000002 +#define TARGET_B110 0000003 +#define TARGET_B134 0000004 +#define TARGET_B150 0000005 +#define TARGET_B200 0000006 +#define TARGET_B300 0000007 +#define TARGET_B600 0000010 +#define TARGET_B1200 0000011 +#define TARGET_B1800 0000012 +#define TARGET_B2400 0000013 +#define TARGET_B4800 0000014 +#define TARGET_B9600 0000015 +#define TARGET_B19200 0000016 +#define TARGET_B38400 0000017 +#define TARGET_EXTA B19200 +#define TARGET_EXTB B38400 +#define TARGET_CSIZE 0000060 +#define TARGET_CS5 0000000 +#define TARGET_CS6 0000020 +#define TARGET_CS7 0000040 +#define TARGET_CS8 0000060 +#define TARGET_CSTOPB 0000100 +#define TARGET_CREAD 0000200 +#define TARGET_PARENB 0000400 +#define TARGET_PARODD 0001000 +#define TARGET_HUPCL 0002000 +#define TARGET_CLOCAL 0004000 +#define TARGET_CBAUDEX 0010000 +#define TARGET_B57600 0010001 +#define TARGET_B115200 0010002 +#define TARGET_B230400 0010003 +#define TARGET_B460800 0010004 +#define TARGET_CIBAUD 002003600000/* input baud rate (not used) */ +#define TARGET_CMSPAR 010000000000/* mark or space (stick) parity */ +#define TARGET_CRTSCTS 020000000000/* flow control */ + +/* c_lflag bits */ +#define TARGET_ISIG 0000001 +#define TARGET_ICANON 0000002 +#define TARGET_XCASE 0000004 +#define TARGET_ECHO 0000010 +#define TARGET_ECHOE 0000020 +#define TARGET_ECHOK 0000040 +#define TARGET_ECHONL 0000100 +#define TARGET_NOFLSH 0000200 +#define TARGET_TOSTOP 0000400 +#define TARGET_ECHOCTL 0001000 +#define TARGET_ECHOPRT 0002000 +#define TARGET_ECHOKE 0004000 +#define TARGET_FLUSHO 0010000 +#define TARGET_PENDIN 0040000 +#define TARGET_IEXTEN 0100000 + +/* c_cc character offsets */ +#define TARGET_VINTR 0 +#define TARGET_VQUIT 1 +#define TARGET_VERASE 2 +#define TARGET_VKILL 3 +#define TARGET_VEOF 4 +#define TARGET_VTIME 5 +#define TARGET_VMIN 6 +#define TARGET_VSWTC 7 +#define TARGET_VSTART 8 +#define TARGET_VSTOP 9 +#define TARGET_VSUSP 10 +#define TARGET_VEOL 11 +#define TARGET_VREPRINT 12 +#define TARGET_VDISCARD 13 +#define TARGET_VWERASE 14 +#define TARGET_VLNEXT 15 +#define TARGET_VEOL2 16 + +/* ioctls */ + +#define TARGET_TCGETS TARGET_IOR('T', 16, struct target_termios) +#define TARGET_TCSETS TARGET_IOW('T', 17, struct target_termios) +#define TARGET_TCSETSW TARGET_IOW('T', 18, struct target_termios) +#define TARGET_TCSETSF TARGET_IOW('T', 19, struct target_termios) +#define TARGET_TCGETA TARGET_IOR('T', 1, struct target_termios) +#define TARGET_TCSETA TARGET_IOW('T', 2, struct target_termios) +#define TARGET_TCSETAW TARGET_IOW('T', 3, struct target_termios) +#define TARGET_TCSETAF TARGET_IOW('T', 4, struct target_termios) +#define TARGET_TCSBRK TARGET_IO('T', 5) +#define TARGET_TCXONC TARGET_IO('T', 6) +#define TARGET_TCFLSH TARGET_IO('T', 7) + +#define TARGET_TIOCEXCL 0x540C +#define TARGET_TIOCNXCL 0x540D +#define TARGET_TIOCSCTTY 0x540E +#define TARGET_TIOCGPGRP TARGET_IOR('T', 30, int) +#define TARGET_TIOCSPGRP TARGET_IOW('T', 29, int) +#define TARGET_TIOCOUTQ 0x5411 +#define TARGET_TIOCSTI 0x5412 +#define TARGET_TIOCGWINSZ 0x5413 +#define TARGET_TIOCSWINSZ 0x5414 +#define TARGET_TIOCMGET 0x5415 +#define TARGET_TIOCMBIS 0x5416 +#define TARGET_TIOCMBIC 0x5417 +#define TARGET_TIOCMSET 0x5418 +#define TARGET_TIOCGSOFTCAR 0x5419 +#define TARGET_TIOCSSOFTCAR 0x541A +#define TARGET_FIONREAD 0x541B +#define TARGET_TIOCINQ TARGET_FIONREAD +#define TARGET_TIOCLINUX 0x541C +#define TARGET_TIOCCONS 0x541D +#define TARGET_TIOCGSERIAL 0x541E +#define TARGET_TIOCSSERIAL 0x541F +#define TARGET_TIOCPKT 0x5420 +#define TARGET_FIONBIO 0x5421 +#define TARGET_TIOCNOTTY 0x5422 +#define TARGET_TIOCSETD 0x5423 +#define TARGET_TIOCGETD 0x5424 +#define TARGET_TCSBRKP 0x5425/* Needed for POSIX tcsendbreak() */ +#define TARGET_TIOCTTYGSTRUCT 0x5426/* For debugging only */ +#define TARGET_TIOCSBRK 0x5427/* BSD compatibility */ +#define TARGET_TIOCCBRK 0x5428/* BSD compatibility */ +#define TARGET_TIOCGSID TARGET_IOR('T', 20, int) +#define TARGET_TIOCGPTN TARGET_IOR('T', 0x30, unsigned int) +/* Get Pty Number (of pty-mux device) */ +#define TARGET_TIOCSPTLCK TARGET_IOW('T', 0x31, int) +/* Lock/unlock Pty */ + +#define TARGET_FIONCLEX 0x5450/* these numbers need to be adjusted. */ +#define TARGET_FIOCLEX 0x5451 +#define TARGET_FIOASYNC 0x5452 +#define TARGET_TIOCSERCONFIG 0x5453 +#define TARGET_TIOCSERGWILD 0x5454 +#define TARGET_TIOCSERSWILD 0x5455 +#define TARGET_TIOCGLCKTRMIOS 0x5456 +#define TARGET_TIOCSLCKTRMIOS 0x5457 +#define TARGET_TIOCSERGSTRUCT 0x5458/* For debugging only */ +#define TARGET_TIOCSERGETLSR 0x5459/* Get line status register */ +#define TARGET_TIOCSERGETMULTI 0x545A/* Get multiport config */ +#define TARGET_TIOCSERSETMULTI 0x545B/* Set multiport config */ + +#define TARGET_TIOCMIWAIT 0x545C/* wait for a change on serial */ +#define TARGET_TIOCGICOUNT 0x545D +#define TARGET_FIOQSIZE 0x5460 +#define TARGET_TIOCSTART 0x5461 +#define TARGET_TIOCSTOP 0x5462 +#define TARGET_TIOCSLTC 0x5462 + +/* Used for packet mode */ +#define TARGET_TIOCPKT_DATA 0 +#define TARGET_TIOCPKT_FLUSHREAD 1 +#define TARGET_TIOCPKT_FLUSHWRITE 2 +#define TARGET_TIOCPKT_STOP 4 +#define TARGET_TIOCPKT_START 8 +#define TARGET_TIOCPKT_NOSTOP 16 +#define TARGET_TIOCPKT_DOSTOP 32 + +#define TARGET_TIOCSER_TEMT 0x01/* Transmitter physically empty */
Signature · 1 line
2.9.3
PATCH 11/26 linux-user: Add HPPA target_syscall.h
In reply to Richard HendersonWhich is primarily a re-definition of errno numbers.
--- linux-user/hppa/target_syscall.h | 237 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) create mode 100644 linux-user/hppa/target_syscall.h
linux-user/hppa/target_syscall.h new file +237 -0
@@ -0,0 +1,237 @@ +#ifndef HPPA_TARGET_SYSCALL_H +#define HPPA_TARGET_SYSCALL_H + +struct target_pt_regs { +target_ulong gr[32 ]; +uint64_t fr[32 ]; +target_ulong sr[8 ]; +target_ulong iasq[2 ]; +target_ulong iaoq[2 ]; +target_ulong cr27; +target_ulong __pad0; +target_ulong orig_r28; +target_ulong ksp; +target_ulong kpc; +target_ulong sar; +target_ulong iir; +target_ulong isr; +target_ulong ior; +target_ulong ipsw; +}; + +#define UNAME_MACHINE "hppa" +#define UNAME_MINIMUM_RELEASE "2.6.32" +#define TARGET_CLONE_BACKWARDS +#define TARGET_MINSIGSTKSZ 2048 +#define TARGET_MLOCKALL_MCL_CURRENT 1 +#define TARGET_MLOCKALL_MCL_FUTURE 2 + +#undef TARGET_ENOMSG +#define TARGET_ENOMSG 35 +#undef TARGET_EIDRM +#define TARGET_EIDRM 36 +#undef TARGET_ECHRNG +#define TARGET_ECHRNG 37 +#undef TARGET_EL2NSYNC +#define TARGET_EL2NSYNC 38 +#undef TARGET_EL3HLT +#define TARGET_EL3HLT 39 +#undef TARGET_EL3RST +#define TARGET_EL3RST 40 +#undef TARGET_ELNRNG +#define TARGET_ELNRNG 41 +#undef TARGET_EUNATCH +#define TARGET_EUNATCH 42 +#undef TARGET_ENOCSI +#define TARGET_ENOCSI 43 +#undef TARGET_EL2HLT +#define TARGET_EL2HLT 44 +#undef TARGET_EDEADLK +#define TARGET_EDEADLK 45 +#undef TARGET_ENOLCK +#define TARGET_ENOLCK 46 +#undef TARGET_EILSEQ +#define TARGET_EILSEQ 47 + +#undef TARGET_ENONET +#define TARGET_ENONET 50 +#undef TARGET_ENODATA +#define TARGET_ENODATA 51 +#undef TARGET_ETIME +#define TARGET_ETIME 52 +#undef TARGET_ENOSR +#define TARGET_ENOSR 53 +#undef TARGET_ENOSTR +#define TARGET_ENOSTR 54 +#undef TARGET_ENOPKG +#define TARGET_ENOPKG 55 + +#undef TARGET_ENOLINK +#define TARGET_ENOLINK 57 +#undef TARGET_EADV +#define TARGET_EADV 58 +#undef TARGET_ESRMNT +#define TARGET_ESRMNT 59 +#undef TARGET_ECOMM +#define TARGET_ECOMM 60 +#undef TARGET_EPROTO +#define TARGET_EPROTO 61 + +#undef TARGET_EMULTIHOP +#define TARGET_EMULTIHOP 64 + +#undef TARGET_EDOTDOT +#define TARGET_EDOTDOT 66 +#undef TARGET_EBADMSG +#define TARGET_EBADMSG 67 +#undef TARGET_EUSERS +#define TARGET_EUSERS 68 +#undef TARGET_EDQUOT +#define TARGET_EDQUOT 69 +#undef TARGET_ESTALE +#define TARGET_ESTALE 70 +#undef TARGET_EREMOTE +#define TARGET_EREMOTE 71 +#undef TARGET_EOVERFLOW +#define TARGET_EOVERFLOW 72 + +#undef TARGET_EBADE +#define TARGET_EBADE 160 +#undef TARGET_EBADR +#define TARGET_EBADR 161 +#undef TARGET_EXFULL +#define TARGET_EXFULL 162 +#undef TARGET_ENOANO +#define TARGET_ENOANO 163 +#undef TARGET_EBADRQC +#define TARGET_EBADRQC 164 +#undef TARGET_EBADSLT +#define TARGET_EBADSLT 165 +#undef TARGET_EBFONT +#define TARGET_EBFONT 166 +#undef TARGET_ENOTUNIQ +#define TARGET_ENOTUNIQ 167 +#undef TARGET_EBADFD +#define TARGET_EBADFD 168 +#undef TARGET_EREMCHG +#define TARGET_EREMCHG 169 +#undef TARGET_ELIBACC +#define TARGET_ELIBACC 170 +#undef TARGET_ELIBBAD +#define TARGET_ELIBBAD 171 +#undef TARGET_ELIBSCN +#define TARGET_ELIBSCN 172 +#undef TARGET_ELIBMAX +#define TARGET_ELIBMAX 173 +#undef TARGET_ELIBEXEC +#define TARGET_ELIBEXEC 174 +#undef TARGET_ERESTART +#define TARGET_ERESTART 175 +#undef TARGET_ESTRPIPE +#define TARGET_ESTRPIPE 176 +#undef TARGET_EUCLEAN +#define TARGET_EUCLEAN 177 +#undef TARGET_ENOTNAM +#define TARGET_ENOTNAM 178 +#undef TARGET_ENAVAIL +#define TARGET_ENAVAIL 179 +#undef TARGET_EISNAM +#define TARGET_EISNAM 180 +#undef TARGET_EREMOTEIO +#define TARGET_EREMOTEIO 181 +#undef TARGET_ENOMEDIUM +#define TARGET_ENOMEDIUM 182 +#undef TARGET_EMEDIUMTYPE +#define TARGET_EMEDIUMTYPE 183 +#undef TARGET_ENOKEY +#define TARGET_ENOKEY 184 +#undef TARGET_EKEYEXPIRED +#define TARGET_EKEYEXPIRED 185 +#undef TARGET_EKEYREVOKED +#define TARGET_EKEYREVOKED 186 +#undef TARGET_EKEYREJECTED +#define TARGET_EKEYREJECTED 187 + +/* Never used in linux. */ +/* #define TARGET_ENOSYM 215 */ +#undef TARGET_ENOTSOCK +#define TARGET_ENOTSOCK 216 +#undef TARGET_EDESTADDRREQ +#define TARGET_EDESTADDRREQ 217 +#undef TARGET_EMSGSIZE +#define TARGET_EMSGSIZE 218 +#undef TARGET_EPROTOTYPE +#define TARGET_EPROTOTYPE 219 +#undef TARGET_ENOPROTOOPT +#define TARGET_ENOPROTOOPT 220 +#undef TARGET_EPROTONOSUPPORT +#define TARGET_EPROTONOSUPPORT 221 +#undef TARGET_ESOCKTNOSUPPORT +#define TARGET_ESOCKTNOSUPPORT 222 +#undef TARGET_EOPNOTSUPP +#define TARGET_EOPNOTSUPP 223 +#undef TARGET_EPFNOSUPPORT +#define TARGET_EPFNOSUPPORT 224 +#undef TARGET_EAFNOSUPPORT +#define TARGET_EAFNOSUPPORT 225 +#undef TARGET_EADDRINUSE +#define TARGET_EADDRINUSE 226 +#undef TARGET_EADDRNOTAVAIL +#define TARGET_EADDRNOTAVAIL 227 +#undef TARGET_ENETDOWN +#define TARGET_ENETDOWN 228 +#undef TARGET_ENETUNREACH +#define TARGET_ENETUNREACH 229 +#undef TARGET_ENETRESET +#define TARGET_ENETRESET 230 +#undef TARGET_ECONNABORTED +#define TARGET_ECONNABORTED 231 +#undef TARGET_ECONNRESET +#define TARGET_ECONNRESET 232 +#undef TARGET_ENOBUFS +#define TARGET_ENOBUFS 233 +#undef TARGET_EISCONN +#define TARGET_EISCONN 234 +#undef TARGET_ENOTCONN +#define TARGET_ENOTCONN 235 +#undef TARGET_ESHUTDOWN +#define TARGET_ESHUTDOWN 236 +#undef TARGET_ETOOMANYREFS +#define TARGET_ETOOMANYREFS 237 +#undef TARGET_ETIMEDOUT +#define TARGET_ETIMEDOUT 238 +#undef TARGET_ECONNREFUSED +#define TARGET_ECONNREFUSED 239 +#define TARGET_EREMOTERELEASE 240 +#undef TARGET_EHOSTDOWN +#define TARGET_EHOSTDOWN 241 +#undef TARGET_EHOSTUNREACH +#define TARGET_EHOSTUNREACH 242 + +#undef TARGET_EALREADY +#define TARGET_EALREADY 244 +#undef TARGET_EINPROGRESS +#define TARGET_EINPROGRESS 245 +#undef TARGET_ENOTEMPTY +#define TARGET_ENOTEMPTY 247 +#undef TARGET_ENAMETOOLONG +#define TARGET_ENAMETOOLONG 248 +#undef TARGET_ELOOP +#define TARGET_ELOOP 249 +#undef TARGET_ENOSYS +#define TARGET_ENOSYS 251 + +#undef TARGET_ECANCELED +#define TARGET_ECANCELED 253 + +#undef TARGET_EOWNERDEAD +#define TARGET_EOWNERDEAD 254 +#undef TARGET_ENOTRECOVERABLE +#define TARGET_ENOTRECOVERABLE 255 + +#undef TARGET_ERFKILL +#define TARGET_ERFKILL 256 +#undef TARGET_EHWPOISON +#define TARGET_EHWPOISON 257 + +#endif /* HPPA_TARGET_SYSCALL_H */
Signature · 1 line
2.9.3
PATCH 12/26 linux-user: Add HPPA definitions to syscall_defs.h
In reply to Richard Henderson--- linux-user/syscall_defs.h | 131 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 130 insertions(+), 1 deletion(-)
linux-user/syscall_defs.h +130 -1
@@ -90,6 +90,15 @@#define TARGET_IOC_READ 2U#define TARGET_IOC_WRITE 4U +#elif defined(TARGET_HPPA ) + +#define TARGET_IOC_SIZEBITS 14 +#define TARGET_IOC_DIRBITS 2 + +#define TARGET_IOC_NONE 0U +#define TARGET_IOC_WRITE 2U +#define TARGET_IOC_READ 1U +#else #error unsupported CPU#endif
@@ -417,7 +426,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, ||defined (TARGET_M68K ) ||defined (TARGET_ALPHA ) ||defined (TARGET_CRIS ) \ ||defined (TARGET_MICROBLAZE ) ||defined (TARGET_UNICORE32 ) \ ||defined (TARGET_S390X ) ||defined (TARGET_OPENRISC ) \ - || defined(TARGET_TILEGX) + || defined(TARGET_TILEGX) || defined(TARGET_HPPA)#if defined(TARGET_SPARC )#define TARGET_SA_NOCLDSTOP 8u
@@ -587,6 +596,46 @@ int do_sigaction(int sig, const struct target_sigaction *act,#define TARGET_SIG_UNBLOCK 2/* for unblocking signals */ #define TARGET_SIG_SETMASK 3/* for setting the signal mask */ +#elif defined(TARGET_HPPA ) + +#define TARGET_SIGHUP 1 +#define TARGET_SIGINT 2 +#define TARGET_SIGQUIT 3 +#define TARGET_SIGILL 4 +#define TARGET_SIGTRAP 5 +#define TARGET_SIGABRT 6 +#define TARGET_SIGIOT 6 +#define TARGET_SIGSTKFLT 7 +#define TARGET_SIGFPE 8 +#define TARGET_SIGKILL 9 +#define TARGET_SIGBUS 10 +#define TARGET_SIGSEGV 11 +#define TARGET_SIGXCPU 12 +#define TARGET_SIGPIPE 13 +#define TARGET_SIGALRM 14 +#define TARGET_SIGTERM 15 +#define TARGET_SIGUSR1 16 +#define TARGET_SIGUSR2 17 +#define TARGET_SIGCHLD 18 +#define TARGET_SIGPWR 19 +#define TARGET_SIGVTALRM 20 +#define TARGET_SIGPROF 21 +#define TARGET_SIGIO 22 +#define TARGET_SIGPOLL TARGET_SIGIO +#define TARGET_SIGWINCH 23 +#define TARGET_SIGSTOP 24 +#define TARGET_SIGTSTP 25 +#define TARGET_SIGCONT 26 +#define TARGET_SIGTTIN 27 +#define TARGET_SIGTTOU 28 +#define TARGET_SIGURG 29 +#define TARGET_SIGXFSZ 30 +#define TARGET_SIGSYS 31 + +#define TARGET_SIG_BLOCK 0 +#define TARGET_SIG_UNBLOCK 1 +#define TARGET_SIG_SETMASK 2 +#else /* OpenRISC Using the general signals */
@@ -1279,6 +1328,16 @@ struct target_winsize {#define TARGET_MAP_NORESERVE 0x10000/* no check for reservations */ #define TARGET_MAP_POPULATE 0x20000/* pop (prefault) pagetables */ #define TARGET_MAP_NONBLOCK 0x40000/* do not block on IO */ +#elif defined(TARGET_HPPA ) +#define TARGET_MAP_ANONYMOUS 0x10/* don't use a file */ +#define TARGET_MAP_FIXED 0x04/* Interpret addr exactly */ +#define TARGET_MAP_GROWSDOWN 0x08000/* stack-like segment */ +#define TARGET_MAP_DENYWRITE 0x00800/* ETXTBSY */ +#define TARGET_MAP_EXECUTABLE 0x01000/* mark it as an executable */ +#define TARGET_MAP_LOCKED 0x02000/* lock the mapping */ +#define TARGET_MAP_NORESERVE 0x04000/* no check for reservations */ +#define TARGET_MAP_POPULATE 0x10000/* pop (prefault) pagetables */ +#define TARGET_MAP_NONBLOCK 0x20000/* do not block on IO */ #else #define TARGET_MAP_FIXED 0x10/* Interpret addr exactly */ #define TARGET_MAP_ANONYMOUS 0x20/* don't use a file */
@@ -2029,6 +2088,62 @@ struct target_stat64 {unsigned int __unused5; }; +#elif defined(TARGET_HPPA ) + +struct target_stat { +abi_uint st_dev; +abi_uint st_ino; +abi_ushort st_mode; +abi_ushort st_nlink; +abi_ushort _res1; +abi_ushort _res2; +abi_uint st_rdev; +abi_int st_size; +abi_int target_st_atime; +abi_uint target_st_atime_nsec; +abi_int target_st_mtime; +abi_uint target_st_mtime_nsec; +abi_int target_st_ctime; +abi_uint target_st_ctime_nsec; +abi_int st_blksize; +abi_int st_blocks; +abi_uint _unused1; +abi_uint _unused2; +abi_uint _unused3; +abi_uint _unused4; +abi_ushort _unused5; +abi_short st_fstype; +abi_uint st_realdev; +abi_ushort st_basemode; +abi_ushort _unused6; +abi_uint st_uid; +abi_uint st_gid; +abi_uint _unused7[3 ]; +}; + +#define TARGET_HAS_STRUCT_STAT64 +struct target_stat64 { +uint64_t st_dev; +abi_uint _pad1; +abi_uint _res1; +abi_uint st_mode; +abi_uint st_nlink; +abi_uint st_uid; +abi_uint st_gid; +uint64_t st_rdev; +abi_uint _pad2; +int64_t st_size; +abi_int st_blksize; +int64_t st_blocks; +abi_int target_st_atime; +abi_uint target_st_atime_nsec; +abi_int target_st_mtime; +abi_uint target_st_mtime_nsec; +abi_int target_st_ctime; +abi_uint target_st_ctime_nsec; +uint64_t st_ino; +}; +#else #error unsupported CPU#endif
@@ -2273,6 +2388,20 @@ struct target_statfs64 {#define TARGET_O_CLOEXEC 010000000#define TARGET___O_SYNC 020000000#define TARGET_O_PATH 040000000 +#elif defined(TARGET_HPPA ) +#define TARGET_O_NONBLOCK 000200004/* HPUX has separate NDELAY & NONBLOCK */ +#define TARGET_O_APPEND 000000010 +#define TARGET_O_CREAT 000000400/* not fcntl */ +#define TARGET_O_EXCL 000002000/* not fcntl */ +#define TARGET_O_NOCTTY 000400000/* not fcntl */ +#define TARGET_O_DSYNC 001000000 +#define TARGET_O_LARGEFILE 000004000 +#define TARGET_O_DIRECTORY 000010000/* must be a directory */ +#define TARGET_O_NOFOLLOW 000000200/* don't follow links */ +#define TARGET_O_NOATIME 004000000 +#define TARGET_O_CLOEXEC 010000000 +#define TARGET___O_SYNC 000100000 +#define TARGET_O_PATH 020000000#elif defined(TARGET_ARM ) || defined(TARGET_M68K )#define TARGET_O_DIRECTORY 040000/* must be a directory */ #define TARGET_O_NOFOLLOW 0100000/* don't follow links */
Signature · 1 line
2.9.3
PATCH 13/26 linux-user: Add HPPA target_structs.h
In reply to Richard Henderson--- linux-user/hppa/target_structs.h | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 linux-user/hppa/target_structs.h
linux-user/hppa/target_structs.h new file +54 -0
@@ -0,0 +1,54 @@ +/* +* HPPA specific structures for linux-user +* +* Copyright (c) 2016 Richard Henderson +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef HPPA_TARGET_STRUCTS_H +#define HPPA_TARGET_STRUCTS_H + +struct target_ipc_perm { +abi_int __key;/* Key. */ +abi_uint uid;/* Owner's user ID. */ +abi_uint gid;/* Owner's group ID. */ +abi_uint cuid;/* Creator's user ID. */ +abi_uint cgid;/* Creator's group ID. */ +abi_ushort __pad1; +abi_ushort mode;/* Read/write permission. */ +abi_ushort __pad2; +abi_ushort __seq;/* Sequence number. */ +abi_uint __pad3; +uint64_t __unused1; +uint64_t __unused2; +}; + +struct target_shmid_ds { +struct target_ipc_perm shm_perm;/* operation permission struct */ +abi_uint __pad1; +abi_ulong shm_atime;/* time of last shmat() */ +abi_uint __pad2; +abi_ulong shm_dtime;/* time of last shmdt() */ +abi_uint __pad3; +abi_ulong shm_ctime;/* time of last change by shmctl() */ +abi_uint __pad4; +abi_long shm_segsz;/* size of segment in bytes */ +abi_int shm_cpid;/* pid of creator */ +abi_int shm_lpid;/* pid of last shmop */ +abi_ulong shm_nattch;/* number of current attaches */ +abi_ulong __unused1; +abi_ulong __unused2; +}; + +#endif
Signature · 1 line
2.9.3
PATCH 14/26 linux-user: Add HPPA target_signal.h and target_cpu.h
In reply to Richard HendersonThe cpu.h structure that these manipulate hasn't been defined yet, but we haven't enabled compilation yet either.
--- linux-user/hppa/target_cpu.h | 35 +++++++++++++++++++++++++++++++++++ linux-user/hppa/target_signal.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 linux-user/hppa/target_cpu.h create mode 100644 linux-user/hppa/target_signal.h
linux-user/hppa/target_cpu.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* HPPA specific CPU ABI and functions for linux-user +* +* Copyright (c) 2016 Richard Henderson +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, see <http://www.gnu.org/licenses/>. +*/ +#ifndef ALPHA_TARGET_CPU_H +#define ALPHA_TARGET_CPU_H + +static inline void cpu_clone_regs (CPUHPPAState *env,target_ulong newsp) +{ +if (newsp) { + env->gr[30 ] = newsp; + } + env->gr[28 ] =0 ; +} + +static inline void cpu_set_tls (CPUHPPAState *env,target_ulong newtls) +{ + env->cr27 = newtls; +} + +#endif
linux-user/hppa/target_signal.h new file +29 -0
@@ -0,0 +1,29 @@ +#ifndef HPPA_TARGET_SIGNAL_H +#define HPPA_TARGET_SIGNAL_H + +#include "cpu.h" + +/* this struct defines a stack used during syscall handling */ + +typedef struct target_sigaltstack { +abi_ulong ss_sp; +int32_t ss_flags; +abi_ulong ss_size; +}target_stack_t ; + + +/* +* sigaltstack controls +*/ +#define TARGET_SS_ONSTACK 1 +#define TARGET_SS_DISABLE 2 + +#define TARGET_MINSIGSTKSZ 2048 +#define TARGET_SIGSTKSZ 8192 + +static inline abi_ulong get_sp_from_cpustate (CPUHPPAState *state) +{ +return state->gr[30 ]; +} + +#endif /* HPPA_TARGET_SIGNAL_H */
Signature · 1 line
2.9.3
PATCH 15/26 linux-user: Add HPPA signal handling
In reply to Richard Henderson--- linux-user/signal.c | 191 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 190 insertions(+), 1 deletion(-)
linux-user/signal.c +190 -1
@@ -5888,6 +5888,195 @@ long do_rt_sigreturn(CPUTLGState *env)return -TARGET_QEMU_ESIGRETURN ; } +#elif defined(TARGET_HPPA ) + +struct target_sigcontext { +abi_ulong sc_flags; +abi_ulong sc_gr[32 ]; +uint64_t sc_fr[32 ]; +abi_ulong sc_iasq[2 ]; +abi_ulong sc_iaoq[2 ]; +abi_ulong sc_sar; +}; + +struct target_ucontext { +abi_uint tuc_flags; +abi_ulong tuc_link; +target_stack_t tuc_stack; +abi_uint pad[1 ]; +struct target_sigcontext tuc_mcontext; +target_sigset_t tuc_sigmask; +}; + +struct target_rt_sigframe { +abi_uint tramp[9 ]; +target_siginfo_t info; +struct target_ucontext uc; +/* hidden location of upper halves of pa2.0 64-bit gregs */ +}; + +static void setup_sigcontext (struct target_sigcontext *sc,CPUArchState *env) +{ +int flags =0 ; +int i; + +/* ??? if on_sig_stack, flags |= 1 (PARISC_SC_FLAG_ONSTACK). */ + +if (env->iaoq_f <TARGET_PAGE_SIZE ) { +/* In the gateway page, executing a syscall. */ + flags |=2 ;/* PARISC_SC_FLAG_IN_SYSCALL */ +__put_user (env->gr[31 ], &sc->sc_iaoq[0 ]); +__put_user (env->gr[31 ] +4 , &sc->sc_iaoq[1 ]); + }else { +__put_user (env->iaoq_f, &sc->sc_iaoq[0 ]); +__put_user (env->iaoq_b, &sc->sc_iaoq[1 ]); + } +__put_user (0 , &sc->sc_iasq[0 ]); +__put_user (0 , &sc->sc_iasq[1 ]); +__put_user (flags, &sc->sc_flags); + +__put_user (cpu_hppa_get_psw (env), &sc->sc_gr[0 ]); +for (i =1 ; i <32 ; ++i) { +__put_user (env->gr[i], &sc->sc_gr[i]); + } + +__put_user ((uint64_t )env->fr0_shadow <<32 , &sc->sc_fr[0 ]); +for (i =1 ; i <32 ; ++i) { +__put_user (env->fr[i], &sc->sc_fr[i]); + } + +__put_user (env->sar, &sc->sc_sar); +} + +static void restore_sigcontext (CPUArchState *env,struct target_sigcontext *sc) +{ +target_ulong psw; +int i; + +__get_user (psw, &sc->sc_gr[0 ]); +cpu_hppa_put_psw (env, psw); + +for (i =1 ; i <32 ; ++i) { +__get_user (env->gr[i], &sc->sc_gr[i]); + } +for (i =0 ; i <32 ; ++i) { +__get_user (env->fr[i], &sc->sc_fr[i]); + } +cpu_hppa_loaded_fr0 (env); + +__get_user (env->iaoq_f, &sc->sc_iaoq[0 ]); +__get_user (env->iaoq_b, &sc->sc_iaoq[1 ]); +__get_user (env->sar, &sc->sc_sar); +} + +/* No, this doesn't look right, but it's copied straight from the kernel. */ +#define PARISC_RT_SIGFRAME_SIZE32 \ + ((sizeof(struct target_rt_sigframe) + 48 + 64) & -64) + +static void setup_rt_frame (int sig,struct target_sigaction *ka, +target_siginfo_t *info, +target_sigset_t *set,CPUArchState *env) +{ +abi_ulong frame_addr, sp, haddr; +struct target_rt_sigframe *frame; +int i; + + sp = env->gr[30 ]; +if (ka->sa_flags &TARGET_SA_ONSTACK ) { +if (sas_ss_flags (sp) ==0 ) { + sp = (target_sigaltstack_used.ss_sp +0x7f ) & ~0x3f ; + } + } + frame_addr =QEMU_ALIGN_UP (sp,64 ); + sp = frame_addr +PARISC_RT_SIGFRAME_SIZE32 ; + +trace_user_setup_rt_frame (env, frame_addr); + +if (!lock_user_struct (VERIFY_WRITE , frame, frame_addr,0 )) { + goto give_sigsegv; + } + +tswap_siginfo (&frame->info, info); + frame->uc.tuc_flags =0 ; + frame->uc.tuc_link =0 ; + +__put_user (target_sigaltstack_used.ss_sp, &frame->uc.tuc_stack.ss_sp); +__put_user (sas_ss_flags (get_sp_from_cpustate (env)), + &frame->uc.tuc_stack.ss_flags); +__put_user (target_sigaltstack_used.ss_size, + &frame->uc.tuc_stack.ss_size); + +for (i =0 ; i <TARGET_NSIG_WORDS ; i++) { +__put_user (set->sig[i], &frame->uc.tuc_sigmask.sig[i]); + } + +setup_sigcontext (&frame->uc.tuc_mcontext, env); + +__put_user (0x34190000 , frame->tramp +0 );/* ldi 0,%r25 */ +__put_user (0x3414015a , frame->tramp +1 );/* ldi __NR_rt_sigreturn,%r20 */ +__put_user (0xe4008200 , frame->tramp +2 );/* be,l 0x100(%sr2,%r0) */ +__put_user (0x08000240 , frame->tramp +3 );/* nop */ + +unlock_user_struct (frame, frame_addr,1 ); + + env->gr[2 ] =h2g (frame->tramp); + env->gr[30 ] = sp; + env->gr[26 ] = sig; + env->gr[25 ] =h2g (&frame->info); + env->gr[24 ] =h2g (&frame->uc); + + haddr = ka->_sa_handler; +if (haddr &2 ) { +/* Function descriptor. */ +target_ulong *fdesc, dest; + + haddr &=-4 ; +if (!lock_user_struct (VERIFY_READ , fdesc, haddr,1 )) { + goto give_sigsegv; + } +__get_user (dest, fdesc); +__get_user (env->gr[19 ], fdesc +1 ); +unlock_user_struct (fdesc, haddr,1 ); + haddr = dest; + } + env->iaoq_f = haddr; + env->iaoq_b = haddr +4 ;; +return ; + + give_sigsegv: +force_sigsegv (sig); +} + +long do_rt_sigreturn (CPUArchState *env) +{ +abi_ulong frame_addr = env->gr[30 ] -PARISC_RT_SIGFRAME_SIZE32 ; +struct target_rt_sigframe *frame; +sigset_t set; + +trace_user_do_rt_sigreturn (env, frame_addr); +if (!lock_user_struct (VERIFY_READ , frame, frame_addr,1 )) { + goto badframe; + } +target_to_host_sigset (&set, &frame->uc.tuc_sigmask); +set_sigmask (&set); + +restore_sigcontext (env, &frame->uc.tuc_mcontext); +unlock_user_struct (frame, frame_addr,0 ); + +if (do_sigaltstack (frame_addr + offsetof(struct target_rt_sigframe , + uc.tuc_stack), + 0, env->gr[30]) == -EFAULT) { + goto badframe; + } + +unlock_user_struct (frame, frame_addr,0 ); +return -TARGET_QEMU_ESIGRETURN ; + + badframe: +force_sig (TARGET_SIGSEGV ); +return -TARGET_QEMU_ESIGRETURN ; +} +#else static void setup_frame(int sig, struct target_sigaction *ka,
@@ -5989,7 +6178,7 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig,/* prepare the stack frame of the virtual CPU */ #if defined(TARGET_ABI_MIPSN32 ) || defined(TARGET_ABI_MIPSN64 ) \ || defined(TARGET_OPENRISC ) || defined(TARGET_TILEGX ) \ - || defined(TARGET_PPC64 ) + || defined(TARGET_PPC64 ) || defined(TARGET_HPPA )/* These targets do not have traditional signals. */ setup_rt_frame (sig, sa, &k->info, &target_old_set, cpu_env);#else
Signature · 1 line
2.9.3
PATCH 16/26 linux-user: Add HPPA startup and main loop
In reply to Richard HendersonIncluding support for the atomic memory op syscalls.
--- linux-user/elfload.c | 24 +++++++ linux-user/main.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+)
linux-user/elfload.c +24 -0
@@ -1215,6 +1215,30 @@ static inline void init_thread(struct target_pt_regs *regs,#endif /* TARGET_TILEGX */ +#ifdef TARGET_HPPA + +#define ELF_START_MMAP 0x80000000 +#define ELF_CLASS ELFCLASS32 +#define ELF_ARCH EM_PARISC +#define ELF_PLATFORM "PARISC" +#define STACK_GROWS_DOWN 0 +#define STACK_ALIGNMENT 64 + +static inline void init_thread (struct target_pt_regs *regs, +struct image_info *infop) +{ + regs->iaoq[0 ] = infop->entry; + regs->iaoq[1 ] = infop->entry +4 ; + regs->gr[23 ] =0 ; + regs->gr[24 ] = infop->arg_start; + regs->gr[25 ] = (infop->arg_end - infop->arg_start) /sizeof (abi_ulong); +/* The top-of-stack contains a linkage buffer. */ + regs->gr[30 ] = infop->start_stack +64 ; + regs->gr[31 ] = infop->entry; +} + +#endif /* TARGET_HPPA */ +#ifndef ELF_PLATFORM #define ELF_PLATFORM (NULL)#endif
linux-user/main.c +172 -0
184 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 17/26 target-hppa: Add softfloat specializations
In reply to Richard HendersonLike the original MIPS, HPPA has the MSB of an SNaN set. However, it has different rules for silencing an SNaN:
(1) msb is cleared and (2) msb-1 must be set if the fraction is now zero, and (implementation defined) may be set always. I haven't checked real hardware but chose the set always alternative because it's easy and within spec.
--- fpu/softfloat-specialize.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
fpu/softfloat-specialize.h +19 -1
@@ -116,6 +116,8 @@ float32 float32_default_nan(float_status *status)#elif defined(TARGET_PPC ) || defined(TARGET_ARM ) || defined(TARGET_ALPHA ) || \ defined(TARGET_XTENSA ) || defined(TARGET_S390X ) || defined(TARGET_TRICORE )return const_float32 (0x7FC00000 ); +#elif defined(TARGET_HPPA ) +return const_float32 (0x7FA00000 );#else if (status->snan_bit_is_one) {return const_float32 (0x7FBFFFFF );
@@ -139,6 +141,8 @@ float64 float64_default_nan(float_status *status)#elif defined(TARGET_PPC ) || defined(TARGET_ARM ) || defined(TARGET_ALPHA ) || \ defined(TARGET_S390X )return const_float64 (LIT64 (0x7FF8000000000000 )); +#elif defined(TARGET_HPPA ) +return const_float64 (LIT64 (0x7FF4000000000000 ));#else if (status->snan_bit_is_one) {return const_float64 (LIT64 (0x7FF7FFFFFFFFFFFF ));
@@ -361,7 +365,14 @@ float32 float32_maybe_silence_nan(float32 a_, float_status *status) {if (float32_is_signaling_nan (a_, status)) {if (status->snan_bit_is_one) { +#ifdef TARGET_HPPA +uint32_t a =float32_val (a_); + a &= ~0x00400000 ; + a |=0x00200000 ; +return make_float32 (a); +#else return float32_default_nan (status); +#endif }else {uint32_t a =float32_val (a_); a |= (1 <<22 );
@@ -449,7 +460,7 @@ static int pickNaN(flag aIsQNaN, flag aIsSNaN, flag bIsQNaN, flag bIsSNaN, return 1; } } -#elif defined(TARGET_MIPS) +#elif defined(TARGET_MIPS) || defined(TARGET_HPPA)static int pickNaN (flag aIsQNaN,flag aIsSNaN,flag bIsQNaN,flag bIsSNaN,flag aIsLargerSignificand) {
@@ -794,7 +805,14 @@ float64 float64_maybe_silence_nan(float64 a_, float_status *status) {if (float64_is_signaling_nan (a_, status)) {if (status->snan_bit_is_one) { +#ifdef TARGET_HPPA +uint64_t a =float64_val (a_); + a &= ~0x0008000000000000ULL ; + a |=0x0004000000000000ULL ; +return make_float64 (a); +#else return float64_default_nan (status); +#endif }else {uint64_t a =float64_val (a_); a |=LIT64 (0x0008000000000000 );
Signature · 1 line
2.9.3
PATCH 18/26 target-hppa: Add framework and enable compilation
In reply to Richard HendersonThis is just about the minimum required to enable compilation without actually executing any instructions. This contains the HPPACPU structure and the required callbacks, the gdbstub, the basic translation loop, and a translate_one function that always results in an illegal instruction.
--- configure | 6 +- default-configs/hppa-linux-user.mak | 1 + target-hppa/Makefile.objs | 1 + target-hppa/cpu-qom.h | 52 +++++ target-hppa/cpu.c | 165 ++++++++++++++ target-hppa/cpu.h | 144 ++++++++++++ target-hppa/gdbstub.c | 111 ++++++++++ target-hppa/helper.c | 137 ++++++++++++ target-hppa/helper.h | 3 + target-hppa/op_helper.c | 65 ++++++ target-hppa/translate.c | 429 ++++++++++++++++++++++++++++++++++++ 11 files changed, 1111 insertions(+), 3 deletions(-) create mode 100644 default-configs/hppa-linux-user.mak create mode 100644 target-hppa/Makefile.objs create mode 100644 target-hppa/cpu-qom.h create mode 100644 target-hppa/cpu.c create mode 100644 target-hppa/cpu.h create mode 100644 target-hppa/gdbstub.c create mode 100644 target-hppa/helper.c create mode 100644 target-hppa/helper.h create mode 100644 target-hppa/op_helper.c create mode 100644 target-hppa/translate.c
configure +3 -3
@@ -511,8 +511,6 @@ elif check_define __arm__ ; then cpu="arm" elif check_define __aarch64__ ; then cpu="aarch64" -elif check_define __hppa__ ; then - cpu="hppa" else cpu=$(uname -m) fi
@@ -5839,7 +5837,7 @@ target_bigendian="no" target_mttcg_support="no" case "$target_name" in - armeb|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb) + armeb|hppa|lm32|m68k|microblaze|mips|mipsn32|mips64|moxie|or32|ppc|ppcemb|ppc64|ppc64abi32|s390x|sh4eb|sparc|sparc64|sparc32plus|xtensaeb) target_bigendian=yes ;; esac
@@ -5904,6 +5902,8 @@ case "$target_name" in ;; cris) ;; + hppa) + ;; lm32) ;; m68k)
default-configs/hppa-linux-user.mak new file +1 -0
@@ -0,0 +1 @@ +# Default configuration for hppa-linux-user
target-hppa/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-y += translate.o helper.o cpu.o op_helper.o gdbstub.o
target-hppa/cpu-qom.h new file +52 -0
52 lines not on this page · raw message
target-hppa/cpu.c new file +165 -0
165 lines not on this page · raw message
target-hppa/cpu.h new file +144 -0
144 lines not on this page · raw message
target-hppa/gdbstub.c new file +111 -0
111 lines not on this page · raw message
target-hppa/helper.c new file +137 -0
137 lines not on this page · raw message
target-hppa/helper.h new file +3 -0
@@ -0,0 +1,3 @@ +DEF_HELPER_2(excp, noreturn, env, int) + +DEF_HELPER_FLAGS_1 (loaded_fr0,TCG_CALL_NO_RWG , void, env)
target-hppa/op_helper.c new file +65 -0
65 lines not on this page · raw message
target-hppa/translate.c new file +429 -0
429 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 19/26 target-hppa: Add nullification framework
In reply to Richard HendersonThe HPPA cpu has a unique form of predicated execution in which almost any instruction can set the PSW[N] (or "nullify") bit, which suppresses execution (and even decoding) of the following instruction. Execution of a nullified insn clears the PSW[N] bit.
This adds a generic framework for branching over nullified insns, or for sufficiently simple insns, transforming the writeback of the result to a conditional move. In the process, we want to be able to represent PSW[N] as a TCG condition, which implies management of the related tcg temps.
--- target-hppa/translate.c | 228 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 224 insertions(+), 4 deletions(-)
target-hppa/translate.c +224 -4
@@ -151,6 +151,78 @@ void hppa_translate_init(void) } } +static DisasCond cond_make_f (void ) +{ +DisasCond r = { .c =TCG_COND_NEVER }; +TCGV_UNUSED (r.a0); +TCGV_UNUSED (r.a1); +return r; +} + +static DisasCond cond_make_n (void ) +{ +DisasCond r = { .c =TCG_COND_NE , .a0_is_n = true, .a1_is_0 = true }; + r.a0 = cpu_psw_n; +TCGV_UNUSED (r.a1); +return r; +} + +static DisasCond cond_make_0 (TCGCond c,TCGv a0) +{ +DisasCond r = { .c = c, .a1_is_0 = true }; + +assert (c !=TCG_COND_NEVER && c !=TCG_COND_ALWAYS ); + r.a0 =tcg_temp_new (); +tcg_gen_mov_tl (r.a0, a0); +TCGV_UNUSED (r.a1); + +return r; +} + +static DisasCond cond_make (TCGCond c,TCGv a0,TCGv a1) +{ +DisasCond r = { .c = c }; + +assert (c !=TCG_COND_NEVER && c !=TCG_COND_ALWAYS ); + r.a0 =tcg_temp_new (); +tcg_gen_mov_tl (r.a0, a0); + r.a1 =tcg_temp_new (); +tcg_gen_mov_tl (r.a1, a1); + +return r; +} + +static void cond_prep (DisasCond *cond) +{ +if (cond->a1_is_0) { + cond->a1_is_0 = false; + cond->a1 =tcg_const_tl (0 ); + } +} + +static void cond_free (DisasCond *cond) +{ +switch (cond->c) { +default : +if (!cond->a0_is_n) { +tcg_temp_free (cond->a0); + } +if (!cond->a1_is_0) { +tcg_temp_free (cond->a1); + } + cond->a0_is_n = false; + cond->a1_is_0 = false; +TCGV_UNUSED (cond->a0); +TCGV_UNUSED (cond->a1); +/* fallthru */ +case TCG_COND_ALWAYS : + cond->c =TCG_COND_NEVER ; +break ; +case TCG_COND_NEVER : +break ; + } +} +static TCGv get_temp (DisasContext *ctx) {unsigned i = ctx->ntemps++;
@@ -178,13 +250,125 @@ static TCGv load_gpr(DisasContext *ctx, unsigned reg)static TCGv dest_gpr (DisasContext *ctx,unsigned reg) { -if (reg ==0 ) { +if (reg ==0 || ctx->null_cond.c !=TCG_COND_NEVER ) {return get_temp (ctx); }else {return cpu_gr[reg]; } } +static void save_or_nullify (DisasContext *ctx,TCGv dest,TCGv t) +{ +if (ctx->null_cond.c !=TCG_COND_NEVER ) { +cond_prep (&ctx->null_cond); +tcg_gen_movcond_tl (ctx->null_cond.c, dest, ctx->null_cond.a0, + ctx->null_cond.a1, dest, t); + }else { +tcg_gen_mov_tl (dest, t); + } +} + +static void save_gpr (DisasContext *ctx,unsigned reg,TCGv t) +{ +if (reg !=0 ) { +save_or_nullify (ctx, cpu_gr[reg], t); + } +} + +/* Skip over the implementation of an insn that has been nullified. +Use this when the insn is too complex for a conditional move. */ +static void nullify_over (DisasContext *ctx) +{ +if (ctx->null_cond.c !=TCG_COND_NEVER ) { +/* The always condition should have been handled in the main loop. */ +assert (ctx->null_cond.c !=TCG_COND_ALWAYS ); + + ctx->null_lab =gen_new_label (); +cond_prep (&ctx->null_cond); + +/* If we're using PSW[N], copy it to a temp because... */ +if (ctx->null_cond.a0_is_n) { + ctx->null_cond.a0_is_n = false; + ctx->null_cond.a0 =tcg_temp_new (); +tcg_gen_mov_tl (ctx->null_cond.a0, cpu_psw_n); + } +/* ... we clear it before branching over the implementation, +so that (1) it's clear after nullifying this insn and +(2) if this insn nullifies the next, PSW[N] is valid. */ +if (ctx->psw_n_nonzero) { + ctx->psw_n_nonzero = false; +tcg_gen_movi_tl (cpu_psw_n,0 ); + } + +tcg_gen_brcond_tl (ctx->null_cond.c, ctx->null_cond.a0, + ctx->null_cond.a1, ctx->null_lab); +cond_free (&ctx->null_cond); + } +} + +/* Save the current nullification state to PSW[N]. */ +static void nullify_save (DisasContext *ctx) +{ +if (ctx->null_cond.c ==TCG_COND_NEVER ) { +if (ctx->psw_n_nonzero) { +tcg_gen_movi_tl (cpu_psw_n,0 ); + } +return ; + } +if (!ctx->null_cond.a0_is_n) { +cond_prep (&ctx->null_cond); +tcg_gen_setcond_tl (ctx->null_cond.c, cpu_psw_n, + ctx->null_cond.a0, ctx->null_cond.a1); + ctx->psw_n_nonzero = true; + } +cond_free (&ctx->null_cond); +} + +/* Set a PSW[N] to X. The intention is that this is used immediately +before a goto_tb/exit_tb, so that there is no fallthru path to other +code within the TB. Therefore we do not update psw_n_nonzero. */ +static void nullify_set (DisasContext *ctx,bool x) +{ +if (ctx->psw_n_nonzero || x) { +tcg_gen_movi_tl (cpu_psw_n, x); + } +} + +/* Mark the end of an instruction that may have been nullified. +This is the pair to nullify_over. */ +static ExitStatus nullify_end (DisasContext *ctx,ExitStatus status) +{ +TCGLabel *null_lab = ctx->null_lab; + +if (likely (null_lab ==NULL )) { +/* The current insn wasn't conditional or handled the condition +applied to it without a branch, so the (new) setting of +NULL_COND can be applied directly to the next insn. */ +return status; + } + ctx->null_lab =NULL ; + +if (likely (ctx->null_cond.c ==TCG_COND_NEVER )) { +/* The next instruction will be unconditional, +and NULL_COND already reflects that. */ +gen_set_label (null_lab); + }else { +/* The insn that we just executed is itself nullifying the next +instruction. Store the condition in the PSW[N] global. +We asserted PSW[N] = 0 in nullify_over, so that after the +label we have the proper value in place. */ +nullify_save (ctx); +gen_set_label (null_lab); + ctx->null_cond =cond_make_n (); + } + +assert (status !=EXIT_GOTO_TB && status !=EXIT_IAQ_N_UPDATED ); +if (status ==EXIT_NORETURN ) { + status =NO_EXIT ; + } +return status; +} +static void copy_iaoq_entry (TCGv dest,target_ulong ival,TCGv vval) {if (unlikely (ival ==-1 )) {
@@ -210,13 +394,15 @@ static ExitStatus gen_excp(DisasContext *ctx, int exception) {copy_iaoq_entry (cpu_iaoq_f, ctx->iaoq_f, cpu_iaoq_f);copy_iaoq_entry (cpu_iaoq_b, ctx->iaoq_b, cpu_iaoq_b); +nullify_save (ctx);gen_excp_1 (exception);return EXIT_NORETURN ; }static ExitStatus gen_illegal (DisasContext *ctx) { -return gen_excp (ctx,EXCP_SIGILL ); +nullify_over (ctx); +return nullify_end (ctx,gen_excp (ctx,EXCP_SIGILL )); }static bool use_goto_tb (DisasContext *ctx,target_ulong dest)
@@ -228,6 +414,16 @@ static bool use_goto_tb(DisasContext *ctx, target_ulong dest)return true; } +/* If the next insn is to be nullified, and it's on the same page, +and we're not attempting to set a breakpoint on it, then we can +totally skip the nullified insn. This avoids creating and +executing a TB that merely branches to the next TB. */ +static bool use_nullify_skip (DisasContext *ctx) +{ +return (((ctx->iaoq_b ^ ctx->iaoq_f) &TARGET_PAGE_MASK ) ==0 + && !cpu_breakpoint_test (ctx->cs, ctx->iaoq_b,BP_ANY )); +} +static void gen_goto_tb (DisasContext *ctx,int which,target_ulong f,target_ulong b) {
@@ -308,6 +504,15 @@ void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb) num_insns =0 ;gen_tb_start (tb); +/* Seed the nullification status from PSW[N], as shown in TB->FLAGS. */ + ctx.null_cond =cond_make_f (); + ctx.psw_n_nonzero = false; +if (tb->flags &1 ) { + ctx.null_cond.c =TCG_COND_ALWAYS ; + ctx.psw_n_nonzero = true; + } + ctx.null_lab =NULL ; + do { tcg_gen_insn_start(ctx.iaoq_f, ctx.iaoq_b); num_insns++;
@@ -336,7 +541,13 @@ void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb)TCGV_UNUSED (ctx.iaoq_n_var); } - ret =translate_one (&ctx, insn); +if (unlikely (ctx.null_cond.c ==TCG_COND_ALWAYS )) { + ctx.null_cond.c =TCG_COND_NEVER ; + ret =NO_EXIT ; + }else { + ret =translate_one (&ctx, insn); +assert (ctx.null_lab ==NULL ); + } }for (i =0 ; i < ctx.ntemps; ++i) {
@@ -354,7 +565,14 @@ void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb) && (ctx.iaoq_b != ctx.iaoq_f + 4 || num_insns >= max_insns || tcg_op_buf_full())) { - ret =EXIT_IAQ_N_STALE ; +if (ctx.null_cond.c ==TCG_COND_NEVER + || ctx.null_cond.c ==TCG_COND_ALWAYS ) { +nullify_set (&ctx, ctx.null_cond.c ==TCG_COND_ALWAYS ); +gen_goto_tb (&ctx,0 , ctx.iaoq_b, ctx.iaoq_n); + ret =EXIT_GOTO_TB ; + }else { + ret =EXIT_IAQ_N_STALE ; + } } ctx.iaoq_f = ctx.iaoq_b;
@@ -367,6 +585,7 @@ void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb)if (ctx.iaoq_f ==-1 ) {tcg_gen_mov_tl (cpu_iaoq_f, cpu_iaoq_b);copy_iaoq_entry (cpu_iaoq_b, ctx.iaoq_n, ctx.iaoq_n_var); +nullify_save (&ctx); ret =EXIT_IAQ_N_UPDATED ;break ; }
@@ -386,6 +605,7 @@ void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb)case EXIT_IAQ_N_STALE :copy_iaoq_entry (cpu_iaoq_f, ctx.iaoq_f, cpu_iaoq_f);copy_iaoq_entry (cpu_iaoq_b, ctx.iaoq_b, cpu_iaoq_b); +nullify_save (&ctx);/* FALLTHRU */ case EXIT_IAQ_N_UPDATED :if (ctx.singlestep_enabled) {
Signature · 1 line
2.9.3
PATCH 20/26 target-hppa: Implement basic arithmetic
In reply to Richard Henderson--- target-hppa/helper.h | 2 + target-hppa/op_helper.c | 23 ++ target-hppa/translate.c | 882 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 907 insertions(+)
target-hppa/helper.h +2 -0
@@ -1,3 +1,5 @@ DEF_HELPER_2(excp, noreturn, env, int) +DEF_HELPER_FLAGS_2(tsv, TCG_CALL_NO_WG, void, env, tl) +DEF_HELPER_FLAGS_2(tcond, TCG_CALL_NO_WG, void, env, tl)DEF_HELPER_FLAGS_1 (loaded_fr0,TCG_CALL_NO_RWG , void, env)
target-hppa/op_helper.c +23 -0
@@ -31,6 +31,29 @@ void QEMU_NORETURN HELPER(excp)(CPUHPPAState *env, int excp)cpu_loop_exit (cs); } +static void QEMU_NORETURN dynexcp(CPUHPPAState *env, int excp, uintptr_t ra) +{ +HPPACPU *cpu =hppa_env_get_cpu (env); +CPUState *cs =CPU (cpu); + + cs->exception_index = excp; +cpu_loop_exit_restore (cs, ra); +} + +void HELPER (tsv )(CPUHPPAState *env,target_ulong cond) +{ +if (unlikely ((target_long )cond <0 )) { +dynexcp (env,EXCP_SIGFPE ,GETPC ()); + } +} + +void HELPER (tcond )(CPUHPPAState *env,target_ulong cond) +{ +if (unlikely (cond)) { +dynexcp (env,EXCP_SIGFPE ,GETPC ()); + } +} +void HELPER (loaded_fr0 )(CPUHPPAState *env) {uint32_t shadow = env->fr[0 ] >>32 ;
target-hppa/translate.c +882 -0
900 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 21/26 target-hppa: Implement branches
In reply to Richard Henderson--- target-hppa/translate.c | 477 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 477 insertions(+)
target-hppa/translate.c +477 -0
@@ -455,6 +455,14 @@ static target_long low_sextract(uint32_t val, int pos, int len)return x; } +static target_long assemble_12 (uint32_t insn) +{ +target_ulong x = -(target_ulong)(insn &1 ); + x = (x <<1 ) |extract32 (insn,2 ,1 ); + x = (x <<10 ) |extract32 (insn,3 ,10 ); +return x; +} +static target_long assemble_16 (uint32_t insn) {/* Take the name from PA2.0, which produces a 16-bit number
@@ -463,6 +471,15 @@ static target_long assemble_16(uint32_t insn)return low_sextract (insn,0 ,14 ); } +static target_long assemble_17 (uint32_t insn) +{ +target_ulong x = -(target_ulong)(insn &1 ); + x = (x <<5 ) |extract32 (insn,16 ,5 ); + x = (x <<1 ) |extract32 (insn,2 ,1 ); + x = (x <<10 ) |extract32 (insn,3 ,10 ); +return x <<2 ; +} +static target_long assemble_21 (uint32_t insn) {target_ulong x = -(target_ulong)(insn &1 );
@@ -473,6 +490,15 @@ static target_long assemble_21(uint32_t insn)return x <<11 ; } +static target_long assemble_22 (uint32_t insn) +{ +target_ulong x = -(target_ulong)(insn &1 ); + x = (x <<10 ) |extract32 (insn,16 ,10 ); + x = (x <<1 ) |extract32 (insn,2 ,1 ); + x = (x <<10 ) |extract32 (insn,3 ,10 ); +return x <<2 ; +} +/* The parisc documentation describes only the general interpretation of the conditions, without describing their exact implementation. The interpretations do not stand up well when considering ADD,C and SUB,B.
@@ -574,6 +600,24 @@ static DisasCond do_log_cond(unsigned cf, TCGv res)return do_cond (cf, res, res, res); } +/* Similar, but for shift/extract/deposit conditions. */ + +static DisasCond do_sed_cond (unsigned orig,TCGv res) +{ +unsigned c, f; + +/* Convert the compressed condition codes to standard. +0-2 are the same as logicals (nv,<,<=), while 3 is OD. +4-7 are the reverse of 0-3. */ + c = orig &3 ; +if (c ==3 ) { + c =7 ; + } + f = (orig &4 ) /4 ; + +return do_log_cond (c *2 + f, res); +} +/* Similar, but for unit conditions. */ static DisasCond do_unit_cond (unsigned cf,TCGv res,TCGv in1,TCGv in2)
@@ -897,6 +941,188 @@ static ExitStatus do_unit(DisasContext *ctx, unsigned rt, TCGv in1,return NO_EXIT ; } +/* Emit an unconditional branch to a direct target, which may or may not +have already had nullification handled. */ +static ExitStatus do_dbranch (DisasContext *ctx,target_ulong dest, +unsigned link,bool is_n) +{ +if (ctx->null_cond.c ==TCG_COND_NEVER && ctx->null_lab ==NULL ) { +if (link !=0 ) { +copy_iaoq_entry (cpu_gr[link], ctx->iaoq_n, ctx->iaoq_n_var); + } + ctx->iaoq_n = dest; +if (is_n) { + ctx->null_cond.c =TCG_COND_ALWAYS ; + } +return NO_EXIT ; + }else { +nullify_over (ctx); + +if (link !=0 ) { +copy_iaoq_entry (cpu_gr[link], ctx->iaoq_n, ctx->iaoq_n_var); + } + +if (is_n &&use_nullify_skip (ctx)) { +nullify_set (ctx,0 ); +gen_goto_tb (ctx,0 , dest, dest +4 ); + }else { +nullify_set (ctx, is_n); +gen_goto_tb (ctx,0 , ctx->iaoq_b, dest); + } + +nullify_end (ctx,NO_EXIT ); + +nullify_set (ctx,0 ); +gen_goto_tb (ctx,1 , ctx->iaoq_b, ctx->iaoq_n); +return EXIT_GOTO_TB ; + } +} + +/* Emit a conditional branch to a direct target. If the branch itself +is nullified, we should have already used nullify_over. */ +static ExitStatus do_cbranch (DisasContext *ctx,target_long disp,bool is_n, +DisasCond *cond) +{ +target_ulong dest =iaoq_dest (ctx, disp); +TCGLabel *taken =NULL ; +TCGCond c = cond->c; +int which =0 ; +bool n; + +assert (ctx->null_cond.c ==TCG_COND_NEVER ); + +/* Handle TRUE and NEVER as direct branches. */ +if (c ==TCG_COND_ALWAYS ) { +return do_dbranch (ctx, dest,0 , is_n && disp >=0 ); + } +if (c ==TCG_COND_NEVER ) { +return do_dbranch (ctx, ctx->iaoq_n,0 , is_n && disp <0 ); + } + + taken =gen_new_label (); +cond_prep (cond); +tcg_gen_brcond_tl (c, cond->a0, cond->a1, taken); +cond_free (cond); + +/* Not taken: Condition not satisfied; nullify on backward branches. */ + n = is_n && disp <0 ; +if (n &&use_nullify_skip (ctx)) { +nullify_set (ctx,0 ); +gen_goto_tb (ctx, which++, ctx->iaoq_n, ctx->iaoq_n +4 ); + }else { +if (!n && ctx->null_lab) { +gen_set_label (ctx->null_lab); + ctx->null_lab =NULL ; + } +nullify_set (ctx, n); +gen_goto_tb (ctx, which++, ctx->iaoq_b, ctx->iaoq_n); + } + +gen_set_label (taken); + +/* Taken: Condition satisfied; nullify on forward branches. */ + n = is_n && disp >=0 ; +if (n &&use_nullify_skip (ctx)) { +nullify_set (ctx,0 ); +gen_goto_tb (ctx, which++, dest, dest +4 ); + }else { +nullify_set (ctx, n); +gen_goto_tb (ctx, which++, ctx->iaoq_b, dest); + } + +/* Not taken: the branch itself was nullified. */ +if (ctx->null_lab) { +gen_set_label (ctx->null_lab); + ctx->null_lab =NULL ; +if (which <2 ) { +nullify_set (ctx,0 ); +gen_goto_tb (ctx, which, ctx->iaoq_b, ctx->iaoq_n); +return EXIT_GOTO_TB ; + }else { +return EXIT_IAQ_N_STALE ; + } + }else { +return EXIT_GOTO_TB ; + } +} + +/* Emit an unconditional branch to an indirect target. This handles +nullification of the branch itself. */ +static ExitStatus do_ibranch (DisasContext *ctx,TCGv dest, +unsigned link,bool is_n) +{ +TCGv a0, a1, next, tmp; +TCGCond c; + +assert (ctx->null_lab ==NULL ); + +if (ctx->null_cond.c ==TCG_COND_NEVER ) { +if (link !=0 ) { +copy_iaoq_entry (cpu_gr[link], ctx->iaoq_n, ctx->iaoq_n_var); + } + next =get_temp (ctx); +tcg_gen_mov_tl (next, dest); + ctx->iaoq_n =-1 ; + ctx->iaoq_n_var = next; +if (is_n) { + ctx->null_cond.c =TCG_COND_ALWAYS ; + } + }else if (is_n &&use_nullify_skip (ctx)) { +/* The (conditional) branch, B, nullifies the next insn, N, +and we're allowed to skip execution N (no single-step or +tracepoint in effect). Since the exit_tb that we must use +for the indirect branch consumes no special resources, we +can (conditionally) skip B and continue execution. */ +/* The use_nullify_skip test implies we have a known control path. */ +tcg_debug_assert (ctx->iaoq_b !=-1 ); +tcg_debug_assert (ctx->iaoq_n !=-1 ); + +/* We do have to handle the non-local temporary, DEST, before +branching. Since IOAQ_F is not really live at this point, we +can simply store DEST optimistically. Similarly with IAOQ_B. */ +tcg_gen_mov_tl (cpu_iaoq_f, dest); +tcg_gen_addi_tl (cpu_iaoq_b, dest,4 ); + +nullify_over (ctx); +if (link !=0 ) { +tcg_gen_movi_tl (cpu_gr[link], ctx->iaoq_n); + } +tcg_gen_exit_tb (0 ); +return nullify_end (ctx,NO_EXIT ); + }else { +cond_prep (&ctx->null_cond); + c = ctx->null_cond.c; + a0 = ctx->null_cond.a0; + a1 = ctx->null_cond.a1; + + tmp =tcg_temp_new (); + next =get_temp (ctx); + +copy_iaoq_entry (tmp, ctx->iaoq_n, ctx->iaoq_n_var); +tcg_gen_movcond_tl (c, next, a0, a1, tmp, dest); + ctx->iaoq_n =-1 ; + ctx->iaoq_n_var = next; + +if (link !=0 ) { +tcg_gen_movcond_tl (c, cpu_gr[link], a0, a1, cpu_gr[link], tmp); + } + +if (is_n) { +/* The branch nullifies the next insn, which means the state of N +after the branch is the inverse of the state of N that applied +to the branch. */ +tcg_gen_setcond_tl (tcg_invert_cond (c), cpu_psw_n, a0, a1); +cond_free (&ctx->null_cond); + ctx->null_cond =cond_make_n (); + ctx->psw_n_nonzero = true; + }else { +cond_free (&ctx->null_cond); + } + } + +return NO_EXIT ; +} +static ExitStatus trans_nop (DisasContext *ctx,uint32_t insn,const DisasInsn *di) {
@@ -1310,6 +1536,224 @@ static ExitStatus trans_ldo(DisasContext *ctx, uint32_t insn)return NO_EXIT ; } +static ExitStatus trans_cmpb (DisasContext *ctx,uint32_t insn, +bool is_true,bool is_imm,bool is_dw) +{ +target_long disp =assemble_12 (insn) *4 ; +unsigned n =extract32 (insn,1 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned r =extract32 (insn,21 ,5 ); +unsigned cf = c *2 + !is_true; +TCGv dest, in1, in2, sv; +DisasCond cond; + +nullify_over (ctx); + +if (is_imm) { + in1 =load_const (ctx,low_sextract (insn,16 ,5 )); + }else { + in1 =load_gpr (ctx,extract32 (insn,16 ,5 )); + } + in2 =load_gpr (ctx, r); + dest =get_temp (ctx); + +tcg_gen_sub_tl (dest, in1, in2); + +TCGV_UNUSED (sv); +if (c ==6 ) { + sv =do_sub_sv (ctx, dest, in1, in2); + } + + cond =do_sub_cond (cf, dest, in1, in2, sv); +return do_cbranch (ctx, disp, n, &cond); +} + +static ExitStatus trans_addb (DisasContext *ctx,uint32_t insn, +bool is_true,bool is_imm) +{ +target_long disp =assemble_12 (insn) *4 ; +unsigned n =extract32 (insn,1 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned r =extract32 (insn,21 ,5 ); +unsigned cf = c *2 + !is_true; +TCGv dest, in1, in2, sv, cb_msb; +DisasCond cond; + +nullify_over (ctx); + +if (is_imm) { + in1 =load_const (ctx,low_sextract (insn,16 ,5 )); + }else { + in1 =load_gpr (ctx,extract32 (insn,16 ,5 )); + } + in2 =load_gpr (ctx, r); + dest =dest_gpr (ctx, r); +TCGV_UNUSED (sv); +TCGV_UNUSED (cb_msb); + +switch (c) { +default : +tcg_gen_add_tl (dest, in1, in2); +break ; +case 4 :case 5 : + cb_msb =get_temp (ctx); +tcg_gen_movi_tl (cb_msb,0 ); +tcg_gen_add2_tl (dest, cb_msb, in1, cb_msb, in2, cb_msb); +break ; +case 6 : +tcg_gen_add_tl (dest, in1, in2); + sv =do_add_sv (ctx, dest, in1, in2); +break ; + } + + cond =do_cond (cf, dest, cb_msb, sv); +return do_cbranch (ctx, disp, n, &cond); +} + +static ExitStatus trans_bb (DisasContext *ctx,uint32_t insn) +{ +target_long disp =assemble_12 (insn) *4 ; +unsigned n =extract32 (insn,1 ,1 ); +unsigned c =extract32 (insn,15 ,1 ); +unsigned r =extract32 (insn,16 ,5 ); +unsigned p =extract32 (insn,21 ,5 ); +unsigned i =extract32 (insn,26 ,1 ); +TCGv tmp, tcg_r; +DisasCond cond; + +nullify_over (ctx); + + tmp =tcg_temp_new (); + tcg_r =load_gpr (ctx, r); +if (i) { +tcg_gen_shli_tl (tmp, tcg_r, p); + }else { +tcg_gen_shl_tl (tmp, tcg_r, cpu_sar); + } + + cond =cond_make_0 (c ?TCG_COND_GE :TCG_COND_LT , tmp); +tcg_temp_free (tmp); +return do_cbranch (ctx, disp, n, &cond); +} + +static ExitStatus trans_movb (DisasContext *ctx,uint32_t insn,bool is_imm) +{ +target_long disp =assemble_12 (insn) *4 ; +unsigned n =extract32 (insn,1 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned t =extract32 (insn,16 ,5 ); +unsigned r =extract32 (insn,21 ,5 ); +TCGv dest; +DisasCond cond; + +nullify_over (ctx); + + dest =dest_gpr (ctx, r); +if (is_imm) { +tcg_gen_movi_tl (dest,low_sextract (t,0 ,5 )); + }else if (t ==0 ) { +tcg_gen_movi_tl (dest,0 ); + }else { +tcg_gen_mov_tl (dest, cpu_gr[t]); + } + + cond =do_sed_cond (c, dest); +return do_cbranch (ctx, disp, n, &cond); +} + +static ExitStatus trans_be (DisasContext *ctx,uint32_t insn,bool is_l) +{ +unsigned n =extract32 (insn,1 ,1 ); +unsigned b =extract32 (insn,21 ,5 ); +target_long disp =assemble_17 (insn); + +/* unsigned s = low_uextract(insn, 13, 3); */ +/* ??? It seems like there should be a good way of using +"be disp(sr2, r0)", the canonical gateway entry mechanism +to our advantage. But that appears to be inconvenient to +manage along side branch delay slots. Therefore we handle +entry into the gateway page via absolute address. */ + +/* Since we don't implement spaces, just branch. Do notice the special +case of "be disp(*,r0)" using a direct branch to disp, so that we can +goto_tb to the TB containing the syscall. */ +if (b ==0 ) { +return do_dbranch (ctx, disp, is_l ?31 :0 , n); + }else { +TCGv tmp =get_temp (ctx); +tcg_gen_addi_tl (tmp,load_gpr (ctx, b), disp); +return do_ibranch (ctx, tmp, is_l ?31 :0 , n); + } +} + +static ExitStatus trans_bl (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned n =extract32 (insn,1 ,1 ); +unsigned link =extract32 (insn,21 ,5 ); +target_long disp =assemble_17 (insn); + +return do_dbranch (ctx,iaoq_dest (ctx, disp), link, n); +} + +static ExitStatus trans_bl_long (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned n =extract32 (insn,1 ,1 ); +target_long disp =assemble_22 (insn); + +return do_dbranch (ctx,iaoq_dest (ctx, disp),2 , n); +} + +static ExitStatus trans_blr (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned n =extract32 (insn,1 ,1 ); +unsigned rx =extract32 (insn,16 ,5 ); +unsigned link =extract32 (insn,21 ,5 ); +TCGv tmp =get_temp (ctx); + +tcg_gen_shli_tl (tmp,load_gpr (ctx, rx),3 ); +tcg_gen_addi_tl (tmp, tmp, ctx->iaoq_f +8 ); +return do_ibranch (ctx, tmp, link, n); +} + +static ExitStatus trans_bv (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned n =extract32 (insn,1 ,1 ); +unsigned rx =extract32 (insn,16 ,5 ); +unsigned rb =extract32 (insn,21 ,5 ); +TCGv dest; + +if (rx ==0 ) { + dest =load_gpr (ctx, rb); + }else { + dest =get_temp (ctx); +tcg_gen_shli_tl (dest,load_gpr (ctx, rx),3 ); +tcg_gen_add_tl (dest, dest,load_gpr (ctx, rb)); + } +return do_ibranch (ctx, dest,0 , n); +} + +static ExitStatus trans_bve (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned n =extract32 (insn,1 ,1 ); +unsigned rb =extract32 (insn,21 ,5 ); +unsigned link =extract32 (insn,13 ,1 ) ?2 :0 ; + +return do_ibranch (ctx,load_gpr (ctx, rb), link, n); +} + +static const DisasInsn table_branch[] = { + {0xe8000000u ,0xfc006000u , trans_bl },/* B,L and B,L,PUSH */ + {0xe800a000u ,0xfc00e000u , trans_bl_long }, + {0xe8004000u ,0xfc00fffdu , trans_blr }, + {0xe800c000u ,0xfc00fffdu , trans_bv }, + {0xe800d000u ,0xfc00dffcu , trans_bve }, +}; +static ExitStatus translate_table_int (DisasContext *ctx,uint32_t insn,const DisasInsn table[],size_t n) {
@@ -1338,13 +1782,46 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)return trans_addil (ctx, insn);case 0x0D :return trans_ldo (ctx, insn); +case 0x20 : +return trans_cmpb (ctx, insn, true, false, false); +case 0x21 : +return trans_cmpb (ctx, insn, true, true, false); +case 0x22 : +return trans_cmpb (ctx, insn, false, false, false); +case 0x23 : +return trans_cmpb (ctx, insn, false, true, false);case 0x24 :return trans_cmpiclr (ctx, insn);case 0x25 :return trans_subi (ctx, insn); +case 0x27 : +return trans_cmpb (ctx, insn, true, false, true); +case 0x28 : +return trans_addb (ctx, insn, true, false); +case 0x29 : +return trans_addb (ctx, insn, true, true); +case 0x2A : +return trans_addb (ctx, insn, false, false); +case 0x2B : +return trans_addb (ctx, insn, false, true);case 0x2C :case 0x2D :return trans_addi (ctx, insn); +case 0x2F : +return trans_cmpb (ctx, insn, false, false, true); +case 0x30 : +case 0x31 : +return trans_bb (ctx, insn); +case 0x32 : +return trans_movb (ctx, insn, false); +case 0x33 : +return trans_movb (ctx, insn, true); +case 0x38 : +return trans_be (ctx, insn, false); +case 0x39 : +return trans_be (ctx, insn, true); +case 0x3A : +return translate_table (ctx, insn, table_branch);default :break ; }
Signature · 1 line
2.9.3
PATCH 22/26 target-hppa: Implement linux-user gateway page
In reply to Richard HendersonFor linux, page 0 is mapped as an execute-only gateway. A gateway page is a special bit in the page table that allows a B,GATE insn within that page to raise processor permissions. This is how system calls are implemented for HPPA.
Rather than actually map anything here, or handle permissions at all, implement the semantics of the actual linux syscall entry points.
--- target-hppa/translate.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 81 insertions(+), 4 deletions(-)
target-hppa/translate.c +81 -4
@@ -1123,6 +1123,64 @@ static ExitStatus do_ibranch(DisasContext *ctx, TCGv dest,return NO_EXIT ; } +/* On Linux, page zero is normally marked execute only + gateway. +Therefore normal read or write is supposed to fail, but specific +offsets have kernel code mapped to raise permissions to implement +system calls. Handling this via an explicit check here, rather +in than the "be disp(sr2,r0)" instruction that probably sent us +here, is the easiest way to handle the branch delay slot on the +aforementioned BE. */ +static ExitStatus do_page_zero (DisasContext *ctx) +{ +/* If by some means we get here with PSW[N]=1, that implies that +the B,GATE instruction would be skipped, and we'd fault on the +next insn within the privilaged page. */ +switch (ctx->null_cond.c) { +case TCG_COND_NEVER : +break ; +case TCG_COND_ALWAYS : +tcg_gen_movi_tl (cpu_psw_n,0 ); + goto do_sigill; +default : +/* Since this is always the first (and only) insn within the +TB, we should know the state of PSW[N] from TB->FLAGS. */ +g_assert_not_reached (); + } + +/* Check that we didn't arrive here via some means that allowed +non-sequential instruction execution. Normally the PSW[B] bit +detects this by disallowing the B,GATE instruction to execute +under such conditions. */ +if (ctx->iaoq_b != ctx->iaoq_f +4 ) { + goto do_sigill; + } + +switch (ctx->iaoq_f) { +case 0x00 :/* Null pointer call */ +gen_excp_1 (EXCP_SIGSEGV ); +return EXIT_NORETURN ; + +case 0xb0 :/* LWS */ +gen_excp_1 (EXCP_SYSCALL_LWS ); +return EXIT_NORETURN ; + +case 0xe0 :/* SET_THREAD_POINTER */ +tcg_gen_mov_tl (cpu_cr27, cpu_gr[26 ]); +tcg_gen_mov_tl (cpu_iaoq_f, cpu_gr[31 ]); +tcg_gen_addi_tl (cpu_iaoq_b, cpu_iaoq_f,4 ); +return EXIT_IAQ_N_UPDATED ; + +case 0x100 :/* SYSCALL */ +gen_excp_1 (EXCP_SYSCALL ); +return EXIT_NORETURN ; + +default : + do_sigill: +gen_excp_1 (EXCP_SIGILL ); +return EXIT_NORETURN ; + } +} +static ExitStatus trans_nop (DisasContext *ctx,uint32_t insn,const DisasInsn *di) {
@@ -1884,7 +1942,10 @@ void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb)gen_io_start (); } - { +if (ctx.iaoq_f <TARGET_PAGE_SIZE ) { + ret =do_page_zero (&ctx); +assert (ret !=NO_EXIT ); + }else {/* Always fetch the insn, even if nullified, so that we check the page permissions for execute. */ uint32_t insn =cpu_ldl_code (env, ctx.iaoq_f);
@@ -1986,9 +2047,25 @@ void gen_intermediate_code(CPUHPPAState *env, struct TranslationBlock *tb)if (qemu_loglevel_mask (CPU_LOG_TB_IN_ASM ) &&qemu_log_in_addr_range (tb->pc)) {qemu_log_lock (); -qemu_log ("IN: %s\n" ,lookup_symbol (tb->pc)); -log_target_disas (cs, tb->pc, tb->size,1 ); -qemu_log ("\n" ); +switch (tb->pc) { +case 0x00 : +qemu_log ("IN:\n0x00000000: (null)\n\n" ); +break ; +case 0xb0 : +qemu_log ("IN:\n0x000000b0: light-weight-syscall\n\n" ); +break ; +case 0xe0 : +qemu_log ("IN:\n0x000000e0: set-thread-pointer-syscall\n\n" ); +break ; +case 0x100 : +qemu_log ("IN:\n0x00000100: syscall\n\n" ); +break ; +default : +qemu_log ("IN: %s\n" ,lookup_symbol (tb->pc)); +log_target_disas (cs, tb->pc, tb->size,1 ); +qemu_log ("\n" ); +break ; + }qemu_log_unlock (); }#endif
Signature · 1 line
2.9.3
PATCH 23/26 target-hppa: Implement shifts and deposits
In reply to Richard Henderson--- target-hppa/translate.c | 309 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 309 insertions(+)
target-hppa/translate.c +309 -0
@@ -1719,6 +1719,311 @@ static ExitStatus trans_movb(DisasContext *ctx, uint32_t insn, bool is_imm)return do_cbranch (ctx, disp, n, &cond); } +static ExitStatus trans_shrpw_sar (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned rt =extract32 (insn,0 ,5 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned r1 =extract32 (insn,16 ,5 ); +unsigned r2 =extract32 (insn,21 ,5 ); +TCGv dest; + +if (c) { +nullify_over (ctx); + } + + dest =dest_gpr (ctx, rt); +if (r1 ==0 ) { +tcg_gen_ext32u_tl (dest,load_gpr (ctx, r2)); +tcg_gen_shr_tl (dest, dest, cpu_sar); + }else if (r1 == r2) { +TCGv_i32 t32 =tcg_temp_new_i32 (); +tcg_gen_trunc_tl_i32 (t32,load_gpr (ctx, r2)); +tcg_gen_rotr_i32 (t32, t32, cpu_sar); +tcg_gen_extu_i32_tl (dest, t32); +tcg_temp_free_i32 (t32); + }else { +TCGv_i64 t =tcg_temp_new_i64 (); +TCGv_i64 s =tcg_temp_new_i64 (); + +tcg_gen_concat_tl_i64 (t,load_gpr (ctx, r2),load_gpr (ctx, r1)); +tcg_gen_extu_tl_i64 (s, cpu_sar); +tcg_gen_shr_i64 (t, t, s); +tcg_gen_trunc_i64_tl (dest, t); + +tcg_temp_free_i64 (t); +tcg_temp_free_i64 (s); + } +save_gpr (ctx, rt, dest); + +/* Install the new nullification. */ +cond_free (&ctx->null_cond); +if (c) { + ctx->null_cond =do_sed_cond (c, dest); + } +return nullify_end (ctx,NO_EXIT ); +} + +static ExitStatus trans_shrpw_imm (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned rt =extract32 (insn,0 ,5 ); +unsigned cpos =extract32 (insn,5 ,5 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned r1 =extract32 (insn,16 ,5 ); +unsigned r2 =extract32 (insn,21 ,5 ); +unsigned sa =31 - cpos; +TCGv dest, t2; + +if (c) { +nullify_over (ctx); + } + + dest =dest_gpr (ctx, rt); + t2 =load_gpr (ctx, r2); +if (r1 == r2) { +TCGv_i32 t32 =tcg_temp_new_i32 (); +tcg_gen_trunc_tl_i32 (t32, t2); +tcg_gen_rotri_i32 (t32, t32, sa); +tcg_gen_extu_i32_tl (dest, t32); +tcg_temp_free_i32 (t32); + }else if (r1 ==0 ) { +tcg_gen_extract_tl (dest, t2, sa,32 - sa); + }else { +TCGv t0 =tcg_temp_new (); +tcg_gen_extract_tl (t0, t2, sa,32 - sa); +tcg_gen_deposit_tl (dest, t0, cpu_gr[r1],32 - sa, sa); +tcg_temp_free (t0); + } +save_gpr (ctx, rt, dest); + +/* Install the new nullification. */ +cond_free (&ctx->null_cond); +if (c) { + ctx->null_cond =do_sed_cond (c, dest); + } +return nullify_end (ctx,NO_EXIT ); +} + +static ExitStatus trans_extrw_sar (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned clen =extract32 (insn,0 ,5 ); +unsigned is_se =extract32 (insn,10 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned rt =extract32 (insn,16 ,5 ); +unsigned rr =extract32 (insn,21 ,5 ); +unsigned len =32 - clen; +TCGv dest, src, tmp; + +if (c) { +nullify_over (ctx); + } + + dest =dest_gpr (ctx, rt); + src =load_gpr (ctx, rr); + tmp =tcg_temp_new (); + +/* Recall that SAR is using big-endian bit numbering. */ +tcg_gen_xori_tl (tmp, cpu_sar,TARGET_LONG_BITS -1 ); +if (is_se) { +tcg_gen_sar_tl (dest, src, tmp); +tcg_gen_sextract_tl (dest, dest,0 , len); + }else { +tcg_gen_shr_tl (dest, src, tmp); +tcg_gen_extract_tl (dest, dest,0 , len); + } +tcg_temp_free (tmp); +save_gpr (ctx, rt, dest); + +/* Install the new nullification. */ +cond_free (&ctx->null_cond); +if (c) { + ctx->null_cond =do_sed_cond (c, dest); + } +return nullify_end (ctx,NO_EXIT ); +} + +static ExitStatus trans_extrw_imm (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned clen =extract32 (insn,0 ,5 ); +unsigned pos =extract32 (insn,5 ,5 ); +unsigned is_se =extract32 (insn,10 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned rt =extract32 (insn,16 ,5 ); +unsigned rr =extract32 (insn,21 ,5 ); +unsigned len =32 - clen; +unsigned cpos =31 - pos; +TCGv dest, src; + +if (c) { +nullify_over (ctx); + } + + dest =dest_gpr (ctx, rt); + src =load_gpr (ctx, rr); +if (is_se) { +tcg_gen_sextract_tl (dest, src, cpos, len); + }else { +tcg_gen_extract_tl (dest, src, cpos, len); + } +save_gpr (ctx, rt, dest); + +/* Install the new nullification. */ +cond_free (&ctx->null_cond); +if (c) { + ctx->null_cond =do_sed_cond (c, dest); + } +return nullify_end (ctx,NO_EXIT ); +} + +static const DisasInsn table_sh_ex[] = { + {0xd0000000u ,0xfc001fe0u , trans_shrpw_sar }, + {0xd0000800u ,0xfc001c00u , trans_shrpw_imm }, + {0xd0001000u ,0xfc001be0u , trans_extrw_sar }, + {0xd0001800u ,0xfc001800u , trans_extrw_imm }, +}; + +static ExitStatus trans_depw_imm_c (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned clen =extract32 (insn,0 ,5 ); +unsigned cpos =extract32 (insn,5 ,5 ); +unsigned nz =extract32 (insn,10 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +target_long val =low_sextract (insn,16 ,5 ); +unsigned rt =extract32 (insn,21 ,5 ); +unsigned len =32 - clen; +target_long mask0, mask1; +TCGv dest; + +if (c) { +nullify_over (ctx); + } +if (cpos + len >32 ) { + len =32 - cpos; + } + + dest =dest_gpr (ctx, rt); + mask0 =deposit64 (0 , cpos, len, val); + mask1 =deposit64 (-1 , cpos, len, val); + +if (nz) { +TCGv src =load_gpr (ctx, rt); +if (mask1 !=-1 ) { +tcg_gen_andi_tl (dest, src, mask1); + src = dest; + } +tcg_gen_ori_tl (dest, src, mask0); + }else { +tcg_gen_movi_tl (dest, mask0); + } +save_gpr (ctx, rt, dest); + +/* Install the new nullification. */ +cond_free (&ctx->null_cond); +if (c) { + ctx->null_cond =do_sed_cond (c, dest); + } +return nullify_end (ctx,NO_EXIT ); +} + +static ExitStatus trans_depw_imm (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned clen =extract32 (insn,0 ,5 ); +unsigned cpos =extract32 (insn,5 ,5 ); +unsigned nz =extract32 (insn,10 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned rr =extract32 (insn,16 ,5 ); +unsigned rt =extract32 (insn,21 ,5 ); +unsigned rs = nz ? rt :0 ; +unsigned len =32 - clen; +TCGv dest, val; + +if (c) { +nullify_over (ctx); + } +if (cpos + len >32 ) { + len =32 - cpos; + } + + dest =dest_gpr (ctx, rt); + val =load_gpr (ctx, rr); +if (rs ==0 ) { +tcg_gen_deposit_z_tl (dest, val, cpos, len); + }else { +tcg_gen_deposit_tl (dest, cpu_gr[rs], val, cpos, len); + } +save_gpr (ctx, rt, dest); + +/* Install the new nullification. */ +cond_free (&ctx->null_cond); +if (c) { + ctx->null_cond =do_sed_cond (c, dest); + } +return nullify_end (ctx,NO_EXIT ); +} + +static ExitStatus trans_depw_sar (DisasContext *ctx,uint32_t insn, +const DisasInsn *di) +{ +unsigned clen =extract32 (insn,0 ,5 ); +unsigned nz =extract32 (insn,10 ,1 ); +unsigned i =extract32 (insn,12 ,1 ); +unsigned c =extract32 (insn,13 ,3 ); +unsigned rt =extract32 (insn,21 ,5 ); +unsigned rs = nz ? rt :0 ; +unsigned len =32 - clen; +TCGv val, mask, tmp, shift, dest; +unsigned msb =1U << (len -1 ); + +if (c) { +nullify_over (ctx); + } + +if (i) { + val =load_const (ctx,low_sextract (insn,16 ,5 )); + }else { + val =load_gpr (ctx,extract32 (insn,16 ,5 )); + } + dest =dest_gpr (ctx, rt); + shift =tcg_temp_new (); + tmp =tcg_temp_new (); + +/* Convert big-endian bit numbering in SAR to left-shift. */ +tcg_gen_xori_tl (shift, cpu_sar,TARGET_LONG_BITS -1 ); + + mask =tcg_const_tl (msb + (msb -1 )); +tcg_gen_and_tl (tmp, val, mask); +if (rs) { +tcg_gen_shl_tl (mask, mask, shift); +tcg_gen_shl_tl (tmp, tmp, shift); +tcg_gen_andc_tl (dest, cpu_gr[rs], mask); +tcg_gen_or_tl (dest, dest, tmp); + }else { +tcg_gen_shl_tl (dest, tmp, shift); + } +tcg_temp_free (shift); +tcg_temp_free (mask); +tcg_temp_free (tmp); +save_gpr (ctx, rt, dest); + +/* Install the new nullification. */ +cond_free (&ctx->null_cond); +if (c) { + ctx->null_cond =do_sed_cond (c, dest); + } +return nullify_end (ctx,NO_EXIT ); +} + +static const DisasInsn table_depw[] = { + {0xd4000000u ,0xfc000be0u , trans_depw_sar }, + {0xd4000800u ,0xfc001800u , trans_depw_imm }, + {0xd4001800u ,0xfc001800u , trans_depw_imm_c }, +}; +static ExitStatus trans_be (DisasContext *ctx,uint32_t insn,bool is_l) {unsigned n =extract32 (insn,1 ,1 );
@@ -1874,6 +2179,10 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)return trans_movb (ctx, insn, false);case 0x33 :return trans_movb (ctx, insn, true); +case 0x34 : +return translate_table (ctx, insn, table_sh_ex); +case 0x35 : +return translate_table (ctx, insn, table_depw);case 0x38 :return trans_be (ctx, insn, false);case 0x39 :
Signature · 1 line
2.9.3
PATCH 24/26 target-hppa: Implement loads and stores
In reply to Richard Henderson--- target-hppa/helper.h | 3 + target-hppa/op_helper.c | 78 ++++++ target-hppa/translate.c | 618 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 699 insertions(+)
target-hppa/helper.h +3 -0
@@ -2,4 +2,7 @@ DEF_HELPER_2(excp, noreturn, env, int) DEF_HELPER_FLAGS_2(tsv, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_2(tcond, TCG_CALL_NO_WG, void, env, tl) +DEF_HELPER_FLAGS_3(stby_b, TCG_CALL_NO_WG, void, env, tl, tl) +DEF_HELPER_FLAGS_3(stby_e, TCG_CALL_NO_WG, void, env, tl, tl) +DEF_HELPER_FLAGS_1 (loaded_fr0,TCG_CALL_NO_RWG , void, env)
target-hppa/op_helper.c +78 -0
90 lines not on this page · raw message
target-hppa/translate.c +618 -0
672 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 25/26 target-hppa: Implement system and memory-management insns
In reply to Richard Henderson--- target-hppa/helper.h | 3 + target-hppa/op_helper.c | 10 +++ target-hppa/translate.c | 206 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+)
target-hppa/helper.h +3 -0
@@ -5,4 +5,7 @@ DEF_HELPER_FLAGS_2(tcond, TCG_CALL_NO_WG, void, env, tl) DEF_HELPER_FLAGS_3(stby_b, TCG_CALL_NO_WG, void, env, tl, tl) DEF_HELPER_FLAGS_3(stby_e, TCG_CALL_NO_WG, void, env, tl, tl) +DEF_HELPER_FLAGS_1(probe_r, TCG_CALL_NO_RWG_SE, tl, tl) +DEF_HELPER_FLAGS_1(probe_w, TCG_CALL_NO_RWG_SE, tl, tl) +DEF_HELPER_FLAGS_1 (loaded_fr0,TCG_CALL_NO_RWG , void, env)
target-hppa/op_helper.c +10 -0
@@ -132,6 +132,16 @@ void HELPER(stby_e)(CPUHPPAState *env, target_ulong addr, target_ulong val) } } +target_ulong HELPER (probe_r )(target_ulong addr) +{ +return page_check_range (addr,1 ,PAGE_READ ); +} + +target_ulong HELPER (probe_w )(target_ulong addr) +{ +return page_check_range (addr,1 ,PAGE_WRITE ); +} +void HELPER (loaded_fr0 )(CPUHPPAState *env) {uint32_t shadow = env->fr[0 ] >>32 ;
target-hppa/translate.c +206 -0
218 lines not on this page · raw message
Signature · 1 line
2.9.3
PATCH 26/26 target-hppa: Implement floating-point insns
In reply to Richard Henderson--- target-hppa/helper.h | 55 ++++ target-hppa/op_helper.c | 394 ++++++++++++++++++++++++++ target-hppa/translate.c | 728 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1177 insertions(+)
target-hppa/helper.h +55 -0
@@ -9,3 +9,58 @@ DEF_HELPER_FLAGS_1(probe_r, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(probe_w, TCG_CALL_NO_RWG_SE, tl, tl) DEF_HELPER_FLAGS_1(loaded_fr0, TCG_CALL_NO_RWG, void, env) + +DEF_HELPER_FLAGS_2(fsqrt_s, TCG_CALL_NO_RWG, f32, env, f32) +DEF_HELPER_FLAGS_2(frnd_s, TCG_CALL_NO_RWG, f32, env, f32) +DEF_HELPER_FLAGS_3(fadd_s, TCG_CALL_NO_RWG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(fsub_s, TCG_CALL_NO_RWG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(fmpy_s, TCG_CALL_NO_RWG, f32, env, f32, f32) +DEF_HELPER_FLAGS_3(fdiv_s, TCG_CALL_NO_RWG, f32, env, f32, f32) + +DEF_HELPER_FLAGS_2(fsqrt_d, TCG_CALL_NO_RWG, f64, env, f64) +DEF_HELPER_FLAGS_2(frnd_d, TCG_CALL_NO_RWG, f64, env, f64) +DEF_HELPER_FLAGS_3(fadd_d, TCG_CALL_NO_RWG, f64, env, f64, f64) +DEF_HELPER_FLAGS_3(fsub_d, TCG_CALL_NO_RWG, f64, env, f64, f64) +DEF_HELPER_FLAGS_3(fmpy_d, TCG_CALL_NO_RWG, f64, env, f64, f64) +DEF_HELPER_FLAGS_3(fdiv_d, TCG_CALL_NO_RWG, f64, env, f64, f64) + +DEF_HELPER_FLAGS_2(fcnv_s_d, TCG_CALL_NO_RWG, f64, env, f32) +DEF_HELPER_FLAGS_2(fcnv_d_s, TCG_CALL_NO_RWG, f32, env, f64) + +DEF_HELPER_FLAGS_2(fcnv_w_s, TCG_CALL_NO_RWG, f32, env, s32) +DEF_HELPER_FLAGS_2(fcnv_dw_s, TCG_CALL_NO_RWG, f32, env, s64) +DEF_HELPER_FLAGS_2(fcnv_w_d, TCG_CALL_NO_RWG, f64, env, s32) +DEF_HELPER_FLAGS_2(fcnv_dw_d, TCG_CALL_NO_RWG, f64, env, s64) + +DEF_HELPER_FLAGS_2(fcnv_s_w, TCG_CALL_NO_RWG, s32, env, f32) +DEF_HELPER_FLAGS_2(fcnv_d_w, TCG_CALL_NO_RWG, s32, env, f64) +DEF_HELPER_FLAGS_2(fcnv_s_dw, TCG_CALL_NO_RWG, s64, env, f32) +DEF_HELPER_FLAGS_2(fcnv_d_dw, TCG_CALL_NO_RWG, s64, env, f64) + +DEF_HELPER_FLAGS_2(fcnv_t_s_w, TCG_CALL_NO_RWG, s32, env, f32) +DEF_HELPER_FLAGS_2(fcnv_t_d_w, TCG_CALL_NO_RWG, s32, env, f64) +DEF_HELPER_FLAGS_2(fcnv_t_s_dw, TCG_CALL_NO_RWG, s64, env, f32) +DEF_HELPER_FLAGS_2(fcnv_t_d_dw, TCG_CALL_NO_RWG, s64, env, f64) + +DEF_HELPER_FLAGS_2(fcnv_uw_s, TCG_CALL_NO_RWG, f32, env, i32) +DEF_HELPER_FLAGS_2(fcnv_udw_s, TCG_CALL_NO_RWG, f32, env, i64) +DEF_HELPER_FLAGS_2(fcnv_uw_d, TCG_CALL_NO_RWG, f64, env, i32) +DEF_HELPER_FLAGS_2(fcnv_udw_d, TCG_CALL_NO_RWG, f64, env, i64) + +DEF_HELPER_FLAGS_2(fcnv_s_uw, TCG_CALL_NO_RWG, i32, env, f32) +DEF_HELPER_FLAGS_2(fcnv_d_uw, TCG_CALL_NO_RWG, i32, env, f64) +DEF_HELPER_FLAGS_2(fcnv_s_udw, TCG_CALL_NO_RWG, i64, env, f32) +DEF_HELPER_FLAGS_2(fcnv_d_udw, TCG_CALL_NO_RWG, i64, env, f64) + +DEF_HELPER_FLAGS_2(fcnv_t_s_uw, TCG_CALL_NO_RWG, i32, env, f32) +DEF_HELPER_FLAGS_2(fcnv_t_d_uw, TCG_CALL_NO_RWG, i32, env, f64) +DEF_HELPER_FLAGS_2(fcnv_t_s_udw, TCG_CALL_NO_RWG, i64, env, f32) +DEF_HELPER_FLAGS_2(fcnv_t_d_udw, TCG_CALL_NO_RWG, i64, env, f64) + +DEF_HELPER_FLAGS_5(fcmp_s, TCG_CALL_NO_RWG, void, env, f32, f32, i32, i32) +DEF_HELPER_FLAGS_5(fcmp_d, TCG_CALL_NO_RWG, void, env, f64, f64, i32, i32) + +DEF_HELPER_FLAGS_4(fmpyfadd_s, TCG_CALL_NO_RWG, i32, env, i32, i32, i32) +DEF_HELPER_FLAGS_4(fmpynfadd_s, TCG_CALL_NO_RWG, i32, env, i32, i32, i32) +DEF_HELPER_FLAGS_4(fmpyfadd_d, TCG_CALL_NO_RWG, i64, env, i64, i64, i64) +DEF_HELPER_FLAGS_4 (fmpynfadd_d,TCG_CALL_NO_RWG , i64, env, i64, i64, i64)
target-hppa/op_helper.c +394 -0
397 lines not on this page · raw message
target-hppa/translate.c +728 -0
790 lines not on this page · raw message
Signature · 1 line
2.9.3
Quoted 103 lines · Richard Henderson
This is a linux-user only port, emulating a 32-bit only version of a pa-2.0 cpu. This is good enough to do well with both the gcc and glibc testsuites. Helge Deller has provided invaluable assistance testing with a more complete debian chroot.
What's missing:
* Space registers. Since Linux sets them all equal (for a flat address space) and uses them like address-space identifiers, we can simply set them all to 0 and ignore them.* Architecture subsets. There's no markup for running a pure pa1.0 or pa1.1 cpu. I happily accept everything up to pa2.0 at the moment.
* Wide mode. While I have pa2.0 instructions, I don't support running in 64-bit mode. Since neither the linux kernel nor glibc support a 64-bit userland, it would be a lot more work than just adding the insns.
* Multimedia instructions. These are tied to wide mode, so...
When squashing the patches down from my development tree, I wanted to preserve Helge's contributions, so the linux-user part is more patches than I would normally have preserved.
r~
Helge Deller (3):
linux-user: Handle TIOCSTART and TIOCSTOP
linux-user: Add SIOCGPGRP, SIOCGSTAMP, SIOCGSTAMPNS
linux-user: Add some hppa ioctlsRichard Henderson (23):
Revert "Remove remainders of HPPA backend"
linux-user: Support stack-grows-up inelfload.c
linux-user: Handle ERFKILL and EHWPOISON
linux-user: Handle more IPV6 sockopts
linux-user: Add HPPAsocket.hdefinitions
linux-user: Add HPPA syscall numbers
linux-user: Add HPPAtermbits.h
linux-user: Add HPPAtarget_syscall.h
linux-user: Add HPPA definitions tosyscall_defs.h
linux-user: Add HPPAtarget_structs.h
linux-user: Add HPPAtarget_signal.handtarget_cpu.h
linux-user: Add HPPA signal handling
linux-user: Add HPPA startup and main loop
target-hppa: Add softfloat specializations
target-hppa: Add framework and enable compilation
target-hppa: Add nullification framework
target-hppa: Implement basic arithmetic
target-hppa: Implement branches
target-hppa: Implement linux-user gateway page
target-hppa: Implement shifts and deposits
target-hppa: Implement loads and stores
target-hppa: Implement system and memory-management insns
target-hppa: Implement floating-point insnsconfigure | 7 +- default-configs/hppa-linux-user.mak | 1 + disas.c | 2 + disas/Makefile.objs | 1 + disas/hppa.c | 2832 +++++++++++++++++++++++++ fpu/softfloat-specialize.h | 20 +- linux-user/alpha/target_syscall.h | 2 + linux-user/elfload.c | 259 ++- linux-user/errno_defs.h | 3 + linux-user/hppa/sockbits.h | 97 + linux-user/hppa/syscall_nr.h | 353 ++++ linux-user/hppa/target_cpu.h | 35 + linux-user/hppa/target_signal.h | 29 + linux-user/hppa/target_structs.h | 54 + linux-user/hppa/target_syscall.h | 237 +++ linux-user/hppa/termbits.h | 219 ++ linux-user/ioctls.h | 8 + linux-user/main.c | 185 +- linux-user/mips/target_syscall.h | 5 + linux-user/mips64/target_syscall.h | 5 + linux-user/qemu.h | 3 + linux-user/signal.c | 191 +- linux-user/socket.h | 2 + linux-user/syscall.c | 41 +- linux-user/syscall_defs.h | 154 +- linux-user/syscall_types.h | 6 + target-hppa/Makefile.objs | 1 + target-hppa/cpu-qom.h | 52 + target-hppa/cpu.c | 165 ++ target-hppa/cpu.h | 144 ++ target-hppa/gdbstub.c | 111 + target-hppa/helper.c | 137 ++ target-hppa/helper.h | 66 + target-hppa/op_helper.c | 570 +++++ target-hppa/translate.c | 3946 +++++++++++++++++++++++++++++++++++ 35 files changed, 9864 insertions(+), 79 deletions(-) create mode 100644 default-configs/hppa-linux-user.mak create mode 100644 disas/hppa.c create mode 100644 linux-user/hppa/sockbits.h create mode 100644 linux-user/hppa/syscall_nr.h create mode 100644 linux-user/hppa/target_cpu.h create mode 100644 linux-user/hppa/target_signal.h create mode 100644 linux-user/hppa/target_structs.h create mode 100644 linux-user/hppa/target_syscall.h create mode 100644 linux-user/hppa/termbits.h create mode 100644 target-hppa/Makefile.objs
Quoted 8 lines
create mode 100644 target-hppa/cpu-qom.h create mode 100644 target-hppa/cpu.c create mode 100644 target-hppa/cpu.h create mode 100644 target-hppa/gdbstub.c create mode 100644 target-hppa/helper.c create mode 100644 target-hppa/helper.h create mode 100644 target-hppa/op_helper.c create mode 100644 target-hppa/translate.c
IMHO we should not add new targets without having somebody volunteering to look after them, too. So there should be an update to MAINTAINERS here, too, even if it's just for "Odd fixes". So could you or Helge please volunteer for the maintainers job here, too?
Thanks,
Thomas
Quoted 113 lines · Thomas Huth
Quoted 103 lines · Richard Henderson
This is a linux-user only port, emulating a 32-bit only version of a pa-2.0 cpu. This is good enough to do well with both the gcc and glibc testsuites. Helge Deller has provided invaluable assistance testing with a more complete debian chroot.
What's missing:
* Space registers. Since Linux sets them all equal (for a flat address space) and uses them like address-space identifiers, we can simply set them all to 0 and ignore them.* Architecture subsets. There's no markup for running a pure pa1.0 or pa1.1 cpu. I happily accept everything up to pa2.0 at the moment.
* Wide mode. While I have pa2.0 instructions, I don't support running in 64-bit mode. Since neither the linux kernel nor glibc support a 64-bit userland, it would be a lot more work than just adding the insns.
* Multimedia instructions. These are tied to wide mode, so...
When squashing the patches down from my development tree, I wanted to preserve Helge's contributions, so the linux-user part is more patches than I would normally have preserved.
r~
Helge Deller (3):
linux-user: Handle TIOCSTART and TIOCSTOP
linux-user: Add SIOCGPGRP, SIOCGSTAMP, SIOCGSTAMPNS
linux-user: Add some hppa ioctlsRichard Henderson (23):
Revert "Remove remainders of HPPA backend"
linux-user: Support stack-grows-up inelfload.c
linux-user: Handle ERFKILL and EHWPOISON
linux-user: Handle more IPV6 sockopts
linux-user: Add HPPAsocket.hdefinitions
linux-user: Add HPPA syscall numbers
linux-user: Add HPPAtermbits.h
linux-user: Add HPPAtarget_syscall.h
linux-user: Add HPPA definitions tosyscall_defs.h
linux-user: Add HPPAtarget_structs.h
linux-user: Add HPPAtarget_signal.handtarget_cpu.h
linux-user: Add HPPA signal handling
linux-user: Add HPPA startup and main loop
target-hppa: Add softfloat specializations
target-hppa: Add framework and enable compilation
target-hppa: Add nullification framework
target-hppa: Implement basic arithmetic
target-hppa: Implement branches
target-hppa: Implement linux-user gateway page
target-hppa: Implement shifts and deposits
target-hppa: Implement loads and stores
target-hppa: Implement system and memory-management insns
target-hppa: Implement floating-point insnsconfigure | 7 +- default-configs/hppa-linux-user.mak | 1 + disas.c | 2 + disas/Makefile.objs | 1 + disas/hppa.c | 2832 +++++++++++++++++++++++++ fpu/softfloat-specialize.h | 20 +- linux-user/alpha/target_syscall.h | 2 + linux-user/elfload.c | 259 ++- linux-user/errno_defs.h | 3 + linux-user/hppa/sockbits.h | 97 + linux-user/hppa/syscall_nr.h | 353 ++++ linux-user/hppa/target_cpu.h | 35 + linux-user/hppa/target_signal.h | 29 + linux-user/hppa/target_structs.h | 54 + linux-user/hppa/target_syscall.h | 237 +++ linux-user/hppa/termbits.h | 219 ++ linux-user/ioctls.h | 8 + linux-user/main.c | 185 +- linux-user/mips/target_syscall.h | 5 + linux-user/mips64/target_syscall.h | 5 + linux-user/qemu.h | 3 + linux-user/signal.c | 191 +- linux-user/socket.h | 2 + linux-user/syscall.c | 41 +- linux-user/syscall_defs.h | 154 +- linux-user/syscall_types.h | 6 + target-hppa/Makefile.objs | 1 + target-hppa/cpu-qom.h | 52 + target-hppa/cpu.c | 165 ++ target-hppa/cpu.h | 144 ++ target-hppa/gdbstub.c | 111 + target-hppa/helper.c | 137 ++ target-hppa/helper.h | 66 + target-hppa/op_helper.c | 570 +++++ target-hppa/translate.c | 3946 +++++++++++++++++++++++++++++++++++ 35 files changed, 9864 insertions(+), 79 deletions(-) create mode 100644 default-configs/hppa-linux-user.mak create mode 100644 disas/hppa.c create mode 100644 linux-user/hppa/sockbits.h create mode 100644 linux-user/hppa/syscall_nr.h create mode 100644 linux-user/hppa/target_cpu.h create mode 100644 linux-user/hppa/target_signal.h create mode 100644 linux-user/hppa/target_structs.h create mode 100644 linux-user/hppa/target_syscall.h create mode 100644 linux-user/hppa/termbits.h create mode 100644 target-hppa/Makefile.objsQuoted 8 lines
create mode 100644 target-hppa/cpu-qom.h create mode 100644 target-hppa/cpu.c create mode 100644 target-hppa/cpu.h create mode 100644 target-hppa/gdbstub.c create mode 100644 target-hppa/helper.c create mode 100644 target-hppa/helper.h create mode 100644 target-hppa/op_helper.c create mode 100644 target-hppa/translate.c
Quoted 4 lines
IMHO we should not add new targets without having somebody volunteering to look after them, too. So there should be an update to
MAINTAINERShere, too, even if it's just for "Odd fixes". So could you or Helge please volunteer for the maintainers job here, too?
Sure, I volunteer.
Helge