From patchwork Tue Oct 11 19:58:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13004291 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 54FB4C4332F for ; Tue, 11 Oct 2022 19:58:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDA8C6B0078; Tue, 11 Oct 2022 15:58:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C15298E0002; Tue, 11 Oct 2022 15:58:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1ABB8E0001; Tue, 11 Oct 2022 15:58:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 899486B0078 for ; Tue, 11 Oct 2022 15:58:17 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 50F1E16113D for ; Tue, 11 Oct 2022 19:58:17 +0000 (UTC) X-FDA: 80009730234.18.E126A6B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id C4B1A12002B for ; Tue, 11 Oct 2022 19:58:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665518296; 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=SAlECgJKwNknwoioVUeF/uXHuNVkO1eljRPrSr7m9O4=; b=XfBY+BpzifjONzdlKZfmEJu9cwztHrJJbXiVVe6QDjw4sHG5XBSZN6cqCSOcCkALat6Ezu FU6TQtdgvLJLqx2IPR0CT6rOaYDO/43bB8sB5z8eAiE1PXOPm3bGIrcH0s9cNME/Zrfzg+ 1OOwNVYhHZk8uS7yRUmD7+zKxfClc+0= 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.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-349-tLqXs5ZgPPqYcNiz9ogRzg-1; Tue, 11 Oct 2022 15:58:15 -0400 X-MC-Unique: tLqXs5ZgPPqYcNiz9ogRzg-1 Received: by mail-qk1-f200.google.com with SMTP id bs30-20020a05620a471e00b006ed2a84071bso4800691qkb.0 for ; Tue, 11 Oct 2022 12:58:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SAlECgJKwNknwoioVUeF/uXHuNVkO1eljRPrSr7m9O4=; b=kfQ8inDbdWB7DJ0l2zSt+eHqqSBJsf13mBH3QG9wvmIQoOYNF1Utc1ckDVXlQChocd jBfIJBXTBjPHZnqbmSwkBsq/JA9H775cluxaq92WqJjL3rs4+Q+ldsPeYqf72PKltAGi 5uXruTCUgb9W2URzwQnfIft9lVStcc36QBJE+3maMY9LLfQh++9BZlDbq9BfiJ1M5aHT 9DVT1ExOIX3fC5MLH/CEzPSrTarR75f62/KJnJ8gprLtTH5LZmvBGBGjyYib0EKUnhXu vNkHQfwa0oy5DCnFKOkjZktt+tZx8RoiZvXcgW/AM+lDVVFQZ2mPoP4/CGsdIprDUow/ iaJg== X-Gm-Message-State: ACrzQf3ukpHMFKcU3Gv1D72KVoGixcWtfP7fBsv0LzLDxP0IX6SY4WJi 2UCxVUC6LoE8xTknLHXIE4KEZDBgKI6CweBB3D3PejSxoKLtlQv5Cayn5639Mv19D78Ac3/b2S0 c8plKHohyka4= X-Received: by 2002:ac8:574a:0:b0:394:3388:9fc3 with SMTP id 10-20020ac8574a000000b0039433889fc3mr20682006qtx.292.1665518294787; Tue, 11 Oct 2022 12:58:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5lzV/hWT/COel7yjUmDe/h42rtZvKalYrmBS4qOaAdmcwzGvcmWe1PC252299lW5tk7hr3pg== X-Received: by 2002:ac8:574a:0:b0:394:3388:9fc3 with SMTP id 10-20020ac8574a000000b0039433889fc3mr20681987qtx.292.1665518294584; Tue, 11 Oct 2022 12:58:14 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id az31-20020a05620a171f00b006ce9e880c6fsm13648837qkb.111.2022.10.11.12.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 12:58:14 -0700 (PDT) From: Peter Xu To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sean Christopherson , peterx@redhat.com, John Hubbard , Paolo Bonzini , David Matlack , Andrew Morton , Andrea Arcangeli , "Dr . David Alan Gilbert" , David Hildenbrand , Linux MM Mailing List , Mike Kravetz Subject: [PATCH v4 2/4] kvm: Add KVM_PFN_ERR_SIGPENDING Date: Tue, 11 Oct 2022 15:58:07 -0400 Message-Id: <20221011195809.557016-3-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011195809.557016-1-peterx@redhat.com> References: <20221011195809.557016-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; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XfBY+Bpz; spf=pass (imf29.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665518296; a=rsa-sha256; cv=none; b=D+WPl0gvXt7fTkJ9rKIsUPf1DBlhURvQf3Dg+GqAhoUCtANYEHPK8n69UUBnjpUkdsm/Qr HHfW0sPNiSqF+dtc4+2zUFDPkSeikrC3SdaGLap/8/D1+wwLIKMu4P7aiL6InBYO+oADiV sZ+PChxwPjVoJHqSkASVmn9wlXZ3gYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665518296; 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=SAlECgJKwNknwoioVUeF/uXHuNVkO1eljRPrSr7m9O4=; b=aVnIJXb/wv2U8xXKJ8f1yihcomt7wmvqmd2RquJFxM8NwSzqSWiTGVfNoVcaLjn+kRKq2W N1CivOykDy3oVAyd8nRn3FFkzhu2wcNLw7BNwAIFsbwLpey/FbPV0X2Quz/RuumGbIkJEH YiL2Tsuuvu7eWWvRf0UBa6aZ/IFn374= X-Rspamd-Queue-Id: C4B1A12002B X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XfBY+Bpz; spf=pass (imf29.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Stat-Signature: fgbs6mj1s6j4j8giaya6pc8m7mu8cgx3 X-HE-Tag: 1665518296-646915 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 a new pfn error to show that we've got a pending signal to handle during hva_to_pfn_slow() procedure (of -EINTR retval). Signed-off-by: Peter Xu Reviewed-by: Sean Christopherson --- include/linux/kvm_host.h | 10 ++++++++++ virt/kvm/kvm_main.c | 2 ++ 2 files changed, 12 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 32f259fa5801..92baa930b891 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,15 @@ static inline bool is_error_pfn(kvm_pfn_t pfn) return !!(pfn & KVM_PFN_ERR_MASK); } +/* + * KVM_PFN_ERR_SIGPENDING indicates that fetching the PFN was interrupted + * by a pending signal. Note, the signal may or may not be fatal. + */ +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 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index e30f1b4ecfa5..e20a59dcda32 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2667,6 +2667,8 @@ kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async, npages = hva_to_pfn_slow(addr, async, write_fault, writable, &pfn); if (npages == 1) return pfn; + if (npages == -EINTR) + return KVM_PFN_ERR_SIGPENDING; mmap_read_lock(current->mm); if (npages == -EHWPOISON ||