Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5593346pxb; Mon, 28 Mar 2022 14:41:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxU/1Z+BboCKOeT9EZJUfKblIUyu33ntgBLGt8vXWgVYNJC4eZTuMm3XqUtU9nHQUv1+Et9 X-Received: by 2002:a67:c894:0:b0:324:c5da:a9b5 with SMTP id v20-20020a67c894000000b00324c5daa9b5mr13640122vsk.33.1648503708060; Mon, 28 Mar 2022 14:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648503708; cv=none; d=google.com; s=arc-20160816; b=VYKNFxSQCCG3eLHQ/lotRQEEqekd7P15sAECsWKyA6E9HQYriDGPmrvTe4A2uf2KZH lAYKdl9tHVGmH5qVQxPB+gDCG7C9djWdKUuvY2ROKCV9Y/xmMBXAYK2dBrzSoMzQ8Hft qiIeJUCDwUstfKwskmx0Wmxt29tiDfcej+MhhroXBTFMHiIpTchHL8FvED4wY6ciifAB WoyA9RyMO9HatxzvowzuZN9eJ/MSlEBBFK1P10avRBbvRxlFk8eB7rPwMFOP9sPs8rxo Wu52N8z2LJZV/W0G0dAnnhVh8GJkrbaxC5J6nToenvkdy72IWwNNpn1/k+QxCcx7nmJh 891w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=WUfzDi6HwwG9N6jy6TsAQs1R82h/90Sn8xoP4yyCVas=; b=HI8L44hIdg/9q7bZT8u2dqwllvu4+bLSgAbkshFjYcqvapAzSFfEBODGl8C/d8LKhx gZqhKYnpiOA6lpGNyXuTN3kVscqdYLwyDTLEADv+D+j7suhAepaLZ5HjBaidjtAlZESd R2d4eBZUMFw/WpgPp9Is0ENbRAaenA9JmO1hpf0MhBB37j6pM1/BHDAmaGHPCX8hmXuA Yq3RlrR+wJgOFhOh2tFErFz8wMA6pFpve74iKWSDLr164UiP9J4pc26FsFGhhKDwTJtJ 8Izcuyhcz5Y7uuXm5bnGwTlljgcVI2I2yUjJQ9OMwqQL66MWPTT9+GFv2PogK4vDR2WB IcGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NDZS3v1E; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q126-20020a1fd984000000b0033e8317029fsi3081903vkg.265.2022.03.28.14.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 14:41:48 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NDZS3v1E; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 802C4A76E9; Mon, 28 Mar 2022 14:18:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344992AbiC1Ubp (ORCPT + 99 others); Mon, 28 Mar 2022 16:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344555AbiC1Ubm (ORCPT ); Mon, 28 Mar 2022 16:31:42 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C18B6BC26; Mon, 28 Mar 2022 13:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648499401; x=1680035401; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=KDJhS+gF41QpT4r+vh7URXlkO3BK6Mbi7mjFtJyx8Rs=; b=NDZS3v1EDr2pMKAr23h1xA/Wo60BR2lQjBoYuLDMERVyLssyOKPffD2l Skb4zfj3fBctyqdt/ZUwulc5/naiREyodMAC3wM6fZjlVjhY/YSJBKzbA iFO7TmNzsv69UGEKe2lfdp7p9teaq5x0cPlilmbWW+jCGkiQ7LDI40S25 W/jLJXfWP+Rsnx20SF3NZzg3XDsfDenSyADztMkDvUav0NzeWCHWP9DJq 0+UbVBjZCs8aPR4tWpwdGeev2rXj7xpTJrWsz0ucO5CNPAM+jx6hwfnSV tmGq2YwcBjBXy/u5dwWUPXPAKwKBbylKd1gCd/ZE/VLrcHG8hm+SZolAK Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="345533272" X-IronPort-AV: E=Sophos;i="5.90,218,1643702400"; d="scan'208";a="345533272" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 13:30:01 -0700 X-IronPort-AV: E=Sophos;i="5.90,218,1643702400"; d="scan'208";a="832181780" Received: from weiweihx-mobl.amr.corp.intel.com (HELO [10.255.229.113]) ([10.255.229.113]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 13:30:00 -0700 Message-ID: <60bf1aa7-b004-0ea7-7efc-37b4a1ea2461@intel.com> Date: Mon, 28 Mar 2022 13:30:01 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2 09/21] x86/virt/tdx: Get information about TDX module and convertible memory Content-Language: en-US To: Isaku Yamahata , Kai Huang Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, peterz@infradead.org, tony.luck@intel.com, ak@linux.intel.com, dan.j.williams@intel.com, isaku.yamahata@intel.com References: <98c1010509aa412e7f05b12187cacf40451d5246.1647167475.git.kai.huang@intel.com> <20220324174301.GA1212881@ls.amr.corp.intel.com> <20220328202225.GA1525925@ls.amr.corp.intel.com> From: Dave Hansen In-Reply-To: <20220328202225.GA1525925@ls.amr.corp.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/28/22 13:22, Isaku Yamahata wrote: >>>> + /* >>>> + * Also a sane BIOS should never generate invalid CMR(s) between >>>> + * two valid CMRs. Sanity check this and simply return error in >>>> + * this case. >>>> + */ >>>> + for (j = i; j < cmr_num; j++) >>>> + if (cmr_valid(&cmr_array[j])) { >>>> + pr_err("Firmware bug: invalid CMR(s) among valid CMRs.\n"); >>>> + return -EFAULT; >>>> + } >>> This check doesn't make sense because above i-for loop has break. >> The break in above i-for loop will hit at the first invalid CMR entry. Yes "j = >> i" will make double check on this invalid CMR entry, but it should have no >> problem. Or we can change to "j = i + 1" to skip the first invalid CMR entry. >> >> Does this make sense? > It makes sense. Somehow I missed j = i. I scratch my review. You can also take it as something you might want to refactor, add comments, or work on better variable names. If it confused one person, it will confuse more in the future.