KVM: nSVM: Check reserved bits in DR6, DR7 and EFER on vmrun of nested guests
cover KVM: nSVM: Check reserved bits in DR6, DR7 and EFER on vmrun of nested guests
Patch# 1: Moves the check for upper 32 reserved bits of DR6 to a new function. Patch# 2: Adds the KVM checks for DR6[63:32] and DR7[64:32] reserved bits Patch# 3: Adds kvm-unit-tests for DR6[63:32] and DR7[64:32] reserved bits and
reserved bits in EFER
Patch# 4: Removes the duplicate definition of 'vmcb' that sneaked via one of
my previous patches.
[PATCH 1/4] KVM: x86: Move the check for upper 32 reserved bits of [PATCH 2/4] KVM: nSVM: Check that DR6[63:32] and DR7[64:32] are not [PATCH 3/4] kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] [PATCH 4/4] kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
arch/x86/kvm/svm/nested.c | 3 +++ arch/x86/kvm/x86.c | 2 +- arch/x86/kvm/x86.h | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-)
Krish Sadhukhan (2):
KVM: x86: Move the check for upper 32 reserved bits of DR6 to separate fun
KVM: nVMX: Check that DR6[63:32] and DR7[64:32] are not set on vmrun of ne
x86/svm.c | 1 - x86/svm.h | 3 +++ x86/svm_tests.c | 59 ++++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 42 insertions(+), 21 deletions(-)
Krish Sadhukhan (2):
kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] and EFER reserved b
kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
PATCH 1/4 KVM: x86: Move the check for upper 32 reserved bits of DR6 to separate function
--- arch/x86/kvm/x86.c | 2 +- arch/x86/kvm/x86.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-)
arch/x86/kvm/x86.c +1 -1
@@ -1096,7 +1096,7 @@ static int __kvm_set_dr(struct kvm_vcpu *vcpu, int dr, unsigned long val)case 4 :/* fall through */ case 6 : -if (val &0xffffffff00000000ULL ) +if (!kvm_dr6_valid (val))return -1 ;/* #GP */ vcpu->arch.dr6 = (val &DR6_VOLATILE ) |kvm_dr6_fixed (vcpu);break ;
arch/x86/kvm/x86.h +5 -0
@@ -354,6 +354,11 @@ static inline bool kvm_dr7_valid(u64 data)/* Bits [63:32] are reserved */ return !(data >>32 ); } +static inline bool kvm_dr6_valid (u64 data) +{ +/* Bits [63:32] are reserved */ +return !(data >>32 ); +}void kvm_load_guest_xsave_state (struct kvm_vcpu *vcpu);void kvm_load_host_xsave_state (struct kvm_vcpu *vcpu);
Signature · 1 line
1.8.3.1
PATCH 2/4 KVM: nSVM: Check that DR6[63:32] and DR7[64:32] are not set on vmrun of nested guests
In reply to Krish SadhukhanAccording to section "Canonicalization and Consistency Checks" in APM vol. 2 the following guest state is illegal:
"DR6[63:32] are not zero."
"DR7[63:32] are not zero."
"Any MBZ bit of EFER is set."--- arch/x86/kvm/svm/nested.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/svm/nested.c +3 -0
@@ -208,6 +208,9 @@ static bool nested_vmcb_checks(struct vmcb *vmcb)if ((vmcb->save.efer &EFER_SVME ) ==0 )return false; +if (!kvm_dr6_valid (vmcb->save.dr6) || !kvm_dr7_valid (vmcb->save.dr7)) +return false; +if ((vmcb->control.intercept & (1ULL <<INTERCEPT_VMRUN )) ==0 )return false;
Signature · 1 line
1.8.3.1
PATCH 3/4 kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] and EFER reserved bits are not set on vmrun of nested guests
In reply to Krish SadhukhanAccording to section "Canonicalization and Consistency Checks" in APM vol. 2 the following guest state is illegal:
"DR6[63:32] are not zero."
"DR7[63:32] are not zero."
"Any MBZ bit of EFER is set."--- x86/svm.h | 3 +++ x86/svm_tests.c | 59 ++++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 42 insertions(+), 20 deletions(-)
x86/svm.h +3 -0
@@ -329,6 +329,9 @@ struct __attribute__ ((__packed__)) vmcb {#define SVM_CR3_LONG_RESERVED_MASK 0xfff0000000000fe7U#define SVM_CR4_LEGACY_RESERVED_MASK 0xffbaf000U#define SVM_CR4_RESERVED_MASK 0xffffffffffbaf000U +#define SVM_DR6_RESERVED_MASK 0xffffffffffff1ff0U +#define SVM_DR7_RESERVED_MASK 0xffffffff0000cc00U +#define SVM_EFER_RESERVED_MASK 0xffffffffffff0200U#define MSR_BITMAP_SIZE 8192
x86/svm_tests.c +39 -20
108 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 4/4 kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
In reply to Krish Sadhukhan--- x86/svm.c | 1 - 1 file changed, 1 deletion(-)
x86/svm.c +0 -1
@@ -201,7 +201,6 @@ struct regs get_regs(void)#define LOAD_GPR_C SAVE_GPR_Cstruct svm_test *v2_test; -struct vmcb *vmcb;#define ASM_VMRUN_CMD \ "vmload %%rax\n\t" \
Signature · 1 line
1.8.3.1
Quoted 21 lines · Krish Sadhukhan
Patch# 1: Moves the check for upper 32 reserved bits of DR6 to a new function. Patch# 2: Adds the KVM checks for DR6[63:32] and DR7[64:32] reserved bits Patch# 3: Adds kvm-unit-tests for DR6[63:32] and DR7[64:32] reserved bits and
reserved bits in EFER
Patch# 4: Removes the duplicate definition of 'vmcb' that sneaked via one of
my previous patches.[PATCH 1/4] KVM: x86: Move the check for upper 32 reserved bits of [PATCH 2/4] KVM: nSVM: Check that DR6[63:32] and DR7[64:32] are not [PATCH 3/4] kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] [PATCH 4/4] kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
arch/x86/kvm/svm/nested.c | 3 +++ arch/x86/kvm/x86.c | 2 +- arch/x86/kvm/x86.h | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-)Krish Sadhukhan (2):
KVM: x86: Move the check for upper 32 reserved bits of DR6 to separate fun
KVM: nVMX: Check that DR6[63:32] and DR7[64:32] are not set on vmrun of ne
Quoted 9 lines
x86/svm.c | 1 - x86/svm.h | 3 +++ x86/svm_tests.c | 59 ++++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 42 insertions(+), 21 deletions(-)Krish Sadhukhan (2):
kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] and EFER reserved b
kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
Queued, thanks.
Paolo
Ping.
Quoted 30 lines · Krish Sadhukhan
Patch# 1: Moves the check for upper 32 reserved bits of DR6 to a new function. Patch# 2: Adds the KVM checks for DR6[63:32] and DR7[64:32] reserved bits Patch# 3: Adds kvm-unit-tests for DR6[63:32] and DR7[64:32] reserved bits and
reserved bits in EFER
Patch# 4: Removes the duplicate definition of 'vmcb' that sneaked via one of
my previous patches.[PATCH 1/4] KVM: x86: Move the check for upper 32 reserved bits of [PATCH 2/4] KVM: nSVM: Check that DR6[63:32] and DR7[64:32] are not [PATCH 3/4] kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] [PATCH 4/4] kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
arch/x86/kvm/svm/nested.c | 3 +++ arch/x86/kvm/x86.c | 2 +- arch/x86/kvm/x86.h | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-)Krish Sadhukhan (2):
KVM: x86: Move the check for upper 32 reserved bits of DR6 to separate fun
KVM: nVMX: Check that DR6[63:32] and DR7[64:32] are not set on vmrun of nex86/svm.c | 1 - x86/svm.h | 3 +++ x86/svm_tests.c | 59 ++++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 42 insertions(+), 21 deletions(-)Krish Sadhukhan (2):
kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] and EFER reserved b
kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
Quoted 41 lines · Krish Sadhukhan
Ping.
Quoted 37 lines · Krish Sadhukhan
Patch# 1: Moves the check for upper 32 reserved bits of DR6 to a new function.
Patch# 2: Adds the KVM checks for DR6[63:32] and DR7[64:32] reserved bits Patch# 3: Adds kvm-unit-tests for DR6[63:32] and DR7[64:32] reserved bits and
reserved bits in EFER
Patch# 4: Removes the duplicate definition of 'vmcb' that sneaked via one of
my previous patches.[PATCH 1/4] KVM: x86: Move the check for upper 32 reserved bits of [PATCH 2/4] KVM: nSVM: Check that DR6[63:32] and DR7[64:32] are not [PATCH 3/4] kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] [PATCH 4/4] kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
arch/x86/kvm/svm/nested.c| 3 +++
arch/x86/kvm/x86.c | 2 +-
arch/x86/kvm/x86.h | 5 +++++3 files changed, 9 insertions(+), 1 deletion(-)Krish Sadhukhan (2):
KVM: x86: Move the check for upper 32 reserved bits of DR6 to separate fun
KVM: nVMX: Check that DR6[63:32] and DR7[64:32] are not set on vmrun of ne
x86/svm.c | 1 -
x86/svm.h | 3 +++
x86/svm_tests.c| 59
++++++++++++++++++++++++++++++++++++++-------------------3 files changed, 42 insertions(+), 21 deletions(-)Krish Sadhukhan (2):
kvm-unit-tests: nSVM: Test that DR6[63:32], DR7[63:32] and EFER reserved b
kvm-unit-tests: x86: Remove duplicate instance of 'vmcb'
Queued, thanks.
Paolo