File tree Expand file tree Collapse file tree
Documentation/virt/kvm/arm Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,3 +44,25 @@ Provides a discovery mechanism for other KVM/arm64 hypercalls.
4444----------------------------------------
4545
4646See 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 77void kvm_init_hyp_services (void );
88bool kvm_arm_hyp_service_available (u32 func_id );
99
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+
1016static inline void kvm_arch_init_hyp_services (void )
1117{
18+ pkvm_init_hyp_services ();
1219};
1320
1421#endif
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ config TSM_REPORTS
99
1010source "drivers/virt/coco/efi_secret/Kconfig"
1111
12+ source "drivers/virt/coco/pkvm-guest/Kconfig"
13+
1214source "drivers/virt/coco/sev-guest/Kconfig"
1315
1416source "drivers/virt/coco/tdx-guest/Kconfig"
Original file line number Diff line number Diff line change 44#
55obj-$(CONFIG_TSM_REPORTS) += tsm.o
66obj-$(CONFIG_EFI_SECRET) += efi_secret/
7+ obj-$(CONFIG_ARM_PKVM_GUEST) += pkvm-guest/
78obj-$(CONFIG_SEV_GUEST) += sev-guest/
89obj-$(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 <will@kernel.org>
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 115115/* KVM "vendor specific" services */
116116#define ARM_SMCCC_KVM_FUNC_FEATURES 0
117117#define ARM_SMCCC_KVM_FUNC_PTP 1
118+ #define ARM_SMCCC_KVM_FUNC_HYP_MEMINFO 2
118119#define ARM_SMCCC_KVM_FUNC_FEATURES_2 127
119120#define ARM_SMCCC_KVM_NUM_FUNCS 128
120121
137138 ARM_SMCCC_OWNER_VENDOR_HYP, \
138139 ARM_SMCCC_KVM_FUNC_PTP)
139140
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+
140147/* ptp_kvm counter type ID */
141148#define KVM_PTP_VIRT_COUNTER 0
142149#define KVM_PTP_PHYS_COUNTER 1
You can’t perform that action at this time.
0 commit comments