lkml.org 
[lkml]   [2020]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v38 14/24] x86/sgx: Add SGX_IOC_ENCLAVE_INIT
On Tue, Sep 22, 2020 at 04:29:09PM +0200, Borislav Petkov wrote:
> On Tue, Sep 22, 2020 at 02:56:19PM +0200, Jethro Beekman wrote:
> > I don't see why you'd need to retry indefinitely. Yes the MSRs may not
> > match the cached value for “reasons”, but if after you've written
> > them once it still doesn't work, clearly either 1) an “unhelpful”
> > VMM is actively messing with the MSRs which I'd say is at best a VMM
> > bug or 2) there was an EPC reset and your enclave is now invalid
> > anyway, so no need to EINIT.
>
> /me likes that even more.

OK, so I did not follow this particular discussion in high detail, so
as a sanity check I'll preview my changes.

I'd refine sgx_update_lepubkeyhash_msrs() to:

static void sgx_update_lepubkeyhash_msrs(u64 *lepubkeyhash)
{
u64 *cache;
int i;

preempt_disable();

cache = per_cpu(sgx_lepubkeyhash_cache, smp_processor_id());
for (i = 0; i < 4; i++) {
if (lepubkeyhash[i] != cache[i]) {
wrmsrl(MSR_IA32_SGXLEPUBKEYHASH0 + i, lepubkeyhash[i]);
cache[i] = lepubkeyhash[i];
}
}

preempt_enable();
}

I'd drop sgx_einit() completely.

Finally, in sgx_encl_init() I would call sgx_update_lepubkeyhash_msrs()
directly:

/* ... */
sgx_update_lepubkeyhash_msrs(mrsigner);

ret = __einit(sigstruct, token, sgx_get_epc_addr(secs));
/* ... */

These staments would replace the call to sgx_einit().

Do I have the correct understanding?

/Jarkko

\
 
 \ /
  Last update: 2020-09-23 16:47    [W:0.177 / U:5.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site