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 B3DA1C43334 for ; Fri, 24 Jun 2022 02:00:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 47A208E01B6; Thu, 23 Jun 2022 22:00:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 428E08E01A1; Thu, 23 Jun 2022 22:00:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F0938E01B6; Thu, 23 Jun 2022 22:00:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1F5B68E01A1 for ; Thu, 23 Jun 2022 22:00:12 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DDF9F3558E for ; Fri, 24 Jun 2022 02:00:11 +0000 (UTC) X-FDA: 79611474222.22.9A417D2 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf09.hostedemail.com (Postfix) with ESMTP id F2EF9140021 for ; Fri, 24 Jun 2022 02:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656036011; x=1687572011; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=UJ0AYgFys+sE10qyEdSaNFzs230jBihAsKBv88t635A=; b=ClIK6yYD1OODt0Bk+1dCEb0NJTffj5e5RuiEqlr5jns0ddkl7B7N0ahO V5bFFvzrhOzCPSRBAYl1HDAOF7okKDdzuTixLrjVAwmMMV1whnq6eJwMZ vEXP0VR3RcTwKDQip67A4Fxu7tUPFWWN4c0J0O01vtdmshBcUwFqSQ7W4 QUvgddh3PZtHlfIXcIvuv3qKMjyGANhFRVbVS0ZlKgO/j6fkvhDytpRQv lrcohzYTjahVmaMJb35r9XPHuAbR1fMAfgxCN02lpMKKyu1lvYQ2iZ2cx vfcp57vgOKeGsFNVcUZXtixqxKsGOWSUS9znp1ZND9faLjcnB0DoZiJ80 g==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="263932346" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="263932346" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 19:00:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="656446240" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 23 Jun 2022 19:00:00 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id A3D07136; Fri, 24 Jun 2022 05:00:05 +0300 (EEST) Date: Fri, 24 Jun 2022 05:00:05 +0300 From: "Kirill A. Shutemov" To: "Eric W. Biederman" Cc: Dave Hansen , 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, kexec@lists.infradead.org Subject: Re: [PATCHv7 11/14] x86: Disable kexec if system has unaccepted memory Message-ID: <20220624020005.txpxlsbjbebf6oq4@black.fi.intel.com> References: <20220614120231.48165-1-kirill.shutemov@linux.intel.com> <20220614120231.48165-12-kirill.shutemov@linux.intel.com> <6be29d38-5c93-7cc9-0de7-235d3f83773c@intel.com> <87a6a3aw50.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a6a3aw50.fsf@email.froward.int.ebiederm.org> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656036011; 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=eMO8Y5dKBcBcC3e7TyeK3rb72VYL995XvSYJ62WGASw=; b=m2Oeu4lAcNUB2XwilmnlybdyzQZzusWWM70D7Ni+0nDk43l+kNemaenQAH6oRn4yRt9Qe/ 0QWhDXingiN8Qma/+Y8fF8zRkA6LaJSpgLaRiVuYHbA/I1Cq7jPwD4KuEXKB8KcdjjBhUF uThYOzUHIYlCR9fJVwr6neYHyFuu6Gk= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ClIK6yYD; spf=none (imf09.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656036011; a=rsa-sha256; cv=none; b=2fQpxHY84CaBaBo9pw1IWewRVUbmeFrhd+r0HzrIJADEkspXxK3x8Mgx3qwyjYsRs8XWMl dByly2Ad/nyKfOTB9Tuoef5qwUTTy0Cx94Ltt9P1ZPbduzPD+huSmBVbvBRNiHAIY5XvEz GzDU2Zg/UI9ofUgrarRXcSOB6ozSYps= Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=ClIK6yYD; spf=none (imf09.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.126) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: pczn89e7u3c18inb9eizoui14wd3deda X-Rspamd-Queue-Id: F2EF9140021 X-HE-Tag: 1656036010-173366 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 Thu, Jun 23, 2022 at 04:48:59PM -0500, Eric W. Biederman wrote: > Dave Hansen writes: > > > ... adding kexec folks > > > > On 6/14/22 05:02, Kirill A. Shutemov wrote: > >> On kexec, the target kernel has to know what memory has been accepted. > >> Information in EFI map is out of date and cannot be used. > >> > >> boot_params.unaccepted_memory can be used to pass the bitmap between two > >> kernels on kexec, but the use-case is not yet implemented. > >> > >> Disable kexec on machines with unaccepted memory for now. > > ... > >> +static int __init unaccepted_init(void) > >> +{ > >> + if (!boot_params.unaccepted_memory) > >> + return 0; > >> + > >> +#ifdef CONFIG_KEXEC_CORE > >> + /* > >> + * TODO: Information on memory acceptance status has to be communicated > >> + * between kernel. > >> + */ > >> + pr_warn("Disable kexec: not yet supported on systems with unaccepted memory\n"); > >> + kexec_load_disabled = 1; > >> +#endif > > > > This looks to be the *only* in-kernel user tweaking kexec_load_disabled. > > It doesn't feel great to just be disabling kexec like this. Why not > > just fix it properly? Unfortunately, problems with kexec are not limited to the unaccepted memory. Isaku pointed out that MADT CPU wake is also problematic for kexec. It doesn't allow CPU offline so secondary kernel will not be able to wake it up. So additional limitation (as of now) for kexec is !SMP on TDX guest. I guess we can implement CPU offlining by going to a loop that checks mailbox and responds to the command. That loops has to be somehow protected from being overwritten on kexec. Other issues may come up as we actually try to implement it. That's all doable, but feels like a scope creep for unaccepted memory enabling patchset :/ Is it a must for merge consideration? > > What do the kexec folks think? > > I didn't realized someone had implemented kexec_load_disabled. I am not > particularly happy about that. It looks like an over-broad stick that > we will have to support forever. > > This change looks like it just builds on that bad decision. > > If people don't want to deal with this situation right now, then I > recommend they make this new code and KEXEC conflict at the Kconfig > level. That would give serious incentive to adding the missing > implementation. I tried to limit KEXEC on Kconfig level before[1]. Naive approach does not work[2]: WARNING: unmet direct dependencies detected for UNACCEPTED_MEMORY Depends on [n]: EFI [=y] && EFI_STUB [=y] && !KEXEC_CORE [=y] Selected by [y]: - INTEL_TDX_GUEST [=y] && HYPERVISOR_GUEST [=y] && X86_64 [=y] && CPU_SUP_INTEL [=y] && X86_X2APIC [=y] Maybe my Kconfig-fu is not strong enough, I donno. [1] https://lore.kernel.org/all/20220425033934.68551-6-kirill.shutemov@linux.intel.com [2] https://lore.kernel.org/all/YnOjJB8h3ZUR9sLX@zn.tnic > If there is some deep and fundamental why this can not be supported > then it probably makes sense to put some code in the arch_kexec_load > hook that verifies that deep and fundamental reason is present. Sounds straight-forward. I can do this. > With the kexec code all we have to verify it works is a little testing > and careful code review. Something like this makes code review much > harder because the entire kernel has to be checked to see if some random > driver without locking changed a variable. Rather than having it > apparent that this special case exists when reading through the kexec > code. > > Eric > -- Kirill A. Shutemov