lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <C1483DFC-94D2-4515-95E5-FCEEC0B2A250@tencent.com>
Date:   Thu, 29 Dec 2022 01:52:21 +0000
From:   flyingpeng(彭浩) <flyingpeng@...cent.com>
To:     "pbonzini@...hat.com" <pbonzini@...hat.com>
CC:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [RESEND PATCH v2] KVM: use unified srcu interface function

kvm->irq_routing is protected by kvm->irq_srcu.

Signed-off-by: Peng Hao <flyingpeng@...cent.com>
---
 virt/kvm/irqchip.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/virt/kvm/irqchip.c b/virt/kvm/irqchip.c
index 1e567d1f6d3d..d3ccfe922880 100644
--- a/virt/kvm/irqchip.c
+++ b/virt/kvm/irqchip.c
@@ -18,6 +18,10 @@
 #include <linux/export.h>
 #include <trace/events/kvm.h>

+#define kvm_get_irq_routing(kvm) \
+       srcu_dereference_check((kvm)->irq_routing, &(kvm)->irq_srcu,    \
+                               lockdep_is_held(&(kvm)->irq_lock))
+
 int kvm_irq_map_gsi(struct kvm *kvm,
                    struct kvm_kernel_irq_routing_entry *entries, int gsi)
 {
@@ -25,8 +29,7 @@ int kvm_irq_map_gsi(struct kvm *kvm,
        struct kvm_kernel_irq_routing_entry *e;
        int n = 0;

-       irq_rt = srcu_dereference_check(kvm->irq_routing, &kvm->irq_srcu,
-                                       lockdep_is_held(&kvm->irq_lock));
+       irq_rt = kvm_get_irq_routing(kvm);
        if (irq_rt && gsi < irq_rt->nr_rt_entries) {
                hlist_for_each_entry(e, &irq_rt->map[gsi], link) {
                        entries[n] = *e;
@@ -216,7 +219,7 @@ int kvm_set_irq_routing(struct kvm *kvm,
        }

        mutex_lock(&kvm->irq_lock);
-       old = rcu_dereference_protected(kvm->irq_routing, 1);
+       old = kvm_get_irq_routing(kvm);
        rcu_assign_pointer(kvm->irq_routing, new);
        kvm_irq_routing_update(kvm);
        kvm_arch_irq_routing_update(kvm);
--
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ