From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (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 29EF13DE44D for ; Mon, 13 Jul 2026 15:41:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.215.176 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783957313; cv=pass; b=ct+c/6QfipC7i8HPW6Ve5M+vpfB//jTmc1/kyRVM03VMGZ3YfDToz/i/C1COjwKK79usvImk5fDhpfr2mOsyzzB7Qtc3MjUY9nhmTS9a9R15bVKZrVHSWogtb9tclwQITW0k7JjaMwW6UZa2gFFgmjQ4LMa8dg06xBxc3P6Wy4E= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783957313; c=relaxed/simple; bh=E00i/s09eU5gl2pPwex8CcCqyUvImg1zAVHPmKsPPzg=; h=From:In-Reply-To:References:MIME-Version:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZRFb8/VgfowuSh40G8LX4R1c/2M7Li46zdudzwiXChoR6LePdWGBbKUXws2d9K98/yuKfHAYBuZTCUv1olO3lXqsdMgXIKlT9qsxXVnS0K0114bcfw+dYDIvhrAsr0snuo1nrD7r/TwO93SMr9UTRETyh5XNiNQPBggQ1cB7CKk= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tPiZPN13; arc=pass smtp.client-ip=209.85.215.176 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tPiZPN13" Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-ca957432c7fso2277568a12.1 for ; Mon, 13 Jul 2026 08:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783957311; cv=none; d=google.com; s=arc-20260327; b=i0ptWS1TzB+tkkyvaKyKVKFSx1O37KlQULZDaDtmvbZvwq43YVamZuwKgfpLGyunvN w9rnJhyLaG8bSa4pXRBaSRlJ6f3Fk0TNgIcFtzghrul8eOngZzB4R0FRwZbDYY2VKCD+ SGenfi/wFkwNdyi+QAwFabOwqoZPeKl9pqDlMEGMS8p5uvIFvxsepSNhp9bs5AheqsBA pnwOkRLt+vwS28kS1CfPKwzk+jqGSDjV3gAx1V+5dbrOeA4XxY8il0lV0lDGxvwHdWkD BQhTYtsM7E+zImD2s9qZLsoxn2YjtvWeD37l94n+d+3MOHSS8suo1BSfJ2bKJrSMC3TC PcuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:dkim-signature; bh=E00i/s09eU5gl2pPwex8CcCqyUvImg1zAVHPmKsPPzg=; fh=5f1ZJjm7mVu90lepumFnkg1uOsnsUijQqk6uS/ljEPE=; b=pfgxIJpvb8jmL/c3/0nQEbSpHU6Uqa7he0Xsj0NMdBc1ypCqhjAXalCfQwPlrlb1xD gPSzEh1PflGN93UQUwbC+nZwn5gTYY9JWABzvlydUdqWttgGilMqiqvdOQvIP1HJLjUE HDHQF4vswEEBQ5+4LFI+fifPTSMamItI50Eb6q5Ggb6xPsDExupZuctHpS0UsaYXkLRZ oJN+vbDCUmSURph3uEc6Aae4rpMtKyjt7Oh0Ruot6D82tTTPUmYpb1yQO9J9IcDRBmbd eLZtT05P+LqpVzhgQDEs0neBoRpMMZHvdGD7IcSAZHofdezzaP+AflirSkYp3jsxNipV Iq+A==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783957311; x=1784562111; darn=vger.kernel.org; h=content-type:cc:to:subject:message-id:date:mime-version:references :in-reply-to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=E00i/s09eU5gl2pPwex8CcCqyUvImg1zAVHPmKsPPzg=; b=tPiZPN13/77+3dKCmRpGvEpZh+NfPB8OM9WG/fivPUw2EamGCWoOTvRprSXuBo/LtJ x59WQ2kETIgIZWE9Q/dX82uiAKVMpwnhUbK3hZObZISB1rqlAPrwAFW7wWwzXpwwjiWl 0qi3HH69x0K/lMSCdea5E0LTOH358k1zalPOepA8m8nUJgCJ9Szask7v+n3wTcYmaHgB lqbUe+H325kCcCA3EHEQKCQGR8W0sVXV3OMUe4+gFTLq2IszqWjILp5LTmaaNCCyxvmy 18YVpybQoR51XSFjf84tdQwmU7XXVhqKth3pDEk+2PPW3IQQDVADGxbtfuUUvNsoHFQ/ 9buA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783957311; x=1784562111; h=content-type:cc:to:subject:message-id:date:mime-version:references :in-reply-to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=E00i/s09eU5gl2pPwex8CcCqyUvImg1zAVHPmKsPPzg=; b=Kw5gcHO3Zlrozf4IgHHpwvFCb3XjKVJdepK2YAzMu4hssbqD8h5kgIXZOUN3Q70u9I aI/APp2TP4pZtPNLQbTGqdGMDxZN7Nm/oc6bLgclzCBCAcquUEcKXV3AsBxU71912zvU egxHWKlyWwhIHVE05LD+5ZuyamPOcnPI58QXzyBUHMN/kNynF+FTcRTkvYyOvWfAxA84 1E+kkOlgg+n4Wco/PRgSLQ2KyHLDrZ/aHW8xmVLePZnFiYCafE8eBrgfLRrTBczZpnhs 4THTTtIl9i78zaLBC+bvmi7HvrzX7+xNQXKcmgqeVAIi3eiABkiPtnANft9MYi5RwQB8 rtOw== X-Forwarded-Encrypted: i=1; AHgh+Rogp5As3zeD422XQ1NfIn1Vw2HXgAmrfbwwvQfF6fSkDqc27hRjPfFkiANYOV0jMSr2mPcl2gqupfPDJoI=@vger.kernel.org X-Gm-Message-State: AOJu0YybizSovoK3YBdQaxDp9BiwdtaLfI+u1/T2Jz+S7IblB7Zv41hR tS1aSM9YBALVHHwfoQVf5eayxiLkZnsUlgNCZ9gI6Ceotbq59RrUgmkrFgvXGUAM2fl60weLi7n x7ypIikG0BaoBe+YtxNx8qR+kXMKyDfV95JuvMazx X-Gm-Gg: AfdE7clDXwSwc1mkLN9DX/H8ws7ul/8lZCnEQei/plsqSSAb0RN2+oqZgg8MK0Jqe5d 7x08vmDaXkWum+PF7gO+OvaMunlfO/X1yxr+XHvW6tZcnNqk/9Alk6OFKz2u4Zmvh/XZl0CJWRR Q5FL4N/bSyNfeN+vi8CSqlckfjnJ6XUZ4yJNp2kASbRKaZxzRVjlw+h+/CqSVPB4Ub5rq3A4ykF v0P7XfYhEpbaGPBTH9iSBMi/xvtnqGqNUosE+j75X37LoYHuq26OTYcRawp7UfAiaLYWot5Qyyr zhxppvBALbpY+sqH0IOyJ694/zik+yea5aoTQ3Z74Fp+jItcjtbsLKpVurs1Kty6swSe X-Received: by 2002:a05:6a21:113:b0:3aa:c93b:625b with SMTP id adf61e73a8af0-3c110762fd4mr10225955637.3.1783957310978; Mon, 13 Jul 2026 08:41:50 -0700 (PDT) Received: from 176938342045 named unknown by gmailapi.google.com with HTTPREST; Mon, 13 Jul 2026 08:41:49 -0700 Received: from 176938342045 named unknown by gmailapi.google.com with HTTPREST; Mon, 13 Jul 2026 08:41:49 -0700 From: Ackerley Tng In-Reply-To: References: <20260709204948.1988414-1-seanjc@google.com> <20260709204948.1988414-19-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Mon, 13 Jul 2026 08:41:49 -0700 X-Gm-Features: AVVi8Cdlu73h_odPVr1xWZ78EcVtzZg0XBmzdD3qDpzU7-JRYgNm36lPCMQb_B4 Message-ID: Subject: Re: [PATCH v4 18/18] KVM: guest_memfd: Combine .gmem_prepare()+.gmem_invalidate() into .gmem_convert() To: Fuad Tabba , Sean Christopherson Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Roth , Hyunwoo Kim , Tom Lendacky , =?UTF-8?B?SsO2cmcgUsO2ZGVs?= Content-Type: text/plain; charset="UTF-8" Fuad Tabba writes: > > [...snip...] > Thanks for bringing [1] up, I didn't make the link when this change was being discussed. pKVM definitely needs a callback when the folio is released from guest_memfd's ownership. > > free_folio is the only to_private=false caller today, but the cover > letter sketches the other one, a private->shared conversion through > kvm_gmem_make_shared(inode, start, end). Once that lands both reach > the hook with to_private=false, and as far as I can tell, the only > thing separating them is kvm == NULL / INVALID_GPA. That isn't On the folio teardown path kvm has to be non-NULL so that SNP can find out which VM to unassign from, so you're right that INVALID_GPA won't be sufficient to separate conversion to private and teardown, for pKVM, from the arch perspective. > documented as a contract, and nothing in-tree reads it on that branch > (the kvm/gpa check is under if (to_private), and > sev_gmem_make_shared() doesn't take a kvm at all), so nothing would > catch it regressing. The sketch is also inode-scoped, so I'm not sure > the conversion path passes a non-NULL kvm at all; if it doesn't, the > two aren't distinguishable. > >> >> [...snip...] >> > > The Kconfig now couples them too: an arch can't take teardown without also > taking conversion. pKVM wants teardown and not conversion, so that's a problem > for us today, not only once the second caller lands. > > This is the same ground as v8 15/46, which ended with the two split under > separate Kconfigs. Suzuki confirmed CCA disables both; pKVM wants teardown only, > since our conversions are guest-initiated and EL2 has already done the > transition by the time the host runs the generic path [1]. > > I'd rather keep the free path on its own callback. If you want a single hook, > passing the caller explicitly instead of leaving it implied by kvm would work > too. Merging the two conversion directions is a genuine cleanup, it's the free > path I'd like to keep separate. > Is it okay if later, we add a .gmem_teardown callback with a new CONFIG flag that pKVM can use? If that's okay, this merge (of function names and of the patch series) can proceed. It's also nicer that the new callback and CONFIG are explicitly (re?)-introduced with pKVM support so the introduction is chronologically linked with pKVM support too :) > Thanks, > /fuad > > [1] https://lore.kernel.org/all/CA+EHjTwLRzrq0vY0-OosENJ2Gkknerux53aVBj0zGRQUkRQP=A@mail.gmail.com/ > >> >> [...snip...] >>