qemu valid dtb and unrecognized/unsupported machine ID - raspbian

I am following this tutorial to run Raspbian on my Windows PC, but it does not work.
I renamed my system img and kernel to fit the command, but no success.
valid dtb and unrecognized/unsupported machine ID
r1=0x00000183, r2=0x00000100
r2[]=05 00 00 00 01 00 41 54 01 00 00 00 00 10 00 00
Available machine support:
ID (hex) NAME
ffffffff Generic DT based system
ffffffff ARM-Versatile (Device Tree Support)
The command I was executing:
qemu-system-arm -kernel kernel-qemu-4.4.34-jessie -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -drive "file=2017-03-02-raspbian-jessie.img,index=0,media=disk,format=raw"

You've cut off the first part of the error message, which is confusing. The full text is "Error: invalid dtb and unrecognized/unsupported machine ID".
What the kernel is trying to tell you here is that you must provide it with the correct device tree blob (dtb) file for the board you are running it on. Newer kernels can't boot without a dtb. You need to pass QEMU the correct file via its -dtb option, which in this case is "versatile-pb.dtb". That file should be built when you build the kernel from source, or if you got your kernel from somebody else they should also provide the dtb.

Related

How to unload an NVIDIA kernel module 'nvidia' for new driver installation?

I needed to upgrade my nvidia driver so that I have tried running NVIDIA-LInux-x86_64.run file
However, I was seeing following message
ERROR: An NVIDIA kernel module 'nvidia' appears to already be loaded in your kernel. This may be because it is in use (for example, by an X server, a CUDA program, or the NVIDIA Persistence Daemon), but this may also happen if your kernel was configured without support for module unloading. Please be sure to exit any programs that may be using the GPU(s) before attempting to upgrade your driver. If no GPU-based programs are running, you know that your kernel supports module unloading, and you still receive this message, then an error may have occured that has corrupted an NVIDIA kernel module's usage count, for which the simplest remedy is to reboot your computer.
I have already unloaded nvidia-drm and when I tried to unload nvidia
$ sudo modprobe -r nvidia
modprobe: FATAL: Module nvidia is in use.
Can anyone guide me on installing this new driver without any issue?
Thanks
Use lsof /dev/nvidia* to find the processes that are using the old driver. In my case it was "nvidia-persistenced". Just kill the process by pid and retry the installer NVIDIA-***.run
# lsof /dev/nvidia*
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nvidia-pe 1334 nvidia-persistenced 2u CHR 195,255 0t0 420 /dev/nvidiactl
nvidia-pe 1334 nvidia-persistenced 3u CHR 195,0 0t0 421 /dev/nvidia0
nvidia-pe 1334 nvidia-persistenced 5u CHR 195,0 0t0 421 /dev/nvidia0
nvidia-pe 1334 nvidia-persistenced 6u CHR 195,0 0t0 421 /dev/nvidia0
nvidia-pe 1334 nvidia-persistenced 7u CHR 195,0 0t0 421 /dev/nvidia0
I just removed existing driver and reinstalled

running gem5 with SPEC2006

when running GEM5 X86 in SE mode, I am trying to run bzip2 from SPEC2006, at first it was failing because it says it can't run dynamic execution so I compiled it with -static flag.
now I get this error:
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
gem5 compiled Oct 27 2018 00:36:02
gem5 started Dec 22 2018 18:16:40
gem5 executing on Dan
command line: ./build/X86/gem5.opt configs/example/se.py -c /home/dan/SPEC2006/benchspec/CPU2006/401.bzip2/exe/bzip2_base.ia64-gcc42 -i /home/dan/SPEC2006/benchspec/CPU2006/401.bzip2/data/test/input/dryer.jpg
Could not import 03_BASE_FLAT
Could not import 03_BASE_NARROW
Global frequency set at 1000000000000 ticks per second
warn: DRAM device capacity (8192 Mbytes) does not match the address range assigned (4096 Mbytes)
0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000
**** REAL SIMULATION ****
info: Entering event queue # 0. Starting simulation...
panic: Tried to write unmapped address 0xffffedd8. Inst is at 0x400da4
# tick 5500
[invoke:build/X86/arch/x86/faults.cc, line 160]
Memory Usage: 4316736 KBytes
Program aborted at tick 5500
Aborted (core dumped)
I am running gem5 on ubuntu 17.10.
I tried to find solutions in google but I didn't see any one referring to this problem, does anyone know how to fix the problem?
Please check your host machine configuration. Bzip2 does not work in a 32-bit machine. My desktop is dual core have 32-bit X86 architecture, I tried to run bzip2 it had shown same error.

How to set KVM VM use shadow page table?

I want to measure shadow page table performance vs EPT. I know in kvm code path, EPT and shadow page table share some code path. There is a switch to check if EPT is enabled.
So, I turn off EPT, I think this is a way to use shadow page table in KVM VM.
I exec some commands on host:
# cat /sys/module/kvm_intel/parameters/ept
Y //check if EPT is enabled, Yes it is
# rmmod kvm_intel
# modprobe kvm_intel ept=0,vpid=0 //Re-modprobe kvm_intel, but turn off EPT and VPID
# cat /sys/module/kvm_intel/parameters/ept
N // EPT is disabled
# cat /sys/module/kvm_intel/parameters/vpid
Y //VPID is still enabled
After these commads, I expect the EPT is disabled, However, I create a VM with 4 vcpu, but in VM, I use htop in VM only find i vcpu. I don't know why.
So, I turn on ept again, I can see 4 vcpu in vm using htop. But, on another server, I turn off ept, in VM, I still can find 4 vcpu.
In host, I test qemu thread num:
pstree -p | grep qemu
|-qemu-kvm(20594)-+-{qemu-kvm}(20612)
| |-{qemu-kvm}(20613)
| |-{qemu-kvm}(20614)
| |-{qemu-kvm}(20615)
| |-{qemu-kvm}(20618)
| `-{qemu-kvm}(23429)
There are still muti threads.
In KVM VM, I use lscpu to check:
# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0
Off-line CPU(s) list: 1-3
Thread(s) per core: 1
Core(s) per socket: 1
座: 1
NUMA 节点: 1
厂商 ID: GenuineIntel
CPU 系列: 6
型号: 62
型号名称: Intel(R) Xeon(R) CPU E5-2640 v2 # 2.00GHz
步进: 4
CPU MHz: 1999.999
BogoMIPS: 3999.99
超管理器厂商: KVM
虚拟化类型: 完全
L1d 缓存: 32K
L1i 缓存: 32K
L2 缓存: 4096K
NUMA 节点0 CPU: 0
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm fsgsbase tsc_adjust smep erms xsaveopt
VPID is still enabled cause your command format was incorrect
# modprobe kvm_intel ept=0 vpid=0(Use spaces instead of commas)

How do I configure crosstools-ng sample for cross compiling toolchain for my router?

I want to cross compile shadowsocks for my router ( netcore q3, made in china) on CentOS 7. So I got crosstools-ng, I ssh into the router, and get following info (The router is on a Tomato Firmware 1.28.0000 MIPSR2-131 K26 Max by shibby), I used How to build a cross compiler for your Raspberry Pi as my reference
$less /proc/cpuinfo
system type : Broadcom BCM53572 chip rev 1 pkg 8
processor : 0
cpu model : MIPS 74K V4.9
BogoMIPS : 149.50
cpu MHz : 300
wait instruction : no
microsecond timers : yes
tlb_entries : 32
extra interrupt vector : no
hardware watchpoint : yes
ASEs implemented : mips16 dsp
shadow register sets : 1
VCED exceptions : not available
VCEI exceptions : not available
unaligned_instructions : 0
I also copied a .so file from /lib
$ scp root#router:/lib/libc.so.0 .
[oglop#localhost tmp]$ readelf -h libc.so.0
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: MIPS R3000
Version: 0x1
Entry point address: 0x6d50
Start of program headers: 52 (bytes into file)
Start of section headers: 260672 (bytes into file)
Flags: 0x50001007, noreorder, pic, cpic, o32, mips32
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 5
Size of section headers: 40 (bytes)
Number of section headers: 18
Section header string table index: 17
files in /lib on the router
root#unknown:/tmp/home/root# ls /lib
ld-uClibc.so.0 libgcc_s.so.1 libutil.so.0
libc.so.0 libm.so.0 modules
libcrypt.so.0 libnsl.so.0 openvpn_plugin_auth_nvram.so
libdl.so.0 libpthread.so.0
Can I get all the information from these two? Which sample should I choose ?
So from the .so file :
endianness : little endian
bitness: ?
abi: ?
target os: linux or bare-metal?
c library: glibc, musl or uClibc ?
...
I guess I should starts with mips-unknown-linux-uclibc and change it to little endian ?
[oglop#localhost tmp]$ ct-ng list-samples | grep mips
[G.X] mips64el-n32-linux-uclibc
[G.X] mips64el-n64-linux-uclibc
[G..] mips-ar2315-linux-gnu
[G..] mipsel-sde-elf
[G..] mipsel-unknown-linux-gnu
[G..] mips-malta-linux-gnu
[G..] mips-unknown-elf
[G..] mips-unknown-linux-uclibc
root#unknown:/tmp/home/root# cat /proc/version
Linux version 2.6.22.19 (root#tomato) (gcc version 4.2.4) #16 Tue Aug 4 00:16:31 CEST 2015
I tried to figure out the libc version tomato uses, but
root#unknown:/tmp/home/root# /lib/libc.so.0
Segmentation fault
root#unknown:/tmp/home/root# ldd --version
-sh: --version: not found
Or Can I get the info I need from tomato source shibby branch on github?

readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

I build a program and it works well(I mean that I can run this program). But when I use "readelf" to check whether there is debug information,errors come:
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
readelf: Error: test/select: Failed to read file header
My linux distribution is Ubuntu-12. Somebody can help me?
It may not actually be an ELF executable file. There are plenty of things that will run that are not ELF files (such as shell scripts, Perl files, Python py source and pyc compiled files). There are even things that will "run" without having an individual identifiable file at all (aliases or functions in your shell, bash built-ins and such).
I would first execute:
file /path/to/your/file
to see what sort of file it actually is, such as with:
pax> file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
dynamically linked (uses shared libs), for GNU/Linux 2.6.26,
BuildID[sha1]=0xd3280633faaabf56a14a26693d2f810a32222e51,
stripped
Only if it's recognised as an ELF file should you try to treat it as such.
pax> readelf -h /bin/ls
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: Intel 80386
Version: 0x1
Entry point address: 0x804c1b4
Start of program headers: 52 (bytes into file)
Start of section headers: 111580 (bytes into file)
Flags: 0x0
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 9
Size of section headers: 40 (bytes)
Number of section headers: 28
Section header string table index: 27
For what it's worth, I have a backup script which executes just fine but which would fail your readelf assumption:
pax> file backup1.sh
backup1.sh: Bourne-Again shell script, ASCII text executable
pax> readelf -h backup1.sh
readelf: Error: Unable to read in 0x253a bytes of section headers
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
As to what you do when you find out it isn't ELF format, that depends on what you're trying to ascertain, something you haven't actually specified. If all you want to do is run readelf on it, that won't work unless it's an ELF format file.
If you want a particular piece of information about the executable file, you need to tell us both:
what type it is (from file for example); and
the information you want.