File tree Expand file tree Collapse file tree 8 files changed +88
-0
lines changed
Documentation/virt/kvm/arm Expand file tree Collapse file tree 8 files changed +88
-0
lines changed Original file line number Diff line number Diff line change @@ -44,3 +44,25 @@ Provides a discovery mechanism for other KVM/arm64 hypercalls.
44
44
----------------------------------------
45
45
46
46
See ptp_kvm.rst
47
+
48
+ ``ARM_SMCCC_KVM_FUNC_HYP_MEMINFO ``
49
+ ----------------------------------
50
+
51
+ Query the memory protection parameters for a pKVM protected virtual machine.
52
+
53
+ +---------------------+-------------------------------------------------------------+
54
+ | Presence: | Optional; pKVM protected guests only. |
55
+ +---------------------+-------------------------------------------------------------+
56
+ | Calling convention: | HVC64 |
57
+ +---------------------+----------+--------------------------------------------------+
58
+ | Function ID: | (uint32) | 0xC6000002 |
59
+ +---------------------+----------+----+---------------------------------------------+
60
+ | Arguments: | (uint64) | R1 | Reserved / Must be zero |
61
+ | +----------+----+---------------------------------------------+
62
+ | | (uint64) | R2 | Reserved / Must be zero |
63
+ | +----------+----+---------------------------------------------+
64
+ | | (uint64) | R3 | Reserved / Must be zero |
65
+ +---------------------+----------+----+---------------------------------------------+
66
+ | Return Values: | (int64) | R0 | ``INVALID_PARAMETER (-3) `` on error, else |
67
+ | | | | memory protection granule in bytes |
68
+ +---------------------+----------+----+---------------------------------------------+
Original file line number Diff line number Diff line change 7
7
void kvm_init_hyp_services (void );
8
8
bool kvm_arm_hyp_service_available (u32 func_id );
9
9
10
+ #ifdef CONFIG_ARM_PKVM_GUEST
11
+ void pkvm_init_hyp_services (void );
12
+ #else
13
+ static inline void pkvm_init_hyp_services (void ) { };
14
+ #endif
15
+
10
16
static inline void kvm_arch_init_hyp_services (void )
11
17
{
18
+ pkvm_init_hyp_services ();
12
19
};
13
20
14
21
#endif
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ config TSM_REPORTS
9
9
10
10
source "drivers/virt/coco/efi_secret/Kconfig"
11
11
12
+ source "drivers/virt/coco/pkvm-guest/Kconfig"
13
+
12
14
source "drivers/virt/coco/sev-guest/Kconfig"
13
15
14
16
source "drivers/virt/coco/tdx-guest/Kconfig"
Original file line number Diff line number Diff line change 4
4
#
5
5
obj-$(CONFIG_TSM_REPORTS) += tsm.o
6
6
obj-$(CONFIG_EFI_SECRET) += efi_secret/
7
+ obj-$(CONFIG_ARM_PKVM_GUEST) += pkvm-guest/
7
8
obj-$(CONFIG_SEV_GUEST) += sev-guest/
8
9
obj-$(CONFIG_INTEL_TDX_GUEST) += tdx-guest/
Original file line number Diff line number Diff line change
1
+ config ARM_PKVM_GUEST
2
+ bool "Arm pKVM protected guest driver"
3
+ depends on ARM64
4
+ help
5
+ Protected guests running under the pKVM hypervisor on arm64
6
+ are isolated from the host and must issue hypercalls to enable
7
+ interaction with virtual devices. This driver implements
8
+ support for probing and issuing these hypercalls.
9
+
10
+ If unsure, say 'N'.
Original file line number Diff line number Diff line change
1
+ # SPDX-License-Identifier: GPL-2.0-only
2
+ obj-$(CONFIG_ARM_PKVM_GUEST) += arm-pkvm-guest.o
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0-only
2
+ /*
3
+ * Support for the hypercall interface exposed to protected guests by
4
+ * pKVM.
5
+ *
6
+ * Author: Will Deacon <[email protected] >
7
+ * Copyright (C) 2024 Google LLC
8
+ */
9
+
10
+ #include <linux/arm-smccc.h>
11
+ #include <linux/array_size.h>
12
+ #include <linux/mm.h>
13
+
14
+ #include <asm/hypervisor.h>
15
+
16
+ static size_t pkvm_granule ;
17
+
18
+ void pkvm_init_hyp_services (void )
19
+ {
20
+ int i ;
21
+ struct arm_smccc_res res ;
22
+ const u32 funcs [] = {
23
+ ARM_SMCCC_KVM_FUNC_HYP_MEMINFO ,
24
+ };
25
+
26
+ for (i = 0 ; i < ARRAY_SIZE (funcs ); ++ i ) {
27
+ if (!kvm_arm_hyp_service_available (funcs [i ]))
28
+ return ;
29
+ }
30
+
31
+ arm_smccc_1_1_invoke (ARM_SMCCC_VENDOR_HYP_KVM_HYP_MEMINFO_FUNC_ID ,
32
+ 0 , 0 , 0 , & res );
33
+ if (res .a0 > PAGE_SIZE ) /* Includes error codes */
34
+ return ;
35
+
36
+ pkvm_granule = res .a0 ;
37
+ }
Original file line number Diff line number Diff line change 115
115
/* KVM "vendor specific" services */
116
116
#define ARM_SMCCC_KVM_FUNC_FEATURES 0
117
117
#define ARM_SMCCC_KVM_FUNC_PTP 1
118
+ #define ARM_SMCCC_KVM_FUNC_HYP_MEMINFO 2
118
119
#define ARM_SMCCC_KVM_FUNC_FEATURES_2 127
119
120
#define ARM_SMCCC_KVM_NUM_FUNCS 128
120
121
137
138
ARM_SMCCC_OWNER_VENDOR_HYP, \
138
139
ARM_SMCCC_KVM_FUNC_PTP)
139
140
141
+ #define ARM_SMCCC_VENDOR_HYP_KVM_HYP_MEMINFO_FUNC_ID \
142
+ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \
143
+ ARM_SMCCC_SMC_64, \
144
+ ARM_SMCCC_OWNER_VENDOR_HYP, \
145
+ ARM_SMCCC_KVM_FUNC_HYP_MEMINFO)
146
+
140
147
/* ptp_kvm counter type ID */
141
148
#define KVM_PTP_VIRT_COUNTER 0
142
149
#define KVM_PTP_PHYS_COUNTER 1
You can’t perform that action at this time.
0 commit comments