Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp5747001pxb; Mon, 28 Mar 2022 17:10:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFTw6VB6gs0SOxcxmJv6FJFkAgClXNiPqrGIzCPd/VNzKxF7y5ccyZXFxRtZctITDHDTUG X-Received: by 2002:a05:6102:e8e:b0:325:8377:8372 with SMTP id l14-20020a0561020e8e00b0032583778372mr8332895vst.18.1648512600636; Mon, 28 Mar 2022 17:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648512600; cv=none; d=google.com; s=arc-20160816; b=l0oxP/vWXQu7zORZ8nLubyz3L0Y52CipHxf/ZKfuYb8X5Tpqqk1qIuiaWYGaQAFTmC ZyO5rAOzIe37RLSPrqUWCvuDy8PhBrNo+h7McwJduNmqnKD7L6UiG57LCzx4BFxAGMaF X4WH2GIqIN3c6k1Yodt8JSpAjiqLJ2Ejn65M5UAv7NPd7D+f8fhGXHx/UJxXI509eJkG y1A3vacq19afJqw39mkdrvYL7hfU6i7X5mZdXziCmy1s35JflNmGeyFo33Bhxm+ScQSq CTobuShKvyUyNWTTBtatbo2DxSrsZpX3kWnyLktmtCxcSqCpUqyZ4eulrMzgj2ZwQ6v9 3ypQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=Ybu2mVUZpTn29qH03qK6Utgm4AYC59lQknyb12GoX4A=; b=gu0J9dYTpAzNi4Vfoi3YI45D36OM7bKUd9y2EzDZBwFsOYBm7QwZqGeQQF33+ZaVJ3 H43uUhKZp513U0eZgIJn70vF8I9Z1LeOoJMNRhdU01L/MIRZl6IQbBFHCZ/Ij8/H7oFz bGgB0KgJpXwiWASaE6fhRbvOBf6SK/l/iLfAlJY0UnJTBHoCt2Ygn6AsdS1x3wJOO6F3 J6MV5xB9A2N/zm2w5WIY3jOAhDmd06QDysGL2xjMpxAkltx4AtrL7CbSfcgopqxYygvn DIBs5A8zmlYy+rKm5PR5l6lq8p8K0wLg5q1ufRyuTQzrIOx1ssLeqCgVLtR6yR229xQB bn6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jjl01dh8; 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 u8-20020ab069c8000000b0035970b574f8si3402943uaq.142.2022.03.28.17.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 17:10:00 -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=jjl01dh8; 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 8553212AB7; Mon, 28 Mar 2022 16:40:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230506AbiC1XmY (ORCPT + 99 others); Mon, 28 Mar 2022 19:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230472AbiC1XmW (ORCPT ); Mon, 28 Mar 2022 19:42:22 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60A3A63A9; Mon, 28 Mar 2022 16:40:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648510841; x=1680046841; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=0mmJ/whBeCllU3xdwmN5YeVPUumAS7XqYgOhdOdB3g8=; b=jjl01dh8ga3r27G7Um1eUGGr8KRhZuwKdHNJA8XrfOrx2q34bLFFB0bh +Kfef9U0isZrgaDez4SqQq5CPpJE/FjslqG4P36My16BNB/SmDIGgTiyA 9xLcMEjMU2Oek2fKiqq72QOjVvwO6urQc+nUW49dk1sXEUcuDQT912YSF 4OrFfkw4JiZqQK7oaTi4ePqGKqStWiQmS/f2+onwghqGDgwmbghnljUef +geCGv+W1Th5azb3OQRKVxs9zZe6MkIegtR4IbeQictN6ql3Vk1YI3D4I lQ7H6OKgsTWZ7gARnHwKhrIOTrE8MBnJy33SvOM/UINRuGlSlVnjYxwoL g==; X-IronPort-AV: E=McAfee;i="6200,9189,10300"; a="239057013" X-IronPort-AV: E=Sophos;i="5.90,218,1643702400"; d="scan'208";a="239057013" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 16:40:40 -0700 X-IronPort-AV: E=Sophos;i="5.90,218,1643702400"; d="scan'208";a="521215541" Received: from nhawacha-mobl1.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.27.18]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Mar 2022 16:40:37 -0700 Message-ID: <9d8d20f62f82e052893fa32368d6a228a2140728.camel@intel.com> Subject: Re: [PATCH v2 09/21] x86/virt/tdx: Get information about TDX module and convertible memory From: Kai Huang To: Dave Hansen , Isaku Yamahata 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 Date: Tue, 29 Mar 2022 12:40:35 +1300 In-Reply-To: <60bf1aa7-b004-0ea7-7efc-37b4a1ea2461@intel.com> References: <98c1010509aa412e7f05b12187cacf40451d5246.1647167475.git.kai.huang@intel.com> <20220324174301.GA1212881@ls.amr.corp.intel.com> <20220328202225.GA1525925@ls.amr.corp.intel.com> <60bf1aa7-b004-0ea7-7efc-37b4a1ea2461@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 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,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 Mon, 2022-03-28 at 13:30 -0700, Dave Hansen wrote: > 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. Hi Dave, OK I'll think over whether I can improve. Thanks for advice. Btw if you have time, could you help to review this series? Or could you take a look at whether the overall design is OK, for instance, the design limitations described in the cover letter? -- Thanks, -Kai