diff options
| author | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-02-10 18:40:14 -0700 |
|---|---|---|
| committer | Courtney Goeltzenleuchter <courtney@LunarG.com> | 2015-02-12 16:31:13 -0700 |
| commit | 7250e7ecab292ac5debd1e11bed31e3fda034baa (patch) | |
| tree | 3c3f7c9b56037328992dda571783b0b14362889d /loader/loader.c | |
| parent | 22ec3a52c48963ef92a87fd32a9cc27dae617868 (diff) | |
| download | usermoji-7250e7ecab292ac5debd1e11bed31e3fda034baa.tar.xz | |
icd: add loader magic word to verify ICD is compatible
We wanted a more explicit way to determine if the driver
ICD being loaded is providing compatible objects. To do
that we check for a magic dword value at the beginning
of the object. Non-compliant ICDs will assert in the loader
or the loader's dispatch functions if an object does
not have the correct value.
Dispatch checks are debug only.
Diffstat (limited to 'loader/loader.c')
| -rw-r--r-- | loader/loader.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/loader/loader.c b/loader/loader.c index 6dd4013f..4cc7c1a0 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -42,6 +42,7 @@ #include "loader_platform.h" #include "table_ops.h" #include "loader.h" +#include "xglIcd.h" struct loader_instance { struct loader_icd *icds; @@ -967,6 +968,14 @@ LOADER_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus( memcpy(pGpus + count, &wrapped_gpus, sizeof(*pGpus)); loader_init_dispatch_table(icd->loader_dispatch + i, get_proc_addr, gpus[i]); + + /* Verify ICD compatibility */ + if (!valid_loader_magic_value(gpus[i])) { + loader_log(XGL_DBG_MSG_WARNING, 0, + "Loader: Incompatible ICD, first dword must be initialized to ICD_LOADER_MAGIC. See loader/README.md for details.\n"); + assert(0); + } + const XGL_LAYER_DISPATCH_TABLE **disp; disp = (const XGL_LAYER_DISPATCH_TABLE **) gpus[i]; *disp = icd->loader_dispatch + i; |
