Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros

Define macros for memory type indexes and construct DEFAULT_MAIR_EL1
with macros from asm/sysreg.h. The index macros can then be used when
constructing PTEs (instead of using raw numbers).

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
Reviewed-by: Oliver Upton <oupton@google.com>
Signed-off-by: Ricardo Koller <ricarkol@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20221017195834.2295901-5-ricarkol@google.com

authored by

Ricardo Koller and committed by
Marc Zyngier
41f5189e b6b03b86

+20 -7
+19 -6
tools/testing/selftests/kvm/include/aarch64/processor.h
··· 38 38 * NORMAL 4 1111:1111 39 39 * NORMAL_WT 5 1011:1011 40 40 */ 41 - #define DEFAULT_MAIR_EL1 ((0x00ul << (0 * 8)) | \ 42 - (0x04ul << (1 * 8)) | \ 43 - (0x0cul << (2 * 8)) | \ 44 - (0x44ul << (3 * 8)) | \ 45 - (0xfful << (4 * 8)) | \ 46 - (0xbbul << (5 * 8))) 41 + 42 + /* Linux doesn't use these memory types, so let's define them. */ 43 + #define MAIR_ATTR_DEVICE_GRE UL(0x0c) 44 + #define MAIR_ATTR_NORMAL_WT UL(0xbb) 45 + 46 + #define MT_DEVICE_nGnRnE 0 47 + #define MT_DEVICE_nGnRE 1 48 + #define MT_DEVICE_GRE 2 49 + #define MT_NORMAL_NC 3 50 + #define MT_NORMAL 4 51 + #define MT_NORMAL_WT 5 52 + 53 + #define DEFAULT_MAIR_EL1 \ 54 + (MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRnE, MT_DEVICE_nGnRnE) | \ 55 + MAIR_ATTRIDX(MAIR_ATTR_DEVICE_nGnRE, MT_DEVICE_nGnRE) | \ 56 + MAIR_ATTRIDX(MAIR_ATTR_DEVICE_GRE, MT_DEVICE_GRE) | \ 57 + MAIR_ATTRIDX(MAIR_ATTR_NORMAL_NC, MT_NORMAL_NC) | \ 58 + MAIR_ATTRIDX(MAIR_ATTR_NORMAL, MT_NORMAL) | \ 59 + MAIR_ATTRIDX(MAIR_ATTR_NORMAL_WT, MT_NORMAL_WT)) 47 60 48 61 #define MPIDR_HWID_BITMASK (0xff00fffffful) 49 62
+1 -1
tools/testing/selftests/kvm/lib/aarch64/processor.c
··· 133 133 134 134 void virt_arch_pg_map(struct kvm_vm *vm, uint64_t vaddr, uint64_t paddr) 135 135 { 136 - uint64_t attr_idx = 4; /* NORMAL (See DEFAULT_MAIR_EL1) */ 136 + uint64_t attr_idx = MT_NORMAL; 137 137 138 138 _virt_pg_map(vm, vaddr, paddr, attr_idx); 139 139 }