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 E4B2AC433E1 for ; Thu, 13 Aug 2020 19:12:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 92FF0206B2 for ; Thu, 13 Aug 2020 19:12:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=jrtc27.com header.i=@jrtc27.com header.b="D87RVrJ7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92FF0206B2 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 2649F6B0028; Thu, 13 Aug 2020 15:12:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 215D46B0029; Thu, 13 Aug 2020 15:12:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 12BD76B002A; Thu, 13 Aug 2020 15:12:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id F06476B0028 for ; Thu, 13 Aug 2020 15:12:29 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A7EEB8248047 for ; Thu, 13 Aug 2020 19:12:29 +0000 (UTC) X-FDA: 77146491618.24.burn95_110309826ff6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 7C7391A4A0 for ; Thu, 13 Aug 2020 19:12:29 +0000 (UTC) X-HE-Tag: burn95_110309826ff6 X-Filterd-Recvd-Size: 7601 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Thu, 13 Aug 2020 19:12:28 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id 9so5580275wmj.5 for ; Thu, 13 Aug 2020 12:12:28 -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=W/BIFbceizggg/9lDLKGKhKgYUcVEubo8er0W9HlrdA=; b=D87RVrJ7KnrOkyzYyqFKdURL4929QTtBzYnToNk7NR5QPJt84BDlCP+R1EOKwzWLmX fkmOhCnhg1/p4COpYq++qVCz4KLBscgyEJCSIRFTGMiCVkRTUhuMwlGe0vfW1tjFeKoL xuCGbq+GrbJSibt4mSXqUHPfEC8a+iFMHlpYKusLzHSYJsnNC66Xo5TgmNfqkGcysw5D NnXhHkyK/o1XpkUWCec/BdnrWwhjXIg6dIlolMe8y9xTe5pR7LKpHhmP8DbPgPU8MdV5 x3Bs03cSpZSUZeyOqWiu7Muf/MGTl6GI2CZXH+fXDmAMpizA4zHPcg1IxjI3mf1pwQZw WqaQ== 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=W/BIFbceizggg/9lDLKGKhKgYUcVEubo8er0W9HlrdA=; b=HWlnljqIcoX9UZQXfQLo0W48aBdZPTljRms+RWDMI+Rgjsa2BTsS3rIZKZooQL7WvS Zvd6Te3SiUmpfe55ifwrccnLlinJiv7PAg8eFJuswrnArSZ0qJ+01+Vp3qNxcPWdOdxV 0eSeuVVQEMtXhCfkpS3Q8e+hWNFWRQn0a+jBBp3RJvk14wR3y+J7HU/Wi7ESE5zbmGbm gqCdnEEZgpBcyFjUFwRFr7/HyK1zsFj53bBDSuGnXWIXXGKEJcxOB26b/YYf3L8IsDHG GB9YieC9DiseGSMNPT+IadbDHJDhOL/G5UBUIZGISPO1lX/QN9A8E7cZCDISW2JqfO/8 G44w== X-Gm-Message-State: AOAM532NE1QHG/7OILPycduK3ukFt3ryGzkuuqpeKEsgHrao478cF1sg a4CvhzTFJDp1q1Sp7nUFrMzkWQ== X-Google-Smtp-Source: ABdhPJws7/mYcdD3+LaGIFQyuOxkURrDb40pMS1U/qpeFEMtmcC3KqAt0FqUudbkDZ2k0ECvtstVmA== X-Received: by 2002:a1c:bc54:: with SMTP id m81mr5943864wmf.73.1597345947663; Thu, 13 Aug 2020 12:12:27 -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 i14sm14062427wrc.19.2020.08.13.12.12.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Aug 2020 12:12:26 -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 v3] arch/ia64: Restore arch-specific pgd_offset_k implementation From: Jessica Clarke In-Reply-To: <20200813190546.4788-1-rppt@kernel.org> Date: Thu, 13 Aug 2020 20:12:25 +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: <13B46F16-1E82-4E15-8F6B-E8C24D6800AA@jrtc27.com> References: <20200813190546.4788-1-rppt@kernel.org> To: Mike Rapoport X-Mailer: Apple Mail (2.3608.120.23.2.1) X-Rspamd-Queue-Id: 7C7391A4A0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000318, 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:05, Mike Rapoport wrote: >=20 > From: Jessica Clarke Given this commit is being attributed to me please apply these = grammatical fixes (and tweaks) to your wording, as well as a technical correction. (I have not re-wrapped, for easier diffing, and due to my laziness) > IA-64 is special and treats pgd_offset_k() differently from = pgd_offset() by > using different formulas to calculate index into kernel and user PGD > tables. The index into user PGDs takes into account the region number > and the index into the kernel (init_mm) PGD always presumes predefined > kernel region number. Commit 974b9b2c68 ("mm: consolidate pte_index() > and pte_offset_*() definitions") made IA-64 to use generic > pgd_offset_k() which wrongly used pgd_index() for user page tables. As > the result, the index into kernel PGD was going out of bounds and the > kernel hang during early boot. >=20 > Allow overrides of pgd_offset_k() and use an override on IA-64 with = the > old implementation that will correctly index kernel PGD. 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. Allow overrides of pgd_offset_k() and override it on IA-64 with the old implementation that will correctly index the kernel PGD. > 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 > --- > 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 > 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. > + */ /* * 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. */ Jess > +#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