Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2231539rbb; Tue, 27 Feb 2024 15:30:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXcSuryotQxGbSRaMZrzzxI7ec3NOMXgPfby/jjl5wvlbH94yJ5IQWUbnkuNxvemhAPuUDMNz9bVNfHeCQ5VrvlnBnk+f+U4VIAaRimZQ== X-Google-Smtp-Source: AGHT+IE1MzG8nTekKGmSCU+kK1FvuXIlfUIj3Y4MDOCBVIxa+JS7UDp3L+WR0x2aQgwISpm79SDV X-Received: by 2002:a17:902:ed0d:b0:1dc:78ea:1ae with SMTP id b13-20020a170902ed0d00b001dc78ea01aemr9760078pld.26.1709076602309; Tue, 27 Feb 2024 15:30:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709076602; cv=pass; d=google.com; s=arc-20160816; b=oXZkc1fCElk5p7VWRedG2VhHgXuQRrSAx8wqSOBpiu9a/MBnHQRQmzUbmZRo58yu5M KhkljzzRi7oGXRt2rE8h1HAT9ZDxH7ihkBSdc+VYk5ETUG/j/w3Dt/0/2RFX1cwsRNKr 8aINpbWokIEeeyNMEnSxt3Dxh/rxKVlkP9rGHjqO3ZzbZlovtp6L7/b/PbUuD0mi27ob EKcUjF+1DbH0WSN3yHW1qIxB1bjgowlPMyZwnYF3UHVzUwbq6qdzQObJw46f3XCp6JEX /G525nB6Zg5Y9W7K/oKuyNqhSgyFM47OmPpLyH6pYmB7HSwzxX+LirJyCaK7W6+GeMn/ Q70w== 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=b2AC1kWCQIdviuYJSL43BWVEXzcmh8/McQsHaI1LaBw=; fh=miuXyzfw5j8qsOURKCmYrSiXirUlKyDkR37pPJ+5+/s=; b=gaWqPnnNCuVRinf/WXs9Euy9dtuRJXtiIsNfXxmsHpIOwpUSW7GO7kNkB9kr25Ridd ZlOgilBMG8PViO4ZHUCo+X1+Bds1SzmgJZnFR60rOdLMYDvz1xkWIcF2j7pe/l8pDiL2 4Ub3FV6c9J6l0O12Zxy2tMs7VWOc6iGDVylT/EzykXRs4y4Ieq7FjtZTuFB7PqR4GHMJ h/8bjBbMJGtQjxwy8egzPeQDBM+YOjoBMkKEX0YZwx3lv6epU6I6YmmWKtAYq5i9G2AM q1OL5Kf34scXHU+PDPyUvwMBnMbimxdJs4Lim/Ad0rMA1lINLe+Ba1GZ8Ha5lgPcxYUU 4KaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZFjgvgk6; 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-84204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84204-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k18-20020a170902c41200b001dbc4d9d82csi2231867plk.479.2024.02.27.15.30.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 15:30:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZFjgvgk6; 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-84204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84204-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0BC7D28E9B8 for ; Tue, 27 Feb 2024 23:27:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8305E5EE89; Tue, 27 Feb 2024 23:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZFjgvgk6" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 0F2E858106 for ; Tue, 27 Feb 2024 23:21:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709076072; cv=none; b=Mdo9zggY11YmgYCtpoos9P5QRemfA4Mvvxu1Ut/+AH/gD6mTXM7QVpNnMTvqYwZoS/4v2WEBEYwq7rdNJYUwAxggMhLULI4Kx/a4oNX3rXBZvl11Hvlp48hSl1RABsRC/2JZFZDLdfFeUKgOcatToQ5qlwb6grJXUnuUCMYKW54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709076072; c=relaxed/simple; bh=S+uYhRirj57d50L93671lbfFFpK+UcWKuIe6fA+sLME=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Lvp5pGIKbtaXeV9UnUrExblyFaWqJwsyUXBS4vUKfHRHJQsbrmA1p5jyKA6piNYoc91eMpnWzkLy8YM8p6Q5wc+zazdzHsYt49lpCp/Gf0AbFN0NPTIlvRcO2JSunifOdWThaemVbRLEMG+Jqf2dVQcYYPpcRtB3u2xwhlsn240= 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=ZFjgvgk6; arc=none smtp.client-ip=170.10.129.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=1709076068; 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=b2AC1kWCQIdviuYJSL43BWVEXzcmh8/McQsHaI1LaBw=; b=ZFjgvgk6YnxGz+suaEYbiWl8TZj0bml9iNQbXZGrprzmB5TYPtAD5VI716EUKdRzKQNwC0 7Q76tU4ButKMTmP6+BZc5n6MHXj9aOvxy2skkKlqL6cEM1Vg9ij+dF5uk5veU/ezaet/jf HkW9/ZvgbQpdKSOiF8nKOD6yvSNJ1pg= 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-179-bY7PtkpjPjONcKbOO7aBxQ-1; Tue, 27 Feb 2024 18:21:05 -0500 X-MC-Unique: bY7PtkpjPjONcKbOO7aBxQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 999A83C13A87; Tue, 27 Feb 2024 23:21:04 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D272C0348F; Tue, 27 Feb 2024 23:21:04 +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, thomas.lendacky@amd.com Subject: [PATCH 16/21] KVM: guest_memfd: pass error up from filemap_grab_folio Date: Tue, 27 Feb 2024 18:20:55 -0500 Message-Id: <20240227232100.478238-17-pbonzini@redhat.com> In-Reply-To: <20240227232100.478238-1-pbonzini@redhat.com> References: <20240227232100.478238-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.8 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 0f4e0cf4f158..de0d5a5c210c 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.39.0