0
0

More than 3 years have passed since last update.

dxgkrnlを有効にしてkernelビルド(5.10.y)

Last updated at Posted at 2021-04-20

カーネルビルド

任意のkernelでlinux-msft-wsl-5.10.16.3のdxgkrnlを有効にする。
linux-msft-wsl-5.4.yのやり方はここ

stableカーネルリポジトリをcloneする

$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
$ cd linux
$ git checkout origin/linux-5.11.y

WSL2のカーネルリポジトリをリモートに追加し、fetchする

$ git remote add wsl-origin https://github.com/microsoft/WSL2-Linux-Kernel.git
$ git fetch wsl-origin linux-msft-wsl-5.10.y

履歴を調査

$ git log linux-msft-wsl-5.10.16.3 --oneline
a571dc8cedc8 (tag: linux-msft-wsl-5.10.16.3, wsl-origin/linux-msft-wsl-5.10.y) Merge tag 'rolling-lts/wsl/5.10.16.3' into linux-msft-wsl-5.10.y
a73aec090501 Linux rolling-lts/wsl/5.10.16.3
cb68ddad0cfb Merge feature/mm_discard (e0e7ed2671bc8a7cc0cb1c51ac27c6b7fa93f874)
69d65f53e433 Merge feature/hyperv-arm64 (65dbae1a07c4c08c0499cbd4dec79ef3988e504e)
7b22472e8077 Merge feature/dxgkrnl (ec49cf3e069105f57c17ca70d9da70559931ea2a)
...

変更点を取り込む

$ git checkout v5.11.15
$ git merge ec49cf3e069105f57c17ca70d9da70559931ea2a
$ git merge 65dbae1a07c4c08c0499cbd4dec79ef3988e504e
$ git merge e0e7ed2671bc8a7cc0cb1c51ac27c6b7fa93f874
$ git cherry-pick a73aec090501
$ vi Makefile #修正点: EXTRAVERSION =.3
$ git add Makefile
$ git cherry-pick --continue
$ git tag linux-msft-wsl-5.11.15.3-local

v5.12.*に取り込む場合

v5.12.*に取り込む場合、e0e7ed2671bcのマージでコンフリクトを起こすので、下記のような編集を行う

arch/arm64/hyperv/hv_core.c
diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c
index 4517a19d0c12..65dd646eab0a 100644
--- a/arch/arm64/hyperv/hv_core.c
+++ b/arch/arm64/hyperv/hv_core.c
@@ -159,14 +159,14 @@ static int __init hyperv_init(struct acpi_table_header *table)
        /* Get the features and hints from Hyper-V */
        hv_get_vpreg_128(HV_REGISTER_FEATURES, &result);
        ms_hyperv.features = result.as32.a;
-       ms_hyperv.priv_high = result.as32.b;
+       ms_hyperv.features_b = result.as32.b;
        ms_hyperv.misc_features = result.as32.c;

        hv_get_vpreg_128(HV_REGISTER_ENLIGHTENMENTS, &result);
        ms_hyperv.hints = result.as32.a;

        pr_info("Hyper-V: Features 0x%x, privilege high: 0x%x, hints 0x%x, misc 0x%x\n",
-               ms_hyperv.features, ms_hyperv.priv_high, ms_hyperv.hints,
+               ms_hyperv.features, ms_hyperv.features_b, ms_hyperv.hints,
                ms_hyperv.misc_features);

        /*
arch/x86/kernel/cpu/mshyperv.c
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 973bbb48dba6..da82a9f45020 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -274,16 +274,12 @@ static void __init ms_hyperv_init_platform(void)
         * Extract the features and hints
         */
        ms_hyperv.features = cpuid_eax(HYPERV_CPUID_FEATURES);
-<<<<<<< HEAD
        ms_hyperv.features_b = cpuid_ebx(HYPERV_CPUID_FEATURES);
-=======
-       ms_hyperv.priv_high = cpuid_ebx(HYPERV_CPUID_FEATURES);
->>>>>>> cb68ddad0cfb... Merge feature/mm_discard (e0e7ed2671bc8a7cc0cb1c51ac27c6b7fa93f874)
        ms_hyperv.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES);
        ms_hyperv.hints    = cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO);

        pr_info("Hyper-V: features 0x%x, privilege high: 0x%x, hints 0x%x, misc 0x%x\n",
-               ms_hyperv.features, ms_hyperv.priv_high, ms_hyperv.hints,
+               ms_hyperv.features, ms_hyperv.features_b, ms_hyperv.hints,
                ms_hyperv.misc_features);

        ms_hyperv.max_vp_index = cpuid_eax(HYPERV_CPUID_IMPLEMENT_LIMITS);
include/asm-generic/hyperv-tlfs.h
diff --git a/include/asm-generic/hyperv-tlfs.h b/include/asm-generic/hyperv-tlfs.h
index 1b3e2ef25d1d..674388182bbf 100644
--- a/include/asm-generic/hyperv-tlfs.h
+++ b/include/asm-generic/hyperv-tlfs.h
@@ -88,13 +88,9 @@
 #define HV_CONNECT_PORT                                BIT(7)
 #define HV_ACCESS_STATS                                BIT(8)
 #define HV_DEBUGGING                           BIT(11)
-<<<<<<< HEAD
 #define HV_CPU_MANAGEMENT                      BIT(12)
-#define HV_ISOLATION                           BIT(22)
-=======
-#define HV_CPU_POWER_MANAGEMENT                        BIT(12)
 #define HV_ENABLE_EXTENDED_HYPERCALLS           BIT(20)
->>>>>>> cb68ddad0cfb... Merge feature/mm_discard (e0e7ed2671bc8a7cc0cb1c51ac27c6b7fa93f874)
+#define HV_ISOLATION                           BIT(22)


 /*
@@ -639,7 +635,6 @@ struct hv_set_vp_registers_input {
        } element[];
 } __packed;

-<<<<<<< HEAD
 enum hv_device_type {
        HV_DEVICE_TYPE_LOGICAL = 0,
        HV_DEVICE_TYPE_PCI = 1,
@@ -753,7 +748,6 @@ struct hv_input_unmap_device_interrupt {
 #define HV_SOURCE_SHADOW_NONE               0x0
 #define HV_SOURCE_SHADOW_BRIDGE_BUS_RANGE   0x1

-=======
 #ifdef CONFIG_PAGE_REPORTING
 #define HV_CAPABILITY_MEMORY_COLD_DISCARD_HINT BIT(8)

@@ -770,5 +764,4 @@ struct hv_memory_hint {
 };

 #endif //CONFIG_PAGE_REPORTING
->>>>>>> cb68ddad0cfb... Merge feature/mm_discard (e0e7ed2671bc8a7cc0cb1c51ac27c6b7fa93f874)
 #endif
include/asm-generic/mshyperv.h
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index 0f205a481289..7fe9a42b91dd 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -28,11 +28,7 @@

 struct ms_hyperv_info {
        u32 features;
-<<<<<<< HEAD
        u32 features_b;
-=======
-       u32 priv_high;
->>>>>>> cb68ddad0cfb... Merge feature/mm_discard (e0e7ed2671bc8a7cc0cb1c51ac27c6b7fa93f874)
        u32 misc_features;
        u32 hints;
        u32 nested_features;
@@ -237,7 +233,7 @@ static inline bool hyperv_query_ext_cap(u64 cap_to_query)
         * Querying extended capabilities is done via an extended hypercall.
         * Check if the partition supports extended hypercall, first.
         */
-       if (!(ms_hyperv.priv_high & HV_ENABLE_EXTENDED_HYPERCALLS)) {
+       if (!(ms_hyperv.features_b & HV_ENABLE_EXTENDED_HYPERCALLS)) {
                pr_info("Hyper-V doesn't support extended hypercalls\n");
                return 0;
        }

カーネルビルド&インストール

make oldconfigの設定は適宜行う。

$ make mrproper
$ git show wsl-origin/linux-msft-wsl-5.10.y:Microsoft/config-wsl > .config
$ make oldconfig
$ make
$ cp arch/x86/boot/bzImage /mnt/d/kernel-5.11.15.3-microsoft-standard-WSL2+

.wslconfigの設定

$ vi /mnt/c/Users/[USERNAME]/.wslconfig
$ cat /mnt/c/Users/[USERNAME]/.wslconfig
[wsl2]
kernel=d:\\kernel-5.11.15.3-microsoft-standard-WSL2+

動作確認

$ uname -r
5.11.15.3-microsoft-standard-WSL2+
$ dmesg|grep dxg
[    0.189402] hv_vmbus: registering driver dxgkrnl
[    0.189419] (NULL device *): dxgk: dxg_drv_init  Version: 2103
[    0.190341] (NULL device *): dxgk: mmio allocated c00000000  200000000 c00000000 dffffffff
$ ls /dev/dxg
/dev/dxg
$ /usr/local/cuda-11.2/samples/bin/x86_64/linux/release/deviceQuery
/usr/local/cuda-11.2/samples/bin/x86_64/linux/release/deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA GeForce GTX 1070"
  CUDA Driver Version / Runtime Version          11.3 / 11.2
  CUDA Capability Major/Minor version number:    6.1
  Total amount of global memory:                 8192 MBytes (8589934592 bytes)
  (15) Multiprocessors, (128) CUDA Cores/MP:     1920 CUDA Cores
  GPU Max Clock rate:                            1709 MHz (1.71 GHz)
  Memory Clock rate:                             4004 Mhz
  Memory Bus Width:                              256-bit
  L2 Cache Size:                                 2097152 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       49152 bytes
  Total shared memory per multiprocessor:        98304 bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  2048
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             512 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      Yes
  Device supports Managed Memory:                Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      Yes
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.3, CUDA Runtime Version = 11.2, NumDevs = 1
Result = PASS
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0