Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4117686rdb; Thu, 14 Sep 2023 12:15:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRi2zjXF1gMFNGMA/Nf+i4+/GvwTdAhB/ShNGs9T1CX1Q9A1FhElhGhNoNcdGekFU8In0t X-Received: by 2002:a05:6a00:2296:b0:68c:705d:78ad with SMTP id f22-20020a056a00229600b0068c705d78admr7663226pfe.27.1694718938025; Thu, 14 Sep 2023 12:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694718938; cv=none; d=google.com; s=arc-20160816; b=t1UU4NPePle0YNotehT1zydbS0CmICCYompXva0+dt0bd9F4cVu1vMtiQb3EIS4rOb gVN5bLoTOgHnQROOa3bWAWYJv3Ao7VoyN22itLj0LSh3MgghbLXzQo0KsfWL60cLpZcI 5NY0CRl0XhefrMOX6P7iqYBweMYQ2T6c0/d2Nav7E6qE1D1IqmQJqKNjeG+8ROSLQd/F k+puh8Fjdz+XiNWWOAd1KciajMaBk5cKhLnLJ4dxqw8PfsYrFMdr7wp4QR5aFPMckomR OgCEtlE/bOg5ShbMPNdLuxby2mkMyciiHcDrHNJeYL9LaCLhWUs/jP/2WzWnlMJyzI/C /xng== 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=je5qIKMz7inJzcDC8fP590eGLZWjQsZlGsQE9k3VcHg=; fh=3T5QxTcwWkIN0tOnG1AjNTqScbqEVCFpxXWUT2fu1PQ=; b=xkD10lrk21n66zzW7t5sirWtVWLUO1XF5bRrwc5ER5DmOmLtc+VfDmYo1U7DuEayEg I/d3PqKxHtF97X3D9zKJto4joVpB1xph2mTtN5VgkII3n0SrGoMhUHz1NeKOcCwhzE0r JZUgU7I0IuNLvCBjovvbQ12ZerPjOD28QaOVJ2//IGcuouzfQ8m32MvMP9B3k/BdGcPM qod+e/VEIijhjLc28VYzzcUql9uHBUmtHzrpRNFeWgoPuzTzHhUljvjvSr7BKJnlCvag YTq0LS2WnNK2mLYPjxvLHAaiaS+TzW/H9AV53wCfnZf8kl17r6SGwDUgL7EzpAc+8q3I Ia1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UtSBiv2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id cr7-20020a056a000f0700b0068e29a05fa4si1994422pfb.326.2023.09.14.12.15.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 12:15:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UtSBiv2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3AB2E809C437; Thu, 14 Sep 2023 10:07:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238801AbjINRHi (ORCPT + 99 others); Thu, 14 Sep 2023 13:07:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbjINRHh (ORCPT ); Thu, 14 Sep 2023 13:07:37 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B191FE1 for ; Thu, 14 Sep 2023 10:07:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694711253; x=1726247253; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/eQr3ybfflzRpAXDDtun+U9e54s/8RMewMOTgkhAo/s=; b=UtSBiv2bmIg9fjI/9x+9/d/P+3b5Hsxlegq4vtLROeluNt9UcDlQkjq0 fUpzW5RYcPtI35m2YOVRVKEzHBFndmmPUuo7CD0YV2LTEM6q3uavNUMDZ 7osvMlVJLVZDPncrdeJ3hPb2G5WEwkU2mCwVInOp3W+9qJXex2ZnaI6To 3UEAcvnJ+7AYaVoAEahphuSHCCgqQDhzfw0Vfc5WFvZK4DY9dIjdvzh/L d69EBoicsCyyX3OyY6x8o8cT1owNbHiPyaIzIRuBRd1aIHj/mBSsKQap/ 5TQ3eoid7vGO0TYKiBGpXfkVJmpx38sqFOH175v8Xd2onjSK4VwM0yNsj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="382832868" X-IronPort-AV: E=Sophos;i="6.02,146,1688454000"; d="scan'208";a="382832868" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 10:07:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10833"; a="1075471230" X-IronPort-AV: E=Sophos;i="6.02,146,1688454000"; d="scan'208";a="1075471230" Received: from njayagop-mobl2.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.48.41]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 10:07:29 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 5E48B109D89; Thu, 14 Sep 2023 20:07:26 +0300 (+03) Date: Thu, 14 Sep 2023 20:07:26 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Thomas Gleixner , Borislav Petkov , Ard Biesheuvel , Kees Cook , Aaron Lu , Bagas Sanjaya , Tom Lendacky , x86@kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, regressions@lists.linux.de Subject: Re: [PATCH] x86/boot/compressed: Reserve more memory for page tables Message-ID: <20230914170726.4am7xi36m4hdgiyk@box> References: <20230914123001.27659-1-kirill.shutemov@linux.intel.com> <45cdb5ae-986e-d186-f0fd-a308f946ce8d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <45cdb5ae-986e-d186-f0fd-a308f946ce8d@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:07:40 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email On Thu, Sep 14, 2023 at 08:51:50AM -0700, Dave Hansen wrote: > On 9/14/23 05:30, Kirill A. Shutemov wrote: > > +/* > > + * Total number of page table kernel_add_identity_map() can allocate, > > + * including page tables consumed by startup_32(). > > + */ > > +# define BOOT_PGT_SIZE (32*4096) > > I agree that needing to know this in advance *exactly* is troublesome. > > But I do think that we should preserve the comment about the worst-case > scenario. Want me to send v2 for that? > Also, I thought this was triggered by unaccepted memory. Am > I remembering it wrong? How was it in play? Unaccepted memory touched EFI system table. I was able to reproduce without unaccepted memory enabled: if get_rsdp_addr() takes efi_get_rsdp_addr() path. So it is not the root cause, just a trigger. So we need several things to run into the problem: - System supports 5-level paging and it is enabled; - Decompressor takes control in 64-bit mode, so it uses page tables inherited from bootloader until initialize_identity_maps(). In initialize_identity_maps() kernel resets page tables, rebuilding them from scratch. Here we only map what is definitely required: kernel, cmdline, boot_patams, setup_data. Entering in 32-bit mode would make startup_32() map the first 4G unconditionally, but in this setup we rely more on #PF to fill page table. It masks problem as we rarely need all four PMD tables. - Make kernel touch at least one page per-gigabyte in the first 4G. In our case, unaccepted memory path was the last straw: it triggered allocation of the fourth PMD table which failed. We can increase the constant by one and it will work as long as nobody need anything beyond the first 4G (or any 1G-aligned 4G region where we've got loaded, I guess). I am not sure we can guarantee this with (potentially buggy) ACPI and EFI in the picture. > Either way, I think your general approach here is sound. But let's add > one little tweak to at least warn when we're getting close to the limit. Yeah, makes sense. -- Kiryl Shutsemau / Kirill A. Shutemov