qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Wu, Fei" <fei2.wu@intel.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: <palmer@dabbelt.com>, <alistair.francis@wdc.com>,
	<bin.meng@windriver.com>, <liweiwei@iscas.ac.cn>,
	<dbarboza@ventanamicro.com>, <zhiwei_liu@linux.alibaba.com>,
	<qemu-riscv@nongnu.org>, <qemu-devel@nongnu.org>,
	Andrei Warkentin <andrei.warkentin@intel.com>
Subject: Re: [PATCH] hw/riscv: split RAM into low and high memory
Date: Fri, 4 Aug 2023 17:15:30 +0800	[thread overview]
Message-ID: <d654810c-4f4f-7491-7711-c6076f42dcae@intel.com> (raw)
In-Reply-To: <20230803-3855259bbabb934c247c5607@orel>

On 8/3/2023 11:07 PM, Andrew Jones wrote:
> On Mon, Jul 31, 2023 at 09:53:17AM +0800, Fei Wu wrote:
>> riscv virt platform's memory started at 0x80000000 and
>> straddled the 4GiB boundary. Curiously enough, this choice
>> of a memory layout will prevent from launching a VM with
>> a bit more than 2000MiB and PCIe pass-thru on an x86 host, due
>> to identity mapping requirements for the MSI doorbell on x86,
>> and these (APIC/IOAPIC) live right below 4GiB.
>>
>> So just split the RAM range into two portions:
>> - 1 GiB range from 0x80000000 to 0xc0000000.
>> - The remainder at 0x100000000
>>
>> ...leaving a hole between the ranges.
> 
> Can you elaborate on the use case? Maybe provide details of the host
> system and the QEMU command line? I'm wondering why we didn't have
> any problems with the arm virt machine type. Has nobody tried this
> use case with that? Is the use case something valid for riscv, but
> not arm?
> 
Firstly we have to enable pcie passthru on host, find the device groups,
e.g. the vga card, and add their pci ids to host kernel cmdline:
	vfio-pci.ids=10de:0f02,10de:0e08

then start vm through qemu as follows:
$Q -machine virt -m 4G -smp 4 -nographic \
  -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
  -kernel ./vmlinuz -initrd initrd.img -append "root=/dev/vda1 rw" \
  -drive
file=ubuntu-22.04.1-preinstalled-server-riscv64+unmatched.img,if=virtio,format=raw
\
  -device vfio-pci,host=01:00.0 -device vfio-pci,host=01:00.1 \
  -netdev user,id=vnet,hostfwd=:127.0.0.1:2223-:22 -device
virtio-net-pci,netdev=vnet

Without this patch, qemu exits immediately instead of boots up.

Just tried pcie passthru on arm, it cannot handle 4G memory either.
$Q -m 4G -smp 4 -cpu max -M virt -nographic \
  -pflash /usr/share/AAVMF/AAVMF_CODE.fd -pflash flash1.img \
  -drive if=none,file=ubuntu-22.04-server-cloudimg-arm64.img,id=hd0 \
  -device virtio-blk-device,drive=hd0 \
  -device vfio-pci,host=01:00.0 -device vfio-pci,host=01:00.1

qemu-system-aarch64: -device vfio-pci,host=01:00.0: VFIO_MAP_DMA failed:
Invalid argument
qemu-system-aarch64: -device vfio-pci,host=01:00.0: vfio 0000:01:00.0:
failed to setup container for group 11: memory listener initialization
failed: Region mach-virt.ram: vfio_dma_map(0x55de3c2a97f0, 0x40000000,
0x100000000, 0x7f8fcbe00000) = -22 (Invalid argument)

Thanks,
Fei.

> Thanks,
> drew



  reply	other threads:[~2023-08-04  9:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31  1:53 [PATCH] hw/riscv: split RAM into low and high memory Fei Wu
2023-07-31 22:46 ` Daniel Henrique Barboza
2023-08-01  2:34   ` Wu, Fei
2023-08-03  0:45   ` Wu, Fei
2023-09-07  3:17     ` Alistair Francis
2023-09-07 15:57       ` Anup Patel
2023-09-07 15:46   ` Anup Patel
2023-09-08  0:16     ` Wu, Fei
2023-08-03 15:07 ` Andrew Jones
2023-08-04  9:15   ` Wu, Fei [this message]
2023-09-07  7:16     ` Philippe Mathieu-Daudé
2023-09-07  9:10       ` Eric Auger
2023-09-07 10:04         ` Wu, Fei
2023-09-07 13:49           ` Eric Auger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d654810c-4f4f-7491-7711-c6076f42dcae@intel.com \
    --to=fei2.wu@intel.com \
    --cc=ajones@ventanamicro.com \
    --cc=alistair.francis@wdc.com \
    --cc=andrei.warkentin@intel.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=palmer@dabbelt.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).