qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to increase memory in a RISCV32 image? Stuck with 988MB


From: Daniel Henrique Barboza
Subject: Re: How to increase memory in a RISCV32 image? Stuck with 988MB
Date: Tue, 18 Apr 2023 10:32:34 -0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0



On 4/18/23 08:10, Mikhail R. Gadelha wrote:
Yeah, I mentioned in the email it doesn't even start with mem=4G...

With lower values, e.g., mem=3G, the image starts but I'm limited to 988MB of 
RAM.

QEMU doesn't make a distinction between 32 or 64 bits when setting the memory 
banks.


From Linux kernel arch/riscv/mm/init.c, early_mem():


        pr_notice("Memory limited to %lldMB\n", (u64)memory_limit >> 20);


'memory_limit' is defined in the same file in setup_vm() as:

        /*
         * The default maximal physical memory size is KERN_VIRT_SIZE for 32-bit
         * kernel, whereas for 64-bit kernel, the end of the virtual address
         * space is occupied by the modules/BPF/kernel mappings which reduces
         * the available size of the linear mapping.
         */
        memory_limit = KERN_VIRT_SIZE - (IS_ENABLED(CONFIG_64BIT) ? SZ_4G : 0);


So my educated guess here is that the kernel is capping the max memory for 32 
bits
to 988Mb, as you've pointed in your first email.


Thanks,


Daniel



Em ter., 18 de abr. de 2023 às 04:42, Thomas Huth <thuth@redhat.com 
<mailto:thuth@redhat.com>> escreveu:

    On 17/04/2023 19.21, Mikhail R. Gadelha wrote:
     > Hi qemu folks,
     >
     > I'm using yocto to generate a riscv32 image but qemu seems to be ignoring
     > the -m argument from the command line and forcing the image to run with
     > 988MB of RAM.
     >
     > Is there any way I can increase it to 4G?
     >
     > I'm using the following cmdline to start qemu:
     >
     > qemu-system-riscv32 -nographic -machine virt -m 4G -smp 8 -bios
     > /home/mgadelha/tools/poky/build/tmp/deploy/images/qemuriscv32/fw_jump.elf
     > -kernel 
/home/mgadelha/tools/poky/build/tmp/deploy/images/qemuriscv32/Image
     > -append "root=/dev/vda rw mem=4G" -drive

    That "mem=4G" part of the -append option looks suspicious ... have you
    already tried to boot without that, or to decrease it to a number that fits
    into 32-bit, e.g. "mem=3G" ?

       HTH,
        Thomas

     > 
id=disk0,file=/home/mgadelha/tools/poky/build/tmp/deploy/images/qemuriscv32/core-image-full-cmdline-qemuriscv32-20230415202008.rootfs.ext4,if=none,format=raw
 -device virtio-net-device,netdev=usernet -netdev 
user,id=usernet,hostfwd=tcp::22222-:22 -device virtio-blk-device,drive=disk0 
-object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 
-device virtio-tablet-pci -device virtio-keyboard-pci
     >
     > Well, it actually doesn't start if I use -m 4G, but any value lower than
     > that is fine.
     >
     > Here's also the boot log: https://pastebin.com/b7ZEP659 
<https://pastebin.com/b7ZEP659>
     > <https://pastebin.com/b7ZEP659 <https://pastebin.com/b7ZEP659>>
     >
     > I see that the kernel prints:
     >
     > [    0.000000] Memory limited to 1024MB
     >
     > so maybe it's a kernel limitation rather than qemu?
     >
     > --
     >
     > Mikhail Ramalho.



--

Mikhail Ramalho.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]