Skip to content

Commit

Permalink
Merge pull request #125 from haitaohuang/master
Browse files Browse the repository at this point in the history
reset hashes
  • Loading branch information
haitaohuang authored Sep 16, 2020
2 parents 276c5c6 + 1bc987f commit 4505f07
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.ko
*.o
*.cmd
*.mod
*.mod.*
*.symvers
*.order
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ install: default
endif

clean:
rm -vrf *.o *.ko *.order *.symvers *.mod.c .tmp_versions .*o.cmd
rm -vrf *.o *.ko *.order *.symvers *.mod.c .tmp_versions .*o.cmd *.mod
6 changes: 6 additions & 0 deletions sgx.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
#define SGX_EDMM_SPIN_COUNT 20

#define SGX_VA_SLOT_COUNT 512
#ifndef MSR_IA32_SGXLEPUBKEYHASH0
#define MSR_IA32_SGXLEPUBKEYHASH0 0x0000008C
#define MSR_IA32_SGXLEPUBKEYHASH1 0x0000008D
#define MSR_IA32_SGXLEPUBKEYHASH2 0x0000008E
#define MSR_IA32_SGXLEPUBKEYHASH3 0x0000008F
#endif

struct sgx_epc_page {
resource_size_t pa;
Expand Down
15 changes: 15 additions & 0 deletions sgx_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,15 @@ static int sgx_pm_suspend(struct device *dev)
return 0;
}

static void sgx_reset_pubkey_hash(void *failed)
{
if (wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH0, 0xa6053e051270b7acULL) ||
wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH1, 0x6cfbe8ba8b3b413dULL) ||
wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH2, 0xc4916d99f2b3735dULL) ||
wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH3, 0xd4f8c05909f9bb3bULL))
*(int *)failed = -EIO;
}

static SIMPLE_DEV_PM_OPS(sgx_drv_pm, sgx_pm_suspend, NULL);

static int sgx_dev_init(struct device *parent)
Expand All @@ -193,6 +202,7 @@ static int sgx_dev_init(struct device *parent)
unsigned long size;
int ret;
int i;
int msr_reset_failed = 0;

pr_info("intel_sgx: " DRV_DESCRIPTION " v" DRV_VERSION "\n");

Expand Down Expand Up @@ -271,6 +281,11 @@ static int sgx_dev_init(struct device *parent)
goto out_workqueue;
}

on_each_cpu(sgx_reset_pubkey_hash, &msr_reset_failed, 1);
if (msr_reset_failed) {
pr_info("intel_sgx: can not reset SGX LE public key hash MSRs\n");
}

return 0;
out_workqueue:
destroy_workqueue(sgx_add_page_wq);
Expand Down

0 comments on commit 4505f07

Please sign in to comment.