-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sgx-sdk, sgx-psw: improve samples #153237
Conversation
0db9212
to
6710dd8
Compare
Make it easier to review updates to `sgx-{sdk,psw}` on machines with actual SGX hardware support. The passthru tests build and run the SGX samples in simulation mode which works without any hardware support. To run the samples on a machine with SGX hardware support, issue the following command: ```bash $(nix-build -A sgx-sdk.runTestsHW)/bin/run-tests-hw ``` Make sure the SGX AESM daemon is running as some tests require it. See the `services.aesmd.*` NixOS module options and the `sgx-psw` package for details.
6710dd8
to
9dac06a
Compare
Unrelated to this PR with the new systemd version from here, aesmd fails with: Jan 10 02:18:33 turingmachine systemd[75093]: aesmd.service: Failed to set up mount namespacing: File exists |
I am using the mainline sgx kernel driver
This allows aesmd to start:
However the hardware test don't quite work:
Sgx is enabled in BIOS on my thinkpad x13 (Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz) $ uname -a
Linux turingmachine 5.15.11-zen1 #1-NixOS ZEN SMP Tue Jan 1 00:00:00 UTC 1980 x86_64 GNU/Linux
$ dmesg | grep sgx
[ 0.508793] sgx: EPC section 0xa0200000-0xa5f7ffff Here is the strace output: |
Anything else needed? |
Thanks for taking a look!
I cannot quite understand what's happening. I suppose something's not working properly with regard to the setup of the SGX devices on your machine; both
Apparently, although the in-tree Kernel driver uses the flat paths
I can confirm this on my machine and also in the source code: This is an issue as systemd decided to not provide a symlink (which seems like a sane choice): systemd/systemd#18944 (comment). As we do not install the udev rules packaged with I'm going to open an upstream issue if you share my analysis. I'm not sure how to tackle this issue in the meantime. A {
systemd.tmpfiles.rules = [
"L /dev/sgx/enclave - - - - /dev/sgx_enclave"
];
} Edit: opened an upstream issue: intel/linux-sgx#772 |
Intel also suggests some udev rules to create those symlinks: https://github.com/intel/SGXDataCenterAttestationPrimitives/blob/94e327a8235bc7c85353dc5e0a6dc1564e6c96c6/driver/linux/README.kernel.md#udev-rules I switched from enabled in bios to software-controlled and then enabled it with https://github.com/intel/sgx-software-enable $ ls -la /sys/class/misc | grep sgx
lrwxrwxrwx 0 root 10 Jan 17:08 sgx_provision -> ../../devices/virtual/misc/sgx_provision/
lrwxrwxrwx 0 root 10 Jan 17:08 sgx_vepc -> ../../devices/virtual/misc/sgx_vepc/ pretty weird. |
That's correct; yet, they also mention that installing those udev rules mainly aims at supporting existing enclaves compiled with an SGX PSW without in-tree support:
I'm happy to open a PR which includes a udev rule to symlink |
Intel announced that they'd address the issue in the upcoming release. Meanwhile, I've opened #154550 which adds two udev rules to symlink the application and provisioning enclave devices for backward compatibility. I guess this PR already showed its usefulness. Unfortunately, @Mic92's SGX setup seems not working properly (for whatever reason). Maybe anybody else with an SGX-enabled machine (preferably running NixOS) could test this PR to get it merged? @sbellem @citadelcore @arcz |
@veehaitch I'll try to test this out before the end of this week. |
At some point I might be able to get access got some other SGX hardware. |
Did you have chance to test this, @sbellem? |
I ran this on my i5-8500 using 5.15.12. Looks fine until it comes to the remote attestation test:
When I remove this test, all the others succeed. |
Unfortunately, I don't know. Maybe it's a network issue? |
Maybe tcpdump helps? |
I think we can merge this. I would assume the issue @jtraue sees is related to their configuration. In any case, this PR is an improvement. |
@veehaitch I'm trying to test it right now.
Nevermind, the above, it works with Hardware tests pass on my end. Looks all good to me! Thanks @veehaitch! |
Motivation for this change
Make it easier to review updates to
sgx-{sdk,psw}
on machines withactual SGX hardware support. The passthru tests build and run the SGX
samples in simulation mode which works without any hardware support. To
run the samples on a machine with SGX hardware support, issue the
following command:
$(nix-build -A sgx-sdk.runTestsHW)/bin/run-tests-hw
Make sure the SGX AESM daemon is running as some tests require it. See
the
services.aesmd.*
NixOS module options and thesgx-psw
packagefor details.
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes