From nobody Mon Feb 9 15:27:13 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 1CA4D33DEE3 for ; Thu, 29 Jan 2026 01:16:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769649379; cv=none; b=BH5anuldInszgt0JK4akGW6Hk2zJRaBviOHIAUtj50UdOC1qeeazAbFxjyRc9jh0vls9BiSwfaRSxQ4gQwqYWnb+Ql/mALx/ezFPq5qunQk7Sf7h2AVW85EsNaEjlUC3Hg9hy5AOShwh9kbcjEhHInzRaRIWVe479SBxBiZNTzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769649379; c=relaxed/simple; bh=2AFN/urgPi8sHxS0ED+9ecVsZaZqGadZaHDApgUZnpM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AoEWOOE7xzGDcEmh1tIR/0iULpaciMYXbzf1W+3AClY3zoDm3ZGVe/JBP+qeSF0lvaQqQx4Y05faBjjyYo1QN09zg4V3GFc1aZQ8iSNbaB+NkfPm+bjNKilJNnm5GwdgmLN2HAUaOdl/Cq1f5WF8SnkNVtpe44bih2eTKtZkkOI= 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=eaVBYD+0; arc=none smtp.client-ip=209.85.216.73 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="eaVBYD+0" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-34c6e05af6fso309000a91.1 for ; Wed, 28 Jan 2026 17:16:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769649377; x=1770254177; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=80B6pHXYnPFCaLMTncYxaAMN7FbDOTiyI0xEQDWm1fU=; b=eaVBYD+0n6Ge25BC3ApptZtLTjnLI5TOcJm7WWj03lkKmIyYze7yhM4BVhah0PXQN/ j0QU8O9nhV/ZkwKKkoPbzaFEj4EhkiNmHMqs7m9N7ey/+bCYffpxlkmVEk55STy1p2EK 2xJ011t+ec7KS0PS/hPxuzWhSV7QaukJLyOuJ+fL4IHzMfvEvBr/RjoVB+nIALURK5z5 c3pREQMMAvaAFIh98VyTjtO86rev/+lrIYhmjr97q4vQ4H0gtribkooM6NFElFo8Hkat TAvJR6hHJwb8s6q8CKQdZ3qRH5Ce3l8pOtbCg6m2xqKh7PkO12ijpThBWO1y/sO/FbSH L2ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769649377; x=1770254177; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=80B6pHXYnPFCaLMTncYxaAMN7FbDOTiyI0xEQDWm1fU=; b=C03yiyr1jfxc1Dc40vN7tB/EQTOtHT4HgAVY74RkKQYM/bKZYi1oief5mSnD+AEvXd QFDSc0v2IEpjA66jTkQsfxkGPi2XtmPnPL4HKhybL6miWaLEjTWv1x2AdTFxLUfwCFL7 YHLnOqPklJ0FVvDxrnXdAYYb0bsxrlV3OBOka6I+frtbdbiUKaN4VGmTKpTaW1tEcI9o CvoOZI9XpqWj3YjI06+bT6d/tZp5VVjwkWOyTfhgeeKLyzHVm03xaCt8pomduHQf46ju 2yINVChu1o5LuPjBoiG5cK+ip3fh0Nl8LkFSzztTqSY0Oo0u8Wa03cyVoaOqxeJcdtX5 NVGA== X-Gm-Message-State: AOJu0YzmRTDdgjbio+HBPGbQV+Sb2zXKeLuzAGVZZc+QE83Hj28rx84/ d6GzVuqqWLv3bSmN69NiLMCyYDnyFnaRCAo50PCoED+HlO+YfMjGwwm+tW/JBXCavbrEysbyggh BKFbHpA== X-Received: from pjbos4.prod.google.com ([2002:a17:90b:1cc4:b0:34a:c87f:a95a]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:c88c:b0:340:9cf1:54d0 with SMTP id 98e67ed59e1d1-353fecca19emr6398135a91.1.1769649377470; Wed, 28 Jan 2026 17:16:17 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 28 Jan 2026 17:14:58 -0800 In-Reply-To: <20260129011517.3545883-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260129011517.3545883-1-seanjc@google.com> X-Mailer: git-send-email 2.53.0.rc1.217.geba53bf80e-goog Message-ID: <20260129011517.3545883-27-seanjc@google.com> Subject: [RFC PATCH v5 26/45] x86/virt/tdx: Enhance tdh_mem_page_aug() to support huge pages From: Sean Christopherson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, Kiryl Shutsemau , Sean Christopherson , Paolo Bonzini Cc: linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, kvm@vger.kernel.org, Kai Huang , Rick Edgecombe , Yan Zhao , Vishal Annapurve , Ackerley Tng , Sagi Shahar , Binbin Wu , Xiaoyao Li , Isaku Yamahata Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yan Zhao Enhance the SEAMCALL wrapper tdh_mem_page_aug() to support huge pages. The SEAMCALL TDH_MEM_PAGE_AUG currently supports adding physical memory to the S-EPT up to 2MB in size. While keeping the "level" parameter in the tdh_mem_page_aug() wrapper to allow callers to specify the physical memory size, introduce the parameters "folio" and "start_idx" to specify the physical memory starting from the page at "start_idx" within the "folio". The specified physical memory must be fully contained within a single folio. Invoke tdx_clflush_page() for each 4KB segment of the physical memory being added. tdx_clflush_page() performs CLFLUSH operations conservatively to prevent dirty cache lines from writing back later and corrupting TD memory. Signed-off-by: Xiaoyao Li Signed-off-by: Isaku Yamahata Signed-off-by: Yan Zhao [sean: remove the page+folio assumptions] Signed-off-by: Sean Christopherson --- arch/x86/virt/vmx/tdx/tdx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 85c31ed9b9d1..37776ea56eb7 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -1756,9 +1756,13 @@ u64 tdh_mem_page_aug(struct tdx_td *td, u64 gpa, enu= m pg_level level, u64 pfn, .rdx =3D tdx_tdr_pa(td), .r8 =3D PFN_PHYS(pfn), }; + unsigned long npages =3D page_level_size(level) / PAGE_SIZE; + unsigned long i; u64 ret; =20 - tdx_clflush_pfn(pfn); + for (i =3D 0; i < npages; i++) + tdx_clflush_pfn(pfn + i); + ret =3D seamcall_ret(TDH_MEM_PAGE_AUG, &args); =20 *ext_err1 =3D args.rcx; --=20 2.53.0.rc1.217.geba53bf80e-goog