Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp245822lqp; Thu, 4 Apr 2024 11:53:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsqzCXklmzuu0W099HQTcAqp4nY7vUvPVuFy03rUVNzhcLzDnDbwRevzOThND7MTHGaJ+mrgkYXyMR60gHto/g/0pFlRaMFBnOojtEiw== X-Google-Smtp-Source: AGHT+IEUhEm9kA0lNXl34Ddasj9MHuCLU5SriQomYu93rK+vnXc6uWoU9IgJkO4Mngh7tNwi1sYC X-Received: by 2002:a50:9e43:0:b0:56e:1010:cd7c with SMTP id z61-20020a509e43000000b0056e1010cd7cmr2727525ede.12.1712256812546; Thu, 04 Apr 2024 11:53:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712256812; cv=pass; d=google.com; s=arc-20160816; b=YRUmldAs4DMpBQBSu6DEzhmewWMwRa6Qi9CQWG2doVwZhulej2dsC2WMDzh603b2Ip TQPTra780mv65QoVoB2zy556HKzTnHM9kzi1wR592DGCrx9jSQ8UqCJJ0HUStJfY6SRq FbXlo6n4pbKsQjfsReH1phuW1GwaEUTohtlhr9Hfzie5prc/mnpONjc2yK64gFw7Ik7+ S3IjBc1CFjB3GBZ0JzecldSrHVGFq0kclqo6IPjndd4Xfg4UPCr3NsAjnBgbvDidI2zE gvVqRJrnUY9yBHDswu32Hq+8wWvImdDWqJRRnIzawsWj4F9UkDgsbuveZOZpDwtmo/fm YNNw== 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=IGNOj1ZA+U6rAjLuPpugLuw9vdunQ/dJ6CvoC6KHQIo=; fh=YodCu8Vte8qk6mmfvotnw4P3XuROgs3fniKbwtpv3JY=; b=HxHaoGHCO8kz6Gyl0yJrXKQasza/6BXZQOtjkwmVSu+spopC/pXyNtIGLB9KWiQxZP yKAEFAT9DZyZtfF5cSwJoLpujSCeYM8KgWXR8YPyf9NNKJL3yU2RJfjNYpj+AWhe3bPc ptnFLTXgZBAqWajbnAfSnYSqMvqw4NqkVLgH7gSxD3S6LfbOi2Cs5lCLfJ1HTpJmvscX ajflSN4jS+90QGh6/ymdHiUcfVEByLE8CpGxkk2w9wj0xVwH5YQUbFeFp7tJ6/QIWBh+ ll5S6dfdG96L8vB95bplxW6WImU440rHYPuIT6NJ2RBGIAvdAarXSPZraFXZcYbjK6Oh VxCw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CGwbto6/"; 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-131990-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131990-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 a19-20020a50c313000000b0056dfac75a17si2399211edb.180.2024.04.04.11.53.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 11:53:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131990-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="CGwbto6/"; 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-131990-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131990-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 07B331F24160 for ; Thu, 4 Apr 2024 18:52:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE37913AA3F; Thu, 4 Apr 2024 18:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CGwbto6/" 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 52185131BDD for ; Thu, 4 Apr 2024 18:50:40 +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=1712256643; cv=none; b=ORaVqNdmwNOeRUkYc7bnzOphiCYEIuZYaTe5aq65rX4cl77ghntJ1V5gwcRqA1OA1FaQI4aeayijRRt5tFBnRcveE1PzE/oBh6P0CkTaUHu85spJN3vSZnM2bCDJh62rFwSTniqzE2rI0WUqqy82aOff4SEKWXT2DH97m6ocr+w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712256643; c=relaxed/simple; bh=F9Opcs5Sfjt55zjO6/Xlftcpp0gbWr27hsN6hC6zdq0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JplqdDJXuVtQZQdLKg01RpC4TmQUEvddV9WYNAgxGO/+aARG2MTw7OGz+G/Jlw+3542ZbM8yvhe55xbiK4vV/Y5mHyvLYyF4E1yMsNDo4Mbym5erGcApQ0LgmM9XxO0tkPq8Mz0wBQCxnHqC9PoqJhL1fln3VwpV4WynCq0fBpI= 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=CGwbto6/; 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=1712256639; 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=IGNOj1ZA+U6rAjLuPpugLuw9vdunQ/dJ6CvoC6KHQIo=; b=CGwbto6/ViFZrsOs8kiwksDMkpq634tYwaWX/x7rrKAVIuv7AgNs0IxEPgYbPm822eNBBK B8F+9xzUxG4gXhpYyJikGPu7gv/2B5BPciqhj77vQ3OPIdItqTf8TEK9pECdYFkHr9mjhs /lMVF3Kq8gGUgHtnBxDruY+TQ7j8+Vk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-4NWzNcSxOBKwgJ5puyVL_Q-1; Thu, 04 Apr 2024 14:50:35 -0400 X-MC-Unique: 4NWzNcSxOBKwgJ5puyVL_Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 5FEBB85A588; Thu, 4 Apr 2024 18:50:35 +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 39C4E1C060A4; Thu, 4 Apr 2024 18:50:35 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, michael.roth@amd.com, isaku.yamahata@intel.com Subject: [PATCH 03/11] KVM: guest_memfd: pass error up from filemap_grab_folio Date: Thu, 4 Apr 2024 14:50:25 -0400 Message-ID: <20240404185034.3184582-4-pbonzini@redhat.com> In-Reply-To: <20240404185034.3184582-1-pbonzini@redhat.com> References: <20240404185034.3184582-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.7 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index 5a929536ecf2..409cf9b51313 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -20,7 +20,7 @@ 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; + 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_OR_NULL(folio)) { + r = folio ? PTR_ERR(folio) : -ENOMEM; break; } -- 2.43.0