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 69592C433FE for ; Fri, 25 Nov 2022 01:18:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95C316B0071; Thu, 24 Nov 2022 20:18:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9333A6B0072; Thu, 24 Nov 2022 20:18:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 821E06B0073; Thu, 24 Nov 2022 20:18:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 733696B0071 for ; Thu, 24 Nov 2022 20:18:17 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 47594C07F1 for ; Fri, 25 Nov 2022 01:18:17 +0000 (UTC) X-FDA: 80170203834.04.53189A6 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf12.hostedemail.com (Postfix) with ESMTP id 3FB3340008 for ; Fri, 25 Nov 2022 01:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669339096; x=1700875096; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=CoI48b71D2FMu4pWXHed6vmIDB7C2XvjCrv4WvChyA8=; b=kZ/rvIITBJYJw0VOrj8m8l0TouU9CoiVApBF/m0Zg/epa1xnrjZh9ZxV xkriHwlRPsErfzTY+2QmrE3/plgkoif/h4UT5EjpycLlc0JXqikT4OP44 X+MqAz67osePIkrRAG2G0sYuCXOowKwAmwKDQuDT8WDok7A07wDy1hBue KJLK+gcWeobZC20FDHNeowaxsFaZ4XQa9Zxf49R+p8MBWma7kynkG711+ cypwlmAdqKnPwSUyTSoM5qBF+3gxYTSHxoRYV0SoMsjuGh14QzULmCpcm H6zITUAZrrgGfF7twxdGzLHOE7V/9uYRuBFZIdo0OjQz3m1WI5z2bUsDt Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="315544951" X-IronPort-AV: E=Sophos;i="5.96,191,1665471600"; d="scan'208";a="315544951" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 17:18:13 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10541"; a="642544539" X-IronPort-AV: E=Sophos;i="5.96,191,1665471600"; d="scan'208";a="642544539" Received: from stechane-mobl2.amr.corp.intel.com (HELO [10.212.146.33]) ([10.212.146.33]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2022 17:18:12 -0800 Message-ID: <89a746cc-8f60-8472-0d0b-71a459e2dd64@intel.com> Date: Thu, 24 Nov 2022 17:18:11 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v7 16/20] x86/virt/tdx: Configure TDX module with TDMRs and global KeyID Content-Language: en-US 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" , "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: <344234642a5eb9dc1aa34410f641f596ec428ea5.1668988357.git.kai.huang@intel.com> <301184ce-05e5-871c-7a6c-4298a0cbd1ae@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669339096; a=rsa-sha256; cv=none; b=tIgFvssvRoQ+1TsGinyeilTpWltsFW2x9iKzDrM5JCz0mu4yyjtN6TFSGxIGEXJPJMgW5B 7yJP3wqIGIz0MpRB4tr9peSHo6OUTftJ8npoSzwg/iEpEHs3Z6Yzix6xdX9ppKiFewq9sS 4GEygadHdOjE3hXvtYeMm/GYR3+V310= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b="kZ/rvIIT"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf12.hostedemail.com: domain of dave.hansen@intel.com designates 134.134.136.24 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=1669339096; 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=m8jGRJx9/SU6oUV2Kbi1ABt1Rr588T0KY+ASJbGVfCY=; b=cuwpW6moIoSHBCldZG24vULGBByCA3MsyqFF+uoQ8ejrILexljG0X2fFlaD5wsrRlWThyR KZi27aEMDc56/bX9r6u5cIjsW3BGIo+XXXGPnLbr/CS1g6bIIDbRTDTVkVcxSxmacqCukW pXrhBZ3N4R5Y4voTRcxNemDDM1Qh9EQ= X-Rspamd-Queue-Id: 3FB3340008 X-Stat-Signature: qep9ji78ddhydznwjdj9amni9o6crutn X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b="kZ/rvIIT"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf12.hostedemail.com: domain of dave.hansen@intel.com designates 134.134.136.24 as permitted sender) smtp.mailfrom=dave.hansen@intel.com X-Rspamd-Server: rspam09 X-HE-Tag: 1669339096-575759 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 11/24/22 16:59, Huang, Kai wrote: > On Wed, 2022-11-23 at 15:56 -0800, Dave Hansen wrote: >> On 11/20/22 16:26, Kai Huang wrote: >>> + array_sz = ALIGN(tdmr_num * sizeof(u64), TDMR_INFO_PA_ARRAY_ALIGNMENT); >>> + tdmr_pa_array = kzalloc(array_sz, GFP_KERNEL); >> >> Just to be clear, all that chatter about alignment is because the >> *START* of the array has to be aligned. Right? > > Correct. > >> I see alignment for >> 'array_sz', but that's not the start of the array. >> >> tdmr_pa_array is the start of the array. Where is *THAT* aligned? > > The alignment is assumed to be guaranteed based on the Documentation you quoted > below. I'm feeling kinda dense today, being Thanksgiving and all. Could you please walk me through, step-by-step how you get kzalloc() to give you an allocation where the start address is 512-byte aligned? ... > Perhaps I should just allocate one page so it must be 512-byte aligned? > > /* > * TDMR_INFO entries are configured to the TDX module via an array > * of physical address of each TDMR_INFO. The TDX module requires > * the array itself to be 512-byte aligned. Just allocate a page > * to use it as the array so the alignment can be guaranteed. The > * page will be freed after TDH.SYS.CONFIG anyway. > */ Kai, I just plain can't believe at this point that comments like this are still being written. I _thought_ I was very clear before that if you have a constant, say: #define FOO_ALIGN 512 and you want to align foo, you can just do: foo = ALIGN(foo, FOO_ALIGN); You don't need to mention the 512-byte alignment again. The #define is good enough.