Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp587423imw; Fri, 15 Jul 2022 09:03:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vQ6X85Q4x0h46Lf0eaSwfNQNv19Frw/fnCOH4awlgWzqXR1/5rEuCxZm8p4fGv00ng76Cw X-Received: by 2002:a63:884:0:b0:412:9c83:47b1 with SMTP id 126-20020a630884000000b004129c8347b1mr12491707pgi.387.1657900999429; Fri, 15 Jul 2022 09:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657900999; cv=none; d=google.com; s=arc-20160816; b=p2kqmkPqbOY7tkyvswp4S9qaOaLkf8AW60PQj1rovTtPxw7LFqgY6FqDNJbgLODMTq umzKdO8xfsbOtS0MFpRLUjJB6iZcjj0OdhT0vDE3yn1+/dcsswsPB+9XD5GZSdShm0Fh 72Ps/gBizCcCoH9oK1IQ8yYslXUCEdVYjAMd/+oQQ4rZG8EOE0VEWjCiQPA3pAKSbAKA BWipvyvo2cei8seSbhXwkS+EjA6LVQKNG4gNLNKPkVY7069AB/Aga88yDOftCIZ6llNz 3lFXy731A/w9BxBOSl+uAuS0LL08Kk4wz20N7fDhknZwcg2KYLSbq7bj46zLe9s5/sPC Vt4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DgAPxu68EVPkc4OcXPg6lrRhMAAc/3X1Z7wfY7wDJ3U=; b=zopmNn3kPgTy3KBPHICHZFQSbPEOjpUZE47A3Lmnj9BZGn4inRrXkSrTzDy0Hr6h1G QeQOcXPzBgoqsTLAE+ZTS2C7rZO2nK29vy/jiVYRV7MvRTUoZUvxr8kGyRl78TFyzsPa ikmrRxnGZGzmyzdXunfPxWL6Z7QF9+HzQPvQ3HsE+oscT6ua4H32yd+qVW+E+8AkFbcJ SSSlpC79OZ3D0T0OumjtKTWPP9HJRvAf3VmXuoBgvGo24q0ak3XzZFk+GiDTOWVtsnZN YJn7OiFZsTuKldtFvXhUcuXl+vZsv6Om/TEMLky3KJwLKl7auwWgAhRIiGqDjXeJsLua otmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=c3pigEnt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a17-20020aa78e91000000b0052543a673a0si4470186pfr.93.2022.07.15.09.03.04; Fri, 15 Jul 2022 09:03:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=c3pigEnt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232642AbiGOQAy (ORCPT + 99 others); Fri, 15 Jul 2022 12:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbiGOQAt (ORCPT ); Fri, 15 Jul 2022 12:00:49 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B62EA6C120 for ; Fri, 15 Jul 2022 09:00:48 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id bf9so8470466lfb.13 for ; Fri, 15 Jul 2022 09:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DgAPxu68EVPkc4OcXPg6lrRhMAAc/3X1Z7wfY7wDJ3U=; b=c3pigEntsf04zOudkz13PWuERnOm3JGaha7ZtSo12Gx0iyVKVLLJh3nx2XmwUpW9Qk IFJ+8W8MojdtRDFQzuXoiNwWT4R1e2Q88A3f6VJTTEo4tdP+6DNhfXtXntUSFcSCEmrj SSaFXTA4JJk1KIL0oWbMeJKCB4i1hirIOMoJDDvKNim6/L6oHM7/J3Rfu651Z+cL92AX TY9gwcdrrmo5QKFS0T60fL+PQVyflyCqwHDEtTrb2RQVviPUP6pk1W+Sd47Oo8XrbPxZ oviuJkuZVCskdPfHbtvpXN2jKncLjlXyZ/fNL8uhpS4yYc2j0oLHRSP8wDmeT3099Yot LeBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DgAPxu68EVPkc4OcXPg6lrRhMAAc/3X1Z7wfY7wDJ3U=; b=rCBgWtUDmyywatJ+NlvFTiOGkUpjyQKEsLymrVOLUdaIZvYkId2Ur/tcgC6EQ9dZMW mwnpsrSz8ED3nERqGiKzBNMRUG5unk94B15/jPPD0kb/ofyCHuUXZsZj/FoN8WovDgdu vGN0xh4mXpwkHXsQoFbThQuoO1N1Df430mlNA6S39FAzZJY5dVfaT2+xJcQB0P5CK6GN 2C6/E/6QUNyhq7zSp07+QXwyJvCQEIALK+PC++1J305PvsUOQ+kx6jhXmFOxFoSFGR9T EeZPceM9DNdzfLZ0s0g+4lD+juKnPfTBonFTgmyqfDraO+CRMD5QturVDJ0ryP+VyqfY OXyQ== X-Gm-Message-State: AJIora/9QWDcCibF4byJKxKtjj2lPT/j3diCsiLYpg4JlHWDLqWQ62PX 2GW9IquiuqoZRSqVIfCX2EMqGg== X-Received: by 2002:a05:6512:1096:b0:489:cbad:de4f with SMTP id j22-20020a056512109600b00489cbadde4fmr8499188lfg.164.1657900847021; Fri, 15 Jul 2022 09:00:47 -0700 (PDT) Received: from dmaluka.office.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id c12-20020a056512238c00b0047968606114sm959772lfv.111.2022.07.15.09.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 09:00:46 -0700 (PDT) From: Dmytro Maluka To: Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Eric Auger , Alex Williamson , Rong L Liu , Zhenyu Wang , Tomasz Nowicki , Grzegorz Jaszczyk , Dmitry Torokhov , Dmytro Maluka Subject: [PATCH 1/3] KVM: x86: Move kvm_(un)register_irq_mask_notifier() to generic KVM Date: Fri, 15 Jul 2022 17:59:26 +0200 Message-Id: <20220715155928.26362-2-dmy@semihalf.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog In-Reply-To: <20220715155928.26362-1-dmy@semihalf.com> References: <20220715155928.26362-1-dmy@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for implementing postponing resamplefd event until the interrupt is unmasked, move kvm_(un)register_irq_mask_notifier() from x86 to arch-independent code to make it usable by irqfd. Note that calling mask notifiers is still implemented for x86 only, so registering mask notifiers on non-x86 will have no effect. Link: https://lore.kernel.org/kvm/31420943-8c5f-125c-a5ee-d2fde2700083@semihalf.com/ Signed-off-by: Dmytro Maluka --- arch/x86/include/asm/kvm_host.h | 10 ---------- arch/x86/kvm/irq_comm.c | 18 ------------------ include/linux/kvm_host.h | 10 ++++++++++ virt/kvm/eventfd.c | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 9217bd6cf0d1..39a867d68721 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1688,16 +1688,6 @@ int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3); int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, const void *val, int bytes); -struct kvm_irq_mask_notifier { - void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked); - int irq; - struct hlist_node link; -}; - -void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, - struct kvm_irq_mask_notifier *kimn); -void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, - struct kvm_irq_mask_notifier *kimn); void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin, bool mask); diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c index 0687162c4f22..43e13892ed34 100644 --- a/arch/x86/kvm/irq_comm.c +++ b/arch/x86/kvm/irq_comm.c @@ -234,24 +234,6 @@ void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id) mutex_unlock(&kvm->irq_lock); } -void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, - struct kvm_irq_mask_notifier *kimn) -{ - mutex_lock(&kvm->irq_lock); - kimn->irq = irq; - hlist_add_head_rcu(&kimn->link, &kvm->arch.mask_notifier_list); - mutex_unlock(&kvm->irq_lock); -} - -void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, - struct kvm_irq_mask_notifier *kimn) -{ - mutex_lock(&kvm->irq_lock); - hlist_del_rcu(&kimn->link); - mutex_unlock(&kvm->irq_lock); - synchronize_srcu(&kvm->irq_srcu); -} - void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin, bool mask) { diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 90a45ef7203b..9e12ef503157 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1581,6 +1581,12 @@ struct kvm_irq_ack_notifier { void (*irq_acked)(struct kvm_irq_ack_notifier *kian); }; +struct kvm_irq_mask_notifier { + void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked); + int irq; + struct hlist_node link; +}; + int kvm_irq_map_gsi(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *entries, int gsi); int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin); @@ -1599,6 +1605,10 @@ void kvm_register_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian); void kvm_unregister_irq_ack_notifier(struct kvm *kvm, struct kvm_irq_ack_notifier *kian); +void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, + struct kvm_irq_mask_notifier *kimn); +void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, + struct kvm_irq_mask_notifier *kimn); int kvm_request_irq_source_id(struct kvm *kvm); void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); bool kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args); diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 2a3ed401ce46..50ddb1d1a7f0 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -520,6 +520,24 @@ void kvm_unregister_irq_ack_notifier(struct kvm *kvm, } #endif +void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq, + struct kvm_irq_mask_notifier *kimn) +{ + mutex_lock(&kvm->irq_lock); + kimn->irq = irq; + hlist_add_head_rcu(&kimn->link, &kvm->arch.mask_notifier_list); + mutex_unlock(&kvm->irq_lock); +} + +void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq, + struct kvm_irq_mask_notifier *kimn) +{ + mutex_lock(&kvm->irq_lock); + hlist_del_rcu(&kimn->link); + mutex_unlock(&kvm->irq_lock); + synchronize_srcu(&kvm->irq_srcu); +} + void kvm_eventfd_init(struct kvm *kvm) { -- 2.37.0.170.g444d1eabd0-goog