From a6f79cc9a5efc34c5b751b2e866a4977259f3f63 Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Tue, 31 Jan 2012 12:43:16 +0100 Subject: linux-user: fail execve() if env/args too big If the host's page size is equal to or smaller than the target's, native execve() will fail appropriately with E2BIG if called with too big an environment for the target to handle. It may falsely succeed, however, if the host's page size is bigger, and feed the executed target process an environment that is too big for it to handle, at which point QEMU barfs and exits, confusing procmail's autoconf script and causing the build to fail. This patch makes sure that execve() will return E2BIG if the environment is too large for the target. Signed-off-by: Ulrich Hecht Signed-off-by: Stefan Hajnoczi --- linux-user/syscall.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ee8899ef3d..e868ec6aff 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4949,6 +4949,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, abi_ulong guest_envp; abi_ulong addr; char **q; + int total_size = 0; argc = 0; guest_argp = arg2; @@ -4980,6 +4981,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; if (!(*q = lock_user_string(addr))) goto execve_efault; + total_size += strlen(*q) + 1; } *q = NULL; @@ -4991,9 +4993,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; if (!(*q = lock_user_string(addr))) goto execve_efault; + total_size += strlen(*q) + 1; } *q = NULL; + /* This case will not be caught by the host's execve() if its + page size is bigger than the target's. */ + if (total_size > MAX_ARG_PAGES * TARGET_PAGE_SIZE) { + ret = -TARGET_E2BIG; + goto execve_end; + } if (!(p = lock_user_string(arg1))) goto execve_efault; ret = get_errno(execve(p, argp, envp)); -- cgit v1.2.1 From e3c52bf2e59a1caa7a8f4d1eb069cc1406075d10 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Fri, 13 Jan 2012 20:29:49 +0000 Subject: CODING_STYLE: Clarify style for enum and function type names Clarify that enum type names and function type names should follow the CamelCase style used for structured type names. Signed-off-by: Peter Maydell Signed-off-by: Stefan Hajnoczi --- CODING_STYLE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CODING_STYLE b/CODING_STYLE index 6e61c49089..7c82d4d0af 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -44,7 +44,8 @@ Rationale: 3. Naming Variables are lower_case_with_underscores; easy to type and read. Structured -type names are in CamelCase; harder to type but standing out. Scalar type +type names are in CamelCase; harder to type but standing out. Enum type +names and function type names should also be in CamelCase. Scalar type names are lower_case_with_underscores_ending_with_a_t, like the POSIX uint64_t and family. Note that this last convention contradicts POSIX and is therefore likely to be changed. -- cgit v1.2.1 From e965fc380703110e967febf8d5b2ecd7db53b5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B3=E9=9F=8B=E4=BB=BB?= Date: Mon, 6 Feb 2012 14:02:55 +0800 Subject: cpu-exec.c: Correct comment about this file and indentation cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each target uses the #define macro (in target-xxx/cpu.h) to rename cpu_exec (cpu-exec.c) to cpu_xxx_exec, then defines its own cpu_loop which calls cpu_xxx_exec. So basically, cpu-exec.c is not only the i386 emulator main execution loop. This patch corrects the comment of this file and does indentation cleanup. Signed-off-by: Chen Wei-Ren (陳韋任) Signed-off-by: Stefan Hajnoczi --- cpu-exec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index a9fa608cff..2c2d24ea04 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -1,5 +1,5 @@ /* - * i386 emulator main execution loop + * emulator main execution loop * * Copyright (c) 2003-2005 Fabrice Bellard * @@ -304,7 +304,7 @@ int cpu_exec(CPUState *env) env->hflags2 |= HF2_NMI_MASK; do_interrupt_x86_hardirq(env, EXCP02_NMI, 1); next_tb = 0; - } else if (interrupt_request & CPU_INTERRUPT_MCE) { + } else if (interrupt_request & CPU_INTERRUPT_MCE) { env->interrupt_request &= ~CPU_INTERRUPT_MCE; do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0); next_tb = 0; @@ -390,7 +390,7 @@ int cpu_exec(CPUState *env) next_tb = 0; } } - } + } #elif defined(TARGET_ARM) if (interrupt_request & CPU_INTERRUPT_FIQ && !(env->uncached_cpsr & CPSR_F)) { @@ -429,7 +429,7 @@ int cpu_exec(CPUState *env) { int idx = -1; /* ??? This hard-codes the OSF/1 interrupt levels. */ - switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) { + switch (env->pal_mode ? 7 : env->ps & PS_INT_MASK) { case 0 ... 3: if (interrupt_request & CPU_INTERRUPT_HARD) { idx = EXCP_DEV_INTERRUPT; @@ -562,7 +562,7 @@ int cpu_exec(CPUState *env) barrier(); if (likely(!env->exit_request)) { tc_ptr = tb->tc_ptr; - /* execute the generated code */ + /* execute the generated code */ next_tb = tcg_qemu_tb_exec(env, tc_ptr); if ((next_tb & 3) == 2) { /* Instruction counter expired. */ -- cgit v1.2.1 From cb67be85a612e8b9ab25edb68976c0fa203d12ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Mon, 6 Feb 2012 22:19:42 +0100 Subject: ide: fix compilation errors when DEBUG_IDE is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hervé Poussineau Signed-off-by: Stefan Hajnoczi --- hw/ide/pci.c | 2 +- hw/ide/piix.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/ide/pci.c b/hw/ide/pci.c index 246dd5704b..88c0942e34 100644 --- a/hw/ide/pci.c +++ b/hw/ide/pci.c @@ -336,7 +336,7 @@ static uint64_t bmdma_addr_read(void *opaque, target_phys_addr_t addr, data = (bm->addr >> (addr * 8)) & mask; #ifdef DEBUG_IDE - printf("%s: 0x%08x\n", __func__, (unsigned)*data); + printf("%s: 0x%08x\n", __func__, (unsigned)data); #endif return data; } diff --git a/hw/ide/piix.c b/hw/ide/piix.c index bf4465bb49..76cf209474 100644 --- a/hw/ide/piix.c +++ b/hw/ide/piix.c @@ -53,7 +53,7 @@ static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr, unsigned size) break; } #ifdef DEBUG_IDE - printf("bmdma: readb 0x%02x : 0x%02x\n", addr, val); + printf("bmdma: readb 0x%02x : 0x%02x\n", (uint8_t)addr, val); #endif return val; } @@ -68,7 +68,7 @@ static void bmdma_write(void *opaque, target_phys_addr_t addr, } #ifdef DEBUG_IDE - printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val); + printf("bmdma: writeb 0x%02x : 0x%02x\n", (uint8_t)addr, (uint8_t)val); #endif switch(addr & 3) { case 0: -- cgit v1.2.1 From 1b785a975830993fff988028d90f2b55b2ab41f0 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Tue, 7 Feb 2012 20:57:27 +0000 Subject: vl.c: Fix typo in variable name Fix a typo in a local variable name. Signed-off-by: Peter Maydell Reviewed-by: Stefan Weil Signed-off-by: Stefan Hajnoczi --- vl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vl.c b/vl.c index 63dd725216..c4b3aab81d 100644 --- a/vl.c +++ b/vl.c @@ -2030,7 +2030,7 @@ static int configure_accelerator(void) const char *p = NULL; char buf[10]; int i, ret; - bool accel_initalised = 0; + bool accel_initialised = 0; bool init_failed = 0; QemuOptsList *list = qemu_find_opts("machine"); @@ -2043,7 +2043,7 @@ static int configure_accelerator(void) p = "tcg"; } - while (!accel_initalised && *p != '\0') { + while (!accel_initialised && *p != '\0') { if (*p == ':') { p++; } @@ -2064,7 +2064,7 @@ static int configure_accelerator(void) } *(accel_list[i].allowed) = 0; } else { - accel_initalised = 1; + accel_initialised = 1; } break; } @@ -2074,7 +2074,7 @@ static int configure_accelerator(void) } } - if (!accel_initalised) { + if (!accel_initialised) { fprintf(stderr, "No accelerator found!\n"); exit(1); } @@ -2083,7 +2083,7 @@ static int configure_accelerator(void) fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name); } - return !accel_initalised; + return !accel_initialised; } void qemu_add_exit_notifier(Notifier *notify) -- cgit v1.2.1 From 31de83140d23ccc0e290bc0de609ba2b1aff674a Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Tue, 7 Feb 2012 22:26:29 +0100 Subject: fmopl: Fix typo in function name Fix a typo in a local function name. Signed-off-by: Stefan Weil Signed-off-by: Stefan Hajnoczi --- hw/fmopl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/fmopl.c b/hw/fmopl.c index 734d2f4aae..f0a023477d 100644 --- a/hw/fmopl.c +++ b/hw/fmopl.c @@ -733,7 +733,7 @@ INLINE void CSMKeyControll(OPL_CH *CH) } /* ---------- opl initialize ---------- */ -static void OPL_initalize(FM_OPL *OPL) +static void OPL_initialize(FM_OPL *OPL) { int fn; @@ -1239,7 +1239,7 @@ FM_OPL *OPLCreate(int type, int clock, int rate) OPL->rate = rate; OPL->max_ch = max_ch; /* init grobal tables */ - OPL_initalize(OPL); + OPL_initialize(OPL); /* reset chip */ OPLResetChip(OPL); #ifdef OPL_OUTPUT_LOG -- cgit v1.2.1 From da8d605733c9b368230a716cc71c7915902387db Mon Sep 17 00:00:00 2001 From: Benjamin MARSILI Date: Mon, 23 Jan 2012 03:42:38 +0900 Subject: net: remove extra spaces in help messages Signed-off-by: Benjamin MARSILI Signed-off-by: Stefan Hajnoczi --- net/socket.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/socket.c b/net/socket.c index d4c2002923..0bcf229c24 100644 --- a/net/socket.c +++ b/net/socket.c @@ -664,8 +664,8 @@ int net_init_socket(QemuOpts *opts, qemu_opt_get(opts, "connect") || qemu_opt_get(opts, "listen") || qemu_opt_get(opts, "mcast")) { - error_report("fd=, connect=, listen=\ - and mcast= is invalid with udp="); + error_report("fd=, connect=, listen=" + " and mcast= is invalid with udp="); return -1; } @@ -680,8 +680,8 @@ int net_init_socket(QemuOpts *opts, return -1; } } else { - error_report("-socket requires fd=, listen=, \ - connect=, mcast= or udp="); + error_report("-socket requires fd=, listen=," + " connect=, mcast= or udp="); return -1; } return 0; -- cgit v1.2.1 From 6f79e06b35b26a1beda6f6dc4dd02588887597e9 Mon Sep 17 00:00:00 2001 From: Luiz Capitulino Date: Thu, 9 Feb 2012 11:29:42 -0200 Subject: virtio: Remove unneeded g_free() check in virtio_cleanup() Signed-off-by: Luiz Capitulino Signed-off-by: Stefan Hajnoczi --- hw/virtio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 74cc038af9..064aecf553 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -845,8 +845,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f) void virtio_cleanup(VirtIODevice *vdev) { qemu_del_vm_change_state_handler(vdev->vmstate); - if (vdev->config) - g_free(vdev->config); + g_free(vdev->config); g_free(vdev->vq); g_free(vdev); } -- cgit v1.2.1 From 3a0c6c4ad6f97931f1d9a729322cb1612218ed96 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Thu, 9 Feb 2012 19:04:27 +0000 Subject: linux-user: brk() debugging Fix format type mismatches in do_brk debug printfs. Signed-off-by: Paul Brook Signed-off-by: Stefan Hajnoczi --- linux-user/syscall.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e868ec6aff..8a11213402 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -756,14 +756,15 @@ abi_long do_brk(abi_ulong new_brk) abi_long mapped_addr; int new_alloc_size; - DEBUGF_BRK("do_brk(%#010x) -> ", new_brk); + DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk); if (!new_brk) { - DEBUGF_BRK("%#010x (!new_brk)\n", target_brk); + DEBUGF_BRK(TARGET_ABI_FMT_lx " (!new_brk)\n", target_brk); return target_brk; } if (new_brk < target_original_brk) { - DEBUGF_BRK("%#010x (new_brk < target_original_brk)\n", target_brk); + DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk < target_original_brk)\n", + target_brk); return target_brk; } @@ -776,7 +777,7 @@ abi_long do_brk(abi_ulong new_brk) memset(g2h(target_brk), 0, new_brk - target_brk); } target_brk = new_brk; - DEBUGF_BRK("%#010x (new_brk <= brk_page)\n", target_brk); + DEBUGF_BRK(TARGET_ABI_FMT_lx " (new_brk <= brk_page)\n", target_brk); return target_brk; } @@ -803,7 +804,8 @@ abi_long do_brk(abi_ulong new_brk) target_brk = new_brk; brk_page = HOST_PAGE_ALIGN(target_brk); - DEBUGF_BRK("%#010x (mapped_addr == brk_page)\n", target_brk); + DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr == brk_page)\n", + target_brk); return target_brk; } else if (mapped_addr != -1) { /* Mapped but at wrong address, meaning there wasn't actually @@ -811,10 +813,10 @@ abi_long do_brk(abi_ulong new_brk) */ target_munmap(mapped_addr, new_alloc_size); mapped_addr = -1; - DEBUGF_BRK("%#010x (mapped_addr != -1)\n", target_brk); + DEBUGF_BRK(TARGET_ABI_FMT_lx " (mapped_addr != -1)\n", target_brk); } else { - DEBUGF_BRK("%#010x (otherwise)\n", target_brk); + DEBUGF_BRK(TARGET_ABI_FMT_lx " (otherwise)\n", target_brk); } #if defined(TARGET_ALPHA) -- cgit v1.2.1