Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp296358yba; Wed, 24 Apr 2019 01:04:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl48tm7uYtzIl4xJpUq9athJ5V9kkB1JZlCdvevr9V4eW8A4wJ3MDGtZUwn8o/TB24yUSy X-Received: by 2002:a65:6202:: with SMTP id d2mr29456751pgv.176.1556093082524; Wed, 24 Apr 2019 01:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556093082; cv=none; d=google.com; s=arc-20160816; b=z4tyPeBpdNkWOo2YROw3JdmGVWYZJv+2BY+AfAG3Z0RMQHTGQRA86Y6Wg0he5m9Mpa QVGxwi1xj2O4iTw1GZZjHERsF9S/Ujx2NGWmlJMGr+9hN7n0NX+7dmLeet6eQ6eVUjAo PI4vE4ggn+RfEQTN9USElCBbtSPZQcUzTbd5v9KYYOX7VnKDDLB2N3p9Wo/4+Gxm1oTm dA9rn7OZbpdxZA2e3xuTHVofIXbRKewTjRPe33CfY++Z4aWPN+mZFTq2tHracOcE8K6h AcQZmDcJuBUAaJIhCnhTFUtN9CcJ2nvv57MlFGTUkVEsmGhFIp7il1QqrnbzgJ2iJvhL TVwg== 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=MUzBcZSYyjNmVAln4pH9+hDa+BhI195V73WdadLwrkU=; b=Shh6bWYXrOeNDpI4TzBUWGpWLBNSkQffO/vryIraqp2YMFsSzZflqildjJCKEVXIjI 51xuaHBA2dDWsDKN0HGCGIeCEooU8Sm4Mp4JfWl3q0gMn27ydgawK8fI7E5QteJqV9XS eIrEwxSHmjDHnW/LZAdhZqTjO6/31eykVket+o+Owvdri0K6RdCE67eOCD2h+zVqK3eq iaOTP2IfflyHtWcUdBYP9Y26JuWKicGqqfAg9X3DKLnkIDjf9DKa/GRQoy/xpznhadXK ivz1gzP7DNz7ChBko5D5D5alCjmANmTV8nLEbmgEP+amSB6gQaEY4j1tHBRzhPlf+qM1 Fbjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WSYYeM2z; 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 y3si8169326pgy.134.2019.04.24.01.04.16; Wed, 24 Apr 2019 01:04:42 -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=WSYYeM2z; 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 S1729927AbfDXHv0 (ORCPT + 99 others); Wed, 24 Apr 2019 03:51:26 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:41905 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728927AbfDXHv0 (ORCPT ); Wed, 24 Apr 2019 03:51:26 -0400 Received: by mail-pf1-f195.google.com with SMTP id 188so8868110pfd.8 for ; Wed, 24 Apr 2019 00:51:25 -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=MUzBcZSYyjNmVAln4pH9+hDa+BhI195V73WdadLwrkU=; b=WSYYeM2z+eSgl8RJu1kf4xsUmWL7TbV5E6Ksim/kAqfLPjA9PZ2Ruuvb75pEEBqmaO hmWO8ZJfjNoZbzzYPXrRpUjgt+lJD3bGSmVjVYN2/NEqvqoD8j0iKTDs2o+VhkFoWGds 2h1UGZnLo647Fkru6r8zZyfQfjZNFXTKr9jQeyHFnKf7ysfUwJ7XjFtutT1KGrKFfwRs +1WMMPH3DzHK5klPDLqH4FpXyp+8fnxG4KLx4sguNKZYUyYmi4AeFPShJ9wO/0d1Aky0 sdobm3ERFskuhlTX5kM4GeTCYdI9x1W8Jb5znHsCNaQYZE9DWOvN6IULgWk6dDXp8VfP Tagw== 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=MUzBcZSYyjNmVAln4pH9+hDa+BhI195V73WdadLwrkU=; b=MC9ilCj33wD/atcWKFdJEWGHqJr2H0zcZd+kQCYbimazJCT4Zm06ZTt40ec2THEK8W BRGVkt2GYFm3b4fen/igHlWUY2qceM4iUR9ByteCB+D9ctgd7N8ZjbZy5UEhVbbBSvom nLSBOzdO/+elD0+HaiOREeID23ZXK+Js4SqFGQN4kYpVnd5Ag2WSo4/q2aK9O4Vg96SJ j3d/leVc34eItF9Ka4EykX9CtEUgoAr6Rlpkz1zfCE1nXzazliNFFHgEgVW3+LrdanP5 4lML6+DUvWJCRsX8/wX7dU5Ydg8jNKo86rKtDv1OqML2NxfJLWhrIq8wyMU7PpSEw8lO bcPw== X-Gm-Message-State: APjAAAU+fbXJj6w5q1uS8kUYmp32YErh84aYwWByXugBTtcl/ao6/2Hq SGPKe7Bzf7SDWCqJ+EonuAI= X-Received: by 2002:a63:6e88:: with SMTP id j130mr6603072pgc.452.1556092285074; Wed, 24 Apr 2019 00:51:25 -0700 (PDT) Received: from pcliush.allwinnertech.com ([223.197.233.48]) by smtp.gmail.com with ESMTPSA id y23sm26230823pfn.25.2019.04.24.00.51.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Apr 2019 00:51:24 -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: Wed, 24 Apr 2019 15:51:08 +0800 Message-Id: <1556092268-4646-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 | 8 ++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/riscv/include/asm/pgtable-32.h b/arch/riscv/include/asm/pgtable-32.h index d61974b7..433886b 100644 --- a/arch/riscv/include/asm/pgtable-32.h +++ b/arch/riscv/include/asm/pgtable-32.h @@ -17,6 +17,8 @@ #include #include +#define __PAGETABLE_PMD_FOLDED 1 +#define MAX_USER_VA_BITS 32 /* Size of region mapped by a page global directory */ #define PGDIR_SHIFT 22 #define PGDIR_SIZE (_AC(1, UL) << PGDIR_SHIFT) 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..9148043 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -33,9 +33,13 @@ #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)) +#ifdef __PAGETABLE_PMD_FOLDED +#define PTRS_PER_PTE (1 << (PGDIR_SHIFT - PAGE_SHIFT)) +#else +#define PTRS_PER_PTE (1 << (PMD_SHIFT - PAGE_SHIFT)) +#endif /* Number of PGD entries that a user-mode program can use */ #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) -- 1.9.1