From: Jan Kiszka <[email protected]>

Array lookup is simpler, given this input-output mapping. Cover the
52-bit case as well at this chance. 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             | 19 +++----------------
 2 files changed, 3 insertions(+), 21 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 db8314a6..cccce410 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, 52 };
        unsigned int cpu;
 
        /* Larger than any possible value */
@@ -42,20 +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:
-               return 48;
-       default:
-               return 0;
-       }
+       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/7434305f16589d47d0248ba127edd82bf234d9e0.1601838005.git.jan.kiszka%40siemens.com.

Reply via email to