From d86b0601b9cad839225dcd786a5c341ff54f44c8 Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Sat, 22 Aug 2020 01:10:28 -0500 Subject: [PATCH] lkm: tweak Kbuild to work on 4.x (hardcoded fallback stack size); add linuxkm/get_thread_size.c. --- linuxkm/Kbuild | 7 ++++++- linuxkm/get_thread_size.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 linuxkm/get_thread_size.c diff --git a/linuxkm/Kbuild b/linuxkm/Kbuild index b7b37845c..f8509c83d 100644 --- a/linuxkm/Kbuild +++ b/linuxkm/Kbuild @@ -20,11 +20,16 @@ ifeq "$(WOLFSSL_CFLAGS)" "" $(error $$WOLFSSL_CFLAGS is unset.) endif +# this mechanism only works in kernel 5.x+ (fallback to hardcoded value) hostprogs := linuxkm/get_thread_size always-y := $(hostprogs) HOST_EXTRACFLAGS += $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CFLAGS) -static + +# this rule is needed to get build to succeed in 4.x (get_thread_size still doesn't get built) +$(obj)/linuxkm/get_thread_size: $(src)/linuxkm/get_thread_size.c + $(patsubst %, $(obj)/%, $(WOLFSSL_OBJ_FILES)): $(obj)/linuxkm/get_thread_size -KERNEL_THREAD_STACK_SIZE=$(shell $(obj)/linuxkm/get_thread_size) +KERNEL_THREAD_STACK_SIZE=$(shell test -x $(obj)/linuxkm/get_thread_size && $(obj)/linuxkm/get_thread_size || echo 16384) MAX_STACK_FRAME_SIZE=$(shell echo $$(( $(KERNEL_THREAD_STACK_SIZE) / 4))) libwolfssl-y := $(WOLFSSL_OBJ_FILES) diff --git a/linuxkm/get_thread_size.c b/linuxkm/get_thread_size.c new file mode 100644 index 000000000..cad1c0c61 --- /dev/null +++ b/linuxkm/get_thread_size.c @@ -0,0 +1,13 @@ +#ifndef __KERNEL__ +#define __KERNEL__ +#endif +#include +#include +#include + +extern int dprintf(int fd, const char *format, ...); + +int main(__maybe_unused int argc, __maybe_unused char **argv) { + dprintf(1, "%lu\n",THREAD_SIZE); + return 0; +}