Re: [PATCH v4 27/34] nios2: Convert __pte_free_tlb() to use ptdescs
On 6/12/23 16:04, Vishal Moola (Oracle) wrote: Part of the conversions to replace pgtable constructor/destructors with ptdesc equivalents. Signed-off-by: Vishal Moola (Oracle) --- arch/nios2/include/asm/pgalloc.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/nios2/include/asm/pgalloc.h b/arch/nios2/include/asm/pgalloc.h index ecd1657bb2ce..ce6bb8e74271 100644 --- a/arch/nios2/include/asm/pgalloc.h +++ b/arch/nios2/include/asm/pgalloc.h @@ -28,10 +28,10 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, extern pgd_t *pgd_alloc(struct mm_struct *mm); -#define __pte_free_tlb(tlb, pte, addr)\ - do {\ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), (pte)); \ +#define __pte_free_tlb(tlb, pte, addr) \ + do {\ + pagetable_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ } while (0) #endif /* _ASM_NIOS2_PGALLOC_H */ Applied! Thanks, Dinh ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v4 27/34] nios2: Convert __pte_free_tlb() to use ptdescs
On 6/14/23 04:30, Geert Uytterhoeven wrote: Hi Dinh, On Wed, Jun 14, 2023 at 12:17 AM Dinh Nguyen wrote: On 6/12/23 16:04, Vishal Moola (Oracle) wrote: Part of the conversions to replace pgtable constructor/destructors with ptdesc equivalents. Signed-off-by: Vishal Moola (Oracle) --- arch/nios2/include/asm/pgalloc.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/nios2/include/asm/pgalloc.h b/arch/nios2/include/asm/pgalloc.h index ecd1657bb2ce..ce6bb8e74271 100644 --- a/arch/nios2/include/asm/pgalloc.h +++ b/arch/nios2/include/asm/pgalloc.h @@ -28,10 +28,10 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, extern pgd_t *pgd_alloc(struct mm_struct *mm); -#define __pte_free_tlb(tlb, pte, addr) \ - do {\ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), (pte)); \ +#define __pte_free_tlb(tlb, pte, addr) \ + do {\ + pagetable_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ } while (0) #endif /* _ASM_NIOS2_PGALLOC_H */ Applied! I don't think you can just apply this patch, as the new functions were only introduced in [PATCH v4 05/34] of this series. Ah, thanks for the pointer! Dinh ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v5 26/33] nios2: Convert __pte_free_tlb() to use ptdescs
On 6/22/23 15:57, Vishal Moola (Oracle) wrote: Part of the conversions to replace pgtable constructor/destructors with ptdesc equivalents. Signed-off-by: Vishal Moola (Oracle) Acked-by: Mike Rapoport (IBM) --- arch/nios2/include/asm/pgalloc.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/nios2/include/asm/pgalloc.h b/arch/nios2/include/asm/pgalloc.h index ecd1657bb2ce..ce6bb8e74271 100644 --- a/arch/nios2/include/asm/pgalloc.h +++ b/arch/nios2/include/asm/pgalloc.h @@ -28,10 +28,10 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, extern pgd_t *pgd_alloc(struct mm_struct *mm); -#define __pte_free_tlb(tlb, pte, addr)\ - do {\ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), (pte)); \ +#define __pte_free_tlb(tlb, pte, addr) \ + do {\ + pagetable_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), (page_ptdesc(pte))); \ } while (0) #endif /* _ASM_NIOS2_PGALLOC_H */ Acked-by: Dinh Nguyen ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v5 26/33] nios2: Convert __pte_free_tlb() to use ptdescs
On 6/27/23 14:56, Vishal Moola wrote: On Tue, Jun 27, 2023 at 12:14 PM Guenter Roeck wrote: On 6/27/23 12:10, Guenter Roeck wrote: On 6/27/23 10:42, Vishal Moola wrote: On Mon, Jun 26, 2023 at 10:47 PM Guenter Roeck wrote: On Thu, Jun 22, 2023 at 01:57:38PM -0700, Vishal Moola (Oracle) wrote: Part of the conversions to replace pgtable constructor/destructors with ptdesc equivalents. Signed-off-by: Vishal Moola (Oracle) Acked-by: Mike Rapoport (IBM) This patch causes all nios2 builds to fail. It looks like you tried to apply this patch on its own. This patch depends on patches 01-12 of this patchset to compile properly. I've cross-compiled this architecture and it worked, but let me know if something fails when its applied on top of those patches (or the rest of the patchset). No, I did not try to apply this patch on its own. I tried to build yesterday's pending-fixes branch of linux-next. A quick check shows that the build fails with next-20230627. See log below. Ah it looks like this one slipped into -next on its own somehow? Stephen, please drop this patch from -next; it shouldn't be in without the rest of the patchset which I intend to have Andrew take through the mm tree. I apologize, but I queue this patch up for Linus and it's been pulled for this merge window. I didn't realize you were going to take this patchset through another tree. Sorry about that. Dinh ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v5 26/33] nios2: Convert __pte_free_tlb() to use ptdescs
On 6/27/23 16:01, Guenter Roeck wrote: On 6/27/23 13:05, Dinh Nguyen wrote: On 6/27/23 14:56, Vishal Moola wrote: On Tue, Jun 27, 2023 at 12:14 PM Guenter Roeck wrote: On 6/27/23 12:10, Guenter Roeck wrote: On 6/27/23 10:42, Vishal Moola wrote: On Mon, Jun 26, 2023 at 10:47 PM Guenter Roeck wrote: On Thu, Jun 22, 2023 at 01:57:38PM -0700, Vishal Moola (Oracle) wrote: Part of the conversions to replace pgtable constructor/destructors with ptdesc equivalents. Signed-off-by: Vishal Moola (Oracle) Acked-by: Mike Rapoport (IBM) This patch causes all nios2 builds to fail. It looks like you tried to apply this patch on its own. This patch depends on patches 01-12 of this patchset to compile properly. I've cross-compiled this architecture and it worked, but let me know if something fails when its applied on top of those patches (or the rest of the patchset). No, I did not try to apply this patch on its own. I tried to build yesterday's pending-fixes branch of linux-next. A quick check shows that the build fails with next-20230627. See log below. Ah it looks like this one slipped into -next on its own somehow? Stephen, please drop this patch from -next; it shouldn't be in without the rest of the patchset which I intend to have Andrew take through the mm tree. I apologize, but I queue this patch up for Linus and it's been pulled for this merge window. I didn't realize you were going to take this patchset through another tree. Sorry about that. Yes, indeed, I just confirmed that all nios2 builds in the mainline kernel are now broken. Please let me know if you need to do anything. I'm going to out for a week starting tomorrow. Dinh ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v5 06/11] nios2: use fallback for random_get_entropy() instead of zero
On 4/19/22 06:16, Jason A. Donenfeld wrote: In the event that random_get_entropy() can't access a cycle counter or similar, falling back to returning 0 is really not the best we can do. Instead, at least calling random_get_entropy_fallback() would be preferable, because that always needs to return _something_, even falling back to jiffies eventually. It's not as though random_get_entropy_fallback() is super high precision or guaranteed to be entropic, but basically anything that's not zero all the time is better than returning zero all the time. Cc: Thomas Gleixner Cc: Arnd Bergmann Cc: Dinh Nguyen Signed-off-by: Jason A. Donenfeld --- arch/nios2/include/asm/timex.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/nios2/include/asm/timex.h b/arch/nios2/include/asm/timex.h index a769f871b28d..d9a3f426cdda 100644 --- a/arch/nios2/include/asm/timex.h +++ b/arch/nios2/include/asm/timex.h @@ -9,4 +9,6 @@ typedef unsigned long cycles_t; extern cycles_t get_cycles(void); +#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback()) + #endif Acked-by: Dinh Nguyen ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v4 06/11] nios2: use fallback for random_get_entropy() instead of zero
On 4/13/22 06:54, Jason A. Donenfeld wrote: In the event that random_get_entropy() can't access a cycle counter or similar, falling back to returning 0 is really not the best we can do. Instead, at least calling random_get_entropy_fallback() would be preferable, because that always needs to return _something_, even falling back to jiffies eventually. It's not as though random_get_entropy_fallback() is super high precision or guaranteed to be entropic, but basically anything that's not zero all the time is better than returning zero all the time. Cc: Thomas Gleixner Cc: Arnd Bergmann Cc: Dinh Nguyen Signed-off-by: Jason A. Donenfeld --- arch/nios2/include/asm/timex.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/nios2/include/asm/timex.h b/arch/nios2/include/asm/timex.h index a769f871b28d..d9a3f426cdda 100644 --- a/arch/nios2/include/asm/timex.h +++ b/arch/nios2/include/asm/timex.h @@ -9,4 +9,6 @@ typedef unsigned long cycles_t; extern cycles_t get_cycles(void); +#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback()) + #endif Acked-by: Dinh Nguyen ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH V7 15/26] nios2/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT
On 7/11/22 02:05, Anshuman Khandual wrote: This enables ARCH_HAS_VM_GET_PAGE_PROT on the platform and exports standard vm_get_page_prot() implementation via DECLARE_VM_GET_PAGE_PROT, which looks up a private and static protection_map[] array. Subsequently all __SXXX and __PXXX macros can be dropped which are no longer needed. Cc: Dinh Nguyen Cc: linux-ker...@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/nios2/Kconfig | 1 + arch/nios2/include/asm/pgtable.h | 16 arch/nios2/mm/init.c | 20 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index 4167f1eb4cd8..e0459dffd218 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -6,6 +6,7 @@ config NIOS2 select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE select ARCH_HAS_DMA_SET_UNCACHED + select ARCH_HAS_VM_GET_PAGE_PROT select ARCH_NO_SWAP select COMMON_CLK select TIMER_OF diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h index 262d0609268c..470516d4555e 100644 --- a/arch/nios2/include/asm/pgtable.h +++ b/arch/nios2/include/asm/pgtable.h @@ -40,24 +40,8 @@ struct mm_struct; */ /* Remove W bit on private pages for COW support */ -#define __P000 MKP(0, 0, 0) -#define __P001 MKP(0, 0, 1) -#define __P010 MKP(0, 0, 0)/* COW */ -#define __P011 MKP(0, 0, 1)/* COW */ -#define __P100 MKP(1, 0, 0) -#define __P101 MKP(1, 0, 1) -#define __P110 MKP(1, 0, 0)/* COW */ -#define __P111 MKP(1, 0, 1)/* COW */ /* Shared pages can have exact HW mapping */ -#define __S000 MKP(0, 0, 0) -#define __S001 MKP(0, 0, 1) -#define __S010 MKP(0, 1, 0) -#define __S011 MKP(0, 1, 1) -#define __S100 MKP(1, 0, 0) -#define __S101 MKP(1, 0, 1) -#define __S110 MKP(1, 1, 0) -#define __S111 MKP(1, 1, 1) /* Used all over the kernel */ #define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHED | _PAGE_READ | \ diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index 613fcaa5988a..ae24687d12ad 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -124,3 +124,23 @@ const char *arch_vma_name(struct vm_area_struct *vma) { return (vma->vm_start == KUSER_BASE) ? "[kuser]" : NULL; } + +static const pgprot_t protection_map[16] = { + [VM_NONE] = MKP(0, 0, 0), + [VM_READ] = MKP(0, 0, 1), + [VM_WRITE] = MKP(0, 0, 0), + [VM_WRITE | VM_READ]= MKP(0, 0, 1), + [VM_EXEC] = MKP(1, 0, 0), + [VM_EXEC | VM_READ] = MKP(1, 0, 1), + [VM_EXEC | VM_WRITE]= MKP(1, 0, 0), + [VM_EXEC | VM_WRITE | VM_READ] = MKP(1, 0, 1), + [VM_SHARED] = MKP(0, 0, 0), + [VM_SHARED | VM_READ] = MKP(0, 0, 1), + [VM_SHARED | VM_WRITE] = MKP(0, 1, 0), + [VM_SHARED | VM_WRITE | VM_READ]= MKP(0, 1, 1), + [VM_SHARED | VM_EXEC] = MKP(1, 0, 0), + [VM_SHARED | VM_EXEC | VM_READ] = MKP(1, 0, 1), + [VM_SHARED | VM_EXEC | VM_WRITE]= MKP(1, 1, 0), + [VM_SHARED | VM_EXEC | VM_WRITE | VM_READ] = MKP(1, 1, 1) +}; +DECLARE_VM_GET_PAGE_PROT Acked-by: Dinh Nguyen ___ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um
Re: [PATCH v2 06/13] nios2: move pr_debug() about memory start and end to setup_arch()
On 3/13/25 08:49, Mike Rapoport wrote: From: "Mike Rapoport (Microsoft)" This will help with pulling out memblock_free_all() to the generic code and reducing code duplication in arch::mem_init(). Signed-off-by: Mike Rapoport (Microsoft) --- arch/nios2/kernel/setup.c | 2 ++ arch/nios2/mm/init.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c index da122a5fa43b..a4cffbfc1399 100644 --- a/arch/nios2/kernel/setup.c +++ b/arch/nios2/kernel/setup.c @@ -149,6 +149,8 @@ void __init setup_arch(char **cmdline_p) memory_start = memblock_start_of_DRAM(); memory_end = memblock_end_of_DRAM(); + pr_debug("%s: start=%lx, end=%lx\n", __func__, memory_start, memory_end); + setup_initial_init_mm(_stext, _etext, _edata, _end); init_task.thread.kregs = &fake_regs; diff --git a/arch/nios2/mm/init.c b/arch/nios2/mm/init.c index a2278485de19..aa692ad30044 100644 --- a/arch/nios2/mm/init.c +++ b/arch/nios2/mm/init.c @@ -65,8 +65,6 @@ void __init mem_init(void) unsigned long end_mem = memory_end; /* this must not include kernel stack at top */ - pr_debug("mem_init: start=%lx, end=%lx\n", memory_start, memory_end); - end_mem &= PAGE_MASK; high_memory = __va(end_mem); Acked-By: Dinh Nguyen