| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/06/25 22:42 | flow | patch-triage |
0mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch only moves definitions, macros, and structs between header and source files, adds __read_mostly attributes, and introduces compile-time static_asserts. There are no functional changes to the kernel logic.",
"WorthFuzzing": false
} |
| 1/1 | 2026/06/25 22:42 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 4da71b01d7148a56964bb094a54d64df38cc98b2\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Thu Jun 25 22:42:43 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h\nindex b517257a631532..fdb8953aeeb157 100644\n--- a/arch/x86/include/asm/kvm_host.h\n+++ b/arch/x86/include/asm/kvm_host.h\n@@ -125,24 +125,6 @@\n #define KVM_REQ_UPDATE_PROTECTED_GUEST_STATE \\\n \tKVM_ARCH_REQ_FLAGS(34, KVM_REQUEST_WAIT)\n \n-#define CR0_RESERVED_BITS \\\n-\t(~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \\\n-\t\t\t | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \\\n-\t\t\t | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))\n-\n-#define CR4_RESERVED_BITS \\\n-\t(~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\\\n-\t\t\t | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE \\\n-\t\t\t | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \\\n-\t\t\t | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \\\n-\t\t\t | X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_VMXE \\\n-\t\t\t | X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP \\\n-\t\t\t | X86_CR4_LAM_SUP | X86_CR4_CET))\n-\n-#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)\n-\n-\n-\n #define INVALID_PAGE (~(hpa_t)0)\n #define VALID_PAGE(x) ((x) != INVALID_PAGE)\n \n@@ -230,37 +212,6 @@ enum x86_intercept_stage;\n \n #define KVM_NR_DB_REGS\t4\n \n-#define DR6_BUS_LOCK (1 \u003c\u003c 11)\n-#define DR6_BD\t\t(1 \u003c\u003c 13)\n-#define DR6_BS\t\t(1 \u003c\u003c 14)\n-#define DR6_BT\t\t(1 \u003c\u003c 15)\n-#define DR6_RTM\t\t(1 \u003c\u003c 16)\n-/*\n- * DR6_ACTIVE_LOW combines fixed-1 and active-low bits.\n- * We can regard all the bits in DR6_FIXED_1 as active_low bits;\n- * they will never be 0 for now, but when they are defined\n- * in the future it will require no code change.\n- *\n- * DR6_ACTIVE_LOW is also used as the init/reset value for DR6.\n- */\n-#define DR6_ACTIVE_LOW\t0xffff0ff0\n-#define DR6_VOLATILE\t0x0001e80f\n-#define DR6_FIXED_1\t(DR6_ACTIVE_LOW \u0026 ~DR6_VOLATILE)\n-\n-#define DR7_BP_EN_MASK\t0x000000ff\n-#define DR7_GE\t\t(1 \u003c\u003c 9)\n-#define DR7_GD\t\t(1 \u003c\u003c 13)\n-#define DR7_VOLATILE\t0xffff2bff\n-\n-#define KVM_GUESTDBG_VALID_MASK \\\n-\t(KVM_GUESTDBG_ENABLE | \\\n-\tKVM_GUESTDBG_SINGLESTEP | \\\n-\tKVM_GUESTDBG_USE_HW_BP | \\\n-\tKVM_GUESTDBG_USE_SW_BP | \\\n-\tKVM_GUESTDBG_INJECT_BP | \\\n-\tKVM_GUESTDBG_INJECT_DB | \\\n-\tKVM_GUESTDBG_BLOCKIRQ)\n-\n #define PFERR_PRESENT_MASK\tBIT(0)\n #define PFERR_WRITE_MASK\tBIT(1)\n #define PFERR_USER_MASK\t\tBIT(2)\n@@ -290,19 +241,11 @@ enum x86_intercept_stage;\n #define PFERR_PRIVATE_ACCESS BIT_ULL(49)\n #define PFERR_SYNTHETIC_MASK (PFERR_IMPLICIT_ACCESS | PFERR_PRIVATE_ACCESS)\n \n-/* apic attention bits */\n-#define KVM_APIC_CHECK_VAPIC\t0\n-/*\n- * The following bit is set with PV-EOI, unset on EOI.\n- * We detect PV-EOI changes by guest by comparing\n- * this bit with PV-EOI in guest memory.\n- * See the implementation in apic_update_pv_eoi.\n- */\n-#define KVM_APIC_PV_EOI_PENDING\t1\n-\n struct kvm_kernel_irqfd;\n struct kvm_kernel_irq_routing_entry;\n \n+struct kvm_apic_map;\n+\n struct kvm_x86_msr_filter;\n struct kvm_x86_pmu_event_filter;\n \n@@ -705,95 +648,6 @@ struct kvm_mtrr {\n \tu64 deftype;\n };\n \n-/* Hyper-V SynIC timer */\n-struct kvm_vcpu_hv_stimer {\n-\tstruct hrtimer timer;\n-\tint index;\n-\tunion hv_stimer_config config;\n-\tu64 count;\n-\tu64 exp_time;\n-\tstruct hv_message msg;\n-\tbool msg_pending;\n-};\n-\n-/* Hyper-V synthetic interrupt controller (SynIC)*/\n-struct kvm_vcpu_hv_synic {\n-\tu64 version;\n-\tu64 control;\n-\tu64 msg_page;\n-\tu64 evt_page;\n-\tatomic64_t sint[HV_SYNIC_SINT_COUNT];\n-\tatomic_t sint_to_gsi[HV_SYNIC_SINT_COUNT];\n-\tDECLARE_BITMAP(auto_eoi_bitmap, 256);\n-\tDECLARE_BITMAP(vec_bitmap, 256);\n-\tbool active;\n-\tbool dont_zero_synic_pages;\n-};\n-\n-/* The maximum number of entries on the TLB flush fifo. */\n-#define KVM_HV_TLB_FLUSH_FIFO_SIZE (16)\n-/*\n- * Note: the following 'magic' entry is made up by KVM to avoid putting\n- * anything besides GVA on the TLB flush fifo. It is theoretically possible\n- * to observe a request to flush 4095 PFNs starting from 0xfffffffffffff000\n- * which will look identical. KVM's action to 'flush everything' instead of\n- * flushing these particular addresses is, however, fully legitimate as\n- * flushing more than requested is always OK.\n- */\n-#define KVM_HV_TLB_FLUSHALL_ENTRY ((u64)-1)\n-\n-enum hv_tlb_flush_fifos {\n-\tHV_L1_TLB_FLUSH_FIFO,\n-\tHV_L2_TLB_FLUSH_FIFO,\n-\tHV_NR_TLB_FLUSH_FIFOS,\n-};\n-\n-struct kvm_vcpu_hv_tlb_flush_fifo {\n-\tspinlock_t write_lock;\n-\tDECLARE_KFIFO(entries, u64, KVM_HV_TLB_FLUSH_FIFO_SIZE);\n-};\n-\n-/* Hyper-V per vcpu emulation context */\n-struct kvm_vcpu_hv {\n-\tstruct kvm_vcpu *vcpu;\n-\tu32 vp_index;\n-\tu64 hv_vapic;\n-\ts64 runtime_offset;\n-\tstruct kvm_vcpu_hv_synic synic;\n-\tstruct kvm_hyperv_exit exit;\n-\tstruct kvm_vcpu_hv_stimer stimer[HV_SYNIC_STIMER_COUNT];\n-\tDECLARE_BITMAP(stimer_pending_bitmap, HV_SYNIC_STIMER_COUNT);\n-\tbool enforce_cpuid;\n-\tstruct {\n-\t\tu32 features_eax; /* HYPERV_CPUID_FEATURES.EAX */\n-\t\tu32 features_ebx; /* HYPERV_CPUID_FEATURES.EBX */\n-\t\tu32 features_edx; /* HYPERV_CPUID_FEATURES.EDX */\n-\t\tu32 enlightenments_eax; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EAX */\n-\t\tu32 enlightenments_ebx; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EBX */\n-\t\tu32 syndbg_cap_eax; /* HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX */\n-\t\tu32 nested_eax; /* HYPERV_CPUID_NESTED_FEATURES.EAX */\n-\t\tu32 nested_ebx; /* HYPERV_CPUID_NESTED_FEATURES.EBX */\n-\t} cpuid_cache;\n-\n-\tstruct kvm_vcpu_hv_tlb_flush_fifo tlb_flush_fifo[HV_NR_TLB_FLUSH_FIFOS];\n-\n-\t/*\n-\t * Preallocated buffers for handling hypercalls that pass sparse vCPU\n-\t * sets (for high vCPU counts, they're too large to comfortably fit on\n-\t * the stack).\n-\t */\n-\tu64 sparse_banks[HV_MAX_SPARSE_VCPU_BANKS];\n-\tDECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);\n-\n-\tstruct hv_vp_assist_page vp_assist_page;\n-\n-\tstruct {\n-\t\tu64 pa_page_gpa;\n-\t\tu64 vm_id;\n-\t\tu32 vp_id;\n-\t} nested;\n-};\n-\n struct kvm_hypervisor_cpuid {\n \tu32 base;\n \tu32 limit;\n@@ -824,6 +678,8 @@ struct kvm_vcpu_xen {\n };\n #endif\n \n+struct kvm_vcpu_hv;\n+\n struct kvm_queued_exception {\n \tbool pending;\n \tbool injected;\n@@ -1181,39 +1037,6 @@ struct kvm_arch_memory_slot {\n \tunsigned short *gfn_write_track;\n };\n \n-/*\n- * Track the mode of the optimized logical map, as the rules for decoding the\n- * destination vary per mode. Enabling the optimized logical map requires all\n- * software-enabled local APIs to be in the same mode, each addressable APIC to\n- * be mapped to only one MDA, and each MDA to map to at most one APIC.\n- */\n-enum kvm_apic_logical_mode {\n-\t/* All local APICs are software disabled. */\n-\tKVM_APIC_MODE_SW_DISABLED,\n-\t/* All software enabled local APICs in xAPIC cluster addressing mode. */\n-\tKVM_APIC_MODE_XAPIC_CLUSTER,\n-\t/* All software enabled local APICs in xAPIC flat addressing mode. */\n-\tKVM_APIC_MODE_XAPIC_FLAT,\n-\t/* All software enabled local APICs in x2APIC mode. */\n-\tKVM_APIC_MODE_X2APIC,\n-\t/*\n-\t * Optimized map disabled, e.g. not all local APICs in the same logical\n-\t * mode, same logical ID assigned to multiple APICs, etc.\n-\t */\n-\tKVM_APIC_MODE_MAP_DISABLED,\n-};\n-\n-struct kvm_apic_map {\n-\tstruct rcu_head rcu;\n-\tenum kvm_apic_logical_mode logical_mode;\n-\tu32 max_apic_id;\n-\tunion {\n-\t\tstruct kvm_lapic *xapic_flat_map[8];\n-\t\tstruct kvm_lapic *xapic_cluster_map[16][4];\n-\t};\n-\tstruct kvm_lapic *phys_map[];\n-};\n-\n /* Hyper-V synthetic debugger (SynDbg)*/\n struct kvm_hv_syndbg {\n \tstruct {\n@@ -2019,13 +1842,6 @@ static inline unsigned long read_msr(unsigned long msr)\n }\n #endif\n \n-enum {\n-\tTASK_SWITCH_CALL = 0,\n-\tTASK_SWITCH_IRET = 1,\n-\tTASK_SWITCH_JMP = 2,\n-\tTASK_SWITCH_GATE = 3,\n-};\n-\n #define HF_GUEST_MASK\t\t(1 \u003c\u003c 0) /* VCPU is in guest-mode */\n \n #ifdef CONFIG_KVM_SMM\ndiff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h\nindex 1c8f7aaab063d0..6258ed277a7b47 100644\n--- a/arch/x86/kvm/hyperv.h\n+++ b/arch/x86/kvm/hyperv.h\n@@ -27,6 +27,96 @@\n \n #ifdef CONFIG_KVM_HYPERV\n \n+\n+/* Hyper-V SynIC timer */\n+struct kvm_vcpu_hv_stimer {\n+\tstruct hrtimer timer;\n+\tint index;\n+\tunion hv_stimer_config config;\n+\tu64 count;\n+\tu64 exp_time;\n+\tstruct hv_message msg;\n+\tbool msg_pending;\n+};\n+\n+/* Hyper-V synthetic interrupt controller (SynIC)*/\n+struct kvm_vcpu_hv_synic {\n+\tu64 version;\n+\tu64 control;\n+\tu64 msg_page;\n+\tu64 evt_page;\n+\tatomic64_t sint[HV_SYNIC_SINT_COUNT];\n+\tatomic_t sint_to_gsi[HV_SYNIC_SINT_COUNT];\n+\tDECLARE_BITMAP(auto_eoi_bitmap, 256);\n+\tDECLARE_BITMAP(vec_bitmap, 256);\n+\tbool active;\n+\tbool dont_zero_synic_pages;\n+};\n+\n+/* The maximum number of entries on the TLB flush fifo. */\n+#define KVM_HV_TLB_FLUSH_FIFO_SIZE (16)\n+/*\n+ * Note: the following 'magic' entry is made up by KVM to avoid putting\n+ * anything besides GVA on the TLB flush fifo. It is theoretically possible\n+ * to observe a request to flush 4095 PFNs starting from 0xfffffffffffff000\n+ * which will look identical. KVM's action to 'flush everything' instead of\n+ * flushing these particular addresses is, however, fully legitimate as\n+ * flushing more than requested is always OK.\n+ */\n+#define KVM_HV_TLB_FLUSHALL_ENTRY ((u64)-1)\n+\n+enum hv_tlb_flush_fifos {\n+\tHV_L1_TLB_FLUSH_FIFO,\n+\tHV_L2_TLB_FLUSH_FIFO,\n+\tHV_NR_TLB_FLUSH_FIFOS,\n+};\n+\n+struct kvm_vcpu_hv_tlb_flush_fifo {\n+\tspinlock_t write_lock;\n+\tDECLARE_KFIFO(entries, u64, KVM_HV_TLB_FLUSH_FIFO_SIZE);\n+};\n+\n+/* Hyper-V per vcpu emulation context */\n+struct kvm_vcpu_hv {\n+\tstruct kvm_vcpu *vcpu;\n+\tu32 vp_index;\n+\tu64 hv_vapic;\n+\ts64 runtime_offset;\n+\tstruct kvm_vcpu_hv_synic synic;\n+\tstruct kvm_hyperv_exit exit;\n+\tstruct kvm_vcpu_hv_stimer stimer[HV_SYNIC_STIMER_COUNT];\n+\tDECLARE_BITMAP(stimer_pending_bitmap, HV_SYNIC_STIMER_COUNT);\n+\tbool enforce_cpuid;\n+\tstruct {\n+\t\tu32 features_eax; /* HYPERV_CPUID_FEATURES.EAX */\n+\t\tu32 features_ebx; /* HYPERV_CPUID_FEATURES.EBX */\n+\t\tu32 features_edx; /* HYPERV_CPUID_FEATURES.EDX */\n+\t\tu32 enlightenments_eax; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EAX */\n+\t\tu32 enlightenments_ebx; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EBX */\n+\t\tu32 syndbg_cap_eax; /* HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX */\n+\t\tu32 nested_eax; /* HYPERV_CPUID_NESTED_FEATURES.EAX */\n+\t\tu32 nested_ebx; /* HYPERV_CPUID_NESTED_FEATURES.EBX */\n+\t} cpuid_cache;\n+\n+\tstruct kvm_vcpu_hv_tlb_flush_fifo tlb_flush_fifo[HV_NR_TLB_FLUSH_FIFOS];\n+\n+\t/*\n+\t * Preallocated buffers for handling hypercalls that pass sparse vCPU\n+\t * sets (for high vCPU counts, they're too large to comfortably fit on\n+\t * the stack).\n+\t */\n+\tu64 sparse_banks[HV_MAX_SPARSE_VCPU_BANKS];\n+\tDECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);\n+\n+\tstruct hv_vp_assist_page vp_assist_page;\n+\n+\tstruct {\n+\t\tu64 pa_page_gpa;\n+\t\tu64 vm_id;\n+\t\tu32 vp_id;\n+\t} nested;\n+};\n+\n /* \"Hv#1\" signature */\n #define HYPERV_CPUID_SIGNATURE_EAX 0x31237648\n \ndiff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c\nindex 6f30bbdddb5aa9..0354db0f2c0f03 100644\n--- a/arch/x86/kvm/lapic.c\n+++ b/arch/x86/kvm/lapic.c\n@@ -75,6 +75,16 @@ module_param(lapic_timer_advance, bool, 0444);\n /* step-by-step approximation to mitigate fluctuation */\n #define LAPIC_TIMER_ADVANCE_ADJUST_STEP 8\n \n+/* apic attention bits */\n+#define KVM_APIC_CHECK_VAPIC\t0\n+/*\n+ * The following bit is set with PV-EOI, unset on EOI.\n+ * We detect PV-EOI changes by guest by comparing\n+ * this bit with PV-EOI in guest memory.\n+ * See the implementation in apic_update_pv_eoi.\n+ */\n+#define KVM_APIC_PV_EOI_PENDING\t1\n+\n static bool __read_mostly vector_hashing_enabled = true;\n module_param_named(vector_hashing, vector_hashing_enabled, bool, 0444);\n \ndiff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h\nindex 58dbb94f980da2..bd1098c89d9980 100644\n--- a/arch/x86/kvm/lapic.h\n+++ b/arch/x86/kvm/lapic.h\n@@ -32,6 +32,39 @@ enum lapic_mode {\n \tLAPIC_MODE_X2APIC = MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE,\n };\n \n+/*\n+ * Track the mode of the optimized logical map, as the rules for decoding the\n+ * destination vary per mode. Enabling the optimized logical map requires all\n+ * software-enabled local APIs to be in the same mode, each addressable APIC to\n+ * be mapped to only one MDA, and each MDA to map to at most one APIC.\n+ */\n+enum kvm_apic_logical_mode {\n+\t/* All local APICs are software disabled. */\n+\tKVM_APIC_MODE_SW_DISABLED,\n+\t/* All software enabled local APICs in xAPIC cluster addressing mode. */\n+\tKVM_APIC_MODE_XAPIC_CLUSTER,\n+\t/* All software enabled local APICs in xAPIC flat addressing mode. */\n+\tKVM_APIC_MODE_XAPIC_FLAT,\n+\t/* All software enabled local APICs in x2APIC mode. */\n+\tKVM_APIC_MODE_X2APIC,\n+\t/*\n+\t * Optimized map disabled, e.g. not all local APICs in the same logical\n+\t * mode, same logical ID assigned to multiple APICs, etc.\n+\t */\n+\tKVM_APIC_MODE_MAP_DISABLED,\n+};\n+\n+struct kvm_apic_map {\n+\tstruct rcu_head rcu;\n+\tenum kvm_apic_logical_mode logical_mode;\n+\tu32 max_apic_id;\n+\tunion {\n+\t\tstruct kvm_lapic *xapic_flat_map[8];\n+\t\tstruct kvm_lapic *xapic_cluster_map[16][4];\n+\t};\n+\tstruct kvm_lapic *phys_map[];\n+};\n+\n enum lapic_lvt_entry {\n \tLVT_TIMER,\n \tLVT_THERMAL_MONITOR,\ndiff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h\nindex c9f628b97daeb9..85bc503de1b6fd 100644\n--- a/arch/x86/kvm/mmu.h\n+++ b/arch/x86/kvm/mmu.h\n@@ -6,14 +6,14 @@\n #include \"regs.h\"\n #include \"cpuid.h\"\n \n-extern bool tdp_enabled;\n+extern bool __read_mostly tdp_enabled;\n #ifdef CONFIG_X86_64\n-extern bool tdp_mmu_enabled;\n+extern bool __read_mostly tdp_mmu_enabled;\n #else\n #define tdp_mmu_enabled false\n #endif\n extern bool __read_mostly enable_mmio_caching;\n-extern bool eager_page_split;\n+extern bool __read_mostly eager_page_split;\n \n #define KVM_MEMSLOT_PAGES_TO_MMU_PAGES_RATIO 50\n #define KVM_MIN_ALLOC_MMU_PAGES 64UL\ndiff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c\nindex 6c13da942bfccc..af3820136f7c21 100644\n--- a/arch/x86/kvm/mmu/mmu.c\n+++ b/arch/x86/kvm/mmu/mmu.c\n@@ -104,7 +104,7 @@ module_param_named(flush_on_reuse, force_flush_and_sync_on_reuse, bool, 0644);\n * 2. while doing 1. it walks guest-physical to host-physical\n * If the hardware supports that we don't need to do shadow paging.\n */\n-bool tdp_enabled = false;\n+bool __read_mostly tdp_enabled = false;\n \n static bool __ro_after_init tdp_mmu_allowed;\n \ndiff --git a/arch/x86/kvm/msrs.h b/arch/x86/kvm/msrs.h\nindex b698983e37fb61..9c5c6b33e58f57 100644\n--- a/arch/x86/kvm/msrs.h\n+++ b/arch/x86/kvm/msrs.h\n@@ -1,6 +1,6 @@\n /* SPDX-License-Identifier: GPL-2.0 */\n-#ifndef ARCH_X86_KVM_MSR_H\n-#define ARCH_X86_KVM_MSR_H\n+#ifndef ARCH_X86_KVM_MSRS_H\n+#define ARCH_X86_KVM_MSRS_H\n \n #include \u003clinux/kvm_host.h\u003e\n #include \u003clinux/user-return-notifier.h\u003e\ndiff --git a/arch/x86/kvm/regs.h b/arch/x86/kvm/regs.h\nindex 94fd86728fed29..447f0ec3e63e4e 100644\n--- a/arch/x86/kvm/regs.h\n+++ b/arch/x86/kvm/regs.h\n@@ -16,6 +16,44 @@\n \n static_assert(!(KVM_POSSIBLE_CR0_GUEST_BITS \u0026 X86_CR0_PDPTR_BITS));\n \n+#define CR0_RESERVED_BITS \\\n+\t(~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \\\n+\t\t\t | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \\\n+\t\t\t | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))\n+\n+#define CR4_RESERVED_BITS \\\n+\t(~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\\\n+\t\t\t | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE \\\n+\t\t\t | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \\\n+\t\t\t | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \\\n+\t\t\t | X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_VMXE \\\n+\t\t\t | X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP \\\n+\t\t\t | X86_CR4_LAM_SUP | X86_CR4_CET))\n+\n+#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)\n+\n+#define DR6_BUS_LOCK (1 \u003c\u003c 11)\n+#define DR6_BD\t\t(1 \u003c\u003c 13)\n+#define DR6_BS\t\t(1 \u003c\u003c 14)\n+#define DR6_BT\t\t(1 \u003c\u003c 15)\n+#define DR6_RTM\t\t(1 \u003c\u003c 16)\n+/*\n+ * DR6_ACTIVE_LOW combines fixed-1 and active-low bits.\n+ * We can regard all the bits in DR6_FIXED_1 as active_low bits;\n+ * they will never be 0 for now, but when they are defined\n+ * in the future it will require no code change.\n+ *\n+ * DR6_ACTIVE_LOW is also used as the init/reset value for DR6.\n+ */\n+#define DR6_ACTIVE_LOW\t0xffff0ff0\n+#define DR6_VOLATILE\t0x0001e80f\n+#define DR6_FIXED_1\t(DR6_ACTIVE_LOW \u0026 ~DR6_VOLATILE)\n+\n+#define DR7_BP_EN_MASK\t0x000000ff\n+#define DR7_GE\t\t(1 \u003c\u003c 9)\n+#define DR7_GD\t\t(1 \u003c\u003c 13)\n+#define DR7_VOLATILE\t0xffff2bff\n+\n void kvm_post_set_cr0(struct kvm_vcpu *vcpu, unsigned long old_cr0, unsigned long cr0);\n void kvm_post_set_cr4(struct kvm_vcpu *vcpu, unsigned long old_cr4, unsigned long cr4);\n int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);\ndiff --git a/arch/x86/kvm/tss.h b/arch/x86/kvm/tss.h\nindex 117bf8bec07dca..55ced897584065 100644\n--- a/arch/x86/kvm/tss.h\n+++ b/arch/x86/kvm/tss.h\n@@ -2,6 +2,10 @@\n #ifndef __TSS_SEGMENT_H\n #define __TSS_SEGMENT_H\n \n+#include \u003clinux/build_bug.h\u003e\n+#include \u003clinux/stddef.h\u003e\n+#include \u003clinux/types.h\u003e\n+\n struct tss_segment_32 {\n \tu32 prev_task_link;\n \tu32 esp0;\n@@ -64,4 +68,7 @@ struct tss_segment_16 {\n #define RMODE_TSS_SIZE\t\t\t\t\t\t\t\\\n \t(TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)\n \n+static_assert(offsetof(struct tss_segment_32, io_map) == TSS_IOPB_BASE_OFFSET);\n+static_assert(sizeof(struct tss_segment_32) == TSS_BASE_SIZE);\n+\n #endif\ndiff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c\nindex 0626e835e9eb77..5ee6d0c3300953 100644\n--- a/arch/x86/kvm/x86.c\n+++ b/arch/x86/kvm/x86.c\n@@ -115,6 +115,15 @@ EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_host);\n \n #define KVM_CAP_PMU_VALID_MASK KVM_PMU_CAP_DISABLE\n \n+#define KVM_GUESTDBG_VALID_MASK \\\n+\t(KVM_GUESTDBG_ENABLE | \\\n+\tKVM_GUESTDBG_SINGLESTEP | \\\n+\tKVM_GUESTDBG_USE_HW_BP | \\\n+\tKVM_GUESTDBG_USE_SW_BP | \\\n+\tKVM_GUESTDBG_INJECT_BP | \\\n+\tKVM_GUESTDBG_INJECT_DB | \\\n+\tKVM_GUESTDBG_BLOCKIRQ)\n+\n #define KVM_X2APIC_API_VALID_FLAGS (KVM_X2APIC_API_USE_32BIT_IDS\t\t| \\\n \t\t\t\t KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK\t| \\\n \t\t\t\t KVM_X2APIC_ENABLE_SUPPRESS_EOI_BROADCAST\t| \\\ndiff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h\nindex 8ece468087a8ee..494d97e9a9c9f3 100644\n--- a/arch/x86/kvm/x86.h\n+++ b/arch/x86/kvm/x86.h\n@@ -482,6 +482,12 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu);\n \n void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);\n \n+enum kvm_task_switch_reason {\n+\tTASK_SWITCH_CALL = 0,\n+\tTASK_SWITCH_IRET = 1,\n+\tTASK_SWITCH_JMP = 2,\n+\tTASK_SWITCH_GATE = 3,\n+};\n int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index,\n \t\t int reason, bool has_error_code, u32 error_code);\n \n"
} |
| 2/1 | 2026/06/25 22:42 | agent | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch only moves definitions, macros, and structs between header and source files, adds __read_mostly attributes, and introduces compile-time static_asserts. There are no functional changes to the kernel logic.",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Do not list too generic configs (we already have them enabled). Only list those that specifically cover the modified code. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 4da71b01d7148a56964bb094a54d64df38cc98b2
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Jun 25 22:42:43 2026 +0000
syz-cluster: applied patch under review
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index b517257a631532..fdb8953aeeb157 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -125,24 +125,6 @@
#define KVM_REQ_UPDATE_PROTECTED_GUEST_STATE \
KVM_ARCH_REQ_FLAGS(34, KVM_REQUEST_WAIT)
-#define CR0_RESERVED_BITS \
- (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
- | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
- | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))
-
-#define CR4_RESERVED_BITS \
- (~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
- | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE \
- | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \
- | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \
- | X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_VMXE \
- | X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP \
- | X86_CR4_LAM_SUP | X86_CR4_CET))
-
-#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
-
-
-
#define INVALID_PAGE (~(hpa_t)0)
#define VALID_PAGE(x) ((x) != INVALID_PAGE)
@@ -230,37 +212,6 @@ enum x86_intercept_stage;
#define KVM_NR_DB_REGS 4
-#define DR6_BUS_LOCK (1 << 11)
-#define DR6_BD (1 << 13)
-#define DR6_BS (1 << 14)
-#define DR6_BT (1 << 15)
-#define DR6_RTM (1 << 16)
-/*
- * DR6_ACTIVE_LOW combines fixed-1 and active-low bits.
- * We can regard all the bits in DR6_FIXED_1 as active_low bits;
- * they will never be 0 for now, but when they are defined
- * in the future it will require no code change.
- *
- * DR6_ACTIVE_LOW is also used as the init/reset value for DR6.
- */
-#define DR6_ACTIVE_LOW 0xffff0ff0
-#define DR6_VOLATILE 0x0001e80f
-#define DR6_FIXED_1 (DR6_ACTIVE_LOW & ~DR6_VOLATILE)
-
-#define DR7_BP_EN_MASK 0x000000ff
-#define DR7_GE (1 << 9)
-#define DR7_GD (1 << 13)
-#define DR7_VOLATILE 0xffff2bff
-
-#define KVM_GUESTDBG_VALID_MASK \
- (KVM_GUESTDBG_ENABLE | \
- KVM_GUESTDBG_SINGLESTEP | \
- KVM_GUESTDBG_USE_HW_BP | \
- KVM_GUESTDBG_USE_SW_BP | \
- KVM_GUESTDBG_INJECT_BP | \
- KVM_GUESTDBG_INJECT_DB | \
- KVM_GUESTDBG_BLOCKIRQ)
-
#define PFERR_PRESENT_MASK BIT(0)
#define PFERR_WRITE_MASK BIT(1)
#define PFERR_USER_MASK BIT(2)
@@ -290,19 +241,11 @@ enum x86_intercept_stage;
#define PFERR_PRIVATE_ACCESS BIT_ULL(49)
#define PFERR_SYNTHETIC_MASK (PFERR_IMPLICIT_ACCESS | PFERR_PRIVATE_ACCESS)
-/* apic attention bits */
-#define KVM_APIC_CHECK_VAPIC 0
-/*
- * The following bit is set with PV-EOI, unset on EOI.
- * We detect PV-EOI changes by guest by comparing
- * this bit with PV-EOI in guest memory.
- * See the implementation in apic_update_pv_eoi.
- */
-#define KVM_APIC_PV_EOI_PENDING 1
-
struct kvm_kernel_irqfd;
struct kvm_kernel_irq_routing_entry;
+struct kvm_apic_map;
+
struct kvm_x86_msr_filter;
struct kvm_x86_pmu_event_filter;
@@ -705,95 +648,6 @@ struct kvm_mtrr {
u64 deftype;
};
-/* Hyper-V SynIC timer */
-struct kvm_vcpu_hv_stimer {
- struct hrtimer timer;
- int index;
- union hv_stimer_config config;
- u64 count;
- u64 exp_time;
- struct hv_message msg;
- bool msg_pending;
-};
-
-/* Hyper-V synthetic interrupt controller (SynIC)*/
-struct kvm_vcpu_hv_synic {
- u64 version;
- u64 control;
- u64 msg_page;
- u64 evt_page;
- atomic64_t sint[HV_SYNIC_SINT_COUNT];
- atomic_t sint_to_gsi[HV_SYNIC_SINT_COUNT];
- DECLARE_BITMAP(auto_eoi_bitmap, 256);
- DECLARE_BITMAP(vec_bitmap, 256);
- bool active;
- bool dont_zero_synic_pages;
-};
-
-/* The maximum number of entries on the TLB flush fifo. */
-#define KVM_HV_TLB_FLUSH_FIFO_SIZE (16)
-/*
- * Note: the following 'magic' entry is made up by KVM to avoid putting
- * anything besides GVA on the TLB flush fifo. It is theoretically possible
- * to observe a request to flush 4095 PFNs starting from 0xfffffffffffff000
- * which will look identical. KVM's action to 'flush everything' instead of
- * flushing these particular addresses is, however, fully legitimate as
- * flushing more than requested is always OK.
- */
-#define KVM_HV_TLB_FLUSHALL_ENTRY ((u64)-1)
-
-enum hv_tlb_flush_fifos {
- HV_L1_TLB_FLUSH_FIFO,
- HV_L2_TLB_FLUSH_FIFO,
- HV_NR_TLB_FLUSH_FIFOS,
-};
-
-struct kvm_vcpu_hv_tlb_flush_fifo {
- spinlock_t write_lock;
- DECLARE_KFIFO(entries, u64, KVM_HV_TLB_FLUSH_FIFO_SIZE);
-};
-
-/* Hyper-V per vcpu emulation context */
-struct kvm_vcpu_hv {
- struct kvm_vcpu *vcpu;
- u32 vp_index;
- u64 hv_vapic;
- s64 runtime_offset;
- struct kvm_vcpu_hv_synic synic;
- struct kvm_hyperv_exit exit;
- struct kvm_vcpu_hv_stimer stimer[HV_SYNIC_STIMER_COUNT];
- DECLARE_BITMAP(stimer_pending_bitmap, HV_SYNIC_STIMER_COUNT);
- bool enforce_cpuid;
- struct {
- u32 features_eax; /* HYPERV_CPUID_FEATURES.EAX */
- u32 features_ebx; /* HYPERV_CPUID_FEATURES.EBX */
- u32 features_edx; /* HYPERV_CPUID_FEATURES.EDX */
- u32 enlightenments_eax; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EAX */
- u32 enlightenments_ebx; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EBX */
- u32 syndbg_cap_eax; /* HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX */
- u32 nested_eax; /* HYPERV_CPUID_NESTED_FEATURES.EAX */
- u32 nested_ebx; /* HYPERV_CPUID_NESTED_FEATURES.EBX */
- } cpuid_cache;
-
- struct kvm_vcpu_hv_tlb_flush_fifo tlb_flush_fifo[HV_NR_TLB_FLUSH_FIFOS];
-
- /*
- * Preallocated buffers for handling hypercalls that pass sparse vCPU
- * sets (for high vCPU counts, they're too large to comfortably fit on
- * the stack).
- */
- u64 sparse_banks[HV_MAX_SPARSE_VCPU_BANKS];
- DECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);
-
- struct hv_vp_assist_page vp_assist_page;
-
- struct {
- u64 pa_page_gpa;
- u64 vm_id;
- u32 vp_id;
- } nested;
-};
-
struct kvm_hypervisor_cpuid {
u32 base;
u32 limit;
@@ -824,6 +678,8 @@ struct kvm_vcpu_xen {
};
#endif
+struct kvm_vcpu_hv;
+
struct kvm_queued_exception {
bool pending;
bool injected;
@@ -1181,39 +1037,6 @@ struct kvm_arch_memory_slot {
unsigned short *gfn_write_track;
};
-/*
- * Track the mode of the optimized logical map, as the rules for decoding the
- * destination vary per mode. Enabling the optimized logical map requires all
- * software-enabled local APIs to be in the same mode, each addressable APIC to
- * be mapped to only one MDA, and each MDA to map to at most one APIC.
- */
-enum kvm_apic_logical_mode {
- /* All local APICs are software disabled. */
- KVM_APIC_MODE_SW_DISABLED,
- /* All software enabled local APICs in xAPIC cluster addressing mode. */
- KVM_APIC_MODE_XAPIC_CLUSTER,
- /* All software enabled local APICs in xAPIC flat addressing mode. */
- KVM_APIC_MODE_XAPIC_FLAT,
- /* All software enabled local APICs in x2APIC mode. */
- KVM_APIC_MODE_X2APIC,
- /*
- * Optimized map disabled, e.g. not all local APICs in the same logical
- * mode, same logical ID assigned to multiple APICs, etc.
- */
- KVM_APIC_MODE_MAP_DISABLED,
-};
-
-struct kvm_apic_map {
- struct rcu_head rcu;
- enum kvm_apic_logical_mode logical_mode;
- u32 max_apic_id;
- union {
- struct kvm_lapic *xapic_flat_map[8];
- struct kvm_lapic *xapic_cluster_map[16][4];
- };
- struct kvm_lapic *phys_map[];
-};
-
/* Hyper-V synthetic debugger (SynDbg)*/
struct kvm_hv_syndbg {
struct {
@@ -2019,13 +1842,6 @@ static inline unsigned long read_msr(unsigned long msr)
}
#endif
-enum {
- TASK_SWITCH_CALL = 0,
- TASK_SWITCH_IRET = 1,
- TASK_SWITCH_JMP = 2,
- TASK_SWITCH_GATE = 3,
-};
-
#define HF_GUEST_MASK (1 << 0) /* VCPU is in guest-mode */
#ifdef CONFIG_KVM_SMM
diff --git a/arch/x86/kvm/hyperv.h b/arch/x86/kvm/hyperv.h
index 1c8f7aaab063d0..6258ed277a7b47 100644
--- a/arch/x86/kvm/hyperv.h
+++ b/arch/x86/kvm/hyperv.h
@@ -27,6 +27,96 @@
#ifdef CONFIG_KVM_HYPERV
+
+/* Hyper-V SynIC timer */
+struct kvm_vcpu_hv_stimer {
+ struct hrtimer timer;
+ int index;
+ union hv_stimer_config config;
+ u64 count;
+ u64 exp_time;
+ struct hv_message msg;
+ bool msg_pending;
+};
+
+/* Hyper-V synthetic interrupt controller (SynIC)*/
+struct kvm_vcpu_hv_synic {
+ u64 version;
+ u64 control;
+ u64 msg_page;
+ u64 evt_page;
+ atomic64_t sint[HV_SYNIC_SINT_COUNT];
+ atomic_t sint_to_gsi[HV_SYNIC_SINT_COUNT];
+ DECLARE_BITMAP(auto_eoi_bitmap, 256);
+ DECLARE_BITMAP(vec_bitmap, 256);
+ bool active;
+ bool dont_zero_synic_pages;
+};
+
+/* The maximum number of entries on the TLB flush fifo. */
+#define KVM_HV_TLB_FLUSH_FIFO_SIZE (16)
+/*
+ * Note: the following 'magic' entry is made up by KVM to avoid putting
+ * anything besides GVA on the TLB flush fifo. It is theoretically possible
+ * to observe a request to flush 4095 PFNs starting from 0xfffffffffffff000
+ * which will look identical. KVM's action to 'flush everything' instead of
+ * flushing these particular addresses is, however, fully legitimate as
+ * flushing more than requested is always OK.
+ */
+#define KVM_HV_TLB_FLUSHALL_ENTRY ((u64)-1)
+
+enum hv_tlb_flush_fifos {
+ HV_L1_TLB_FLUSH_FIFO,
+ HV_L2_TLB_FLUSH_FIFO,
+ HV_NR_TLB_FLUSH_FIFOS,
+};
+
+struct kvm_vcpu_hv_tlb_flush_fifo {
+ spinlock_t write_lock;
+ DECLARE_KFIFO(entries, u64, KVM_HV_TLB_FLUSH_FIFO_SIZE);
+};
+
+/* Hyper-V per vcpu emulation context */
+struct kvm_vcpu_hv {
+ struct kvm_vcpu *vcpu;
+ u32 vp_index;
+ u64 hv_vapic;
+ s64 runtime_offset;
+ struct kvm_vcpu_hv_synic synic;
+ struct kvm_hyperv_exit exit;
+ struct kvm_vcpu_hv_stimer stimer[HV_SYNIC_STIMER_COUNT];
+ DECLARE_BITMAP(stimer_pending_bitmap, HV_SYNIC_STIMER_COUNT);
+ bool enforce_cpuid;
+ struct {
+ u32 features_eax; /* HYPERV_CPUID_FEATURES.EAX */
+ u32 features_ebx; /* HYPERV_CPUID_FEATURES.EBX */
+ u32 features_edx; /* HYPERV_CPUID_FEATURES.EDX */
+ u32 enlightenments_eax; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EAX */
+ u32 enlightenments_ebx; /* HYPERV_CPUID_ENLIGHTMENT_INFO.EBX */
+ u32 syndbg_cap_eax; /* HYPERV_CPUID_SYNDBG_PLATFORM_CAPABILITIES.EAX */
+ u32 nested_eax; /* HYPERV_CPUID_NESTED_FEATURES.EAX */
+ u32 nested_ebx; /* HYPERV_CPUID_NESTED_FEATURES.EBX */
+ } cpuid_cache;
+
+ struct kvm_vcpu_hv_tlb_flush_fifo tlb_flush_fifo[HV_NR_TLB_FLUSH_FIFOS];
+
+ /*
+ * Preallocated buffers for handling hypercalls that pass sparse vCPU
+ * sets (for high vCPU counts, they're too large to comfortably fit on
+ * the stack).
+ */
+ u64 sparse_banks[HV_MAX_SPARSE_VCPU_BANKS];
+ DECLARE_BITMAP(vcpu_mask, KVM_MAX_VCPUS);
+
+ struct hv_vp_assist_page vp_assist_page;
+
+ struct {
+ u64 pa_page_gpa;
+ u64 vm_id;
+ u32 vp_id;
+ } nested;
+};
+
/* "Hv#1" signature */
#define HYPERV_CPUID_SIGNATURE_EAX 0x31237648
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 6f30bbdddb5aa9..0354db0f2c0f03 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -75,6 +75,16 @@ module_param(lapic_timer_advance, bool, 0444);
/* step-by-step approximation to mitigate fluctuation */
#define LAPIC_TIMER_ADVANCE_ADJUST_STEP 8
+/* apic attention bits */
+#define KVM_APIC_CHECK_VAPIC 0
+/*
+ * The following bit is set with PV-EOI, unset on EOI.
+ * We detect PV-EOI changes by guest by comparing
+ * this bit with PV-EOI in guest memory.
+ * See the implementation in apic_update_pv_eoi.
+ */
+#define KVM_APIC_PV_EOI_PENDING 1
+
static bool __read_mostly vector_hashing_enabled = true;
module_param_named(vector_hashing, vector_hashing_enabled, bool, 0444);
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 58dbb94f980da2..bd1098c89d9980 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -32,6 +32,39 @@ enum lapic_mode {
LAPIC_MODE_X2APIC = MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE,
};
+/*
+ * Track the mode of the optimized logical map, as the rules for decoding the
+ * destination vary per mode. Enabling the optimized logical map requires all
+ * software-enabled local APIs to be in the same mode, each addressable APIC to
+ * be mapped to only one MDA, and each MDA to map to at most one APIC.
+ */
+enum kvm_apic_logical_mode {
+ /* All local APICs are software disabled. */
+ KVM_APIC_MODE_SW_DISABLED,
+ /* All software enabled local APICs in xAPIC cluster addressing mode. */
+ KVM_APIC_MODE_XAPIC_CLUSTER,
+ /* All software enabled local APICs in xAPIC flat addressing mode. */
+ KVM_APIC_MODE_XAPIC_FLAT,
+ /* All software enabled local APICs in x2APIC mode. */
+ KVM_APIC_MODE_X2APIC,
+ /*
+ * Optimized map disabled, e.g. not all local APICs in the same logical
+ * mode, same logical ID assigned to multiple APICs, etc.
+ */
+ KVM_APIC_MODE_MAP_DISABLED,
+};
+
+struct kvm_apic_map {
+ struct rcu_head rcu;
+ enum kvm_apic_logical_mode logical_mode;
+ u32 max_apic_id;
+ union {
+ struct kvm_lapic *xapic_flat_map[8];
+ struct kvm_lapic *xapic_cluster_map[16][4];
+ };
+ struct kvm_lapic *phys_map[];
+};
+
enum lapic_lvt_entry {
LVT_TIMER,
LVT_THERMAL_MONITOR,
diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h
index c9f628b97daeb9..85bc503de1b6fd 100644
--- a/arch/x86/kvm/mmu.h
+++ b/arch/x86/kvm/mmu.h
@@ -6,14 +6,14 @@
#include "regs.h"
#include "cpuid.h"
-extern bool tdp_enabled;
+extern bool __read_mostly tdp_enabled;
#ifdef CONFIG_X86_64
-extern bool tdp_mmu_enabled;
+extern bool __read_mostly tdp_mmu_enabled;
#else
#define tdp_mmu_enabled false
#endif
extern bool __read_mostly enable_mmio_caching;
-extern bool eager_page_split;
+extern bool __read_mostly eager_page_split;
#define KVM_MEMSLOT_PAGES_TO_MMU_PAGES_RATIO 50
#define KVM_MIN_ALLOC_MMU_PAGES 64UL
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 6c13da942bfccc..af3820136f7c21 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -104,7 +104,7 @@ module_param_named(flush_on_reuse, force_flush_and_sync_on_reuse, bool, 0644);
* 2. while doing 1. it walks guest-physical to host-physical
* If the hardware supports that we don't need to do shadow paging.
*/
-bool tdp_enabled = false;
+bool __read_mostly tdp_enabled = false;
static bool __ro_after_init tdp_mmu_allowed;
diff --git a/arch/x86/kvm/msrs.h b/arch/x86/kvm/msrs.h
index b698983e37fb61..9c5c6b33e58f57 100644
--- a/arch/x86/kvm/msrs.h
+++ b/arch/x86/kvm/msrs.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef ARCH_X86_KVM_MSR_H
-#define ARCH_X86_KVM_MSR_H
+#ifndef ARCH_X86_KVM_MSRS_H
+#define ARCH_X86_KVM_MSRS_H
#include <linux/kvm_host.h>
#include <linux/user-return-notifier.h>
diff --git a/arch/x86/kvm/regs.h b/arch/x86/kvm/regs.h
index 94fd86728fed29..447f0ec3e63e4e 100644
--- a/arch/x86/kvm/regs.h
+++ b/arch/x86/kvm/regs.h
@@ -16,6 +16,44 @@
static_assert(!(KVM_POSSIBLE_CR0_GUEST_BITS & X86_CR0_PDPTR_BITS));
+#define CR0_RESERVED_BITS \
+ (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
+ | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
+ | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))
+
+#define CR4_RESERVED_BITS \
+ (~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
+ | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE \
+ | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR | X86_CR4_PCIDE \
+ | X86_CR4_OSXSAVE | X86_CR4_SMEP | X86_CR4_FSGSBASE \
+ | X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_VMXE \
+ | X86_CR4_SMAP | X86_CR4_PKE | X86_CR4_UMIP \
+ | X86_CR4_LAM_SUP | X86_CR4_CET))
+
+#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
+
+#define DR6_BUS_LOCK (1 << 11)
+#define DR6_BD (1 << 13)
+#define DR6_BS (1 << 14)
+#define DR6_BT (1 << 15)
+#define DR6_RTM (1 << 16)
+/*
+ * DR6_ACTIVE_LOW combines fixed-1 and active-low bits.
+ * We can regard all the bits in DR6_FIXED_1 as active_low bits;
+ * they will never be 0 for now, but when they are defined
+ * in the future it will require no code change.
+ *
+ * DR6_ACTIVE_LOW is also used as the init/reset value for DR6.
+ */
+#define DR6_ACTIVE_LOW 0xffff0ff0
+#define DR6_VOLATILE 0x0001e80f
+#define DR6_FIXED_1 (DR6_ACTIVE_LOW & ~DR6_VOLATILE)
+
+#define DR7_BP_EN_MASK 0x000000ff
+#define DR7_GE (1 << 9)
+#define DR7_GD (1 << 13)
+#define DR7_VOLATILE 0xffff2bff
+
void kvm_post_set_cr0(struct kvm_vcpu *vcpu, unsigned long old_cr0, unsigned long cr0);
void kvm_post_set_cr4(struct kvm_vcpu *vcpu, unsigned long old_cr4, unsigned long cr4);
int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
diff --git a/arch/x86/kvm/tss.h b/arch/x86/kvm/tss.h
index 117bf8bec07dca..55ced897584065 100644
--- a/arch/x86/kvm/tss.h
+++ b/arch/x86/kvm/tss.h
@@ -2,6 +2,10 @@
#ifndef __TSS_SEGMENT_H
#define __TSS_SEGMENT_H
+#include <linux/build_bug.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+
struct tss_segment_32 {
u32 prev_task_link;
u32 esp0;
@@ -64,4 +68,7 @@ struct tss_segment_16 {
#define RMODE_TSS_SIZE \
(TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
+static_assert(offsetof(struct tss_segment_32, io_map) == TSS_IOPB_BASE_OFFSET);
+static_assert(sizeof(struct tss_segment_32) == TSS_BASE_SIZE);
+
#endif
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 0626e835e9eb77..5ee6d0c3300953 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -115,6 +115,15 @@ EXPORT_SYMBOL_FOR_KVM_INTERNAL(kvm_host);
#define KVM_CAP_PMU_VALID_MASK KVM_PMU_CAP_DISABLE
+#define KVM_GUESTDBG_VALID_MASK \
+ (KVM_GUESTDBG_ENABLE | \
+ KVM_GUESTDBG_SINGLESTEP | \
+ KVM_GUESTDBG_USE_HW_BP | \
+ KVM_GUESTDBG_USE_SW_BP | \
+ KVM_GUESTDBG_INJECT_BP | \
+ KVM_GUESTDBG_INJECT_DB | \
+ KVM_GUESTDBG_BLOCKIRQ)
+
#define KVM_X2APIC_API_VALID_FLAGS (KVM_X2APIC_API_USE_32BIT_IDS | \
KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK | \
KVM_X2APIC_ENABLE_SUPPRESS_EOI_BROADCAST | \
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index 8ece468087a8ee..494d97e9a9c9f3 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -482,6 +482,12 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu);
void kvm_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector);
+enum kvm_task_switch_reason {
+ TASK_SWITCH_CALL = 0,
+ TASK_SWITCH_IRET = 1,
+ TASK_SWITCH_JMP = 2,
+ TASK_SWITCH_GATE = 3,
+};
int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index,
int reason, bool has_error_code, u32 error_code);
|
| 3/2 | 2026/06/25 22:42 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 10028 output: 74 thoughts: 835 Thoughts: **KVM x86 Code Refactoring Analysis** Alright, let's break this down. From what I'm seeing, this patch is primarily focused on reorganizing and tidying up the KVM x86 code. The core of it seems to be moving macro and struct definitions around. Specifically, things are being moved out of `arch/x86/include/asm/kvm_host.h` and redistributed into various other x86 KVM header and source files like `hyperv.h`, `lapic.c`, `lapic.h`, `regs.h`, `x86.c`, and `x86.h`. No fundamental logic changes there, just re-arranging. The addition of `__read_mostly` to `tdp_enabled`, `tdp_mmu_enabled`, and `eager_page_split` within `arch/x86/kvm/mmu.h` and `mmu.c` also catches my eye. This is a classic optimization; a hint to the compiler to place these variables in a read-mostly section, likely for cache efficiency. That's a layout change, not a functional change in terms of the actual algorithm or behavior. Then there are those `static_assert`s added in `arch/x86/kvm/tss.h`. These are compile-time checks, ensuring certain assumptions about the `tss_segment_32` structure hold true. Again, no runtime impact on functionality. I had to double-check the enum change. Renaming the enum for task switch reasons from an anonymous enum to `kvm_task_switch_reason` is definitely just for clarity and maintainability. And that include guard fix in `arch/x86/kvm/msrs.h`, changing the `#ifndef` macro name, that's just good hygiene. I took a good look at the `__read_mostly` changes in more detail and confirmed that they are just section attributes and therefore not related to any functional change. So, after a thorough review, this patch appears to be purely a refactoring effort. It's a cleanup, improving code organization and potentially performance with `__read_mostly`. I'm confident there are no functional alterations that require fuzzing. My assessment is that this patch is not worth fuzzing. I'll flag `WorthFuzzing=false`. |
| 4/2 | 2026/06/25 22:42 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch only moves definitions, macros, and structs between header and source files, adds __read_mostly attributes, and introduces compile-time static_asserts. There are no functional changes to the kernel logic.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch only moves definitions, macros, and structs between header and source files, adds __read_mostly attributes, and introduces compile-time static_asserts. There are no functional changes to the kernel logic.",
"WorthFuzzing": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|