some nested vmx fixing to hyper-v
cover some nested vmx fixing to hyper-v
From: Yang Zhang <[email protected]>
This series patches fix some issues which i encountered when boot L1 hyper-v.
This patch fixed RHEL6 guest installation problem with L1 hyper-v:
Nested VMX: update nested paging mode when vmswitch is in progress
The two fixing SMP hyper-v boot issue:
VMX,apicv: Set "NMI-window exiting" for NMI Nested VMX: Setup the virtual NMI exiting info:
Yang Zhang (3):
Nested VMX: update nested paging mode when vmswitch is in progress VMX,apicv: Set "NMI-window exiting" for NMI
Nested VMX: Setup the virtual NMI exiting info
xen/arch/x86/hvm/hvm.c | 4 ++-- xen/arch/x86/hvm/vmx/intr.c | 7 ++++--- xen/arch/x86/hvm/vmx/vvmx.c | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-)
PATCH 1/3 Nested VMX: update nested paging mode when vmswitch is in progress
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
--- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
This patch fixed RHEL6 guest installation problem with L1 hyper-v.
xen/arch/x86/hvm/hvm.c +2 -2
@@ -1925,7 +1925,7 @@ int hvm_set_cr0(unsigned long value)hvm_update_cr (v,0 , value);if ( (value ^ old_value) &X86_CR0_PG ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);
@@ -2014,7 +2014,7 @@ int hvm_set_cr4(unsigned long value) (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE | X86_CR4_SMEP)) || (!(value & X86_CR4_PCIDE) && (old_cr & X86_CR4_PCIDE)) ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);
Signature · 1 line
1.7.1
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Quoted 6 lines · Yang Zhang
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
Signed-off-by Yang Zhang <[email protected]>
I weakly remember the "!nestedhvm_vmswitch_in_progress" is needed to avoid a nested pagefault loop on AMD. I do not remember the actual reproduction case. Unfortunately, I do not have a setup to verify.
Christoph
Quoted 29 lines
--- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)This patch fixed RHEL6 guest installation problem with L1 hyper-v.
xen/arch/x86/hvm/hvm.c +2
-2@@ -1925,7 +1925,7 @@ int hvm_set_cr0(unsigned long value)hvm_update_cr (v,0 , value);if ( (value ^ old_value) &X86_CR0_PG ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);@@ -2014,7 +2014,7 @@ int hvm_set_cr4(unsigned long value) (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE | X86_CR4_SMEP)) || (!(value & X86_CR4_PCIDE) && (old_cr & X86_CR4_PCIDE)) ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Egger, Christoph wrote on 2013-12-12:
Quoted 6 lines · Yang Zhang
Quoted 5 lines
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
Quoted 6 lines
Quoted 1 line
Signed-off-by Yang Zhang <[email protected]>I weakly remember the "!nestedhvm_vmswitch_in_progress" is needed to avoid a nested pagefault loop on AMD. I do not remember the actual reproduction case. Unfortunately, I do not have a setup to verify.
So you mean if CR0.PG bit is changed during vmentry, there is no need to update nested paging mode on AMD?
Consider that, if the nested VCPU is scheduled from ETP to shadow and you don't update the nested paging mode, then it will cause problem, and vice versa.
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
In reply to Egger, ChristophZhang, Yang Z wrote on 2013-12-13:
Quoted 13 lines
Egger, Christoph wrote on 2013-12-12:
Quoted 11 lines · Yang Zhang
Quoted 6 lines
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
Signed-off-by Yang Zhang <[email protected]>I weakly remember the "!nestedhvm_vmswitch_in_progress" is needed to avoid a nested pagefault loop on AMD. I do not remember the actual reproduction case. Unfortunately, I do not have a setup to verify.
Quoted 5 lines
So you mean if CR0.PG bit is changed during vmentry, there is no need to update nested paging mode on AMD?
Consider that, if the nested VCPU is scheduled from ETP to shadow and you don't update the nested paging mode, then it will cause problem, and vice versa.
Hi, Christoph,
Any concern with this patch?
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
In reply to Yang ZhangAcked by Eddie Dong <[email protected]>
-----Original Message-----
From: Zhang, Yang Z
Sent: Thursday, December 12, 2013 10:07 AM
To: [email protected]
Cc: [email protected]; Dong, Eddie; Zhang, Yang Z
Subject: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
--- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
This patch fixed RHEL6 guest installation problem with L1 hyper-v.
xen/arch/x86/hvm/hvm.c +2 -2
@@ -1925,7 +1925,7 @@ int hvm_set_cr0(unsigned long value)hvm_update_cr (v,0 , value);if ( (value ^ old_value) &X86_CR0_PG ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);
@@ -2014,7 +2014,7 @@ int hvm_set_cr4(unsigned long value) (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE | X86_CR4_SMEP)) || (!(value & X86_CR4_PCIDE) && (old_cr & X86_CR4_PCIDE)) ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);
Signature · 1 line
1.7.1
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Furthermore, while you ack-ed this patch (which isn't really VMX specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to go in).
Jan
Quoted 46 lines
-----Original Message-----
From: Zhang, Yang Z
Sent: Thursday, December 12, 2013 10:07 AM
To: [email protected]
Cc: [email protected]; Dong, Eddie; Zhang, Yang Z
Subject: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progressFrom: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
Signed-off-by Yang Zhang <[email protected]>--- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)This patch fixed RHEL6 guest installation problem with L1 hyper-v.
xen/arch/x86/hvm/hvm.c +1
-1@@ -1925,7 +1925,7 @@ int hvm_set_cr0(unsigned long value)hvm_update_cr (v,0 , value);if ( (value ^ old_value) &X86_CR0_PG ) { -if ( !nestedhvm_vmswitch_in_progress (v) && nestedhvm_vcpu_in_guestmode(v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes(v);xen/arch/x86/hvm/hvm.c +1
-1@@ -2014,7 +2014,7 @@ int hvm_set_cr4(unsigned long value) (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE | X86_CR4_SMEP)) || (!(value & X86_CR4_PCIDE) && (old_cr & X86_CR4_PCIDE)) ) { -if ( !nestedhvm_vmswitch_in_progress (v) && nestedhvm_vcpu_in_guestmode(v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes(v);Signature · 1 line
1.7.1
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Jan Beulich wrote on 2013-12-18:
Quoted 9 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Furthermore, while you ack-ed this patch (which isn't really VMX specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
Actually, I asked him help to review the first patch. Since Christoph thought the first patch may break AMD. So I hope he can help to review the first patch to see whether I am wrong.
Quoted 4 lines
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to go in).
Yes, the three patches are independent.
Quoted 31 lines
Jan
Zhang, Yang Z wrote on 2013-12-12:
Quoted 18 lines
vmswitch is in progress
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
Signed-off-by Yang Zhang <[email protected]>--- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)This patch fixed RHEL6 guest installation problem with L1 hyper-v.
xen/arch/x86/hvm/hvm.c index renamed from xen/arch/x86/hvm/hvm.c +0
-069f7e74..1f62e00 100644
xen/arch/x86/hvm/hvm.c int hvm_set_cr0(unsigned long value) · line 1931
Quoted 8 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -1925,7 +1925,7 @@ int hvm_set_cr0(unsigned long value)hvm_update_cr (v,0 , value);if ( (value ^ old_value) &X86_CR0_PG ) { -if ( !nestedhvm_vmswitch_in_progress (v) && nestedhvm_vcpu_in_guestmode(v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes(v); @@ -2014,7 +2014,7@@ int
Quoted 14 lines
Quoted 2 lines
hvm_set_cr4(unsigned long value)(X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE |
X86_CR4_SMEP)) ||Quoted 9 lines
(!(value & X86_CR4_PCIDE) && (old_cr & X86_CR4_PCIDE)) ) { - if ( !nestedhvm_vmswitch_in_progress(v) && nestedhvm_vcpu_in_guestmode(v) ) + if ( nestedhvm_vcpu_in_guestmode(v) ) paging_update_nestedmode(v); else paging_update_paging_modes(v);--
1.7.1
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Quoted 11 lines · Yang Z
Jan Beulich wrote on 2013-12-18:
Quoted 9 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Furthermore, while you ack-ed this patch (which isn't really VMX specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
Quoted 8 lines
Actually, I asked him help to review the first patch. Since Christoph thought the first patch may break AMD. So I hope he can help to review the first patch to see whether I am wrong.
Quoted 4 lines
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to go in).
Yes, the three patches are independent.
I have looked through code.
vcpu is in guestmode till the vmentry/vmexit emulation is done. In SVM the vcpu guestmode changes right before setting nv_vmswitch_in_progress to 0 when the vmentry/vmexit emulation was successfull (there is a bunch of error-checking).
This patch breaks both vmentry and vmexit emulation for SVM. The vmentry breakage comes with l1-hypervisor using shadow-paging.
During vmexit emulation hvm_set_cr0 and hvm_set_cr4 are called to restore cr0 and cr4 for the l1 guest.
With this patch the paging mode for the l2 guest is updated rather for the l1 guest.
I think this patch also breaks the case where l2 guest wants to set cr0 or cr4 and l1-hypervisor does not intercept cr0/cr4 and l1-hypervisor uses shadow-paging. This may also count for VMX.
This is just from reading the code. As I said, I do not have a setup to verify this, unfortunately.
Christoph
Quoted 51 lines
Quoted 31 lines
Jan
Zhang, Yang Z wrote on 2013-12-12:
Quoted 18 lines
vmswitch is in progress
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
Signed-off-by Yang Zhang <[email protected]>--- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)This patch fixed RHEL6 guest installation problem with L1 hyper-v.
xen/arch/x86/hvm/hvm.c index renamed from xen/arch/x86/hvm/hvm.c +0
-069f7e74..1f62e00 100644
xen/arch/x86/hvm/hvm.c int hvm_set_cr0(unsigned long value) · line 1931
Quoted 8 lines
xen/arch/x86/hvm/hvm.c +1
-1@@ -1925,7 +1925,7 @@ int hvm_set_cr0(unsigned long value)hvm_update_cr (v,0 , value);if ( (value ^ old_value) &X86_CR0_PG ) { -if ( !nestedhvm_vmswitch_in_progress (v) && nestedhvm_vcpu_in_guestmode(v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes(v); @@ -2014,7 +2014,7@@ int
Quoted 14 lines
Quoted 2 lines
hvm_set_cr4(unsigned long value)(X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE |
X86_CR4_SMEP)) ||Quoted 9 lines
(!(value & X86_CR4_PCIDE) && (old_cr & X86_CR4_PCIDE)) ) { - if ( !nestedhvm_vmswitch_in_progress(v) && nestedhvm_vcpu_in_guestmode(v) ) + if ( nestedhvm_vcpu_in_guestmode(v) ) paging_update_nestedmode(v); else paging_update_paging_modes(v);--
1.7.1Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Egger, Christoph wrote on 2013-12-18:
Quoted 24 lines · Yang Z
Quoted 7 lines
Jan Beulich wrote on 2013-12-18:
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Quoted 6 lines
Quoted 3 lines
Furthermore, while you ack-ed this patch (which isn't really VMX specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
Actually, I asked him help to review the first patch. Since Christoph thought
the first patch may break AMD. So I hope he can help to review the first patch to see whether I am wrong.
Quoted 6 lines
Quoted 6 lines
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to
go in).
Quoted 1 line
Quoted 9 lines
Quoted 1 line
Yes, the three patches are independent.
I have looked through code.
vcpu is in guestmode till the vmentry/vmexit emulation is done. In SVM the vcpu guestmode changes right before setting
nv_vmswitch_in_progressto 0 when the vmentry/vmexit emulation was successfull (there is a bunch of error-checking).
After checking the SVM logic, I find the basic usage of vcpu_in/exitk_guestmode of VMX side is different from that of SVM side:
VMX side:
virtual vmentry: set vcpu in guestmode after vmcs switched to vmcs02. This happed at the beginning of vmentry which means the whole vmentry emulation code is executed when vcpu is in guest mode.
virtual vmexit: set vcpu exit guestmode after vmcs switched to vmcs01. Also, this action occurred just after sync vmcs02 to vmcs12 and before the vmcs01's state restored (like set_cr), which means the vmcs01's state restored when vcpu is not in guest mode.
SVM side:
virtual vmentry: set vcpu in guest mode after vmentry emulation is done, which means the emulation code is executed when vcpu is not in guest mode.
virtual vmexit: set vcpu exit guest mode after vmexit emulation is done, which means the emulation code is executed when vcpu is in guest mode.
Ok, now let us take a look at current implementation, take hvm_set_cr0 for example:
Update nested mode when (vcpu_in_guestmode && !vmswitch_in_progress). Otherwise, update L1's paging mode:
if ( !nestedhvm_vmswitch_in_progress(v) && nestedhvm_vcpu_in_guestmode(v) )
paging_update_nestedmode(v);
else
paging_update_paging_modes(v);virtual vmentry:
Expected result: nested mode is being updated.
Current result in SVM:
!vcpu_in_guestmode and vmswitch_in_progress: L1's paging mode is updated. Wrong.
Current result in VMX:
vcpu_in_guestmode and vmswitch_in_progress : L1's paging mode is updated. Wrong.
Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmode and vmswitch_in_progress: L1's paging mode is updated. Correct.
Current result in VMX:
!vcpu_in_guestmode and vmswitch_in_progress: L1's paging mod is updated. Correct
Quoted 1 line
From the above result, we can see the
vmswitch_in_progressis actually take effect notvcpu_guest_mode. The original code doesn't consider the paging mode changed during vmentry/vmexit emulation. This seems wrong to me, because paging mode changing happens in real world.
Here is the result with my patch:
Update nested mode when vcpu_in_guestmode. Otherwise, update L1's paging mode:
if (nestedhvm_vcpu_in_guestmode(v) )
paging_update_nestedmode(v);
else
paging_update_paging_modes(v);virtual vmentry:
Expected result: nested mode is being updated.
Current result in SVM:
!vcpu_in_guestmode: L1's paging mode is updated. Wrong.
Current result in VMX:
vcpu_in_guestmode : Nested paging mode is updated. Correct.
Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmode: Nested paging mode is updated. Wrong.
Current result in VMX:
!vcpu_in_guestmode: L1's paging mod is updated. Correct
Quoted 1 line
From the above, we can see the problem is that the way to distinguish the vmentry and vmexit in SVM and VMX side is different. Since I am not familiar the SVM, so i am not sure whether the usage of
vcpu_in_guestmodein SVM is right or wrong. But in VMX side, once the vmcs is changed, then thevcpu_in_guestmodeis changed too which we think is following hardware's behavior.
Also, I think I found another issue that the paging mode cannot be tracked correctly with current way or with my patch. Need more time to investigate.
Quoted 10 lines
This patch breaks both vmentry and vmexit emulation for SVM. The vmentry breakage comes with l1-hypervisor using shadow-paging.
During vmexit emulation
hvm_set_cr0andhvm_set_cr4are called to restore cr0 and cr4 for the l1 guest. With this patch the paging mode for the l2 guest is updated rather for the l1 guest.I think this patch also breaks the case where l2 guest wants to set cr0 or cr4 and l1-hypervisor does not intercept cr0/cr4 and l1-hypervisor uses shadow-paging. This may also count for VMX.
For this case, am I missing something? If yes, please correct me.
Quoted 4 lines
This is just from reading the code. As I said, I do not have a setup to verify this, unfortunately.
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
In reply to Egger, ChristophZhang, Yang Z wrote on 2013-12-23:
Quoted 106 lines
Egger, Christoph wrote on 2013-12-18:
Quoted 24 lines · Yang Z
Quoted 7 lines
Jan Beulich wrote on 2013-12-18:
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Quoted 6 lines
Quoted 3 lines
Furthermore, while you ack-ed this patch (which isn't really VMX specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
Actually, I asked him help to review the first patch. Since Christoph thought
the first patch may break AMD. So I hope he can help to review the first patch to see whether I am wrong.
Quoted 6 lines
Quoted 6 lines
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to
go in).
Quoted 1 line
Quoted 9 lines
Quoted 1 line
Yes, the three patches are independent.
I have looked through code.
vcpu is in guestmode till the vmentry/vmexit emulation is done. In SVM the vcpu guestmode changes right before setting
nv_vmswitch_in_progressto 0 when the vmentry/vmexit emulation was successfull (there is a bunch of error-checking).After checking the SVM logic, I find the basic usage of vcpu_in/exitk_guestmode of VMX side is different from that of SVM side:
VMX side:
virtual vmentry: set vcpu in guestmode after vmcs switched to vmcs02.
This happed at the beginning of vmentry which means the whole vmentry emulation code is executed when vcpu is in guest mode.
virtual vmexit: set vcpu exit guestmode after vmcs switched to vmcs01.
Also, this action occurred just after sync vmcs02 to vmcs12 and before the vmcs01's state restored (likeset_cr), which means the vmcs01's state restored when vcpu is not in guest mode.
SVM side:
virtual vmentry: set vcpu in guest mode after vmentry emulation is done, which means the emulation code is executed when vcpu is not in guest mode. virtual vmexit: set vcpu exit guest mode after vmexit emulation is
done, which means the emulation code is executed when vcpu is in guest mode.Ok, now let us take a look at current implementation, take
hvm_set_cr0for example: Update nested mode when (vcpu_in_guestmode&& !vmswitch_in_progress). Otherwise, update L1's paging mode:if ( !nestedhvm_vmswitch_in_progress(v) && nestedhvm_vcpu_in_guestmode(v) ) paging_update_nestedmode(v); else paging_update_paging_modes(v);virtual vmentry:
Expected result: nested mode is being updated. Current result in SVM:
!vcpu_in_guestmode andvmswitch_in_progress: L1's paging
mode is updated. Wrong.
Current result in VMX:
vcpu_in_guestmodeandvmswitch_in_progress: L1's paging
mode is updated. Wrong.Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmodeandvmswitch_in_progress: L1's paging
mode is updated. Correct.
Current result in VMX:
!vcpu_in_guestmode andvmswitch_in_progress: L1's paging
mod is updated. CorrectFrom the above result, we can see the
vmswitch_in_progressis actually take effect notvcpu_guest_mode. The original code doesn't consider the paging mode changed during vmentry/vmexit emulation. This seems wrong to me, because paging mode changing happens in real world.Here is the result with my patch: Update nested mode when
vcpu_in_guestmode. Otherwise, update L1's paging mode:
if (nestedhvm_vcpu_in_guestmode(v))
paging_update_nestedmode(v); elsepaging_update_paging_modes(v);
virtual vmentry:
Expected result: nested mode is being updated.
Current result in SVM:
!vcpu_in_guestmode: L1's paging mode is updated. Wrong.
Current result in VMX:vcpu_in_guestmode: Nested paging mode is updated. Correct.
Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmode: Nested paging mode is updated. Wrong.
Current result in VMX: !vcpu_in_guestmode: L1's paging mod is
updated. Correct
From the above, we can see the problem is that the way to distinguish the vmentry and vmexit in SVM and VMX side is different. Since I am not familiar the SVM, so i am not sure whether the usage ofvcpu_in_guestmodein SVM is right or wrong. But in VMX side, once the vmcs is changed, then thevcpu_in_guestmodeis changed too which we think is following hardware's behavior.
Quoted 2 lines
Also, I think I found another issue that the paging mode cannot be tracked correctly with current way or with my patch. Need more time to investigate.
Ok. The issue is that if the paging state is changed via vmwrite (L1 writes L2's vmcs to change paging mode directly) which is unaware to L0. And hypervisor cannot set the right nested paging mode during virtual vmentry. So we need to update nest mode unconditionally for each virtual vmentry.
Quoted 16 lines
Quoted 5 lines
This patch breaks both vmentry and vmexit emulation for SVM. The vmentry breakage comes with l1-hypervisor using shadow-paging.
Quoted 7 lines
During vmexit emulation
hvm_set_cr0andhvm_set_cr4are called to restore cr0 and cr4 for the l1 guest. With this patch the paging mode for the l2 guest is updated rather for the l1 guest.I think this patch also breaks the case where l2 guest wants to set cr0 or cr4 and l1-hypervisor does not intercept cr0/cr4 and l1-hypervisor uses shadow-paging. This may also count for VMX.
For this case, am I missing something? If yes, please correct me.
Quoted 1 line
Quoted 8 lines
Quoted 3 lines
This is just from reading the code. As I said, I do not have a setup to verify this, unfortunately.
Best regards,
Yang
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
In reply to Egger, ChristophZhang, Yang Z wrote on 2013-12-24:
Quoted 139 lines
Zhang, Yang Z wrote on 2013-12-23:
Quoted 82 lines
Egger, Christoph wrote on 2013-12-18:
Quoted 24 lines · Yang Z
Quoted 7 lines
Jan Beulich wrote on 2013-12-18:
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Quoted 6 lines
Quoted 3 lines
Furthermore, while you ack-ed this patch (which isn't really VMX specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
Actually, I asked him help to review the first patch. Since Christoph thought
the first patch may break AMD. So I hope he can help to review the first patch to see whether I am wrong.
Quoted 6 lines
Quoted 6 lines
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to
go in).
Quoted 1 line
Quoted 9 lines
Quoted 1 line
Yes, the three patches are independent.
I have looked through code.
vcpu is in guestmode till the vmentry/vmexit emulation is done. In SVM the vcpu guestmode changes right before setting
nv_vmswitch_in_progressto 0 when the vmentry/vmexit emulation was successfull (there is a bunch of error-checking).After checking the SVM logic, I find the basic usage of vcpu_in/exitk_guestmode of VMX side is different from that of SVM side:
VMX side:
virtual vmentry: set vcpu in guestmode after vmcs switched to vmcs02.
This happed at the beginning of vmentry which means the whole vmentry emulation code is executed when vcpu is in guest mode.
virtual vmexit: set vcpu exit guestmode after vmcs switched to vmcs01.
Also, this action occurred just after sync vmcs02 to vmcs12 and before the vmcs01's state restored (likeset_cr), which means the vmcs01's state restored when vcpu is not in guest mode.
SVM side:
virtual vmentry: set vcpu in guest mode after vmentry emulation is done, which means the emulation code is executed when vcpu is not in guest mode. virtual vmexit: set vcpu exit guest mode after vmexit emulation is
done, which means the emulation code is executed when vcpu is in guest mode.Ok, now let us take a look at current implementation, take
hvm_set_cr0for example: Update nested mode when (vcpu_in_guestmode&& !vmswitch_in_progress). Otherwise, update L1's paging mode:if ( !nestedhvm_vmswitch_in_progress(v) &&
nestedhvm_vcpu_in_guestmode(v))
paging_update_nestedmode(v); elsepaging_update_paging_modes(v); virtual vmentry:
Expected result: nested mode is being updated. Current result in SVM:
!vcpu_in_guestmode andvmswitch_in_progress: L1's paging
mode is updated. Wrong.
Current result in VMX:
vcpu_in_guestmodeandvmswitch_in_progress: L1's paging
mode is updated. Wrong.Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmodeandvmswitch_in_progress: L1's paging
mode is updated. Correct.
Current result in VMX:
!vcpu_in_guestmode andvmswitch_in_progress: L1's paging
mod is updated. CorrectFrom the above result, we can see the
vmswitch_in_progressis actually take effect notvcpu_guest_mode. The original code doesn't consider the paging mode changed during vmentry/vmexit emulation. This seems wrong to me, because paging mode changing happens in real world.Quoted 16 lines
Here is the result with my patch: Update nested mode when
vcpu_in_guestmode. Otherwise, update L1's paging mode:
if (nestedhvm_vcpu_in_guestmode(v))
paging_update_nestedmode(v); elsepaging_update_paging_modes(v); virtual vmentry:
Expected result: nested mode is being updated. Current result in SVM:
!vcpu_in_guestmode: L1's paging mode is updated. Wrong. Current result in VMX:vcpu_in_guestmode: Nested paging mode is updated. Correct.
Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmode: Nested paging mode is updated. Wrong. Current result in VMX: !vcpu_in_guestmode: L1's paging
modis
Quoted 11 lines
updated. Correct
From the above, we can see the problem is that the way to distinguish the vmentry and vmexit in SVM and VMX side is different. Since I am not familiar the SVM, so i am not sure whether the usage ofvcpu_in_guestmodein SVM is right or wrong. But in VMX side, once the vmcs is changed, then thevcpu_in_guestmodeis changed too which we think is following hardware's behavior.Also, I think I found another issue that the paging mode cannot be tracked correctly with current way or with my patch. Need more time to
investigate.
Ok. The issue is that if the paging state is changed via vmwrite (L1
writes L2's vmcs to change paging mode directly) which is unaware to
L0. And hypervisor cannot set the right nested paging mode during
virtual vmentry. So we need to update nest mode unconditionally for each virtual vmentry.Quoted 21 lines
Quoted 5 lines
This patch breaks both vmentry and vmexit emulation for SVM. The vmentry breakage comes with l1-hypervisor using shadow-paging.
Quoted 7 lines
During vmexit emulation
hvm_set_cr0andhvm_set_cr4are called to restore cr0 and cr4 for the l1 guest. With this patch the paging mode for the l2 guest is updated rather for the l1 guest.I think this patch also breaks the case where l2 guest wants to set cr0 or cr4 and l1-hypervisor does not intercept cr0/cr4 and l1-hypervisor uses shadow-paging. This may also count for VMX.
For this case, am I missing something? If yes, please correct me.
Quoted 4 lines
This is just from reading the code. As I said, I do not have a setup to verify this, unfortunately.
Quoted 8 lines
Quoted 3 lines
Best regards,
YangBest regards,
Yang
Any comments ?
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Quoted 134 lines
Quoted 1 line
Quoted 1 line · Yang Z
Zhang, Yang Z wrote on 2013-12-24:
Quoted 111 lines
Zhang, Yang Z wrote on 2013-12-23:
Quoted 82 lines
Egger, Christoph wrote on 2013-12-18:
Quoted 24 lines · Yang Z
Quoted 7 lines
Jan Beulich wrote on 2013-12-18:
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Quoted 6 lines
Quoted 3 lines
Furthermore, while you ack-ed this patch (which isn't really VMX specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
Actually, I asked him help to review the first patch. Since Christoph thought
the first patch may break AMD. So I hope he can help to review the first patch to see whether I am wrong.
Quoted 6 lines
Quoted 6 lines
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to
go in).
Quoted 1 line
Quoted 9 lines
Quoted 1 line
Yes, the three patches are independent.
I have looked through code.
vcpu is in guestmode till the vmentry/vmexit emulation is done. In SVM the vcpu guestmode changes right before setting
nv_vmswitch_in_progressto 0 when the vmentry/vmexit emulation was successfull (there is a bunch of error-checking).After checking the SVM logic, I find the basic usage of vcpu_in/exitk_guestmode of VMX side is different from that of SVM side:
VMX side:
virtual vmentry: set vcpu in guestmode after vmcs switched to vmcs02.
This happed at the beginning of vmentry which means the whole vmentry emulation code is executed when vcpu is in guest mode.
virtual vmexit: set vcpu exit guestmode after vmcs switched to vmcs01.
Also, this action occurred just after sync vmcs02 to vmcs12 and before the vmcs01's state restored (likeset_cr), which means the vmcs01's state restored when vcpu is not in guest mode.
SVM side:
virtual vmentry: set vcpu in guest mode after vmentry emulation is done, which means the emulation code is executed when vcpu is not in guest mode. virtual vmexit: set vcpu exit guest mode after vmexit emulation is
done, which means the emulation code is executed when vcpu is in guest mode.Ok, now let us take a look at current implementation, take
hvm_set_cr0for example: Update nested mode when (vcpu_in_guestmode&& !vmswitch_in_progress). Otherwise, update L1's paging mode:if ( !nestedhvm_vmswitch_in_progress(v) &&
nestedhvm_vcpu_in_guestmode(v))
paging_update_nestedmode(v); elsepaging_update_paging_modes(v); virtual vmentry:
Expected result: nested mode is being updated. Current result in SVM:
!vcpu_in_guestmode andvmswitch_in_progress: L1's paging
mode is updated. Wrong.
Current result in VMX:
vcpu_in_guestmodeandvmswitch_in_progress: L1's paging
mode is updated. Wrong.Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmodeandvmswitch_in_progress: L1's paging
mode is updated. Correct.
Current result in VMX:
!vcpu_in_guestmode andvmswitch_in_progress: L1's paging
mod is updated. CorrectFrom the above result, we can see the
vmswitch_in_progressis actually take effect notvcpu_guest_mode. The original code doesn't consider the paging mode changed during vmentry/vmexit emulation. This seems wrong to me, because paging mode changing happens in real world.Quoted 16 lines
Here is the result with my patch: Update nested mode when
vcpu_in_guestmode. Otherwise, update L1's paging mode:
if (nestedhvm_vcpu_in_guestmode(v))
paging_update_nestedmode(v); elsepaging_update_paging_modes(v); virtual vmentry:
Expected result: nested mode is being updated. Current result in SVM:
!vcpu_in_guestmode: L1's paging mode is updated. Wrong. Current result in VMX:vcpu_in_guestmode: Nested paging mode is updated. Correct.
Virtual vmexit:
Expected result: L1's paging mode is updated. Current result in SVM:
vcpu_in_guestmode: Nested paging mode is updated. Wrong. Current result in VMX: !vcpu_in_guestmode: L1's paging
modis
Quoted 11 lines
updated. Correct
From the above, we can see the problem is that the way to distinguish the vmentry and vmexit in SVM and VMX side is different. Since I am not familiar the SVM, so i am not sure whether the usage ofvcpu_in_guestmodein SVM is right or wrong. But in VMX side, once the vmcs is changed, then thevcpu_in_guestmodeis changed too which we think is following hardware's behavior.Also, I think I found another issue that the paging mode cannot be tracked correctly with current way or with my patch. Need more time to
Quoted 6 lines
investigate.
Ok. The issue is that if the paging state is changed via vmwrite (L1 writes L2's vmcs to change paging mode directly) which is unaware to L0. And hypervisor cannot set the right nested paging mode during virtual vmentry. So we need to update nest mode unconditionally for each
virtual vmentry.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
This patch breaks both vmentry and vmexit emulation for SVM. The vmentry breakage comes with l1-hypervisor using shadow-paging.
During vmexit emulation
hvm_set_cr0andhvm_set_cr4are called to restore cr0 and cr4 for the l1 guest. With this patch the paging mode for the l2 guest is updated rather for the l1 guest.I think this patch also breaks the case where l2 guest wants to set cr0 or cr4 and l1-hypervisor does not intercept cr0/cr4 and l1-hypervisor uses shadow-paging. This may also count for VMX.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
For this case, am I missing something? If yes, please correct me.
Quoted 3 lines
This is just from reading the code. As I said, I do not have a setup to verify this, unfortunately.
Any comments ?
Considering Christoph's comments and reservations, if you can't alone deal with this I think you should work with the AMD people to eliminate or address his concerns.
Jan
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Jan Beulich wrote on 2014-01-14:
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Yang Z
Zhang, Yang Z wrote on 2013-12-24:
Any comments ?
Considering Christoph's comments and reservations, if you can't alone deal with this I think you should work with the AMD people to eliminate or address his concerns.
Yes. But the problem puzzled me is that Christoph said nested SVM works well w/o my patch which I cannot understand. Because according my analysis in previous thread, it also buggy in AMD side. But if they really solved the issue in their side, I wonder how they fix it. Perhaps I can use the same solution in VMX side without touch the common code.
Christoph, can you help to check it? thanks.
Quoted 1 line
Jan
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Quoted 11 lines · Yang Z
Jan Beulich wrote on 2014-01-14:
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Yang Z
Zhang, Yang Z wrote on 2013-12-24:
Any comments ?
Considering Christoph's comments and reservations, if you can't alone deal with this I think you should work with the AMD people to eliminate or address his concerns.
Quoted 7 lines
Yes. But the problem puzzled me is that Christoph said nested SVM works well w/o my patch which I cannot understand. Because according my analysis in previous thread, it also buggy in AMD side. But if they really solved the issue in their side, I wonder how they fix it. Perhaps I can use the same solution in VMX side without touch the common code.
Christoph, can you help to check it? thanks.
The fix I mentioned solves the vmswitch problem on AMD side. The page mode problem you discovered is a seperate issue for both SVM and VMX that needs to be addressed.
Christoph
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Egger, Christoph wrote on 2014-01-20:
Quoted 20 lines · Yang Z
Quoted 2 lines
Jan Beulich wrote on 2014-01-14:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 14.01.14 at 03:33, "Zhang, Yang Z" <[email protected]>
Quoted 16 lines · wrote:
Quoted 8 lines
Quoted 3 lines
Zhang, Yang Z wrote on 2013-12-24:
Any comments ?
Considering Christoph's comments and reservations, if you can't alone deal with this I think you should work with the AMD people to eliminate or address his concerns.
Yes. But the problem puzzled me is that Christoph said nested SVM works well w/o my patch which I cannot understand. Because according my analysis in previous thread, it also buggy in AMD side. But if they really solved the issue in their side, I wonder how they fix it. Perhaps I can use the same solution in VMX side without touch the common code.
Quoted 3 lines
Quoted 1 line
Christoph, can you help to check it? thanks.
The fix I mentioned solves the vmswitch problem on AMD side.
But the current code is buggy with your fixing even in AMD side, see below scenario:
virtual vmentry:
Expected result: nested mode is being updated.
Current result in SVM:
!vcpu_in_guestmode and vmswitch_in_progress: L1's paging mode is updated. Wrong.
I cannot understand why you said it is working.
Quoted 4 lines
The page mode problem you discovered is a seperate issue for both SVM and VMX that needs to be addressed.
Christoph
Best regards,
Yang
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Quoted 25 lines · Yang Z
Egger, Christoph wrote on 2014-01-20:
Quoted 20 lines · Yang Z
Quoted 2 lines
Jan Beulich wrote on 2014-01-14:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 14.01.14 at 03:33, "Zhang, Yang Z" <[email protected]>
Quoted 16 lines · wrote:
Quoted 8 lines
Quoted 3 lines
Zhang, Yang Z wrote on 2013-12-24:
Any comments ?
Considering Christoph's comments and reservations, if you can't alone deal with this I think you should work with the AMD people to eliminate or address his concerns.
Yes. But the problem puzzled me is that Christoph said nested SVM works well w/o my patch which I cannot understand. Because according my analysis in previous thread, it also buggy in AMD side. But if they really solved the issue in their side, I wonder how they fix it. Perhaps I can use the same solution in VMX side without touch the common code.
Quoted 3 lines
Quoted 1 line
Christoph, can you help to check it? thanks.
The fix I mentioned solves the vmswitch problem on AMD side.
Quoted 7 lines
But the current code is buggy with your fixing even in AMD side, see below scenario:
virtual vmentry:
Expected result: nested mode is being updated.
Current result in SVM:
!vcpu_in_guestmode andvmswitch_in_progress: L1's paging mode is updated. Wrong.I cannot understand why you said it is working.
This page mode problem you discovered that needs to be addressed for both SVM and VMX.
The fix I am saying is working solves the problem of emulating an MMIO instruction which is finished in the softirq while an interrupt can cause a vmswitch during instruction emulation.
We are talking about two different issues. One is fixed on AMD side and one not.
Christoph
Re: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
In reply to Jan BeulichHi Jan:
Usually I ack one for a series of patch. This one is probably different: It appears as a series of patch, but it seems they look like quit independent. But you are correct, the 1st one is not VMX only stuff. The 3rd one appears to be harmless to me, that you may take seperately.
Thx Eddie
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Wednesday, December 18, 2013 6:08 PM
To: Dong, Eddie; Zhang, Yang Z
Cc: Christoph Egger; xen-devel
Subject: RE: [PATCH 1/3] Nested VMX: update nested paging mode when vmswitch is in progress
Quoted 2 lines
Quoted 1 line
Quoted 1 line · Eddie
Acked by Eddie Dong <[email protected]>
As long as Christoph's reservations wrt SVM aren't being addressed/ eliminated, I don't think we can apply this patch.
Furthermore, while you ack-ed this patch (which isn't really VMX
specific) and patch 3, you didn't ack patch 2, but you also didn't indicate anything that's possibly wrong with it.
And finally, with patch 1 needing to be left out for the moment, I'd like to have confirmation that all three patches can be applied independently (i.e. with the current state of things only patch 3 is ready to go in).
Jan
PATCH 2/3 VMX, apicv: Set "NMI-window exiting" for NMI
In reply to Yang ZhangFrom: Yang Zhang <[email protected]>
Enable NMI-window exiting if interrupt is blocked by NMI under apicv enabled platform.
--- xen/arch/x86/hvm/vmx/intr.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vmx/intr.c +4 -3
@@ -252,10 +252,11 @@ void vmx_intr_assist(void) intblk =hvm_interrupt_blocked (v, intack);if ( cpu_has_vmx_virtual_intr_delivery ) { -/* Set "Interrupt-window exiting" for ExtINT */ +/* Set "Interrupt-window exiting" for ExtINT and NMI. */ if ( (intblk != hvm_intblk_none) && - ( (intack.source == hvm_intsrc_pic) || - ( intack.source == hvm_intsrc_vector) ) ) + (intack.source == hvm_intsrc_pic || + intack.source == hvm_intsrc_vector || + intack.source == hvm_intsrc_nmi) ) {enable_intr_window (v, intack); goto out;
Signature · 1 line
1.7.1
Re: [PATCH 2/3] VMX, apicv: Set "NMI-window exiting" for NMI
Zhang, Yang Z wrote on 2013-12-12:
Quoted 5 lines
From: Yang Zhang <[email protected]>
Enable NMI-window exiting if interrupt is blocked by NMI under apicv enabled platform.
Hi Jun,
Can you help to review this patch? Thanks.
Quoted 12 lines
Signed-off-by Yang Zhang <[email protected]>--- xen/arch/x86/hvm/vmx/intr.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)xen/arch/x86/hvm/vmx/intr.c +0
-0
b/xen/arch/x86/hvm/vmx/intr.c@@ -252,10 +252,11 @@ voidvmx_intr_assist(void)intblk = hvm_interrupt_blocked(v, intack); if ( cpu_has_vmx_virtual_intr_delivery ) {xen/arch/x86/hvm/vmx/intr.c +0
-1-/* Set "Interrupt-window exiting" for ExtINT */
xen/arch/x86/hvm/vmx/intr.c void vmx_intr_assist(void) · line 262
Quoted 10 lines
xen/arch/x86/hvm/vmx/intr.c +4
-2+/* Set "Interrupt-window exiting" for ExtINT and NMI. */ if ( (intblk != hvm_intblk_none) && - ( (intack.source == hvm_intsrc_pic) || - ( intack.source == hvm_intsrc_vector) ) ) + (intack.source == hvm_intsrc_pic || + intack.source == hvm_intsrc_vector || + intack.source == hvm_intsrc_nmi) ) {enable_intr_window (v, intack); goto out;
Best regards,
Yang
Re: [PATCH 2/3] VMX, apicv: Set "NMI-window exiting" for NMI
Quoted 9 lines · Yang Z
Zhang, Yang Z wrote on 2013-12-12:
Quoted 5 lines
From: Yang Zhang <[email protected]>
Enable NMI-window exiting if interrupt is blocked by NMI under apicv enabled platform.
Hi Jun,
Can you help to review this patch? Thanks.
Also committed earlier today
(http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=185e83591ce420e0b004646b55c5e4783e388531)
~Andrew
Re: [PATCH 2/3] VMX, apicv: Set "NMI-window exiting" for NMI
Andrew Cooper wrote on 2014-01-08:
Quoted 9 lines · Yang Z
Quoted 8 lines
Zhang, Yang Z wrote on 2013-12-12:
Quoted 5 lines
From: Yang Zhang <[email protected]>
Enable NMI-window exiting if interrupt is blocked by NMI under apicv enabled platform.
Hi Jun,
Quoted 7 lines
Quoted 1 line
Can you help to review this patch? Thanks.
Also committed earlier today
(http://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=185e83591ce42
0e0b004646b55c5e4783e388531)~Andrew
I see it. Thanks for your remainder.
Best regards,
Yang
Re: [PATCH 2/3] VMX, apicv: Set "NMI-window exiting" for NMI
In reply to Yang ZhangZhang, Yang Z wrote on 2014-01-08:
Quoted 10 lines
Zhang, Yang Z wrote on 2013-12-12:
Quoted 5 lines
From: Yang Zhang <[email protected]>
Enable NMI-window exiting if interrupt is blocked by NMI under apicv enabled platform.
Hi Jun,
Can you help to review this patch? Thanks.
Sorry. It already been committed earlier today.
Quoted 26 lines
Quoted 14 lines
Signed-off-by Yang Zhang <[email protected]>--- xen/arch/x86/hvm/vmx/intr.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git
a/xen/arch/x86/hvm/vmx/intr.cb/xen/arch/x86/hvm/vmx/intr.cindex 7757910..8507432 100644 ---a/xen/arch/x86/hvm/vmx/intr.c+++b/xen/arch/x86/hvm/vmx/intr.c@@ -252,10 +252,11 @@ voidvmx_intr_assist(void)intblk = hvm_interrupt_blocked(v, intack); if ( cpu_has_vmx_virtual_intr_delivery ) {xen/arch/x86/hvm/vmx/intr.c +1
-1-/* Set "Interrupt-window exiting" for ExtINT */ +/* Set "Interrupt-window exiting" for ExtINT and NMI. xen/arch/x86/hvm/vmx/intr.c void vmx_intr_assist(void) · line 262
Quoted 10 lines
xen/arch/x86/hvm/vmx/intr.c +4
-2+*/ if ( (intblk != hvm_intblk_none) && - ( (intack.source == hvm_intsrc_pic) || - ( intack.source == hvm_intsrc_vector) ) ) + (intack.source == hvm_intsrc_pic || + intack.source == hvm_intsrc_vector || + intack.source == hvm_intsrc_nmi) ) {enable_intr_window (v, intack); goto out;
Quoted 3 lines
Best regards,
Yang
Best regards,
Yang
PATCH 3/3 Nested VMX: Setup the virtual NMI exiting info
In reply to Yang ZhangFrom: Yang Zhang <[email protected]>
When inject a virtual nmi exit to L1, hypervisor need to set the virtual vmcs with right vaule which is missing in current Xen.
--- xen/arch/x86/hvm/vmx/vvmx.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +6 -0
@@ -1293,6 +1293,12 @@ static void sync_exception_state(struct vcpu *v) nvmx->intr.error_code);break ;case X86_EVENTTYPE_NMI : +__set_vvmcs (nvcpu->nv_vvmcx,VM_EXIT_REASON , +EXIT_REASON_EXCEPTION_NMI ); +__set_vvmcs (nvcpu->nv_vvmcx,EXIT_QUALIFICATION ,0 ); +__set_vvmcs (nvcpu->nv_vvmcx,VM_EXIT_INTR_INFO , + nvmx->intr.intr_info); +break ;default :gdprintk (XENLOG_ERR ,"Exception state %lx not handled\n" , nvmx->intr.intr_info);
Signature · 1 line
1.7.1
Re: [PATCH 3/3] Nested VMX: Setup the virtual NMI exiting info
Acked by Eddie Dong <[email protected]>
-----Original Message-----
From: Zhang, Yang Z
Sent: Thursday, December 12, 2013 10:07 AM
To: [email protected]
Cc: [email protected]; Dong, Eddie; Zhang, Yang Z
Subject: [PATCH 3/3] Nested VMX: Setup the virtual NMI exiting info
From: Yang Zhang <[email protected]>
When inject a virtual nmi exit to L1, hypervisor need to set the virtual vmcs with right vaule which is missing in current Xen.
--- xen/arch/x86/hvm/vmx/vvmx.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +6 -0
@@ -1293,6 +1293,12 @@ static void sync_exception_state(struct vcpu *v) nvmx->intr.error_code);break ;case X86_EVENTTYPE_NMI : +__set_vvmcs (nvcpu->nv_vvmcx,VM_EXIT_REASON , +EXIT_REASON_EXCEPTION_NMI ); +__set_vvmcs (nvcpu->nv_vvmcx,EXIT_QUALIFICATION ,0 ); +__set_vvmcs (nvcpu->nv_vvmcx,VM_EXIT_INTR_INFO , + nvmx->intr.intr_info); +break ;default :gdprintk (XENLOG_ERR ,"Exception state %lx not handled\n" , nvmx->intr.intr_info);
Signature · 1 line
1.7.1
Hi, eddie,
Can you help to review the patches?
Best regards,
Yang
Quoted 23 lines
-----Original Message-----
From: Zhang, Yang Z
Sent: Thursday, December 12, 2013 10:07 AM
To: [email protected]
Cc: [email protected]; Dong, Eddie; Zhang, Yang Z
Subject: [PATCH 0/3] some nested vmx fixing to hyper-vFrom: Yang Zhang <[email protected]>
This series patches fix some issues which i encountered when boot L1 hyper-v.
This patch fixed RHEL6 guest installation problem with L1 hyper-v:
Nested VMX: update nested paging mode when vmswitch is in progressThe two fixing SMP hyper-v boot issue:
VMX,apicv: Set "NMI-window exiting" for NMI Nested VMX: Setup the virtual NMI exiting info:Yang Zhang (3):
Nested VMX: update nested paging mode when vmswitch is in progress VMX,apicv: Set "NMI-window exiting" for NMI
Nested VMX: Setup the virtual NMI exiting info
Quoted 4 lines
xen/arch/x86/hvm/hvm.c | 4 ++-- xen/arch/x86/hvm/vmx/intr.c | 7 ++++--- xen/arch/x86/hvm/vmx/vvmx.c | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-)
From: Yang Zhang <[email protected]>
virtual vmentry will change paging related stucture, so corrensponding nested mode need to be updated which is missing currently.
--- xen/arch/x86/hvm/hvm.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
This patch fixed RHEL6 guest installation problem with L1 hyper-v.
xen/arch/x86/hvm/hvm.c +2 -2
@@ -1925,7 +1925,7 @@ int hvm_set_cr0(unsigned long value)hvm_update_cr (v,0 , value);if ( (value ^ old_value) &X86_CR0_PG ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);
@@ -2014,7 +2014,7 @@ int hvm_set_cr4(unsigned long value) (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE | X86_CR4_SMEP)) || (!(value & X86_CR4_PCIDE) && (old_cr & X86_CR4_PCIDE)) ) { -if ( !nestedhvm_vmswitch_in_progress (v) &&nestedhvm_vcpu_in_guestmode (v) ) +if (nestedhvm_vcpu_in_guestmode (v) )paging_update_nestedmode (v);else paging_update_paging_modes (v);
--
1.7.1
From: Yang Zhang <[email protected]>
Enable NMI-window exiting if interrupt is blocked by NMI under apicv enabled platform.
--- xen/arch/x86/hvm/vmx/intr.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
xen/arch/x86/hvm/vmx/intr.c +4 -3
@@ -252,10 +252,11 @@ void vmx_intr_assist(void) intblk =hvm_interrupt_blocked (v, intack);if ( cpu_has_vmx_virtual_intr_delivery ) { -/* Set "Interrupt-window exiting" for ExtINT */ +/* Set "Interrupt-window exiting" for ExtINT and NMI. */ if ( (intblk != hvm_intblk_none) && - ( (intack.source == hvm_intsrc_pic) || - ( intack.source == hvm_intsrc_vector) ) ) + (intack.source == hvm_intsrc_pic || + intack.source == hvm_intsrc_vector || + intack.source == hvm_intsrc_nmi) ) {enable_intr_window (v, intack); goto out;
--
1.7.1
From: Yang Zhang <[email protected]>
When inject a virtual nmi exit to L1, hypervisor need to set the virtual vmcs with right vaule which is missing in current Xen.
--- xen/arch/x86/hvm/vmx/vvmx.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
xen/arch/x86/hvm/vmx/vvmx.c +6 -0
@@ -1293,6 +1293,12 @@ static void sync_exception_state(struct vcpu *v) nvmx->intr.error_code);break ;case X86_EVENTTYPE_NMI : +__set_vvmcs (nvcpu->nv_vvmcx,VM_EXIT_REASON , +EXIT_REASON_EXCEPTION_NMI ); +__set_vvmcs (nvcpu->nv_vvmcx,EXIT_QUALIFICATION ,0 ); +__set_vvmcs (nvcpu->nv_vvmcx,VM_EXIT_INTR_INFO , + nvmx->intr.intr_info); +break ;default :gdprintk (XENLOG_ERR ,"Exception state %lx not handled\n" , nvmx->intr.intr_info);
--
1.7.1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel