Skip to content

Commit e900042

Browse files
committed
Merge tag 'x86_sev_for_v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 SEV updates from Borislav Petkov: - Convert the sev-guest plaform ->remove callback to return void - Move the SEV C-bit verification to the BSP as it needs to happen only once and not on every AP * tag 'x86_sev_for_v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: virt: sev-guest: Convert to platform remove callback returning void x86/sev: Do the C-bit verification only on the BSP
2 parents fc5e5c5 + d642ef7 commit e900042

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

arch/x86/kernel/head_64.S

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,28 @@ SYM_CODE_START_NOALIGN(startup_64)
114114

115115
/* Form the CR3 value being sure to include the CR3 modifier */
116116
addq $(early_top_pgt - __START_KERNEL_map), %rax
117+
118+
#ifdef CONFIG_AMD_MEM_ENCRYPT
119+
mov %rax, %rdi
120+
mov %rax, %r14
121+
122+
addq phys_base(%rip), %rdi
123+
124+
/*
125+
* For SEV guests: Verify that the C-bit is correct. A malicious
126+
* hypervisor could lie about the C-bit position to perform a ROP
127+
* attack on the guest by writing to the unencrypted stack and wait for
128+
* the next RET instruction.
129+
*/
130+
call sev_verify_cbit
131+
132+
/*
133+
* Restore CR3 value without the phys_base which will be added
134+
* below, before writing %cr3.
135+
*/
136+
mov %r14, %rax
137+
#endif
138+
117139
jmp 1f
118140
SYM_CODE_END(startup_64)
119141

@@ -192,15 +214,6 @@ SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
192214
/* Setup early boot stage 4-/5-level pagetables. */
193215
addq phys_base(%rip), %rax
194216

195-
/*
196-
* For SEV guests: Verify that the C-bit is correct. A malicious
197-
* hypervisor could lie about the C-bit position to perform a ROP
198-
* attack on the guest by writing to the unencrypted stack and wait for
199-
* the next RET instruction.
200-
*/
201-
movq %rax, %rdi
202-
call sev_verify_cbit
203-
204217
/*
205218
* Switch to new page-table
206219
*

drivers/virt/coco/sev-guest/sev-guest.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ static int __init sev_guest_probe(struct platform_device *pdev)
994994
return ret;
995995
}
996996

997-
static int __exit sev_guest_remove(struct platform_device *pdev)
997+
static void __exit sev_guest_remove(struct platform_device *pdev)
998998
{
999999
struct snp_guest_dev *snp_dev = platform_get_drvdata(pdev);
10001000

@@ -1003,8 +1003,6 @@ static int __exit sev_guest_remove(struct platform_device *pdev)
10031003
free_shared_pages(snp_dev->request, sizeof(struct snp_guest_msg));
10041004
deinit_crypto(snp_dev->crypto);
10051005
misc_deregister(&snp_dev->misc);
1006-
1007-
return 0;
10081006
}
10091007

10101008
/*
@@ -1013,7 +1011,7 @@ static int __exit sev_guest_remove(struct platform_device *pdev)
10131011
* with the SEV-SNP support, it is named "sev-guest".
10141012
*/
10151013
static struct platform_driver sev_guest_driver = {
1016-
.remove = __exit_p(sev_guest_remove),
1014+
.remove_new = __exit_p(sev_guest_remove),
10171015
.driver = {
10181016
.name = "sev-guest",
10191017
},

0 commit comments

Comments
 (0)