Re: Emulating multi core processor (ARM cortex M7) on QEMU

2024-02-26 Thread Peter Maydell
On Mon, 26 Feb 2024 at 10:59, ankita suman  wrote:
> I am trying to emulate multi core processor (dual core for now) on QEMU. The 
> processor I am targeting is cortex m7. I tried by running multiple instances 
> of QEMU to emulate multi cores, and use shared memory for communication, but 
> since I am working on a bare metal environment, I don't have the options of 
> libraries for synchronization.
> Another approach I tried was using inter VM shared memory(ivshmem). But I am 
> facing the same problem. I am able to write and read from the ivshmem device 
> from two different QEMU instances, but it is not working for ARM.

None of this is the right way to go. Running multiple QEMU instances
is like having two separate Arm hardware boards connected to each
other somehow, not like having an actual multi-CPU board.

You need to either:
 (1) use one of QEMU's existing boards with multiple CPUs
 (unfortunately we have no dual-M7 board)
 (2) model some dual-M7 board in QEMU, by writing C code to do that.
 This will not be particularly simple, depending on what the
 board you're trying to model is.

If you're OK with a pair of Cortex-M33 rather than M7 specifically,
you can look at using the mps3-an521 or mps3-an524 board models.
I would suggest doing that: it will be by far the easiest thing.

thanks
-- PMM



Re: Emulating multi core processor (ARM cortex M7) on QEMU

2024-02-26 Thread Philippe Mathieu-Daudé

Hello,

On 26/2/24 11:58, ankita suman wrote:

Hello,

I am trying to emulate multi core processor (dual core for now) on QEMU. 
The processor I am targeting is cortex m7. I tried by running multiple 
instances of QEMU to emulate multi cores, and use shared memory for 
communication, but since I am working on a bare metal environment, I 
don't have the options of libraries for synchronization.


Have a look at the 'fby35' machine in hw/arm/fby35.c, it uses
a pair of Aspeed ast1030 and ast2600 ARM cores.

Another approach I tried was using inter VM shared memory(ivshmem). But 
I am facing the same problem. I am able to write and read from the 
ivshmem device from two different QEMU instances, but it is not working 
for ARM.


Cc'ing Gustavo who worked on something similar and posted ivshmem
patches:
https://lore.kernel.org/qemu-devel/2024022218.2261956-1-gustavo.rom...@linaro.org/

can someone please guide me on how to proceed and what is the best 
approach? If there are library support in QEMU for multi core emulation, 
kindly let me know, that would be helpful as well.


Regards,

Phil.