xref: /openbmc/qemu/target/arm/tcg/m-nocp.decode (revision e1f9f73ba15e0356ce1aa3317d7bd294f587ab58)
1*f0984d40SFabiano Rosas# M-profile UserFault.NOCP exception handling
2*f0984d40SFabiano Rosas#
3*f0984d40SFabiano Rosas#  Copyright (c) 2020 Linaro, Ltd
4*f0984d40SFabiano Rosas#
5*f0984d40SFabiano Rosas# This library is free software; you can redistribute it and/or
6*f0984d40SFabiano Rosas# modify it under the terms of the GNU Lesser General Public
7*f0984d40SFabiano Rosas# License as published by the Free Software Foundation; either
8*f0984d40SFabiano Rosas# version 2.1 of the License, or (at your option) any later version.
9*f0984d40SFabiano Rosas#
10*f0984d40SFabiano Rosas# This library is distributed in the hope that it will be useful,
11*f0984d40SFabiano Rosas# but WITHOUT ANY WARRANTY; without even the implied warranty of
12*f0984d40SFabiano Rosas# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13*f0984d40SFabiano Rosas# Lesser General Public License for more details.
14*f0984d40SFabiano Rosas#
15*f0984d40SFabiano Rosas# You should have received a copy of the GNU Lesser General Public
16*f0984d40SFabiano Rosas# License along with this library; if not, see <http://www.gnu.org/licenses/>.
17*f0984d40SFabiano Rosas
18*f0984d40SFabiano Rosas#
19*f0984d40SFabiano Rosas# This file is processed by scripts/decodetree.py
20*f0984d40SFabiano Rosas#
21*f0984d40SFabiano Rosas# For M-profile, the architecture specifies that NOCP UsageFaults
22*f0984d40SFabiano Rosas# should take precedence over UNDEF faults over the whole wide
23*f0984d40SFabiano Rosas# range of coprocessor-space encodings, with the exception of
24*f0984d40SFabiano Rosas# VLLDM and VLSTM. (Compare v8.1M IsCPInstruction() pseudocode and
25*f0984d40SFabiano Rosas# v8M Arm ARM rule R_QLGM.) This isn't mandatory for v8.0M but we choose
26*f0984d40SFabiano Rosas# to behave the same as v8.1M.
27*f0984d40SFabiano Rosas# This decode is handled before any others (and in particular before
28*f0984d40SFabiano Rosas# decoding FP instructions which are in the coprocessor space).
29*f0984d40SFabiano Rosas# If the coprocessor is not present or disabled then we will generate
30*f0984d40SFabiano Rosas# the NOCP exception; otherwise we let the insn through to the main decode.
31*f0984d40SFabiano Rosas
32*f0984d40SFabiano Rosas%vd_dp  22:1 12:4
33*f0984d40SFabiano Rosas%vd_sp  12:4 22:1
34*f0984d40SFabiano Rosas
35*f0984d40SFabiano Rosas&nocp cp
36*f0984d40SFabiano Rosas
37*f0984d40SFabiano Rosas# M-profile VLDR/VSTR to sysreg
38*f0984d40SFabiano Rosas%vldr_sysreg 22:1 13:3
39*f0984d40SFabiano Rosas%imm7_0x4 0:7 !function=times_4
40*f0984d40SFabiano Rosas
41*f0984d40SFabiano Rosas&vldr_sysreg rn reg imm a w p
42*f0984d40SFabiano Rosas@vldr_sysreg .... ... . a:1 . . . rn:4 ... . ... .. ....... \
43*f0984d40SFabiano Rosas             reg=%vldr_sysreg imm=%imm7_0x4 &vldr_sysreg
44*f0984d40SFabiano Rosas
45*f0984d40SFabiano Rosas{
46*f0984d40SFabiano Rosas  # Special cases which do not take an early NOCP: VLLDM and VLSTM
47*f0984d40SFabiano Rosas  VLLDM_VLSTM  1110 1100 001 l:1 rn:4 0000 1010 op:1 000 0000
48*f0984d40SFabiano Rosas  # VSCCLRM (new in v8.1M) is similar:
49*f0984d40SFabiano Rosas  VSCCLRM      1110 1100 1.01 1111 .... 1011 imm:7 0   vd=%vd_dp size=3
50*f0984d40SFabiano Rosas  VSCCLRM      1110 1100 1.01 1111 .... 1010 imm:8     vd=%vd_sp size=2
51*f0984d40SFabiano Rosas
52*f0984d40SFabiano Rosas  # FP system register accesses: these are a special case because accesses
53*f0984d40SFabiano Rosas  # to FPCXT_NS succeed even if the FPU is disabled. We therefore need
54*f0984d40SFabiano Rosas  # to handle them before the big NOCP blocks. Note that within these
55*f0984d40SFabiano Rosas  # insns NOCP still has higher priority than UNDEFs; this is implemented
56*f0984d40SFabiano Rosas  # by their returning 'false' for UNDEF so as to fall through into the
57*f0984d40SFabiano Rosas  # NOCP check (in contrast to VLLDM etc, which call unallocated_encoding()
58*f0984d40SFabiano Rosas  # for the UNDEFs there that must take precedence over NOCP.)
59*f0984d40SFabiano Rosas
60*f0984d40SFabiano Rosas  VMSR_VMRS    ---- 1110 111 l:1 reg:4 rt:4 1010 0001 0000
61*f0984d40SFabiano Rosas
62*f0984d40SFabiano Rosas  # P=0 W=0 is SEE "Related encodings", so split into two patterns
63*f0984d40SFabiano Rosas  VLDR_sysreg  ---- 110 1 . . w:1 1 .... ... 0 111 11 ....... @vldr_sysreg p=1
64*f0984d40SFabiano Rosas  VLDR_sysreg  ---- 110 0 . . 1   1 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1
65*f0984d40SFabiano Rosas  VSTR_sysreg  ---- 110 1 . . w:1 0 .... ... 0 111 11 ....... @vldr_sysreg p=1
66*f0984d40SFabiano Rosas  VSTR_sysreg  ---- 110 0 . . 1   0 .... ... 0 111 11 ....... @vldr_sysreg p=0 w=1
67*f0984d40SFabiano Rosas
68*f0984d40SFabiano Rosas  NOCP         111- 1110 ---- ---- ---- cp:4 ---- ---- &nocp
69*f0984d40SFabiano Rosas  NOCP         111- 110- ---- ---- ---- cp:4 ---- ---- &nocp
70*f0984d40SFabiano Rosas  # From v8.1M onwards this range will also NOCP:
71*f0984d40SFabiano Rosas  NOCP_8_1     111- 1111 ---- ---- ---- ---- ---- ---- &nocp cp=10
72*f0984d40SFabiano Rosas}
73