kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: Alexander Graf <agraf@suse.de>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/12] kvm/svm: cache nested intercepts
Date: Wed, 29 Jul 2009 16:13:35 +0300	[thread overview]
Message-ID: <4A704AFF.8070702@redhat.com> (raw)
In-Reply-To: <1248872192-30881-9-git-send-email-joerg.roedel@amd.com>

On 07/29/2009 03:56 PM, Joerg Roedel wrote:
> Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
> ---
>   arch/x86/kvm/svm.c |   30 +++++++++++++++++++++++-------
>   1 files changed, 23 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 31467b1..9192c9a 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -86,6 +86,15 @@ struct nested_state {
>
>   	/* gpa pointers to the real vectors */
>   	u64 vmcb_msrpm;
> +
> +	/* cache for intercepts of the guest */
> +	u16 intercept_cr_read;
> +	u16 intercept_cr_write;
> +	u16 intercept_dr_read;
> +	u16 intercept_dr_write;
> +	u32 intercept_exceptions;
> +	u64 intercept;
> +
>   };
>
>   struct vcpu_svm {
> @@ -1459,7 +1468,6 @@ static int nested_svm_exit_handled_real(struct vcpu_svm *svm,
>   					void *arg2,
>   					void *opaque)
>   {
> -	struct vmcb *nested_vmcb = (struct vmcb *)arg1;
>   	bool kvm_overrides = *(bool *)opaque;
>   	u32 exit_code = svm->vmcb->control.exit_code;
>
> @@ -1486,38 +1494,38 @@ static int nested_svm_exit_handled_real(struct vcpu_svm *svm,
>   	switch (exit_code) {
>   	case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR8: {
>   		u32 cr_bits = 1<<  (exit_code - SVM_EXIT_READ_CR0);
> -		if (nested_vmcb->control.intercept_cr_read&  cr_bits)
> +		if (svm->nested.intercept_cr_read&  cr_bits)
>   			return 1;
>   		break;
>   	}
>   	case SVM_EXIT_WRITE_CR0 ... SVM_EXIT_WRITE_CR8: {
>   		u32 cr_bits = 1<<  (exit_code - SVM_EXIT_WRITE_CR0);
> -		if (nested_vmcb->control.intercept_cr_write&  cr_bits)
> +		if (svm->nested.intercept_cr_write&  cr_bits)
>   			return 1;
>   		break;
>   	}
>   	case SVM_EXIT_READ_DR0 ... SVM_EXIT_READ_DR7: {
>   		u32 dr_bits = 1<<  (exit_code - SVM_EXIT_READ_DR0);
> -		if (nested_vmcb->control.intercept_dr_read&  dr_bits)
> +		if (svm->nested.intercept_dr_read&  dr_bits)
>   			return 1;
>   		break;
>   	}
>   	case SVM_EXIT_WRITE_DR0 ... SVM_EXIT_WRITE_DR7: {
>   		u32 dr_bits = 1<<  (exit_code - SVM_EXIT_WRITE_DR0);
> -		if (nested_vmcb->control.intercept_dr_write&  dr_bits)
> +		if (svm->nested.intercept_dr_write&  dr_bits)
>   			return 1;
>   		break;
>   	}
>   	case SVM_EXIT_EXCP_BASE ... SVM_EXIT_EXCP_BASE + 0x1f: {
>   		u32 excp_bits = 1<<  (exit_code - SVM_EXIT_EXCP_BASE);
> -		if (nested_vmcb->control.intercept_exceptions&  excp_bits)
> +		if (svm->nested.intercept_exceptions&  excp_bits)
>   			return 1;
>   		break;
>   	}
>   	default: {
>   		u64 exit_bits = 1ULL<<  (exit_code - SVM_EXIT_INTR);
>   		nsvm_printk("exit code: 0x%x\n", exit_code);
> -		if (nested_vmcb->control.intercept&  exit_bits)
> +		if (svm->nested.intercept&  exit_bits)
>   			return 1;
>   	}
>   	}
> @@ -1808,6 +1816,14 @@ static int nested_svm_vmrun(struct vcpu_svm *svm, void *arg1,
>
>   	svm->nested.vmcb_msrpm = nested_vmcb->control.msrpm_base_pa;
>
> +	/* cache intercepts */
> +	svm->nested.intercept_cr_read    = nested_vmcb->control.intercept_cr_read;
> +	svm->nested.intercept_cr_write   = nested_vmcb->control.intercept_cr_write;
> +	svm->nested.intercept_dr_read    = nested_vmcb->control.intercept_dr_read;
> +	svm->nested.intercept_dr_write   = nested_vmcb->control.intercept_dr_write;
> +	svm->nested.intercept_exceptions = nested_vmcb->control.intercept_exceptions;
> +	svm->nested.intercept            = nested_vmcb->control.intercept;
> +
>   	force_new_asid(&svm->vcpu);
>   	svm->vmcb->control.exit_int_info = nested_vmcb->control.exit_int_info;
>   	svm->vmcb->control.exit_int_info_err = nested_vmcb->control.exit_int_info_err;
>    

I don't see the benefit of this patch.  Accessing the cache is just as 
expensive as accessing the real vmcb.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2009-07-29 13:08 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-29 12:56 [PATCH 0/12] Nested SVM cleanups Joerg Roedel
2009-07-29 12:56 ` [PATCH 01/12] kvm/svm: make nested svm debugging runtime configurable Joerg Roedel
2009-07-29 13:22   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 02/12] kvm/svm: add helper functions for global interrupt flag Joerg Roedel
2009-07-29 13:15   ` Alexander Graf
2009-07-29 13:44     ` Joerg Roedel
2009-07-29 12:56 ` [PATCH 03/12] kvm/svm: optimize nested #vmexit Joerg Roedel
2009-07-29 13:23   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 04/12] kvm/svm: optimize nested vmrun Joerg Roedel
2009-07-29 13:27   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 05/12] kvm/svm: copy only necessary parts of the control area on vmrun/vmexit Joerg Roedel
2009-07-29 13:30   ` Alexander Graf
2009-07-29 13:47     ` Joerg Roedel
2009-07-29 13:48       ` Alexander Graf
2009-07-29 12:56 ` [PATCH 06/12] kvm/svm: complete interrupts after handling nested exits Joerg Roedel
2009-07-29 13:46   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 07/12] kvm/svm: move nested svm state into seperate struct Joerg Roedel
2009-07-29 13:49   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 08/12] kvm/svm: cache nested intercepts Joerg Roedel
2009-07-29 13:13   ` Avi Kivity [this message]
2009-07-29 13:13     ` Joerg Roedel
2009-07-29 13:26       ` Avi Kivity
2009-07-29 13:47         ` Joerg Roedel
2009-07-29 13:50   ` Alexander Graf
2009-07-29 13:52     ` Joerg Roedel
2009-07-29 12:56 ` [PATCH 09/12] kvm/svm: consolidate nested_svm_exit_handled Joerg Roedel
2009-07-29 13:56   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 10/12] kvm/svm: do nested vmexit in nested_svm_exit_handled Joerg Roedel
2009-07-29 14:15   ` Alexander Graf
2009-07-29 12:56 ` [PATCH 11/12] kvm/svm: handle #pf intercepts in nested_svm_exit_handled directly Joerg Roedel
2009-07-29 14:20   ` Alexander Graf
2009-07-29 14:44     ` Avi Kivity
2009-07-29 14:41       ` Alexander Graf
2009-07-29 14:49         ` Avi Kivity
2009-07-29 14:46           ` Alexander Graf
2009-07-29 12:56 ` [PATCH 12/12] kvm/svm: simplify nested_svm_check_exception Joerg Roedel
2009-07-29 14:21   ` Alexander Graf
2009-07-29 13:05 ` [PATCH 0/12] Nested SVM cleanups Avi Kivity
2009-07-29 13:09   ` Joerg Roedel
2009-07-29 13:31     ` Avi Kivity
2009-07-29 13:32     ` Avi Kivity
2009-07-29 13:29       ` Alexander Graf
2009-07-29 13:38       ` Joerg Roedel
2009-07-29 13:48         ` Avi Kivity
2009-07-29 13:48           ` Joerg Roedel
2009-07-29 13:59             ` Avi Kivity
2009-07-29 13:58               ` Joerg Roedel
2009-07-29 14:07                 ` Avi Kivity
2009-07-29 13:06 ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A704AFF.8070702@redhat.com \
    --to=avi@redhat.com \
    --cc=agraf@suse.de \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).