adding Irix (and, to a lesser extent, Solaris) userland emulation to QEMU
Go to file
vincent 4d1de87c75 linux-user: Fix the computation of the requested heap size
There were several remaining bugs in the previous implementation of
do_brk():

    1. the value of "new_alloc_size" was one page too large when the
       requested brk was aligned on a host page boundary.

    2. no new pages should be (re-)allocated when the requested brk is
       in the range of the pages that were already allocated
       previsouly (for the same purpose).  Technically these pages are
       never unmapped in the current implementation.

The problem/fix can be reproduced/validated with the test-suite above:

    #include <unistd.h>       /* syscall(2),      */
    #include <sys/syscall.h>  /* SYS_brk,         */
    #include <stdio.h>        /* puts(3),         */
    #include <stdlib.h>       /* exit(3), EXIT_*, */
    #include <stdint.h>       /* uint*_t,         */
    #include <sys/mman.h>     /* mmap(2), MAP_*,  */
    #include <string.h>       /* memset(3), */

    int main()
    {
        int exit_status = EXIT_SUCCESS;
        uint8_t *current_brk = 0;
        uint8_t *initial_brk;
        uint8_t *new_brk;
        uint8_t *old_brk;
        int failure = 0;
        int i;

        void test_brk(int increment, int expected_result) {
            new_brk = (uint8_t *)syscall(SYS_brk, current_brk + increment);
            if ((new_brk == current_brk) == expected_result)
                failure = 1;
            current_brk = (uint8_t *)syscall(SYS_brk, 0);
        }

        void test_result() {
            if (!failure)
                puts("OK");
            else {
                puts("failure");
                exit_status = EXIT_FAILURE;
            }
        }

        void test_title(const char *title) {
            failure = 0;
            printf("%-45s : ", title);
            fflush(stdout);
        }

        test_title("Initialization");
        test_brk(0, 1);
        initial_brk = current_brk;
        test_result();

        test_title("Don't overlap \"brk\" pages");
        test_brk(HOST_PAGE_SIZE, 1);
        test_brk(HOST_PAGE_SIZE, 1);
        test_result();

        /* Preparation for the test "Re-allocated heap is initialized".  */
        old_brk = current_brk - HOST_PAGE_SIZE;
        memset(old_brk, 0xFF, HOST_PAGE_SIZE);

        test_title("Don't allocate the same \"brk\" page twice");
        test_brk(-HOST_PAGE_SIZE, 1);
        test_brk(HOST_PAGE_SIZE, 1);
        test_result();

        test_title("Re-allocated \"brk\" pages are initialized");
        for (i = 0; i < HOST_PAGE_SIZE; i++) {
            if (old_brk[i] != 0) {
                printf("(index = %d, value = 0x%x) ", i, old_brk[i]);
                failure = 1;
                break;
            }
        }
        test_result();

        test_title("Don't allocate \"brk\" pages over \"mmap\" pages");
        new_brk = mmap(current_brk, HOST_PAGE_SIZE / 2, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
        if (new_brk == (void *) -1)
            puts("unknown");
        else {
            test_brk(HOST_PAGE_SIZE, 0);
            test_result();
        }

        test_title("All \"brk\" pages are writable (please wait)");
        if (munmap(current_brk, HOST_PAGE_SIZE / 2) != 0)
            puts("unknown");
        else {
            while (current_brk - initial_brk < 2*1024*1024*1024UL) {
                old_brk = current_brk;

                test_brk(HOST_PAGE_SIZE, -1);
                if (old_brk == current_brk)
                    break;

                for (i = 0; i < HOST_PAGE_SIZE; i++)
                    old_brk[i] = 0xAA;
            }
            puts("OK");
        }

        test_title("Maximum size of the heap > 16MB");
        failure = (current_brk - initial_brk) < 16*1024*1024;
        test_result();

        exit(exit_status);
    }

Changes introduced in patch v2:

    * extend the "brk" test-suite embedded within the commit message;

    * heap contents have to be initialized to zero, this bug was
      exposed by "tst-calloc.c" from the GNU C library;

    * don't [try to] allocate a new host page if the new "brk" is
      equal to the latest allocated host page ("brk_page"); and

    * print some debug information when DEBUGF_BRK is defined.

Signed-off-by: Cédric VINCENT <cedric.vincent@st.com>
Reviewed-by: Christophe Guillon <christophe.guillon@st.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2011-06-21 20:30:09 +03:00
QMP QMP: add server mode to QEMUMonitorProtocol 2011-06-01 11:43:18 -03:00
audio Fix compilation warning due to incorrectly specified type 2011-06-14 03:08:56 +02:00
block qcow2: Fix in-flight list after qcow2_cache_put failure 2011-06-15 14:36:15 +02:00
bsd-user Command line support for altering the log file location 2011-06-15 16:51:24 +00:00
darwin-user Command line support for altering the log file location 2011-06-15 16:51:24 +00:00
default-configs target-alpha: Enable the alpha-softmmu target. 2011-05-31 10:18:05 -07:00
docs usb: documentation update 2011-06-14 12:56:49 +02:00
fpu softfloat: add float*_is_zero_or_denormal() 2011-06-03 16:07:53 +02:00
fsdev fsdev: Fix archs that dont use fsdev 2011-06-10 15:29:11 +02:00
gdb-xml
hw hw/9118.c: Implement active-low interrupt support 2011-06-15 13:23:37 +02:00
libcacard libcacard: add libcacard.la target 2011-06-14 09:34:34 -05:00
linux-user linux-user: Fix the computation of the requested heap size 2011-06-21 20:30:09 +03:00
net slirp: fix guestfwd id 2011-06-08 09:04:29 +01:00
pc-bios s390x: update zipl rom 2011-06-03 13:34:01 +02:00
roms Revert SeaBIOS change due to overzealous commit -a 2011-04-13 08:16:53 -05:00
scripts s390x: s390x-linux-user support 2011-05-20 17:35:12 +02:00
slirp
sysconfigs/target
target-alpha target-alpha: Implement TLB flush primitives. 2011-05-31 10:18:06 -07:00
target-arm target-arm: BKPT instructions should raise prefetch aborts with IFSR type 00010 2011-06-03 18:42:17 +02:00
target-cris Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-05-12 08:08:12 -05:00
target-i386 kvm: Enable CPU SMEP feature 2011-06-14 09:34:35 -05:00
target-lm32 Remove warning in printf due to type mismatch 2011-06-14 03:08:57 +02:00
target-m68k m68k: Replace gen_im32() by tcg_const_i32() 2011-06-08 09:04:29 +01:00
target-microblaze Merge remote-tracking branch 'stefanha/trivial-patches' into staging 2011-05-12 08:08:12 -05:00
target-mips target-mips: Fix warning caused by unused local variable 2011-05-15 01:00:20 +02:00
target-ppc Fix compilation warning due to missing header for sigaction (followup) 2011-06-08 09:04:29 +01:00
target-s390x s390x: implement lrvgr 2011-06-03 13:34:02 +02:00
target-sh4 Remove unused function parameter from cpu_restore_state 2011-04-20 10:37:03 +02:00
target-sparc Fix compilation warning due to missing header for sigaction (followup) 2011-06-08 09:04:29 +01:00
target-unicore32 Remove unused function parameters from gen_pc_load and rename the function 2011-04-20 10:33:59 +02:00
tcg tcg: Fix unused-but-set-variable warning 2011-06-03 18:32:46 +02:00
tests Fix spelling in comments (intruction -> instruction) 2011-05-08 10:59:15 +01:00
ui cocoa: Avoid warning related to multiple handleEvent: definitions 2011-06-14 03:08:58 +02:00
.gitignore Makefile: Clean up after "make pdf" 2011-04-16 12:24:28 +01:00
.gitmodules Add ipxe submodule 2011-04-08 13:03:34 -06:00
CODING_STYLE
COPYING
COPYING.LIB
Changelog Changelog: Add explanatory note that this file is no longer updated 2011-06-13 21:16:27 +02:00
HACKING
LICENSE
MAINTAINERS target-alpha: Claim ownership. 2011-05-31 10:18:04 -07:00
Makefile libcacard: add libcacard.la target 2011-06-14 09:34:34 -05:00
Makefile.dis
Makefile.hw
Makefile.objs Merge branch 'cocoa-for-upstream' of git://repo.or.cz/qemu/afaerber 2011-06-15 18:31:56 +00:00
Makefile.target Merge remote branch 'rth/axp-next' into alpha-merge 2011-06-10 22:21:14 +02:00
Makefile.user
README
TODO
VERSION
a.out.h
acl.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
acl.h
aes.c
aes.h
aio.c
alpha-dis.c target-alpha: Disassemble EV6 PALcode instructions. 2011-05-31 10:18:04 -07:00
alpha.ld
arch_init.c Introduce -machine command option. 2011-05-08 10:09:59 +02:00
arch_init.h Introduce -machine command option. 2011-05-08 10:09:59 +02:00
arm-dis.c
arm-semi.c arm-semi.c: Use correct check for failure of do_brk() 2011-06-21 20:29:01 +03:00
arm.ld
async.c Allow nested qemu_bh_poll() after BH deletion 2011-06-15 15:43:20 +02:00
balloon.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
balloon.h
bitmap.c
bitmap.h
bitops.c
bitops.h
block-migration.c Improve accuracy of block migration bandwidth calculation 2011-04-27 14:36:57 +02:00
block-migration.h
block.c bdrv_img_create: Fix segfault 2011-06-08 11:56:40 +02:00
block.h Replaced tabs with spaces in block.h and block_int.h 2011-06-15 14:36:15 +02:00
block_int.h Replaced tabs with spaces in block.h and block_int.h 2011-06-15 14:36:15 +02:00
blockdev.c block: clarify the meaning of BDRV_O_NOCACHE 2011-06-08 10:39:32 +02:00
blockdev.h blockdev: Store -drive option media in DriveInfo 2011-05-19 10:26:21 +02:00
bswap.h
bt-host.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
bt-host.h
bt-vhci.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
buffered_file.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
buffered_file.h
cache-utils.c
cache-utils.h
check-qdict.c
check-qfloat.c
check-qint.c
check-qjson.c
check-qlist.c
check-qstring.c
cmd.c
cmd.h
compatfd.c sigfd: use pthread_sigmask 2011-06-10 23:18:19 +02:00
compatfd.h
config.h
configure Introduce format string for pid_t 2011-06-15 19:58:48 +00:00
console.c Fix segfault on screendump with -nographic 2011-06-03 12:42:19 +02:00
console.h
cpu-all.h softfloat: always enable floatx80 and float128 support 2011-06-03 16:07:51 +02:00
cpu-common.h exec: Implement qemu_ram_free_from_ptr() 2011-06-03 22:59:15 +02:00
cpu-defs.h
cpu-exec.c target-alpha: Disable interrupts properly. 2011-05-31 10:18:05 -07:00
cpus.c Command line support for altering the log file location 2011-06-15 16:51:24 +00:00
cpus.h Command line support for altering the log file location 2011-06-15 16:51:24 +00:00
cris-dis.c
cursor.c
cursor_hidden.xpm
cursor_left_ptr.xpm
cutils.c
def-helper.h
device_tree.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
device_tree.h
dis-asm.h target-alpha: Disassemble EV6 PALcode instructions. 2011-05-31 10:18:04 -07:00
disas.c target-alpha: Disassemble EV6 PALcode instructions. 2011-05-31 10:18:04 -07:00
disas.h
dma-helpers.c make dma_bdrv_io available to drivers 2011-06-15 14:36:16 +02:00
dma.h make dma_bdrv_io available to drivers 2011-06-15 14:36:16 +02:00
dyngen-exec.h
elf.h unicore32: necessary modifications for other files to support unicore32 2011-04-12 18:49:05 +00:00
envlist.c
envlist.h
error.c Introduce the new error framework 2011-06-07 13:52:10 -05:00
error.h Introduce the new error framework 2011-06-07 13:52:10 -05:00
error_int.h Introduce the new error framework 2011-06-07 13:52:10 -05:00
exec-all.h target-alpha: Trap for unassigned and unaligned addresses. 2011-05-31 10:18:06 -07:00
exec.c Merge remote branch 'rth/axp-next' into alpha-merge 2011-06-10 22:21:14 +02:00
gdbstub.c target-mips/gdbstub: remove old CONFIG_SOFTFLOAT #ifndef 2011-06-03 16:07:49 +02:00
gdbstub.h
gen-icount.h Fix conversions from pointer to tcg_target_long 2011-04-10 00:45:16 +02:00
hmp-commands.hx HMP: Use QMP inject nmi implementation 2011-06-01 11:42:25 -03:00
host-utils.c
host-utils.h
hpet.h
hppa-dis.c Fix typo in comment (relevent -> relevant) 2011-05-08 10:02:18 +01:00
hppa.ld
i386-dis.c
i386.ld
ia64-dis.c
ia64.ld
input.c event: trivial coding style fixes 2011-04-09 10:56:17 +01:00
iohandler.c
ioport-user.c
ioport.c
ioport.h
iorange.h
iov.c
iov.h
json-lexer.c json-lexer: make lexer error-recovery more deterministic 2011-06-07 13:52:11 -05:00
json-lexer.h json-lexer: make lexer error-recovery more deterministic 2011-06-07 13:52:11 -05:00
json-parser.c json-parser: add handling for NULL token list 2011-06-07 13:52:11 -05:00
json-parser.h json-parser: propagate error from parser 2011-06-07 13:52:10 -05:00
json-streamer.c json-streamer: add handling for JSON_ERROR token/state 2011-06-07 13:52:11 -05:00
json-streamer.h json-streamer: make sure to reset token_size after emitting a token list 2011-06-07 13:52:11 -05:00
kvm-all.c kvm: ppc: warn user on PAGE_SIZE mismatch 2011-05-09 22:31:38 +02:00
kvm-stub.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
kvm.h
libfdt_env.h Fix libfdt warnings on Darwin 2011-06-14 03:08:57 +02:00
linux-aio.c
m68k-dis.c
m68k-semi.c m68k-semi.c: Use correct check for failure of do_brk() 2011-06-21 20:29:01 +03:00
m68k.ld
microblaze-dis.c
migration-exec.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
migration-fd.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
migration-tcp.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
migration-unix.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
migration.c
migration.h migration: move some declarations to migration.h 2011-04-15 20:14:54 +00:00
mips-dis.c
mips.ld
module.c
module.h
monitor.c HMP: Use QMP inject nmi implementation 2011-06-01 11:42:25 -03:00
monitor.h
nbd.c
nbd.h
net.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
net.h
notify.c
notify.h
os-posix.c Introduce format string for pid_t 2011-06-15 19:58:48 +00:00
os-win32.c Introduce format string for pid_t 2011-06-15 19:58:48 +00:00
osdep.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
osdep.h Introduce format string for pid_t 2011-06-15 19:58:48 +00:00
oslib-posix.c Darwin: Fix compilation warning regarding the deprecated daemon() function 2011-06-14 03:10:47 +02:00
oslib-win32.c
path.c
pci-ids.txt
pflib.c
pflib.h
poison.h irq: Privatize CPU_INTERRUPT_NMI. 2011-05-08 16:55:24 +00:00
posix-aio-compat.c Fix compilation warning due to missing header for sigaction (followup) 2011-06-08 09:04:29 +01:00
ppc-dis.c
ppc.ld
ppc64.ld
qbool.c
qbool.h
qdict-test-data.txt
qdict.c
qdict.h
qemu-aio.h
qemu-barrier.h
qemu-char.c Fix compilation warning due to missing header for sigaction (followup) 2011-06-08 09:04:29 +01:00
qemu-char.h char: Allow devices to use a single multiplexed chardev. 2011-04-28 11:03:07 +05:30
qemu-common.h cocoa: Provide central qemu_main() prototype 2011-06-14 03:08:58 +02:00
qemu-config.c qemu-config: comment spell fix 2011-06-06 09:14:42 +02:00
qemu-config.h
qemu-doc.texi doc: Add explanation that -alt-grab and -ctrl-grab affect special keys 2011-05-15 00:13:48 +02:00
qemu-error.c Remove unused sysemu.h include directives 2011-04-15 18:25:41 +00:00
qemu-error.h
qemu-img-cmds.hx
qemu-img.c qemu_img: is_not_zero() optimization 2011-05-18 14:39:15 +02:00
qemu-img.texi
qemu-io.c block: clarify the meaning of BDRV_O_NOCACHE 2011-06-08 10:39:32 +02:00
qemu-lock.h
qemu-log.h
qemu-malloc.c
qemu-nbd.c Darwin: Fix compilation warning regarding the deprecated daemon() function 2011-06-14 03:10:47 +02:00
qemu-nbd.texi
qemu-objects.h
qemu-option.c
qemu-option.h
qemu-options.h
qemu-options.hx Command line support for altering the log file location 2011-06-15 16:51:24 +00:00
qemu-os-posix.h
qemu-os-win32.h w32: Fix missing declaration of ffs() 2011-05-15 12:34:39 +02:00
qemu-progress.c Fix compilation warning due to missing header for sigaction (followup) 2011-06-08 09:04:29 +01:00
qemu-queue.h
qemu-sockets.c
qemu-tech.texi
qemu-thread-posix.c
qemu-thread-posix.h
qemu-thread-win32.c
qemu-thread-win32.h
qemu-thread.h
qemu-timer-common.c
qemu-timer.c timer: drop HPET and RTC 2011-06-06 08:54:55 -05:00
qemu-timer.h qemu-timer: Remove unneeded include statement (w32) 2011-04-27 13:30:18 +02:00
qemu-tool.c qemu-tool: Stub out qemu-timer functions 2011-05-18 14:38:46 +02:00
qemu-x509.h
qemu.sasl
qemu_socket.h
qerror.c Merge remote-tracking branch 'qmp/for-anthony' into staging 2011-06-08 12:16:24 -05:00
qerror.h Merge remote-tracking branch 'qmp/for-anthony' into staging 2011-06-08 12:16:24 -05:00
qfloat.c
qfloat.h
qint.c
qint.h
qjson.c
qjson.h
qlist.c
qlist.h
qmp-commands.hx HMP: Use QMP inject nmi implementation 2011-06-01 11:42:25 -03:00
qobject.h
qstring.c
qstring.h
range.h
readline.c
readline.h
rules.mak libcacard: add libcacard.la target 2011-06-14 09:34:34 -05:00
rwhandler.c
rwhandler.h
s390-dis.c
s390.ld
savevm.c Fix compilation warning due to missing header for sigaction (followup) 2011-06-08 09:04:29 +01:00
sh4-dis.c
simpletrace.c
simpletrace.h
softmmu-semi.h
softmmu_defs.h
softmmu_exec.h
softmmu_header.h
softmmu_template.h
sparc-dis.c
sparc.ld
sparc64.ld
spice-qemu-char.c spice-qemu-char: Fix flow control in client -> guest direction 2011-06-06 09:14:42 +02:00
sysemu.h vl.c: Introduce getter for shutdown_requested and reset_requested. 2011-05-08 10:10:01 +02:00
targphys.h
tcg-runtime.c
thunk.c
thunk.h
trace-events usb-ehci: split trace calls to handle arg count limits 2011-06-14 12:56:49 +02:00
translate-all.c Remove unused function parameter from cpu_restore_state 2011-04-20 10:37:03 +02:00
uboot_image.h
usb-bsd.c Fix compilation warning due to missing header for sigaction (followup) 2011-06-08 09:04:29 +01:00
usb-linux.c usb-linux: Enlarge buffer for descriptors to 8192 bytes 2011-06-14 12:56:49 +02:00
usb-stub.c
user-exec.c Move user emulator stuff from cpu-exec.c to user-exec.c 2011-05-28 06:26:00 +00:00
version.rc
vgafont.h
vl.c Introduce format string for pid_t 2011-06-15 19:58:48 +00:00
x86_64.ld
xen-all.c xen: Add Xen hypercall for sleep state in the cmos_s3 callback. 2011-05-08 10:10:02 +02:00
xen-mapcache-stub.c xen: Introduce the Xen mapcache 2011-05-08 10:10:01 +02:00
xen-mapcache.c Introduce qemu_put_ram_ptr 2011-05-08 10:10:01 +02:00
xen-mapcache.h xen: Introduce the Xen mapcache 2011-05-08 10:10:01 +02:00
xen-stub.c xen: Add Xen hypercall for sleep state in the cmos_s3 callback. 2011-05-08 10:10:02 +02:00

README

Read the documentation in qemu-doc.html.

Fabrice Bellard.