Skip to content

Commit 26e228e

Browse files
committed
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>
1 parent 69e5a7d commit 26e228e

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

arch/x86/include/asm/kvm_host.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,8 @@ struct kvm_xen {
11881188
struct gfn_to_pfn_cache shinfo_cache;
11891189
struct idr evtchn_ports;
11901190
unsigned long poll_mask[BITS_TO_LONGS(KVM_MAX_VCPUS)];
1191+
1192+
struct kvm_xen_hvm_config hvm_config;
11911193
};
11921194
#endif
11931195

@@ -1419,7 +1421,6 @@ struct kvm_arch {
14191421

14201422
#ifdef CONFIG_KVM_XEN
14211423
struct kvm_xen xen;
1422-
struct kvm_xen_hvm_config xen_hvm_config;
14231424
#endif
14241425

14251426
bool backwards_tsc_observed;

arch/x86/kvm/x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3188,7 +3188,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
31883188
* problems if they observe PVCLOCK_TSC_STABLE_BIT in the pvclock flags.
31893189
*/
31903190
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;
31923192
#endif
31933193

31943194
kernel_ns = 0;

arch/x86/kvm/xen.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,10 +1280,10 @@ int kvm_xen_write_hypercall_page(struct kvm_vcpu *vcpu, u64 data)
12801280
* Note, truncation is a non-issue as 'lm' is guaranteed to be
12811281
* false for a 32-bit kernel, i.e. when hva_t is only 4 bytes.
12821282
*/
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;
12871287
u8 *page;
12881288
int ret;
12891289

@@ -1335,13 +1335,13 @@ int kvm_xen_hvm_config(struct kvm *kvm, struct kvm_xen_hvm_config *xhc)
13351335

13361336
mutex_lock(&kvm->arch.xen.xen_lock);
13371337

1338-
if (xhc->msr && !kvm->arch.xen_hvm_config.msr)
1338+
if (xhc->msr && !kvm->arch.xen.hvm_config.msr)
13391339
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)
13411341
static_branch_slow_dec_deferred(&kvm_xen_enabled);
13421342

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));
13451345

13461346
mutex_unlock(&kvm->arch.xen.xen_lock);
13471347

@@ -1422,7 +1422,7 @@ static bool kvm_xen_schedop_poll(struct kvm_vcpu *vcpu, bool longmode,
14221422
int i;
14231423

14241424
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))
14261426
return false;
14271427

14281428
if (IS_ENABLED(CONFIG_64BIT) && !longmode) {
@@ -2300,6 +2300,6 @@ void kvm_xen_destroy_vm(struct kvm *kvm)
23002300
}
23012301
idr_destroy(&kvm->arch.xen.evtchn_ports);
23022302

2303-
if (kvm->arch.xen_hvm_config.msr)
2303+
if (kvm->arch.xen.hvm_config.msr)
23042304
static_branch_slow_dec_deferred(&kvm_xen_enabled);
23052305
}

arch/x86/kvm/xen.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,21 @@ static inline void kvm_xen_sw_enable_lapic(struct kvm_vcpu *vcpu)
5353
static inline bool kvm_xen_msr_enabled(struct kvm *kvm)
5454
{
5555
return static_branch_unlikely(&kvm_xen_enabled.key) &&
56-
kvm->arch.xen_hvm_config.msr;
56+
kvm->arch.xen.hvm_config.msr;
5757
}
5858

5959
static inline bool kvm_xen_is_hypercall_page_msr(struct kvm *kvm, u32 msr)
6060
{
6161
if (!static_branch_unlikely(&kvm_xen_enabled.key))
6262
return false;
6363

64-
return msr && msr == kvm->arch.xen_hvm_config.msr;
64+
return msr && msr == kvm->arch.xen.hvm_config.msr;
6565
}
6666

6767
static inline bool kvm_xen_hypercall_enabled(struct kvm *kvm)
6868
{
6969
return static_branch_unlikely(&kvm_xen_enabled.key) &&
70-
(kvm->arch.xen_hvm_config.flags &
70+
(kvm->arch.xen.hvm_config.flags &
7171
KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL);
7272
}
7373

0 commit comments

Comments
 (0)