Skip to content

Commit 0409220

Browse files
committed
Merge tag 'kvm-arm-for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into kvm-next
Changed for the 3.16 merge window. This includes KVM support for PSCI v0.2 and also includes generic Linux support for PSCI v0.2 (on hosts that advertise that feature via their DT), since the latter depends on headers introduced by the former. Finally there's a small patch from Marc that enables Cortex-A53 support.
2 parents 9b88ae9 + 1252b33 commit 0409220

25 files changed

Lines changed: 831 additions & 116 deletions

File tree

‎Documentation/devicetree/bindings/arm/psci.txt‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@ to #0.
2121

2222
Main node required properties:
2323

24-
- compatible : Must be "arm,psci"
24+
- compatible : should contain at least one of:
25+
26+
* "arm,psci" : for implementations complying to PSCI versions prior to
27+
0.2. For these cases function IDs must be provided.
28+
29+
* "arm,psci-0.2" : for implementations complying to PSCI 0.2. Function
30+
IDs are not required and should be ignored by an OS with PSCI 0.2
31+
support, but are permitted to be present for compatibility with
32+
existing software when "arm,psci" is later in the compatible list.
2533

2634
- method : The method of calling the PSCI firmware. Permitted
2735
values are:
@@ -45,6 +53,8 @@ Main node optional properties:
4553

4654
Example:
4755

56+
Case 1: PSCI v0.1 only.
57+
4858
psci {
4959
compatible = "arm,psci";
5060
method = "smc";
@@ -53,3 +63,28 @@ Example:
5363
cpu_on = <0x95c10002>;
5464
migrate = <0x95c10003>;
5565
};
66+
67+
68+
Case 2: PSCI v0.2 only
69+
70+
psci {
71+
compatible = "arm,psci-0.2";
72+
method = "smc";
73+
};
74+
75+
Case 3: PSCI v0.2 and PSCI v0.1.
76+
77+
A DTB may provide IDs for use by kernels without PSCI 0.2 support,
78+
enabling firmware and hypervisors to support existing and new kernels.
79+
These IDs will be ignored by kernels with PSCI 0.2 support, which will
80+
use the standard PSCI 0.2 IDs exclusively.
81+
82+
psci {
83+
compatible = "arm,psci-0.2", "arm,psci";
84+
method = "hvc";
85+
86+
cpu_on = < arbitrary value >;
87+
cpu_off = < arbitrary value >;
88+
89+
...
90+
};

‎Documentation/virtual/kvm/api.txt‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,6 +2378,8 @@ Possible features:
23782378
Depends on KVM_CAP_ARM_PSCI.
23792379
- KVM_ARM_VCPU_EL1_32BIT: Starts the CPU in a 32bit mode.
23802380
Depends on KVM_CAP_ARM_EL1_32BIT (arm64 only).
2381+
- KVM_ARM_VCPU_PSCI_0_2: Emulate PSCI v0.2 for the CPU.
2382+
Depends on KVM_CAP_ARM_PSCI_0_2.
23812383

23822384

23832385
4.83 KVM_ARM_PREFERRED_TARGET
@@ -2740,6 +2742,21 @@ It gets triggered whenever both KVM_CAP_PPC_EPR are enabled and an
27402742
external interrupt has just been delivered into the guest. User space
27412743
should put the acknowledged interrupt vector into the 'epr' field.
27422744

2745+
/* KVM_EXIT_SYSTEM_EVENT */
2746+
struct {
2747+
#define KVM_SYSTEM_EVENT_SHUTDOWN 1
2748+
#define KVM_SYSTEM_EVENT_RESET 2
2749+
__u32 type;
2750+
__u64 flags;
2751+
} system_event;
2752+
2753+
If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered
2754+
a system-level event using some architecture specific mechanism (hypercall
2755+
or some special instruction). In case of ARM/ARM64, this is triggered using
2756+
HVC instruction based PSCI call from the vcpu. The 'type' field describes
2757+
the system-level event type. The 'flags' field describes architecture
2758+
specific flags for the system-level event.
2759+
27432760
/* Fix the size of the union. */
27442761
char padding[256];
27452762
};

‎arch/arm/include/asm/kvm_host.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
3737
#define KVM_HAVE_ONE_REG
3838

39-
#define KVM_VCPU_MAX_FEATURES 1
39+
#define KVM_VCPU_MAX_FEATURES 2
4040

4141
#include <kvm/arm_vgic.h>
4242

‎arch/arm/include/asm/kvm_psci.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
#ifndef __ARM_KVM_PSCI_H__
1919
#define __ARM_KVM_PSCI_H__
2020

21-
bool kvm_psci_call(struct kvm_vcpu *vcpu);
21+
#define KVM_ARM_PSCI_0_1 1
22+
#define KVM_ARM_PSCI_0_2 2
23+
24+
int kvm_psci_version(struct kvm_vcpu *vcpu);
25+
int kvm_psci_call(struct kvm_vcpu *vcpu);
2226

2327
#endif /* __ARM_KVM_PSCI_H__ */

‎arch/arm/include/asm/psci.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ struct psci_operations {
2929
int (*cpu_off)(struct psci_power_state state);
3030
int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
3131
int (*migrate)(unsigned long cpuid);
32+
int (*affinity_info)(unsigned long target_affinity,
33+
unsigned long lowest_affinity_level);
34+
int (*migrate_info_type)(void);
3235
};
3336

3437
extern struct psci_operations psci_ops;
3538
extern struct smp_operations psci_smp_ops;
3639

3740
#ifdef CONFIG_ARM_PSCI
38-
void psci_init(void);
41+
int psci_init(void);
3942
bool psci_smp_available(void);
4043
#else
41-
static inline void psci_init(void) { }
44+
static inline int psci_init(void) { }
4245
static inline bool psci_smp_available(void) { return false; }
4346
#endif
4447

‎arch/arm/include/uapi/asm/kvm.h‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define __ARM_KVM_H__
2121

2222
#include <linux/types.h>
23+
#include <linux/psci.h>
2324
#include <asm/ptrace.h>
2425

2526
#define __KVM_HAVE_GUEST_DEBUG
@@ -83,6 +84,7 @@ struct kvm_regs {
8384
#define KVM_VGIC_V2_CPU_SIZE 0x2000
8485

8586
#define KVM_ARM_VCPU_POWER_OFF 0 /* CPU is started in OFF state */
87+
#define KVM_ARM_VCPU_PSCI_0_2 1 /* CPU uses PSCI v0.2 */
8688

8789
struct kvm_vcpu_init {
8890
__u32 target;
@@ -201,9 +203,9 @@ struct kvm_arch_memory_slot {
201203
#define KVM_PSCI_FN_CPU_ON KVM_PSCI_FN(2)
202204
#define KVM_PSCI_FN_MIGRATE KVM_PSCI_FN(3)
203205

204-
#define KVM_PSCI_RET_SUCCESS 0
205-
#define KVM_PSCI_RET_NI ((unsigned long)-1)
206-
#define KVM_PSCI_RET_INVAL ((unsigned long)-2)
207-
#define KVM_PSCI_RET_DENIED ((unsigned long)-3)
206+
#define KVM_PSCI_RET_SUCCESS PSCI_RET_SUCCESS
207+
#define KVM_PSCI_RET_NI PSCI_RET_NOT_SUPPORTED
208+
#define KVM_PSCI_RET_INVAL PSCI_RET_INVALID_PARAMS
209+
#define KVM_PSCI_RET_DENIED PSCI_RET_DENIED
208210

209211
#endif /* __ARM_KVM_H__ */

0 commit comments

Comments
 (0)