W-M-R opened a new pull request, #14978: URL: https://github.com/apache/nuttx/pull/14978
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary arm64/mte: Add support for arm64 mte arm64/qemu: Add arm64 mte defconfig support arm64/qemu: Add support for arm64 qemu's maximum feature cpu ## Impact ## Testing Please compile my newly added arm64/qemu:mte. Then run it with the following command ``` qemu-system-aarch64 -cpu max -nographic -smp 4 \ -machine virt,virtualization=on,gic-version=3,mte=on -chardev stdio,id=con,mux=on, -serial chardev:con \ -mon chardev=con,mode=readline -kernel ./nuttx/nuttx ``` Add the following app to test the mte function: ` /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include <nuttx/compiler.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> /**************************************************************************** * Private Data ****************************************************************************/ static aligned_data(16) char buffer[65536]; /**************************************************************************** * Public Functions ****************************************************************************/ static void __attribute__((noinline)) tagset(void *p, size_t size) { size_t i; for (i = 0; i < size; i += 16) { asm("stg %0, [%0]" : : "r"(p + i)); } } static void __attribute__((noinline)) tagcheck(void *p, size_t size) { size_t i; void *c; for (i = 0; i < size; i += 16) { asm("ldg %0, [%1]" : "=r"(c) : "r"(p + i), "0"(p)); assert(c == p); } } int main(int argc, FAR char *argv[]) { char *p0 = (uint64_t)buffer; long excl = 1; char *p1 = 0; size_t size = 65536; /* Tag the pointer. */ asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(excl)); printf("p0: %llx\n", (unsigned long long)p0); printf("p1: %llx\n", (unsigned long long)p1); tagset(p1, 65536); tagcheck(p1, 65536); for (int i = 0; i < size / sizeof(int); i++) { p0[i] = i; printf("p0[%d]: %d\n", i, p0[i]); } return 0; } ` It will run with an error and enter the tag synchronization detection exception: ``` ➜ NX git:(master) ✗ qemu-system-aarch64 -cpu max -nographic -smp 4 \ -machine virt,virtualization=on,gic-version=3,mte=on -chardev stdio,id=con,mux=on, -serial chardev:con \ -mon chardev=con,mode=readline -kernel ./nuttx/nuttx - Ready to Boot Primary CPU - Boot from EL2 - Boot from EL1 - Boot to C runtime for OS Initialize NuttShell (NSH) nsh> nsh> nsh> hello p0: 403d4d50 p1: 3000000403d4d50 default_fatal_handler: (IFSC/DFSC) for Data/Instruction aborts: synchronous tag check fault arm64_exception_handler: CurrentEL: MODE_EL1 arm64_exception_handler: ESR_ELn: 0x96000051 arm64_exception_handler: FAR_ELn: 0x403d4d50 arm64_exception_handler: ELR_ELn: 0x402a6aa8 print_ec_cause: DABT (current EL) print_ec_cause: Data Abort taken without a change in Exception level dump_assert_info: Current Version: NuttX 0.0.0 757d27880e Nov 29 2024 11:14:09 arm64 dump_assert_info: Assertion failed panic: at file: common/arm64_fatal.c:571 task: hello process: hello 0x402a6a44 up_dump_register: stack = 0x403f37f0 up_dump_register: x0: 0x403bbc98 x1: 0x0 up_dump_register: x2: 0x0 x3: 0x3000000403e4d40 up_dump_register: x4: 0x0 x5: 0x1 up_dump_register: x6: 0x1 x7: 0x0 up_dump_register: x8: 0x1 x9: 0x1 up_dump_register: x10: 0x0 x11: 0x0 up_dump_register: x12: 0x0 x13: 0x0 up_dump_register: x14: 0x0 x15: 0x0 up_dump_register: x16: 0x0 x17: 0x0 up_dump_register: x18: 0x0 x19: 0x0 up_dump_register: x20: 0x403d4d50 x21: 0x403bbc98 up_dump_register: x22: 0x0 x23: 0x0 up_dump_register: x24: 0x0 x25: 0x0 up_dump_register: x26: 0x0 x27: 0x0 up_dump_register: x28: 0x0 x29: 0x403f3b20 up_dump_register: x30: 0x402a6a9c up_dump_register: up_dump_register: STATUS Registers: up_dump_register: SPSR: 0x60000005 up_dump_register: ELR: 0x402a6aa8 up_dump_register: SP_EL0: 0x403f3870 up_dump_register: SP_ELX: 0x403f3b20 up_dump_register: EXE_DEPTH: 0xfffffffffffffffd dump_tasks: PID GROUP PRI POLICY TYPE NPX STATE EVENT SIGMASK STACKBASE STACKSIZE USED FILLED COMMAND dump_tasks: ---- --- --- -------- ------- --- ------- ---------- ---------------- 0x403e9000 4096 320 7.8% irq dump_task: 0 0 0 FIFO Kthread - Ready 0000000000000000 0x403ea010 8176 1488 18.1% Idle_Task dump_task: 1 0 192 RR Kthread - Waiting Semaphore 0000000000000000 0x403ec8e0 8112 1008 12.4% hpwork 0x403c64d8 0x403c6520 dump_task: 2 2 100 RR Task - Waiting Semaphore 0000000000000000 0x403eef70 8144 2160 26.5% nsh_main dump_task: 3 3 100 RR Task - Running 0000000000000000 0x403f1bd0 8144 2512 30.8% hello ``` -- 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-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org