From patchwork Thu Feb 17 10:12:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12749707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75BE5C433F5 for ; Thu, 17 Feb 2022 10:14:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=r7UrKwxaIXcEIQXofDpQry5KcUYJ1BmKTMaJfIMeXMI=; b=v+E 45cdw1CASV7acJ+ivglJCym98ZObrOVHO37KVDETlC00ugL0Ig5Yqouz4APqSXwAHJFallzBhDdL9 BL5y0d02BdLKvVxk5hrXWDZt/fUQVl4z8yW+bMFN43X2Eu7tdC5FiJdr4nWpAQbv7aBMoWegJenzw ryNWSCSMduxx1m6YubkIy4lN+dMF7Q47aBoFYuHQ7alWxip8SI4UpcHWmXQmC6QQkRGnWksVnvTxH gl8jJU3kpFUhod6EGBi096DYhVWKdA1UlhuDp6+9AX3JplQlHW8Lhwx+ca8oVR31PePkqEEL2eApI Q3dW2lse19d+UOP7FgNG+n/MGnDftNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKdmP-009r5x-IB; Thu, 17 Feb 2022 10:12:53 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKdmL-009r4Q-Fd for linux-arm-kernel@lists.infradead.org; Thu, 17 Feb 2022 10:12:51 +0000 Received: by mail-io1-xd4a.google.com with SMTP id t19-20020a6b5f13000000b0064041171126so817606iob.10 for ; Thu, 17 Feb 2022 02:12:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=5T4ROjtiSYSmILGtelNbeXe0t7OVZ2zJkKj18jqpZkM=; b=lUzq+PCpYalHly9R3Q1U06bzq2o75xRuFbqYlkDMnnn5KOiSDkcPRkLnJpxR5Y8s6B 9tmLnKvXcEOsWLwD/z+2dF9XLULMO0qynB+qbLVFy26bDbAUp0tP0SzxNUTphTAMM+Sx 0GMYh6axYOoWjIqXTFUhW1VVWvlzFSQ9o4jfRjm9ckT8YcZxiclp3BVxF201cY1Zrvhc 6/2A6C99zU5v+t3j9xPzLnTUPRsc1NO6sjAYA+ULe5x8D3BdddGJ+Aa8Wtago4gpPimI /tAFA1zexbYa1S0w3fX2xlxIKnGK8w01qy0lx0n4/6DuJa2N4ru7jTu16TfwzuDrSQWh cWbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=5T4ROjtiSYSmILGtelNbeXe0t7OVZ2zJkKj18jqpZkM=; b=Dvfg9q47xzsT/uW2To6x95dylnqdDibubzVIEaCYUgIJ+39NQV3z/mSjZ0jPeoDEIy t4gAEvUaM1Fh5tSoiGhFYPd7MSjW+FuG04RDByEgUhmIcU96ETmP9EBkyKZtUXuhjDX5 96qwsJsYNBjLLGlm22EUzPgBPCqRCBVtXRAgKSokXtazvzWlvPMOCaSHh6oJtnvhnX2e jI0XM/g2Z7Tm0cKiVx2WET8D1yjvzKY/acH1SJ8Bf6kJstwYh6FW1AoAcJnlcSd90ByV XAgv+C1rWiOhH/9vcx2kRWBmESajyx6q2z56HbKV7Ak3Rbxz4pPUOFDt64wLE+0jtk2v SS+Q== X-Gm-Message-State: AOAM533bnMVu9/bXHin7JY8Dj6TtlhGx0dcgbDqVHYhtqfkrbiep3VaO /aT8lSJhJC7n6cZzpitOiPUwYcgwiv8= X-Google-Smtp-Source: ABdhPJyOEPz9mt5BJMOOnZ7Z5Hae+tzeYPXrDeNDmxnly8CXUchWb06soiTAXuk5BdL+NZ9baVeN5BMO0QM= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6602:2f01:b0:5ec:f99a:93a1 with SMTP id q1-20020a0566022f0100b005ecf99a93a1mr1452284iow.109.1645092767893; Thu, 17 Feb 2022 02:12:47 -0800 (PST) Date: Thu, 17 Feb 2022 10:12:42 +0000 Message-Id: <20220217101242.3013716-1-oupton@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH] KVM: arm64: Don't miss pending interrupts for suspended vCPU From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Paolo Bonzini , Sean Christopherson , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220217_021249_552486_2E0AC6F2 X-CRM114-Status: GOOD ( 11.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to properly emulate the WFI instruction, KVM reads back ICH_VMCR_EL2 and enables doorbells for GICv4. These preparations are necessary in order to recognize pending interrupts in kvm_arch_vcpu_runnable() and return to the guest. Until recently, this work was done by kvm_arch_vcpu_{blocking,unblocking}(). Since commit 6109c5a6ab7f ("KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook"), these callbacks were gutted and superseded by kvm_vcpu_wfi(). It is important to note that KVM implements PSCI CPU_SUSPEND calls as a WFI within the guest. However, the implementation calls directly into kvm_vcpu_halt(), which skips the needed work done in kvm_vcpu_wfi() to detect pending interrupts. Fix the issue by calling the WFI helper. Fixes: 6109c5a6ab7f ("KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook") Signed-off-by: Oliver Upton --- arch/arm64/kvm/psci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c index 3eae32876897..2ce60fecd861 100644 --- a/arch/arm64/kvm/psci.c +++ b/arch/arm64/kvm/psci.c @@ -46,8 +46,7 @@ static unsigned long kvm_psci_vcpu_suspend(struct kvm_vcpu *vcpu) * specification (ARM DEN 0022A). This means all suspend states * for KVM will preserve the register state. */ - kvm_vcpu_halt(vcpu); - kvm_clear_request(KVM_REQ_UNHALT, vcpu); + kvm_vcpu_wfi(vcpu); return PSCI_RET_SUCCESS; }