From patchwork Tue Aug 11 18:24:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jessica Clarke X-Patchwork-Id: 11709501 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFE8F739 for ; Tue, 11 Aug 2020 18:25:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8889220786 for ; Tue, 11 Aug 2020 18:25:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=jrtc27.com header.i=@jrtc27.com header.b="FkfQGzpI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8889220786 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 7E7576B0002; Tue, 11 Aug 2020 14:25:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7988B6B0005; Tue, 11 Aug 2020 14:25:39 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 686CB6B0006; Tue, 11 Aug 2020 14:25:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id 549026B0002 for ; Tue, 11 Aug 2020 14:25:39 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C3E9F180AD81A for ; Tue, 11 Aug 2020 18:25:38 +0000 (UTC) X-FDA: 77139115956.09.work85_52026d926fe5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 4F46A180AD806 for ; Tue, 11 Aug 2020 18:25:38 +0000 (UTC) X-Spam-Summary: 1,0,0,f0308899a0550a16,d41d8cd98f00b204,jrtc27@jrtc27.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:2393:2559:2562:2895:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4117:4250:4321:4605:5007:6119:6261:6653:7807:7903:9036:10004:11026:11232:11473:11657:11658:11914:12043:12296:12297:12517:12519:12555:12679:12895:12986:13095:13141:13221:13229:13230:13894:14096:14130:14181:14394:14721:21080:21324:21433:21444:21451:21627:21939:30003:30034:30054:30060:30069:30070,0,RBL:209.85.221.65:@jrtc27.com:.lbl8.mailshell.net-62.2.0.100 66.100.201.201;04y8d7iccas1mnw1xr3gk1wuwrq78opwgtnpct5z87k3jargsotpeosqqw3y73p.xdra78ytpgsoerfeusby5wn9crwpt8coertkw4im8dyjw7knesdk6a8ekqcmwfw.n-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: work85_52026d926fe5 X-Filterd-Recvd-Size: 6062 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Tue, 11 Aug 2020 18:25:37 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id a15so12349203wrh.10 for ; Tue, 11 Aug 2020 11:25:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jrtc27.com; s=gmail.jrtc27.user; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kg0VF6ErX5lT4lkgbP5PbpghpVG9uMhPSEFo6VamS/k=; b=FkfQGzpI44fbqgrcOaj1mgkIjSMLmbJv3+916pIl7eKyrNEb/q5Qf6pcbttxCIlXMC soo0SglK/yG3GOLxSmMNYjNLmD7B9jzwqC5PD5sxiif9EaDqEngFD8CtscBayUAhhNdK yzJHHOxgnoLpCozUcFjyDe3yvHFeV7Fn3ESp+MZ4cQDAjhBDUgjr02p9Q0Y5IoSjPOQF zL0/wsPE7hZnmXCGQsn0tHiUM6Mqa2SMZqVY9ojuftOmgiDa6D0KYCDXNku/nfRfNG6/ rulqM/TzsVmO14H6DC6ye4zfwGMM3nqJRuTAR9EAcJgD8CBbRPrAElqfkAHRmLM2ctPW +A/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kg0VF6ErX5lT4lkgbP5PbpghpVG9uMhPSEFo6VamS/k=; b=eWUiapwF4l5X40pdlp8PXDTtRLFy2UTXWGW958g3YgYp+rnPws4CwbfYfxkDZBTceu sQ7jVix50mazLvh5j7rqnXfI5OglsA6C+Fx+8Z7H5yOS06G0DXwIs9OJsfcJr4YKg6+O MxHC5kmn02jRMuPfPBGd8soxKYB3EaoGz2iAJtkHYG4ZcZMRpv8AmLzFcOqSVr18TRST n+BpGoE9SL0AYkV5reE4+ha+fXCB+kraD8ZQIgQLBiBBUncOq/rM5plV75k5PC62B5Mn oG/o8vhps6ctqLaOGdM1Ndq+Kffkg5UJdHua9xDyLX4+uhHn4x959YvCJSYJkgaIDAO+ vHZA== X-Gm-Message-State: AOAM533h684TcfJxECmoY5+5d9ViWWSHH8+Deus5RgREb7sP8yqMZvkd 6Tjs/6S+JZr8JuwZGJSUABPgRA== X-Google-Smtp-Source: ABdhPJx3xd5kWvkA/X2/NFNPoUCPO1s6nR2S1WU2LkG5uY9O7IMEyCUYrD8bC3Aplc8N5CFwdop0eg== X-Received: by 2002:a5d:6a8b:: with SMTP id s11mr29945727wru.222.1597170335629; Tue, 11 Aug 2020 11:25:35 -0700 (PDT) Received: from Jessicas-MacBook.local (trinity-students-nat.trin.cam.ac.uk. [131.111.193.104]) by smtp.gmail.com with ESMTPSA id i4sm28401118wrw.26.2020.08.11.11.25.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Aug 2020 11:25:35 -0700 (PDT) Received: by Jessicas-MacBook.local (Postfix, from userid 501) id 6EE9C207EFCE4D; Tue, 11 Aug 2020 19:25:34 +0100 (BST) From: Jessica Clarke To: John Paul Adrian Glaubitz Cc: Jessica Clarke , Mike Rapoport , Tony Luck , "linux-ia64@vger.kernel.org" , Anatoly Pugachev , Sergei Trofimovich , Linux MM , Linux Kernel Mailing List , Frank Scheiner Subject: [PATCH v2] arch/ia64: Restore arch-specific pgd_offset_k implementation Date: Tue, 11 Aug 2020 19:24:57 +0100 Message-Id: <20200811182457.57957-1-jrtc27@jrtc27.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4F46A180AD806 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: IA-64 is special and treats pgd_offset_k differently from pgd_offset by not including the region number, and init_mm's PGD is such that it only points to the kernel's region's PGD. This was broken in 974b9b2c68 which unified the two and therefore included the region number, causing it to go way out of bounds of the kernel's PGD, which made the kernel hang during early boot. Thus, permit pgd_offset_k to be overridden like the other macros and override it on IA-64 with the old implementation. Also update the comment to clarify that this is not just an optimisation but a required implementation detail. 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 Reviewed-by: Mike Rapoport --- Changes since v1: * Fixed typo in commit message * Slightly reworded commit message to sound less weird * Included Adrian's Tested-by arch/ia64/include/asm/pgtable.h | 8 ++++++++ include/linux/pgtable.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h index 10850897a91c..2ac2199d99ce 100644 --- a/arch/ia64/include/asm/pgtable.h +++ b/arch/ia64/include/asm/pgtable.h @@ -366,6 +366,14 @@ pgd_index (unsigned long address) } #define pgd_index pgd_index +/* + * 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, but + * that means not adding the region here is required, not just an optimisation. + */ +#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 53e97da1e8e2..73c64fe098ba 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 /* * In many cases it is known that a virtual address is mapped at PMD or PTE