From patchwork Thu Jul 21 00:03:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12924634 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 5AA41C43334 for ; Thu, 21 Jul 2022 00:03:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1C416B0075; Wed, 20 Jul 2022 20:03:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCC306B0078; Wed, 20 Jul 2022 20:03:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6C336B007B; Wed, 20 Jul 2022 20:03:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B86746B0075 for ; Wed, 20 Jul 2022 20:03:33 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8A3E2140795 for ; Thu, 21 Jul 2022 00:03:33 +0000 (UTC) X-FDA: 79709157906.01.8D3E614 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 4ADFA1C0090 for ; Thu, 21 Jul 2022 00:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658361804; 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=17Vp4Ex87tn6Uk/BpRm2TxdVL2JJUXYS9NeIPo0wplg=; b=EcWfdj4C+RULS3swIwtT6bJTVZVlKBudT09igcl9kYdbYSREsqI0TcIe/yWLgseN80oQtz uzP0RyLnSKo3B21mS+DutOSSFt+7FiqmuowdYyQ86n2FHCBFhDJ+wRgaLCdNNMyQdtkIGA 844d1KXxsDNd9oDhYyzbneZheDTm2vs= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-532-yHa0RW0-P2u0Ec4aQlJmYw-1; Wed, 20 Jul 2022 20:03:23 -0400 X-MC-Unique: yHa0RW0-P2u0Ec4aQlJmYw-1 Received: by mail-qk1-f200.google.com with SMTP id h8-20020a05620a284800b006b5c98f09fbso204740qkp.21 for ; Wed, 20 Jul 2022 17:03:23 -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=17Vp4Ex87tn6Uk/BpRm2TxdVL2JJUXYS9NeIPo0wplg=; b=LOM4Sp6haTRRbFN+WELZBVoyy6ToGj3hzA/2wQLt9mZGAB3X8fndkfTInskxVpHHvY E4Ue8wESm4G/IHruJOMp5ghkiGUpebRUp8Q0Zgh1jKolFxUvz2niecyuwZD2nSUZLpmt OF8Ygn/hVW/XSkAIFO0vozTfFgKkr77IPtub4Zog83OHyozZxWVTfwQBJtd03t0gGz/w 7gnRheqIf0Zrx6eVqN0JHQSBD2LqiaJZoXySpYpVH9zyh9QUmV2cJd0wYKv+HkxaTM18 nT0SaeeQo7AEs2hPIbRyz0Qg8JU3dNZUFuSUfMu7Dx0YWmD3hd7vDX+wkc8b7CTm+2JG Q5ng== X-Gm-Message-State: AJIora/FTXneoNKJIeZ+n6tAPQkTENpURKFNlo8V6xt5Ny60YARgnR2+ sTAYpRv9RSZXuaF7hB7CoA9CmM8T/BHAt70/Wyf8wsTQx9pCs/kcOb4JHcPmquPzSpvT4zU3BBa aVZDbDKNcvOc= X-Received: by 2002:a0c:b284:0:b0:472:6e5e:e2f0 with SMTP id r4-20020a0cb284000000b004726e5ee2f0mr32317992qve.90.1658361803306; Wed, 20 Jul 2022 17:03:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s1+KU5FgF3m6vx4q4MlpqxGLoNsyQhiNfjM06PJt/2rXTILbIrwzzfnLXh7xwYd1LxLFugOw== X-Received: by 2002:a0c:b284:0:b0:472:6e5e:e2f0 with SMTP id r4-20020a0cb284000000b004726e5ee2f0mr32317973qve.90.1658361803125; Wed, 20 Jul 2022 17:03:23 -0700 (PDT) Received: from localhost.localdomain (bras-base-aurron9127w-grc-37-74-12-30-48.dsl.bell.ca. [74.12.30.48]) by smtp.gmail.com with ESMTPSA id g4-20020ac87f44000000b0031eb3af3ffesm418640qtk.52.2022.07.20.17.03.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 20 Jul 2022 17:03:22 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: David Hildenbrand , "Dr . David Alan Gilbert" , peterx@redhat.com, John Hubbard , Sean Christopherson , Linux MM Mailing List , Andrew Morton , Paolo Bonzini , Andrea Arcangeli Subject: [PATCH v2 2/3] kvm: Add new pfn error KVM_PFN_ERR_SIGPENDING Date: Wed, 20 Jul 2022 20:03:17 -0400 Message-Id: <20220721000318.93522-3-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220721000318.93522-1-peterx@redhat.com> References: <20220721000318.93522-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=redhat.com header.s=mimecast20190719 header.b=EcWfdj4C; spf=temperror (imf18.hostedemail.com: error in processing during lookup of peterx@redhat.com: DNS error) smtp.mailfrom=peterx@redhat.com; dmarc=temperror reason="SPF/DKIM temp error" header.from=redhat.com (policy=temperror) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658361812; a=rsa-sha256; cv=none; b=Ee/y+lPWdQfrHzoWbxXNmQcrho5flJVphdBiGJ794g2Jl5q8jFGhhXhGe1ZP2kL3ZyyT3p sU5MmDhjJCnWf/QsA9BtCTbkBdBkCKYrVErnlgAEm3hdGSx3vGjkehNL2zps5o6hLvXRnd L6S41TWJHorrXGOUCNwHHIhajGXts0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658361812; 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=17Vp4Ex87tn6Uk/BpRm2TxdVL2JJUXYS9NeIPo0wplg=; b=NwppQcuDjgUFiiPsBBAYg2O4myTiRaBwT1OE7qadjA8wf2FrNV783Bc/oJIorql1gxYh35 zfLDTTtFZQLMflzKVLUZTsptYN2VA200Hxgw/tD5PZaWAVDQmxPCqO1jZlGGztTYusPBjh yzi2ImO6k+l9D6qntxOFPi56+arOSd8= Authentication-Results: imf18.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=redhat.com header.s=mimecast20190719 header.b=EcWfdj4C; spf=temperror (imf18.hostedemail.com: error in processing during lookup of peterx@redhat.com: DNS error) smtp.mailfrom=peterx@redhat.com; dmarc=temperror reason="SPF/DKIM temp error" header.from=redhat.com (policy=temperror) X-Rspam-User: X-Rspamd-Server: rspam01 X-Stat-Signature: wfjetcrhzz14g3m6nk1ia41ufdu6hike X-Rspamd-Queue-Id: 4ADFA1C0090 X-HE-Tag: 1658361805-845592 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 got interrupted when fetching the PFN due to signal pending. 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 83cf7fd842e0..06a5b17d3679 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_SIGPENDING (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_SIGPENDING returned, it means we're interrupted during + * fetching the PFN (a signal might have arrived), we may want to retry at + * some later point and kick the userspace to handle the signal. + */ +static inline bool is_sigpending_pfn(kvm_pfn_t pfn) +{ + return pfn == KVM_PFN_ERR_SIGPENDING; +} + /* * error_noslot pfns indicate that the gfn can not be * translated to pfn - it is not in slot or failed to