ANDROID: misc: pkvm_smc: Add pKVM SMC filter driver
Add a driver that filters SMCs during running KVM in protected mode. This patch has the skeleton for the driver and its config, and the logic is added in next patches. Bug: 278009271 Bug: 357781595 Change-Id: I76b7f0c1fab49f38700d22a161c7cc92730f81a1 Signed-off-by: Mostafa Saleh <smostafa@google.com> Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
committed by
Treehugger Robot
parent
f58171c35f
commit
55d5ad26bf
@@ -618,6 +618,15 @@ config MARVELL_CN10K_DPI
|
||||
To compile this driver as a module, choose M here: the module
|
||||
will be called mrvl_cn10k_dpi.
|
||||
|
||||
config PKVM_SMC_FILTER
|
||||
tristate "pKVM SMC Filter"
|
||||
depends on KVM && ARM64 && m
|
||||
help
|
||||
Support SMC filtering from hypervisor, through a hardcoded configuration in the
|
||||
driver, this is intended to be a template and not shipped as is.
|
||||
|
||||
Say N here unless you know what you are doing.
|
||||
|
||||
source "drivers/misc/c2port/Kconfig"
|
||||
source "drivers/misc/eeprom/Kconfig"
|
||||
source "drivers/misc/cb710/Kconfig"
|
||||
|
||||
@@ -73,3 +73,4 @@ obj-$(CONFIG_NSM) += nsm.o
|
||||
obj-$(CONFIG_MARVELL_CN10K_DPI) += mrvl_cn10k_dpi.o
|
||||
obj-y += keba/
|
||||
obj-$(CONFIG_UID_SYS_STATS) += uid_sys_stats.o
|
||||
obj-$(CONFIG_PKVM_SMC_FILTER) += pkvm-smc/
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
clean-files := pkvm/hyp.lds pkvm/hyp-reloc.S
|
||||
obj-m := pkvm_smc.o
|
||||
|
||||
pkvm_smc-y := pkvm-smc.o pkvm/kvm_nvhe.o
|
||||
|
||||
$(obj)/pkvm/kvm_nvhe.o: FORCE
|
||||
$(Q)$(MAKE) $(build)=$(obj)/pkvm $(obj)/pkvm/kvm_nvhe.o
|
||||
else
|
||||
all:
|
||||
make -C $(KDIR) M=$(PWD) modules
|
||||
clean:
|
||||
make -C $(KDIR) M=$(PWD) clean
|
||||
endif
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (C) 2023 - Google Inc
|
||||
* Author: Mostafa Saleh <smostafa@google.com>
|
||||
* Simple module for pKVM SMC filtering.
|
||||
*/
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <asm/kvm_pkvm_module.h>
|
||||
|
||||
static unsigned long pkvm_module_token;
|
||||
int kvm_nvhe_sym(pkvm_smc_filter_hyp_init)(const struct pkvm_module_ops *ops);
|
||||
|
||||
static int __init smc_filter_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = pkvm_load_el2_module(kvm_nvhe_sym(pkvm_smc_filter_hyp_init),
|
||||
&pkvm_module_token);
|
||||
if (ret)
|
||||
pr_err("Failed to register pKVM SMC filter: %d\n", ret);
|
||||
else
|
||||
pr_info("pKVM SMC filter registered successfully\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
module_init(smc_filter_init);
|
||||
|
||||
MODULE_AUTHOR("Mostafa Saleh <smostafa@google.com>");
|
||||
MODULE_DESCRIPTION("pKVM SMC filter");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
@@ -0,0 +1,2 @@
|
||||
hyp-obj-y := pkvm-smc.o
|
||||
include $(srctree)/arch/arm64/kvm/hyp/nvhe/Makefile.module
|
||||
@@ -0,0 +1,13 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (C) 2023 - Google Inc
|
||||
* Author: Mostafa Saleh <smostafa@google.com>
|
||||
* Simple module for pKVM SMC filtering.
|
||||
*/
|
||||
|
||||
#include <asm/kvm_pkvm_module.h>
|
||||
|
||||
int pkvm_smc_filter_hyp_init(const struct pkvm_module_ops *ops)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user