From 53e7408166427ff6f9252563f99fe81a0eff66b1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 17 Apr 2026 19:29:01 -0400 Subject: [PATCH] sp1/amd64: head: Add kfence.h Signed-off-by: Ian Moffett --- usr/src/sp1/head/amd64/kfence.h | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 usr/src/sp1/head/amd64/kfence.h diff --git a/usr/src/sp1/head/amd64/kfence.h b/usr/src/sp1/head/amd64/kfence.h new file mode 100644 index 0000000..7879c41 --- /dev/null +++ b/usr/src/sp1/head/amd64/kfence.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * All rights reserved. + * + * The following sources are CONFIDENTIAL and PROPRIETARY + * property of Mirocom Laboratories. Unauthorized copying, + * use, distribution or modification of this file, in whole + * and in part, is strictly prohibited without the prior written + * consent from Mirocom Laboratories. + */ + +#ifndef _MACHINE_KFENCE_H_ +#define _MACHINE_KFENCE_H_ 1 + +/* + * Kernel fence for interrupt entries that do + * not have an error code + */ +#define KFENCE \ + testq $0x3, 8(%rsp) ; \ + jz 1f ; \ + lfence ; \ + swapgs ; \ +1: nop + +/* + * Kernel fence for interrupt entries that + * have an error code + */ +#define KFENCE_EC \ + testq $0x3, 16(%rsp) ; \ + jz 1f ; \ + lfence ; \ + swapgs ; \ +1: nop + +#endif /* !_MACHINE_KFENCE_H_ *