forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers/virt: pkvm: Add initial support for running as a protected guest
Implement a pKVM protected guest driver to probe the presence of pKVM and determine the memory protection granule using the HYP_MEMINFO hypercall. Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
- Loading branch information
1 parent
0ba5b4b
commit a06c3fa
Showing
8 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
config ARM_PKVM_GUEST | ||
bool "Arm pKVM protected guest driver" | ||
depends on ARM64 | ||
help | ||
Protected guests running under the pKVM hypervisor on arm64 | ||
are isolated from the host and must issue hypercalls to enable | ||
interaction with virtual devices. This driver implements | ||
support for probing and issuing these hypercalls. | ||
|
||
If unsure, say 'N'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# SPDX-License-Identifier: GPL-2.0-only | ||
obj-$(CONFIG_ARM_PKVM_GUEST) += arm-pkvm-guest.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Support for the hypercall interface exposed to protected guests by | ||
* pKVM. | ||
* | ||
* Author: Will Deacon <[email protected]> | ||
* Copyright (C) 2024 Google LLC | ||
*/ | ||
|
||
#include <linux/arm-smccc.h> | ||
#include <linux/array_size.h> | ||
#include <linux/mm.h> | ||
|
||
#include <asm/hypervisor.h> | ||
|
||
static size_t pkvm_granule; | ||
|
||
void pkvm_init_hyp_services(void) | ||
{ | ||
int i; | ||
struct arm_smccc_res res; | ||
const u32 funcs[] = { | ||
ARM_SMCCC_KVM_FUNC_HYP_MEMINFO, | ||
}; | ||
|
||
for (i = 0; i < ARRAY_SIZE(funcs); ++i) { | ||
if (!kvm_arm_hyp_service_available(funcs[i])) | ||
return; | ||
} | ||
|
||
arm_smccc_1_1_invoke(ARM_SMCCC_VENDOR_HYP_KVM_HYP_MEMINFO_FUNC_ID, | ||
0, 0, 0, &res); | ||
if (res.a0 > PAGE_SIZE) /* Includes error codes */ | ||
return; | ||
|
||
pkvm_granule = res.a0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters