kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE
@ 2015-03-06 20:44 Joel Schopp
  2015-03-09 15:49 ` Radim Krčmář
  2015-03-13 14:47 ` Marcelo Tosatti
  0 siblings, 2 replies; 3+ messages in thread
From: Joel Schopp @ 2015-03-06 20:44 UTC (permalink / raw)
  To: Gleb Natapov, Paolo Bonzini, kvm
  Cc: Joerg Roedel, Borislav Petkov, linux-kernel, David Kaplan,
	rkrcmar

From: David Kaplan <david.kaplan@amd.com>

Another patch in my war on emulate_on_interception() use as a svm exit handler.

These were pulled out of a larger patch at the suggestion of Radim Krcmar, see
https://lkml.org/lkml/2015/2/25/559

Changes since v1:
	* fixed typo introduced after test, retested

Signed-off-by: David Kaplan <david.kaplan@amd.com>
[separated out just cr_interception part from larger removal of
INTERCEPT_CR0_WRITE, forward ported, tested]
Signed-off-by: Joel Schopp <joel.schopp@amd.com>
---
 arch/x86/kvm/svm.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index d319e0c..16ad05b 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -2940,7 +2940,10 @@ static int cr_interception(struct vcpu_svm *svm)
 		return emulate_on_interception(svm);
 
 	reg = svm->vmcb->control.exit_info_1 & SVM_EXITINFO_REG_MASK;
-	cr = svm->vmcb->control.exit_code - SVM_EXIT_READ_CR0;
+	if (svm->vmcb->control.exit_code == SVM_EXIT_CR0_SEL_WRITE)
+		cr = SVM_EXIT_WRITE_CR0 - SVM_EXIT_READ_CR0;
+	else
+		cr = svm->vmcb->control.exit_code - SVM_EXIT_READ_CR0;
 
 	err = 0;
 	if (cr >= 16) { /* mov to cr */
@@ -3325,7 +3328,7 @@ static int (*const svm_exit_handlers[])(struct vcpu_svm *svm) = {
 	[SVM_EXIT_READ_CR3]			= cr_interception,
 	[SVM_EXIT_READ_CR4]			= cr_interception,
 	[SVM_EXIT_READ_CR8]			= cr_interception,
-	[SVM_EXIT_CR0_SEL_WRITE]		= emulate_on_interception,
+	[SVM_EXIT_CR0_SEL_WRITE]		= cr_interception,
 	[SVM_EXIT_WRITE_CR0]			= cr_interception,
 	[SVM_EXIT_WRITE_CR3]			= cr_interception,
 	[SVM_EXIT_WRITE_CR4]			= cr_interception,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE
  2015-03-06 20:44 [PATCH v2] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE Joel Schopp
@ 2015-03-09 15:49 ` Radim Krčmář
  2015-03-13 14:47 ` Marcelo Tosatti
  1 sibling, 0 replies; 3+ messages in thread
From: Radim Krčmář @ 2015-03-09 15:49 UTC (permalink / raw)
  To: Joel Schopp
  Cc: Gleb Natapov, Paolo Bonzini, kvm, Joerg Roedel, Borislav Petkov,
	linux-kernel, David Kaplan

2015-03-06 14:44-0600, Joel Schopp:
> From: David Kaplan <david.kaplan@amd.com>
> 
> Another patch in my war on emulate_on_interception() use as a svm exit handler.
> 
> These were pulled out of a larger patch at the suggestion of Radim Krcmar, see
> https://lkml.org/lkml/2015/2/25/559
> 
> Changes since v1:
> 	* fixed typo introduced after test, retested
> 
> Signed-off-by: David Kaplan <david.kaplan@amd.com>
> [separated out just cr_interception part from larger removal of
> INTERCEPT_CR0_WRITE, forward ported, tested]
> Signed-off-by: Joel Schopp <joel.schopp@amd.com>
> ---

(Existing nested handling is tangled, but looks like everything works,)

Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE
  2015-03-06 20:44 [PATCH v2] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE Joel Schopp
  2015-03-09 15:49 ` Radim Krčmář
@ 2015-03-13 14:47 ` Marcelo Tosatti
  1 sibling, 0 replies; 3+ messages in thread
From: Marcelo Tosatti @ 2015-03-13 14:47 UTC (permalink / raw)
  To: Joel Schopp
  Cc: Gleb Natapov, Paolo Bonzini, kvm, Joerg Roedel, Borislav Petkov,
	linux-kernel, David Kaplan, rkrcmar

On Fri, Mar 06, 2015 at 02:44:35PM -0600, Joel Schopp wrote:
> From: David Kaplan <david.kaplan@amd.com>
> 
> Another patch in my war on emulate_on_interception() use as a svm exit handler.
> 
> These were pulled out of a larger patch at the suggestion of Radim Krcmar, see
> https://lkml.org/lkml/2015/2/25/559
> 
> Changes since v1:
> 	* fixed typo introduced after test, retested
> 
> Signed-off-by: David Kaplan <david.kaplan@amd.com>
> [separated out just cr_interception part from larger removal of
> INTERCEPT_CR0_WRITE, forward ported, tested]
> Signed-off-by: Joel Schopp <joel.schopp@amd.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-13 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-06 20:44 [PATCH v2] x86: svm: use cr_interception for SVM_EXIT_CR0_SEL_WRITE Joel Schopp
2015-03-09 15:49 ` Radim Krčmář
2015-03-13 14:47 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).