History

KVM: arm64: Implement PV_TIME_FEATURES call

This provides a mechanism for querying which paravirtualized time features are available in this hypervisor. Also add the header file which defines the ABI for the paravirtualized time features we're about to add.

Steven Price committed 7 years ago

Commit b48c1a41 parent 55009c67 files · +67 −1Browse files

Unified · Split

7 files
  1. arch/arm/include/asm/kvm_host.h +6 −0
  2. arch/arm64/include/asm/kvm_host.h +2 −0
  3. arch/arm64/include/asm/pvclock-abi.h +17 −0
  4. arch/arm64/kvm/Makefile +1 −0
  5. include/linux/arm-smccc.h +14 −0
  6. virt/kvm/arm/hypercalls.c +7 −1
  7. virt/kvm/arm/pvtime.c +20 −0
arch/arm/include/asm/kvm_host.h+6−0
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #ifndef __ARM_KVM_HOST_H__
88 #define __ARM_KVM_HOST_H__
99
10+#include <linux/arm-smccc.h>
1011 #include <linux/errno.h>
1112 #include <linux/types.h>
1213 #include <linux/kvm_types.h>
@@ -323,6 +324,11 @@ static inline int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext) · 310 unmodified lines
323324 int kvm_perf_init(void);
324325 int kvm_perf_teardown(void);
325326
327+static inline long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
328+{
329+ return SMCCC_RET_NOT_SUPPORTED;
330+}
331+
326332 void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);
327333
328334 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);
arch/arm64/include/asm/kvm_host.h+2−0
@@ -478,6 +478,8 @@ void handle_exit_early(struct kvm_vcpu *vcpu, struct kvm_run *run, · 477 unmodified lines
478478 int kvm_perf_init(void);
479479 int kvm_perf_teardown(void);
480480
481+long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu);
482+
481483 void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);
482484
483485 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);
arch/arm64/include/asm/pvclock-abi.h+17−0
@@ -0,0 +1,17 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/* Copyright (C) 2019 Arm Ltd. */
3+
4+#ifndef __ASM_PVCLOCK_ABI_H
5+#define __ASM_PVCLOCK_ABI_H
6+
7+/* The below structure is defined in ARM DEN0057A */
8+
9+struct pvclock_vcpu_stolen_time {
10+ __le32 revision;
11+ __le32 attributes;
12+ __le64 stolen_time;
13+ /* Structure must be 64 byte aligned, pad to that size */
14+ u8 padding[48];
15+} __packed;
16+
17+#endif
arch/arm64/kvm/Makefile+1−0
@@ -14,6 +14,7 @@ kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/e · 13 unmodified lines
1414 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/arm.o $(KVM)/arm/mmu.o $(KVM)/arm/mmio.o
1515 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/psci.o $(KVM)/arm/perf.o
1616 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hypercalls.o
17+kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/pvtime.o
1718
1819 kvm-$(CONFIG_KVM_ARM_HOST) += inject_fault.o regmap.o va_layout.o
1920 kvm-$(CONFIG_KVM_ARM_HOST) += hyp.o hyp-init.o handle_exit.o
include/linux/arm-smccc.h+14−0
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 #define ARM_SMCCC_OWNER_SIP 2
4646 #define ARM_SMCCC_OWNER_OEM 3
4747 #define ARM_SMCCC_OWNER_STANDARD 4
48+#define ARM_SMCCC_OWNER_STANDARD_HYP 5
4849 #define ARM_SMCCC_OWNER_TRUSTED_APP 48
4950 #define ARM_SMCCC_OWNER_TRUSTED_APP_END 49
5051 #define ARM_SMCCC_OWNER_TRUSTED_OS 50
@@ -318,5 +319,18 @@ asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1, · 267 unmodified lines
318319 #define SMCCC_RET_NOT_SUPPORTED -1
319320 #define SMCCC_RET_NOT_REQUIRED -2
320321
322+/* Paravirtualised time calls (defined by ARM DEN0057A) */
323+#define ARM_SMCCC_HV_PV_TIME_FEATURES \
324+ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
325+ ARM_SMCCC_SMC_64, \
326+ ARM_SMCCC_OWNER_STANDARD_HYP, \
327+ 0x20)
328+
329+#define ARM_SMCCC_HV_PV_TIME_ST \
330+ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
331+ ARM_SMCCC_SMC_64, \
332+ ARM_SMCCC_OWNER_STANDARD_HYP, \
333+ 0x21)
334+
321335 #endif /*__ASSEMBLY__*/
322336 #endif /*__LINUX_ARM_SMCCC_H*/
virt/kvm/arm/hypercalls.c+7−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
1313 {
1414 u32 func_id = smccc_get_function(vcpu);
15− u32 val = SMCCC_RET_NOT_SUPPORTED;
15+ long val = SMCCC_RET_NOT_SUPPORTED;
1616 u32 feature;
1717
1818 switch (func_id) {
@@ -48,8 +48,14 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) · 29 unmodified lines
4848 break;
4949 }
5050 break;
51+ case ARM_SMCCC_HV_PV_TIME_FEATURES:
52+ val = SMCCC_RET_SUCCESS;
53+ break;
5154 }
5255 break;
56+ case ARM_SMCCC_HV_PV_TIME_FEATURES:
57+ val = kvm_hypercall_pv_features(vcpu);
58+ break;
5359 default:
5460 return kvm_psci_call(vcpu);
5561 }
virt/kvm/arm/pvtime.c+20−0
@@ -0,0 +1,20 @@
1+// SPDX-License-Identifier: GPL-2.0
2+// Copyright (C) 2019 Arm Ltd.
3+
4+#include <linux/arm-smccc.h>
5+
6+#include <kvm/arm_hypercalls.h>
7+
8+long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
9+{
10+ u32 feature = smccc_get_arg1(vcpu);
11+ long val = SMCCC_RET_NOT_SUPPORTED;
12+
13+ switch (feature) {
14+ case ARM_SMCCC_HV_PV_TIME_FEATURES:
15+ val = SMCCC_RET_SUCCESS;
16+ break;
17+ }
18+
19+ return val;
20+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t