Files
ipxe/src/config/fault.h

45 lines
1019 B
C
Raw Normal View History

#ifndef CONFIG_FAULT_H
#define CONFIG_FAULT_H
/** @file
*
* Fault injection
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
FILE_SECBOOT ( PERMITTED );
#include <config/defaults.h>
/* Drop every N transmitted or received network packets */
#define NETDEV_DISCARD_RATE 0
/* Delay transmissions to neighbour-resolved destinations (in ms) */
#define NEIGHBOUR_DELAY_MS 0
/* Drop every N transmitted or received PeerDist discovery packets */
#define PEERDISC_DISCARD_RATE 0
/* Annul every N PeerDist download attempts */
#define PEERBLK_ANNUL_RATE 0
/* Stall every N PeerDist download attempts */
#define PEERBLK_STALL_RATE 0
/* Abort every N PeerDist download attempts */
#define PEERBLK_ABORT_RATE 0
/* Corrupt every N received PeerDist packets */
#define PEERBLK_CORRUPT_RATE 0
/* Experience virtual machine migration on every N watchdog checks */
#define VM_MIGRATED_RATE 0
[riscv] Allow for poisoning .bss section before early initialisation On startup, we may be running from read-only memory, and therefore cannot zero the .bss section (or write to the .data section) until we have parsed the system memory map and relocated ourselves to somewhere suitable in RAM. The code that runs during this early initialisation stage must be carefully written to avoid writing to the .data section and to avoid reading from or writing to the .bss section. Detecting code that erroneously writes to the .data or .bss sections is relatively easy since running from read-only memory (e.g. via QEMU's -pflash option) will immediately reveal the bug. Detecting code that erroneously reads from the .bss section is harder, since in a freshly powered-on machine (or in a virtual machine) there is a high probability that the contents of the memory will be zero even before we explicitly zero out the section. Add the ability to fill the .bss section with an invalid non-zero value to expose bugs in early initialisation code that erroneously relies upon variables in .bss before the section has been zeroed. We use the value 0xeb55eb55eb55eb55 ("EBSS") since this is immediately recognisable as a value in a crash dump, and will trigger a page fault if dereferenced since the address is in a non-canonical form. Poisoning the .bss can be done only when the image is known to already reside in writable memory. It will overwrite the relocation records, and so can be done only on a system where relocation is known to be unnecessary (e.g. because paging is supported). We therefore do not enable this behaviour by default, but leave it as a configurable option via the config/fault.h header. Signed-off-by: Michael Brown <mcb30@ipxe.org>
2025-07-30 11:11:00 +01:00
/* Poison .bss section before early execution */
#define POISON_BSS 0
#include <config/local/fault.h>
#endif /* CONFIG_FAULT_H */