Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] riscv: don't use the symbolic satp name in assembler code
       [not found] <20180124132447.5517-1-hch@lst.de>
@ 2018-01-24 22:19 ` Palmer Dabbelt
  2018-01-24 22:19   ` [PATCH 1/4] riscv: remove the unused current_pgdir function Palmer Dabbelt
                     ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-01-24 22:19 UTC (permalink / raw)
  To: linux-riscv

On Wed, 24 Jan 2018 05:24:47 PST (-0800), Christoph Hellwig wrote:
> The most recent release binutils release (2.29) doesn't know about
> the satp name yet, so stick to the name from the previous privileged
> ISA release and comment on the fact.

I think it'd be better to squash these into the previous cleanup you sent, just
to make sure the kernel always builds.  How do these look?

[PATCH 1/4] riscv: remove the unused current_pgdir function
[PATCH 2/4] riscv: don't read back satp in paging_init
[PATCH 3/4] riscv: rename sptbr to satp
[PATCH 4/4] riscv: inline set_pgdir into its only caller

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] riscv: remove the unused current_pgdir function
  2018-01-24 22:19 ` [PATCH] riscv: don't use the symbolic satp name in assembler code Palmer Dabbelt
@ 2018-01-24 22:19   ` Palmer Dabbelt
  2018-01-24 22:19   ` [PATCH 2/4] riscv: don't read back satp in paging_init Palmer Dabbelt
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-01-24 22:19 UTC (permalink / raw)
  To: linux-riscv

From: Christoph Hellwig <hch@lst.de>

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
---
 arch/riscv/include/asm/mmu_context.h | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/arch/riscv/include/asm/mmu_context.h b/arch/riscv/include/asm/mmu_context.h
index 97424834dce2..082ef8652ac7 100644
--- a/arch/riscv/include/asm/mmu_context.h
+++ b/arch/riscv/include/asm/mmu_context.h
@@ -39,11 +39,6 @@ static inline void destroy_context(struct mm_struct *mm)
 {
 }
 
-static inline pgd_t *current_pgdir(void)
-{
-	return pfn_to_virt(csr_read(sptbr) & SPTBR_PPN);
-}
-
 static inline void set_pgdir(pgd_t *pgd)
 {
 	csr_write(sptbr, virt_to_pfn(pgd) | SPTBR_MODE);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] riscv: don't read back satp in paging_init
  2018-01-24 22:19 ` [PATCH] riscv: don't use the symbolic satp name in assembler code Palmer Dabbelt
  2018-01-24 22:19   ` [PATCH 1/4] riscv: remove the unused current_pgdir function Palmer Dabbelt
@ 2018-01-24 22:19   ` Palmer Dabbelt
  2018-01-24 22:19   ` [PATCH 3/4] riscv: rename sptbr to satp Palmer Dabbelt
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-01-24 22:19 UTC (permalink / raw)
  To: linux-riscv

From: Christoph Hellwig <hch@lst.de>

init_mm.pgd (aka swapped_pgd) gets relocated like all other kernel
symbols by the elf loader, so there is no need to reload it from satp.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
---
 arch/riscv/mm/init.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 9f4bee5e51fd..26a291ee792e 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -39,8 +39,6 @@ void setup_zero_page(void)
 
 void __init paging_init(void)
 {
-	init_mm.pgd = (pgd_t *)pfn_to_virt(csr_read(sptbr));
-
 	setup_zero_page();
 	local_flush_tlb_all();
 	zone_sizes_init();
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] riscv: rename sptbr to satp
  2018-01-24 22:19 ` [PATCH] riscv: don't use the symbolic satp name in assembler code Palmer Dabbelt
  2018-01-24 22:19   ` [PATCH 1/4] riscv: remove the unused current_pgdir function Palmer Dabbelt
  2018-01-24 22:19   ` [PATCH 2/4] riscv: don't read back satp in paging_init Palmer Dabbelt
@ 2018-01-24 22:19   ` Palmer Dabbelt
  2018-01-24 22:19   ` [PATCH 4/4] riscv: inline set_pgdir into its only caller Palmer Dabbelt
  2018-01-25  7:20   ` [PATCH] riscv: don't use the symbolic satp name in assembler code Christoph Hellwig
  4 siblings, 0 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-01-24 22:19 UTC (permalink / raw)
  To: linux-riscv

From: Christoph Hellwig <hch@lst.de>

satp is the name used by the current privileged spec 1.10, use it
instead of the old name.  The most recent release binutils release
(2.29) doesn't know about the satp name yet, so stick to the name from
the previous privileged ISA release and comment on the fact.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
---
 arch/riscv/include/asm/csr.h         | 14 +++++++-------
 arch/riscv/include/asm/mmu_context.h |  7 ++++++-
 arch/riscv/kernel/head.S             |  6 +++---
 arch/riscv/mm/fault.c                |  4 ++++
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h
index 3c7a2c97e377..421fa3585798 100644
--- a/arch/riscv/include/asm/csr.h
+++ b/arch/riscv/include/asm/csr.h
@@ -40,15 +40,15 @@
 #define SR_SD   _AC(0x8000000000000000, UL) /* FS/XS dirty */
 #endif
 
-/* SPTBR flags */
+/* SATP flags */
 #if __riscv_xlen == 32
-#define SPTBR_PPN     _AC(0x003FFFFF, UL)
-#define SPTBR_MODE_32 _AC(0x80000000, UL)
-#define SPTBR_MODE    SPTBR_MODE_32
+#define SATP_PPN     _AC(0x003FFFFF, UL)
+#define SATP_MODE_32 _AC(0x80000000, UL)
+#define SATP_MODE    SATP_MODE_32
 #else
-#define SPTBR_PPN     _AC(0x00000FFFFFFFFFFF, UL)
-#define SPTBR_MODE_39 _AC(0x8000000000000000, UL)
-#define SPTBR_MODE    SPTBR_MODE_39
+#define SATP_PPN     _AC(0x00000FFFFFFFFFFF, UL)
+#define SATP_MODE_39 _AC(0x8000000000000000, UL)
+#define SATP_MODE    SATP_MODE_39
 #endif
 
 /* Interrupt Enable and Interrupt Pending flags */
diff --git a/arch/riscv/include/asm/mmu_context.h b/arch/riscv/include/asm/mmu_context.h
index 082ef8652ac7..d30f0c54b8b2 100644
--- a/arch/riscv/include/asm/mmu_context.h
+++ b/arch/riscv/include/asm/mmu_context.h
@@ -41,7 +41,12 @@ static inline void destroy_context(struct mm_struct *mm)
 
 static inline void set_pgdir(pgd_t *pgd)
 {
-	csr_write(sptbr, virt_to_pfn(pgd) | SPTBR_MODE);
+	/*
+	 * Use the old spbtr name instead of using the current satp
+	 * name to support binutils 2.29 which doesn't know about the
+	 * privileged ISA 1.10 yet.
+	 */
+	csr_write(sptbr, virt_to_pfn(next->pgd) | SATP_MODE);
 }
 
 /*
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index 78f670d70133..226eeb190f90 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -74,15 +74,15 @@ relocate:
 	sub a1, a1, a0
 	add ra, ra, a1
 
-	/* Point stvec to virtual address of intruction after sptbr write */
+	/* Point stvec to virtual address of intruction after satp write */
 	la a0, 1f
 	add a0, a0, a1
 	csrw stvec, a0
 
-	/* Compute sptbr for kernel page tables, but don't load it yet */
+	/* Compute satp for kernel page tables, but don't load it yet */
 	la a2, swapper_pg_dir
 	srl a2, a2, PAGE_SHIFT
-	li a1, SPTBR_MODE
+	li a1, SATP_MODE
 	or a2, a2, a1
 
 	/*
diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c
index 0713f3c67ab4..06c5621970ae 100644
--- a/arch/riscv/mm/fault.c
+++ b/arch/riscv/mm/fault.c
@@ -239,6 +239,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
 		 * Do _not_ use "tsk->active_mm->pgd" here.
 		 * We might be inside an interrupt in the middle
 		 * of a task switch.
+		 *
+		 * Note: Use the old spbtr name instead of using the current
+		 * satp name to support binutils 2.29 which doesn't know about
+		 * the privileged ISA 1.10 yet.
 		 */
 		index = pgd_index(addr);
 		pgd = (pgd_t *)pfn_to_virt(csr_read(sptbr)) + index;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] riscv: inline set_pgdir into its only caller
  2018-01-24 22:19 ` [PATCH] riscv: don't use the symbolic satp name in assembler code Palmer Dabbelt
                     ` (2 preceding siblings ...)
  2018-01-24 22:19   ` [PATCH 3/4] riscv: rename sptbr to satp Palmer Dabbelt
@ 2018-01-24 22:19   ` Palmer Dabbelt
  2018-01-25  7:20   ` [PATCH] riscv: don't use the symbolic satp name in assembler code Christoph Hellwig
  4 siblings, 0 replies; 6+ messages in thread
From: Palmer Dabbelt @ 2018-01-24 22:19 UTC (permalink / raw)
  To: linux-riscv

From: Christoph Hellwig <hch@lst.de>

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
---
 arch/riscv/include/asm/mmu_context.h | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/arch/riscv/include/asm/mmu_context.h b/arch/riscv/include/asm/mmu_context.h
index d30f0c54b8b2..336d60ec5698 100644
--- a/arch/riscv/include/asm/mmu_context.h
+++ b/arch/riscv/include/asm/mmu_context.h
@@ -39,16 +39,6 @@ static inline void destroy_context(struct mm_struct *mm)
 {
 }
 
-static inline void set_pgdir(pgd_t *pgd)
-{
-	/*
-	 * Use the old spbtr name instead of using the current satp
-	 * name to support binutils 2.29 which doesn't know about the
-	 * privileged ISA 1.10 yet.
-	 */
-	csr_write(sptbr, virt_to_pfn(next->pgd) | SATP_MODE);
-}
-
 /*
  * When necessary, performs a deferred icache flush for the given MM context,
  * on the local CPU.  RISC-V has no direct mechanism for instruction cache
@@ -93,7 +83,12 @@ static inline void switch_mm(struct mm_struct *prev,
 		cpumask_clear_cpu(cpu, mm_cpumask(prev));
 		cpumask_set_cpu(cpu, mm_cpumask(next));
 
-		set_pgdir(next->pgd);
+		/*
+		 * Use the old spbtr name instead of using the current satp
+		 * name to support binutils 2.29 which doesn't know about the
+		 * privileged ISA 1.10 yet.
+		 */
+		csr_write(sptbr, virt_to_pfn(next->pgd) | SATP_MODE);
 		local_flush_tlb_all();
 
 		flush_icache_deferred(next);
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] riscv: don't use the symbolic satp name in assembler code
  2018-01-24 22:19 ` [PATCH] riscv: don't use the symbolic satp name in assembler code Palmer Dabbelt
                     ` (3 preceding siblings ...)
  2018-01-24 22:19   ` [PATCH 4/4] riscv: inline set_pgdir into its only caller Palmer Dabbelt
@ 2018-01-25  7:20   ` Christoph Hellwig
  4 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2018-01-25  7:20 UTC (permalink / raw)
  To: linux-riscv

On Wed, Jan 24, 2018 at 02:19:09PM -0800, Palmer Dabbelt wrote:
> On Wed, 24 Jan 2018 05:24:47 PST (-0800), Christoph Hellwig wrote:
> > The most recent release binutils release (2.29) doesn't know about
> > the satp name yet, so stick to the name from the previous privileged
> > ISA release and comment on the fact.
> 
> I think it'd be better to squash these into the previous cleanup you sent, just
> to make sure the kernel always builds.  How do these look?

Sure, fine with me.  Thanks for doing the work, next time I'd be happy
to resend as well.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-25  7:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20180124132447.5517-1-hch@lst.de>
2018-01-24 22:19 ` [PATCH] riscv: don't use the symbolic satp name in assembler code Palmer Dabbelt
2018-01-24 22:19   ` [PATCH 1/4] riscv: remove the unused current_pgdir function Palmer Dabbelt
2018-01-24 22:19   ` [PATCH 2/4] riscv: don't read back satp in paging_init Palmer Dabbelt
2018-01-24 22:19   ` [PATCH 3/4] riscv: rename sptbr to satp Palmer Dabbelt
2018-01-24 22:19   ` [PATCH 4/4] riscv: inline set_pgdir into its only caller Palmer Dabbelt
2018-01-25  7:20   ` [PATCH] riscv: don't use the symbolic satp name in assembler code Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox