From: Jan Kiszka <jan.kiszka@web.de>
To: Marcelo Tosatti <mtosatti@redhat.com>, Avi Kivity <avi@redhat.com>
Cc: kvm <kvm@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] qemu-kvm: x86: Add support for event states
Date: Fri, 06 Nov 2009 09:44:04 +0100 [thread overview]
Message-ID: <4AF3E1D4.80600@web.de> (raw)
In-Reply-To: <4AF28C0A.8050209@siemens.com>
[-- Attachment #1: Type: text/plain, Size: 2985 bytes --]
Jan Kiszka wrote:
> This patch extends the qemu-kvm state sync logic with the event substate
> from the new VCPU state interface, giving access to yet missing
> exception, interrupt and NMI states.
>
> The patch does not switch the rest of qemu-kvm's code to the new
> interface as it is expected to be morphed into upstream's version
> anyway. Instead, a full conversion will be submitted for upstream.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>
> Changes from v1:
> - added support for has_error_code
> - properly clear exception_index and interrupt_injected in case the
> kernel does not support KVM_GET_VCPU_STATE
>
> qemu-kvm-x86.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++
> target-i386/cpu.h | 5 +++
> target-i386/machine.c | 5 +++
> 3 files changed, 96 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
> index e03a4ba..dc3e6cb 100644
> --- a/qemu-kvm-x86.c
> +++ b/qemu-kvm-x86.c
> @@ -903,6 +903,82 @@ static void get_seg(SegmentCache *lhs, const struct kvm_segment *rhs)
> | (rhs->avl * DESC_AVL_MASK);
> }
>
> +static void kvm_get_events(CPUState *env)
> +{
> +#ifdef KVM_CAP_VCPU_STATE
> + struct {
> + struct kvm_vcpu_state header;
> + struct kvm_vcpu_substate substates[1];
> + } request;
> + struct kvm_x86_event_state events;
> + int r;
> +
> + request.header.nsubstates = 1;
> + request.header.substates[0].type = KVM_X86_VCPU_STATE_EVENTS;
> + request.header.substates[0].offset = (size_t)&events - (size_t)&request;
> + r = kvm_vcpu_ioctl(env, KVM_GET_VCPU_STATE, &request);
> + if (r == 0) {
> + env->exception_index =
> + events.exception.injected ? events.exception.nr : -1;
> + env->has_error_code = events.exception.has_error_code;
> + env->error_code = events.exception.error_code;
> +
> + env->interrupt_injected =
> + events.interrupt.injected ? events.interrupt.nr : -1;
> + env->soft_interrupt = events.interrupt.soft;
> +
> + env->nmi_injected = events.nmi.injected;
> + env->nmi_pending = events.nmi.pending;
> + if (events.nmi.masked) {
> + env->hflags2 |= HF2_NMI_MASK;
> + } else {
> + env->hflags2 &= ~HF2_NMI_MASK;
> + }
> +
> + env->sipi_vector = events.sipi_vector;
> +
> + return;
> + }
> +#endif
> + env->exception_index = -1;
> + env->interrupt_injected = -1;
> + env->nmi_injected = 0;
> + env->nmi_pending = 0;
> + env->hflags2 &= ~HF2_NMI_MASK;
Frankly, I don't recall anymore why I added these 5 lines. This state is
reached on every guest reset and won't change afterwards unless the
kernel actually supports KVM_X86_VCPU_STATE_EVENTS.
This is temporary code, the upstream version will not contain it, but if
you want me to clean this up, just drop me a note.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 257 bytes --]
prev parent reply other threads:[~2009-11-06 8:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-03 17:36 [PATCH 1/2] qemu-kvm: x86: Refactor use of interrupt_bitmap Jan Kiszka
2009-11-03 17:42 ` [PATCH 2/2] qemu-kvm: x86: Add support for event states Jan Kiszka
2009-11-05 8:25 ` [PATCH v2 " Jan Kiszka
2009-11-06 8:44 ` Jan Kiszka [this message]
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=4AF3E1D4.80600@web.de \
--to=jan.kiszka@web.de \
--cc=avi@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