From: Avi Kivity <avi@redhat.com>
To: Andre Przywara <andre.przywara@amd.com>
Cc: kvm@vger.kernel.org, mtosatti@redhat.com
Subject: Re: [PATCH 5/5] kvm/svm: copy instruction bytes from VMCB
Date: Tue, 07 Dec 2010 15:33:22 +0200 [thread overview]
Message-ID: <4CFE37A2.7010703@redhat.com> (raw)
In-Reply-To: <1291719586-22533-6-git-send-email-andre.przywara@amd.com>
On 12/07/2010 12:59 PM, Andre Przywara wrote:
> In case of a nested page fault or an intercepted #PF newer SVM
> implementations provide a copy of the faulting instruction bytes
> in the VMCB.
> Use these bytes to feed the instruction emulator and avoid the costly
> guest instruction fetch in this case.
>
>
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index cfbcbfa..3e3a67e 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -586,6 +586,9 @@ struct kvm_x86_ops {
> void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset);
>
> void (*get_exit_info)(struct kvm_vcpu *vcpu, u64 *info1, u64 *info2);
> +
> + int (*prefetch_instruction)(struct kvm_vcpu *vcpu);
> +
> const struct trace_print_flags *exit_reasons_str;
> };
How about adding a byte array/len parameter to x86_decode_insn()? It
could be used to prefill the buffer instead of invoking a callback.
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 6366735..abff8ff 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -525,6 +525,7 @@ static int do_insn_fetch(struct x86_emulate_ctxt *ctxt,
> /* x86 instructions are limited to 15 bytes. */
> if (eip + size - ctxt->eip> 15)
> return X86EMUL_UNHANDLEABLE;
> + kvm_x86_ops->prefetch_instruction(ctxt->vcpu);
Even with the callback, this belongs in x86_decode_insn(), not on every
fetch.
> while (size--) {
> rc = do_fetch_insn_byte(ctxt, ops, eip++, dest++);
> if (rc != X86EMUL_CONTINUE)
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 3cf2cef..ed94e9a 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -464,6 +464,24 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
> svm_set_interrupt_shadow(vcpu, 0);
> }
>
> +static int prefetch_instruction(struct kvm_vcpu *vcpu)
svm_prefetch_instruction()
> +{
> + struct vcpu_svm *svm = to_svm(vcpu);
> + uint8_t len;
> + struct fetch_cache *fetch;
> +
> + len = svm->vmcb->control.insn_len& 0x0F;
> + if (len == 0)
> + return 1;
> +
> + fetch =&svm->vcpu.arch.emulate_ctxt.decode.fetch;
> + fetch->start = kvm_rip_read(&svm->vcpu);
> + fetch->end = fetch->start + len;
> + memcpy(fetch->data, svm->vmcb->control.insn_bytes, len);
> +
> + return 0;
> +}
svm code shouldn't reach in so deep into the emulator privates.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2010-12-07 13:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-07 10:59 [PATCH 0/5] kvm/svm: implement new DecodeAssist features Andre Przywara
2010-12-07 10:59 ` [PATCH 1/5] kvm/svm: add new SVM feature bit names Andre Przywara
2010-12-07 10:59 ` [PATCH 2/5] kvm/svm: enhance MOV CR intercept handler Andre Przywara
2010-12-07 13:24 ` Avi Kivity
2010-12-07 14:30 ` Andre Przywara
2010-12-07 14:41 ` Avi Kivity
2010-12-07 10:59 ` [PATCH 3/5] kvm/svm: enhance mov DR " Andre Przywara
2010-12-07 11:02 ` Alexander Graf
2010-12-07 13:14 ` Avi Kivity
2010-12-07 13:25 ` Avi Kivity
2010-12-07 10:59 ` [PATCH 4/5] kvm/svm: implement enhanced INVLPG intercept Andre Przywara
2010-12-07 13:27 ` Avi Kivity
2010-12-07 10:59 ` [PATCH 5/5] kvm/svm: copy instruction bytes from VMCB Andre Przywara
2010-12-07 13:33 ` Avi Kivity [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-12-10 13:51 [PATCH -v2 0/5] kvm/svm: implement new DecodeAssist features Andre Przywara
2010-12-10 13:51 ` [PATCH 5/5] kvm/svm: copy instruction bytes from VMCB Andre Przywara
2010-12-13 12:24 ` 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=4CFE37A2.7010703@redhat.com \
--to=avi@redhat.com \
--cc=andre.przywara@amd.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