Merge branch 'for-next/rng' into for-next/core
authorWill Deacon <will@kernel.org>
Wed, 22 Jan 2020 11:38:53 +0000 (11:38 +0000)
committerWill Deacon <will@kernel.org>
Wed, 22 Jan 2020 11:38:53 +0000 (11:38 +0000)
* for-next/rng: (2 commits)
  arm64: Use v8.5-RNG entropy for KASLR seed
  ...

1  2 
Documentation/arm64/cpu-feature-registers.rst
Documentation/arm64/elf_hwcaps.rst
arch/arm64/Kconfig
arch/arm64/include/asm/cpucaps.h
arch/arm64/include/asm/hwcap.h
arch/arm64/include/asm/sysreg.h
arch/arm64/include/uapi/asm/hwcap.h
arch/arm64/kernel/cpufeature.c
arch/arm64/kernel/cpuinfo.c

@@@ -204,34 -204,11 +204,38 @@@ HWCAP2_FRIN
  
      Functionality implied by ID_AA64ISAR1_EL1.FRINTTS == 0b0001.
  
 -
 +HWCAP2_SVEI8MM
 +
 +    Functionality implied by ID_AA64ZFR0_EL1.I8MM == 0b0001.
 +
 +HWCAP2_SVEF32MM
 +
 +    Functionality implied by ID_AA64ZFR0_EL1.F32MM == 0b0001.
 +
 +HWCAP2_SVEF64MM
 +
 +    Functionality implied by ID_AA64ZFR0_EL1.F64MM == 0b0001.
 +
 +HWCAP2_SVEBF16
 +
 +    Functionality implied by ID_AA64ZFR0_EL1.BF16 == 0b0001.
 +
 +HWCAP2_I8MM
 +
 +    Functionality implied by ID_AA64ISAR1_EL1.I8MM == 0b0001.
 +
 +HWCAP2_BF16
 +
 +    Functionality implied by ID_AA64ISAR1_EL1.BF16 == 0b0001.
 +
 +HWCAP2_DGH
 +
 +    Functionality implied by ID_AA64ISAR1_EL1.DGH == 0b0001.
 +
+ HWCAP2_RNG
+     Functionality implied by ID_AA64ISAR0_EL1.RNDR == 0b0001.
  4. Unused AT_HWCAP bits
  -----------------------
  
@@@ -1516,18 -1486,14 +1516,26 @@@ endmen
  
  menu "ARMv8.5 architectural features"
  
 +config ARM64_E0PD
 +      bool "Enable support for E0PD"
 +      default y
 +      help
 +        E0PD (part of the ARMv8.5 extensions) allows us to ensure
 +        that EL0 accesses made via TTBR1 always fault in constant time,
 +        providing similar benefits to KASLR as those provided by KPTI, but
 +        with lower overhead and without disrupting legitimate access to
 +        kernel memory such as SPE.
 +
 +        This option enables E0PD for TTBR1 where available.
 +
+ config ARCH_RANDOM
+       bool "Enable support for random number generation"
+       default y
+       help
+         Random number generation (part of the ARMv8.5 Extensions)
+         provides a high bandwidth, cryptographically secure
+         hardware random number generator.
  endmenu
  
  config ARM64_SVE
  #define ARM64_WORKAROUND_CAVIUM_TX2_219_TVM   45
  #define ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM  46
  #define ARM64_WORKAROUND_1542419              47
 -#define ARM64_WORKAROUND_1319367              48
 -#define ARM64_HAS_RNG                         49
 +#define ARM64_WORKAROUND_SPECULATIVE_AT_NVHE  48
 +#define ARM64_HAS_E0PD                                49
++#define ARM64_HAS_RNG                         50
  
--#define ARM64_NCAPS                           50
++#define ARM64_NCAPS                           51
  
  #endif /* __ASM_CPUCAPS_H */
  #define KERNEL_HWCAP_SVESM4           __khwcap2_feature(SVESM4)
  #define KERNEL_HWCAP_FLAGM2           __khwcap2_feature(FLAGM2)
  #define KERNEL_HWCAP_FRINT            __khwcap2_feature(FRINT)
- #define KERNEL_HWCAP_DGH              __khwcap2_feature(DGH)
 +#define KERNEL_HWCAP_SVEI8MM          __khwcap2_feature(SVEI8MM)
 +#define KERNEL_HWCAP_SVEF32MM         __khwcap2_feature(SVEF32MM)
 +#define KERNEL_HWCAP_SVEF64MM         __khwcap2_feature(SVEF64MM)
 +#define KERNEL_HWCAP_SVEBF16          __khwcap2_feature(SVEBF16)
 +#define KERNEL_HWCAP_I8MM             __khwcap2_feature(I8MM)
 +#define KERNEL_HWCAP_BF16             __khwcap2_feature(BF16)
++#define KERNEL_HWCAP_DGH              __khwcap2_feature(DGH)
+ #define KERNEL_HWCAP_RNG              __khwcap2_feature(RNG)
  
  /*
   * This yields a mask that user programs can use to figure out what
                         SCTLR_EL1_NTWE | SCTLR_ELx_IESB | SCTLR_EL1_SPAN |\
                         ENDIAN_SET_EL1 | SCTLR_EL1_UCI  | SCTLR_EL1_RES1)
  
 +/* MAIR_ELx memory attributes (used by Linux) */
 +#define MAIR_ATTR_DEVICE_nGnRnE               UL(0x00)
 +#define MAIR_ATTR_DEVICE_nGnRE                UL(0x04)
 +#define MAIR_ATTR_DEVICE_GRE          UL(0x0c)
 +#define MAIR_ATTR_NORMAL_NC           UL(0x44)
 +#define MAIR_ATTR_NORMAL_WT           UL(0xbb)
 +#define MAIR_ATTR_NORMAL              UL(0xff)
 +#define MAIR_ATTR_MASK                        UL(0xff)
 +
 +/* Position the attr at the correct index */
 +#define MAIR_ATTRIDX(attr, idx)               ((attr) << ((idx) * 8))
 +
  /* id_aa64isar0 */
+ #define ID_AA64ISAR0_RNDR_SHIFT               60
  #define ID_AA64ISAR0_TS_SHIFT         52
  #define ID_AA64ISAR0_FHM_SHIFT                48
  #define ID_AA64ISAR0_DP_SHIFT         44
  #define HWCAP2_SVESM4         (1 << 6)
  #define HWCAP2_FLAGM2         (1 << 7)
  #define HWCAP2_FRINT          (1 << 8)
 -#define HWCAP2_RNG            (1 << 9)
 +#define HWCAP2_SVEI8MM                (1 << 9)
 +#define HWCAP2_SVEF32MM               (1 << 10)
 +#define HWCAP2_SVEF64MM               (1 << 11)
 +#define HWCAP2_SVEBF16                (1 << 12)
 +#define HWCAP2_I8MM           (1 << 13)
 +#define HWCAP2_BF16           (1 << 14)
 +#define HWCAP2_DGH            (1 << 15)
++#define HWCAP2_RNG            (1 << 16)
  
  #endif /* _UAPI__ASM_HWCAP_H */
@@@ -1646,19 -1568,18 +1647,31 @@@ static const struct arm64_cpu_capabilit
                .min_field_value = 1,
        },
  #endif
 +#ifdef CONFIG_ARM64_E0PD
 +      {
 +              .desc = "E0PD",
 +              .capability = ARM64_HAS_E0PD,
 +              .type = ARM64_CPUCAP_SYSTEM_FEATURE,
 +              .sys_reg = SYS_ID_AA64MMFR2_EL1,
 +              .sign = FTR_UNSIGNED,
 +              .field_pos = ID_AA64MMFR2_E0PD_SHIFT,
 +              .matches = has_cpuid_feature,
 +              .min_field_value = 1,
 +              .cpu_enable = cpu_enable_e0pd,
 +      },
 +#endif
+ #ifdef CONFIG_ARCH_RANDOM
+       {
+               .desc = "Random Number Generator",
+               .capability = ARM64_HAS_RNG,
+               .type = ARM64_CPUCAP_SYSTEM_FEATURE,
+               .matches = has_cpuid_feature,
+               .sys_reg = SYS_ID_AA64ISAR0_EL1,
+               .field_pos = ID_AA64ISAR0_RNDR_SHIFT,
+               .sign = FTR_UNSIGNED,
+               .min_field_value = 1,
+       },
+ #endif
        {},
  };
  
@@@ -84,13 -84,7 +84,14 @@@ static const char *const hwcap_str[] = 
        "svesm4",
        "flagm2",
        "frint",
 +      "svei8mm",
 +      "svef32mm",
 +      "svef64mm",
 +      "svebf16",
 +      "i8mm",
 +      "bf16",
 +      "dgh",
+       "rng",
        NULL
  };