Skip to content

Instantly share code, notes, and snippets.

@wjy20030407
Last active March 9, 2024 12:52
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save wjy20030407/f0b3658d56e8dec043614a6bdebed929 to your computer and use it in GitHub Desktop.
Save wjy20030407/f0b3658d56e8dec043614a6bdebed929 to your computer and use it in GitHub Desktop.
SER6 Pro Vest 7735HS

SER6 Pro Vest 7735HS

环境信息

BIOS: EC-ARB20A-1.15-T01

Proxmox VE: 7.3-1

修复安装引导 Xorg

Xorg -configure
cp /xorg.conf.new /etc/X11/xorg.conf
sed -i 's/amdgpu/fbdev/g' /etc/X11/xorg.conf
startx

删除 local-lvm 合并到 local

lvremove pve/data
lvextend -l +100%FREE -r pve/root

AMD Radeon 680M 核显直通给 Windows 11 虚拟机

Windows 11: Build 25300

virtio-win: 0.1.229

AMD Ryzen™ 7 7735HS Drivers: Adrenalin 23.3.1

  1. 编辑 kernel commandline
sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="quiet iommu=pt initcall_blacklist=sysfb_init"/g' /etc/default/grub
update-grub
  1. 添加内核模块
cat >>/etc/modules <<EOF
vfio
vfio_iommu_type1
vfio_pci
vfio_virqfd
EOF
  1. 添加驱动黑名单
cat >>/etc/modprobe.d/pve-blacklist.conf <<EOF
blacklist amdgpu
blacklist snd_hda_intel
EOF
  1. 将显卡绑定至 vfio-pci,其中显卡是 1002:1681,声卡是 1002:1640
cat >/etc/modprobe.d/vfio.conf <<EOF
options vfio-pci ids=1002:1681,1002:1640
EOF
  1. 刷新 initramfs 并重启 Proxmox VE
update-initramfs -u -k all
reboot
  1. 获取 vBIOS

编译 vBIOS 获取工具

点击展开
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

typedef uint32_t ULONG;
typedef uint8_t UCHAR;
typedef uint16_t USHORT;

typedef struct {
    ULONG Signature;
    ULONG TableLength; // Length
    UCHAR Revision;
    UCHAR Checksum;
    UCHAR OemId[6];
    UCHAR OemTableId[8]; // UINT64  OemTableId;
    ULONG OemRevision;
    ULONG CreatorId;
    ULONG CreatorRevision;
} AMD_ACPI_DESCRIPTION_HEADER;

typedef struct {
    AMD_ACPI_DESCRIPTION_HEADER SHeader;
    UCHAR TableUUID[16]; // 0x24
    ULONG VBIOSImageOffset; // 0x34. Offset to the first GOP_VBIOS_CONTENT block from the beginning of the stucture.
    ULONG Lib1ImageOffset; // 0x38. Offset to the first GOP_LIB1_CONTENT block from the beginning of the stucture.
    ULONG Reserved[4]; // 0x3C
} UEFI_ACPI_VFCT;

typedef struct {
    ULONG PCIBus; // 0x4C
    ULONG PCIDevice; // 0x50
    ULONG PCIFunction; // 0x54
    USHORT VendorID; // 0x58
    USHORT DeviceID; // 0x5A
    USHORT SSVID; // 0x5C
    USHORT SSID; // 0x5E
    ULONG Revision; // 0x60
    ULONG ImageLength; // 0x64
} VFCT_IMAGE_HEADER;

typedef struct {
    VFCT_IMAGE_HEADER VbiosHeader;
    UCHAR VbiosContent[1];
} GOP_VBIOS_CONTENT;

int main(int argc, char** argv)
{
    FILE* fp_vfct;
    FILE* fp_vbios;
    UEFI_ACPI_VFCT* pvfct;
    char vbios_name[0x400];

    if (!(fp_vfct = fopen("/sys/firmware/acpi/tables/VFCT", "r"))) {
        perror(argv[0]);
        return -1;
    }

    if (!(pvfct = malloc(sizeof(UEFI_ACPI_VFCT)))) {
        perror(argv[0]);
        return -1;
    }

    if (sizeof(UEFI_ACPI_VFCT) != fread(pvfct, 1, sizeof(UEFI_ACPI_VFCT), fp_vfct)) {
        fprintf(stderr, "%s: failed to read VFCT header!\n", argv[0]);
        return -1;
    }

    ULONG offset = pvfct->VBIOSImageOffset;
    ULONG tbl_size = pvfct->SHeader.TableLength;

    if (!(pvfct = realloc(pvfct, tbl_size))) {
        perror(argv[0]);
        return -1;
    }

    if (tbl_size - sizeof(UEFI_ACPI_VFCT) != fread(pvfct + 1, 1, tbl_size - sizeof(UEFI_ACPI_VFCT), fp_vfct)) {
        fprintf(stderr, "%s: failed to read VFCT body!\n", argv[0]);
        return -1;
    }

    fclose(fp_vfct);

    while (offset < tbl_size) {
        GOP_VBIOS_CONTENT* vbios = (GOP_VBIOS_CONTENT*)((char*)pvfct + offset);
        VFCT_IMAGE_HEADER* vhdr = &vbios->VbiosHeader;

        if (!vhdr->ImageLength)
            break;

        snprintf(vbios_name, sizeof(vbios_name), "vbios_%x_%x.bin", vhdr->VendorID, vhdr->DeviceID);

        if (!(fp_vbios = fopen(vbios_name, "wb"))) {
            perror(argv[0]);
            return -1;
        }

        if (vhdr->ImageLength != fwrite(&vbios->VbiosContent, 1, vhdr->ImageLength, fp_vbios)) {
            fprintf(stderr, "%s: failed to dump vbios %x:%x\n", argv[0], vhdr->VendorID, vhdr->DeviceID);
            return -1;
        }

        fclose(fp_vbios);

        printf("dump vbios %x:%x to %s\n", vhdr->VendorID, vhdr->DeviceID, vbios_name);

        offset += sizeof(VFCT_IMAGE_HEADER);
        offset += vhdr->ImageLength;
    }

    return 0;
}
gcc vbios.c -o vbios
./vbios
mv vbios_1002_1681.bin /usr/share/kvm/
  1. 配置 Windows 11 虚拟机

直接挂载镜像并添加 TPM v2.0 提示设备不受支持无法安装。这里采用 Rufus 烧录镜像干掉 TPM 直通 U 盘给虚拟机安装。

创建虚拟机时,BIOS 选择 SeaBIOS,Machine 选择 q35,Disks Bus/Device 选择 SCSI 并勾选 Discard 和 SSD emulation,Network Model 选择 VirtIO。

安装完成后在 Windows 虚拟机内启用远程桌面并关机。

在虚拟机配置页面添加 PCI Device 选择 0000:74:00.0(显卡)并勾选 Primary GPU 和 PCI-Express,再添加一个 0000:74:00.1 (声卡)。将 Display 的 Graphic card 修改为 none。直通你的键盘和鼠标。

编辑 /etc/pve/qemu-server/.conf,在显卡后追加 romfile=vbios_1002_1681.bin。

sed -i 's/0000:74:00.0,pcie=1,x-vga=1/0000:74:00.0,pcie=1,x-vga=1,romfile=vbios_1002_1681.bin/g' /etc/pve/qemu-server/<VM ID>.conf

启动虚拟机,通过远程桌面连接后下载驱动程序并安装(安装时选择 Driver Only)。

至此,核显直通流程基本完成。后续虚拟机每次关机之前须通过远程桌面手动弹出显卡及声卡,否则会导致 Proxmox VE 强制重启!

@wangzexi
Copy link

wangzexi commented Apr 28, 2023

lvmremove pve/datea

@wjy20030407
Copy link
Author

lvmremove pve/datea

Thank you for correcting it.

@zncs520
Copy link

zncs520 commented May 1, 2023

QQ图片20230501222405
QQ图片20230501222353

发B站 大大帅666 个开机就能显示的方案。

@cfboss
Copy link

cfboss commented May 3, 2023

image

奇怪了

@cfboss
Copy link

cfboss commented May 3, 2023

能贴一份 最终的conf吗

@wangzexi
Copy link

wangzexi commented May 8, 2023

@cfboss 主机PVE 7.4-3,虚拟机Windows 10,直通成功。
但是似乎虚拟机重启会连带PVE主机一起重启,目前没找到什么解决方案。

boot: order=scsi0;ide2;net0;ide0
cores: 4
cpu: host
hostpci0: 0000:74:00.0,pcie=1,x-vga=1,romfile=vbios_1002_1681.bin
hostpci1: 0000:74:00.1
ide0: local:iso/virtio-win-0.1.229.iso,media=cdrom,size=522284K
ide2: local:iso/SW_DVD9_Win_Pro_10_22H2_64BIT_ChnSimp_Pro_Ent_EDU_N_MLF_X23-20012.ISO,media=cdrom,size=5813860K
machine: pc-q35-7.2
memory: 8096
meta: creation-qemu=7.2.0,ctime=1683566159
name: Windows10
net0: virtio=56:4D:C1:59:4A:0E,bridge=vmbr0
numa: 0
ostype: win10
parent: gpu-success
scsi0: local:102/vm-102-disk-0.qcow2,discard=on,iothread=1,size=256G,ssd=1
scsihw: virtio-scsi-single
smbios1: uuid=843f8e90-470e-49c4-865d-aa5d342c3a25
sockets: 1
usb0: host=4-1
usb1: host=1-3
usb2: host=3-2
vga: none
vmgenid: c936a6a8-617c-4bc2-9e56-4c6aa74d4e20

@CzBiX
Copy link

CzBiX commented Aug 6, 2023

AMD GPU reset bug 可以用这个 workaround: https://github.com/inga-lovinde/RadeonResetBugFix

@Buksa
Copy link

Buksa commented Aug 12, 2023

this is will https://www.youtube.com/watch?v=D4Q66ctW1xI work better or same?

@isc30
Copy link

isc30 commented Sep 29, 2023

youre a hero, it seems to work. Its important to notice that this needs to be done on Proxmox version 7, I couldn't make this work on v8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment