mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
linuxkm: add macros mapping malloc(), free(), and realloc() to the kernel equivalents, don't set WOLFSSL_NO_MALLOC, and reduce -Wframe-larger-than= from 256k to 64k; tweak fix for HAVE_INTEL_RDSEED conflict with WOLFSSL_LINUXKM; add clean rule to linuxkm/Makefile.
This commit is contained in:
@@ -22,9 +22,10 @@ ifeq "$(src_libwolfssl_la_OBJECTS)" ""
|
||||
$(error $$src_libwolfssl_la_OBJECTS is unset.)
|
||||
endif
|
||||
|
||||
WOLFSSL_CFLAGS=-DHAVE_CONFIG_H -I$(SRC_TOP) -DBUILDING_WOLFSSL $(AM_CFLAGS) $(CFLAGS) -Wframe-larger-than=262144
|
||||
WOLFSSL_CFLAGS=-DHAVE_CONFIG_H -I$(SRC_TOP) -DBUILDING_WOLFSSL $(AM_CFLAGS) $(CFLAGS) -Wframe-larger-than=65536 -mpreferred-stack-boundary=4
|
||||
WOLFSSL_ASFLAGS=-DHAVE_CONFIG_H -I$(SRC_TOP) -DBUILDING_WOLFSSL $(AM_CCASFLAGS) $(CCASFLAGS)
|
||||
WOLFSSL_OBJ_FILES=linuxkm/module_hooks.o $(patsubst %.lo, %.o, $(patsubst src/libwolfssl_la-%, src/%, $(patsubst wolfcrypt/src/src_libwolfssl_la-%, wolfcrypt/src/%, $(src_libwolfssl_la_OBJECTS))))
|
||||
|
||||
WOLFSSL_OBJ_FILES=linuxkm/module_hooks.o $(patsubst %.lo, %.o, $(patsubst src/src_libwolfssl_la-%, src/%, $(patsubst src/libwolfssl_la-%, src/%, $(patsubst wolfcrypt/src/src_libwolfssl_la-%, wolfcrypt/src/%, $(src_libwolfssl_la_OBJECTS)))))
|
||||
|
||||
export WOLFSSL_CFLAGS WOLFSSL_ASFLAGS WOLFSSL_OBJ_FILES
|
||||
|
||||
@@ -32,3 +33,8 @@ libwolfssl.ko:
|
||||
@mkdir -p linuxkm src wolfcrypt/src
|
||||
@if [[ ! -h $(SRC_TOP)/Kbuild ]]; then ln -s $(MODULE_TOP)/Kbuild $(SRC_TOP)/Kbuild; fi
|
||||
make -C $(KROOT) M=$(MODULE_TOP) src=$(SRC_TOP)
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
@cd $(MODULE_TOP) && rm -f libwolfssl.ko Module.symvers built-in.a modules.order libwolfssl.mod libwolfssl.mod.c src/*.o wolfcrypt/src/*.o
|
||||
|
@@ -27,16 +27,3 @@ else
|
||||
AC_MSG_RESULT([no default configured kernel arch found])
|
||||
fi
|
||||
])
|
||||
|
||||
dnl AC_DEFUN([AC_DEFINE_KERNEL_KFLAGS],
|
||||
dnl [
|
||||
dnl AC_MSG_CHECKING([flags for compiling objects for kernel module])
|
||||
dnl if test -z "${KROOT}" || test -z "${KARCH}"; then
|
||||
dnl AC_MSG_ERROR([Linux kernel configuration incomplete (KROOT=${KROOT}, KARCH=${KARCH}).])
|
||||
dnl else
|
||||
dnl GCC_SHORT_VERSION="$($CC -dumpversion)"
|
||||
dnl KFLAGS="-I${KROOT}/include -I${KROOT}/include/uapi -I${KROOT}/arch/${KARCH}/include -I${KROOT}/arch/${KARCH}/include/generated -I${KROOT}/arch/${KARCH}/include/generated/uapi -I${KROOT}/arch/${KARCH}/include/uapi -I${KROOT}/tools/include -I${KROOT}/tools/arch/${KARCH}/include -I${KROOT}/tools/include/uapi -I/usr/lib/gcc/${host_cpu}-${host_vendor}-${host_os}/${GCC_SHORT_VERSION}/include"
|
||||
dnl AC_MSG_RESULT([$KFLAGS])
|
||||
dnl fi
|
||||
dnl ])
|
||||
dnl
|
||||
|
@@ -176,7 +176,7 @@ int wc_RNG_GenerateByte(WC_RNG* rng, byte* b)
|
||||
{
|
||||
intel_flags = cpuid_get_flags();
|
||||
}
|
||||
#ifdef HAVE_INTEL_RDSEED
|
||||
#if defined(HAVE_INTEL_RDSEED) && !defined(WOLFSSL_LINUXKM)
|
||||
static int wc_GenerateSeed_IntelRD(OS_Seed* os, byte* output, word32 sz);
|
||||
#endif
|
||||
#ifdef HAVE_INTEL_RDRAND
|
||||
@@ -1438,6 +1438,7 @@ static WC_INLINE int IntelRDseed64_r(word64* rnd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_LINUXKM
|
||||
/* return 0 on success */
|
||||
static int wc_GenerateSeed_IntelRD(OS_Seed* os, byte* output, word32 sz)
|
||||
{
|
||||
@@ -1468,6 +1469,7 @@ static int wc_GenerateSeed_IntelRD(OS_Seed* os, byte* output, word32 sz)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_INTEL_RDSEED */
|
||||
|
||||
|
@@ -2099,10 +2099,8 @@ extern void uITRON4_free(void *p) ;
|
||||
#undef WOLFSSL_HAVE_MIN
|
||||
#undef WOLFSSL_HAVE_MAX
|
||||
#define WOLFSSL_DH_CONST 1 /* Linux kernel doesn't have floating point math facilities. */
|
||||
#define WOLFSSL_NO_MALLOC 1
|
||||
#define WOLFSSL_NO_SOCK 1
|
||||
#define WOLFSSL_USER_IO 1
|
||||
#undef HAVE_INTEL_RDSEED /* prevents -Wunused-function on wc_GenerateSeed_IntelRD() */
|
||||
#define USE_WOLF_STRTOK
|
||||
#define NO_CRYPT_BENCHMARK 1
|
||||
#define NO_CRYPT_TEST 1
|
||||
|
@@ -357,7 +357,7 @@ decouple library dependencies with standard string, memory and so on.
|
||||
#endif
|
||||
|
||||
#elif defined(WOLFSSL_LINUXKM)
|
||||
#include <linux/slab.h>
|
||||
/* the requisite linux/slab.h is included in wc_port.h, with incompatible warnings masked out. */
|
||||
#define XMALLOC(s, h, t) ((void)h, (void)t, kmalloc((s), GFP_KERNEL))
|
||||
#define XFREE(p, h, t) {void* xp = (p); if((xp)) kfree((xp));}
|
||||
#define XREALLOC(p, n, h, t) krealloc((p), (n), GFP_KERNEL)
|
||||
|
@@ -55,23 +55,6 @@
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_LINUXKM
|
||||
|
||||
/*
|
||||
note, leaving out --enable-pkcs11 in this (depends on -ldl):
|
||||
|
||||
KROOT=/usr/src/linux KARCH=x86 CFLAGS="-I${KROOT}/include -I${KROOT}/arch/${KARCH}/include -I${KROOT}/arch/${KARCH}/include/generated -I${KROOT}/arch/${KARCH}/include/generated/uapi -I${KROOT}/arch/${KARCH}/include/uapi -I${KROOT}/include/uapi -I${KROOT}/tools/include/uapi -I${KROOT}/tools/arch/${KARCH}/include -I${KROOT}/tools/include -I/usr/lib/gcc/${KARCH}_64-pc-linux-gnu/9.3.0/include" ./configure --disable-jobserver --enable-keygen --enable-tls13 --enable-dtls --enable-dtls-mtu --enable-openssh --enable-wpas --enable-wpas-dpp --enable-opensslall --enable-opensslextra --enable-aesccm --enable-aesctr --enable-aesofb --enable-intelasm --enable-sp --enable-sp-asm --enable-curve25519 --enable-ed25519 --enable-curve448 --enable-blake2 --enable-blake2s --enable-camellia --enable-ed448 --enable-hc128 --enable-idea --enable-md2 --enable-rabbit --enable-srp --enable-fpecc --enable-certreq --enable-certgen --enable-certext --enable-certgencache --enable-eccencrypt --enable-mcast --enable-ssh --enable-pkcs7 --enable-pkcallbacks --enable-cryptocb --enable-libwebsockets --enable-linuxkm --disable-examples
|
||||
|
||||
(for coverage, build with and without --enable-fpecc, and with and without --enable-intelasm --enable-sp --enable-sp-asm)
|
||||
|
||||
probably better if lib objs are compiled -ffreestanding -nostdinc.
|
||||
|
||||
building so far:
|
||||
|
||||
make -j src/libwolfssl.la
|
||||
|
||||
still to do: actual kernel module construction per https://www.kernel.org/doc/Documentation/kbuild/modules.txt
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#ifndef PACKAGE_NAME
|
||||
#error wc_port.h included before config.h
|
||||
@@ -80,10 +63,6 @@ still to do: actual kernel module construction per https://www.kernel.org/doc/Do
|
||||
#undef HAVE_CONFIG_H
|
||||
#endif
|
||||
|
||||
#ifndef __KERNEL__
|
||||
#define __KERNEL__
|
||||
#endif
|
||||
|
||||
_Pragma("GCC diagnostic push");
|
||||
/* Linux kernel header files generate profuse warnings unless these are masked out: */
|
||||
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"");
|
||||
@@ -94,6 +73,10 @@ still to do: actual kernel module construction per https://www.kernel.org/doc/Do
|
||||
_Pragma("GCC diagnostic ignored \"-Wsign-compare\"");
|
||||
_Pragma("GCC diagnostic ignored \"-Wpointer-sign\"");
|
||||
_Pragma("GCC diagnostic ignored \"-Wbad-function-cast\"");
|
||||
/* these includes bring in all the needed kernel headers.
|
||||
* they need to be included here while the incompatible warnings are disabled,
|
||||
* and before undefining conflicting kernel macros afterward.
|
||||
*/
|
||||
#include <linux/kconfig.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/version.h>
|
||||
@@ -103,19 +86,22 @@ still to do: actual kernel module construction per https://www.kernel.org/doc/Do
|
||||
#ifndef SINGLE_THREADED
|
||||
#include <linux/kthread.h>
|
||||
#endif
|
||||
#include <linux/net.h> /* include this here, while the incompatible warnings are disabled, and before undefining conflicting kernel macros below. */
|
||||
#include <linux/net.h>
|
||||
#include <linux/slab.h>
|
||||
_Pragma("GCC diagnostic pop");
|
||||
|
||||
/* a multifariously conflicting macro is picked up from
|
||||
* Linux arch/<arch>/include/asm/current.h, which must be
|
||||
* removed here.
|
||||
/* remove this multifariously conflicting macro, picked up from
|
||||
* Linux arch/<arch>/include/asm/current.h.
|
||||
*/
|
||||
#undef current
|
||||
|
||||
/* prevent gcc's mm_malloc.h from being included, since it unconditionally includes stdlib.h, which is kernel-incompatible: */
|
||||
#define _MM_MALLOC_H_INCLUDED
|
||||
|
||||
#define malloc(x) kmalloc(x, GFP_KERNEL)
|
||||
#define free(x) kfree(x)
|
||||
#define realloc(x,y) krealloc(x, y, GFP_KERNEL)
|
||||
|
||||
/* min() and max() in linux/kernel.h over-aggressively type-check, producing myriad spurious -Werrors throughout the codebase. */
|
||||
#undef min
|
||||
#undef max
|
||||
|
Reference in New Issue
Block a user