Skip to content

Commit

Permalink
vmsa: enable shadow stacks
Browse files Browse the repository at this point in the history
This enables shadow stacks on the secondary APs.

Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
  • Loading branch information
Freax13 committed Sep 12, 2024
1 parent d9f67be commit 93e1490
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kernel/src/cpu/percpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,9 @@ impl PerCpu {
vmsa.tr = self.vmsa_tr_segment();
vmsa.rip = start_rip;
vmsa.rsp = self.get_top_of_stack().into();
if cfg!(feature = "shadow-stacks") {
vmsa.ssp = self.get_top_of_shadow_stack().into();
}
vmsa.cr3 = self.get_pgtable().cr3_value().into();
vmsa.enable();

Expand Down
4 changes: 4 additions & 0 deletions kernel/src/cpu/vmsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use super::control_regs::{read_cr0, read_cr3, read_cr4};
use super::efer::read_efer;
use super::gdt;
use super::idt::common::idt;
use super::shadow_stack::read_s_cet;

fn svsm_code_segment() -> VMSASegment {
VMSASegment {
Expand Down Expand Up @@ -66,6 +67,9 @@ pub fn init_svsm_vmsa(vmsa: &mut VMSA, vtom: u64) {
vmsa.cr3 = read_cr3().bits() as u64;
vmsa.cr4 = read_cr4().bits();
vmsa.efer = read_efer().bits();
if cfg!(feature = "shadow-stacks") {
vmsa.s_cet = read_s_cet().bits();
}

vmsa.rflags = 0x2;
vmsa.dr6 = 0xffff0ff0;
Expand Down

0 comments on commit 93e1490

Please sign in to comment.