From patchwork Wed Dec 13 10:46:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10109715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E10D860352 for ; Wed, 13 Dec 2017 10:51:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0059294D5 for ; Wed, 13 Dec 2017 10:51:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB63429608; Wed, 13 Dec 2017 10:51:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5897729449 for ; Wed, 13 Dec 2017 10:50:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NclezaAJxI/YFaSr9w2UXLaYjrjIs0zPWJ8RUfom1Po=; b=ZLREpkVM2tGFfWZE0uktHDN5B/ Oqxtaruu6yVlXvpRcQ56q+7UmuaAELmgXM8BOIea8cBGF+j2P40X+l90siO+KaW1WMGQ7dNnBSaso qYfqFiVCslsJDS6/QrO4PZJ4QDjqZPZXsD11+WR1FvNWcsSTCRAegDGG8TAiNzUdaGZmjDP7fUDtO kRyzFvUttEJCReVeM6ytcvzNj76F1G6XKmGthm1kPWdGtOZfJypp7UQtewawTwVdzndAUn1jti6VR GdfIH8albfKGpHtU+Wk9GRhO2EQuVvZZ0RJLPY38ONrH4lJXFOTWA+nOIg14j0yUw+MmMw/eX3+wN eszuYgDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eP4cY-0005Oc-DD; Wed, 13 Dec 2017 10:50:38 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eP4Z9-0000oN-7P for linux-arm-kernel@lists.infradead.org; Wed, 13 Dec 2017 10:47:21 +0000 Received: by mail-wm0-x241.google.com with SMTP id t8so4053897wmc.3 for ; Wed, 13 Dec 2017 02:46:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2pyT49S1n9OTBmxU3YGi+BlKGirgwxaW0MmMuR0RR8g=; b=OOcG7Y3PGFk+G905fLY5m7PHaTAnzVAZgUPrcRM6kyLZpx2PLfmlLA5AiXvoR2bO7B /uNeUIX5VRcIEU1t4Lq09hJOli4cKmiJqklEzvw1bvkBqZiL8MeCZuAJNrJhio8TpmKV oNcM+pAshAeCMNSfvbnNQYciYOjqn4hWx3rug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2pyT49S1n9OTBmxU3YGi+BlKGirgwxaW0MmMuR0RR8g=; b=AC4lZq8hnZylv9dCmHXcJSfxmsJf7viC4pJE9oH48g6uqItvs0bt3hIDYQwvQ1Xj0n 0oAH5ODLsZ/yDEdlt3Mjmrm6U3h7ZOozfKTH2XEt8MD05aRs5zN9+Z2xsyK1r9dAyCMR uRzXnm3PeFaKe2rIz5MQOucNzk5EjnsxpOHpdj3YoWrjxQFWxsW+jeHyL1U+TD4LEedm OnL2ePDg4B51rJ+ltaSxz1CYE6O3zg/UPqSD1Qnr8ZU4tIXVOJY4Lo6liWLN11W5pnKd Cep5hBeqSd09aQbcnzGs6mWkB15/9k3Mny8XQfHEQMwlh5h6moCJ67iQ00PZk8/MY5z/ PyHw== X-Gm-Message-State: AKGB3mLCjX1KW0EkKg9HJ/DXDzeDWEaCcejv2fwMzn1C+uu/Od2fbKRS 1ryo/x/ShPcSVVUKorSKz/eAqQ== X-Google-Smtp-Source: ACJfBot8ysdKE8BV0geo2Y4vfQoIA68vpo0JCL38Tmfir+gHVk+sdR8MSEKPHWqi3eGLpBxRD4lkQg== X-Received: by 10.80.224.198 with SMTP id j6mr7120979edl.0.1513162008483; Wed, 13 Dec 2017 02:46:48 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id d92sm1079682edd.21.2017.12.13.02.46.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 Dec 2017 02:46:47 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v8 9/9] KVM: arm/arm64: Update timer and forwarded irq documentation Date: Wed, 13 Dec 2017 11:46:02 +0100 Message-Id: <20171213104602.16383-10-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171213104602.16383-1-christoffer.dall@linaro.org> References: <20171213104602.16383-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171213_024708_108491_4E48AF46 X-CRM114-Status: GOOD ( 15.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Andre Przywara , Christoffer Dall , kvm@vger.kernel.org, Eric Auger MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Now when we've reworked how mapped level-triggered interrupts are processed for the timer interrupts, we update the documentation correspondingly. Signed-off-by: Christoffer Dall --- Documentation/virtual/kvm/arm/vgic-mapped-irqs.txt | 50 ++++++++++------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/Documentation/virtual/kvm/arm/vgic-mapped-irqs.txt b/Documentation/virtual/kvm/arm/vgic-mapped-irqs.txt index 38bca2835278..f68c7d95a341 100644 --- a/Documentation/virtual/kvm/arm/vgic-mapped-irqs.txt +++ b/Documentation/virtual/kvm/arm/vgic-mapped-irqs.txt @@ -7,9 +7,10 @@ allowing software to inject virtual interrupts to a VM, which the guest OS sees as regular interrupts. The code is famously known as the VGIC. Some of these virtual interrupts, however, correspond to physical -interrupts from real physical devices. One example could be the -architected timer, which itself supports virtualization, and therefore -lets a guest OS program the hardware device directly to raise an +interrupts from real physical devices. One example could be the ARM +Generic Timers (also known as the "architected timers"), which are +directly assigned to a VM while it's running, and therefore +makes it possible for guest OSes to program the timers directly to raise an interrupt at some point in time. When such an interrupt is raised, the host OS initially handles the interrupt and must somehow signal this event as a virtual interrupt to the guest. Another example could be a @@ -37,7 +38,7 @@ inactive. The LRs include an extra bit, called the HW bit. When this bit is set, KVM must also program an additional field in the LR, the physical IRQ -number, to link the virtual with the physical IRQ. +number, to link the virtual and physical IRQs together. When the HW bit is set, KVM must EITHER set the Pending OR the Active bit, never both at the same time. @@ -59,21 +60,21 @@ The state of forwarded physical interrupts is managed in the following way: - LR.Pending will stay set as long as the guest has not acked the interrupt. - LR.Pending transitions to LR.Active on the guest read of the IAR, as expected. - - On guest EOI, the *physical distributor* active bit gets cleared, + - On guest deactivate, the *physical distributor* active bit gets cleared, but the LR.Active is left untouched (set). - KVM clears the LR on VM exits when the physical distributor active state has been cleared. (*): The host handling is slightly more complicated. For some forwarded -interrupts (shared), KVM directly sets the active state on the physical -distributor before entering the guest, because the interrupt is never actually -handled on the host (see details on the timer as an example below). For other -forwarded interrupts (non-shared) the host does not deactivate the interrupt -when the host ISR completes, but leaves the interrupt active until the guest -deactivates it. Leaving the interrupt active is allowed, because Linux -configures the physical GIC with EOIMode=1, which causes EOI operations to -perform a priority drop allowing the GIC to receive other interrupts of the -default priority. +interrupts (shared), in some cases, KVM directly sets the active state +on the physical distributor before entering the guest, because the +interrupt is never actually handled on the host (see details on the +timer as an example below). In other cases, the host does not +deactivate the interrupt when the host ISR completes, but leaves the +interrupt active until the guest deactivates it. Leaving the interrupt +active is allowed, because Linux configures the physical GIC with +EOIMode=1, which causes EOI operations to perform a priority drop +allowing the GIC to receive other interrupts of the default priority. Forwarded Edge and Level Triggered PPIs and SPIs @@ -170,18 +171,13 @@ instead: 1. KVM runs the VCPU 2. The guest programs the time to fire in T+100 -4. At T+100 the timer fires and a physical IRQ causes the VM to exit +3. At T+100 the timer fires and a physical IRQ causes the VM to exit (note that this initially only traps to EL2 and does not run the host ISR until KVM has returned to the host). -5. With interrupts still disabled on the CPU coming back from the guest, KVM - stores the virtual timer state to memory and disables the virtual hw timer. -6. KVM looks at the timer state (in memory) and injects a forwarded physical - interrupt because it concludes the timer has expired. -7. KVM marks the timer interrupt as active on the physical distributor -7. KVM enables the timer, enables interrupts, and runs the VCPU - -Notice that again the forwarded physical interrupt is injected to the -guest without having actually been handled on the host. In this case it -is because the physical interrupt is never actually seen by the host because the -timer is disabled upon guest return, and the virtual forwarded interrupt is -injected on the KVM guest entry path. +4. When KVM returns to EL1 and enables interrupts, the timer interrupt + fires again, and the kvm arch timer ISR runs and injects a virtual + interrupt to the guest. +5. Because the timer interrupt has the vcpu affinity set, as the ISR + completes, the physical interrupt stays active on the physical + distributor. +6. KVM enables the timer, enables interrupts, and runs the VCPU