mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-23 16:31:16 +00:00
vmm: Detect and handle AMD SME (Secure Memory Encryption)
Some physical address bits may become reserved in page table when SME is enabled on AMD platform. Guest will trigger a reserved bit violation page fault in this case due to write these reserved bits to 1 in page table. We need reduce the reserved bits to get the right physical address range. Signed-off-by: Qiu Wenbo <qiuwenbo@phytium.com.cn>
This commit is contained in:
parent
dcfd6ffd4b
commit
5208ff86c8
@ -213,9 +213,23 @@ fn get_host_cpu_phys_bits() -> u8 {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let leaf = x86_64::__cpuid(0x8000_0000);
|
let leaf = x86_64::__cpuid(0x8000_0000);
|
||||||
|
|
||||||
|
// Detect and handle AMD SME (Secure Memory Encryption) properly.
|
||||||
|
// Some physical address bits may become reserved when the feature is enabled.
|
||||||
|
// See AMD64 Architecture Programmer's Manual Volume 2, Section 7.10.1
|
||||||
|
let reduced = if leaf.eax >= 0x8000_001f
|
||||||
|
&& leaf.ebx == 0x6874_7541 // Vendor ID: AuthenticAMD
|
||||||
|
&& leaf.ecx == 0x444d_4163
|
||||||
|
&& leaf.edx == 0x6974_6e65
|
||||||
|
&& x86_64::__cpuid(0x8000_001f).eax & 0x1 != 0
|
||||||
|
{
|
||||||
|
(x86_64::__cpuid(0x8000_001f).ebx >> 6) & 0x3f
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
if leaf.eax >= 0x8000_0008 {
|
if leaf.eax >= 0x8000_0008 {
|
||||||
let leaf = x86_64::__cpuid(0x8000_0008);
|
let leaf = x86_64::__cpuid(0x8000_0008);
|
||||||
(leaf.eax & 0xff) as u8
|
((leaf.eax & 0xff) - reduced) as u8
|
||||||
} else {
|
} else {
|
||||||
36
|
36
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user