From: Avi Kivity <avi@redhat.com>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, kvm@vger.kernel.org
Subject: Re: [PATCH 04/13] KVM: X86: Add x86 callback for intercept check
Date: Sat, 26 Mar 2011 11:23:02 +0200 [thread overview]
Message-ID: <4D8DB076.50408@redhat.com> (raw)
In-Reply-To: <1301045356-25257-5-git-send-email-joerg.roedel@amd.com>
On 03/25/2011 11:29 AM, Joerg Roedel wrote:
> This patch adds a callback into kvm_x86_ops so that svm and
> vmx code can do intercept checks on emulated instructions.
>
>
>
> +/*
> + * This struct is used to carry enough information from the instruction
> + * decoder to main KVM so that a decision can be made whether the
> + * instruction needs to be intercepted or not.
> + */
> +struct x86_instruction_info {
> + u8 intercept; /* which intercept */
> + u8 rep_prefix; /* rep prefix? */
> + u8 modrm; /* index of register used */
> + u64 src_val; /* value of source operand */
> + u8 src_bytes; /* size of source operand */
> + u8 dst_bytes; /* size of destination operand */
> + u8 ad_bytes; /* size of src/dst address */
> + u64 next_rip; /* rip following the instruction */
> +};
Should be in kvm_emulate.h.
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 90a41aa..bf72ec6 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4245,7 +4245,25 @@ static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
> enum x86_intercept intercept,
> enum x86_intercept_stage stage)
> {
> - return X86EMUL_CONTINUE;
> + struct x86_instruction_info info = {
> + .intercept = intercept,
> + .rep_prefix = ctxt->decode.rep_prefix,
> + .modrm = ctxt->decode.modrm,
> + .src_val = ctxt->decode.src.val64,
> + .src_bytes = ctxt->decode.src.bytes,
> + .dst_bytes = ctxt->decode.dst.bytes,
> + .ad_bytes = ctxt->decode.ad_bytes,
> + .next_rip = ctxt->eip,
> + };
And this should be in emulate.c, so kvm code doesn't have to peek into
the emulator internals.
> +
> + /*
> + * The callback only needs to be implemented if the architecture
> + * supports emulated guest-mode. This BUG_ON reminds the
> + * programmer that this callback needs to be implemented.
> + */
> + BUG_ON(kvm_x86_ops->check_intercept == NULL);
> +
BUG_ON()s are nasty. I prefer a null implementation for vmx.
> + return kvm_x86_ops->check_intercept(ctxt->vcpu,&info, stage);
> }
>
> static struct x86_emulate_ops emulate_ops = {
--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
next prev parent reply other threads:[~2011-03-26 9:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-25 9:29 [PATCH 0/13] KVM: Make the instruction emulator aware of Nested Virtualization v2 Joerg Roedel
2011-03-25 9:29 ` [PATCH 01/13] KVM: x86 emulator: add framework for instruction Joerg Roedel
2011-03-26 9:54 ` Avi Kivity
2011-03-27 12:56 ` Gleb Natapov
2011-03-28 10:19 ` Joerg Roedel
2011-03-25 9:29 ` [PATCH 02/13] KVM: x86 emulator: add SVM intercepts Joerg Roedel
2011-03-25 9:29 ` [PATCH 03/13] KVM: X86: Don't write-back cpu-state on X86EMUL_INTERCEPTED Joerg Roedel
2011-03-25 9:29 ` [PATCH 04/13] KVM: X86: Add x86 callback for intercept check Joerg Roedel
2011-03-26 9:23 ` Avi Kivity [this message]
2011-03-25 9:29 ` [PATCH 05/13] KVM: SVM: Add intercept check for emulated cr accesses Joerg Roedel
2011-03-26 9:37 ` Avi Kivity
2011-03-26 11:06 ` Joerg Roedel
2011-03-27 9:45 ` Avi Kivity
2011-03-25 9:29 ` [PATCH 06/13] KVM: SVM: Add intercept check for accessing dr registers Joerg Roedel
2011-03-25 9:29 ` [PATCH 07/13] KVM: SVM: Add intercept checks for descriptor table accesses Joerg Roedel
2011-03-26 9:43 ` Avi Kivity
2011-03-26 11:10 ` Joerg Roedel
2011-03-25 9:29 ` [PATCH 08/13] KVM: SVM: Add intercept checks for SVM instructions Joerg Roedel
2011-03-25 9:29 ` [PATCH 09/13] KVM: SVM: Add intercept checks for remaining group7 instructions Joerg Roedel
2011-03-25 9:29 ` [PATCH 10/13] KVM: SVM: Add intercept checks for remaining twobyte instructions Joerg Roedel
2011-03-25 9:29 ` [PATCH 11/13] KVM: SVM: Add intercept checks for one-byte instructions Joerg Roedel
2011-03-26 9:53 ` Avi Kivity
2011-03-25 9:29 ` [PATCH 12/13] KVM: SVM: Add checks for IO instructions Joerg Roedel
2011-03-25 9:29 ` [PATCH 13/13] KVM: SVM: Remove nested sel_cr0_write handling code Joerg Roedel
2011-03-26 9:55 ` [PATCH 0/13] KVM: Make the instruction emulator aware of Nested Virtualization v2 Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2011-03-28 10:46 [PATCH 0/13] KVM: Make the instruction emulator aware of Nested Virtualization v3 Joerg Roedel
2011-03-28 10:46 ` [PATCH 04/13] KVM: X86: Add x86 callback for intercept check Joerg Roedel
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=4D8DB076.50408@redhat.com \
--to=avi@redhat.com \
--cc=joerg.roedel@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.