Commit 51ad7abc authored by Jingxian He's avatar Jingxian He Committed by hejingxian
Browse files

mm: enable swiotlb alloc for cvm share mem

virtcca inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9CC0X



--------------------------------

Enable swiotlb alloc for cvm share mem:
1. Cvm guest mapped memory is secure memory.
2. Qemu/kvm cannot access the secure memory.
3. Use swiotlb buffer as memory shared by cvm guest and qemu/kvm.

Signed-off-by: default avatarJingxian He <hejingxian@huawei.com>
parent 876f29b7
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2283,6 +2283,14 @@ config ARCH_ENABLE_THP_MIGRATION
	def_bool y
	depends on TRANSPARENT_HUGEPAGE

config CVM_GUEST
	bool "Enable cvm guest run"
	depends on DMA_RESTRICTED_POOL
	help
	  Support CVM guest based on S-EL2

	  If unsure, say N.

menu "Power management options"

source "kernel/power/Kconfig"
+0 −1
Original line number Diff line number Diff line
@@ -2,5 +2,4 @@
generic-y += early_ioremap.h
generic-y += mcs_spinlock.h
generic-y += qrwlock.h
generic-y += set_memory.h
generic-y += user.h
+46 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2024. Huawei Technologies Co., Ltd. All rights reserved.
 */
#ifndef __CVM_GUEST_H
#define __CVM_GUEST_H

#ifdef CONFIG_CVM_GUEST
struct device;

extern int set_cvm_memory_encrypted(unsigned long addr, int numpages);

extern int set_cvm_memory_decrypted(unsigned long addr, int numpages);

extern bool is_cvm_world(void);

#define is_swiotlb_for_alloc is_swiotlb_for_alloc
static inline bool is_swiotlb_for_alloc(struct device *dev)
{
	/* Force dma alloc by swiotlb in Confidential VMs */
	return is_cvm_world();
}

extern void __init swiotlb_cvm_update_mem_attributes(void);

#else

static inline int set_cvm_memory_encrypted(unsigned long addr, int numpages)
{
	return 0;
}

static inline int set_cvm_memory_decrypted(unsigned long addr, int numpages)
{
	return 0;
}

static inline bool is_cvm_world(void)
{
	return false;
}

static inline void __init swiotlb_cvm_update_mem_attributes(void) {}

#endif /* CONFIG_CVM_GUEST */
#endif /* __CVM_GUEST_H */
+9 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef _ASM_ARM64_SET_MEMORY_H
#define _ASM_ARM64_SET_MEMORY_H

#include <asm-generic/set_memory.h>
#include <asm/cvm_guest.h>

#endif /* _ASM_ARM64_SET_MEMORY_H */
+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ obj-$(CONFIG_ARM64_PTR_AUTH) += pointer_auth.o
obj-$(CONFIG_SHADOW_CALL_STACK)		+= scs.o
obj-$(CONFIG_ARM64_MTE)			+= mte.o
obj-$(CONFIG_MPAM)			+= mpam/
obj-$(CONFIG_CVM_GUEST)			+= cvm_guest.o

obj-y					+= vdso/ probes/
obj-$(CONFIG_COMPAT_VDSO)		+= vdso32/
Loading