Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1152109imm; Wed, 1 Aug 2018 11:03:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeph/Rzvv6pO8NlIUFeOOnPLGXkyyUBeNuWsLII5rIF39TApyuqKCqb+YM+xQhpJTGJK/Ps X-Received: by 2002:a63:4450:: with SMTP id t16-v6mr25576300pgk.102.1533146580240; Wed, 01 Aug 2018 11:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146580; cv=none; d=google.com; s=arc-20160816; b=vbYLlPJ2jovU5XbbQvuRruPC2fzMYwgm+XNG82RWjp80OjeaMh9FFn48wmz0KwCfJX tN+RiaqATRq+brzMnZzkfBf3bhuNc7q5B5PrIoQHFFb4+EbWVb3atbOIFClVQiZA8wZv UtJLPrBK2UrKGSBdf8TRZHKfh2RRHEiKaLbfXNw/uRSWr9ueW9J/SZTCS1PnC8iWUb7o iSLqfoLbu2XYMiDI/m6w6V1kbDploy1zMYQcfwnA0U5MzCzLVYv/PpoAlJi+znYFQJQS vZMO3gFbf2izOL2AZs3Jsuim3aItMfOQv+/g5El1FQkqGP7McwZZ6PDtHOKfx+dcHYJ3 Yw7g== 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=DJwe/kDgnObSRG+K+vr34LuuJk3pXI5lO92TVBcXoLg=; b=OurqpieJkN4mXJt/lM4o1Qqf5RqrVLrfACoGyWRjSIXOL9PdUEtcx2/pDxT0I+Ffj7 fVLlwmvC06aeWCSKV2cvFDhMnJueGB6UOm5nwQsTDD30X6NNDgpXXyJuKYmWqHjTr9Kj OuRxgd8LIdZe7jKXrOi2tZxkHG6jnJVxrKMcjdjftBjWJeJT67QvPQ6HGiP7RduHWgml 1u0UtV8c9r6FT6Yl4zSRiOBCNVa/yttUoJeRzhdLA0zHNnnu3/EZ36Wh/c7XByyGUusV tqh380adey1Mx4oYkw8Z2psA3XLVKMfXUpcVZrTJGjV54FD3BlQ+LR4uzbfCZ2eoSPJ2 dG4g== 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 y186-v6si17582305pgb.395.2018.08.01.11.02.45; Wed, 01 Aug 2018 11:03:00 -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 S1732622AbeHATsP (ORCPT + 99 others); Wed, 1 Aug 2018 15:48:15 -0400 Received: from mga11.intel.com ([192.55.52.93]:58990 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731955AbeHATsP (ORCPT ); Wed, 1 Aug 2018 15:48:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2018 11:01:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,432,1526367600"; d="scan'208";a="61270676" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga007.jf.intel.com with ESMTP; 01 Aug 2018 11:01:06 -0700 Subject: [PATCH 3/5] 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: Wed, 01 Aug 2018 11:01:02 -0700 References: <20180801180058.EC46D963@viggo.jf.intel.com> In-Reply-To: <20180801180058.EC46D963@viggo.jf.intel.com> Message-Id: <20180801180102.9B58A341@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-07-30 09:53:13.778915692 -0700 +++ b/arch/x86/mm/init_64.c 2018-07-30 09:53:13.782915692 -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(); _