diff options
| author | Yosry Ahmed <yosry@kernel.org> | 2026-03-03 00:34:14 +0000 |
|---|---|---|
| committer | Sean Christopherson <seanjc@google.com> | 2026-03-04 16:09:04 -0800 |
| commit | 84dc9fd0354d3d0e02faf2f7b3f4d1228c2571ea (patch) | |
| tree | 4bab58b0abcee371ef924fa41b24ef59886f0aba /tools/perf/scripts/python | |
| parent | 7e6eab9be2200f83ab03ab2b921ea7ca47a6c3b4 (diff) | |
KVM: nSVM: Cache all used fields from VMCB12
Currently, most fields used from VMCB12 are cached in
svm->nested.{ctl/save}. This is mainly to avoid TOC-TOU bugs. However,
for the save area, only the fields used in the consistency checks (i.e.
nested_vmcb_check_save()) were being cached. Other fields are read
directly from guest memory in nested_vmcb02_prepare_save().
While probably benign, this still makes it possible for TOC-TOU bugs to
happen. For example, RAX, RSP, and RIP are read twice, once to store in
VMCB02, and once to store in vcpu->arch.regs. It is possible for the
guest to modify the value between both reads, potentially causing nasty
bugs.
Harden against such bugs by caching everything in svm->nested.save.
Cache all the needed fields, and keep all accesses to the VMCB12
strictly in nested_svm_vmrun() for caching and early error injection.
Following changes will further limit the access to the VMCB12 in the
nested VMRUN path.
Introduce vmcb12_is_dirty() to use with the cached control fields
instead of vmcb_is_dirty(), similar to vmcb12_is_intercept().
Opportunistically order the copies in __nested_copy_vmcb_save_to_cache()
by the order in which the fields are defined in struct vmcb_save_area.
Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260303003421.2185681-21-yosry@kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
