Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp154891imm; Thu, 2 Aug 2018 16:00:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpePL+ftOTSa6fgG2ye1qS6xaK1AEDmsJMcqro+xzPj67XegW73nUyTBjwOBEA1eiBaquc13 X-Received: by 2002:a63:6604:: with SMTP id a4-v6mr1226877pgc.404.1533250807452; Thu, 02 Aug 2018 16:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533250807; cv=none; d=google.com; s=arc-20160816; b=wkbbrym/TTZ6jbBDhQSHzJhERi6qebKTMpiB8yLYpZE9FMvgXeo2i0WLKBPbXUylas s66i84bcJ2fGvxNT1hFNaparIOGBGAXg0/qm1dNRkH7SuvfEO0bnZ3Vrr7vVQjndpl8Z 7eojK+qqTEw6IWd9vtz8UZIeAZURHx3wnk9FP/j5ojr1whoycH5GQh2kfWzaT0yJk3h3 oF0V0E/798Dse2tZ73XSanEnjeJMoo3JbujYgATI1dDNOh1ir28hvosCQWQSNohHHUBx l6m0Be79SC+9E6siuFxpWl+1b5SyVe8hn76fkPAZ+wB9TaqL1nbUWeUR8GnWAJxN8kKy chOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject:arc-authentication-results; bh=9X/sigwO2oj436rG5VOuUwy8h9s4aN5jU1kaelC2UA4=; b=RbdxwYaIw7ftDd7DB8ArPNZjpTq95ZteX5kWNyWuYsSjuFpF2b+dlWutETAnLRCSSj 6gyYlJe5eL2SLHIiE7zf5ND5p9gswO8geuUTHSVmzLWbmDKWxWu+N4sp1W2MNxhjs+zN I+S4HIEAI1Gqz/W5SmPXKpfIFn8O0Yhk+mCVftsnpVTR90T4LbKwHdZ0Xo3ZkHwltr+0 DWVcFc46ue5br1ZJFBLbmK2oOEhFus1IaS8cLgTeoxGaj7RFwzNOKICOSOcPWBo8E5zF z+yha5GEPm4XwTF/COwtZgXGJkQNsTOs3Y8kPAiM2g98dkAbMsIt8XOJoPbezvR8M5mw +dow== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q16-v6si2328668pls.404.2018.08.02.15.59.52; Thu, 02 Aug 2018 16:00:07 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732471AbeHCAwM (ORCPT + 99 others); Thu, 2 Aug 2018 20:52:12 -0400 Received: from mga14.intel.com ([192.55.52.115]:57753 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726791AbeHCAwM (ORCPT ); Thu, 2 Aug 2018 20:52:12 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Aug 2018 15:58:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,437,1526367600"; d="scan'208";a="221320317" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga004.jf.intel.com with ESMTP; 02 Aug 2018 15:58:36 -0700 Subject: [PATCH 3/7] x86/mm/init: pass unconverted symbol addresses to free_init_pages() To: linux-kernel@vger.kernel.org Cc: Dave Hansen , keescook@google.com, tglx@linutronix.de, mingo@kernel.org, aarcange@redhat.com, jgross@suse.com, jpoimboe@redhat.com, gregkh@linuxfoundation.org, peterz@infradead.org, hughd@google.com, torvalds@linux-foundation.org, bp@alien8.de, luto@kernel.org, ak@linux.intel.com From: Dave Hansen Date: Thu, 02 Aug 2018 15:58:28 -0700 References: <20180802225823.4711C55B@viggo.jf.intel.com> In-Reply-To: <20180802225823.4711C55B@viggo.jf.intel.com> Message-Id: <20180802225828.89B2D0E2@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen The x86 code has several places where it frees parts of kernel image: 1. Unused SMP alternative 2. __init code 3. The hole between text and rodata 4. The hole between rodata and data We call free_init_pages() to do this. Strangely, we convert the symbol addresses to kernel direct map addresses in some cases (#3, #4) but not others (#1, #2). The virt_to_page() and the other code in free_reserved_area() now works fine for for symbol addresses on x86, so don't bother converting the addresses to direct map addresses before freeing them. Signed-off-by: Dave Hansen Cc: Kees Cook Cc: Thomas Gleixner Cc: Ingo Molnar 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 --- b/arch/x86/mm/init_64.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff -puN arch/x86/mm/init_64.c~x86-init-do-not-convert-symbol-addresses arch/x86/mm/init_64.c --- a/arch/x86/mm/init_64.c~x86-init-do-not-convert-symbol-addresses 2018-08-02 14:14:48.380483277 -0700 +++ b/arch/x86/mm/init_64.c 2018-08-02 14:14:48.383483277 -0700 @@ -1283,12 +1283,8 @@ void mark_rodata_ro(void) set_memory_ro(start, (end-start) >> PAGE_SHIFT); #endif - free_init_pages("unused kernel", - (unsigned long) __va(__pa_symbol(text_end)), - (unsigned long) __va(__pa_symbol(rodata_start))); - free_init_pages("unused kernel", - (unsigned long) __va(__pa_symbol(rodata_end)), - (unsigned long) __va(__pa_symbol(_sdata))); + free_init_pages("unused kernel", text_end, rodata_start); + free_init_pages("unused kernel", rodata_end, _sdata); debug_checkwx(); _