Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1779839imm; Sat, 4 Aug 2018 10:33:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpelzernKJ5al8rwy0LcKaLdmEnVLBHIyYOZHzv9/yJQ612fTiDR9+vXl76aAydgF1P0wEVF X-Received: by 2002:a65:594b:: with SMTP id g11-v6mr8594508pgu.260.1533404015370; Sat, 04 Aug 2018 10:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533404015; cv=none; d=google.com; s=arc-20160816; b=erxETT0sxbZKEzXUp8ITfVQWIHkKSQ4ibTesv1Nh2qISNAcxCJbZB0RAHhqvB93Rag vF9ngjTdE5M3Sa1nEAyyvIJxxl4XhQKQsAL4ukPGnOJfXl4/dPfnsyay2nteX9+aEpuc HYAl8vW17zfipvn709bjjGHHnNE2D8FrfaVbjrVlRF+N/zfwb9eOe04OZL5543457PKv gCszePz6i9a3HZyvxCQu6/VagN2Y/flMNoC1D3ULVSXnoVKdip+BXYxCE9u1XWypUPZx n34ILahqslikSX5n2rp7zlv44uNm7qRLqPViZH8tJAfeZYtksq7S7HI0eTtWyqMODz6Y pfCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=J7Ob1cLoEtjq7DYdAqJAxtBr3hEFML40mOJW39D48EI=; b=yr3WuDmNKwi6AaC/RnJSprJml+EtHTUfbsLl775qzByQIcow8OKb+JQoPk6qp3dKYe Yp7X3X7XmVLyq2SS8nTQFBr7l5Wz2KSNfnb5Mhakv3wSzhIAQzxzz9UbN3OJuqSNvaW/ aX8ZZnfpgYnWo9+/iq+PtW2SsMxnL9Y5VLhOhepRo/VvX2cen7V8srbPHniEwNJIokTK Xdz3RMgtY94qY4xlZe4hOXvx05iDXp0gGfQUBqemgwFfNWy/l9z8v0lUI7n0Gn4JZv0U 8RawUr3vp7blcXEEbwNEBTizr9SfDpgFg94nER31PCktkfUmFbdSf4XC4hmXo0rslM2F Y9bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=DZAzOot4; 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 a35-v6si6673999pla.27.2018.08.04.10.33.07; Sat, 04 Aug 2018 10:33:35 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=DZAzOot4; 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 S1729060AbeHDTdE (ORCPT + 99 others); Sat, 4 Aug 2018 15:33:04 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:53034 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727953AbeHDTdD (ORCPT ); Sat, 4 Aug 2018 15:33:03 -0400 Received: by mail-it0-f68.google.com with SMTP id d9-v6so12412691itf.2 for ; Sat, 04 Aug 2018 10:31:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=J7Ob1cLoEtjq7DYdAqJAxtBr3hEFML40mOJW39D48EI=; b=DZAzOot4MJSP+QoaRU7Bg+hJZR0AyqCPZjF0/Yelo3nMPmc7Eh5EUy7LLG9Xzg4d2q ywG2jj+Br7285iSExPOaUlF9QI87F6MjLKxVofP2Ebmfw76hY2nKVsx7M+AE0M3UhtUj BUQlmh5GUFk8e8ZzDAe4JzNsHxQh0K3IqmtoE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=J7Ob1cLoEtjq7DYdAqJAxtBr3hEFML40mOJW39D48EI=; b=CGu1B2YE5s8LhvQfqtS1gTZ9GOLquDWz+YUjVdixRfeIqZrKsAk9YggzPA00lbO41z +vihpLTbc+qg6iKh2t9ZJuhtUyWI/Ckkxzo8tfWksVa+HjsUBc3xVhuaAvDrS2qLiRg6 OahXTXygCsVl5NLQcDp/WGmayMyd+eEGMPy/1mPzS/TvJXFy/NWQwiehZlIxvTCSpI2w d2xTpw4jWIky3jLWFI+zqfNspyokFmFJsBUZ4JmjrvS7oRnH2jArYzl6e+9pX8ZctKnY EzR6UtwH9xL6wEvDc+4DFOu5riFx1TPOGnBecpo9xsofb4t08Tx1C1i+TLoAACDQU+36 e2dw== X-Gm-Message-State: AOUpUlEyakrek+PpMmQmc9GEdPKdTK72KjjLP/fveVCNFnnwv/hIvoVL Z5FNTfH+wDnvuJz4OOZp/8Qb9m7TwhHyVyARZIY= X-Received: by 2002:a24:b211:: with SMTP id u17-v6mr10041461ite.1.1533403900946; Sat, 04 Aug 2018 10:31:40 -0700 (PDT) MIME-Version: 1.0 References: <20180802225823.4711C55B@viggo.jf.intel.com> <20180802225828.89B2D0E2@viggo.jf.intel.com> In-Reply-To: From: Linus Torvalds Date: Sat, 4 Aug 2018 10:31:29 -0700 Message-ID: Subject: Re: [PATCH 3/7] x86/mm/init: pass unconverted symbol addresses to free_init_pages() To: Hugh Dickins Cc: Dave Hansen , Linux Kernel Mailing List , Kees Cook , Thomas Gleixner , Ingo Molnar , Andrea Arcangeli , =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= , Josh Poimboeuf , Greg Kroah-Hartman , Peter Zijlstra , Borislav Petkov , Andrew Lutomirski , Andi Kleen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 3, 2018 at 5:19 PM Hugh Dickins wrote: > > I thought that virt_to_page() only works on virtual addresses > in the direct map You're right that virt_to_page() does not work on any _actual_ virtual mappings (ie no user pages, and no vmalloc() pages etc). It does not follow page tables at all. And on 32-bit, it literally ends up doing (see __phys_addr_nodebug()) a simple #define __phys_addr_nodebug(x) ((x) - PAGE_OFFSET) However, on x86-64, we have *two* cases of direct mappings: we have the one at __START_KERNEL_map, and we have the one at PAGE_OFFSET. And virt_to_page() handles both of those direct mappings. Annoying? Yes. And it has caused bugs in the past. And I entirely forget why we needed it on x86-64. [ Goes around and rummages ] Oh, never mind, looking around reminded me why: we want to map the kernel text in the top 31 bits, so that we can use the faster -mcmodel=kernel because all symbols fit in sign-extended 32 bits. Maybe there was some other reason too, but I think that's it. Linus