Age | Commit message (Collapse) | Author | Files | Lines |
|
-Wextra enables a bunch of rather useful checks which this fixes.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The Forth-to-C wrapper for get-named-nvram-partition also
uses the STRING_INIT macro. This causes heavy stack usage
in the engine() function due to the static array in that
macro. So let's rework the wrapper to do the string convertion
in a separate function instead.
Now that all users of the STRING_INIT and STRING_FROM_STACK
macros are gone, the macros can be removed, too.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The Forth-to-C wrapper code in libnvram.code uses a temporary
buffer of 255 bytes via the STRING_INIT macro for each Forth string
that has to be converted to a C string. However, using such big
arrays in the wrapper code is a bad idea: Each of the buffers
is put into the stack frame of the engine() function (from paflof.c)!
That means the 7 strings from libnvram.code increase the stack
usage of engine() by 7 * 255 = 1785 bytes! This can cause stack
overflows since engine() can be called recursively, e.g. via the
forth_eval() macro.
To fix this issue in the functions from envvar.c, we can simply
pass the Forth strings directly to the functions by adding the
string length as additional function parameter, since the functions
in envvar.c don't really depend on NUL-terminated strings.
And while we're at it (i.e. we touch the function prototypes here
anyway), also rename the functions to have a proper "nvram_" prefix,
so we clearly mark them as part of libnvram instead of cluttering
the global name space with rather trivial function names.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
The wrapper for new_nvram_partition() is using a 12 bytes buffer to
create a zero-terminated string. However, if the string has exactly
12 characters, the final NUL-terminator is missing. new_nvram_partition()
then calls create_nvram_partition() internally which depends on proper
NUL-terminated strings. So fix this by making sure that the copied
string is always NUL-terminated - and while we're at it, also move
the copy code out of libnvram.code to save some precious bytes in the
stack space of the engine() function.
Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
BenH still need to ACK this though.
From: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
* Determines size of the flash using device tree.
* Provides nvram access functions for RTAS_NVRAM
* Allocates temporary buffer of nvram in SLOF code and use that in C.
(sbrk not available)
* NVRAM_LENGTH is used at various places, make sure it is well guarded
and also use dynamically determined size once an RTAS-NVRAM is
found.
* Use NVRAM_LENGTH as a variable in case of RTAS_NVRAM, not very
elegant though
Signed-off-by: Nikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
--
Changelog from v1:
* #define cleanups suggested by Thomas/Benh
* Fix makefile which missed passing $FLAG for building llfw
* renamed vio-nvram.fs as rtas-nvram.fs
|
|
The byte-swapping functions were scattered all over the source tree, now they
are merged into a new common header file called byteswap.h.
Signed-off-by: <thuth@linux.vnet.ibm.com>
|
|
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
|