]>
Commit | Line | Data |
---|---|---|
c86c7721 EA |
1 | /* |
2 | * VGIC: KVM DEVICE API | |
3 | * | |
4 | * Copyright (C) 2015 ARM Ltd. | |
5 | * Author: Marc Zyngier <marc.zyngier@arm.com> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | */ | |
16 | #include <linux/kvm_host.h> | |
17 | #include <kvm/arm_vgic.h> | |
18 | ||
19 | /* common helpers */ | |
20 | ||
21 | static int vgic_create(struct kvm_device *dev, u32 type) | |
22 | { | |
23 | return kvm_vgic_create(dev->kvm, type); | |
24 | } | |
25 | ||
26 | static void vgic_destroy(struct kvm_device *dev) | |
27 | { | |
28 | kfree(dev); | |
29 | } | |
30 | ||
31 | void kvm_register_vgic_device(unsigned long type) | |
32 | { | |
33 | switch (type) { | |
34 | case KVM_DEV_TYPE_ARM_VGIC_V2: | |
35 | kvm_register_device_ops(&kvm_arm_vgic_v2_ops, | |
36 | KVM_DEV_TYPE_ARM_VGIC_V2); | |
37 | break; | |
38 | #ifdef CONFIG_KVM_ARM_VGIC_V3 | |
39 | case KVM_DEV_TYPE_ARM_VGIC_V3: | |
40 | kvm_register_device_ops(&kvm_arm_vgic_v3_ops, | |
41 | KVM_DEV_TYPE_ARM_VGIC_V3); | |
42 | break; | |
43 | #endif | |
44 | } | |
45 | } | |
46 | ||
47 | /* V2 ops */ | |
48 | ||
49 | static int vgic_v2_set_attr(struct kvm_device *dev, | |
50 | struct kvm_device_attr *attr) | |
51 | { | |
52 | return -ENXIO; | |
53 | } | |
54 | ||
55 | static int vgic_v2_get_attr(struct kvm_device *dev, | |
56 | struct kvm_device_attr *attr) | |
57 | { | |
58 | return -ENXIO; | |
59 | } | |
60 | ||
61 | static int vgic_v2_has_attr(struct kvm_device *dev, | |
62 | struct kvm_device_attr *attr) | |
63 | { | |
64 | return -ENXIO; | |
65 | } | |
66 | ||
67 | struct kvm_device_ops kvm_arm_vgic_v2_ops = { | |
68 | .name = "kvm-arm-vgic-v2", | |
69 | .create = vgic_create, | |
70 | .destroy = vgic_destroy, | |
71 | .set_attr = vgic_v2_set_attr, | |
72 | .get_attr = vgic_v2_get_attr, | |
73 | .has_attr = vgic_v2_has_attr, | |
74 | }; | |
75 | ||
76 | /* V3 ops */ | |
77 | ||
78 | #ifdef CONFIG_KVM_ARM_VGIC_V3 | |
79 | ||
80 | static int vgic_v3_set_attr(struct kvm_device *dev, | |
81 | struct kvm_device_attr *attr) | |
82 | { | |
83 | return -ENXIO; | |
84 | } | |
85 | ||
86 | static int vgic_v3_get_attr(struct kvm_device *dev, | |
87 | struct kvm_device_attr *attr) | |
88 | { | |
89 | return -ENXIO; | |
90 | } | |
91 | ||
92 | static int vgic_v3_has_attr(struct kvm_device *dev, | |
93 | struct kvm_device_attr *attr) | |
94 | { | |
95 | return -ENXIO; | |
96 | } | |
97 | ||
98 | struct kvm_device_ops kvm_arm_vgic_v3_ops = { | |
99 | .name = "kvm-arm-vgic-v3", | |
100 | .create = vgic_create, | |
101 | .destroy = vgic_destroy, | |
102 | .set_attr = vgic_v3_set_attr, | |
103 | .get_attr = vgic_v3_get_attr, | |
104 | .has_attr = vgic_v3_has_attr, | |
105 | }; | |
106 | ||
107 | #endif /* CONFIG_KVM_ARM_VGIC_V3 */ | |
108 |