Michael Clark
unread,Jun 17, 2017, 3:38:40 AM6/17/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to RISC-V ISA Dev
The specification talks at a high level about PMAs (Physical Memory Attributes) but in reality only has fine details on PMP (Physical Memory Protection).
So while I was reading the spec I decided to make a table of PMAs.
I generally tried to avoid attributes with negative meanings so there are some properties that are expressed via the absence of flags. e.g. the absence of pma_policy_coherent means a region without this flag is incoherent.
I have split cache write policy from cache allocation policy so there are some combinations that may not make sense and there may be some duplication, however it is a starting point.
For cache allocation, the lack of read allocate means only writes cause allocation and vice versa. Normally both or neither would be set but there are cases where one may wish reads to be cached and writes direct to memory, or writes cached and reads go direct to memory. This is as about as fine grained control as one could get. Allocate on read and write are both properties of caches and my intention was to be exhaustive (even if both bits are usually set). In some sense pma_cache_alloc_read may make pma_cache_write_around redundant however it is included for completeness.
I am not happy with the IO sizes as they are all powers of 2 and the limit is currently 1024-bit. I ran out of bits in a 32-bit word. We have 384-bit GDDR memory systems and 4096-bit HBM memory systems so the IO sizes need some work.
Ordering and AMOs comes straight from the spec. There are also PMP properties for implementations that may implement PMP as attributes of a wider scoped PMA table. There are also needs to be a distinction between read-only attributes that expose the type of memory ranges versus bits that can be changed.
Given we were discussing caching I thought I would share the list. It might be useful for future reference.
/* supported memory range types */
pma_type_illegal = 1U<<0, /* illegal region */
pma_type_main = 1U<<1, /* main memory region */
pma_type_io = 1U<<2, /* IO memory region */
/* supported memory range cache write modes */
pma_cache_write_back = 1U<<3, /* write back caching (normal cache policy) */
pma_cache_write_through = 1U<<4, /* write through cache to backing store */
pma_cache_write_combine = 1U<<5, /* write accumulate until fence or cache line is full */
pma_cache_write_around = 1U<<6, /* uncacheable, write directly to backing store */
/* supported memory range cache allocation modes (4 combinations) */
pma_cache_alloc_read = 1U<<7, /* allocate cache on reads */
pma_cache_alloc_write = 1U<<8, /* allocate cache on writes */
/* supported memory range backing store write sizes */
pma_io_size_1 = 1U<<9, /* b - 8-bit */
pma_io_size_2 = 1U<<10, /* h - 16-bit */
pma_io_size_4 = 1U<<11, /* w - 32-bit */
pma_io_size_8 = 1U<<12, /* d - 64-bit */
pma_io_size_16 = 1U<<13, /* q - 128-bit */
pma_io_size_32 = 1U<<14, /* o - 256-bit */
pma_io_size_64 = 1U<<15, /* qq - 512-bit */
pma_io_size_128 = 1U<<16, /* qo - 1024-bit */
/* supported memory ordering */
pma_order_channel_0 = 1U<<17, /* hart point to point strong ordering */
pma_order_channel_1 = 1U<<18, /* hart global strong ordering */
/* supported memory range coherence policies (not coherent, not private is a type) */
pma_policy_coherent = 1U<<19, /* hardware managed coherence */
pma_policy_private = 1U<<20, /* non shared private */
/* support memory range atomic operations (not present indicates no amo support) */
pma_io_amo_swap = 1U<<21, /* amoswap */
pma_io_amo_logical = 1U<<22, /* above + amoand, amoor, amoxor */
pma_io_amo_arithmetic = 1U<<23, /* above + amoadd, amomin, amomax, amominu, amomaxu */
/* supported memory range atomic operation sizes (amo for aligend main memory is implied) */
pma_io_amo_size_4 = 1U<<24, /* amo<>.w */
pma_io_amo_size_8 = 1U<<25, /* amo<>.d */
pma_io_amo_size_16 = 1U<<26, /* amo<>.q */
/* supported memory range io idempotency (N/A main memory) */
pma_io_idempotent_read = 1U<<27, /* reads are idempotent (allow speculative or redundant reads) */
pma_io_idempotent_write = 1U<<28, /* writes are idempotent (allow speculative or redundant writes) */
/* supported memory range protection */
pma_prot_read = 1U<<29, /* region is readable */
pma_prot_write = 1U<<30, /* region is writable */
pma_prot_execute = 1U<<31, /* region is executable */