Skip to content

Commit a25e910

Browse files
Andrew JonesMarc Zyngier
authored andcommitted
KVM: arm64: pvtime: Ensure task delay accounting is enabled
Ensure we're actually accounting run_delay before we claim that we'll expose it to the guest. If we're not, then we just pretend like steal time isn't supported in order to avoid any confusion. Signed-off-by: Andrew Jones <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 66b7e05 commit a25e910

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

arch/arm64/kvm/pvtime.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/arm-smccc.h>
55
#include <linux/kvm_host.h>
6+
#include <linux/sched/stat.h>
67

78
#include <asm/kvm_mmu.h>
89
#include <asm/pvclock-abi.h>
@@ -73,6 +74,11 @@ gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu)
7374
return base;
7475
}
7576

77+
static bool kvm_arm_pvtime_supported(void)
78+
{
79+
return !!sched_info_on();
80+
}
81+
7682
int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
7783
struct kvm_device_attr *attr)
7884
{
@@ -82,7 +88,8 @@ int kvm_arm_pvtime_set_attr(struct kvm_vcpu *vcpu,
8288
int ret = 0;
8389
int idx;
8490

85-
if (attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
91+
if (!kvm_arm_pvtime_supported() ||
92+
attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
8693
return -ENXIO;
8794

8895
if (get_user(ipa, user))
@@ -110,7 +117,8 @@ int kvm_arm_pvtime_get_attr(struct kvm_vcpu *vcpu,
110117
u64 __user *user = (u64 __user *)attr->addr;
111118
u64 ipa;
112119

113-
if (attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
120+
if (!kvm_arm_pvtime_supported() ||
121+
attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
114122
return -ENXIO;
115123

116124
ipa = vcpu->arch.steal.base;
@@ -125,7 +133,8 @@ int kvm_arm_pvtime_has_attr(struct kvm_vcpu *vcpu,
125133
{
126134
switch (attr->attr) {
127135
case KVM_ARM_VCPU_PVTIME_IPA:
128-
return 0;
136+
if (kvm_arm_pvtime_supported())
137+
return 0;
129138
}
130139
return -ENXIO;
131140
}

0 commit comments

Comments
 (0)