gramine icon indicating copy to clipboard operation
gramine copied to clipboard

[Pal/Linux-SGX] Add `sgx.disable_[cpu-feature]` manifest options

Open dimakuv opened this issue 3 years ago • 1 comments

Description of the changes

This PR adds three new manifest options: sgx.disable_avx, sgx.disable_avx512, sgx.disable_amx. Setting each of these options to true disables the corresponding CPU feature inside the SGX enclave even if this CPU feature is available on the system: this may improve enclave performance because this CPU feature will not be saved and restored during enclave entry/exit.

This PR is a re-creation of https://github.com/gramineproject/gramine/pull/321, since it turned out to be useful for performance. Without disclosing any perf numbers, I performed a set of micro-benchmarks and they prove that disabling Intel AMX inside of the enclave (when it is available on the machine but is not needed by the app inside the enclave) gives a measurable performance boost (for the worst-case scenarios). So this change actually is beneficial.

How to test this PR?

I tested this PR manually on the AMX-enabled machine:

# with   sgx.require_amx = false,   sgx.disable_amx = false 
$ gramine-sgx helloworld
[::] debug: LibOS xsave_enabled 1, xsave_size 0x2b00(11008), xsave_features 0x600e7 

# with   sgx.require_amx = true,   sgx.disable_amx = false 
$ gramine-sgx helloworld
[::] debug: LibOS xsave_enabled 1, xsave_size 0x2b00(11008), xsave_features 0x600e7

# with   sgx.require_amx = false,   sgx.disable_amx = true
$ gramine-sgx helloworld
[::] debug: LibOS xsave_enabled 1, xsave_size 0xa80(2688), xsave_features 0xe7

# with   sgx.require_amx = true,   sgx.disable_amx = true   -> this one is not recommended
$ gramine-sgx helloworld
[::] debug: LibOS xsave_enabled 1, xsave_size 0xa80(2688), xsave_features 0xe7

This change is Reviewable

dimakuv avatar Mar 16 '22 08:03 dimakuv

Jenkins, retest Jenkins-Debug-18.04 please (LibOS.shim.test.ltp.test_ltp.test_ltp[fcntl14_64] and LibOS.shim.test.ltp.test_ltp.test_ltp[fdatasync01] timed out, unrelated)

dimakuv avatar Mar 16 '22 09:03 dimakuv

Closed in favor of https://github.com/gramineproject/gramine/pull/877 (rebased and improved version)

dimakuv avatar Sep 02 '22 11:09 dimakuv