public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dor Laor <dor.laor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: [PATCH] Correct the highest priority order of irq injection path from userspace
Date: Thu, 13 Dec 2007 15:19:31 +0200	[thread overview]
Message-ID: <47613163.9090701@qumranet.com> (raw)

 From e6fa298ad00b96fd457c737ec9e100cd3be5f02e Mon Sep 17 00:00:00 2001
From: Dor Laor <dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Date: Thu, 13 Dec 2007 15:09:54 +0200
Subject: [PATCH] Correct the highest priority order of irq injection 
from userspace.
 Actually this is not a must here since no more than a single
 interrupt should be pending so no matter how we scan the vector should be
 good, so it is more for being correct theoretically.

Signed-off-by: Dor Laor <dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
 drivers/kvm/x86.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index c9e4b67..0fac2a1 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -2638,7 +2638,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu 
*vcpu,
                   struct kvm_sregs *sregs)
 {
     int mmu_reset_needed = 0;
-    int i, pending_vec, max_bits;
+    int i, pending_vec;
     struct descriptor_table dt;
 
     vcpu_load(vcpu);
@@ -2684,12 +2684,14 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct 
kvm_vcpu *vcpu,
             if (vcpu->irq_pending[i])
                 __set_bit(i, &vcpu->irq_summary);
     } else {
-        max_bits = (sizeof sregs->interrupt_bitmap) << 3;
-        pending_vec = find_first_bit(
-            (const unsigned long *)sregs->interrupt_bitmap,
-            max_bits);
+        for (i = sizeof sregs->interrupt_bitmap/sizeof(long) - 1;i;i--) {
+            pending_vec = __fls(((unsigned long 
*)sregs->interrupt_bitmap)[i]);
+            if (pending_vec) break;
+        }
+
         /* Only pending external irq is handled here */
-        if (pending_vec < max_bits) {
+        if (pending_vec) {
+            pending_vec += i * BITS_PER_LONG;
             kvm_x86_ops->set_irq(vcpu, pending_vec);
             pr_debug("Set back pending irq %d\n",
                  pending_vec);
-- 
1.5.3.3


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

                 reply	other threads:[~2007-12-13 13:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=47613163.9090701@qumranet.com \
    --to=dor.laor-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=dor.laor-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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