xref: /openbmc/qemu/include/exec/memattrs.h (revision 92ec7805190313c9e628f8fc4eb4f932c15247bd)
1cc05c43aSPeter Maydell /*
2cc05c43aSPeter Maydell  * Memory transaction attributes
3cc05c43aSPeter Maydell  *
4cc05c43aSPeter Maydell  * Copyright (c) 2015 Linaro Limited.
5cc05c43aSPeter Maydell  *
6cc05c43aSPeter Maydell  * Authors:
7cc05c43aSPeter Maydell  *  Peter Maydell <peter.maydell@linaro.org>
8cc05c43aSPeter Maydell  *
9cc05c43aSPeter Maydell  * This work is licensed under the terms of the GNU GPL, version 2 or later.
10cc05c43aSPeter Maydell  * See the COPYING file in the top-level directory.
11cc05c43aSPeter Maydell  *
12cc05c43aSPeter Maydell  */
13cc05c43aSPeter Maydell 
14cc05c43aSPeter Maydell #ifndef MEMATTRS_H
15cc05c43aSPeter Maydell #define MEMATTRS_H
16cc05c43aSPeter Maydell 
17cc05c43aSPeter Maydell /* Every memory transaction has associated with it a set of
18cc05c43aSPeter Maydell  * attributes. Some of these are generic (such as the ID of
19cc05c43aSPeter Maydell  * the bus master); some are specific to a particular kind of
20cc05c43aSPeter Maydell  * bus (such as the ARM Secure/NonSecure bit). We define them
21cc05c43aSPeter Maydell  * all as non-overlapping bitfields in a single struct to avoid
22cc05c43aSPeter Maydell  * confusion if different parts of QEMU used the same bit for
23cc05c43aSPeter Maydell  * different semantics.
24cc05c43aSPeter Maydell  */
25cc05c43aSPeter Maydell typedef struct MemTxAttrs {
26cc05c43aSPeter Maydell     /* Bus masters which don't specify any attributes will get this
27cc05c43aSPeter Maydell      * (via the MEMTXATTRS_UNSPECIFIED constant), so that we can
28cc05c43aSPeter Maydell      * distinguish "all attributes deliberately clear" from
29cc05c43aSPeter Maydell      * "didn't specify" if necessary.
30cc05c43aSPeter Maydell      */
31cc05c43aSPeter Maydell     unsigned int unspecified:1;
324d6e1c64SRichard Henderson     /*
334d6e1c64SRichard Henderson      * ARM/AMBA: TrustZone Secure access
34f794aa4aSPaolo Bonzini      * x86: System Management Mode access
35f794aa4aSPaolo Bonzini      */
368bf5b6a9SPeter Maydell     unsigned int secure:1;
374d6e1c64SRichard Henderson     /*
384d6e1c64SRichard Henderson      * ARM: ArmSecuritySpace.  This partially overlaps secure, but it is
394d6e1c64SRichard Henderson      * easier to have both fields to assist code that does not understand
404d6e1c64SRichard Henderson      * ARMv9 RME, or no specific knowledge of ARM at all (e.g. pflash).
414d6e1c64SRichard Henderson      */
424d6e1c64SRichard Henderson     unsigned int space:2;
430995bf8cSPeter Maydell     /* Memory access is usermode (unprivileged) */
440995bf8cSPeter Maydell     unsigned int user:1;
453ab6fdc9SPhilippe Mathieu-Daudé     /*
463ab6fdc9SPhilippe Mathieu-Daudé      * Bus interconnect and peripherals can access anything (memories,
473ab6fdc9SPhilippe Mathieu-Daudé      * devices) by default. By setting the 'memory' bit, bus transaction
483ab6fdc9SPhilippe Mathieu-Daudé      * are restricted to "normal" memories (per the AMBA documentation)
493ab6fdc9SPhilippe Mathieu-Daudé      * versus devices. Access to devices will be logged and rejected
503ab6fdc9SPhilippe Mathieu-Daudé      * (see MEMTX_ACCESS_ERROR).
513ab6fdc9SPhilippe Mathieu-Daudé      */
523ab6fdc9SPhilippe Mathieu-Daudé     unsigned int memory:1;
53a05f686fSPavel Fedin     /* Requester ID (for MSI for example) */
54a05f686fSPavel Fedin     unsigned int requester_id:16;
55*c6f3443aSTomasz Jeznach 
56*c6f3443aSTomasz Jeznach     /*
57*c6f3443aSTomasz Jeznach      * PID (PCI PASID) support: Limited to 8 bits process identifier.
58*c6f3443aSTomasz Jeznach      */
59*c6f3443aSTomasz Jeznach     unsigned int pid:8;
60cc05c43aSPeter Maydell } MemTxAttrs;
61cc05c43aSPeter Maydell 
62cc05c43aSPeter Maydell /* Bus masters which don't specify any attributes will get this,
63cc05c43aSPeter Maydell  * which has all attribute bits clear except the topmost one
64cc05c43aSPeter Maydell  * (so that we can distinguish "all attributes deliberately clear"
65cc05c43aSPeter Maydell  * from "didn't specify" if necessary).
66cc05c43aSPeter Maydell  */
67cc05c43aSPeter Maydell #define MEMTXATTRS_UNSPECIFIED ((MemTxAttrs) { .unspecified = 1 })
68cc05c43aSPeter Maydell 
693114d092SPeter Maydell /* New-style MMIO accessors can indicate that the transaction failed.
703114d092SPeter Maydell  * A zero (MEMTX_OK) response means success; anything else is a failure
713114d092SPeter Maydell  * of some kind. The memory subsystem will bitwise-OR together results
723114d092SPeter Maydell  * if it is synthesizing an operation from multiple smaller accesses.
733114d092SPeter Maydell  */
743114d092SPeter Maydell #define MEMTX_OK 0
753114d092SPeter Maydell #define MEMTX_ERROR             (1U << 0) /* device returned an error */
763114d092SPeter Maydell #define MEMTX_DECODE_ERROR      (1U << 1) /* nothing at that address */
773ab6fdc9SPhilippe Mathieu-Daudé #define MEMTX_ACCESS_ERROR      (1U << 2) /* access denied */
783114d092SPeter Maydell typedef uint32_t MemTxResult;
793114d092SPeter Maydell 
80cc05c43aSPeter Maydell #endif
81