diff options
author | Thomas Huth <thuth@redhat.com> | 2015-11-25 20:58:19 +0100 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2015-12-01 17:02:04 +1100 |
commit | 2ef6d1e52d5b6f3a8198c1c39a55eeff2981b282 (patch) | |
tree | 6b6ad92775b881f28a6ce7e42f39b5289c8fec87 /lib/libhvcall | |
parent | f0d251a0775572ebce8566c16e4482455b9efd84 (diff) | |
download | SLOF-2ef6d1e52d5b6f3a8198c1c39a55eeff2981b282.zip SLOF-2ef6d1e52d5b6f3a8198c1c39a55eeff2981b282.tar.gz SLOF-2ef6d1e52d5b6f3a8198c1c39a55eeff2981b282.tar.bz2 |
Move the code for rfill into a separate function
The code from the FAST_RFILL macro uses a local array as a
temporary buffer - which gets allocated in the stack frame
of the engine() function. Since engine() can be called
recursively, this can cause stack overflows. So let's
move the rfill code into a separate function to avoid
these problems.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib/libhvcall')
-rw-r--r-- | lib/libhvcall/Makefile | 2 | ||||
-rw-r--r-- | lib/libhvcall/rfill.c | 38 |
2 files changed, 39 insertions, 1 deletions
diff --git a/lib/libhvcall/Makefile b/lib/libhvcall/Makefile index 2a9b2d7..def5325 100644 --- a/lib/libhvcall/Makefile +++ b/lib/libhvcall/Makefile @@ -24,7 +24,7 @@ TARGET = ../libhvcall.a all: $(TARGET) -SRCS = brokensc1.c +SRCS = brokensc1.c rfill.c SRCSS = hvcall.S diff --git a/lib/libhvcall/rfill.c b/lib/libhvcall/rfill.c new file mode 100644 index 0000000..5407cd2 --- /dev/null +++ b/lib/libhvcall/rfill.c @@ -0,0 +1,38 @@ +/***************************************************************************** + * Fast function for filling cache-inhibited memory regions via h-call. + * + * Copyright 2015 Red Hat, Inc. + * + * This program and the accompanying materials + * are made available under the terms of the BSD License + * which accompanies this distribution, and is available at + * http://www.opensource.org/licenses/bsd-license.php + * + * Contributors: + * Thomas Huth, Red Hat Inc. - initial implementation + *****************************************************************************/ + +#include <cache.h> +#include <string.h> + +typedef unsigned long type_u; + +/** + * fast_rfill is the implementation of the FAST_RFILL macro with h-calls. + * This is defined here instead of cache.h since we need a temporary + * local buffer - and that caused stack size problems in engine() when + * we used it directly in the FAST_RFILL macro. + */ +void fast_rfill(char *dst, long size, char pat) +{ + type_u buf[64]; + + memset(buf, pat, size < sizeof(buf) ? size : sizeof(buf)); + + while (size > sizeof(buf)) { + FAST_MRMOVE(buf, dst, sizeof(buf)); + dst += sizeof(buf); + size -= sizeof(buf); + } + FAST_MRMOVE(buf, dst, size); +} |