Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp649137pxa; Tue, 11 Aug 2020 11:28:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGrV/dpvPY9r0/e7xb/IlWXPzUTkCOLhsLX5JFBPf1Iq0LJK29KzYOnkHKFihmbZYsFjVR X-Received: by 2002:a17:906:2356:: with SMTP id m22mr27244119eja.124.1597170515026; Tue, 11 Aug 2020 11:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597170515; cv=none; d=google.com; s=arc-20160816; b=usDO4WwCy/2iOXAmWZXqzlNvzCpBoQrGDWYraQESGuC8PVhcY7KJgBKNsvlnrtTFZ0 yQ3O3roqSbJgQI4qcIp3CLHkw7GaiWoTZgQyJxtCMIxEC+Wf2tZaM0bymfQ2Hhu8jHZX Y8L9UNwAlm8ozfkNlHL4yvmqgziGh8wshwtVXh1YPTUVp78PwCt8MJefd+6r5jQINrZb uemcjjWVppQzEWxm2Bgxaeyz95clg5lqsxMkFFtFntHBYmsvhJ5TfTk4NJv4sU+N/C/y ti+oUVQZ9ol9Bq5Da42wOjeMu51j6TaSDKyRA8FyLcwX9RTpdkLxRBAagKS4JCxEk1+r /YAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kg0VF6ErX5lT4lkgbP5PbpghpVG9uMhPSEFo6VamS/k=; b=kaqRVRBmKZTkWbXe5pxJyYct+B/vBnMIkGiv0wDzCcKsfsYJwky/6v7cRsACLVzYva ORZu0fgoqLsmXwBPwSbicnB8gmjjY954WiupPH2smlzKAziGHAcOqOPkbAYq1GKPgcF1 hse4EBm3U4VYIlSCjY6a52oq1K+bhChmUto10VX7rY+b8lgPq309hUMMWd2uE7q46Z2m gK7j8eWL6+Q+umoF0N1OFH4v+TAZPS14Ra494dPnrZz93S8kQzQ7M4ezEs34hes3VnAd IeDN7ThFgokoeCARAhRR86kj22Sk5URNT4IYHaFEp0MMVCuXJoF7pDD8N8cPuphrZbH3 NCdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=FkfQGzpI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gq12si13868336ejb.428.2020.08.11.11.28.11; Tue, 11 Aug 2020 11:28:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@jrtc27.com header.s=gmail.jrtc27.user header.b=FkfQGzpI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726271AbgHKSZj (ORCPT + 99 others); Tue, 11 Aug 2020 14:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbgHKSZh (ORCPT ); Tue, 11 Aug 2020 14:25:37 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA228C061787 for ; Tue, 11 Aug 2020 11:25:36 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id f7so12395186wrw.1 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=EUqyYnvGTvHMLIQXBzOyK5fF6AmKct1krD46SgufRJtLhrnyCOEdu+VH8/aNT/doZh yY5pW0EuoFA9zkjlof69IWq3LxstgmeCB20heCsFOmot7ugCDnri2CKCryLnBm4z5+Qf sYWPewhYVo22v0QJR7nid46HcUFKt5hHNs8kXs2FHlCpoMO7eC6QY+F/R0gpqLz2qm8f jpt3RNka+lXG9CBhZqkljZ5+5TUoaS7Up+lHZKrVdEIzIPK4DAKt0sSG2aVxNGLT4G/D sNs8cPGAQnGLVcheRuEszCfPG1I9YQ87QbAx4okbCUp8cUB/MZhg+bx9Oj8sebl5jiTC q9eA== X-Gm-Message-State: AOAM531BdiqJNeDcj8siG3nKakG0tbfc8WZXeBuUxJZoQ3nozjekbpXw TDmOsLJkZBNy1ar3UuD8xsp1RQ== 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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 -- 2.23.0