Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp569773lqb; Thu, 14 Mar 2024 22:50:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXC6lCID+Feq4+Pi/R5zNix6vLvqtw4yC3JvYhctpHGU0tXq/FkTeHfPQTsJ6xLZRH6EIBaNnB1sGp1Bx7Hm2p0CytPOGl4mLs/D1QBvQ== X-Google-Smtp-Source: AGHT+IH9zmcotHqjLa/i84qi8XH/euNSmCCtzrjEH/220zyv1hztfyp6SmKWwcMdd+oXjsBwFIjJ X-Received: by 2002:a05:6402:3cf:b0:568:32f7:6c55 with SMTP id t15-20020a05640203cf00b0056832f76c55mr2211675edw.9.1710481855578; Thu, 14 Mar 2024 22:50:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710481855; cv=pass; d=google.com; s=arc-20160816; b=JlImWCLsPpH4UWUxnPq1nMPdVk7FypSQ9D2sNWZmu1X+qOHmSUICNuzTgM+37oQPKS 3/66Qoh/9/FpixeDGfX9JQNaV2nsurcynomzt6ooMHL/Zq7iUtwYmu0Jtg6+JgZTMR2L 6y3VJbWpOj3ioLkn+NpubqfzSJwnlBUkf9tRF4nKV4HPIDcC0nzY2BGxj+oC/7xWkXki dy8/Ud5jRzWA1TebOpo4iXcBQ5wkP5+Ov5bbKV0XAkiB1YtZUOINZDIrfZLepXHN2pmY Da3FRpj3vz+eIouP4u7bASdr4MapFrxXKJ6pdp+t73b9gtP+LPAsHaMkl2puRLGcwARe 4NvQ== 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 :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=WddErQ8AcYOtrycZlcgtmeQocmkx62z3FUxlABwbmfI=; fh=Q+PaQKTtdPpBazKFZIyTEk53HRfv8XL8EpalWFI2+CA=; b=LzgBjbGeeQv5iGcxy8p17Af08UJ0Pr+AQbS+JHYBq1AmkwJxrkydt2OcvWissiETae uI2CUJYEHX5urX5EvZ/t8HL5EmSLzsH4We+Ki358ADPw5Pkpzfu1mWFmocT24YIKHl2m geALnRCAoZfmvvBBvGo03DpbIn14oEb0llpINaPJdLSP6pb70oS+Q51RjO1Mt5Lkc4pF Q87+S5qD0mUs/ZG4iHllcLvkYs0cr5afNnstGN/yzKqC9dqqXJ7MO0GWDFEdTA25o0uj Louot1kyqOv0I4VvILFdZ1KU4xzndlEwm3D1N3A3e/6woGs09JRmswQJXTqrkqf2xWR3 hVTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fkqJJJwX; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-104072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104072-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b15-20020a056402350f00b0056830068410si1492470edd.72.2024.03.14.22.50.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 22:50:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fkqJJJwX; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-104072-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104072-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 500561F22D99 for ; Fri, 15 Mar 2024 05:50:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0FAD412E71; Fri, 15 Mar 2024 05:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fkqJJJwX" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.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 6CE4B12B6C; Fri, 15 Mar 2024 05:50:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481848; cv=none; b=hX3XG8fuJKnizSSehWgRjPnKDTUi4b2a3+bEepWW0kE1UO7+fKkw44u5JgPGxC8FDnLoujbfAqN2/WEsKR8qjmDrgxidcZErxuRhFA5XL2uGjOU09mR0T+MSxG7owmomJPKSw75sZLnX6iFARHE3rLkj4zfr7SGFsk0SLXHdmHU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710481848; c=relaxed/simple; bh=S0iZ55C9l1m73RLehXEmJUqcuecM8ZpLpZ+1VMipxEQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iLAY6zAVtm/TIB2UxQpY+FrqFR34MHw7sfClmjbN3pkn4qAnlio9oCF5rlIU/PnxaO222o0R8cFF2oZuI+aY2EJs+8EKFLJOQSsdTg1T7GN0EJv7AGC8tehihVSXqpcau5cfYAsExqgJ2VHuBOxznUHHIlf9Lzh8MpOqUqozDgg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fkqJJJwX; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710481847; x=1742017847; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=S0iZ55C9l1m73RLehXEmJUqcuecM8ZpLpZ+1VMipxEQ=; b=fkqJJJwXvlaVl0FT8YL7aiQ5q3jF1xKTUpEJItAvwm9WuygOw4t5caw7 SfKhgF/gb0f2xpGpk+ue/IATpPBk3kexrMnEmQ4gC0BvHAbXJMEubdBMQ zn1H3Pw8uPd9BSnvCRNDw8v0BSimvqJzrwo44EFJH04ESJYpoWeFYueI1 zhnFxfRBTDMnmNehZnqZqXEZ7STSOMmD41CV8Q6pjUQ2rTHGv1MFjxAyi vB8mMwYPA8r6hl8c0t1r7JAuNkoRRaKfOpbKjzW+x7pAw4oCcoDZLhsjN +3mSRm/wpFwk5iZtEANBXfQxg2v8gJ1nPMZsJ+JAWbObZzHnbOZBJWf+2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11013"; a="9118242" X-IronPort-AV: E=Sophos;i="6.07,127,1708416000"; d="scan'208";a="9118242" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 22:50:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,127,1708416000"; d="scan'208";a="17284036" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.125.243.127]) ([10.125.243.127]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Mar 2024 22:50:42 -0700 Message-ID: <0f20ffa7-63ac-4af2-8293-447dcae45eb7@intel.com> Date: Fri, 15 Mar 2024 13:50:38 +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 034/130] KVM: TDX: Get system-wide info about TDX module on initialization Content-Language: en-US To: "Huang, Kai" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Yamahata, Isaku" Cc: "Zhang, Tina" , "Yuan, Hang" , "seanjc@google.com" , "Chen, Bo2" , "sagis@google.com" , "isaku.yamahata@gmail.com" , "Aktas, Erdem" , "pbonzini@redhat.com" References: <15a13c5d-df88-46cf-8d88-2c8b94ff41ff@intel.com> <10c41a88-d692-4ff5-a0c3-ae13a06a055c@intel.com> <078ed2b1c3681c6c0ada9106d481d2f7d964815a.camel@intel.com> From: Xiaoyao Li In-Reply-To: <078ed2b1c3681c6c0ada9106d481d2f7d964815a.camel@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/15/2024 1:39 PM, Huang, Kai wrote: > On Fri, 2024-03-15 at 13:11 +0800, Li, Xiaoyao wrote: >>> Here is what Isaku can do using the current API: >>> >>>   u64 num_cpuid_config; >>  > >>> >>>   ... >>> >>>   tdx_sys_metadata_field_read(NUM_CPUID_CONFIG, &num_cpuid_config); >>> >>>   tdx_info = kzalloc(calculate_tdx_info_size(num_cpuid_config), ...); >>> >>>   tdx_info->num_cpuid_config = num_cpuid_config; >> >> Dosen't num_cpuid_config serve as temporary variable in some sense? > > You need it, regardless whether it is u64 or u16. > >> >> For this case, it needs to be used for calculating the size of tdx_info. >> So we have to have it. But it's not the common case. >> >> E.g., if we have another non-u64 field (e.g., field_x) in tdx_info, we >> cannot to read it via >> >> tdx_sys_metadata_field_read(FIELD_X_ID, &tdx_info->field_x); >> >> we have to use a temporary u64 variable. > > Let me repeat below in my _previous_ reply: > > " > One example that the current tdx_sys_metadata_field_read() doesn't quite fit is > you have something like this: > > struct { > u16 whatever; > ... > } st; > > tdx_sys_metadata_field_read(FIELD_ID_WHATEVER, &st.whatever); > > But for this use case you are not supposed to use tdx_sys_metadata_field_read(), > but use tdx_sys_metadata_read() which has a mapping provided anyway. > " tdx_sys_metadata_read() is too complicated for just reading one field. Caller needs to prepare a one-item size array of "struct tdx_metadata_field_mapping" and pass the correct offset. > So sorry I am not seeing a real example from you. >