Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp656014ioo; Thu, 26 May 2022 11:27:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/zYRwbAMohAdJ5ua0lPkBfz7HutS0jk38uN61g1L0/53ECR0pH0cVO1kg+avkeJomsWqr X-Received: by 2002:a63:8043:0:b0:3fb:984f:69b2 with SMTP id j64-20020a638043000000b003fb984f69b2mr1306452pgd.108.1653589674617; Thu, 26 May 2022 11:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653589674; cv=none; d=google.com; s=arc-20160816; b=eRvN2K1SJf469In4MWN+SKNDX0Vvg2upD/Lq6PfUQx41CM7nGa84iAcckAbrDHd2/X 2lSW/hcYcjSvMa/HBe8XpUamVKZpQPRVY94qJVM9Gml4jEM0W1vpo6GRvaMfjR98d5+r izbfOEG2J/cMQMHPy0jJhrezJ+DWGEPDNOJrrWmchbsiAEP7AtO29sPbqvUmPHCDhMx1 Tc2KvY6cKcet03/oEB/5UloxBMIHdbTZI7ycPSUlxLY+8gbTqvpWpFHFpV/hXELsQk+Z hAe14TZn1I0RnVHcBMU6QCFEsqcBwTmgS6JdqcEYpNE5SmcUl0OchcjYip/b3H6yFDnP rQQA== 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=Di1xK7T1KY+3szzIcvmGSAkCKAtzBoAOCYOwNboy2q4=; b=pqn2G4t/VYcUpl3I/f3PDiiqENB42tUvjGNrk1gAU0Av51v4HButsyhxY2HC2a/Jf3 xY3Fe4vgCIHdXlMIIRbzuV4NVOHwaVs+RZur95rdHdhVxVcOqFvIUt2qt7YyCX2oz+Pm TE+GoKcY6NQUAvlFwZJTuOPadwMlVpMYNQjw2eGDJdtMrGZ2NPS2YWEEt17C7PDx9KA5 m9pFojy8P9N/mXzczxCUgv8PKM5xuPjjtlNMEYb6k2QRaSX1sSe+Sd/07Q1LZBDGAPoT voMiCx10BcgKXXUiKRSrH/z9/YAiZJO1MIX4LcAoa5MAor7W2Y+5GFlgJPR8Z/N0uNoG 69JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NS5JDpHn; 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 c199-20020a624ed0000000b005189905de2asi2203809pfb.172.2022.05.26.11.27.42; Thu, 26 May 2022 11:27:54 -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=NS5JDpHn; 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 S243504AbiEYQD1 (ORCPT + 99 others); Wed, 25 May 2022 12:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235695AbiEYQDY (ORCPT ); Wed, 25 May 2022 12:03:24 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CE23B41D0; Wed, 25 May 2022 09:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653494602; x=1685030602; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=7NhX25SuGNORs55jhWR7pX5NAvt/ZOoud0zyj6OlrCQ=; b=NS5JDpHnZ3yFPAxk3tY/YOp3ICFbFxBnJ7xnwWBRnwb3ez9tMd0DkxRG NTEzjnUCXbPJhI+KixJDyB0RNtxKSB68CP70kYCwE/5O+zS6PZQp4eeSr 1kd8D+TaIgfe5JRrPGg+8Ux/qrNvGfHowrIeDYaeVFme32/qcWJN94QrO oL0gUbkTELDv8vfqDJkZumG6P7l36SeIdP85gftuxFei0BXAq8F4yCJw6 TaBcpKrnmhmqYepVf1BGbyMPIL1bduXyN7rA2v4a69sh0hXKbQ3fQdO6B 0RVH7h81na2ZE4G20vD3ib+W1qCs64me9bImX5R/+DdJvRcUQYOpDRUar A==; X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="254351182" X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="254351182" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2022 09:00:56 -0700 X-IronPort-AV: E=Sophos;i="5.91,250,1647327600"; d="scan'208";a="573338858" Received: from canagani-mobl1.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.35.228]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2022 09:00:52 -0700 Message-ID: <6efb18e38a7812b62652ce5c403455811336f063.camel@intel.com> Subject: Re: [PATCH v3 09/21] x86/virt/tdx: Get information about TDX module and convertible memory From: Kai Huang To: Dave Hansen , 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 Date: Thu, 26 May 2022 04:00:49 +1200 In-Reply-To: References: <145620795852bf24ba2124a3f8234fd4aaac19d4.1649219184.git.kai.huang@intel.com> <0bab7221179229317a11311386c968bd0d40e344.camel@intel.com> <98f81eed-e532-75bc-d2d8-4e020517b634@intel.com> <4aea41ea-211f-fbde-34e9-4c4467ebc848@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Wed, 2022-05-25 at 16:57 +1200, Kai Huang wrote: > On Wed, 2022-05-25 at 16:47 +1200, Kai Huang wrote: > > On Fri, 2022-04-29 at 10:47 -0700, Dave Hansen wrote: > > > On 4/28/22 16:14, Kai Huang wrote: > > > > On Thu, 2022-04-28 at 07:06 -0700, Dave Hansen wrote: > > > > > On 4/27/22 17:15, Kai Huang wrote: > > > > > > > Couldn't we get rid of that comment if you did something like: > > > > > > > > > > > > > > ret = tdx_get_sysinfo(&tdx_cmr_array, &tdx_sysinfo); > > > > > > > > > > > > Yes will do. > > > > > > > > > > > > > and preferably make the variables function-local. > > > > > > > > > > > > 'tdx_sysinfo' will be used by KVM too. > > > > > > > > > > In other words, it's not a part of this series so I can't review whether > > > > > this statement is correct or whether there's a better way to hand this > > > > > information over to KVM. > > > > > > > > > > This (minor) nugget influencing the design also isn't even commented or > > > > > addressed in the changelog. > > > > > > > > TDSYSINFO_STRUCT is 1024B and CMR array is 512B, so I don't think it should be > > > > in the stack. I can change to use dynamic allocation at the beginning and free > > > > it at the end of the function. KVM support patches can change it to static > > > > variable in the file. > > > > > > 2k of stack is big, but it isn't a deal breaker for something that's not > > > nested anywhere and that's only called once in a pretty controlled > > > setting and not in interrupt context. I wouldn't cry about it. > > > > Hi Dave, > > > > I got below complaining when I use local variable for TDSYSINFO_STRUCT and CMR > > array: > > > > arch/x86/virt/vmx/tdx/tdx.c:383:1: warning: the frame size of 3072 bytes is > > larger than 1024 bytes [-Wframe-larger-than=] > > 383 | } > > > > So I don't think we can use local variable for them. I'll still use static > > variables to avoid dynamic allocation. In the commit message, I'll explain they > > are too big to put into the stack, and KVM will need to use TDSYSINFO_STRUCT > > reported by TDX module anyway. > > > > Let me know if you don't agree? > > Btw, CMR array alone can be put into the stack. It will never be used by KVM, > so I'll put CMR array as local variable, but keep tdx_sysinfo as static > variable. > Sorry for multiple emails about this. If I put CMR array to the stack, I still sometimes get the build warning. So will use static variables. Also, constructing TDMRs internally needs to use tdx_sysinfo (max_tdmrs, pamt_entry_size, max_rsvd_per_tdmr), so with static variable they don't need to be passed around as function arguments. -- Thanks, -Kai