Merge remote-tracking branch 'stefanha/trivial-patches' into staging
* stefanha/trivial-patches: linux-user: brk() debugging virtio: Remove unneeded g_free() check in virtio_cleanup() net: remove extra spaces in help messages fmopl: Fix typo in function name vl.c: Fix typo in variable name ide: fix compilation errors when DEBUG_IDE is set cpu-exec.c: Correct comment about this file and indentation cleanup CODING_STYLE: Clarify style for enum and function type names linux-user: fail execve() if env/args too big
This commit is contained in:
commit
a19255a369
|
@ -44,7 +44,8 @@ Rationale:
|
||||||
3. Naming
|
3. Naming
|
||||||
|
|
||||||
Variables are lower_case_with_underscores; easy to type and read. Structured
|
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
|
names are lower_case_with_underscores_ending_with_a_t, like the POSIX
|
||||||
uint64_t and family. Note that this last convention contradicts POSIX
|
uint64_t and family. Note that this last convention contradicts POSIX
|
||||||
and is therefore likely to be changed.
|
and is therefore likely to be changed.
|
||||||
|
|
10
cpu-exec.c
10
cpu-exec.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* i386 emulator main execution loop
|
* emulator main execution loop
|
||||||
*
|
*
|
||||||
* Copyright (c) 2003-2005 Fabrice Bellard
|
* Copyright (c) 2003-2005 Fabrice Bellard
|
||||||
*
|
*
|
||||||
|
@ -304,7 +304,7 @@ int cpu_exec(CPUState *env)
|
||||||
env->hflags2 |= HF2_NMI_MASK;
|
env->hflags2 |= HF2_NMI_MASK;
|
||||||
do_interrupt_x86_hardirq(env, EXCP02_NMI, 1);
|
do_interrupt_x86_hardirq(env, EXCP02_NMI, 1);
|
||||||
next_tb = 0;
|
next_tb = 0;
|
||||||
} else if (interrupt_request & CPU_INTERRUPT_MCE) {
|
} else if (interrupt_request & CPU_INTERRUPT_MCE) {
|
||||||
env->interrupt_request &= ~CPU_INTERRUPT_MCE;
|
env->interrupt_request &= ~CPU_INTERRUPT_MCE;
|
||||||
do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0);
|
do_interrupt_x86_hardirq(env, EXCP12_MCHK, 0);
|
||||||
next_tb = 0;
|
next_tb = 0;
|
||||||
|
@ -390,7 +390,7 @@ int cpu_exec(CPUState *env)
|
||||||
next_tb = 0;
|
next_tb = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(TARGET_ARM)
|
#elif defined(TARGET_ARM)
|
||||||
if (interrupt_request & CPU_INTERRUPT_FIQ
|
if (interrupt_request & CPU_INTERRUPT_FIQ
|
||||||
&& !(env->uncached_cpsr & CPSR_F)) {
|
&& !(env->uncached_cpsr & CPSR_F)) {
|
||||||
|
@ -429,7 +429,7 @@ int cpu_exec(CPUState *env)
|
||||||
{
|
{
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
/* ??? This hard-codes the OSF/1 interrupt levels. */
|
/* ??? 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:
|
case 0 ... 3:
|
||||||
if (interrupt_request & CPU_INTERRUPT_HARD) {
|
if (interrupt_request & CPU_INTERRUPT_HARD) {
|
||||||
idx = EXCP_DEV_INTERRUPT;
|
idx = EXCP_DEV_INTERRUPT;
|
||||||
|
@ -562,7 +562,7 @@ int cpu_exec(CPUState *env)
|
||||||
barrier();
|
barrier();
|
||||||
if (likely(!env->exit_request)) {
|
if (likely(!env->exit_request)) {
|
||||||
tc_ptr = tb->tc_ptr;
|
tc_ptr = tb->tc_ptr;
|
||||||
/* execute the generated code */
|
/* execute the generated code */
|
||||||
next_tb = tcg_qemu_tb_exec(env, tc_ptr);
|
next_tb = tcg_qemu_tb_exec(env, tc_ptr);
|
||||||
if ((next_tb & 3) == 2) {
|
if ((next_tb & 3) == 2) {
|
||||||
/* Instruction counter expired. */
|
/* Instruction counter expired. */
|
||||||
|
|
|
@ -733,7 +733,7 @@ INLINE void CSMKeyControll(OPL_CH *CH)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------- opl initialize ---------- */
|
/* ---------- opl initialize ---------- */
|
||||||
static void OPL_initalize(FM_OPL *OPL)
|
static void OPL_initialize(FM_OPL *OPL)
|
||||||
{
|
{
|
||||||
int fn;
|
int fn;
|
||||||
|
|
||||||
|
@ -1239,7 +1239,7 @@ FM_OPL *OPLCreate(int type, int clock, int rate)
|
||||||
OPL->rate = rate;
|
OPL->rate = rate;
|
||||||
OPL->max_ch = max_ch;
|
OPL->max_ch = max_ch;
|
||||||
/* init grobal tables */
|
/* init grobal tables */
|
||||||
OPL_initalize(OPL);
|
OPL_initialize(OPL);
|
||||||
/* reset chip */
|
/* reset chip */
|
||||||
OPLResetChip(OPL);
|
OPLResetChip(OPL);
|
||||||
#ifdef OPL_OUTPUT_LOG
|
#ifdef OPL_OUTPUT_LOG
|
||||||
|
|
|
@ -336,7 +336,7 @@ static uint64_t bmdma_addr_read(void *opaque, target_phys_addr_t addr,
|
||||||
|
|
||||||
data = (bm->addr >> (addr * 8)) & mask;
|
data = (bm->addr >> (addr * 8)) & mask;
|
||||||
#ifdef DEBUG_IDE
|
#ifdef DEBUG_IDE
|
||||||
printf("%s: 0x%08x\n", __func__, (unsigned)*data);
|
printf("%s: 0x%08x\n", __func__, (unsigned)data);
|
||||||
#endif
|
#endif
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ static uint64_t bmdma_read(void *opaque, target_phys_addr_t addr, unsigned size)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_IDE
|
#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
|
#endif
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ static void bmdma_write(void *opaque, target_phys_addr_t addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_IDE
|
#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
|
#endif
|
||||||
switch(addr & 3) {
|
switch(addr & 3) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -845,8 +845,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
|
||||||
void virtio_cleanup(VirtIODevice *vdev)
|
void virtio_cleanup(VirtIODevice *vdev)
|
||||||
{
|
{
|
||||||
qemu_del_vm_change_state_handler(vdev->vmstate);
|
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->vq);
|
||||||
g_free(vdev);
|
g_free(vdev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -756,14 +756,15 @@ abi_long do_brk(abi_ulong new_brk)
|
||||||
abi_long mapped_addr;
|
abi_long mapped_addr;
|
||||||
int new_alloc_size;
|
int new_alloc_size;
|
||||||
|
|
||||||
DEBUGF_BRK("do_brk(%#010x) -> ", new_brk);
|
DEBUGF_BRK("do_brk(" TARGET_ABI_FMT_lx ") -> ", new_brk);
|
||||||
|
|
||||||
if (!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;
|
return target_brk;
|
||||||
}
|
}
|
||||||
if (new_brk < target_original_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;
|
return target_brk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -776,7 +777,7 @@ abi_long do_brk(abi_ulong new_brk)
|
||||||
memset(g2h(target_brk), 0, new_brk - target_brk);
|
memset(g2h(target_brk), 0, new_brk - target_brk);
|
||||||
}
|
}
|
||||||
target_brk = new_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;
|
return target_brk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -803,7 +804,8 @@ abi_long do_brk(abi_ulong new_brk)
|
||||||
|
|
||||||
target_brk = new_brk;
|
target_brk = new_brk;
|
||||||
brk_page = HOST_PAGE_ALIGN(target_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;
|
return target_brk;
|
||||||
} else if (mapped_addr != -1) {
|
} else if (mapped_addr != -1) {
|
||||||
/* Mapped but at wrong address, meaning there wasn't actually
|
/* 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);
|
target_munmap(mapped_addr, new_alloc_size);
|
||||||
mapped_addr = -1;
|
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 {
|
else {
|
||||||
DEBUGF_BRK("%#010x (otherwise)\n", target_brk);
|
DEBUGF_BRK(TARGET_ABI_FMT_lx " (otherwise)\n", target_brk);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TARGET_ALPHA)
|
#if defined(TARGET_ALPHA)
|
||||||
|
@ -4949,6 +4951,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
||||||
abi_ulong guest_envp;
|
abi_ulong guest_envp;
|
||||||
abi_ulong addr;
|
abi_ulong addr;
|
||||||
char **q;
|
char **q;
|
||||||
|
int total_size = 0;
|
||||||
|
|
||||||
argc = 0;
|
argc = 0;
|
||||||
guest_argp = arg2;
|
guest_argp = arg2;
|
||||||
|
@ -4980,6 +4983,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
||||||
break;
|
break;
|
||||||
if (!(*q = lock_user_string(addr)))
|
if (!(*q = lock_user_string(addr)))
|
||||||
goto execve_efault;
|
goto execve_efault;
|
||||||
|
total_size += strlen(*q) + 1;
|
||||||
}
|
}
|
||||||
*q = NULL;
|
*q = NULL;
|
||||||
|
|
||||||
|
@ -4991,9 +4995,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
|
||||||
break;
|
break;
|
||||||
if (!(*q = lock_user_string(addr)))
|
if (!(*q = lock_user_string(addr)))
|
||||||
goto execve_efault;
|
goto execve_efault;
|
||||||
|
total_size += strlen(*q) + 1;
|
||||||
}
|
}
|
||||||
*q = NULL;
|
*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)))
|
if (!(p = lock_user_string(arg1)))
|
||||||
goto execve_efault;
|
goto execve_efault;
|
||||||
ret = get_errno(execve(p, argp, envp));
|
ret = get_errno(execve(p, argp, envp));
|
||||||
|
|
|
@ -664,8 +664,8 @@ int net_init_socket(QemuOpts *opts,
|
||||||
qemu_opt_get(opts, "connect") ||
|
qemu_opt_get(opts, "connect") ||
|
||||||
qemu_opt_get(opts, "listen") ||
|
qemu_opt_get(opts, "listen") ||
|
||||||
qemu_opt_get(opts, "mcast")) {
|
qemu_opt_get(opts, "mcast")) {
|
||||||
error_report("fd=, connect=, listen=\
|
error_report("fd=, connect=, listen="
|
||||||
and mcast= is invalid with udp=");
|
" and mcast= is invalid with udp=");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,8 +680,8 @@ int net_init_socket(QemuOpts *opts,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error_report("-socket requires fd=, listen=, \
|
error_report("-socket requires fd=, listen=,"
|
||||||
connect=, mcast= or udp=");
|
" connect=, mcast= or udp=");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
10
vl.c
10
vl.c
|
@ -2030,7 +2030,7 @@ static int configure_accelerator(void)
|
||||||
const char *p = NULL;
|
const char *p = NULL;
|
||||||
char buf[10];
|
char buf[10];
|
||||||
int i, ret;
|
int i, ret;
|
||||||
bool accel_initalised = 0;
|
bool accel_initialised = 0;
|
||||||
bool init_failed = 0;
|
bool init_failed = 0;
|
||||||
|
|
||||||
QemuOptsList *list = qemu_find_opts("machine");
|
QemuOptsList *list = qemu_find_opts("machine");
|
||||||
|
@ -2043,7 +2043,7 @@ static int configure_accelerator(void)
|
||||||
p = "tcg";
|
p = "tcg";
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!accel_initalised && *p != '\0') {
|
while (!accel_initialised && *p != '\0') {
|
||||||
if (*p == ':') {
|
if (*p == ':') {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -2064,7 +2064,7 @@ static int configure_accelerator(void)
|
||||||
}
|
}
|
||||||
*(accel_list[i].allowed) = 0;
|
*(accel_list[i].allowed) = 0;
|
||||||
} else {
|
} else {
|
||||||
accel_initalised = 1;
|
accel_initialised = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2074,7 +2074,7 @@ static int configure_accelerator(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!accel_initalised) {
|
if (!accel_initialised) {
|
||||||
fprintf(stderr, "No accelerator found!\n");
|
fprintf(stderr, "No accelerator found!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -2083,7 +2083,7 @@ static int configure_accelerator(void)
|
||||||
fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name);
|
fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return !accel_initalised;
|
return !accel_initialised;
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_add_exit_notifier(Notifier *notify)
|
void qemu_add_exit_notifier(Notifier *notify)
|
||||||
|
|
Loading…
Reference in a new issue