Unverified Commit 83216175 authored by Lyu Jinglin's avatar Lyu Jinglin Committed by Liu Zhehui
Browse files

HAOC: Add ARM64 kernel command line support to switch IEE on\off.

community inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IBQKOW



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

Use kernel command line parameter "haoc" to control if HAOC should
be enabled on ARM64.

Signed-off-by: default avatarLyu Jinglin <lvjl2022@zgclab.edu.cn>
Signed-off-by: default avatarZhang Shiyang <zhangsy2023@zgclab.edu.cn>
Signed-off-by: default avatarLiu Zhehui <liuzhh@zgclab.edu.cn>
parent 2428a999
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -774,7 +774,7 @@ CONFIG_CPU_MITIGATIONS=y
#
# Hardware Assisted OS Compartmentalization(HAOC)
#
# CONFIG_IEE is not set
CONFIG_IEE=y
# end of Hardware Assisted OS Compartmentalization(HAOC)

#
+4 −1
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@
/* An example of IEE API. */
static inline void iee_memset(void *ptr, int data, size_t n)
{
	if (haoc_enabled)
		iee_rw_gate(IEE_OP_MEMSET, ptr, data, n);
	else
		memset(ptr, data, n);
}

#endif
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
extern unsigned long iee_tcr;
extern unsigned long kernel_tcr;
extern bool iee_init_done;
extern bool haoc_enabled;

#define IEE_OFFSET 0x400000000000
#define IEE_DATA_ORDER (PMD_SHIFT - PAGE_SHIFT)
+1 −1
Original line number Diff line number Diff line
@@ -13,6 +13,6 @@ config IEE
		Needs hardware support FEAT_HPDS.
	depends on ARM64_4K_PAGES
	depends on ARM64_VA_BITS_48
	def_bool n
	def_bool y

endmenu # HAOC
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ __aligned(PAGE_SIZE) DEFINE_PER_CPU(u64*[(PAGE_SIZE/8)],
				iee_cpu_stack_ptr);

bool __initdata iee_init_done;
bool __ro_after_init haoc_enabled;

/* Allocate pages from IEE data pool to use as per-cpu IEE stack. */
static void __init iee_stack_alloc(void)
@@ -35,6 +36,9 @@ static void __init iee_stack_alloc(void)

void __init iee_init_post(void)
{
	if (!haoc_enabled)
		return;

	/* Flush tlb to enable IEE. */
	flush_tlb_all();

@@ -43,5 +47,14 @@ void __init iee_init_post(void)

void __init iee_stack_init(void)
{
	if (!haoc_enabled)
		return;

	iee_stack_alloc();
}

static int __init parse_haoc_enabled(char *str)
{
	return kstrtobool(str, &haoc_enabled);
}
early_param("haoc", parse_haoc_enabled);
Loading