flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Multicore UEFI in QEMU?

Author
Thread Post new topic Reply to topic
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 27 Apr 2022, 16:20
Hi all!

It's posible to do that? I'm failing to run QEMU with more than one core with OVMF_CODE_4M.fd or edk2-x86_64-code.fd

For example:
Quote:
"X:\Program Files\qemu\qemu-system-x86_64w.exe" ^
-nodefaults ^
-cpu qemu64 -smp 4 -vga std -machine q35,smm=on ^
-device qemu-xhci -device usb-mouse -device usb-kbd ^
-drive file=firmware\OVMF_amd64\OVMF_CODE_4M.fd,if=pflash,format=raw,unit=0,readonly=on ^
-drive file=firmware\OVMF_amd64\OVMF_VARS_4M.fd,if=pflash,format=raw,unit=1 ^
-drive file=fat:rw:e:\,index=1,media=disk,if=virtio,format=raw


Thanks in advance, HSE.
Post 27 Apr 2022, 16:20
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3514
Location: vpcmipstrm
bitRAKE 27 Apr 2022, 21:35
Are you using something like:
https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Application/Cpuid/

... to display CPU information, or have you written your own program to detect processors?

If QEMU fails to run, it usually displays an error message.

What are your tools telling you?

_________________
¯\(°_o)/¯ unlicense.org
Post 27 Apr 2022, 21:35
View user's profile Send private message Visit poster's website Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 27 Apr 2022, 22:03
Not like that.

I'm using EFI_MP_SERVICES Protocol. Same program from boot detected 8 CPU (they are 4 cores with hyperthread) but in QEMU detect only one. There are no errors.

[Just some hours ago I adapted your UINT64__Baseform proc to unicode. Very interesting. I need that exactly to show this numbers (until now I loaded to FPU, not so elegant nor fast).]
Post 27 Apr 2022, 22:03
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3514
Location: vpcmipstrm
bitRAKE 27 Apr 2022, 22:17
Have you tried specifying the exact topology you'd like to test?
Code:
-smp [[cpus=]n][,maxcpus=maxcpus][,sockets=sockets][,dies=dies][,clusters=clusters][,cores=cores][,threads=threads]    
QEMU behavior changes with different versions - it is best to be explicit. Current default is just to create cores and not socketed CPUs.

https://www.qemu.org/docs/master/system/qemu-manpage.html
Post 27 Apr 2022, 22:17
View user's profile Send private message Visit poster's website Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 28 Apr 2022, 00:00
Now better:
Code:
-smp sockets=1,dies=1,cpus=8,maxcpus=8,clusters=2,cores=2,threads=2    

No error, just don't run.

Code:
-smp sockets=1,dies=1,cpus=8,maxcpus=8,cores=4,threads=2    


Run but nothing change, only one cpu.
Post 28 Apr 2022, 00:00
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3514
Location: vpcmipstrm
bitRAKE 28 Apr 2022, 11:07
Quote:
For a particular machine type board, an expected CPU topology hierarchy
can be defined through the supported sub-option. Unsupported parameters
can also be provided in addition to the sub-option, but their values
must be set as 1 in the purpose of correct parsing.
These statements on the QEMU -help makes me think the problem might be a limitation of the machine specification.

Does your test program work on real hardware? It would help to insure it's a configuration problem with QEMU.

_________________
¯\(°_o)/¯ unlicense.org
Post 28 Apr 2022, 11:07
View user's profile Send private message Visit poster's website Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 28 Apr 2022, 12:09
Some weeks ago (when was not so relevant Very Happy ) I read somewhere that multicore depends on machine used. But I don't know if x86_64 machines can do that. Multicore examples I found are ARM, or about images with OS.

The program work in real hardware.

Relevant lines are very simple:
Code:
  mov rax, pBootServices
  invoke [rax].EFI_BOOT_SERVICES.LocateProtocol, ADDR EFI_MP_SERVICES_PROTOCOL_GUID, NULL, ADDR MpProtocol

  mov rcx, MpProtocol
  invoke [rcx].MP_SERVICES.GetNumberOfProcessors, MpProtocol, addr ProcessorNum, addr EnabledProcessorNum
    


Description: Have some precarious timing (a little incomplete) and processors detection, wich is the relevant part here
Download
Filename: CoreUEFI1.zip
Filesize: 5.33 KB
Downloaded: 103 Time(s)

Post 28 Apr 2022, 12:09
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3514
Location: vpcmipstrm
bitRAKE 28 Apr 2022, 13:30
Ah, found a better way to confirm QEMU cpus:

Add command line option "-monitor vc"

During emulation press <Ctrl><Alt><2> to enter monitor mode.

Type command: "info cpus"

... and sure enough there they are. (Here they are - I hope there they are, lol.)
Post 28 Apr 2022, 13:30
View user's profile Send private message Visit poster's website Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 28 Apr 2022, 13:43
Perfectly!!

Only one have an asterisk.
Then is a limitation of UEFI emulation ¿?
Post 28 Apr 2022, 13:43
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3514
Location: vpcmipstrm
bitRAKE 28 Apr 2022, 13:53
Maybe, but I always blame myself first.

The EFI app crashed on my end. So, I would try to debug or implement in another way. If that fails too, then try another firmware build. Actually, trying another firmware is quite easy - if that gives same results then the app code is probably in error.
Post 28 Apr 2022, 13:53
View user's profile Send private message Visit poster's website Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 28 Apr 2022, 14:34
Must crash after show processors. I rename BOOTX64 and use like boot file.
Post 28 Apr 2022, 14:34
View user's profile Send private message Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 01 May 2022, 22:34
No luck with QEMU, fortunately worked in VirtualBox, but it's not the same.

Thanks
Post 01 May 2022, 22:34
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3514
Location: vpcmipstrm
bitRAKE 02 May 2022, 01:17
What version of QEMU are you using?

7.0 was just released, but it's very buggy in Windows, in my experience.

_________________
¯\(°_o)/¯ unlicense.org
Post 02 May 2022, 01:17
View user's profile Send private message Visit poster's website Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 02 May 2022, 13:36
bitRAKE wrote:
What version of QEMU are you using?

7.0 was just released, but it's very buggy in Windows, in my experience.

Package is 6.2, but qemu-system-x86_64 is 5.2.

Probably machine is too old:
Code:
q35                  Standard PC (Q35 + ICH9, 2009) (alias of pc-q35-5.2)    
Post 02 May 2022, 13:36
View user's profile Send private message Reply with quote
I



Joined: 19 May 2022
Posts: 33
I 09 Jul 2022, 00:41
It's a bit late but what worked for me using a similar command line was adding option "-accel kvm", otherwise only single core .
Post 09 Jul 2022, 00:41
View user's profile Send private message Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 15
HSE 09 Jul 2022, 03:52
kvm is not valid. Thanks anyway.
Post 09 Jul 2022, 03:52
View user's profile Send private message Reply with quote
I



Joined: 19 May 2022
Posts: 33
I 10 Jul 2022, 03:21
You can find out what can be used for your system with "qemu-system-x86_64.exe -accel help"

The default accelerator tcg seems somewhat limited
https://wiki.qemu.org/Documentation/Platforms

Windows HyperVisor - whpx (only some Windows OS's)
Intel HAXM - hax (Only Windows Intel and needs HAXM installed)

Be aware trying might end up being more trouble than it's worth.
Post 10 Jul 2022, 03:21
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.