Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp385189lqc; Thu, 7 Mar 2024 23:37:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUoTXCGBZiEsem+TVLXqZg+rIzR1HKcfg8wfWHd9hSAj2xxQrtcWI8or9lT8e7KdxYjhOiZAeCIYeaO1RMZEZNQSEbjgH/J2/JcEM/3XA== X-Google-Smtp-Source: AGHT+IEf89KNsGQdUQ/iplMJYR+sZHBQjn1jSyUIx/laA7LdhNQv0vTh/2vpz0epxw6g94f0jFTb X-Received: by 2002:a67:b607:0:b0:472:ee80:60d9 with SMTP id d7-20020a67b607000000b00472ee8060d9mr7115530vsm.22.1709883436421; Thu, 07 Mar 2024 23:37:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709883436; cv=pass; d=google.com; s=arc-20160816; b=KFjtn6lXu05ufsJyyAyNLpFJ+tWwGIsLaXvHZhZV7+c+mpSNINnUcrUm97bBv8oziu 19UYXZhKj5DFZAjf2jRSq3iVu8gMrZTBxrfq3owjEhkvCSjbvkZuJXYgcHA22BAz71vL DUw6DLNTQUs3C6AajtViip/OB1oQ8lNlgN/0RUDJbnwsf52h7H+33L0gm/VnTv4yG5vI IU8VxuJB4Ga8e1uGPkG1nu+XHBm+Dmw1yxrkyL0z1s6ExZnyKyxxNVBYDctGe9JUe3r8 VX06Jvev6kafpYH6TC7V5pxDTDEbJFHo9ty7bbTHLTvlODSWot3hM3sPqV3UAwzkcZX6 kdZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=fJxiJxSgXj6C6SJgkGASSAuteYsxedM6y422cNmCuvQ=; fh=8scsGQn+hJ1HvbMI23kGOdGh/wtWpH4wdCi8Q1zCFc4=; b=S0VVV3TJWcIM0YbAzNAqplccqsrdEEPanr9tWIkecmwsxlSRZGM5i0lLk4osiTxBft X6gV29nyZAsMCzRT4yroqRMONDsm5waGuBtAlwpxM+tQ+DebHPEq0py739qLf1r1QCKK kY7oiWOfI7p227R8zk1r7h9yRhRAkQVA4ti1ULNvPbu3sqR29G/GyCsKWHwOu6RYTEHJ hlM+PsskIwQ/THsLD+I+WUAdi8767KwbQ4q6rXJTxV/JYz26mLhLiZ0pX1JYAcZS0pRO vC0nGRg+7/cRGs4ERrnksRGgW83On0t2qY/ut4W+MCAD/l7NXXhzwFatFQpzs0EUfJ6/ cJZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HqwbC9Yf; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-96590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k12-20020ad45bec000000b0068fe4f0982fsi18710443qvc.156.2024.03.07.23.37.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 23:37:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HqwbC9Yf; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-96590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 897E11C215F0 for ; Fri, 8 Mar 2024 07:37:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A537F4F897; Fri, 8 Mar 2024 07:36:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="HqwbC9Yf" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 240EC4F1FB; Fri, 8 Mar 2024 07:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709883417; cv=none; b=IbV7AHb/VXjcBItI8Af0q4FmK4mJIj7SgHYMzjLKRuHIyuZdZizsWjn+eFQrbJsK/X83pLRLKht44iKsgMqtzMRxWgW0RxbDyZl+TYPrtLKna56nA72+zP2Ychspp2baNDy/qF9g5EufiKA9h2gveOH8lsFAntWwiyVsGLfuGN4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709883417; c=relaxed/simple; bh=q54CEwR1ccTp6ApwGLg7vchnUylayo5XvRfKnbSfVzY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RdDq4xTlyJ6pnQ6tPgdbIuWgo8yf/+TiIs01c0004oZSrnRbM29JFg1gpQbl9m39lANj66SgfuGjgC/t/nGyqmvhyCFaHEUTklgqMZ6mOHSZHcc3dI4PFd8NpY2RGmpQ6+8bkorieKlxR8ZkjouTNat2rJ68mlsqWOe8ky9U6wE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=HqwbC9Yf; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709883416; x=1741419416; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=q54CEwR1ccTp6ApwGLg7vchnUylayo5XvRfKnbSfVzY=; b=HqwbC9YfYrR2Fk1EbdGAkdl0cPf9nfPqsbqfvqjMx2nhflD6tYKj+rlF 99fvO/H48Z7jTI4e46u2cTeDHgk3GjJO58IDHrUxArRoOYko5VWTd44mW 5pdGAB4C50qtPqhGUU4/J4ZVKC9jL96g4Q67COFQ9cr3FFpRkeoId24Tk GG1O3UH1mqq2NRdmp6B2xmu93ZJuRQZ3YeCDyI+WJHSsXnIvGltuav9aM gmYu+GUqKKTvZIY3kmMKTdr8cmqgCCMLnq1/fJJ+WJWZ1mI8qpSiCnMKP Vmw+UMdd+CvAD6wUEn4KgRuUq64QDhpPz87kJLj8QRMm/uP6c+B9wkABF w==; X-IronPort-AV: E=McAfee;i="6600,9927,11006"; a="16024647" X-IronPort-AV: E=Sophos;i="6.07,108,1708416000"; d="scan'208";a="16024647" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 23:36:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,108,1708416000"; d="scan'208";a="15049243" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.124.242.47]) ([10.124.242.47]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2024 23:36:48 -0800 Message-ID: Date: Fri, 8 Mar 2024 15:36:43 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v19 002/130] x86/virt/tdx: Move TDMR metadata fields map table to local variable To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com References: <44d9530187b4b0b1c05e150fa73fe22ab54fc911.1708933498.git.isaku.yamahata@intel.com> From: Binbin Wu In-Reply-To: <44d9530187b4b0b1c05e150fa73fe22ab54fc911.1708933498.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2/26/2024 4:25 PM, isaku.yamahata@intel.com wrote: > From: Kai Huang > > The kernel reads all TDMR related global metadata fields based on a > table which maps the metadata fields to the corresponding members of > 'struct tdx_tdmr_sysinfo'. Currently this table is a static variable. > > But this table is only used by the function which reads these metadata > fields and becomes useless after reading is done. Change the table > to function local variable. > > Signed-off-by: Kai Huang > Signed-off-by: Isaku Yamahata Reviewed-by: Binbin Wu > --- > arch/x86/virt/vmx/tdx/tdx.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c > index 2aee64d2f27f..cdcb3332bc5d 100644 > --- a/arch/x86/virt/vmx/tdx/tdx.c > +++ b/arch/x86/virt/vmx/tdx/tdx.c > @@ -301,17 +301,16 @@ struct field_mapping { > { .field_id = MD_FIELD_ID_##_field_id, \ > .offset = offsetof(struct tdx_tdmr_sysinfo, _member) } > > -/* Map TD_SYSINFO fields into 'struct tdx_tdmr_sysinfo': */ > -static const struct field_mapping fields[] = { > - TD_SYSINFO_MAP(MAX_TDMRS, max_tdmrs), > - TD_SYSINFO_MAP(MAX_RESERVED_PER_TDMR, max_reserved_per_tdmr), > - TD_SYSINFO_MAP(PAMT_4K_ENTRY_SIZE, pamt_entry_size[TDX_PS_4K]), > - TD_SYSINFO_MAP(PAMT_2M_ENTRY_SIZE, pamt_entry_size[TDX_PS_2M]), > - TD_SYSINFO_MAP(PAMT_1G_ENTRY_SIZE, pamt_entry_size[TDX_PS_1G]), > -}; > - > static int get_tdx_tdmr_sysinfo(struct tdx_tdmr_sysinfo *tdmr_sysinfo) > { > + /* Map TD_SYSINFO fields into 'struct tdx_tdmr_sysinfo': */ > + const struct field_mapping fields[] = { > + TD_SYSINFO_MAP(MAX_TDMRS, max_tdmrs), > + TD_SYSINFO_MAP(MAX_RESERVED_PER_TDMR, max_reserved_per_tdmr), > + TD_SYSINFO_MAP(PAMT_4K_ENTRY_SIZE, pamt_entry_size[TDX_PS_4K]), > + TD_SYSINFO_MAP(PAMT_2M_ENTRY_SIZE, pamt_entry_size[TDX_PS_2M]), > + TD_SYSINFO_MAP(PAMT_1G_ENTRY_SIZE, pamt_entry_size[TDX_PS_1G]), > + }; > int ret; > int i; >