You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "tmedicci (via GitHub)" <gi...@apache.org> on 2023/04/13 16:05:09 UTC

[GitHub] [nuttx] tmedicci opened a new pull request, #9022: libc/string: add option to force arch implementations on kernel

tmedicci opened a new pull request, #9022:
URL: https://github.com/apache/nuttx/pull/9022

   ## Summary
   
   Add the `FORCE_LIBC_ARCH_KERNEL` option to force arch-specific implementation of `libc` for kernel when built with protected mode. This option is beneficial for architectures with optimized implementations on ROM but requires software-defined versions to be used by the userspace.
   
   ## Impact
   
   This option should be selected by an arch's Kconfig to be enabled. Currently, it's selected by the xtensa-based ESP32-S3. There is no impact on other architectures.
   
   ## Testing
   
   Internal CI testing + ESP32S3 running Wi-Fi on protected build mode (PR to be submitted).
   


-- 
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] [nuttx] xiaoxiang781216 commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1178331450


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   @tmedicci but no LIBC_ARCH_xxx is selected if BUILD_PROTECTED equals y, so both kernel and userspace compile and link with the C version. Why LIBC_ARCH_FORCE_KERNEL is needed in this case?



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1179524639


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   No. Otherwise, the architecture-specific implementation would be used by the userspace.
   
   Considering the protected build for the ESP32-S3, the userspace is forbidden to access the architecture-specific (in this case, the libc's ROM functions). 
   
   The considerations about this patch:
   
   1) On flat build: there are no problems to use the architecture-specific implementation at all as no access rule (managed by the MMU) would be violated;
   2) On protected build: we need to build the software version (that's why the `LIBC_ARCH_xxx` is not selected), but;
   2.1) For the kernel, we can force the usage of the architecture-specific implementation by not building the software version when  `FORCE_LIBC_ARCH_KERNEL` equals `y` (the software version would be used only on the userspace).



-- 
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] [nuttx] xiaoxiang781216 commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1174292582


##########
arch/xtensa/Kconfig:
##########
@@ -82,6 +82,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select FORCE_LIBC_ARCH_KERNEL if BUILD_PROTECTED
 	select LIBC_ARCH_MEMCPY if BUILD_FLAT

Review Comment:
   @tmedicci I can't fully understand your change. From my understanding, ARCH_CHIP_ESP32S3 only enable the assembly version when BUILD_FLAT is enabled, and BUILD_PROTECTED already use the C version which already match your expectation. why need add FORCE_LIBC_ARCH_KERNEL?



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1175552966


##########
arch/xtensa/Kconfig:
##########
@@ -82,6 +82,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select FORCE_LIBC_ARCH_KERNEL if BUILD_PROTECTED
 	select LIBC_ARCH_MEMCPY if BUILD_FLAT

Review Comment:
   The option `FORCE_LIBC_ARCH_KERNEL` forces the kernel to use the alternative version (or ROM functions, in this case) on the kernel while allowing the userspace to build the C version.
   
   Specifically, S3 does not allow userspace to directly access the ROM functions through the MMU. That's why the userspace would need to build the C version. On the other hand, the Wi-Fi driver requires the usage of the ROM functions on the kernel-side.



-- 
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] [nuttx] xiaoxiang781216 commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1165808392


##########
libs/libc/string/lib_strnlen.c:
##########
@@ -30,7 +30,8 @@
  * Public Functions
  ****************************************************************************/
 
-#ifndef CONFIG_LIBC_ARCH_STRNLEN
+#if !defined(CONFIG_LIBC_ARCH_STRNLEN) && \

Review Comment:
   why not remove CONFIG_LIBC_ARCH_STRNLEN check directly? lib_strnlen.c is already skipped in Makefile if CONFIG_LIBC_ARCH_STRNLEN equals y, which make the check redundancy.



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1169141148


##########
libs/libc/string/lib_strnlen.c:
##########
@@ -30,7 +30,8 @@
  * Public Functions
  ****************************************************************************/
 
-#ifndef CONFIG_LIBC_ARCH_STRNLEN
+#if !defined(CONFIG_LIBC_ARCH_STRNLEN) && \

Review Comment:
   I created a previous commit to remove redundant code. Could you please take a look, @xiaoxiang781216 ?



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1177748312


##########
arch/xtensa/Kconfig:
##########
@@ -82,6 +82,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select FORCE_LIBC_ARCH_KERNEL if BUILD_PROTECTED
 	select LIBC_ARCH_MEMCPY if BUILD_FLAT

Review Comment:
   done! I also updated the `help` function to better explain this flag usage.



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1165888202


##########
libs/libc/string/lib_strnlen.c:
##########
@@ -30,7 +30,8 @@
  * Public Functions
  ****************************************************************************/
 
-#ifndef CONFIG_LIBC_ARCH_STRNLEN
+#if !defined(CONFIG_LIBC_ARCH_STRNLEN) && \

Review Comment:
   Yes, it's redundant. I just kept the old logic and added the new logic. It isn't directly related to this PR, so I preferred to keep it. What do you think about 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] [nuttx] tmedicci commented on pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#issuecomment-1516863601

   The code was rebased to pass the CI. @pkarashchenko and @xiaoxiang781216 , could you please take a look?


-- 
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] [nuttx] xiaoxiang781216 commented on pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#issuecomment-1552971066

   let's close this PR since https://github.com/apache/nuttx/pull/9138 is merged.


-- 
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] [nuttx] xiaoxiang781216 commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1165891847


##########
libs/libc/string/lib_strnlen.c:
##########
@@ -30,7 +30,8 @@
  * Public Functions
  ****************************************************************************/
 
-#ifndef CONFIG_LIBC_ARCH_STRNLEN
+#if !defined(CONFIG_LIBC_ARCH_STRNLEN) && \

Review Comment:
   it's better to crreate a new patch to remove the redundant check from the source code directly.



-- 
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] [nuttx] tmedicci commented on pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#issuecomment-1515294675

   Rebased!


-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1169141148


##########
libs/libc/string/lib_strnlen.c:
##########
@@ -30,7 +30,8 @@
  * Public Functions
  ****************************************************************************/
 
-#ifndef CONFIG_LIBC_ARCH_STRNLEN
+#if !defined(CONFIG_LIBC_ARCH_STRNLEN) && \

Review Comment:
   I created a commit prior to the existing one to remove the redundant code. The PR now contains two commits. Could you please take a look, @xiaoxiang781216 ?



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1179524639


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   No. Otherwise, the architecture-specific implementation would be used by the userspace.
   
   Considering the protected build for the ESP32-S3, the userspace is forbidden to access the architecture-specific (in this case, the libc's ROM functions). 
   
   The considerations about this patch:
   
   1) On flat build: there are no problems to use the architecture-specific implementation at all;
   2) On protected build: we need to build the software version (that's why the `LIBC_ARCH_xxx` is not selected), but;
   2.1) For the kernel, we can force the usage of the architecture-specific implementation by not building the software version when  `FORCE_LIBC_ARCH_KERNEL` equals `y` (the software version would be used only on the userspace).



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1179533437


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   I'm sorry, I answered you before your last message (https://github.com/apache/nuttx/pull/9022#discussion_r1179518496). Let me think about 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] [nuttx] xiaoxiang781216 commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1177257430


##########
arch/xtensa/Kconfig:
##########
@@ -82,6 +82,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select FORCE_LIBC_ARCH_KERNEL if BUILD_PROTECTED
 	select LIBC_ARCH_MEMCPY if BUILD_FLAT

Review Comment:
   should we change FORCE_LIBC_ARCH_KERNEL  to LIBC_ARCH_FORCE_KERNEL?



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1179524639


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   No. Otherwise, the architecture-specific implementation would be used by the userspace.
   
   Considering the protected build, the userspace is forbidden to access the architecture-specific (in this case, the FOM function). 
   
   The considerations about this patch:
   
   1) On flat build: there are no problems to use the architecture-specific implementation at all;
   2) On protected build: we need to build the software version (that's why the `LIBC_ARCH_xxx` is not selected), but;
   2.1) For the kernel, we can force the usage of the architecture-specific implementation by not building the software version when  `FORCE_LIBC_ARCH_KERNEL` equals `y` (the software version would be used only on the userspace).



-- 
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] [nuttx] xiaoxiang781216 commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1179518496


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   After enabling memxxx chip version, we have three choice in PROTECTED or KERNEL mode:
   
   1. Enable for both user and privilege mode
   2. Enable for user mode only
   3. Enable for privilege mode only
   
   So, it's more suitable to have a choice with three options e.g.:
   ```
   choice
   	default LIBC_ARCH_BOTH
   
   config LIBC_ARCH_BOTH
   
   config LIBC_ARCH_KERNEL_ONLY
   
   config LIBC_ARCH_USER_ONLY
   ```
   And the check CONFIG_LIBC_ARCH_xxx in Make.defs need to move into source files, and Make.defs orsource code under libc/machine need to be updated too.



-- 
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] [nuttx] xiaoxiang781216 commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1179503489


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   so should you remove if BUILD_FLAT from select LIBC_ARCH_xxx in this patch too?



-- 
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] [nuttx] xiaoxiang781216 closed pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 closed pull request #9022: libc/string: add option to force arch implementations on kernel
URL: https://github.com/apache/nuttx/pull/9022


-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1177733330


##########
arch/xtensa/Kconfig:
##########
@@ -82,6 +82,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select FORCE_LIBC_ARCH_KERNEL if BUILD_PROTECTED
 	select LIBC_ARCH_MEMCPY if BUILD_FLAT

Review Comment:
   It makes sense. Just a minute!



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1178382930


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   That is the point, @xiaoxiang781216 . If `BUILD_PROTECTED` equals `y`, `LIBC_ARCH_xxx` isn't selected and the software version would be built. But, in this case, we'd like to force the architecture-specific version to be used on kernel instead of the SW version (`LIBC_ARCH_FORCE_KERNEL` forces that). Alternatively, we could do that by changing the linker script, but that wouldn't be as clear for the user as creating this variable.



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1179582175


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   > After enabling memxxx chip version, we have three choice in PROTECTED or KERNEL mode:
   > 
   > 1. Enable for both user and privilege mode
   > 2. Enable for user mode only
   > 3. Enable for privilege mode only
   > 
   > So, it's more suitable to have a choice with three options e.g.:
   > 
   > ```
   > choice
   > 	default LIBC_ARCH_BOTH
   > 
   > config LIBC_ARCH_BOTH
   > 
   > config LIBC_ARCH_KERNEL_ONLY
   > 
   > config LIBC_ARCH_USER_ONLY
   > ```
   > 
   > And the check CONFIG_LIBC_ARCH_xxx in Make.defs need to move into source files, and Make.defs orsource code under libc/machine need to be updated too.
   
   Well, I'd think something simpler (considering these variables you suggested).
   
   First of all, please note that currently, there is no one-to-one relation between `CONFIG_LIBC_ARCH_xxx` and `libc/machine` source. Kconfig options from `libc/machine` select `CONFIG_LIBC_ARCH_xxx`, but the opposite is not true: selecting `CONFIG_LIBC_ARCH_xxx` won't select the `libc/machine` implementation. Instead, it'll only ensure that the software C version isn't being built. That is the case for ESP32-S3: we are not using the `XTENSA_xxx` version. We use the ROM functions whose symbols are provided by the linker script (`nuttx/boards/xtensa/esp32s3/common/scripts/esp32s3_rom.ld`): we only need to ensure that no other software has the same symbol.
   
   That being said, currently 1) we cover the situation when the arch-specific version is not selected by providing an alternative software C version, but 2) the opposite, when arch-specific is selected, we can't ensure for sure that something will be built to provide these functions (we need either to provide symbols on linker or select the arch-specific implementation on `libc/machine`).
   
   So, instead `CONFIG_FORCE_LIBC_ARCH_KERNEL` to ensure the software C version won't be built on kernel, we could use `CONFIG_LIBC_ARCH_BOTH/KERNEL_ONLY/USER_ONLY` to, in case of `CONFIG_LIBC_ARCH_xxx`  being selected, decide (depending whether the kernel is being built) to build or not the software C version. I wouldn't mess it with `libc/machine` sources/`Make.defs`, otherwise it'd be a huge modification and error-prone. My suggestion, in this case, affects only the same sources I already suggested modifying: just some different Karnaugh combinations. 
   
   Honestly, It'd be just a better name specification than `CONFIG_FORCE_LIBC_ARCH_KERNEL`. But it's feasible.
   
   What do you think about it? Am I missing something?



-- 
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] [nuttx] tmedicci commented on a diff in pull request #9022: libc/string: add option to force arch implementations on kernel

Posted by "tmedicci (via GitHub)" <gi...@apache.org>.
tmedicci commented on code in PR #9022:
URL: https://github.com/apache/nuttx/pull/9022#discussion_r1180722805


##########
arch/xtensa/Kconfig:
##########
@@ -83,6 +83,7 @@ config ARCH_CHIP_ESP32S3
 	select ARCH_HAVE_RESET
 	select ARCH_HAVE_TESTSET
 	select ARCH_VECNOTIRQ
+	select LIBC_ARCH_FORCE_KERNEL if BUILD_PROTECTED

Review Comment:
   Hi @xiaoxiang781216 , I've submitted an alternative implementation on https://github.com/apache/nuttx/pull/9138 (it's marked as a draft). 
   
   Unfortunately, choices can't be selected directly by other configs, so I needed to provide supportive configs to enable the arch's chip to select it (I don't like the idea of leaving the decision of selecting a necessary option up to the user). Could you please evaluate it if it better suits the problem?



-- 
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