Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp732081lqd; Wed, 24 Apr 2024 15:34:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5N9V+kWEV9LwpvRvpWh8nLfYFvUYL1E9KyGc2ZMUfMSAg+FJSgVZshKz14G12dV0qQWB6cOaCGkpGQQZpfiiFq0cEChAGp5k5Ocvagg== X-Google-Smtp-Source: AGHT+IF0A+xyiaYZTSuaKD3Voh3zJHAGwm8chQGMMmbvWSptVKooQ95rsrT5k35XlrXO4NAJMNWb X-Received: by 2002:a9d:5e0d:0:b0:6ed:a862:c24d with SMTP id d13-20020a9d5e0d000000b006eda862c24dmr91487oti.2.1713998079191; Wed, 24 Apr 2024 15:34:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713998079; cv=pass; d=google.com; s=arc-20160816; b=uHGp4nGIJYF3Va+Yp1i0UA6PSRZxTeZ0pF8jwsM22dHPuiifKfzz33SKAfAFFzgaAU rYzXoaXFHfdEyFiIjYxpKeiATdjGq3EdguR5uYsuT5Zl8WmHG/YCruFwLwtHR01iLHUP lr/kz6EAKHI495tdWoNgonx6ctUg8IaBT3aYAFcgfo3Yv6oN2dQxUsjvhJLa8upjaDR0 FVqCUeDJIWYTCpo4sVP8Yk5BfDstqKO2+xnNaiag9bo63oaTvspm83eK6GVDldFdaGjk nc+NWMwMz6/1h75IrKrNew+3uIr9xXduOAHLxbXekF5FAsO6vF8hfmXKz4yjiVUKET8O raMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=yhZptQyvv5xokxwHGECOmJsyHAUY1E5WI4kuUHDLdOc=; fh=uTe4RNUovI16CcTR5RyOf5Ezo4ahT1OCtLTXVwuIdrc=; b=AIfTcs3RJXs9wquWF8mRwIEAq0fj0pKyLmacgWcR78eyB8OENshZNwx7padv5bBQCa vuKtZpYaTBwzInRCZgHYvppc6DyHQXtP5hBUZ0xIqBXPTStHKtzQ8v2HDKwJvAsQriJ+ g7FbywkuYuPAGS9w/+Arfu6qOtMQhfpsZhIMTcYRrD04ncPWcCxnzpu2BM8rETc4Djzs 5QuS/t6kFuRPExbOhoS0Ab4aCX5HCdMPrhTG0AH9+JzxzMnd11HJ8scFC94LmLiakirJ Vpo3orHA9TT6m8WZuwG4RvADYdGe6eGYf6ePMEXsPL18qD3pja6WOohdyHHJp6urB+zf vp6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2aPw+sag; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 q8-20020a656848000000b005f76fa38b0asi12012690pgt.345.2024.04.24.15.34.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157791-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=@google.com header.s=20230601 header.b=2aPw+sag; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-157791-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157791-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 CA3C82828DD for ; Wed, 24 Apr 2024 22:34:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 67DC916DECE; Wed, 24 Apr 2024 22:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2aPw+sag" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59CBD2942D for ; Wed, 24 Apr 2024 22:34:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713998069; cv=none; b=OtoRmLNE0ULJHqJ//vQXl9JbOBBdEIToaaW2iVFzzXbN2Ynzr/Ytv8xkiu0YZz4R8b765djppCs9I4j+P+qkhIdKqkGZpT7+K0M7N1RHdcEAd00f7Bgj9e2jsv9UQwSaALKih1hvFxeN3iFdIvsP7XRFIMZiFRzDMVV3D76qWwg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713998069; c=relaxed/simple; bh=asc2e9byBb6WbLiXPgQe7Wz0QSbFZ/SU6XAk6Ce1SYQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=SNsp/mvmPn+qVbJ4V3BUgzxE8q1UvIi+ByeGXbDPNbhUTf5VHCfZhLn7UU3X4nJ+P96VsrFgNhsg8HfYLmtJZ4JDNc7iNoHwVbRKKGxh8czk28qdfd54w+j3LkoJDAYLoj5ZFk0JDhgRCbI44KzeYX1WmYZjplTdiYafVvv4DNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2aPw+sag; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc693399655so761232276.1 for ; Wed, 24 Apr 2024 15:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1713998067; x=1714602867; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=yhZptQyvv5xokxwHGECOmJsyHAUY1E5WI4kuUHDLdOc=; b=2aPw+sagdPWEKp/sU1sHRHS9T7HuLpWdZZIq8kRxu0CmXPDZSUHA72fjfzvKhRyvco OPzdoNKs8D5FcYv/nB0yQdGg3KbtVME/zkCAxwYVgcthkWW3WBN07KN1uHN8WXJT0+kO zerUHdobFIE7uo+09+ynhiaik/inSILZmBqMop+1tzPgGM0pp4Yrhh1MI80pw5Es+nHQ NPgAmAxcpnb9LFddgL0jFQMSkQJRWfXT/UiPfkmxOcH5iYJ8AchsvjtFBont5bm4n1VP NkYfKV6Zk+lqARBhPiW3JJ5+VFG4a19yKbcyjgAKY4HTIMKsocSuOzup1zDvmQRAI/EE vL/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713998067; x=1714602867; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yhZptQyvv5xokxwHGECOmJsyHAUY1E5WI4kuUHDLdOc=; b=OvKDYEA9gg4FmCsxjLOr8iiPq3wHXWrru31s/jHfEndaHpM/ctqGlriTt4xSyBe4MX CR+hXYpLb6R2pknaM1IqzPPdX0UFdkg4p0V0HXC/lTfe9MKpRJ8gYOnjNsC4uXBwRSWd 3BriVwXroWsZ8bkzzlnoLsp88jVLlD6Jk04I1MV0JOU+ZPg/A0z/ufVFD/clNcdwIxzz vecQQEV1SWsgTn1FUs2tCYGjqIOX0teFMfkNVDMYnf5XV4xkeQrsrmnJOsNIlz2/kqMK rvWUjCoHgNgJxmGtI2cD37v+KQz0S5VbG83PabKRY9f59ORX1IxghldN5nuA6RgPldzU 943g== X-Gm-Message-State: AOJu0YyXbH/9V7/WLHrsK5FD7lEYvAb+qCfVKStee6aSGLmukHlsqxcd TG63gQvQEh9GtNemzI18Acm6TJXkn5dp2lfxRLCqjmcfQutbkm1f+/Bx9zPKxwQlAZeHrRVxE1Z wdQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:150d:b0:dc7:7ce9:fb4d with SMTP id q13-20020a056902150d00b00dc77ce9fb4dmr1279124ybu.12.1713998067469; Wed, 24 Apr 2024 15:34:27 -0700 (PDT) Date: Wed, 24 Apr 2024 15:34:26 -0700 In-Reply-To: <20240404185034.3184582-8-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240404185034.3184582-1-pbonzini@redhat.com> <20240404185034.3184582-8-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH 07/11] KVM: guest_memfd: extract __kvm_gmem_get_pfn() From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, michael.roth@amd.com, isaku.yamahata@intel.com Content-Type: text/plain; charset="us-ascii" On Thu, Apr 04, 2024, Paolo Bonzini wrote: > In preparation for adding a function that walks a set of pages > provided by userspace and populates them in a guest_memfd, > add a version of kvm_gmem_get_pfn() that has a "bool prepare" > argument and passes it down to kvm_gmem_get_folio(). > > Populating guest memory has to call repeatedly __kvm_gmem_get_pfn() > on the same file, so make the new function take struct file*. > > Signed-off-by: Paolo Bonzini > --- > virt/kvm/guest_memfd.c | 38 +++++++++++++++++++++++--------------- > 1 file changed, 23 insertions(+), 15 deletions(-) > > diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c > index 486748e65f36..a537a7e63ab5 100644 > --- a/virt/kvm/guest_memfd.c > +++ b/virt/kvm/guest_memfd.c > @@ -540,33 +540,29 @@ void kvm_gmem_unbind(struct kvm_memory_slot *slot) > fput(file); > } > > -int kvm_gmem_get_pfn(struct kvm *kvm, struct kvm_memory_slot *slot, > - gfn_t gfn, kvm_pfn_t *pfn, int *max_order) > +static int __kvm_gmem_get_pfn(struct file *file, struct kvm_memory_slot *slot, > + gfn_t gfn, kvm_pfn_t *pfn, int *max_order, bool prepare) I genuinely don't know what it means to "prepare" a guest_memfd. I see it becomes if (!prepare) fgp_flags |= FGP_CREAT_ONLY; but I find the name "prepare" to be extremely unhelpful.