sgx-lkl icon indicating copy to clipboard operation
sgx-lkl copied to clipboard

Populate /proc/cpuinfo with complete and attested entries

Open prp opened this issue 4 years ago • 2 comments

Applications such as OpenVINO (https://github.com/opencv/dldt) parse '/proc/cpuinfo' instead of using sysconf (which SGX-LKL supports) to obtain CPU information. Without valid entries in `/proc/cpuinfo', this is broken.

SGX-LKL has some limited support for cpuinfo by populating this with valid (static) values:

https://github.com/lsds/lkl/blob/86819ac5446e1fa31ca67db68aa165bbf07b90a9/arch/lkl/kernel/proc.c#L13

A full solution should read the host cpuinfo and bring some of that information into the enclave. For security reasons, it needs to be attested and checked for plausibility. The number of CPU cores should be set to the number of ethreads (which is also what we do for sysconf information inside the enclave.)

A proper implementation of cpuinfo will also have to bring in more x86 architecture specific code under arch/lkl/, in particular, cpu.h.

(Related to https://github.com/lsds/sgx-lkl/issues/256.)

prp avatar Jun 25 '20 09:06 prp

I think the right way to approach this is to add a hook in LKL that exposes host ops for populating /proc/cpuinfo. We can then populate it from the same source that we use for emulating CPUID and for sysinfo, once we have that information in the attested configuration.

davidchisnall avatar Jun 25 '20 09:06 davidchisnall

This PR partially fixes this issue: https://github.com/lsds/sgx-lkl/pull/798 It adds the host ops that can be used to populate cpuinfo, and fills it with mostly dummy information. The only values that are real are the number of CPUs, and the indexes of CPUs, which is obtained from the number of ethreads.

AntonioND avatar Sep 10 '20 15:09 AntonioND