keystone-enclave / keystone

Keystone Enclave (QEMU + HiFive Unleashed)
Other
466 stars 134 forks source link

[runtime] page fault at 0x1650 on 0x3ffdfff0 (scause: 0xf) #472

Open shirinebadi opened 1 month ago

shirinebadi commented 1 month ago

I'm trying to generate the session key inside enclave. Following is the code.

  unsigned char server_pk[crypto_kx_PUBLICKEYBYTES], server_sk[crypto_kx_SECRETKEYBYTES];
  unsigned char client_pk[crypto_kx_PUBLICKEYBYTES], client_sk[crypto_kx_PUBLICKEYBYTES];
  unsigned char rx[crypto_kx_SESSIONKEYBYTES];
  unsigned char tx[crypto_kx_SESSIONKEYBYTES];
if(crypto_kx_keypair(server_pk, server_sk) != 0){
    ocall_print_string("[C] Unable to generate keypair, exiting\n");
    EAPP_RETURN(1);
  }
  if(crypto_kx_keypair(client_pk, client_sk) != 0){
    ocall_print_string("[C] Unable to generate keypair, exiting\n");
    EAPP_RETURN(1);
  }
  if(crypto_kx_server_session_keys(rx, tx, server_pk, server_sk, client_pk) != 0) {
    ocall_print_string("[C] Unable to generate session keys, exiting\n");
    EAPP_RETURN(1);
  }

However, the function crypto_kx_server_session_keys raises [runtime] page fault at 0x1650 on 0x3ffdfff0 (scause: 0xf)`. Any thoughts what might cause this?

grg-haas commented 1 month ago

It looks like you probably ran out of stack, which begins at 0x40000000 and ends at 0x3ffe0000 by default. Try bumping EYRIE_USER_STACK_SIZE.

shirinebadi commented 1 month ago

I tried #define EYRIE_USER_STACK_SIZE 0x80000, and the problem still exists. Should I clean the make directory for runtime and try again? or any other thoughts?

grg-haas commented 1 month ago

Yep, you'll need to clean both the runtime and examples subdirectories: BUILDROOT_TARGET="keystone-runtime-dirclean keystone-examples-dirclean" make

shirinebadi commented 1 month ago

I cleaned both directories and raised stack size up to 16, but the problem still exists.

shirinebadi commented 1 month ago

I also tried initializing rx and tx using malloc unsigned char *rx = malloc(crypto_kx_SESSIONKEYBYTES); unsigned char *tx = malloc(crypto_kx_SESSIONKEYBYTES);, but the errors is not gone. Do you have any thoughts on this?