From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A78C433E1 for ; Thu, 13 Aug 2020 20:00:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5C4AA20716 for ; Thu, 13 Aug 2020 20:00:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=jrtc27.com header.i=@jrtc27.com header.b="e0fgTlM6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C4AA20716 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=jrtc27.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C16D88D0006; Thu, 13 Aug 2020 16:00:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC6808D0002; Thu, 13 Aug 2020 16:00:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB6228D0006; Thu, 13 Aug 2020 16:00:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id 94FA78D0002 for ; Thu, 13 Aug 2020 16:00:11 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 58F498248068 for ; Thu, 13 Aug 2020 20:00:11 +0000 (UTC) X-FDA: 77146611822.19.knee68_1e1600026ff6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id F05611AD31E for ; Thu, 13 Aug 2020 20:00:10 +0000 (UTC) X-HE-Tag: knee68_1e1600026ff6 X-Filterd-Recvd-Size: 6776 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Thu, 13 Aug 2020 20:00:10 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id f18so7000405wmc.0 for ; Thu, 13 Aug 2020 13:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=MDY4VR7sk8ivVZRv1+DZoU7fYwncB9DP7kIqn5ZnsBg=; b=e0fgTlM6T+JTHANbqOxXPMp9rlQ3z4KQDIuuirFfVsMQ7PVnu7NTmlAREr8eoljjXE 7B0q1E2Yp6MkMarfcl53zvH5nyJiW36+jH0nyicHNgQDfN/5sCJCVFSDtdAoY8luFQQL 9L6bT7d8zWP8OAoLjDP1r1OmltskiwVhtmSx6gXpZKmm+2Xo+xJUAgPDQKKqDWtf9GYv SMSUNPz9nJzcY6DzdWCgad8o4iYXEu3O4xDMAlbpgGmePc0NStT1PHxR7CyK8hUbOv50 toqZdewWZ543o1MGXJqzNKurGTbE+kmBEDZX9LTTmMNhCnfT6cEABybYq3zWIR/GbrzD kdZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=MDY4VR7sk8ivVZRv1+DZoU7fYwncB9DP7kIqn5ZnsBg=; b=KTDeN8kFtVD68PusilOrv4X3SDo+Qy0SQ1/sdAM/LuIT5z+UiUzx6flNvsvqYE6hX0 fS8BberV1vE5uRbry/kyv5w77J4Ae0WOeRdXbMO0kF9ZEmMRHk71unbXxRRZg99YLrPk IWP5fhyTZMIJj+4i3vRuOVMa5cr7MBjDeQZ0rVLUaK/VVSh/2ikJkBeJ5pxAXANFzqL/ SvMfZykgKrDU8gltq718pXcdMaim3kK0qKwxQoBl9Na0MmcPhskU9RMoFT19Hv67BfgO 4+Cvjg77Onw+1hSqjPBgIrsWd6foUzapjoCLohUyVphoMBT8Trmus76DuYTSGkBMADDR w+ZQ== X-Gm-Message-State: AOAM532F4TrCGl2LUbt4hol1T027ikq7xjJXJZYxvCOxI6TLtjy4wMvB oE/l2R2HyX5YARVSbD6nI64v0A== X-Google-Smtp-Source: ABdhPJyhcLy1FCYgiQmcz7z4M8mlGqUkzYi5Efs3zlqP71Ury2zPANaNiOuuxSVAMQ48O41+XPj8og== X-Received: by 2002:a1c:14e:: with SMTP id 75mr6140187wmb.151.1597348808202; Thu, 13 Aug 2020 13:00:08 -0700 (PDT) Received: from [192.168.149.251] (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id t11sm10358708wrs.66.2020.08.13.13.00.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2020 13:00:07 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.1\)) Subject: Re: [PATCH v4] arch/ia64: Restore arch-specific pgd_offset_k implementation From: Jessica Clarke In-Reply-To: <20200813195129.5099-1-rppt@kernel.org> Date: Thu, 13 Aug 2020 21:00:06 +0100 Cc: John Paul Adrian Glaubitz , Tony Luck , linux-ia64@vger.kernel.org, Anatoly Pugachev , Sergei Trofimovich , linux-mm@kvack.org, Frank Scheiner , Mike Rapoport Content-Transfer-Encoding: quoted-printable Message-Id: <4BAE916F-BC99-4CE8-9A9B-266AC69CF346@jrtc27.com> References: <20200813195129.5099-1-rppt@kernel.org> To: Mike Rapoport X-Mailer: Apple Mail (2.3608.120.23.2.1) X-Rspamd-Queue-Id: F05611AD31E X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000106, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 13 Aug 2020, at 20:51, Mike Rapoport wrote: >=20 > From: Jessica Clarke >=20 > IA-64 is special and treats pgd_offset_k() differently to = pgd_offset(), > using different formulae to calculate the indices into the kernel and = user > PGDs. The index into the user PGDs takes into account the region = number, > but the index into the kernel (init_mm) PGD always assumes a = predefined > kernel region number. Commit 974b9b2c68 ("mm: consolidate pte_index() = and > pte_offset_*() definitions") made IA-64 use a generic pgd_offset_k() = which > incorrectly used pgd_index() for kernel page tables. As a result, the > index into the kernel PGD was going out of bounds and the kernel hung > during early boot. >=20 > Allow overrides of pgd_offset_k() and override it on IA-64 with the = old > implementation that will correctly index the kernel PGD. >=20 > Fixes: 974b9b2c68 ("mm: consolidate pte_index() and pte_offset_*() = definitions") > Reported-by: John Paul Adrian Glaubitz > Signed-off-by: Jessica Clarke > Tested-by: John Paul Adrian Glaubitz > Signed-off-by: Mike Rapoport > --- >=20 > Changes since v3: > * Correct commit message as Jessica suggested I also corrected the comment to: /* * In the kernel's mapped region we know everything is in region number = 5, so * as an optimisation its PGD already points to the area for that = region. * However, this also means that we cannot use pgd_index() and we must * never add the region here. */ > Changes since v2: > * Rephrase commit message and comment about pgd_offset_k() >=20 > Changes since v1: > * Fixed typo in commit message > * Slightly reworded commit message to sound less weird > * Included Adrian's Tested-by >=20 >=20 > arch/ia64/include/asm/pgtable.h | 9 +++++++++ > include/linux/pgtable.h | 2 ++ > 2 files changed, 11 insertions(+) >=20 > diff --git a/arch/ia64/include/asm/pgtable.h = b/arch/ia64/include/asm/pgtable.h > index 10850897a91c..6ef501cd0166 100644 > --- a/arch/ia64/include/asm/pgtable.h > +++ b/arch/ia64/include/asm/pgtable.h > @@ -366,6 +366,15 @@ pgd_index (unsigned long address) > } > #define pgd_index pgd_index >=20 > +/* > + * In the kernel's mapped region we know everything is in region = number 5, so > + * as an optimisation its PGD already points to the area for that = region. > + * However, this also means that we cannot use pgd_index() and we = never > + * should add the region here. > + */ > +#define pgd_offset_k(addr) \ > + (init_mm.pgd + (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))) > + > /* Look up a pgd entry in the gate area. On IA-64, the gate-area > resides in the kernel-mapped segment, hence we use pgd_offset_k() > here. */ > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index a124c21e3204..e8cbc2e795d5 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -117,7 +117,9 @@ static inline pgd_t *pgd_offset_pgd(pgd_t *pgd, = unsigned long address) > * a shortcut which implies the use of the kernel's pgd, instead > * of a process's > */ > +#ifndef pgd_offset_k > #define pgd_offset_k(address) pgd_offset(&init_mm, (address)) > +#endif >=20 > /* > * In many cases it is known that a virtual address is mapped at PMD = or PTE > --=20 > 2.26.2 >=20