Message ID | 20230507234618.18067-7-kirill.shutemov@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1813197vqo; Sun, 7 May 2023 16:48:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hHXNENK07kkiyNbUkEMFvnoyTEKYTEm6dAbfBhhN49YT6cRtwjfNne+NKiuKxZipzLOOS X-Received: by 2002:a05:6a20:728b:b0:ff:d437:13fb with SMTP id o11-20020a056a20728b00b000ffd43713fbmr5329294pzk.49.1683503310878; Sun, 07 May 2023 16:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683503310; cv=none; d=google.com; s=arc-20160816; b=m1MvU+S9NYFhLnwiE+hstrnRdpEFT1mag8Wx/ul25E0JZ+C/+t5URfwtXYZlcbqUkI YMyRRdoxxYsUZAZIAUE+Y7As3ZL73nIHcIghiYyXyRlV1CYTMdNIzlNMTAHZl1jUY78l Nvn5QyMBsi4e5aFvoCxK21lE9DTCmTozT206zrc8EF2s8F9IopfFIYgSOiZBl6QNK/+p ICy0jbS3hxqfHTcYeUDvqIwFRUDmfRxp5P0MwAp4q8cWzYPYKwjt+Mhk6okVIHR2I59j 36eicefvdS93eQf9v3Fq/G3AjorvYBhNixrEP59MoBDhC3VSFo1De9fwQmE0f0ywE448 u1Vw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SxAVKXcnaB18uGCScmaGm0KtqOzQ9BlZ2AI3oJdJlic=; b=Xuu7CrKyA6JCiAzdd+agHRX2eGwLyk3sjqnQjFnv+BuUgGPQqIsnVhJSMfRJDNkv6e LQeZ2Z5xamDfPbVNwS6/B0VcGxrGknhm1/WBH5JK6u3+YvKoa3hMIfm2OzexT7UBGRff xQKgIIQXi8is7rywk+OPnesgEK1r4U9tF7pgFEQrvniAfJSYSMMxtvpJwWpCOIYnetx8 854BGeF3V5MFjWUk2s/PJGlHMyX3Ds0yUkSIq/gD9NwyV34r3gp+pUlH2GcQGSmTaCiQ jmiyrMNvpmEh0LZ+crBG3zmIwTExAoenZu9A/i/FaLcAG1mmgX8BsJWuhGB+5gpnGG9K RNpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fcZWfqn9; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f194-20020a6238cb000000b0064105588e53si6138979pfa.359.2023.05.07.16.48.17; Sun, 07 May 2023 16:48:30 -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=fcZWfqn9; 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 S232274AbjEGXrE (ORCPT <rfc822;baris.duru.linux@gmail.com> + 99 others); Sun, 7 May 2023 19:47:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231234AbjEGXqu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 7 May 2023 19:46:50 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68E54100D0; Sun, 7 May 2023 16:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683503205; x=1715039205; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XL6vN5u+KeCOGSvPKGIDg51xwwNZ7oq3J9d7SYKdrYE=; b=fcZWfqn9q7bmmKZljKc6VQTOoLpHNUhvZ/Za2NEB4vyn4Uu+r5sVbIds YN1zsh7CVDpFHWGNsu4OoWy7LbRELGhFz7pKWkkNGJRfyFtxgkxAWdOJT 3aWJ40vTtSDNxmkMA53F8+c1cWrb02XK5tv4xyet46wfOat7pM40fgIFO oF0B7Td2Z6+4oMro+et5zoi8iE1iYCLc77U1OXgReKIwynVLBzQl9Nq6i 6x0jkVl7C/gq7qFwndb3MrfCV0Fz2B5cJOB4WnDloMHfp1Y7Yg3Cur2sd DW0MTqtDVjxzLxO1F9xvPG/4XPlRkKEKZgSztkO4XbgUEK+7HT7CWFleC A==; X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="349550290" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="349550290" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2023 16:46:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10703"; a="701222810" X-IronPort-AV: E=Sophos;i="5.99,258,1677571200"; d="scan'208";a="701222810" Received: from dancaspi-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.61.73]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 May 2023 16:46:32 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 47A4610D334; Mon, 8 May 2023 02:46:20 +0300 (+03) From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> To: Borislav Petkov <bp@alien8.de>, Andy Lutomirski <luto@kernel.org>, Dave Hansen <dave.hansen@intel.com>, Sean Christopherson <seanjc@google.com>, Andrew Morton <akpm@linux-foundation.org>, Joerg Roedel <jroedel@suse.de>, Ard Biesheuvel <ardb@kernel.org> Cc: Andi Kleen <ak@linux.intel.com>, Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>, David Rientjes <rientjes@google.com>, Vlastimil Babka <vbabka@suse.cz>, Tom Lendacky <thomas.lendacky@amd.com>, Thomas Gleixner <tglx@linutronix.de>, Peter Zijlstra <peterz@infradead.org>, Paolo Bonzini <pbonzini@redhat.com>, Ingo Molnar <mingo@redhat.com>, Dario Faggioli <dfaggioli@suse.com>, Mike Rapoport <rppt@kernel.org>, David Hildenbrand <david@redhat.com>, Mel Gorman <mgorman@techsingularity.net>, marcelo.cerri@canonical.com, tim.gardner@canonical.com, khalid.elmously@canonical.com, philip.cox@canonical.com, aarcange@redhat.com, peterx@redhat.com, x86@kernel.org, linux-mm@kvack.org, linux-coco@lists.linux.dev, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Mike Rapoport <rppt@linux.ibm.com> Subject: [PATCHv10 06/11] x86/mm: Reserve unaccepted memory bitmap Date: Mon, 8 May 2023 02:46:13 +0300 Message-Id: <20230507234618.18067-7-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230507234618.18067-1-kirill.shutemov@linux.intel.com> References: <20230507234618.18067-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765281167744701607?= X-GMAIL-MSGID: =?utf-8?q?1765281167744701607?= |
Series |
mm, x86/cc: Implement support for unaccepted memory
|
|
Commit Message
Kirill A. Shutemov
May 7, 2023, 11:46 p.m. UTC
A given page of memory can only be accepted once. The kernel has to accept memory both in the early decompression stage and during normal runtime. A bitmap is used to communicate the acceptance state of each page between the decompression stage and normal runtime. boot_params is used to communicate location of the bitmap throughout the boot. The bitmap is allocated and initially populated in EFI stub. Decompression stage accepts pages required for kernel/initrd and marks these pages accordingly in the bitmap. The main kernel picks up the bitmap from the same boot_params and uses it to determine what has to be accepted on allocation. In the runtime kernel, reserve the bitmap's memory to ensure nothing overwrites it. The size of bitmap is determined with e820__end_of_ram_pfn() which relies on setup_e820() marking unaccepted memory as E820_TYPE_RAM. Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Mike Rapoport <rppt@linux.ibm.com> --- arch/x86/kernel/e820.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index fb8cf953380d..483c36a28d2e 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -1316,6 +1316,23 @@ void __init e820__memblock_setup(void) int i; u64 end; + /* + * Mark unaccepted memory bitmap reserved. + * + * This kind of reservation usually done from early_reserve_memory(), + * but early_reserve_memory() called before e820__memory_setup(), so + * e820_table is not finalized and e820__end_of_ram_pfn() cannot be + * used to get correct RAM size. + */ + if (boot_params.unaccepted_memory) { + unsigned long size; + + /* One bit per 2MB */ + size = DIV_ROUND_UP(e820__end_of_ram_pfn() * PAGE_SIZE, + PMD_SIZE * BITS_PER_BYTE); + memblock_reserve(boot_params.unaccepted_memory, size); + } + /* * The bootstrap memblock region count maximum is 128 entries * (INIT_MEMBLOCK_REGIONS), but EFI might pass us more E820 entries