Skip to content

Rustc does not recognize ttbr0_el2 as a valid armv8 system register #97724

Open
@iankronquist

Description

@iankronquist

Rustc does not recognize ttbr0_el2 as a valid armv8 system register.
ttbr0_el2 is used by hypervisors to configure page tables for the lower half of memory, typically used for userspace.

#![no_std]
use core::arch::asm;

static PT: [u64; 512] = [0; 512];
pub fn main() {
    unsafe {
        asm!("msr {pt}, ttbr0_el2", pt = in(reg) &PT as *const _ );
    }
}

This fails to compile with the error:

error: expected writable system register or pstate
 --> <source>:8:15
  |
8 |         asm!("msr {pt}, ttbr0_el2", pt = in(reg) &PT as *const _ );
  |               ^
  |
note: instantiated into assembly here
 --> <inline asm>:1:6
  |
1 |     msr x8, ttbr0_el2
  |         ^

error: aborting due to previous error

Compiler returned: 1

Here is a live example on godbolt:
https://godbolt.org/z/3jsGEd59a

My rustc version is:

$ rustc --version
rustc 1.63.0-nightly (e71440575 2022-06-02)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-inline-assemblyArea: Inline assembly (`asm!(…)`)E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.O-AArch64Armv8-A or later processors in AArch64 modeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions