Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: x86/xen: Move kvm_xen_hvm_config field into kvm_xen

Now that all KVM usage of the Xen HVM config information is buried behind
CONFIG_KVM_XEN=y, move the per-VM kvm_xen_hvm_config field out of kvm_arch
and into kvm_xen.

No functional change intended.

Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
Link: https://lore.kernel.org/r/20250215011437.1203084-6-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>

+16 -15
+2 -1
arch/x86/include/asm/kvm_host.h
··· 1188 1188 struct gfn_to_pfn_cache shinfo_cache; 1189 1189 struct idr evtchn_ports; 1190 1190 unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)]; 1191 + 1192 + struct kvm_xen_hvm_config hvm_config; 1191 1193 }; 1192 1194 #endif 1193 1195 ··· 1421 1419 1422 1420 #ifdef CONFIG_KVM_XEN 1423 1421 struct kvm_xen xen; 1424 - struct kvm_xen_hvm_config xen_hvm_config; 1425 1422 #endif 1426 1423 1427 1424 bool backwards_tsc_observed;
+1 -1
arch/x86/kvm/x86.c
··· 3188 3188 * problems if they observe PVCLOCK_TSC_STABLE_BIT in the pvclock flags. 3189 3189 */ 3190 3190 bool xen_pvclock_tsc_unstable = 3191 - ka->xen_hvm_config.flags & KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE; 3191 + ka->xen.hvm_config.flags & KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE; 3192 3192 #endif 3193 3193 3194 3194 kernel_ns = 0;
+10 -10
arch/x86/kvm/xen.c
··· 1280 1280 * Note, truncation is a non-issue as 'lm' is guaranteed to be 1281 1281 * false for a 32-bit kernel, i.e. when hva_t is only 4 bytes. 1282 1282 */ 1283 - hva_t blob_addr = lm ? kvm->arch.xen_hvm_config.blob_addr_64 1284 - : kvm->arch.xen_hvm_config.blob_addr_32; 1285 - u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64 1286 - : kvm->arch.xen_hvm_config.blob_size_32; 1283 + hva_t blob_addr = lm ? kvm->arch.xen.hvm_config.blob_addr_64 1284 + : kvm->arch.xen.hvm_config.blob_addr_32; 1285 + u8 blob_size = lm ? kvm->arch.xen.hvm_config.blob_size_64 1286 + : kvm->arch.xen.hvm_config.blob_size_32; 1287 1287 u8 *page; 1288 1288 int ret; 1289 1289 ··· 1335 1335 1336 1336 mutex_lock(&kvm->arch.xen.xen_lock); 1337 1337 1338 - if (xhc->msr && !kvm->arch.xen_hvm_config.msr) 1338 + if (xhc->msr && !kvm->arch.xen.hvm_config.msr) 1339 1339 static_branch_inc(&kvm_xen_enabled.key); 1340 - else if (!xhc->msr && kvm->arch.xen_hvm_config.msr) 1340 + else if (!xhc->msr && kvm->arch.xen.hvm_config.msr) 1341 1341 static_branch_slow_dec_deferred(&kvm_xen_enabled); 1342 1342 1343 - old_flags = kvm->arch.xen_hvm_config.flags; 1344 - memcpy(&kvm->arch.xen_hvm_config, xhc, sizeof(*xhc)); 1343 + old_flags = kvm->arch.xen.hvm_config.flags; 1344 + memcpy(&kvm->arch.xen.hvm_config, xhc, sizeof(*xhc)); 1345 1345 1346 1346 mutex_unlock(&kvm->arch.xen.xen_lock); 1347 1347 ··· 1422 1422 int i; 1423 1423 1424 1424 if (!lapic_in_kernel(vcpu) || 1425 - !(vcpu->kvm->arch.xen_hvm_config.flags & KVM_XEN_HVM_CONFIG_EVTCHN_SEND)) 1425 + !(vcpu->kvm->arch.xen.hvm_config.flags & KVM_XEN_HVM_CONFIG_EVTCHN_SEND)) 1426 1426 return false; 1427 1427 1428 1428 if (IS_ENABLED(CONFIG_64BIT) && !longmode) { ··· 2300 2300 } 2301 2301 idr_destroy(&kvm->arch.xen.evtchn_ports); 2302 2302 2303 - if (kvm->arch.xen_hvm_config.msr) 2303 + if (kvm->arch.xen.hvm_config.msr) 2304 2304 static_branch_slow_dec_deferred(&kvm_xen_enabled); 2305 2305 }
+3 -3
arch/x86/kvm/xen.h
··· 53 53 static inline bool kvm_xen_msr_enabled(struct kvm *kvm) 54 54 { 55 55 return static_branch_unlikely(&kvm_xen_enabled.key) && 56 - kvm->arch.xen_hvm_config.msr; 56 + kvm->arch.xen.hvm_config.msr; 57 57 } 58 58 59 59 static inline bool kvm_xen_is_hypercall_page_msr(struct kvm *kvm, u32 msr) ··· 61 61 if (!static_branch_unlikely(&kvm_xen_enabled.key)) 62 62 return false; 63 63 64 - return msr && msr == kvm->arch.xen_hvm_config.msr; 64 + return msr && msr == kvm->arch.xen.hvm_config.msr; 65 65 } 66 66 67 67 static inline bool kvm_xen_hypercall_enabled(struct kvm *kvm) 68 68 { 69 69 return static_branch_unlikely(&kvm_xen_enabled.key) && 70 - (kvm->arch.xen_hvm_config.flags & 70 + (kvm->arch.xen.hvm_config.flags & 71 71 KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL); 72 72 } 73 73