From: Avi Kivity <avi@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com
Subject: Re: [PATCH 2/2] Provide fast path for "rep ins" emulation if possible.
Date: Wed, 23 May 2012 17:40:43 +0300 [thread overview]
Message-ID: <4FBCF6EB.8040604@redhat.com> (raw)
In-Reply-To: <1337782095-32287-3-git-send-email-gleb@redhat.com>
On 05/23/2012 05:08 PM, Gleb Natapov wrote:
> "rep ins" emulation is going through emulator now. This is slow because
> emulator knows how to write back only one datum at a time. This patch
> provides fast path for the instruction in certain conditions. The
> conditions are: DF flag is not set, destination memory is RAM and single
> datum does not cross page boundary. If fast path code fails it falls
> back to emulation.
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index f75af40..20e3fb0 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1887,21 +1887,31 @@ static int io_interception(struct vcpu_svm *svm)
> {
> struct kvm_vcpu *vcpu = &svm->vcpu;
> u32 io_info = svm->vmcb->control.exit_info_1; /* address size bug? */
> - int size, in, string;
> + int size, in, string, rep;
> unsigned port;
>
> ++svm->vcpu.stat.io_exits;
> string = (io_info & SVM_IOIO_STR_MASK) != 0;
> + rep = (io_info & SVM_IOIO_REP_MASK) != 0;
> in = (io_info & SVM_IOIO_TYPE_MASK) != 0;
> - if (string || in)
> - return emulate_instruction(vcpu, 0) == EMULATE_DONE;
>
If decode assists are not available, we still need to emulate, see 15.33.5.
> port = io_info >> 16;
> size = (io_info & SVM_IOIO_SIZE_MASK) >> SVM_IOIO_SIZE_SHIFT;
> svm->next_rip = svm->vmcb->control.exit_info_2;
> - skip_emulated_instruction(&svm->vcpu);
>
> - return kvm_fast_pio_out(vcpu, size, port);
> + if (!string && !in) {
> + skip_emulated_instruction(&svm->vcpu);
> + return kvm_fast_pio_out(vcpu, size, port);
> + } else if (string && in && rep) {
> + int addr_size = (io_info & SVM_IOIO_ASIZE_MASK) >>
> + SVM_IOIO_ASIZE_SHIFT;
> + int r = kvm_fast_string_pio_in(vcpu, size, port,
> + ffs(addr_size) - 1);
> + if (r != EMULATE_FAIL)
> + return r == EMULATE_DONE;
> + }
> +
> + return emulate_instruction(vcpu, 0) == EMULATE_DONE;
> }
>
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2012-05-23 14:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-23 14:08 [PATCH 0/2] improve speed of "rep ins" emulation Gleb Natapov
2012-05-23 14:08 ` [PATCH 1/2] Provide userspace IO exit completion callback Gleb Natapov
2012-05-23 14:08 ` [PATCH 2/2] Provide fast path for "rep ins" emulation if possible Gleb Natapov
2012-05-23 14:40 ` Avi Kivity [this message]
2012-05-23 14:49 ` Avi Kivity
2012-05-24 10:34 ` Roedel, Joerg
2012-05-24 10:36 ` Avi Kivity
2012-05-24 10:54 ` Roedel, Joerg
2012-06-05 17:27 ` Alexander Graf
2012-06-05 17:36 ` Gleb Natapov
2012-06-05 17:41 ` Alexander Graf
2012-06-05 17:50 ` Gleb Natapov
2012-06-05 18:17 ` Gleb Natapov
2012-06-05 17:57 ` Gleb Natapov
2012-06-06 9:28 ` Roedel, Joerg
2012-06-05 16:07 ` Avi Kivity
2012-06-05 17:19 ` Gleb Natapov
2012-06-06 8:04 ` 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=4FBCF6EB.8040604@redhat.com \
--to=avi@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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