Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4707260yba; Wed, 17 Apr 2019 17:58:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqztfu/HAeKJWlGKre8MNIQfG+BTc2rnA6ibbhkQjHmKisg4sQMvRXt1L6fhWvYFRC1m2mQU X-Received: by 2002:a65:648c:: with SMTP id e12mr86624952pgv.346.1555549089148; Wed, 17 Apr 2019 17:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555549089; cv=none; d=google.com; s=arc-20160816; b=r/MtJp/y8ciC0EvaQXgiCwpHkTsUBGf55rvaj8bOc2jgTUEi7kAOLm78bKiLKlWVVq B0mtLSesbicu/3zLkmcdZ+eOwFBA/tCh5DV3aiZVsUYG4IEA3gR2BWofvVJWMtjPs7Rx lppRSAIMBnwmyishOFJi3zR0oIO4Skk+rCxYYmTurqUgeyrY2P7T6kSBhLn2uO3HweR3 JS1Qhl2ms+M8T7V9THMaLS9edhLij5mEeQjz5uDpg4RSfqQ4IAIjVGqRg7iqrb8ZX/2n YvZ7r2DUu6XTjoF151QAvPM18ixe30RSDCtb2MgzusLPBNFik+CR6Ah7x4BJ65stthwQ EKjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=NCTHDha1xM/aVhgZQjb426tHN47IE4D29YS6s+8P+hI=; b=cBBZ6cMJPFkH8mQOIr4VU2pFIhzlm1Rt07XPMqI4asTOXNoxX52fqV4aF0wG0p3Y4N 4qlGmcZwEUC1ut59NkM+B1VqfyzO1y1DXW/6/76uTJYcjSKDPNrFkDfe/Z7inMgzPIN2 3uZEDOmM49igzK71d025i51fM8dr7tELWl4hDoyUdXbEUJAnrPX5wd9HO4dCwzj/Jiid Rfd5llXTXIAYbhBdNajtrLvBxGDhDZOwybFugxnNuc6tTNJU5IxS+Ki9c9u+koT1uUYk oagrLmz4Pj6dqrCCKfbpAZAU3j9DsAkMj86SUGbnfouA1Pki51SgaV3ksMaXnMx5aI7s MmIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lyvDfTTa; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si534636pls.395.2019.04.17.17.57.53; Wed, 17 Apr 2019 17:58:09 -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=@gmail.com header.s=20161025 header.b=lyvDfTTa; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387687AbfDRA4a (ORCPT + 99 others); Wed, 17 Apr 2019 20:56:30 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45426 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729331AbfDRA43 (ORCPT ); Wed, 17 Apr 2019 20:56:29 -0400 Received: by mail-pg1-f195.google.com with SMTP id y3so327931pgk.12 for ; Wed, 17 Apr 2019 17:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=NCTHDha1xM/aVhgZQjb426tHN47IE4D29YS6s+8P+hI=; b=lyvDfTTaK38CqH1AhVyLFO5T4uwMdNwEKxMXlLK6Lpa3f85mFo4McQeMf8zqhAOhXR bzNV3fMbnmQTCPuPsop6W2MbELV/HdTm6TOmNhicM5OpKt617ir9uMXZrm/aeE6mqS5L oklQjol5CW+xUvNOci0gOlMPa9X3RKaSzvTkVFmkzQY2lWFnqOHn7FxqyQ4Oj0HuraTQ 48vTGo0JB5aRwV8wjJ5WwkcKvyQZo37HI+uoUGXoZC5IMnUw4yLuM3/v1Buyc4F0Eh3a 1Y12KICsKkRC1RIdvDEd91/cvpPoYk6CmhGJol4zWVvuRNpJbKCSRXH/I9FAtZxQkgki GyZA== 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; bh=NCTHDha1xM/aVhgZQjb426tHN47IE4D29YS6s+8P+hI=; b=c+rnl7lCEihCm2tRmBoDliRR8ubiuFDMRJn1BWRRvfW1sRNVhVPisCmpd0qjzDmYN/ MMk0UXp62WmZJcRgVI7PMFx73pDXeQTz7lkITkwl/Ng6GURiuHjTI4toKnKhLFKVpp4S JDbAbiAetQY/XQSzHXRuWfbVW2pmS+VSsTcf1kIC4vWB3TGnLf7bn0vu8nYhxPYDnZiB GeOUPNLUMkZPsRFUwH+aoQUsiU14xnO358FXEddna5GcVX2pajzl/pN1Tat2M4104h6D KGli/6xINKuxGWlFLnhr6poghXgVbs1oIXlVavK8ff695NZ40s6AuUlv38lDc+PxWO/X S86Q== X-Gm-Message-State: APjAAAWCHcmgG0yRI0H7N6qM475OfSU1M/7Q2fUz5aSIIAdIllkKwvYK cJeSm6pfd/y+Uc2lpAaMdVo= X-Received: by 2002:a63:4e10:: with SMTP id c16mr85610316pgb.302.1555548989107; Wed, 17 Apr 2019 17:56:29 -0700 (PDT) Received: from pcliush.allwinnertech.com ([223.197.233.48]) by smtp.gmail.com with ESMTPSA id p14sm535622pfa.26.2019.04.17.17.56.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Apr 2019 17:56:28 -0700 (PDT) From: damon To: palmer@sifive.com Cc: aou@eecs.berkeley.edu, anup.patel@wdc.com, liush.damon@gmail.com, rppt@linux.ibm.com, sorear2@gmail.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] RISC-V: redefine PTRS_PER_PGD/PTRS_PER_PMD/PTRS_PER_PTE Date: Thu, 18 Apr 2019 08:56:15 +0800 Message-Id: <1555548975-7011-1-git-send-email-liush.damon@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the number of addresses to define the relevant macros. Signed-off-by: damon --- arch/riscv/include/asm/pgtable-32.h | 2 ++ arch/riscv/include/asm/pgtable-64.h | 3 ++- arch/riscv/include/asm/pgtable.h | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/riscv/include/asm/pgtable-32.h b/arch/riscv/include/asm/pgtable-32.h index d61974b7..93607f6 100644 --- a/arch/riscv/include/asm/pgtable-32.h +++ b/arch/riscv/include/asm/pgtable-32.h @@ -17,8 +17,10 @@ #include #include +#define MAX_USER_VA_BITS 32 /* Size of region mapped by a page global directory */ #define PGDIR_SHIFT 22 +#define PMD_SHIFT PGDIR_SHIFT #define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT) #define PGDIR_MASK (~(PGDIR_SIZE - 1)) diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index 7aa0ea9..a56d4d0 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -16,6 +16,7 @@ #include +#define MAX_USER_VA_BITS 39 #define PGDIR_SHIFT 30 /* Size of region mapped by a page global directory */ #define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT) @@ -34,7 +35,7 @@ #define pmd_val(x) ((x).pmd) #define __pmd(x) ((pmd_t) { (x) }) -#define PTRS_PER_PMD (PAGE_SIZE / sizeof(pmd_t)) +#define PTRS_PER_PMD (1 << (PGDIR_SHIFT - PMD_SHIFT)) static inline int pud_present(pud_t pud) { diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 1141364..d9cb3c8 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -33,9 +33,9 @@ #endif /* CONFIG_64BIT */ /* Number of entries in the page global directory */ -#define PTRS_PER_PGD (PAGE_SIZE / sizeof(pgd_t)) +#define PTRS_PER_PGD (1 << (MAX_USER_VA_BITS - PGDIR_SHIFT)) /* Number of entries in the page table */ -#define PTRS_PER_PTE (PAGE_SIZE / sizeof(pte_t)) +#define PTRS_PER_PTE (1 << (PMD_SHIFT - PAGE_SHIFT)) /* Number of PGD entries that a user-mode program can use */ #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) -- 1.9.1