From: Jan Kiszka <[email protected]> Array lookup is simpler, given this input-output mapping. This also obsoletes a couple of PARANGE constants.
Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/arch/arm64/include/asm/paging.h | 5 ----- hypervisor/arch/arm64/paging.c | 18 +++--------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/hypervisor/arch/arm64/include/asm/paging.h b/hypervisor/arch/arm64/include/asm/paging.h index 67664efa..932dbb50 100644 --- a/hypervisor/arch/arm64/include/asm/paging.h +++ b/hypervisor/arch/arm64/include/asm/paging.h @@ -101,11 +101,6 @@ #define SL0_L0 2 #define SL0_L1 1 #define SL0_L2 0 -#define PARANGE_32B 0x0 -#define PARANGE_36B 0x1 -#define PARANGE_40B 0x2 -#define PARANGE_42B 0x3 -#define PARANGE_44B 0x4 #define PARANGE_48B 0x5 #define TCR_RGN_NON_CACHEABLE 0x0 #define TCR_RGN_WB_WA 0x1 diff --git a/hypervisor/arch/arm64/paging.c b/hypervisor/arch/arm64/paging.c index 3a4eb096..27adcf55 100644 --- a/hypervisor/arch/arm64/paging.c +++ b/hypervisor/arch/arm64/paging.c @@ -26,6 +26,7 @@ unsigned int cpu_parange_encoded; */ unsigned int get_cpu_parange(void) { + static const unsigned int pa_bits[] = { 32, 36, 40, 42, 44, 48 }; unsigned int cpu; /* Largest supported value (for 4K paging) */ @@ -42,19 +43,6 @@ unsigned int get_cpu_parange(void) (per_cpu(cpu)->id_aa64mmfr0 & 0xf) < cpu_parange_encoded) cpu_parange_encoded = per_cpu(cpu)->id_aa64mmfr0 & 0xf; - switch (cpu_parange_encoded) { - case PARANGE_32B: - return 32; - case PARANGE_36B: - return 36; - case PARANGE_40B: - return 40; - case PARANGE_42B: - return 42; - case PARANGE_44B: - return 44; - case PARANGE_48B: - default: - return 48; - } + return cpu_parange_encoded < ARRAY_SIZE(pa_bits) ? + pa_bits[cpu_parange_encoded] : 0; } -- 2.26.2 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/3fbf6add766308dc29cb2f654f5247b97bc53072.1602664150.git.jan.kiszka%40siemens.com.
