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
7#ifndef __ARM_KVM_HOST_H__7#ifndef __ARM_KVM_HOST_H__
8#define __ARM_KVM_HOST_H__8#define __ARM_KVM_HOST_H__
9 9
10#include <linux/arm-smccc.h>
10#include <linux/errno.h>11#include <linux/errno.h>
11#include <linux/types.h>12#include <linux/types.h>
12#include <linux/kvm_types.h>13#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
323int kvm_perf_init(void);324int kvm_perf_init(void);
324int kvm_perf_teardown(void);325int kvm_perf_teardown(void);
325 326
327static inline long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
328{
329 return SMCCC_RET_NOT_SUPPORTED;
330}
331
326void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);332void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);
327 333
328struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);334struct 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
478int kvm_perf_init(void);478int kvm_perf_init(void);
479int kvm_perf_teardown(void);479int kvm_perf_teardown(void);
480 480
481long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu);
482
481void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);483void kvm_set_sei_esr(struct kvm_vcpu *vcpu, u64 syndrome);
482 484
483struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);485struct 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
9struct 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
14kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/arm.o $(KVM)/arm/mmu.o $(KVM)/arm/mmio.o14kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/arm.o $(KVM)/arm/mmu.o $(KVM)/arm/mmio.o
15kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/psci.o $(KVM)/arm/perf.o15kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/psci.o $(KVM)/arm/perf.o
16kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hypercalls.o16kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hypercalls.o
17kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/pvtime.o
17 18
18kvm-$(CONFIG_KVM_ARM_HOST) += inject_fault.o regmap.o va_layout.o19kvm-$(CONFIG_KVM_ARM_HOST) += inject_fault.o regmap.o va_layout.o
19kvm-$(CONFIG_KVM_ARM_HOST) += hyp.o hyp-init.o handle_exit.o20kvm-$(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
45#define ARM_SMCCC_OWNER_SIP 245#define ARM_SMCCC_OWNER_SIP 2
46#define ARM_SMCCC_OWNER_OEM 346#define ARM_SMCCC_OWNER_OEM 3
47#define ARM_SMCCC_OWNER_STANDARD 447#define ARM_SMCCC_OWNER_STANDARD 4
48#define ARM_SMCCC_OWNER_STANDARD_HYP 5
48#define ARM_SMCCC_OWNER_TRUSTED_APP 4849#define ARM_SMCCC_OWNER_TRUSTED_APP 48
49#define ARM_SMCCC_OWNER_TRUSTED_APP_END 4950#define ARM_SMCCC_OWNER_TRUSTED_APP_END 49
50#define ARM_SMCCC_OWNER_TRUSTED_OS 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
318#define SMCCC_RET_NOT_SUPPORTED -1319#define SMCCC_RET_NOT_SUPPORTED -1
319#define SMCCC_RET_NOT_REQUIRED -2320#define SMCCC_RET_NOT_REQUIRED -2
320 321
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
321#endif /*__ASSEMBLY__*/335#endif /*__ASSEMBLY__*/
322#endif /*__LINUX_ARM_SMCCC_H*/336#endif /*__LINUX_ARM_SMCCC_H*/
virt/kvm/arm/hypercalls.c+7−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
12int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)12int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
13{13{
14 u32 func_id = smccc_get_function(vcpu);14 u32 func_id = smccc_get_function(vcpu);
15 u32 val = SMCCC_RET_NOT_SUPPORTED;15 long val = SMCCC_RET_NOT_SUPPORTED;
16 u32 feature;16 u32 feature;
17 17
18 switch (func_id) {18 switch (func_id) {
@@ -48,8 +48,14 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) · 29 unmodified lines
48 break;48 break;
49 }49 }
50 break;50 break;
51 case ARM_SMCCC_HV_PV_TIME_FEATURES:
52 val = SMCCC_RET_SUCCESS;
53 break;
51 }54 }
52 break;55 break;
56 case ARM_SMCCC_HV_PV_TIME_FEATURES:
57 val = kvm_hypercall_pv_features(vcpu);
58 break;
53 default:59 default:
54 return kvm_psci_call(vcpu);60 return kvm_psci_call(vcpu);
55 }61 }
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
8long 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