Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 4505f07

Browse files
authored
Merge pull request #125 from haitaohuang/master
reset hashes
2 parents 276c5c6 + 1bc987f commit 4505f07

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.ko
22
*.o
33
*.cmd
4+
*.mod
45
*.mod.*
56
*.symvers
67
*.order

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ install: default
2323
endif
2424

2525
clean:
26-
rm -vrf *.o *.ko *.order *.symvers *.mod.c .tmp_versions .*o.cmd
26+
rm -vrf *.o *.ko *.order *.symvers *.mod.c .tmp_versions .*o.cmd *.mod

sgx.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
#define SGX_EDMM_SPIN_COUNT 20
8080

8181
#define SGX_VA_SLOT_COUNT 512
82+
#ifndef MSR_IA32_SGXLEPUBKEYHASH0
83+
#define MSR_IA32_SGXLEPUBKEYHASH0 0x0000008C
84+
#define MSR_IA32_SGXLEPUBKEYHASH1 0x0000008D
85+
#define MSR_IA32_SGXLEPUBKEYHASH2 0x0000008E
86+
#define MSR_IA32_SGXLEPUBKEYHASH3 0x0000008F
87+
#endif
8288

8389
struct sgx_epc_page {
8490
resource_size_t pa;

sgx_main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ static int sgx_pm_suspend(struct device *dev)
184184
return 0;
185185
}
186186

187+
static void sgx_reset_pubkey_hash(void *failed)
188+
{
189+
if (wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH0, 0xa6053e051270b7acULL) ||
190+
wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH1, 0x6cfbe8ba8b3b413dULL) ||
191+
wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH2, 0xc4916d99f2b3735dULL) ||
192+
wrmsrl_safe(MSR_IA32_SGXLEPUBKEYHASH3, 0xd4f8c05909f9bb3bULL))
193+
*(int *)failed = -EIO;
194+
}
195+
187196
static SIMPLE_DEV_PM_OPS(sgx_drv_pm, sgx_pm_suspend, NULL);
188197

189198
static int sgx_dev_init(struct device *parent)
@@ -193,6 +202,7 @@ static int sgx_dev_init(struct device *parent)
193202
unsigned long size;
194203
int ret;
195204
int i;
205+
int msr_reset_failed = 0;
196206

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

@@ -271,6 +281,11 @@ static int sgx_dev_init(struct device *parent)
271281
goto out_workqueue;
272282
}
273283

284+
on_each_cpu(sgx_reset_pubkey_hash, &msr_reset_failed, 1);
285+
if (msr_reset_failed) {
286+
pr_info("intel_sgx: can not reset SGX LE public key hash MSRs\n");
287+
}
288+
274289
return 0;
275290
out_workqueue:
276291
destroy_workqueue(sgx_add_page_wq);

0 commit comments

Comments
 (0)