run binary file with qeum on my M1 Mabook? - nasm

My qemu version is 6.2.0, and I did all of this in my M1 MacBook(Monterey 12.1)
Before the problem, I can get right results about the tutorial(https://github.com/cfenollosa/os-tutorial/tree/master/01-bootsector-barebones).
After I input the command of "qemu-system-aarch64 -S -drive file=boot_sect_simple.bin,format=raw -machine virt-5.2"
There is nothing in my qemu console.
The picture is as below.
I did not get the message of "Booting from Hard Disk..." in chapter 01.
Is there any solutions to let me get message:"Booting from Hard Disk..." like the chaoter 01?

I am so confused.But it is works by using qemu-system-x86_64 instead.

Related

Trace instructions in QEMU Full System Emulation (RISC-V)

As a college homework I have to run a benchmark on a system that uses RISC-V architecture.
Note: I don't have much knowledge of Linux and I don't know almost anything about QEMU.
About the virtual machine with RISC-V architecture:
To access a system with RISC-V architecture I used QEMU and as I'm using WSL2 to access a Linux kernel I used the tutorial below to install QEMU inside WSL2 and build the risc-v system with debian:
Emulating RISC-V Debian on WSL2 | David Burela’s blog
I was able to install it correctly and run the QEMU virtual machine with RISC-V architecture.
About the benchmark:
As a benchmark I'm using JPEG2000 from MediaBench II which you can access at this link:
MediaBench II (slu.edu)
The benchmark consists of running the JPEG2000 encoder using the provided application called “Jasper” with the benchmark image included in the files. Thus, the application takes the image file “input_base_4CIF.ppm” which is in the ppm format and encodes it to the jp2 format (JPEG2000) generating the output file “output_base_4CIF_96bps.jp2”.
To run the benchmark:
I accessed the RISC-V virtual machine through QEMU (which runs Debian)
Inside the virtual machine, I downloaded all the source code, data, & scripts for JPEG-2000 using wget
I compiled all scripts of the JPEG2000 algorithm as well as the Jasper application scripts following the included guides (as I compiled inside the virtual machine, I guarantee that the files were compiled for the RISC-V architecture)
I entered the jpg2000enc folder with the command:
$ cd jpg2000enc
I deleted the jpg2000 image already included in the output_base folder with the commands:
$ cd output_base
$ rm output_base_4CIF_96bps.jp2
I went back to the jpg2000enc folder with the command
$ cd ..
Finally I ran the command that runs Jasper for the image provided (input_base_4CIF.ppm) which is in the input_base folder with the command:
$ jasper -f ./input_base/input_base_4CIF.ppm -F ./output_base/output_base_4CIF_96bps.jp2 -T jp2 -O rate=0.010416667
I accessed the output_base folder to check if the jpg2000 file was generated successfully
$ cd output_base
$ ls
I saw that the file was generated successfully!
Note that everything ran perfectly!
Now the problem I'm failing to solve:
For the next steps of my homework, I need to log all the RISC-V instructions executed when I run the command:
$ jasper -f ./input_base/input_base_4CIF.ppm -F ./output_base/output_base_4CIF_96bps.jp2 -T jp2 -O rate=0.010416667
How can I trace all RISC-V instructions as they are translated by QEMU during execution of the presented command?
Ps: It's important to mention that I don't want to trace the x86 instructions that are actually executed by my processor when QEMU translates the RISC-V instructions of the jasper application, I really need the RISC-V instructions.

How to mount a rootfs using NFS to emulate ARM architecture on qemu?

I want to emulate ARM architecture on qemu. I followed instructions in this tutorial. First I compiled linux-5.5.17 kernel. The only difference between me and this tutorial was the CROSS_COMPILE variable. Mine was arm-linux-gnueabi-. Everything went as the same as this tutorial before building the filesystem.
I used buildroot-2020.02.1 to build rootfs. I ran command make qemu_vexpress_defconfig. Then I executed make menuconfig to set the root password, choose the ext4 root filesystem and set the compression method to "xz". I compiled this rootfs successfully. And I configure NFS following the tutorial above. But when I ran the command
qemu-system-arm -M vexpress-a15 \
-net tap -net nic -m 512 -kernel /home/myuser/linux-5.5.17/arch/arm/boot/zImage \
-dtb /home/myuser/linux-5.5.17/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dtb \
-append "console=tty1 root=/dev/nfs rw nfsroot=192.168.0.1:/home/myuser/armsystem/outfs ip=192.168.0.2:192.168.0.1:192.168.0.1:255.255.255.0:qemu:eth0"
Finally I got this result. I don't know whether there are some errors when building rootfs or configuring the network. I searched for some other tutorial to mount NFS rootfs, but it doesn't work for me.I wonder how I can successfully mount a rootfs to emulate ARM architecture on qemu.
Try adding ,vers=3,tcp to your nfsroot line, like this: nfsroot=192.168.0.1:/home/myuser/armsystem/outfs,vers=3,tcp.
Also the following step is incorrect in the tutorial: cp -r -d [buildroot]/output/target/* ~/armsystem/outfs. There's a file THIS_IS_NOT_YOUR_ROOT_FILESYSTEM in the output/target directory with an explanation why and what is the right thing to do.

QEMU debugging:: Warning:TCG doesn't support requested feature: CPUID.01H:ECX

I want to use QEMU to debug my compiled kernel linux-4.13.4 on Ubuntu 16.04.3 LTS
I follow the following steps:
1 install qemu
sudo apt-get install qemu
2 run qemu
qemu-system-x86_64 -s -S -kernel /home/wxf/kernelSources/linux-4.13.4/arch/x86_64/boot/bzImage -initrd /boot/initrd.img-4.13.4
Note:
-s shorthand for -gdb tcp::1234
-S freeze CPU at startup (use 'c' to start execution)
But I get the following warning:
warning: TCG doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
The terminal stops there and I cannot input other commands.
The QEMU window pops up when I run it but it is stopped.
So, my question is
How to eliminate the warning and is it normal(since it is not an error information)?
Frankly speaking, I don't know how to handle that warning, can it be ignored or have you to do something with it. But I suppose the main problem is that you cannot run the VM. If so, you need to properly determine where to enter that c to start the VM. :)
QEMU has several graphical interfaces (and AFAIK can even be run in plain console). Suppose we have identical defaults for which UI to use (probably, the GTK one). When I run similar command (qemu-system-x86_64 -s -S -kernel ...), I can switch to the monitor console of QEMU by pressing Ctrl+Alt+2 (just 2, not F2). There I press c (and Enter, it seems to behave like regular terminal) and then switch to the VM display by Ctrl+Alt+1.
I had this problem, or something very similar. It gave the same warning and, while it would then boot, it was unusably slow.
I fixed it it by adding -machine ubuntu,accel=kvm to the qemu-system-x86_64 command line.
You missed out giving the RAM size to be used by the VM. The default RAM allocated by qemu is 128M, which in your case was not sufficient, I guess. Try passing
-m 512
Source

How do I cross compile my Go program from Mac OS X to Ubuntu 64-bit

As the title says I'm wondering how to cross-compile my program so that I can run it on Ubuntu 64-bit
I've went into the /usr/local/go/src folder and ran
GOOS=linux GOARCH=amd64 ./make.bash --no-clean
everything compiled fine
then went into my project directory and ran go build -v -a and then took the compiled binary and moved it to my linux server, but when running it I get this error:
root#PanicCSGO40:~/test# ./test
-bash: ./test: cannot execute binary file: Exec format error
root#PanicCSGO40:~/test# sudo ./test
./test: 1: ./test: Syntax error: "(" unexpected
root#PanicCSGO40:~/test#
Not sure what I am doing wrong any information would be great thanks.
I've also tried doing it with GOARCH=386 but still get the same errors. Thanks!
This link does not solve my question because the chosen answer is a link to a blog post which relies heavily on doing all cross-compilation on using the blog writers bash scripts to do it, I just simply wanted to know what the correct way to do it was and now I do.
The build command needs to identify the target environment:
$ GOOS=linux GOARCH=amd64 go build -v /path/to/target/package

zssh can't start and shows "out of pty's" when start

In CentOS 6.5, yum install zssh, but when I execute zssh, it gives an error showing: out of pty's.
What does this mean? How to solve this?
You can see the list of used ptys with
ls /dev/pts
The maximum number of ptys is given by
cat /proc/sys/kernel/pty/max
That value can be configured in
/etc/sysctl.conf
(see man pty)
Note that some versions of the kernel were buggy.
The ptys, or pseudo terminals are the 'channels' through which a process interacts with the user console (keyboard and screen)
There seems to be some weird library mismatch bug that cropps up in some binary distributions. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=769366. Has not been tracked down, but a simple recompile seems to be a workaround.

Resources