NVIDIA GPU Passthrough on an Optimus MUXed Laptop (Updated 2023-05)

A year ago, to simultaneously browse webpages and write codes on my Arch Linux installation and use Windows to run tasks infeasible on Linux (such as gaming), I tried GPU passthrough on my Lenovo R720 gaming laptop. But since that laptop has an Optimus MUXless architecture (as mentioned in that post), its dedicated GPU doesn't have output ports, and the integrated GPU is in charge of all the displays. Therefore, severe limitations exist for that setup, and I eventually gave up on it.But now, I've purchased a new laptop. The HDMI output port on this laptop is directly connected to its NVIDIA dedicated graphics card, or in other words, it has an Optimus MUXed architecture. Since there is a way to make the virtual machine aware of a "monitor on the dedicated GPU",...
Illustration

NixOS Series 4: "Stateless" Operating System

List of NixOS Series Posts:NixOS Series 1: Why I fell in loveNixOS Series 2: Basic Config, Nix Flake & Batch DeployRecommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan YinNixOS Series 3: Software Packaging 101NixOS Series 4: "Stateless" Operating SystemChangelog:2023-02-18: Fix config not applied to the root user, in the "Move Temp Directory of Nix Daemon" section.One of the most famous features of NixOS is that most software configurations on the system are generated and managed exclusively by a Nix-language config file. Even if such software modifies its config file while running, the config file will still be overwritten on the next Nix config switch or the next reboot.For example, if you run ls -alh /etc on a computer running NixOS,...
Illustration

NixOS Series 3: Software Packaging 101

List of NixOS Series Posts:NixOS Series 1: Why I fell in loveNixOS Series 2: Basic Config, Nix Flake & Batch DeployRecommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan YinNixOS Series 3: Software Packaging 101NixOS Series 4: "Stateless" Operating SystemOne characteristic of NixOS is that all binary applications and libraries are stored in /nix/store directory and managed by Nix package manager. This means that NixOS doesn't conform to the FHS standard of Linux, and there's not even a dynamic library loader like ld-linux-x86-64.so.2 in /lib or /lib64, let alone other shared libraries like libc.so. Therefore, unless the program is statically linked, binaries compiled for other Linux distros will not run on NixOS at all.Therefore,...

Reverse Engineered Linux Driver for HP OMEN Macro Keys

I got a new laptop some time ago, an HP OMEN 17t-ck000. While it's a nice laptop with excellent build quality and performance, it has one problem: it's drivers under Linux are far from complete.No support for fan speed control. You can see the fan speed but that's it. In addition, HP's default fan control strategy is very agressive, in the sense that even with fan spin down enabled in BIOS, the fan keeps running with the CPU being around 40 degrees celsius and GPU being idle.Actually, NBFC can be used to control the fan speed by directly writing to EC registers, but in an unfortunate accident I lost my configuration file.I was trying NixOS on my new laptop when I set up NBFC. When the accident happened, I had removed NixOS from the laptop,...
Illustration

Intel and NVIDIA GPU Passthrough on a Optimus MUXless Laptop

Changelog2022-07-21: Add starting GVT-g on startup. Thanks to comment from Owsmyf (on Chinese version of this post).2022-01-22: Revisions on NVIDIA driver updates and comments.I successfully passed through an Optimus MUXed GPU on my new laptop.Abstract (Spoiler Alert!)I successfully passed through Intel's GVT-g virtual GPU, as well as the dedicated NVIDIA GPU itself, into a virtual machine on Lenovo R720 gaming laptop.However, due to the limitation of the architecture itself, this GPU passthrough scheme is severely limited. For example, the dGPU is unusable in many games, and the performance is still relatively worse despite the complicated setup it needs.Therefore, you may attempt the passthrough purely for the fun of tinkering, but I don't recommend using it for anything important....
Illustration

Graduation Design - Sensor Network Development Log

Welcome to my third development log. In the two previous logs, I discussed the pitfalls I met in the RoboMaster competition and FPGA course final project.This time I will be talking about my graduate design project, an air quality sensor network built by a 3-person group. The whole project is structured as follow:Obtain data from installed sensor modules and upload them to InfluxDB running on a serverSensors we used:MiCS6814, measures NO2, CO, and NH3Analog outputBME680, measures temperature, humidity, atmospheric pressure, and TVOCI2C interfacePMS5003, measures particle mattersUART serial outputExtra modules:ATGM336H, global positioning module with GPS+BeiDou supportUART serial outputESP8266, a widely used Wi-Fi moduleUART serial outputMH-CD42,...

(Almost) Lossless Archival with Modern Formats - H265 and HEIF

Many people keep their inventory of photos and videos for their travels, parties, or whatever important moments of their lives. If you are into taking photos and recording videos and like keeping all of them, you will likely fill up hard drives after hard drives. If you don't want to keep adding more drives to your collection, you may also try to compress your photos and videos.Speaking of compression, a common method is to reduce the resolution of images. I've used the good old Microsoft Office Picture Manager (that comes with Office 2003) and its built-in one-key image compression. Behind the scenes, it's actually downsampling images to JPEG files of around 1024x768. One major drawback is that a lot of the details are completely lost....
Illustration

OS/2 Warp 4: Trying out & Installing Firefox

OS/2 is an operating system initially developed by IBM and Microsoft and later maintained by IBM. Back in the 1990s, OS/2 was a competitive rival to Windows, but later OS/2 was defeated by the Windows series, and IBM finally shut down OS/2 Warp 4's tech support on Dec 31, 2006.But this does not mark the death of OS/2. After official tech support ended, Senerity System took over OS/2's development and continued it under the name eComStation. In 2015, another company, Arca Noae LLC, produced an OS/2 based distribution called ArcaOS, and sold it as a commercial product.At the same time, the open-source community is providing some support to OS/2. They cross-compiled common Unix tools (including ls, rm, etc.), RPM/YUM package manager, and a series of libraries on OS/2....

Cyclone IV FPGA Development Log

Last semester, the school offered a digital systems course, which involves development on FPGAs. At the end of the course, we need to gather in groups and achieve some complicated functionality with the flexible architecture of FPGA, such as creating a game or running a convoluted neural network. We are free to add extra functionalities as we wish.Our group has done a game similar to Raiden, or controlling a fighter jet and attacking enemies with bullets. In addition to course requirements, we implemented these extra functionalities:A 640x480 VGA framebuffer with 16-bit color depth, stored on SRAM chipNaturally, Simplified Chinese fonts are included (full UTF-8 Chinese range, but without punctuation marks, since they are out of that range and we're kinda lazy)...
Illustration

Writing Stories in Traceroute

2020-10-11 UpdateNow a better way exists that doesn't involve a bunch of Docker containers. Please refer to Writing Stories in Traceroute, Elegantly.IntroTraceroute is one of the popular tools for network inspection. It shows the IP addresses of routers on the route from your computer to a destination server, similar to:Domains are shown on the last 2 hops, which is the IP's reverse DNS record. Reverse DNS records exist as PTR records in the format of 4.3.2.1.in-addr.arpa. For more information, you may refer to Setting IP Reverse Records in DN42 (Chinese Only).However, PTR records need not be real domains. They can be any string that "looks like" a domain. With this, we can write one sentence on each hop of a Traceroute path to make a story:This story is set up in DN42....