Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5047178pxj; Wed, 26 May 2021 01:15:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvRc/EHKxwFl6zNDeb4pkjpml6H7kWoKgJQldj5H2LcCM9vuLZT/BKOyDEwiJjKtADnZ57 X-Received: by 2002:a5d:9804:: with SMTP id a4mr25366735iol.164.1622016939757; Wed, 26 May 2021 01:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622016939; cv=none; d=google.com; s=arc-20160816; b=OX/fmY6lCJKgD6WPFh0pXQB2dhpOHd07funnMZzRxL0rNwAcTAKRR2nN4XiMT1nsVa scNtmpkzzEmJ8GJPG8tXQXeMk5g7+BgnAFWkWpVJzd6H2hvERpCFl3eRvL57gAUicA5E rxg84tKK3X9gfnNEuOPhoke2srdi8ojcHgTCHEG3KW3DUYEARge+/t/Xi6kQB5aXrgdt 79WUtFbN6PRykdsY4ottZxzxpuT6peDBaKzUAbCgeEgczqPz2YVck51yLIaIYqmSPh+a 0dqiAp2GN42rIMEto3l6PrIJq36nIUq/maooV23EEGmmqF9EBh1TVwnL2uTtJgZXDZYy qdHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2TQ5YzZEsrxoESu6opX3S2RB3rvs/I02YqP9vVNQqG8=; b=oEBV8JO//pN7WwxEW5uFSVMQO56/atxjfee6qOovcd5e1frh1T5W+xDEyNa+p8o1Q2 7cBfuXrkDLLeYiitktHTd22P3jbjCbtoicobwtRSZ40CugA1spQ0f4o24OU/Gtb4CVNI RmLLbZfUfv4Cs4I2APsNiQ1Q69goOXuh5xVD497RM3yA7+V7Vb3dtHUiNXJewqQteWDV PDnC6ANShZ4W+MTvpU2Ht5c0dj9kBlrbeWjP7/3NV/dNmGiieSqw2l5vZw1gqo1PYJeh XzaZBfDPkdEJns+3VuvMM1jScJJn9USmZixe5/n/R/OezLNECU6Ga+JLrz2BR0vObqbe jmOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DypxiYV4; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l22si21211093jad.10.2021.05.26.01.15.25; Wed, 26 May 2021 01:15:39 -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=@kernel.org header.s=k20201202 header.b=DypxiYV4; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233386AbhEZIMu (ORCPT + 99 others); Wed, 26 May 2021 04:12:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:45976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233070AbhEZIMi (ORCPT ); Wed, 26 May 2021 04:12:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 11DC961441; Wed, 26 May 2021 08:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622016667; bh=IRRZpq7Jq6eVb7k8X++aNz0iYj4Kp1VdyKG7JS2CUdw=; h=From:To:Cc:Subject:Date:From; b=DypxiYV4EnmWqr5/BrbqHnWa0itvvbKhLPZnOXah/J2MH9u8gzy87JqJJGXUxRYql fwVHz/s+RghDND7X/6lM7uMixQdzsIErwcFklg9jTh4aXzKmMJcln5dlpgI/hLz0Hx 1L5usGbfKci1ZZjdSdhQydzDNwGCBV5qMUWg3o0d4C38+kV2CqaFnnMw8SWFa75JY3 Xre+eIFrICLFkLQ/BxlcayKk0iS20HcLQCuG79XZxV+BVhYJkLLjweUSdLSqlv3Iqs m0OEHpAB+NkHijJJqfjC7ZST1Aa/xRnlKaNcwXrjcCPXqSscibitL3BS+k0nwih0L3 ItvvBf9Qc7zpA== From: Mike Rapoport To: Borislav Petkov Cc: Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Mike Rapoport , Mike Rapoport , untaintableangel@hotmail.co.uk, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86/Kconfig: decrease maximum of X86_RESERVE_LOW to 512K Date: Wed, 26 May 2021 11:11:00 +0300 Message-Id: <20210526081100.12239-1-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Rapoport After the consolidation of early memory reservations introduced by the commit a799c2bd29d1 ("x86/setup: Consolidate early memory reservations") the kernel fails to boot if X86_RESERVE_LOW is set to 640K. The boot fails because real-time trampoline must be allocated under 1M (or essentially under 640K) but with X86_RESERVE_LOW set to 640K the memory is already reserved by the time reserve_real_mode() is called. Before the reordering of the early memory reservations it was possible to allocate from low memory even despite user's request to avoid using that memory. This lack of consistency could potentially lead to memory corruptions by BIOS in the areas allocated by kernel. Decrease the maximum of X86_RESERVE_LOW range to 512K to allow blocking the use of most of the low memory by the kernel while still leaving space for allocations that should be compatible with real mode. Update the Kconfig help text of X86_RESERVE_LOW to make it explicit that kernel requires low memory to boot properly. Link: https://bugzilla.kernel.org/show_bug.cgi?id=213177 Fixes: a799c2bd29d1 ("x86/setup: Consolidate early memory reservations") Signed-off-by: Mike Rapoport --- arch/x86/Kconfig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 0045e1b44190..7a972b77819e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1696,7 +1696,7 @@ config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK config X86_RESERVE_LOW int "Amount of low memory, in kilobytes, to reserve for the BIOS" default 64 - range 4 640 + range 4 512 help Specify the amount of low memory to reserve for the BIOS. @@ -1711,8 +1711,11 @@ config X86_RESERVE_LOW You can set this to 4 if you are absolutely sure that you trust the BIOS to get all its memory reservations and usages right. If you know your BIOS have problems beyond the - default 64K area, you can set this to 640 to avoid using the - entire low memory range. + default 64K area, you can set this to 512 to avoid using most + of the low memory range. + + Note, that a part of the low memory range is still required for + kernel to boot properly. If you have doubts about the BIOS (e.g. suspend/resume does not work or there's kernel crashes after certain hardware base-commit: c4681547bcce777daf576925a966ffa824edd09d -- 2.28.0