From: Avi Kivity <avi@redhat.com>
To: Andre Przywara <andre.przywara@amd.com>
Cc: mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH 5/5] kvm/svm: copy instruction bytes from VMCB
Date: Mon, 13 Dec 2010 14:24:13 +0200 [thread overview]
Message-ID: <4D06106D.8030007@redhat.com> (raw)
In-Reply-To: <1291989088-1380-6-git-send-email-andre.przywara@amd.com>
On 12/10/2010 03:51 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.
>
>
>
> +static int svm_prefetch_instruction(struct kvm_vcpu *vcpu)
> +{
> + 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;
> +}
This reaching in into the emulator internals from svm code is not very
good. It also assumes ->prefetch_instruction() is called immediately
after an exit; this isn't true in vmx and at least was considered for
svm (emulating multiple instructions during the nsvm vmexit sequence).
Alternatives are:
- add the insn data to emulate_instruction() and friends (my first
suggestion)
- adding x86_decode_insn_init(), which initializes the decode cache, and
x86_decode_insn_prefill_cache(), called only if we have the insn data
Another one: teach kvm_fetch_guest_virt() to check if addr/bytes
intersects with csbase+rip/len; if so, use that instead of doing the
page table dance.
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2010-12-13 12:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-10 13:51 [PATCH -v2 0/5] kvm/svm: implement new DecodeAssist features Andre Przywara
2010-12-10 13:51 ` [PATCH 1/5] kvm/svm: add new SVM feature bit names Andre Przywara
2010-12-10 13:51 ` [PATCH 2/5] kvm/svm: enhance MOV CR intercept handler Andre Przywara
2010-12-13 12:13 ` Avi Kivity
2010-12-20 11:56 ` Marcelo Tosatti
2010-12-20 13:20 ` Andre Przywara
2010-12-10 13:51 ` [PATCH 3/5] kvm/svm: enhance mov DR " Andre Przywara
2010-12-13 12:14 ` Avi Kivity
2010-12-16 12:07 ` Andre Przywara
2010-12-16 12:48 ` Avi Kivity
2010-12-10 13:51 ` [PATCH 4/5] kvm/svm: implement enhanced INVLPG intercept 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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2010-12-07 10:59 [PATCH 0/5] kvm/svm: implement new DecodeAssist features Andre Przywara
2010-12-07 10:59 ` [PATCH 5/5] kvm/svm: copy instruction bytes from VMCB Andre Przywara
2010-12-07 13:33 ` 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=4D06106D.8030007@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 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.