#include <linux/arm-smccc.h>
#include <linux/kvm_host.h>
#include <linux/sched/stat.h>
#include <asm/kvm_mmu.h>
#include <asm/pvclock-abi.h>
#include <kvm/arm_hypercalls.h>
Go to the source code of this file.
◆ kvm_arm_pvtime_get_attr()
int kvm_arm_pvtime_get_attr |
( |
struct kvm_vcpu * |
vcpu, |
|
|
struct kvm_device_attr * |
attr |
|
) |
| |
Definition at line 107 of file pvtime.c.
110 u64 __user *user = (u64 __user *)attr->addr;
114 attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
117 ipa = vcpu->arch.steal.base;
119 if (put_user(ipa, user))
bool kvm_arm_pvtime_supported(void)
◆ kvm_arm_pvtime_has_attr()
int kvm_arm_pvtime_has_attr |
( |
struct kvm_vcpu * |
vcpu, |
|
|
struct kvm_device_attr * |
attr |
|
) |
| |
Definition at line 124 of file pvtime.c.
127 switch (attr->attr) {
128 case KVM_ARM_VCPU_PVTIME_IPA:
◆ kvm_arm_pvtime_set_attr()
int kvm_arm_pvtime_set_attr |
( |
struct kvm_vcpu * |
vcpu, |
|
|
struct kvm_device_attr * |
attr |
|
) |
| |
Definition at line 75 of file pvtime.c.
78 u64 __user *user = (u64 __user *)attr->addr;
79 struct kvm *kvm = vcpu->kvm;
85 attr->attr != KVM_ARM_VCPU_PVTIME_IPA)
88 if (get_user(ipa, user))
90 if (!IS_ALIGNED(ipa, 64))
92 if (vcpu->arch.steal.base != INVALID_GPA)
96 idx = srcu_read_lock(&kvm->srcu);
97 if (kvm_is_error_hva(
gfn_to_hva(kvm, ipa >> PAGE_SHIFT)))
99 srcu_read_unlock(&kvm->srcu, idx);
102 vcpu->arch.steal.base = ipa;
unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn)
◆ kvm_arm_pvtime_supported()
bool kvm_arm_pvtime_supported |
( |
void |
| ) |
|
Definition at line 70 of file pvtime.c.
72 return !!sched_info_on();
◆ kvm_hypercall_pv_features()
long kvm_hypercall_pv_features |
( |
struct kvm_vcpu * |
vcpu | ) |
|
Definition at line 35 of file pvtime.c.
38 long val = SMCCC_RET_NOT_SUPPORTED;
41 case ARM_SMCCC_HV_PV_TIME_FEATURES:
42 case ARM_SMCCC_HV_PV_TIME_ST:
43 if (vcpu->arch.steal.base != INVALID_GPA)
44 val = SMCCC_RET_SUCCESS;
static unsigned long smccc_get_arg1(struct kvm_vcpu *vcpu)
◆ kvm_init_stolen_time()
gpa_t kvm_init_stolen_time |
( |
struct kvm_vcpu * |
vcpu | ) |
|
Definition at line 51 of file pvtime.c.
53 struct pvclock_vcpu_stolen_time init_values = {};
54 struct kvm *kvm = vcpu->kvm;
55 u64
base = vcpu->arch.steal.base;
57 if (
base == INVALID_GPA)
64 vcpu->arch.steal.last_steal = current->sched_info.run_delay;
65 kvm_write_guest_lock(kvm,
base, &init_values,
sizeof(init_values));
static unsigned long base
◆ kvm_update_stolen_time()
void kvm_update_stolen_time |
( |
struct kvm_vcpu * |
vcpu | ) |
|
Definition at line 13 of file pvtime.c.
15 struct kvm *kvm = vcpu->kvm;
16 u64
base = vcpu->arch.steal.base;
17 u64 last_steal = vcpu->arch.steal.last_steal;
18 u64 offset = offsetof(
struct pvclock_vcpu_stolen_time, stolen_time);
22 if (
base == INVALID_GPA)
25 idx = srcu_read_lock(&kvm->srcu);
26 if (!kvm_get_guest(kvm,
base + offset, steal)) {
27 steal = le64_to_cpu(steal);
28 vcpu->arch.steal.last_steal = READ_ONCE(current->sched_info.run_delay);
29 steal += vcpu->arch.steal.last_steal - last_steal;
30 kvm_put_guest(kvm,
base + offset, cpu_to_le64(steal));
32 srcu_read_unlock(&kvm->srcu, idx);