x86/tdx: Release private memory before private->shared conversion - #160
Conversation
There was a problem hiding this comment.
Pull request overview
This PR backports/rebases upstream Intel TDX guest changes to release accepted private pages back to the TDX “PENDING” state before performing private→shared GPA conversion, aiming to reduce failures when converting pages back to private on buggy VMMs.
Changes:
- Add new TDCALL leaf ID and TDCS config flag bit for PAGE.RELEASE support.
- Detect PAGE.RELEASE support at TDX guest setup time.
- Implement TDG.MEM.PAGE.RELEASE flow and invoke it before private→shared conversion in
tdx_enc_status_changed_phys().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| arch/x86/include/asm/shared/tdx.h | Adds constants for TDG.MEM.PAGE.RELEASE leaf ID and TDCS PAGE_RELEASE config bit. |
| arch/x86/coco/tdx/tdx.c | Detects PAGE.RELEASE support, implements page release helper, and uses it before private→shared conversion. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7e96578 to
66e794f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
arch/x86/coco/tdx/tdx.c:351
- tdx_page_release_supported is initialized once during early boot and then treated as a read-only feature flag. Marking it __ro_after_init matches the hardening pattern used for similar CC globals (e.g., cc_vendor/cc_mask in arch/x86/coco/core.c) and prevents accidental/runtime modification.
static bool tdx_page_release_supported;
arch/x86/coco/tdx/tdx.c:410
- The _tdx_release_memory() definition exceeds the kernel's typical 80-column style and is inconsistent with nearby wrapped function signatures (e.g., tdx_enc_status_changed_phys()). Please wrap the parameters to keep the declaration readable and checkpatch-friendly.
static bool _tdx_release_memory(phys_addr_t start, phys_addr_t end, phys_addr_t *cur)
{
The code is from Intel: https://lore.kernel.org/all/20260604093551.1511079-6-zhenzhong.duan@intel.com/#t https://lore.kernel.org/all/20260604093551.1511079-7-zhenzhong.duan@intel.com/ I rebased the code to the OHCL branch product/hcl-main/6.18. Signed-off-by: Dexuan Cui <decui@microsoft.com>
66e794f to
4b85081
Compare
Chris Oo (chris-oo)
left a comment
There was a problem hiding this comment.
This looks reasonable to me. I assume we will drop these commits once we take a new kernel release and upstream has merged them? Have they merged in upstream?
Intel hasn't upstreamed the change yet. I suppose Intel will upstream the change some day, but there is no ETA yet. Once Intel upstreams the change, we will drop the commit once we take a new kernel version that has this change from Intel. |
|
BTW, the patch has been used by the host team for quite a while and they haven't seen any issues. |
dd0ee2f
into
microsoft:product/hcl-main/6.18
The code is from Intel:
https://lore.kernel.org/all/20260604093551.1511079-6-zhenzhong.duan@intel.com/#t https://lore.kernel.org/all/20260604093551.1511079-7-zhenzhong.duan@intel.com/
I rebased the code to the OHCL branch product/hcl-main/6.18.