From patchwork Mon Sep 10 14:23:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Guo X-Patchwork-Id: 968074 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 4289K16707z9sCc; 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 1fzN6c-0001k1-Hb; Mon, 10 Sep 2018 14:23:58 +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 1fzN6a-0001jF-3m for kernel-team@lists.ubuntu.com; Mon, 10 Sep 2018 14:23:56 +0000 Received: from mail-pg1-f200.google.com ([209.85.215.200]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fzN6Z-0003nf-OO for kernel-team@lists.ubuntu.com; Mon, 10 Sep 2018 14:23:55 +0000 Received: by mail-pg1-f200.google.com with SMTP id f13-v6so10815181pgs.15 for ; Mon, 10 Sep 2018 07:23:55 -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=VwXYLVth6hXCLIBf6RwUszwiJWCrMDnFyRO8y8a5gS0=; b=YHIlf+bv4wd5UlsAYrJ8DSUkJEigjqYC0m+tb28faFWecrSfasLf/VPOPN/+0xmKXf DIsSfj/Hy9zLCjKoFMoGLua2+lT04rWRpPW310kp+JHIlFyJM+LkHCteyXfwPn4SssmX DHt5Lu2dkPlNCPYFszDXqdC+CpkmrBfTSkInIh8BbcxeL/QIuvsUCUhdnhqIXTwEluEW MRYesnwahFLsIrZYMSxK5/sjYKxYIpE3Cb+WyZ0UoZiC/7t85bcGeUdoTBAmX0peQLMO kCNDl2q++p9kY9rMuxS2sUwGv/WNWm7rP8mAcj4W2r1oQAZEBfM+Ahcfrv7nS5o8a/4b KNdw== X-Gm-Message-State: APzg51C2lMHik/sr/DWnWOeNaQNjnwoTCiJiO2jfsATet8gB0nHw3l2O QtN9Q6DTxqy5FYufDcqMZyHOSReFETGuFll65TOCVL5x6zVxqewXQKb4gqxrwD2Z22kUt75g3Bz 7rLUKf8hgRM8wC7rZptxS37zVEcdlsCRNE2V37uEFcw== X-Received: by 2002:a63:f14d:: with SMTP id o13-v6mr22800967pgk.236.1536589434112; Mon, 10 Sep 2018 07:23:54 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbIO5hSlDJCIgf57HxBRejnakXe5RA2ZiAvaeYZ37tbSJ5uwEUxHJFfCltWJEg0Aeg60opAtg== X-Received: by 2002:a63:f14d:: with SMTP id o13-v6mr22800947pgk.236.1536589433884; Mon, 10 Sep 2018 07:23:53 -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.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Sep 2018 07:23:52 -0700 (PDT) From: Gavin Guo To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4] KVM: ioapic: clear IRR for edge-triggered interrupts at delivery Date: Mon, 10 Sep 2018 22:23:40 +0800 Message-Id: <1536589422-20822-3-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 This ensures that IRR bits are set in the KVM_GET_IRQCHIP result only if the interrupt is still sitting in the IOAPIC. After the next patches, it avoids spurious reinjection of the interrupt when KVM_SET_IRQCHIP is called. Reviewed-by: Alex Williamson Signed-off-by: Paolo Bonzini (cherry picked from commit 0bc830b05c667218d703f2026ec866c49df974fc) Signed-off-by: Gavin Guo --- virt/kvm/ioapic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 3a0ccff16830..1cc1851812fa 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -287,6 +287,9 @@ static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status) irqe.level = 1; irqe.shorthand = 0; + if (irqe.trig_mode == IOAPIC_EDGE_TRIG) + ioapic->irr &= ~(1 << irq); + if (irq == RTC_GSI && line_status) { BUG_ON(ioapic->rtc_status.pending_eoi != 0); ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe,