From patchwork Wed Oct 4 22:23:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Kinsburskii X-Patchwork-Id: 13409627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB4F9E936EA for ; Wed, 4 Oct 2023 22:23:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32E356B0248; Wed, 4 Oct 2023 18:23:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DD856B024A; Wed, 4 Oct 2023 18:23:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17E2F6B024C; Wed, 4 Oct 2023 18:23:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 048006B0248 for ; Wed, 4 Oct 2023 18:23:20 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C864E1C9C5F for ; Wed, 4 Oct 2023 22:23:19 +0000 (UTC) X-FDA: 81309206118.07.E8D9A99 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by imf26.hostedemail.com (Postfix) with ESMTP id EE2B114001B for ; Wed, 4 Oct 2023 22:23:17 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=QbSVwGL5; dmarc=pass (policy=none) header.from=linux.microsoft.com; spf=pass (imf26.hostedemail.com: domain of skinsburskii@linux.microsoft.com designates 13.77.154.182 as permitted sender) smtp.mailfrom=skinsburskii@linux.microsoft.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696458198; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ycFAv0PCBQmDgiC3b/2+OMlEJBzxcUfQc48aiL7bf3M=; b=Uyy08y1hgpz7i+akKlOc9u4vjEiCe5IvqOIsmgS1D9BDrsGSJX3WhW5QkAywcbEcJx1h0j 7TubwnKnP5qzTrTa1wv6tJ7gmZylmdz3oCG5bGfF6ViOfYSQQEtnfG1qGabAwljp7T5BZg ALyAwDb4qH8CK3yRFTDTj98XewOVZug= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=linux.microsoft.com header.s=default header.b=QbSVwGL5; dmarc=pass (policy=none) header.from=linux.microsoft.com; spf=pass (imf26.hostedemail.com: domain of skinsburskii@linux.microsoft.com designates 13.77.154.182 as permitted sender) smtp.mailfrom=skinsburskii@linux.microsoft.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696458198; a=rsa-sha256; cv=none; b=Sld1KeJW402Gq/g3HlgjH7RFBYZQR7Ets6t8YsFntltyYo9A/pTOhBWwtSLP0HimiN/iiz FsXkIQ474QOLm2G1QX8V6kUOUjUx+yT95mbTHZUDwv0vS9n94mTPuvhz1CoSCqtCn07muO ZV0RkFaT5rvVi96fWzWc7gr6nSysAEY= Received: from skinsburskii. (c-67-170-100-148.hsd1.wa.comcast.net [67.170.100.148]) by linux.microsoft.com (Postfix) with ESMTPSA id 7781420B74C2; Wed, 4 Oct 2023 15:23:16 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7781420B74C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1696458196; bh=ycFAv0PCBQmDgiC3b/2+OMlEJBzxcUfQc48aiL7bf3M=; h=Subject:From:To:Date:In-Reply-To:References:From; b=QbSVwGL5m1YV4ZHlI7tRceJRWnWKXfuvjkrkM6T3QHhhstHPuzxjz07qTLxANFrZk Et3OvrVSC5lRKgTv2fB8uTv8CcmDbYXQ6OSnLKsopKQZg69XmRcsJ0SIvj/Rpo1/lr pygBF8mQ5e3QBv3q3CjyepJosWZjhUMMCLIGYcbk= Subject: [RFC PATCH v3 1/3] x86/boot/e820: Expose kexec range update, remove and table update functions From: Stanislav Kinsburskii To: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, ebiederm@xmission.com, akpm@linux-foundation.org, stanislav.kinsburskii@gmail.com, corbet@lwn.net, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, kys@microsoft.com, jgowans@amazon.com, wei.liu@kernel.org, arnd@arndb.de, gregkh@linuxfoundation.org, graf@amazon.de, pbonzini@redhat.com, bhe@redhat.com, dave.hansen@intel.com, kirill.shutemov@intel.com Date: Wed, 04 Oct 2023 15:23:15 -0700 Message-ID: <169645819587.11424.5389114333710932782.stgit@skinsburskii.> In-Reply-To: <169645773092.11424.7258549771090599226.stgit@skinsburskii.> References: <169645773092.11424.7258549771090599226.stgit@skinsburskii.> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Rspamd-Queue-Id: EE2B114001B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ya3cjmuma4igkn1z4hmfuarpwykxi3f7 X-HE-Tag: 1696458197-53863 X-HE-Meta: U2FsdGVkX18fpCi8VQDHR3T7DVR/BkBJJckxUBAkF5BKmaBajXXZ9SfeM0Z0rAREezUJcfkfA/Ddkd8BbrOIh4hWYtlsTTHVGuUKvm9Ef2j8WldTyyOpxPJIPeaTYswQmKNqbQ0rz0FkCC6iixc4yZUid1PVlrggdvH6MUj6LOtNcIwqJtbB1K7X75cr+z551yt+4NQSHBl6OFXHivPat/0uWBtrJ6DlVKqqgqdDYaFnQZkZBNCYqe49aBnpcHpzoTsEeccXe2yfONx0sh+0oexY3ag0w9n8z00wzenCqt4UhjfHCdZpHaI2IRpPdK2aoeJ/Ti+fzXls323KI9hVuyfLVGjpmiQQStYFeKsU2T7PiFD/E6BvTto1+bWShu644lepsbrvNkHrbwbRJRgxiI0cjVnQPb67KhoNTG0fl7hrDLQ9GMiEVq++ywnhhLO83laCztDd0ap4QubMTHM2CLiho3xRTvjjTbs0I1YiHWneeprPm2Qm4tD9gZJRziKQKiVthD4T8BSMyyDfSE2jmbGZzTpByc3NuE0WvMIHFnSYZiuAooasWGuKzXQccAMO8d5cR1CMrtYKWq9wC95znVVUae0sjFxYcnoSsKk/WEEsLaB6Y99sXZD7Bm2+38e1EtKLGzCfDnqew7BOTptCDw0v5tRiQq4zc4DxK8JEqT+GSyzNRNeHUeptu/q95pxrdxniyQUZkteXssc2HXMJWPDJATH5H16YX3mjn3Qq2Fny9FgKerhl10QHtYMB3XwLJPK250SQlQVdKeg6SJWisL6L4IiDOZbhhXwhI5To2SBDIYtb0xakhv/EoDsSgZEC24AtVLnKXTJLoHtV2B88Z5E7/LOukoIANWMikpQHlht36aYH9VnJLzKqmt/OirAZtvttPI+ZTbn00EQv1pug+JNxUMjBH5f374YhCwL5RVHtLaMrbxTsivRIv0LjIJbQgpGiRPhbQKm21pLviv3 rV9u5Ah9 UtNo81J9SOrWXonAWAQDM8YWij8SdvP28cM0ZMMPGzgKewpMPvYS87buSkl11iFxqCGtK5eKJThvo7AkYlojwAhzfnm/EvJFAE6uIL5BkF+THOcYM438G5VCE1FLwOw144HioTDK87fXZ/9IHlm2sWhkExNMp9UMaoXllkv5gWJ9NA6IriIk/6OP8ztUPvmEbbYtstf/v5/19dy8ebNd7vWolzDHeUvCAJ3axgaoqcaRXz4g9dtqYV48UGhVs8X1ZVX6CPes6xK+Q3jTv924HXU8Ayg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This functions are to be used to reserve memory regions in kexec kernel by other kernel subsystems. Signed-off-by: Stanislav Kinsburskii --- arch/x86/include/asm/e820/api.h | 4 ++++ arch/x86/kernel/e820.c | 21 +++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h index e8f58ddd06d9..24bb8da928bb 100644 --- a/arch/x86/include/asm/e820/api.h +++ b/arch/x86/include/asm/e820/api.h @@ -22,6 +22,10 @@ extern void e820__print_table(char *who); extern int e820__update_table(struct e820_table *table); extern void e820__update_table_print(void); +extern u64 e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type); +extern u64 e820__range_remove_kexec(u64 start, u64 size, enum e820_type old_type, bool check_type); +extern void e820__update_table_kexec(void); + extern unsigned long e820__end_of_ram_pfn(void); extern unsigned long e820__end_of_low_ram_pfn(void); diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index fb8cf953380d..f339815029f7 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -532,13 +532,12 @@ u64 __init e820__range_update(u64 start, u64 size, enum e820_type old_type, enum return __e820__range_update(e820_table, start, size, old_type, new_type); } -static u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type) +u64 __init e820__range_update_kexec(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type) { return __e820__range_update(e820_table_kexec, start, size, old_type, new_type); } -/* Remove a range of memory from the E820 table: */ -u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type) +u64 __init __e820__range_remove(struct e820_table *table, u64 start, u64 size, enum e820_type old_type, bool check_type) { int i; u64 end; @@ -553,8 +552,8 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool e820_print_type(old_type); pr_cont("\n"); - for (i = 0; i < e820_table->nr_entries; i++) { - struct e820_entry *entry = &e820_table->entries[i]; + for (i = 0; i < table->nr_entries; i++) { + struct e820_entry *entry = &table->entries[i]; u64 final_start, final_end; u64 entry_end; @@ -599,6 +598,16 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool return real_removed_size; } +u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type) +{ + return __e820__range_remove(e820_table, start, size, old_type, check_type); +} + +u64 __init e820__range_remove_kexec(u64 start, u64 size, enum e820_type old_type, bool check_type) +{ + return __e820__range_remove(e820_table_kexec, start, size, old_type, check_type); +} + void __init e820__update_table_print(void) { if (e820__update_table(e820_table)) @@ -608,7 +617,7 @@ void __init e820__update_table_print(void) e820__print_table("modified"); } -static void __init e820__update_table_kexec(void) +void __init e820__update_table_kexec(void) { e820__update_table(e820_table_kexec); }