[PATCH] KVM: TDX: Remove redundant __GFP_ZERO

Qianfeng Rong posted 1 patch 1 month, 3 weeks ago
arch/x86/kvm/vmx/tdx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] KVM: TDX: Remove redundant __GFP_ZERO
Posted by Qianfeng Rong 1 month, 3 weeks ago
Remove the redundant __GFP_ZERO flag from kcalloc() since kcalloc()
inherently zeroes memory.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
 arch/x86/kvm/vmx/tdx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index 573d6f7d1694..c44c8f0a4190 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -2483,7 +2483,7 @@ static int __tdx_td_init(struct kvm *kvm, struct td_params *td_params,
 	/* TDVPS = TDVPR(4K page) + TDCX(multiple 4K pages), -1 for TDVPR. */
 	kvm_tdx->td.tdcx_nr_pages = tdx_sysinfo->td_ctrl.tdvps_base_size / PAGE_SIZE - 1;
 	tdcs_pages = kcalloc(kvm_tdx->td.tdcs_nr_pages, sizeof(*kvm_tdx->td.tdcs_pages),
-			     GFP_KERNEL | __GFP_ZERO);
+			     GFP_KERNEL);
 	if (!tdcs_pages)
 		goto free_tdr;
 
-- 
2.34.1
Re: [PATCH] KVM: TDX: Remove redundant __GFP_ZERO
Posted by Sean Christopherson 1 month, 2 weeks ago
On Fri, 08 Aug 2025 15:45:32 +0800, Qianfeng Rong wrote:
> Remove the redundant __GFP_ZERO flag from kcalloc() since kcalloc()
> inherently zeroes memory.

Applied to kvm-x86 vmx, thanks!

[1/1] KVM: TDX: Remove redundant __GFP_ZERO
      https://github.com/kvm-x86/linux/commit/7cbb14d361bd

--
https://github.com/kvm-x86/linux/tree/next
Re: [PATCH] KVM: TDX: Remove redundant __GFP_ZERO
Posted by Huang, Kai 1 month, 3 weeks ago
On Fri, 2025-08-08 at 15:45 +0800, Qianfeng Rong wrote:
> Remove the redundant __GFP_ZERO flag from kcalloc() since kcalloc()
> inherently zeroes memory.
> 
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
>  arch/x86/kvm/vmx/tdx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> index 573d6f7d1694..c44c8f0a4190 100644
> --- a/arch/x86/kvm/vmx/tdx.c
> +++ b/arch/x86/kvm/vmx/tdx.c
> @@ -2483,7 +2483,7 @@ static int __tdx_td_init(struct kvm *kvm, struct td_params *td_params,
>  	/* TDVPS = TDVPR(4K page) + TDCX(multiple 4K pages), -1 for TDVPR. */
>  	kvm_tdx->td.tdcx_nr_pages = tdx_sysinfo->td_ctrl.tdvps_base_size / PAGE_SIZE - 1;
>  	tdcs_pages = kcalloc(kvm_tdx->td.tdcs_nr_pages, sizeof(*kvm_tdx->td.tdcs_pages),
> -			     GFP_KERNEL | __GFP_ZERO);
> +			     GFP_KERNEL);
>  	if (!tdcs_pages)
>  		goto free_tdr;
>  

Reviewed-by: Kai Huang <kai.huang@intel.com>