linux-user pull request 20210708

Code and style cleanup
 Add ppid in self/stat
 ELF_HWCAP for RISC-V
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEEzS913cjjpNwuT1Fz8ww4vT8vvjwFAmDmzmMSHGxhdXJlbnRA
 dml2aWVyLmV1AAoJEPMMOL0/L748qXoQAIwHGBAh02KDxXqJg/BHNVnH0b0gcD3H
 HVqAvZTI86NrijRVK8UItekanqvO0AxXSWs0kVQe4gF8vlyViZRlsyhteyHs4Cpf
 +VsRqxMv8h05mUI+8Odxfsrwo/XlpKcPoe4NV1qgdn4LnWY+3g9j9/Rbvg1MtSwt
 QHA4oUfpoFoXwK/k81YJlDPzY86lisfW30tyZLbpq3keSfelzZ6r8zUgxj8hOfOw
 E6U7/UrPa77r1gi/Gx4QdRKPn+9jfVxPjLVObkomC4mkWK3ieR2XAXStEni8veSp
 88OcImLjiZ2DeD5vUqF0J261tYh+/lobcfBw0xjyzF+nkAvHJmt9YcD2nFCj6BzF
 OfcSG1ebWvpvJBGVopNP7VcxaL7bJTEr+FxlpJP9YsnVvCEnJUZiZjcjmIs6I2Tj
 jCOppjyetFu82b0RDs7IxwwVCypeZpNkcEJQpLeSXWgFQrqsJ0M6HVGyO68hTZUX
 ris3K6/CXbmZD/9XgZs+8hqmOfIDZBL6xejFZgCU+GTK+RE9Y2/Uq0kxy38cc7N7
 3epskyv5IPBTxEXoaaCNvLEI2qx+RFsPJ+9Ei5/ZbjDE3/7lgW/FAC2JAAmer1eQ
 KuY/GhNgYDGM+Kluk41GNsKnEyFMXHhWc52cjKl0i+9Ni7r95qzTifd7QkUNX12M
 b0LiF6emY5gV
 =wCA4
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/vivier2/tags/linux-user-for-6.1-pull-request' into staging

linux-user pull request 20210708

Code and style cleanup
Add ppid in self/stat
ELF_HWCAP for RISC-V

# gpg: Signature made Thu 08 Jul 2021 11:07:31 BST
# gpg:                using RSA key CD2F75DDC8E3A4DC2E4F5173F30C38BD3F2FBE3C
# gpg:                issuer "laurent@vivier.eu"
# gpg: Good signature from "Laurent Vivier <lvivier@redhat.com>" [full]
# gpg:                 aka "Laurent Vivier <laurent@vivier.eu>" [full]
# gpg:                 aka "Laurent Vivier (Red Hat) <lvivier@redhat.com>" [full]
# Primary key fingerprint: CD2F 75DD C8E3 A4DC 2E4F  5173 F30C 38BD 3F2F BE3C

* remotes/vivier2/tags/linux-user-for-6.1-pull-request:
  linux-user/syscall: Remove hardcoded tabs (code style)
  linux-user/alpha: Remove hardcoded tabs (code style)
  linux-user/mips: Handle TARGET_EWOULDBLOCK as TARGET_EAGAIN
  linux-user/hppa: Handle TARGET_EWOULDBLOCK as TARGET_EAGAIN
  linux-user/alpha: Handle TARGET_EWOULDBLOCK as TARGET_EAGAIN
  linux-user: Fix style problems in linuxload.c
  linux-user: fill ppid field in /proc/self/stat
  linux-user/elfload: Implement ELF_HWCAP for RISC-V

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-07-08 16:30:18 +01:00
commit 9db3065c62
7 changed files with 235 additions and 215 deletions

View File

@ -44,6 +44,8 @@ struct target_pt_regs {
#define UNAME_MACHINE "alpha" #define UNAME_MACHINE "alpha"
#define UNAME_MINIMUM_RELEASE "2.6.32" #define UNAME_MINIMUM_RELEASE "2.6.32"
#undef TARGET_EWOULDBLOCK
#define TARGET_EWOULDBLOCK TARGET_EAGAIN /* Operation would block */
#undef TARGET_EDEADLK #undef TARGET_EDEADLK
#define TARGET_EDEADLK 11 #define TARGET_EDEADLK 11
#undef TARGET_EAGAIN #undef TARGET_EAGAIN
@ -110,7 +112,7 @@ struct target_pt_regs {
#define TARGET_EHOSTUNREACH 65 #define TARGET_EHOSTUNREACH 65
#undef TARGET_ENOTEMPTY #undef TARGET_ENOTEMPTY
#define TARGET_ENOTEMPTY 66 #define TARGET_ENOTEMPTY 66
// Unused 67 /* Unused 67 */
#undef TARGET_EUSERS #undef TARGET_EUSERS
#define TARGET_EUSERS 68 #define TARGET_EUSERS 68
#undef TARGET_EDQUOT #undef TARGET_EDQUOT
@ -119,12 +121,12 @@ struct target_pt_regs {
#define TARGET_ESTALE 70 #define TARGET_ESTALE 70
#undef TARGET_EREMOTE #undef TARGET_EREMOTE
#define TARGET_EREMOTE 71 #define TARGET_EREMOTE 71
// Unused 72-76 /* Unused 72-76 */
#undef TARGET_ENOLCK #undef TARGET_ENOLCK
#define TARGET_ENOLCK 77 #define TARGET_ENOLCK 77
#undef TARGET_ENOSYS #undef TARGET_ENOSYS
#define TARGET_ENOSYS 78 #define TARGET_ENOSYS 78
// Unused 79 /* Unused 79 */
#undef TARGET_ENOMSG #undef TARGET_ENOMSG
#define TARGET_ENOMSG 80 #define TARGET_ENOMSG 80
#undef TARGET_EIDRM #undef TARGET_EIDRM
@ -171,7 +173,7 @@ struct target_pt_regs {
#define TARGET_EBADRQC 101 #define TARGET_EBADRQC 101
#undef TARGET_EBADSLT #undef TARGET_EBADSLT
#define TARGET_EBADSLT 102 #define TARGET_EBADSLT 102
// Unused 103 /* Unused 103 */
#undef TARGET_EBFONT #undef TARGET_EBFONT
#define TARGET_EBFONT 104 #define TARGET_EBFONT 104
#undef TARGET_ENONET #undef TARGET_ENONET
@ -198,9 +200,7 @@ struct target_pt_regs {
#define TARGET_EREMCHG 115 #define TARGET_EREMCHG 115
#undef TARGET_EILSEQ #undef TARGET_EILSEQ
#define TARGET_EILSEQ 116 #define TARGET_EILSEQ 116
/* Same as default 117-121 */
// Same as default 117-121
#undef TARGET_ELIBACC #undef TARGET_ELIBACC
#define TARGET_ELIBACC 122 #define TARGET_ELIBACC 122
#undef TARGET_ELIBBAD #undef TARGET_ELIBBAD

View File

@ -1434,6 +1434,19 @@ static void elf_core_copy_regs(target_elf_gregset_t *regs,
#define ELF_CLASS ELFCLASS64 #define ELF_CLASS ELFCLASS64
#endif #endif
#define ELF_HWCAP get_elf_hwcap()
static uint32_t get_elf_hwcap(void)
{
#define MISA_BIT(EXT) (1 << (EXT - 'A'))
RISCVCPU *cpu = RISCV_CPU(thread_cpu);
uint32_t mask = MISA_BIT('I') | MISA_BIT('M') | MISA_BIT('A')
| MISA_BIT('F') | MISA_BIT('D') | MISA_BIT('C');
return cpu->env.misa & mask;
#undef MISA_BIT
}
static inline void init_thread(struct target_pt_regs *regs, static inline void init_thread(struct target_pt_regs *regs,
struct image_info *infop) struct image_info *infop)
{ {

View File

@ -27,6 +27,8 @@ struct target_pt_regs {
#define TARGET_MCL_FUTURE 2 #define TARGET_MCL_FUTURE 2
#define TARGET_MCL_ONFAULT 4 #define TARGET_MCL_ONFAULT 4
#undef TARGET_EWOULDBLOCK
#define TARGET_EWOULDBLOCK TARGET_EAGAIN /* Operation would block */
#undef TARGET_ENOMSG #undef TARGET_ENOMSG
#define TARGET_ENOMSG 35 #define TARGET_ENOMSG 35
#undef TARGET_EIDRM #undef TARGET_EIDRM

View File

@ -1,34 +1,32 @@
/* Code for loading Linux executables. Mostly linux kernel code. */ /* Code for loading Linux executables. Mostly linux kernel code. */
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu.h" #include "qemu.h"
#define NGROUPS 32 #define NGROUPS 32
/* ??? This should really be somewhere else. */ /* ??? This should really be somewhere else. */
abi_long memcpy_to_target(abi_ulong dest, const void *src, abi_long memcpy_to_target(abi_ulong dest, const void *src, unsigned long len)
unsigned long len)
{ {
void *host_ptr; void *host_ptr;
host_ptr = lock_user(VERIFY_WRITE, dest, len, 0); host_ptr = lock_user(VERIFY_WRITE, dest, len, 0);
if (!host_ptr) if (!host_ptr) {
return -TARGET_EFAULT; return -TARGET_EFAULT;
}
memcpy(host_ptr, src, len); memcpy(host_ptr, src, len);
unlock_user(host_ptr, dest, 1); unlock_user(host_ptr, dest, 1);
return 0; return 0;
} }
static int count(char ** vec) static int count(char **vec)
{ {
int i; int i;
for(i = 0; *vec; i++) { for (i = 0; *vec; i++) {
vec++; vec++;
} }
return i;
return(i);
} }
static int prepare_binprm(struct linux_binprm *bprm) static int prepare_binprm(struct linux_binprm *bprm)
@ -37,23 +35,23 @@ static int prepare_binprm(struct linux_binprm *bprm)
int mode; int mode;
int retval; int retval;
if(fstat(bprm->fd, &st) < 0) { if (fstat(bprm->fd, &st) < 0) {
return(-errno); return -errno;
} }
mode = st.st_mode; mode = st.st_mode;
if(!S_ISREG(mode)) { /* Must be regular file */ if (!S_ISREG(mode)) { /* Must be regular file */
return(-EACCES); return -EACCES;
} }
if(!(mode & 0111)) { /* Must have at least one execute bit set */ if (!(mode & 0111)) { /* Must have at least one execute bit set */
return(-EACCES); return -EACCES;
} }
bprm->e_uid = geteuid(); bprm->e_uid = geteuid();
bprm->e_gid = getegid(); bprm->e_gid = getegid();
/* Set-uid? */ /* Set-uid? */
if(mode & S_ISUID) { if (mode & S_ISUID) {
bprm->e_uid = st.st_uid; bprm->e_uid = st.st_uid;
} }
@ -125,7 +123,7 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
} }
int loader_exec(int fdexec, const char *filename, char **argv, char **envp, int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
struct target_pt_regs * regs, struct image_info *infop, struct target_pt_regs *regs, struct image_info *infop,
struct linux_binprm *bprm) struct linux_binprm *bprm)
{ {
int retval; int retval;
@ -139,7 +137,7 @@ int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
retval = prepare_binprm(bprm); retval = prepare_binprm(bprm);
if(retval>=0) { if (retval >= 0) {
if (bprm->buf[0] == 0x7f if (bprm->buf[0] == 0x7f
&& bprm->buf[1] == 'E' && bprm->buf[1] == 'E'
&& bprm->buf[2] == 'L' && bprm->buf[2] == 'L'
@ -157,11 +155,11 @@ int loader_exec(int fdexec, const char *filename, char **argv, char **envp,
} }
} }
if(retval>=0) { if (retval >= 0) {
/* success. Initialize important registers */ /* success. Initialize important registers */
do_init_thread(regs, infop); do_init_thread(regs, infop);
return retval; return retval;
} }
return(retval); return retval;
} }

View File

@ -21,6 +21,8 @@ struct target_pt_regs {
}; };
/* Target errno definitions taken from asm-mips/errno.h */ /* Target errno definitions taken from asm-mips/errno.h */
#undef TARGET_EWOULDBLOCK
#define TARGET_EWOULDBLOCK TARGET_EAGAIN /* Operation would block */
#undef TARGET_ENOMSG #undef TARGET_ENOMSG
#define TARGET_ENOMSG 35 /* Identifier removed */ #define TARGET_ENOMSG 35 /* Identifier removed */
#undef TARGET_EIDRM #undef TARGET_EIDRM

View File

@ -18,6 +18,8 @@ struct target_pt_regs {
}; };
/* Target errno definitions taken from asm-mips/errno.h */ /* Target errno definitions taken from asm-mips/errno.h */
#undef TARGET_EWOULDBLOCK
#define TARGET_EWOULDBLOCK TARGET_EAGAIN /* Operation would block */
#undef TARGET_ENOMSG #undef TARGET_ENOMSG
#define TARGET_ENOMSG 35 /* Identifier removed */ #define TARGET_ENOMSG 35 /* Identifier removed */
#undef TARGET_EIDRM #undef TARGET_EIDRM

View File

@ -7956,6 +7956,9 @@ static int open_self_stat(void *cpu_env, int fd)
gchar *bin = g_strrstr(ts->bprm->argv[0], "/"); gchar *bin = g_strrstr(ts->bprm->argv[0], "/");
bin = bin ? bin + 1 : ts->bprm->argv[0]; bin = bin ? bin + 1 : ts->bprm->argv[0];
g_string_printf(buf, "(%.15s) ", bin); g_string_printf(buf, "(%.15s) ", bin);
} else if (i == 3) {
/* ppid */
g_string_printf(buf, FMT_pid " ", getppid());
} else if (i == 27) { } else if (i == 27) {
/* stack bottom */ /* stack bottom */
g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_stack); g_string_printf(buf, TARGET_ABI_FMT_ld " ", ts->info->start_stack);