From: JaeJoon Jung <rgbi3307@gmail.com>
To: linux-riscv@lists.infradead.org
Subject: [PATCH] riscv: using page table index in setup_vm()
Date: Mon, 20 May 2019 17:48:24 +0900 [thread overview]
Message-ID: <CAHOvCC7EtFcYQDAQoenP7RdwW-4FQEex4FG5jLR2W0m+Q8t__Q@mail.gmail.com> (raw)
From: JaeJoon Jung <rgbi3307@gmail.com>
The page table index macro are defined already in pgtable.h as below:
///arch/riscv/include/asm/pgtable.h
#define pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_PGD - 1))
#define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
///arch/riscv/include/asm/pgtable-64.h
#define pmd_index(addr) (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1))
But, In the arch/riscv/mm/init.c,
I found that it does not use above macro in setup_vm().
I wat to use this macro in setup_vm() as below:
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
Cc: Anup Patel <anup.patel@wdc.com>
Cc: linux-riscv@lists.infradead.org
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index bc7b77e34d09..785954b776ac 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
asmlinkage void __init setup_vm(void)
{
extern char _start;
@@ -223,13 +190,13 @@ asmlinkage void __init setup_vm(void)
BUG_ON((pa % (PAGE_SIZE * PTRS_PER_PTE)) != 0);
#ifndef __PAGETABLE_PMD_FOLDED
- trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ trampoline_pg_dir[pgd_index(PAGE_OFFSET)] =
pfn_pgd(PFN_DOWN((uintptr_t)trampoline_pmd),
__pgprot(_PAGE_TABLE));
trampoline_pmd[0] = pfn_pmd(PFN_DOWN(pa), prot);
for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
- size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
+ size_t o = pgd_index(PAGE_OFFSET) + i;
swapper_pg_dir[o] =
pfn_pgd(PFN_DOWN((uintptr_t)swapper_pmd) + i,
@@ -238,24 +205,23 @@ asmlinkage void __init setup_vm(void)
for (i = 0; i < ARRAY_SIZE(swapper_pmd); i++)
swapper_pmd[i] = pfn_pmd(PFN_DOWN(pa + i * PMD_SIZE), prot);
- swapper_pg_dir[(FIXADDR_START >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ swapper_pg_dir[pgd_index(FIXADDR_START)] =
pfn_pgd(PFN_DOWN((uintptr_t)fixmap_pmd),
__pgprot(_PAGE_TABLE));
- fixmap_pmd[(FIXADDR_START >> PMD_SHIFT) % PTRS_PER_PMD] =
+ fixmap_pmd[pmd_index(FIXADDR_START)] =
pfn_pmd(PFN_DOWN((uintptr_t)fixmap_pte),
__pgprot(_PAGE_TABLE));
#else
- trampoline_pg_dir[(PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ trampoline_pg_dir[pgd_index(PAGE_OFFSET)] =
pfn_pgd(PFN_DOWN(pa), prot);
for (i = 0; i < (-PAGE_OFFSET)/PGDIR_SIZE; ++i) {
- size_t o = (PAGE_OFFSET >> PGDIR_SHIFT) % PTRS_PER_PGD + i;
+ size_t o = pgd_index(PAGE_OFFSET) + i;
swapper_pg_dir[o] =
pfn_pgd(PFN_DOWN(pa + i * PGDIR_SIZE), prot);
}
-
- swapper_pg_dir[(FIXADDR_START >> PGDIR_SHIFT) % PTRS_PER_PGD] =
+ swapper_pg_dir[pgd_index(FIXADDR_START)] =
pfn_pgd(PFN_DOWN((uintptr_t)fixmap_pte),
__pgprot(_PAGE_TABLE));
#endif
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2019-05-20 8:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-20 8:48 JaeJoon Jung [this message]
2019-05-23 9:52 ` [PATCH] riscv: using page table index in setup_vm() Mike Rapoport
2019-05-23 10:12 ` JaeJoon Jung
2019-06-28 6:04 ` Paul Walmsley
2019-06-28 6:11 ` Christoph Hellwig
2019-06-28 8:11 ` Anup Patel
2019-06-28 10:38 ` JaeJoon Jung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHOvCC7EtFcYQDAQoenP7RdwW-4FQEex4FG5jLR2W0m+Q8t__Q@mail.gmail.com \
--to=rgbi3307@gmail.com \
--cc=linux-riscv@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).