* [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 @ 2014-11-03 12:02 riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 1/3] linux-user: Let user specify random seed riku.voipio ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: riku.voipio @ 2014-11-03 12:02 UTC (permalink / raw) To: qemu-devel; +Cc: Peter Maydell, Riku Voipio From: Riku Voipio <riku.voipio@linaro.org> The following changes since commit 0a2923f8488498000eec54871456aa64a4391da4: tcg/mips: fix store softmmu slow path (2014-11-02 13:30:00 +0100) are available in the git repository at: git://git.linaro.org/people/riku.voipio/qemu.git tags/pull-linux-user-20141101 for you to fetch changes up to a93934fecd4dffc9d4b452b670c9506be5dea30d: elf: take phdr offset into account when calculating the program load address (2014-11-03 11:03:34 +0200) ---------------------------------------------------------------- linux-user pull for 2.2 Two minor fixes and new a feature, addition of QEMU_RAND_SEED for testing needs. ---------------------------------------------------------------- Jonas Maebe (1): elf: take phdr offset into account when calculating the program load address Magnus Reftel (1): linux-user: Let user specify random seed Riku Voipio (1): linux-user: Fix fault address truncation AArch64 linux-user/elfload.c | 3 +-- linux-user/main.c | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) -- 2.1.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 1/3] linux-user: Let user specify random seed 2014-11-03 12:02 [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 riku.voipio @ 2014-11-03 12:02 ` riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 2/3] linux-user: Fix fault address truncation AArch64 riku.voipio ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: riku.voipio @ 2014-11-03 12:02 UTC (permalink / raw) To: qemu-devel; +Cc: Peter Maydell, Magnus Reftel From: Magnus Reftel <reftel@spotify.com> This patch introduces the -seed command line option and the QEMU_RAND_SEED environment variable for setting the random seed, which is used for the AT_RANDOM ELF aux entry. Signed-off-by: Magnus Reftel <reftel@spotify.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> --- linux-user/elfload.c | 1 - linux-user/main.c | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 1c04fcf..f2e2197 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1539,7 +1539,6 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, * Generate 16 random bytes for userspace PRNG seeding (not * cryptically secure but it's not the aim of QEMU). */ - srand((unsigned int) time(NULL)); for (i = 0; i < 16; i++) { k_rand_bytes[i] = rand(); } diff --git a/linux-user/main.c b/linux-user/main.c index 483eb3f..5887022 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3546,6 +3546,17 @@ static void handle_arg_pagesize(const char *arg) } } +static void handle_arg_randseed(const char *arg) +{ + unsigned long long seed; + + if (parse_uint_full(arg, &seed, 0) != 0 || seed > UINT_MAX) { + fprintf(stderr, "Invalid seed number: %s\n", arg); + exit(1); + } + srand(seed); +} + static void handle_arg_gdb(const char *arg) { gdbstub_port = atoi(arg); @@ -3674,6 +3685,8 @@ static const struct qemu_argument arg_table[] = { "", "run in singlestep mode"}, {"strace", "QEMU_STRACE", false, handle_arg_strace, "", "log system calls"}, + {"seed", "QEMU_RAND_SEED", true, handle_arg_randseed, + "", "Seed for pseudo-random number generator"}, {"version", "QEMU_VERSION", false, handle_arg_version, "", "display version information and exit"}, {NULL, NULL, false, NULL, NULL, NULL} @@ -3856,6 +3869,8 @@ int main(int argc, char **argv, char **envp) cpudef_setup(); /* parse cpu definitions in target config file (TBD) */ #endif + srand(time(NULL)); + optind = parse_args(argc, argv); /* Zero out regs */ @@ -3926,6 +3941,10 @@ int main(int argc, char **argv, char **envp) do_strace = 1; } + if (getenv("QEMU_RAND_SEED")) { + handle_arg_randseed(getenv("QEMU_RAND_SEED")); + } + target_environ = envlist_to_environ(envlist, NULL); envlist_free(envlist); -- 2.1.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 2/3] linux-user: Fix fault address truncation AArch64 2014-11-03 12:02 [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 1/3] linux-user: Let user specify random seed riku.voipio @ 2014-11-03 12:02 ` riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 3/3] elf: take phdr offset into account when calculating the program load address riku.voipio 2014-11-03 22:50 ` [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 Peter Maydell 3 siblings, 0 replies; 5+ messages in thread From: riku.voipio @ 2014-11-03 12:02 UTC (permalink / raw) To: qemu-devel; +Cc: Peter Maydell, Riku Voipio From: Riku Voipio <riku.voipio@linaro.org> On AArch64 the si_addr field of siginfo_t is truncated to 32 bits because the fault address passes through an uint32_t variable. Follow Peters suggestion and drop the uint32_t variable since its only used once in the Aarch64 loop. Reported-by: Amanieu d'Antras <amanieu@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> --- linux-user/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 5887022..5c14c1e 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -1006,7 +1006,6 @@ void cpu_loop(CPUARMState *env) CPUState *cs = CPU(arm_env_get_cpu(env)); int trapnr, sig; target_siginfo_t info; - uint32_t addr; for (;;) { cpu_exec_start(cs); @@ -1042,12 +1041,11 @@ void cpu_loop(CPUARMState *env) /* fall through for segv */ case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: - addr = env->exception.vaddress; info.si_signo = SIGSEGV; info.si_errno = 0; /* XXX: check env->error_code */ info.si_code = TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr = addr; + info._sifields._sigfault._addr = env->exception.vaddress; queue_signal(env, info.si_signo, &info); break; case EXCP_DEBUG: -- 2.1.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 3/3] elf: take phdr offset into account when calculating the program load address 2014-11-03 12:02 [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 1/3] linux-user: Let user specify random seed riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 2/3] linux-user: Fix fault address truncation AArch64 riku.voipio @ 2014-11-03 12:02 ` riku.voipio 2014-11-03 22:50 ` [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 Peter Maydell 3 siblings, 0 replies; 5+ messages in thread From: riku.voipio @ 2014-11-03 12:02 UTC (permalink / raw) To: qemu-devel; +Cc: Peter Maydell, Jonas Maebe From: Jonas Maebe <jonas.maebe@elis.ugent.be> The first program header does not necessarily start at offset 0. This change corresponds to what the Linux kernel does in load_elf_binary(). Signed-off-by: Jonas Maebe <jonas.maebe@elis.ugent.be> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f2e2197..84123ba 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1820,7 +1820,7 @@ static void load_elf_image(const char *image_name, int image_fd, loaddr = -1, hiaddr = 0; for (i = 0; i < ehdr->e_phnum; ++i) { if (phdr[i].p_type == PT_LOAD) { - abi_ulong a = phdr[i].p_vaddr; + abi_ulong a = phdr[i].p_vaddr - phdr[i].p_offset; if (a < loaddr) { loaddr = a; } -- 2.1.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 2014-11-03 12:02 [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 riku.voipio ` (2 preceding siblings ...) 2014-11-03 12:02 ` [Qemu-devel] [PULL 3/3] elf: take phdr offset into account when calculating the program load address riku.voipio @ 2014-11-03 22:50 ` Peter Maydell 3 siblings, 0 replies; 5+ messages in thread From: Peter Maydell @ 2014-11-03 22:50 UTC (permalink / raw) To: Riku Voipio; +Cc: QEMU Developers On 3 November 2014 12:02, <riku.voipio@linaro.org> wrote: > From: Riku Voipio <riku.voipio@linaro.org> > > The following changes since commit 0a2923f8488498000eec54871456aa64a4391da4: > > tcg/mips: fix store softmmu slow path (2014-11-02 13:30:00 +0100) > > are available in the git repository at: > > git://git.linaro.org/people/riku.voipio/qemu.git tags/pull-linux-user-20141101 > > for you to fetch changes up to a93934fecd4dffc9d4b452b670c9506be5dea30d: > > elf: take phdr offset into account when calculating the program load address (2014-11-03 11:03:34 +0200) > > ---------------------------------------------------------------- > linux-user pull for 2.2 > > Two minor fixes and new a feature, addition of QEMU_RAND_SEED for > testing needs. > > ---------------------------------------------------------------- Applied, thanks. -- PMM ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-11-03 22:50 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-11-03 12:02 [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 1/3] linux-user: Let user specify random seed riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 2/3] linux-user: Fix fault address truncation AArch64 riku.voipio 2014-11-03 12:02 ` [Qemu-devel] [PULL 3/3] elf: take phdr offset into account when calculating the program load address riku.voipio 2014-11-03 22:50 ` [Qemu-devel] [PULL 0/3] linux-user changes for 2.2 Peter Maydell
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).