From patchwork Thu Oct 10 18:23:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13831157 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 BC6F1D24454 for ; Thu, 10 Oct 2024 21:16:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RdgAxVyxp31c7WibHLiyIF43paER00mxZOAIHhsdwhk=; b=3/C0AnfUrEBWYY4HUYqa3EfOMq 5pSAVZGfB64Z4LqPTQWLhp2jnH21PwnJtX2IXlE2DjeckBAaqZeRvdjhMPllhIizCh3Ntl/+kMjZU tYB8EodRCyB04H8O6itAKwS6MPiUty7pLXSUzuTyvNT3byYxdPROar0PviGtirMy+9bQvKLkxDno7 PWiBu1tXCY9lsxMvn5pUHpweri2vTs5VN2/gd8DGybJ/DTzkBzI8wLocc1mpAjDBbwYZnf/s3Z9o9 Q5QJ1UXo6rXHpxzzbxUCfez5DYwwuXx65yhAfLFxTLLfAMDoEQ1iEzygtdD1AaSIrgQ86vC0w5ruM 5zBDG2Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sz0WJ-0000000ENWr-3P7V; Thu, 10 Oct 2024 21:16:27 +0000 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syxql-0000000DpyZ-3XZh for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 18:25:26 +0000 Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-2e2ca4fb175so1247620a91.3 for ; Thu, 10 Oct 2024 11:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728584722; x=1729189522; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=RdgAxVyxp31c7WibHLiyIF43paER00mxZOAIHhsdwhk=; b=b7p6IY4ClkV+QsXomlwvoGqMh+SB8UDjT7mX9uoM5ZhyMGTHNoOTrGpBZfJp2lwLVX 0x23jdq8biX8z0ZIidDU79yQDeDe6dBrdMgsah/xF71aJn4U5mr4VKqCbENkqredNlpT 0tfmwqY+XQFrBOrUvncPhvTCE4/rbEy5HZJ/ggCCaLBScKOKMlUvJ3pQP7qNuXb3HndF Zsxc8oRV34Z1rzEDTCj2Q4Ps4jWYqYy79NUHweHrj8V03+aXAOEnxXwmcoZQhpeNOYhO B+38kYQySh0koQBeoNmkx1In/nwDJQ3xu5Ei0inEsydspQsXYJq9uOlExrXPKZG/AZXL dJmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728584722; x=1729189522; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RdgAxVyxp31c7WibHLiyIF43paER00mxZOAIHhsdwhk=; b=U6W0AjmRbDyjKC5TMHwtxPNKBIt5lsMaYeY0p6WMShTDK19IdGU7cN1LUIx8f6BaKn IwHHPxkRdqk7RqocqhiIRDiYCnff/HwTbkoA3eogMLIFs44m6nD3x0dEqM+19U0G6atb cZhg29bZ7Sd5sEDjKvdpHheKm9tyEQ9jP7GFhgd/Ai9rpvoP6dbvQI32K4/POiCiKUxx aP6K1Vz7CWsP5PmgjTyKttSsLfOYT8sYkVZEqZmS2vhctZGSAb3q55w2vsBLLkXZQ1cm udMsi+bZSTBqjTbQPQ9R+rXuyeiCSdPd4RwVw04E3ofiDKcBcMofLx55c4+eBCRCTxmx WKhw== X-Forwarded-Encrypted: i=1; AJvYcCXVBimMk+vvfnsLeZVcIDrvRNhqkUItx+qkCfcoJvGObtvbz58N06YwU/GGKFhQF/n7kZyK6wL1rT54ufF+eR/F@lists.infradead.org X-Gm-Message-State: AOJu0Yz3v5CMTcr2YFAyi/sAdL6Exh9dgpqzbGBwoki9lmzKJoCDKOSX qlFN5tGadO3zgvaDHh7BkWDqudUWpqvXVC3wxgZxjzDXyKFGowtkt5sYShZpbZMRGWSPCMUV6g4 dIg== X-Google-Smtp-Source: AGHT+IH031wjBK6zBugJiyQwbgM1S3WkZumhuZG0/47H7WWzE24O4tbIqX0eqBdD0TzKWzHgCchY3qP4ics= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:9d:3983:ac13:c240]) (user=seanjc job=sendgmr) by 2002:a17:90a:9a94:b0:2e2:da81:40c1 with SMTP id 98e67ed59e1d1-2e2f09f2280mr107a91.1.1728584720854; Thu, 10 Oct 2024 11:25:20 -0700 (PDT) Date: Thu, 10 Oct 2024 11:23:16 -0700 In-Reply-To: <20241010182427.1434605-1-seanjc@google.com> Mime-Version: 1.0 References: <20241010182427.1434605-1-seanjc@google.com> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog Message-ID: <20241010182427.1434605-15-seanjc@google.com> Subject: [PATCH v13 14/85] KVM: Return ERR_SIGPENDING from hva_to_pfn() if GUP returns -EGAIN From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Tianrui Zhao , Bibo Mao , Huacai Chen , Michael Ellerman , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Sean Christopherson Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, " =?utf-8?q?Alex_Benn=C3=A9e?= " , Yan Zhao , David Matlack , David Stevens , Andrew Jones X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_112523_975585_601D5DC4 X-CRM114-Status: GOOD ( 11.50 ) 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: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Treat an -EAGAIN return from GUP the same as -EINTR and immediately report to the caller that a signal is pending. GUP only returns -EAGAIN if the _initial_ mmap_read_lock_killable() fails, which in turn onnly fails if a signal is pending Note, rwsem_down_read_slowpath() actually returns -EINTR, so GUP is really just making life harder than it needs to be. And the call to mmap_read_lock_killable() in the retry path returns its -errno verbatim, i.e. GUP (and thus KVM) is already handling locking failure this way, but only some of the time. Suggested-by: Paolo Bonzini Signed-off-by: Sean Christopherson --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 17acc75990a5..ebba5d22db2d 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2946,7 +2946,7 @@ kvm_pfn_t hva_to_pfn(unsigned long addr, bool interruptible, bool *async, writable, &pfn); if (npages == 1) return pfn; - if (npages == -EINTR) + if (npages == -EINTR || npages == -EAGAIN) return KVM_PFN_ERR_SIGPENDING; mmap_read_lock(current->mm);