No description
QEMU MMU tracing showed that there might be something wrong with its Xtensa MMU implementation, which result in access violation when running samples/userspace/hello_world_user. Here is the MMU trace from QEMU from failed runs: get_pte: autorefill(00109020): PTE va = 20000424, pa = 0010c424 get_physical_addr_mmu: autorefill(00109020): 00109000 -> 00109006 xtensa_cpu_tlb_fill(00109020, 1, 0) -> 00109020, ret = 0 xtensa_cpu_tlb_fill(00109028, 1, 0) -> 00109028, ret = 0 xtensa_cpu_tlb_fill(00109014, 0, 2) -> 00103050, ret = 26 The place where it fails is during reading from 0x109014. From the trace above, the auto-refill maps 0x109000 correctly with ring 0 and RW access with WB cache (which should be correct the first time under kernel mode). The page 0x109000 is the libc partition which needs to be accessible from user thread. However, when accessing that page, the returned physical address became 0x103050 (and resulting in load/store access violation). We always identity map memory pages so it should never return a different physical address. After forcing TLB invalidation during page table swaps, the MMU trace is: get_pte: autorefill(00109020): PTE va = 20000424, pa = 0010c424 get_physical_addr_mmu: autorefill(00109020): 00109000 -> 00109006 xtensa_cpu_tlb_fill(00109020, 1, 0) -> 00109020, ret = 0 get_pte: autorefill(00109028): PTE va = 21000424, pa = 0010e424 get_physical_addr_mmu: autorefill(00109028): 00109000 -> 00109022 xtensa_cpu_tlb_fill(00109028, 1, 0) -> 00109028, ret = 0 get_pte: autorefill(00109014): PTE va = 21000424, pa = 0010e424 get_physical_addr_mmu: autorefill(00109014): 00109000 -> 00109022 xtensa_cpu_tlb_fill(00109014, 0, 2) -> 00109014, ret = 0 xtensa_cpu_tlb_fill(00109020, 0, 0) -> 00109020, ret = 0 Here, when the same page is accessed, it got the correct PTE entry, which is ring 2 with RW access mode (but no cache). Actually accessing the variable via virtual address returns the correct physical address: 0x109014. So workaround that by forcing TLB invalidation during page swap. Fixes #66029 Signed-off-by: Daniel Leung <daniel.leung@intel.com> |
||
---|---|---|
.github | ||
arch | ||
boards | ||
cmake | ||
doc | ||
drivers | ||
dts | ||
include/zephyr | ||
kernel | ||
lib | ||
misc | ||
modules | ||
samples | ||
scripts | ||
share | ||
snippets | ||
soc | ||
submanifests | ||
subsys | ||
tests | ||
.checkpatch.conf | ||
.clang-format | ||
.codecov.yml | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitlint | ||
.mailmap | ||
.yamllint | ||
CMakeLists.txt | ||
CODE_OF_CONDUCT.md | ||
CODEOWNERS | ||
CONTRIBUTING.rst | ||
Kconfig | ||
Kconfig.zephyr | ||
LICENSE | ||
MAINTAINERS.yml | ||
README.rst | ||
VERSION | ||
version.h.in | ||
west.yml | ||
zephyr-env.cmd | ||
zephyr-env.sh |
.. raw:: html <a href="https://www.zephyrproject.org"> <p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="doc/_static/images/logo-readme-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="doc/_static/images/logo-readme-light.svg"> <img src="doc/_static/images/logo-readme-light.svg"> </picture> </p> </a> <a href="https://bestpractices.coreinfrastructure.org/projects/74"><img src="https://bestpractices.coreinfrastructure.org/projects/74/badge"></a> <a href="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml?query=branch%3Amain"> <img src="https://github.com/zephyrproject-rtos/zephyr/actions/workflows/twister.yaml/badge.svg?event=push"></a> The Zephyr Project is a scalable real-time operating system (RTOS) supporting multiple hardware architectures, optimized for resource constrained devices, and built with security in mind. The Zephyr OS is based on a small-footprint kernel designed for use on resource-constrained systems: from simple embedded environmental sensors and LED wearables to sophisticated smart watches and IoT wireless gateways. The Zephyr kernel supports multiple architectures, including ARM (Cortex-A, Cortex-R, Cortex-M), Intel x86, ARC, Nios II, Tensilica Xtensa, and RISC-V, SPARC, MIPS, and a large number of `supported boards`_. .. below included in doc/introduction/introduction.rst Getting Started *************** Welcome to Zephyr! See the `Introduction to Zephyr`_ for a high-level overview, and the documentation's `Getting Started Guide`_ to start developing. .. start_include_here Community Support ***************** Community support is provided via mailing lists and Discord; see the Resources below for details. .. _project-resources: Resources ********* Here's a quick summary of resources to help you find your way around: Getting Started --------------- | 📖 `Zephyr Documentation`_ | 🚀 `Getting Started Guide`_ | 🙋🏽 `Tips when asking for help`_ | 💻 `Code samples`_ Code and Development -------------------- | 🌐 `Source Code Repository`_ | 📦 `Releases`_ | 🤝 `Contribution Guide`_ Community and Support --------------------- | 💬 `Discord Server`_ for real-time community discussions | 📧 `User mailing list (users@lists.zephyrproject.org)`_ | 📧 `Developer mailing list (devel@lists.zephyrproject.org)`_ | 📬 `Other project mailing lists`_ | 📚 `Project Wiki`_ Issue Tracking and Security --------------------------- | 🐛 `GitHub Issues`_ | 🔒 `Security documentation`_ | 🛡️ `Security Advisories Repository`_ | ⚠️ Report security vulnerabilities at vulnerabilities@zephyrproject.org Additional Resources -------------------- | 🌐 `Zephyr Project Website`_ | 📺 `Zephyr Tech Talks`_ .. _Zephyr Project Website: https://www.zephyrproject.org .. _Discord Server: https://chat.zephyrproject.org .. _supported boards: https://docs.zephyrproject.org/latest/boards/index.html .. _Zephyr Documentation: https://docs.zephyrproject.org .. _Introduction to Zephyr: https://docs.zephyrproject.org/latest/introduction/index.html .. _Getting Started Guide: https://docs.zephyrproject.org/latest/develop/getting_started/index.html .. _Contribution Guide: https://docs.zephyrproject.org/latest/contribute/index.html .. _Source Code Repository: https://github.com/zephyrproject-rtos/zephyr .. _GitHub Issues: https://github.com/zephyrproject-rtos/zephyr/issues .. _Releases: https://github.com/zephyrproject-rtos/zephyr/releases .. _Project Wiki: https://github.com/zephyrproject-rtos/zephyr/wiki .. _User mailing list (users@lists.zephyrproject.org): https://lists.zephyrproject.org/g/users .. _Developer mailing list (devel@lists.zephyrproject.org): https://lists.zephyrproject.org/g/devel .. _Other project mailing lists: https://lists.zephyrproject.org/g/main/subgroups .. _Code samples: https://docs.zephyrproject.org/latest/samples/index.html .. _Security documentation: https://docs.zephyrproject.org/latest/security/index.html .. _Security Advisories Repository: https://github.com/zephyrproject-rtos/zephyr/security .. _Tips when asking for help: https://docs.zephyrproject.org/latest/develop/getting_started/index.html#asking-for-help .. _Zephyr Tech Talks: https://www.zephyrproject.org/tech-talks