From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 03F4B258CE5 for ; Wed, 1 Jul 2026 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782914441; cv=none; b=CgnzU6VvFkvPAG6cYZURr5kErlKMDlHJPBJ1koUccy27iCJuYjL3BfJekAlG0wD7PGcQkoiyTVqTxz0KrtANkDVzgW7Le4Z0AAGqstT9jmN49/rOwgul+sqfY77nXCQLyXszhr+Wpb520nVlpnh9bgin75L2q24sIwxl/PV2gB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782914441; c=relaxed/simple; bh=4+CF4D06wokhU4O+NifMVK8cQYxNVxqRt/1c9XuJGcg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Xd4waKhJsXNxJigybFXwixvXtFAzC5LzME0x03TQZMXXwE7g5F2SE8GP2POyQXbREHoc73DNPhCjgrVbn80S7p72zFouNKOE/WqNJ5yCgGt39hlaqHI5w5cA66OWT6Y3A9rUEncjz55y9M0WCIQQDPuErpAydhWjngOy8QfFi1k= 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=lFJ0HTbs; arc=none smtp.client-ip=209.85.215.202 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lFJ0HTbs" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c88aab7c1fcso523352a12.3 for ; Wed, 01 Jul 2026 07:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1782914439; x=1783519239; darn=lists.linux.dev; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=mXus0JUDYxgkQTMchRIbdr+tq1wNp1blaxpaHfy1IqU=; b=lFJ0HTbs/gmqrxeKxEJIwIG9eN30KEmpkFfIduvIbY887eEnkSJSjWVFch/9flKcik cUwqRgeDSQCIOUSY/LoWTdb6EWf2MlTB0o/rq9T1x/Yx6lA6UA8dbXsR8+jajCyKjICb NwP45kPgaq0c30nrnIsRIdv8J/HVfi40IxZM/ibjn1qRp/ae3Y2LgvtUOkR2lBOasbR3 aX2t+XuBSnAWNZuGHbVFwKPYDl3DmYNv4pQPhhjMTdbSgikv6YWN7Aa7a8vl41zG5PKi /H0vvkiDWV8xV7vcZX9NTJlE5ZK1Cjir3SN4qo5SbwfzaxzjbaEF6swqZdZJXrtEYe8n G4Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782914439; x=1783519239; 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=mXus0JUDYxgkQTMchRIbdr+tq1wNp1blaxpaHfy1IqU=; b=Zn6UiprvttwBxpNuS2HyN0vQRrr8bjazIPR750LrPlg4tojx1FIE9cDduhrdp/iH6Z Rk3yjXhUUW39/x1L/PcoYVo5UChhf+7k/vuW9PGBnVLmmIiXkI2iNGS6ayPWRiH4y2c6 ekrntdi/eEtxLnKuiD+3yXCA7gvolKJSV0Vt9eTpsxz4OhFWNaM5GII8lSompnF8my/r ljLWey5T8tM8DStYEqr4/O/2295X7UbLdKjoym/BBc3N6xRbB02gS6gLBHIi/KpwcUCP seghzDHH/etCU7ykCyx0YBSJ1jukGTiPLpHcLlpXjzM/KcPbAKUvpKnwRz4I3DKipNpQ eV/w== X-Forwarded-Encrypted: i=1; AFNElJ8t/T1uGPKoXRapSWd29YydC0VjcGEEkEHIr9pgnyOnMxWwgThmGRM6Yuvpgnkb15upGIUIhvnhrLa/@lists.linux.dev X-Gm-Message-State: AOJu0Yxei1aujXCvwoU5F7cEVIY++chvKo6YY2W8R+IZQWoWdQcgBwK/ cvroVZOCSgNlXojqk2F59i6WUo5xEEwzu2JqaQyhbqg2qkii2Q/Foo+F6nXujUupvy4k3LBXT5S IKD04wA== X-Received: from pgbcq12.prod.google.com ([2002:a05:6a02:408c:b0:c99:a30a:7619]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:6a20:b0:3bf:a1e5:ff62 with SMTP id adf61e73a8af0-3bfed592b05mr1757052637.47.1782914438635; Wed, 01 Jul 2026 07:00:38 -0700 (PDT) Date: Wed, 1 Jul 2026 07:00:37 -0700 In-Reply-To: <81caa42d-9d07-4bed-892d-c24e0b298a1d@intel.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260521-tdx-selftests-v13-v13-0-6983ae4c3a4d@google.com> <20260521-tdx-selftests-v13-v13-13-6983ae4c3a4d@google.com> <81caa42d-9d07-4bed-892d-c24e0b298a1d@intel.com> Message-ID: Subject: Re: [PATCH v13 13/22] KVM: selftests: Set first memory region as shared if guest_memfd From: Sean Christopherson To: Xiaoyao Li Cc: Ackerley Tng , Lisa Wang , Andrew Jones , Binbin Wu , Chao Gao , Chenyi Qiang , Dave Hansen , Erdem Aktas , Ira Weiny , Isaku Yamahata , Kiryl Shutsemau , linux-kselftest@vger.kernel.org, Paolo Bonzini , "Pratik R. Sampat" , Reinette Chatre , Rick Edgecombe , Roger Wang , Ryan Afranji , Sagi Shahar , Shuah Khan , Oliver Upton , Jeremiah McReynolds , kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, x86@kernel.org Content-Type: text/plain; charset="us-ascii" On Wed, Jul 01, 2026, Xiaoyao Li wrote: > On 7/1/2026 2:18 AM, Ackerley Tng wrote: > > > > I think this patch should fully buy into in-place conversions, so we > > > > need to also set GUEST_MEMFD_FLAG_MMAP: > > > > > > > > @@ -483,6 +483,7 @@ struct kvm_vm *__vm_create(struct vm_shape shape, > > > > u32 nr_runnable_vcpus, > > > > { > > > > u64 nr_pages = vm_nr_pages_required(shape.mode, nr_runnable_vcpus, > > > > nr_extra_pages); > > > > + enum vm_mem_backing_src_type src_type = VM_MEM_SRC_ANONYMOUS; > > > > struct userspace_mem_region *slot0; > > > > u64 gmem_flags = 0; > > > > struct kvm_vm *vm; > > > > @@ -503,10 +504,16 @@ struct kvm_vm *__vm_create(struct vm_shape > > > > shape, u32 nr_runnable_vcpus, > > > > */ > > > > if (is_guest_memfd_required(shape)) { > > > > flags |= KVM_MEM_GUEST_MEMFD; > > > > - gmem_flags |= GUEST_MEMFD_FLAG_INIT_SHARED; > > > > + gmem_flags |= GUEST_MEMFD_FLAG_INIT_SHARED | GUEST_MEMFD_FLAG_MMAP; > > > GUEST_MEMFD_FLAG_INIT_SHARED is valid only when the memory attributes is > > > per-gmem. > > > > > GUEST_MEMFD_FLAG_INIT_SHARED was introduced before guest_memfd in-place > > conversions, so I think it's orthogonal to whether memory attributes is > > per-gmem. > > But before gmem in-place conversion, i.e., per-gmem attribute, > GUEST_MEMFD_FLAG_INIT_SHARED is not supported/valid for Coco VMs. > > > we need to check KVM_CAP_GUEST_MEMFD_FLAGS or kvm_has_gmem_attributes. > > I think we do want to deprecate the non-in-place-conversions setup, so > > how about inserting a TEST_REQIRE(kvm_has_gmem_attributes) here? No. Unless supporting out-of-place conversion requires orders of magnitude more effort than just supporting in-place conversion, selftests should play nice with both. > Well, then all the TDX and SNP selftest will be skipped on the kernel with > gmem_in_place_conversion=false. Exactly. They'll also be unusable on previous kernels. Deprecating per-VM PRIVATE tracking does not mean dropping support. We won't be able to drop support for years, if ever. And so from a testing perspective, we absolutely need to validate both models (again, within reason).