Skip to content

nSVM: Fix PAT in VMCB02 and check PAT in VMCB12

Krish Sadhukhan kvm 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3nSVM: Fix PAT in VMCB02 and check PAT in VMCB12arch/x86/kvm/svm/nested.c arch/x86/kvm/svm/svm.c arch/x86/kvm/svm/svm.h+31 -90 replies
2/3SVM: Add a helpter function for checking if PAT is supported by the VCPUlib/x86/processor.h x86/svm.c x86/svm.h+7 -00 replies
3/3nSVM: Test G_PAT fieldslib/x86/asm/page.h x86/svm.c x86/svm.h +1 more+86 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH KVM 0/3] nSVM: Fix PAT in VMCB02 and check PAT in VMCB12

According to section "Nested Paging and VMRUN/#VMEXIT" in APM vol 2:

"When VMRUN is executed with nested paging enabled (NP_ENABLE = 1),
the paging registers are affected as follows:

• VMRUN loads the guest paging state from the guest VMCB into the guest registers (i.e., VMRUN loads CR3 with the VMCB CR3 field, etc.). The guest PAT register is loaded from G_PAT field in the VMCB.

The following guest state is illegal:

• Any G_PAT.PA field has an unsupported type encoding or any reserved field in G_PAT has a nonzero value."

Patch# 1 does the following:
i) Fixes the PAT value in VMCB02 before launching nested guests as follows:

If nested paging is enabled in VMCB12, use PAT from VMCB12. Otherwise, use PAT from VMCB01.

ii) When nested guests attempt to write MSR_IA32_CR_PAT, the register
is updated only when nested paging is disabled and PAT from VMCB12 is used to update it.

iii) Adds checks for the PAT fields in VMCB12.

Patch# 2 adds a helper to check if PAT is supported by the VCPU. Patch# 3 adds tests for all the PAT fields.

[PATCH KVM 1/3] nSVM: Fix PAT value in VMCB02
[PATCH kvm-unit-tests 2/3] SVM: Add a helpter function for checking if PAT is [PATCH kvm-unit-tests 3/3] nSVM: Test G_PAT fields

 arch/x86/kvm/svm/nested.c | 34 +++++++++++++++++++++++++++-------
 arch/x86/kvm/svm/svm.c    |  3 ++-
 arch/x86/kvm/svm/svm.h    |  3 ++-
 3 files changed, 31 insertions(+), 9 deletions(-)

Krish Sadhukhan (1):
nSVM: Fix PAT value in VMCB02

 lib/x86/asm/page.h  | 11 +++++++++
 lib/x86/processor.h |  1 +
 x86/svm.c           | 13 +++++++++++
 x86/svm.h           |  2 ++
 x86/svm_tests.c     | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 93 insertions(+)

Krish Sadhukhan (2):
SVM: Add a helpter function for checking if PAT is supported by the VCPU
nSVM: Test G_PAT fields