Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hal: AArch64/ZynqMP port #635

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

hal: AArch64/ZynqMP port #635

wants to merge 4 commits into from

Conversation

jmaksymowicz
Copy link
Contributor

@jmaksymowicz jmaksymowicz commented Jan 30, 2025

Port plo to AArch64 architecture and Zynq Ultrascale platform.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: aarch64-zynqmp-qemu

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

Due to exiting on different stack than current's thread in fork in child
the return value was not set by threads_setupUserReturn.

JIRA: RTOS-979
Comment on lines 25 to 29
__asm__ volatile ( \
"msr " #sysreg ", %0" \
: \
: "r"(__v) \
: "memory"); \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ( \
"msr " #sysreg ", %0" \
: \
: "r"(__v) \
: "memory"); \
__asm__ volatile( \
"msr " #sysreg ", %0" \
: \
: "r"(__v) \
: "memory"); \

Comment on lines 36 to 40
__asm__ volatile ( \
"mrs %0, " #sysreg \
: "=r"(__v) \
: \
: "memory"); \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ( \
"mrs %0, " #sysreg \
: "=r"(__v) \
: \
: "memory"); \
__asm__ volatile( \
"mrs %0, " #sysreg \
: "=r"(__v) \
: \
: "memory"); \


static inline void hal_cpuDataMemoryBarrier(void)
{
__asm__ volatile ("dmb ish");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("dmb ish");
__asm__ volatile("dmb ish");


static inline void hal_cpuDataSyncBarrier(void)
{
__asm__ volatile ("dsb ish");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("dsb ish");
__asm__ volatile("dsb ish");


static inline void hal_cpuDataSyncBarrierSys(void)
{
__asm__ volatile ("dsb sy");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("dsb sy");
__asm__ volatile("dsb sy");

static inline void hal_tlbInvalVA_IS(ptr_t vaddr)
{
u64 arg = (vaddr >> 12) & ((1uL << 44) - 1);
__asm__ volatile ("tlbi vaae1is, %0" : : "r"(arg));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("tlbi vaae1is, %0" : : "r"(arg));
__asm__ volatile("tlbi vaae1is, %0" : : "r"(arg));

static inline void hal_tlbInvalVAASID_IS(ptr_t vaddr, asid_t asid)
{
u64 arg = ((vaddr >> 12) & ((1uL << 44) - 1)) | ((u64)asid << 48);
__asm__ volatile ("tlbi vae1is, %0" : : "r"(arg));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("tlbi vae1is, %0" : : "r"(arg));
__asm__ volatile("tlbi vae1is, %0" : : "r"(arg));

/* Invalidate entire Unified TLB (broadcast to Inner Shareable domain) */
static inline void hal_tlbInvalAll_IS(void)
{
__asm__ volatile ("tlbi vmalle1is");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("tlbi vmalle1is");
__asm__ volatile("tlbi vmalle1is");


struct aarch64_proc_id {
u64 mmfr0; /* ID_AA64MMFR0_EL1 */
u64 pfr0; /* ID_AA64PFR0_EL1 */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
u64 pfr0; /* ID_AA64PFR0_EL1 */
u64 pfr0; /* ID_AA64PFR0_EL1 */

Comment on lines 177 to 189
u32 dfr0; /* ID_AA64DFR0_EL1 */
u32 midr; /* MIDR_EL1 */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
u32 dfr0; /* ID_AA64DFR0_EL1 */
u32 midr; /* MIDR_EL1 */
u32 dfr0; /* ID_AA64DFR0_EL1 */
u32 midr; /* MIDR_EL1 */

_exceptions_checkFPUTrap:
#ifndef __SOFTFP__
lsr w26, W_ESR_EL1, #26
cmp w26, #0x7 /* SME, SVE, SIMD or FP trapped due to CPACR_EL1 */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[codespell] reported by reviewdog 🐶
SME ==> SAME, SEME, SOME, SMS

case 0b000110:
return "Trapped LDC/STC access";
case 0b000111:
return "Trapped SME, SVE, Advanced SIMD or floating-point functionality due to CPACR_ELx.FPEN";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[codespell] reported by reviewdog 🐶
SME ==> SAME, SEME, SOME, SMS

case 0b011100:
return "(FEAT_FPAC) Exception from a PAC Fail";
case 0b011101:
return "(FEAT_SME) Access to SME functionality trapped";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[codespell] reported by reviewdog 🐶
SME ==> SAME, SEME, SOME, SMS

}
}

/* Set code to read-only, everthing else XN and remove mappings past the end */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[codespell] reported by reviewdog 🐶
everthing ==> everything


#include "hal/types.h"

/* Predefined virtual adresses */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[codespell] reported by reviewdog 🐶
adresses ==> addresses

#define VADDR_DTB 0xfffffffffff00000 /* Last 1 MB of virtual space */


/* Architecure dependent page attributes */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[codespell] reported by reviewdog 🐶
Architecure ==> Architecture

Copy link

github-actions bot commented Jan 30, 2025

Unit Test Results

7 958 tests  ±0   7 416 ✅ ±0   40m 13s ⏱️ -15s
  470 suites ±0     542 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit dd3cc03. ± Comparison against base commit 4396455.

♻️ This comment has been updated with latest results.

/* Invalidate all instruction caches to PoU */
static inline void hal_cpuInvalInstrCacheAll(void)
{
__asm__ volatile ("dsb ish\n ic iallu\n dsb ish\n isb\n");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("dsb ish\n ic iallu\n dsb ish\n isb\n");
__asm__ volatile("dsb ish\n ic iallu\n dsb ish\n isb\n");

Previously loop counters were counting the number of pages, while the
count limit was in bytes, potentially causing a buffer overrun.

JIRA: RTOS-949
Add support for ZynqMP platform.

JIRA: RTOS-949
Set stack size of usrv message thread to SIZE_KSTACK. The default stack
size of 2048 was insufficient on AArch64.

JIRA: RTOS-949

static inline void hal_cpuDisableInterrupts(void)
{
__asm__ volatile ("msr daifSet, #3\n dsb ish \n isb");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("msr daifSet, #3\n dsb ish \n isb");
__asm__ volatile("msr daifSet, #3\n dsb ish \n isb");


static inline void hal_cpuEnableInterrupts(void)
{
__asm__ volatile ("msr daifClr, #3\n dsb ish \n isb");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[clang-format-pr] reported by reviewdog 🐶
suggested fix

Suggested change
__asm__ volatile ("msr daifClr, #3\n dsb ish \n isb");
__asm__ volatile("msr daifClr, #3\n dsb ish \n isb");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants