From patchwork Wed Jun 22 21:36:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12891499 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 462C7C43334 for ; Wed, 22 Jun 2022 21:37:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0CDB8E00F5; Wed, 22 Jun 2022 17:37:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBCEF8E00E7; Wed, 22 Jun 2022 17:37:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A85528E00F5; Wed, 22 Jun 2022 17:37:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 996268E00E7 for ; Wed, 22 Jun 2022 17:37:16 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6CFE561161 for ; Wed, 22 Jun 2022 21:37:16 +0000 (UTC) X-FDA: 79607182872.21.8587EC3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id E7D33400B7 for ; Wed, 22 Jun 2022 21:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655933830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ghHac7UV1N6vPGfjk7ojRXZFbMUyEtSeJQo5S/wAoOg=; b=YRCpHorWcD1kefTMslBVEa8A/M7umsaxfZ5hCP746xr4zzujlNPUdvl1xdbwO8Zzy8f9x6 i6mwrOuYAgsHnUCrQhy+VWbOYJnSFriO+vba/tR/zSnYCQTNSJAsQh59G562sRWnfANjCH /vwigs6EeOy3kx+XDLclBKFWkpJsnx0= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-110-Fm35eI8xOVqKfZVkZtR1vw-1; Wed, 22 Jun 2022 17:37:10 -0400 X-MC-Unique: Fm35eI8xOVqKfZVkZtR1vw-1 Received: by mail-il1-f199.google.com with SMTP id l3-20020a056e021aa300b002d9094fb397so6772419ilv.11 for ; Wed, 22 Jun 2022 14:37:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ghHac7UV1N6vPGfjk7ojRXZFbMUyEtSeJQo5S/wAoOg=; b=CC+cCpmaAUw30qvsng5yc+AvjfNTa7nx+7a8+Cmwf+i+/P3UpVnaGKBWKhR+WNoUya NV5PO3zY8S6gVw528l+zz18ksdRRKDN8MExk4TcXrJlyc50gBLOXxB6bDDH1YVcLhpKK s9/oZzWydIlDI7J2ERdFdGEGAa22BdmjcOQYT8dFojfd5HfhxwQ1QwzwXkTnp2OJt3HK d3YiIa2ZcwDtZkPmXr4qYQx630300rwiRktTc+boFE5DyokQMMrjdxI9t7kf5oMuNN7E dbIvkbEqoRYfsA3tjJoANWSDemj8/VpqpHd3yjmc8YdkAkZoTN/Not9EL/GLk/ECMdG/ 0m7w== X-Gm-Message-State: AJIora9KA6PNiPeglypRux2zfe8QDWLWvAj4UxqtiHf21UxBh0IFgguN 8sd6mImAKnVFh0VMHkLJ3u1Ac9hfKBISxy8cb5X5+jfQC3D4a+maUWYkJxZfp/1rPSBmtBssJJe 3WADTP9Y3MjE= X-Received: by 2002:a05:6638:3802:b0:32e:3d9a:9817 with SMTP id i2-20020a056638380200b0032e3d9a9817mr3381402jav.206.1655933828963; Wed, 22 Jun 2022 14:37:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sef3p8Uu7ssABriH3qblNDoH/AkpKRoJmrO09ZGEgP+PL9or7LCLMx+soJFip3k0p/jz0afA== X-Received: by 2002:a05:6638:3802:b0:32e:3d9a:9817 with SMTP id i2-20020a056638380200b0032e3d9a9817mr3381390jav.206.1655933828779; Wed, 22 Jun 2022 14:37:08 -0700 (PDT) Received: from localhost.localdomain (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id g7-20020a0566380c4700b00339d892cc89sm1510446jal.83.2022.06.22.14.37.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 22 Jun 2022 14:37:07 -0700 (PDT) From: Peter Xu To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Paolo Bonzini , Andrew Morton , David Hildenbrand , "Dr . David Alan Gilbert" , Andrea Arcangeli , Linux MM Mailing List , Sean Christopherson Subject: [PATCH 3/4] kvm: Add new pfn error KVM_PFN_ERR_INTR Date: Wed, 22 Jun 2022 17:36:55 -0400 Message-Id: <20220622213656.81546-4-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220622213656.81546-1-peterx@redhat.com> References: <20220622213656.81546-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655933836; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ghHac7UV1N6vPGfjk7ojRXZFbMUyEtSeJQo5S/wAoOg=; b=rWfSUFz41m6h0nVyJcEeV3TUhL64gtSUUW/bGw6dGdXvDkavOtIBzv/25hUFs0rfhxWx/b /yVdQQ2kBvR1J/mEr+rwe+sA4duLhGc3hdEihfCVTHKUOF1jnxTsGfYXaFDBsHLsi5jkPA jQQ0qz61im+YksLLhK8s8OkK6Fdza2M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655933836; a=rsa-sha256; cv=none; b=PpxbpyANBBOExeZxYxlq9LIjKZ9O3Uj+qq8/Jv+K7lwS7NN/6MQTthhzPlZr1Bcb5Z5Zr8 RXGBrQzGz6NInL+vtKillY6LLqewn9qhYXW8CJij0ihVBz/ivuideROTZnHT9ILzZN/THj G8VT5qlAhonp5D7B9pw6FI+p9jvuleU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YRCpHorW; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf01.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Stat-Signature: atjthurx8kwzwz8gk4jf8ueoynj6aqrs X-Rspamd-Queue-Id: E7D33400B7 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YRCpHorW; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf01.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655933835-943138 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add one new PFN error type to show when we cannot finish fetching the PFN due to interruptions. For example, by receiving a generic signal. This prepares KVM to be able to respond to SIGUSR1 (for QEMU that's the SIGIPI) even during e.g. handling an userfaultfd page fault. Signed-off-by: Peter Xu --- include/linux/kvm_host.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b646b6fcaec6..4f84a442f67f 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -96,6 +96,7 @@ #define KVM_PFN_ERR_FAULT (KVM_PFN_ERR_MASK) #define KVM_PFN_ERR_HWPOISON (KVM_PFN_ERR_MASK + 1) #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 2) +#define KVM_PFN_ERR_INTR (KVM_PFN_ERR_MASK + 3) /* * error pfns indicate that the gfn is in slot but faild to @@ -106,6 +107,16 @@ static inline bool is_error_pfn(kvm_pfn_t pfn) return !!(pfn & KVM_PFN_ERR_MASK); } +/* + * When KVM_PFN_ERR_INTR is returned, it means we're interrupted during + * fetching the PFN (e.g. a signal might have arrived), so we may want to + * retry at some later point and kick the userspace to handle the signal. + */ +static inline bool is_intr_pfn(kvm_pfn_t pfn) +{ + return pfn == KVM_PFN_ERR_INTR; +} + /* * error_noslot pfns indicate that the gfn can not be * translated to pfn - it is not in slot or failed to