From patchwork Mon Sep 10 14:23:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Guo X-Patchwork-Id: 968071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4289K12Bmfz9sC2; Tue, 11 Sep 2018 00:24:05 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fzN6a-0001jM-Ck; Mon, 10 Sep 2018 14:23:56 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fzN6Y-0001hZ-DW for kernel-team@lists.ubuntu.com; Mon, 10 Sep 2018 14:23:54 +0000 Received: from mail-pf1-f198.google.com ([209.85.210.198]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fzN6Y-0003nV-1b for kernel-team@lists.ubuntu.com; Mon, 10 Sep 2018 14:23:54 +0000 Received: by mail-pf1-f198.google.com with SMTP id x85-v6so11308582pfe.13 for ; Mon, 10 Sep 2018 07:23:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=tmjfQl7EVk+EtaTgtQ9e+69T4jn24zU0yE+7lrZekMA=; b=O5Xx8AQVzRYiH5loLFCdu11QKSJR5YgKGtRJtIt5jmAiGJ+e0ytUMPLXuhnYe++vv1 oGcF0T2WX5EWQPq1AqQ8LrwkFXG+twiAJCTCpY8dD4UuRamoGvljG4Xe+p5ZYQkCPzPG 9AlEu52QjUr6Atr0rAk/AUSLsGFJdJBVcXafLl0giVvm+TezGm+jsS0NHEA4N6Lh3orD VDdc9sR7u2CtUODnns88nL3sImUi8EIR5ubGYWeuLj0ZmzvDS0rbZF77kIRtWhVjTJiA EkZlJbJlJgozB+Bb+vwZ8deICrK3lhjU2oOJaq5J+VpuOC3VJi6rUagGUwQDoWSLcHfI rtxw== X-Gm-Message-State: APzg51Dmy2v77J9N+OD7p86V9x0Lxb2wy1JSPFfNt4cygKLGgToyOVAC YPG/LkucP+APmWbukxFMNa5j/Cx5fcYuaQDarYqWGzbLs0NkvxctqekOdkQ4DQMVu/0vmxTsqb+ A/ypIX5kTykOjZ3qHGQvVQIe/nVi9ILkcFwZ6BQOg6A== X-Received: by 2002:a17:902:4401:: with SMTP id k1-v6mr21585727pld.97.1536589432140; Mon, 10 Sep 2018 07:23:52 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbi+mFIKuJ+D4vS5Ba0591+qLwvCxVhz4EX7ExfEOWeMFd9SOG3gO1R2aDU/fRNKDnB5BeJtw== X-Received: by 2002:a17:902:4401:: with SMTP id k1-v6mr21585704pld.97.1536589431894; Mon, 10 Sep 2018 07:23:51 -0700 (PDT) Received: from gavin-P70.buildd (114-35-245-81.HINET-IP.hinet.net. [114.35.245.81]) by smtp.gmail.com with ESMTPSA id j191-v6sm22868224pfc.136.2018.09.10.07.23.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Sep 2018 07:23:50 -0700 (PDT) From: Gavin Guo To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/4] KVM: ioapic: merge ioapic_deliver into ioapic_service Date: Mon, 10 Sep 2018 22:23:39 +0800 Message-Id: <1536589422-20822-2-git-send-email-gavin.guo@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536589422-20822-1-git-send-email-gavin.guo@canonical.com> References: <1536589422-20822-1-git-send-email-gavin.guo@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Paolo Bonzini BugLink: https://bugs.launchpad.net/bugs/1791286 Commonize the handling of masking, which was absent for kvm_ioapic_set_irq. Setting remote_irr does not need a separate function either, and merging the two functions avoids confusion. Reviewed-by: Alex Williamson Signed-off-by: Paolo Bonzini (cherry picked from commit 0b10a1c87a2b0fb459baaefba9cb163dbb8d3344) Signed-off-by: Gavin Guo --- virt/kvm/ioapic.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 5eaf18f90e83..3a0ccff16830 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -50,7 +50,7 @@ #else #define ioapic_debug(fmt, arg...) #endif -static int ioapic_deliver(struct kvm_ioapic *vioapic, int irq, +static int ioapic_service(struct kvm_ioapic *vioapic, int irq, bool line_status); static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, @@ -163,23 +163,6 @@ static bool rtc_irq_check_coalesced(struct kvm_ioapic *ioapic) return false; } -static int ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx, - bool line_status) -{ - union kvm_ioapic_redirect_entry *pent; - int injected = -1; - - pent = &ioapic->redirtbl[idx]; - - if (!pent->fields.mask) { - injected = ioapic_deliver(ioapic, idx, line_status); - if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG) - pent->fields.remote_irr = 1; - } - - return injected; -} - static void update_handled_vectors(struct kvm_ioapic *ioapic) { DECLARE_BITMAP(handled_vectors, 256); @@ -281,12 +264,15 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val) } } -static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq, bool line_status) +static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status) { union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq]; struct kvm_lapic_irq irqe; int ret; + if (entry->fields.mask) + return -1; + ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x " "vector=%x trig_mode=%x\n", entry->fields.dest_id, entry->fields.dest_mode, @@ -309,6 +295,9 @@ static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq, bool line_status) } else ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL); + if (ret && irqe.trig_mode == IOAPIC_LEVEL_TRIG) + entry->fields.remote_irr = 1; + return ret; } @@ -393,7 +382,7 @@ static void __kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG); ent->fields.remote_irr = 0; - if (!ent->fields.mask && (ioapic->irr & (1 << i))) + if (ioapic->irr & (1 << i)) ioapic_service(ioapic, i, false); } }