WorkingTipsOnProxmoxGVTG

Change configuration

Change grub options:

# vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
TO
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt i915.enable_gvt=1"

# vi /etc/modules
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
kvmgt

Update:

# update-grub2
# update-initramfs -u -k all

Check status:

Check iommu features:

# dmesg | grep -e DMAR -e IOMMU -e AMD-Vi
# find /sys/kernel/iommu_groups/ -type l

Get the VGA related:

root@pve:~# lspci | grep -i vga
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
root@pve:~# ls /sys/bus/pci/devices/0000\:00\:02.0/mdev_supported_types/
i915-GVTg_V5_4	i915-GVTg_V5_8

vm installation

Create a vm (win7) like:

/images/2022_09_30_10_01_06_720x245.jpg

/images/2022_09_30_10_02_04_724x216.jpg

Add PCI device:

/images/2022_09_30_10_03_54_614x173.jpg

hardware:

/images/2022_09_30_10_04_22_961x349.jpg

Then install the windows in console.

Install “Jianjizhi” and test usage.

/images/2022_09_30_10_30_50_943x660.jpg

Install intel video:

/images/2022_09_30_10_31_52_599x404.jpg

/images/2022_09_30_10_32_15_427x337.jpg

Select Install this driver software anyway:

/images/2022_09_30_10_32_37_549x382.jpg

Select reboot this computer now:

/images/2022_09_30_10_33_49_438x342.jpg

Status:

/images/2022_09_30_10_43_27_657x467.jpg

WorkingtipsOnXenGT

hardware

hardware:

$ cat /proc/cpuinfo | grep model
model		: 60
model name	: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
$ free -g
             total       used       free     shared    buffers     cached
Mem:            30          1         29          0          0          0
-/+ buffers/cache:          0         30
Swap:            0          0          0
dash@ubuntu1404:~$ cat /etc/issue
Ubuntu 14.04.5 LTS \n \l

dash@ubuntu1404:~$ uname -a
Linux ubuntu1404 4.4.0-31-generic #50~14.04.1-Ubuntu SMP Wed Jul 13 01:07:32 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Install ubuntu14.04, change repository to mirrors.ustc.edu.cn, then install packages:

# apt-get install libarchive-dev libghc-bzlib-dev  zlib1g-dev mercurial gettext bcc iasl uuid-dev libncurses5-dev kpartx bc libperl-dev libgtk2.0-dev libc6-dev-i386 libaio-dev libsdl1.2-dev nfs-common libyajl-dev libx11-dev autoconf libtool xsltproc bison flex xutils-dev xserver-xorg-dev x11proto-gl-dev libx11-xcb-dev vncviewer libxcb-glx0 libxcb-glx0-dev libxcb-dri2-0-dev libxcb-xfixes0-dev bridge-utils python-dev bin86 git vim libssl-dev pciutils-dev tightvncserver ssh texinfo -y

Check

Before install driver:

/images/2022_09_29_10_00_16_732x530.jpg

Install driver:

/images/2022_09_29_10_06_34_519x420.jpg

Restart the machine, check the driver status:

LinuxTips15

1. x11docker

Start and specify vt:

# x11docker --gpu --vt=2 --xorg x11docker/mate

With internet and more features:

# x11docker --gpu --vt=2 --network --desktop --init=systemd x11docker/deepin

2. git without ssl check

via:

export GIT_SSL_NO_VERIFY=1
git clone https://xxxx.xx

RaspberryPI_PKVM_WorkingTips

Flash aosp 13 images

Image download URL:
https://konstakang.com/devices/rpi4/AOSP13/

Flash it into rpi 4b.

pkvm kernel/images

Download alpine kernel/images from(https://www.worldofgh0st.com/blog/):

https://www.worldofgh0st.com/wp-content/uploads/2022/09/KVM-Linux.zip

adb push them to /data/local/tmp.

Start crosvm machine

adb root and login with adb shell:

➜  Downloads adb -s 192.168.1.114:5555 root 
restarting adbd as root
➜  Downloads adb -s 192.168.1.114:5555 shell
rpi4:/ # 

Start the crosvm vm and examine the vm info:

rpi4:/ # /apex/com.android.virt/bin/crosvm run --disable-sandbox -p 'init=/bin/sh' --rwroot /data/local/tmp/alpine.img /data/local/tmp/kernel.img

..............

/ # uname -a
Linux (none) 5.19.0-13666-gffcf9c5700e4 #3 SMP PREEMPT Sat Sep 3 15:11:04 PDT 2022 aarch64 Linux
/ # cat /etc/issue
Welcome to Alpine Linux 3.16
Kernel \r on an \m (\l)

Customize Kernel

In an arm64 server, clone the latest kernel and compile Image:

# apt install build-essential flex bison libssl-dev -y
# git clone  git://mirrors.ustc.edu.cn/linux.git
# cd linux
# make defconfig
# make -j128
# ls arch/arm64/boot
dts  Image  Image.gz  install.sh  Makefile

Transfer the Image to rpi4’s /data/local/tmp/

Customize Ubuntu20.04 rootfs

Get the latest aarch64 image and change the corresponding items:

# axel https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-arm64-root.tar.xz
# qemu-img create -f raw ubuntu.img 6G
# mkfs.ext4 ubuntu.img
# mount ubuntu.img /mnt
# tar xJvf ubuntu-20.04-server-cloudimg-arm64-root.tar.xz -C /mnt/
# cd /mnt
# touch etc/cloud/cloud-init.disabled
# vim etc/passwd
Change the first line :   
root::0:0:root:/root:/bin/bash
# umount /mnt

Transfer the ubuntu.img onto the rpi4’s /data/local/tmp/

Start ubuntu vm

Start via:

# /apex/com.android.virt/bin/crosvm run --disable-sandbox -p 'root=/dev/vda' --rwroot /data/local/tmp/ubuntu.img /data/local/tmp/Image

Examine the vm info:

root@ubuntu:~# uname -a
Linux ubuntu 6.0.0-rc4-00062-g0066f1b0e275 #1 SMP PREEMPT Thu Sep 8 01:24:14 EDT 2022 aarch64 aarch64 aarch64 GNU/Linux
root@ubuntu:~# cat /etc/issue
Ubuntu 20.04.4 LTS \n \l

root@ubuntu:~# free -m
              total        used        free      shared  buff/cache   available
Mem:            221          88          17           0         115         127
Swap:             0           0           0
root@ubuntu:~# cat /proc/cpuinfo
processor	: 0
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

WorkingTipsOnUpgradingSG1DriverCentOS1810.qcow2

VM

Import new image:

/images/2022_08_29_10_25_29_498x422.jpg

Name it:

/images/2022_08_29_10_26_09_467x332.jpg

Upgrade kernel to 4.19.12:

$ ls
kernel-4.19.12-1.x86_64.rpm  kernel-devel-4.19.12-1.x86_64.rpm  kernel-headers-4.19.12-1.x86_64.rpm  kmod-ukmd-4.19.12-20212.el7.x86_64.rpm
$ rpm -ivh *.rpm
$ vi /etc/default/grub
Changed to 4.19.12 kernel
$ grub2-mkconfig -o /boot/grub2/grub.cfg 
$ sudo reboot

Change the repository using iso:

# mount /dev/sr0 /mnt
# cat /etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt
enabled=1
gpgcheck=0
# yum makecache

Using official install-sg1.sh for installing to 4.19.112 kernel for fetching the dependencies.

Merge steps

安装官方驱动的过程中会编译出相应的文件,需要按照以下步骤进行更改:

# mkdir /root/merge
# cp /root/rpmbuild/SRPMS/kmod-ukmd-4.19.112-20413.el7.centos.src.rpm /root/merge
# cd /root/merge
# mkdir kmod-ukmd-4.19.12.cpio
# cd kmod-ukmd-4.19.12.cpio
# rpm2cpio ../kmod-ukmd-4.19.112-20413.el7.centos.src.rpm | cpio -idmv
# ls
dg1_dmc_ver2_02.bin  dg1_guc_49.0.1.bin  dg1_huc_7.9.5.bin  kmod.spec  kmod-ukmd-4.19.112.tar.gz
# tar xzvf kmod-ukmd-4.19.112.tar.gz
# mv kmod-ukmd-4.19.112 kmod-ukmd-4.19.12
# vim kmod.spec 
Change 4.19.112->4.19.12
# vim kmod-ukmd-4.19.12/kmod.spec
Change 4.19.112->4.19.12
# cp /usr/src/kernels/4.19.12/drivers/gpu/drm/drm_edid.c kmod-ukmd-4.19.12/orig/drivers/gpu/drm/
# cp /usr/src/kernels/4.19.12/drivers/gpu/drm/drm_probe_helper.c kmod-ukmd-4.19.12/orig/drivers/gpu/drm/
# cp /usr/src/kernels/4.19.12/drivers/gpu/drm/drm_vblank.c kmod-ukmd-4.19.12/orig/drivers/gpu/drm/
# mv kmod-ukmd-4.19.112.tar.gz /tmp
# tar czvf kmod-ukmd-4.19.12.tar.gz kmod-ukmd-4.19.12
# rm -rf kmod-ukmd-4.19.12
# ls
dg1_dmc_ver2_02.bin  dg1_guc_49.0.1.bin  dg1_huc_7.9.5.bin  kmod.spec  kmod-ukmd-4.19.12.tar.gz
# cd ..
# tar czvf kmod-ukmd-4.19.12.cpio.tar.gz kmod-ukmd-4.19.12.cpio
# ls
kmod-ukmd-4.19.112-20413.el7.centos.src.rpm  kmod-ukmd-4.19.12.cpio  kmod-ukmd-4.19.12.cpio.tar.gz
# mv /root/rpmbuild/SOURCES/ /root/rpmbuild/SOURCES.back && mkdir -p /root/rpmbuild/SOURCES/
# cp -ar /root/merge/kmod-ukmd-4.19.12.cpio/* /root/rpmbuild/SOURCES
# cd /root/rpmbuild/SOURCES
# vim /usr/src/kernels/4.19.12/include/linux/math64.h
在文件末尾倒数第二行添加
.....
    #endif /* mul_u64_u32_div */
    +++++ #define DIV64_U64_ROUND_UP(ll, d)	\
    +++++	({ u64 _tmp = (d); div64_u64((ll) + _tmp - 1, _tmp); })
    
    #endif /* _LINUX_MATH64_H */

# rpmbuild -bb kmod.spec
# ls /root/rpmbuild/RPMS/x86_64
kmod-ukmd-4.19.12-20413.el7.centos.x86_64.rpm

Verification

Install any 4.19.12 kernel, test the package kmod-ukmd-4.19.12-20413.el7.centos.x86_64.rpm.

$ ls /dev/dri/
card0  renderD128
$ lsmod | grep i915
i915_spi               20480  0 
mtd                    57344  5 i915_spi
i915                 1933312  0 
drm_ukmd_kms_helper   188416  1 i915
drm_ukmd              495616  3 drm_ukmd_kms_helper,i915
drm_ukmd_compat        98304  3 drm_ukmd_kms_helper,i915,drm_ukmd
video                  40960  1 i915
i2c_algo_bit           16384  1 i915
cec                    45056  1 i915
mfd_core               16384  2 lpc_ich,i915

Examine the kernel demsg:

$ sudo dmesg | grep drm
[sudo] password for ctctest: 
[    7.776406] drm: loading out-of-tree module taints kernel.
[    7.800836] Initialized drm/i915 compat module 20160105
[    7.892916] [drm] i915 backporting
[    7.893701] [drm] Intel graphics LMEM: [mem 0x00000000-0x1fb7fffff]
[    7.893702] [drm] Intel graphics LMEM IO start: a00000000
[    7.893702] [drm] Intel graphics LMEM size: 1fb800000
[    7.893714] [drm] Intel graphics stolen LMEM: [mem 0x1fc000000-0x1ffffffff]
[    7.893714] [drm] Intel graphics stolen LMEM IO start: bfc000000
[    7.895015] i915 0000:07:00.0: [drm] Couldn't get system memory bandwidth
[    7.895053] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    7.895054] [drm] Driver supports precise vblank timestamp query.
[    7.971850] i915 0000:07:00.0: [drm] Finished loading DMC firmware i915/dg1_dmc_ver2_02.bin (v2.2)
[    7.994442] [drm] GuC communication enabled
[    7.999403] i915 0000:07:00.0: [drm] GuC firmware i915/dg1_guc_49.0.1.bin version 49.0 submission:disabled
[    7.999405] i915 0000:07:00.0: [drm] HuC firmware i915/dg1_huc_7.9.5.bin version 7.9 authenticated:yes
[    8.001958] [drm] Initialized i915 1.6.0 20220718-8a58be7 for 0000:07:00.0 on minor 0
[    8.003950] i915 0000:07:00.0: [drm] Cannot find any crtc or sizes