diff options
author | Vasant Hegde <hegdevasant@linux.vnet.ibm.com> | 2016-08-30 21:10:56 +0530 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-10-11 15:40:22 +1100 |
commit | edf57684bd6821d4d01515b6e599f477e04ca01d (patch) | |
tree | 84dd177a7f65ebc1ed103b1bd14bb5d688b3500f /core/test | |
parent | 5b43f79e3bebf4f504013c1155c2d23856324d91 (diff) | |
download | skiboot-edf57684bd6821d4d01515b6e599f477e04ca01d.zip skiboot-edf57684bd6821d4d01515b6e599f477e04ca01d.tar.gz skiboot-edf57684bd6821d4d01515b6e599f477e04ca01d.tar.bz2 |
core/pel: Validate 'system-id' DT property before using
Platforms like mambo doesn't populate 'system-id' DT property. Validate
these properties before using.
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
[stewart@linux.vnet.ibm.com, memset(0) for not found dt props, fix unit test]
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/test')
-rw-r--r-- | core/test/run-pel.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/core/test/run-pel.c b/core/test/run-pel.c index ab1fa05..433842b 100644 --- a/core/test/run-pel.c +++ b/core/test/run-pel.c @@ -25,6 +25,7 @@ #include <assert.h> #include <pel.h> #include <errorlog.h> +#include <device.h> #define TEST_ERROR 0x1234 #define TEST_SUBSYS 0x5678 @@ -33,14 +34,24 @@ DEFINE_LOG_ENTRY(TEST_ERROR, OPAL_PLATFORM_ERR_EVT, TEST_SUBSYS, OPAL_PLATFORM_FIRMWARE, OPAL_INFO, OPAL_NA); +/* Override this for testing. */ +#define is_rodata(p) fake_is_rodata(p) + +char __rodata_start[16]; +#define __rodata_end (__rodata_start + sizeof(__rodata_start)) + +static inline bool fake_is_rodata(const void *p) +{ + return ((char *)p >= __rodata_start && (char *)p < __rodata_end); +} + +#define zalloc(bytes) calloc((bytes), 1) + +#include "../device.c" #include "../pel.c" struct dt_node *dt_root = NULL; char dt_prop[] = "DUMMY DT PROP"; -const void *dt_prop_get(const struct dt_node *node __unused, const char *prop __unused) -{ - return dt_prop; -} int rtc_cache_get_datetime(uint32_t *year_month_day, uint64_t *hour_minute_second_millisecond) @@ -60,6 +71,9 @@ int main(void) char *buffer; struct elog_user_data_section *tmp; + dt_root = dt_new_root(""); + dt_add_property_string(dt_root, "model", "run-pel-unittest"); + elog = malloc(sizeof(struct errorlog)); pel_buf = malloc(PEL_MIN_SIZE + 4); assert(elog); @@ -96,7 +110,7 @@ int main(void) size = pel_size(elog); pel_buf = realloc(pel_buf, size); assert(pel_buf); - + buffer = elog->user_data_dump + elog->user_section_size; tmp = (struct elog_user_data_section *)buffer; tmp->tag = 0x44455343; /* ASCII of DESC */ |