All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Gleb Natapov <gleb@redhat.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com
Subject: Re: [PATCHv4 5/5] KVM: Provide fast path for "rep ins" emulation if possible.
Date: Thu, 19 Jul 2012 13:37:32 +0300	[thread overview]
Message-ID: <5007E36C.6000807@redhat.com> (raw)
In-Reply-To: <1342683653-32114-6-git-send-email-gleb@redhat.com>

On 07/19/2012 10:40 AM, 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.
> 
> +
> +int kvm_fast_string_pio_in(struct kvm_vcpu *vcpu, int size,
> +		unsigned short port, u8 ad_bytes_idx)
> +{
> +	unsigned long rdi = kvm_register_read(vcpu, VCPU_REGS_RDI);
> +	unsigned long linear_addr;
> +	unsigned long rcx = kvm_register_read(vcpu, VCPU_REGS_RCX), count;
> +	u8 ad_bytes;
> +	int r;
> +
> +	if (ad_bytes_idx > 2)
> +		return EMULATE_FAIL;
> +
> +	ad_bytes = (u8[]){2, 4, 8}[ad_bytes_idx];
> +

2 << logs2_ad_bytes instead of this nice functional programming style.

> +	rcx = kvm_address_mask(ad_bytes, rcx);
> +
> +	if (rcx == 0) {
> +		kvm_x86_ops->skip_emulated_instruction(vcpu);
> +		return EMULATE_DONE;
> +	}
> +
> +	if (kvm_get_rflags(vcpu) & X86_EFLAGS_DF)
> +		return EMULATE_FAIL;
> +
> +	rdi = kvm_address_mask(ad_bytes, rdi);
> +
> +	r = kvm_linearize_address(vcpu, get_emulation_mode(vcpu),
> +			rdi, VCPU_SREG_ES, rcx * size, true, false, ad_bytes,
> +			&linear_addr);
> +
> +	if (r >= 0)
> +		return EMULATE_FAIL;
> +
> +	count = (PAGE_SIZE - offset_in_page(linear_addr))/size;
> +
> +	if (count == 0) /* 'in' crosses page boundry */
> +		return EMULATE_FAIL;
> +
> +	count = min(count, rcx);
> +
> +	r = __kvm_fast_string_pio_in(vcpu, size, port, linear_addr, count);
> +
> +	if (r != EMULATE_DO_MMIO)
> +		return r;
> +
> +	vcpu->arch.fast_string_pio_ctxt.linear_addr = linear_addr;
> +	vcpu->arch.fast_string_pio_ctxt.ad_bytes = ad_bytes;
> +	vcpu->arch.complete_userspace_io = complete_fast_string_pio;
> +	return EMULATE_DO_MMIO;
> +}
> +EXPORT_SYMBOL_GPL(kvm_fast_string_pio_in);
> +

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



  reply	other threads:[~2012-07-19 10:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-19  7:40 [PATCHv4 0/5] improve speed of "rep ins" emulation Gleb Natapov
2012-07-19  7:40 ` [PATCHv4 1/5] Provide userspace IO exit completion callback Gleb Natapov
2012-07-19  7:40 ` [PATCHv4 2/5] KVM: emulator: make x86 emulation modes enum instead of defines Gleb Natapov
2012-07-19  7:40 ` [PATCHv4 3/5] KVM: emulator: move some address manipulation function out of emulator code Gleb Natapov
2012-07-19 10:42   ` Avi Kivity
2012-07-19 10:49     ` Gleb Natapov
2012-07-19 13:34       ` Avi Kivity
2012-07-19 13:43         ` Gleb Natapov
2012-07-19  7:40 ` [PATCHv4 4/5] KVM: emulator: make linearize() callable from outside of emulator Gleb Natapov
2012-07-19 10:32   ` Avi Kivity
2012-07-19 10:51     ` Gleb Natapov
2012-07-19 12:52       ` Avi Kivity
2012-07-19 12:54         ` Gleb Natapov
2012-07-19  7:40 ` [PATCHv4 5/5] KVM: Provide fast path for "rep ins" emulation if possible Gleb Natapov
2012-07-19 10:37   ` Avi Kivity [this message]
2012-07-19 11:09     ` Gleb Natapov

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=5007E36C.6000807@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.