Closed dubek closed 2 years ago
For the C-bit location
32
should be added or it should be renamed to C-bit location in page table entry
.
And Physical address bit reduction
might be renamed to Physical address bits
Physical address bit reduction
is taken from the AMD64 Programmer's Manual Volume 3 - E.4.18 - page 635
on Milan this value is 51
For the
C-bit location
32
should be added or it should be renamed toC-bit location in page table entry
.
I think that the C-bit location ebx mask is wrong:
let res = unsafe { x86_64::__cpuid(0x8000_001f) };
let field = res.ebx & 0b01_1111;
the mask should be res.ebx & 0b11_1111;
(equivalent to qemu's ebx & 0x3f
).
For the
C-bit location
32
should be added or it should be renamed toC-bit location in page table entry
.I think that the C-bit location ebx mask is wrong:
let res = unsafe { x86_64::__cpuid(0x8000_001f) }; let field = res.ebx & 0b01_1111;
the mask should be
res.ebx & 0b11_1111;
(equivalent to qemu'sebx & 0x3f
).
Manual says "5:0 C-bit location in page table entry" .. you are right
Luckily our enarx sev kernel does the right thing: https://github.com/enarx/enarx/blob/d2d2f60fb6453051a68c5388f1da17cfde6f38dd/internal/shim-sev/src/main.rs#L315-L316
// mask the other bits
"and edx, 0x3f",
Do you want to create the PR?
Suggested fix for the C-bit location in PR #85 .
I ran
sevctl ok
on an AMD Rome machine:As far as I understand it, the C-bit location is 47, and the physical address bit reduction is 1 (instead of 48-bit addresses we can only have 47-bit).
The code in sevctl (
ok.rs
) is:The "equivalent" code in QEMU (
target/i386/sev.c
) is: