Re: [PATCH v6 12/21] x86/virt/tdx: Add placeholder to construct TDMRs to cover all TDX memory regions

From: Andi Kleen
Date: Thu Oct 27 2022 - 11:31:34 EST



+/* Calculate the actual TDMR_INFO size */
+static inline int cal_tdmr_size(void)
+{
+ int tdmr_sz;
+
+ /*
+ * The actual size of TDMR_INFO depends on the maximum number
+ * of reserved areas.
+ */
+ tdmr_sz = sizeof(struct tdmr_info);
+ tdmr_sz += sizeof(struct tdmr_reserved_area) *
+ tdx_sysinfo.max_reserved_per_tdmr;


would seem safer to have a overflow check here.