Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp466507pxj; Thu, 3 Jun 2021 10:59:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4DqtzvkEaXpbFVJmdXrKEhGrn9S5k5T20CBxv6OjBECR1gnhzO9+DOFgVMENEyQe8N1Pi X-Received: by 2002:a17:906:fa13:: with SMTP id lo19mr542210ejb.468.1622743150308; Thu, 03 Jun 2021 10:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622743150; cv=none; d=google.com; s=arc-20160816; b=bLLg19dbW8vgM1tUb4mmey8QVhmFaHPzAuzv8p4vO+K9g/N2Ea/K5LfXqSbZy228U1 TT8Eewk0ql/dLnaGvkM2lkIWvc/Tiz1iGixRz7hQXFEwZFIUCgVmvoDM5MRLZ4cFqlBK bxwsP8MWVKymuxsNV6PSfhzIBA8QyPfAQXffNNPWS3ARLbnHY3RKnbgedEkW9w+noSTi 7mAiCysqb1b7u2vct81gbDaKI9rHkV+Fh927rmBsuOjhgoggklHc6DJzz0S8Ibb5CE0u Rg9KTJjR1oxMKRz7uuANppfvDPpPnxZ+UVgqBM82aRQNLTBXWq1oDTIdg3+pNrVblfRi wovA== 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=skVr9zMvIufazzChvk3drDWrXdpHfZx6gfNB+k0l89Q=; b=AEli6ARziAEfo7HVLjGcI88rGIRIO893gPHMwtppPKm2Yj83fMmwr1cjjMkHZe9G88 1Z7P5SioYsD9knFGY+qikMrfceZl4Fb70JzyCMAKsWnyy4FMbjTC4FdypcfFXdPbjSlz l2hspjdL7PrR+Meb9Dm4IHJV6YWVI0dBwKh56hFF0i2D05ddSMdyVpwMqyWwZCKfXBZ0 xVmamoxGJZqDES8OnVwEDZThHinSJ62uNSiegBdKg+X+oo2cph/ActOgN8GIV/8XBjaN 4IdhN3QwKsCzxrAG+LleaNgoApArEPxMx4npNBa0TZHGUU6FdYtHz4o1Nv/odaZObZX7 5uNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=r8jqC+hg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m14si2755729edp.172.2021.06.03.10.58.45; Thu, 03 Jun 2021 10:59:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=r8jqC+hg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbhFCR7a (ORCPT + 99 others); Thu, 3 Jun 2021 13:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbhFCR73 (ORCPT ); Thu, 3 Jun 2021 13:59:29 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05F1AC06174A; Thu, 3 Jun 2021 10:57:45 -0700 (PDT) Received: from zn.tnic (p200300ec2f13850035eef6c5c121f5ff.dip0.t-ipconnect.de [IPv6:2003:ec:2f13:8500:35ee:f6c5:c121:f5ff]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id D78D61EC03D2; Thu, 3 Jun 2021 19:57:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1622743062; h=from:from: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; bh=skVr9zMvIufazzChvk3drDWrXdpHfZx6gfNB+k0l89Q=; b=r8jqC+hgf3ijlHDfI2JOAPpy5D4fDHz1DUW1javoAm/NG1nkQr3dG932YUuEztnxhfFjUV rNHiADzamRL3amcP8n1xMpppr5QY2DuHu66FO2Fmm9cYR0X6WY6nS8JaiYzhqkOHgLBtlI 3VAQ67hbOn4WatmRC+SkaEiaRgF6B1s= Date: Thu, 3 Jun 2021 19:57:36 +0200 From: Borislav Petkov To: Mike Rapoport Cc: x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Andy Shevchenko , Ard Biesheuvel , Baoquan He , Darren Hart , Dave Young , Hugh Dickins , Ingo Molnar , Jonathan Corbet , Lianbo Jiang , Mike Rapoport , Randy Dunlap , Thomas Gleixner , linux-doc@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: Re: [PATCH 1/3] x86/setup: always reserve the first 1M of RAM Message-ID: References: <20210601075354.5149-1-rppt@kernel.org> <20210601075354.5149-2-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210601075354.5149-2-rppt@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 01, 2021 at 10:53:52AM +0300, Mike Rapoport wrote: > From: Mike Rapoport > > There are BIOSes that are known to corrupt the memory under 1M, or more > precisely under 640K because the memory above 640K is anyway reserved for > the EGA/VGA frame buffer and BIOS. > > To prevent usage of the memory that will be potentially clobbered by the > kernel, the beginning of the memory is always reserved. The exact size of > the reserved area is determined by CONFIG_X86_RESERVE_LOW build time and > reservelow command line option. The reserved range may be from 4K to 640K > with the default of 64K. There are also configurations that reserve the > entire 1M range, like machines with SandyBridge graphic devices or systems > that enable crash kernel. > > In addition to the potentially clobbered memory, EBDA of unknown size may > be as low as 128K and the memory above that EBDA start is also reserved > early. > > It would have been possible to reserve the entire range under 1M unless for > the real mode trampoline that must reside in that area. > > To accommodate placement of the real mode trampoline and keep the memory > safe from being clobbered by BIOS reserve the first 64K of RAM before > memory allocations are possible and then, after the real mode trampoline is > allocated, reserve the entire range from 0 to 1M. > > Update trim_snb_memory() and reserve_real_mode() to avoid redundant > reservations of the same memory range. > > Also make sure the memory under 1M is not getting freed by > efi_free_boot_services(). > > Fixes: a799c2bd29d1 ("x86/setup: Consolidate early memory reservations") > Signed-off-by: Mike Rapoport > --- > arch/x86/kernel/setup.c | 35 ++++++++++++++++++++-------------- > arch/x86/platform/efi/quirks.c | 12 ++++++++++++ > arch/x86/realmode/init.c | 14 ++++++++------ > 3 files changed, 41 insertions(+), 20 deletions(-) Ok, let's try it. Booting on a couple of boxes looks ok here, the difference is visible: - DMA zone: 30 pages reserved + DMA zone: 159 pages reserved On the other box, it was already reserving so many pages even before DMA zone: 159 pages reserved i.e., the first 640K. But it's not like I had problems before with early reservations so my testing doesn't mean a whole lot. Hugh's testing sounds good, lemme add his tag too. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette