Created
September 27, 2019 02:33
-
-
Save juniorprincewang/c41c2f7e53c503414c8b7348e14c3d02 to your computer and use it in GitHub Desktop.
enable SGX in Software Controlled BIOS option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
After setting BIOS with "software controlled" option, try to enable SGX in software opt-in way. | |
The source code comes from https://github.com/intel/linux-sgx/issues/238#issuecomment-377324381. | |
I just compile and execute it. | |
Note that: replace the path with your own, run it with root permission, then reboot the machine | |
gcc -o sgx_enable sgx_enable.c -I /home/max/data/gitroom/linux-sgx/common/inc/ -L /home/max/data/gitroom/linux-sgx/build/linux/ -lsgx_capable | |
sudo ./sgx_enable | |
sudo reboot | |
**/ | |
#include <stdio.h> | |
#include "sgx_uae_service.h" | |
#include "sgx_capable.h" | |
/* Application entry */ | |
int SGX_CDECL main(int argc, char *argv[]) | |
{ | |
(void)(argc); | |
(void)(argv); | |
sgx_device_status_t sgx_device_status; | |
sgx_status_t sgx_ret = sgx_cap_enable_device(&sgx_device_status); | |
if (sgx_ret != SGX_SUCCESS) { | |
printf("Failed to get SGX device status.\n"); | |
return -1; | |
} | |
else { | |
switch (sgx_device_status) { | |
case SGX_ENABLED: | |
printf("SGX device is enabled\n"); | |
return 0; | |
case SGX_DISABLED_REBOOT_REQUIRED: | |
printf("SGX device has been enabled. Please reboot your machine.\n"); | |
return -1; | |
case SGX_DISABLED_LEGACY_OS: | |
printf("SGX device can't be enabled on an OS that doesn't support EFI interface.\n"); | |
return -1; | |
case SGX_DISABLED: | |
printf("SGX device not found.\n"); | |
return -1; | |
default: | |
printf("Unexpected error.\n"); | |
return -1; | |
} | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment