Skip to content

Commit

Permalink
Merge pull request #373 from AdamCDunlap/fix_phys_addr_sizes
Browse files Browse the repository at this point in the history
platform: Get correct phys addr sizes when not using vtom
  • Loading branch information
joergroedel authored Jun 5, 2024
2 parents 7eabead + a3cba31 commit 8f591bf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kernel/src/platform/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,25 @@ impl SvsmPlatform for SnpPlatform {

fn get_page_encryption_masks(&self, vtom: usize) -> PageEncryptionMasks {
// Find physical address size.
let res =
let processor_capacity =
cpuid_table(0x80000008).expect("Can not get physical address size from CPUID table");
if vtom_enabled() {
PageEncryptionMasks {
private_pte_mask: 0,
shared_pte_mask: vtom,
addr_mask_width: vtom.leading_zeros(),
phys_addr_sizes: res.eax,
phys_addr_sizes: processor_capacity.eax,
}
} else {
// Find C-bit position.
let res = cpuid_table(0x8000001f).expect("Can not get C-Bit position from CPUID table");
let c_bit = res.ebx & 0x3f;
let sev_capabilities =
cpuid_table(0x8000001f).expect("Can not get C-Bit position from CPUID table");
let c_bit = sev_capabilities.ebx & 0x3f;
PageEncryptionMasks {
private_pte_mask: 1 << c_bit,
shared_pte_mask: 0,
addr_mask_width: c_bit,
phys_addr_sizes: res.eax,
phys_addr_sizes: processor_capacity.eax,
}
}
}
Expand Down

0 comments on commit 8f591bf

Please sign in to comment.