Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4187781iog; Tue, 28 Jun 2022 10:43:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tW1u16mIxxFiXHLfpcvkM3FPMvGJqYA6uO4KRLm/LdAegx00NOTQ+6HjmFpYIMIEKqNjU3 X-Received: by 2002:a17:902:d2cb:b0:16a:2efb:d03e with SMTP id n11-20020a170902d2cb00b0016a2efbd03emr6013190plc.81.1656438210816; Tue, 28 Jun 2022 10:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656438210; cv=none; d=google.com; s=arc-20160816; b=bGy30EBcg9Ev+2aUpBhqLpQVo62FolzyI8OlJ0gYKyrnrJCn5t8pO398SPvSQGw6lH TgPUrHawoO/WOO3xkK7DCxClJoZA0iBRTnu8rYqKVlv906+nEzjel/Q7IrW+lQcGZ8A6 +AuCXVia06VrilLd44CAHNco0PxdkUj1rwoxm7OFU08KgPz9TOuCTPYx7r2NHRlZdf0d SxC9AwWxr0Ov/hHBr9941uRZYxk+lQmpMMoDzF1rJ1u7xZ5Juq+1CqeKCVUrTh+qXZOZ 2GSd96VrhWRTBTmo7Mxq8/jnMRnO3ZSM9cueNnGO+eu8P+qT5TmnRZzGy5IyzQzOudud CS6A== 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=uIq7KtqL+0mX2beZhm+6mkn/nVGtI8CXoF9jdZhXzsg=; b=ZY3ZNl0vKH+CaJcRlyQd2gEyGhxiphu91mEEMIjKWirmIpLVWx7AOD+AZp9bEV1y7y TNOqrO83Ht2NLxwRCgm69OAJz8wbGSGDDbK1FgYgsfHhgax98Yy3nYmV5HAxHgp+3xk/ a5XI2npZRPfwt1Rqac8vhPhY/mJt/Wx4zZM+or20P0fE+T3fzhpjy8eIVS5nsQodcbid PplmwsXu1SHH30vtZ4yI7RLMLNOi76vjEzEa7i8E2aMBJ4RFV8jsoLiMP7FUNew9ocdy AHaMGsOiZs6tVqnGeFKB12MRGQaOgHSwb4e3KWUU19Q10br8GrbVyTJTMp0c5UtOi3SE DYwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hmUwtDB6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jc7-20020a17090325c700b00168b8ef0734si16991596plb.508.2022.06.28.10.43.18; Tue, 28 Jun 2022 10:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hmUwtDB6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231265AbiF1RFs (ORCPT + 99 others); Tue, 28 Jun 2022 13:05:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbiF1RFp (ORCPT ); Tue, 28 Jun 2022 13:05:45 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 445762AE3B; Tue, 28 Jun 2022 10:05:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656435945; x=1687971945; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=He+/gvN4uag1zs/e9FSisKAycqG0udPhwiCpLr5nAw0=; b=hmUwtDB6+W1/IOfvnm7h7aCPZbyz5YM1puHOUg3aX0SS5VTao0cSn2cr tRZZXavtUVRW/U6zswtqQxPLEJi7h4fFxKi4hloGjpUtbqBYSI0T0dCiO owEty6yeSdVjkXY1cECc0g+riecp1hWhySArcc+z6XtdHeVgQwZJsWEs7 GzdO1LTxTI2iqVDYhOH0FcWqfWI3AIvtij95OAcQGoG5LA3ZFyMT33BU/ 0YBWtIMtvm7anxb0zglETO13r6yUs++L7VnCuNeZv9VdRv0oNrvy6yHnw a4w2a6GukZEWvxFV+9LD0it4U3oeJNowH8K99KzHeARXJQFbCvvlEaUdU w==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="307282189" X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="307282189" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 10:05:02 -0700 X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="587937625" Received: from staibmic-mobl1.amr.corp.intel.com (HELO [10.209.67.166]) ([10.209.67.166]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 10:05:02 -0700 Message-ID: Date: Tue, 28 Jun 2022 10:03:57 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v5 15/22] x86/virt/tdx: Allocate and set up PAMTs for TDMRs Content-Language: en-US To: Xiaoyao Li , Kai Huang , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, isaku.yamahata@intel.com References: <28110f9c-b84c-591a-d365-ae4412408e48@intel.com> From: Dave Hansen In-Reply-To: <28110f9c-b84c-591a-d365-ae4412408e48@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 6/27/22 17:48, Xiaoyao Li wrote: >> >> I meant this: >> >> +       switch (level) { >> +       case PG_LEVEL_4K: >> +               page_size = 0; >> +               break; >> >> Because TDX_PG_4K==page_size==0, and for this: >> >> +       case PG_LEVEL_2M: >> +               page_size = 1; > > here we can just do > >     page_size = level - 1; > > or >      >     tdx_page_level = level - 1; > > yes, TDX's page level definition is one level smaller of Linux's > definition. Uhh. No. The 'page_size' is in the kernel/TDX-module ABI. It can't change. PG_LEVEL_* is just some random internal Linux enum. It *CAN* change. There's a *MASSIVE* difference between the two. What you suggest will probably actually work. But, it will work accidentally and may break in horribly confusing ways in the future. It's the difference between hacking something together and actually writing code that will keep working for a long time. Please, take a minute and reflect on this. Please.