summaryrefslogtreecommitdiff
path: root/scripts/Makefile.thinlto
diff options
context:
space:
mode:
authorRick Edgecombe <rick.p.edgecombe@intel.com>2026-09-04 14:58:35 -0700
committerDave Hansen <dave.hansen@linux.intel.com>2026-09-04 15:06:02 -0700
commiteca9d4a3f1f820439453f07ce700d316c398520e (patch)
treeea35c792b12c0f821030393c87542d3e3fe72f20 /scripts/Makefile.thinlto
parent5386c5288001f00e5f2019d5f7b50c97d62f3a7b (diff)
downloadlinux-next-eca9d4a3f1f820439453f07ce700d316c398520e.tar.gz
linux-next-eca9d4a3f1f820439453f07ce700d316c398520e.zip
x86/virt/tdx: Handle multiple callers in tdx_pamt_get/put()
__tdx_pamt_get()/__tdx_pamt_put() unconditionally add or remove Dynamic PAMT (DPAMT) backing for the 2MB region covering the passed page. However, multiple callers can add or remove 4KB pages that fall within the same 2MB region and in that scenario only a single PAMT entry is required. Make the helpers handle only adding/removing DPAMT backing when required, by refcounting each 2MB range. Gate the actual DPAMT add and remove on refcount transitions (0->1 and 1->0). Serialize the refcount check and SEAMCALL with a global spinlock so the read-decide-act sequence is atomic. This also avoids TDX module BUSY errors, as the DPAMT add and remove SEAMCALLs take internal TDX module locks for the 2MB ranges of the specified PFN and the PAMT page pair PFNs. So simultaneous attempts on the same 2MB ranges of the PFNs would otherwise encounter an error, which would not be handleable in the put case. The lock is global and heavyweight. Use simple conditional logic to keep correctness obvious. This will be optimized in a later change. The dpamt_refcounts[] are atomic_t's. They do not strictly need to be because all access is protected by pamt_lock. The overhead of an atomic_t in this situation is minuscule compared to the global lock. Leave the atomic_t in place to enable future optimization with minimal churn. Since the DPAMT helpers are broadly functional now, drop the "__" to rename them tdx_pamt_get/put() and tdx_alloc/free_control_page(). Export them for use in KVM in subsequent changes. AI was used under supervision to collect/apply feedback, split patches, review code and workshop logs. Based on a patch originally by Kiryl Shutsemau. Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com> Reviewed-by: Chao Gao <chao.gao@intel.com> Reviewed-by: Yan Zhao <yan.y.zhao@intel.com> Reviewed-by: Tony Lindgren <tony.lindgren@linux.intel.com> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com> Reviewed-by: Vishal Annapurve <vannapurve@google.com> Acked-by: Sohil Mehta <sohil.mehta@intel.com> Tested-by: Hongyu Ning <hongyu.ning@linux.intel.com> Link: https://patch.msgid.link/20260904215841.303070-6-rick.p.edgecombe@intel.com
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions