From 411ca73cdf4a5b5c0eeae1759ab62a8752cc3fb2 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Fri, 30 Dec 2022 18:51:53 +0900 Subject: [PATCH] arch/aarch64: Setup SIMD at startup A recent GRUB binary implicitly uses advanced SIMD registers. We don't want to trap use of these registers, we have to ensure that CPACR_EL.FPEN is set to 0b11. Signed-off-by: Akira Moroo --- src/arch/aarch64/mod.rs | 1 + src/arch/aarch64/simd.rs | 9 +++++++++ src/main.rs | 1 + 3 files changed, 11 insertions(+) create mode 100644 src/arch/aarch64/simd.rs diff --git a/src/arch/aarch64/mod.rs b/src/arch/aarch64/mod.rs index 1ad69e8b..f7cf5bc1 100644 --- a/src/arch/aarch64/mod.rs +++ b/src/arch/aarch64/mod.rs @@ -5,4 +5,5 @@ pub mod asm; pub mod layout; pub mod paging; +pub mod simd; mod translation; diff --git a/src/arch/aarch64/simd.rs b/src/arch/aarch64/simd.rs new file mode 100644 index 00000000..3ec1b8f7 --- /dev/null +++ b/src/arch/aarch64/simd.rs @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2023 Akira Moroo + +use aarch64_cpu::registers::*; +use tock_registers::interfaces::ReadWriteable; + +pub fn setup_simd() { + CPACR_EL1.modify(CPACR_EL1::FPEN::TrapNothing); +} diff --git a/src/main.rs b/src/main.rs index ea1d485b..993f8b2a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -171,6 +171,7 @@ pub extern "C" fn rust64_start(#[cfg(not(feature = "coreboot"))] pvh_info: &pvh: pub extern "C" fn rust64_start(x0: *const u8) -> ! { serial::PORT.borrow_mut().init(); + arch::aarch64::simd::setup_simd(); arch::aarch64::paging::setup(); let info = fdt::StartInfo::new(x0);