lkml.org 
[lkml]   [2018]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH RFC] selftests/x86: Add a selftest for SGX
From
Date
On 11/13/18 1:40 PM, Jarkko Sakkinen wrote:
> +int main(int argc, char **argv)
> +{
> + unsigned long bin_size = (unsigned long)&encl_bin_end -
> + (unsigned long)&encl_bin;
> + struct sgx_secs secs;
> + uint64_t result = 0;
> +
> + if (!encl_load(&secs, bin_size))
> + exit(1);
> +
> + sgx_call((void *)&MAGIC, &result, (void *)secs.base);
> + if (result != MAGIC) {
> + fprintf(stderr, "0x%lx != 0x%lx\n", result, MAGIC);
> + exit(1);
> + }
> +
> + exit(0);
> +}

Well, I guess 100 lines of code for something a wee bit shy of hello
world isn't bad. :)

In general, this looks fine, but probably needs some better commenting
and probably some messages that make it a bit more clear what is going on.

It would be _nice_, for instance to try to do some CPUID detection of
SGX so that the error (or success?) message can tell you whether you're
missing hardware support or kernel support.

Thanks for doing this, though. It's sorely needed.

\
 
 \ /
  Last update: 2018-11-13 22:51    [W:0.083 / U:1.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site