CV-Bowen opened a new pull request, #20927:
URL: https://github.com/apache/nuttx/pull/20927

   ## Summary
   
   struct rptun_rsc_s mirrors the resource table that the remote side
   parses through struct fw_rsc_vdev and the other openamp resource
   structures, which are all packed. rptun_rsc_s itself was only
   aligned(8), so a compiler may insert padding between its members. With
   the TASKING compiler the offset of rpmsg_vring0 seen through
   rptun_rsc_s differed from the one seen through fw_rsc_vdev, and the
   remote read the wrong vring.
   
   Declare it packed like the structures it contains.
   
   ## Impact
   
   With GCC the layout does not change. Measured on sim and qemu-armv8a
   before and after:
   
   | member | offset |
   |---|---|
   | log_trace | 28 |
   | rpmsg_vdev | 76 |
   | rpmsg_vring0 | 104 |
   | rpmsg_vring1 | 124 |
   | config | 144 |
   | carveout | 208 |
   | sizeof | 264 |
   
   Only the alignment of the type drops from 8 to 1. In tree:
   
   - nrf53, stm32h7, k230, mpfs, qemu-rv, sim embed it in a driver
     structure or size it with `ALIGN_UP(sizeof(struct rptun_rsc_s),
     VRING_ALIGN)`
   - imx9 and mx8mp define a bare `const struct rptun_rsc_s` in the
     `.resource_table` section, which their linker scripts place with
     `ALIGN(8)`, so its address does not change
   
   Out-of-tree code that places a bare `struct rptun_rsc_s` and relies on
   the type for 8-byte alignment needs an explicit `aligned_data(8)`.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   The resource table is consumed when the remote starts, so the rpmsg
   cases below (dump, ping, rpmsgfs over the vrings described by it) cover
   the change on sim and qemu-armv8a.
   
   Baseline (`test.sh`, cases: baseline.yaml):
   
   - host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   - tested: nuttx 4dffcd3b129 apps ea8addeaf
   - qemu-armv8a built with test-only overlay: disabled LIBC_ENVPATH 
BINFMT_CHECKEXEC
   - sim:rpserver + sim:rpproxy: PASS
     - [x] `uname -a` (server)
     - [x] `rpmsg dump all` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (server)
     - [x] `uname -a` (proxy)
     - [x] `rpmsg ping all 10 1024 3 0` (proxy)
     - [x] `mount -t rpmsgfs -o cpu=server,fs=/proc /sp` (proxy)
     - [x] `cat /sp/version` (proxy)
     - [x] `rpmsg dump all` (proxy)
   - qemu-armv8a:rpserver + qemu-armv8a:rpproxy: PASS
     - [x] `uname -a` (server)
     - [x] `uname -a` (proxy)
     - [x] `rpmsg dump all` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (server)
     - [x] `rpmsg ping all 10 1024 3 0` (proxy)
     - [x] `mount -t rpmsgfs -o cpu=server,fs=/proc /sp` (proxy)
     - [x] `cat /sp/version` (proxy)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to