From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE09CC54EBD for ; Mon, 9 Jan 2023 19:52:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C7268E0002; Mon, 9 Jan 2023 14:52:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 050348E0001; Mon, 9 Jan 2023 14:52:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E33AB8E0002; Mon, 9 Jan 2023 14:52:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CFE568E0001 for ; Mon, 9 Jan 2023 14:52:23 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8944240703 for ; Mon, 9 Jan 2023 19:52:23 +0000 (UTC) X-FDA: 80336307366.05.67C133B Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf29.hostedemail.com (Postfix) with ESMTP id E9EE812000F for ; Mon, 9 Jan 2023 19:52:20 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ANc9wa07; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf29.hostedemail.com: domain of dave.hansen@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=dave.hansen@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673293941; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0WaAPyXk1fS+Km6sNpMv6pRJdHf+4odFcqqmMwHrWuE=; b=suMsJENdYfz2xNRcCwf8bm3rMThMouomU8yCQ7LP1wkD7RkF9mN1vPAFskfN69jWJ/zj5R CqSgXS07UVtzE615sOLNN1BozSECVVIMvH24QV0QhjsuX9ry8AUt1gRyV4WYuHq2G1cK+G Ihy1wd0zKdrv1m+UPjEBpXmTw3Zp4Gc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ANc9wa07; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf29.hostedemail.com: domain of dave.hansen@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=dave.hansen@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673293941; a=rsa-sha256; cv=none; b=NrEldFGL4DTTuUqQYP56AqveRmycwMHB5wU1v9gtKaQoyherHv022uIW3liM/aph8QK1zp QlGu/KmOQMG0XoWCYvQoxl2PUyvkLApyUFdBb6hiblPBTFhz3TpCa/mBw7bWPtbhkj4bFw 1FAR1TRDluXIxF4IzccDwallQsjEQXg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673293941; x=1704829941; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=rblSatFgkQX+6uOg/BWjvl2hRNBzPB7DjbscdtDtOdQ=; b=ANc9wa07vznFT/e46LFBaEWEzvP4B9MVOdLvDSr6LC2IsCLz/aMvIaOK if3Z0OKnUr6Vlzpumlm3bc43I/w5teE90lV9C2T3MdDreI8jQ40GjIfo8 51OWK6HLflqUxqAu3EjOg9Vi+j3F9fNpGiNb4HOUzWw0CiR+SEjosaWvh jtou+y8Ut/ibnBh6GVGUYtrPX4LnpnJwjWpkX/clSDl1akX3BPp4wB6mx WReonuhQuhlYSYR64TKSLUsTWKxQAkXIch9qDBiZZX6rIxyiaGDv1xIiX RfjQSnjSuQZzREoooaP5xgr4RW8Dd1o8ETWnI2Fe8TrxklDKGPo4whx5/ Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="306481859" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="306481859" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 11:52:19 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10585"; a="985504267" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="985504267" Received: from swapnadi-mobl2.amr.corp.intel.com (HELO [10.209.29.117]) ([10.209.29.117]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 11:52:17 -0800 Message-ID: Date: Mon, 9 Jan 2023 11:52:16 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v8 06/16] x86/virt/tdx: Get information about TDX module and TDX-capable memory To: "Huang, Kai" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: "Luck, Tony" , "bagasdotme@gmail.com" , "ak@linux.intel.com" , "Wysocki, Rafael J" , "kirill.shutemov@linux.intel.com" , "Christopherson,, Sean" , "Chatre, Reinette" , "pbonzini@redhat.com" , "tglx@linutronix.de" , "linux-mm@kvack.org" , "Yamahata, Isaku" , "peterz@infradead.org" , "Shahar, Sagi" , "imammedo@redhat.com" , "Gao, Chao" , "Brown, Len" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Huang, Ying" , "Williams, Dan J" References: <7c21a3de810397901bade0b1021912bbbf2d18bd.1670566861.git.kai.huang@intel.com> Content-Language: en-US From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: E9EE812000F X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 4ggk3bh8baz66ofbyrg6jgg1uycuothb X-HE-Tag: 1673293940-48159 X-HE-Meta: U2FsdGVkX1+f2ymcDQXjCX3vOJRImtAPtnj8BEok+C3yhWOMTXPgClAFOVBcPPi/0cZWFW84CS67SuDtDHvzhyW2QiW7bBGAz8IuZYuR8SFhW/xetEUqYn/Jvtl7ZFxGaV/MitCSnDAgvf+c3RVzcFZv3e+qPqE4GbHFF98u2eeTNpZFr5oOyjQS8uxla8u2Hjw61Bbfc6Rx4rjpXTjv1dSj83Vr6+5cVPhvWRGAgObW1Foum7EdbFNbkIUTE0B6wZnILoRQHMObQJjQuQ4XxH+qqeuLz9IXrwNHnlFf022v/UO3xtoshWRqPs7itJSRAT3NU5VqNymwzTcjKDYG62Y+FXS8PXxuMZ3kIocRLOaxwPTnWbDB+hwmsaS/xqj8EKypeh/xMeqUhhrsmn4ChB3lqq7QGB5Sfk6VU82+zvV4MESvasUfc+LU86uxJr2KE4eC2N9eY0TxlEKz0IL6CUogMD5Gf25q8ap8z/v6NluRi0nX8UHiLhKu4Nt3OSOcyHAIW5DwBg2T5EIyAuTw7kssPmlpCCgjsd1Z7gvK84ZH6xjKzuDvxE49lSs+eIr1BiDMqs0MZlPAiZO3JgfdyrKgyKAhHVWhYhWHIfYMS99H21xArAxCZ0/bHdnYWdObuLrOMvn/LrnnNMZfwUwqoJDLfMDhymbwx1FFsNxDnwW0y2Vp24c+pg2RfNkL3x9iZbAqeGPSnmgGtZ7bPSAvgV25YqWxIwxW5FpdCnlO477Z2Aprn/SAg/mH/CDcAIv52ku7Fd1uhE20kVSvcuz0m5OxzHynBqEqeyKujn71d+n9R+sgAUzwSHa5wzJerfDAgbgxn0Hs9guOIza3d25RuKGdgihfltU8e2CfjOSIGflc2QTA2IPOLMmETpbhRu339RKkTNvyWoHQjzyFGU3IRg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 1/9/23 02:25, Huang, Kai wrote: > On Fri, 2023-01-06 at 09:46 -0800, Dave Hansen wrote: ... >>> Note not all members in the 1024 bytes TDX module information are used >>> (even by the KVM). >> >> I'm not sure what this has to do with anything. > > You mentioned in v7 that: >>>> This is also a great place to mention that the tdsysinfo_struct contains >>> a *lot* of gunk which will not be used for a bit or that may never get >>> used. > > https://lore.kernel.org/linux-mm/cc195eb6499cf021b4ce2e937200571915bfe66f.camel@intel.com/T/#m168e619aac945fa418ccb1d6652113003243d895 > > Perhaps I misunderstood something but I was trying to address this. > > Should I remove this sentence? If someone goes looking at this patch, the see tdsysinfo_struct with something like two dozen defined fields. But, very few of them get used in this patch. Why? Just saying that they are unused is a bit silly. The 'tdsysinfo_struct' is fairly large (1k) and contains a lot of info about the TD. Fully define the entire structure, but only use the fields necessary to build the PAMT and TDMRs and pr_info() some basics about the module. The rest of the fields will get used... (by kvm? never??) ... >>> + struct tdsysinfo_struct *sysinfo = &PADDED_STRUCT(tdsysinfo); >>> + int ret; >>> + >>> + ret = tdx_get_sysinfo(sysinfo, cmr_array); >>> + if (ret) >>> + goto out; >>> + >>> /* >>> * TODO: >>> * >>> - * - Get TDX module information and TDX-capable memory regions. >>> * - Build the list of TDX-usable memory regions. >>> * - Construct a list of TDMRs to cover all TDX-usable memory >>> * regions. >>> @@ -166,7 +239,9 @@ static int init_tdx_module(void) >>> * >>> * Return error before all steps are done. >>> */ >>> - return -EINVAL; >>> + ret = -EINVAL; >>> +out: >>> + return ret; >>> } >> >> I'm going to be lazy and not look into the future. But, you don't need >> the "out:" label here, yet. It doesn'serve any purpose like this, so >> why introduce it here? > > The 'out' label is here because of below code: > > ret = tdx_get_sysinfo(...); > if (ret) > goto out; > > If I don't have 'out' label here in this patch, do you mean something below? > > ret = tdx_get_sysinfo(...); > if (ret) > return ret; > > /* > * TODO: > * ... > * Return error before all steps are done. > */ > return -EINVAL; Yes, if you remove the 'out:' label like you've shown in your reply, it's actually _less_ code. The labels are really only necessary when you have common work to "undo" something before returning from the function. Here, you can just return.