qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 14/18] KVM: x86: ignore interrupt_bitmap field of KVM_GET/SET_SREGS
Date: Mon, 10 Jan 2022 15:40:30 +0100	[thread overview]
Message-ID: <20220110144034.67410-15-pbonzini@redhat.com> (raw)
In-Reply-To: <20220110144034.67410-1-pbonzini@redhat.com>

This is unnecessary, because the interrupt would be retrieved and queued
anyway by KVM_GET_VCPU_EVENTS and KVM_SET_VCPU_EVENTS respectively,
and it makes the flow more similar to the one for KVM_GET/SET_SREGS2.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/kvm/kvm.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index d81745620b..2c8feb4a6f 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2607,11 +2607,11 @@ static int kvm_put_sregs(X86CPU *cpu)
     CPUX86State *env = &cpu->env;
     struct kvm_sregs sregs;
 
+    /*
+     * The interrupt_bitmap is ignored because KVM_SET_SREGS is
+     * always followed by KVM_SET_VCPU_EVENTS.
+     */
     memset(sregs.interrupt_bitmap, 0, sizeof(sregs.interrupt_bitmap));
-    if (env->interrupt_injected >= 0) {
-        sregs.interrupt_bitmap[env->interrupt_injected / 64] |=
-                (uint64_t)1 << (env->interrupt_injected % 64);
-    }
 
     if ((env->eflags & VM_MASK)) {
         set_v8086_seg(&sregs.cs, &env->segs[R_CS]);
@@ -3341,23 +3341,17 @@ static int kvm_get_sregs(X86CPU *cpu)
 {
     CPUX86State *env = &cpu->env;
     struct kvm_sregs sregs;
-    int bit, i, ret;
+    int ret;
 
     ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_SREGS, &sregs);
     if (ret < 0) {
         return ret;
     }
 
-    /* There can only be one pending IRQ set in the bitmap at a time, so try
-       to find it and save its number instead (-1 for none). */
-    env->interrupt_injected = -1;
-    for (i = 0; i < ARRAY_SIZE(sregs.interrupt_bitmap); i++) {
-        if (sregs.interrupt_bitmap[i]) {
-            bit = ctz64(sregs.interrupt_bitmap[i]);
-            env->interrupt_injected = i * 64 + bit;
-            break;
-        }
-    }
+    /*
+     * The interrupt_bitmap is ignored because KVM_GET_SREGS is
+     * always preceded by KVM_GET_VCPU_EVENTS.
+     */
 
     get_seg(&env->segs[R_CS], &sregs.cs);
     get_seg(&env->segs[R_DS], &sregs.ds);
-- 
2.33.1




  parent reply	other threads:[~2022-01-10 15:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-10 14:40 [PULL v4 00/18] Build system and KVM changes for 2021-12-23 Paolo Bonzini
2022-01-10 14:40 ` [PULL 01/18] meson: reuse common_user_inc when building files specific to user-mode emulators Paolo Bonzini
2022-01-10 14:40 ` [PULL 02/18] user: move common-user includes to a subdirectory of {bsd, linux}-user/ Paolo Bonzini
2022-01-10 14:40 ` [PULL 03/18] meson: cleanup common-user/ build Paolo Bonzini
2022-01-10 14:40 ` [PULL 04/18] block/file-posix: Simplify the XFS_IOC_DIOINFO handling Paolo Bonzini
2022-01-10 14:40 ` [PULL 05/18] configure: simplify creation of plugin symbol list Paolo Bonzini
2022-01-10 14:40 ` [PULL 06/18] configure: do not set bsd_user/linux_user early Paolo Bonzini
2022-01-10 14:40 ` [PULL 07/18] configure, makefile: remove traces of really old files Paolo Bonzini
2022-01-10 14:40 ` [PULL 08/18] configure: parse --enable/--disable-strip automatically, flip default Paolo Bonzini
2022-01-10 14:40 ` [PULL 09/18] configure: move non-command-line variables away from command-line parsing section Paolo Bonzini
2022-01-10 14:40 ` [PULL 10/18] meson: build contrib/ executables after generated headers Paolo Bonzini
2022-01-10 14:40 ` [PULL 11/18] configure, meson: move config-poison.h to meson Paolo Bonzini
2022-01-10 14:40 ` [PULL 12/18] meson: add comments in the target-specific flags section Paolo Bonzini
2022-01-10 14:40 ` [PULL 13/18] KVM: use KVM_{GET|SET}_SREGS2 when supported Paolo Bonzini
2022-01-10 14:40 ` Paolo Bonzini [this message]
2022-01-10 14:40 ` [PULL 15/18] tests/tcg: Fix target-specific Makefile variables path for user-mode Paolo Bonzini
2022-01-10 14:40 ` [PULL 16/18] configure: do not create roms/seabios/config.mak if SeaBIOS not present Paolo Bonzini
2022-01-10 14:40 ` [PULL 17/18] meson: build all modules by default Paolo Bonzini
2022-01-10 14:40 ` [PULL 18/18] meson: reenable filemonitor-inotify compilation Paolo Bonzini
2022-01-11 10:12 ` [PULL v4 00/18] Build system and KVM changes for 2021-12-23 Peter Maydell

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=20220110144034.67410-15-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).