diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2016-04-14 10:43:32 +0800 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2016-04-18 13:31:10 -0700 |
commit | 41a064ecb742383a15b9daac5b5dde1ba76e1460 (patch) | |
tree | b5ffe4bda3337b9a3dae57370d85b3b2c9153944 /external | |
parent | 4b432ed3aa3ea586ebc4bb6cd9cf1d56a6d492ca (diff) | |
download | skiboot-41a064ecb742383a15b9daac5b5dde1ba76e1460.zip skiboot-41a064ecb742383a15b9daac5b5dde1ba76e1460.tar.gz skiboot-41a064ecb742383a15b9daac5b5dde1ba76e1460.tar.bz2 |
external/opal-prd: Ensure that struct host_interfaces matches the thunk
Currently, we don't describe the reserved area at the end of struct
host_interfaces; it's in the thunk, but not the struct itself.
This change adds the reserved area, and adds a set of runtime asserts to
ensure that the struct layout matches the thunk.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Acked-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/opal-prd/hostboot-interface.h | 3 | ||||
-rw-r--r-- | external/opal-prd/opal-prd.c | 20 | ||||
-rw-r--r-- | external/opal-prd/thunk.S | 6 |
3 files changed, 28 insertions, 1 deletions
diff --git a/external/opal-prd/hostboot-interface.h b/external/opal-prd/hostboot-interface.h index 0d268d3..0393152 100644 --- a/external/opal-prd/hostboot-interface.h +++ b/external/opal-prd/hostboot-interface.h @@ -277,7 +277,8 @@ struct host_interfaces { int (*memory_error)( uint64_t i_startAddr, uint64_t i_endAddr, enum MemoryError_t i_errorType ); - + /* Reserve some space for future growth. */ + void (*reserved[32])(void); }; struct runtime_interfaces { diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c index 7c11c9a..d3dbc16 100644 --- a/external/opal-prd/opal-prd.c +++ b/external/opal-prd/opal-prd.c @@ -221,6 +221,24 @@ static void pr_log_daemon_init(void) } } +/** + * ABI check that we can't perform at build-time: we want to ensure that the + * layout of struct host_interfaces matches that defined in the thunk. + */ +static void check_abi(void) +{ + extern unsigned char __hinterface_start, __hinterface_pad, + __hinterface_end; + + /* ensure our struct size matches the thunk definition */ + assert((&__hinterface_end - &__hinterface_start) + == sizeof(struct host_interfaces)); + + /* ensure the padding layout is as expected */ + assert((void *)&__hinterface_start == (void *)&hinterface); + assert((void *)&__hinterface_pad == (void *)&hinterface.reserved); +} + /* HBRT init wrappers */ extern struct runtime_interfaces *call_hbrt_init(struct host_interfaces *); @@ -1960,6 +1978,8 @@ int main(int argc, char *argv[]) enum action action; int rc; + check_abi(); + ctx = &_ctx; memset(ctx, 0, sizeof(*ctx)); ctx->vlog = pr_log_stdio; diff --git a/external/opal-prd/thunk.S b/external/opal-prd/thunk.S index 7549efc..f25afde 100644 --- a/external/opal-prd/thunk.S +++ b/external/opal-prd/thunk.S @@ -157,6 +157,8 @@ name##_thunk: ;\ */ .data .globl hinterface + .globl __hinterface_start +__hinterface_start: hinterface: /* HBRT interface version */ .llong 1 @@ -184,8 +186,12 @@ hinterface: CALLBACK_THUNK(hservice_i2c_write) CALLBACK_THUNK(hservice_ipmi_msg) CALLBACK_THUNK(hservice_memory_error) +.globl __hinterface_pad +__hinterface_pad: /* Reserved space for future growth */ .space 32*8,0 +.globl __hinterface_end +__hinterface_end: /* Eye catcher for debugging */ .llong 0xdeadbeef |