• S
    target/ppc: Add Instruction Authority Mask Register Check · a6152b52
    Suraj Jitindar Singh 提交于
    The instruction authority mask register (IAMR) can be used to restrict
    permissions for instruction fetch accesses on a per key basis for each
    of 32 different key values. Access permissions are derived based on the
    specific key value stored in the relevant page table entry.
    
    The IAMR was introduced in, and is present in processors since, POWER8
    (ISA v2.07). Thus introduce a function to check access permissions based
    on the pte key value and the contents of the IAMR when handling a page
    fault to ensure sufficient access permissions for an instruction fetch.
    
    A hash pte contains a key value in bits 2:3|52:54 of the second double word
    of the pte, this key value gives an index into the IAMR which contains 32
    2-bit access masks. If the least significant bit of the 2-bit access mask
    corresponding to the given key value is set (IAMR[key] & 0x1 == 0x1) then
    the instruction fetch is not permitted and an ISI is generated accordingly.
    While we're here, add defines for the srr1 bits to be set for the ISI for
    clarity.
    
    e.g.
    
    pte:
    dw0 [XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]
    dw1 [XX01XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX010XXXXXXXXX]
           ^^                                                ^^^
    key = 01010 (0x0a)
    
    IAMR: [XXXXXXXXXXXXXXXXXXXX01XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX]
                               ^^
    Access mask = 0b01
    
    Test access mask: 0b01 & 0x1 == 0x1
    
    Least significant bit of the access mask is set, thus the instruction fetch
    is not permitted. We should generate an instruction storage interrupt (ISI)
    with bit 42 of SRR1 set to indicate access precluded by virtual page class
    key protection.
    Signed-off-by: NSuraj Jitindar Singh <sjitindarsingh@gmail.com>
    [dwg: Move new constants to cpu.h, since they're not MMUv3 specific]
    Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
    a6152b52
mmu-hash64.c 31.6 KB