From patchwork Fri Jun 17 01:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12885024 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 30FADC43334 for ; Fri, 17 Jun 2022 01:42:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 562E46B0074; Thu, 16 Jun 2022 21:42:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 512006B0075; Thu, 16 Jun 2022 21:42:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38BF76B0078; Thu, 16 Jun 2022 21:42:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2848D6B0074 for ; Thu, 16 Jun 2022 21:42:00 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 046B93512F for ; Fri, 17 Jun 2022 01:41:59 +0000 (UTC) X-FDA: 79586026800.21.F1B5922 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 8812640086 for ; Fri, 17 Jun 2022 01:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655430118; 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=NrOv7d3XvSDGb0fYfbi7wP1PoaH7k/6zz5b27rM4b4vBGKehgt+FutkOsW5Xm3jwREuXMO kl4pb6WiiCLKesYQkwfEqy09WwPDc3Mh//J5Q6LTbZO/LLhC0TICRncdzNLLTEv6Oa8Mlq xx4D9Bw6WCvmb5vUpa4VSjHaH7e9Ej4= Received: from mail-il1-f198.google.com (mail-il1-f198.google.com [209.85.166.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-rRgf8BrBP2qvLTsUUtyolA-1; Thu, 16 Jun 2022 21:41:57 -0400 X-MC-Unique: rRgf8BrBP2qvLTsUUtyolA-1 Received: by mail-il1-f198.google.com with SMTP id a3-20020a924443000000b002d1bc79da14so1819922ilm.15 for ; Thu, 16 Jun 2022 18:41:57 -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=m+diBoW2HSP3dKQJOLNKWn+wC7rKbA/axuf6SXsM568Zl1vupQH+swFyEPfnj7d45e MoB6J8W8rBPsWafqjxFiW417V4IWp5f6EOFWpjcy3xXfQm4Hb6qAEJF90b1D+eMWc4ti lAcQbqeDEXO6DiY93z4G7raQcSU+immWFgJkXlZzp2exzTXLCW5OC1LrZOG0/avCK3q+ JXTLtrYb7oIvnQ4RxXKhwSh17ZlJOUI4/PHlKzMs257391zLq7L2mGVqcVgEbfWJircW vfKGgHN1fW0wB759JaZBbghtz88k6dKjHDpmwscbkQpvUbV+C5f6KXAXkkjF3OFVz6ze +U4g== X-Gm-Message-State: AJIora80KTxT1hus7CNHkDjK3VeQ/OhhBurAe/Rz4YY5NA10rufSigp1 TkuNTANb5BTPx5h78L8A2UMgnjgSKy6+3AomeqShnvqTNkAORJms840Lju5xC7T1BxXDoA2Hmwq COI4WcLqEOPM= X-Received: by 2002:a05:6e02:811:b0:2d5:2294:ff37 with SMTP id u17-20020a056e02081100b002d52294ff37mr4319993ilm.249.1655430116764; Thu, 16 Jun 2022 18:41:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vkkfMz7cqp5MF8GJOCZIECqzgeFNO0MvlQHMdn1ovMhxzPuVoVfsfN47FOLsLaed4L90CO1w== X-Received: by 2002:a05:6e02:811:b0:2d5:2294:ff37 with SMTP id u17-20020a056e02081100b002d52294ff37mr4319979ilm.249.1655430116477; Thu, 16 Jun 2022 18:41:56 -0700 (PDT) Received: from localhost.localdomain (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id n4-20020a056e02140400b002d522958fb4sm1726538ilo.2.2022.06.16.18.41.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Jun 2022 18:41:56 -0700 (PDT) From: Peter Xu To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Dr . David Alan Gilbert" , Linux MM Mailing List , Sean Christopherson , Paolo Bonzini , Andrea Arcangeli , Andrew Morton , peterx@redhat.com Subject: [PATCH RFC 3/4] kvm: Add new pfn error KVM_PFN_ERR_INTR Date: Thu, 16 Jun 2022 21:41:46 -0400 Message-Id: <20220617014147.7299-4-peterx@redhat.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220617014147.7299-1-peterx@redhat.com> References: <20220617014147.7299-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; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NrOv7d3X; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655430119; 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=TnE7VYTdVoVtKLEaeW97iFX3fCZ/7sxzrBTQbSF2/+B1DllDPFHeFEuusZhGez2YS0GdFe sZoID00+2xycmVHQ7jvqLZl6HqKjxc2pucFt1DXHzi2dVhtlw7nj9fE9l2yln4q/i6Dlcz nwRF+I/Z5rp0+WfHer02oiVsRge+3gk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655430119; a=rsa-sha256; cv=none; b=j3woExolU31kc1I/XfSzI17bv+LoMV1hkaFjozSSTeR9ZbdQWhck/la6K319k6jD3edV6A 3BS2YRMOCWt+x3lqEjXdDQKdQPTG0b6sC15V7xEOKxRmnfQ4hLs6f7lszdaL2CKkDtXEf4 VitP9vQT3Hxb0rcDrQzzxCBdaW0NATA= X-Stat-Signature: 7yr1g3q9rfudogxrrebtp1gyootxaa3c X-Rspamd-Queue-Id: 8812640086 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NrOv7d3X; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam10 X-HE-Tag: 1655430119-374699 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