Yes. As you described above, TDX module does when assining a page to a private+}Is it really necessary to clear the reclaimed page using MOVDIR64?
+
+static int tdx_reclaim_page(unsigned long va, hpa_t pa, bool do_wb, u16 hkid)
+{
+ struct tdx_module_output out;
+ u64 err;
+
+ err = tdh_phymem_page_reclaim(pa, &out);
+ if (WARN_ON_ONCE(err)) {
+ pr_tdx_error(TDH_PHYMEM_PAGE_RECLAIM, err, &out);
+ return -EIO;
+ }
+
+ if (do_wb) {
+ err = tdh_phymem_page_wbinvd(set_hkid_to_hpa(pa, hkid));
+ if (WARN_ON_ONCE(err)) {
+ pr_tdx_error(TDH_PHYMEM_PAGE_WBINVD, err, NULL);
+ return -EIO;
+ }
+ }
+
+ tdx_clear_page(va);
According to the TDX module spec, when add a page to TD, both for control
structures and TD private memory, during the process some function of the
TDX module will initialize the page using binding hkid and direct write
(MOVDIR64B).
So still need to clear the page using direct write to avoid integrity error
when re-assign one page from old keyid to a new keyid as you mentioned in
the comment?
hkid. i.e. TDH.MEM.PAGE.{ADD, AUG}. But when re-assigning a page from an old
private hkid to a new _shared_ hkid, i.e. TDH.MEM.PAGE.REMOVE or
TDH.PHYMEM.PAGE.RECLAIM, TDX module doesn't.