mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yan Zhao <yan.y.zhao@intel.com>
To: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: <pbonzini@redhat.com>, <dave.hansen@intel.com>,
	<seanjc@google.com>, <x86@kernel.org>, <kas@kernel.org>,
	<adrian.hunter@intel.com>, <binbin.wu@intel.com>,
	<xiaoyao.li@intel.com>, <chao.gao@intel.com>,
	<linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>
Subject: Re: [PATCH 1/2] x86/virt/tdx: Drop tdx_clflush_*()
Date: Wed, 23 Sep 2026 13:25:00 +0800	[thread overview]
Message-ID: <arNirJownovqY66q@yzhao56-desk.sh.intel.com> (raw)
In-Reply-To: <20260922205215.870563-2-rick.p.edgecombe@intel.com>

Reviewed-by: Yan Zhao <yan.y.zhao@intel.com>

Just some nits to the commit log. Free free to ignore.

On Tue, Sep 22, 2026 at 01:52:14PM -0700, Rick Edgecombe wrote:
> The TDX module exposes a bit (CLFLUSH_BEFORE_ALLOC) to say whether it
> requires some memory to be flushed from the cache before being handed
Drop "some"?

> to the TDX module.
> 
> During the initial TDX upstreaming, it was decided it would be simplest
> to just always flush in these cases, rather than checking for the bit and
"in these cases" is ambiguous.

> having conditional logic. So currently the kernel flushes in several
> places when handing memory to the TDX module.
>
> In practice this bit has never been set by any TDX module, so flushing
> is unneeded. Going forward the TDX docs will be updated to clarify that
"Going forward, ...".

> CLFLUSH_BEFORE_ALLOC will never be set in any future TDX module either.
> 
> So make code even simpler by just deleting all the CLFLUSH_BEFORE_ALLOC
> handling.
> 
> AI was used to review the change.
> 
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
> ---
>  arch/x86/virt/vmx/tdx/tdx.c | 23 -----------------------
>  1 file changed, 23 deletions(-)
> 
> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index 1b9ff749dd8e0..8f9d3588f200f 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
> @@ -1619,22 +1619,6 @@ static inline u64 tdx_tdr_pa(struct tdx_td *td)
>  	return page_to_phys(td->tdr_page);
>  }
>  
> -/*
> - * The TDX module exposes a CLFLUSH_BEFORE_ALLOC bit to specify whether
> - * a CLFLUSH of pages is required before handing them to the TDX module.
> - * Be conservative and make the code simpler by doing the CLFLUSH
> - * unconditionally.
> - */
> -static void tdx_clflush_page(struct page *page)
> -{
> -	clflush_cache_range(page_to_virt(page), PAGE_SIZE);
> -}
> -
> -static void tdx_clflush_pfn(kvm_pfn_t pfn)
> -{
> -	clflush_cache_range(__va(PFN_PHYS(pfn)), PAGE_SIZE);
> -}
> -
>  static int pg_level_to_tdx_sept_level(enum pg_level level)
>  {
>  	WARN_ON_ONCE(level == PG_LEVEL_NONE);
> @@ -1656,7 +1640,6 @@ u64 tdh_mng_addcx(struct tdx_td *td, struct page *tdcs_page)
>  		.rdx = tdx_tdr_pa(td),
>  	};
>  
> -	tdx_clflush_page(tdcs_page);
>  	return seamcall(TDH_MNG_ADDCX, &args);
>  }
>  EXPORT_SYMBOL_FOR_KVM(tdh_mng_addcx);
> @@ -1672,7 +1655,6 @@ u64 tdh_mem_page_add(struct tdx_td *td, u64 gpa, kvm_pfn_t pfn, struct page *sou
>  	};
>  	u64 ret;
>  
> -	tdx_clflush_pfn(pfn);
>  	ret = seamcall_ret(TDH_MEM_PAGE_ADD, &args);
>  
>  	*ext_err1 = args.rcx;
> @@ -1692,7 +1674,6 @@ u64 tdh_mem_sept_add(struct tdx_td *td, u64 gpa, enum pg_level level,
>  	};
>  	u64 ret;
>  
> -	tdx_clflush_page(page);
>  	ret = seamcall_ret(TDH_MEM_SEPT_ADD, &args);
>  
>  	*ext_err1 = args.rcx;
> @@ -1709,7 +1690,6 @@ u64 tdh_vp_addcx(struct tdx_vp *vp, struct page *tdcx_page)
>  		.rdx = vp->tdvpr_pa,
>  	};
>  
> -	tdx_clflush_page(tdcx_page);
>  	return seamcall(TDH_VP_ADDCX, &args);
>  }
>  EXPORT_SYMBOL_FOR_KVM(tdh_vp_addcx);
> @@ -1724,7 +1704,6 @@ u64 tdh_mem_page_aug(struct tdx_td *td, u64 gpa, enum pg_level level,
>  	};
>  	u64 ret;
>  
> -	tdx_clflush_pfn(pfn);
>  	ret = seamcall_ret(TDH_MEM_PAGE_AUG, &args);
>  
>  	*ext_err1 = args.rcx;
> @@ -1769,7 +1748,6 @@ u64 tdh_mng_create(struct tdx_td *td, u16 hkid)
>  		.rdx = hkid,
>  	};
>  
> -	tdx_clflush_page(td->tdr_page);
>  	return seamcall(TDH_MNG_CREATE, &args);
>  }
>  EXPORT_SYMBOL_FOR_KVM(tdh_mng_create);
> @@ -1781,7 +1759,6 @@ u64 tdh_vp_create(struct tdx_td *td, struct tdx_vp *vp)
>  		.rdx = tdx_tdr_pa(td),
>  	};
>  
> -	tdx_clflush_page(vp->tdvpr_page);
>  	return seamcall(TDH_VP_CREATE, &args);
>  }
>  EXPORT_SYMBOL_FOR_KVM(tdh_vp_create);
> -- 
> 2.55.0
> 

  reply	other threads:[~2026-09-23  5:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 20:52 [PATCH 0/2] Drop unneeded cache flushing Rick Edgecombe
2026-09-22 20:52 ` [PATCH 1/2] x86/virt/tdx: Drop tdx_clflush_*() Rick Edgecombe
2026-09-23  5:25   ` Yan Zhao [this message]
2026-09-23  7:30     ` Binbin Wu
2026-09-23  7:47   ` Tony Lindgren
2026-09-23 15:50     ` Edgecombe, Rick P
2026-09-24  4:44       ` Tony Lindgren
2026-09-23 11:58   ` Nikolay Borisov
2026-09-23 16:26     ` Edgecombe, Rick P
2026-09-23 18:07       ` Nikolay Borisov
2026-09-22 20:52 ` [PATCH 2/2] x86/virt/tdx: Drop tdh_phymem_page_wbinvd_*() Rick Edgecombe
2026-09-23  2:18   ` Xiaoyao Li
2026-09-23 16:31     ` Edgecombe, Rick P
2026-10-12 12:50       ` Xiaoyao Li
2026-09-23  5:41   ` Yan Zhao
2026-09-23 18:22     ` Edgecombe, Rick P
2026-09-23  7:09   ` Xu Yilun
2026-09-23 18:18     ` Edgecombe, Rick P
2026-09-24  9:10   ` Chao Gao
2026-09-24 18:58     ` Edgecombe, Rick P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=arNirJownovqY66q@yzhao56-desk.sh.intel.com \
    --to=yan.y.zhao@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=binbin.wu@intel.com \
    --cc=chao.gao@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=kas@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=seanjc@google.com \
    --cc=x86@kernel.org \
    --cc=xiaoyao.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®