Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2840351imm; Sun, 5 Aug 2018 13:35:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfshEXuy4ZLsSBl5p/gRys5u1K46VVrUvWBFHtoHP72nIsgAKvOW/6MSNvwk7kaJx0TW1Fa X-Received: by 2002:a65:62d8:: with SMTP id m24-v6mr12157124pgv.307.1533501331187; Sun, 05 Aug 2018 13:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533501331; cv=none; d=google.com; s=arc-20160816; b=Tu4ox6md6KpuiGmCOQWE8ppe5LQws14+MIgrzAtF/g2UXeaoPgTngWILC8IzH8X/g7 UTw3a4P1HeAO+TWgElJ75z9eJJGQg6D+F8vVClXP1R78/NP732m9tIIEhHHDNQ86Ya0C zFoPBpaZTPXomnAr0jTlA2ZjSASi48yt3umXAUFuBx78t3EjUMLrbHwY2517lL8o2r93 yzs4hgADd5jVa2x2q1sk7DmxyOmRSbP2xhThWCUADMSSRVWDIwy8DNuWtF7+IQ5PBnmE fKQjX+ZjLkbvzTHAf+x8oqPvkXPBp+Mn0EppkPaBKsTqbhMKjp/HYqWmz3N2qy83Upgl UB9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=cJ1H1buxJ1vqnVcYCcAvmDEPjhrJ4A3ItrAicpVolw0=; b=SBruv3NNbOkAQZQpllFjm1hFi2bcpN9emsBuNaJ723oLooJFEJMbfrT3526I6GCxIJ WjCspHr1XXSCs4+cY76SENMmeDpYqsZNjcSun7kwK1YQjr7QuEqei86RNFBc73krBpXg glzrOns2xPV+ukl5K+gd0UnN9oC93O9v3yzjW8Z/QoVq6RbEVSIUE4/iGO6ZZDjOv43Z tdsY2hMQcS5WZSPs6XBCl9ZXrmUna2FAkRS3mNf7smD8WYNDbf/7sH2Mr+R4ysti8N46 PSsUDryG+28/ZRHKrgerxwEx9LSIOfcjxlCd9g/7NdUhq95twMtwx17o7fqf8OSfS9nx gC6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14-v6si10712708pgi.449.2018.08.05.13.35.16; Sun, 05 Aug 2018 13:35:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727738AbeHEWiz (ORCPT + 99 others); Sun, 5 Aug 2018 18:38:55 -0400 Received: from terminus.zytor.com ([198.137.202.136]:47987 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726769AbeHEWiy (ORCPT ); Sun, 5 Aug 2018 18:38:54 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w75KWQW0590261 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 5 Aug 2018 13:32:26 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w75KWPvL590258; Sun, 5 Aug 2018 13:32:25 -0700 Date: Sun, 5 Aug 2018 13:32:25 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Dave Hansen Message-ID: Cc: ak@linux.intel.com, hpa@zytor.com, aarcange@redhat.com, gregkh@linuxfoundation.org, jgross@suse.com, torvalds@linux-foundation.org, peterz@infradead.org, hughd@google.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, bp@alien8.de, keescook@google.com, dave.hansen@linux.intel.com, mingo@kernel.org, jpoimboe@redhat.com, luto@kernel.org Reply-To: jgross@suse.com, gregkh@linuxfoundation.org, aarcange@redhat.com, ak@linux.intel.com, hpa@zytor.com, hughd@google.com, torvalds@linux-foundation.org, peterz@infradead.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, keescook@google.com, bp@alien8.de, jpoimboe@redhat.com, dave.hansen@linux.intel.com, mingo@kernel.org, luto@kernel.org In-Reply-To: <20180802225829.FE0E32EA@viggo.jf.intel.com> References: <20180802225829.FE0E32EA@viggo.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/pti] x86/mm/init: Add helper for freeing kernel image pages Git-Commit-ID: 6ea2738e0ca0e626c75202fb051c1e88d7a950fa X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 6ea2738e0ca0e626c75202fb051c1e88d7a950fa Gitweb: https://git.kernel.org/tip/6ea2738e0ca0e626c75202fb051c1e88d7a950fa Author: Dave Hansen AuthorDate: Thu, 2 Aug 2018 15:58:29 -0700 Committer: Thomas Gleixner CommitDate: Sun, 5 Aug 2018 22:21:03 +0200 x86/mm/init: Add helper for freeing kernel image pages When chunks of the kernel image are freed, free_init_pages() is used directly. Consolidate the three sites that do this. Also update the string to give an incrementally better description of that memory versus what was there before. Signed-off-by: Dave Hansen Signed-off-by: Thomas Gleixner Cc: keescook@google.com Cc: aarcange@redhat.com Cc: jgross@suse.com Cc: jpoimboe@redhat.com Cc: gregkh@linuxfoundation.org Cc: peterz@infradead.org Cc: hughd@google.com Cc: torvalds@linux-foundation.org Cc: bp@alien8.de Cc: luto@kernel.org Cc: ak@linux.intel.com Cc: Kees Cook Cc: Andrea Arcangeli Cc: Juergen Gross Cc: Josh Poimboeuf Cc: Greg Kroah-Hartman Cc: Peter Zijlstra Cc: Hugh Dickins Cc: Linus Torvalds Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Andi Kleen Link: https://lkml.kernel.org/r/20180802225829.FE0E32EA@viggo.jf.intel.com --- arch/x86/include/asm/processor.h | 1 + arch/x86/mm/init.c | 15 ++++++++++++--- arch/x86/mm/init_64.c | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index cfd29ee8c3da..59663c08c949 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -966,6 +966,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves) extern unsigned long arch_align_stack(unsigned long sp); extern void free_init_pages(char *what, unsigned long begin, unsigned long end); +extern void free_kernel_image_pages(void *begin, void *end); void default_idle(void); #ifdef CONFIG_XEN diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index cee58a972cb2..bc11dedffc45 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -773,13 +773,22 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end) } } +/* + * begin/end can be in the direct map or the "high kernel mapping" + * used for the kernel image only. free_init_pages() will do the + * right thing for either kind of address. + */ +void free_kernel_image_pages(void *begin, void *end) +{ + free_init_pages("unused kernel image", + (unsigned long)begin, (unsigned long)end); +} + void __ref free_initmem(void) { e820__reallocate_tables(); - free_init_pages("unused kernel", - (unsigned long)(&__init_begin), - (unsigned long)(&__init_end)); + free_kernel_image_pages(&__init_begin, &__init_end); } #ifdef CONFIG_BLK_DEV_INITRD diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 73158655c4a7..68c292cb1ebf 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1283,8 +1283,8 @@ void mark_rodata_ro(void) set_memory_ro(start, (end-start) >> PAGE_SHIFT); #endif - free_init_pages("unused kernel", text_end, rodata_start); - free_init_pages("unused kernel", rodata_end, _sdata); + free_kernel_image_pages((void *)text_end, (void *)rodata_start); + free_kernel_image_pages((void *)rodata_end, (void *)_sdata); debug_checkwx();