You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/09/09 11:34:45 UTC

[GitHub] [incubator-nuttx] pussuw opened a new pull request, #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users…

pussuw opened a new pull request, #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060

   …pace
   
   ## Summary
   The L3 mapping function was just way too simplistic. Depending on memory configuration it either works or not.
   
   Noticed that with icicle:pnsh the software crashes due to instruction page fault, reason is the map_region() implementation that does not work for regions that are not aligned to 2MB (the L2 page size).
   
   Implemented an extremely simplistic page table allocator for the L3 references, that should once and for all get rid of the L3 mapping issue.
   
   NOTE: gran_alloc() cannot be used at this point, it is too early for it.
   
   ## Impact
   Fixes full system crash if the kernel memory regions (or user memory regions in protected mode) are selected so that they
   are not aligned to 2MB boundary.
   
   ## Testing
   icicle:pnsh / icicle:knsh
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pussuw commented on pull request #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users…

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060#issuecomment-1242655613

   > @pussuw I confirmed that `qv-virt:knsh64` works without a side effect.
   
   Excellent, thank you!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pussuw commented on pull request #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users…

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060#issuecomment-1241917893

   > @pussuw Let me try this PR later.
   
   Sounds good! 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 merged pull request #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode user space

Posted by GitBox <gi...@apache.org>.
masayuki2009 merged PR #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pussuw commented on pull request #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users…

Posted by GitBox <gi...@apache.org>.
pussuw commented on PR #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060#issuecomment-1241866917

   @masayuki2009 I know you use the qemu-rv / rv-virt target, I cannot test / verify that because I don't have the environment set up. If it breaks can you please inform me and I'll fix it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users…

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on PR #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060#issuecomment-1242565367

   @pussuw 
   I confirmed that `qv-virt:knsh64` works without a side effect.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users…

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on PR #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060#issuecomment-1241885980

   @pussuw 
   Let me try this PR later.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7060: risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users…

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7060:
URL: https://github.com/apache/incubator-nuttx/pull/7060#discussion_r967620480


##########
arch/risc-v/src/mpfs/mpfs_mm_init.c:
##########
@@ -58,6 +58,19 @@
 #define PGT_L2_SIZE     (512)  /* Enough to map 1 GiB */
 #define PGT_L3_SIZE     (1024) /* Enough to map 4 MiB */
 
+#define SLAB_COUNT      sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE

Review Comment:
   ```suggestion
   #define SLAB_COUNT      (sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE)
   ```



##########
arch/risc-v/src/qemu-rv/qemu_rv_mm_init.c:
##########
@@ -58,6 +58,19 @@
 #define PGT_L2_SIZE     (512)  /* Enough to map 1 GiB */
 #define PGT_L3_SIZE     (1024) /* Enough to map 4 MiB (2MiB x 2) */
 
+#define SLAB_COUNT      sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE

Review Comment:
   ```suggestion
   #define SLAB_COUNT      (sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE)
   ```



##########
arch/risc-v/src/mpfs/mpfs_userspace.c:
##########
@@ -45,19 +46,30 @@
 
 #define PGT_L1_PBASE    (uint64_t)&m_l1_pgtable
 #define PGT_L2_PBASE    (uint64_t)&m_l2_pgtable
-#define PGT_L3_ROMPBASE (uint64_t)&m_l3_romtbl
-#define PGT_L3_RAMPBASE (uint64_t)&m_l3_ramtbl
+#define PGT_L3_PBASE    (uint64_t)&m_l3_pgtable
 #define PGT_L1_VBASE    PGT_L1_PBASE
 #define PGT_L2_VBASE    PGT_L2_PBASE
-#define PGT_L3_ROMVBASE PGT_L3_ROMPBASE
-#define PGT_L3_RAMVBASE PGT_L3_RAMPBASE
+#define PGT_L3_VBASE    PGT_L3_PBASE
 
 #define PGT_L1_SIZE     (512)  /* Enough to map 512 GiB */
 #define PGT_L2_SIZE     (512)  /* Enough to map 1 GiB */
-#define PGT_L3_SIZE     (512)  /* Enough to map 2 MiB */
+#define PGT_L3_SIZE     (1024) /* Enough to map 4 MiB */
+
+#define SLAB_COUNT      sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE

Review Comment:
   ```suggestion
   #define SLAB_COUNT      (sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE)
   ```



##########
arch/risc-v/src/mpfs/mpfs_mm_init.c:
##########
@@ -58,6 +58,19 @@
 #define PGT_L2_SIZE     (512)  /* Enough to map 1 GiB */
 #define PGT_L3_SIZE     (1024) /* Enough to map 4 MiB */
 
+#define SLAB_COUNT      sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE

Review Comment:
   ```suggestion
   #define SLAB_COUNT      (sizeof(m_l3_pgtable) / RV_MMU_PAGE_SIZE)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org