From 7250e7ecab292ac5debd1e11bed31e3fda034baa Mon Sep 17 00:00:00 2001 From: Courtney Goeltzenleuchter Date: Tue, 10 Feb 2015 18:40:14 -0700 Subject: 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. --- loader/loader.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'loader/loader.c') 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; -- cgit v1.2.3