mbox series

[0/3] nSVM: Fix PAT in VMCB02 and check PAT in VMCB12

Message ID 20220118191449.38852-1-krish.sadhukhan@oracle.com (mailing list archive)
Headers show
Series nSVM: Fix PAT in VMCB02 and check PAT in VMCB12 | expand

Message

Krish Sadhukhan Jan. 18, 2022, 7:14 p.m. UTC
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