Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bochs user mode emulator like SDE or QEMU #388

Open
stlintel opened this issue Nov 16, 2024 · 4 comments
Open

Add Bochs user mode emulator like SDE or QEMU #388

stlintel opened this issue Nov 16, 2024 · 4 comments
Labels
enhancement request New feature or request

Comments

@stlintel
Copy link
Contributor

For QEMU it is:
QEMU User space emulator, mentioned in QEMU docs: https://www.qemu.org/docs/master/user/main.html

I believe code from QEMU could be heavily reused as well

@stlintel stlintel added the enhancement request New feature or request label Nov 16, 2024
@stlintel
Copy link
Contributor Author

In ideal world instead of copying console linux binary into Bochs and running I would

bochs [-h] [-d] [-L path] [-s size] [-cpu model] [-g port] [-B offset] program [arguments...]

@Vort
Copy link
Contributor

Vort commented Nov 16, 2024

Bochs is a portable IA-32 (x86) PC emulator

From your link:

In this mode, QEMU can launch processes compiled for one CPU on another CPU.

Launching processes and emulating computers are different things in my opinion.

@stlintel
Copy link
Contributor Author

stlintel commented Nov 16, 2024

Intel SDE is also emulator of CPU as well as QEMU.
For Intel SDE it is mainly to emulate future ISA, for QEMU it is to emulate one ISA on another.

But for this feature main advantage is abstraction from disk images and guest operating system.
In my CPU validation code I compare Bochs implementation to SDE implementation on automatically generated unit tests, one per instruction. I generate one instruction like VDPBF16PS with millions of random inputs and compare results against same thing running on SDE. Running it locally without uploading to disk image and downloading results would be huge advantage.

How I see it ?
Smth similar to Load32OSHack feature we had many years ago and deprecated.

  • Set up CPU to pre-defined state matching one running under linux
  • load ELF file with binary
  • allocate memory for the ELF file in host memory by creating page tables on the fly
  • map system calls from ELF to corresponding host handlers or, in future, emulated handlers
  • transfer control to the ELF by setting RIP=ELF_START and running cpu_loop()

@Vort
Copy link
Contributor

Vort commented Nov 16, 2024

Running it locally without uploading to disk image and downloading results would be huge advantage.

With SSH access to guest there should not be many problems in automating this task.
It looks like it can be done with relatively simple script. Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants