Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6409657iog; Thu, 23 Jun 2022 19:15:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sPdfRsGx33gcN8QhVgx72puq5IZK7aOuKLv0jQj6twNOuRNmAv83/sM8HIK+WlAY69HJwM X-Received: by 2002:a17:902:b494:b0:167:97e4:8a1a with SMTP id y20-20020a170902b49400b0016797e48a1amr41909433plr.83.1656036900022; Thu, 23 Jun 2022 19:15:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656036900; cv=none; d=google.com; s=arc-20160816; b=PINWalTMIcp+2I7I3Q10gVzTAjsxUOLLonG1nYr0bEMjFXrlE7oArOREvfGym5PH2z MyoXj/LwvujNkmsMryEU+9tuf0mwQMBYA21Rpq4GnG/X7TsxXEZ5eKLrqN45uGc6RL8A aqhiXc4qb6TlHdnI4KYJ7ZDTcN7Hs2lk8RqY3uDVeuZany4TZ67/aM2wVcuBc+T+ECO4 eZacySFgLCCC3+QIV0OY3R5LMpMFjUFEEkW0+Tb5dYj0jWi3pnMFCXJsch8Cy0gJs4wR /oppqphO9sRoIvJGw30U7/CimxB9j5VGnLvBGMBLRDpP3YXRfgv75np+KK0X6mJwf+V/ CwTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eMO8Y5dKBcBcC3e7TyeK3rb72VYL995XvSYJ62WGASw=; b=vJjrTY1PBrVRUXGeqFeg7NyK2QieEyaWnB9xwLw/aAnuQVKdWLT+lqLvCkK4qqrjQB 4u8PPK/vqyI/zd7hdlg/4BAk8ubp/OxsuGwVeWKByFQwgYL/hV09yzWee2IhuBgvk4vq l3OP9AJs9AlcNSnn2Vm5YjApCqlzRMRZbT5vfVSsKy8yj/hH2XqJC6pjx35t9IwY74DE 3W3OsYb/waEHKHAQdoM1J1qF7kktBLGocVcTqtJz/rUBb8G0j15Mz0QA+xBvBKHnBIjw Cs8wxZfcNhxL1MwKbuJtYKYYweYHPpgcMxBEPibzT2g+eUGruyiDF5+Cov2AlrjqAVmc UoDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Ob+cbOrB; 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 u38-20020a056a0009a600b005253c441681si1083300pfg.218.2022.06.23.19.14.47; Thu, 23 Jun 2022 19:15:00 -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=Ob+cbOrB; 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 S230202AbiFXCAR (ORCPT + 99 others); Thu, 23 Jun 2022 22:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbiFXCAO (ORCPT ); Thu, 23 Jun 2022 22:00:14 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C11160E18; Thu, 23 Jun 2022 19:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656036013; x=1687572013; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=UJ0AYgFys+sE10qyEdSaNFzs230jBihAsKBv88t635A=; b=Ob+cbOrB5tKnEODNov5NsCkqf0D/+jsFyFbQclqy1OCGC7BzhdkkYPpH 1vWlSJSfizrHnA/BDjfyZPWVh5dVTDB0VQT99B9fuZ9Hex+swYjvWvjDI L8MqVBvmHZL8cgB5IHwG5BPLCcCV2g0MfYdAm3+Yd4DlpEapC4Fhufy6/ JmzXUOaGw8FiIQdXRrTlk8tTfe7rzjCUUsopH3YQ6aI/ksad+pB1yFhPG 1DWdwhrSw7FpbdYd/t4SCmSU8jB2XZuzTvNMBnOro65nXDt16NmUQ0SRy 2QkczgRFM7PuAToFySpwsGCX7U0wu0JQWbdm2WkQ/pcVlRctQP2076xUf Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10387"; a="260713552" X-IronPort-AV: E=Sophos;i="5.92,217,1650956400"; d="scan'208";a="260713552" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.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> X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, 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 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