I have a laptop with Intel Core i5 M 450 # 2.40GHz which apparently has VT-x but not VT-d. I have Ubuntu 12.04 32bit but would like to have a virtual 64bit terminal-based Linux running on it. How do I know if the BIOS has this VT-x feature activated without having to reboot?
You can use rdmsr from msr-tools to read register IA32_FEATURE_CONTROL (address 0x3a). The kernel module msr has to be loaded for this.
On most Linux systems:
sudo modprobe msr
sudo rdmsr 0x3a
Values 3 and 5 mean it's activated.
You can use
sudo kvm-ok
from cpu-checker. On Intel, which has the most complicated logic, kvm-ok checks that if bit 0 of rdmsr 0x3a (the lock bit) is set, bit 2 (which allows virt use outside of SMX mode, something to do with trusted boot) must also be set. If the output of rdmsr 0x3a is anything but 1 or 3, you will be able to use kvm. kvm will set bit 2 of the msr if necessary, I expect virtualbox and the rest have the same logic.
Install cpu-checker and run "kvm-ok"
If the CPU is enabled, you should see something like:
INFO: /dev/kvm exists
KVM acceleration can be used
othewise
INFO: /dev/kvm does not exist
HINT: sudo modprobe kvm_intel
INFO: Your CPU supports KVM extensions
INFO: KVM (vmx) is disabled by your BIOS
HINT: Enter your BIOS setup and enable Virtualization Technology (VT),
and then hard poweroff/poweron your system
KVM acceleration can NOT be used
you can use:
sudo apt-get update
sudo apt-get install cpu-checker
kvm-ok
In linux you can check cpuinfo:
cat /proc/cpuinfo| egrep "vmx|svm"
I found that scai's answer doesn't work on my AMD Ryzen systems.
This however works really well for me, even on Intel:
if systool -m kvm_amd -v &> /dev/null || systool -m kvm_intel -v &> /dev/null ; then
echo "AMD-V / VT-X is enabled in the BIOS/UEFI."
else
echo "AMD-V / VT-X is not enabled in the BIOS/UEFI"
fi
(systool is found in the sysfsutils package on most distros.)
For Intel's VT-D / AMD's IOMMU, I came up with this solution:
if compgen -G "/sys/kernel/iommu_groups/*/devices/*" > /dev/null; then
echo "AMD's IOMMU / Intel's VT-D is enabled in the BIOS/UEFI."
else
echo "AMD's IOMMU / Intel's VT-D is not enabled in the BIOS/UEFI"
fi
(It even worked for me if the iommu kernel parameters are not set.)
A simple approach to confirm that Vt-D is enabled in the BIOS is through the Linux system. If the VT-D is enable in the BIOS and Iommu=on in the grub.cfg then the below folder structure is created automatically to hold the Virtual devices.
/sys/kernel/iommu_groups/0/devices/0000:00:00.0
Whereas if either one of the options VT-D or Iommu is not configured/enabled then the above mentioned folder structure is not created. This behavior is confirmed in CentOS 7.4 and Ubuntu. Hopefully this behavior is similar for other operating systems as well but this would need to be confirmed.
Related
I've built a kernel and root file system for the AT91SAM9260 with the following buildroot menu selections on "Filesystem Settings":
And the kernel build settings including the at91_dt_defconfig option.
buildroot's output folders contained the following images:
rootfs.cpio rootfs.ext2 rootfs.tar zImage
I've tried to boot using qemu with the following commands:
qemu-system-arm -machine virt -kernel zImage -initrd rootfs.cpio -hda rootfs.ext2 -append "console=ttyS0,115200 root=/dev/sda" -serial stdio
Which resulted in a blank qemu screen.
What am I doing wrong? Is it a qemu operation or buildroot configuration problem?
The problem is that a kernel will only boot on a piece of Arm hardware if it is compiled for that hardware. Otherwise it will generally fail, usually by crashing before it is able to output anything useful. This is because (unlike x86 systems), every embedded Arm board and SoC is different to every other one, with different devices, devices and RAM at different addresses, and so on. The QEMU "virt" board is not an AT91SAM9260, and will not run a kernel that is built for that SoC.
You can either:
build a kernel that is intended to run on the 'virt' board, and run it
write device models and an SoC model for QEMU for the SoC you're interested in (beware that this is a large amount of work; it's about as much effort as porting the Linux kernel and writing device drivers for the hardware would be; it also requires either having or learning quite a lot about QEMU's internals)
I'm trying to bring up a gem5 FullSystem (FS) simulation of Linux kernel 2.6.22.9 (as the binary was provided by gem5) and also with a custom Linux kernel 3.4.112 on a TimingSimpleCPU. While both of these work in a single core x86 FS simulated machine, they fail to boot up in a multi-core simulated machine.
I'm lost on how to even begin debugging. I have tried connecting to the remote gdb port provided by gem5 TimingSimpleCPU for each processor on ports 7000, 7001 and so on. I see that on a dual core boot up, after a point, core 0 gets stuck on schedule() call and core 1 always stays on idle() and never schedules() anything until core 0 also gets stuck on the schedule() call.
What is a proper way to go about debugging gem5 and its compatibility with Linux Kernel for multi core full system boot up on a TimingSimpleCPU X86 arch? I'm thinking there could be issues relating to spinlock support or the APIC.
X86 2 core Linux kernel 5.1, TimingSimpleCPU, gem5 08c79a194d1a3430801c04f37d13216cc9ec1da3 happened to work on this setup: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/6aa2f783a8a18589ae66e85f781f86b08abb3397#gem5-buildroot-setup-getting-started Boot completes and cat /proc/cpuinfo says 2 CPUs.
The final run command was:
./run --cpus 2 --emulator gem5 -- --cpu-type TimingSimpleCPU
Everything is specified in that repo, including how to build gem5, the Linux kernel, and how to run them.
Then, with a mere flick of a switch, the same works on aarch64 as well if you are curious:
./run --arch aarch64 --cpus 2 --emulator gem5 -- --cpu-type TimingSimpleCPU
I then added the options --caches --l2cache as per OP's comment, and now I reproduce the failure, to which I don't have a solution:
./run --cpus 2 --emulator gem5 -- --cpu-type TimingSimpleCPU --caches --l2cache
Boot hangs, the last terminal message is:
pci 0000:00:04.0: legacy IDE quirk: reg 0x1c: [io 0x0376]
and a bit above we can see the suspicious message:
[Firmware Bug]: CPU1: APIC id mismatch. Firmware: 1 APIC: 0
ARM boot with the extra options worked however:
./run --arch aarch64 --cpus 2 --emulator gem5 -- --cpu-type TimingSimpleCPU --caches --l2cache
However, I later tried with more cache options:
/run --arch aarch64 --emulator gem5 --cpu 2 --run-id 2 -- --cpu-type=HPI --caches --l2cache --l1d_size=64kB --l1i_size=64kB --l2_size=256kB
and it also failed as explained at: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/99180e6616331b7385b09147f11f67962f9facc4#gem5-arm-multicore-hpi-boot-fails ...
How to debug such problems to get things working in general is an extremely difficult problem that requires understanding enough Linux kernel + X86 ISA + gem5, where enough is undefined. This learning process is closely intertwined with enabling just the right log options / focusing on the right part of the code. That setup just happened to work out of "luck".
I need to run real time applications on Ubuntu RT Linux and was reading about ways to make linux act as RT system and I learned two ways to do it
preemptive_rt kernel patching
enabling CONFIG_RT_GROUP_SCHED flag in the kernel.
I've already tried my hands on 1st method Install RT Linux patch for Ubuntu
However, apart from uname -r showing #1 SMP PREEMPT RT I've no other proof that it is actually a RT system and hence want to try the 2nd method. Enable CONFIG_RT_GROUP_SCHED flag in the kernel and see its performance.
I read we can confirm if the kernel already has the flag by following command:
# zcat /proc/config.gz | grep RT_GROUP
CONFIG_RT_GROUP_SCHED=y
However, my system doesn't even have the config.gz file in proc, so I believe my kernel does not have this enabled.
I'm relatively new to linux kernels so this might be naive but how can I enable this in the kernel?
Step 1
Download linux kernel from https://www.kernel.org/pub/linux/kernel/. For the purpose of this PoC we downloaded linux-4.16.18.tar.gz kernel from above link.
Step 2
Unzip the kernel
$ tar -xzvf linux-4.16.18.tar.gz
Step 3
Move to kernel source directory
$ cd linux-4.16.18
Step 4
Install kernel build dependencies
$ sudo apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache bison flex
Step 5
Run kernel configuration
$make menuconfig
Step 6
Go to General setup ─> Control Group Support ─> CPU controller ─> Group scheduling for SCHED_RR/FIFO configuration as shown below:
Go to General setup ─> Kernel .config support and enable access to .config through /proc/config.gz
Step 7
Compile the kernel
$ make -j20
Make modules & install
$ sudo make modules_install -j20
$ sudo make install -j20
Step 8
Open the grub.cfg file to verify if kernel is installed
$ vim /boot/grub/grub.cfg
Look for the menuentry with menuentry 'Ubuntu, with Linux linux-4.16.18'
If it's not your default kernel then change the GRUB_DEFAULT=0 value to your kernel
Step 9
Reboot your system
sudo reboot
Step 10
Verify the system by the following command:
# zcat /proc/config.gz | grep RT_GROUP
CONFIG_RT_GROUP_SCHED=y
I am facing problem with interrupt in guest OS runing in qemu-2.3.0.
I am loading windriver (Linux kernel-2.6.34.12-grsec) in -nographic mode in Qemu emulator on Ubuntu 14.04 host.
Host details:
>$ uname -a
>$ Linux my-qemu-host 3.13.0-52-generic #86-Ubuntu SMP Mon May 4 04:32:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
my command line is:
>$ qemu-system-x86_64 -enable-kvm -nographic -k en-us -kernel ${KERNEL} -cpu kvm64 -smp 4 -m 1G ${NETCFG} -gdb tcp::1234 -append "console=ttyS0,115200 ip=dhcp root=/dev/nfs nfsroot=${NFSROOT}" -hda /home/hda
I am getting following logs in /var/log/kern.log
kernel: serial8250: too much work for irq4
I searched to get rid of this but so many people are suggesting to increase PASS_LIMIT in /serial/8250.c file. this workaround is just avoiding error messages in kern.log file.
Any one having idea how to stop or slow down interrupt frequency?
What exactly are you running i.e. what sort of build? It appears that some hefty serial work is going on (which is expected with embedded).
I just googled how to disable the kernel module for the serial8250 to see if that would help and happened upon this:
http://www.spinics.net/lists/linux-serial/msg12360.html
Another thought, seeing as windriver (if it's this: http://www.windriver.com/products/linux/) then I wouldn't be shocked if a "serial console" is automatically enabled. This too could drive s/w interrupt watchdogs to blacklist them as the can spam quite a bit of info depending on what they're set to output.
Sorry, it's just totally a random guess, but I'm going by pure experience with embedded serial device fun (MIPS) and (ARM) past experiences with generic distros
I am a beginner learning linux kernel module development. I am following a tutorial that says to recompile my kernel so as to enable various debugging features like forced module unloading e.t.c. Is is okay if I do that? Does it effects my pre-built kernel. In what cases that I am forced to insert a module into a running kernel and the kernel won't allow me to do so?
It is perfectly okay to compile and install a kernel to do kernel module development. If you are in ubuntu, you can follow the following steps to make sure that you are using the same kernel sources as your booted machine.
Step 1. Find out the linux being used in your booting from /boot/grub/grub.cfg file. Look for the entry agains 'linux ' in the boot option entries that you select while booting up.
Example excerpt : linux /boot/vmlinuz-3.13.0-24-generic root=UUID=e377a464-92db-4c07-86a9-b151800630c0 ro quiet splash $vt_handoff
Step 2. Look for the name of the package with the same version using the following command.
dpkg -l | grep linux | grep 3.13.0-24-generic
Example output:
$ dpkg -l | grep linux | grep 3.13.0-24-generic
ii linux-headers-3.13.0-24-generic 3.13.0-24.46 amd64 Linux kernel headers for version 3.13.0 on 64 bit x86 SMP
ii linux-image-3.13.0-24-generic 3.13.0-24.46 amd64 Linux kernel image for version 3.13.0 on 64 bit x86 SMP
ii linux-image-extra-3.13.0-24-generic 3.13.0-24.46 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP
Step 3. Download sources of the package "linux-headers-3.13.0-24-generic" to get the same kernel that was used in your PC.
$ apt-get source linux-headers-3.13.0-24-generic
Step 4. Use the config file that is available at /boot/ folder as the config file to compile this kernel source
Example :
$ ls /boot/config-3.13.0-24-generic (Notice the same version used in this file)
Step 5. Turn on your debugging symbols on this config to do your testing.
Recompiling kernel help us to learn how kernel work.
latest kernel patches can be applied through kernel compile and install.
We can enable debug flag through compilation.
We can remove the not needed code.
Helps to add your own kernel code and test your code.
It is easy to recompile and install the linux kernel but it takes more time if we compile using low speed computer or VM.