Re: [RFC PATCH v3 08/27] x86/sgx: Initialize virtual EPC driver even when SGX driver is disabled

Dave Hansen
2021-02-01T15:27:36Z

On 1/31/21 9:40 PM, Kai Huang wrote:
>>> - ret = sgx_drv_init();
>>> + /* Success if the native *or* virtual EPC driver initialized cleanly. */
>>> + ret = !!sgx_drv_init() & !!sgx_vepc_init();
>> If would create more dumb code and just add
>>
>> ret = sgx_vepc_init()
>> if (ret)
>> goto err_kthread;

Jarkko, I'm not sure I understand this suggestion.

> Do you mean you want below?
>
> ret = sgx_drv_init();
> ret = sgx_vepc_init();
> if (ret)
> goto err_kthread;
>
> This was Sean's original code, but Dave didn't like it.

Are you sure? I remember the !!&!! abomination being Sean's doing. :)

> Sean/Dave,
>
> Please let me know which way you prefer.

Kai, I don't really know you are saying here. In the end,
sgx_vepc_init() has to run regardless of whether sgx_drv_init() is
successful or not. Also, we only want to 'goto err_kthraed' if *BOTH*
fail. The code you have above will, for instance, 'goto err_kthread' if
sgx_drv_init() succeeds but sgx_vepc_init() fails. It entirely
disregards the sgx_drv_init() error code.