Linux Kernel: SBI MPXY
2024-10-19
| 2025-1-12
本文字數 305閱讀時長 1 分鐘
type
status
date
slug
summary
tags
category
icon
password
⚠️
The code is based on: https://gitlab.com/riseproject/riscv-optee/linux/-/tree/dev-optee-mpxy Commit ID: df5dc01764820f113312f7a39f221b49985bbd7a


  • sbi_mpxy_init()
    • Check SBI version and if MPXY extension is supported by OpenSBI.
    • Setup CPUHP notifier to setup shared memory on all CPUs.
  • __sbi_mpxy_setup_shmem()
    • Allocates 4KB shared memory (4KB aligned).
    • Call sbi_mpxy_set_shmem SBI call to set up MPXY shared memory for the current core. This will invoke OpenSBI’s sbi_mpxy_set_shmem() to save the shared memory address and size into current hart domain’s mpxy_state (Untrusted domain).
  • sbi_mpxy_tee_probe()
    • Check SBI version and whether MPXY extension is supported by OpenSBI.
    • Get channel ID from DTS property: riscv,sbi-mpxy-channel-id.
    • Read MPXY protocol ID attribute (SBI_MPXY_ATTR_MSG_PROT_ID (0x0)) from channel with sbi_mpxy_read_attrs() .
    • Check if the returned MPXY protocol ID equals SBI_MPXY_MSGPROTO_TEE_ID (0x2). Throw an error if not.
  • sbi_mpxy_read_attrs()
    • Disable preemption (get_cpu()).
      • Shared memory is per-core. We only need to disable the preemption to prevent the shared memory of current CPU from being corrupted by the other tasks.
    • Issue SBI call: SBI_EXT_MPXY_READ_ATTRS to read the attribute.
    • If successful, copy the attribute from the shared memory to the buffer.
    • Enable preemption (put_cpu()).
  • sbi_mpxy_write_attrs()
    • Disable preemption (get_cpu()).
      • Shared memory is per-core. We only need to disable the preemption to prevent the shared memory of current CPU from being corrupted by the other tasks.
    • Copy the attribute from the buffer to the shared memory.
    • Issue SBI call: SBI_EXT_MPXY_WRITE_ATTRS to write the attribute.
    • Enable preemption (put_cpu()).
  • sbi_mpxy_send_message_withresp()
    • Disable preemption (get_cpu()).
      • Shared memory is per-core. We only need to disable the preemption to prevent the shared memory of current CPU from being corrupted by the other tasks.
    • Issue SBI call: SBI_EXT_MPXY_SEND_MSG_WITH_RESP with message ID: OPTEED_MSG_COMMUNICATE (0x1) to send the message to tdomain and get the response.
    • Enable preemption (put_cpu()).
  • Linux Kernel
  • OP-TEE
  • AMD PetaLinux + OpenAMP DemosLinux Kernel: OP-TEE Supplicant
    Loading...
    目錄