From patchwork Mon Sep 10 14:23:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Guo X-Patchwork-Id: 968075 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 4289K44PP6z9s4s; Tue, 11 Sep 2018 00:24:08 +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 1fzN6g-0001mZ-73; Mon, 10 Sep 2018 14:24:02 +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 1fzN6e-0001l6-Fb for kernel-team@lists.ubuntu.com; Mon, 10 Sep 2018 14:24:00 +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 1fzN6e-0003nq-3p for kernel-team@lists.ubuntu.com; Mon, 10 Sep 2018 14:24:00 +0000 Received: by mail-pf1-f198.google.com with SMTP id t26-v6so11310887pfh.0 for ; Mon, 10 Sep 2018 07:24:00 -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=mZWl4uT6lx4h3UitnPSHwSDLRVGTs07kWxBpVE4yVC4=; b=PjUhT9DTfy7QgtvrTQuCGvZ09MM5CrHqHsrCJ4tFP/RdlyvJAsUMvmv7wG9TjE3zn+ 9hAtssgK31aqJi66viSImLAKBnAlFXXFvFs7lOx2d6CsSY0to86XUGgronE0tQZC0PPL S0G7M3XcXhVf+AqP6HvlRQrdzmukFqZa+OGnVGU+aSXgQ3zLuHjT9sT1YiswkjK3XJdP A3gaF7p8T1F2zVulHDK3RHg5b/gQgPz37rPmdGl2sK+//Oxxv6L50IjtyGYCHkLOiXeC C8GQEMzEQ+KAym9aiMkQJFiiOg3f4qMF8+WFuOprtY+vUKiunYVtoF4SlSzGiqWvXNHx hP1A== X-Gm-Message-State: APzg51A5oPmY2GXhZMnvdklVu1hg82SL0nMBEBPyD1BKuB5lvTxEqTfG BZN/8DCeotTgK8iXguqzzqfUTrrXABHwgZQp1GRt3mA1LzvvRphS9T2RvNPw/KDeKkB3hJqZyLA tmbJmdVedwHv9R2bn1ugxUYk/ZbH8F6hr4202zyU5kQ== X-Received: by 2002:a63:ce43:: with SMTP id r3-v6mr23556405pgi.439.1536589438171; Mon, 10 Sep 2018 07:23:58 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaKIXmyLNHwm0LnO9jZyS+8MXw/hS4TtMYX9F6J3bwWtqFR1mZBY3kYJyUSlboH/l7DK49AHA== X-Received: by 2002:a63:ce43:: with SMTP id r3-v6mr23556380pgi.439.1536589437925; Mon, 10 Sep 2018 07:23:57 -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.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Sep 2018 07:23:56 -0700 (PDT) From: Gavin Guo To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/4] KVM: ioapic: reinject pending interrupts on KVM_SET_IRQCHIP Date: Mon, 10 Sep 2018 22:23:42 +0800 Message-Id: <1536589422-20822-5-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 After the previous patches, an interrupt whose bit is set in the IRR register will never be in the LAPIC's IRR and has never been injected on the migration source. So inject it on the destination. This fixes migration of Windows guests without HPET (they use the RTC to trigger the scheduler tick, and lose it after migration). Reviewed-by: Alex Williamson Signed-off-by: Paolo Bonzini (cherry picked from commit 673f7b4257a1fe7b181e1a1182ecc2b6b2b795f1) Signed-off-by: Gavin Guo --- virt/kvm/ioapic.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c index 6f6460a7c562..05bdad6c6369 100644 --- a/virt/kvm/ioapic.c +++ b/virt/kvm/ioapic.c @@ -213,6 +213,18 @@ out: return ret; } +static void kvm_ioapic_inject_all(struct kvm_ioapic *ioapic, unsigned long irr) +{ + u32 idx; + + rtc_irq_eoi_tracking_reset(ioapic); + for_each_set_bit(idx, &irr, IOAPIC_NUM_PINS) + ioapic_set_irq(ioapic, idx, 1, true); + + kvm_rtc_eoi_tracking_restore_all(ioapic); +} + + static void update_handled_vectors(struct kvm_ioapic *ioapic) { DECLARE_BITMAP(handled_vectors, 256); @@ -612,9 +624,10 @@ int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state) spin_lock(&ioapic->lock); memcpy(ioapic, state, sizeof(struct kvm_ioapic_state)); + ioapic->irr = 0; update_handled_vectors(ioapic); kvm_vcpu_request_scan_ioapic(kvm); - kvm_rtc_eoi_tracking_restore_all(ioapic); + kvm_ioapic_inject_all(ioapic, state->irr); spin_unlock(&ioapic->lock); return 0; }