Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp29680lqo; Tue, 7 May 2024 11:09:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0ER28Rhy+jUFWtfDJ3A0uIeiYyoezGWbW5BsO9KWPTD16oPAO7vw7OLo/2PtuJROG3DG89LGLOgXHZtE1FctYf6w3sQ/sBRWSBolKIg== X-Google-Smtp-Source: AGHT+IFkkfxGUJobPrLbdJsGCFiRPsSgUJDajC0HCXuawwQ7bRh8R4uUkNFpUgPrSw6X35XPuLmR X-Received: by 2002:a17:906:b197:b0:a59:9f79:b242 with SMTP id a640c23a62f3a-a59fb9d11c4mr12911866b.66.1715105352986; Tue, 07 May 2024 11:09:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715105352; cv=pass; d=google.com; s=arc-20160816; b=bmU0AeUC35yAh/xUWF8TOhCXtOgr7RrMQ6+NW4qjhlHv6SYk0e4OHe1A/R/P4qDQqP xmHPX9xHQxCaXVL+IZS6TARC8nsYFgk5S5qairJ5Y0EiNp/oBWjeJ0B9/tJbmqa99658 iXrzAB8yc2n1STd3gwA78YSgUZN32jXCDvptfS9fFzi+w8EWRietPxd4gRu1uY1J+CxK +pr2FyCzRlT5uwfaBtl7J/SHUOtYxEiZo1/HQ21St0o6BEuO3YwAvb40PYDsMJqOtTlJ 0lhQzvgF1Vm9bc0VDQArQr27goBUc7f/OLZogOPXyqr8xFSeSOWq0gEyohsZeLPaMJd7 Z8MA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=84S9YTb1A848Gfhc9IGVmnU4na6DpJYIQ4q1jmZ4h+M=; fh=uwOp2UVTonYvy7JjkwYgWmEzMj+LYWBj3xu2PrpNAkc=; b=FfqB1CCG/MHy1VSXj0mYlz8eAT5OJ2GK9tCo7QwxbFEtUZu0c3HL3Leask/YCjyKpG 8coq6TL53/GGgggxljdzJPpHcfMDVTUyJ+1tLJ9dkLhquhHu33o3k1rL2jCthkOhR8EH 8sZedsrr32CkVYAqifS5GtapRKsiQtiKABl3nTfl2AhfsShydcabAsJnsQ8PcsSZXQhG 7KliMmwK3uzW+yn6SRYCn3+Lqj5jHLoRHy13yOgRMck6D1uhhRXhP8YmQtPS7O1sdvhy l9ON+pIrJ4UkoNVUyr7IF3pCiGVQTA56NzjIqSLY+bJopybn612Bwd76buaxk3FqPLvH 2QqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=guJdzGjj; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-171959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r9-20020a1709067fc900b00a59ad2fe7b6si3938261ejs.81.2024.05.07.11.09.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 11:09:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=guJdzGjj; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-171959-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171959-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B49FA1F22A66 for ; Tue, 7 May 2024 18:09:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E6C2F16D32D; Tue, 7 May 2024 18:07:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="guJdzGjj" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D67F16D4D0 for ; Tue, 7 May 2024 18:07:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715105259; cv=none; b=Ob+/qf0xJswN3Fen8SduXAy6RNlXJ0Y/ULiKaC3014qe5g4I/LtZ0BMqtsljZbELSvdYYINkdNUJd+1+y5yrsllpLTCVIkn+dTE4nh6vfZGnod7xpNTYmNxb9+5NqlH/l70/eGO1uvc3vh5tacI0fcgRrMYb2DOSriBbOwmy3L4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715105259; c=relaxed/simple; bh=4FD3tqr2t4IpN6Mf9tAY2Lg2qs/GATirslBpU8gtVWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dHfDjSa7FRg/7VUw8/iSmh8zEdqANCCX0cTfSxmDmHYGbP+LUJWPJNfmXhF9hDvdxJMKliy735TyV1u/W9YQQejSQUIfcj5xk+8YQunK7TeJGOdFoYI5JlQDWuvpJEPHnpJokVbsZ275mCNT4k9N89titwj6ZFnIEVh4duH/ubA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=guJdzGjj; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715105256; 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=84S9YTb1A848Gfhc9IGVmnU4na6DpJYIQ4q1jmZ4h+M=; b=guJdzGjjakpjj+NAmwGGWi6UDs81cFh8h1IXYGiYw6BnIKRNYnCJ53zbPRKfZ4Umx31Rsw 8ARkkc39cNULIKfG+Q4vKTDNzA3pefn7hGEIb1LgdBk+5g4BS39ZLrdTixqxjXxWsMPRg0 1tsN7O6p8Ho8p9F0YyfFwOhFDP5iOIw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-gU33u87IPlu7g6xAckBFPA-1; Tue, 07 May 2024 14:07:31 -0400 X-MC-Unique: gU33u87IPlu7g6xAckBFPA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 124BF1C4C3EB; Tue, 7 May 2024 18:07:31 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5FA240C6EB7; Tue, 7 May 2024 18:07:30 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vbabka@suse.cz, isaku.yamahata@intel.com, xiaoyao.li@intel.com, binbin.wu@linux.intel.com, seanjc@google.com, rick.p.edgecombe@intel.com, michael.roth@amd.com, yilun.xu@intel.com Subject: [PATCH 3/9] KVM: guest_memfd: pass error up from filemap_grab_folio Date: Tue, 7 May 2024 14:07:23 -0400 Message-ID: <20240507180729.3975856-4-pbonzini@redhat.com> In-Reply-To: <20240507180729.3975856-1-pbonzini@redhat.com> References: <20240507180729.3975856-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Some SNP ioctls will require the page not to be in the pagecache, and as such they will want to return EEXIST to userspace. Start by passing the error up from filemap_grab_folio. Signed-off-by: Paolo Bonzini --- virt/kvm/guest_memfd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index 5a929536ecf2..c27828b0d42d 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -19,8 +19,8 @@ static struct folio *kvm_gmem_get_folio(struct inode *inode, pgoff_t index) /* TODO: Support huge pages. */ folio = filemap_grab_folio(inode->i_mapping, index); - if (IS_ERR_OR_NULL(folio)) - return NULL; + if (IS_ERR(folio)) + return folio; /* * Use the up-to-date flag to track whether or not the memory has been @@ -146,8 +146,8 @@ static long kvm_gmem_allocate(struct inode *inode, loff_t offset, loff_t len) } folio = kvm_gmem_get_folio(inode, index); - if (!folio) { - r = -ENOMEM; + if (IS_ERR(folio)) { + r = PTR_ERR(folio); break; } @@ -505,8 +505,8 @@ int kvm_gmem_get_pfn(struct kvm *kvm, struct kvm_memory_slot *slot, } folio = kvm_gmem_get_folio(file_inode(file), index); - if (!folio) { - r = -ENOMEM; + if (IS_ERR(folio)) { + r = PTR_ERR(folio); goto out_fput; } -- 2.43.0