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 95EC3C43334 for ; Mon, 27 Jun 2022 10:42:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01FDC6B0071; Mon, 27 Jun 2022 06:42:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EEA7C6B0072; Mon, 27 Jun 2022 06:42:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D64CF8E0001; Mon, 27 Jun 2022 06:42:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C38A56B0071 for ; Mon, 27 Jun 2022 06:42:18 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 939C9120EB1 for ; Mon, 27 Jun 2022 10:42:18 +0000 (UTC) X-FDA: 79623676356.30.A340C7E Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by imf30.hostedemail.com (Postfix) with ESMTP id B96CA8003B for ; Mon, 27 Jun 2022 10:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656326537; x=1687862537; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=sd/cHeGy8jdWVz1qnBVANjV157gqCMkdgO7Xv3oof5I=; b=ByKb9uMYLN+paVYxzsFjCRMZEaaUVzBh6B77HkGoL2WGHYrL+3N9iEEk cLM9VZNp2Cxc6xLWFFsvogIOb3aMkIMgx13f2j+0V4yzeUcHYwHGJlMd/ 2/p6lCDxPX6HRU1bibcsrJnqtECIs1KSP/MwLfSrVLTf1FRWnkrY28nsO gVWTjpSYbcSnSfWrn+QeWPSjeiggaYSDFSySf6kNMrcEU8/dOztuh+SOo Tm/8g6y2O8prxwIKh9/JDn+SRBYOnhZ6PkLA39NDPBzkRiBwCBjsUlj/Y d7D6Wzxo58KogIpYibMVblBQd2+yvPvU/VKbXQeBACVpKnx912kCyhptS g==; X-IronPort-AV: E=McAfee;i="6400,9594,10390"; a="282154098" X-IronPort-AV: E=Sophos;i="5.92,226,1650956400"; d="scan'208";a="282154098" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jun 2022 03:42:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,226,1650956400"; d="scan'208";a="622510788" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 27 Jun 2022 03:42:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 90E5FD9; Mon, 27 Jun 2022 13:42:11 +0300 (EEST) Date: Mon, 27 Jun 2022 13:42:11 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Borislav Petkov , Andy Lutomirski , Sean Christopherson , Andrew Morton , Joerg Roedel , Ard Biesheuvel , Andi Kleen , Kuppuswamy Sathyanarayanan , David Rientjes , Vlastimil Babka , Tom Lendacky , Thomas Gleixner , Peter Zijlstra , Paolo Bonzini , Ingo Molnar , Varad Gautam , Dario Faggioli , Mike Rapoport , David Hildenbrand , marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv7 14/14] x86/tdx: Add unaccepted memory support Message-ID: <20220627104211.whyuxx7h5tebrasb@black.fi.intel.com> References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-15-kirill.shutemov@linux.intel.com> <7c74e86e-295f-0958-cbdf-b54b4ca688dd@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7c74e86e-295f-0958-cbdf-b54b4ca688dd@intel.com> ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ByKb9uMY; spf=none (imf30.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656326538; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eHXdfOnfqIubBOPa0dAOYp0gPcy9uNwrAuVx4OK3I2s=; b=XM/5B26mAArPoA5JLiGI0KCziNOeDwOtIir8pv3XKgoQGSBk5G1z0MOwvGzzQIbFi7I3/f a0w98w4d4n6813TBqZPCH+EoXEwsAq+f1xDww3rmGh6H5Mm1XeoDikpKfqL+lhOSvapqcn vdGdb3bIIxjcuJih2Uhr+JnZ2PN8yyY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656326538; a=rsa-sha256; cv=none; b=po/TNfH1WrD52yGqS5xd8WnPGbrqNmuG08f3sY7815E70HVFRv6ApV073ibr7dZRpBq08T /gWJDHFOrRyFa1VR4NVSfsRoQMBDHKHF8QMMYN07TCAyk/ANFci4nap/m2eHCrV2MIWPZ/ cflvKEIn+U99rtdMMa0f0m3CGqLxjSM= X-Stat-Signature: xf4uqqh1feozktmta6z35k54y7n67j7g X-Rspamd-Queue-Id: B96CA8003B X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ByKb9uMY; spf=none (imf30.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.24) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam02 X-HE-Tag: 1656326537-549935 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 Fri, Jun 24, 2022 at 09:22:03AM -0700, Dave Hansen wrote: > On 6/14/22 05:02, Kirill A. Shutemov wrote: > > static inline void __accept_memory(phys_addr_t start, phys_addr_t end) > > { > > /* Platform-specific memory-acceptance call goes here */ > > - error("Cannot accept memory"); > > + if (is_tdx_guest()) > > + tdx_accept_memory(start, end); > > + else > > + error("Cannot accept memory: unknown platform\n"); > > } > > There are quite a few of these > > if (tdx()) > ... > > conditions in common code here. Shouldn't this be something like a > CC_ATTR_MEM_ACCEPT? > > if (cc_platform_has(CC_ATTR_MEM_ACCEPT)) > cc_accept_memory(...); > else > error("Cannot accept memory: unknown platform\n"); > > I understand that TDX is the first one to the party. Is this the time > to add the cc_ infrastructure? We need if tdx() check *somewhere* as how exactly memory gets accepted is specific to a particular platform. There are two callsites where memory acceptance happens. One of them is in boot stub where we don't have cc_ infrastructure. So it will boil down to a single cc_accept_memory() that will have 'if tdx()' inside. I don't see much sense in the exercise. We can as well keep the 'if' in accept_memory(). -- Kirill A. Shutemov