mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 17:42:41 +00:00
ipq807x: revert all 11.5 changes
Fixes: WIFI-7570 Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -4,17 +4,17 @@ ARCH:=arm
|
||||
BOARD:=ipq807x
|
||||
BOARDNAME:=Qualcomm Atheros AX
|
||||
SUBTARGETS:=ipq807x ipq60xx ipq50xx
|
||||
FEATURES:=squashfs ramdisk nand pcie usb usbgadget
|
||||
FEATURES:=squashfs ramdisk nand pcie usb
|
||||
KERNELNAME:=Image dtbs
|
||||
CPU_TYPE:=cortex-a7
|
||||
|
||||
KERNEL_PATCHVER:=5.4
|
||||
KERNEL_NAME_SUFFIX=-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac
|
||||
KERNEL_PATCHVER:=4.4
|
||||
KERNEL_NAME_SUFFIX=-qsdk-11f09717303ecd83c3a64e9efe23f25921dc1016
|
||||
|
||||
include $(INCLUDE_DIR)/target.mk
|
||||
DEFAULT_PACKAGES += kmod-qca-nss-dp kmod-qca-ssdk swconfig \
|
||||
kmod-qca-nss-drv \
|
||||
kmod-usb-phy-ipq807x kmod-usb-dwc3-qcom-internal \
|
||||
kmod-usb-phy-ipq807x kmod-usb-dwc3-of-simple \
|
||||
kmod-ath11k-ahb kmod-qrtr_mproc wpad \
|
||||
kmod-gpio-button-hotplug \
|
||||
qca-thermald-10.4 qca-ssdk-shell kmod-qca-nss-drv-bridge-mgr \
|
||||
|
||||
@@ -79,7 +79,7 @@ qcom_setup_macs()
|
||||
cig,wf194c|\
|
||||
cig,wf194c4|\
|
||||
cig,wf196)
|
||||
mac=$(grep BaseMacAddress= /dev/mtd18 | cut -dx -f2)
|
||||
mac=$(grep BaseMacAddress= /dev/mtd14 | cut -dx -f2)
|
||||
wan_mac=$(macaddr_canonicalize $mac)
|
||||
lan_mac=$(macaddr_add "$wan_mac" 1)
|
||||
ucidef_set_network_device_mac eth0 $lan_mac
|
||||
|
||||
829
feeds/ipq807x/ipq807x/config-4.4
Normal file
829
feeds/ipq807x/ipq807x/config-4.4
Normal file
@@ -0,0 +1,829 @@
|
||||
# CONFIG_AHCI_IPQ is not set
|
||||
CONFIG_ALIGNMENT_TRAP=y
|
||||
# CONFIG_ALLOW_DEV_COREDUMP is not set
|
||||
# CONFIG_AMBA_PL08X is not set
|
||||
# CONFIG_APM_EMULATION is not set
|
||||
# CONFIG_APQ_GCC_8084 is not set
|
||||
# CONFIG_APQ_MMCC_8084 is not set
|
||||
# CONFIG_AR8216_PHY is not set
|
||||
CONFIG_ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE=y
|
||||
CONFIG_ARCH_HAS_ELF_RANDOMIZE=y
|
||||
CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y
|
||||
CONFIG_ARCH_HAS_SG_CHAIN=y
|
||||
CONFIG_ARCH_HAS_TICK_BROADCAST=y
|
||||
CONFIG_ARCH_HAVE_CUSTOM_GPIO_H=y
|
||||
# CONFIG_ARCH_IPQ40XX is not set
|
||||
# CONFIG_ARCH_IPQ806x is not set
|
||||
# CONFIG_ARCH_IPQ807x is not set
|
||||
# CONFIG_ARCH_IPQ6018 is not set
|
||||
# CONFIG_ARCH_IPQ5018 is not set
|
||||
CONFIG_ARCH_MIGHT_HAVE_PC_PARPORT=y
|
||||
# CONFIG_ARCH_MSM8960 is not set
|
||||
# CONFIG_ARCH_MSM8974 is not set
|
||||
CONFIG_ARCH_MSM8X60=y
|
||||
CONFIG_ARCH_MULTIPLATFORM=y
|
||||
# CONFIG_ARCH_MULTI_CPU_AUTO is not set
|
||||
CONFIG_ARCH_MULTI_V6_V7=y
|
||||
CONFIG_ARCH_MULTI_V7=y
|
||||
CONFIG_ARCH_NR_GPIO=0
|
||||
CONFIG_ARCH_QCOM=y
|
||||
CONFIG_QSEECOM=m
|
||||
# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
|
||||
# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
|
||||
CONFIG_ARCH_SUPPORTS_ATOMIC_RMW=y
|
||||
CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
|
||||
CONFIG_ARCH_SUPPORTS_UPROBES=y
|
||||
CONFIG_ARCH_SUSPEND_POSSIBLE=y
|
||||
CONFIG_ARCH_USE_BUILTIN_BSWAP=y
|
||||
CONFIG_ARCH_USE_CMPXCHG_LOCKREF=y
|
||||
CONFIG_ARCH_WANT_GENERAL_HUGETLB=y
|
||||
CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y
|
||||
CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
|
||||
CONFIG_ARM=y
|
||||
CONFIG_ARM_AMBA=y
|
||||
CONFIG_ARM_ARCH_TIMER=y
|
||||
CONFIG_ARM_ARCH_TIMER_EVTSTREAM=y
|
||||
# CONFIG_ARM_ATAG_DTB_COMPAT is not set
|
||||
CONFIG_ARM_CCI=y
|
||||
CONFIG_ARM_CCI400_COMMON=y
|
||||
CONFIG_ARM_CCI400_PMU=y
|
||||
CONFIG_ARM_CCI_PMU=y
|
||||
CONFIG_ARM_CPU_SUSPEND=y
|
||||
CONFIG_ARM_GIC=y
|
||||
CONFIG_ARM_HAS_SG_CHAIN=y
|
||||
# CONFIG_ARM_HIGHBANK_CPUIDLE is not set
|
||||
CONFIG_ARM_CPUIDLE=y
|
||||
CONFIG_ARM_L1_CACHE_SHIFT=6
|
||||
CONFIG_ARM_L1_CACHE_SHIFT_6=y
|
||||
# CONFIG_ARM_LPAE is not set
|
||||
CONFIG_ARM_MODULE_PLTS=y
|
||||
CONFIG_ARM_PATCH_PHYS_VIRT=y
|
||||
CONFIG_ARM_PMU=y
|
||||
CONFIG_ARM_PSCI=y
|
||||
CONFIG_ARM_PSCI_FW=y
|
||||
CONFIG_ARM_QCOM_CPUFREQ=y
|
||||
# CONFIG_ARM_SMMU is not set
|
||||
# CONFIG_ARM_SP805_WATCHDOG is not set
|
||||
CONFIG_ARM_THUMB=y
|
||||
# CONFIG_ARM_THUMBEE is not set
|
||||
CONFIG_ARM_UNWIND=y
|
||||
CONFIG_ARM_VIRT_EXT=y
|
||||
CONFIG_AT803X_PHY=y
|
||||
# CONFIG_ATA is not set
|
||||
CONFIG_BLK_DEV_LOOP=y
|
||||
CONFIG_BLK_DEV_NVME=y
|
||||
CONFIG_BLK_DEV_RAM=y
|
||||
CONFIG_BLK_DEV_RAM_COUNT=16
|
||||
CONFIG_BLK_DEV_RAM_SIZE=4096
|
||||
# CONFIG_VIRTIO_BLK is not set
|
||||
# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
|
||||
CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
|
||||
CONFIG_BOUNCE=y
|
||||
CONFIG_BUILD_BIN2C=y
|
||||
# CONFIG_CNSS_QCN9000 is not set
|
||||
# CONFIG_CNSS2 is not set
|
||||
# CONFIG_CNSS2_GENL is not set
|
||||
# CONFIG_CNSS2_DEBUG is not set
|
||||
# CONFIG_CNSS2_PM is not set
|
||||
# CONFIG_CNSS2_PCI_DRIVER is not set
|
||||
# CONFIG_CNSS2_CALIBRATION_SUPPORT is not set
|
||||
# CONFIG_CNSS2_SMMU is not set
|
||||
# CONFIG_CNSS2_RAMDUMP is not set
|
||||
# CONFIG_CACHE_L2X0 is not set
|
||||
CONFIG_CC_OPTIMIZE_FOR_SIZE=y
|
||||
CONFIG_CC_STACKPROTECTOR=y
|
||||
# CONFIG_CC_STACKPROTECTOR_NONE is not set
|
||||
CONFIG_CC_STACKPROTECTOR_REGULAR=y
|
||||
# CONFIG_CHARGER_QCOM_SMBB is not set
|
||||
CONFIG_CLEANCACHE=y
|
||||
CONFIG_CLKDEV_LOOKUP=y
|
||||
CONFIG_CLKSRC_OF=y
|
||||
CONFIG_CLKSRC_PROBE=y
|
||||
CONFIG_CLKSRC_QCOM=y
|
||||
CONFIG_CLONE_BACKWARDS=y
|
||||
CONFIG_COMMON_CLK=y
|
||||
CONFIG_COMMON_CLK_QCOM=y
|
||||
CONFIG_CONFIGFS_FS=y
|
||||
CONFIG_COREDUMP=y
|
||||
# CONFIG_CORESIGHT is not set
|
||||
# CONFIG_CORESIGHT_CSR is not set
|
||||
# CONFIG_CORESIGHT_CTI is not set
|
||||
# NFIG_CORESIGHT_EVENT is not set
|
||||
# CONFIG_CORESIGHT_HWEVENT is not set
|
||||
# CONFIG_CORESIGHT_LINKS_AND_SINKS is not set
|
||||
# CONFIG_CORESIGHT_LINK_AND_SINK_TMC is not set
|
||||
# CONFIG_CORESIGHT_QCOM_REPLICATOR is not set
|
||||
# CONFIG_CORESIGHT_QPDI is not set
|
||||
# CONFIG_CORESIGHT_SINK_ETBV10 is not set
|
||||
# CONFIG_CORESIGHT_SINK_TPIU is not set
|
||||
# CONFIG_CORESIGHT_SOURCE_DUMMY is not set
|
||||
# CONFIG_CORESIGHT_SOURCE_ETM3X is not set
|
||||
# CONFIG_CORESIGHT_SOURCE_ETM4X is not set
|
||||
# CONFIG_CORESIGHT_REMOTE_ETM is not set
|
||||
# CONFIG_CORESIGHT_STM is not set
|
||||
# CONFIG_CORESIGHT_TPDA is not set
|
||||
# CONFIG_CORESIGHT_TPDM is not set
|
||||
# CONFIG_CORESIGHT_TPDM_DEFAULT_ENABLE is not set
|
||||
# CONFIG_CORESIGHT_STREAM is not set
|
||||
CONFIG_CPUFREQ_DT=y
|
||||
CONFIG_CPUFREQ_DT_PLATDEV=y
|
||||
CONFIG_CPU_32v6K=y
|
||||
CONFIG_CPU_32v7=y
|
||||
CONFIG_CPU_ABRT_EV7=y
|
||||
# CONFIG_CPU_BIG_ENDIAN is not set
|
||||
# CONFIG_CPU_BPREDICT_DISABLE is not set
|
||||
CONFIG_CPU_CACHE_V7=y
|
||||
CONFIG_CPU_CACHE_VIPT=y
|
||||
CONFIG_CPU_COPY_V6=y
|
||||
CONFIG_CPU_CP15=y
|
||||
CONFIG_CPU_CP15_MMU=y
|
||||
# CONFIG_CPU_SW_DOMAIN_PAN is not set
|
||||
CONFIG_CPU_FREQ=y
|
||||
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
|
||||
CONFIG_CPU_FREQ_GOV_COMMON=y
|
||||
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
|
||||
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
|
||||
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
|
||||
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
|
||||
CONFIG_CPU_FREQ_GOV_USERSPACE=y
|
||||
CONFIG_CPU_FREQ_STAT=y
|
||||
CONFIG_CPU_HAS_ASID=y
|
||||
# CONFIG_CPU_ICACHE_DISABLE is not set
|
||||
CONFIG_CPU_IDLE=y
|
||||
CONFIG_CPU_IDLE_GOV_LADDER=y
|
||||
CONFIG_CPU_IDLE_GOV_MENU=y
|
||||
CONFIG_CPU_PABRT_V7=y
|
||||
CONFIG_CPU_PM=y
|
||||
CONFIG_CPU_RMAP=y
|
||||
# CONFIG_CPU_THERMAL is not set
|
||||
CONFIG_CPU_TLB_V7=y
|
||||
CONFIG_CPU_V7=y
|
||||
CONFIG_CRC16=y
|
||||
# CONFIG_CRC32_SARWATE is not set
|
||||
CONFIG_CRC32_SLICEBY8=y
|
||||
CONFIG_CROSS_MEMORY_ATTACH=y
|
||||
# CONFIG_CRYPTO_DEV_QCOM_MSM_QCE is not set
|
||||
# CONFIG_CRYPTO_DEV_OTA_CRYPTO is not set
|
||||
# CONFIG_FIPS_ENABLE is not set
|
||||
CONFIG_CRYPTO_AEAD=y
|
||||
CONFIG_CRYPTO_AEAD2=y
|
||||
CONFIG_CRYPTO_BLKCIPHER=y
|
||||
CONFIG_CRYPTO_BLKCIPHER2=y
|
||||
CONFIG_CRYPTO_CBC=y
|
||||
CONFIG_CRYPTO_CCM=y
|
||||
CONFIG_CRYPTO_CRC32C=y
|
||||
CONFIG_CRYPTO_CTR=y
|
||||
CONFIG_CRYPTO_DEFLATE=y
|
||||
CONFIG_CRYPTO_CMAC=y
|
||||
# CONFIG_CRYPTO_DEV_QCOM_ICE is not set
|
||||
CONFIG_CRYPTO_ECHAINIV=y
|
||||
CONFIG_CRYPTO_ECB=y
|
||||
CONFIG_CRYPTO_HASH2=y
|
||||
CONFIG_CRYPTO_HASH_INFO=y
|
||||
CONFIG_CRYPTO_HW=y
|
||||
CONFIG_CRYPTO_LZO=y
|
||||
CONFIG_CRYPTO_MANAGER=y
|
||||
CONFIG_CRYPTO_MANAGER2=y
|
||||
CONFIG_CRYPTO_NULL=y
|
||||
CONFIG_CRYPTO_RNG=y
|
||||
CONFIG_CRYPTO_RNG2=y
|
||||
CONFIG_CRYPTO_SEQIV=y
|
||||
CONFIG_CRYPTO_SHA256=y
|
||||
CONFIG_CRYPTO_WORKQUEUE=y
|
||||
CONFIG_CRYPTO_XZ=y
|
||||
CONFIG_CRYPTO_ARC4=y
|
||||
CONFIG_CRYPTO_GCM=y
|
||||
CONFIG_DCACHE_WORD_ACCESS=y
|
||||
CONFIG_DEBUG_BUGVERBOSE=y
|
||||
CONFIG_DEBUG_GPIO=y
|
||||
# CONFIG_DEBUG_INFO_REDUCED is not set
|
||||
CONFIG_DEBUG_LL_INCLUDE="mach/debug-macro.S"
|
||||
# CONFIG_DEBUG_MEM_USAGE is not set
|
||||
# CONFIG_DEBUG_UART_8250 is not set
|
||||
# CONFIG_DEBUG_USER is not set
|
||||
CONFIG_DECOMPRESS_GZIP=y
|
||||
CONFIG_DEVMEM=y
|
||||
# CONFIG_DIAG_OVER_USB is not set
|
||||
CONFIG_DMADEVICES=y
|
||||
CONFIG_DMA_ENGINE=y
|
||||
CONFIG_DMA_OF=y
|
||||
CONFIG_DMA_VIRTUAL_CHANNELS=y
|
||||
CONFIG_DTC=y
|
||||
# CONFIG_DWMAC_GENERIC is not set
|
||||
# CONFIG_DWMAC_IPQ806X is not set
|
||||
# CONFIG_DWMAC_SUNXI is not set
|
||||
# CONFIG_DW_DMAC_PCI is not set
|
||||
# CONFIG_VHOST_NET is not set
|
||||
# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set
|
||||
CONFIG_DYNAMIC_DEBUG=y
|
||||
CONFIG_ETHERNET_PACKET_MANGLE=y
|
||||
CONFIG_EXT4_FS=y
|
||||
# CONFIG_EXT4_USE_FOR_EXT2 is not set
|
||||
CONFIG_FB=y
|
||||
CONFIG_FB_CFB_COPYAREA=y
|
||||
CONFIG_FB_CFB_FILLRECT=y
|
||||
CONFIG_FB_CFB_IMAGEBLIT=y
|
||||
CONFIG_FB_CMDLINE=y
|
||||
CONFIG_FB_QCOM_QPIC=y
|
||||
CONFIG_FB_QCOM_QPIC_ER_SSD1963_PANEL=y
|
||||
CONFIG_FB_SYS_FOPS=y
|
||||
CONFIG_FIXED_PHY=y
|
||||
CONFIG_FIX_EARLYCON_MEM=y
|
||||
CONFIG_FS_MBCACHE=y
|
||||
CONFIG_GENERIC_ALLOCATOR=y
|
||||
CONFIG_GENERIC_BUG=y
|
||||
CONFIG_GENERIC_CLOCKEVENTS=y
|
||||
CONFIG_GENERIC_CLOCKEVENTS_BROADCAST=y
|
||||
# CONFIG_GENERIC_CPUFREQ_KRAIT is not set
|
||||
CONFIG_GENERIC_IDLE_POLL_SETUP=y
|
||||
CONFIG_GENERIC_IO=y
|
||||
CONFIG_GENERIC_IRQ_SHOW=y
|
||||
CONFIG_GENERIC_IRQ_SHOW_LEVEL=y
|
||||
CONFIG_GENERIC_MSI_IRQ=y
|
||||
CONFIG_GENERIC_PCI_IOMAP=y
|
||||
CONFIG_GENERIC_PHY=y
|
||||
CONFIG_GENERIC_PINCONF=y
|
||||
CONFIG_GENERIC_SCHED_CLOCK=y
|
||||
CONFIG_GENERIC_SMP_IDLE_THREAD=y
|
||||
CONFIG_GENERIC_STRNCPY_FROM_USER=y
|
||||
CONFIG_GENERIC_STRNLEN_USER=y
|
||||
CONFIG_GENERIC_TIME_VSYSCALL=y
|
||||
CONFIG_GPIOLIB=y
|
||||
CONFIG_GPIOLIB_IRQCHIP=y
|
||||
CONFIG_GPIO_DEVRES=y
|
||||
# CONFIG_GPIO_LATCH is not set
|
||||
# CONFIG_GPIO_NXP_74HC153 is not set
|
||||
CONFIG_GPIO_SYSFS=y
|
||||
CONFIG_HANDLE_DOMAIN_IRQ=y
|
||||
CONFIG_HARDIRQS_SW_RESEND=y
|
||||
CONFIG_HAS_DMA=y
|
||||
CONFIG_HAS_IOMEM=y
|
||||
CONFIG_HAS_IOPORT_MAP=y
|
||||
# CONFIG_HAVE_64BIT_ALIGNED_ACCESS is not set
|
||||
CONFIG_HAVE_ARCH_AUDITSYSCALL=y
|
||||
CONFIG_HAVE_ARCH_BITREVERSE=y
|
||||
CONFIG_HAVE_ARCH_JUMP_LABEL=y
|
||||
CONFIG_HAVE_ARCH_KGDB=y
|
||||
CONFIG_HAVE_ARCH_PFN_VALID=y
|
||||
CONFIG_HAVE_ARCH_SECCOMP_FILTER=y
|
||||
CONFIG_HAVE_ARCH_TRACEHOOK=y
|
||||
CONFIG_HAVE_ARM_ARCH_TIMER=y
|
||||
# CONFIG_HAVE_BOOTMEM_INFO_NODE is not set
|
||||
CONFIG_HAVE_BPF_JIT=y
|
||||
CONFIG_HAVE_CC_STACKPROTECTOR=y
|
||||
CONFIG_HAVE_CLK=y
|
||||
CONFIG_HAVE_CLK_PREPARE=y
|
||||
CONFIG_HAVE_CONTEXT_TRACKING=y
|
||||
CONFIG_HAVE_C_RECORDMCOUNT=y
|
||||
CONFIG_HAVE_DEBUG_KMEMLEAK=y
|
||||
CONFIG_HAVE_DMA_API_DEBUG=y
|
||||
CONFIG_HAVE_DMA_ATTRS=y
|
||||
CONFIG_HAVE_DMA_CONTIGUOUS=y
|
||||
CONFIG_HAVE_DYNAMIC_FTRACE=y
|
||||
CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y
|
||||
CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
|
||||
CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
|
||||
CONFIG_HAVE_FUNCTION_TRACER=y
|
||||
# CONFIG_SRD_TRACE is not set
|
||||
CONFIG_HAVE_GENERIC_DMA_COHERENT=y
|
||||
CONFIG_HAVE_HW_BREAKPOINT=y
|
||||
CONFIG_HAVE_IDE=y
|
||||
CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
|
||||
CONFIG_HAVE_KERNEL_GZIP=y
|
||||
CONFIG_HAVE_KERNEL_LZ4=y
|
||||
CONFIG_HAVE_KERNEL_LZMA=y
|
||||
CONFIG_HAVE_KERNEL_LZO=y
|
||||
CONFIG_HAVE_KERNEL_XZ=y
|
||||
# CONFIG_HAVE_KPROBES is not set
|
||||
# CONFIG_HAVE_KRETPROBES is not set
|
||||
CONFIG_HAVE_MEMBLOCK=y
|
||||
CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
|
||||
CONFIG_HAVE_NET_DSA=y
|
||||
CONFIG_HAVE_OPROFILE=y
|
||||
# CONFIG_HAVE_OPTPROBES is not set
|
||||
CONFIG_HAVE_PERF_EVENTS=y
|
||||
CONFIG_HAVE_PERF_REGS=y
|
||||
CONFIG_HAVE_PERF_USER_STACK_DUMP=y
|
||||
CONFIG_HAVE_PROC_CPU=y
|
||||
CONFIG_HAVE_REGS_AND_STACK_ACCESS_API=y
|
||||
CONFIG_HAVE_SMP=y
|
||||
CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
|
||||
CONFIG_HAVE_UID16=y
|
||||
CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y
|
||||
CONFIG_HIGHMEM=y
|
||||
CONFIG_HIGHPTE=y
|
||||
CONFIG_HOTPLUG_CPU=y
|
||||
CONFIG_HWMON=y
|
||||
CONFIG_HWSPINLOCK=y
|
||||
CONFIG_HWSPINLOCK_QCOM=y
|
||||
CONFIG_HW_RANDOM=y
|
||||
CONFIG_HW_RANDOM_MSM=y
|
||||
CONFIG_HZ_FIXED=0
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_BOARDINFO=y
|
||||
CONFIG_I2C_CHARDEV=y
|
||||
CONFIG_I2C_COMPAT=y
|
||||
CONFIG_I2C_HELPER_AUTO=y
|
||||
CONFIG_I2C_QUP=y
|
||||
# CONFIG_IIO is not set
|
||||
# CONFIG_IIO_BUFFER is not set
|
||||
# CONFIG_IIO_TRIGGER is not set
|
||||
CONFIG_IKCONFIG=y
|
||||
CONFIG_IKCONFIG_PROC=y
|
||||
CONFIG_INITRAMFS_SOURCE=""
|
||||
# CONFIG_INPUT_PM8941_PWRKEY is not set
|
||||
CONFIG_IOMMU_HELPER=y
|
||||
# CONFIG_IOMMU_IO_PGTABLE_LPAE is not set
|
||||
# CONFIG_IPQ_DWC3_QTI_EXTCON is not set
|
||||
# CONFIG_IPQ_GCC_4019 is not set
|
||||
# CONFIG_IPQ_GCC_5018 is not set
|
||||
# CONFIG_IPQ_APSS_5018 is not set
|
||||
# CONFIG_IPQ_GCC_6018 is not set
|
||||
# CONFIG_IPQ_APSS_6018 is not set
|
||||
# CONFIG_IPQ_GCC_806X is not set
|
||||
# CONFIG_IPQ_ADSS_807x is not set
|
||||
# CONFIG_IPQ_APSS_807x is not set
|
||||
# CONFIG_IPQ_GCC_807x is not set
|
||||
# CONFIG_IPQ_ADCC_4019 is not set
|
||||
# CONFIG_IPQ_LCC_806X is not set
|
||||
# CONFIG_IPQ_REMOTEPROC_ADSP is not set
|
||||
# CONFIG_IPQ_SUBSYSTEM_RESTART is not set
|
||||
# CONFIG_IPQ_SUBSYSTEM_RESTART_TEST is not set
|
||||
CONFIG_IRQCHIP=y
|
||||
CONFIG_IRQ_DOMAIN=y
|
||||
CONFIG_IRQ_DOMAIN_HIERARCHY=y
|
||||
CONFIG_IRQ_FORCED_THREADING=y
|
||||
CONFIG_IRQ_WORK=y
|
||||
CONFIG_JBD2=y
|
||||
# CONFIG_IPC_ROUTER is not set
|
||||
# CONFIG_IPC_ROUTER_SECURITY is not set
|
||||
# CONFIG_IPC_LOGGING is not set
|
||||
CONFIG_KPSS_XCC=y
|
||||
# CONFIG_KRAITCC is not set
|
||||
# CONFIG_KRAIT_CLOCKS is not set
|
||||
# CONFIG_KRAIT_L2_ACCESSORS is not set
|
||||
CONFIG_LEDS_IPQ=y
|
||||
CONFIG_LEDS_PWM=y
|
||||
CONFIG_LEDS_TLC591XX=y
|
||||
# CONFIG_LEDS_PCA9956B is not set
|
||||
CONFIG_LIBFDT=y
|
||||
CONFIG_LOCKUP_DETECTOR=y
|
||||
CONFIG_LOCK_SPIN_ON_OWNER=y
|
||||
CONFIG_LZO_COMPRESS=y
|
||||
CONFIG_LZO_DECOMPRESS=y
|
||||
CONFIG_MDIO=y
|
||||
CONFIG_MDIO_BITBANG=y
|
||||
CONFIG_MDIO_BOARDINFO=y
|
||||
CONFIG_MDIO_GPIO=y
|
||||
# CONFIG_MDIO_QCA is not set
|
||||
CONFIG_MFD_QCOM_RPM=y
|
||||
CONFIG_MFD_SPMI_PMIC=y
|
||||
# CONFIG_SLIMBUS is not set
|
||||
# CONFIG_SLIMBUS_MSM_CTRL is not set
|
||||
# CONFIG_SLIMBUS_MSM_NGD is not set
|
||||
# CONFIG_OF_SLIMBUS is not set
|
||||
CONFIG_MFD_SYSCON=y
|
||||
CONFIG_MIGHT_HAVE_CACHE_L2X0=y
|
||||
CONFIG_MIGHT_HAVE_PCI=y
|
||||
CONFIG_MMC=y
|
||||
CONFIG_MMC_ARMMMCI=y
|
||||
CONFIG_MMC_BLOCK=y
|
||||
CONFIG_MMC_BLOCK_MINORS=32
|
||||
CONFIG_MMC_QCOM_DML=y
|
||||
CONFIG_MMC_QCOM_TUNING=y
|
||||
CONFIG_MMC_SDHCI=y
|
||||
CONFIG_MMC_SDHCI_MSM=y
|
||||
# CONFIG_MMC_SDHCI_OF_ARASAN is not set
|
||||
# CONFIG_MMC_SDHCI_PCI is not set
|
||||
CONFIG_MMC_SDHCI_PLTFM=y
|
||||
# CONFIG_MMC_TIFM_SD is not set
|
||||
CONFIG_MODULES_TREE_LOOKUP=y
|
||||
CONFIG_MODULES_USE_ELF_REL=y
|
||||
# CONFIG_MPLS_ROUTING is not set
|
||||
# CONFIG_MSM_GCC_8660 is not set
|
||||
# CONFIG_MSM_GCC_8916 is not set
|
||||
# CONFIG_MSM_GCC_8960 is not set
|
||||
# CONFIG_MSM_GCC_8974 is not set
|
||||
# CONFIG_MSM_LCC_8960 is not set
|
||||
# CONFIG_MSM_MMCC_8960 is not set
|
||||
# CONFIG_MSM_MMCC_8974 is not set
|
||||
# CONFIG_MSM_MHI is not set
|
||||
# CONFIG_MSM_IPC_ROUTER_MHI_XPRT is not set
|
||||
# CONFIG_MSM_MHI_DEBUG is not set
|
||||
# CONFIG_MSM_MHI_DEV is not set
|
||||
# CONFIG_MSM_MHI_UCI is not set
|
||||
# CONFIG_DIAGFWD_BRIDGE_CODE is not set
|
||||
# CONFIG_MSM_BUS_SCALING is not set
|
||||
# CONFIG_BUS_TOPOLOGY_ADHOC is not set
|
||||
# CONFIG_QPNP_REVID is not set
|
||||
# CONFIG_SPS is not set
|
||||
# CONFIG_SPS_SUPPORT_NDP_BAM is not set
|
||||
# CONFIG_USB_BAM is not set
|
||||
# CONFIG_SPS_SUPPORT_BAMDMA is not set
|
||||
# CONFIG_IPA is not set
|
||||
# CONFIG_IPA3 is not set
|
||||
# CONFIG_EP_PCIE is not set
|
||||
# CONFIG_GSI is not set
|
||||
# CONFIG_PFT is not set
|
||||
# CONFIG_SEEMP_CORE is not set
|
||||
# CONFIG_GPIO_USB_DETECT is not set
|
||||
# CONFIG_MSM_GLINK is not set
|
||||
# CONFIG_MSM_GLINK_LOOPBACK_SERVER is not set
|
||||
# CONFIG_MSM_GLINK_SMEM_NATIVE_XPRT is not set
|
||||
# CONFIG_MSM_GLINK_PKT is not set
|
||||
# CONFIG_MSM_IPC_ROUTER_GLINK_XPRT is not set
|
||||
# CONFIG_MSM_QMI_INTERFACE is not set
|
||||
# CONFIG_MSM_TEST_QMI_CLIENT is not set
|
||||
# CONFIG_GLINK_DEBUG_FS is not set
|
||||
# CONFIG_MSM_RPM_SMD is not set
|
||||
# CONFIG_MSM_RPM_GLINK is not set
|
||||
CONFIG_MSM_RPM_LOG=y
|
||||
# CONFIG_MSM_SMEM is not set
|
||||
CONFIG_MTD_CMDLINE_PARTS=y
|
||||
CONFIG_MTD_M25P80=y
|
||||
CONFIG_MTD_NAND=y
|
||||
CONFIG_MTD_NAND_ECC=y
|
||||
CONFIG_MTD_NAND_QCOM=y
|
||||
CONFIG_MTD_QCOM_SMEM_PARTS=y
|
||||
CONFIG_MTD_SPINAND_GIGADEVICE=y
|
||||
CONFIG_MTD_SPINAND_MT29F=y
|
||||
CONFIG_MTD_SPINAND_ONDIEECC=y
|
||||
CONFIG_MTD_SPI_NOR=y
|
||||
CONFIG_MTD_SPLIT_FIRMWARE=y
|
||||
CONFIG_MTD_SPLIT_FIT_FW=y
|
||||
CONFIG_MTD_UBI=y
|
||||
CONFIG_MTD_UBI_BEB_LIMIT=20
|
||||
CONFIG_MTD_UBI_BLOCK=y
|
||||
# CONFIG_MTD_UBI_FASTMAP is not set
|
||||
CONFIG_MTD_UBI_GLUEBI=y
|
||||
CONFIG_MTD_UBI_WL_THRESHOLD=4096
|
||||
CONFIG_MULTI_IRQ_HANDLER=y
|
||||
CONFIG_MUTEX_SPIN_ON_OWNER=y
|
||||
CONFIG_NEED_DMA_MAP_STATE=y
|
||||
CONFIG_NEON=y
|
||||
CONFIG_NET=y
|
||||
# CONFIG_NET_DSA_MV88E6063 is not set
|
||||
CONFIG_NET_FLOW_LIMIT=y
|
||||
CONFIG_NET_PTP_CLASSIFY=y
|
||||
CONFIG_NO_BOOTMEM=y
|
||||
CONFIG_NO_HZ=y
|
||||
CONFIG_NO_HZ_COMMON=y
|
||||
CONFIG_NO_HZ_IDLE=y
|
||||
CONFIG_NR_CPUS=4
|
||||
CONFIG_NUM_ALT_PARTITION=8
|
||||
CONFIG_NVMEM=y
|
||||
CONFIG_OF=y
|
||||
CONFIG_OF_ADDRESS=y
|
||||
CONFIG_OF_ADDRESS_PCI=y
|
||||
CONFIG_OF_EARLY_FLATTREE=y
|
||||
CONFIG_OF_FLATTREE=y
|
||||
CONFIG_OF_GPIO=y
|
||||
CONFIG_OF_IRQ=y
|
||||
CONFIG_OF_MDIO=y
|
||||
CONFIG_OF_MTD=y
|
||||
CONFIG_OF_NET=y
|
||||
CONFIG_OF_PCI=y
|
||||
CONFIG_OF_PCI_IRQ=y
|
||||
CONFIG_OF_RESERVED_MEM=y
|
||||
CONFIG_OLD_SIGACTION=y
|
||||
CONFIG_OLD_SIGSUSPEND3=y
|
||||
CONFIG_PAGE_OFFSET=0xC0000000
|
||||
CONFIG_PANIC_ON_OOPS=y
|
||||
CONFIG_PANIC_ON_OOPS_VALUE=1
|
||||
CONFIG_PANIC_TIMEOUT=5
|
||||
CONFIG_PCI=y
|
||||
# CONFIG_PCIEAER is not set
|
||||
CONFIG_PCIE_DW=y
|
||||
# CONFIG_PCIE_DW_PLAT is not set
|
||||
CONFIG_PCIE_PME=y
|
||||
CONFIG_PCIE_QCOM=y
|
||||
CONFIG_PCI_DOMAINS=y
|
||||
CONFIG_PCI_DOMAINS_GENERIC=y
|
||||
CONFIG_PCI_MSI=y
|
||||
CONFIG_PERF_EVENTS=y
|
||||
CONFIG_PERF_USE_VMALLOC=y
|
||||
CONFIG_PGTABLE_LEVELS=2
|
||||
CONFIG_PHYLIB=y
|
||||
# CONFIG_PHY_IPQ_BALDUR_USB is not set
|
||||
# CONFIG_PHY_IPQ_UNIPHY_USB is not set
|
||||
# CONFIG_PHY_QCOM_APQ8064_SATA is not set
|
||||
# CONFIG_PHY_QCOM_IPQ806X_SATA is not set
|
||||
CONFIG_PHY_QCA_PCIE_QMP=y
|
||||
# CONFIG_PHY_QCOM_UFS is not set
|
||||
# CONFIG_PHY_IPQ_UNIPHY_PCIE is not set
|
||||
CONFIG_PINCTRL=y
|
||||
# CONFIG_PINCTRL_APQ8064 is not set
|
||||
# CONFIG_PINCTRL_APQ8084 is not set
|
||||
# CONFIG_PINCTRL_IPQ4019 is not set
|
||||
# CONFIG_PINCTRL_IPQ6018 is not set
|
||||
# CONFIG_PINCTRL_IPQ8064 is not set
|
||||
# CONFIG_PINCTRL_IPQ807x is not set
|
||||
# CONFIG_PINCTRL_IPQ5018 is not set
|
||||
CONFIG_PINCTRL_MSM=y
|
||||
# CONFIG_PINCTRL_MSM8660 is not set
|
||||
# CONFIG_PINCTRL_MSM8916 is not set
|
||||
# CONFIG_PINCTRL_MSM8960 is not set
|
||||
CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
|
||||
# CONFIG_PINCTRL_QCOM_SSBI_PMIC is not set
|
||||
# CONFIG_PL330_DMA is not set
|
||||
CONFIG_PM=y
|
||||
CONFIG_PM_CLK=y
|
||||
# CONFIG_PM_DEBUG is not set
|
||||
CONFIG_PM_GENERIC_DOMAINS=y
|
||||
CONFIG_PM_GENERIC_DOMAINS_OF=y
|
||||
CONFIG_PM_GENERIC_DOMAINS_SLEEP=y
|
||||
CONFIG_PM_OPP=y
|
||||
CONFIG_PM_SLEEP=y
|
||||
CONFIG_PM_SLEEP_SMP=y
|
||||
CONFIG_POWER_RESET=y
|
||||
CONFIG_POWER_RESET_MSM=y
|
||||
CONFIG_POWER_SUPPLY=y
|
||||
CONFIG_PREEMPT=y
|
||||
CONFIG_PREEMPT_COUNT=y
|
||||
# CONFIG_PREEMPT_NONE is not set
|
||||
CONFIG_PREEMPT_RCU=y
|
||||
CONFIG_PRINTK_TIME=y
|
||||
CONFIG_PROC_PAGE_MONITOR=y
|
||||
# CONFIG_PROC_STRIPPED is not set
|
||||
CONFIG_PSTORE=y
|
||||
CONFIG_PSTORE_RAM=y
|
||||
# CONFIG_PSTORE_CONSOLE is not set
|
||||
# CONFIG_PSTORE_PMSG is not set
|
||||
CONFIG_PWM=y
|
||||
CONFIG_PWM_IPQ4019=y
|
||||
# CONFIG_PWM_PCA9685 is not set
|
||||
CONFIG_PWM_SYSFS=y
|
||||
CONFIG_QCOM_ADM=y
|
||||
# CONFIG_QCOM_APM is not set
|
||||
CONFIG_QCOM_BAM_DMA=y
|
||||
# CONFIG_QTI_BT_TTY is not set
|
||||
# CONFIG_QCOM_COINCELL is not set
|
||||
# CONFIG_QCOM_DCC is not set
|
||||
CONFIG_QCOM_GDSC=y
|
||||
CONFIG_QCOM_GSBI=y
|
||||
# CONFIG_QCOM_HFPLL is not set
|
||||
# CONFIG_QCOM_MEMORY_DUMP_V2 is not set
|
||||
# CONFIG_QCOM_MDT_LOADER is not set
|
||||
CONFIG_QCOM_QFPROM=y
|
||||
# CONFIG_QCOM_SPMI_TEMP_ALARM is not set
|
||||
CONFIG_QCOM_RPM_CLK=y
|
||||
# CONFIG_QCOM_RTB is not set
|
||||
# CONFIG_QCOM_PM is not set
|
||||
CONFIG_QCOM_SCM=y
|
||||
CONFIG_QCOM_SCM_32=y
|
||||
# CONFIG_HAVE_ARM_SMCCC is not set
|
||||
CONFIG_QCA_SCM_RESTART_REASON=y
|
||||
CONFIG_IPQ_TCSR=y
|
||||
CONFIG_QCOM_QFPROM=y
|
||||
# CONFIG_QCOM_SMD is not set
|
||||
CONFIG_QCOM_SMEM=y
|
||||
CONFIG_QCOM_SMEM_STATE=y
|
||||
# CONFIG_QCOM_SMD is not set
|
||||
CONFIG_QCOM_SMP2P=y
|
||||
# CONFIG_QCOM_SPMI_VADC is not set
|
||||
CONFIG_QCOM_TSENS=y
|
||||
CONFIG_QCOM_TZ_LOG=y
|
||||
CONFIG_QCOM_WDT=y
|
||||
CONFIG_QMI_ENCDEC=y
|
||||
CONFIG_RATIONAL=y
|
||||
# CONFIG_RCU_BOOST is not set
|
||||
CONFIG_RCU_CPU_STALL_TIMEOUT=21
|
||||
# CONFIG_RCU_EXPERT is not set
|
||||
CONFIG_RCU_STALL_COMMON=y
|
||||
CONFIG_RD_GZIP=y
|
||||
CONFIG_REGMAP=y
|
||||
# CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS is not set
|
||||
CONFIG_REGMAP_MMIO=y
|
||||
CONFIG_REGULATOR=y
|
||||
# CONFIG_REGULATOR_CPR3 is not set
|
||||
CONFIG_REGULATOR_GPIO=y
|
||||
CONFIG_REGULATOR_FIXED_VOLTAGE=y
|
||||
CONFIG_REGULATOR_QCOM_RPM=y
|
||||
CONFIG_REGULATOR_QCOM_SPMI=y
|
||||
# CONFIG_REGULATOR_IPQ40XX is not set
|
||||
# CONFIG_REGULATOR_RPM_SMD is not set
|
||||
# CONFIG_REGULATOR_RPM_GLINK is not set
|
||||
CONFIG_RELAY=y
|
||||
CONFIG_REMOTEPROC=y
|
||||
# CONFIG_IPQ807X_REMOTEPROC is not set
|
||||
CONFIG_RESET_CONTROLLER=y
|
||||
CONFIG_RFS_ACCEL=y
|
||||
CONFIG_RPS=y
|
||||
CONFIG_RTC_CLASS=y
|
||||
CONFIG_NET_L3_MASTER_DEV=y
|
||||
# CONFIG_RTC_DRV_CMOS is not set
|
||||
# CONFIG_RTC_DRV_PM8XXX is not set
|
||||
CONFIG_RWSEM_SPIN_ON_OWNER=y
|
||||
CONFIG_RWSEM_XCHGADD_ALGORITHM=y
|
||||
# CONFIG_SATA_AHCI is not set
|
||||
CONFIG_SCHED_HRTICK=y
|
||||
# CONFIG_SCSI is not set
|
||||
# CONFIG_SCHED_INFO is not set
|
||||
# CONFIG_SCSI_DMA is not set
|
||||
# CONFIG_SERIAL_8250 is not set
|
||||
# CONFIG_SERIAL_8250_CONSOLE is not set
|
||||
# CONFIG_SERIAL_8250_DMA is not set
|
||||
# CONFIG_SERIAL_AMBA_PL010 is not set
|
||||
# CONFIG_SERIAL_AMBA_PL011 is not set
|
||||
CONFIG_SERIAL_MSM=y
|
||||
CONFIG_SERIAL_MSM_CONSOLE=y
|
||||
# CONFIG_VIRTIO_CONSOLE is not set
|
||||
CONFIG_SMP=y
|
||||
CONFIG_SMP_ON_UP=y
|
||||
# CONFIG_SND is not set
|
||||
CONFIG_SND_DYNAMIC_MINORS=y
|
||||
CONFIG_SND_MAX_CARDS=32
|
||||
CONFIG_SND_PROC_FS=y
|
||||
# CONFIG_SND_COMPRESS_OFFLOAD is not set
|
||||
CONFIG_SND_PCM=y
|
||||
CONFIG_SND_SOC=y
|
||||
# CONFIG_SND_SOC_APQ8016_SBC is not set
|
||||
CONFIG_SND_SOC_I2C_AND_SPI=y
|
||||
# CONFIG_SND_SOC_IPQ is not set
|
||||
# CONFIG_SND_SOC_IPQ806X_LPAIF is not set
|
||||
# CONFIG_SND_SOC_IPQ806X_PCM_RAW is not set
|
||||
CONFIG_SND_SOC_IPQ_ADSS=y
|
||||
CONFIG_SND_SOC_IPQ_CODEC=y
|
||||
CONFIG_SND_SOC_IPQ_CPU_DAI=y
|
||||
CONFIG_SND_SOC_IPQ_MBOX=y
|
||||
CONFIG_SND_SOC_IPQ_PCM_I2S=y
|
||||
CONFIG_SND_SOC_IPQ_PCM_RAW=y
|
||||
CONFIG_SND_SOC_IPQ_PCM_SPDIF=y
|
||||
CONFIG_SND_SOC_IPQ_PCM_TDM=y
|
||||
CONFIG_SND_SOC_IPQ_STEREO=y
|
||||
CONFIG_SND_SOC_QCOM=y
|
||||
# CONFIG_SND_SOC_STORM is not set
|
||||
CONFIG_SOUND=y
|
||||
CONFIG_SPARSE_IRQ=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPI_MASTER=y
|
||||
CONFIG_SPI_QUP=y
|
||||
CONFIG_SPI_SPIDEV=y
|
||||
# CONFIG_SPI_VSC7385 is not set
|
||||
CONFIG_SPMI=y
|
||||
CONFIG_SPMI_MSM_PMIC_ARB=y
|
||||
CONFIG_SRCU=y
|
||||
# CONFIG_STRIP_ASM_SYMS is not set
|
||||
# CONFIG_STOPWATCH is not set
|
||||
CONFIG_SUSPEND=y
|
||||
CONFIG_SWCONFIG=y
|
||||
CONFIG_SWIOTLB=y
|
||||
# CONFIG_SWAP is not set
|
||||
CONFIG_SWP_EMULATE=y
|
||||
CONFIG_SYS_SUPPORTS_APM_EMULATION=y
|
||||
CONFIG_THERMAL=y
|
||||
CONFIG_THERMAL_DEFAULT_GOV_STEP_WISE=y
|
||||
CONFIG_THERMAL_GOV_STEP_WISE=y
|
||||
CONFIG_THERMAL_GOV_USER_SPACE=y
|
||||
CONFIG_THERMAL_HWMON=y
|
||||
CONFIG_THERMAL_OF=y
|
||||
CONFIG_THERMAL_WRITABLE_TRIPS=y
|
||||
# CONFIG_THUMB2_KERNEL is not set
|
||||
# CONFIG_TICK_CPU_ACCOUNTING is not set
|
||||
CONFIG_IRQ_TIME_ACCOUNTING=y
|
||||
CONFIG_TRACING_EVENTS_GPIO=y
|
||||
CONFIG_UBIFS_FS=y
|
||||
CONFIG_UBIFS_FS_ADVANCED_COMPR=y
|
||||
CONFIG_UBIFS_FS_LZO=y
|
||||
CONFIG_UBIFS_FS_XZ=y
|
||||
CONFIG_UBIFS_FS_ZLIB=y
|
||||
CONFIG_UEVENT_HELPER_PATH=""
|
||||
CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"
|
||||
CONFIG_UNINLINE_SPIN_UNLOCK=y
|
||||
CONFIG_USB_GADGET=n
|
||||
CONFIG_USB_SUPPORT=y
|
||||
# CONFIG_USB_DWC3_OF_SIMPLE is not set
|
||||
# CONFIG_USB_QCOM_8X16_PHY is not set
|
||||
# CONFIG_USB_QCOM_KS_BRIDGE is not set
|
||||
# CONFIG_USB_QCOM_QUSB_PHY is not set
|
||||
# CONFIG_USB_QCOM_QMP_PHY is not set
|
||||
# CONFIG_USB_QCA_M31_PHY is not set
|
||||
# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
|
||||
# CONFIG_USB_EHCI_TT_NEWSCHED is not set
|
||||
# CONFIG_USB_OHCI_LITTLE_ENDIAN is not set
|
||||
CONFIG_USE_OF=y
|
||||
CONFIG_VDSO=y
|
||||
CONFIG_VECTORS_BASE=0xffff0000
|
||||
CONFIG_VFP=y
|
||||
CONFIG_VFPv3=y
|
||||
CONFIG_VM_EVENT_COUNTERS=y
|
||||
CONFIG_WATCHDOG_CORE=y
|
||||
# CONFIG_WL_TI is not set
|
||||
# CONFIG_WQ_POWER_EFFICIENT_DEFAULT is not set
|
||||
CONFIG_XPS=y
|
||||
CONFIG_XZ_DEC_ARM=y
|
||||
CONFIG_XZ_DEC_BCJ=y
|
||||
CONFIG_ZBOOT_ROM_BSS=0
|
||||
CONFIG_ZBOOT_ROM_TEXT=0
|
||||
CONFIG_ZLIB_DEFLATE=y
|
||||
CONFIG_ZLIB_INFLATE=y
|
||||
CONFIG_ZONE_DMA_FLAG=0
|
||||
CONFIG_QCOM_CACHE_DUMP=y
|
||||
CONFIG_QCOM_CACHE_DUMP_ON_PANIC=y
|
||||
# CONFIG_QCOM_RESTART_REASON is not set
|
||||
# CONFIG_QCOM_DLOAD_MODE is not set
|
||||
CONFIG_FW_AUTH=y
|
||||
CONFIG_FW_AUTH_TEST=m
|
||||
CONFIG_ASYMMETRIC_KEY_TYPE=y
|
||||
CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y
|
||||
CONFIG_PUBLIC_KEY_ALGO_RSA=y
|
||||
CONFIG_X509_CERTIFICATE_PARSER=y
|
||||
CONFIG_PKCS7_MESSAGE_PARSER=n
|
||||
CONFIG_KEYS=y
|
||||
# CONFIG_SKB_RECYCLER is not set
|
||||
CONFIG_SKB_RECYCLER_MULTI_CPU=y
|
||||
# CONFIG_SKB_RECYCLER_PREALLOC is not set
|
||||
# CONFIG_U_SERIAL_CONSOLE is not set
|
||||
CONFIG_SCSI_SCAN_ASYNC=y
|
||||
# CONFIG_NF_IPV6_DUMMY_HEADER is not set
|
||||
# CONFIG_RMNET is not set
|
||||
# CONFIG_RMNET_DATA is not set
|
||||
# CONFIG_RMNET_CTL is not set
|
||||
# CONFIG_MSM_SECURE_BUFFER is not set
|
||||
# CONFIG_STAGING is not set
|
||||
# CONFIG_ANDROID is not set
|
||||
# CONFIG_ION is not set
|
||||
# CONFIG_ION_DUMMY is not set
|
||||
# CONFIG_ION_MSM is not set
|
||||
# CONFIG_ION_TEST is not set
|
||||
# CONFIG_CMA is not set
|
||||
# CONFIG_CMA_DEBUG is not set
|
||||
# CONFIG_CMA_DEBUGFS is not set
|
||||
# CONFIG_DMA_CMA is not set
|
||||
# CONFIG_CMA_AREAS is not set
|
||||
# CONFIG_CMA_SIZE_MBYTES is not set
|
||||
# CONFIG_CMA_SIZE_SEL_MBYTES is not set
|
||||
# CONFIG_CMA_SIZE_SEL_PERCENTAGE is not set
|
||||
# CONFIG_CMA_SIZE_SEL_MIN is not set
|
||||
# CONFIG_CMA_SIZE_SEL_MAX is not set
|
||||
# CONFIG_CMA_ALIGNMENT is not set
|
||||
# CONFIG_ASHMEM is not set
|
||||
# CONFIG_ANDROID_TIMED_OUTPUT is not set
|
||||
# CONFIG_ANDROID_LOW_MEMORY_KILLER is not set
|
||||
# CONFIG_SYNC is not set
|
||||
# CONFIG_SW_SYNC is not set
|
||||
# CONFIG_FSL_MC_BUS is not set
|
||||
# CONFIG_ALLOC_BUFFERS_IN_4K_CHUNKS is not set
|
||||
CONFIG_ALLOC_SKB_PAGE_FRAG_DISABLE=y
|
||||
# CONFIG_MMAP_ALLOW_UNINITIALIZED is not set
|
||||
# CONFIG_MAILBOX is not set
|
||||
# CONFIG_MAILBOX_TEST is not set
|
||||
# CONFIG_QCOM_APCS_IPC is not set
|
||||
# CONFIG_QCOM_GLINK_SSR is not set
|
||||
# CONFIG_QCOM_Q6V5_WCSS is not set
|
||||
# CONFIG_QCOM_SYSMON is not set
|
||||
# CONFIG_QRTR is not set
|
||||
# CONFIG_QRTR_SMD is not set
|
||||
# CONFIG_QRTR_TUN is not set
|
||||
# CONFIG_RPMSG is not set
|
||||
# CONFIG_RPMSG_QCOM_GLINK_RPM is not set
|
||||
# CONFIG_RPMSG_VIRTIO is not set
|
||||
# CONFIG_RPMSG_CHAR is not set
|
||||
# CONFIG_RPMSG_QCOM_GLINK_SMEM is not set
|
||||
# CONFIG_RPMSG_QCOM_SMD is not set
|
||||
CONFIG_QCA_MINIDUMP=y
|
||||
# CONFIG_QCA_MINIDUMP_DEBUG is not set
|
||||
# CONFIG_QRTR_USB is not set
|
||||
# CONFIG_QRTR_FIFO is not set
|
||||
CONFIG_QRTR_MHI=y
|
||||
CONFIG_MHI_BUS=y
|
||||
# CONFIG_MHI_QTI is not set
|
||||
# CONFIG_MHI_NETDEV is not set
|
||||
# CONFIG_MHI_DEBUG is not set
|
||||
# CONFIG_MHI_UCI is not set
|
||||
# CONFIG_MHI_SATELLITE is not set
|
||||
# CONFIG_DIAG_OVER_QRTR is not set
|
||||
# CONFIG_MSM_ADSPRPC is not set
|
||||
CONFIG_CRYPTO_MICHAEL_MIC=y
|
||||
# CONFIG_ARCH_HAS_KCOV is not set
|
||||
# CONFIG_KCOV is not set
|
||||
# CONFIG_GCC_PLUGINS is not set
|
||||
# CONFIG_QTI_Q6V5_ADSP is not set
|
||||
# CONFIG_MSM_RPM_RPMSG is not set
|
||||
# CONFIG_RPMSG_QCOM_GLINK_RPM is not set
|
||||
# CONFIG_REGULATOR_RPM_GLINK is not set
|
||||
# CONFIG_MTD_NAND_SERIAL is not set
|
||||
# CONFIG_ARM_QTI_IPQ60XX_CPUFREQ is not set
|
||||
# CONFIG_PAGE_SCOPE_MULTI_PAGE_READ is not set
|
||||
# CONFIG_CRYPTO_NO_ZERO_LEN_HASH is not set
|
||||
# CONFIG_CRYPTO_DISABLE_AES192_TEST is not set
|
||||
# CONFIG_QTI_EUD is not set
|
||||
# CONFIG_EUD_EXTCON_SUPPORT is not set
|
||||
# CONFIG_CLK_TEST_5018 is not set
|
||||
CONFIG_MAP_E_SUPPORT=y
|
||||
# CONFIG_IPQ_FLASH_16M_PROFILE is not set
|
||||
# CONFIG_QGIC2_MSI is not set
|
||||
CONFIG_BRIDGE_VLAN_FILTERING=y
|
||||
CONFIG_LEDS_GPIO=y
|
||||
# CONFIG_ARCH_IPQ256M is not set
|
||||
CONFIG_SKB_FIXED_SIZE_2K=y
|
||||
# CONFIG_IPQ_MEM_PROFILE is not set
|
||||
# CONFIG_VIRTIO_NET is not set
|
||||
# CONFIG_QCA_85XX_SWITCH is not set
|
||||
CONFIG_AQ_PHY=y
|
||||
CONFIG_DIAG_CHAR=y
|
||||
# CONFIG_HW_RANDOM_VIRTIO is not set
|
||||
# CONFIG_BOOTCONFIG_PARTITION is not set
|
||||
# CONFIG_CRYPTO_DEV_QCEDEV is not set
|
||||
# CONFIG_CRYPTO_DEV_QCRYPTO is not set
|
||||
# CONFIG_MHI_BUS_TEST is not set
|
||||
@@ -1,5 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/ipq8074-hk14.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
@@ -15,4 +15,9 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq5018-eap104.dts"
|
||||
#include "ipq5018.dtsi"
|
||||
|
||||
/ {
|
||||
pmuv8: pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-cig-wf188n.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-edgecore-eap101.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-gl-ax1800.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-gl-axt1800.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -14,10 +14,5 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-hfcl-ion4x.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
|
||||
/ {
|
||||
model = "HFCL ION4Xe";
|
||||
compatible = "hfcl,ion4xe", "qcom,ipq6018-cp01", "qcom,ipq6018";
|
||||
};
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-hfcl-ion4xe.dts"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -14,10 +14,5 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-hfcl-ion4x.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
|
||||
/ {
|
||||
model = "HFCL ION4Xi";
|
||||
compatible = "hfcl,ion4xi", "qcom,ipq6018-cp01", "qcom,ipq6018";
|
||||
};
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-hfcl-ion4xi.dts"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-wallys-dr6018-v4.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-wallys-dr6018.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -15,4 +15,4 @@
|
||||
*/
|
||||
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq6018-yuncore-ax840.dts"
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
|
||||
@@ -14,4 +14,13 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
|
||||
/ {
|
||||
soc {
|
||||
pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
|
||||
IRQ_TYPE_LEVEL_HIGH)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,13 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq807x-eap106.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
|
||||
/ {
|
||||
soc {
|
||||
pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
|
||||
IRQ_TYPE_LEVEL_HIGH)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,13 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq807x-ex227.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
|
||||
/ {
|
||||
soc {
|
||||
pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
|
||||
IRQ_TYPE_LEVEL_HIGH)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,13 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq807x-ex447.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
|
||||
/ {
|
||||
soc {
|
||||
pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
|
||||
IRQ_TYPE_LEVEL_HIGH)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,13 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq807x-wf194c.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
|
||||
/ {
|
||||
soc {
|
||||
pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
|
||||
IRQ_TYPE_LEVEL_HIGH)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,13 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq807x-wf194c4.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
|
||||
/ {
|
||||
soc {
|
||||
pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
|
||||
IRQ_TYPE_LEVEL_HIGH)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,4 +14,13 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include "../../../arm64/boot/dts/qcom/qcom-ipq807x-wf196.dts"
|
||||
#include "ipq8074.dtsi"
|
||||
|
||||
/ {
|
||||
soc {
|
||||
pmu {
|
||||
compatible = "arm,cortex-a7-pmu";
|
||||
interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) |
|
||||
IRQ_TYPE_LEVEL_HIGH)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/dts-v1/;
|
||||
/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -16,7 +14,7 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ipq5018.dtsi"
|
||||
#include "qcom-ipq5018.dtsi"
|
||||
|
||||
/ {
|
||||
#address-cells = <0x2>;
|
||||
@@ -40,7 +38,11 @@
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
bootargs-append = " swiotlb=1";
|
||||
#else
|
||||
bootargs-append = " swiotlb=1 coherent_pool=2M";
|
||||
#endif
|
||||
stdout-path = "serial0";
|
||||
};
|
||||
|
||||
@@ -78,22 +80,22 @@
|
||||
* | QDSS | 0x4D200000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | data | 0x4D300000 | 13MB |
|
||||
* | data | 0x4D300000 | 15MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | M3 Dump | 0x4E000000 | 1MB |
|
||||
* | M3 Dump | 0x4E200000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | QDSS | 0x4E100000 | 1MB |
|
||||
* | QDSS | 0x4E300000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | data | 0x4E200000 | 13MB |
|
||||
* | data | 0x4E400000 | 15MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | M3 Dump | 0x4EF00000 | 1MB |
|
||||
* | M3 Dump | 0x4F300000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | QDSS | 0x4F000000 | 1MB |
|
||||
* | QDSS | 0x4F400000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | |
|
||||
* | Rest of the memory for Linux |
|
||||
@@ -102,7 +104,7 @@
|
||||
*/
|
||||
q6_mem_regions: q6_mem_regions@4B000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4B000000 0x0 0x4100000>;
|
||||
reg = <0x0 0x4B000000 0x0 0x4500000>;
|
||||
};
|
||||
|
||||
q6_code_data: q6_code_data@4B000000 {
|
||||
@@ -127,32 +129,32 @@
|
||||
|
||||
q6_qcn6122_data1: q6_qcn6122_data1@4D300000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D300000 0x0 0xD00000>;
|
||||
reg = <0x0 0x4D300000 0x0 0xF00000>;
|
||||
};
|
||||
|
||||
m3_dump_qcn6122_1: m3_dump_qcn6122_1@4E000000 {
|
||||
m3_dump_qcn6122_1: m3_dump_qcn6122_1@4E200000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E000000 0x0 0x100000>;
|
||||
reg = <0x0 0x4E200000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_etr_1: q6_qcn6122_etr_1@4E100000 {
|
||||
q6_qcn6122_etr_1: q6_qcn6122_etr_1@4E300000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E100000 0x0 0x100000>;
|
||||
reg = <0x0 0x4E300000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_data2: q6_qcn6122_data2@4E200000 {
|
||||
q6_qcn6122_data2: q6_qcn6122_data2@4E400000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E200000 0x0 0xD00000>;
|
||||
reg = <0x0 0x4E400000 0x0 0xF00000>;
|
||||
};
|
||||
|
||||
m3_dump_qcn6122_2: m3_dump_qcn6122_2@4EF00000 {
|
||||
m3_dump_qcn6122_2: m3_dump_qcn6122_2@4F300000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4EF00000 0x0 0x100000>;
|
||||
reg = <0x0 0x4F300000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_etr_2: q6_qcn6122_etr_2@4F000000 {
|
||||
q6_qcn6122_etr_2: q6_qcn6122_etr_2@4F400000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4F000000 0x0 0x100000>;
|
||||
reg = <0x0 0x4F400000 0x0 0x100000>;
|
||||
};
|
||||
#else
|
||||
/* 512MB/1GB Profiles
|
||||
@@ -299,6 +301,7 @@
|
||||
blsp1_uart2: serial@78b0000 {
|
||||
pinctrl-0 = <&blsp1_uart_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
qpic_bam: dma@7984000{
|
||||
@@ -341,6 +344,7 @@
|
||||
pinctrl-0 = <&mdio1_pins>;
|
||||
pinctrl-names = "default";
|
||||
phy-reset-gpio = <&tlmm 39 0>;
|
||||
|
||||
ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
};
|
||||
@@ -376,6 +380,8 @@
|
||||
forced-duplex = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
led_source@0 {
|
||||
source = <0>;
|
||||
mode = "normal";
|
||||
@@ -383,13 +389,15 @@
|
||||
blink_en = "enable";
|
||||
active = "high";
|
||||
};
|
||||
*/
|
||||
|
||||
};
|
||||
ess-switch1@1 {
|
||||
compatible = "qcom,ess-switch-qca83xx";
|
||||
device_id = <1>;
|
||||
switch_access_mode = "mdio";
|
||||
mdio-bus = <&mdio1>;
|
||||
reset_gpio = <&tlmm 0x27 0>;
|
||||
reset_gpio = <0x27>;
|
||||
switch_cpu_bmp = <0x40>; /* cpu port bitmap */
|
||||
switch_lan_bmp = <0x1e>; /* lan port bitmap */
|
||||
switch_wan_bmp = <0x0>; /* wan port bitmap */
|
||||
@@ -424,8 +432,8 @@
|
||||
};
|
||||
};
|
||||
|
||||
ess-uniphy@98000 {
|
||||
status = "disabled";
|
||||
wifi0: wifi@c000000 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
dp1 {
|
||||
@@ -442,7 +450,6 @@
|
||||
mdio-bus = <&mdio0>;
|
||||
local-mac-address = [000000000000];
|
||||
phy-mode = "sgmii";
|
||||
qcom,rx-page-mode = <0>;
|
||||
};
|
||||
|
||||
dp2 {
|
||||
@@ -456,13 +463,14 @@
|
||||
qcom,mactype = <2>;
|
||||
local-mac-address = [000000000000];
|
||||
phy-mode = "sgmii";
|
||||
qcom,rx-page-mode = <0>;
|
||||
};
|
||||
|
||||
nss-macsec1 {
|
||||
compatible = "qcom,nss-macsec";
|
||||
phy_addr = <0x1c>;
|
||||
mdiobus = <&mdio1>;
|
||||
qcom,test@0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
lpass: lpass@0xA000000{
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
pcm: pcm@0xA3C0000{
|
||||
@@ -471,151 +479,72 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
pinctrl-0 = <&leds_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
led@2 {
|
||||
label = "green:wifi5";
|
||||
gpios = <&tlmm 2 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
led@3 {
|
||||
label = "green:wifi2";
|
||||
gpios = <&tlmm 3 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
led_power: led@30 {
|
||||
label = "green:power";
|
||||
gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "on";
|
||||
};
|
||||
|
||||
led@42 {
|
||||
label = "orange:uplink";
|
||||
gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
led@43 {
|
||||
label = "yellow:uplink";
|
||||
gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
|
||||
led@46 {
|
||||
label = "green:cloud";
|
||||
gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
pcm_lb: pcm_lb@0 {
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
qcom,test@0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
thermal-zones {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
wps {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 32 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
pinctrl-0 = <&leds_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
led@2 {
|
||||
label = "green:wifi5";
|
||||
gpios = <&tlmm 2 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
led@3 {
|
||||
label = "green:wifi2";
|
||||
gpios = <&tlmm 3 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
led_power: led@30 {
|
||||
label = "green:power";
|
||||
gpios = <&tlmm 30 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "on";
|
||||
};
|
||||
led@42 {
|
||||
label = "orange:uplink";
|
||||
gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
led@43 {
|
||||
label = "yellow:uplink";
|
||||
gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
led@46 {
|
||||
label = "green:cloud";
|
||||
gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>;
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
pinctrl-0 = <&blsp0_uart_pins>;
|
||||
/* pinctrl-0 = <&blsp0_uart_pins &phy_led_pins>; */
|
||||
pinctrl-0 = <&blsp0_uart_pins &phy_led_pins &ble_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
blsp0_uart_pins: uart_pins {
|
||||
blsp0_uart_rx_tx {
|
||||
pins = "gpio20", "gpio21";
|
||||
function = "blsp0_uart0";
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
blsp1_uart_pins: blsp1_uart_pins {
|
||||
blsp1_uart_rx_tx {
|
||||
pins = "gpio23", "gpio25", "gpio24", "gpio26";
|
||||
function = "blsp1_uart2";
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
blsp0_spi_pins: blsp0_spi_pins {
|
||||
mux {
|
||||
pins = "gpio10", "gpio11", "gpio12", "gpio13";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <2>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
qspi_nand_pins: qspi_nand_pins {
|
||||
qspi_clock {
|
||||
pins = "gpio9";
|
||||
function = "qspi_clk";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
qspi_cs {
|
||||
pins = "gpio8";
|
||||
function = "qspi_cs";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
qspi_data {
|
||||
pins = "gpio4", "gpio5", "gpio6", "gpio7";
|
||||
function = "qspi_data";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
mdio1_pins: mdio_pinmux {
|
||||
mux_0 {
|
||||
pins = "gpio36";
|
||||
function = "mdc";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
mux_1 {
|
||||
pins = "gpio37";
|
||||
function = "mdio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
i2c_pins: i2c_pins {
|
||||
i2c_scl {
|
||||
pins = "gpio25";
|
||||
function = "blsp2_i2c1";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
i2c_sda {
|
||||
pins = "gpio26";
|
||||
function = "blsp2_i2c1";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio38";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
leds_pins: leds_pins {
|
||||
led_5g {
|
||||
pins = "gpio2";
|
||||
@@ -654,6 +583,131 @@
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
blsp0_uart_pins: uart_pins {
|
||||
blsp0_uart_rx_tx {
|
||||
pins = "gpio20", "gpio21";
|
||||
function = "blsp0_uart0";
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
blsp1_uart_pins: blsp1_uart_pins {
|
||||
blsp1_uart_rx_tx {
|
||||
pins = "gpio23", "gpio25", "gpio24", "gpio26";
|
||||
function = "blsp1_uart2";
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
blsp0_spi_pins: blsp0_spi_pins {
|
||||
mux {
|
||||
pins = "gpio10", "gpio11", "gpio12", "gpio13";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <2>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
qspi_nand_pins: qspi_nand_pins {
|
||||
qspi_clock {
|
||||
pins = "gpio9";
|
||||
function = "qspi_clk";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_cs {
|
||||
pins = "gpio8";
|
||||
function = "qspi_cs";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_data_0 {
|
||||
pins = "gpio7";
|
||||
function = "qspi0";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_data_1 {
|
||||
pins = "gpio6";
|
||||
function = "qspi1";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_data_2 {
|
||||
pins = "gpio5";
|
||||
function = "qspi2";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_data_3 {
|
||||
pins = "gpio4";
|
||||
function = "qspi3";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
mdio1_pins: mdio_pinmux {
|
||||
mux_0 {
|
||||
pins = "gpio36";
|
||||
function = "mdc";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
mux_1 {
|
||||
pins = "gpio37";
|
||||
function = "mdio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
phy_led_pins: phy_led_pins {
|
||||
gephy_led_pin {
|
||||
pins = "gpio46";
|
||||
/* function = "led0"; */
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
ble_pins: ble_pins {
|
||||
ble_coex_grant {
|
||||
pins = "gpio19";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
i2c_pins: i2c_pins {
|
||||
i2c_scl {
|
||||
pins = "gpio33";
|
||||
function = "blsp2_i2c0";
|
||||
drive-strength = <8>;
|
||||
/* bias-disable; */
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
i2c_sda {
|
||||
pins = "gpio34";
|
||||
function = "blsp2_i2c0";
|
||||
drive-strength = <8>;
|
||||
/* bias-disable; */
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio38";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
audio_pins: audio_pinmux {
|
||||
mux_1 {
|
||||
@@ -705,8 +759,10 @@
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/* Disable gpio 38 and 24
|
||||
&soc {
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
@@ -714,174 +770,190 @@
|
||||
pinctrl-names = "default";
|
||||
|
||||
button@1 {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 32 GPIO_ACTIVE_LOW>;
|
||||
label = "wps";
|
||||
linux,code = <KEY_WPS_BUTTON>;
|
||||
gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&q6v5_wcss {
|
||||
compatible = "qcom,ipq5018-q6-mpd";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
ranges;
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
reg = <0x0cd00000 0x4040>,
|
||||
<0x1938000 0x8>,
|
||||
<0x193d204 0x4>;
|
||||
reg-names = "qdsp6",
|
||||
"tcsr-msip",
|
||||
"tcsr-q6";
|
||||
resets = <&gcc GCC_WCSSAON_RESET>,
|
||||
<&gcc GCC_WCSS_Q6_BCR>;
|
||||
&usb3 {
|
||||
status = "ok";
|
||||
device-power-gpio = <&tlmm 24 1>;
|
||||
};
|
||||
|
||||
reset-names = "wcss_aon_reset",
|
||||
"wcss_q6_reset";
|
||||
*/
|
||||
|
||||
clocks = <&gcc GCC_Q6_AXIS_CLK>,
|
||||
<&gcc GCC_WCSS_ECAHB_CLK>,
|
||||
<&gcc GCC_Q6_AXIM_CLK>,
|
||||
<&gcc GCC_Q6_AXIM2_CLK>,
|
||||
<&gcc GCC_Q6_AHB_CLK>,
|
||||
<&gcc GCC_Q6_AHB_S_CLK>,
|
||||
<&gcc GCC_WCSS_AXI_S_CLK>;
|
||||
clock-names = "gcc_q6_axis_clk",
|
||||
"gcc_wcss_ecahb_clk",
|
||||
"gcc_q6_axim_clk",
|
||||
"gcc_q6_axim2_clk",
|
||||
"gcc_q6_ahb_clk",
|
||||
"gcc_q6_ahb_s_clk",
|
||||
"gcc_wcss_axi_s_clk";
|
||||
&eud {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_mem_regions>, <&q6_etr_region>;
|
||||
#else
|
||||
memory-region = <&q6_mem_regions>, <&q6_etr_region>,
|
||||
<&q6_caldb_region>;
|
||||
#endif
|
||||
&pcie_x1 {
|
||||
status = "disabled";
|
||||
perst-gpio = <&tlmm 18 1>;
|
||||
};
|
||||
|
||||
qcom,rproc = <&q6v5_wcss>;
|
||||
&pcie_x2 {
|
||||
status = "disabled";
|
||||
perst-gpio = <&tlmm 15 1>;
|
||||
};
|
||||
|
||||
&dwc_0 {
|
||||
/delete-property/ #phy-cells;
|
||||
/delete-property/ phys;
|
||||
/delete-property/ phy-names;
|
||||
};
|
||||
|
||||
&hs_m31phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&pcie_x1phy {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&pcie_x2phy {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&pcie_x1_rp {
|
||||
status = "disabled";
|
||||
|
||||
mhi_0: qcom,mhi@0 {
|
||||
reg = <0 0 0 0 0 >;
|
||||
};
|
||||
};
|
||||
|
||||
&pcie_x2_rp {
|
||||
status = "disabled";
|
||||
|
||||
mhi_1: qcom,mhi@1 {
|
||||
reg = <0 0 0 0 0 >;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
&qfprom {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&tsens {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qcom_q6v5_wcss {
|
||||
qcom,multipd_arch;
|
||||
memory-region = <&q6_mem_regions>;
|
||||
qcom,share_bootargs;
|
||||
qcom,bootargs_smem = <507>;
|
||||
boot-args = <0x1 0x4 0x3 0x0F 0x0 0x0>,
|
||||
<0x2 0x4 0x2 0x12 0x0 0x0>;
|
||||
status = "ok";
|
||||
q6_wcss_pd1: remoteproc_pd1@4ab000 {
|
||||
compatible = "qcom,ipq5018-wcss-ahb-mpd";
|
||||
reg = <0x4ab000 0x20>;
|
||||
reg-names = "rmb";
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
/* IPQ5018 */
|
||||
q6v5_wcss_userpd1 {
|
||||
m3_firmware = "IPQ5018/m3_fw.mdt";
|
||||
interrupts-extended = <&wcss_smp2p_in 8 0>,
|
||||
<&wcss_smp2p_in 9 0>,
|
||||
<&wcss_smp2p_in 12 0>,
|
||||
<&wcss_smp2p_in 11 0>;
|
||||
interrupt-names = "fatal",
|
||||
"ready",
|
||||
"spawn-ack",
|
||||
"stop-ack";
|
||||
|
||||
resets = <&gcc GCC_WCSSAON_RESET>,
|
||||
<&gcc GCC_WCSS_BCR>,
|
||||
<&gcc GCC_CE_BCR>;
|
||||
reset-names = "wcss_aon_reset",
|
||||
"wcss_reset",
|
||||
"ce_reset";
|
||||
|
||||
clocks = <&gcc GCC_WCSS_AHB_S_CLK>,
|
||||
<&gcc GCC_WCSS_ACMT_CLK>,
|
||||
<&gcc GCC_WCSS_AXI_M_CLK>;
|
||||
clock-names = "gcc_wcss_ahb_s_clk",
|
||||
"gcc_wcss_acmt_clk",
|
||||
"gcc_wcss_axi_m_clk";
|
||||
|
||||
qcom,halt-regs = <&tcsr_q6_block 0xa000 0xd000 0x0>;
|
||||
|
||||
<&wcss_smp2p_in 9 0>,
|
||||
<&wcss_smp2p_in 12 0>,
|
||||
<&wcss_smp2p_in 11 0>;
|
||||
interrupt-names ="fatal",
|
||||
"ready",
|
||||
"spawn_ack",
|
||||
"stop-ack";
|
||||
qcom,smem-states = <&wcss_smp2p_out 8>,
|
||||
<&wcss_smp2p_out 9>,
|
||||
<&wcss_smp2p_out 10>;
|
||||
<&wcss_smp2p_out 9>,
|
||||
<&wcss_smp2p_out 10>;
|
||||
qcom,smem-state-names = "shutdown",
|
||||
"stop",
|
||||
"spawn";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
"stop",
|
||||
"spawn";
|
||||
qca,asid = <1>;
|
||||
qca,auto-restart;
|
||||
qca,int_radio;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_ipq5018_data>, <&m3_dump>,
|
||||
<&q6_etr_region>;
|
||||
#else
|
||||
#else
|
||||
memory-region = <&q6_ipq5018_data>, <&m3_dump>,
|
||||
<&q6_etr_region>, <&q6_caldb_region>;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
q6_wcss_pd2: remoteproc_pd2 {
|
||||
compatible = "qcom,ipq5018-wcss-pcie-mpd";
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
/* QCN6122 6G */
|
||||
q6v5_wcss_userpd2 {
|
||||
m3_firmware = "qcn6122/m3_fw.mdt";
|
||||
interrupts-extended = <&wcss_smp2p_in 16 0>,
|
||||
<&wcss_smp2p_in 17 0>,
|
||||
<&wcss_smp2p_in 20 0>,
|
||||
<&wcss_smp2p_in 19 0>;
|
||||
interrupt-names = "fatal",
|
||||
"ready",
|
||||
"spawn-ack",
|
||||
"stop-ack";
|
||||
|
||||
<&wcss_smp2p_in 17 0>,
|
||||
<&wcss_smp2p_in 20 0>,
|
||||
<&wcss_smp2p_in 19 0>;
|
||||
interrupt-names ="fatal",
|
||||
"ready",
|
||||
"spawn_ack",
|
||||
"stop-ack";
|
||||
qcom,smem-states = <&wcss_smp2p_out 16>,
|
||||
<&wcss_smp2p_out 17>,
|
||||
<&wcss_smp2p_out 18>;
|
||||
<&wcss_smp2p_out 17>,
|
||||
<&wcss_smp2p_out 18>;
|
||||
qcom,smem-state-names = "shutdown",
|
||||
"stop",
|
||||
"spawn";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
"stop",
|
||||
"spawn";
|
||||
qca,asid = <2>;
|
||||
qca,auto-restart;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_qcn6122_data1>, <&m3_dump_qcn6122_1>,
|
||||
<&q6_qcn6122_etr_1>;
|
||||
#else
|
||||
#else
|
||||
memory-region = <&q6_qcn6122_data1>, <&m3_dump_qcn6122_1>,
|
||||
<&q6_qcn6122_etr_1>, <&q6_qcn6122_caldb_1>;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
q6_wcss_pd3: remoteproc_pd3 {
|
||||
compatible = "qcom,ipq5018-wcss-pcie-mpd";
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
/* QCN6122 5G */
|
||||
q6v5_wcss_userpd3 {
|
||||
m3_firmware = "qcn6122/m3_fw.mdt";
|
||||
interrupts-extended = <&wcss_smp2p_in 24 0>,
|
||||
<&wcss_smp2p_in 25 0>,
|
||||
<&wcss_smp2p_in 28 0>,
|
||||
<&wcss_smp2p_in 27 0>;
|
||||
interrupt-names = "fatal",
|
||||
"ready",
|
||||
"spawn-ack",
|
||||
"stop-ack";
|
||||
|
||||
<&wcss_smp2p_in 25 0>,
|
||||
<&wcss_smp2p_in 28 0>,
|
||||
<&wcss_smp2p_in 27 0>;
|
||||
interrupt-names ="fatal",
|
||||
"ready",
|
||||
"spawn_ack",
|
||||
"stop-ack";
|
||||
qcom,smem-states = <&wcss_smp2p_out 24>,
|
||||
<&wcss_smp2p_out 25>,
|
||||
<&wcss_smp2p_out 26>;
|
||||
<&wcss_smp2p_out 25>,
|
||||
<&wcss_smp2p_out 26>;
|
||||
qcom,smem-state-names = "shutdown",
|
||||
"stop",
|
||||
"spawn";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
"stop",
|
||||
"spawn";
|
||||
qca,asid = <3>;
|
||||
qca,auto-restart;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_qcn6122_data2>, <&m3_dump_qcn6122_2>,
|
||||
<&q6_qcn6122_etr_2>;
|
||||
#else
|
||||
#else
|
||||
memory-region = <&q6_qcn6122_data2>, <&m3_dump_qcn6122_2>,
|
||||
<&q6_qcn6122_etr_2>, <&q6_qcn6122_caldb_2>;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
&i2c_0 {
|
||||
pinctrl-0 = <&i2c_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "disabled";
|
||||
/* status = "disabled"; */
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qgic_msi_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qgic_msi_1 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&wifi0 {
|
||||
/* IPQ5018 */
|
||||
qcom,multipd_arch;
|
||||
qcom,rproc = <&q6_wcss_pd1>;
|
||||
qcom,userpd-subsys-name = "q6v5_wcss_userpd1";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
qcom,tgt-mem-mode = <2>;
|
||||
@@ -897,7 +969,6 @@
|
||||
m3-dump-addr = <0x4D200000>;
|
||||
#endif
|
||||
qcom,caldb-size = <0x200000>;
|
||||
mem-region = <&q6_ipq5018_data>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
@@ -905,13 +976,12 @@
|
||||
/* QCN6122 5G */
|
||||
qcom,multipd_arch;
|
||||
qcom,userpd-subsys-name = "q6v5_wcss_userpd2";
|
||||
qcom,rproc = <&q6_wcss_pd2>;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
qcom,tgt-mem-mode = <2>;
|
||||
#else
|
||||
qcom,tgt-mem-mode = <1>;
|
||||
#endif
|
||||
qcom,board_id = <0x60>;
|
||||
qcom,board_id = <0x50>;
|
||||
qcom,bdf-addr = <0x4D600000 0x4D600000 0x4D300000 0x0 0x0>;
|
||||
#ifdef __CNSS2__
|
||||
qcom,caldb-addr = <0x4E800000 0x4E800000 0 0 0>;
|
||||
@@ -920,7 +990,6 @@
|
||||
m3-dump-addr = <0x4E600000>;
|
||||
#endif
|
||||
qcom,caldb-size = <0x500000>;
|
||||
mem-region = <&q6_qcn6122_data1>;
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
@@ -928,14 +997,13 @@
|
||||
/* QCN6122 6G */
|
||||
qcom,multipd_arch;
|
||||
qcom,userpd-subsys-name = "q6v5_wcss_userpd3";
|
||||
qcom,rproc = <&q6_wcss_pd3>;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
qcom,tgt-mem-mode = <2>;
|
||||
#else
|
||||
qcom,tgt-mem-mode = <1>;
|
||||
#endif
|
||||
qcom,board_id = <0xb0>;
|
||||
qcom,bdf-addr = <0x4ED00000 0x4ED00000 0x4E200000 0x0 0x0>;
|
||||
qcom,bdf-addr = <0x4ED00000 0x4ED00000 0x4E400000 0x0 0x0>;
|
||||
#ifdef __CNSS2__
|
||||
qcom,caldb-addr = <0x4FF00000 0x4FF00000 0 0 0>;
|
||||
#else
|
||||
@@ -943,60 +1011,5 @@
|
||||
m3-dump-addr = <0x4FD00000>;
|
||||
#endif
|
||||
qcom,caldb-size = <0x500000>;
|
||||
mem-region = <&q6_qcn6122_data2>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&usb3 {
|
||||
status = "ok";
|
||||
device-power-gpio = <&tlmm 24 1>;
|
||||
};
|
||||
|
||||
&dwc_0 {
|
||||
/delete-property/ #phy-cells;
|
||||
/delete-property/ phys;
|
||||
/delete-property/ phy-names;
|
||||
};
|
||||
|
||||
&hs_m31phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&eud {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&pcie_x1 {
|
||||
status = "disabled";
|
||||
perst-gpio = <&tlmm 18 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
&pcie_x2 {
|
||||
status = "disabled";
|
||||
perst-gpio = <&tlmm 15 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
&pcie_x1phy {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&pcie_x2phy {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&pcie_x1_rp {
|
||||
status = "disabled";
|
||||
|
||||
mhi_0: qcom,mhi@0 {
|
||||
reg = <0 0 0 0 0 >;
|
||||
};
|
||||
};
|
||||
|
||||
&pcie_x2_rp {
|
||||
status = "disabled";
|
||||
|
||||
mhi_1: qcom,mhi@1 {
|
||||
reg = <0 0 0 0 0 >;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/dts-v1/;
|
||||
/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -16,14 +14,17 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ipq5018.dtsi"
|
||||
#include "qcom-ipq5018.dtsi"
|
||||
|
||||
/ {
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
model = "Qualcomm Technologies, Inc. IPQ5018/AP-MP03.1";
|
||||
compatible = "qcom,ipq5018-ap-mp03.1", "qcom,ipq5018-mp03.1", "qcom,ipq5018";
|
||||
compatible = "qcom,ipq5018-mp03.1", "qcom,ipq5018";
|
||||
interrupt-parent = <&intc>;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
AUTO_MOUNT;
|
||||
#endif
|
||||
|
||||
aliases {
|
||||
sdhc1 = &sdhc_1; /* SDC1 eMMC slot */
|
||||
@@ -31,11 +32,19 @@
|
||||
serial1 = &blsp1_uart2;
|
||||
ethernet0 = "/soc/dp1";
|
||||
ethernet1 = "/soc/dp2";
|
||||
led-boot = &led_sys;
|
||||
led-failsafe = &led_sys;
|
||||
led-running = &led_sys;
|
||||
led-upgrade = &led_sys;
|
||||
};
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
bootargs-append = " swiotlb=1";
|
||||
#else
|
||||
bootargs-append = " swiotlb=1 coherent_pool=2M";
|
||||
#endif
|
||||
stdout-path = "serial0";
|
||||
};
|
||||
|
||||
@@ -92,7 +101,7 @@
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | MHI1 | 0x4DA00000 | 9MB |
|
||||
* | MHI1 | 0x4DA00000 | 16MB |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | |
|
||||
@@ -100,7 +109,7 @@
|
||||
* | |
|
||||
* +=================================================+
|
||||
*/
|
||||
q6_region: memory@4b000000 {
|
||||
q6_region: wcnss@4b000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4b000000 0x0 0x01700000>;
|
||||
};
|
||||
@@ -115,18 +124,16 @@
|
||||
reg = <0x0 0x4c800000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
qcn9000_pcie0: qcn9000_pcie0@4c900000 {
|
||||
qcn9000_pcie0@4c900000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4C900000 0x0 0x01100000>;
|
||||
};
|
||||
|
||||
#if defined(__CNSS2__)
|
||||
mhi_region1: dma_pool1@4da00000 {
|
||||
compatible = "shared-dma-pool";
|
||||
no-map;
|
||||
reg = <0x0 0x4DA00000 0x0 0x00900000>;
|
||||
reg = <0x0 0x4da00000 0x0 0x01000000>;
|
||||
};
|
||||
#endif
|
||||
#elif __IPQ_MEM_PROFILE_512_MB__
|
||||
/* 512 MB Profile
|
||||
* +=========+==============+========================+
|
||||
@@ -176,11 +183,11 @@
|
||||
* | caldb | 0x4CA00000 | 2MB |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* |QCN9000 | 0x4CC00000 | 38MB |
|
||||
* |QCN9000 | 0x4CC00000 | 30MB |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | MHI1 | 0x4F200000 | 9MB |
|
||||
* | MHI1 | 0x4EA00000 | 16MB |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | |
|
||||
@@ -188,7 +195,7 @@
|
||||
* | |
|
||||
* +=================================================+
|
||||
*/
|
||||
q6_region: memory@4b000000 {
|
||||
q6_region: wcnss@4b000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4b000000 0x0 0x01800000>;
|
||||
};
|
||||
@@ -208,18 +215,16 @@
|
||||
reg = <0x0 0x4ca00000 0x0 0x200000>;
|
||||
};
|
||||
|
||||
qcn9000_pcie0: qcn9000_pcie0@4cc00000 {
|
||||
qcn9000_pcie0@4cc00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4CC00000 0x0 0x02600000>;
|
||||
reg = <0x0 0x4CC00000 0x0 0x01E00000>;
|
||||
};
|
||||
|
||||
#if defined(__CNSS2__)
|
||||
mhi_region1: dma_pool1@4f200000 {
|
||||
mhi_region1: dma_pool1@4ea00000 {
|
||||
compatible = "shared-dma-pool";
|
||||
no-map;
|
||||
reg = <0x0 0x4f200000 0x0 0x00900000>;
|
||||
reg = <0x0 0x4ea00000 0x0 0x01000000>;
|
||||
};
|
||||
#endif
|
||||
#else
|
||||
/* 1G Profile
|
||||
* +=========+==============+========================+
|
||||
@@ -269,11 +274,11 @@
|
||||
* | caldb | 0x4CA00000 | 2MB |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* |QCN9000 | 0x4CC00000 | 53MB |
|
||||
* |QCN9000 | 0x4CC00000 | 45MB |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | MHI1 | 0x50100000 | 9MB |
|
||||
* | MHI1 | 0x4F900000 | 24MB |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | |
|
||||
@@ -281,7 +286,7 @@
|
||||
* | |
|
||||
* +=================================================+
|
||||
*/
|
||||
q6_region: memory@4b000000 {
|
||||
q6_region: wcnss@4b000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4b000000 0x0 0x01800000>;
|
||||
};
|
||||
@@ -301,19 +306,17 @@
|
||||
reg = <0x0 0x4ca00000 0x0 0x200000>;
|
||||
};
|
||||
|
||||
qcn9000_pcie0: qcn9000_pcie0@4cc00000 {
|
||||
qcn9000_pcie0@4cc00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4CC00000 0x0 0x03500000>;
|
||||
reg = <0x0 0x4CC00000 0x0 0x02D00000>;
|
||||
};
|
||||
|
||||
#if defined(__CNSS2__)
|
||||
mhi_region1: dma_pool1@50100000 {
|
||||
mhi_region1: dma_pool1@4F900000 {
|
||||
compatible = "shared-dma-pool";
|
||||
no-map;
|
||||
reg = <0x0 0x50100000 0x0 0x00900000>;
|
||||
reg = <0x0 0x4F900000 0x0 0x01800000>;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
soc {
|
||||
@@ -425,7 +428,7 @@
|
||||
device_id = <1>;
|
||||
switch_access_mode = "mdio";
|
||||
mdio-bus = <&mdio1>;
|
||||
reset_gpio = <&tlmm 0x27 0>;
|
||||
reset_gpio = <0x27>;
|
||||
switch_cpu_bmp = <0x40>; /* cpu port bitmap */
|
||||
switch_lan_bmp = <0x3c>; /* lan port bitmap */
|
||||
switch_wan_bmp = <0x0>; /* wan port bitmap */
|
||||
@@ -464,6 +467,15 @@
|
||||
};
|
||||
};
|
||||
|
||||
wifi0: wifi@c000000 {
|
||||
qcom,bdf-addr = <0x4BA00000 0x4BA00000 0x4BA00000
|
||||
0x0 0x0>;
|
||||
qcom,caldb-addr = <0x4CA00000 0x4CA00000 0x4CA00000
|
||||
0x0 0x0>;
|
||||
qcom,caldb-size = <0x200000>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
ess-uniphy@98000 {
|
||||
status = "disabled";
|
||||
};
|
||||
@@ -472,6 +484,10 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
qcom,usbbam@8B04000 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
qcom,diag@0 {
|
||||
status = "ok";
|
||||
};
|
||||
@@ -490,7 +506,6 @@
|
||||
mdio-bus = <&mdio0>;
|
||||
local-mac-address = [000000000000];
|
||||
phy-mode = "sgmii";
|
||||
qcom,rx-page-mode = <0>;
|
||||
};
|
||||
|
||||
dp2 {
|
||||
@@ -504,74 +519,16 @@
|
||||
qcom,mactype = <2>;
|
||||
local-mac-address = [000000000000];
|
||||
phy-mode = "sgmii";
|
||||
qcom,rx-page-mode = <0>;
|
||||
};
|
||||
|
||||
rpm_etm0 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
pcm: pcm@0xA3C0000{
|
||||
pinctrl-0 = <&audio_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
button@1 {
|
||||
label = "wps";
|
||||
linux,code = <KEY_WPS_BUTTON>;
|
||||
gpios = <&tlmm 27 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
|
||||
button@2 {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 28 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
};
|
||||
|
||||
gpio_leds {
|
||||
compatible = "gpio-leds";
|
||||
pinctrl-0 = <&leds_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
led_sys: led@1 {
|
||||
label = "sys:blue";
|
||||
gpios = <&tlmm 1 GPIO_ACTIVE_HIGH>; /* GPIO_1 */
|
||||
default-state="on";
|
||||
};
|
||||
|
||||
led@35 {
|
||||
label = "sys:green";
|
||||
gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; /* GPIO_35 */
|
||||
default-state="off";
|
||||
};
|
||||
|
||||
led@31 {
|
||||
label = "sys:red";
|
||||
gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; /* GPIO_31 */
|
||||
default-state="off";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
qcom,test@0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
thermal-zones {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
@@ -610,17 +567,33 @@
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
qspi_cs {
|
||||
pins = "gpio8";
|
||||
function = "qspi_cs";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
qspi_data {
|
||||
pins = "gpio4", "gpio5", "gpio6", "gpio7";
|
||||
function = "qspi_data";
|
||||
qspi_data_0 {
|
||||
pins = "gpio7";
|
||||
function = "qspi0";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_data_1 {
|
||||
pins = "gpio6";
|
||||
function = "qspi1";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_data_2 {
|
||||
pins = "gpio5";
|
||||
function = "qspi2";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
qspi_data_3 {
|
||||
pins = "gpio4";
|
||||
function = "qspi3";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
@@ -643,12 +616,18 @@
|
||||
};
|
||||
|
||||
phy_led_pins: phy_led_pins {
|
||||
gephy_led_pin {
|
||||
pins = "gpio46";
|
||||
function = "led0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
gephy_led_pin_1g {
|
||||
pins = "gpio30";
|
||||
function = "led2";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
gephy_led_pin_100 {
|
||||
pins = "gpio46";
|
||||
function = "led0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
i2c_pins: i2c_pins {
|
||||
@@ -668,95 +647,87 @@
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio27";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
reset_button {
|
||||
pins = "gpio28";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
leds_pins: leds_pinmux {
|
||||
sys_blue {
|
||||
pins = "gpio1";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
sys_green {
|
||||
pins = "gpio35";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
sys_red {
|
||||
pins = "gpio31";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
audio_pins: audio_pinmux {
|
||||
mux_1 {
|
||||
pins = "gpio24";
|
||||
function = "audio_rxbclk";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_2 {
|
||||
pins = "gpio25";
|
||||
function = "audio_rxfsync";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_3 {
|
||||
pins = "gpio26";
|
||||
function = "audio_rxd";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_4 {
|
||||
wps_button {
|
||||
pins = "gpio27";
|
||||
function = "audio_txmclk";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
mux_5 {
|
||||
reset_button {
|
||||
pins = "gpio28";
|
||||
function = "audio_txbclk";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_6 {
|
||||
pins = "gpio29";
|
||||
function = "audio_txfsync";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_7 {
|
||||
pins = "gpio30";
|
||||
function = "audio_txd";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
leds_pins: leds_pinmux {
|
||||
sys_blue {
|
||||
pins = "gpio1";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
sys_green {
|
||||
pins = "gpio35";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
sys_red {
|
||||
pins = "gpio31";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
&soc {
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
button@1 {
|
||||
label = "wps";
|
||||
linux,code = <KEY_WPS_BUTTON>;
|
||||
gpios = <&tlmm 27 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
|
||||
button@2 {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 28 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
};
|
||||
gpio_leds {
|
||||
compatible = "gpio-leds";
|
||||
pinctrl-0 = <&leds_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
led_sys: led@1 {
|
||||
label = "sys:blue";
|
||||
gpios = <&tlmm 1 GPIO_ACTIVE_HIGH>; /* GPIO_1 */
|
||||
default-state="on";
|
||||
};
|
||||
led@35 {
|
||||
label = "sys:green";
|
||||
gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>; /* GPIO_35 */
|
||||
default-state="off";
|
||||
};
|
||||
led@31 {
|
||||
label = "sys:red";
|
||||
gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>; /* GPIO_31 */
|
||||
default-state="off";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&usb3 {
|
||||
@@ -772,22 +743,42 @@
|
||||
|
||||
&pcie_x1 {
|
||||
status = "disabled";
|
||||
perst-gpio = <&tlmm 18 GPIO_ACTIVE_LOW>;
|
||||
perst-gpio = <&tlmm 18 1>;
|
||||
};
|
||||
|
||||
&pcie_x2 {
|
||||
status = "ok";
|
||||
perst-gpio = <&tlmm 15 GPIO_ACTIVE_LOW>;
|
||||
perst-gpio = <&tlmm 15 1>;
|
||||
};
|
||||
|
||||
&bt {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&wcss {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&q6v5_wcss {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&q6v5_m3 {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&tcsr_mutex_block {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&tcsr_mutex {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&smem {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&apcs_glb {
|
||||
status = "ok";
|
||||
};
|
||||
@@ -796,13 +787,34 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&q6v5_wcss {
|
||||
&qcom_q6v5_wcss {
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_region>, <&q6_etr_region>;
|
||||
#else
|
||||
memory-region = <&q6_region>, <&q6_etr_region>,
|
||||
<&q6_caldb_region>;
|
||||
#endif
|
||||
/* IPQ5018 */
|
||||
q6v5_wcss_userpd1 {
|
||||
m3_firmware = "IPQ5018/m3_fw.mdt";
|
||||
interrupts-extended = <&wcss_smp2p_in 8 0>,
|
||||
<&wcss_smp2p_in 9 0>,
|
||||
<&wcss_smp2p_in 12 0>,
|
||||
<&wcss_smp2p_in 11 0>;
|
||||
interrupt-names ="fatal",
|
||||
"ready",
|
||||
"spawn_ack",
|
||||
"stop-ack";
|
||||
qcom,smem-states = <&wcss_smp2p_out 8>,
|
||||
<&wcss_smp2p_out 9>,
|
||||
<&wcss_smp2p_out 10>;
|
||||
qcom,smem-state-names = "shutdown",
|
||||
"stop",
|
||||
"spawn";
|
||||
qca,asid = <1>;
|
||||
qca,auto-restart;
|
||||
qca,int_radio;
|
||||
};
|
||||
};
|
||||
|
||||
&i2c_0 {
|
||||
@@ -811,6 +823,14 @@
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&dbm_1p5 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&msm_imem {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&blsp1_uart1 {
|
||||
status = "ok";
|
||||
};
|
||||
@@ -847,108 +867,35 @@
|
||||
qrtr_instance_id = <0x20>;
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
#if defined(__CNSS2__)
|
||||
memory-region = <&mhi_region1>;
|
||||
#else
|
||||
#if !defined(__CNSS2__)
|
||||
base-addr = <0x4CC00000>;
|
||||
m3-dump-addr = <0x4E000000>;
|
||||
etr-addr = <0x4E100000>;
|
||||
qcom,caldb-addr = <0x4E200000>;
|
||||
pageable-addr = <0x4EA00000>;
|
||||
qcom,tgt-mem-mode = <0x1>;
|
||||
mhi,max-channels = <30>;
|
||||
mhi,timeout = <10000>;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
&wifi0 {
|
||||
/* IPQ5018 */
|
||||
mem-region = <&q6_region>;
|
||||
qcom,board_id = <0x24>;
|
||||
|
||||
qcom,bdf-addr = <0x4BA00000 0x4BA00000 0x4BA00000
|
||||
0x0 0x0>;
|
||||
qcom,caldb-addr = <0x4CA00000 0x4CA00000 0x0 0x0 0x0>;
|
||||
qcom,caldb-size = <0x200000>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&wifi3 {
|
||||
/* QCN9000 5G */
|
||||
board_id = <0xa0>;
|
||||
hremote_node = <&qcn9000_pcie0>;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
/* QCN9000 tgt-mem-mode=2 layout - 17MB
|
||||
* +=========+==============+=========+
|
||||
* | Region | Start Offset | Size |
|
||||
* +---------+--------------+---------+
|
||||
* | HREMOTE | 0x4C900000 | 11MB |
|
||||
* +---------+--------------+---------+
|
||||
* | M3 Dump | 0x4D400000 | 1MB |
|
||||
* +---------+--------------+---------+
|
||||
* | ETR | 0x4D500000 | 1MB |
|
||||
* +---------+--------------+---------+
|
||||
* | Pageable| 0x4D600000 | 4MB |
|
||||
* +==================================+
|
||||
*/
|
||||
base-addr = <0x4C900000>;
|
||||
m3-dump-addr = <0x4D400000>;
|
||||
etr-addr = <0x4D500000>;
|
||||
caldb-addr = <0>;
|
||||
pageable-addr = <0x4D600000>;
|
||||
caldb-size = <0>;
|
||||
hremote-size = <0xB00000>;
|
||||
tgt-mem-mode = <0x2>;
|
||||
pageable-size = <0x400000>;
|
||||
#elif __IPQ_MEM_PROFILE_512_MB__
|
||||
/* QCN9000 tgt-mem-mode=1 layout - 38MB
|
||||
* +=========+==============+=========+
|
||||
* | Region | Start Offset | Size |
|
||||
* +---------+--------------+---------+
|
||||
* | HREMOTE | 0x4CC00000 | 20MB |
|
||||
* +---------+--------------+---------+
|
||||
* | M3 Dump | 0x4E000000 | 1MB |
|
||||
* +---------+--------------+---------+
|
||||
* | ETR | 0x4E100000 | 1MB |
|
||||
* +---------+--------------+---------+
|
||||
* | Caldb | 0x4E200000 | 8MB |
|
||||
* +---------+--------------+---------+
|
||||
* | Pageable| 0x4EA00000 | 8MB |
|
||||
* +==================================+
|
||||
*/
|
||||
base-addr = <0x4CC00000>;
|
||||
m3-dump-addr = <0x4E000000>;
|
||||
etr-addr = <0x4E100000>;
|
||||
caldb-addr = <0x4E200000>;
|
||||
pageable-addr = <0x4EA00000>;
|
||||
caldb-size = <0x800000>;
|
||||
hremote-size = <0x1400000>;
|
||||
tgt-mem-mode = <0x1>;
|
||||
pageable-size = <0x800000>;
|
||||
#else
|
||||
/* QCN9000 tgt-mem-mode=0 layout - 53MB
|
||||
* +=========+==============+=========+
|
||||
* | Region | Start Offset | Size |
|
||||
* +---------+--------------+---------+
|
||||
* | HREMOTE | 0x4CC00000 | 35MB |
|
||||
* +---------+--------------+---------+
|
||||
* | M3 Dump | 0x4EF00000 | 1MB |
|
||||
* +---------+--------------+---------+
|
||||
* | ETR | 0x4F000000 | 1MB |
|
||||
* +---------+--------------+---------+
|
||||
* | Caldb | 0x4F100000 | 8MB |
|
||||
* +---------+--------------+---------+
|
||||
* | Pageable| 0x4F900000 | 8MB |
|
||||
* +==================================+
|
||||
*/
|
||||
base-addr = <0x4CC00000>;
|
||||
m3-dump-addr = <0x4EF00000>;
|
||||
etr-addr = <0x4F000000>;
|
||||
caldb-addr = <0x4F100000>;
|
||||
pageable-addr = <0x4F900000>;
|
||||
hremote-size = <0x2300000>;
|
||||
caldb-size = <0x800000>;
|
||||
tgt-mem-mode = <0x0>;
|
||||
pageable-size = <0x800000>;
|
||||
#endif
|
||||
/* QCN9000 5G */
|
||||
board_id = <0xa0>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qfprom {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&tsens {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
@@ -1,934 +0,0 @@
|
||||
/dts-v1/;
|
||||
/* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ipq5018.dtsi"
|
||||
|
||||
/ {
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
model = "Mototola Q14";
|
||||
compatible = "motorola,q14", "qcom,ipq5018-mp03.5", "qcom,ipq5018";
|
||||
interrupt-parent = <&intc>;
|
||||
|
||||
aliases {
|
||||
sdhc1 = &sdhc_1; /* SDC1 eMMC slot */
|
||||
serial0 = &blsp1_uart1;
|
||||
serial1 = &blsp1_uart2;
|
||||
ethernet0 = "/soc/dp1";
|
||||
ethernet1 = "/soc/dp2";
|
||||
};
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
bootargs-append = " swiotlb=1 coherent_pool=2M";
|
||||
stdout-path = "serial0";
|
||||
};
|
||||
|
||||
reserved-memory {
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
/* 256 MB Profile
|
||||
* +==========+==============+=========================+
|
||||
* | | | |
|
||||
* | Region | Start Offset | Size |
|
||||
* | | | |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | NSS | 0x40000000 | 8MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | Linux | 0x40800000 | Depends on total memory |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | uboot | 0x4A600000 | 4MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | SBL | 0x4AA00000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | smem | 0x4AB00000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | TZ | 0x4AC00000 | 4MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | Q6 | | |
|
||||
* | code/ | 0x4B000000 | 20MB |
|
||||
* | data | | |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | IPQ5018 | | |
|
||||
* | data | 0x4C400000 | 13MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | IPQ5018 | | |
|
||||
* | M3 Dump | 0x4D100000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | IPQ5018 | | |
|
||||
* | QDSS | 0x4D200000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | data | 0x4D300000 | 13MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | M3 Dump | 0x4E000000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | QDSS | 0x4E100000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | data | 0x4E200000 | 13MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | M3 Dump | 0x4EF00000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | QDSS | 0x4F000000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | |
|
||||
* | Rest of the memory for Linux |
|
||||
* | |
|
||||
* +===================================================+
|
||||
*/
|
||||
q6_mem_regions: q6_mem_regions@4B000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4B000000 0x0 0x4100000>;
|
||||
};
|
||||
|
||||
q6_code_data: q6_code_data@4B000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4B000000 0x0 0x1400000>;
|
||||
};
|
||||
|
||||
q6_ipq5018_data: q6_ipq5018_data@4C400000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4C400000 0x0 0xD00000>;
|
||||
};
|
||||
|
||||
m3_dump: m3_dump@4D100000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D100000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_etr_region: q6_etr_dump@4D200000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D200000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_data1: q6_qcn6122_data1@4D300000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D300000 0x0 0xD00000>;
|
||||
};
|
||||
|
||||
m3_dump_qcn6122_1: m3_dump_qcn6122_1@4E000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E000000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_etr_1: q6_qcn6122_etr_1@4E100000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E100000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_data2: q6_qcn6122_data2@4E200000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E200000 0x0 0xD00000>;
|
||||
};
|
||||
|
||||
m3_dump_qcn6122_2: m3_dump_qcn6122_2@4EF00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4EF00000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_etr_2: q6_qcn6122_etr_2@4F000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4F000000 0x0 0x100000>;
|
||||
};
|
||||
#else
|
||||
/* 512MB/1GB Profiles
|
||||
* +==========+==============+=========================+
|
||||
* | | | |
|
||||
* | Region | Start Offset | Size |
|
||||
* | | | |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | NSS | 0x40000000 | 16MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | Linux | 0x41000000 | Depends on total memory |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | uboot | 0x4A600000 | 4MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | SBL | 0x4AA00000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | smem | 0x4AB00000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | TZ | 0x4AC00000 | 4MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | Q6 | | |
|
||||
* | code/ | 0x4B000000 | 20MB |
|
||||
* | data | | |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | IPQ5018 | | |
|
||||
* | data | 0x4C400000 | 14MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | IPQ5018 | | |
|
||||
* | M3 Dump | 0x4D200000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | IPQ5018 | | |
|
||||
* | QDSS | 0x4D300000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | IPQ5018 | | |
|
||||
* | Caldb | 0x4D400000 | 2MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | data | 0x4D600000 | 16MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | M3 Dump | 0x4E600000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | QDSS | 0x4E700000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_1| | |
|
||||
* | Caldb | 0x4E800000 | 5MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | data | 0x4ED00000 | 16MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | M3 Dump | 0x4FD00000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | QDSS | 0x4FE00000 | 1MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | QCN6122_2| | |
|
||||
* | Caldb | 0x4FF00000 | 5MB |
|
||||
* +----------+--------------+-------------------------+
|
||||
* | |
|
||||
* | Rest of the memory for Linux |
|
||||
* | |
|
||||
* +===================================================+
|
||||
*/
|
||||
q6_mem_regions: q6_mem_regions@4B000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4B000000 0x0 0x5400000>;
|
||||
};
|
||||
|
||||
q6_code_data: q6_code_data@4B000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4B000000 0x0 01400000>;
|
||||
};
|
||||
|
||||
q6_ipq5018_data: q6_ipq5018_data@4C400000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4C400000 0x0 0xE00000>;
|
||||
};
|
||||
|
||||
m3_dump: m3_dump@4D200000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D200000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_etr_region: q6_etr_dump@4D300000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D300000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_caldb_region: q6_caldb_region@4D400000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D400000 0x0 0x200000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_data1: q6_qcn6122_data1@4D600000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4D600000 0x0 0x1000000>;
|
||||
};
|
||||
|
||||
m3_dump_qcn6122_1: m3_dump_qcn6122_1@4E600000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E600000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_etr_1: q6_qcn6122_etr_1@4E700000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E700000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_caldb_1: q6_qcn6122_caldb_1@4E800000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4E800000 0x0 0x500000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_data2: q6_qcn6122_data2@4E900000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4ED00000 0x0 0x1000000>;
|
||||
};
|
||||
|
||||
m3_dump_qcn6122_2: m3_dump_qcn6122_2@4FD00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4FD00000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_etr_2: q6_qcn6122_etr_2@4FE00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4FE00000 0x0 0x100000>;
|
||||
};
|
||||
|
||||
q6_qcn6122_caldb_2: q6_qcn6122_caldb_2@4FF00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x4FF00000 0x0 0x500000>;
|
||||
};
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
soc {
|
||||
serial@78af000 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
blsp1_uart2: serial@78b0000 {
|
||||
pinctrl-0 = <&blsp1_uart_pins>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
qpic_bam: dma@7984000{
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
nand: qpic-nand@79b0000 {
|
||||
pinctrl-0 = <&qspi_nand_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
spi_0: spi@78b5000 { /* BLSP1 QUP0 */
|
||||
pinctrl-0 = <&blsp0_spi_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
};
|
||||
};
|
||||
|
||||
mdio0: mdio@88000 {
|
||||
status = "ok";
|
||||
|
||||
ethernet-phy@0 {
|
||||
reg = <7>;
|
||||
};
|
||||
};
|
||||
|
||||
mdio1: mdio@90000 {
|
||||
status = "ok";
|
||||
pinctrl-0 = <&mdio1_pins>;
|
||||
pinctrl-names = "default";
|
||||
phy-reset-gpio = <&tlmm 39 0>;
|
||||
|
||||
ethernet-phy@0 {
|
||||
reg = <28>;
|
||||
};
|
||||
};
|
||||
|
||||
ess-instance {
|
||||
num_devices = <0x1>;
|
||||
ess-switch@0x39c00000 {
|
||||
switch_mac_mode = <0xf>; /* mac mode for uniphy instance*/
|
||||
cmnblk_clk = "internal_96MHz"; /* cmnblk clk*/
|
||||
qcom,port_phyinfo {
|
||||
port@0 {
|
||||
port_id = <1>;
|
||||
phy_address = <7>;
|
||||
mdiobus = <&mdio0>;
|
||||
};
|
||||
port@1 {
|
||||
port_id = <2>;
|
||||
phy_address = <0x1c>;
|
||||
mdiobus = <&mdio1>;
|
||||
port_mac_sel = "QGMAC_PORT";
|
||||
};
|
||||
};
|
||||
led_source@0 {
|
||||
source = <0>;
|
||||
mode = "normal";
|
||||
speed = "all";
|
||||
blink_en = "enable";
|
||||
active = "high";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
dp1 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,nss-dp";
|
||||
clocks = <&gcc GCC_SNOC_GMAC0_AXI_CLK>;
|
||||
clock-names = "nss-snoc-gmac-axi-clk";
|
||||
qcom,id = <1>;
|
||||
reg = <0x39C00000 0x10000>;
|
||||
interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
|
||||
qcom,mactype = <2>;
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <7>;
|
||||
mdio-bus = <&mdio0>;
|
||||
local-mac-address = [000000000000];
|
||||
phy-mode = "sgmii";
|
||||
qcom,rx-page-mode = <0>;
|
||||
};
|
||||
|
||||
dp2 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,nss-dp";
|
||||
clocks = <&gcc GCC_SNOC_GMAC1_AXI_CLK>;
|
||||
clock-names = "nss-snoc-gmac-axi-clk";
|
||||
qcom,id = <2>;
|
||||
reg = <0x39D00000 0x10000>;
|
||||
interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
|
||||
qcom,mactype = <2>;
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <28>;
|
||||
mdio-bus = <&mdio1>;
|
||||
local-mac-address = [000000000000];
|
||||
phy-mode = "sgmii";
|
||||
qcom,rx-page-mode = <0>;
|
||||
};
|
||||
|
||||
nss-macsec1 {
|
||||
compatible = "qcom,nss-macsec";
|
||||
phy_addr = <0x1c>;
|
||||
mdiobus = <&mdio1>;
|
||||
};
|
||||
|
||||
pcm: pcm@0xA3C0000{
|
||||
pinctrl-0 = <&audio_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
qcom,test@0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
thermal-zones {
|
||||
status = "ok";
|
||||
};
|
||||
};
|
||||
|
||||
&sdhc_1 {
|
||||
status = "ok";
|
||||
pinctrl-0 = <&emmc_pins>;
|
||||
pinctrl-names = "default";
|
||||
qcom,nonremovable;
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
pinctrl-0 = <&blsp0_uart_pins &phy_led_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
emmc_pins: emmc_pins {
|
||||
emmc_clk {
|
||||
pins = "gpio9";
|
||||
function = "sdc1_clk";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
emmc_cmd {
|
||||
pins = "gpio8";
|
||||
function = "sdc1_cmd";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
emmc_data_0 {
|
||||
pins = "gpio7";
|
||||
function = "sdc10";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
emmc_data_1 {
|
||||
pins = "gpio6";
|
||||
function = "sdc11";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
emmc_data_2 {
|
||||
pins = "gpio5";
|
||||
function = "sdc12";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
emmc_data_3 {
|
||||
pins = "gpio4";
|
||||
function = "sdc13";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
blsp0_uart_pins: uart_pins {
|
||||
blsp0_uart_rx_tx {
|
||||
pins = "gpio20", "gpio21";
|
||||
function = "blsp0_uart0";
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
blsp1_uart_pins: blsp1_uart_pins {
|
||||
blsp1_uart_rx_tx {
|
||||
pins = "gpio23", "gpio25", "gpio24", "gpio26";
|
||||
function = "blsp1_uart2";
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
blsp0_spi_pins: blsp0_spi_pins {
|
||||
mux {
|
||||
pins = "gpio10", "gpio11", "gpio12", "gpio13";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <2>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
qspi_nand_pins: qspi_nand_pins {
|
||||
qspi_clock {
|
||||
pins = "gpio9";
|
||||
function = "qspi_clk";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
qspi_cs {
|
||||
pins = "gpio8";
|
||||
function = "qspi_cs";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
qspi_data {
|
||||
pins = "gpio4", "gpio5", "gpio6", "gpio7";
|
||||
function = "qspi_data";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
mdio1_pins: mdio_pinmux {
|
||||
mux_0 {
|
||||
pins = "gpio36";
|
||||
function = "mdc";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
mux_1 {
|
||||
pins = "gpio37";
|
||||
function = "mdio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
phy_led_pins: phy_led_pins {
|
||||
gephy_led_pin {
|
||||
pins = "gpio46";
|
||||
function = "led0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
i2c_pins: i2c_pins {
|
||||
i2c_scl {
|
||||
pins = "gpio25";
|
||||
function = "blsp2_i2c1";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
i2c_sda {
|
||||
pins = "gpio26";
|
||||
function = "blsp2_i2c1";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio38";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
reset_button {
|
||||
pins = "gpio31";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
audio_pins: audio_pinmux {
|
||||
mux_1 {
|
||||
pins = "gpio24";
|
||||
function = "audio_rxbclk";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_2 {
|
||||
pins = "gpio25";
|
||||
function = "audio_rxfsync";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_3 {
|
||||
pins = "gpio26";
|
||||
function = "audio_rxd";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_4 {
|
||||
pins = "gpio27";
|
||||
function = "audio_txmclk";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_5 {
|
||||
pins = "gpio28";
|
||||
function = "audio_txbclk";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_6 {
|
||||
pins = "gpio29";
|
||||
function = "audio_txfsync";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mux_7 {
|
||||
pins = "gpio30";
|
||||
function = "audio_txd";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&soc {
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
button@1 {
|
||||
label = "wps";
|
||||
linux,code = <KEY_WPS_BUTTON>;
|
||||
gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
button@2 {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 31 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&q6v5_wcss {
|
||||
compatible = "qcom,ipq5018-q6-mpd";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
ranges;
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
reg = <0x0cd00000 0x4040>,
|
||||
<0x1938000 0x8>,
|
||||
<0x193d204 0x4>;
|
||||
reg-names = "qdsp6",
|
||||
"tcsr-msip",
|
||||
"tcsr-q6";
|
||||
resets = <&gcc GCC_WCSSAON_RESET>,
|
||||
<&gcc GCC_WCSS_Q6_BCR>;
|
||||
|
||||
reset-names = "wcss_aon_reset",
|
||||
"wcss_q6_reset";
|
||||
|
||||
clocks = <&gcc GCC_Q6_AXIS_CLK>,
|
||||
<&gcc GCC_WCSS_ECAHB_CLK>,
|
||||
<&gcc GCC_Q6_AXIM_CLK>,
|
||||
<&gcc GCC_Q6_AXIM2_CLK>,
|
||||
<&gcc GCC_Q6_AHB_CLK>,
|
||||
<&gcc GCC_Q6_AHB_S_CLK>,
|
||||
<&gcc GCC_WCSS_AXI_S_CLK>;
|
||||
clock-names = "gcc_q6_axis_clk",
|
||||
"gcc_wcss_ecahb_clk",
|
||||
"gcc_q6_axim_clk",
|
||||
"gcc_q6_axim2_clk",
|
||||
"gcc_q6_ahb_clk",
|
||||
"gcc_q6_ahb_s_clk",
|
||||
"gcc_wcss_axi_s_clk";
|
||||
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_mem_regions>, <&q6_etr_region>;
|
||||
#else
|
||||
memory-region = <&q6_mem_regions>, <&q6_etr_region>,
|
||||
<&q6_caldb_region>;
|
||||
#endif
|
||||
|
||||
qcom,rproc = <&q6v5_wcss>;
|
||||
qcom,bootargs_smem = <507>;
|
||||
boot-args = <0x1 0x4 0x3 0x0F 0x0 0x0>,
|
||||
<0x2 0x4 0x2 0x12 0x0 0x0>;
|
||||
status = "ok";
|
||||
q6_wcss_pd1: remoteproc_pd1@4ab000 {
|
||||
compatible = "qcom,ipq5018-wcss-ahb-mpd";
|
||||
reg = <0x4ab000 0x20>;
|
||||
reg-names = "rmb";
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
m3_firmware = "IPQ5018/m3_fw.mdt";
|
||||
interrupts-extended = <&wcss_smp2p_in 8 0>,
|
||||
<&wcss_smp2p_in 9 0>,
|
||||
<&wcss_smp2p_in 12 0>,
|
||||
<&wcss_smp2p_in 11 0>;
|
||||
interrupt-names = "fatal",
|
||||
"ready",
|
||||
"spawn-ack",
|
||||
"stop-ack";
|
||||
|
||||
resets = <&gcc GCC_WCSSAON_RESET>,
|
||||
<&gcc GCC_WCSS_BCR>,
|
||||
<&gcc GCC_CE_BCR>;
|
||||
reset-names = "wcss_aon_reset",
|
||||
"wcss_reset",
|
||||
"ce_reset";
|
||||
|
||||
clocks = <&gcc GCC_WCSS_AHB_S_CLK>,
|
||||
<&gcc GCC_WCSS_ACMT_CLK>,
|
||||
<&gcc GCC_WCSS_AXI_M_CLK>;
|
||||
clock-names = "gcc_wcss_ahb_s_clk",
|
||||
"gcc_wcss_acmt_clk",
|
||||
"gcc_wcss_axi_m_clk";
|
||||
|
||||
qcom,halt-regs = <&tcsr_q6_block 0xa000 0xd000 0x0>;
|
||||
|
||||
qcom,smem-states = <&wcss_smp2p_out 8>,
|
||||
<&wcss_smp2p_out 9>,
|
||||
<&wcss_smp2p_out 10>;
|
||||
qcom,smem-state-names = "shutdown",
|
||||
"stop",
|
||||
"spawn";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_ipq5018_data>, <&m3_dump>,
|
||||
<&q6_etr_region>;
|
||||
#else
|
||||
memory-region = <&q6_ipq5018_data>, <&m3_dump>,
|
||||
<&q6_etr_region>, <&q6_caldb_region>;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
q6_wcss_pd2: remoteproc_pd2 {
|
||||
compatible = "qcom,ipq5018-wcss-pcie-mpd";
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
m3_firmware = "qcn6122/m3_fw.mdt";
|
||||
interrupts-extended = <&wcss_smp2p_in 16 0>,
|
||||
<&wcss_smp2p_in 17 0>,
|
||||
<&wcss_smp2p_in 20 0>,
|
||||
<&wcss_smp2p_in 19 0>;
|
||||
interrupt-names = "fatal",
|
||||
"ready",
|
||||
"spawn-ack",
|
||||
"stop-ack";
|
||||
|
||||
qcom,smem-states = <&wcss_smp2p_out 16>,
|
||||
<&wcss_smp2p_out 17>,
|
||||
<&wcss_smp2p_out 18>;
|
||||
qcom,smem-state-names = "shutdown",
|
||||
"stop",
|
||||
"spawn";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_qcn6122_data1>, <&m3_dump_qcn6122_1>,
|
||||
<&q6_qcn6122_etr_1>;
|
||||
#else
|
||||
memory-region = <&q6_qcn6122_data1>, <&m3_dump_qcn6122_1>,
|
||||
<&q6_qcn6122_etr_1>, <&q6_qcn6122_caldb_1>;
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
q6_wcss_pd3: remoteproc_pd3 {
|
||||
compatible = "qcom,ipq5018-wcss-pcie-mpd";
|
||||
firmware = "IPQ5018/q6_fw.mdt";
|
||||
interrupts-extended = <&wcss_smp2p_in 24 0>,
|
||||
<&wcss_smp2p_in 25 0>,
|
||||
<&wcss_smp2p_in 28 0>,
|
||||
<&wcss_smp2p_in 27 0>;
|
||||
interrupt-names = "fatal",
|
||||
"ready",
|
||||
"spawn-ack",
|
||||
"stop-ack";
|
||||
|
||||
qcom,smem-states = <&wcss_smp2p_out 24>,
|
||||
<&wcss_smp2p_out 25>,
|
||||
<&wcss_smp2p_out 26>;
|
||||
qcom,smem-state-names = "shutdown",
|
||||
"stop",
|
||||
"spawn";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
memory-region = <&q6_qcn6122_data2>, <&m3_dump_qcn6122_2>,
|
||||
<&q6_qcn6122_etr_2>;
|
||||
#else
|
||||
memory-region = <&q6_qcn6122_data2>, <&m3_dump_qcn6122_2>,
|
||||
<&q6_qcn6122_etr_2>, <&q6_qcn6122_caldb_2>;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
&i2c_0 {
|
||||
pinctrl-0 = <&i2c_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&wifi0 {
|
||||
/* IPQ5018 */
|
||||
qcom,multipd_arch;
|
||||
qcom,rproc = <&q6_wcss_pd1>;
|
||||
qcom,userpd-subsys-name = "q6v5_wcss_userpd1";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
qcom,tgt-mem-mode = <2>;
|
||||
#else
|
||||
qcom,tgt-mem-mode = <1>;
|
||||
#endif
|
||||
qcom,board_id = <0x23>;
|
||||
qcom,bdf-addr = <0x4C400000 0x4C400000 0x4C400000 0x0 0x0>;
|
||||
#ifdef __CNSS2__
|
||||
qcom,caldb-addr = <0x4D400000 0x4D400000 0 0 0>;
|
||||
#else
|
||||
qcom,caldb-addr = <0x4D400000>;
|
||||
m3-dump-addr = <0x4D200000>;
|
||||
#endif
|
||||
qcom,caldb-size = <0x200000>;
|
||||
mem-region = <&q6_ipq5018_data>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&wifi1 {
|
||||
/* QCN6122 5G */
|
||||
qcom,multipd_arch;
|
||||
qcom,userpd-subsys-name = "q6v5_wcss_userpd2";
|
||||
qcom,rproc = <&q6_wcss_pd2>;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
qcom,tgt-mem-mode = <2>;
|
||||
#else
|
||||
qcom,tgt-mem-mode = <1>;
|
||||
#endif
|
||||
qcom,board_id = <0x60>;
|
||||
qcom,bdf-addr = <0x4D600000 0x4D600000 0x4D300000 0x0 0x0>;
|
||||
#ifdef __CNSS2__
|
||||
qcom,caldb-addr = <0x4E800000 0x4E800000 0 0 0>;
|
||||
#else
|
||||
qcom,caldb-addr = <0x4E800000>;
|
||||
m3-dump-addr = <0x4E600000>;
|
||||
#endif
|
||||
qcom,caldb-size = <0x500000>;
|
||||
mem-region = <&q6_qcn6122_data1>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&wifi2 {
|
||||
/* QCN6122 6G */
|
||||
qcom,multipd_arch;
|
||||
qcom,userpd-subsys-name = "q6v5_wcss_userpd3";
|
||||
qcom,rproc = <&q6_wcss_pd3>;
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
qcom,tgt-mem-mode = <2>;
|
||||
#else
|
||||
qcom,tgt-mem-mode = <1>;
|
||||
#endif
|
||||
qcom,board_id = <0xb0>;
|
||||
qcom,bdf-addr = <0x4ED00000 0x4ED00000 0x4E200000 0x0 0x0>;
|
||||
#ifdef __CNSS2__
|
||||
qcom,caldb-addr = <0x4FF00000 0x4FF00000 0 0 0>;
|
||||
#else
|
||||
qcom,caldb-addr = <0x4FF00000>;
|
||||
m3-dump-addr = <0x4FD00000>;
|
||||
#endif
|
||||
qcom,caldb-size = <0x500000>;
|
||||
mem-region = <&q6_qcn6122_data2>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&usb3 {
|
||||
status = "ok";
|
||||
device-power-gpio = <&tlmm 24 1>;
|
||||
};
|
||||
|
||||
&dwc_0 {
|
||||
/delete-property/ #phy-cells;
|
||||
/delete-property/ phys;
|
||||
/delete-property/ phy-names;
|
||||
};
|
||||
|
||||
&hs_m31phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&eud {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&pcie_x1 {
|
||||
status = "disabled";
|
||||
perst-gpio = <&tlmm 18 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
&pcie_x2 {
|
||||
status = "disabled";
|
||||
perst-gpio = <&tlmm 15 GPIO_ACTIVE_LOW>;
|
||||
};
|
||||
|
||||
&pcie_x1phy {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&pcie_x2phy {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
&pcie_x1_rp {
|
||||
status = "disabled";
|
||||
|
||||
mhi_0: qcom,mhi@0 {
|
||||
reg = <0 0 0 0 0 >;
|
||||
};
|
||||
};
|
||||
|
||||
&pcie_x2_rp {
|
||||
status = "disabled";
|
||||
|
||||
mhi_1: qcom,mhi@1 {
|
||||
reg = <0 0 0 0 0 >;
|
||||
|
||||
};
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
/dts-v1/;
|
||||
/*
|
||||
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,9 +15,12 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ipq6018.dtsi"
|
||||
#include "ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
#include "qcom-ipq6018-rpm-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cp-cpu.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
#address-cells = <0x2>;
|
||||
@@ -25,9 +28,11 @@
|
||||
model = "Cigtech WF-188n";
|
||||
compatible = "cig,wf188n", "qcom,ipq6018-cp03", "qcom,ipq6018";
|
||||
interrupt-parent = <&intc>;
|
||||
qcom,msm-id = <0x1A5 0x0>;
|
||||
|
||||
aliases {
|
||||
serial0 = &blsp1_uart3;
|
||||
serial1 = &blsp1_uart2;
|
||||
|
||||
/*
|
||||
* Aliases as required by u-boot
|
||||
* to patch MAC addresses
|
||||
@@ -43,11 +48,7 @@
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
bootargs-append = " swiotlb=1";
|
||||
#else
|
||||
bootargs-append = " swiotlb=1 coherent_pool=2M";
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -105,13 +106,71 @@
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio9";
|
||||
function = "gpio";
|
||||
qpic_pins: qpic_pins {
|
||||
data_0 {
|
||||
pins = "gpio15";
|
||||
function = "qpic_pad0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_1 {
|
||||
pins = "gpio12";
|
||||
function = "qpic_pad1";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_2 {
|
||||
pins = "gpio13";
|
||||
function = "qpic_pad2";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_3 {
|
||||
pins = "gpio14";
|
||||
function = "qpic_pad3";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_4 {
|
||||
pins = "gpio5";
|
||||
function = "qpic_pad4";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_5 {
|
||||
pins = "gpio6";
|
||||
function = "qpic_pad5";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_6 {
|
||||
pins = "gpio7";
|
||||
function = "qpic_pad6";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_7 {
|
||||
pins = "gpio8";
|
||||
function = "qpic_pad7";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
qpic_pad {
|
||||
pins = "gpio1", "gpio3", "gpio4",
|
||||
"gpio10", "gpio11", "gpio17";
|
||||
function = "qpic_pad";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio22";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
mdio_pins: mdio_pinmux {
|
||||
@@ -136,17 +195,37 @@
|
||||
|
||||
leds_pins: leds_pins {
|
||||
led_5g {
|
||||
pins = "gpio35";
|
||||
pins = "gpio25";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_2g {
|
||||
pins = "gpio37";
|
||||
pins = "gpio24";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_eth {
|
||||
pins = "gpio18";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_pwr {
|
||||
pins = "gpio16";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
uart2_pins: uart2_pins {
|
||||
mux {
|
||||
pins = "gpio57", "gpio58";
|
||||
function = "blsp4_uart";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -164,6 +243,7 @@
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
ess-switch@3a000000 {
|
||||
switch_cpu_bmp = <0x1>; /* cpu port bitmap */
|
||||
switch_lan_bmp = <0x08>; /* lan port bitmap */
|
||||
@@ -180,7 +260,7 @@
|
||||
port@4 {
|
||||
port_id = <4>;
|
||||
phy_address = <3>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -206,6 +286,7 @@
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <3>;
|
||||
phy-mode = "sgmii";
|
||||
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
@@ -245,17 +326,17 @@
|
||||
linux,default-trigger = "wf188:green:eth";
|
||||
default-state = "off";
|
||||
};
|
||||
led_power: led@16 {
|
||||
label = "green:power";
|
||||
gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "wf188:green:power";
|
||||
led_power: led@16 {
|
||||
label = "green:power";
|
||||
gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "wf188:green:power";
|
||||
default-state = "on";
|
||||
};
|
||||
};
|
||||
|
||||
gpio-watchdog {
|
||||
compatible = "linux,wdt-gpio";
|
||||
gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>;
|
||||
gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>;
|
||||
hw_algo = "toggle";
|
||||
hw_margin_ms = <5000>;
|
||||
always-running;
|
||||
@@ -285,22 +366,22 @@
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&uart2_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
};
|
||||
&qpic_bam {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qpic_nand {
|
||||
&nand {
|
||||
pinctrl-0 = <&qpic_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
|
||||
nand@0 {
|
||||
reg = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
nand-ecc-strength = <4>;
|
||||
nand-ecc-step-size = <512>;
|
||||
nand-bus-width = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
&ssphy_0 {
|
||||
@@ -318,3 +399,25 @@
|
||||
&nss_crypto {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&cpu0_opp_table {
|
||||
compatible = "operating-points-v2";
|
||||
opp-shared;
|
||||
opp03 {
|
||||
opp-hz = /bits/ 64 <1200000000>;
|
||||
opp-microvolt = <3>;
|
||||
clock-latency-ns = <200000>;
|
||||
};
|
||||
/delete-node/ opp04;
|
||||
/delete-node/ opp05;
|
||||
/delete-node/ opp06;
|
||||
};
|
||||
|
||||
/* TZAPP is enabled in default memory profile only */
|
||||
#if !defined(__IPQ_MEM_PROFILE_256_MB__) && !defined(__IPQ_MEM_PROFILE_512_MB__)
|
||||
&qseecom {
|
||||
mem-start = <0x49B00000>;
|
||||
mem-size = <0x600000>;
|
||||
status = "ok";
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,23 +1,38 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
|
||||
/dts-v1/;
|
||||
/*
|
||||
* IPQ6018 CP01 board device tree source
|
||||
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
#include "ipq6018.dtsi"
|
||||
#include "ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
#include "qcom-ipq6018-rpm-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cp-cpu.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
model = "EdgeCore EAP101";
|
||||
compatible = "edgecore,eap101", "qcom,ipq6018-cp01", "qcom,ipq6018";
|
||||
interrupt-parent = <&intc>;
|
||||
|
||||
aliases {
|
||||
serial0 = &blsp1_uart3;
|
||||
serial1 = &blsp1_uart2;
|
||||
|
||||
/*
|
||||
* Aliases as required by u-boot
|
||||
* to patch MAC addresses
|
||||
@@ -33,84 +48,130 @@
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs-append = " swiotlb=1";
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
bootargs-append = " console=ttyMSM0,115200,n8 swiotlb=1 coherent_pool=2M";
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart3 {
|
||||
pinctrl-0 = <&serial_3_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
/*
|
||||
* +=========+==============+========================+
|
||||
* | | | |
|
||||
* | Region | Start Offset | Size |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | Linux | 0x41000000 | 139MB |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | TZ App | 0x49B00000 | 6MB |
|
||||
* +--------+--------------+-------------------------+
|
||||
*
|
||||
* From the available 145 MB for Linux in the first 256 MB,
|
||||
* we are reserving 6 MB for TZAPP.
|
||||
*
|
||||
* Refer arch/arm64/boot/dts/qcom/qcom-ipq6018-memory.dtsi
|
||||
* for memory layout.
|
||||
*/
|
||||
|
||||
&spi_0 {
|
||||
pinctrl-0 = <&spi_0_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
/* TZAPP is enabled only in default memory profile */
|
||||
#if !defined(__IPQ_MEM_PROFILE_256_MB__) && !defined(__IPQ_MEM_PROFILE_512_MB__)
|
||||
reserved-memory {
|
||||
tzapp:tzapp@49B00000 { /* TZAPPS */
|
||||
no-map;
|
||||
reg = <0x0 0x49B00000 0x0 0x00600000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&hsuart_pins &btcoex_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
#endif
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
spi_0_pins: spi-0-pins {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
spi_1_pins: spi_1_pins {
|
||||
uart_pins: uart_pins {
|
||||
mux {
|
||||
pins = "gpio69", "gpio71", "gpio72";
|
||||
function = "blsp1_spi";
|
||||
pins = "gpio44", "gpio45";
|
||||
function = "blsp2_uart";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
spi_cs {
|
||||
pins = "gpio70";
|
||||
function = "blsp1_spi";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
quartz_interrupt {
|
||||
pins = "gpio78";
|
||||
function = "gpio";
|
||||
input;
|
||||
bias-disable;
|
||||
};
|
||||
quartz_reset {
|
||||
pins = "gpio79";
|
||||
function = "gpio";
|
||||
output-low;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
sd_pins: sd-pinmux {
|
||||
pins = "gpio62";
|
||||
function = "sd_card";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
spi_0_pins: spi_0_pins {
|
||||
mux {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
qpic_pins: qpic_pins {
|
||||
data_0 {
|
||||
pins = "gpio15";
|
||||
function = "qpic_pad0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_1 {
|
||||
pins = "gpio12";
|
||||
function = "qpic_pad1";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_2 {
|
||||
pins = "gpio13";
|
||||
function = "qpic_pad2";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_3 {
|
||||
pins = "gpio14";
|
||||
function = "qpic_pad3";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_4 {
|
||||
pins = "gpio5";
|
||||
function = "qpic_pad4";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_5 {
|
||||
pins = "gpio6";
|
||||
function = "qpic_pad5";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_6 {
|
||||
pins = "gpio7";
|
||||
function = "qpic_pad6";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_7 {
|
||||
pins = "gpio8";
|
||||
function = "qpic_pad7";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
qpic_pad {
|
||||
pins = "gpio1", "gpio3", "gpio4",
|
||||
"gpio10", "gpio11", "gpio17";
|
||||
function = "qpic_pad";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
extcon_usb_pins: extcon_usb_pins {
|
||||
mux {
|
||||
pins = "gpio26";
|
||||
function = "gpio";
|
||||
drive-strength = <2>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
@@ -140,26 +201,6 @@
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_3 {
|
||||
pins = "gpio77";
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
pwm_pins: pwm_pinmux {
|
||||
pins = "gpio18";
|
||||
function = "pwm00";
|
||||
drive-strength = <8>;
|
||||
};
|
||||
|
||||
hsuart_pins: hsuart_pins {
|
||||
mux {
|
||||
pins = "gpio71", "gpio72", "gpio69", "gpio70";
|
||||
function = "blsp1_uart";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
leds_pins: leds_pins {
|
||||
@@ -182,42 +223,22 @@
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
btcoex_pins: btcoex_pins {
|
||||
mux_0 {
|
||||
pins = "gpio51";
|
||||
function = "pta1_1";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_1 {
|
||||
pins = "gpio53";
|
||||
function = "pta1_0";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_2 {
|
||||
pins = "gpio52";
|
||||
function = "pta1_2";
|
||||
drive-strength = <6>;
|
||||
uart2_pins: uart2_pins {
|
||||
mux {
|
||||
pins = "gpio57", "gpio58";
|
||||
function = "blsp4_uart";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&soc {
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
extcon_usb: extcon_usb {
|
||||
pinctrl-0 = <&extcon_usb_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
wps {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 19 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
id-gpio = <&tlmm 26 GPIO_ACTIVE_LOW>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
mdio: mdio@90000 {
|
||||
@@ -297,11 +318,18 @@
|
||||
};
|
||||
};
|
||||
|
||||
nss-macsec0 {
|
||||
compatible = "qcom,nss-macsec";
|
||||
phy_addr = <0x18>;
|
||||
phy_access_mode = <0>;
|
||||
mdiobus = <&mdio>;
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
wps {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 19 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
};
|
||||
|
||||
leds {
|
||||
@@ -321,56 +349,79 @@
|
||||
linux,default-trigger = "wf188:green:2g";
|
||||
default-state = "off";
|
||||
};
|
||||
led_power: led@16 {
|
||||
label = "green:led_pwr";
|
||||
gpios = <&tlmm 74 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
led_power: led@16 {
|
||||
label = "green:led_pwr";
|
||||
gpios = <&tlmm 74 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
default-state = "off";
|
||||
};
|
||||
led@61 {
|
||||
label = "green:lan1";
|
||||
gpios = <&tlmm 61 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
led@61 {
|
||||
label = "green:lan1";
|
||||
gpios = <&tlmm 61 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
default-state = "off";
|
||||
};
|
||||
led@62 {
|
||||
label = "green:wan";
|
||||
gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
led@62 {
|
||||
label = "green:wan";
|
||||
gpios = <&tlmm 62 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
default-state = "off";
|
||||
};
|
||||
led@63 {
|
||||
label = "green:lan2";
|
||||
gpios = <&tlmm 63 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
led@63 {
|
||||
label = "green:lan2";
|
||||
gpios = <&tlmm 63 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart3 {
|
||||
pinctrl-0 = <&uart_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&spi_0 {
|
||||
pinctrl-0 = <&spi_0_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&uart2_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
};
|
||||
&qpic_bam {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qpic_nand {
|
||||
status = "ok";
|
||||
|
||||
nand@0 {
|
||||
reg = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
nand-ecc-strength = <4>;
|
||||
nand-ecc-step-size = <512>;
|
||||
nand-bus-width = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
&pcie_phy {
|
||||
&nand {
|
||||
pinctrl-0 = <&qpic_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&pcie0 {
|
||||
&ssphy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qusb_phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
@@ -382,14 +433,6 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qusb_phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&ssphy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&usb3 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/dts-v1/;
|
||||
/*
|
||||
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -15,7 +14,7 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
|
||||
/ {
|
||||
@@ -37,47 +36,8 @@
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
bootargs-append = " swiotlb=1";
|
||||
#else
|
||||
bootargs-append = " swiotlb=1 coherent_pool=2M";
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* +=========+==============+========================+
|
||||
* | | | |
|
||||
* | Region | Start Offset | Size |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | Linux | 0x41000000 | 139MB |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | TZ App | 0x49B00000 | 6MB |
|
||||
* +--------+--------------+-------------------------+
|
||||
*
|
||||
* From the available 145 MB for Linux in the first 256 MB,
|
||||
* we are reserving 6 MB for TZAPP.
|
||||
*
|
||||
* Refer arch/arm64/boot/dts/qcom/qcom-ipq6018-memory.dtsi
|
||||
* for memory layout.
|
||||
*/
|
||||
|
||||
/* TZAPP is enabled only in default memory profile */
|
||||
#if !defined(__IPQ_MEM_PROFILE_256_MB__) && !defined(__IPQ_MEM_PROFILE_512_MB__)
|
||||
reserved-memory {
|
||||
tzapp:tzapp@49B00000 { /* TZAPPS */
|
||||
no-map;
|
||||
reg = <0x0 0x49B00000 0x0 0x00600000>;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
@@ -90,10 +50,59 @@
|
||||
};
|
||||
};
|
||||
|
||||
spi_0_pins: spi_0_pins {
|
||||
mux {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
qpic_pins: qpic_pins {
|
||||
data_0 {
|
||||
pins = "gpio15";
|
||||
function = "qpic_pad0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_1 {
|
||||
pins = "gpio12";
|
||||
function = "qpic_pad1";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_2 {
|
||||
pins = "gpio13";
|
||||
function = "qpic_pad2";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_3 {
|
||||
pins = "gpio14";
|
||||
function = "qpic_pad3";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_4 {
|
||||
pins = "gpio5";
|
||||
function = "qpic_pad4";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_5 {
|
||||
pins = "gpio6";
|
||||
function = "qpic_pad5";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_6 {
|
||||
pins = "gpio7";
|
||||
function = "qpic_pad6";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_7 {
|
||||
pins = "gpio8";
|
||||
function = "qpic_pad7";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
qpic_pad {
|
||||
pins = "gpio1", "gpio3", "gpio4",
|
||||
"gpio10", "gpio11", "gpio17";
|
||||
function = "qpic_pad";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
@@ -262,7 +271,7 @@
|
||||
switch {
|
||||
label = "switch";
|
||||
linux,code = <KEY_WPS_BUTTON>;
|
||||
gpios = <&tlmm 9 GPIO_ACTIVE_HIGH>;
|
||||
gpios = <&tlmm 9 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
@@ -286,18 +295,10 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qpic_nand {
|
||||
&nand {
|
||||
pinctrl-0 = <&qpic_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
|
||||
nand@0 {
|
||||
reg = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
nand-ecc-strength = <4>;
|
||||
nand-ecc-step-size = <512>;
|
||||
nand-bus-width = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
&ssphy_0 {
|
||||
@@ -318,13 +319,16 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&q6_region {
|
||||
reg = <0x0 0x4ab00000 0x0 0x05500000>;
|
||||
};
|
||||
|
||||
&CPU0 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1200000 1100000
|
||||
1608000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
@@ -335,7 +339,6 @@
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1200000 1100000
|
||||
1608000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
@@ -346,7 +349,6 @@
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1200000 1100000
|
||||
1608000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
@@ -357,7 +359,6 @@
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1200000 1100000
|
||||
1608000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
@@ -1,305 +0,0 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
|
||||
/*
|
||||
* IPQ6018 CP01 board device tree source
|
||||
*
|
||||
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
#include "ipq6018.dtsi"
|
||||
#include "ipq6018-cpr-regulator.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
|
||||
/ {
|
||||
aliases {
|
||||
serial0 = &blsp1_uart3;
|
||||
serial1 = &blsp1_uart2;
|
||||
/*
|
||||
* Aliases as required by u-boot
|
||||
* to patch MAC addresses
|
||||
*/
|
||||
ethernet0 = "/soc/dp1";
|
||||
ethernet1 = "/soc/dp2";
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs-append = " swiotlb=1";
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart3 {
|
||||
pinctrl-0 = <&serial_3_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&spi_0 {
|
||||
pinctrl-0 = <&spi_0_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&hsuart_pins &btcoex_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
spi_0_pins: spi-0-pins {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
mdio_pins: mdio_pinmux {
|
||||
mux_0 {
|
||||
pins = "gpio64";
|
||||
function = "mdc";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_1 {
|
||||
pins = "gpio65";
|
||||
function = "mdio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_2 {
|
||||
pins = "gpio75";
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_3 {
|
||||
pins = "gpio77";
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
hsuart_pins: hsuart_pins {
|
||||
mux {
|
||||
pins = "gpio71", "gpio72", "gpio69", "gpio70";
|
||||
function = "blsp1_uart";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
reset_button {
|
||||
pins = "gpio53";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
leds_pins: leds_pins {
|
||||
led_5g {
|
||||
pins = "gpio60";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_2g {
|
||||
pins = "gpio61";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
mdio_pins: mdio_pinmux {
|
||||
mux_0 {
|
||||
pins = "gpio64";
|
||||
function = "mdc";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_1 {
|
||||
pins = "gpio65";
|
||||
function = "mdio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_2 {
|
||||
pins = "gpio75";
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_3 {
|
||||
pins = "gpio77";
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
btcoex_pins: btcoex_pins {
|
||||
mux_0 {
|
||||
pins = "gpio51";
|
||||
function = "pta1_1";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_1 {
|
||||
pins = "gpio53";
|
||||
function = "pta1_0";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_2 {
|
||||
pins = "gpio52";
|
||||
function = "pta1_2";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&soc {
|
||||
mdio: mdio@90000 {
|
||||
pinctrl-0 = <&mdio_pins>;
|
||||
pinctrl-names = "default";
|
||||
phy-reset-gpio = <&tlmm 77 0>;
|
||||
status = "ok";
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <4>;
|
||||
};
|
||||
phy1: ethernet-phy@1 {
|
||||
reg = <30>;
|
||||
};
|
||||
};
|
||||
|
||||
dp1 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,nss-dp";
|
||||
qcom,id = <4>;
|
||||
reg = <0x3a001600 0x200>;
|
||||
qcom,mactype = <0>;
|
||||
local-mac-address = [000000000000];
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <4>;
|
||||
phy-mode = "sgmii";
|
||||
};
|
||||
|
||||
dp2 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,nss-dp";
|
||||
qcom,id = <5>;
|
||||
reg = <0x3a003000 0x3fff>;
|
||||
qcom,mactype = <1>;
|
||||
local-mac-address = [000000000000];
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <30>;
|
||||
phy-mode = "sgmii";
|
||||
};
|
||||
|
||||
ess-switch@3a000000 {
|
||||
switch_cpu_bmp = <0x1>; /* cpu port bitmap */
|
||||
switch_lan_bmp = <0x10>; /* lan port bitmap */
|
||||
switch_wan_bmp = <0x20>; /* wan port bitmap */
|
||||
switch_inner_bmp = <0xc0>; /*inner port bitmap*/
|
||||
switch_mac_mode = <0xf>; /* mac mode for uniphy instance0*/
|
||||
switch_mac_mode1 = <0x14>; /* mac mode for uniphy instance1*/
|
||||
switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/
|
||||
qcom,port_phyinfo {
|
||||
port@4 {
|
||||
port_id = <4>;
|
||||
phy_address = <4>;
|
||||
};
|
||||
port@5 {
|
||||
port_id = <5>;
|
||||
phy_address = <30>;
|
||||
port_mac_sel = "QGMAC_PORT";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nss-macsec0 {
|
||||
compatible = "qcom,nss-macsec";
|
||||
phy_addr = <30>;
|
||||
phy_access_mode = <0>;
|
||||
mdiobus = <&mdio>;
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
reset {
|
||||
label = "reset";
|
||||
linux,code = <KEY_RESTART>;
|
||||
gpios = <&tlmm 53 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
pinctrl-0 = <&leds_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
led@60 {
|
||||
label = "blue:wifi5";
|
||||
gpios = <&tlmm 60 GPIO_ACTIVE_LOW>;
|
||||
linux,default-trigger = "led_5g";
|
||||
default-state = "off";
|
||||
};
|
||||
led@61 {
|
||||
label = "blue:wifi2";
|
||||
gpios = <&tlmm 61 GPIO_ACTIVE_LOW>;
|
||||
linux,default-trigger = "led_2g";
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&qpic_bam {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qpic_nand {
|
||||
status = "ok";
|
||||
|
||||
nand@0 {
|
||||
reg = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
nand-ecc-strength = <4>;
|
||||
nand-ecc-step-size = <512>;
|
||||
nand-bus-width = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
&pcie_phy {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&pcie0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&nss_crypto {
|
||||
status = "ok";
|
||||
};
|
||||
@@ -1,28 +1,49 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
|
||||
/dts-v1/;
|
||||
/*
|
||||
* IPQ6018 CP01 board device tree source
|
||||
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
#include "qcom-ipq6018-rpm-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cp-cpu.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
model = "Wallys DR6018";
|
||||
compatible = "wallys,dr6018", "qcom,ipq6018-cp01", "qcom,ipq6018";
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
model = "Wallys DR6018 V4";
|
||||
compatible = "wallys,dr6018-v4", "qcom,ipq6018-cp01", "qcom,ipq6018";
|
||||
interrupt-parent = <&intc>;
|
||||
|
||||
aliases {
|
||||
serial0 = &blsp1_uart3;
|
||||
serial1 = &blsp1_uart2;
|
||||
|
||||
/*
|
||||
* Aliases as required by u-boot
|
||||
* to patch MAC addresses
|
||||
*/
|
||||
ethernet0 = "/soc/dp1";
|
||||
ethernet1 = "/soc/dp2";
|
||||
ethernet2 = "/soc/dp3";
|
||||
ethernet3 = "/soc/dp4";
|
||||
ethernet4 = "/soc/dp5";
|
||||
|
||||
sdhc2 = "/soc/sdhci_sd@7804000";
|
||||
|
||||
led-boot = &led_power;
|
||||
led-failsafe = &led_power;
|
||||
@@ -31,97 +52,148 @@
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs-append = " swiotlb=1";
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
bootargs-append = " console=ttyMSM0,115200,n8 swiotlb=1 coherent_pool=2M";
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart3 {
|
||||
pinctrl-0 = <&serial_3_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
/*
|
||||
* +=========+==============+========================+
|
||||
* | | | |
|
||||
* | Region | Start Offset | Size |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | Linux | 0x41000000 | 139MB |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | TZ App | 0x49B00000 | 6MB |
|
||||
* +--------+--------------+-------------------------+
|
||||
*
|
||||
* From the available 145 MB for Linux in the first 256 MB,
|
||||
* we are reserving 6 MB for TZAPP.
|
||||
*
|
||||
* Refer arch/arm64/boot/dts/qcom/qcom-ipq6018-memory.dtsi
|
||||
* for memory layout.
|
||||
*/
|
||||
|
||||
&spi_0 {
|
||||
pinctrl-0 = <&spi_0_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&hsuart_pins &btcoex_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&spi_1 { /* BLSP1 QUP1 */
|
||||
pinctrl-0 = <&spi_1_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
quartz-reset-gpio = <&tlmm 79 1>;
|
||||
status = "disabled";
|
||||
spidev1: spi@1 {
|
||||
compatible = "qca,spidev";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <24000000>;
|
||||
/* TZAPP is enabled only in default memory profile */
|
||||
#if !defined(__IPQ_MEM_PROFILE_256_MB__) && !defined(__IPQ_MEM_PROFILE_512_MB__)
|
||||
reserved-memory {
|
||||
tzapp:tzapp@49B00000 { /* TZAPPS */
|
||||
no-map;
|
||||
reg = <0x0 0x49B00000 0x0 0x00600000>;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
spi_0_pins: spi-0-pins {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
spi_1_pins: spi_1_pins {
|
||||
uart_pins: uart_pins {
|
||||
mux {
|
||||
pins = "gpio69", "gpio71", "gpio72";
|
||||
function = "blsp1_spi";
|
||||
pins = "gpio44", "gpio45";
|
||||
function = "blsp2_uart";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
spi_cs {
|
||||
pins = "gpio70";
|
||||
function = "blsp1_spi";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
quartz_interrupt {
|
||||
pins = "gpio78";
|
||||
function = "gpio";
|
||||
input;
|
||||
bias-disable;
|
||||
};
|
||||
quartz_reset {
|
||||
pins = "gpio79";
|
||||
function = "gpio";
|
||||
output-low;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
sd_pins: sd-pinmux {
|
||||
pins = "gpio62";
|
||||
function = "sd_card";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
sd_pins: sd_pins {
|
||||
mux {
|
||||
pins = "gpio62";
|
||||
function = "sd_card";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
spi_0_pins: spi_0_pins {
|
||||
mux {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
qpic_pins: qpic_pins {
|
||||
data_0 {
|
||||
pins = "gpio15";
|
||||
function = "qpic_pad0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_1 {
|
||||
pins = "gpio12";
|
||||
function = "qpic_pad1";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_2 {
|
||||
pins = "gpio13";
|
||||
function = "qpic_pad2";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_3 {
|
||||
pins = "gpio14";
|
||||
function = "qpic_pad3";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_4 {
|
||||
pins = "gpio5";
|
||||
function = "qpic_pad4";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_5 {
|
||||
pins = "gpio6";
|
||||
function = "qpic_pad5";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_6 {
|
||||
pins = "gpio7";
|
||||
function = "qpic_pad6";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_7 {
|
||||
pins = "gpio8";
|
||||
function = "qpic_pad7";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
qpic_pad {
|
||||
pins = "gpio1", "gpio3", "gpio4",
|
||||
"gpio10", "gpio11", "gpio17";
|
||||
function = "qpic_pad";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
extcon_usb_pins: extcon_usb_pins {
|
||||
mux {
|
||||
pins = "gpio26";
|
||||
function = "gpio";
|
||||
drive-strength = <2>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio19";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
mdio_pins: mdio_pinmux {
|
||||
@@ -142,101 +214,70 @@
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_3 {
|
||||
pins = "gpio77";
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
pwm_pins: pwm_pinmux {
|
||||
pins = "gpio18";
|
||||
function = "pwm00";
|
||||
drive-strength = <8>;
|
||||
};
|
||||
|
||||
hsuart_pins: hsuart_pins {
|
||||
mux {
|
||||
pins = "gpio71", "gpio72", "gpio69", "gpio70";
|
||||
function = "blsp1_uart";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio19";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
leds_pins: leds_pins {
|
||||
led_pwr {
|
||||
pins = "gpio74";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_5g {
|
||||
pins = "gpio35";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_2g {
|
||||
pins = "gpio37";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
pins = "gpio74";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_5g {
|
||||
pins = "gpio35";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_2g {
|
||||
pins = "gpio37";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
btcoex_pins: btcoex_pins {
|
||||
mux_0 {
|
||||
pins = "gpio51";
|
||||
function = "pta1_1";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_1 {
|
||||
pins = "gpio53";
|
||||
function = "pta1_0";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_2 {
|
||||
pins = "gpio52";
|
||||
function = "pta1_2";
|
||||
drive-strength = <6>;
|
||||
uart2_pins: uart2_pins {
|
||||
mux {
|
||||
pins = "gpio57", "gpio58";
|
||||
function = "blsp4_uart";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&soc {
|
||||
extcon_usb: extcon_usb {
|
||||
pinctrl-0 = <&extcon_usb_pins>;
|
||||
pinctrl-names = "default";
|
||||
id-gpio = <&tlmm 26 GPIO_ACTIVE_LOW>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
mdio: mdio@90000 {
|
||||
pinctrl-0 = <&mdio_pins>;
|
||||
pinctrl-names = "default";
|
||||
phy-reset-gpio = <&tlmm 75 0 &tlmm 77 1>;
|
||||
status = "ok";
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
ethernet-phy@3 {
|
||||
reg = <0x03>;
|
||||
};
|
||||
phy1: ethernet-phy@1 {
|
||||
reg = <1>;
|
||||
};
|
||||
phy2: ethernet-phy@2 {
|
||||
reg = <2>;
|
||||
};
|
||||
phy3: ethernet-phy@3 {
|
||||
reg = <3>;
|
||||
};
|
||||
phy4: ethernet-phy@4 {
|
||||
|
||||
ethernet-phy@4 {
|
||||
reg = <0x18>;
|
||||
};
|
||||
|
||||
ethernet-phy@1 {
|
||||
reg = <0x01>;
|
||||
};
|
||||
|
||||
ethernet-phy@2 {
|
||||
reg = <0x02>;
|
||||
};
|
||||
|
||||
ethernet-phy@0 {
|
||||
reg = <0x00>;
|
||||
};
|
||||
};
|
||||
|
||||
dp1 {
|
||||
@@ -263,51 +304,79 @@
|
||||
phy-mode = "sgmii";
|
||||
};
|
||||
|
||||
dp3 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,nss-dp";
|
||||
qcom,id = <3>;
|
||||
reg = <0x3a001400 0x200>;
|
||||
qcom,mactype = <0>;
|
||||
local-mac-address = [000000000000];
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <2>;
|
||||
phy-mode = "sgmii";
|
||||
};
|
||||
|
||||
dp4 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,nss-dp";
|
||||
qcom,id = <4>;
|
||||
reg = <0x3a001600 0x200>;
|
||||
qcom,mactype = <0>;
|
||||
local-mac-address = [000000000000];
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <3>;
|
||||
phy-mode = "sgmii";
|
||||
};
|
||||
|
||||
dp5 {
|
||||
device_type = "network";
|
||||
compatible = "qcom,nss-dp";
|
||||
qcom,id = <5>;
|
||||
reg = <0x3a001800 0x200>;
|
||||
qcom,mactype = <0>;
|
||||
local-mac-address = [000000000000];
|
||||
qcom,link-poll = <1>;
|
||||
qcom,phy-mdio-addr = <0x18>;
|
||||
phy-mode = "sgmii";
|
||||
};
|
||||
|
||||
ess-switch@3a000000 {
|
||||
switch_cpu_bmp = <0x1>; /* cpu port bitmap */
|
||||
switch_lan_bmp = <0x4>; /* lan port bitmap */
|
||||
switch_lan_bmp = <0x3c>; /* lan port bitmap */
|
||||
switch_wan_bmp = <0x2>; /* wan port bitmap */
|
||||
switch_inner_bmp = <0xc0>; /*inner port bitmap*/
|
||||
switch_mac_mode = <0x0>; /* mac mode for uniphy instance0*/
|
||||
switch_mac_mode1 = <0xf>; /* mac mode for uniphy instance1*/
|
||||
switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/
|
||||
qcom,port_phyinfo {
|
||||
port@0 {
|
||||
port_id = <1>;
|
||||
phy_address = <0>;
|
||||
};
|
||||
port@1 {
|
||||
port_id = <2>;
|
||||
phy_address = <1>;
|
||||
phy_address = <0x01>;
|
||||
port_id = <0x02>;
|
||||
};
|
||||
|
||||
port@0 {
|
||||
phy_address = <0x00>;
|
||||
port_id = <0x01>;
|
||||
};
|
||||
|
||||
port@2 {
|
||||
port_id = <3>;
|
||||
phy_address = <2>;
|
||||
phy_address = <0x02>;
|
||||
port_id = <0x03>;
|
||||
};
|
||||
|
||||
port@3 {
|
||||
port_id = <4>;
|
||||
phy_address = <3>;
|
||||
phy_address = <0x03>;
|
||||
port_id = <0x04>;
|
||||
};
|
||||
|
||||
port@4 {
|
||||
port_id = <5>;
|
||||
phy_address = <0x18>;
|
||||
port_id = <0x05>;
|
||||
port_mac_sel = "QGMAC_PORT";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nss-macsec0 {
|
||||
compatible = "qcom,nss-macsec";
|
||||
phy_addr = <0x18>;
|
||||
phy_access_mode = <0>;
|
||||
mdiobus = <&mdio>;
|
||||
};
|
||||
|
||||
pwm {
|
||||
pinctrl-0 = <&pwm_pins>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
@@ -339,38 +408,61 @@
|
||||
linux,default-trigger = "green:2g";
|
||||
default-state = "off";
|
||||
};
|
||||
led_power: led@16 {
|
||||
label = "green:led_pwr";
|
||||
gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
led_power: led@16 {
|
||||
label = "green:led_pwr";
|
||||
gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart3 {
|
||||
pinctrl-0 = <&uart_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&spi_0 {
|
||||
pinctrl-0 = <&spi_0_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&uart2_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
};
|
||||
&qpic_bam {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qpic_nand {
|
||||
status = "ok";
|
||||
|
||||
nand@0 {
|
||||
reg = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
nand-ecc-strength = <4>;
|
||||
nand-ecc-step-size = <512>;
|
||||
nand-bus-width = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
&pcie_phy {
|
||||
&nand {
|
||||
pinctrl-0 = <&qpic_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&pcie0 {
|
||||
&ssphy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qusb_phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
@@ -382,21 +474,6 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&sdhc_2 {
|
||||
pinctrl-0 = <&sd_pins>;
|
||||
pinctrl-names = "default";
|
||||
cd-gpios = <&tlmm 62 GPIO_ACTIVE_LOW>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qusb_phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&ssphy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&usb3 {
|
||||
status = "ok";
|
||||
};
|
||||
@@ -405,77 +482,11 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&CPU0 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&CPU1 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&CPU2 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&CPU3 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
gpio-reserved-ranges = <20 1>;
|
||||
|
||||
i2c_1_pins: i2c_1_pins {
|
||||
mux {
|
||||
pins = "gpio42", "gpio43";
|
||||
function = "blsp2_i2c";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&i2c_1 {
|
||||
pinctrl-0 = <&i2c_1_pins>;
|
||||
&sdhc_2 {
|
||||
pinctrl-0 = <&sd_pins>;
|
||||
pinctrl-names = "default";
|
||||
cd-gpios = <&tlmm 62 1>;
|
||||
sd-ldo-gpios = <&tlmm 66 0>;
|
||||
//vqmmc-supply = <&ipq6018_l2_corner>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&rpm_glink {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
@@ -1,22 +1,38 @@
|
||||
// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
|
||||
/dts-v1/;
|
||||
/*
|
||||
* IPQ6018 CP01 board device tree source
|
||||
* Copyright (c) 2019, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2019-2021 The Linux Foundation. All rights reserved.
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
#include "ipq6018.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
#include "qcom-ipq6018-rpm-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cp-cpu.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
model = "Wallys DR6018";
|
||||
compatible = "wallys,dr6018", "qcom,ipq6018-cp01", "qcom,ipq6018";
|
||||
interrupt-parent = <&intc>;
|
||||
|
||||
aliases {
|
||||
serial0 = &blsp1_uart3;
|
||||
serial1 = &blsp1_uart2;
|
||||
|
||||
/*
|
||||
* Aliases as required by u-boot
|
||||
* to patch MAC addresses
|
||||
@@ -31,97 +47,139 @@
|
||||
};
|
||||
|
||||
chosen {
|
||||
stdout-path = "serial0:115200n8";
|
||||
bootargs-append = " swiotlb=1";
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
bootargs-append = " console=ttyMSM0,115200,n8 swiotlb=1 coherent_pool=2M";
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart3 {
|
||||
pinctrl-0 = <&serial_3_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
/*
|
||||
* +=========+==============+========================+
|
||||
* | | | |
|
||||
* | Region | Start Offset | Size |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | Linux | 0x41000000 | 139MB |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | TZ App | 0x49B00000 | 6MB |
|
||||
* +--------+--------------+-------------------------+
|
||||
*
|
||||
* From the available 145 MB for Linux in the first 256 MB,
|
||||
* we are reserving 6 MB for TZAPP.
|
||||
*
|
||||
* Refer arch/arm64/boot/dts/qcom/qcom-ipq6018-memory.dtsi
|
||||
* for memory layout.
|
||||
*/
|
||||
|
||||
&spi_0 {
|
||||
pinctrl-0 = <&spi_0_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&hsuart_pins &btcoex_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&spi_1 { /* BLSP1 QUP1 */
|
||||
pinctrl-0 = <&spi_1_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
quartz-reset-gpio = <&tlmm 79 1>;
|
||||
status = "disabled";
|
||||
spidev1: spi@1 {
|
||||
compatible = "qca,spidev";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <24000000>;
|
||||
/* TZAPP is enabled only in default memory profile */
|
||||
#if !defined(__IPQ_MEM_PROFILE_256_MB__) && !defined(__IPQ_MEM_PROFILE_512_MB__)
|
||||
reserved-memory {
|
||||
tzapp:tzapp@49B00000 { /* TZAPPS */
|
||||
no-map;
|
||||
reg = <0x0 0x49B00000 0x0 0x00600000>;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
spi_0_pins: spi-0-pins {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
spi_1_pins: spi_1_pins {
|
||||
uart_pins: uart_pins {
|
||||
mux {
|
||||
pins = "gpio69", "gpio71", "gpio72";
|
||||
function = "blsp1_spi";
|
||||
pins = "gpio44", "gpio45";
|
||||
function = "blsp2_uart";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
spi_cs {
|
||||
pins = "gpio70";
|
||||
function = "blsp1_spi";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
quartz_interrupt {
|
||||
pins = "gpio78";
|
||||
function = "gpio";
|
||||
input;
|
||||
bias-disable;
|
||||
};
|
||||
quartz_reset {
|
||||
pins = "gpio79";
|
||||
function = "gpio";
|
||||
output-low;
|
||||
bias-disable;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
sd_pins: sd-pinmux {
|
||||
pins = "gpio62";
|
||||
function = "sd_card";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
spi_0_pins: spi_0_pins {
|
||||
mux {
|
||||
pins = "gpio38", "gpio39", "gpio40", "gpio41";
|
||||
function = "blsp0_spi";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
qpic_pins: qpic_pins {
|
||||
data_0 {
|
||||
pins = "gpio15";
|
||||
function = "qpic_pad0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_1 {
|
||||
pins = "gpio12";
|
||||
function = "qpic_pad1";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_2 {
|
||||
pins = "gpio13";
|
||||
function = "qpic_pad2";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_3 {
|
||||
pins = "gpio14";
|
||||
function = "qpic_pad3";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_4 {
|
||||
pins = "gpio5";
|
||||
function = "qpic_pad4";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_5 {
|
||||
pins = "gpio6";
|
||||
function = "qpic_pad5";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_6 {
|
||||
pins = "gpio7";
|
||||
function = "qpic_pad6";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
data_7 {
|
||||
pins = "gpio8";
|
||||
function = "qpic_pad7";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
qpic_pad {
|
||||
pins = "gpio1", "gpio3", "gpio4",
|
||||
"gpio10", "gpio11", "gpio17";
|
||||
function = "qpic_pad";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
extcon_usb_pins: extcon_usb_pins {
|
||||
mux {
|
||||
pins = "gpio26";
|
||||
function = "gpio";
|
||||
drive-strength = <2>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio19";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
mdio_pins: mdio_pinmux {
|
||||
@@ -142,101 +200,70 @@
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
mux_3 {
|
||||
pins = "gpio77";
|
||||
function = "gpio";
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
pwm_pins: pwm_pinmux {
|
||||
pins = "gpio18";
|
||||
function = "pwm00";
|
||||
drive-strength = <8>;
|
||||
};
|
||||
|
||||
hsuart_pins: hsuart_pins {
|
||||
mux {
|
||||
pins = "gpio71", "gpio72", "gpio69", "gpio70";
|
||||
function = "blsp1_uart";
|
||||
drive-strength = <8>;
|
||||
bias-disable;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio19";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
leds_pins: leds_pins {
|
||||
led_pwr {
|
||||
pins = "gpio74";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_5g {
|
||||
pins = "gpio35";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_2g {
|
||||
pins = "gpio37";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
pins = "gpio74";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_5g {
|
||||
pins = "gpio35";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
led_2g {
|
||||
pins = "gpio37";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
btcoex_pins: btcoex_pins {
|
||||
mux_0 {
|
||||
pins = "gpio51";
|
||||
function = "pta1_1";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_1 {
|
||||
pins = "gpio53";
|
||||
function = "pta1_0";
|
||||
drive-strength = <6>;
|
||||
bias-pull-down;
|
||||
};
|
||||
mux_2 {
|
||||
pins = "gpio52";
|
||||
function = "pta1_2";
|
||||
drive-strength = <6>;
|
||||
uart2_pins: uart2_pins {
|
||||
mux {
|
||||
pins = "gpio57", "gpio58";
|
||||
function = "blsp4_uart";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&soc {
|
||||
extcon_usb: extcon_usb {
|
||||
pinctrl-0 = <&extcon_usb_pins>;
|
||||
pinctrl-names = "default";
|
||||
id-gpio = <&tlmm 26 GPIO_ACTIVE_LOW>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
mdio: mdio@90000 {
|
||||
pinctrl-0 = <&mdio_pins>;
|
||||
pinctrl-names = "default";
|
||||
phy-reset-gpio = <&tlmm 75 0 &tlmm 77 1>;
|
||||
status = "ok";
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <0>;
|
||||
ethernet-phy@3 {
|
||||
reg = <0x03>;
|
||||
};
|
||||
phy1: ethernet-phy@1 {
|
||||
reg = <1>;
|
||||
};
|
||||
phy2: ethernet-phy@2 {
|
||||
reg = <2>;
|
||||
};
|
||||
phy3: ethernet-phy@3 {
|
||||
reg = <3>;
|
||||
};
|
||||
phy4: ethernet-phy@4 {
|
||||
|
||||
ethernet-phy@4 {
|
||||
reg = <0x18>;
|
||||
};
|
||||
|
||||
ethernet-phy@1 {
|
||||
reg = <0x01>;
|
||||
};
|
||||
|
||||
ethernet-phy@2 {
|
||||
reg = <0x02>;
|
||||
};
|
||||
|
||||
ethernet-phy@0 {
|
||||
reg = <0x00>;
|
||||
};
|
||||
};
|
||||
|
||||
dp1 {
|
||||
@@ -272,42 +299,34 @@
|
||||
switch_mac_mode1 = <0xf>; /* mac mode for uniphy instance1*/
|
||||
switch_mac_mode2 = <0xff>; /* mac mode for uniphy instance2*/
|
||||
qcom,port_phyinfo {
|
||||
port@0 {
|
||||
port_id = <1>;
|
||||
phy_address = <0>;
|
||||
};
|
||||
port@1 {
|
||||
port_id = <2>;
|
||||
phy_address = <1>;
|
||||
phy_address = <0x01>;
|
||||
port_id = <0x02>;
|
||||
};
|
||||
|
||||
port@0 {
|
||||
phy_address = <0x00>;
|
||||
port_id = <0x01>;
|
||||
};
|
||||
|
||||
port@2 {
|
||||
port_id = <3>;
|
||||
phy_address = <2>;
|
||||
phy_address = <0x02>;
|
||||
port_id = <0x03>;
|
||||
};
|
||||
|
||||
port@3 {
|
||||
port_id = <4>;
|
||||
phy_address = <3>;
|
||||
phy_address = <0x03>;
|
||||
port_id = <0x04>;
|
||||
};
|
||||
|
||||
port@4 {
|
||||
port_id = <5>;
|
||||
phy_address = <0x18>;
|
||||
port_id = <0x05>;
|
||||
port_mac_sel = "QGMAC_PORT";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nss-macsec0 {
|
||||
compatible = "qcom,nss-macsec";
|
||||
phy_addr = <0x18>;
|
||||
phy_access_mode = <0>;
|
||||
mdiobus = <&mdio>;
|
||||
};
|
||||
|
||||
pwm {
|
||||
pinctrl-0 = <&pwm_pins>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
|
||||
gpio_keys {
|
||||
compatible = "gpio-keys";
|
||||
pinctrl-0 = <&button_pins>;
|
||||
@@ -320,6 +339,14 @@
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};
|
||||
|
||||
/* wps {
|
||||
label = "wps";
|
||||
linux,code = <>;
|
||||
gpios = <&tlmm 9 GPIO_ACTIVE_LOW>;
|
||||
linux,input-type = <1>;
|
||||
debounce-interval = <60>;
|
||||
};*/
|
||||
};
|
||||
|
||||
leds {
|
||||
@@ -339,38 +366,61 @@
|
||||
linux,default-trigger = "green:2g";
|
||||
default-state = "off";
|
||||
};
|
||||
led_power: led@16 {
|
||||
label = "green:led_pwr";
|
||||
gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
led_power: led@16 {
|
||||
label = "green:led_pwr";
|
||||
gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>;
|
||||
linux,default-trigger = "green:power";
|
||||
default-state = "off";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart3 {
|
||||
pinctrl-0 = <&uart_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&spi_0 {
|
||||
pinctrl-0 = <&spi_0_pins>;
|
||||
pinctrl-names = "default";
|
||||
cs-select = <0>;
|
||||
status = "ok";
|
||||
|
||||
m25p80@0 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
reg = <0>;
|
||||
compatible = "n25q128a11";
|
||||
linux,modalias = "m25p80", "n25q128a11";
|
||||
spi-max-frequency = <50000000>;
|
||||
use-default-sizes;
|
||||
};
|
||||
};
|
||||
|
||||
&blsp1_uart2 {
|
||||
pinctrl-0 = <&uart2_pins>;
|
||||
pinctrl-names = "default";
|
||||
dmas = <&blsp_dma 2>,
|
||||
<&blsp_dma 3>;
|
||||
dma-names = "tx", "rx";
|
||||
status = "ok";
|
||||
};
|
||||
&qpic_bam {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qpic_nand {
|
||||
status = "ok";
|
||||
|
||||
nand@0 {
|
||||
reg = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
nand-ecc-strength = <4>;
|
||||
nand-ecc-step-size = <512>;
|
||||
nand-bus-width = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
&pcie_phy {
|
||||
&nand {
|
||||
pinctrl-0 = <&qpic_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&pcie0 {
|
||||
&ssphy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qusb_phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
@@ -382,14 +432,6 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qusb_phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&ssphy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&usb3 {
|
||||
status = "ok";
|
||||
};
|
||||
@@ -397,78 +439,3 @@
|
||||
&nss_crypto {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&CPU0 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&CPU1 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&CPU2 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&CPU3 {
|
||||
operating-points = <
|
||||
/* kHz uV (fixed) */
|
||||
864000 1100000
|
||||
1056000 1100000
|
||||
1320000 1100000
|
||||
1440000 1100000
|
||||
1608000 1100000
|
||||
1800000 1100000
|
||||
>;
|
||||
clock-latency = <200000>;
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
gpio-reserved-ranges = <20 1>;
|
||||
|
||||
i2c_1_pins: i2c_1_pins {
|
||||
mux {
|
||||
pins = "gpio42", "gpio43";
|
||||
function = "blsp2_i2c";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&i2c_1 {
|
||||
pinctrl-0 = <&i2c_1_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&rpm_glink {
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
@@ -1,39 +1,29 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
|
||||
/dts-v1/;
|
||||
/*
|
||||
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "ipq6018.dtsi"
|
||||
#include "ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018.dtsi"
|
||||
#include "qcom-ipq6018-rpm-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cpr-regulator.dtsi"
|
||||
#include "qcom-ipq6018-cp-cpu.dtsi"
|
||||
#include <dt-bindings/input/input.h>
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
|
||||
/ {
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
model = "YunCore AX840";
|
||||
compatible = "yuncore,ax840", "qcom,ipq6018-cp03", "qcom,ipq6018";
|
||||
|
||||
#address-cells = <0x2>;
|
||||
#size-cells = <0x2>;
|
||||
interrupt-parent = <&intc>;
|
||||
qcom,msm-id = <0x1A5 0x0>;
|
||||
|
||||
aliases {
|
||||
/*
|
||||
* Aliases as required by u-boot
|
||||
* to patch MAC addresses
|
||||
*/
|
||||
/* Aliases as required by u-boot to patch MAC addresses */
|
||||
ethernet0 = "/soc/dp2";
|
||||
ethernet1 = "/soc/dp1";
|
||||
|
||||
serial0 = &blsp1_uart3;
|
||||
serial1 = &blsp1_uart2;
|
||||
|
||||
led-boot = &led_system;
|
||||
led-failsafe = &led_system;
|
||||
led-running = &led_system;
|
||||
@@ -42,47 +32,15 @@
|
||||
|
||||
chosen {
|
||||
bootargs = "console=ttyMSM0,115200,n8 rw init=/init";
|
||||
#ifdef __IPQ_MEM_PROFILE_256_MB__
|
||||
bootargs-append = " swiotlb=1";
|
||||
#else
|
||||
bootargs-append = " swiotlb=1 coherent_pool=2M";
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* +=========+==============+========================+
|
||||
* | | | |
|
||||
* | Region | Start Offset | Size |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | Linux | 0x41000000 | 139MB |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* | | | |
|
||||
* +--------+--------------+-------------------------+
|
||||
* | TZ App | 0x49B00000 | 6MB |
|
||||
* +--------+--------------+-------------------------+
|
||||
*
|
||||
* From the available 145 MB for Linux in the first 256 MB,
|
||||
* we are reserving 6 MB for TZAPP.
|
||||
*
|
||||
* Refer arch/arm64/boot/dts/qcom/qcom-ipq6018-memory.dtsi
|
||||
* for memory layout.
|
||||
*/
|
||||
|
||||
/* TZAPP is enabled only in default memory profile */
|
||||
#if !defined(__IPQ_MEM_PROFILE_256_MB__) && !defined(__IPQ_MEM_PROFILE_512_MB__)
|
||||
reserved-memory {
|
||||
tzapp:tzapp@49B00000 { /* TZAPPS */
|
||||
no-map;
|
||||
reg = <0x0 0x49B00000 0x0 0x00600000>;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
};
|
||||
|
||||
&tlmm {
|
||||
@@ -104,13 +62,79 @@
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
wps_button {
|
||||
pins = "gpio9";
|
||||
function = "gpio";
|
||||
qpic_pins: qpic_pins {
|
||||
data_0 {
|
||||
pins = "gpio15";
|
||||
function = "qpic_pad0";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
data_1 {
|
||||
pins = "gpio12";
|
||||
function = "qpic_pad1";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
data_2 {
|
||||
pins = "gpio13";
|
||||
function = "qpic_pad2";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
data_3 {
|
||||
pins = "gpio14";
|
||||
function = "qpic_pad3";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
data_4 {
|
||||
pins = "gpio5";
|
||||
function = "qpic_pad4";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
data_5 {
|
||||
pins = "gpio6";
|
||||
function = "qpic_pad5";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
data_6 {
|
||||
pins = "gpio7";
|
||||
function = "qpic_pad6";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
data_7 {
|
||||
pins = "gpio8";
|
||||
function = "qpic_pad7";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
|
||||
qpic_pad {
|
||||
pins = "gpio1", "gpio3", "gpio4",
|
||||
"gpio10", "gpio11", "gpio17";
|
||||
function = "qpic_pad";
|
||||
drive-strength = <8>;
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
rst_button {
|
||||
pins = "gpio19";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
|
||||
mdio_pins: mdio_pinmux {
|
||||
@@ -120,12 +144,14 @@
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
mux_1 {
|
||||
pins = "gpio65";
|
||||
function = "mdio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
mux_2 {
|
||||
pins = "gpio75";
|
||||
function = "gpio";
|
||||
@@ -155,28 +181,22 @@
|
||||
bias-pull-down;
|
||||
};
|
||||
};
|
||||
|
||||
button_pins: button_pins {
|
||||
rst_button {
|
||||
pins = "gpio19";
|
||||
function = "gpio";
|
||||
drive-strength = <8>;
|
||||
bias-pull-up;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&soc {
|
||||
mdio@90000 {
|
||||
mdio: mdio@90000 {
|
||||
status = "ok";
|
||||
|
||||
pinctrl-0 = <&mdio_pins>;
|
||||
pinctrl-names = "default";
|
||||
phy-reset-gpio = <&tlmm 75 0>;
|
||||
status = "ok";
|
||||
phy0: ethernet-phy@0 {
|
||||
reg = <3>;
|
||||
|
||||
ethernet-phy@0 {
|
||||
reg = <0x03>;
|
||||
};
|
||||
phy1: ethernet-phy@1 {
|
||||
reg = <4>;
|
||||
|
||||
ethernet-phy@1 {
|
||||
reg = <0x04>;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -243,6 +263,7 @@
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
|
||||
pinctrl-0 = <&leds_pins>;
|
||||
pinctrl-names = "default";
|
||||
|
||||
@@ -290,32 +311,33 @@
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qpic_nand {
|
||||
status = "ok";
|
||||
|
||||
nand@0 {
|
||||
reg = <0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
nand-ecc-strength = <4>;
|
||||
nand-ecc-step-size = <512>;
|
||||
nand-bus-width = <8>;
|
||||
};
|
||||
};
|
||||
|
||||
&ssphy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&qusb_phy_0 {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&usb3 {
|
||||
&nand {
|
||||
pinctrl-0 = <&qpic_pins>;
|
||||
pinctrl-names = "default";
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&nss_crypto {
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
&cpu0_opp_table {
|
||||
compatible = "operating-points-v2";
|
||||
opp-shared;
|
||||
|
||||
opp03 {
|
||||
opp-hz = /bits/ 64 <1200000000>;
|
||||
opp-microvolt = <3>;
|
||||
clock-latency-ns = <200000>;
|
||||
};
|
||||
|
||||
/delete-node/ opp04;
|
||||
/delete-node/ opp05;
|
||||
/delete-node/ opp06;
|
||||
};
|
||||
|
||||
&qseecom {
|
||||
mem-start = <0x49B00000>;
|
||||
mem-size = <0x600000>;
|
||||
status = "ok";
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,7 @@ define Device/qcom_mp03_1
|
||||
DEVICE_PACKAGES := ath11k-wifi-qcom-ipq5018
|
||||
DEVICE_DTS_CONFIG := config@mp03.1
|
||||
endef
|
||||
#TARGET_DEVICES += qcom_mp03_1
|
||||
TARGET_DEVICES += qcom_mp03_1
|
||||
|
||||
define Device/qcom_mp03_3
|
||||
DEVICE_TITLE := Qualcomm Maple 03.3
|
||||
@@ -45,4 +45,4 @@ define Device/qcom_mp03_3
|
||||
DEVICE_PACKAGES := ath11k-wifi-qcom-ipq5018
|
||||
DEVICE_DTS_CONFIG := config@mp03.3
|
||||
endef
|
||||
#TARGET_DEVICES += qcom_mp03_3
|
||||
TARGET_DEVICES += qcom_mp03_3
|
||||
|
||||
@@ -50,10 +50,18 @@ define Device/wallys_dr6018_v4
|
||||
DEVICE_DTS := qcom-ipq6018-wallys-dr6018-v4
|
||||
DEVICE_DTS_CONFIG := config@cp01-c4
|
||||
SUPPORTED_DEVICES := wallys,dr6018-v4
|
||||
DEVICE_PACKAGES := ath11k-wifi-wallys-dr6018-v4 uboot-envtools ath11k-firmware-qcn9000
|
||||
DEVICE_PACKAGES := ath11k-wifi-wallys-dr6018-v4 uboot-envtools
|
||||
endef
|
||||
TARGET_DEVICES += wallys_dr6018_v4
|
||||
|
||||
define Device/qcom_cp01_c1
|
||||
DEVICE_TITLE := Qualcomm Cypress C1
|
||||
DEVICE_DTS := qcom-ipq6018-cp01-c1
|
||||
SUPPORTED_DEVICES := qcom,ipq6018-cp01
|
||||
DEVICE_PACKAGES := ath11k-wifi-qcom-ipq6018
|
||||
endef
|
||||
TARGET_DEVICES += qcom_cp01_c1
|
||||
|
||||
define Device/glinet_ax1800
|
||||
DEVICE_TITLE := GL-iNet AX1800
|
||||
DEVICE_DTS := qcom-ipq6018-gl-ax1800
|
||||
|
||||
@@ -2,16 +2,16 @@ KERNEL_LOADADDR := 0x41208000
|
||||
|
||||
define Device/qcom_hk01
|
||||
DEVICE_TITLE := Qualcomm Hawkeye HK01
|
||||
DEVICE_DTS := ipq8074-hk01
|
||||
DEVICE_DTS := qcom-ipq807x-hk01
|
||||
DEVICE_DTS_CONFIG=config@hk01
|
||||
SUPPORTED_DEVICES := qcom,ipq807x-hk01
|
||||
DEVICE_PACKAGES := ath11k-wifi-qcom-ipq8074
|
||||
endef
|
||||
#TARGET_DEVICES += qcom_hk01
|
||||
TARGET_DEVICES += qcom_hk01
|
||||
|
||||
define Device/qcom_hk14
|
||||
DEVICE_TITLE := Qualcomm Hawkeye HK14
|
||||
DEVICE_DTS := ipq8074-hk14
|
||||
DEVICE_DTS := qcom-ipq807x-hk14
|
||||
DEVICE_DTS_CONFIG=config@hk14
|
||||
SUPPORTED_DEVICES := qcom,ipq807x-hk14
|
||||
DEVICE_PACKAGES := ath11k-wifi-qcom-ipq8074 kmod-ath11k-pci ath11k-firmware-qcn9000
|
||||
@@ -41,6 +41,8 @@ define Device/cig_wf196
|
||||
DEVICE_DTS := qcom-ipq807x-wf196
|
||||
DEVICE_DTS_CONFIG=config@hk14
|
||||
SUPPORTED_DEVICES := cig,wf196
|
||||
BLOCKSIZE := 256k
|
||||
PAGESIZE := 4096
|
||||
DEVICE_PACKAGES := ath11k-wifi-cig-wf196 aq-fw-download uboot-envtools kmod-usb3 kmod-usb2 \
|
||||
ath11k-firmware-qcn9000 ath11k-wifi-cig-wf196_6g
|
||||
endef
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
85
feeds/ipq807x/ipq807x/ipq50xx/config-default
Normal file
85
feeds/ipq807x/ipq807x/ipq50xx/config-default
Normal file
@@ -0,0 +1,85 @@
|
||||
# CONFIG_AHCI_IPQ is not set
|
||||
CONFIG_ARCH_IPQ5018=y
|
||||
# CONFIG_DIAGFWD_BRIDGE_CODE is not set
|
||||
CONFIG_IPQ_ADSS_5018=y
|
||||
CONFIG_IPQ_APSS_5018=y
|
||||
CONFIG_IPQ_GCC_5018=y
|
||||
# CONFIG_NET_SWITCHDEV is not set
|
||||
CONFIG_NUM_ALT_PARTITION=16
|
||||
CONFIG_PINCTRL_IPQ5018=y
|
||||
# CONFIG_IPC_LOGGING is not set
|
||||
CONFIG_IPQ_SUBSYSTEM_DUMP=y
|
||||
CONFIG_SPS=y
|
||||
CONFIG_SPS_SUPPORT_NDP_BAM=y
|
||||
CONFIG_CORESIGHT=y
|
||||
CONFIG_CORESIGHT_CSR=y
|
||||
CONFIG_CORESIGHT_CTI=y
|
||||
CONFIG_CORESIGHT_EVENT=y
|
||||
CONFIG_CORESIGHT_HWEVENT=y
|
||||
CONFIG_CORESIGHT_LINKS_AND_SINKS=y
|
||||
CONFIG_CORESIGHT_LINK_AND_SINK_TMC=y
|
||||
CONFIG_CORESIGHT_QCOM_REPLICATOR=y
|
||||
# CONFIG_INPUT_PM8941_PWRKEY is not set
|
||||
CONFIG_MDIO_QCA=y
|
||||
# CONFIG_CRYPTO_ALL_CASES is not set
|
||||
CONFIG_CRYPTO_DEV_QCOM_ICE=y
|
||||
# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
|
||||
CONFIG_CRYPTO_SHA512=y
|
||||
# CONFIG_CORESIGHT_QPDI is not set
|
||||
# CONFIG_CORESIGHT_SINK_ETBV10 is not set
|
||||
CONFIG_CORESIGHT_SINK_TPIU=y
|
||||
# CONFIG_CORESIGHT_SOURCE_DUMMY is not set
|
||||
CONFIG_CORESIGHT_SOURCE_ETM3X=y
|
||||
CONFIG_CORESIGHT_SOURCE_ETM4X=y
|
||||
# CONFIG_CORESIGHT_REMOTE_ETM is not set
|
||||
CONFIG_CORESIGHT_STM=y
|
||||
CONFIG_CORESIGHT_TPDA=y
|
||||
CONFIG_CORESIGHT_TPDM=y
|
||||
# CONFIG_CORESIGHT_TPDM_DEFAULT_ENABLE is not set
|
||||
CONFIG_IIO=y
|
||||
# CONFIG_IIO_BUFFER is not set
|
||||
# CONFIG_IIO_TRIGGER is not set
|
||||
CONFIG_PCIE_DW_PLAT=y
|
||||
CONFIG_PHY_IPQ_UNIPHY_PCIE=y
|
||||
CONFIG_VMSPLIT_2G=y
|
||||
# CONFIG_VMSPLIT_3G is not set
|
||||
CONFIG_PPS=y
|
||||
CONFIG_PTP_1588_CLOCK=y
|
||||
# CONFIG_DP83640_PHY is not set
|
||||
CONFIG_PWM_IPQ5018=y
|
||||
CONFIG_QCOM_APM=y
|
||||
CONFIG_QCOM_DCC=y
|
||||
# CONFIG_QCOM_SPMI_TEMP_ALARM is not set
|
||||
CONFIG_MMC_SDHCI_MSM_ICE=y
|
||||
CONFIG_USB_BAM=y
|
||||
CONFIG_MAILBOX=y
|
||||
# CONFIG_USB_QCOM_DIAG_BRIDGE is not set
|
||||
# CONFIG_USB_CONFIGFS_F_DIAG is not set
|
||||
# CONFIG_NF_IPV6_DUMMY_HEADER is not set
|
||||
CONFIG_RMNET_DATA=y
|
||||
CONFIG_RMNET_DATA_DEBUG_PKT=y
|
||||
CONFIG_MTD_NAND_SERIAL=y
|
||||
CONFIG_PAGE_SCOPE_MULTI_PAGE_READ=y
|
||||
# CONFIG_RMNET_DATA_FC is not set
|
||||
CONFIG_CRYPTO_NO_ZERO_LEN_HASH=y
|
||||
CONFIG_CRYPTO_DISABLE_AES192_TEST=y
|
||||
# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
|
||||
# CONFIG_CPU_FREQ_GOV_PERFORMANCE is not set
|
||||
# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
|
||||
# CONFIG_CPU_FREQ_GOV_ONDEMAND is not set
|
||||
# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
|
||||
CONFIG_QTI_EUD=y
|
||||
CONFIG_USB_QCA_M31_PHY=y
|
||||
CONFIG_QGIC2_MSI=y
|
||||
CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
|
||||
CONFIG_PWM_IPQ4019=y
|
||||
CONFIG_RMNET=y
|
||||
CONFIG_QCOM_QMI_RMNET=y
|
||||
CONFIG_QCOM_QMI_DFC=y
|
||||
CONFIG_QCOM_QMI_POWER_COLLAPSE=y
|
||||
CONFIG_RMNET_CTL=y
|
||||
CONFIG_RMNET_CTL_DEBUG=y
|
||||
CONFIG_SND_SOC_IPQ_LPASS=y
|
||||
CONFIG_SND_SOC_IPQ_LPASS_PCM_RAW=y
|
||||
# CONFIG_SND_SOC_IPQ_PCM_RAW is not set
|
||||
CONFIG_QCOM_RESTART_REASON=y
|
||||
73
feeds/ipq807x/ipq807x/ipq50xx/config-lowmem
Normal file
73
feeds/ipq807x/ipq807x/ipq50xx/config-lowmem
Normal file
@@ -0,0 +1,73 @@
|
||||
# CONFIG_AHCI_IPQ is not set
|
||||
CONFIG_ARCH_IPQ5018=y
|
||||
# CONFIG_DIAGFWD_BRIDGE_CODE is not set
|
||||
CONFIG_IPQ_ADSS_5018=y
|
||||
CONFIG_IPQ_APSS_5018=y
|
||||
CONFIG_IPQ_GCC_5018=y
|
||||
# CONFIG_NET_SWITCHDEV is not set
|
||||
CONFIG_NUM_ALT_PARTITION=16
|
||||
CONFIG_PINCTRL_IPQ5018=y
|
||||
# CONFIG_IPC_LOGGING is not set
|
||||
CONFIG_IPQ_SUBSYSTEM_DUMP=y
|
||||
# CONFIG_SPS is not set
|
||||
# CONFIG_SPS_SUPPORT_NDP_BAM is not set
|
||||
# CONFIG_CORESIGHT is not set
|
||||
# CONFIG_INPUT_PM8941_PWRKEY is not set
|
||||
CONFIG_MDIO_QCA=y
|
||||
# CONFIG_CRYPTO_ALL_CASES is not set
|
||||
# CONFIG_CRYPTO_DEV_QCOM_ICE is not set
|
||||
# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
|
||||
# CONFIG_CRYPTO_SHA512 is not set
|
||||
# CONFIG_IIO is not set
|
||||
# CONFIG_IIO_BUFFER is not set
|
||||
# CONFIG_IIO_TRIGGER is not set
|
||||
CONFIG_PCIE_DW_PLAT=y
|
||||
CONFIG_PHY_IPQ_UNIPHY_PCIE=y
|
||||
CONFIG_VMSPLIT_2G=y
|
||||
# CONFIG_VMSPLIT_3G is not set
|
||||
# CONFIG_PPS is not set
|
||||
# CONFIG_PTP_1588_CLOCK is not set
|
||||
# CONFIG_DP83640_PHY is not set
|
||||
CONFIG_PWM_IPQ5018=y
|
||||
CONFIG_QCOM_APM=y
|
||||
# CONFIG_QCOM_DCC is not set
|
||||
# CONFIG_QCOM_SPMI_TEMP_ALARM is not set
|
||||
CONFIG_MMC_SDHCI_MSM_ICE=y
|
||||
CONFIG_USB_BAM=y
|
||||
CONFIG_MAILBOX=y
|
||||
# CONFIG_USB_QCOM_DIAG_BRIDGE is not set
|
||||
# CONFIG_USB_CONFIGFS_F_DIAG is not set
|
||||
# CONFIG_NF_IPV6_DUMMY_HEADER is not set
|
||||
# CONFIG_RMNET_DATA is not set
|
||||
# CONFIG_RMNET_DATA_DEBUG_PKT is not set
|
||||
CONFIG_MTD_NAND_SERIAL=y
|
||||
CONFIG_PAGE_SCOPE_MULTI_PAGE_READ=y
|
||||
# CONFIG_RMNET_DATA_FC is not set
|
||||
# CONFIG_CRYPTO_NO_ZERO_LEN_HASH is not set
|
||||
# CONFIG_CRYPTO_DISABLE_AES192_TEST is not set
|
||||
# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
|
||||
# CONFIG_CPU_FREQ_GOV_PERFORMANCE is not set
|
||||
# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
|
||||
# CONFIG_CPU_FREQ_GOV_ONDEMAND is not set
|
||||
# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
|
||||
CONFIG_QTI_EUD=y
|
||||
CONFIG_USB_QCA_M31_PHY=y
|
||||
CONFIG_SQUASHFS_XZ=y
|
||||
# CONFIG_SQUASHFS_ZLIB is not set
|
||||
# CONFIG_JFFS2_LZMA is not set
|
||||
CONFIG_JFFS2_ZLIB=y
|
||||
# CONFIG_LZO_COMPRESS is not set
|
||||
# CONFIG_LZO_DECOMPRESS is not set
|
||||
CONFIG_XZ_DEC=y
|
||||
# CONFIG_XZ_DEC_X86 is not set
|
||||
# CONFIG_XZ_DEC_POWERPC is not set
|
||||
# CONFIG_XZ_DEC_IA64 is not set
|
||||
CONFIG_XZ_DEC_ARM=y
|
||||
# CONFIG_XZ_DEC_ARMTHUMB is not set
|
||||
# CONFIG_XZ_DEC_SPARC is not set
|
||||
CONFIG_XZ_DEC_BCJ=y
|
||||
# CONFIG_LZO_COMPRESS is not set
|
||||
# CONFIG_LZO_DECOMPRESS is not set
|
||||
# CONFIG_CRYPTO is not set
|
||||
CONFIG_QGIC2_MSI=y
|
||||
CONFIG_MTD_SPI_NOR_USE_4K_SECTORS=y
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,6 @@
|
||||
SUBTARGET:=ipq60xx
|
||||
BOARDNAME:=IPQ60xx based boards
|
||||
|
||||
KERNEL_PATCHVER:=5.4
|
||||
|
||||
DEFAULT_PACKAGES += ath11k-firmware-ipq60xx qca-nss-fw-ipq60xx
|
||||
|
||||
define Target/Description
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,15 +2,12 @@ define KernelPackage/usb-phy-ipq807x
|
||||
TITLE:=DWC3 USB QCOM PHY driver for IPQ807x
|
||||
DEPENDS:=@TARGET_ipq807x
|
||||
KCONFIG:= \
|
||||
CONFIG_PHY_QCOM_QUSB2 \
|
||||
CONFIG_PHY_QCOM_QMP=y \
|
||||
CONFIG_USB_QCOM_QUSB_PHY \
|
||||
CONFIG_USB_QCOM_QMP_PHY
|
||||
FILES:= \
|
||||
$(LINUX_DIR)/drivers/phy/qualcomm/phy-qcom-qusb2.ko@ge5.4 \
|
||||
$(LINUX_DIR)/drivers/usb/phy/phy-msm-qusb.ko@le4.4 \
|
||||
$(LINUX_DIR)/drivers/usb/phy/phy-msm-ssusb-qmp.ko@le4.4
|
||||
AUTOLOAD:=$(call AutoLoad,45,phy-qcom-qusb2 phy-msm-qusb phy-msm-ssusb-qmp,1)
|
||||
$(LINUX_DIR)/drivers/usb/phy/phy-msm-qusb.ko \
|
||||
$(LINUX_DIR)/drivers/usb/phy/phy-msm-ssusb-qmp.ko
|
||||
AUTOLOAD:=$(call AutoLoad,45,phy-msm-qusb phy-msm-ssusb-qmp,1)
|
||||
$(call AddDepends/usb)
|
||||
endef
|
||||
|
||||
@@ -22,45 +19,46 @@ endef
|
||||
$(eval $(call KernelPackage,usb-phy-ipq807x))
|
||||
|
||||
|
||||
define KernelPackage/usb-dwc3-internal
|
||||
TITLE:=DWC3 USB controller driver
|
||||
DEPENDS:=+USB_GADGET_SUPPORT:kmod-usb-gadget +kmod-usb-core
|
||||
define KernelPackage/qrtr_mproc
|
||||
TITLE:= Ath11k Specific kernel configs for IPQ807x and IPQ60xx
|
||||
DEPENDS+= @TARGET_ipq807x
|
||||
KCONFIG:= \
|
||||
CONFIG_USB_DWC3 \
|
||||
CONFIG_USB_DWC3_HOST=n \
|
||||
CONFIG_USB_DWC3_GADGET=n \
|
||||
CONFIG_USB_DWC3_DUAL_ROLE=y \
|
||||
CONFIG_EXTCON=y \
|
||||
CONFIG_USB_DWC3_DEBUG=n \
|
||||
CONFIG_USB_DWC3_VERBOSE=n
|
||||
FILES:= $(LINUX_DIR)/drivers/usb/dwc3/dwc3.ko
|
||||
AUTOLOAD:=$(call AutoLoad,54,dwc3,1)
|
||||
$(call AddPlatformDepends/usb)
|
||||
CONFIG_QRTR=y \
|
||||
CONFIG_QRTR_MHI=y \
|
||||
CONFIG_MHI_BUS=y \
|
||||
CONFIG_MHI_QTI=y \
|
||||
CONFIG_QCOM_APCS_IPC=y \
|
||||
CONFIG_QCOM_GLINK_SSR=y \
|
||||
CONFIG_QCOM_Q6V5_WCSS=y \
|
||||
CONFIG_MSM_RPM_RPMSG=y \
|
||||
CONFIG_RPMSG_QCOM_GLINK_RPM=y \
|
||||
CONFIG_REGULATOR_RPM_GLINK=y \
|
||||
CONFIG_QCOM_SYSMON=y \
|
||||
CONFIG_RPMSG=y \
|
||||
CONFIG_RPMSG_CHAR=y \
|
||||
CONFIG_RPMSG_QCOM_GLINK_SMEM=y \
|
||||
CONFIG_RPMSG_QCOM_SMD=y \
|
||||
CONFIG_QRTR_SMD=y \
|
||||
CONFIG_QCOM_QMI_HELPERS=y \
|
||||
CONFIG_SAMPLES=y \
|
||||
CONFIG_SAMPLE_QMI_CLIENT=m \
|
||||
CONFIG_SAMPLE_TRACE_EVENTS=n \
|
||||
CONFIG_SAMPLE_KOBJECT=n \
|
||||
CONFIG_SAMPLE_KPROBES=n \
|
||||
CONFIG_SAMPLE_KRETPROBES=n \
|
||||
CONFIG_SAMPLE_HW_BREAKPOINT=n \
|
||||
CONFIG_SAMPLE_KFIFO=n \
|
||||
CONFIG_SAMPLE_CONFIGFS=n \
|
||||
CONFIG_SAMPLE_RPMSG_CLIENT=n \
|
||||
CONFIG_MAILBOX=y \
|
||||
CONFIG_DIAG_OVER_QRTR=y
|
||||
endef
|
||||
|
||||
define KernelPackage/usb-dwc3-internal/description
|
||||
This driver provides support for the Dual Role SuperSpeed
|
||||
USB Controller based on the Synopsys DesignWare USB3 IP Core
|
||||
define KernelPackage/qrtr_mproc/description
|
||||
Kernel configs for ath11k support specific to ipq807x and IPQ60xx
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,usb-dwc3-internal))
|
||||
|
||||
define KernelPackage/usb-dwc3-qcom-internal
|
||||
TITLE:=DWC3 QTI USB driver
|
||||
DEPENDS:=@!LINUX_4_14 @(TARGET_ipq807x||TARGET_ipq60xx||TARGET_ipq95xx||TARGET_ipq50xx) +kmod-usb-dwc3-internal
|
||||
KCONFIG:= CONFIG_USB_DWC3_QCOM
|
||||
FILES:= $(LINUX_DIR)/drivers/usb/dwc3/dwc3-qcom.ko
|
||||
AUTOLOAD:=$(call AutoLoad,53,dwc3-qcom,1)
|
||||
$(call AddPlatformDepends/usb)
|
||||
endef
|
||||
|
||||
define KernelPackage/usb-dwc3-qcom-internal/description
|
||||
Some QTI SoCs use DesignWare Core IP for USB2/3 functionality.
|
||||
This driver also handles Qscratch wrapper which is needed for
|
||||
peripheral mode support.
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,usb-dwc3-qcom-internal))
|
||||
$(eval $(call KernelPackage,qrtr_mproc))
|
||||
|
||||
define KernelPackage/bt_tty
|
||||
TITLE:= BT Inter-processor Communication
|
||||
@@ -85,8 +83,8 @@ define KernelPackage/usb-phy-ipq5018
|
||||
CONFIG_USB_QCA_M31_PHY \
|
||||
CONFIG_PHY_IPQ_UNIPHY_USB
|
||||
FILES:= \
|
||||
$(LINUX_DIR)/drivers/usb/phy/phy-qca-m31.ko \
|
||||
$(LINUX_DIR)/drivers/phy/qualcomm/phy-qca-uniphy.ko
|
||||
$(LINUX_DIR)/drivers/usb/phy/phy-qca-m31.ko \
|
||||
$(LINUX_DIR)/drivers/phy/phy-qca-uniphy.ko
|
||||
AUTOLOAD:=$(call AutoLoad,45,phy-qca-m31 phy-qca-uniphy,1)
|
||||
$(call AddDepends/usb)
|
||||
endef
|
||||
@@ -98,30 +96,13 @@ endef
|
||||
|
||||
$(eval $(call KernelPackage,usb-phy-ipq5018))
|
||||
|
||||
define KernelPackage/usb-f-diag
|
||||
TITLE:=USB DIAG
|
||||
KCONFIG:=CONFIG_USB_F_DIAG \
|
||||
CONFIG_USB_CONFIGFS_F_DIAG=y \
|
||||
CONFIG_DIAG_OVER_USB=y
|
||||
DEPENDS:=+kmod-usb-lib-composite +kmod-usb-configfs
|
||||
FILES:=$(LINUX_DIR)/drivers/usb/gadget/function/usb_f_diag.ko
|
||||
AUTOLOAD:=$(call AutoLoad,52,usb_f_diag)
|
||||
$(call AddPlatformDepends/usb)
|
||||
endef
|
||||
|
||||
define KernelPackage/usb-f-diag/description
|
||||
USB DIAG
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,usb-f-diag))
|
||||
|
||||
define KernelPackage/diag-char
|
||||
TITLE:=CHAR DIAG
|
||||
KCONFIG:= CONFIG_DIAG_MHI=y@ge5.4 \
|
||||
CONFIG_DIAG_OVER_PCIE=n@ge5.4 \
|
||||
CONFIG_DIAGFWD_BRIDGE_CODE=y \
|
||||
CONFIG_DIAG_CHAR
|
||||
DEPENDS:=+kmod-lib-crc-ccitt +kmod-usb-f-diag
|
||||
CONFIG_DIAG_CHAR=m
|
||||
DEPENDS:=+kmod-lib-crc-ccitt
|
||||
FILES:=$(LINUX_DIR)/drivers/char/diag/diagchar.ko
|
||||
endef
|
||||
|
||||
@@ -131,34 +112,21 @@ endef
|
||||
|
||||
$(eval $(call KernelPackage,diag-char))
|
||||
|
||||
define KernelPackage/usb-configfs
|
||||
TITLE:= USB functions
|
||||
KCONFIG:=CONFIG_USB_CONFIGFS \
|
||||
CONFIG_USB_CONFIGFS_SERIAL=n \
|
||||
CONFIG_USB_CONFIGFS_ACM=n \
|
||||
CONFIG_USB_CONFIGFS_OBEX=n \
|
||||
CONFIG_USB_CONFIGFS_NCM=n \
|
||||
CONFIG_USB_CONFIGFS_ECM=n \
|
||||
CONFIG_USB_CONFIGFS_ECM_SUBSET=n \
|
||||
CONFIG_USB_CONFIGFS_RNDIS=n \
|
||||
CONFIG_USB_CONFIGFS_EEM=n \
|
||||
CONFIG_USB_CONFIGFS_MASS_STORAGE=n \
|
||||
CONFIG_USB_CONFIGFS_F_LB_SS=n \
|
||||
CONFIG_USB_CONFIGFS_F_FS=n \
|
||||
CONFIG_USB_CONFIGFS_F_UAC1=n \
|
||||
CONFIG_USB_CONFIGFS_F_UAC2=n \
|
||||
CONFIG_USB_CONFIGFS_F_MIDI=n \
|
||||
CONFIG_USB_CONFIGFS_F_HID=n \
|
||||
CONFIG_USB_CONFIGFS_F_PRINTER=n \
|
||||
CONFIG_USB_CONFIGFS_F_QDSS=n
|
||||
$(call AddPlatformDepends/usb)
|
||||
define KernelPackage/usb-dwc3-qcom
|
||||
TITLE:=DWC3 Qualcomm USB driver
|
||||
DEPENDS:=@(!LINUX_4_14) @TARGET_ipq807x +kmod-usb-dwc3
|
||||
KCONFIG:= CONFIG_USB_DWC3_QCOM
|
||||
FILES:= $(LINUX_DIR)/drivers/usb/dwc3/dwc3-qcom.ko \
|
||||
$(LINUX_DIR)/drivers/usb/dwc3/dbm.ko
|
||||
AUTOLOAD:=$(call AutoLoad,53,dwc3-qcom dbm,1)
|
||||
$(call AddDepends/usb)
|
||||
endef
|
||||
|
||||
define KernelPackage/usb-configfs/description
|
||||
USB functions
|
||||
define KernelPackage/usb-dwc3-qcom/description
|
||||
Some Qualcomm SoCs use DesignWare Core IP for USB2/3 functionality.
|
||||
This driver also handles Qscratch wrapper which is needed for
|
||||
peripheral mode support.
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,usb-configfs))
|
||||
|
||||
|
||||
|
||||
$(eval $(call KernelPackage,usb-dwc3-qcom))
|
||||
|
||||
25
feeds/ipq807x/ipq807x/patches/001-backport_kbuild_fix.patch
Normal file
25
feeds/ipq807x/ipq807x/patches/001-backport_kbuild_fix.patch
Normal file
@@ -0,0 +1,25 @@
|
||||
--- a/scripts/Makefile.lib
|
||||
+++ b/scripts/Makefile.lib
|
||||
@@ -96,10 +96,10 @@ obj-dirs := $(addprefix $(obj)/,$(obj-di
|
||||
# Note: Files that end up in two or more modules are compiled without the
|
||||
# KBUILD_MODNAME definition. The reason is that any made-up name would
|
||||
# differ in different configs.
|
||||
-name-fix = $(subst $(comma),_,$(subst -,_,$1))
|
||||
-basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
|
||||
+name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
|
||||
+basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
|
||||
modname_flags = $(if $(filter 1,$(words $(modname))),\
|
||||
- -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
|
||||
+ -DKBUILD_MODNAME=$(call name-fix,$(modname)))
|
||||
|
||||
orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
|
||||
$(ccflags-y) $(CFLAGS_$(basetarget).o)
|
||||
@@ -155,7 +155,7 @@ endif
|
||||
|
||||
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
|
||||
$(__c_flags) $(modkern_cflags) \
|
||||
- -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
|
||||
+ $(basename_flags) $(modname_flags)
|
||||
|
||||
a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
|
||||
$(__a_flags) $(modkern_aflags)
|
||||
@@ -1,118 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:07 +0100
|
||||
Subject: [PATCH] crypto: lib - tidy up lib/crypto Kconfig and Makefile
|
||||
|
||||
commit 746b2e024c67aa605ac12d135cd7085a49cf9dc4 upstream.
|
||||
|
||||
In preparation of introducing a set of crypto library interfaces, tidy
|
||||
up the Makefile and split off the Kconfig symbols into a separate file.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/Kconfig | 13 +------------
|
||||
lib/crypto/Kconfig | 15 +++++++++++++++
|
||||
lib/crypto/Makefile | 16 ++++++++--------
|
||||
3 files changed, 24 insertions(+), 20 deletions(-)
|
||||
create mode 100644 lib/crypto/Kconfig
|
||||
|
||||
Index: linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/crypto/Kconfig
|
||||
===================================================================
|
||||
--- linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac.orig/crypto/Kconfig
|
||||
+++ linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/crypto/Kconfig
|
||||
@@ -942,9 +942,6 @@ config CRYPTO_SHA1_PPC_SPE
|
||||
SHA-1 secure hash standard (DFIPS 180-4) implemented
|
||||
using powerpc SPE SIMD instruction set.
|
||||
|
||||
-config CRYPTO_LIB_SHA256
|
||||
- tristate
|
||||
-
|
||||
config CRYPTO_SHA256
|
||||
tristate "SHA224 and SHA256 digest algorithm"
|
||||
select CRYPTO_HASH
|
||||
@@ -1083,9 +1080,6 @@ config CRYPTO_GHASH_CLMUL_NI_INTEL
|
||||
|
||||
comment "Ciphers"
|
||||
|
||||
-config CRYPTO_LIB_AES
|
||||
- tristate
|
||||
-
|
||||
config CRYPTO_AES
|
||||
tristate "AES cipher algorithms"
|
||||
select CRYPTO_ALGAPI
|
||||
@@ -1214,9 +1208,6 @@ config CRYPTO_ANUBIS
|
||||
<https://www.cosic.esat.kuleuven.be/nessie/reports/>
|
||||
<http://www.larc.usp.br/~pbarreto/AnubisPage.html>
|
||||
|
||||
-config CRYPTO_LIB_ARC4
|
||||
- tristate "ARC4 cipher library"
|
||||
-
|
||||
config CRYPTO_ARC4
|
||||
tristate "ARC4 cipher algorithm"
|
||||
select CRYPTO_BLKCIPHER
|
||||
@@ -1403,9 +1394,6 @@ config CRYPTO_CAST6_AVX_X86_64
|
||||
This module provides the Cast6 cipher algorithm that processes
|
||||
eight blocks parallel using the AVX instruction set.
|
||||
|
||||
-config CRYPTO_LIB_DES
|
||||
- tristate
|
||||
-
|
||||
config CRYPTO_DES
|
||||
tristate "DES and Triple DES EDE cipher algorithms"
|
||||
select CRYPTO_ALGAPI
|
||||
@@ -1909,6 +1897,7 @@ config CRYPTO_STATS
|
||||
config CRYPTO_HASH_INFO
|
||||
bool
|
||||
|
||||
+source "lib/crypto/Kconfig"
|
||||
source "drivers/crypto/Kconfig"
|
||||
source "crypto/asymmetric_keys/Kconfig"
|
||||
source "certs/Kconfig"
|
||||
Index: linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/lib/crypto/Kconfig
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/lib/crypto/Kconfig
|
||||
@@ -0,0 +1,15 @@
|
||||
+# SPDX-License-Identifier: GPL-2.0
|
||||
+
|
||||
+comment "Crypto library routines"
|
||||
+
|
||||
+config CRYPTO_LIB_AES
|
||||
+ tristate
|
||||
+
|
||||
+config CRYPTO_LIB_ARC4
|
||||
+ tristate
|
||||
+
|
||||
+config CRYPTO_LIB_DES
|
||||
+ tristate
|
||||
+
|
||||
+config CRYPTO_LIB_SHA256
|
||||
+ tristate
|
||||
Index: linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/lib/crypto/Makefile
|
||||
===================================================================
|
||||
--- linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac.orig/lib/crypto/Makefile
|
||||
+++ linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/lib/crypto/Makefile
|
||||
@@ -1,13 +1,13 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
-obj-$(CONFIG_CRYPTO_LIB_AES) += libaes.o
|
||||
-libaes-y := aes.o
|
||||
+obj-$(CONFIG_CRYPTO_LIB_AES) += libaes.o
|
||||
+libaes-y := aes.o
|
||||
|
||||
-obj-$(CONFIG_CRYPTO_LIB_ARC4) += libarc4.o
|
||||
-libarc4-y := arc4.o
|
||||
+obj-$(CONFIG_CRYPTO_LIB_ARC4) += libarc4.o
|
||||
+libarc4-y := arc4.o
|
||||
|
||||
-obj-$(CONFIG_CRYPTO_LIB_DES) += libdes.o
|
||||
-libdes-y := des.o
|
||||
+obj-$(CONFIG_CRYPTO_LIB_DES) += libdes.o
|
||||
+libdes-y := des.o
|
||||
|
||||
-obj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
|
||||
-libsha256-y := sha256.o
|
||||
+obj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
|
||||
+libsha256-y := sha256.o
|
||||
@@ -1,668 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:08 +0100
|
||||
Subject: [PATCH] crypto: chacha - move existing library code into lib/crypto
|
||||
|
||||
commit 5fb8ef25803ef33e2eb60b626435828b937bed75 upstream.
|
||||
|
||||
Currently, our generic ChaCha implementation consists of a permute
|
||||
function in lib/chacha.c that operates on the 64-byte ChaCha state
|
||||
directly [and which is always included into the core kernel since it
|
||||
is used by the /dev/random driver], and the crypto API plumbing to
|
||||
expose it as a skcipher.
|
||||
|
||||
In order to support in-kernel users that need the ChaCha streamcipher
|
||||
but have no need [or tolerance] for going through the abstractions of
|
||||
the crypto API, let's expose the streamcipher bits via a library API
|
||||
as well, in a way that permits the implementation to be superseded by
|
||||
an architecture specific one if provided.
|
||||
|
||||
So move the streamcipher code into a separate module in lib/crypto,
|
||||
and expose the init() and crypt() routines to users of the library.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/chacha-neon-glue.c | 2 +-
|
||||
arch/arm64/crypto/chacha-neon-glue.c | 2 +-
|
||||
arch/x86/crypto/chacha_glue.c | 2 +-
|
||||
crypto/Kconfig | 1 +
|
||||
crypto/chacha_generic.c | 60 ++--------------------
|
||||
include/crypto/chacha.h | 77 ++++++++++++++++++++++------
|
||||
include/crypto/internal/chacha.h | 53 +++++++++++++++++++
|
||||
lib/Makefile | 3 +-
|
||||
lib/crypto/Kconfig | 26 ++++++++++
|
||||
lib/crypto/Makefile | 4 ++
|
||||
lib/{ => crypto}/chacha.c | 20 ++++----
|
||||
lib/crypto/libchacha.c | 35 +++++++++++++
|
||||
12 files changed, 199 insertions(+), 86 deletions(-)
|
||||
create mode 100644 include/crypto/internal/chacha.h
|
||||
rename lib/{ => crypto}/chacha.c (88%)
|
||||
create mode 100644 lib/crypto/libchacha.c
|
||||
|
||||
--- a/arch/arm/crypto/chacha-neon-glue.c
|
||||
+++ b/arch/arm/crypto/chacha-neon-glue.c
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
-#include <crypto/chacha.h>
|
||||
+#include <crypto/internal/chacha.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <linux/kernel.h>
|
||||
--- a/arch/arm64/crypto/chacha-neon-glue.c
|
||||
+++ b/arch/arm64/crypto/chacha-neon-glue.c
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
-#include <crypto/chacha.h>
|
||||
+#include <crypto/internal/chacha.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <linux/kernel.h>
|
||||
--- a/arch/x86/crypto/chacha_glue.c
|
||||
+++ b/arch/x86/crypto/chacha_glue.c
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
-#include <crypto/chacha.h>
|
||||
+#include <crypto/internal/chacha.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <linux/kernel.h>
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -1393,6 +1393,7 @@ config CRYPTO_SALSA20
|
||||
|
||||
config CRYPTO_CHACHA20
|
||||
tristate "ChaCha stream cipher algorithms"
|
||||
+ select CRYPTO_LIB_CHACHA_GENERIC
|
||||
select CRYPTO_BLKCIPHER
|
||||
help
|
||||
The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms.
|
||||
--- a/crypto/chacha_generic.c
|
||||
+++ b/crypto/chacha_generic.c
|
||||
@@ -8,29 +8,10 @@
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
#include <crypto/algapi.h>
|
||||
-#include <crypto/chacha.h>
|
||||
+#include <crypto/internal/chacha.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
-static void chacha_docrypt(u32 *state, u8 *dst, const u8 *src,
|
||||
- unsigned int bytes, int nrounds)
|
||||
-{
|
||||
- /* aligned to potentially speed up crypto_xor() */
|
||||
- u8 stream[CHACHA_BLOCK_SIZE] __aligned(sizeof(long));
|
||||
-
|
||||
- while (bytes >= CHACHA_BLOCK_SIZE) {
|
||||
- chacha_block(state, stream, nrounds);
|
||||
- crypto_xor_cpy(dst, src, stream, CHACHA_BLOCK_SIZE);
|
||||
- bytes -= CHACHA_BLOCK_SIZE;
|
||||
- dst += CHACHA_BLOCK_SIZE;
|
||||
- src += CHACHA_BLOCK_SIZE;
|
||||
- }
|
||||
- if (bytes) {
|
||||
- chacha_block(state, stream, nrounds);
|
||||
- crypto_xor_cpy(dst, src, stream, bytes);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
static int chacha_stream_xor(struct skcipher_request *req,
|
||||
const struct chacha_ctx *ctx, const u8 *iv)
|
||||
{
|
||||
@@ -48,8 +29,8 @@ static int chacha_stream_xor(struct skci
|
||||
if (nbytes < walk.total)
|
||||
nbytes = round_down(nbytes, CHACHA_BLOCK_SIZE);
|
||||
|
||||
- chacha_docrypt(state, walk.dst.virt.addr, walk.src.virt.addr,
|
||||
- nbytes, ctx->nrounds);
|
||||
+ chacha_crypt_generic(state, walk.dst.virt.addr,
|
||||
+ walk.src.virt.addr, nbytes, ctx->nrounds);
|
||||
err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
||||
}
|
||||
|
||||
@@ -58,41 +39,10 @@ static int chacha_stream_xor(struct skci
|
||||
|
||||
void crypto_chacha_init(u32 *state, const struct chacha_ctx *ctx, const u8 *iv)
|
||||
{
|
||||
- state[0] = 0x61707865; /* "expa" */
|
||||
- state[1] = 0x3320646e; /* "nd 3" */
|
||||
- state[2] = 0x79622d32; /* "2-by" */
|
||||
- state[3] = 0x6b206574; /* "te k" */
|
||||
- state[4] = ctx->key[0];
|
||||
- state[5] = ctx->key[1];
|
||||
- state[6] = ctx->key[2];
|
||||
- state[7] = ctx->key[3];
|
||||
- state[8] = ctx->key[4];
|
||||
- state[9] = ctx->key[5];
|
||||
- state[10] = ctx->key[6];
|
||||
- state[11] = ctx->key[7];
|
||||
- state[12] = get_unaligned_le32(iv + 0);
|
||||
- state[13] = get_unaligned_le32(iv + 4);
|
||||
- state[14] = get_unaligned_le32(iv + 8);
|
||||
- state[15] = get_unaligned_le32(iv + 12);
|
||||
+ chacha_init_generic(state, ctx->key, iv);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_chacha_init);
|
||||
|
||||
-static int chacha_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize, int nrounds)
|
||||
-{
|
||||
- struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
- int i;
|
||||
-
|
||||
- if (keysize != CHACHA_KEY_SIZE)
|
||||
- return -EINVAL;
|
||||
-
|
||||
- for (i = 0; i < ARRAY_SIZE(ctx->key); i++)
|
||||
- ctx->key[i] = get_unaligned_le32(key + i * sizeof(u32));
|
||||
-
|
||||
- ctx->nrounds = nrounds;
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
unsigned int keysize)
|
||||
{
|
||||
@@ -126,7 +76,7 @@ int crypto_xchacha_crypt(struct skcipher
|
||||
|
||||
/* Compute the subkey given the original key and first 128 nonce bits */
|
||||
crypto_chacha_init(state, ctx, req->iv);
|
||||
- hchacha_block(state, subctx.key, ctx->nrounds);
|
||||
+ hchacha_block_generic(state, subctx.key, ctx->nrounds);
|
||||
subctx.nrounds = ctx->nrounds;
|
||||
|
||||
/* Build the real IV */
|
||||
--- a/include/crypto/chacha.h
|
||||
+++ b/include/crypto/chacha.h
|
||||
@@ -15,9 +15,8 @@
|
||||
#ifndef _CRYPTO_CHACHA_H
|
||||
#define _CRYPTO_CHACHA_H
|
||||
|
||||
-#include <crypto/skcipher.h>
|
||||
+#include <asm/unaligned.h>
|
||||
#include <linux/types.h>
|
||||
-#include <linux/crypto.h>
|
||||
|
||||
/* 32-bit stream position, then 96-bit nonce (RFC7539 convention) */
|
||||
#define CHACHA_IV_SIZE 16
|
||||
@@ -29,26 +28,70 @@
|
||||
/* 192-bit nonce, then 64-bit stream position */
|
||||
#define XCHACHA_IV_SIZE 32
|
||||
|
||||
-struct chacha_ctx {
|
||||
- u32 key[8];
|
||||
- int nrounds;
|
||||
-};
|
||||
-
|
||||
-void chacha_block(u32 *state, u8 *stream, int nrounds);
|
||||
+void chacha_block_generic(u32 *state, u8 *stream, int nrounds);
|
||||
static inline void chacha20_block(u32 *state, u8 *stream)
|
||||
{
|
||||
- chacha_block(state, stream, 20);
|
||||
+ chacha_block_generic(state, stream, 20);
|
||||
}
|
||||
-void hchacha_block(const u32 *in, u32 *out, int nrounds);
|
||||
|
||||
-void crypto_chacha_init(u32 *state, const struct chacha_ctx *ctx, const u8 *iv);
|
||||
+void hchacha_block_arch(const u32 *state, u32 *out, int nrounds);
|
||||
+void hchacha_block_generic(const u32 *state, u32 *out, int nrounds);
|
||||
+
|
||||
+static inline void hchacha_block(const u32 *state, u32 *out, int nrounds)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CHACHA))
|
||||
+ hchacha_block_arch(state, out, nrounds);
|
||||
+ else
|
||||
+ hchacha_block_generic(state, out, nrounds);
|
||||
+}
|
||||
|
||||
-int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize);
|
||||
-int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize);
|
||||
+void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv);
|
||||
+static inline void chacha_init_generic(u32 *state, const u32 *key, const u8 *iv)
|
||||
+{
|
||||
+ state[0] = 0x61707865; /* "expa" */
|
||||
+ state[1] = 0x3320646e; /* "nd 3" */
|
||||
+ state[2] = 0x79622d32; /* "2-by" */
|
||||
+ state[3] = 0x6b206574; /* "te k" */
|
||||
+ state[4] = key[0];
|
||||
+ state[5] = key[1];
|
||||
+ state[6] = key[2];
|
||||
+ state[7] = key[3];
|
||||
+ state[8] = key[4];
|
||||
+ state[9] = key[5];
|
||||
+ state[10] = key[6];
|
||||
+ state[11] = key[7];
|
||||
+ state[12] = get_unaligned_le32(iv + 0);
|
||||
+ state[13] = get_unaligned_le32(iv + 4);
|
||||
+ state[14] = get_unaligned_le32(iv + 8);
|
||||
+ state[15] = get_unaligned_le32(iv + 12);
|
||||
+}
|
||||
|
||||
-int crypto_chacha_crypt(struct skcipher_request *req);
|
||||
-int crypto_xchacha_crypt(struct skcipher_request *req);
|
||||
+static inline void chacha_init(u32 *state, const u32 *key, const u8 *iv)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CHACHA))
|
||||
+ chacha_init_arch(state, key, iv);
|
||||
+ else
|
||||
+ chacha_init_generic(state, key, iv);
|
||||
+}
|
||||
+
|
||||
+void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src,
|
||||
+ unsigned int bytes, int nrounds);
|
||||
+void chacha_crypt_generic(u32 *state, u8 *dst, const u8 *src,
|
||||
+ unsigned int bytes, int nrounds);
|
||||
+
|
||||
+static inline void chacha_crypt(u32 *state, u8 *dst, const u8 *src,
|
||||
+ unsigned int bytes, int nrounds)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_CHACHA))
|
||||
+ chacha_crypt_arch(state, dst, src, bytes, nrounds);
|
||||
+ else
|
||||
+ chacha_crypt_generic(state, dst, src, bytes, nrounds);
|
||||
+}
|
||||
+
|
||||
+static inline void chacha20_crypt(u32 *state, u8 *dst, const u8 *src,
|
||||
+ unsigned int bytes)
|
||||
+{
|
||||
+ chacha_crypt(state, dst, src, bytes, 20);
|
||||
+}
|
||||
|
||||
#endif /* _CRYPTO_CHACHA_H */
|
||||
--- /dev/null
|
||||
+++ b/include/crypto/internal/chacha.h
|
||||
@@ -0,0 +1,53 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+
|
||||
+#ifndef _CRYPTO_INTERNAL_CHACHA_H
|
||||
+#define _CRYPTO_INTERNAL_CHACHA_H
|
||||
+
|
||||
+#include <crypto/chacha.h>
|
||||
+#include <crypto/internal/skcipher.h>
|
||||
+#include <linux/crypto.h>
|
||||
+
|
||||
+struct chacha_ctx {
|
||||
+ u32 key[8];
|
||||
+ int nrounds;
|
||||
+};
|
||||
+
|
||||
+void crypto_chacha_init(u32 *state, const struct chacha_ctx *ctx, const u8 *iv);
|
||||
+
|
||||
+static inline int chacha_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+ unsigned int keysize, int nrounds)
|
||||
+{
|
||||
+ struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
+ int i;
|
||||
+
|
||||
+ if (keysize != CHACHA_KEY_SIZE)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(ctx->key); i++)
|
||||
+ ctx->key[i] = get_unaligned_le32(key + i * sizeof(u32));
|
||||
+
|
||||
+ ctx->nrounds = nrounds;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline int chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+ unsigned int keysize)
|
||||
+{
|
||||
+ return chacha_setkey(tfm, key, keysize, 20);
|
||||
+}
|
||||
+
|
||||
+static int inline chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+ unsigned int keysize)
|
||||
+{
|
||||
+ return chacha_setkey(tfm, key, keysize, 12);
|
||||
+}
|
||||
+
|
||||
+int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+ unsigned int keysize);
|
||||
+int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+ unsigned int keysize);
|
||||
+
|
||||
+int crypto_chacha_crypt(struct skcipher_request *req);
|
||||
+int crypto_xchacha_crypt(struct skcipher_request *req);
|
||||
+
|
||||
+#endif /* _CRYPTO_CHACHA_H */
|
||||
--- a/lib/Makefile
|
||||
+++ b/lib/Makefile
|
||||
@@ -26,8 +26,7 @@ endif
|
||||
|
||||
lib-y := ctype.o string.o vsprintf.o cmdline.o \
|
||||
rbtree.o radix-tree.o timerqueue.o xarray.o \
|
||||
- idr.o extable.o \
|
||||
- sha1.o chacha.o irq_regs.o argv_split.o \
|
||||
+ idr.o extable.o sha1.o irq_regs.o argv_split.o \
|
||||
flex_proportions.o ratelimit.o show_mem.o \
|
||||
is_single_threaded.o plist.o decompress.o kobject_uevent.o \
|
||||
earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
|
||||
--- a/lib/crypto/Kconfig
|
||||
+++ b/lib/crypto/Kconfig
|
||||
@@ -8,6 +8,32 @@ config CRYPTO_LIB_AES
|
||||
config CRYPTO_LIB_ARC4
|
||||
tristate
|
||||
|
||||
+config CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
+ tristate
|
||||
+ help
|
||||
+ Declares whether the architecture provides an arch-specific
|
||||
+ accelerated implementation of the ChaCha library interface,
|
||||
+ either builtin or as a module.
|
||||
+
|
||||
+config CRYPTO_LIB_CHACHA_GENERIC
|
||||
+ tristate
|
||||
+ select CRYPTO_ALGAPI
|
||||
+ help
|
||||
+ This symbol can be depended upon by arch implementations of the
|
||||
+ ChaCha library interface that require the generic code as a
|
||||
+ fallback, e.g., for SIMD implementations. If no arch specific
|
||||
+ implementation is enabled, this implementation serves the users
|
||||
+ of CRYPTO_LIB_CHACHA.
|
||||
+
|
||||
+config CRYPTO_LIB_CHACHA
|
||||
+ tristate "ChaCha library interface"
|
||||
+ depends on CRYPTO_ARCH_HAVE_LIB_CHACHA || !CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
+ select CRYPTO_LIB_CHACHA_GENERIC if CRYPTO_ARCH_HAVE_LIB_CHACHA=n
|
||||
+ help
|
||||
+ Enable the ChaCha library interface. This interface may be fulfilled
|
||||
+ by either the generic implementation or an arch-specific one, if one
|
||||
+ is available and enabled.
|
||||
+
|
||||
config CRYPTO_LIB_DES
|
||||
tristate
|
||||
|
||||
--- a/lib/crypto/Makefile
|
||||
+++ b/lib/crypto/Makefile
|
||||
@@ -1,5 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
+# chacha is used by the /dev/random driver which is always builtin
|
||||
+obj-y += chacha.o
|
||||
+obj-$(CONFIG_CRYPTO_LIB_CHACHA_GENERIC) += libchacha.o
|
||||
+
|
||||
obj-$(CONFIG_CRYPTO_LIB_AES) += libaes.o
|
||||
libaes-y := aes.o
|
||||
|
||||
--- a/lib/chacha.c
|
||||
+++ /dev/null
|
||||
@@ -1,113 +0,0 @@
|
||||
-// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
-/*
|
||||
- * The "hash function" used as the core of the ChaCha stream cipher (RFC7539)
|
||||
- *
|
||||
- * Copyright (C) 2015 Martin Willi
|
||||
- */
|
||||
-
|
||||
-#include <linux/kernel.h>
|
||||
-#include <linux/export.h>
|
||||
-#include <linux/bitops.h>
|
||||
-#include <linux/cryptohash.h>
|
||||
-#include <asm/unaligned.h>
|
||||
-#include <crypto/chacha.h>
|
||||
-
|
||||
-static void chacha_permute(u32 *x, int nrounds)
|
||||
-{
|
||||
- int i;
|
||||
-
|
||||
- /* whitelist the allowed round counts */
|
||||
- WARN_ON_ONCE(nrounds != 20 && nrounds != 12);
|
||||
-
|
||||
- for (i = 0; i < nrounds; i += 2) {
|
||||
- x[0] += x[4]; x[12] = rol32(x[12] ^ x[0], 16);
|
||||
- x[1] += x[5]; x[13] = rol32(x[13] ^ x[1], 16);
|
||||
- x[2] += x[6]; x[14] = rol32(x[14] ^ x[2], 16);
|
||||
- x[3] += x[7]; x[15] = rol32(x[15] ^ x[3], 16);
|
||||
-
|
||||
- x[8] += x[12]; x[4] = rol32(x[4] ^ x[8], 12);
|
||||
- x[9] += x[13]; x[5] = rol32(x[5] ^ x[9], 12);
|
||||
- x[10] += x[14]; x[6] = rol32(x[6] ^ x[10], 12);
|
||||
- x[11] += x[15]; x[7] = rol32(x[7] ^ x[11], 12);
|
||||
-
|
||||
- x[0] += x[4]; x[12] = rol32(x[12] ^ x[0], 8);
|
||||
- x[1] += x[5]; x[13] = rol32(x[13] ^ x[1], 8);
|
||||
- x[2] += x[6]; x[14] = rol32(x[14] ^ x[2], 8);
|
||||
- x[3] += x[7]; x[15] = rol32(x[15] ^ x[3], 8);
|
||||
-
|
||||
- x[8] += x[12]; x[4] = rol32(x[4] ^ x[8], 7);
|
||||
- x[9] += x[13]; x[5] = rol32(x[5] ^ x[9], 7);
|
||||
- x[10] += x[14]; x[6] = rol32(x[6] ^ x[10], 7);
|
||||
- x[11] += x[15]; x[7] = rol32(x[7] ^ x[11], 7);
|
||||
-
|
||||
- x[0] += x[5]; x[15] = rol32(x[15] ^ x[0], 16);
|
||||
- x[1] += x[6]; x[12] = rol32(x[12] ^ x[1], 16);
|
||||
- x[2] += x[7]; x[13] = rol32(x[13] ^ x[2], 16);
|
||||
- x[3] += x[4]; x[14] = rol32(x[14] ^ x[3], 16);
|
||||
-
|
||||
- x[10] += x[15]; x[5] = rol32(x[5] ^ x[10], 12);
|
||||
- x[11] += x[12]; x[6] = rol32(x[6] ^ x[11], 12);
|
||||
- x[8] += x[13]; x[7] = rol32(x[7] ^ x[8], 12);
|
||||
- x[9] += x[14]; x[4] = rol32(x[4] ^ x[9], 12);
|
||||
-
|
||||
- x[0] += x[5]; x[15] = rol32(x[15] ^ x[0], 8);
|
||||
- x[1] += x[6]; x[12] = rol32(x[12] ^ x[1], 8);
|
||||
- x[2] += x[7]; x[13] = rol32(x[13] ^ x[2], 8);
|
||||
- x[3] += x[4]; x[14] = rol32(x[14] ^ x[3], 8);
|
||||
-
|
||||
- x[10] += x[15]; x[5] = rol32(x[5] ^ x[10], 7);
|
||||
- x[11] += x[12]; x[6] = rol32(x[6] ^ x[11], 7);
|
||||
- x[8] += x[13]; x[7] = rol32(x[7] ^ x[8], 7);
|
||||
- x[9] += x[14]; x[4] = rol32(x[4] ^ x[9], 7);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-/**
|
||||
- * chacha_block - generate one keystream block and increment block counter
|
||||
- * @state: input state matrix (16 32-bit words)
|
||||
- * @stream: output keystream block (64 bytes)
|
||||
- * @nrounds: number of rounds (20 or 12; 20 is recommended)
|
||||
- *
|
||||
- * This is the ChaCha core, a function from 64-byte strings to 64-byte strings.
|
||||
- * The caller has already converted the endianness of the input. This function
|
||||
- * also handles incrementing the block counter in the input matrix.
|
||||
- */
|
||||
-void chacha_block(u32 *state, u8 *stream, int nrounds)
|
||||
-{
|
||||
- u32 x[16];
|
||||
- int i;
|
||||
-
|
||||
- memcpy(x, state, 64);
|
||||
-
|
||||
- chacha_permute(x, nrounds);
|
||||
-
|
||||
- for (i = 0; i < ARRAY_SIZE(x); i++)
|
||||
- put_unaligned_le32(x[i] + state[i], &stream[i * sizeof(u32)]);
|
||||
-
|
||||
- state[12]++;
|
||||
-}
|
||||
-EXPORT_SYMBOL(chacha_block);
|
||||
-
|
||||
-/**
|
||||
- * hchacha_block - abbreviated ChaCha core, for XChaCha
|
||||
- * @in: input state matrix (16 32-bit words)
|
||||
- * @out: output (8 32-bit words)
|
||||
- * @nrounds: number of rounds (20 or 12; 20 is recommended)
|
||||
- *
|
||||
- * HChaCha is the ChaCha equivalent of HSalsa and is an intermediate step
|
||||
- * towards XChaCha (see https://cr.yp.to/snuffle/xsalsa-20081128.pdf). HChaCha
|
||||
- * skips the final addition of the initial state, and outputs only certain words
|
||||
- * of the state. It should not be used for streaming directly.
|
||||
- */
|
||||
-void hchacha_block(const u32 *in, u32 *out, int nrounds)
|
||||
-{
|
||||
- u32 x[16];
|
||||
-
|
||||
- memcpy(x, in, 64);
|
||||
-
|
||||
- chacha_permute(x, nrounds);
|
||||
-
|
||||
- memcpy(&out[0], &x[0], 16);
|
||||
- memcpy(&out[4], &x[12], 16);
|
||||
-}
|
||||
-EXPORT_SYMBOL(hchacha_block);
|
||||
--- /dev/null
|
||||
+++ b/lib/crypto/chacha.c
|
||||
@@ -0,0 +1,115 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+/*
|
||||
+ * The "hash function" used as the core of the ChaCha stream cipher (RFC7539)
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Martin Willi
|
||||
+ */
|
||||
+
|
||||
+#include <linux/bug.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/export.h>
|
||||
+#include <linux/bitops.h>
|
||||
+#include <linux/string.h>
|
||||
+#include <linux/cryptohash.h>
|
||||
+#include <asm/unaligned.h>
|
||||
+#include <crypto/chacha.h>
|
||||
+
|
||||
+static void chacha_permute(u32 *x, int nrounds)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ /* whitelist the allowed round counts */
|
||||
+ WARN_ON_ONCE(nrounds != 20 && nrounds != 12);
|
||||
+
|
||||
+ for (i = 0; i < nrounds; i += 2) {
|
||||
+ x[0] += x[4]; x[12] = rol32(x[12] ^ x[0], 16);
|
||||
+ x[1] += x[5]; x[13] = rol32(x[13] ^ x[1], 16);
|
||||
+ x[2] += x[6]; x[14] = rol32(x[14] ^ x[2], 16);
|
||||
+ x[3] += x[7]; x[15] = rol32(x[15] ^ x[3], 16);
|
||||
+
|
||||
+ x[8] += x[12]; x[4] = rol32(x[4] ^ x[8], 12);
|
||||
+ x[9] += x[13]; x[5] = rol32(x[5] ^ x[9], 12);
|
||||
+ x[10] += x[14]; x[6] = rol32(x[6] ^ x[10], 12);
|
||||
+ x[11] += x[15]; x[7] = rol32(x[7] ^ x[11], 12);
|
||||
+
|
||||
+ x[0] += x[4]; x[12] = rol32(x[12] ^ x[0], 8);
|
||||
+ x[1] += x[5]; x[13] = rol32(x[13] ^ x[1], 8);
|
||||
+ x[2] += x[6]; x[14] = rol32(x[14] ^ x[2], 8);
|
||||
+ x[3] += x[7]; x[15] = rol32(x[15] ^ x[3], 8);
|
||||
+
|
||||
+ x[8] += x[12]; x[4] = rol32(x[4] ^ x[8], 7);
|
||||
+ x[9] += x[13]; x[5] = rol32(x[5] ^ x[9], 7);
|
||||
+ x[10] += x[14]; x[6] = rol32(x[6] ^ x[10], 7);
|
||||
+ x[11] += x[15]; x[7] = rol32(x[7] ^ x[11], 7);
|
||||
+
|
||||
+ x[0] += x[5]; x[15] = rol32(x[15] ^ x[0], 16);
|
||||
+ x[1] += x[6]; x[12] = rol32(x[12] ^ x[1], 16);
|
||||
+ x[2] += x[7]; x[13] = rol32(x[13] ^ x[2], 16);
|
||||
+ x[3] += x[4]; x[14] = rol32(x[14] ^ x[3], 16);
|
||||
+
|
||||
+ x[10] += x[15]; x[5] = rol32(x[5] ^ x[10], 12);
|
||||
+ x[11] += x[12]; x[6] = rol32(x[6] ^ x[11], 12);
|
||||
+ x[8] += x[13]; x[7] = rol32(x[7] ^ x[8], 12);
|
||||
+ x[9] += x[14]; x[4] = rol32(x[4] ^ x[9], 12);
|
||||
+
|
||||
+ x[0] += x[5]; x[15] = rol32(x[15] ^ x[0], 8);
|
||||
+ x[1] += x[6]; x[12] = rol32(x[12] ^ x[1], 8);
|
||||
+ x[2] += x[7]; x[13] = rol32(x[13] ^ x[2], 8);
|
||||
+ x[3] += x[4]; x[14] = rol32(x[14] ^ x[3], 8);
|
||||
+
|
||||
+ x[10] += x[15]; x[5] = rol32(x[5] ^ x[10], 7);
|
||||
+ x[11] += x[12]; x[6] = rol32(x[6] ^ x[11], 7);
|
||||
+ x[8] += x[13]; x[7] = rol32(x[7] ^ x[8], 7);
|
||||
+ x[9] += x[14]; x[4] = rol32(x[4] ^ x[9], 7);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * chacha_block - generate one keystream block and increment block counter
|
||||
+ * @state: input state matrix (16 32-bit words)
|
||||
+ * @stream: output keystream block (64 bytes)
|
||||
+ * @nrounds: number of rounds (20 or 12; 20 is recommended)
|
||||
+ *
|
||||
+ * This is the ChaCha core, a function from 64-byte strings to 64-byte strings.
|
||||
+ * The caller has already converted the endianness of the input. This function
|
||||
+ * also handles incrementing the block counter in the input matrix.
|
||||
+ */
|
||||
+void chacha_block_generic(u32 *state, u8 *stream, int nrounds)
|
||||
+{
|
||||
+ u32 x[16];
|
||||
+ int i;
|
||||
+
|
||||
+ memcpy(x, state, 64);
|
||||
+
|
||||
+ chacha_permute(x, nrounds);
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(x); i++)
|
||||
+ put_unaligned_le32(x[i] + state[i], &stream[i * sizeof(u32)]);
|
||||
+
|
||||
+ state[12]++;
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_block_generic);
|
||||
+
|
||||
+/**
|
||||
+ * hchacha_block_generic - abbreviated ChaCha core, for XChaCha
|
||||
+ * @state: input state matrix (16 32-bit words)
|
||||
+ * @out: output (8 32-bit words)
|
||||
+ * @nrounds: number of rounds (20 or 12; 20 is recommended)
|
||||
+ *
|
||||
+ * HChaCha is the ChaCha equivalent of HSalsa and is an intermediate step
|
||||
+ * towards XChaCha (see https://cr.yp.to/snuffle/xsalsa-20081128.pdf). HChaCha
|
||||
+ * skips the final addition of the initial state, and outputs only certain words
|
||||
+ * of the state. It should not be used for streaming directly.
|
||||
+ */
|
||||
+void hchacha_block_generic(const u32 *state, u32 *stream, int nrounds)
|
||||
+{
|
||||
+ u32 x[16];
|
||||
+
|
||||
+ memcpy(x, state, 64);
|
||||
+
|
||||
+ chacha_permute(x, nrounds);
|
||||
+
|
||||
+ memcpy(&stream[0], &x[0], 16);
|
||||
+ memcpy(&stream[4], &x[12], 16);
|
||||
+}
|
||||
+EXPORT_SYMBOL(hchacha_block_generic);
|
||||
--- /dev/null
|
||||
+++ b/lib/crypto/libchacha.c
|
||||
@@ -0,0 +1,35 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+/*
|
||||
+ * The ChaCha stream cipher (RFC7539)
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Martin Willi
|
||||
+ */
|
||||
+
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/export.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include <crypto/algapi.h> // for crypto_xor_cpy
|
||||
+#include <crypto/chacha.h>
|
||||
+
|
||||
+void chacha_crypt_generic(u32 *state, u8 *dst, const u8 *src,
|
||||
+ unsigned int bytes, int nrounds)
|
||||
+{
|
||||
+ /* aligned to potentially speed up crypto_xor() */
|
||||
+ u8 stream[CHACHA_BLOCK_SIZE] __aligned(sizeof(long));
|
||||
+
|
||||
+ while (bytes >= CHACHA_BLOCK_SIZE) {
|
||||
+ chacha_block_generic(state, stream, nrounds);
|
||||
+ crypto_xor_cpy(dst, src, stream, CHACHA_BLOCK_SIZE);
|
||||
+ bytes -= CHACHA_BLOCK_SIZE;
|
||||
+ dst += CHACHA_BLOCK_SIZE;
|
||||
+ src += CHACHA_BLOCK_SIZE;
|
||||
+ }
|
||||
+ if (bytes) {
|
||||
+ chacha_block_generic(state, stream, nrounds);
|
||||
+ crypto_xor_cpy(dst, src, stream, bytes);
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_crypt_generic);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
@@ -1,192 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:09 +0100
|
||||
Subject: [PATCH] crypto: x86/chacha - depend on generic chacha library instead
|
||||
of crypto driver
|
||||
|
||||
commit 28e8d89b1ce8d2e7badfb5f69971dd635acb8863 upstream.
|
||||
|
||||
In preparation of extending the x86 ChaCha driver to also expose the ChaCha
|
||||
library interface, drop the dependency on the chacha_generic crypto driver
|
||||
as a non-SIMD fallback, and depend on the generic ChaCha library directly.
|
||||
This way, we only pull in the code we actually need, without registering
|
||||
a set of ChaCha skciphers that we will never use.
|
||||
|
||||
Since turning the FPU on and off is cheap these days, simplify the SIMD
|
||||
routine by dropping the per-page yield, which makes for a cleaner switch
|
||||
to the library API as well. This also allows use to invoke the skcipher
|
||||
walk routines in non-atomic mode.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/chacha_glue.c | 90 ++++++++++++++---------------------
|
||||
crypto/Kconfig | 2 +-
|
||||
2 files changed, 36 insertions(+), 56 deletions(-)
|
||||
|
||||
--- a/arch/x86/crypto/chacha_glue.c
|
||||
+++ b/arch/x86/crypto/chacha_glue.c
|
||||
@@ -123,37 +123,38 @@ static void chacha_dosimd(u32 *state, u8
|
||||
}
|
||||
}
|
||||
|
||||
-static int chacha_simd_stream_xor(struct skcipher_walk *walk,
|
||||
+static int chacha_simd_stream_xor(struct skcipher_request *req,
|
||||
const struct chacha_ctx *ctx, const u8 *iv)
|
||||
{
|
||||
u32 *state, state_buf[16 + 2] __aligned(8);
|
||||
- int next_yield = 4096; /* bytes until next FPU yield */
|
||||
- int err = 0;
|
||||
+ struct skcipher_walk walk;
|
||||
+ int err;
|
||||
+
|
||||
+ err = skcipher_walk_virt(&walk, req, false);
|
||||
|
||||
BUILD_BUG_ON(CHACHA_STATE_ALIGN != 16);
|
||||
state = PTR_ALIGN(state_buf + 0, CHACHA_STATE_ALIGN);
|
||||
|
||||
- crypto_chacha_init(state, ctx, iv);
|
||||
+ chacha_init_generic(state, ctx->key, iv);
|
||||
|
||||
- while (walk->nbytes > 0) {
|
||||
- unsigned int nbytes = walk->nbytes;
|
||||
+ while (walk.nbytes > 0) {
|
||||
+ unsigned int nbytes = walk.nbytes;
|
||||
|
||||
- if (nbytes < walk->total) {
|
||||
- nbytes = round_down(nbytes, walk->stride);
|
||||
- next_yield -= nbytes;
|
||||
- }
|
||||
-
|
||||
- chacha_dosimd(state, walk->dst.virt.addr, walk->src.virt.addr,
|
||||
- nbytes, ctx->nrounds);
|
||||
+ if (nbytes < walk.total)
|
||||
+ nbytes = round_down(nbytes, walk.stride);
|
||||
|
||||
- if (next_yield <= 0) {
|
||||
- /* temporarily allow preemption */
|
||||
- kernel_fpu_end();
|
||||
+ if (!crypto_simd_usable()) {
|
||||
+ chacha_crypt_generic(state, walk.dst.virt.addr,
|
||||
+ walk.src.virt.addr, nbytes,
|
||||
+ ctx->nrounds);
|
||||
+ } else {
|
||||
kernel_fpu_begin();
|
||||
- next_yield = 4096;
|
||||
+ chacha_dosimd(state, walk.dst.virt.addr,
|
||||
+ walk.src.virt.addr, nbytes,
|
||||
+ ctx->nrounds);
|
||||
+ kernel_fpu_end();
|
||||
}
|
||||
-
|
||||
- err = skcipher_walk_done(walk, walk->nbytes - nbytes);
|
||||
+ err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
||||
}
|
||||
|
||||
return err;
|
||||
@@ -163,55 +164,34 @@ static int chacha_simd(struct skcipher_r
|
||||
{
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
- struct skcipher_walk walk;
|
||||
- int err;
|
||||
-
|
||||
- if (req->cryptlen <= CHACHA_BLOCK_SIZE || !crypto_simd_usable())
|
||||
- return crypto_chacha_crypt(req);
|
||||
|
||||
- err = skcipher_walk_virt(&walk, req, true);
|
||||
- if (err)
|
||||
- return err;
|
||||
-
|
||||
- kernel_fpu_begin();
|
||||
- err = chacha_simd_stream_xor(&walk, ctx, req->iv);
|
||||
- kernel_fpu_end();
|
||||
- return err;
|
||||
+ return chacha_simd_stream_xor(req, ctx, req->iv);
|
||||
}
|
||||
|
||||
static int xchacha_simd(struct skcipher_request *req)
|
||||
{
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
- struct skcipher_walk walk;
|
||||
- struct chacha_ctx subctx;
|
||||
u32 *state, state_buf[16 + 2] __aligned(8);
|
||||
+ struct chacha_ctx subctx;
|
||||
u8 real_iv[16];
|
||||
- int err;
|
||||
-
|
||||
- if (req->cryptlen <= CHACHA_BLOCK_SIZE || !crypto_simd_usable())
|
||||
- return crypto_xchacha_crypt(req);
|
||||
-
|
||||
- err = skcipher_walk_virt(&walk, req, true);
|
||||
- if (err)
|
||||
- return err;
|
||||
|
||||
BUILD_BUG_ON(CHACHA_STATE_ALIGN != 16);
|
||||
state = PTR_ALIGN(state_buf + 0, CHACHA_STATE_ALIGN);
|
||||
- crypto_chacha_init(state, ctx, req->iv);
|
||||
+ chacha_init_generic(state, ctx->key, req->iv);
|
||||
|
||||
- kernel_fpu_begin();
|
||||
-
|
||||
- hchacha_block_ssse3(state, subctx.key, ctx->nrounds);
|
||||
+ if (req->cryptlen > CHACHA_BLOCK_SIZE && crypto_simd_usable()) {
|
||||
+ kernel_fpu_begin();
|
||||
+ hchacha_block_ssse3(state, subctx.key, ctx->nrounds);
|
||||
+ kernel_fpu_end();
|
||||
+ } else {
|
||||
+ hchacha_block_generic(state, subctx.key, ctx->nrounds);
|
||||
+ }
|
||||
subctx.nrounds = ctx->nrounds;
|
||||
|
||||
memcpy(&real_iv[0], req->iv + 24, 8);
|
||||
memcpy(&real_iv[8], req->iv + 16, 8);
|
||||
- err = chacha_simd_stream_xor(&walk, &subctx, real_iv);
|
||||
-
|
||||
- kernel_fpu_end();
|
||||
-
|
||||
- return err;
|
||||
+ return chacha_simd_stream_xor(req, &subctx, real_iv);
|
||||
}
|
||||
|
||||
static struct skcipher_alg algs[] = {
|
||||
@@ -227,7 +207,7 @@ static struct skcipher_alg algs[] = {
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = CHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
+ .setkey = chacha20_setkey,
|
||||
.encrypt = chacha_simd,
|
||||
.decrypt = chacha_simd,
|
||||
}, {
|
||||
@@ -242,7 +222,7 @@ static struct skcipher_alg algs[] = {
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
+ .setkey = chacha20_setkey,
|
||||
.encrypt = xchacha_simd,
|
||||
.decrypt = xchacha_simd,
|
||||
}, {
|
||||
@@ -257,7 +237,7 @@ static struct skcipher_alg algs[] = {
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha12_setkey,
|
||||
+ .setkey = chacha12_setkey,
|
||||
.encrypt = xchacha_simd,
|
||||
.decrypt = xchacha_simd,
|
||||
},
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -1417,7 +1417,7 @@ config CRYPTO_CHACHA20_X86_64
|
||||
tristate "ChaCha stream cipher algorithms (x86_64/SSSE3/AVX2/AVX-512VL)"
|
||||
depends on X86 && 64BIT
|
||||
select CRYPTO_BLKCIPHER
|
||||
- select CRYPTO_CHACHA20
|
||||
+ select CRYPTO_LIB_CHACHA_GENERIC
|
||||
help
|
||||
SSSE3, AVX2, and AVX-512VL optimized implementations of the ChaCha20,
|
||||
XChaCha20, and XChaCha12 stream ciphers.
|
||||
@@ -1,205 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:10 +0100
|
||||
Subject: [PATCH] crypto: x86/chacha - expose SIMD ChaCha routine as library
|
||||
function
|
||||
|
||||
commit 84e03fa39fbe95a5567d43bff458c6d3b3a23ad1 upstream.
|
||||
|
||||
Wire the existing x86 SIMD ChaCha code into the new ChaCha library
|
||||
interface, so that users of the library interface will get the
|
||||
accelerated version when available.
|
||||
|
||||
Given that calls into the library API will always go through the
|
||||
routines in this module if it is enabled, switch to static keys
|
||||
to select the optimal implementation available (which may be none
|
||||
at all, in which case we defer to the generic implementation for
|
||||
all invocations).
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/chacha_glue.c | 91 +++++++++++++++++++++++++----------
|
||||
crypto/Kconfig | 1 +
|
||||
include/crypto/chacha.h | 6 +++
|
||||
3 files changed, 73 insertions(+), 25 deletions(-)
|
||||
|
||||
--- a/arch/x86/crypto/chacha_glue.c
|
||||
+++ b/arch/x86/crypto/chacha_glue.c
|
||||
@@ -21,24 +21,24 @@ asmlinkage void chacha_block_xor_ssse3(u
|
||||
asmlinkage void chacha_4block_xor_ssse3(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
asmlinkage void hchacha_block_ssse3(const u32 *state, u32 *out, int nrounds);
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
+
|
||||
asmlinkage void chacha_2block_xor_avx2(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
asmlinkage void chacha_4block_xor_avx2(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
asmlinkage void chacha_8block_xor_avx2(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
-static bool chacha_use_avx2;
|
||||
-#ifdef CONFIG_AS_AVX512
|
||||
+
|
||||
asmlinkage void chacha_2block_xor_avx512vl(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
asmlinkage void chacha_4block_xor_avx512vl(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
asmlinkage void chacha_8block_xor_avx512vl(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int len, int nrounds);
|
||||
-static bool chacha_use_avx512vl;
|
||||
-#endif
|
||||
-#endif
|
||||
+
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(chacha_use_simd);
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(chacha_use_avx2);
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(chacha_use_avx512vl);
|
||||
|
||||
static unsigned int chacha_advance(unsigned int len, unsigned int maxblocks)
|
||||
{
|
||||
@@ -49,9 +49,8 @@ static unsigned int chacha_advance(unsig
|
||||
static void chacha_dosimd(u32 *state, u8 *dst, const u8 *src,
|
||||
unsigned int bytes, int nrounds)
|
||||
{
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
-#ifdef CONFIG_AS_AVX512
|
||||
- if (chacha_use_avx512vl) {
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX512) &&
|
||||
+ static_branch_likely(&chacha_use_avx512vl)) {
|
||||
while (bytes >= CHACHA_BLOCK_SIZE * 8) {
|
||||
chacha_8block_xor_avx512vl(state, dst, src, bytes,
|
||||
nrounds);
|
||||
@@ -79,8 +78,9 @@ static void chacha_dosimd(u32 *state, u8
|
||||
return;
|
||||
}
|
||||
}
|
||||
-#endif
|
||||
- if (chacha_use_avx2) {
|
||||
+
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX2) &&
|
||||
+ static_branch_likely(&chacha_use_avx2)) {
|
||||
while (bytes >= CHACHA_BLOCK_SIZE * 8) {
|
||||
chacha_8block_xor_avx2(state, dst, src, bytes, nrounds);
|
||||
bytes -= CHACHA_BLOCK_SIZE * 8;
|
||||
@@ -104,7 +104,7 @@ static void chacha_dosimd(u32 *state, u8
|
||||
return;
|
||||
}
|
||||
}
|
||||
-#endif
|
||||
+
|
||||
while (bytes >= CHACHA_BLOCK_SIZE * 4) {
|
||||
chacha_4block_xor_ssse3(state, dst, src, bytes, nrounds);
|
||||
bytes -= CHACHA_BLOCK_SIZE * 4;
|
||||
@@ -123,6 +123,43 @@ static void chacha_dosimd(u32 *state, u8
|
||||
}
|
||||
}
|
||||
|
||||
+void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
|
||||
+{
|
||||
+ state = PTR_ALIGN(state, CHACHA_STATE_ALIGN);
|
||||
+
|
||||
+ if (!static_branch_likely(&chacha_use_simd) || !crypto_simd_usable()) {
|
||||
+ hchacha_block_generic(state, stream, nrounds);
|
||||
+ } else {
|
||||
+ kernel_fpu_begin();
|
||||
+ hchacha_block_ssse3(state, stream, nrounds);
|
||||
+ kernel_fpu_end();
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL(hchacha_block_arch);
|
||||
+
|
||||
+void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
|
||||
+{
|
||||
+ state = PTR_ALIGN(state, CHACHA_STATE_ALIGN);
|
||||
+
|
||||
+ chacha_init_generic(state, key, iv);
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_init_arch);
|
||||
+
|
||||
+void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
|
||||
+ int nrounds)
|
||||
+{
|
||||
+ state = PTR_ALIGN(state, CHACHA_STATE_ALIGN);
|
||||
+
|
||||
+ if (!static_branch_likely(&chacha_use_simd) || !crypto_simd_usable() ||
|
||||
+ bytes <= CHACHA_BLOCK_SIZE)
|
||||
+ return chacha_crypt_generic(state, dst, src, bytes, nrounds);
|
||||
+
|
||||
+ kernel_fpu_begin();
|
||||
+ chacha_dosimd(state, dst, src, bytes, nrounds);
|
||||
+ kernel_fpu_end();
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_crypt_arch);
|
||||
+
|
||||
static int chacha_simd_stream_xor(struct skcipher_request *req,
|
||||
const struct chacha_ctx *ctx, const u8 *iv)
|
||||
{
|
||||
@@ -143,7 +180,8 @@ static int chacha_simd_stream_xor(struct
|
||||
if (nbytes < walk.total)
|
||||
nbytes = round_down(nbytes, walk.stride);
|
||||
|
||||
- if (!crypto_simd_usable()) {
|
||||
+ if (!static_branch_likely(&chacha_use_simd) ||
|
||||
+ !crypto_simd_usable()) {
|
||||
chacha_crypt_generic(state, walk.dst.virt.addr,
|
||||
walk.src.virt.addr, nbytes,
|
||||
ctx->nrounds);
|
||||
@@ -246,18 +284,21 @@ static struct skcipher_alg algs[] = {
|
||||
static int __init chacha_simd_mod_init(void)
|
||||
{
|
||||
if (!boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
- return -ENODEV;
|
||||
+ return 0;
|
||||
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
- chacha_use_avx2 = boot_cpu_has(X86_FEATURE_AVX) &&
|
||||
- boot_cpu_has(X86_FEATURE_AVX2) &&
|
||||
- cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL);
|
||||
-#ifdef CONFIG_AS_AVX512
|
||||
- chacha_use_avx512vl = chacha_use_avx2 &&
|
||||
- boot_cpu_has(X86_FEATURE_AVX512VL) &&
|
||||
- boot_cpu_has(X86_FEATURE_AVX512BW); /* kmovq */
|
||||
-#endif
|
||||
-#endif
|
||||
+ static_branch_enable(&chacha_use_simd);
|
||||
+
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX2) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX2) &&
|
||||
+ cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL)) {
|
||||
+ static_branch_enable(&chacha_use_avx2);
|
||||
+
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX512) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX512VL) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX512BW)) /* kmovq */
|
||||
+ static_branch_enable(&chacha_use_avx512vl);
|
||||
+ }
|
||||
return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -1418,6 +1418,7 @@ config CRYPTO_CHACHA20_X86_64
|
||||
depends on X86 && 64BIT
|
||||
select CRYPTO_BLKCIPHER
|
||||
select CRYPTO_LIB_CHACHA_GENERIC
|
||||
+ select CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
help
|
||||
SSSE3, AVX2, and AVX-512VL optimized implementations of the ChaCha20,
|
||||
XChaCha20, and XChaCha12 stream ciphers.
|
||||
--- a/include/crypto/chacha.h
|
||||
+++ b/include/crypto/chacha.h
|
||||
@@ -25,6 +25,12 @@
|
||||
#define CHACHA_BLOCK_SIZE 64
|
||||
#define CHACHAPOLY_IV_SIZE 12
|
||||
|
||||
+#ifdef CONFIG_X86_64
|
||||
+#define CHACHA_STATE_WORDS ((CHACHA_BLOCK_SIZE + 12) / sizeof(u32))
|
||||
+#else
|
||||
+#define CHACHA_STATE_WORDS (CHACHA_BLOCK_SIZE / sizeof(u32))
|
||||
+#endif
|
||||
+
|
||||
/* 192-bit nonce, then 64-bit stream position */
|
||||
#define XCHACHA_IV_SIZE 32
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:11 +0100
|
||||
Subject: [PATCH] crypto: arm64/chacha - depend on generic chacha library
|
||||
instead of crypto driver
|
||||
|
||||
commit c77da4867cbb7841177275dbb250f5c09679fae4 upstream.
|
||||
|
||||
Depend on the generic ChaCha library routines instead of pulling in the
|
||||
generic ChaCha skcipher driver, which is more than we need, and makes
|
||||
managing the dependencies between the generic library, generic driver,
|
||||
accelerated library and driver more complicated.
|
||||
|
||||
While at it, drop the logic to prefer the scalar code on short inputs.
|
||||
Turning the NEON on and off is cheap these days, and one major use case
|
||||
for ChaCha20 is ChaCha20-Poly1305, which is guaranteed to hit the scalar
|
||||
path upon every invocation (when doing the Poly1305 nonce generation)
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm64/crypto/Kconfig | 2 +-
|
||||
arch/arm64/crypto/chacha-neon-glue.c | 40 +++++++++++++++-------------
|
||||
2 files changed, 23 insertions(+), 19 deletions(-)
|
||||
|
||||
--- a/arch/arm64/crypto/Kconfig
|
||||
+++ b/arch/arm64/crypto/Kconfig
|
||||
@@ -103,7 +103,7 @@ config CRYPTO_CHACHA20_NEON
|
||||
tristate "ChaCha20, XChaCha20, and XChaCha12 stream ciphers using NEON instructions"
|
||||
depends on KERNEL_MODE_NEON
|
||||
select CRYPTO_BLKCIPHER
|
||||
- select CRYPTO_CHACHA20
|
||||
+ select CRYPTO_LIB_CHACHA_GENERIC
|
||||
|
||||
config CRYPTO_NHPOLY1305_NEON
|
||||
tristate "NHPoly1305 hash function using NEON instructions (for Adiantum)"
|
||||
--- a/arch/arm64/crypto/chacha-neon-glue.c
|
||||
+++ b/arch/arm64/crypto/chacha-neon-glue.c
|
||||
@@ -68,7 +68,7 @@ static int chacha_neon_stream_xor(struct
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
|
||||
- crypto_chacha_init(state, ctx, iv);
|
||||
+ chacha_init_generic(state, ctx->key, iv);
|
||||
|
||||
while (walk.nbytes > 0) {
|
||||
unsigned int nbytes = walk.nbytes;
|
||||
@@ -76,10 +76,16 @@ static int chacha_neon_stream_xor(struct
|
||||
if (nbytes < walk.total)
|
||||
nbytes = rounddown(nbytes, walk.stride);
|
||||
|
||||
- kernel_neon_begin();
|
||||
- chacha_doneon(state, walk.dst.virt.addr, walk.src.virt.addr,
|
||||
- nbytes, ctx->nrounds);
|
||||
- kernel_neon_end();
|
||||
+ if (!crypto_simd_usable()) {
|
||||
+ chacha_crypt_generic(state, walk.dst.virt.addr,
|
||||
+ walk.src.virt.addr, nbytes,
|
||||
+ ctx->nrounds);
|
||||
+ } else {
|
||||
+ kernel_neon_begin();
|
||||
+ chacha_doneon(state, walk.dst.virt.addr,
|
||||
+ walk.src.virt.addr, nbytes, ctx->nrounds);
|
||||
+ kernel_neon_end();
|
||||
+ }
|
||||
err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
||||
}
|
||||
|
||||
@@ -91,9 +97,6 @@ static int chacha_neon(struct skcipher_r
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
|
||||
- if (req->cryptlen <= CHACHA_BLOCK_SIZE || !crypto_simd_usable())
|
||||
- return crypto_chacha_crypt(req);
|
||||
-
|
||||
return chacha_neon_stream_xor(req, ctx, req->iv);
|
||||
}
|
||||
|
||||
@@ -105,14 +108,15 @@ static int xchacha_neon(struct skcipher_
|
||||
u32 state[16];
|
||||
u8 real_iv[16];
|
||||
|
||||
- if (req->cryptlen <= CHACHA_BLOCK_SIZE || !crypto_simd_usable())
|
||||
- return crypto_xchacha_crypt(req);
|
||||
-
|
||||
- crypto_chacha_init(state, ctx, req->iv);
|
||||
+ chacha_init_generic(state, ctx->key, req->iv);
|
||||
|
||||
- kernel_neon_begin();
|
||||
- hchacha_block_neon(state, subctx.key, ctx->nrounds);
|
||||
- kernel_neon_end();
|
||||
+ if (crypto_simd_usable()) {
|
||||
+ kernel_neon_begin();
|
||||
+ hchacha_block_neon(state, subctx.key, ctx->nrounds);
|
||||
+ kernel_neon_end();
|
||||
+ } else {
|
||||
+ hchacha_block_generic(state, subctx.key, ctx->nrounds);
|
||||
+ }
|
||||
subctx.nrounds = ctx->nrounds;
|
||||
|
||||
memcpy(&real_iv[0], req->iv + 24, 8);
|
||||
@@ -134,7 +138,7 @@ static struct skcipher_alg algs[] = {
|
||||
.ivsize = CHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
.walksize = 5 * CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
+ .setkey = chacha20_setkey,
|
||||
.encrypt = chacha_neon,
|
||||
.decrypt = chacha_neon,
|
||||
}, {
|
||||
@@ -150,7 +154,7 @@ static struct skcipher_alg algs[] = {
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
.walksize = 5 * CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
+ .setkey = chacha20_setkey,
|
||||
.encrypt = xchacha_neon,
|
||||
.decrypt = xchacha_neon,
|
||||
}, {
|
||||
@@ -166,7 +170,7 @@ static struct skcipher_alg algs[] = {
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
.walksize = 5 * CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha12_setkey,
|
||||
+ .setkey = chacha12_setkey,
|
||||
.encrypt = xchacha_neon,
|
||||
.decrypt = xchacha_neon,
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:12 +0100
|
||||
Subject: [PATCH] crypto: arm64/chacha - expose arm64 ChaCha routine as library
|
||||
function
|
||||
|
||||
commit b3aad5bad26a01a4bd8c49a5c5f52aec665f3b7c upstream.
|
||||
|
||||
Expose the accelerated NEON ChaCha routine directly as a symbol
|
||||
export so that users of the ChaCha library API can use it directly.
|
||||
|
||||
Given that calls into the library API will always go through the
|
||||
routines in this module if it is enabled, switch to static keys
|
||||
to select the optimal implementation available (which may be none
|
||||
at all, in which case we defer to the generic implementation for
|
||||
all invocations).
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm64/crypto/Kconfig | 1 +
|
||||
arch/arm64/crypto/chacha-neon-glue.c | 53 ++++++++++++++++++++++------
|
||||
2 files changed, 43 insertions(+), 11 deletions(-)
|
||||
|
||||
--- a/arch/arm64/crypto/Kconfig
|
||||
+++ b/arch/arm64/crypto/Kconfig
|
||||
@@ -104,6 +104,7 @@ config CRYPTO_CHACHA20_NEON
|
||||
depends on KERNEL_MODE_NEON
|
||||
select CRYPTO_BLKCIPHER
|
||||
select CRYPTO_LIB_CHACHA_GENERIC
|
||||
+ select CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
|
||||
config CRYPTO_NHPOLY1305_NEON
|
||||
tristate "NHPoly1305 hash function using NEON instructions (for Adiantum)"
|
||||
--- a/arch/arm64/crypto/chacha-neon-glue.c
|
||||
+++ b/arch/arm64/crypto/chacha-neon-glue.c
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <crypto/internal/chacha.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
+#include <linux/jump_label.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
@@ -36,6 +37,8 @@ asmlinkage void chacha_4block_xor_neon(u
|
||||
int nrounds, int bytes);
|
||||
asmlinkage void hchacha_block_neon(const u32 *state, u32 *out, int nrounds);
|
||||
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);
|
||||
+
|
||||
static void chacha_doneon(u32 *state, u8 *dst, const u8 *src,
|
||||
int bytes, int nrounds)
|
||||
{
|
||||
@@ -59,6 +62,37 @@ static void chacha_doneon(u32 *state, u8
|
||||
}
|
||||
}
|
||||
|
||||
+void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
|
||||
+{
|
||||
+ if (!static_branch_likely(&have_neon) || !crypto_simd_usable()) {
|
||||
+ hchacha_block_generic(state, stream, nrounds);
|
||||
+ } else {
|
||||
+ kernel_neon_begin();
|
||||
+ hchacha_block_neon(state, stream, nrounds);
|
||||
+ kernel_neon_end();
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL(hchacha_block_arch);
|
||||
+
|
||||
+void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
|
||||
+{
|
||||
+ chacha_init_generic(state, key, iv);
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_init_arch);
|
||||
+
|
||||
+void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
|
||||
+ int nrounds)
|
||||
+{
|
||||
+ if (!static_branch_likely(&have_neon) || bytes <= CHACHA_BLOCK_SIZE ||
|
||||
+ !crypto_simd_usable())
|
||||
+ return chacha_crypt_generic(state, dst, src, bytes, nrounds);
|
||||
+
|
||||
+ kernel_neon_begin();
|
||||
+ chacha_doneon(state, dst, src, bytes, nrounds);
|
||||
+ kernel_neon_end();
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_crypt_arch);
|
||||
+
|
||||
static int chacha_neon_stream_xor(struct skcipher_request *req,
|
||||
const struct chacha_ctx *ctx, const u8 *iv)
|
||||
{
|
||||
@@ -76,7 +110,8 @@ static int chacha_neon_stream_xor(struct
|
||||
if (nbytes < walk.total)
|
||||
nbytes = rounddown(nbytes, walk.stride);
|
||||
|
||||
- if (!crypto_simd_usable()) {
|
||||
+ if (!static_branch_likely(&have_neon) ||
|
||||
+ !crypto_simd_usable()) {
|
||||
chacha_crypt_generic(state, walk.dst.virt.addr,
|
||||
walk.src.virt.addr, nbytes,
|
||||
ctx->nrounds);
|
||||
@@ -109,14 +144,7 @@ static int xchacha_neon(struct skcipher_
|
||||
u8 real_iv[16];
|
||||
|
||||
chacha_init_generic(state, ctx->key, req->iv);
|
||||
-
|
||||
- if (crypto_simd_usable()) {
|
||||
- kernel_neon_begin();
|
||||
- hchacha_block_neon(state, subctx.key, ctx->nrounds);
|
||||
- kernel_neon_end();
|
||||
- } else {
|
||||
- hchacha_block_generic(state, subctx.key, ctx->nrounds);
|
||||
- }
|
||||
+ hchacha_block_arch(state, subctx.key, ctx->nrounds);
|
||||
subctx.nrounds = ctx->nrounds;
|
||||
|
||||
memcpy(&real_iv[0], req->iv + 24, 8);
|
||||
@@ -179,14 +207,17 @@ static struct skcipher_alg algs[] = {
|
||||
static int __init chacha_simd_mod_init(void)
|
||||
{
|
||||
if (!cpu_have_named_feature(ASIMD))
|
||||
- return -ENODEV;
|
||||
+ return 0;
|
||||
+
|
||||
+ static_branch_enable(&have_neon);
|
||||
|
||||
return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
static void __exit chacha_simd_mod_fini(void)
|
||||
{
|
||||
- crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+ if (cpu_have_named_feature(ASIMD))
|
||||
+ crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
module_init(chacha_simd_mod_init);
|
||||
@@ -1,480 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:13 +0100
|
||||
Subject: [PATCH] crypto: arm/chacha - import Eric Biggers's scalar accelerated
|
||||
ChaCha code
|
||||
|
||||
commit 29621d099f9c642b22a69dc8e7e20c108473a392 upstream.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/chacha-scalar-core.S | 461 +++++++++++++++++++++++++++
|
||||
1 file changed, 461 insertions(+)
|
||||
create mode 100644 arch/arm/crypto/chacha-scalar-core.S
|
||||
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/crypto/chacha-scalar-core.S
|
||||
@@ -0,0 +1,461 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * Copyright (C) 2018 Google, Inc.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/linkage.h>
|
||||
+#include <asm/assembler.h>
|
||||
+
|
||||
+/*
|
||||
+ * Design notes:
|
||||
+ *
|
||||
+ * 16 registers would be needed to hold the state matrix, but only 14 are
|
||||
+ * available because 'sp' and 'pc' cannot be used. So we spill the elements
|
||||
+ * (x8, x9) to the stack and swap them out with (x10, x11). This adds one
|
||||
+ * 'ldrd' and one 'strd' instruction per round.
|
||||
+ *
|
||||
+ * All rotates are performed using the implicit rotate operand accepted by the
|
||||
+ * 'add' and 'eor' instructions. This is faster than using explicit rotate
|
||||
+ * instructions. To make this work, we allow the values in the second and last
|
||||
+ * rows of the ChaCha state matrix (rows 'b' and 'd') to temporarily have the
|
||||
+ * wrong rotation amount. The rotation amount is then fixed up just in time
|
||||
+ * when the values are used. 'brot' is the number of bits the values in row 'b'
|
||||
+ * need to be rotated right to arrive at the correct values, and 'drot'
|
||||
+ * similarly for row 'd'. (brot, drot) start out as (0, 0) but we make it such
|
||||
+ * that they end up as (25, 24) after every round.
|
||||
+ */
|
||||
+
|
||||
+ // ChaCha state registers
|
||||
+ X0 .req r0
|
||||
+ X1 .req r1
|
||||
+ X2 .req r2
|
||||
+ X3 .req r3
|
||||
+ X4 .req r4
|
||||
+ X5 .req r5
|
||||
+ X6 .req r6
|
||||
+ X7 .req r7
|
||||
+ X8_X10 .req r8 // shared by x8 and x10
|
||||
+ X9_X11 .req r9 // shared by x9 and x11
|
||||
+ X12 .req r10
|
||||
+ X13 .req r11
|
||||
+ X14 .req r12
|
||||
+ X15 .req r14
|
||||
+
|
||||
+.Lexpand_32byte_k:
|
||||
+ // "expand 32-byte k"
|
||||
+ .word 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574
|
||||
+
|
||||
+#ifdef __thumb2__
|
||||
+# define adrl adr
|
||||
+#endif
|
||||
+
|
||||
+.macro __rev out, in, t0, t1, t2
|
||||
+.if __LINUX_ARM_ARCH__ >= 6
|
||||
+ rev \out, \in
|
||||
+.else
|
||||
+ lsl \t0, \in, #24
|
||||
+ and \t1, \in, #0xff00
|
||||
+ and \t2, \in, #0xff0000
|
||||
+ orr \out, \t0, \in, lsr #24
|
||||
+ orr \out, \out, \t1, lsl #8
|
||||
+ orr \out, \out, \t2, lsr #8
|
||||
+.endif
|
||||
+.endm
|
||||
+
|
||||
+.macro _le32_bswap x, t0, t1, t2
|
||||
+#ifdef __ARMEB__
|
||||
+ __rev \x, \x, \t0, \t1, \t2
|
||||
+#endif
|
||||
+.endm
|
||||
+
|
||||
+.macro _le32_bswap_4x a, b, c, d, t0, t1, t2
|
||||
+ _le32_bswap \a, \t0, \t1, \t2
|
||||
+ _le32_bswap \b, \t0, \t1, \t2
|
||||
+ _le32_bswap \c, \t0, \t1, \t2
|
||||
+ _le32_bswap \d, \t0, \t1, \t2
|
||||
+.endm
|
||||
+
|
||||
+.macro __ldrd a, b, src, offset
|
||||
+#if __LINUX_ARM_ARCH__ >= 6
|
||||
+ ldrd \a, \b, [\src, #\offset]
|
||||
+#else
|
||||
+ ldr \a, [\src, #\offset]
|
||||
+ ldr \b, [\src, #\offset + 4]
|
||||
+#endif
|
||||
+.endm
|
||||
+
|
||||
+.macro __strd a, b, dst, offset
|
||||
+#if __LINUX_ARM_ARCH__ >= 6
|
||||
+ strd \a, \b, [\dst, #\offset]
|
||||
+#else
|
||||
+ str \a, [\dst, #\offset]
|
||||
+ str \b, [\dst, #\offset + 4]
|
||||
+#endif
|
||||
+.endm
|
||||
+
|
||||
+.macro _halfround a1, b1, c1, d1, a2, b2, c2, d2
|
||||
+
|
||||
+ // a += b; d ^= a; d = rol(d, 16);
|
||||
+ add \a1, \a1, \b1, ror #brot
|
||||
+ add \a2, \a2, \b2, ror #brot
|
||||
+ eor \d1, \a1, \d1, ror #drot
|
||||
+ eor \d2, \a2, \d2, ror #drot
|
||||
+ // drot == 32 - 16 == 16
|
||||
+
|
||||
+ // c += d; b ^= c; b = rol(b, 12);
|
||||
+ add \c1, \c1, \d1, ror #16
|
||||
+ add \c2, \c2, \d2, ror #16
|
||||
+ eor \b1, \c1, \b1, ror #brot
|
||||
+ eor \b2, \c2, \b2, ror #brot
|
||||
+ // brot == 32 - 12 == 20
|
||||
+
|
||||
+ // a += b; d ^= a; d = rol(d, 8);
|
||||
+ add \a1, \a1, \b1, ror #20
|
||||
+ add \a2, \a2, \b2, ror #20
|
||||
+ eor \d1, \a1, \d1, ror #16
|
||||
+ eor \d2, \a2, \d2, ror #16
|
||||
+ // drot == 32 - 8 == 24
|
||||
+
|
||||
+ // c += d; b ^= c; b = rol(b, 7);
|
||||
+ add \c1, \c1, \d1, ror #24
|
||||
+ add \c2, \c2, \d2, ror #24
|
||||
+ eor \b1, \c1, \b1, ror #20
|
||||
+ eor \b2, \c2, \b2, ror #20
|
||||
+ // brot == 32 - 7 == 25
|
||||
+.endm
|
||||
+
|
||||
+.macro _doubleround
|
||||
+
|
||||
+ // column round
|
||||
+
|
||||
+ // quarterrounds: (x0, x4, x8, x12) and (x1, x5, x9, x13)
|
||||
+ _halfround X0, X4, X8_X10, X12, X1, X5, X9_X11, X13
|
||||
+
|
||||
+ // save (x8, x9); restore (x10, x11)
|
||||
+ __strd X8_X10, X9_X11, sp, 0
|
||||
+ __ldrd X8_X10, X9_X11, sp, 8
|
||||
+
|
||||
+ // quarterrounds: (x2, x6, x10, x14) and (x3, x7, x11, x15)
|
||||
+ _halfround X2, X6, X8_X10, X14, X3, X7, X9_X11, X15
|
||||
+
|
||||
+ .set brot, 25
|
||||
+ .set drot, 24
|
||||
+
|
||||
+ // diagonal round
|
||||
+
|
||||
+ // quarterrounds: (x0, x5, x10, x15) and (x1, x6, x11, x12)
|
||||
+ _halfround X0, X5, X8_X10, X15, X1, X6, X9_X11, X12
|
||||
+
|
||||
+ // save (x10, x11); restore (x8, x9)
|
||||
+ __strd X8_X10, X9_X11, sp, 8
|
||||
+ __ldrd X8_X10, X9_X11, sp, 0
|
||||
+
|
||||
+ // quarterrounds: (x2, x7, x8, x13) and (x3, x4, x9, x14)
|
||||
+ _halfround X2, X7, X8_X10, X13, X3, X4, X9_X11, X14
|
||||
+.endm
|
||||
+
|
||||
+.macro _chacha_permute nrounds
|
||||
+ .set brot, 0
|
||||
+ .set drot, 0
|
||||
+ .rept \nrounds / 2
|
||||
+ _doubleround
|
||||
+ .endr
|
||||
+.endm
|
||||
+
|
||||
+.macro _chacha nrounds
|
||||
+
|
||||
+.Lnext_block\@:
|
||||
+ // Stack: unused0-unused1 x10-x11 x0-x15 OUT IN LEN
|
||||
+ // Registers contain x0-x9,x12-x15.
|
||||
+
|
||||
+ // Do the core ChaCha permutation to update x0-x15.
|
||||
+ _chacha_permute \nrounds
|
||||
+
|
||||
+ add sp, #8
|
||||
+ // Stack: x10-x11 orig_x0-orig_x15 OUT IN LEN
|
||||
+ // Registers contain x0-x9,x12-x15.
|
||||
+ // x4-x7 are rotated by 'brot'; x12-x15 are rotated by 'drot'.
|
||||
+
|
||||
+ // Free up some registers (r8-r12,r14) by pushing (x8-x9,x12-x15).
|
||||
+ push {X8_X10, X9_X11, X12, X13, X14, X15}
|
||||
+
|
||||
+ // Load (OUT, IN, LEN).
|
||||
+ ldr r14, [sp, #96]
|
||||
+ ldr r12, [sp, #100]
|
||||
+ ldr r11, [sp, #104]
|
||||
+
|
||||
+ orr r10, r14, r12
|
||||
+
|
||||
+ // Use slow path if fewer than 64 bytes remain.
|
||||
+ cmp r11, #64
|
||||
+ blt .Lxor_slowpath\@
|
||||
+
|
||||
+ // Use slow path if IN and/or OUT isn't 4-byte aligned. Needed even on
|
||||
+ // ARMv6+, since ldmia and stmia (used below) still require alignment.
|
||||
+ tst r10, #3
|
||||
+ bne .Lxor_slowpath\@
|
||||
+
|
||||
+ // Fast path: XOR 64 bytes of aligned data.
|
||||
+
|
||||
+ // Stack: x8-x9 x12-x15 x10-x11 orig_x0-orig_x15 OUT IN LEN
|
||||
+ // Registers: r0-r7 are x0-x7; r8-r11 are free; r12 is IN; r14 is OUT.
|
||||
+ // x4-x7 are rotated by 'brot'; x12-x15 are rotated by 'drot'.
|
||||
+
|
||||
+ // x0-x3
|
||||
+ __ldrd r8, r9, sp, 32
|
||||
+ __ldrd r10, r11, sp, 40
|
||||
+ add X0, X0, r8
|
||||
+ add X1, X1, r9
|
||||
+ add X2, X2, r10
|
||||
+ add X3, X3, r11
|
||||
+ _le32_bswap_4x X0, X1, X2, X3, r8, r9, r10
|
||||
+ ldmia r12!, {r8-r11}
|
||||
+ eor X0, X0, r8
|
||||
+ eor X1, X1, r9
|
||||
+ eor X2, X2, r10
|
||||
+ eor X3, X3, r11
|
||||
+ stmia r14!, {X0-X3}
|
||||
+
|
||||
+ // x4-x7
|
||||
+ __ldrd r8, r9, sp, 48
|
||||
+ __ldrd r10, r11, sp, 56
|
||||
+ add X4, r8, X4, ror #brot
|
||||
+ add X5, r9, X5, ror #brot
|
||||
+ ldmia r12!, {X0-X3}
|
||||
+ add X6, r10, X6, ror #brot
|
||||
+ add X7, r11, X7, ror #brot
|
||||
+ _le32_bswap_4x X4, X5, X6, X7, r8, r9, r10
|
||||
+ eor X4, X4, X0
|
||||
+ eor X5, X5, X1
|
||||
+ eor X6, X6, X2
|
||||
+ eor X7, X7, X3
|
||||
+ stmia r14!, {X4-X7}
|
||||
+
|
||||
+ // x8-x15
|
||||
+ pop {r0-r7} // (x8-x9,x12-x15,x10-x11)
|
||||
+ __ldrd r8, r9, sp, 32
|
||||
+ __ldrd r10, r11, sp, 40
|
||||
+ add r0, r0, r8 // x8
|
||||
+ add r1, r1, r9 // x9
|
||||
+ add r6, r6, r10 // x10
|
||||
+ add r7, r7, r11 // x11
|
||||
+ _le32_bswap_4x r0, r1, r6, r7, r8, r9, r10
|
||||
+ ldmia r12!, {r8-r11}
|
||||
+ eor r0, r0, r8 // x8
|
||||
+ eor r1, r1, r9 // x9
|
||||
+ eor r6, r6, r10 // x10
|
||||
+ eor r7, r7, r11 // x11
|
||||
+ stmia r14!, {r0,r1,r6,r7}
|
||||
+ ldmia r12!, {r0,r1,r6,r7}
|
||||
+ __ldrd r8, r9, sp, 48
|
||||
+ __ldrd r10, r11, sp, 56
|
||||
+ add r2, r8, r2, ror #drot // x12
|
||||
+ add r3, r9, r3, ror #drot // x13
|
||||
+ add r4, r10, r4, ror #drot // x14
|
||||
+ add r5, r11, r5, ror #drot // x15
|
||||
+ _le32_bswap_4x r2, r3, r4, r5, r9, r10, r11
|
||||
+ ldr r9, [sp, #72] // load LEN
|
||||
+ eor r2, r2, r0 // x12
|
||||
+ eor r3, r3, r1 // x13
|
||||
+ eor r4, r4, r6 // x14
|
||||
+ eor r5, r5, r7 // x15
|
||||
+ subs r9, #64 // decrement and check LEN
|
||||
+ stmia r14!, {r2-r5}
|
||||
+
|
||||
+ beq .Ldone\@
|
||||
+
|
||||
+.Lprepare_for_next_block\@:
|
||||
+
|
||||
+ // Stack: x0-x15 OUT IN LEN
|
||||
+
|
||||
+ // Increment block counter (x12)
|
||||
+ add r8, #1
|
||||
+
|
||||
+ // Store updated (OUT, IN, LEN)
|
||||
+ str r14, [sp, #64]
|
||||
+ str r12, [sp, #68]
|
||||
+ str r9, [sp, #72]
|
||||
+
|
||||
+ mov r14, sp
|
||||
+
|
||||
+ // Store updated block counter (x12)
|
||||
+ str r8, [sp, #48]
|
||||
+
|
||||
+ sub sp, #16
|
||||
+
|
||||
+ // Reload state and do next block
|
||||
+ ldmia r14!, {r0-r11} // load x0-x11
|
||||
+ __strd r10, r11, sp, 8 // store x10-x11 before state
|
||||
+ ldmia r14, {r10-r12,r14} // load x12-x15
|
||||
+ b .Lnext_block\@
|
||||
+
|
||||
+.Lxor_slowpath\@:
|
||||
+ // Slow path: < 64 bytes remaining, or unaligned input or output buffer.
|
||||
+ // We handle it by storing the 64 bytes of keystream to the stack, then
|
||||
+ // XOR-ing the needed portion with the data.
|
||||
+
|
||||
+ // Allocate keystream buffer
|
||||
+ sub sp, #64
|
||||
+ mov r14, sp
|
||||
+
|
||||
+ // Stack: ks0-ks15 x8-x9 x12-x15 x10-x11 orig_x0-orig_x15 OUT IN LEN
|
||||
+ // Registers: r0-r7 are x0-x7; r8-r11 are free; r12 is IN; r14 is &ks0.
|
||||
+ // x4-x7 are rotated by 'brot'; x12-x15 are rotated by 'drot'.
|
||||
+
|
||||
+ // Save keystream for x0-x3
|
||||
+ __ldrd r8, r9, sp, 96
|
||||
+ __ldrd r10, r11, sp, 104
|
||||
+ add X0, X0, r8
|
||||
+ add X1, X1, r9
|
||||
+ add X2, X2, r10
|
||||
+ add X3, X3, r11
|
||||
+ _le32_bswap_4x X0, X1, X2, X3, r8, r9, r10
|
||||
+ stmia r14!, {X0-X3}
|
||||
+
|
||||
+ // Save keystream for x4-x7
|
||||
+ __ldrd r8, r9, sp, 112
|
||||
+ __ldrd r10, r11, sp, 120
|
||||
+ add X4, r8, X4, ror #brot
|
||||
+ add X5, r9, X5, ror #brot
|
||||
+ add X6, r10, X6, ror #brot
|
||||
+ add X7, r11, X7, ror #brot
|
||||
+ _le32_bswap_4x X4, X5, X6, X7, r8, r9, r10
|
||||
+ add r8, sp, #64
|
||||
+ stmia r14!, {X4-X7}
|
||||
+
|
||||
+ // Save keystream for x8-x15
|
||||
+ ldm r8, {r0-r7} // (x8-x9,x12-x15,x10-x11)
|
||||
+ __ldrd r8, r9, sp, 128
|
||||
+ __ldrd r10, r11, sp, 136
|
||||
+ add r0, r0, r8 // x8
|
||||
+ add r1, r1, r9 // x9
|
||||
+ add r6, r6, r10 // x10
|
||||
+ add r7, r7, r11 // x11
|
||||
+ _le32_bswap_4x r0, r1, r6, r7, r8, r9, r10
|
||||
+ stmia r14!, {r0,r1,r6,r7}
|
||||
+ __ldrd r8, r9, sp, 144
|
||||
+ __ldrd r10, r11, sp, 152
|
||||
+ add r2, r8, r2, ror #drot // x12
|
||||
+ add r3, r9, r3, ror #drot // x13
|
||||
+ add r4, r10, r4, ror #drot // x14
|
||||
+ add r5, r11, r5, ror #drot // x15
|
||||
+ _le32_bswap_4x r2, r3, r4, r5, r9, r10, r11
|
||||
+ stmia r14, {r2-r5}
|
||||
+
|
||||
+ // Stack: ks0-ks15 unused0-unused7 x0-x15 OUT IN LEN
|
||||
+ // Registers: r8 is block counter, r12 is IN.
|
||||
+
|
||||
+ ldr r9, [sp, #168] // LEN
|
||||
+ ldr r14, [sp, #160] // OUT
|
||||
+ cmp r9, #64
|
||||
+ mov r0, sp
|
||||
+ movle r1, r9
|
||||
+ movgt r1, #64
|
||||
+ // r1 is number of bytes to XOR, in range [1, 64]
|
||||
+
|
||||
+.if __LINUX_ARM_ARCH__ < 6
|
||||
+ orr r2, r12, r14
|
||||
+ tst r2, #3 // IN or OUT misaligned?
|
||||
+ bne .Lxor_next_byte\@
|
||||
+.endif
|
||||
+
|
||||
+ // XOR a word at a time
|
||||
+.rept 16
|
||||
+ subs r1, #4
|
||||
+ blt .Lxor_words_done\@
|
||||
+ ldr r2, [r12], #4
|
||||
+ ldr r3, [r0], #4
|
||||
+ eor r2, r2, r3
|
||||
+ str r2, [r14], #4
|
||||
+.endr
|
||||
+ b .Lxor_slowpath_done\@
|
||||
+.Lxor_words_done\@:
|
||||
+ ands r1, r1, #3
|
||||
+ beq .Lxor_slowpath_done\@
|
||||
+
|
||||
+ // XOR a byte at a time
|
||||
+.Lxor_next_byte\@:
|
||||
+ ldrb r2, [r12], #1
|
||||
+ ldrb r3, [r0], #1
|
||||
+ eor r2, r2, r3
|
||||
+ strb r2, [r14], #1
|
||||
+ subs r1, #1
|
||||
+ bne .Lxor_next_byte\@
|
||||
+
|
||||
+.Lxor_slowpath_done\@:
|
||||
+ subs r9, #64
|
||||
+ add sp, #96
|
||||
+ bgt .Lprepare_for_next_block\@
|
||||
+
|
||||
+.Ldone\@:
|
||||
+.endm // _chacha
|
||||
+
|
||||
+/*
|
||||
+ * void chacha20_arm(u8 *out, const u8 *in, size_t len, const u32 key[8],
|
||||
+ * const u32 iv[4]);
|
||||
+ */
|
||||
+ENTRY(chacha20_arm)
|
||||
+ cmp r2, #0 // len == 0?
|
||||
+ reteq lr
|
||||
+
|
||||
+ push {r0-r2,r4-r11,lr}
|
||||
+
|
||||
+ // Push state x0-x15 onto stack.
|
||||
+ // Also store an extra copy of x10-x11 just before the state.
|
||||
+
|
||||
+ ldr r4, [sp, #48] // iv
|
||||
+ mov r0, sp
|
||||
+ sub sp, #80
|
||||
+
|
||||
+ // iv: x12-x15
|
||||
+ ldm r4, {X12,X13,X14,X15}
|
||||
+ stmdb r0!, {X12,X13,X14,X15}
|
||||
+
|
||||
+ // key: x4-x11
|
||||
+ __ldrd X8_X10, X9_X11, r3, 24
|
||||
+ __strd X8_X10, X9_X11, sp, 8
|
||||
+ stmdb r0!, {X8_X10, X9_X11}
|
||||
+ ldm r3, {X4-X9_X11}
|
||||
+ stmdb r0!, {X4-X9_X11}
|
||||
+
|
||||
+ // constants: x0-x3
|
||||
+ adrl X3, .Lexpand_32byte_k
|
||||
+ ldm X3, {X0-X3}
|
||||
+ __strd X0, X1, sp, 16
|
||||
+ __strd X2, X3, sp, 24
|
||||
+
|
||||
+ _chacha 20
|
||||
+
|
||||
+ add sp, #76
|
||||
+ pop {r4-r11, pc}
|
||||
+ENDPROC(chacha20_arm)
|
||||
+
|
||||
+/*
|
||||
+ * void hchacha20_arm(const u32 state[16], u32 out[8]);
|
||||
+ */
|
||||
+ENTRY(hchacha20_arm)
|
||||
+ push {r1,r4-r11,lr}
|
||||
+
|
||||
+ mov r14, r0
|
||||
+ ldmia r14!, {r0-r11} // load x0-x11
|
||||
+ push {r10-r11} // store x10-x11 to stack
|
||||
+ ldm r14, {r10-r12,r14} // load x12-x15
|
||||
+ sub sp, #8
|
||||
+
|
||||
+ _chacha_permute 20
|
||||
+
|
||||
+ // Skip over (unused0-unused1, x10-x11)
|
||||
+ add sp, #16
|
||||
+
|
||||
+ // Fix up rotations of x12-x15
|
||||
+ ror X12, X12, #drot
|
||||
+ ror X13, X13, #drot
|
||||
+ pop {r4} // load 'out'
|
||||
+ ror X14, X14, #drot
|
||||
+ ror X15, X15, #drot
|
||||
+
|
||||
+ // Store (x0-x3,x12-x15) to 'out'
|
||||
+ stm r4, {X0,X1,X2,X3,X12,X13,X14,X15}
|
||||
+
|
||||
+ pop {r4-r11,pc}
|
||||
+ENDPROC(hchacha20_arm)
|
||||
@@ -1,691 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:14 +0100
|
||||
Subject: [PATCH] crypto: arm/chacha - remove dependency on generic ChaCha
|
||||
driver
|
||||
|
||||
commit b36d8c09e710c71f6a9690b6586fea2d1c9e1e27 upstream.
|
||||
|
||||
Instead of falling back to the generic ChaCha skcipher driver for
|
||||
non-SIMD cases, use a fast scalar implementation for ARM authored
|
||||
by Eric Biggers. This removes the module dependency on chacha-generic
|
||||
altogether, which also simplifies things when we expose the ChaCha
|
||||
library interface from this module.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/Kconfig | 4 +-
|
||||
arch/arm/crypto/Makefile | 3 +-
|
||||
arch/arm/crypto/chacha-glue.c | 304 +++++++++++++++++++++++++++
|
||||
arch/arm/crypto/chacha-neon-glue.c | 202 ------------------
|
||||
arch/arm/crypto/chacha-scalar-core.S | 65 +++---
|
||||
arch/arm64/crypto/chacha-neon-glue.c | 2 +-
|
||||
6 files changed, 340 insertions(+), 240 deletions(-)
|
||||
create mode 100644 arch/arm/crypto/chacha-glue.c
|
||||
delete mode 100644 arch/arm/crypto/chacha-neon-glue.c
|
||||
|
||||
--- a/arch/arm/crypto/Kconfig
|
||||
+++ b/arch/arm/crypto/Kconfig
|
||||
@@ -127,10 +127,8 @@ config CRYPTO_CRC32_ARM_CE
|
||||
select CRYPTO_HASH
|
||||
|
||||
config CRYPTO_CHACHA20_NEON
|
||||
- tristate "NEON accelerated ChaCha stream cipher algorithms"
|
||||
- depends on KERNEL_MODE_NEON
|
||||
+ tristate "NEON and scalar accelerated ChaCha stream cipher algorithms"
|
||||
select CRYPTO_BLKCIPHER
|
||||
- select CRYPTO_CHACHA20
|
||||
|
||||
config CRYPTO_NHPOLY1305_NEON
|
||||
tristate "NEON accelerated NHPoly1305 hash function (for Adiantum)"
|
||||
--- a/arch/arm/crypto/Makefile
|
||||
+++ b/arch/arm/crypto/Makefile
|
||||
@@ -53,7 +53,8 @@ aes-arm-ce-y := aes-ce-core.o aes-ce-glu
|
||||
ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o
|
||||
crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o
|
||||
crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o
|
||||
-chacha-neon-y := chacha-neon-core.o chacha-neon-glue.o
|
||||
+chacha-neon-y := chacha-scalar-core.o chacha-glue.o
|
||||
+chacha-neon-$(CONFIG_KERNEL_MODE_NEON) += chacha-neon-core.o
|
||||
nhpoly1305-neon-y := nh-neon-core.o nhpoly1305-neon-glue.o
|
||||
|
||||
ifdef REGENERATE_ARM_CRYPTO
|
||||
--- /dev/null
|
||||
+++ b/arch/arm/crypto/chacha-glue.c
|
||||
@@ -0,0 +1,304 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * ARM NEON accelerated ChaCha and XChaCha stream ciphers,
|
||||
+ * including ChaCha20 (RFC7539)
|
||||
+ *
|
||||
+ * Copyright (C) 2016-2019 Linaro, Ltd. <ard.biesheuvel@linaro.org>
|
||||
+ * Copyright (C) 2015 Martin Willi
|
||||
+ */
|
||||
+
|
||||
+#include <crypto/algapi.h>
|
||||
+#include <crypto/internal/chacha.h>
|
||||
+#include <crypto/internal/simd.h>
|
||||
+#include <crypto/internal/skcipher.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include <asm/cputype.h>
|
||||
+#include <asm/hwcap.h>
|
||||
+#include <asm/neon.h>
|
||||
+#include <asm/simd.h>
|
||||
+
|
||||
+asmlinkage void chacha_block_xor_neon(const u32 *state, u8 *dst, const u8 *src,
|
||||
+ int nrounds);
|
||||
+asmlinkage void chacha_4block_xor_neon(const u32 *state, u8 *dst, const u8 *src,
|
||||
+ int nrounds);
|
||||
+asmlinkage void hchacha_block_arm(const u32 *state, u32 *out, int nrounds);
|
||||
+asmlinkage void hchacha_block_neon(const u32 *state, u32 *out, int nrounds);
|
||||
+
|
||||
+asmlinkage void chacha_doarm(u8 *dst, const u8 *src, unsigned int bytes,
|
||||
+ const u32 *state, int nrounds);
|
||||
+
|
||||
+static inline bool neon_usable(void)
|
||||
+{
|
||||
+ return crypto_simd_usable();
|
||||
+}
|
||||
+
|
||||
+static void chacha_doneon(u32 *state, u8 *dst, const u8 *src,
|
||||
+ unsigned int bytes, int nrounds)
|
||||
+{
|
||||
+ u8 buf[CHACHA_BLOCK_SIZE];
|
||||
+
|
||||
+ while (bytes >= CHACHA_BLOCK_SIZE * 4) {
|
||||
+ chacha_4block_xor_neon(state, dst, src, nrounds);
|
||||
+ bytes -= CHACHA_BLOCK_SIZE * 4;
|
||||
+ src += CHACHA_BLOCK_SIZE * 4;
|
||||
+ dst += CHACHA_BLOCK_SIZE * 4;
|
||||
+ state[12] += 4;
|
||||
+ }
|
||||
+ while (bytes >= CHACHA_BLOCK_SIZE) {
|
||||
+ chacha_block_xor_neon(state, dst, src, nrounds);
|
||||
+ bytes -= CHACHA_BLOCK_SIZE;
|
||||
+ src += CHACHA_BLOCK_SIZE;
|
||||
+ dst += CHACHA_BLOCK_SIZE;
|
||||
+ state[12]++;
|
||||
+ }
|
||||
+ if (bytes) {
|
||||
+ memcpy(buf, src, bytes);
|
||||
+ chacha_block_xor_neon(state, buf, buf, nrounds);
|
||||
+ memcpy(dst, buf, bytes);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int chacha_stream_xor(struct skcipher_request *req,
|
||||
+ const struct chacha_ctx *ctx, const u8 *iv,
|
||||
+ bool neon)
|
||||
+{
|
||||
+ struct skcipher_walk walk;
|
||||
+ u32 state[16];
|
||||
+ int err;
|
||||
+
|
||||
+ err = skcipher_walk_virt(&walk, req, false);
|
||||
+
|
||||
+ chacha_init_generic(state, ctx->key, iv);
|
||||
+
|
||||
+ while (walk.nbytes > 0) {
|
||||
+ unsigned int nbytes = walk.nbytes;
|
||||
+
|
||||
+ if (nbytes < walk.total)
|
||||
+ nbytes = round_down(nbytes, walk.stride);
|
||||
+
|
||||
+ if (!neon) {
|
||||
+ chacha_doarm(walk.dst.virt.addr, walk.src.virt.addr,
|
||||
+ nbytes, state, ctx->nrounds);
|
||||
+ state[12] += DIV_ROUND_UP(nbytes, CHACHA_BLOCK_SIZE);
|
||||
+ } else {
|
||||
+ kernel_neon_begin();
|
||||
+ chacha_doneon(state, walk.dst.virt.addr,
|
||||
+ walk.src.virt.addr, nbytes, ctx->nrounds);
|
||||
+ kernel_neon_end();
|
||||
+ }
|
||||
+ err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
||||
+ }
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int do_chacha(struct skcipher_request *req, bool neon)
|
||||
+{
|
||||
+ struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
+ struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
+
|
||||
+ return chacha_stream_xor(req, ctx, req->iv, neon);
|
||||
+}
|
||||
+
|
||||
+static int chacha_arm(struct skcipher_request *req)
|
||||
+{
|
||||
+ return do_chacha(req, false);
|
||||
+}
|
||||
+
|
||||
+static int chacha_neon(struct skcipher_request *req)
|
||||
+{
|
||||
+ return do_chacha(req, neon_usable());
|
||||
+}
|
||||
+
|
||||
+static int do_xchacha(struct skcipher_request *req, bool neon)
|
||||
+{
|
||||
+ struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
+ struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
+ struct chacha_ctx subctx;
|
||||
+ u32 state[16];
|
||||
+ u8 real_iv[16];
|
||||
+
|
||||
+ chacha_init_generic(state, ctx->key, req->iv);
|
||||
+
|
||||
+ if (!neon) {
|
||||
+ hchacha_block_arm(state, subctx.key, ctx->nrounds);
|
||||
+ } else {
|
||||
+ kernel_neon_begin();
|
||||
+ hchacha_block_neon(state, subctx.key, ctx->nrounds);
|
||||
+ kernel_neon_end();
|
||||
+ }
|
||||
+ subctx.nrounds = ctx->nrounds;
|
||||
+
|
||||
+ memcpy(&real_iv[0], req->iv + 24, 8);
|
||||
+ memcpy(&real_iv[8], req->iv + 16, 8);
|
||||
+ return chacha_stream_xor(req, &subctx, real_iv, neon);
|
||||
+}
|
||||
+
|
||||
+static int xchacha_arm(struct skcipher_request *req)
|
||||
+{
|
||||
+ return do_xchacha(req, false);
|
||||
+}
|
||||
+
|
||||
+static int xchacha_neon(struct skcipher_request *req)
|
||||
+{
|
||||
+ return do_xchacha(req, neon_usable());
|
||||
+}
|
||||
+
|
||||
+static struct skcipher_alg arm_algs[] = {
|
||||
+ {
|
||||
+ .base.cra_name = "chacha20",
|
||||
+ .base.cra_driver_name = "chacha20-arm",
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = CHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha20_setkey,
|
||||
+ .encrypt = chacha_arm,
|
||||
+ .decrypt = chacha_arm,
|
||||
+ }, {
|
||||
+ .base.cra_name = "xchacha20",
|
||||
+ .base.cra_driver_name = "xchacha20-arm",
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = XCHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha20_setkey,
|
||||
+ .encrypt = xchacha_arm,
|
||||
+ .decrypt = xchacha_arm,
|
||||
+ }, {
|
||||
+ .base.cra_name = "xchacha12",
|
||||
+ .base.cra_driver_name = "xchacha12-arm",
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = XCHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha12_setkey,
|
||||
+ .encrypt = xchacha_arm,
|
||||
+ .decrypt = xchacha_arm,
|
||||
+ },
|
||||
+};
|
||||
+
|
||||
+static struct skcipher_alg neon_algs[] = {
|
||||
+ {
|
||||
+ .base.cra_name = "chacha20",
|
||||
+ .base.cra_driver_name = "chacha20-neon",
|
||||
+ .base.cra_priority = 300,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = CHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .walksize = 4 * CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha20_setkey,
|
||||
+ .encrypt = chacha_neon,
|
||||
+ .decrypt = chacha_neon,
|
||||
+ }, {
|
||||
+ .base.cra_name = "xchacha20",
|
||||
+ .base.cra_driver_name = "xchacha20-neon",
|
||||
+ .base.cra_priority = 300,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = XCHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .walksize = 4 * CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha20_setkey,
|
||||
+ .encrypt = xchacha_neon,
|
||||
+ .decrypt = xchacha_neon,
|
||||
+ }, {
|
||||
+ .base.cra_name = "xchacha12",
|
||||
+ .base.cra_driver_name = "xchacha12-neon",
|
||||
+ .base.cra_priority = 300,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = XCHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .walksize = 4 * CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha12_setkey,
|
||||
+ .encrypt = xchacha_neon,
|
||||
+ .decrypt = xchacha_neon,
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+static int __init chacha_simd_mod_init(void)
|
||||
+{
|
||||
+ int err;
|
||||
+
|
||||
+ err = crypto_register_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && (elf_hwcap & HWCAP_NEON)) {
|
||||
+ int i;
|
||||
+
|
||||
+ switch (read_cpuid_part()) {
|
||||
+ case ARM_CPU_PART_CORTEX_A7:
|
||||
+ case ARM_CPU_PART_CORTEX_A5:
|
||||
+ /*
|
||||
+ * The Cortex-A7 and Cortex-A5 do not perform well with
|
||||
+ * the NEON implementation but do incredibly with the
|
||||
+ * scalar one and use less power.
|
||||
+ */
|
||||
+ for (i = 0; i < ARRAY_SIZE(neon_algs); i++)
|
||||
+ neon_algs[i].base.cra_priority = 0;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ err = crypto_register_skciphers(neon_algs, ARRAY_SIZE(neon_algs));
|
||||
+ if (err)
|
||||
+ crypto_unregister_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
+ }
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static void __exit chacha_simd_mod_fini(void)
|
||||
+{
|
||||
+ crypto_unregister_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
+ if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && (elf_hwcap & HWCAP_NEON))
|
||||
+ crypto_unregister_skciphers(neon_algs, ARRAY_SIZE(neon_algs));
|
||||
+}
|
||||
+
|
||||
+module_init(chacha_simd_mod_init);
|
||||
+module_exit(chacha_simd_mod_fini);
|
||||
+
|
||||
+MODULE_DESCRIPTION("ChaCha and XChaCha stream ciphers (scalar and NEON accelerated)");
|
||||
+MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
+MODULE_ALIAS_CRYPTO("chacha20");
|
||||
+MODULE_ALIAS_CRYPTO("chacha20-arm");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha20");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha20-arm");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha12");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha12-arm");
|
||||
+#ifdef CONFIG_KERNEL_MODE_NEON
|
||||
+MODULE_ALIAS_CRYPTO("chacha20-neon");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha20-neon");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha12-neon");
|
||||
+#endif
|
||||
--- a/arch/arm/crypto/chacha-neon-glue.c
|
||||
+++ /dev/null
|
||||
@@ -1,202 +0,0 @@
|
||||
-/*
|
||||
- * ARM NEON accelerated ChaCha and XChaCha stream ciphers,
|
||||
- * including ChaCha20 (RFC7539)
|
||||
- *
|
||||
- * Copyright (C) 2016 Linaro, Ltd. <ard.biesheuvel@linaro.org>
|
||||
- *
|
||||
- * This program is free software; you can redistribute it and/or modify
|
||||
- * it under the terms of the GNU General Public License version 2 as
|
||||
- * published by the Free Software Foundation.
|
||||
- *
|
||||
- * Based on:
|
||||
- * ChaCha20 256-bit cipher algorithm, RFC7539, SIMD glue code
|
||||
- *
|
||||
- * Copyright (C) 2015 Martin Willi
|
||||
- *
|
||||
- * This program is free software; you can redistribute it and/or modify
|
||||
- * it under the terms of the GNU General Public License as published by
|
||||
- * the Free Software Foundation; either version 2 of the License, or
|
||||
- * (at your option) any later version.
|
||||
- */
|
||||
-
|
||||
-#include <crypto/algapi.h>
|
||||
-#include <crypto/internal/chacha.h>
|
||||
-#include <crypto/internal/simd.h>
|
||||
-#include <crypto/internal/skcipher.h>
|
||||
-#include <linux/kernel.h>
|
||||
-#include <linux/module.h>
|
||||
-
|
||||
-#include <asm/hwcap.h>
|
||||
-#include <asm/neon.h>
|
||||
-#include <asm/simd.h>
|
||||
-
|
||||
-asmlinkage void chacha_block_xor_neon(const u32 *state, u8 *dst, const u8 *src,
|
||||
- int nrounds);
|
||||
-asmlinkage void chacha_4block_xor_neon(const u32 *state, u8 *dst, const u8 *src,
|
||||
- int nrounds);
|
||||
-asmlinkage void hchacha_block_neon(const u32 *state, u32 *out, int nrounds);
|
||||
-
|
||||
-static void chacha_doneon(u32 *state, u8 *dst, const u8 *src,
|
||||
- unsigned int bytes, int nrounds)
|
||||
-{
|
||||
- u8 buf[CHACHA_BLOCK_SIZE];
|
||||
-
|
||||
- while (bytes >= CHACHA_BLOCK_SIZE * 4) {
|
||||
- chacha_4block_xor_neon(state, dst, src, nrounds);
|
||||
- bytes -= CHACHA_BLOCK_SIZE * 4;
|
||||
- src += CHACHA_BLOCK_SIZE * 4;
|
||||
- dst += CHACHA_BLOCK_SIZE * 4;
|
||||
- state[12] += 4;
|
||||
- }
|
||||
- while (bytes >= CHACHA_BLOCK_SIZE) {
|
||||
- chacha_block_xor_neon(state, dst, src, nrounds);
|
||||
- bytes -= CHACHA_BLOCK_SIZE;
|
||||
- src += CHACHA_BLOCK_SIZE;
|
||||
- dst += CHACHA_BLOCK_SIZE;
|
||||
- state[12]++;
|
||||
- }
|
||||
- if (bytes) {
|
||||
- memcpy(buf, src, bytes);
|
||||
- chacha_block_xor_neon(state, buf, buf, nrounds);
|
||||
- memcpy(dst, buf, bytes);
|
||||
- }
|
||||
-}
|
||||
-
|
||||
-static int chacha_neon_stream_xor(struct skcipher_request *req,
|
||||
- const struct chacha_ctx *ctx, const u8 *iv)
|
||||
-{
|
||||
- struct skcipher_walk walk;
|
||||
- u32 state[16];
|
||||
- int err;
|
||||
-
|
||||
- err = skcipher_walk_virt(&walk, req, false);
|
||||
-
|
||||
- crypto_chacha_init(state, ctx, iv);
|
||||
-
|
||||
- while (walk.nbytes > 0) {
|
||||
- unsigned int nbytes = walk.nbytes;
|
||||
-
|
||||
- if (nbytes < walk.total)
|
||||
- nbytes = round_down(nbytes, walk.stride);
|
||||
-
|
||||
- kernel_neon_begin();
|
||||
- chacha_doneon(state, walk.dst.virt.addr, walk.src.virt.addr,
|
||||
- nbytes, ctx->nrounds);
|
||||
- kernel_neon_end();
|
||||
- err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
||||
- }
|
||||
-
|
||||
- return err;
|
||||
-}
|
||||
-
|
||||
-static int chacha_neon(struct skcipher_request *req)
|
||||
-{
|
||||
- struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
- struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
-
|
||||
- if (req->cryptlen <= CHACHA_BLOCK_SIZE || !crypto_simd_usable())
|
||||
- return crypto_chacha_crypt(req);
|
||||
-
|
||||
- return chacha_neon_stream_xor(req, ctx, req->iv);
|
||||
-}
|
||||
-
|
||||
-static int xchacha_neon(struct skcipher_request *req)
|
||||
-{
|
||||
- struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
- struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
- struct chacha_ctx subctx;
|
||||
- u32 state[16];
|
||||
- u8 real_iv[16];
|
||||
-
|
||||
- if (req->cryptlen <= CHACHA_BLOCK_SIZE || !crypto_simd_usable())
|
||||
- return crypto_xchacha_crypt(req);
|
||||
-
|
||||
- crypto_chacha_init(state, ctx, req->iv);
|
||||
-
|
||||
- kernel_neon_begin();
|
||||
- hchacha_block_neon(state, subctx.key, ctx->nrounds);
|
||||
- kernel_neon_end();
|
||||
- subctx.nrounds = ctx->nrounds;
|
||||
-
|
||||
- memcpy(&real_iv[0], req->iv + 24, 8);
|
||||
- memcpy(&real_iv[8], req->iv + 16, 8);
|
||||
- return chacha_neon_stream_xor(req, &subctx, real_iv);
|
||||
-}
|
||||
-
|
||||
-static struct skcipher_alg algs[] = {
|
||||
- {
|
||||
- .base.cra_name = "chacha20",
|
||||
- .base.cra_driver_name = "chacha20-neon",
|
||||
- .base.cra_priority = 300,
|
||||
- .base.cra_blocksize = 1,
|
||||
- .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
- .base.cra_module = THIS_MODULE,
|
||||
-
|
||||
- .min_keysize = CHACHA_KEY_SIZE,
|
||||
- .max_keysize = CHACHA_KEY_SIZE,
|
||||
- .ivsize = CHACHA_IV_SIZE,
|
||||
- .chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .walksize = 4 * CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
- .encrypt = chacha_neon,
|
||||
- .decrypt = chacha_neon,
|
||||
- }, {
|
||||
- .base.cra_name = "xchacha20",
|
||||
- .base.cra_driver_name = "xchacha20-neon",
|
||||
- .base.cra_priority = 300,
|
||||
- .base.cra_blocksize = 1,
|
||||
- .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
- .base.cra_module = THIS_MODULE,
|
||||
-
|
||||
- .min_keysize = CHACHA_KEY_SIZE,
|
||||
- .max_keysize = CHACHA_KEY_SIZE,
|
||||
- .ivsize = XCHACHA_IV_SIZE,
|
||||
- .chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .walksize = 4 * CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
- .encrypt = xchacha_neon,
|
||||
- .decrypt = xchacha_neon,
|
||||
- }, {
|
||||
- .base.cra_name = "xchacha12",
|
||||
- .base.cra_driver_name = "xchacha12-neon",
|
||||
- .base.cra_priority = 300,
|
||||
- .base.cra_blocksize = 1,
|
||||
- .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
- .base.cra_module = THIS_MODULE,
|
||||
-
|
||||
- .min_keysize = CHACHA_KEY_SIZE,
|
||||
- .max_keysize = CHACHA_KEY_SIZE,
|
||||
- .ivsize = XCHACHA_IV_SIZE,
|
||||
- .chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .walksize = 4 * CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha12_setkey,
|
||||
- .encrypt = xchacha_neon,
|
||||
- .decrypt = xchacha_neon,
|
||||
- }
|
||||
-};
|
||||
-
|
||||
-static int __init chacha_simd_mod_init(void)
|
||||
-{
|
||||
- if (!(elf_hwcap & HWCAP_NEON))
|
||||
- return -ENODEV;
|
||||
-
|
||||
- return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
-}
|
||||
-
|
||||
-static void __exit chacha_simd_mod_fini(void)
|
||||
-{
|
||||
- crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
-}
|
||||
-
|
||||
-module_init(chacha_simd_mod_init);
|
||||
-module_exit(chacha_simd_mod_fini);
|
||||
-
|
||||
-MODULE_DESCRIPTION("ChaCha and XChaCha stream ciphers (NEON accelerated)");
|
||||
-MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
|
||||
-MODULE_LICENSE("GPL v2");
|
||||
-MODULE_ALIAS_CRYPTO("chacha20");
|
||||
-MODULE_ALIAS_CRYPTO("chacha20-neon");
|
||||
-MODULE_ALIAS_CRYPTO("xchacha20");
|
||||
-MODULE_ALIAS_CRYPTO("xchacha20-neon");
|
||||
-MODULE_ALIAS_CRYPTO("xchacha12");
|
||||
-MODULE_ALIAS_CRYPTO("xchacha12-neon");
|
||||
--- a/arch/arm/crypto/chacha-scalar-core.S
|
||||
+++ b/arch/arm/crypto/chacha-scalar-core.S
|
||||
@@ -41,14 +41,6 @@
|
||||
X14 .req r12
|
||||
X15 .req r14
|
||||
|
||||
-.Lexpand_32byte_k:
|
||||
- // "expand 32-byte k"
|
||||
- .word 0x61707865, 0x3320646e, 0x79622d32, 0x6b206574
|
||||
-
|
||||
-#ifdef __thumb2__
|
||||
-# define adrl adr
|
||||
-#endif
|
||||
-
|
||||
.macro __rev out, in, t0, t1, t2
|
||||
.if __LINUX_ARM_ARCH__ >= 6
|
||||
rev \out, \in
|
||||
@@ -391,61 +383,65 @@
|
||||
.endm // _chacha
|
||||
|
||||
/*
|
||||
- * void chacha20_arm(u8 *out, const u8 *in, size_t len, const u32 key[8],
|
||||
- * const u32 iv[4]);
|
||||
+ * void chacha_doarm(u8 *dst, const u8 *src, unsigned int bytes,
|
||||
+ * const u32 *state, int nrounds);
|
||||
*/
|
||||
-ENTRY(chacha20_arm)
|
||||
+ENTRY(chacha_doarm)
|
||||
cmp r2, #0 // len == 0?
|
||||
reteq lr
|
||||
|
||||
+ ldr ip, [sp]
|
||||
+ cmp ip, #12
|
||||
+
|
||||
push {r0-r2,r4-r11,lr}
|
||||
|
||||
// Push state x0-x15 onto stack.
|
||||
// Also store an extra copy of x10-x11 just before the state.
|
||||
|
||||
- ldr r4, [sp, #48] // iv
|
||||
- mov r0, sp
|
||||
- sub sp, #80
|
||||
-
|
||||
- // iv: x12-x15
|
||||
- ldm r4, {X12,X13,X14,X15}
|
||||
- stmdb r0!, {X12,X13,X14,X15}
|
||||
+ add X12, r3, #48
|
||||
+ ldm X12, {X12,X13,X14,X15}
|
||||
+ push {X12,X13,X14,X15}
|
||||
+ sub sp, sp, #64
|
||||
|
||||
- // key: x4-x11
|
||||
- __ldrd X8_X10, X9_X11, r3, 24
|
||||
+ __ldrd X8_X10, X9_X11, r3, 40
|
||||
__strd X8_X10, X9_X11, sp, 8
|
||||
- stmdb r0!, {X8_X10, X9_X11}
|
||||
- ldm r3, {X4-X9_X11}
|
||||
- stmdb r0!, {X4-X9_X11}
|
||||
-
|
||||
- // constants: x0-x3
|
||||
- adrl X3, .Lexpand_32byte_k
|
||||
- ldm X3, {X0-X3}
|
||||
+ __strd X8_X10, X9_X11, sp, 56
|
||||
+ ldm r3, {X0-X9_X11}
|
||||
__strd X0, X1, sp, 16
|
||||
__strd X2, X3, sp, 24
|
||||
+ __strd X4, X5, sp, 32
|
||||
+ __strd X6, X7, sp, 40
|
||||
+ __strd X8_X10, X9_X11, sp, 48
|
||||
|
||||
+ beq 1f
|
||||
_chacha 20
|
||||
|
||||
- add sp, #76
|
||||
+0: add sp, #76
|
||||
pop {r4-r11, pc}
|
||||
-ENDPROC(chacha20_arm)
|
||||
+
|
||||
+1: _chacha 12
|
||||
+ b 0b
|
||||
+ENDPROC(chacha_doarm)
|
||||
|
||||
/*
|
||||
- * void hchacha20_arm(const u32 state[16], u32 out[8]);
|
||||
+ * void hchacha_block_arm(const u32 state[16], u32 out[8], int nrounds);
|
||||
*/
|
||||
-ENTRY(hchacha20_arm)
|
||||
+ENTRY(hchacha_block_arm)
|
||||
push {r1,r4-r11,lr}
|
||||
|
||||
+ cmp r2, #12 // ChaCha12 ?
|
||||
+
|
||||
mov r14, r0
|
||||
ldmia r14!, {r0-r11} // load x0-x11
|
||||
push {r10-r11} // store x10-x11 to stack
|
||||
ldm r14, {r10-r12,r14} // load x12-x15
|
||||
sub sp, #8
|
||||
|
||||
+ beq 1f
|
||||
_chacha_permute 20
|
||||
|
||||
// Skip over (unused0-unused1, x10-x11)
|
||||
- add sp, #16
|
||||
+0: add sp, #16
|
||||
|
||||
// Fix up rotations of x12-x15
|
||||
ror X12, X12, #drot
|
||||
@@ -458,4 +454,7 @@ ENTRY(hchacha20_arm)
|
||||
stm r4, {X0,X1,X2,X3,X12,X13,X14,X15}
|
||||
|
||||
pop {r4-r11,pc}
|
||||
-ENDPROC(hchacha20_arm)
|
||||
+
|
||||
+1: _chacha_permute 12
|
||||
+ b 0b
|
||||
+ENDPROC(hchacha_block_arm)
|
||||
--- a/arch/arm64/crypto/chacha-neon-glue.c
|
||||
+++ b/arch/arm64/crypto/chacha-neon-glue.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
- * ARM NEON accelerated ChaCha and XChaCha stream ciphers,
|
||||
+ * ARM NEON and scalar accelerated ChaCha and XChaCha stream ciphers,
|
||||
* including ChaCha20 (RFC7539)
|
||||
*
|
||||
* Copyright (C) 2016 - 2017 Linaro, Ltd. <ard.biesheuvel@linaro.org>
|
||||
@@ -1,108 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:15 +0100
|
||||
Subject: [PATCH] crypto: arm/chacha - expose ARM ChaCha routine as library
|
||||
function
|
||||
|
||||
commit a44a3430d71bad4ee56788a59fff099b291ea54c upstream.
|
||||
|
||||
Expose the accelerated NEON ChaCha routine directly as a symbol
|
||||
export so that users of the ChaCha library API can use it directly.
|
||||
|
||||
Given that calls into the library API will always go through the
|
||||
routines in this module if it is enabled, switch to static keys
|
||||
to select the optimal implementation available (which may be none
|
||||
at all, in which case we defer to the generic implementation for
|
||||
all invocations).
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/Kconfig | 1 +
|
||||
arch/arm/crypto/chacha-glue.c | 41 ++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 41 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/arch/arm/crypto/Kconfig
|
||||
+++ b/arch/arm/crypto/Kconfig
|
||||
@@ -129,6 +129,7 @@ config CRYPTO_CRC32_ARM_CE
|
||||
config CRYPTO_CHACHA20_NEON
|
||||
tristate "NEON and scalar accelerated ChaCha stream cipher algorithms"
|
||||
select CRYPTO_BLKCIPHER
|
||||
+ select CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
|
||||
config CRYPTO_NHPOLY1305_NEON
|
||||
tristate "NEON accelerated NHPoly1305 hash function (for Adiantum)"
|
||||
--- a/arch/arm/crypto/chacha-glue.c
|
||||
+++ b/arch/arm/crypto/chacha-glue.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <crypto/internal/chacha.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
+#include <linux/jump_label.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
@@ -29,9 +30,11 @@ asmlinkage void hchacha_block_neon(const
|
||||
asmlinkage void chacha_doarm(u8 *dst, const u8 *src, unsigned int bytes,
|
||||
const u32 *state, int nrounds);
|
||||
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(use_neon);
|
||||
+
|
||||
static inline bool neon_usable(void)
|
||||
{
|
||||
- return crypto_simd_usable();
|
||||
+ return static_branch_likely(&use_neon) && crypto_simd_usable();
|
||||
}
|
||||
|
||||
static void chacha_doneon(u32 *state, u8 *dst, const u8 *src,
|
||||
@@ -60,6 +63,40 @@ static void chacha_doneon(u32 *state, u8
|
||||
}
|
||||
}
|
||||
|
||||
+void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds)
|
||||
+{
|
||||
+ if (!IS_ENABLED(CONFIG_KERNEL_MODE_NEON) || !neon_usable()) {
|
||||
+ hchacha_block_arm(state, stream, nrounds);
|
||||
+ } else {
|
||||
+ kernel_neon_begin();
|
||||
+ hchacha_block_neon(state, stream, nrounds);
|
||||
+ kernel_neon_end();
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL(hchacha_block_arch);
|
||||
+
|
||||
+void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
|
||||
+{
|
||||
+ chacha_init_generic(state, key, iv);
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_init_arch);
|
||||
+
|
||||
+void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src, unsigned int bytes,
|
||||
+ int nrounds)
|
||||
+{
|
||||
+ if (!IS_ENABLED(CONFIG_KERNEL_MODE_NEON) || !neon_usable() ||
|
||||
+ bytes <= CHACHA_BLOCK_SIZE) {
|
||||
+ chacha_doarm(dst, src, bytes, state, nrounds);
|
||||
+ state[12] += DIV_ROUND_UP(bytes, CHACHA_BLOCK_SIZE);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ kernel_neon_begin();
|
||||
+ chacha_doneon(state, dst, src, bytes, nrounds);
|
||||
+ kernel_neon_end();
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_crypt_arch);
|
||||
+
|
||||
static int chacha_stream_xor(struct skcipher_request *req,
|
||||
const struct chacha_ctx *ctx, const u8 *iv,
|
||||
bool neon)
|
||||
@@ -269,6 +306,8 @@ static int __init chacha_simd_mod_init(v
|
||||
for (i = 0; i < ARRAY_SIZE(neon_algs); i++)
|
||||
neon_algs[i].base.cra_priority = 0;
|
||||
break;
|
||||
+ default:
|
||||
+ static_branch_enable(&use_neon);
|
||||
}
|
||||
|
||||
err = crypto_register_skciphers(neon_algs, ARRAY_SIZE(neon_algs));
|
||||
@@ -1,451 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Fri, 8 Nov 2019 13:22:16 +0100
|
||||
Subject: [PATCH] crypto: mips/chacha - import 32r2 ChaCha code from Zinc
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
commit 49aa7c00eddf8d8f462b0256bd82e81762d7b0c6 upstream.
|
||||
|
||||
This imports the accelerated MIPS 32r2 ChaCha20 implementation from the
|
||||
Zinc patch set.
|
||||
|
||||
Co-developed-by: René van Dorst <opensource@vdorst.com>
|
||||
Signed-off-by: René van Dorst <opensource@vdorst.com>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/mips/crypto/chacha-core.S | 424 +++++++++++++++++++++++++++++++++
|
||||
1 file changed, 424 insertions(+)
|
||||
create mode 100644 arch/mips/crypto/chacha-core.S
|
||||
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/crypto/chacha-core.S
|
||||
@@ -0,0 +1,424 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
|
||||
+/*
|
||||
+ * Copyright (C) 2016-2018 René van Dorst <opensource@vdorst.com>. All Rights Reserved.
|
||||
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||
+ */
|
||||
+
|
||||
+#define MASK_U32 0x3c
|
||||
+#define CHACHA20_BLOCK_SIZE 64
|
||||
+#define STACK_SIZE 32
|
||||
+
|
||||
+#define X0 $t0
|
||||
+#define X1 $t1
|
||||
+#define X2 $t2
|
||||
+#define X3 $t3
|
||||
+#define X4 $t4
|
||||
+#define X5 $t5
|
||||
+#define X6 $t6
|
||||
+#define X7 $t7
|
||||
+#define X8 $t8
|
||||
+#define X9 $t9
|
||||
+#define X10 $v1
|
||||
+#define X11 $s6
|
||||
+#define X12 $s5
|
||||
+#define X13 $s4
|
||||
+#define X14 $s3
|
||||
+#define X15 $s2
|
||||
+/* Use regs which are overwritten on exit for Tx so we don't leak clear data. */
|
||||
+#define T0 $s1
|
||||
+#define T1 $s0
|
||||
+#define T(n) T ## n
|
||||
+#define X(n) X ## n
|
||||
+
|
||||
+/* Input arguments */
|
||||
+#define STATE $a0
|
||||
+#define OUT $a1
|
||||
+#define IN $a2
|
||||
+#define BYTES $a3
|
||||
+
|
||||
+/* Output argument */
|
||||
+/* NONCE[0] is kept in a register and not in memory.
|
||||
+ * We don't want to touch original value in memory.
|
||||
+ * Must be incremented every loop iteration.
|
||||
+ */
|
||||
+#define NONCE_0 $v0
|
||||
+
|
||||
+/* SAVED_X and SAVED_CA are set in the jump table.
|
||||
+ * Use regs which are overwritten on exit else we don't leak clear data.
|
||||
+ * They are used to handling the last bytes which are not multiple of 4.
|
||||
+ */
|
||||
+#define SAVED_X X15
|
||||
+#define SAVED_CA $s7
|
||||
+
|
||||
+#define IS_UNALIGNED $s7
|
||||
+
|
||||
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
+#define MSB 0
|
||||
+#define LSB 3
|
||||
+#define ROTx rotl
|
||||
+#define ROTR(n) rotr n, 24
|
||||
+#define CPU_TO_LE32(n) \
|
||||
+ wsbh n; \
|
||||
+ rotr n, 16;
|
||||
+#else
|
||||
+#define MSB 3
|
||||
+#define LSB 0
|
||||
+#define ROTx rotr
|
||||
+#define CPU_TO_LE32(n)
|
||||
+#define ROTR(n)
|
||||
+#endif
|
||||
+
|
||||
+#define FOR_EACH_WORD(x) \
|
||||
+ x( 0); \
|
||||
+ x( 1); \
|
||||
+ x( 2); \
|
||||
+ x( 3); \
|
||||
+ x( 4); \
|
||||
+ x( 5); \
|
||||
+ x( 6); \
|
||||
+ x( 7); \
|
||||
+ x( 8); \
|
||||
+ x( 9); \
|
||||
+ x(10); \
|
||||
+ x(11); \
|
||||
+ x(12); \
|
||||
+ x(13); \
|
||||
+ x(14); \
|
||||
+ x(15);
|
||||
+
|
||||
+#define FOR_EACH_WORD_REV(x) \
|
||||
+ x(15); \
|
||||
+ x(14); \
|
||||
+ x(13); \
|
||||
+ x(12); \
|
||||
+ x(11); \
|
||||
+ x(10); \
|
||||
+ x( 9); \
|
||||
+ x( 8); \
|
||||
+ x( 7); \
|
||||
+ x( 6); \
|
||||
+ x( 5); \
|
||||
+ x( 4); \
|
||||
+ x( 3); \
|
||||
+ x( 2); \
|
||||
+ x( 1); \
|
||||
+ x( 0);
|
||||
+
|
||||
+#define PLUS_ONE_0 1
|
||||
+#define PLUS_ONE_1 2
|
||||
+#define PLUS_ONE_2 3
|
||||
+#define PLUS_ONE_3 4
|
||||
+#define PLUS_ONE_4 5
|
||||
+#define PLUS_ONE_5 6
|
||||
+#define PLUS_ONE_6 7
|
||||
+#define PLUS_ONE_7 8
|
||||
+#define PLUS_ONE_8 9
|
||||
+#define PLUS_ONE_9 10
|
||||
+#define PLUS_ONE_10 11
|
||||
+#define PLUS_ONE_11 12
|
||||
+#define PLUS_ONE_12 13
|
||||
+#define PLUS_ONE_13 14
|
||||
+#define PLUS_ONE_14 15
|
||||
+#define PLUS_ONE_15 16
|
||||
+#define PLUS_ONE(x) PLUS_ONE_ ## x
|
||||
+#define _CONCAT3(a,b,c) a ## b ## c
|
||||
+#define CONCAT3(a,b,c) _CONCAT3(a,b,c)
|
||||
+
|
||||
+#define STORE_UNALIGNED(x) \
|
||||
+CONCAT3(.Lchacha20_mips_xor_unaligned_, PLUS_ONE(x), _b: ;) \
|
||||
+ .if (x != 12); \
|
||||
+ lw T0, (x*4)(STATE); \
|
||||
+ .endif; \
|
||||
+ lwl T1, (x*4)+MSB ## (IN); \
|
||||
+ lwr T1, (x*4)+LSB ## (IN); \
|
||||
+ .if (x == 12); \
|
||||
+ addu X ## x, NONCE_0; \
|
||||
+ .else; \
|
||||
+ addu X ## x, T0; \
|
||||
+ .endif; \
|
||||
+ CPU_TO_LE32(X ## x); \
|
||||
+ xor X ## x, T1; \
|
||||
+ swl X ## x, (x*4)+MSB ## (OUT); \
|
||||
+ swr X ## x, (x*4)+LSB ## (OUT);
|
||||
+
|
||||
+#define STORE_ALIGNED(x) \
|
||||
+CONCAT3(.Lchacha20_mips_xor_aligned_, PLUS_ONE(x), _b: ;) \
|
||||
+ .if (x != 12); \
|
||||
+ lw T0, (x*4)(STATE); \
|
||||
+ .endif; \
|
||||
+ lw T1, (x*4) ## (IN); \
|
||||
+ .if (x == 12); \
|
||||
+ addu X ## x, NONCE_0; \
|
||||
+ .else; \
|
||||
+ addu X ## x, T0; \
|
||||
+ .endif; \
|
||||
+ CPU_TO_LE32(X ## x); \
|
||||
+ xor X ## x, T1; \
|
||||
+ sw X ## x, (x*4) ## (OUT);
|
||||
+
|
||||
+/* Jump table macro.
|
||||
+ * Used for setup and handling the last bytes, which are not multiple of 4.
|
||||
+ * X15 is free to store Xn
|
||||
+ * Every jumptable entry must be equal in size.
|
||||
+ */
|
||||
+#define JMPTBL_ALIGNED(x) \
|
||||
+.Lchacha20_mips_jmptbl_aligned_ ## x: ; \
|
||||
+ .set noreorder; \
|
||||
+ b .Lchacha20_mips_xor_aligned_ ## x ## _b; \
|
||||
+ .if (x == 12); \
|
||||
+ addu SAVED_X, X ## x, NONCE_0; \
|
||||
+ .else; \
|
||||
+ addu SAVED_X, X ## x, SAVED_CA; \
|
||||
+ .endif; \
|
||||
+ .set reorder
|
||||
+
|
||||
+#define JMPTBL_UNALIGNED(x) \
|
||||
+.Lchacha20_mips_jmptbl_unaligned_ ## x: ; \
|
||||
+ .set noreorder; \
|
||||
+ b .Lchacha20_mips_xor_unaligned_ ## x ## _b; \
|
||||
+ .if (x == 12); \
|
||||
+ addu SAVED_X, X ## x, NONCE_0; \
|
||||
+ .else; \
|
||||
+ addu SAVED_X, X ## x, SAVED_CA; \
|
||||
+ .endif; \
|
||||
+ .set reorder
|
||||
+
|
||||
+#define AXR(A, B, C, D, K, L, M, N, V, W, Y, Z, S) \
|
||||
+ addu X(A), X(K); \
|
||||
+ addu X(B), X(L); \
|
||||
+ addu X(C), X(M); \
|
||||
+ addu X(D), X(N); \
|
||||
+ xor X(V), X(A); \
|
||||
+ xor X(W), X(B); \
|
||||
+ xor X(Y), X(C); \
|
||||
+ xor X(Z), X(D); \
|
||||
+ rotl X(V), S; \
|
||||
+ rotl X(W), S; \
|
||||
+ rotl X(Y), S; \
|
||||
+ rotl X(Z), S;
|
||||
+
|
||||
+.text
|
||||
+.set reorder
|
||||
+.set noat
|
||||
+.globl chacha20_mips
|
||||
+.ent chacha20_mips
|
||||
+chacha20_mips:
|
||||
+ .frame $sp, STACK_SIZE, $ra
|
||||
+
|
||||
+ addiu $sp, -STACK_SIZE
|
||||
+
|
||||
+ /* Return bytes = 0. */
|
||||
+ beqz BYTES, .Lchacha20_mips_end
|
||||
+
|
||||
+ lw NONCE_0, 48(STATE)
|
||||
+
|
||||
+ /* Save s0-s7 */
|
||||
+ sw $s0, 0($sp)
|
||||
+ sw $s1, 4($sp)
|
||||
+ sw $s2, 8($sp)
|
||||
+ sw $s3, 12($sp)
|
||||
+ sw $s4, 16($sp)
|
||||
+ sw $s5, 20($sp)
|
||||
+ sw $s6, 24($sp)
|
||||
+ sw $s7, 28($sp)
|
||||
+
|
||||
+ /* Test IN or OUT is unaligned.
|
||||
+ * IS_UNALIGNED = ( IN | OUT ) & 0x00000003
|
||||
+ */
|
||||
+ or IS_UNALIGNED, IN, OUT
|
||||
+ andi IS_UNALIGNED, 0x3
|
||||
+
|
||||
+ /* Set number of rounds */
|
||||
+ li $at, 20
|
||||
+
|
||||
+ b .Lchacha20_rounds_start
|
||||
+
|
||||
+.align 4
|
||||
+.Loop_chacha20_rounds:
|
||||
+ addiu IN, CHACHA20_BLOCK_SIZE
|
||||
+ addiu OUT, CHACHA20_BLOCK_SIZE
|
||||
+ addiu NONCE_0, 1
|
||||
+
|
||||
+.Lchacha20_rounds_start:
|
||||
+ lw X0, 0(STATE)
|
||||
+ lw X1, 4(STATE)
|
||||
+ lw X2, 8(STATE)
|
||||
+ lw X3, 12(STATE)
|
||||
+
|
||||
+ lw X4, 16(STATE)
|
||||
+ lw X5, 20(STATE)
|
||||
+ lw X6, 24(STATE)
|
||||
+ lw X7, 28(STATE)
|
||||
+ lw X8, 32(STATE)
|
||||
+ lw X9, 36(STATE)
|
||||
+ lw X10, 40(STATE)
|
||||
+ lw X11, 44(STATE)
|
||||
+
|
||||
+ move X12, NONCE_0
|
||||
+ lw X13, 52(STATE)
|
||||
+ lw X14, 56(STATE)
|
||||
+ lw X15, 60(STATE)
|
||||
+
|
||||
+.Loop_chacha20_xor_rounds:
|
||||
+ addiu $at, -2
|
||||
+ AXR( 0, 1, 2, 3, 4, 5, 6, 7, 12,13,14,15, 16);
|
||||
+ AXR( 8, 9,10,11, 12,13,14,15, 4, 5, 6, 7, 12);
|
||||
+ AXR( 0, 1, 2, 3, 4, 5, 6, 7, 12,13,14,15, 8);
|
||||
+ AXR( 8, 9,10,11, 12,13,14,15, 4, 5, 6, 7, 7);
|
||||
+ AXR( 0, 1, 2, 3, 5, 6, 7, 4, 15,12,13,14, 16);
|
||||
+ AXR(10,11, 8, 9, 15,12,13,14, 5, 6, 7, 4, 12);
|
||||
+ AXR( 0, 1, 2, 3, 5, 6, 7, 4, 15,12,13,14, 8);
|
||||
+ AXR(10,11, 8, 9, 15,12,13,14, 5, 6, 7, 4, 7);
|
||||
+ bnez $at, .Loop_chacha20_xor_rounds
|
||||
+
|
||||
+ addiu BYTES, -(CHACHA20_BLOCK_SIZE)
|
||||
+
|
||||
+ /* Is data src/dst unaligned? Jump */
|
||||
+ bnez IS_UNALIGNED, .Loop_chacha20_unaligned
|
||||
+
|
||||
+ /* Set number rounds here to fill delayslot. */
|
||||
+ li $at, 20
|
||||
+
|
||||
+ /* BYTES < 0, it has no full block. */
|
||||
+ bltz BYTES, .Lchacha20_mips_no_full_block_aligned
|
||||
+
|
||||
+ FOR_EACH_WORD_REV(STORE_ALIGNED)
|
||||
+
|
||||
+ /* BYTES > 0? Loop again. */
|
||||
+ bgtz BYTES, .Loop_chacha20_rounds
|
||||
+
|
||||
+ /* Place this here to fill delay slot */
|
||||
+ addiu NONCE_0, 1
|
||||
+
|
||||
+ /* BYTES < 0? Handle last bytes */
|
||||
+ bltz BYTES, .Lchacha20_mips_xor_bytes
|
||||
+
|
||||
+.Lchacha20_mips_xor_done:
|
||||
+ /* Restore used registers */
|
||||
+ lw $s0, 0($sp)
|
||||
+ lw $s1, 4($sp)
|
||||
+ lw $s2, 8($sp)
|
||||
+ lw $s3, 12($sp)
|
||||
+ lw $s4, 16($sp)
|
||||
+ lw $s5, 20($sp)
|
||||
+ lw $s6, 24($sp)
|
||||
+ lw $s7, 28($sp)
|
||||
+
|
||||
+ /* Write NONCE_0 back to right location in state */
|
||||
+ sw NONCE_0, 48(STATE)
|
||||
+
|
||||
+.Lchacha20_mips_end:
|
||||
+ addiu $sp, STACK_SIZE
|
||||
+ jr $ra
|
||||
+
|
||||
+.Lchacha20_mips_no_full_block_aligned:
|
||||
+ /* Restore the offset on BYTES */
|
||||
+ addiu BYTES, CHACHA20_BLOCK_SIZE
|
||||
+
|
||||
+ /* Get number of full WORDS */
|
||||
+ andi $at, BYTES, MASK_U32
|
||||
+
|
||||
+ /* Load upper half of jump table addr */
|
||||
+ lui T0, %hi(.Lchacha20_mips_jmptbl_aligned_0)
|
||||
+
|
||||
+ /* Calculate lower half jump table offset */
|
||||
+ ins T0, $at, 1, 6
|
||||
+
|
||||
+ /* Add offset to STATE */
|
||||
+ addu T1, STATE, $at
|
||||
+
|
||||
+ /* Add lower half jump table addr */
|
||||
+ addiu T0, %lo(.Lchacha20_mips_jmptbl_aligned_0)
|
||||
+
|
||||
+ /* Read value from STATE */
|
||||
+ lw SAVED_CA, 0(T1)
|
||||
+
|
||||
+ /* Store remaining bytecounter as negative value */
|
||||
+ subu BYTES, $at, BYTES
|
||||
+
|
||||
+ jr T0
|
||||
+
|
||||
+ /* Jump table */
|
||||
+ FOR_EACH_WORD(JMPTBL_ALIGNED)
|
||||
+
|
||||
+
|
||||
+.Loop_chacha20_unaligned:
|
||||
+ /* Set number rounds here to fill delayslot. */
|
||||
+ li $at, 20
|
||||
+
|
||||
+ /* BYTES > 0, it has no full block. */
|
||||
+ bltz BYTES, .Lchacha20_mips_no_full_block_unaligned
|
||||
+
|
||||
+ FOR_EACH_WORD_REV(STORE_UNALIGNED)
|
||||
+
|
||||
+ /* BYTES > 0? Loop again. */
|
||||
+ bgtz BYTES, .Loop_chacha20_rounds
|
||||
+
|
||||
+ /* Write NONCE_0 back to right location in state */
|
||||
+ sw NONCE_0, 48(STATE)
|
||||
+
|
||||
+ .set noreorder
|
||||
+ /* Fall through to byte handling */
|
||||
+ bgez BYTES, .Lchacha20_mips_xor_done
|
||||
+.Lchacha20_mips_xor_unaligned_0_b:
|
||||
+.Lchacha20_mips_xor_aligned_0_b:
|
||||
+ /* Place this here to fill delay slot */
|
||||
+ addiu NONCE_0, 1
|
||||
+ .set reorder
|
||||
+
|
||||
+.Lchacha20_mips_xor_bytes:
|
||||
+ addu IN, $at
|
||||
+ addu OUT, $at
|
||||
+ /* First byte */
|
||||
+ lbu T1, 0(IN)
|
||||
+ addiu $at, BYTES, 1
|
||||
+ CPU_TO_LE32(SAVED_X)
|
||||
+ ROTR(SAVED_X)
|
||||
+ xor T1, SAVED_X
|
||||
+ sb T1, 0(OUT)
|
||||
+ beqz $at, .Lchacha20_mips_xor_done
|
||||
+ /* Second byte */
|
||||
+ lbu T1, 1(IN)
|
||||
+ addiu $at, BYTES, 2
|
||||
+ ROTx SAVED_X, 8
|
||||
+ xor T1, SAVED_X
|
||||
+ sb T1, 1(OUT)
|
||||
+ beqz $at, .Lchacha20_mips_xor_done
|
||||
+ /* Third byte */
|
||||
+ lbu T1, 2(IN)
|
||||
+ ROTx SAVED_X, 8
|
||||
+ xor T1, SAVED_X
|
||||
+ sb T1, 2(OUT)
|
||||
+ b .Lchacha20_mips_xor_done
|
||||
+
|
||||
+.Lchacha20_mips_no_full_block_unaligned:
|
||||
+ /* Restore the offset on BYTES */
|
||||
+ addiu BYTES, CHACHA20_BLOCK_SIZE
|
||||
+
|
||||
+ /* Get number of full WORDS */
|
||||
+ andi $at, BYTES, MASK_U32
|
||||
+
|
||||
+ /* Load upper half of jump table addr */
|
||||
+ lui T0, %hi(.Lchacha20_mips_jmptbl_unaligned_0)
|
||||
+
|
||||
+ /* Calculate lower half jump table offset */
|
||||
+ ins T0, $at, 1, 6
|
||||
+
|
||||
+ /* Add offset to STATE */
|
||||
+ addu T1, STATE, $at
|
||||
+
|
||||
+ /* Add lower half jump table addr */
|
||||
+ addiu T0, %lo(.Lchacha20_mips_jmptbl_unaligned_0)
|
||||
+
|
||||
+ /* Read value from STATE */
|
||||
+ lw SAVED_CA, 0(T1)
|
||||
+
|
||||
+ /* Store remaining bytecounter as negative value */
|
||||
+ subu BYTES, $at, BYTES
|
||||
+
|
||||
+ jr T0
|
||||
+
|
||||
+ /* Jump table */
|
||||
+ FOR_EACH_WORD(JMPTBL_UNALIGNED)
|
||||
+.end chacha20_mips
|
||||
+.set at
|
||||
@@ -1,559 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:17 +0100
|
||||
Subject: [PATCH] crypto: mips/chacha - wire up accelerated 32r2 code from Zinc
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
commit 3a2f58f3ba4f6f44e33d1a48240d5eadb882cb59 upstream.
|
||||
|
||||
This integrates the accelerated MIPS 32r2 implementation of ChaCha
|
||||
into both the API and library interfaces of the kernel crypto stack.
|
||||
|
||||
The significance of this is that, in addition to becoming available
|
||||
as an accelerated library implementation, it can also be used by
|
||||
existing crypto API code such as Adiantum (for block encryption on
|
||||
ultra low performance cores) or IPsec using chacha20poly1305. These
|
||||
are use cases that have already opted into using the abstract crypto
|
||||
API. In order to support Adiantum, the core assembler routine has
|
||||
been adapted to take the round count as a function argument rather
|
||||
than hardcoding it to 20.
|
||||
|
||||
Co-developed-by: René van Dorst <opensource@vdorst.com>
|
||||
Signed-off-by: René van Dorst <opensource@vdorst.com>
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/mips/Makefile | 2 +-
|
||||
arch/mips/crypto/Makefile | 4 +
|
||||
arch/mips/crypto/chacha-core.S | 159 ++++++++++++++++++++++++---------
|
||||
arch/mips/crypto/chacha-glue.c | 150 +++++++++++++++++++++++++++++++
|
||||
crypto/Kconfig | 6 ++
|
||||
5 files changed, 277 insertions(+), 44 deletions(-)
|
||||
create mode 100644 arch/mips/crypto/chacha-glue.c
|
||||
|
||||
--- a/arch/mips/Makefile
|
||||
+++ b/arch/mips/Makefile
|
||||
@@ -334,7 +334,7 @@ libs-$(CONFIG_MIPS_FP_SUPPORT) += arch/m
|
||||
# See arch/mips/Kbuild for content of core part of the kernel
|
||||
core-y += arch/mips/
|
||||
|
||||
-drivers-$(CONFIG_MIPS_CRC_SUPPORT) += arch/mips/crypto/
|
||||
+drivers-y += arch/mips/crypto/
|
||||
drivers-$(CONFIG_OPROFILE) += arch/mips/oprofile/
|
||||
|
||||
# suspend and hibernation support
|
||||
--- a/arch/mips/crypto/Makefile
|
||||
+++ b/arch/mips/crypto/Makefile
|
||||
@@ -4,3 +4,7 @@
|
||||
#
|
||||
|
||||
obj-$(CONFIG_CRYPTO_CRC32_MIPS) += crc32-mips.o
|
||||
+
|
||||
+obj-$(CONFIG_CRYPTO_CHACHA_MIPS) += chacha-mips.o
|
||||
+chacha-mips-y := chacha-core.o chacha-glue.o
|
||||
+AFLAGS_chacha-core.o += -O2 # needed to fill branch delay slots
|
||||
--- a/arch/mips/crypto/chacha-core.S
|
||||
+++ b/arch/mips/crypto/chacha-core.S
|
||||
@@ -125,7 +125,7 @@
|
||||
#define CONCAT3(a,b,c) _CONCAT3(a,b,c)
|
||||
|
||||
#define STORE_UNALIGNED(x) \
|
||||
-CONCAT3(.Lchacha20_mips_xor_unaligned_, PLUS_ONE(x), _b: ;) \
|
||||
+CONCAT3(.Lchacha_mips_xor_unaligned_, PLUS_ONE(x), _b: ;) \
|
||||
.if (x != 12); \
|
||||
lw T0, (x*4)(STATE); \
|
||||
.endif; \
|
||||
@@ -142,7 +142,7 @@ CONCAT3(.Lchacha20_mips_xor_unaligned_,
|
||||
swr X ## x, (x*4)+LSB ## (OUT);
|
||||
|
||||
#define STORE_ALIGNED(x) \
|
||||
-CONCAT3(.Lchacha20_mips_xor_aligned_, PLUS_ONE(x), _b: ;) \
|
||||
+CONCAT3(.Lchacha_mips_xor_aligned_, PLUS_ONE(x), _b: ;) \
|
||||
.if (x != 12); \
|
||||
lw T0, (x*4)(STATE); \
|
||||
.endif; \
|
||||
@@ -162,9 +162,9 @@ CONCAT3(.Lchacha20_mips_xor_aligned_, PL
|
||||
* Every jumptable entry must be equal in size.
|
||||
*/
|
||||
#define JMPTBL_ALIGNED(x) \
|
||||
-.Lchacha20_mips_jmptbl_aligned_ ## x: ; \
|
||||
+.Lchacha_mips_jmptbl_aligned_ ## x: ; \
|
||||
.set noreorder; \
|
||||
- b .Lchacha20_mips_xor_aligned_ ## x ## _b; \
|
||||
+ b .Lchacha_mips_xor_aligned_ ## x ## _b; \
|
||||
.if (x == 12); \
|
||||
addu SAVED_X, X ## x, NONCE_0; \
|
||||
.else; \
|
||||
@@ -173,9 +173,9 @@ CONCAT3(.Lchacha20_mips_xor_aligned_, PL
|
||||
.set reorder
|
||||
|
||||
#define JMPTBL_UNALIGNED(x) \
|
||||
-.Lchacha20_mips_jmptbl_unaligned_ ## x: ; \
|
||||
+.Lchacha_mips_jmptbl_unaligned_ ## x: ; \
|
||||
.set noreorder; \
|
||||
- b .Lchacha20_mips_xor_unaligned_ ## x ## _b; \
|
||||
+ b .Lchacha_mips_xor_unaligned_ ## x ## _b; \
|
||||
.if (x == 12); \
|
||||
addu SAVED_X, X ## x, NONCE_0; \
|
||||
.else; \
|
||||
@@ -200,15 +200,18 @@ CONCAT3(.Lchacha20_mips_xor_aligned_, PL
|
||||
.text
|
||||
.set reorder
|
||||
.set noat
|
||||
-.globl chacha20_mips
|
||||
-.ent chacha20_mips
|
||||
-chacha20_mips:
|
||||
+.globl chacha_crypt_arch
|
||||
+.ent chacha_crypt_arch
|
||||
+chacha_crypt_arch:
|
||||
.frame $sp, STACK_SIZE, $ra
|
||||
|
||||
+ /* Load number of rounds */
|
||||
+ lw $at, 16($sp)
|
||||
+
|
||||
addiu $sp, -STACK_SIZE
|
||||
|
||||
/* Return bytes = 0. */
|
||||
- beqz BYTES, .Lchacha20_mips_end
|
||||
+ beqz BYTES, .Lchacha_mips_end
|
||||
|
||||
lw NONCE_0, 48(STATE)
|
||||
|
||||
@@ -228,18 +231,15 @@ chacha20_mips:
|
||||
or IS_UNALIGNED, IN, OUT
|
||||
andi IS_UNALIGNED, 0x3
|
||||
|
||||
- /* Set number of rounds */
|
||||
- li $at, 20
|
||||
-
|
||||
- b .Lchacha20_rounds_start
|
||||
+ b .Lchacha_rounds_start
|
||||
|
||||
.align 4
|
||||
-.Loop_chacha20_rounds:
|
||||
+.Loop_chacha_rounds:
|
||||
addiu IN, CHACHA20_BLOCK_SIZE
|
||||
addiu OUT, CHACHA20_BLOCK_SIZE
|
||||
addiu NONCE_0, 1
|
||||
|
||||
-.Lchacha20_rounds_start:
|
||||
+.Lchacha_rounds_start:
|
||||
lw X0, 0(STATE)
|
||||
lw X1, 4(STATE)
|
||||
lw X2, 8(STATE)
|
||||
@@ -259,7 +259,7 @@ chacha20_mips:
|
||||
lw X14, 56(STATE)
|
||||
lw X15, 60(STATE)
|
||||
|
||||
-.Loop_chacha20_xor_rounds:
|
||||
+.Loop_chacha_xor_rounds:
|
||||
addiu $at, -2
|
||||
AXR( 0, 1, 2, 3, 4, 5, 6, 7, 12,13,14,15, 16);
|
||||
AXR( 8, 9,10,11, 12,13,14,15, 4, 5, 6, 7, 12);
|
||||
@@ -269,31 +269,31 @@ chacha20_mips:
|
||||
AXR(10,11, 8, 9, 15,12,13,14, 5, 6, 7, 4, 12);
|
||||
AXR( 0, 1, 2, 3, 5, 6, 7, 4, 15,12,13,14, 8);
|
||||
AXR(10,11, 8, 9, 15,12,13,14, 5, 6, 7, 4, 7);
|
||||
- bnez $at, .Loop_chacha20_xor_rounds
|
||||
+ bnez $at, .Loop_chacha_xor_rounds
|
||||
|
||||
addiu BYTES, -(CHACHA20_BLOCK_SIZE)
|
||||
|
||||
/* Is data src/dst unaligned? Jump */
|
||||
- bnez IS_UNALIGNED, .Loop_chacha20_unaligned
|
||||
+ bnez IS_UNALIGNED, .Loop_chacha_unaligned
|
||||
|
||||
/* Set number rounds here to fill delayslot. */
|
||||
- li $at, 20
|
||||
+ lw $at, (STACK_SIZE+16)($sp)
|
||||
|
||||
/* BYTES < 0, it has no full block. */
|
||||
- bltz BYTES, .Lchacha20_mips_no_full_block_aligned
|
||||
+ bltz BYTES, .Lchacha_mips_no_full_block_aligned
|
||||
|
||||
FOR_EACH_WORD_REV(STORE_ALIGNED)
|
||||
|
||||
/* BYTES > 0? Loop again. */
|
||||
- bgtz BYTES, .Loop_chacha20_rounds
|
||||
+ bgtz BYTES, .Loop_chacha_rounds
|
||||
|
||||
/* Place this here to fill delay slot */
|
||||
addiu NONCE_0, 1
|
||||
|
||||
/* BYTES < 0? Handle last bytes */
|
||||
- bltz BYTES, .Lchacha20_mips_xor_bytes
|
||||
+ bltz BYTES, .Lchacha_mips_xor_bytes
|
||||
|
||||
-.Lchacha20_mips_xor_done:
|
||||
+.Lchacha_mips_xor_done:
|
||||
/* Restore used registers */
|
||||
lw $s0, 0($sp)
|
||||
lw $s1, 4($sp)
|
||||
@@ -307,11 +307,11 @@ chacha20_mips:
|
||||
/* Write NONCE_0 back to right location in state */
|
||||
sw NONCE_0, 48(STATE)
|
||||
|
||||
-.Lchacha20_mips_end:
|
||||
+.Lchacha_mips_end:
|
||||
addiu $sp, STACK_SIZE
|
||||
jr $ra
|
||||
|
||||
-.Lchacha20_mips_no_full_block_aligned:
|
||||
+.Lchacha_mips_no_full_block_aligned:
|
||||
/* Restore the offset on BYTES */
|
||||
addiu BYTES, CHACHA20_BLOCK_SIZE
|
||||
|
||||
@@ -319,7 +319,7 @@ chacha20_mips:
|
||||
andi $at, BYTES, MASK_U32
|
||||
|
||||
/* Load upper half of jump table addr */
|
||||
- lui T0, %hi(.Lchacha20_mips_jmptbl_aligned_0)
|
||||
+ lui T0, %hi(.Lchacha_mips_jmptbl_aligned_0)
|
||||
|
||||
/* Calculate lower half jump table offset */
|
||||
ins T0, $at, 1, 6
|
||||
@@ -328,7 +328,7 @@ chacha20_mips:
|
||||
addu T1, STATE, $at
|
||||
|
||||
/* Add lower half jump table addr */
|
||||
- addiu T0, %lo(.Lchacha20_mips_jmptbl_aligned_0)
|
||||
+ addiu T0, %lo(.Lchacha_mips_jmptbl_aligned_0)
|
||||
|
||||
/* Read value from STATE */
|
||||
lw SAVED_CA, 0(T1)
|
||||
@@ -342,31 +342,31 @@ chacha20_mips:
|
||||
FOR_EACH_WORD(JMPTBL_ALIGNED)
|
||||
|
||||
|
||||
-.Loop_chacha20_unaligned:
|
||||
+.Loop_chacha_unaligned:
|
||||
/* Set number rounds here to fill delayslot. */
|
||||
- li $at, 20
|
||||
+ lw $at, (STACK_SIZE+16)($sp)
|
||||
|
||||
/* BYTES > 0, it has no full block. */
|
||||
- bltz BYTES, .Lchacha20_mips_no_full_block_unaligned
|
||||
+ bltz BYTES, .Lchacha_mips_no_full_block_unaligned
|
||||
|
||||
FOR_EACH_WORD_REV(STORE_UNALIGNED)
|
||||
|
||||
/* BYTES > 0? Loop again. */
|
||||
- bgtz BYTES, .Loop_chacha20_rounds
|
||||
+ bgtz BYTES, .Loop_chacha_rounds
|
||||
|
||||
/* Write NONCE_0 back to right location in state */
|
||||
sw NONCE_0, 48(STATE)
|
||||
|
||||
.set noreorder
|
||||
/* Fall through to byte handling */
|
||||
- bgez BYTES, .Lchacha20_mips_xor_done
|
||||
-.Lchacha20_mips_xor_unaligned_0_b:
|
||||
-.Lchacha20_mips_xor_aligned_0_b:
|
||||
+ bgez BYTES, .Lchacha_mips_xor_done
|
||||
+.Lchacha_mips_xor_unaligned_0_b:
|
||||
+.Lchacha_mips_xor_aligned_0_b:
|
||||
/* Place this here to fill delay slot */
|
||||
addiu NONCE_0, 1
|
||||
.set reorder
|
||||
|
||||
-.Lchacha20_mips_xor_bytes:
|
||||
+.Lchacha_mips_xor_bytes:
|
||||
addu IN, $at
|
||||
addu OUT, $at
|
||||
/* First byte */
|
||||
@@ -376,22 +376,22 @@ chacha20_mips:
|
||||
ROTR(SAVED_X)
|
||||
xor T1, SAVED_X
|
||||
sb T1, 0(OUT)
|
||||
- beqz $at, .Lchacha20_mips_xor_done
|
||||
+ beqz $at, .Lchacha_mips_xor_done
|
||||
/* Second byte */
|
||||
lbu T1, 1(IN)
|
||||
addiu $at, BYTES, 2
|
||||
ROTx SAVED_X, 8
|
||||
xor T1, SAVED_X
|
||||
sb T1, 1(OUT)
|
||||
- beqz $at, .Lchacha20_mips_xor_done
|
||||
+ beqz $at, .Lchacha_mips_xor_done
|
||||
/* Third byte */
|
||||
lbu T1, 2(IN)
|
||||
ROTx SAVED_X, 8
|
||||
xor T1, SAVED_X
|
||||
sb T1, 2(OUT)
|
||||
- b .Lchacha20_mips_xor_done
|
||||
+ b .Lchacha_mips_xor_done
|
||||
|
||||
-.Lchacha20_mips_no_full_block_unaligned:
|
||||
+.Lchacha_mips_no_full_block_unaligned:
|
||||
/* Restore the offset on BYTES */
|
||||
addiu BYTES, CHACHA20_BLOCK_SIZE
|
||||
|
||||
@@ -399,7 +399,7 @@ chacha20_mips:
|
||||
andi $at, BYTES, MASK_U32
|
||||
|
||||
/* Load upper half of jump table addr */
|
||||
- lui T0, %hi(.Lchacha20_mips_jmptbl_unaligned_0)
|
||||
+ lui T0, %hi(.Lchacha_mips_jmptbl_unaligned_0)
|
||||
|
||||
/* Calculate lower half jump table offset */
|
||||
ins T0, $at, 1, 6
|
||||
@@ -408,7 +408,7 @@ chacha20_mips:
|
||||
addu T1, STATE, $at
|
||||
|
||||
/* Add lower half jump table addr */
|
||||
- addiu T0, %lo(.Lchacha20_mips_jmptbl_unaligned_0)
|
||||
+ addiu T0, %lo(.Lchacha_mips_jmptbl_unaligned_0)
|
||||
|
||||
/* Read value from STATE */
|
||||
lw SAVED_CA, 0(T1)
|
||||
@@ -420,5 +420,78 @@ chacha20_mips:
|
||||
|
||||
/* Jump table */
|
||||
FOR_EACH_WORD(JMPTBL_UNALIGNED)
|
||||
-.end chacha20_mips
|
||||
+.end chacha_crypt_arch
|
||||
+.set at
|
||||
+
|
||||
+/* Input arguments
|
||||
+ * STATE $a0
|
||||
+ * OUT $a1
|
||||
+ * NROUND $a2
|
||||
+ */
|
||||
+
|
||||
+#undef X12
|
||||
+#undef X13
|
||||
+#undef X14
|
||||
+#undef X15
|
||||
+
|
||||
+#define X12 $a3
|
||||
+#define X13 $at
|
||||
+#define X14 $v0
|
||||
+#define X15 STATE
|
||||
+
|
||||
+.set noat
|
||||
+.globl hchacha_block_arch
|
||||
+.ent hchacha_block_arch
|
||||
+hchacha_block_arch:
|
||||
+ .frame $sp, STACK_SIZE, $ra
|
||||
+
|
||||
+ addiu $sp, -STACK_SIZE
|
||||
+
|
||||
+ /* Save X11(s6) */
|
||||
+ sw X11, 0($sp)
|
||||
+
|
||||
+ lw X0, 0(STATE)
|
||||
+ lw X1, 4(STATE)
|
||||
+ lw X2, 8(STATE)
|
||||
+ lw X3, 12(STATE)
|
||||
+ lw X4, 16(STATE)
|
||||
+ lw X5, 20(STATE)
|
||||
+ lw X6, 24(STATE)
|
||||
+ lw X7, 28(STATE)
|
||||
+ lw X8, 32(STATE)
|
||||
+ lw X9, 36(STATE)
|
||||
+ lw X10, 40(STATE)
|
||||
+ lw X11, 44(STATE)
|
||||
+ lw X12, 48(STATE)
|
||||
+ lw X13, 52(STATE)
|
||||
+ lw X14, 56(STATE)
|
||||
+ lw X15, 60(STATE)
|
||||
+
|
||||
+.Loop_hchacha_xor_rounds:
|
||||
+ addiu $a2, -2
|
||||
+ AXR( 0, 1, 2, 3, 4, 5, 6, 7, 12,13,14,15, 16);
|
||||
+ AXR( 8, 9,10,11, 12,13,14,15, 4, 5, 6, 7, 12);
|
||||
+ AXR( 0, 1, 2, 3, 4, 5, 6, 7, 12,13,14,15, 8);
|
||||
+ AXR( 8, 9,10,11, 12,13,14,15, 4, 5, 6, 7, 7);
|
||||
+ AXR( 0, 1, 2, 3, 5, 6, 7, 4, 15,12,13,14, 16);
|
||||
+ AXR(10,11, 8, 9, 15,12,13,14, 5, 6, 7, 4, 12);
|
||||
+ AXR( 0, 1, 2, 3, 5, 6, 7, 4, 15,12,13,14, 8);
|
||||
+ AXR(10,11, 8, 9, 15,12,13,14, 5, 6, 7, 4, 7);
|
||||
+ bnez $a2, .Loop_hchacha_xor_rounds
|
||||
+
|
||||
+ /* Restore used register */
|
||||
+ lw X11, 0($sp)
|
||||
+
|
||||
+ sw X0, 0(OUT)
|
||||
+ sw X1, 4(OUT)
|
||||
+ sw X2, 8(OUT)
|
||||
+ sw X3, 12(OUT)
|
||||
+ sw X12, 16(OUT)
|
||||
+ sw X13, 20(OUT)
|
||||
+ sw X14, 24(OUT)
|
||||
+ sw X15, 28(OUT)
|
||||
+
|
||||
+ addiu $sp, STACK_SIZE
|
||||
+ jr $ra
|
||||
+.end hchacha_block_arch
|
||||
.set at
|
||||
--- /dev/null
|
||||
+++ b/arch/mips/crypto/chacha-glue.c
|
||||
@@ -0,0 +1,150 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * MIPS accelerated ChaCha and XChaCha stream ciphers,
|
||||
+ * including ChaCha20 (RFC7539)
|
||||
+ *
|
||||
+ * Copyright (C) 2019 Linaro, Ltd. <ard.biesheuvel@linaro.org>
|
||||
+ */
|
||||
+
|
||||
+#include <asm/byteorder.h>
|
||||
+#include <crypto/algapi.h>
|
||||
+#include <crypto/internal/chacha.h>
|
||||
+#include <crypto/internal/skcipher.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+asmlinkage void chacha_crypt_arch(u32 *state, u8 *dst, const u8 *src,
|
||||
+ unsigned int bytes, int nrounds);
|
||||
+EXPORT_SYMBOL(chacha_crypt_arch);
|
||||
+
|
||||
+asmlinkage void hchacha_block_arch(const u32 *state, u32 *stream, int nrounds);
|
||||
+EXPORT_SYMBOL(hchacha_block_arch);
|
||||
+
|
||||
+void chacha_init_arch(u32 *state, const u32 *key, const u8 *iv)
|
||||
+{
|
||||
+ chacha_init_generic(state, key, iv);
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha_init_arch);
|
||||
+
|
||||
+static int chacha_mips_stream_xor(struct skcipher_request *req,
|
||||
+ const struct chacha_ctx *ctx, const u8 *iv)
|
||||
+{
|
||||
+ struct skcipher_walk walk;
|
||||
+ u32 state[16];
|
||||
+ int err;
|
||||
+
|
||||
+ err = skcipher_walk_virt(&walk, req, false);
|
||||
+
|
||||
+ chacha_init_generic(state, ctx->key, iv);
|
||||
+
|
||||
+ while (walk.nbytes > 0) {
|
||||
+ unsigned int nbytes = walk.nbytes;
|
||||
+
|
||||
+ if (nbytes < walk.total)
|
||||
+ nbytes = round_down(nbytes, walk.stride);
|
||||
+
|
||||
+ chacha_crypt(state, walk.dst.virt.addr, walk.src.virt.addr,
|
||||
+ nbytes, ctx->nrounds);
|
||||
+ err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
||||
+ }
|
||||
+
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+static int chacha_mips(struct skcipher_request *req)
|
||||
+{
|
||||
+ struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
+ struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
+
|
||||
+ return chacha_mips_stream_xor(req, ctx, req->iv);
|
||||
+}
|
||||
+
|
||||
+static int xchacha_mips(struct skcipher_request *req)
|
||||
+{
|
||||
+ struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
+ struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
+ struct chacha_ctx subctx;
|
||||
+ u32 state[16];
|
||||
+ u8 real_iv[16];
|
||||
+
|
||||
+ chacha_init_generic(state, ctx->key, req->iv);
|
||||
+
|
||||
+ hchacha_block(state, subctx.key, ctx->nrounds);
|
||||
+ subctx.nrounds = ctx->nrounds;
|
||||
+
|
||||
+ memcpy(&real_iv[0], req->iv + 24, 8);
|
||||
+ memcpy(&real_iv[8], req->iv + 16, 8);
|
||||
+ return chacha_mips_stream_xor(req, &subctx, real_iv);
|
||||
+}
|
||||
+
|
||||
+static struct skcipher_alg algs[] = {
|
||||
+ {
|
||||
+ .base.cra_name = "chacha20",
|
||||
+ .base.cra_driver_name = "chacha20-mips",
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = CHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha20_setkey,
|
||||
+ .encrypt = chacha_mips,
|
||||
+ .decrypt = chacha_mips,
|
||||
+ }, {
|
||||
+ .base.cra_name = "xchacha20",
|
||||
+ .base.cra_driver_name = "xchacha20-mips",
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = XCHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha20_setkey,
|
||||
+ .encrypt = xchacha_mips,
|
||||
+ .decrypt = xchacha_mips,
|
||||
+ }, {
|
||||
+ .base.cra_name = "xchacha12",
|
||||
+ .base.cra_driver_name = "xchacha12-mips",
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = 1,
|
||||
+ .base.cra_ctxsize = sizeof(struct chacha_ctx),
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .min_keysize = CHACHA_KEY_SIZE,
|
||||
+ .max_keysize = CHACHA_KEY_SIZE,
|
||||
+ .ivsize = XCHACHA_IV_SIZE,
|
||||
+ .chunksize = CHACHA_BLOCK_SIZE,
|
||||
+ .setkey = chacha12_setkey,
|
||||
+ .encrypt = xchacha_mips,
|
||||
+ .decrypt = xchacha_mips,
|
||||
+ }
|
||||
+};
|
||||
+
|
||||
+static int __init chacha_simd_mod_init(void)
|
||||
+{
|
||||
+ return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+}
|
||||
+
|
||||
+static void __exit chacha_simd_mod_fini(void)
|
||||
+{
|
||||
+ crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+}
|
||||
+
|
||||
+module_init(chacha_simd_mod_init);
|
||||
+module_exit(chacha_simd_mod_fini);
|
||||
+
|
||||
+MODULE_DESCRIPTION("ChaCha and XChaCha stream ciphers (MIPS accelerated)");
|
||||
+MODULE_AUTHOR("Ard Biesheuvel <ard.biesheuvel@linaro.org>");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
+MODULE_ALIAS_CRYPTO("chacha20");
|
||||
+MODULE_ALIAS_CRYPTO("chacha20-mips");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha20");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha20-mips");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha12");
|
||||
+MODULE_ALIAS_CRYPTO("xchacha12-mips");
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -1423,6 +1423,12 @@ config CRYPTO_CHACHA20_X86_64
|
||||
SSSE3, AVX2, and AVX-512VL optimized implementations of the ChaCha20,
|
||||
XChaCha20, and XChaCha12 stream ciphers.
|
||||
|
||||
+config CRYPTO_CHACHA_MIPS
|
||||
+ tristate "ChaCha stream cipher algorithms (MIPS 32r2 optimized)"
|
||||
+ depends on CPU_MIPS32_R2
|
||||
+ select CRYPTO_BLKCIPHER
|
||||
+ select CRYPTO_ARCH_HAVE_LIB_CHACHA
|
||||
+
|
||||
config CRYPTO_SEED
|
||||
tristate "SEED cipher algorithm"
|
||||
select CRYPTO_ALGAPI
|
||||
@@ -1,115 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:18 +0100
|
||||
Subject: [PATCH] crypto: chacha - unexport chacha_generic routines
|
||||
|
||||
commit 22cf705360707ced15f9fe5423938f313c7df536 upstream.
|
||||
|
||||
Now that all users of generic ChaCha code have moved to the core library,
|
||||
there is no longer a need for the generic ChaCha skcpiher driver to
|
||||
export parts of it implementation for reuse by other drivers. So drop
|
||||
the exports, and make the symbols static.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/chacha_generic.c | 26 ++++++++------------------
|
||||
include/crypto/internal/chacha.h | 10 ----------
|
||||
2 files changed, 8 insertions(+), 28 deletions(-)
|
||||
|
||||
--- a/crypto/chacha_generic.c
|
||||
+++ b/crypto/chacha_generic.c
|
||||
@@ -21,7 +21,7 @@ static int chacha_stream_xor(struct skci
|
||||
|
||||
err = skcipher_walk_virt(&walk, req, false);
|
||||
|
||||
- crypto_chacha_init(state, ctx, iv);
|
||||
+ chacha_init_generic(state, ctx->key, iv);
|
||||
|
||||
while (walk.nbytes > 0) {
|
||||
unsigned int nbytes = walk.nbytes;
|
||||
@@ -37,36 +37,27 @@ static int chacha_stream_xor(struct skci
|
||||
return err;
|
||||
}
|
||||
|
||||
-void crypto_chacha_init(u32 *state, const struct chacha_ctx *ctx, const u8 *iv)
|
||||
-{
|
||||
- chacha_init_generic(state, ctx->key, iv);
|
||||
-}
|
||||
-EXPORT_SYMBOL_GPL(crypto_chacha_init);
|
||||
-
|
||||
-int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize)
|
||||
+static int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+ unsigned int keysize)
|
||||
{
|
||||
return chacha_setkey(tfm, key, keysize, 20);
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(crypto_chacha20_setkey);
|
||||
|
||||
-int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize)
|
||||
+static int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+ unsigned int keysize)
|
||||
{
|
||||
return chacha_setkey(tfm, key, keysize, 12);
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(crypto_chacha12_setkey);
|
||||
|
||||
-int crypto_chacha_crypt(struct skcipher_request *req)
|
||||
+static int crypto_chacha_crypt(struct skcipher_request *req)
|
||||
{
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
|
||||
return chacha_stream_xor(req, ctx, req->iv);
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(crypto_chacha_crypt);
|
||||
|
||||
-int crypto_xchacha_crypt(struct skcipher_request *req)
|
||||
+static int crypto_xchacha_crypt(struct skcipher_request *req)
|
||||
{
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm);
|
||||
@@ -75,7 +66,7 @@ int crypto_xchacha_crypt(struct skcipher
|
||||
u8 real_iv[16];
|
||||
|
||||
/* Compute the subkey given the original key and first 128 nonce bits */
|
||||
- crypto_chacha_init(state, ctx, req->iv);
|
||||
+ chacha_init_generic(state, ctx->key, req->iv);
|
||||
hchacha_block_generic(state, subctx.key, ctx->nrounds);
|
||||
subctx.nrounds = ctx->nrounds;
|
||||
|
||||
@@ -86,7 +77,6 @@ int crypto_xchacha_crypt(struct skcipher
|
||||
/* Generate the stream and XOR it with the data */
|
||||
return chacha_stream_xor(req, &subctx, real_iv);
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(crypto_xchacha_crypt);
|
||||
|
||||
static struct skcipher_alg algs[] = {
|
||||
{
|
||||
--- a/include/crypto/internal/chacha.h
|
||||
+++ b/include/crypto/internal/chacha.h
|
||||
@@ -12,8 +12,6 @@ struct chacha_ctx {
|
||||
int nrounds;
|
||||
};
|
||||
|
||||
-void crypto_chacha_init(u32 *state, const struct chacha_ctx *ctx, const u8 *iv);
|
||||
-
|
||||
static inline int chacha_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
unsigned int keysize, int nrounds)
|
||||
{
|
||||
@@ -42,12 +40,4 @@ static int inline chacha12_setkey(struct
|
||||
return chacha_setkey(tfm, key, keysize, 12);
|
||||
}
|
||||
|
||||
-int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize);
|
||||
-int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize);
|
||||
-
|
||||
-int crypto_chacha_crypt(struct skcipher_request *req);
|
||||
-int crypto_xchacha_crypt(struct skcipher_request *req);
|
||||
-
|
||||
#endif /* _CRYPTO_CHACHA_H */
|
||||
@@ -1,649 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:19 +0100
|
||||
Subject: [PATCH] crypto: poly1305 - move core routines into a separate library
|
||||
|
||||
commit 48ea8c6ebc96bc0990e12ee1c43d0832c23576bb upstream.
|
||||
|
||||
Move the core Poly1305 routines shared between the generic Poly1305
|
||||
shash driver and the Adiantum and NHPoly1305 drivers into a separate
|
||||
library so that using just this pieces does not pull in the crypto
|
||||
API pieces of the generic Poly1305 routine.
|
||||
|
||||
In a subsequent patch, we will augment this generic library with
|
||||
init/update/final routines so that Poyl1305 algorithm can be used
|
||||
directly without the need for using the crypto API's shash abstraction.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/poly1305_glue.c | 2 +-
|
||||
crypto/Kconfig | 5 +-
|
||||
crypto/adiantum.c | 5 +-
|
||||
crypto/nhpoly1305.c | 3 +-
|
||||
crypto/poly1305_generic.c | 195 ++---------------------------
|
||||
include/crypto/internal/poly1305.h | 67 ++++++++++
|
||||
include/crypto/poly1305.h | 23 ----
|
||||
lib/crypto/Kconfig | 3 +
|
||||
lib/crypto/Makefile | 3 +
|
||||
lib/crypto/poly1305.c | 158 +++++++++++++++++++++++
|
||||
10 files changed, 248 insertions(+), 216 deletions(-)
|
||||
create mode 100644 include/crypto/internal/poly1305.h
|
||||
create mode 100644 lib/crypto/poly1305.c
|
||||
|
||||
--- a/arch/x86/crypto/poly1305_glue.c
|
||||
+++ b/arch/x86/crypto/poly1305_glue.c
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
+#include <crypto/internal/poly1305.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
-#include <crypto/poly1305.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -446,7 +446,7 @@ config CRYPTO_KEYWRAP
|
||||
config CRYPTO_NHPOLY1305
|
||||
tristate
|
||||
select CRYPTO_HASH
|
||||
- select CRYPTO_POLY1305
|
||||
+ select CRYPTO_LIB_POLY1305_GENERIC
|
||||
|
||||
config CRYPTO_NHPOLY1305_SSE2
|
||||
tristate "NHPoly1305 hash function (x86_64 SSE2 implementation)"
|
||||
@@ -467,7 +467,7 @@ config CRYPTO_NHPOLY1305_AVX2
|
||||
config CRYPTO_ADIANTUM
|
||||
tristate "Adiantum support"
|
||||
select CRYPTO_CHACHA20
|
||||
- select CRYPTO_POLY1305
|
||||
+ select CRYPTO_LIB_POLY1305_GENERIC
|
||||
select CRYPTO_NHPOLY1305
|
||||
select CRYPTO_MANAGER
|
||||
help
|
||||
@@ -686,6 +686,7 @@ config CRYPTO_GHASH
|
||||
config CRYPTO_POLY1305
|
||||
tristate "Poly1305 authenticator algorithm"
|
||||
select CRYPTO_HASH
|
||||
+ select CRYPTO_LIB_POLY1305_GENERIC
|
||||
help
|
||||
Poly1305 authenticator algorithm, RFC7539.
|
||||
|
||||
--- a/crypto/adiantum.c
|
||||
+++ b/crypto/adiantum.c
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <crypto/b128ops.h>
|
||||
#include <crypto/chacha.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
+#include <crypto/internal/poly1305.h>
|
||||
#include <crypto/internal/skcipher.h>
|
||||
#include <crypto/nhpoly1305.h>
|
||||
#include <crypto/scatterwalk.h>
|
||||
@@ -242,11 +243,11 @@ static void adiantum_hash_header(struct
|
||||
|
||||
BUILD_BUG_ON(sizeof(header) % POLY1305_BLOCK_SIZE != 0);
|
||||
poly1305_core_blocks(&state, &tctx->header_hash_key,
|
||||
- &header, sizeof(header) / POLY1305_BLOCK_SIZE);
|
||||
+ &header, sizeof(header) / POLY1305_BLOCK_SIZE, 1);
|
||||
|
||||
BUILD_BUG_ON(TWEAK_SIZE % POLY1305_BLOCK_SIZE != 0);
|
||||
poly1305_core_blocks(&state, &tctx->header_hash_key, req->iv,
|
||||
- TWEAK_SIZE / POLY1305_BLOCK_SIZE);
|
||||
+ TWEAK_SIZE / POLY1305_BLOCK_SIZE, 1);
|
||||
|
||||
poly1305_core_emit(&state, &rctx->header_hash);
|
||||
}
|
||||
--- a/crypto/nhpoly1305.c
|
||||
+++ b/crypto/nhpoly1305.c
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <asm/unaligned.h>
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
+#include <crypto/internal/poly1305.h>
|
||||
#include <crypto/nhpoly1305.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -78,7 +79,7 @@ static void process_nh_hash_value(struct
|
||||
BUILD_BUG_ON(NH_HASH_BYTES % POLY1305_BLOCK_SIZE != 0);
|
||||
|
||||
poly1305_core_blocks(&state->poly_state, &key->poly_key, state->nh_hash,
|
||||
- NH_HASH_BYTES / POLY1305_BLOCK_SIZE);
|
||||
+ NH_HASH_BYTES / POLY1305_BLOCK_SIZE, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
--- a/crypto/poly1305_generic.c
|
||||
+++ b/crypto/poly1305_generic.c
|
||||
@@ -13,27 +13,12 @@
|
||||
|
||||
#include <crypto/algapi.h>
|
||||
#include <crypto/internal/hash.h>
|
||||
-#include <crypto/poly1305.h>
|
||||
+#include <crypto/internal/poly1305.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
-static inline u64 mlt(u64 a, u64 b)
|
||||
-{
|
||||
- return a * b;
|
||||
-}
|
||||
-
|
||||
-static inline u32 sr(u64 v, u_char n)
|
||||
-{
|
||||
- return v >> n;
|
||||
-}
|
||||
-
|
||||
-static inline u32 and(u32 v, u32 mask)
|
||||
-{
|
||||
- return v & mask;
|
||||
-}
|
||||
-
|
||||
int crypto_poly1305_init(struct shash_desc *desc)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
@@ -47,124 +32,8 @@ int crypto_poly1305_init(struct shash_de
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_poly1305_init);
|
||||
|
||||
-void poly1305_core_setkey(struct poly1305_key *key, const u8 *raw_key)
|
||||
-{
|
||||
- /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
|
||||
- key->r[0] = (get_unaligned_le32(raw_key + 0) >> 0) & 0x3ffffff;
|
||||
- key->r[1] = (get_unaligned_le32(raw_key + 3) >> 2) & 0x3ffff03;
|
||||
- key->r[2] = (get_unaligned_le32(raw_key + 6) >> 4) & 0x3ffc0ff;
|
||||
- key->r[3] = (get_unaligned_le32(raw_key + 9) >> 6) & 0x3f03fff;
|
||||
- key->r[4] = (get_unaligned_le32(raw_key + 12) >> 8) & 0x00fffff;
|
||||
-}
|
||||
-EXPORT_SYMBOL_GPL(poly1305_core_setkey);
|
||||
-
|
||||
-/*
|
||||
- * Poly1305 requires a unique key for each tag, which implies that we can't set
|
||||
- * it on the tfm that gets accessed by multiple users simultaneously. Instead we
|
||||
- * expect the key as the first 32 bytes in the update() call.
|
||||
- */
|
||||
-unsigned int crypto_poly1305_setdesckey(struct poly1305_desc_ctx *dctx,
|
||||
- const u8 *src, unsigned int srclen)
|
||||
-{
|
||||
- if (!dctx->sset) {
|
||||
- if (!dctx->rset && srclen >= POLY1305_BLOCK_SIZE) {
|
||||
- poly1305_core_setkey(&dctx->r, src);
|
||||
- src += POLY1305_BLOCK_SIZE;
|
||||
- srclen -= POLY1305_BLOCK_SIZE;
|
||||
- dctx->rset = true;
|
||||
- }
|
||||
- if (srclen >= POLY1305_BLOCK_SIZE) {
|
||||
- dctx->s[0] = get_unaligned_le32(src + 0);
|
||||
- dctx->s[1] = get_unaligned_le32(src + 4);
|
||||
- dctx->s[2] = get_unaligned_le32(src + 8);
|
||||
- dctx->s[3] = get_unaligned_le32(src + 12);
|
||||
- src += POLY1305_BLOCK_SIZE;
|
||||
- srclen -= POLY1305_BLOCK_SIZE;
|
||||
- dctx->sset = true;
|
||||
- }
|
||||
- }
|
||||
- return srclen;
|
||||
-}
|
||||
-EXPORT_SYMBOL_GPL(crypto_poly1305_setdesckey);
|
||||
-
|
||||
-static void poly1305_blocks_internal(struct poly1305_state *state,
|
||||
- const struct poly1305_key *key,
|
||||
- const void *src, unsigned int nblocks,
|
||||
- u32 hibit)
|
||||
-{
|
||||
- u32 r0, r1, r2, r3, r4;
|
||||
- u32 s1, s2, s3, s4;
|
||||
- u32 h0, h1, h2, h3, h4;
|
||||
- u64 d0, d1, d2, d3, d4;
|
||||
-
|
||||
- if (!nblocks)
|
||||
- return;
|
||||
-
|
||||
- r0 = key->r[0];
|
||||
- r1 = key->r[1];
|
||||
- r2 = key->r[2];
|
||||
- r3 = key->r[3];
|
||||
- r4 = key->r[4];
|
||||
-
|
||||
- s1 = r1 * 5;
|
||||
- s2 = r2 * 5;
|
||||
- s3 = r3 * 5;
|
||||
- s4 = r4 * 5;
|
||||
-
|
||||
- h0 = state->h[0];
|
||||
- h1 = state->h[1];
|
||||
- h2 = state->h[2];
|
||||
- h3 = state->h[3];
|
||||
- h4 = state->h[4];
|
||||
-
|
||||
- do {
|
||||
- /* h += m[i] */
|
||||
- h0 += (get_unaligned_le32(src + 0) >> 0) & 0x3ffffff;
|
||||
- h1 += (get_unaligned_le32(src + 3) >> 2) & 0x3ffffff;
|
||||
- h2 += (get_unaligned_le32(src + 6) >> 4) & 0x3ffffff;
|
||||
- h3 += (get_unaligned_le32(src + 9) >> 6) & 0x3ffffff;
|
||||
- h4 += (get_unaligned_le32(src + 12) >> 8) | hibit;
|
||||
-
|
||||
- /* h *= r */
|
||||
- d0 = mlt(h0, r0) + mlt(h1, s4) + mlt(h2, s3) +
|
||||
- mlt(h3, s2) + mlt(h4, s1);
|
||||
- d1 = mlt(h0, r1) + mlt(h1, r0) + mlt(h2, s4) +
|
||||
- mlt(h3, s3) + mlt(h4, s2);
|
||||
- d2 = mlt(h0, r2) + mlt(h1, r1) + mlt(h2, r0) +
|
||||
- mlt(h3, s4) + mlt(h4, s3);
|
||||
- d3 = mlt(h0, r3) + mlt(h1, r2) + mlt(h2, r1) +
|
||||
- mlt(h3, r0) + mlt(h4, s4);
|
||||
- d4 = mlt(h0, r4) + mlt(h1, r3) + mlt(h2, r2) +
|
||||
- mlt(h3, r1) + mlt(h4, r0);
|
||||
-
|
||||
- /* (partial) h %= p */
|
||||
- d1 += sr(d0, 26); h0 = and(d0, 0x3ffffff);
|
||||
- d2 += sr(d1, 26); h1 = and(d1, 0x3ffffff);
|
||||
- d3 += sr(d2, 26); h2 = and(d2, 0x3ffffff);
|
||||
- d4 += sr(d3, 26); h3 = and(d3, 0x3ffffff);
|
||||
- h0 += sr(d4, 26) * 5; h4 = and(d4, 0x3ffffff);
|
||||
- h1 += h0 >> 26; h0 = h0 & 0x3ffffff;
|
||||
-
|
||||
- src += POLY1305_BLOCK_SIZE;
|
||||
- } while (--nblocks);
|
||||
-
|
||||
- state->h[0] = h0;
|
||||
- state->h[1] = h1;
|
||||
- state->h[2] = h2;
|
||||
- state->h[3] = h3;
|
||||
- state->h[4] = h4;
|
||||
-}
|
||||
-
|
||||
-void poly1305_core_blocks(struct poly1305_state *state,
|
||||
- const struct poly1305_key *key,
|
||||
- const void *src, unsigned int nblocks)
|
||||
-{
|
||||
- poly1305_blocks_internal(state, key, src, nblocks, 1 << 24);
|
||||
-}
|
||||
-EXPORT_SYMBOL_GPL(poly1305_core_blocks);
|
||||
-
|
||||
-static void poly1305_blocks(struct poly1305_desc_ctx *dctx,
|
||||
- const u8 *src, unsigned int srclen, u32 hibit)
|
||||
+static void poly1305_blocks(struct poly1305_desc_ctx *dctx, const u8 *src,
|
||||
+ unsigned int srclen)
|
||||
{
|
||||
unsigned int datalen;
|
||||
|
||||
@@ -174,8 +43,8 @@ static void poly1305_blocks(struct poly1
|
||||
srclen = datalen;
|
||||
}
|
||||
|
||||
- poly1305_blocks_internal(&dctx->h, &dctx->r,
|
||||
- src, srclen / POLY1305_BLOCK_SIZE, hibit);
|
||||
+ poly1305_core_blocks(&dctx->h, &dctx->r, src,
|
||||
+ srclen / POLY1305_BLOCK_SIZE, 1);
|
||||
}
|
||||
|
||||
int crypto_poly1305_update(struct shash_desc *desc,
|
||||
@@ -193,13 +62,13 @@ int crypto_poly1305_update(struct shash_
|
||||
|
||||
if (dctx->buflen == POLY1305_BLOCK_SIZE) {
|
||||
poly1305_blocks(dctx, dctx->buf,
|
||||
- POLY1305_BLOCK_SIZE, 1 << 24);
|
||||
+ POLY1305_BLOCK_SIZE);
|
||||
dctx->buflen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (likely(srclen >= POLY1305_BLOCK_SIZE)) {
|
||||
- poly1305_blocks(dctx, src, srclen, 1 << 24);
|
||||
+ poly1305_blocks(dctx, src, srclen);
|
||||
src += srclen - (srclen % POLY1305_BLOCK_SIZE);
|
||||
srclen %= POLY1305_BLOCK_SIZE;
|
||||
}
|
||||
@@ -213,54 +82,6 @@ int crypto_poly1305_update(struct shash_
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_poly1305_update);
|
||||
|
||||
-void poly1305_core_emit(const struct poly1305_state *state, void *dst)
|
||||
-{
|
||||
- u32 h0, h1, h2, h3, h4;
|
||||
- u32 g0, g1, g2, g3, g4;
|
||||
- u32 mask;
|
||||
-
|
||||
- /* fully carry h */
|
||||
- h0 = state->h[0];
|
||||
- h1 = state->h[1];
|
||||
- h2 = state->h[2];
|
||||
- h3 = state->h[3];
|
||||
- h4 = state->h[4];
|
||||
-
|
||||
- h2 += (h1 >> 26); h1 = h1 & 0x3ffffff;
|
||||
- h3 += (h2 >> 26); h2 = h2 & 0x3ffffff;
|
||||
- h4 += (h3 >> 26); h3 = h3 & 0x3ffffff;
|
||||
- h0 += (h4 >> 26) * 5; h4 = h4 & 0x3ffffff;
|
||||
- h1 += (h0 >> 26); h0 = h0 & 0x3ffffff;
|
||||
-
|
||||
- /* compute h + -p */
|
||||
- g0 = h0 + 5;
|
||||
- g1 = h1 + (g0 >> 26); g0 &= 0x3ffffff;
|
||||
- g2 = h2 + (g1 >> 26); g1 &= 0x3ffffff;
|
||||
- g3 = h3 + (g2 >> 26); g2 &= 0x3ffffff;
|
||||
- g4 = h4 + (g3 >> 26) - (1 << 26); g3 &= 0x3ffffff;
|
||||
-
|
||||
- /* select h if h < p, or h + -p if h >= p */
|
||||
- mask = (g4 >> ((sizeof(u32) * 8) - 1)) - 1;
|
||||
- g0 &= mask;
|
||||
- g1 &= mask;
|
||||
- g2 &= mask;
|
||||
- g3 &= mask;
|
||||
- g4 &= mask;
|
||||
- mask = ~mask;
|
||||
- h0 = (h0 & mask) | g0;
|
||||
- h1 = (h1 & mask) | g1;
|
||||
- h2 = (h2 & mask) | g2;
|
||||
- h3 = (h3 & mask) | g3;
|
||||
- h4 = (h4 & mask) | g4;
|
||||
-
|
||||
- /* h = h % (2^128) */
|
||||
- put_unaligned_le32((h0 >> 0) | (h1 << 26), dst + 0);
|
||||
- put_unaligned_le32((h1 >> 6) | (h2 << 20), dst + 4);
|
||||
- put_unaligned_le32((h2 >> 12) | (h3 << 14), dst + 8);
|
||||
- put_unaligned_le32((h3 >> 18) | (h4 << 8), dst + 12);
|
||||
-}
|
||||
-EXPORT_SYMBOL_GPL(poly1305_core_emit);
|
||||
-
|
||||
int crypto_poly1305_final(struct shash_desc *desc, u8 *dst)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
@@ -274,7 +95,7 @@ int crypto_poly1305_final(struct shash_d
|
||||
dctx->buf[dctx->buflen++] = 1;
|
||||
memset(dctx->buf + dctx->buflen, 0,
|
||||
POLY1305_BLOCK_SIZE - dctx->buflen);
|
||||
- poly1305_blocks(dctx, dctx->buf, POLY1305_BLOCK_SIZE, 0);
|
||||
+ poly1305_core_blocks(&dctx->h, &dctx->r, dctx->buf, 1, 0);
|
||||
}
|
||||
|
||||
poly1305_core_emit(&dctx->h, digest);
|
||||
--- /dev/null
|
||||
+++ b/include/crypto/internal/poly1305.h
|
||||
@@ -0,0 +1,67 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 */
|
||||
+/*
|
||||
+ * Common values for the Poly1305 algorithm
|
||||
+ */
|
||||
+
|
||||
+#ifndef _CRYPTO_INTERNAL_POLY1305_H
|
||||
+#define _CRYPTO_INTERNAL_POLY1305_H
|
||||
+
|
||||
+#include <asm/unaligned.h>
|
||||
+#include <linux/types.h>
|
||||
+#include <crypto/poly1305.h>
|
||||
+
|
||||
+struct shash_desc;
|
||||
+
|
||||
+/*
|
||||
+ * Poly1305 core functions. These implement the ε-almost-∆-universal hash
|
||||
+ * function underlying the Poly1305 MAC, i.e. they don't add an encrypted nonce
|
||||
+ * ("s key") at the end. They also only support block-aligned inputs.
|
||||
+ */
|
||||
+void poly1305_core_setkey(struct poly1305_key *key, const u8 *raw_key);
|
||||
+static inline void poly1305_core_init(struct poly1305_state *state)
|
||||
+{
|
||||
+ *state = (struct poly1305_state){};
|
||||
+}
|
||||
+
|
||||
+void poly1305_core_blocks(struct poly1305_state *state,
|
||||
+ const struct poly1305_key *key, const void *src,
|
||||
+ unsigned int nblocks, u32 hibit);
|
||||
+void poly1305_core_emit(const struct poly1305_state *state, void *dst);
|
||||
+
|
||||
+/* Crypto API helper functions for the Poly1305 MAC */
|
||||
+int crypto_poly1305_init(struct shash_desc *desc);
|
||||
+
|
||||
+int crypto_poly1305_update(struct shash_desc *desc,
|
||||
+ const u8 *src, unsigned int srclen);
|
||||
+int crypto_poly1305_final(struct shash_desc *desc, u8 *dst);
|
||||
+
|
||||
+/*
|
||||
+ * Poly1305 requires a unique key for each tag, which implies that we can't set
|
||||
+ * it on the tfm that gets accessed by multiple users simultaneously. Instead we
|
||||
+ * expect the key as the first 32 bytes in the update() call.
|
||||
+ */
|
||||
+static inline
|
||||
+unsigned int crypto_poly1305_setdesckey(struct poly1305_desc_ctx *dctx,
|
||||
+ const u8 *src, unsigned int srclen)
|
||||
+{
|
||||
+ if (!dctx->sset) {
|
||||
+ if (!dctx->rset && srclen >= POLY1305_BLOCK_SIZE) {
|
||||
+ poly1305_core_setkey(&dctx->r, src);
|
||||
+ src += POLY1305_BLOCK_SIZE;
|
||||
+ srclen -= POLY1305_BLOCK_SIZE;
|
||||
+ dctx->rset = true;
|
||||
+ }
|
||||
+ if (srclen >= POLY1305_BLOCK_SIZE) {
|
||||
+ dctx->s[0] = get_unaligned_le32(src + 0);
|
||||
+ dctx->s[1] = get_unaligned_le32(src + 4);
|
||||
+ dctx->s[2] = get_unaligned_le32(src + 8);
|
||||
+ dctx->s[3] = get_unaligned_le32(src + 12);
|
||||
+ src += POLY1305_BLOCK_SIZE;
|
||||
+ srclen -= POLY1305_BLOCK_SIZE;
|
||||
+ dctx->sset = true;
|
||||
+ }
|
||||
+ }
|
||||
+ return srclen;
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
--- a/include/crypto/poly1305.h
|
||||
+++ b/include/crypto/poly1305.h
|
||||
@@ -38,27 +38,4 @@ struct poly1305_desc_ctx {
|
||||
bool sset;
|
||||
};
|
||||
|
||||
-/*
|
||||
- * Poly1305 core functions. These implement the ε-almost-∆-universal hash
|
||||
- * function underlying the Poly1305 MAC, i.e. they don't add an encrypted nonce
|
||||
- * ("s key") at the end. They also only support block-aligned inputs.
|
||||
- */
|
||||
-void poly1305_core_setkey(struct poly1305_key *key, const u8 *raw_key);
|
||||
-static inline void poly1305_core_init(struct poly1305_state *state)
|
||||
-{
|
||||
- memset(state->h, 0, sizeof(state->h));
|
||||
-}
|
||||
-void poly1305_core_blocks(struct poly1305_state *state,
|
||||
- const struct poly1305_key *key,
|
||||
- const void *src, unsigned int nblocks);
|
||||
-void poly1305_core_emit(const struct poly1305_state *state, void *dst);
|
||||
-
|
||||
-/* Crypto API helper functions for the Poly1305 MAC */
|
||||
-int crypto_poly1305_init(struct shash_desc *desc);
|
||||
-unsigned int crypto_poly1305_setdesckey(struct poly1305_desc_ctx *dctx,
|
||||
- const u8 *src, unsigned int srclen);
|
||||
-int crypto_poly1305_update(struct shash_desc *desc,
|
||||
- const u8 *src, unsigned int srclen);
|
||||
-int crypto_poly1305_final(struct shash_desc *desc, u8 *dst);
|
||||
-
|
||||
#endif
|
||||
--- a/lib/crypto/Kconfig
|
||||
+++ b/lib/crypto/Kconfig
|
||||
@@ -37,5 +37,8 @@ config CRYPTO_LIB_CHACHA
|
||||
config CRYPTO_LIB_DES
|
||||
tristate
|
||||
|
||||
+config CRYPTO_LIB_POLY1305_GENERIC
|
||||
+ tristate
|
||||
+
|
||||
config CRYPTO_LIB_SHA256
|
||||
tristate
|
||||
--- a/lib/crypto/Makefile
|
||||
+++ b/lib/crypto/Makefile
|
||||
@@ -13,5 +13,8 @@ libarc4-y := arc4.o
|
||||
obj-$(CONFIG_CRYPTO_LIB_DES) += libdes.o
|
||||
libdes-y := des.o
|
||||
|
||||
+obj-$(CONFIG_CRYPTO_LIB_POLY1305_GENERIC) += libpoly1305.o
|
||||
+libpoly1305-y := poly1305.o
|
||||
+
|
||||
obj-$(CONFIG_CRYPTO_LIB_SHA256) += libsha256.o
|
||||
libsha256-y := sha256.o
|
||||
--- /dev/null
|
||||
+++ b/lib/crypto/poly1305.c
|
||||
@@ -0,0 +1,158 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+/*
|
||||
+ * Poly1305 authenticator algorithm, RFC7539
|
||||
+ *
|
||||
+ * Copyright (C) 2015 Martin Willi
|
||||
+ *
|
||||
+ * Based on public domain code by Andrew Moon and Daniel J. Bernstein.
|
||||
+ */
|
||||
+
|
||||
+#include <crypto/internal/poly1305.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <asm/unaligned.h>
|
||||
+
|
||||
+static inline u64 mlt(u64 a, u64 b)
|
||||
+{
|
||||
+ return a * b;
|
||||
+}
|
||||
+
|
||||
+static inline u32 sr(u64 v, u_char n)
|
||||
+{
|
||||
+ return v >> n;
|
||||
+}
|
||||
+
|
||||
+static inline u32 and(u32 v, u32 mask)
|
||||
+{
|
||||
+ return v & mask;
|
||||
+}
|
||||
+
|
||||
+void poly1305_core_setkey(struct poly1305_key *key, const u8 *raw_key)
|
||||
+{
|
||||
+ /* r &= 0xffffffc0ffffffc0ffffffc0fffffff */
|
||||
+ key->r[0] = (get_unaligned_le32(raw_key + 0) >> 0) & 0x3ffffff;
|
||||
+ key->r[1] = (get_unaligned_le32(raw_key + 3) >> 2) & 0x3ffff03;
|
||||
+ key->r[2] = (get_unaligned_le32(raw_key + 6) >> 4) & 0x3ffc0ff;
|
||||
+ key->r[3] = (get_unaligned_le32(raw_key + 9) >> 6) & 0x3f03fff;
|
||||
+ key->r[4] = (get_unaligned_le32(raw_key + 12) >> 8) & 0x00fffff;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(poly1305_core_setkey);
|
||||
+
|
||||
+void poly1305_core_blocks(struct poly1305_state *state,
|
||||
+ const struct poly1305_key *key, const void *src,
|
||||
+ unsigned int nblocks, u32 hibit)
|
||||
+{
|
||||
+ u32 r0, r1, r2, r3, r4;
|
||||
+ u32 s1, s2, s3, s4;
|
||||
+ u32 h0, h1, h2, h3, h4;
|
||||
+ u64 d0, d1, d2, d3, d4;
|
||||
+
|
||||
+ if (!nblocks)
|
||||
+ return;
|
||||
+
|
||||
+ r0 = key->r[0];
|
||||
+ r1 = key->r[1];
|
||||
+ r2 = key->r[2];
|
||||
+ r3 = key->r[3];
|
||||
+ r4 = key->r[4];
|
||||
+
|
||||
+ s1 = r1 * 5;
|
||||
+ s2 = r2 * 5;
|
||||
+ s3 = r3 * 5;
|
||||
+ s4 = r4 * 5;
|
||||
+
|
||||
+ h0 = state->h[0];
|
||||
+ h1 = state->h[1];
|
||||
+ h2 = state->h[2];
|
||||
+ h3 = state->h[3];
|
||||
+ h4 = state->h[4];
|
||||
+
|
||||
+ do {
|
||||
+ /* h += m[i] */
|
||||
+ h0 += (get_unaligned_le32(src + 0) >> 0) & 0x3ffffff;
|
||||
+ h1 += (get_unaligned_le32(src + 3) >> 2) & 0x3ffffff;
|
||||
+ h2 += (get_unaligned_le32(src + 6) >> 4) & 0x3ffffff;
|
||||
+ h3 += (get_unaligned_le32(src + 9) >> 6) & 0x3ffffff;
|
||||
+ h4 += (get_unaligned_le32(src + 12) >> 8) | (hibit << 24);
|
||||
+
|
||||
+ /* h *= r */
|
||||
+ d0 = mlt(h0, r0) + mlt(h1, s4) + mlt(h2, s3) +
|
||||
+ mlt(h3, s2) + mlt(h4, s1);
|
||||
+ d1 = mlt(h0, r1) + mlt(h1, r0) + mlt(h2, s4) +
|
||||
+ mlt(h3, s3) + mlt(h4, s2);
|
||||
+ d2 = mlt(h0, r2) + mlt(h1, r1) + mlt(h2, r0) +
|
||||
+ mlt(h3, s4) + mlt(h4, s3);
|
||||
+ d3 = mlt(h0, r3) + mlt(h1, r2) + mlt(h2, r1) +
|
||||
+ mlt(h3, r0) + mlt(h4, s4);
|
||||
+ d4 = mlt(h0, r4) + mlt(h1, r3) + mlt(h2, r2) +
|
||||
+ mlt(h3, r1) + mlt(h4, r0);
|
||||
+
|
||||
+ /* (partial) h %= p */
|
||||
+ d1 += sr(d0, 26); h0 = and(d0, 0x3ffffff);
|
||||
+ d2 += sr(d1, 26); h1 = and(d1, 0x3ffffff);
|
||||
+ d3 += sr(d2, 26); h2 = and(d2, 0x3ffffff);
|
||||
+ d4 += sr(d3, 26); h3 = and(d3, 0x3ffffff);
|
||||
+ h0 += sr(d4, 26) * 5; h4 = and(d4, 0x3ffffff);
|
||||
+ h1 += h0 >> 26; h0 = h0 & 0x3ffffff;
|
||||
+
|
||||
+ src += POLY1305_BLOCK_SIZE;
|
||||
+ } while (--nblocks);
|
||||
+
|
||||
+ state->h[0] = h0;
|
||||
+ state->h[1] = h1;
|
||||
+ state->h[2] = h2;
|
||||
+ state->h[3] = h3;
|
||||
+ state->h[4] = h4;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(poly1305_core_blocks);
|
||||
+
|
||||
+void poly1305_core_emit(const struct poly1305_state *state, void *dst)
|
||||
+{
|
||||
+ u32 h0, h1, h2, h3, h4;
|
||||
+ u32 g0, g1, g2, g3, g4;
|
||||
+ u32 mask;
|
||||
+
|
||||
+ /* fully carry h */
|
||||
+ h0 = state->h[0];
|
||||
+ h1 = state->h[1];
|
||||
+ h2 = state->h[2];
|
||||
+ h3 = state->h[3];
|
||||
+ h4 = state->h[4];
|
||||
+
|
||||
+ h2 += (h1 >> 26); h1 = h1 & 0x3ffffff;
|
||||
+ h3 += (h2 >> 26); h2 = h2 & 0x3ffffff;
|
||||
+ h4 += (h3 >> 26); h3 = h3 & 0x3ffffff;
|
||||
+ h0 += (h4 >> 26) * 5; h4 = h4 & 0x3ffffff;
|
||||
+ h1 += (h0 >> 26); h0 = h0 & 0x3ffffff;
|
||||
+
|
||||
+ /* compute h + -p */
|
||||
+ g0 = h0 + 5;
|
||||
+ g1 = h1 + (g0 >> 26); g0 &= 0x3ffffff;
|
||||
+ g2 = h2 + (g1 >> 26); g1 &= 0x3ffffff;
|
||||
+ g3 = h3 + (g2 >> 26); g2 &= 0x3ffffff;
|
||||
+ g4 = h4 + (g3 >> 26) - (1 << 26); g3 &= 0x3ffffff;
|
||||
+
|
||||
+ /* select h if h < p, or h + -p if h >= p */
|
||||
+ mask = (g4 >> ((sizeof(u32) * 8) - 1)) - 1;
|
||||
+ g0 &= mask;
|
||||
+ g1 &= mask;
|
||||
+ g2 &= mask;
|
||||
+ g3 &= mask;
|
||||
+ g4 &= mask;
|
||||
+ mask = ~mask;
|
||||
+ h0 = (h0 & mask) | g0;
|
||||
+ h1 = (h1 & mask) | g1;
|
||||
+ h2 = (h2 & mask) | g2;
|
||||
+ h3 = (h3 & mask) | g3;
|
||||
+ h4 = (h4 & mask) | g4;
|
||||
+
|
||||
+ /* h = h % (2^128) */
|
||||
+ put_unaligned_le32((h0 >> 0) | (h1 << 26), dst + 0);
|
||||
+ put_unaligned_le32((h1 >> 6) | (h2 << 20), dst + 4);
|
||||
+ put_unaligned_le32((h2 >> 12) | (h3 << 14), dst + 8);
|
||||
+ put_unaligned_le32((h3 >> 18) | (h4 << 8), dst + 12);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(poly1305_core_emit);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_AUTHOR("Martin Willi <martin@strongswan.org>");
|
||||
@@ -1,251 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:20 +0100
|
||||
Subject: [PATCH] crypto: x86/poly1305 - unify Poly1305 state struct with
|
||||
generic code
|
||||
|
||||
commit ad8f5b88383ea685f2b8df2a12ee3e08089a1287 upstream.
|
||||
|
||||
In preparation of exposing a Poly1305 library interface directly from
|
||||
the accelerated x86 driver, align the state descriptor of the x86 code
|
||||
with the one used by the generic driver. This is needed to make the
|
||||
library interface unified between all implementations.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/poly1305_glue.c | 88 ++++++++++--------------------
|
||||
crypto/poly1305_generic.c | 6 +-
|
||||
include/crypto/internal/poly1305.h | 4 +-
|
||||
include/crypto/poly1305.h | 18 +++---
|
||||
4 files changed, 43 insertions(+), 73 deletions(-)
|
||||
|
||||
--- a/arch/x86/crypto/poly1305_glue.c
|
||||
+++ b/arch/x86/crypto/poly1305_glue.c
|
||||
@@ -14,40 +14,14 @@
|
||||
#include <linux/module.h>
|
||||
#include <asm/simd.h>
|
||||
|
||||
-struct poly1305_simd_desc_ctx {
|
||||
- struct poly1305_desc_ctx base;
|
||||
- /* derived key u set? */
|
||||
- bool uset;
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
- /* derived keys r^3, r^4 set? */
|
||||
- bool wset;
|
||||
-#endif
|
||||
- /* derived Poly1305 key r^2 */
|
||||
- u32 u[5];
|
||||
- /* ... silently appended r^3 and r^4 when using AVX2 */
|
||||
-};
|
||||
-
|
||||
asmlinkage void poly1305_block_sse2(u32 *h, const u8 *src,
|
||||
const u32 *r, unsigned int blocks);
|
||||
asmlinkage void poly1305_2block_sse2(u32 *h, const u8 *src, const u32 *r,
|
||||
unsigned int blocks, const u32 *u);
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
asmlinkage void poly1305_4block_avx2(u32 *h, const u8 *src, const u32 *r,
|
||||
unsigned int blocks, const u32 *u);
|
||||
-static bool poly1305_use_avx2;
|
||||
-#endif
|
||||
|
||||
-static int poly1305_simd_init(struct shash_desc *desc)
|
||||
-{
|
||||
- struct poly1305_simd_desc_ctx *sctx = shash_desc_ctx(desc);
|
||||
-
|
||||
- sctx->uset = false;
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
- sctx->wset = false;
|
||||
-#endif
|
||||
-
|
||||
- return crypto_poly1305_init(desc);
|
||||
-}
|
||||
+static bool poly1305_use_avx2 __ro_after_init;
|
||||
|
||||
static void poly1305_simd_mult(u32 *a, const u32 *b)
|
||||
{
|
||||
@@ -63,53 +37,49 @@ static void poly1305_simd_mult(u32 *a, c
|
||||
static unsigned int poly1305_simd_blocks(struct poly1305_desc_ctx *dctx,
|
||||
const u8 *src, unsigned int srclen)
|
||||
{
|
||||
- struct poly1305_simd_desc_ctx *sctx;
|
||||
unsigned int blocks, datalen;
|
||||
|
||||
- BUILD_BUG_ON(offsetof(struct poly1305_simd_desc_ctx, base));
|
||||
- sctx = container_of(dctx, struct poly1305_simd_desc_ctx, base);
|
||||
-
|
||||
if (unlikely(!dctx->sset)) {
|
||||
datalen = crypto_poly1305_setdesckey(dctx, src, srclen);
|
||||
src += srclen - datalen;
|
||||
srclen = datalen;
|
||||
}
|
||||
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
- if (poly1305_use_avx2 && srclen >= POLY1305_BLOCK_SIZE * 4) {
|
||||
- if (unlikely(!sctx->wset)) {
|
||||
- if (!sctx->uset) {
|
||||
- memcpy(sctx->u, dctx->r.r, sizeof(sctx->u));
|
||||
- poly1305_simd_mult(sctx->u, dctx->r.r);
|
||||
- sctx->uset = true;
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX2) &&
|
||||
+ poly1305_use_avx2 &&
|
||||
+ srclen >= POLY1305_BLOCK_SIZE * 4) {
|
||||
+ if (unlikely(dctx->rset < 4)) {
|
||||
+ if (dctx->rset < 2) {
|
||||
+ dctx->r[1] = dctx->r[0];
|
||||
+ poly1305_simd_mult(dctx->r[1].r, dctx->r[0].r);
|
||||
}
|
||||
- memcpy(sctx->u + 5, sctx->u, sizeof(sctx->u));
|
||||
- poly1305_simd_mult(sctx->u + 5, dctx->r.r);
|
||||
- memcpy(sctx->u + 10, sctx->u + 5, sizeof(sctx->u));
|
||||
- poly1305_simd_mult(sctx->u + 10, dctx->r.r);
|
||||
- sctx->wset = true;
|
||||
+ dctx->r[2] = dctx->r[1];
|
||||
+ poly1305_simd_mult(dctx->r[2].r, dctx->r[0].r);
|
||||
+ dctx->r[3] = dctx->r[2];
|
||||
+ poly1305_simd_mult(dctx->r[3].r, dctx->r[0].r);
|
||||
+ dctx->rset = 4;
|
||||
}
|
||||
blocks = srclen / (POLY1305_BLOCK_SIZE * 4);
|
||||
- poly1305_4block_avx2(dctx->h.h, src, dctx->r.r, blocks,
|
||||
- sctx->u);
|
||||
+ poly1305_4block_avx2(dctx->h.h, src, dctx->r[0].r, blocks,
|
||||
+ dctx->r[1].r);
|
||||
src += POLY1305_BLOCK_SIZE * 4 * blocks;
|
||||
srclen -= POLY1305_BLOCK_SIZE * 4 * blocks;
|
||||
}
|
||||
-#endif
|
||||
+
|
||||
if (likely(srclen >= POLY1305_BLOCK_SIZE * 2)) {
|
||||
- if (unlikely(!sctx->uset)) {
|
||||
- memcpy(sctx->u, dctx->r.r, sizeof(sctx->u));
|
||||
- poly1305_simd_mult(sctx->u, dctx->r.r);
|
||||
- sctx->uset = true;
|
||||
+ if (unlikely(dctx->rset < 2)) {
|
||||
+ dctx->r[1] = dctx->r[0];
|
||||
+ poly1305_simd_mult(dctx->r[1].r, dctx->r[0].r);
|
||||
+ dctx->rset = 2;
|
||||
}
|
||||
blocks = srclen / (POLY1305_BLOCK_SIZE * 2);
|
||||
- poly1305_2block_sse2(dctx->h.h, src, dctx->r.r, blocks,
|
||||
- sctx->u);
|
||||
+ poly1305_2block_sse2(dctx->h.h, src, dctx->r[0].r,
|
||||
+ blocks, dctx->r[1].r);
|
||||
src += POLY1305_BLOCK_SIZE * 2 * blocks;
|
||||
srclen -= POLY1305_BLOCK_SIZE * 2 * blocks;
|
||||
}
|
||||
if (srclen >= POLY1305_BLOCK_SIZE) {
|
||||
- poly1305_block_sse2(dctx->h.h, src, dctx->r.r, 1);
|
||||
+ poly1305_block_sse2(dctx->h.h, src, dctx->r[0].r, 1);
|
||||
srclen -= POLY1305_BLOCK_SIZE;
|
||||
}
|
||||
return srclen;
|
||||
@@ -159,10 +129,10 @@ static int poly1305_simd_update(struct s
|
||||
|
||||
static struct shash_alg alg = {
|
||||
.digestsize = POLY1305_DIGEST_SIZE,
|
||||
- .init = poly1305_simd_init,
|
||||
+ .init = crypto_poly1305_init,
|
||||
.update = poly1305_simd_update,
|
||||
.final = crypto_poly1305_final,
|
||||
- .descsize = sizeof(struct poly1305_simd_desc_ctx),
|
||||
+ .descsize = sizeof(struct poly1305_desc_ctx),
|
||||
.base = {
|
||||
.cra_name = "poly1305",
|
||||
.cra_driver_name = "poly1305-simd",
|
||||
@@ -177,14 +147,14 @@ static int __init poly1305_simd_mod_init
|
||||
if (!boot_cpu_has(X86_FEATURE_XMM2))
|
||||
return -ENODEV;
|
||||
|
||||
-#ifdef CONFIG_AS_AVX2
|
||||
- poly1305_use_avx2 = boot_cpu_has(X86_FEATURE_AVX) &&
|
||||
+ poly1305_use_avx2 = IS_ENABLED(CONFIG_AS_AVX2) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX) &&
|
||||
boot_cpu_has(X86_FEATURE_AVX2) &&
|
||||
cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL);
|
||||
- alg.descsize = sizeof(struct poly1305_simd_desc_ctx);
|
||||
+ alg.descsize = sizeof(struct poly1305_desc_ctx) + 5 * sizeof(u32);
|
||||
if (poly1305_use_avx2)
|
||||
alg.descsize += 10 * sizeof(u32);
|
||||
-#endif
|
||||
+
|
||||
return crypto_register_shash(&alg);
|
||||
}
|
||||
|
||||
--- a/crypto/poly1305_generic.c
|
||||
+++ b/crypto/poly1305_generic.c
|
||||
@@ -25,7 +25,7 @@ int crypto_poly1305_init(struct shash_de
|
||||
|
||||
poly1305_core_init(&dctx->h);
|
||||
dctx->buflen = 0;
|
||||
- dctx->rset = false;
|
||||
+ dctx->rset = 0;
|
||||
dctx->sset = false;
|
||||
|
||||
return 0;
|
||||
@@ -43,7 +43,7 @@ static void poly1305_blocks(struct poly1
|
||||
srclen = datalen;
|
||||
}
|
||||
|
||||
- poly1305_core_blocks(&dctx->h, &dctx->r, src,
|
||||
+ poly1305_core_blocks(&dctx->h, dctx->r, src,
|
||||
srclen / POLY1305_BLOCK_SIZE, 1);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ int crypto_poly1305_final(struct shash_d
|
||||
dctx->buf[dctx->buflen++] = 1;
|
||||
memset(dctx->buf + dctx->buflen, 0,
|
||||
POLY1305_BLOCK_SIZE - dctx->buflen);
|
||||
- poly1305_core_blocks(&dctx->h, &dctx->r, dctx->buf, 1, 0);
|
||||
+ poly1305_core_blocks(&dctx->h, dctx->r, dctx->buf, 1, 0);
|
||||
}
|
||||
|
||||
poly1305_core_emit(&dctx->h, digest);
|
||||
--- a/include/crypto/internal/poly1305.h
|
||||
+++ b/include/crypto/internal/poly1305.h
|
||||
@@ -46,10 +46,10 @@ unsigned int crypto_poly1305_setdesckey(
|
||||
{
|
||||
if (!dctx->sset) {
|
||||
if (!dctx->rset && srclen >= POLY1305_BLOCK_SIZE) {
|
||||
- poly1305_core_setkey(&dctx->r, src);
|
||||
+ poly1305_core_setkey(dctx->r, src);
|
||||
src += POLY1305_BLOCK_SIZE;
|
||||
srclen -= POLY1305_BLOCK_SIZE;
|
||||
- dctx->rset = true;
|
||||
+ dctx->rset = 1;
|
||||
}
|
||||
if (srclen >= POLY1305_BLOCK_SIZE) {
|
||||
dctx->s[0] = get_unaligned_le32(src + 0);
|
||||
--- a/include/crypto/poly1305.h
|
||||
+++ b/include/crypto/poly1305.h
|
||||
@@ -22,20 +22,20 @@ struct poly1305_state {
|
||||
};
|
||||
|
||||
struct poly1305_desc_ctx {
|
||||
- /* key */
|
||||
- struct poly1305_key r;
|
||||
- /* finalize key */
|
||||
- u32 s[4];
|
||||
- /* accumulator */
|
||||
- struct poly1305_state h;
|
||||
/* partial buffer */
|
||||
u8 buf[POLY1305_BLOCK_SIZE];
|
||||
/* bytes used in partial buffer */
|
||||
unsigned int buflen;
|
||||
- /* r key has been set */
|
||||
- bool rset;
|
||||
- /* s key has been set */
|
||||
+ /* how many keys have been set in r[] */
|
||||
+ unsigned short rset;
|
||||
+ /* whether s[] has been set */
|
||||
bool sset;
|
||||
+ /* finalize key */
|
||||
+ u32 s[4];
|
||||
+ /* accumulator */
|
||||
+ struct poly1305_state h;
|
||||
+ /* key */
|
||||
+ struct poly1305_key r[1];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,224 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:21 +0100
|
||||
Subject: [PATCH] crypto: poly1305 - expose init/update/final library interface
|
||||
|
||||
commit a1d93064094cc5e24d64e35cf093e7191d0c9344 upstream.
|
||||
|
||||
Expose the existing generic Poly1305 code via a init/update/final
|
||||
library interface so that callers are not required to go through
|
||||
the crypto API's shash abstraction to access it. At the same time,
|
||||
make some preparations so that the library implementation can be
|
||||
superseded by an accelerated arch-specific version in the future.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/poly1305_generic.c | 22 +-----------
|
||||
include/crypto/poly1305.h | 38 +++++++++++++++++++-
|
||||
lib/crypto/Kconfig | 26 ++++++++++++++
|
||||
lib/crypto/poly1305.c | 74 +++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 138 insertions(+), 22 deletions(-)
|
||||
|
||||
--- a/crypto/poly1305_generic.c
|
||||
+++ b/crypto/poly1305_generic.c
|
||||
@@ -85,31 +85,11 @@ EXPORT_SYMBOL_GPL(crypto_poly1305_update
|
||||
int crypto_poly1305_final(struct shash_desc *desc, u8 *dst)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
- __le32 digest[4];
|
||||
- u64 f = 0;
|
||||
|
||||
if (unlikely(!dctx->sset))
|
||||
return -ENOKEY;
|
||||
|
||||
- if (unlikely(dctx->buflen)) {
|
||||
- dctx->buf[dctx->buflen++] = 1;
|
||||
- memset(dctx->buf + dctx->buflen, 0,
|
||||
- POLY1305_BLOCK_SIZE - dctx->buflen);
|
||||
- poly1305_core_blocks(&dctx->h, dctx->r, dctx->buf, 1, 0);
|
||||
- }
|
||||
-
|
||||
- poly1305_core_emit(&dctx->h, digest);
|
||||
-
|
||||
- /* mac = (h + s) % (2^128) */
|
||||
- f = (f >> 32) + le32_to_cpu(digest[0]) + dctx->s[0];
|
||||
- put_unaligned_le32(f, dst + 0);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[1]) + dctx->s[1];
|
||||
- put_unaligned_le32(f, dst + 4);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[2]) + dctx->s[2];
|
||||
- put_unaligned_le32(f, dst + 8);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[3]) + dctx->s[3];
|
||||
- put_unaligned_le32(f, dst + 12);
|
||||
-
|
||||
+ poly1305_final_generic(dctx, dst);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_poly1305_final);
|
||||
--- a/include/crypto/poly1305.h
|
||||
+++ b/include/crypto/poly1305.h
|
||||
@@ -35,7 +35,43 @@ struct poly1305_desc_ctx {
|
||||
/* accumulator */
|
||||
struct poly1305_state h;
|
||||
/* key */
|
||||
- struct poly1305_key r[1];
|
||||
+ struct poly1305_key r[CONFIG_CRYPTO_LIB_POLY1305_RSIZE];
|
||||
};
|
||||
|
||||
+void poly1305_init_arch(struct poly1305_desc_ctx *desc, const u8 *key);
|
||||
+void poly1305_init_generic(struct poly1305_desc_ctx *desc, const u8 *key);
|
||||
+
|
||||
+static inline void poly1305_init(struct poly1305_desc_ctx *desc, const u8 *key)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_POLY1305))
|
||||
+ poly1305_init_arch(desc, key);
|
||||
+ else
|
||||
+ poly1305_init_generic(desc, key);
|
||||
+}
|
||||
+
|
||||
+void poly1305_update_arch(struct poly1305_desc_ctx *desc, const u8 *src,
|
||||
+ unsigned int nbytes);
|
||||
+void poly1305_update_generic(struct poly1305_desc_ctx *desc, const u8 *src,
|
||||
+ unsigned int nbytes);
|
||||
+
|
||||
+static inline void poly1305_update(struct poly1305_desc_ctx *desc,
|
||||
+ const u8 *src, unsigned int nbytes)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_POLY1305))
|
||||
+ poly1305_update_arch(desc, src, nbytes);
|
||||
+ else
|
||||
+ poly1305_update_generic(desc, src, nbytes);
|
||||
+}
|
||||
+
|
||||
+void poly1305_final_arch(struct poly1305_desc_ctx *desc, u8 *digest);
|
||||
+void poly1305_final_generic(struct poly1305_desc_ctx *desc, u8 *digest);
|
||||
+
|
||||
+static inline void poly1305_final(struct poly1305_desc_ctx *desc, u8 *digest)
|
||||
+{
|
||||
+ if (IS_ENABLED(CONFIG_CRYPTO_ARCH_HAVE_LIB_POLY1305))
|
||||
+ poly1305_final_arch(desc, digest);
|
||||
+ else
|
||||
+ poly1305_final_generic(desc, digest);
|
||||
+}
|
||||
+
|
||||
#endif
|
||||
--- a/lib/crypto/Kconfig
|
||||
+++ b/lib/crypto/Kconfig
|
||||
@@ -37,8 +37,34 @@ config CRYPTO_LIB_CHACHA
|
||||
config CRYPTO_LIB_DES
|
||||
tristate
|
||||
|
||||
+config CRYPTO_LIB_POLY1305_RSIZE
|
||||
+ int
|
||||
+ default 1
|
||||
+
|
||||
+config CRYPTO_ARCH_HAVE_LIB_POLY1305
|
||||
+ tristate
|
||||
+ help
|
||||
+ Declares whether the architecture provides an arch-specific
|
||||
+ accelerated implementation of the Poly1305 library interface,
|
||||
+ either builtin or as a module.
|
||||
+
|
||||
config CRYPTO_LIB_POLY1305_GENERIC
|
||||
tristate
|
||||
+ help
|
||||
+ This symbol can be depended upon by arch implementations of the
|
||||
+ Poly1305 library interface that require the generic code as a
|
||||
+ fallback, e.g., for SIMD implementations. If no arch specific
|
||||
+ implementation is enabled, this implementation serves the users
|
||||
+ of CRYPTO_LIB_POLY1305.
|
||||
+
|
||||
+config CRYPTO_LIB_POLY1305
|
||||
+ tristate "Poly1305 library interface"
|
||||
+ depends on CRYPTO_ARCH_HAVE_LIB_POLY1305 || !CRYPTO_ARCH_HAVE_LIB_POLY1305
|
||||
+ select CRYPTO_LIB_POLY1305_GENERIC if CRYPTO_ARCH_HAVE_LIB_POLY1305=n
|
||||
+ help
|
||||
+ Enable the Poly1305 library interface. This interface may be fulfilled
|
||||
+ by either the generic implementation or an arch-specific one, if one
|
||||
+ is available and enabled.
|
||||
|
||||
config CRYPTO_LIB_SHA256
|
||||
tristate
|
||||
--- a/lib/crypto/poly1305.c
|
||||
+++ b/lib/crypto/poly1305.c
|
||||
@@ -154,5 +154,79 @@ void poly1305_core_emit(const struct pol
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(poly1305_core_emit);
|
||||
|
||||
+void poly1305_init_generic(struct poly1305_desc_ctx *desc, const u8 *key)
|
||||
+{
|
||||
+ poly1305_core_setkey(desc->r, key);
|
||||
+ desc->s[0] = get_unaligned_le32(key + 16);
|
||||
+ desc->s[1] = get_unaligned_le32(key + 20);
|
||||
+ desc->s[2] = get_unaligned_le32(key + 24);
|
||||
+ desc->s[3] = get_unaligned_le32(key + 28);
|
||||
+ poly1305_core_init(&desc->h);
|
||||
+ desc->buflen = 0;
|
||||
+ desc->sset = true;
|
||||
+ desc->rset = 1;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(poly1305_init_generic);
|
||||
+
|
||||
+void poly1305_update_generic(struct poly1305_desc_ctx *desc, const u8 *src,
|
||||
+ unsigned int nbytes)
|
||||
+{
|
||||
+ unsigned int bytes;
|
||||
+
|
||||
+ if (unlikely(desc->buflen)) {
|
||||
+ bytes = min(nbytes, POLY1305_BLOCK_SIZE - desc->buflen);
|
||||
+ memcpy(desc->buf + desc->buflen, src, bytes);
|
||||
+ src += bytes;
|
||||
+ nbytes -= bytes;
|
||||
+ desc->buflen += bytes;
|
||||
+
|
||||
+ if (desc->buflen == POLY1305_BLOCK_SIZE) {
|
||||
+ poly1305_core_blocks(&desc->h, desc->r, desc->buf, 1, 1);
|
||||
+ desc->buflen = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (likely(nbytes >= POLY1305_BLOCK_SIZE)) {
|
||||
+ poly1305_core_blocks(&desc->h, desc->r, src,
|
||||
+ nbytes / POLY1305_BLOCK_SIZE, 1);
|
||||
+ src += nbytes - (nbytes % POLY1305_BLOCK_SIZE);
|
||||
+ nbytes %= POLY1305_BLOCK_SIZE;
|
||||
+ }
|
||||
+
|
||||
+ if (unlikely(nbytes)) {
|
||||
+ desc->buflen = nbytes;
|
||||
+ memcpy(desc->buf, src, nbytes);
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(poly1305_update_generic);
|
||||
+
|
||||
+void poly1305_final_generic(struct poly1305_desc_ctx *desc, u8 *dst)
|
||||
+{
|
||||
+ __le32 digest[4];
|
||||
+ u64 f = 0;
|
||||
+
|
||||
+ if (unlikely(desc->buflen)) {
|
||||
+ desc->buf[desc->buflen++] = 1;
|
||||
+ memset(desc->buf + desc->buflen, 0,
|
||||
+ POLY1305_BLOCK_SIZE - desc->buflen);
|
||||
+ poly1305_core_blocks(&desc->h, desc->r, desc->buf, 1, 0);
|
||||
+ }
|
||||
+
|
||||
+ poly1305_core_emit(&desc->h, digest);
|
||||
+
|
||||
+ /* mac = (h + s) % (2^128) */
|
||||
+ f = (f >> 32) + le32_to_cpu(digest[0]) + desc->s[0];
|
||||
+ put_unaligned_le32(f, dst + 0);
|
||||
+ f = (f >> 32) + le32_to_cpu(digest[1]) + desc->s[1];
|
||||
+ put_unaligned_le32(f, dst + 4);
|
||||
+ f = (f >> 32) + le32_to_cpu(digest[2]) + desc->s[2];
|
||||
+ put_unaligned_le32(f, dst + 8);
|
||||
+ f = (f >> 32) + le32_to_cpu(digest[3]) + desc->s[3];
|
||||
+ put_unaligned_le32(f, dst + 12);
|
||||
+
|
||||
+ *desc = (struct poly1305_desc_ctx){};
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(poly1305_final_generic);
|
||||
+
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Martin Willi <martin@strongswan.org>");
|
||||
@@ -1,217 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:22 +0100
|
||||
Subject: [PATCH] crypto: x86/poly1305 - depend on generic library not generic
|
||||
shash
|
||||
|
||||
commit 1b2c6a5120489d41c8ea3b8dacd0b4586289b158 upstream.
|
||||
|
||||
Remove the dependency on the generic Poly1305 driver. Instead, depend
|
||||
on the generic library so that we only reuse code without pulling in
|
||||
the generic skcipher implementation as well.
|
||||
|
||||
While at it, remove the logic that prefers the non-SIMD path for short
|
||||
inputs - this is no longer necessary after recent FPU handling changes
|
||||
on x86.
|
||||
|
||||
Since this removes the last remaining user of the routines exported
|
||||
by the generic shash driver, unexport them and make them static.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/poly1305_glue.c | 66 +++++++++++++++++++++++++-----
|
||||
crypto/Kconfig | 2 +-
|
||||
crypto/poly1305_generic.c | 11 ++---
|
||||
include/crypto/internal/poly1305.h | 9 ----
|
||||
4 files changed, 60 insertions(+), 28 deletions(-)
|
||||
|
||||
--- a/arch/x86/crypto/poly1305_glue.c
|
||||
+++ b/arch/x86/crypto/poly1305_glue.c
|
||||
@@ -34,6 +34,24 @@ static void poly1305_simd_mult(u32 *a, c
|
||||
poly1305_block_sse2(a, m, b, 1);
|
||||
}
|
||||
|
||||
+static unsigned int poly1305_scalar_blocks(struct poly1305_desc_ctx *dctx,
|
||||
+ const u8 *src, unsigned int srclen)
|
||||
+{
|
||||
+ unsigned int datalen;
|
||||
+
|
||||
+ if (unlikely(!dctx->sset)) {
|
||||
+ datalen = crypto_poly1305_setdesckey(dctx, src, srclen);
|
||||
+ src += srclen - datalen;
|
||||
+ srclen = datalen;
|
||||
+ }
|
||||
+ if (srclen >= POLY1305_BLOCK_SIZE) {
|
||||
+ poly1305_core_blocks(&dctx->h, dctx->r, src,
|
||||
+ srclen / POLY1305_BLOCK_SIZE, 1);
|
||||
+ srclen %= POLY1305_BLOCK_SIZE;
|
||||
+ }
|
||||
+ return srclen;
|
||||
+}
|
||||
+
|
||||
static unsigned int poly1305_simd_blocks(struct poly1305_desc_ctx *dctx,
|
||||
const u8 *src, unsigned int srclen)
|
||||
{
|
||||
@@ -91,12 +109,6 @@ static int poly1305_simd_update(struct s
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
unsigned int bytes;
|
||||
|
||||
- /* kernel_fpu_begin/end is costly, use fallback for small updates */
|
||||
- if (srclen <= 288 || !crypto_simd_usable())
|
||||
- return crypto_poly1305_update(desc, src, srclen);
|
||||
-
|
||||
- kernel_fpu_begin();
|
||||
-
|
||||
if (unlikely(dctx->buflen)) {
|
||||
bytes = min(srclen, POLY1305_BLOCK_SIZE - dctx->buflen);
|
||||
memcpy(dctx->buf + dctx->buflen, src, bytes);
|
||||
@@ -105,25 +117,57 @@ static int poly1305_simd_update(struct s
|
||||
dctx->buflen += bytes;
|
||||
|
||||
if (dctx->buflen == POLY1305_BLOCK_SIZE) {
|
||||
- poly1305_simd_blocks(dctx, dctx->buf,
|
||||
- POLY1305_BLOCK_SIZE);
|
||||
+ if (likely(crypto_simd_usable())) {
|
||||
+ kernel_fpu_begin();
|
||||
+ poly1305_simd_blocks(dctx, dctx->buf,
|
||||
+ POLY1305_BLOCK_SIZE);
|
||||
+ kernel_fpu_end();
|
||||
+ } else {
|
||||
+ poly1305_scalar_blocks(dctx, dctx->buf,
|
||||
+ POLY1305_BLOCK_SIZE);
|
||||
+ }
|
||||
dctx->buflen = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (likely(srclen >= POLY1305_BLOCK_SIZE)) {
|
||||
- bytes = poly1305_simd_blocks(dctx, src, srclen);
|
||||
+ if (likely(crypto_simd_usable())) {
|
||||
+ kernel_fpu_begin();
|
||||
+ bytes = poly1305_simd_blocks(dctx, src, srclen);
|
||||
+ kernel_fpu_end();
|
||||
+ } else {
|
||||
+ bytes = poly1305_scalar_blocks(dctx, src, srclen);
|
||||
+ }
|
||||
src += srclen - bytes;
|
||||
srclen = bytes;
|
||||
}
|
||||
|
||||
- kernel_fpu_end();
|
||||
-
|
||||
if (unlikely(srclen)) {
|
||||
dctx->buflen = srclen;
|
||||
memcpy(dctx->buf, src, srclen);
|
||||
}
|
||||
+}
|
||||
+
|
||||
+static int crypto_poly1305_init(struct shash_desc *desc)
|
||||
+{
|
||||
+ struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
+
|
||||
+ poly1305_core_init(&dctx->h);
|
||||
+ dctx->buflen = 0;
|
||||
+ dctx->rset = 0;
|
||||
+ dctx->sset = false;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int crypto_poly1305_final(struct shash_desc *desc, u8 *dst)
|
||||
+{
|
||||
+ struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
+
|
||||
+ if (unlikely(!dctx->sset))
|
||||
+ return -ENOKEY;
|
||||
|
||||
+ poly1305_final_generic(dctx, dst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -697,7 +697,7 @@ config CRYPTO_POLY1305
|
||||
config CRYPTO_POLY1305_X86_64
|
||||
tristate "Poly1305 authenticator algorithm (x86_64/SSE2/AVX2)"
|
||||
depends on X86 && 64BIT
|
||||
- select CRYPTO_POLY1305
|
||||
+ select CRYPTO_LIB_POLY1305_GENERIC
|
||||
help
|
||||
Poly1305 authenticator algorithm, RFC7539.
|
||||
|
||||
--- a/crypto/poly1305_generic.c
|
||||
+++ b/crypto/poly1305_generic.c
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <linux/module.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
-int crypto_poly1305_init(struct shash_desc *desc)
|
||||
+static int crypto_poly1305_init(struct shash_desc *desc)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
|
||||
@@ -30,7 +30,6 @@ int crypto_poly1305_init(struct shash_de
|
||||
|
||||
return 0;
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(crypto_poly1305_init);
|
||||
|
||||
static void poly1305_blocks(struct poly1305_desc_ctx *dctx, const u8 *src,
|
||||
unsigned int srclen)
|
||||
@@ -47,8 +46,8 @@ static void poly1305_blocks(struct poly1
|
||||
srclen / POLY1305_BLOCK_SIZE, 1);
|
||||
}
|
||||
|
||||
-int crypto_poly1305_update(struct shash_desc *desc,
|
||||
- const u8 *src, unsigned int srclen)
|
||||
+static int crypto_poly1305_update(struct shash_desc *desc,
|
||||
+ const u8 *src, unsigned int srclen)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
unsigned int bytes;
|
||||
@@ -80,9 +79,8 @@ int crypto_poly1305_update(struct shash_
|
||||
|
||||
return 0;
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(crypto_poly1305_update);
|
||||
|
||||
-int crypto_poly1305_final(struct shash_desc *desc, u8 *dst)
|
||||
+static int crypto_poly1305_final(struct shash_desc *desc, u8 *dst)
|
||||
{
|
||||
struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
|
||||
@@ -92,7 +90,6 @@ int crypto_poly1305_final(struct shash_d
|
||||
poly1305_final_generic(dctx, dst);
|
||||
return 0;
|
||||
}
|
||||
-EXPORT_SYMBOL_GPL(crypto_poly1305_final);
|
||||
|
||||
static struct shash_alg poly1305_alg = {
|
||||
.digestsize = POLY1305_DIGEST_SIZE,
|
||||
--- a/include/crypto/internal/poly1305.h
|
||||
+++ b/include/crypto/internal/poly1305.h
|
||||
@@ -10,8 +10,6 @@
|
||||
#include <linux/types.h>
|
||||
#include <crypto/poly1305.h>
|
||||
|
||||
-struct shash_desc;
|
||||
-
|
||||
/*
|
||||
* Poly1305 core functions. These implement the ε-almost-∆-universal hash
|
||||
* function underlying the Poly1305 MAC, i.e. they don't add an encrypted nonce
|
||||
@@ -28,13 +26,6 @@ void poly1305_core_blocks(struct poly130
|
||||
unsigned int nblocks, u32 hibit);
|
||||
void poly1305_core_emit(const struct poly1305_state *state, void *dst);
|
||||
|
||||
-/* Crypto API helper functions for the Poly1305 MAC */
|
||||
-int crypto_poly1305_init(struct shash_desc *desc);
|
||||
-
|
||||
-int crypto_poly1305_update(struct shash_desc *desc,
|
||||
- const u8 *src, unsigned int srclen);
|
||||
-int crypto_poly1305_final(struct shash_desc *desc, u8 *dst);
|
||||
-
|
||||
/*
|
||||
* Poly1305 requires a unique key for each tag, which implies that we can't set
|
||||
* it on the tfm that gets accessed by multiple users simultaneously. Instead we
|
||||
@@ -1,163 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:23 +0100
|
||||
Subject: [PATCH] crypto: x86/poly1305 - expose existing driver as poly1305
|
||||
library
|
||||
|
||||
commit f0e89bcfbb894e5844cd1bbf6b3cf7c63cb0f5ac upstream.
|
||||
|
||||
Implement the arch init/update/final Poly1305 library routines in the
|
||||
accelerated SIMD driver for x86 so they are accessible to users of
|
||||
the Poly1305 library interface as well.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/poly1305_glue.c | 57 ++++++++++++++++++++++++---------
|
||||
crypto/Kconfig | 1 +
|
||||
lib/crypto/Kconfig | 1 +
|
||||
3 files changed, 43 insertions(+), 16 deletions(-)
|
||||
|
||||
--- a/arch/x86/crypto/poly1305_glue.c
|
||||
+++ b/arch/x86/crypto/poly1305_glue.c
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <crypto/internal/poly1305.h>
|
||||
#include <crypto/internal/simd.h>
|
||||
#include <linux/crypto.h>
|
||||
+#include <linux/jump_label.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <asm/simd.h>
|
||||
@@ -21,7 +22,8 @@ asmlinkage void poly1305_2block_sse2(u32
|
||||
asmlinkage void poly1305_4block_avx2(u32 *h, const u8 *src, const u32 *r,
|
||||
unsigned int blocks, const u32 *u);
|
||||
|
||||
-static bool poly1305_use_avx2 __ro_after_init;
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(poly1305_use_simd);
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(poly1305_use_avx2);
|
||||
|
||||
static void poly1305_simd_mult(u32 *a, const u32 *b)
|
||||
{
|
||||
@@ -64,7 +66,7 @@ static unsigned int poly1305_simd_blocks
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_AS_AVX2) &&
|
||||
- poly1305_use_avx2 &&
|
||||
+ static_branch_likely(&poly1305_use_avx2) &&
|
||||
srclen >= POLY1305_BLOCK_SIZE * 4) {
|
||||
if (unlikely(dctx->rset < 4)) {
|
||||
if (dctx->rset < 2) {
|
||||
@@ -103,10 +105,15 @@ static unsigned int poly1305_simd_blocks
|
||||
return srclen;
|
||||
}
|
||||
|
||||
-static int poly1305_simd_update(struct shash_desc *desc,
|
||||
- const u8 *src, unsigned int srclen)
|
||||
+void poly1305_init_arch(struct poly1305_desc_ctx *desc, const u8 *key)
|
||||
+{
|
||||
+ poly1305_init_generic(desc, key);
|
||||
+}
|
||||
+EXPORT_SYMBOL(poly1305_init_arch);
|
||||
+
|
||||
+void poly1305_update_arch(struct poly1305_desc_ctx *dctx, const u8 *src,
|
||||
+ unsigned int srclen)
|
||||
{
|
||||
- struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
unsigned int bytes;
|
||||
|
||||
if (unlikely(dctx->buflen)) {
|
||||
@@ -117,7 +124,8 @@ static int poly1305_simd_update(struct s
|
||||
dctx->buflen += bytes;
|
||||
|
||||
if (dctx->buflen == POLY1305_BLOCK_SIZE) {
|
||||
- if (likely(crypto_simd_usable())) {
|
||||
+ if (static_branch_likely(&poly1305_use_simd) &&
|
||||
+ likely(crypto_simd_usable())) {
|
||||
kernel_fpu_begin();
|
||||
poly1305_simd_blocks(dctx, dctx->buf,
|
||||
POLY1305_BLOCK_SIZE);
|
||||
@@ -131,7 +139,8 @@ static int poly1305_simd_update(struct s
|
||||
}
|
||||
|
||||
if (likely(srclen >= POLY1305_BLOCK_SIZE)) {
|
||||
- if (likely(crypto_simd_usable())) {
|
||||
+ if (static_branch_likely(&poly1305_use_simd) &&
|
||||
+ likely(crypto_simd_usable())) {
|
||||
kernel_fpu_begin();
|
||||
bytes = poly1305_simd_blocks(dctx, src, srclen);
|
||||
kernel_fpu_end();
|
||||
@@ -147,6 +156,13 @@ static int poly1305_simd_update(struct s
|
||||
memcpy(dctx->buf, src, srclen);
|
||||
}
|
||||
}
|
||||
+EXPORT_SYMBOL(poly1305_update_arch);
|
||||
+
|
||||
+void poly1305_final_arch(struct poly1305_desc_ctx *desc, u8 *digest)
|
||||
+{
|
||||
+ poly1305_final_generic(desc, digest);
|
||||
+}
|
||||
+EXPORT_SYMBOL(poly1305_final_arch);
|
||||
|
||||
static int crypto_poly1305_init(struct shash_desc *desc)
|
||||
{
|
||||
@@ -171,6 +187,15 @@ static int crypto_poly1305_final(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int poly1305_simd_update(struct shash_desc *desc,
|
||||
+ const u8 *src, unsigned int srclen)
|
||||
+{
|
||||
+ struct poly1305_desc_ctx *dctx = shash_desc_ctx(desc);
|
||||
+
|
||||
+ poly1305_update_arch(dctx, src, srclen);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static struct shash_alg alg = {
|
||||
.digestsize = POLY1305_DIGEST_SIZE,
|
||||
.init = crypto_poly1305_init,
|
||||
@@ -189,15 +214,15 @@ static struct shash_alg alg = {
|
||||
static int __init poly1305_simd_mod_init(void)
|
||||
{
|
||||
if (!boot_cpu_has(X86_FEATURE_XMM2))
|
||||
- return -ENODEV;
|
||||
+ return 0;
|
||||
|
||||
- poly1305_use_avx2 = IS_ENABLED(CONFIG_AS_AVX2) &&
|
||||
- boot_cpu_has(X86_FEATURE_AVX) &&
|
||||
- boot_cpu_has(X86_FEATURE_AVX2) &&
|
||||
- cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL);
|
||||
- alg.descsize = sizeof(struct poly1305_desc_ctx) + 5 * sizeof(u32);
|
||||
- if (poly1305_use_avx2)
|
||||
- alg.descsize += 10 * sizeof(u32);
|
||||
+ static_branch_enable(&poly1305_use_simd);
|
||||
+
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX2) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX2) &&
|
||||
+ cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL))
|
||||
+ static_branch_enable(&poly1305_use_avx2);
|
||||
|
||||
return crypto_register_shash(&alg);
|
||||
}
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -698,6 +698,7 @@ config CRYPTO_POLY1305_X86_64
|
||||
tristate "Poly1305 authenticator algorithm (x86_64/SSE2/AVX2)"
|
||||
depends on X86 && 64BIT
|
||||
select CRYPTO_LIB_POLY1305_GENERIC
|
||||
+ select CRYPTO_ARCH_HAVE_LIB_POLY1305
|
||||
help
|
||||
Poly1305 authenticator algorithm, RFC7539.
|
||||
|
||||
--- a/lib/crypto/Kconfig
|
||||
+++ b/lib/crypto/Kconfig
|
||||
@@ -39,6 +39,7 @@ config CRYPTO_LIB_DES
|
||||
|
||||
config CRYPTO_LIB_POLY1305_RSIZE
|
||||
int
|
||||
+ default 4 if X86_64
|
||||
default 1
|
||||
|
||||
config CRYPTO_ARCH_HAVE_LIB_POLY1305
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,322 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:29 +0100
|
||||
Subject: [PATCH] crypto: testmgr - add test cases for Blake2s
|
||||
|
||||
commit 17e1df67023a5c9ccaeb5de8bf5b88f63127ecf7 upstream.
|
||||
|
||||
As suggested by Eric for the Blake2b implementation contributed by
|
||||
David, introduce a set of test vectors for Blake2s covering different
|
||||
digest and key sizes.
|
||||
|
||||
blake2s-128 blake2s-160 blake2s-224 blake2s-256
|
||||
---------------------------------------------------
|
||||
len=0 | klen=0 klen=1 klen=16 klen=32
|
||||
len=1 | klen=16 klen=32 klen=0 klen=1
|
||||
len=7 | klen=32 klen=0 klen=1 klen=16
|
||||
len=15 | klen=1 klen=16 klen=32 klen=0
|
||||
len=64 | klen=0 klen=1 klen=16 klen=32
|
||||
len=247 | klen=16 klen=32 klen=0 klen=1
|
||||
len=256 | klen=32 klen=0 klen=1 klen=16
|
||||
|
||||
Cc: David Sterba <dsterba@suse.com>
|
||||
Cc: Eric Biggers <ebiggers@google.com>
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/testmgr.c | 24 +++++
|
||||
crypto/testmgr.h | 251 +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
2 files changed, 275 insertions(+)
|
||||
|
||||
--- a/crypto/testmgr.c
|
||||
+++ b/crypto/testmgr.c
|
||||
@@ -4035,6 +4035,30 @@ static const struct alg_test_desc alg_te
|
||||
.test = alg_test_null,
|
||||
.fips_allowed = 1,
|
||||
}, {
|
||||
+ .alg = "blake2s-128",
|
||||
+ .test = alg_test_hash,
|
||||
+ .suite = {
|
||||
+ .hash = __VECS(blakes2s_128_tv_template)
|
||||
+ }
|
||||
+ }, {
|
||||
+ .alg = "blake2s-160",
|
||||
+ .test = alg_test_hash,
|
||||
+ .suite = {
|
||||
+ .hash = __VECS(blakes2s_160_tv_template)
|
||||
+ }
|
||||
+ }, {
|
||||
+ .alg = "blake2s-224",
|
||||
+ .test = alg_test_hash,
|
||||
+ .suite = {
|
||||
+ .hash = __VECS(blakes2s_224_tv_template)
|
||||
+ }
|
||||
+ }, {
|
||||
+ .alg = "blake2s-256",
|
||||
+ .test = alg_test_hash,
|
||||
+ .suite = {
|
||||
+ .hash = __VECS(blakes2s_256_tv_template)
|
||||
+ }
|
||||
+ }, {
|
||||
.alg = "cbc(aes)",
|
||||
.test = alg_test_skcipher,
|
||||
.fips_allowed = 1,
|
||||
--- a/crypto/testmgr.h
|
||||
+++ b/crypto/testmgr.h
|
||||
@@ -31567,4 +31567,255 @@ static const struct aead_testvec essiv_h
|
||||
},
|
||||
};
|
||||
|
||||
+static const char blake2_ordered_sequence[] =
|
||||
+ "\x00\x01\x02\x03\x04\x05\x06\x07"
|
||||
+ "\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
|
||||
+ "\x10\x11\x12\x13\x14\x15\x16\x17"
|
||||
+ "\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
|
||||
+ "\x20\x21\x22\x23\x24\x25\x26\x27"
|
||||
+ "\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
|
||||
+ "\x30\x31\x32\x33\x34\x35\x36\x37"
|
||||
+ "\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
|
||||
+ "\x40\x41\x42\x43\x44\x45\x46\x47"
|
||||
+ "\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
|
||||
+ "\x50\x51\x52\x53\x54\x55\x56\x57"
|
||||
+ "\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
|
||||
+ "\x60\x61\x62\x63\x64\x65\x66\x67"
|
||||
+ "\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
|
||||
+ "\x70\x71\x72\x73\x74\x75\x76\x77"
|
||||
+ "\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
|
||||
+ "\x80\x81\x82\x83\x84\x85\x86\x87"
|
||||
+ "\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
|
||||
+ "\x90\x91\x92\x93\x94\x95\x96\x97"
|
||||
+ "\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
|
||||
+ "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7"
|
||||
+ "\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
|
||||
+ "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
|
||||
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
|
||||
+ "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7"
|
||||
+ "\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
|
||||
+ "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7"
|
||||
+ "\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
|
||||
+ "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7"
|
||||
+ "\xe8\xe9\xea\xeb\xec\xed\xee\xef"
|
||||
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7"
|
||||
+ "\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
+
|
||||
+static const struct hash_testvec blakes2s_128_tv_template[] = {{
|
||||
+ .digest = (u8[]){ 0x64, 0x55, 0x0d, 0x6f, 0xfe, 0x2c, 0x0a, 0x01,
|
||||
+ 0xa1, 0x4a, 0xba, 0x1e, 0xad, 0xe0, 0x20, 0x0c, },
|
||||
+}, {
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 64,
|
||||
+ .digest = (u8[]){ 0xdc, 0x66, 0xca, 0x8f, 0x03, 0x86, 0x58, 0x01,
|
||||
+ 0xb0, 0xff, 0xe0, 0x6e, 0xd8, 0xa1, 0xa9, 0x0e, },
|
||||
+}, {
|
||||
+ .ksize = 16,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 1,
|
||||
+ .digest = (u8[]){ 0x88, 0x1e, 0x42, 0xe7, 0xbb, 0x35, 0x80, 0x82,
|
||||
+ 0x63, 0x7c, 0x0a, 0x0f, 0xd7, 0xec, 0x6c, 0x2f, },
|
||||
+}, {
|
||||
+ .ksize = 32,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 7,
|
||||
+ .digest = (u8[]){ 0xcf, 0x9e, 0x07, 0x2a, 0xd5, 0x22, 0xf2, 0xcd,
|
||||
+ 0xa2, 0xd8, 0x25, 0x21, 0x80, 0x86, 0x73, 0x1c, },
|
||||
+}, {
|
||||
+ .ksize = 1,
|
||||
+ .key = "B",
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 15,
|
||||
+ .digest = (u8[]){ 0xf6, 0x33, 0x5a, 0x2c, 0x22, 0xa0, 0x64, 0xb2,
|
||||
+ 0xb6, 0x3f, 0xeb, 0xbc, 0xd1, 0xc3, 0xe5, 0xb2, },
|
||||
+}, {
|
||||
+ .ksize = 16,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 247,
|
||||
+ .digest = (u8[]){ 0x72, 0x66, 0x49, 0x60, 0xf9, 0x4a, 0xea, 0xbe,
|
||||
+ 0x1f, 0xf4, 0x60, 0xce, 0xb7, 0x81, 0xcb, 0x09, },
|
||||
+}, {
|
||||
+ .ksize = 32,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 256,
|
||||
+ .digest = (u8[]){ 0xd5, 0xa4, 0x0e, 0xc3, 0x16, 0xc7, 0x51, 0xa6,
|
||||
+ 0x3c, 0xd0, 0xd9, 0x11, 0x57, 0xfa, 0x1e, 0xbb, },
|
||||
+}};
|
||||
+
|
||||
+static const struct hash_testvec blakes2s_160_tv_template[] = {{
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 7,
|
||||
+ .digest = (u8[]){ 0xb4, 0xf2, 0x03, 0x49, 0x37, 0xed, 0xb1, 0x3e,
|
||||
+ 0x5b, 0x2a, 0xca, 0x64, 0x82, 0x74, 0xf6, 0x62,
|
||||
+ 0xe3, 0xf2, 0x84, 0xff, },
|
||||
+}, {
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 256,
|
||||
+ .digest = (u8[]){ 0xaa, 0x56, 0x9b, 0xdc, 0x98, 0x17, 0x75, 0xf2,
|
||||
+ 0xb3, 0x68, 0x83, 0xb7, 0x9b, 0x8d, 0x48, 0xb1,
|
||||
+ 0x9b, 0x2d, 0x35, 0x05, },
|
||||
+}, {
|
||||
+ .ksize = 1,
|
||||
+ .key = "B",
|
||||
+ .digest = (u8[]){ 0x50, 0x16, 0xe7, 0x0c, 0x01, 0xd0, 0xd3, 0xc3,
|
||||
+ 0xf4, 0x3e, 0xb1, 0x6e, 0x97, 0xa9, 0x4e, 0xd1,
|
||||
+ 0x79, 0x65, 0x32, 0x93, },
|
||||
+}, {
|
||||
+ .ksize = 32,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 1,
|
||||
+ .digest = (u8[]){ 0x1c, 0x2b, 0xcd, 0x9a, 0x68, 0xca, 0x8c, 0x71,
|
||||
+ 0x90, 0x29, 0x6c, 0x54, 0xfa, 0x56, 0x4a, 0xef,
|
||||
+ 0xa2, 0x3a, 0x56, 0x9c, },
|
||||
+}, {
|
||||
+ .ksize = 16,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 15,
|
||||
+ .digest = (u8[]){ 0x36, 0xc3, 0x5f, 0x9a, 0xdc, 0x7e, 0xbf, 0x19,
|
||||
+ 0x68, 0xaa, 0xca, 0xd8, 0x81, 0xbf, 0x09, 0x34,
|
||||
+ 0x83, 0x39, 0x0f, 0x30, },
|
||||
+}, {
|
||||
+ .ksize = 1,
|
||||
+ .key = "B",
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 64,
|
||||
+ .digest = (u8[]){ 0x86, 0x80, 0x78, 0xa4, 0x14, 0xec, 0x03, 0xe5,
|
||||
+ 0xb6, 0x9a, 0x52, 0x0e, 0x42, 0xee, 0x39, 0x9d,
|
||||
+ 0xac, 0xa6, 0x81, 0x63, },
|
||||
+}, {
|
||||
+ .ksize = 32,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 247,
|
||||
+ .digest = (u8[]){ 0x2d, 0xd8, 0xd2, 0x53, 0x66, 0xfa, 0xa9, 0x01,
|
||||
+ 0x1c, 0x9c, 0xaf, 0xa3, 0xe2, 0x9d, 0x9b, 0x10,
|
||||
+ 0x0a, 0xf6, 0x73, 0xe8, },
|
||||
+}};
|
||||
+
|
||||
+static const struct hash_testvec blakes2s_224_tv_template[] = {{
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 1,
|
||||
+ .digest = (u8[]){ 0x61, 0xb9, 0x4e, 0xc9, 0x46, 0x22, 0xa3, 0x91,
|
||||
+ 0xd2, 0xae, 0x42, 0xe6, 0x45, 0x6c, 0x90, 0x12,
|
||||
+ 0xd5, 0x80, 0x07, 0x97, 0xb8, 0x86, 0x5a, 0xfc,
|
||||
+ 0x48, 0x21, 0x97, 0xbb, },
|
||||
+}, {
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 247,
|
||||
+ .digest = (u8[]){ 0x9e, 0xda, 0xc7, 0x20, 0x2c, 0xd8, 0x48, 0x2e,
|
||||
+ 0x31, 0x94, 0xab, 0x46, 0x6d, 0x94, 0xd8, 0xb4,
|
||||
+ 0x69, 0xcd, 0xae, 0x19, 0x6d, 0x9e, 0x41, 0xcc,
|
||||
+ 0x2b, 0xa4, 0xd5, 0xf6, },
|
||||
+}, {
|
||||
+ .ksize = 16,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .digest = (u8[]){ 0x32, 0xc0, 0xac, 0xf4, 0x3b, 0xd3, 0x07, 0x9f,
|
||||
+ 0xbe, 0xfb, 0xfa, 0x4d, 0x6b, 0x4e, 0x56, 0xb3,
|
||||
+ 0xaa, 0xd3, 0x27, 0xf6, 0x14, 0xbf, 0xb9, 0x32,
|
||||
+ 0xa7, 0x19, 0xfc, 0xb8, },
|
||||
+}, {
|
||||
+ .ksize = 1,
|
||||
+ .key = "B",
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 7,
|
||||
+ .digest = (u8[]){ 0x73, 0xad, 0x5e, 0x6d, 0xb9, 0x02, 0x8e, 0x76,
|
||||
+ 0xf2, 0x66, 0x42, 0x4b, 0x4c, 0xfa, 0x1f, 0xe6,
|
||||
+ 0x2e, 0x56, 0x40, 0xe5, 0xa2, 0xb0, 0x3c, 0xe8,
|
||||
+ 0x7b, 0x45, 0xfe, 0x05, },
|
||||
+}, {
|
||||
+ .ksize = 32,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 15,
|
||||
+ .digest = (u8[]){ 0x16, 0x60, 0xfb, 0x92, 0x54, 0xb3, 0x6e, 0x36,
|
||||
+ 0x81, 0xf4, 0x16, 0x41, 0xc3, 0x3d, 0xd3, 0x43,
|
||||
+ 0x84, 0xed, 0x10, 0x6f, 0x65, 0x80, 0x7a, 0x3e,
|
||||
+ 0x25, 0xab, 0xc5, 0x02, },
|
||||
+}, {
|
||||
+ .ksize = 16,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 64,
|
||||
+ .digest = (u8[]){ 0xca, 0xaa, 0x39, 0x67, 0x9c, 0xf7, 0x6b, 0xc7,
|
||||
+ 0xb6, 0x82, 0xca, 0x0e, 0x65, 0x36, 0x5b, 0x7c,
|
||||
+ 0x24, 0x00, 0xfa, 0x5f, 0xda, 0x06, 0x91, 0x93,
|
||||
+ 0x6a, 0x31, 0x83, 0xb5, },
|
||||
+}, {
|
||||
+ .ksize = 1,
|
||||
+ .key = "B",
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 256,
|
||||
+ .digest = (u8[]){ 0x90, 0x02, 0x26, 0xb5, 0x06, 0x9c, 0x36, 0x86,
|
||||
+ 0x94, 0x91, 0x90, 0x1e, 0x7d, 0x2a, 0x71, 0xb2,
|
||||
+ 0x48, 0xb5, 0xe8, 0x16, 0xfd, 0x64, 0x33, 0x45,
|
||||
+ 0xb3, 0xd7, 0xec, 0xcc, },
|
||||
+}};
|
||||
+
|
||||
+static const struct hash_testvec blakes2s_256_tv_template[] = {{
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 15,
|
||||
+ .digest = (u8[]){ 0xd9, 0x7c, 0x82, 0x8d, 0x81, 0x82, 0xa7, 0x21,
|
||||
+ 0x80, 0xa0, 0x6a, 0x78, 0x26, 0x83, 0x30, 0x67,
|
||||
+ 0x3f, 0x7c, 0x4e, 0x06, 0x35, 0x94, 0x7c, 0x04,
|
||||
+ 0xc0, 0x23, 0x23, 0xfd, 0x45, 0xc0, 0xa5, 0x2d, },
|
||||
+}, {
|
||||
+ .ksize = 32,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .digest = (u8[]){ 0x48, 0xa8, 0x99, 0x7d, 0xa4, 0x07, 0x87, 0x6b,
|
||||
+ 0x3d, 0x79, 0xc0, 0xd9, 0x23, 0x25, 0xad, 0x3b,
|
||||
+ 0x89, 0xcb, 0xb7, 0x54, 0xd8, 0x6a, 0xb7, 0x1a,
|
||||
+ 0xee, 0x04, 0x7a, 0xd3, 0x45, 0xfd, 0x2c, 0x49, },
|
||||
+}, {
|
||||
+ .ksize = 1,
|
||||
+ .key = "B",
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 1,
|
||||
+ .digest = (u8[]){ 0x22, 0x27, 0xae, 0xaa, 0x6e, 0x81, 0x56, 0x03,
|
||||
+ 0xa7, 0xe3, 0xa1, 0x18, 0xa5, 0x9a, 0x2c, 0x18,
|
||||
+ 0xf4, 0x63, 0xbc, 0x16, 0x70, 0xf1, 0xe7, 0x4b,
|
||||
+ 0x00, 0x6d, 0x66, 0x16, 0xae, 0x9e, 0x74, 0x4e, },
|
||||
+}, {
|
||||
+ .ksize = 16,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 7,
|
||||
+ .digest = (u8[]){ 0x58, 0x5d, 0xa8, 0x60, 0x1c, 0xa4, 0xd8, 0x03,
|
||||
+ 0x86, 0x86, 0x84, 0x64, 0xd7, 0xa0, 0x8e, 0x15,
|
||||
+ 0x2f, 0x05, 0xa2, 0x1b, 0xbc, 0xef, 0x7a, 0x34,
|
||||
+ 0xb3, 0xc5, 0xbc, 0x4b, 0xf0, 0x32, 0xeb, 0x12, },
|
||||
+}, {
|
||||
+ .ksize = 32,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 64,
|
||||
+ .digest = (u8[]){ 0x89, 0x75, 0xb0, 0x57, 0x7f, 0xd3, 0x55, 0x66,
|
||||
+ 0xd7, 0x50, 0xb3, 0x62, 0xb0, 0x89, 0x7a, 0x26,
|
||||
+ 0xc3, 0x99, 0x13, 0x6d, 0xf0, 0x7b, 0xab, 0xab,
|
||||
+ 0xbd, 0xe6, 0x20, 0x3f, 0xf2, 0x95, 0x4e, 0xd4, },
|
||||
+}, {
|
||||
+ .ksize = 1,
|
||||
+ .key = "B",
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 247,
|
||||
+ .digest = (u8[]){ 0x2e, 0x74, 0x1c, 0x1d, 0x03, 0xf4, 0x9d, 0x84,
|
||||
+ 0x6f, 0xfc, 0x86, 0x32, 0x92, 0x49, 0x7e, 0x66,
|
||||
+ 0xd7, 0xc3, 0x10, 0x88, 0xfe, 0x28, 0xb3, 0xe0,
|
||||
+ 0xbf, 0x50, 0x75, 0xad, 0x8e, 0xa4, 0xe6, 0xb2, },
|
||||
+}, {
|
||||
+ .ksize = 16,
|
||||
+ .key = blake2_ordered_sequence,
|
||||
+ .plaintext = blake2_ordered_sequence,
|
||||
+ .psize = 256,
|
||||
+ .digest = (u8[]){ 0xb9, 0xd2, 0x81, 0x0e, 0x3a, 0xb1, 0x62, 0x9b,
|
||||
+ 0xad, 0x44, 0x05, 0xf4, 0x92, 0x2e, 0x99, 0xc1,
|
||||
+ 0x4a, 0x47, 0xbb, 0x5b, 0x6f, 0xb2, 0x96, 0xed,
|
||||
+ 0xd5, 0x06, 0xb5, 0x3a, 0x7c, 0x7a, 0x65, 0x1d, },
|
||||
+}};
|
||||
+
|
||||
#endif /* _CRYPTO_TESTMGR_H */
|
||||
@@ -1,245 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:30 +0100
|
||||
Subject: [PATCH] crypto: blake2s - implement generic shash driver
|
||||
|
||||
commit 7f9b0880925f1f9d7d59504ea0892d2ae9cfc233 upstream.
|
||||
|
||||
Wire up our newly added Blake2s implementation via the shash API.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/Kconfig | 18 ++++
|
||||
crypto/Makefile | 1 +
|
||||
crypto/blake2s_generic.c | 171 ++++++++++++++++++++++++++++++
|
||||
include/crypto/internal/blake2s.h | 5 +
|
||||
4 files changed, 195 insertions(+)
|
||||
create mode 100644 crypto/blake2s_generic.c
|
||||
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -639,6 +639,24 @@ config CRYPTO_XXHASH
|
||||
xxHash non-cryptographic hash algorithm. Extremely fast, working at
|
||||
speeds close to RAM limits.
|
||||
|
||||
+config CRYPTO_BLAKE2S
|
||||
+ tristate "BLAKE2s digest algorithm"
|
||||
+ select CRYPTO_LIB_BLAKE2S_GENERIC
|
||||
+ select CRYPTO_HASH
|
||||
+ help
|
||||
+ Implementation of cryptographic hash function BLAKE2s
|
||||
+ optimized for 8-32bit platforms and can produce digests of any size
|
||||
+ between 1 to 32. The keyed hash is also implemented.
|
||||
+
|
||||
+ This module provides the following algorithms:
|
||||
+
|
||||
+ - blake2s-128
|
||||
+ - blake2s-160
|
||||
+ - blake2s-224
|
||||
+ - blake2s-256
|
||||
+
|
||||
+ See https://blake2.net for further information.
|
||||
+
|
||||
config CRYPTO_CRCT10DIF
|
||||
tristate "CRCT10DIF algorithm"
|
||||
select CRYPTO_HASH
|
||||
--- a/crypto/Makefile
|
||||
+++ b/crypto/Makefile
|
||||
@@ -74,6 +74,7 @@ obj-$(CONFIG_CRYPTO_STREEBOG) += streebo
|
||||
obj-$(CONFIG_CRYPTO_WP512) += wp512.o
|
||||
CFLAGS_wp512.o := $(call cc-option,-fno-schedule-insns) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79149
|
||||
obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
|
||||
+obj-$(CONFIG_CRYPTO_BLAKE2S) += blake2s_generic.o
|
||||
obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
|
||||
obj-$(CONFIG_CRYPTO_ECB) += ecb.o
|
||||
obj-$(CONFIG_CRYPTO_CBC) += cbc.o
|
||||
--- /dev/null
|
||||
+++ b/crypto/blake2s_generic.c
|
||||
@@ -0,0 +1,171 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0 OR MIT
|
||||
+/*
|
||||
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||
+ */
|
||||
+
|
||||
+#include <crypto/internal/blake2s.h>
|
||||
+#include <crypto/internal/simd.h>
|
||||
+#include <crypto/internal/hash.h>
|
||||
+
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/jump_label.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+static int crypto_blake2s_setkey(struct crypto_shash *tfm, const u8 *key,
|
||||
+ unsigned int keylen)
|
||||
+{
|
||||
+ struct blake2s_tfm_ctx *tctx = crypto_shash_ctx(tfm);
|
||||
+
|
||||
+ if (keylen == 0 || keylen > BLAKE2S_KEY_SIZE) {
|
||||
+ crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(tctx->key, key, keylen);
|
||||
+ tctx->keylen = keylen;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int crypto_blake2s_init(struct shash_desc *desc)
|
||||
+{
|
||||
+ struct blake2s_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
|
||||
+ struct blake2s_state *state = shash_desc_ctx(desc);
|
||||
+ const int outlen = crypto_shash_digestsize(desc->tfm);
|
||||
+
|
||||
+ if (tctx->keylen)
|
||||
+ blake2s_init_key(state, outlen, tctx->key, tctx->keylen);
|
||||
+ else
|
||||
+ blake2s_init(state, outlen);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int crypto_blake2s_update(struct shash_desc *desc, const u8 *in,
|
||||
+ unsigned int inlen)
|
||||
+{
|
||||
+ struct blake2s_state *state = shash_desc_ctx(desc);
|
||||
+ const size_t fill = BLAKE2S_BLOCK_SIZE - state->buflen;
|
||||
+
|
||||
+ if (unlikely(!inlen))
|
||||
+ return 0;
|
||||
+ if (inlen > fill) {
|
||||
+ memcpy(state->buf + state->buflen, in, fill);
|
||||
+ blake2s_compress_generic(state, state->buf, 1, BLAKE2S_BLOCK_SIZE);
|
||||
+ state->buflen = 0;
|
||||
+ in += fill;
|
||||
+ inlen -= fill;
|
||||
+ }
|
||||
+ if (inlen > BLAKE2S_BLOCK_SIZE) {
|
||||
+ const size_t nblocks = DIV_ROUND_UP(inlen, BLAKE2S_BLOCK_SIZE);
|
||||
+ /* Hash one less (full) block than strictly possible */
|
||||
+ blake2s_compress_generic(state, in, nblocks - 1, BLAKE2S_BLOCK_SIZE);
|
||||
+ in += BLAKE2S_BLOCK_SIZE * (nblocks - 1);
|
||||
+ inlen -= BLAKE2S_BLOCK_SIZE * (nblocks - 1);
|
||||
+ }
|
||||
+ memcpy(state->buf + state->buflen, in, inlen);
|
||||
+ state->buflen += inlen;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int crypto_blake2s_final(struct shash_desc *desc, u8 *out)
|
||||
+{
|
||||
+ struct blake2s_state *state = shash_desc_ctx(desc);
|
||||
+
|
||||
+ blake2s_set_lastblock(state);
|
||||
+ memset(state->buf + state->buflen, 0,
|
||||
+ BLAKE2S_BLOCK_SIZE - state->buflen); /* Padding */
|
||||
+ blake2s_compress_generic(state, state->buf, 1, state->buflen);
|
||||
+ cpu_to_le32_array(state->h, ARRAY_SIZE(state->h));
|
||||
+ memcpy(out, state->h, state->outlen);
|
||||
+ memzero_explicit(state, sizeof(*state));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct shash_alg blake2s_algs[] = {{
|
||||
+ .base.cra_name = "blake2s-128",
|
||||
+ .base.cra_driver_name = "blake2s-128-generic",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_128_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}, {
|
||||
+ .base.cra_name = "blake2s-160",
|
||||
+ .base.cra_driver_name = "blake2s-160-generic",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_160_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}, {
|
||||
+ .base.cra_name = "blake2s-224",
|
||||
+ .base.cra_driver_name = "blake2s-224-generic",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_224_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}, {
|
||||
+ .base.cra_name = "blake2s-256",
|
||||
+ .base.cra_driver_name = "blake2s-256-generic",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_256_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}};
|
||||
+
|
||||
+static int __init blake2s_mod_init(void)
|
||||
+{
|
||||
+ return crypto_register_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
|
||||
+}
|
||||
+
|
||||
+static void __exit blake2s_mod_exit(void)
|
||||
+{
|
||||
+ crypto_unregister_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
|
||||
+}
|
||||
+
|
||||
+subsys_initcall(blake2s_mod_init);
|
||||
+module_exit(blake2s_mod_exit);
|
||||
+
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-128");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-128-generic");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-160");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-160-generic");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-224");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-224-generic");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-256");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-256-generic");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
--- a/include/crypto/internal/blake2s.h
|
||||
+++ b/include/crypto/internal/blake2s.h
|
||||
@@ -5,6 +5,11 @@
|
||||
|
||||
#include <crypto/blake2s.h>
|
||||
|
||||
+struct blake2s_tfm_ctx {
|
||||
+ u8 key[BLAKE2S_KEY_SIZE];
|
||||
+ unsigned int keylen;
|
||||
+};
|
||||
+
|
||||
void blake2s_compress_generic(struct blake2s_state *state,const u8 *block,
|
||||
size_t nblocks, const u32 inc);
|
||||
|
||||
@@ -1,557 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Fri, 8 Nov 2019 13:22:31 +0100
|
||||
Subject: [PATCH] crypto: blake2s - x86_64 SIMD implementation
|
||||
|
||||
commit ed0356eda153f6a95649e11feb7b07083caf9e20 upstream.
|
||||
|
||||
These implementations from Samuel Neves support AVX and AVX-512VL.
|
||||
Originally this used AVX-512F, but Skylake thermal throttling made
|
||||
AVX-512VL more attractive and possible to do with negligable difference.
|
||||
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Signed-off-by: Samuel Neves <sneves@dei.uc.pt>
|
||||
Co-developed-by: Samuel Neves <sneves@dei.uc.pt>
|
||||
[ardb: move to arch/x86/crypto, wire into lib/crypto framework]
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/Makefile | 2 +
|
||||
arch/x86/crypto/blake2s-core.S | 258 +++++++++++++++++++++++++++++++++
|
||||
arch/x86/crypto/blake2s-glue.c | 233 +++++++++++++++++++++++++++++
|
||||
crypto/Kconfig | 6 +
|
||||
4 files changed, 499 insertions(+)
|
||||
create mode 100644 arch/x86/crypto/blake2s-core.S
|
||||
create mode 100644 arch/x86/crypto/blake2s-glue.c
|
||||
|
||||
--- a/arch/x86/crypto/Makefile
|
||||
+++ b/arch/x86/crypto/Makefile
|
||||
@@ -48,6 +48,7 @@ ifeq ($(avx_supported),yes)
|
||||
obj-$(CONFIG_CRYPTO_CAST6_AVX_X86_64) += cast6-avx-x86_64.o
|
||||
obj-$(CONFIG_CRYPTO_TWOFISH_AVX_X86_64) += twofish-avx-x86_64.o
|
||||
obj-$(CONFIG_CRYPTO_SERPENT_AVX_X86_64) += serpent-avx-x86_64.o
|
||||
+ obj-$(CONFIG_CRYPTO_BLAKE2S_X86) += blake2s-x86_64.o
|
||||
endif
|
||||
|
||||
# These modules require assembler to support AVX2.
|
||||
@@ -70,6 +71,7 @@ serpent-sse2-x86_64-y := serpent-sse2-x8
|
||||
aegis128-aesni-y := aegis128-aesni-asm.o aegis128-aesni-glue.o
|
||||
|
||||
nhpoly1305-sse2-y := nh-sse2-x86_64.o nhpoly1305-sse2-glue.o
|
||||
+blake2s-x86_64-y := blake2s-core.o blake2s-glue.o
|
||||
|
||||
ifeq ($(avx_supported),yes)
|
||||
camellia-aesni-avx-x86_64-y := camellia-aesni-avx-asm_64.o \
|
||||
--- /dev/null
|
||||
+++ b/arch/x86/crypto/blake2s-core.S
|
||||
@@ -0,0 +1,258 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
|
||||
+/*
|
||||
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||
+ * Copyright (C) 2017-2019 Samuel Neves <sneves@dei.uc.pt>. All Rights Reserved.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/linkage.h>
|
||||
+
|
||||
+.section .rodata.cst32.BLAKE2S_IV, "aM", @progbits, 32
|
||||
+.align 32
|
||||
+IV: .octa 0xA54FF53A3C6EF372BB67AE856A09E667
|
||||
+ .octa 0x5BE0CD191F83D9AB9B05688C510E527F
|
||||
+.section .rodata.cst16.ROT16, "aM", @progbits, 16
|
||||
+.align 16
|
||||
+ROT16: .octa 0x0D0C0F0E09080B0A0504070601000302
|
||||
+.section .rodata.cst16.ROR328, "aM", @progbits, 16
|
||||
+.align 16
|
||||
+ROR328: .octa 0x0C0F0E0D080B0A090407060500030201
|
||||
+.section .rodata.cst64.BLAKE2S_SIGMA, "aM", @progbits, 160
|
||||
+.align 64
|
||||
+SIGMA:
|
||||
+.byte 0, 2, 4, 6, 1, 3, 5, 7, 14, 8, 10, 12, 15, 9, 11, 13
|
||||
+.byte 14, 4, 9, 13, 10, 8, 15, 6, 5, 1, 0, 11, 3, 12, 2, 7
|
||||
+.byte 11, 12, 5, 15, 8, 0, 2, 13, 9, 10, 3, 7, 4, 14, 6, 1
|
||||
+.byte 7, 3, 13, 11, 9, 1, 12, 14, 15, 2, 5, 4, 8, 6, 10, 0
|
||||
+.byte 9, 5, 2, 10, 0, 7, 4, 15, 3, 14, 11, 6, 13, 1, 12, 8
|
||||
+.byte 2, 6, 0, 8, 12, 10, 11, 3, 1, 4, 7, 15, 9, 13, 5, 14
|
||||
+.byte 12, 1, 14, 4, 5, 15, 13, 10, 8, 0, 6, 9, 11, 7, 3, 2
|
||||
+.byte 13, 7, 12, 3, 11, 14, 1, 9, 2, 5, 15, 8, 10, 0, 4, 6
|
||||
+.byte 6, 14, 11, 0, 15, 9, 3, 8, 10, 12, 13, 1, 5, 2, 7, 4
|
||||
+.byte 10, 8, 7, 1, 2, 4, 6, 5, 13, 15, 9, 3, 0, 11, 14, 12
|
||||
+#ifdef CONFIG_AS_AVX512
|
||||
+.section .rodata.cst64.BLAKE2S_SIGMA2, "aM", @progbits, 640
|
||||
+.align 64
|
||||
+SIGMA2:
|
||||
+.long 0, 2, 4, 6, 1, 3, 5, 7, 14, 8, 10, 12, 15, 9, 11, 13
|
||||
+.long 8, 2, 13, 15, 10, 9, 12, 3, 6, 4, 0, 14, 5, 11, 1, 7
|
||||
+.long 11, 13, 8, 6, 5, 10, 14, 3, 2, 4, 12, 15, 1, 0, 7, 9
|
||||
+.long 11, 10, 7, 0, 8, 15, 1, 13, 3, 6, 2, 12, 4, 14, 9, 5
|
||||
+.long 4, 10, 9, 14, 15, 0, 11, 8, 1, 7, 3, 13, 2, 5, 6, 12
|
||||
+.long 2, 11, 4, 15, 14, 3, 10, 8, 13, 6, 5, 7, 0, 12, 1, 9
|
||||
+.long 4, 8, 15, 9, 14, 11, 13, 5, 3, 2, 1, 12, 6, 10, 7, 0
|
||||
+.long 6, 13, 0, 14, 12, 2, 1, 11, 15, 4, 5, 8, 7, 9, 3, 10
|
||||
+.long 15, 5, 4, 13, 10, 7, 3, 11, 12, 2, 0, 6, 9, 8, 1, 14
|
||||
+.long 8, 7, 14, 11, 13, 15, 0, 12, 10, 4, 5, 6, 3, 2, 1, 9
|
||||
+#endif /* CONFIG_AS_AVX512 */
|
||||
+
|
||||
+.text
|
||||
+#ifdef CONFIG_AS_SSSE3
|
||||
+ENTRY(blake2s_compress_ssse3)
|
||||
+ testq %rdx,%rdx
|
||||
+ je .Lendofloop
|
||||
+ movdqu (%rdi),%xmm0
|
||||
+ movdqu 0x10(%rdi),%xmm1
|
||||
+ movdqa ROT16(%rip),%xmm12
|
||||
+ movdqa ROR328(%rip),%xmm13
|
||||
+ movdqu 0x20(%rdi),%xmm14
|
||||
+ movq %rcx,%xmm15
|
||||
+ leaq SIGMA+0xa0(%rip),%r8
|
||||
+ jmp .Lbeginofloop
|
||||
+ .align 32
|
||||
+.Lbeginofloop:
|
||||
+ movdqa %xmm0,%xmm10
|
||||
+ movdqa %xmm1,%xmm11
|
||||
+ paddq %xmm15,%xmm14
|
||||
+ movdqa IV(%rip),%xmm2
|
||||
+ movdqa %xmm14,%xmm3
|
||||
+ pxor IV+0x10(%rip),%xmm3
|
||||
+ leaq SIGMA(%rip),%rcx
|
||||
+.Lroundloop:
|
||||
+ movzbl (%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm4
|
||||
+ movzbl 0x1(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm5
|
||||
+ movzbl 0x2(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm6
|
||||
+ movzbl 0x3(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm7
|
||||
+ punpckldq %xmm5,%xmm4
|
||||
+ punpckldq %xmm7,%xmm6
|
||||
+ punpcklqdq %xmm6,%xmm4
|
||||
+ paddd %xmm4,%xmm0
|
||||
+ paddd %xmm1,%xmm0
|
||||
+ pxor %xmm0,%xmm3
|
||||
+ pshufb %xmm12,%xmm3
|
||||
+ paddd %xmm3,%xmm2
|
||||
+ pxor %xmm2,%xmm1
|
||||
+ movdqa %xmm1,%xmm8
|
||||
+ psrld $0xc,%xmm1
|
||||
+ pslld $0x14,%xmm8
|
||||
+ por %xmm8,%xmm1
|
||||
+ movzbl 0x4(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm5
|
||||
+ movzbl 0x5(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm6
|
||||
+ movzbl 0x6(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm7
|
||||
+ movzbl 0x7(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm4
|
||||
+ punpckldq %xmm6,%xmm5
|
||||
+ punpckldq %xmm4,%xmm7
|
||||
+ punpcklqdq %xmm7,%xmm5
|
||||
+ paddd %xmm5,%xmm0
|
||||
+ paddd %xmm1,%xmm0
|
||||
+ pxor %xmm0,%xmm3
|
||||
+ pshufb %xmm13,%xmm3
|
||||
+ paddd %xmm3,%xmm2
|
||||
+ pxor %xmm2,%xmm1
|
||||
+ movdqa %xmm1,%xmm8
|
||||
+ psrld $0x7,%xmm1
|
||||
+ pslld $0x19,%xmm8
|
||||
+ por %xmm8,%xmm1
|
||||
+ pshufd $0x93,%xmm0,%xmm0
|
||||
+ pshufd $0x4e,%xmm3,%xmm3
|
||||
+ pshufd $0x39,%xmm2,%xmm2
|
||||
+ movzbl 0x8(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm6
|
||||
+ movzbl 0x9(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm7
|
||||
+ movzbl 0xa(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm4
|
||||
+ movzbl 0xb(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm5
|
||||
+ punpckldq %xmm7,%xmm6
|
||||
+ punpckldq %xmm5,%xmm4
|
||||
+ punpcklqdq %xmm4,%xmm6
|
||||
+ paddd %xmm6,%xmm0
|
||||
+ paddd %xmm1,%xmm0
|
||||
+ pxor %xmm0,%xmm3
|
||||
+ pshufb %xmm12,%xmm3
|
||||
+ paddd %xmm3,%xmm2
|
||||
+ pxor %xmm2,%xmm1
|
||||
+ movdqa %xmm1,%xmm8
|
||||
+ psrld $0xc,%xmm1
|
||||
+ pslld $0x14,%xmm8
|
||||
+ por %xmm8,%xmm1
|
||||
+ movzbl 0xc(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm7
|
||||
+ movzbl 0xd(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm4
|
||||
+ movzbl 0xe(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm5
|
||||
+ movzbl 0xf(%rcx),%eax
|
||||
+ movd (%rsi,%rax,4),%xmm6
|
||||
+ punpckldq %xmm4,%xmm7
|
||||
+ punpckldq %xmm6,%xmm5
|
||||
+ punpcklqdq %xmm5,%xmm7
|
||||
+ paddd %xmm7,%xmm0
|
||||
+ paddd %xmm1,%xmm0
|
||||
+ pxor %xmm0,%xmm3
|
||||
+ pshufb %xmm13,%xmm3
|
||||
+ paddd %xmm3,%xmm2
|
||||
+ pxor %xmm2,%xmm1
|
||||
+ movdqa %xmm1,%xmm8
|
||||
+ psrld $0x7,%xmm1
|
||||
+ pslld $0x19,%xmm8
|
||||
+ por %xmm8,%xmm1
|
||||
+ pshufd $0x39,%xmm0,%xmm0
|
||||
+ pshufd $0x4e,%xmm3,%xmm3
|
||||
+ pshufd $0x93,%xmm2,%xmm2
|
||||
+ addq $0x10,%rcx
|
||||
+ cmpq %r8,%rcx
|
||||
+ jnz .Lroundloop
|
||||
+ pxor %xmm2,%xmm0
|
||||
+ pxor %xmm3,%xmm1
|
||||
+ pxor %xmm10,%xmm0
|
||||
+ pxor %xmm11,%xmm1
|
||||
+ addq $0x40,%rsi
|
||||
+ decq %rdx
|
||||
+ jnz .Lbeginofloop
|
||||
+ movdqu %xmm0,(%rdi)
|
||||
+ movdqu %xmm1,0x10(%rdi)
|
||||
+ movdqu %xmm14,0x20(%rdi)
|
||||
+.Lendofloop:
|
||||
+ ret
|
||||
+ENDPROC(blake2s_compress_ssse3)
|
||||
+#endif /* CONFIG_AS_SSSE3 */
|
||||
+
|
||||
+#ifdef CONFIG_AS_AVX512
|
||||
+ENTRY(blake2s_compress_avx512)
|
||||
+ vmovdqu (%rdi),%xmm0
|
||||
+ vmovdqu 0x10(%rdi),%xmm1
|
||||
+ vmovdqu 0x20(%rdi),%xmm4
|
||||
+ vmovq %rcx,%xmm5
|
||||
+ vmovdqa IV(%rip),%xmm14
|
||||
+ vmovdqa IV+16(%rip),%xmm15
|
||||
+ jmp .Lblake2s_compress_avx512_mainloop
|
||||
+.align 32
|
||||
+.Lblake2s_compress_avx512_mainloop:
|
||||
+ vmovdqa %xmm0,%xmm10
|
||||
+ vmovdqa %xmm1,%xmm11
|
||||
+ vpaddq %xmm5,%xmm4,%xmm4
|
||||
+ vmovdqa %xmm14,%xmm2
|
||||
+ vpxor %xmm15,%xmm4,%xmm3
|
||||
+ vmovdqu (%rsi),%ymm6
|
||||
+ vmovdqu 0x20(%rsi),%ymm7
|
||||
+ addq $0x40,%rsi
|
||||
+ leaq SIGMA2(%rip),%rax
|
||||
+ movb $0xa,%cl
|
||||
+.Lblake2s_compress_avx512_roundloop:
|
||||
+ addq $0x40,%rax
|
||||
+ vmovdqa -0x40(%rax),%ymm8
|
||||
+ vmovdqa -0x20(%rax),%ymm9
|
||||
+ vpermi2d %ymm7,%ymm6,%ymm8
|
||||
+ vpermi2d %ymm7,%ymm6,%ymm9
|
||||
+ vmovdqa %ymm8,%ymm6
|
||||
+ vmovdqa %ymm9,%ymm7
|
||||
+ vpaddd %xmm8,%xmm0,%xmm0
|
||||
+ vpaddd %xmm1,%xmm0,%xmm0
|
||||
+ vpxor %xmm0,%xmm3,%xmm3
|
||||
+ vprord $0x10,%xmm3,%xmm3
|
||||
+ vpaddd %xmm3,%xmm2,%xmm2
|
||||
+ vpxor %xmm2,%xmm1,%xmm1
|
||||
+ vprord $0xc,%xmm1,%xmm1
|
||||
+ vextracti128 $0x1,%ymm8,%xmm8
|
||||
+ vpaddd %xmm8,%xmm0,%xmm0
|
||||
+ vpaddd %xmm1,%xmm0,%xmm0
|
||||
+ vpxor %xmm0,%xmm3,%xmm3
|
||||
+ vprord $0x8,%xmm3,%xmm3
|
||||
+ vpaddd %xmm3,%xmm2,%xmm2
|
||||
+ vpxor %xmm2,%xmm1,%xmm1
|
||||
+ vprord $0x7,%xmm1,%xmm1
|
||||
+ vpshufd $0x93,%xmm0,%xmm0
|
||||
+ vpshufd $0x4e,%xmm3,%xmm3
|
||||
+ vpshufd $0x39,%xmm2,%xmm2
|
||||
+ vpaddd %xmm9,%xmm0,%xmm0
|
||||
+ vpaddd %xmm1,%xmm0,%xmm0
|
||||
+ vpxor %xmm0,%xmm3,%xmm3
|
||||
+ vprord $0x10,%xmm3,%xmm3
|
||||
+ vpaddd %xmm3,%xmm2,%xmm2
|
||||
+ vpxor %xmm2,%xmm1,%xmm1
|
||||
+ vprord $0xc,%xmm1,%xmm1
|
||||
+ vextracti128 $0x1,%ymm9,%xmm9
|
||||
+ vpaddd %xmm9,%xmm0,%xmm0
|
||||
+ vpaddd %xmm1,%xmm0,%xmm0
|
||||
+ vpxor %xmm0,%xmm3,%xmm3
|
||||
+ vprord $0x8,%xmm3,%xmm3
|
||||
+ vpaddd %xmm3,%xmm2,%xmm2
|
||||
+ vpxor %xmm2,%xmm1,%xmm1
|
||||
+ vprord $0x7,%xmm1,%xmm1
|
||||
+ vpshufd $0x39,%xmm0,%xmm0
|
||||
+ vpshufd $0x4e,%xmm3,%xmm3
|
||||
+ vpshufd $0x93,%xmm2,%xmm2
|
||||
+ decb %cl
|
||||
+ jne .Lblake2s_compress_avx512_roundloop
|
||||
+ vpxor %xmm10,%xmm0,%xmm0
|
||||
+ vpxor %xmm11,%xmm1,%xmm1
|
||||
+ vpxor %xmm2,%xmm0,%xmm0
|
||||
+ vpxor %xmm3,%xmm1,%xmm1
|
||||
+ decq %rdx
|
||||
+ jne .Lblake2s_compress_avx512_mainloop
|
||||
+ vmovdqu %xmm0,(%rdi)
|
||||
+ vmovdqu %xmm1,0x10(%rdi)
|
||||
+ vmovdqu %xmm4,0x20(%rdi)
|
||||
+ vzeroupper
|
||||
+ retq
|
||||
+ENDPROC(blake2s_compress_avx512)
|
||||
+#endif /* CONFIG_AS_AVX512 */
|
||||
--- /dev/null
|
||||
+++ b/arch/x86/crypto/blake2s-glue.c
|
||||
@@ -0,0 +1,233 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0 OR MIT
|
||||
+/*
|
||||
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||
+ */
|
||||
+
|
||||
+#include <crypto/internal/blake2s.h>
|
||||
+#include <crypto/internal/simd.h>
|
||||
+#include <crypto/internal/hash.h>
|
||||
+
|
||||
+#include <linux/types.h>
|
||||
+#include <linux/jump_label.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include <asm/cpufeature.h>
|
||||
+#include <asm/fpu/api.h>
|
||||
+#include <asm/processor.h>
|
||||
+#include <asm/simd.h>
|
||||
+
|
||||
+asmlinkage void blake2s_compress_ssse3(struct blake2s_state *state,
|
||||
+ const u8 *block, const size_t nblocks,
|
||||
+ const u32 inc);
|
||||
+asmlinkage void blake2s_compress_avx512(struct blake2s_state *state,
|
||||
+ const u8 *block, const size_t nblocks,
|
||||
+ const u32 inc);
|
||||
+
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(blake2s_use_ssse3);
|
||||
+static __ro_after_init DEFINE_STATIC_KEY_FALSE(blake2s_use_avx512);
|
||||
+
|
||||
+void blake2s_compress_arch(struct blake2s_state *state,
|
||||
+ const u8 *block, size_t nblocks,
|
||||
+ const u32 inc)
|
||||
+{
|
||||
+ /* SIMD disables preemption, so relax after processing each page. */
|
||||
+ BUILD_BUG_ON(PAGE_SIZE / BLAKE2S_BLOCK_SIZE < 8);
|
||||
+
|
||||
+ if (!static_branch_likely(&blake2s_use_ssse3) || !crypto_simd_usable()) {
|
||||
+ blake2s_compress_generic(state, block, nblocks, inc);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ for (;;) {
|
||||
+ const size_t blocks = min_t(size_t, nblocks,
|
||||
+ PAGE_SIZE / BLAKE2S_BLOCK_SIZE);
|
||||
+
|
||||
+ kernel_fpu_begin();
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX512) &&
|
||||
+ static_branch_likely(&blake2s_use_avx512))
|
||||
+ blake2s_compress_avx512(state, block, blocks, inc);
|
||||
+ else
|
||||
+ blake2s_compress_ssse3(state, block, blocks, inc);
|
||||
+ kernel_fpu_end();
|
||||
+
|
||||
+ nblocks -= blocks;
|
||||
+ if (!nblocks)
|
||||
+ break;
|
||||
+ block += blocks * BLAKE2S_BLOCK_SIZE;
|
||||
+ }
|
||||
+}
|
||||
+EXPORT_SYMBOL(blake2s_compress_arch);
|
||||
+
|
||||
+static int crypto_blake2s_setkey(struct crypto_shash *tfm, const u8 *key,
|
||||
+ unsigned int keylen)
|
||||
+{
|
||||
+ struct blake2s_tfm_ctx *tctx = crypto_shash_ctx(tfm);
|
||||
+
|
||||
+ if (keylen == 0 || keylen > BLAKE2S_KEY_SIZE) {
|
||||
+ crypto_shash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ memcpy(tctx->key, key, keylen);
|
||||
+ tctx->keylen = keylen;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int crypto_blake2s_init(struct shash_desc *desc)
|
||||
+{
|
||||
+ struct blake2s_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm);
|
||||
+ struct blake2s_state *state = shash_desc_ctx(desc);
|
||||
+ const int outlen = crypto_shash_digestsize(desc->tfm);
|
||||
+
|
||||
+ if (tctx->keylen)
|
||||
+ blake2s_init_key(state, outlen, tctx->key, tctx->keylen);
|
||||
+ else
|
||||
+ blake2s_init(state, outlen);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int crypto_blake2s_update(struct shash_desc *desc, const u8 *in,
|
||||
+ unsigned int inlen)
|
||||
+{
|
||||
+ struct blake2s_state *state = shash_desc_ctx(desc);
|
||||
+ const size_t fill = BLAKE2S_BLOCK_SIZE - state->buflen;
|
||||
+
|
||||
+ if (unlikely(!inlen))
|
||||
+ return 0;
|
||||
+ if (inlen > fill) {
|
||||
+ memcpy(state->buf + state->buflen, in, fill);
|
||||
+ blake2s_compress_arch(state, state->buf, 1, BLAKE2S_BLOCK_SIZE);
|
||||
+ state->buflen = 0;
|
||||
+ in += fill;
|
||||
+ inlen -= fill;
|
||||
+ }
|
||||
+ if (inlen > BLAKE2S_BLOCK_SIZE) {
|
||||
+ const size_t nblocks = DIV_ROUND_UP(inlen, BLAKE2S_BLOCK_SIZE);
|
||||
+ /* Hash one less (full) block than strictly possible */
|
||||
+ blake2s_compress_arch(state, in, nblocks - 1, BLAKE2S_BLOCK_SIZE);
|
||||
+ in += BLAKE2S_BLOCK_SIZE * (nblocks - 1);
|
||||
+ inlen -= BLAKE2S_BLOCK_SIZE * (nblocks - 1);
|
||||
+ }
|
||||
+ memcpy(state->buf + state->buflen, in, inlen);
|
||||
+ state->buflen += inlen;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int crypto_blake2s_final(struct shash_desc *desc, u8 *out)
|
||||
+{
|
||||
+ struct blake2s_state *state = shash_desc_ctx(desc);
|
||||
+
|
||||
+ blake2s_set_lastblock(state);
|
||||
+ memset(state->buf + state->buflen, 0,
|
||||
+ BLAKE2S_BLOCK_SIZE - state->buflen); /* Padding */
|
||||
+ blake2s_compress_arch(state, state->buf, 1, state->buflen);
|
||||
+ cpu_to_le32_array(state->h, ARRAY_SIZE(state->h));
|
||||
+ memcpy(out, state->h, state->outlen);
|
||||
+ memzero_explicit(state, sizeof(*state));
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static struct shash_alg blake2s_algs[] = {{
|
||||
+ .base.cra_name = "blake2s-128",
|
||||
+ .base.cra_driver_name = "blake2s-128-x86",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_128_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}, {
|
||||
+ .base.cra_name = "blake2s-160",
|
||||
+ .base.cra_driver_name = "blake2s-160-x86",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_160_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}, {
|
||||
+ .base.cra_name = "blake2s-224",
|
||||
+ .base.cra_driver_name = "blake2s-224-x86",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_224_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}, {
|
||||
+ .base.cra_name = "blake2s-256",
|
||||
+ .base.cra_driver_name = "blake2s-256-x86",
|
||||
+ .base.cra_flags = CRYPTO_ALG_OPTIONAL_KEY,
|
||||
+ .base.cra_ctxsize = sizeof(struct blake2s_tfm_ctx),
|
||||
+ .base.cra_priority = 200,
|
||||
+ .base.cra_blocksize = BLAKE2S_BLOCK_SIZE,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+
|
||||
+ .digestsize = BLAKE2S_256_HASH_SIZE,
|
||||
+ .setkey = crypto_blake2s_setkey,
|
||||
+ .init = crypto_blake2s_init,
|
||||
+ .update = crypto_blake2s_update,
|
||||
+ .final = crypto_blake2s_final,
|
||||
+ .descsize = sizeof(struct blake2s_state),
|
||||
+}};
|
||||
+
|
||||
+static int __init blake2s_mod_init(void)
|
||||
+{
|
||||
+ if (!boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
+ return 0;
|
||||
+
|
||||
+ static_branch_enable(&blake2s_use_ssse3);
|
||||
+
|
||||
+ if (IS_ENABLED(CONFIG_AS_AVX512) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX2) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX512F) &&
|
||||
+ boot_cpu_has(X86_FEATURE_AVX512VL) &&
|
||||
+ cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM |
|
||||
+ XFEATURE_MASK_AVX512, NULL))
|
||||
+ static_branch_enable(&blake2s_use_avx512);
|
||||
+
|
||||
+ return crypto_register_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
|
||||
+}
|
||||
+
|
||||
+static void __exit blake2s_mod_exit(void)
|
||||
+{
|
||||
+ if (boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
+ crypto_unregister_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
|
||||
+}
|
||||
+
|
||||
+module_init(blake2s_mod_init);
|
||||
+module_exit(blake2s_mod_exit);
|
||||
+
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-128");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-128-x86");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-160");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-160-x86");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-224");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-224-x86");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-256");
|
||||
+MODULE_ALIAS_CRYPTO("blake2s-256-x86");
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -657,6 +657,12 @@ config CRYPTO_BLAKE2S
|
||||
|
||||
See https://blake2.net for further information.
|
||||
|
||||
+config CRYPTO_BLAKE2S_X86
|
||||
+ tristate "BLAKE2s digest algorithm (x86 accelerated version)"
|
||||
+ depends on X86 && 64BIT
|
||||
+ select CRYPTO_LIB_BLAKE2S_GENERIC
|
||||
+ select CRYPTO_ARCH_HAVE_LIB_BLAKE2S
|
||||
+
|
||||
config CRYPTO_CRCT10DIF
|
||||
tristate "CRCT10DIF algorithm"
|
||||
select CRYPTO_HASH
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,136 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:34 +0100
|
||||
Subject: [PATCH] crypto: curve25519 - implement generic KPP driver
|
||||
|
||||
commit ee772cb641135739c1530647391d5a04c39db192 upstream.
|
||||
|
||||
Expose the generic Curve25519 library via the crypto API KPP interface.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/Kconfig | 5 +++
|
||||
crypto/Makefile | 1 +
|
||||
crypto/curve25519-generic.c | 90 +++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 96 insertions(+)
|
||||
create mode 100644 crypto/curve25519-generic.c
|
||||
|
||||
--- a/crypto/Kconfig
|
||||
+++ b/crypto/Kconfig
|
||||
@@ -264,6 +264,11 @@ config CRYPTO_ECRDSA
|
||||
standard algorithms (called GOST algorithms). Only signature verification
|
||||
is implemented.
|
||||
|
||||
+config CRYPTO_CURVE25519
|
||||
+ tristate "Curve25519 algorithm"
|
||||
+ select CRYPTO_KPP
|
||||
+ select CRYPTO_LIB_CURVE25519_GENERIC
|
||||
+
|
||||
comment "Authenticated Encryption with Associated Data"
|
||||
|
||||
config CRYPTO_CCM
|
||||
--- a/crypto/Makefile
|
||||
+++ b/crypto/Makefile
|
||||
@@ -167,6 +167,7 @@ obj-$(CONFIG_CRYPTO_ZSTD) += zstd.o
|
||||
obj-$(CONFIG_CRYPTO_OFB) += ofb.o
|
||||
obj-$(CONFIG_CRYPTO_ECC) += ecc.o
|
||||
obj-$(CONFIG_CRYPTO_ESSIV) += essiv.o
|
||||
+obj-$(CONFIG_CRYPTO_CURVE25519) += curve25519-generic.o
|
||||
|
||||
ecdh_generic-y += ecdh.o
|
||||
ecdh_generic-y += ecdh_helper.o
|
||||
--- /dev/null
|
||||
+++ b/crypto/curve25519-generic.c
|
||||
@@ -0,0 +1,90 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+
|
||||
+#include <crypto/curve25519.h>
|
||||
+#include <crypto/internal/kpp.h>
|
||||
+#include <crypto/kpp.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/scatterlist.h>
|
||||
+
|
||||
+static int curve25519_set_secret(struct crypto_kpp *tfm, const void *buf,
|
||||
+ unsigned int len)
|
||||
+{
|
||||
+ u8 *secret = kpp_tfm_ctx(tfm);
|
||||
+
|
||||
+ if (!len)
|
||||
+ curve25519_generate_secret(secret);
|
||||
+ else if (len == CURVE25519_KEY_SIZE &&
|
||||
+ crypto_memneq(buf, curve25519_null_point, CURVE25519_KEY_SIZE))
|
||||
+ memcpy(secret, buf, CURVE25519_KEY_SIZE);
|
||||
+ else
|
||||
+ return -EINVAL;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int curve25519_compute_value(struct kpp_request *req)
|
||||
+{
|
||||
+ struct crypto_kpp *tfm = crypto_kpp_reqtfm(req);
|
||||
+ const u8 *secret = kpp_tfm_ctx(tfm);
|
||||
+ u8 public_key[CURVE25519_KEY_SIZE];
|
||||
+ u8 buf[CURVE25519_KEY_SIZE];
|
||||
+ int copied, nbytes;
|
||||
+ u8 const *bp;
|
||||
+
|
||||
+ if (req->src) {
|
||||
+ copied = sg_copy_to_buffer(req->src,
|
||||
+ sg_nents_for_len(req->src,
|
||||
+ CURVE25519_KEY_SIZE),
|
||||
+ public_key, CURVE25519_KEY_SIZE);
|
||||
+ if (copied != CURVE25519_KEY_SIZE)
|
||||
+ return -EINVAL;
|
||||
+ bp = public_key;
|
||||
+ } else {
|
||||
+ bp = curve25519_base_point;
|
||||
+ }
|
||||
+
|
||||
+ curve25519_generic(buf, secret, bp);
|
||||
+
|
||||
+ /* might want less than we've got */
|
||||
+ nbytes = min_t(size_t, CURVE25519_KEY_SIZE, req->dst_len);
|
||||
+ copied = sg_copy_from_buffer(req->dst, sg_nents_for_len(req->dst,
|
||||
+ nbytes),
|
||||
+ buf, nbytes);
|
||||
+ if (copied != nbytes)
|
||||
+ return -EINVAL;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static unsigned int curve25519_max_size(struct crypto_kpp *tfm)
|
||||
+{
|
||||
+ return CURVE25519_KEY_SIZE;
|
||||
+}
|
||||
+
|
||||
+static struct kpp_alg curve25519_alg = {
|
||||
+ .base.cra_name = "curve25519",
|
||||
+ .base.cra_driver_name = "curve25519-generic",
|
||||
+ .base.cra_priority = 100,
|
||||
+ .base.cra_module = THIS_MODULE,
|
||||
+ .base.cra_ctxsize = CURVE25519_KEY_SIZE,
|
||||
+
|
||||
+ .set_secret = curve25519_set_secret,
|
||||
+ .generate_public_key = curve25519_compute_value,
|
||||
+ .compute_shared_secret = curve25519_compute_value,
|
||||
+ .max_size = curve25519_max_size,
|
||||
+};
|
||||
+
|
||||
+static int curve25519_init(void)
|
||||
+{
|
||||
+ return crypto_register_kpp(&curve25519_alg);
|
||||
+}
|
||||
+
|
||||
+static void curve25519_exit(void)
|
||||
+{
|
||||
+ crypto_unregister_kpp(&curve25519_alg);
|
||||
+}
|
||||
+
|
||||
+subsys_initcall(curve25519_init);
|
||||
+module_exit(curve25519_exit);
|
||||
+
|
||||
+MODULE_ALIAS_CRYPTO("curve25519");
|
||||
+MODULE_ALIAS_CRYPTO("curve25519-generic");
|
||||
+MODULE_LICENSE("GPL");
|
||||
@@ -1,75 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:35 +0100
|
||||
Subject: [PATCH] crypto: lib/curve25519 - work around Clang stack spilling
|
||||
issue
|
||||
|
||||
commit 660bb8e1f833ea63185fe80fde847e3e42f18e3b upstream.
|
||||
|
||||
Arnd reports that the 32-bit generic library code for Curve25119 ends
|
||||
up using an excessive amount of stack space when built with Clang:
|
||||
|
||||
lib/crypto/curve25519-fiat32.c:756:6: error: stack frame size
|
||||
of 1384 bytes in function 'curve25519_generic'
|
||||
[-Werror,-Wframe-larger-than=]
|
||||
|
||||
Let's give some hints to the compiler regarding which routines should
|
||||
not be inlined, to prevent it from running out of registers and spilling
|
||||
to the stack. The resulting code performs identically under both GCC
|
||||
and Clang, and makes the warning go away.
|
||||
|
||||
Suggested-by: Arnd Bergmann <arnd@arndb.de>
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
lib/crypto/curve25519-fiat32.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/lib/crypto/curve25519-fiat32.c
|
||||
+++ b/lib/crypto/curve25519-fiat32.c
|
||||
@@ -223,7 +223,7 @@ static __always_inline void fe_1(fe *h)
|
||||
h->v[0] = 1;
|
||||
}
|
||||
|
||||
-static void fe_add_impl(u32 out[10], const u32 in1[10], const u32 in2[10])
|
||||
+static noinline void fe_add_impl(u32 out[10], const u32 in1[10], const u32 in2[10])
|
||||
{
|
||||
{ const u32 x20 = in1[9];
|
||||
{ const u32 x21 = in1[8];
|
||||
@@ -266,7 +266,7 @@ static __always_inline void fe_add(fe_lo
|
||||
fe_add_impl(h->v, f->v, g->v);
|
||||
}
|
||||
|
||||
-static void fe_sub_impl(u32 out[10], const u32 in1[10], const u32 in2[10])
|
||||
+static noinline void fe_sub_impl(u32 out[10], const u32 in1[10], const u32 in2[10])
|
||||
{
|
||||
{ const u32 x20 = in1[9];
|
||||
{ const u32 x21 = in1[8];
|
||||
@@ -309,7 +309,7 @@ static __always_inline void fe_sub(fe_lo
|
||||
fe_sub_impl(h->v, f->v, g->v);
|
||||
}
|
||||
|
||||
-static void fe_mul_impl(u32 out[10], const u32 in1[10], const u32 in2[10])
|
||||
+static noinline void fe_mul_impl(u32 out[10], const u32 in1[10], const u32 in2[10])
|
||||
{
|
||||
{ const u32 x20 = in1[9];
|
||||
{ const u32 x21 = in1[8];
|
||||
@@ -441,7 +441,7 @@ fe_mul_tll(fe *h, const fe_loose *f, con
|
||||
fe_mul_impl(h->v, f->v, g->v);
|
||||
}
|
||||
|
||||
-static void fe_sqr_impl(u32 out[10], const u32 in1[10])
|
||||
+static noinline void fe_sqr_impl(u32 out[10], const u32 in1[10])
|
||||
{
|
||||
{ const u32 x17 = in1[9];
|
||||
{ const u32 x18 = in1[8];
|
||||
@@ -619,7 +619,7 @@ static __always_inline void fe_invert(fe
|
||||
*
|
||||
* Preconditions: b in {0,1}
|
||||
*/
|
||||
-static __always_inline void fe_cswap(fe *f, fe *g, unsigned int b)
|
||||
+static noinline void fe_cswap(fe *f, fe *g, unsigned int b)
|
||||
{
|
||||
unsigned i;
|
||||
b = 0 - b;
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,295 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 8 Nov 2019 13:22:40 +0100
|
||||
Subject: [PATCH] crypto: lib/chacha20poly1305 - reimplement crypt_from_sg()
|
||||
routine
|
||||
|
||||
commit d95312a3ccc0cd544d374be2fc45aeaa803e5fd9 upstream.
|
||||
|
||||
Reimplement the library routines to perform chacha20poly1305 en/decryption
|
||||
on scatterlists, without [ab]using the [deprecated] blkcipher interface,
|
||||
which is rather heavyweight and does things we don't really need.
|
||||
|
||||
Instead, we use the sg_miter API in a novel and clever way, to iterate
|
||||
over the scatterlist in-place (i.e., source == destination, which is the
|
||||
only way this library is expected to be used). That way, we don't have to
|
||||
iterate over two scatterlists in parallel.
|
||||
|
||||
Another optimization is that, instead of relying on the blkcipher walker
|
||||
to present the input in suitable chunks, we recognize that ChaCha is a
|
||||
streamcipher, and so we can simply deal with partial blocks by keeping a
|
||||
block of cipherstream on the stack and use crypto_xor() to mix it with
|
||||
the in/output.
|
||||
|
||||
Finally, we omit the scatterwalk_and_copy() call if the last element of
|
||||
the scatterlist covers the MAC as well (which is the common case),
|
||||
avoiding the need to walk the scatterlist and kmap() the page twice.
|
||||
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
include/crypto/chacha20poly1305.h | 11 ++
|
||||
lib/crypto/chacha20poly1305-selftest.c | 45 ++++++++
|
||||
lib/crypto/chacha20poly1305.c | 150 +++++++++++++++++++++++++
|
||||
3 files changed, 206 insertions(+)
|
||||
|
||||
--- a/include/crypto/chacha20poly1305.h
|
||||
+++ b/include/crypto/chacha20poly1305.h
|
||||
@@ -7,6 +7,7 @@
|
||||
#define __CHACHA20POLY1305_H
|
||||
|
||||
#include <linux/types.h>
|
||||
+#include <linux/scatterlist.h>
|
||||
|
||||
enum chacha20poly1305_lengths {
|
||||
XCHACHA20POLY1305_NONCE_SIZE = 24,
|
||||
@@ -34,4 +35,14 @@ bool __must_check xchacha20poly1305_decr
|
||||
const size_t ad_len, const u8 nonce[XCHACHA20POLY1305_NONCE_SIZE],
|
||||
const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
|
||||
+bool chacha20poly1305_encrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
+ const u8 *ad, const size_t ad_len,
|
||||
+ const u64 nonce,
|
||||
+ const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
+
|
||||
+bool chacha20poly1305_decrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
+ const u8 *ad, const size_t ad_len,
|
||||
+ const u64 nonce,
|
||||
+ const u8 key[CHACHA20POLY1305_KEY_SIZE]);
|
||||
+
|
||||
#endif /* __CHACHA20POLY1305_H */
|
||||
--- a/lib/crypto/chacha20poly1305-selftest.c
|
||||
+++ b/lib/crypto/chacha20poly1305-selftest.c
|
||||
@@ -7250,6 +7250,7 @@ bool __init chacha20poly1305_selftest(vo
|
||||
enum { MAXIMUM_TEST_BUFFER_LEN = 1UL << 12 };
|
||||
size_t i;
|
||||
u8 *computed_output = NULL, *heap_src = NULL;
|
||||
+ struct scatterlist sg_src;
|
||||
bool success = true, ret;
|
||||
|
||||
heap_src = kmalloc(MAXIMUM_TEST_BUFFER_LEN, GFP_KERNEL);
|
||||
@@ -7280,6 +7281,29 @@ bool __init chacha20poly1305_selftest(vo
|
||||
}
|
||||
}
|
||||
|
||||
+ for (i = 0; i < ARRAY_SIZE(chacha20poly1305_enc_vectors); ++i) {
|
||||
+ if (chacha20poly1305_enc_vectors[i].nlen != 8)
|
||||
+ continue;
|
||||
+ memcpy(heap_src, chacha20poly1305_enc_vectors[i].input,
|
||||
+ chacha20poly1305_enc_vectors[i].ilen);
|
||||
+ sg_init_one(&sg_src, heap_src,
|
||||
+ chacha20poly1305_enc_vectors[i].ilen + POLY1305_DIGEST_SIZE);
|
||||
+ chacha20poly1305_encrypt_sg_inplace(&sg_src,
|
||||
+ chacha20poly1305_enc_vectors[i].ilen,
|
||||
+ chacha20poly1305_enc_vectors[i].assoc,
|
||||
+ chacha20poly1305_enc_vectors[i].alen,
|
||||
+ get_unaligned_le64(chacha20poly1305_enc_vectors[i].nonce),
|
||||
+ chacha20poly1305_enc_vectors[i].key);
|
||||
+ if (memcmp(heap_src,
|
||||
+ chacha20poly1305_enc_vectors[i].output,
|
||||
+ chacha20poly1305_enc_vectors[i].ilen +
|
||||
+ POLY1305_DIGEST_SIZE)) {
|
||||
+ pr_err("chacha20poly1305 sg encryption self-test %zu: FAIL\n",
|
||||
+ i + 1);
|
||||
+ success = false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
for (i = 0; i < ARRAY_SIZE(chacha20poly1305_dec_vectors); ++i) {
|
||||
memset(computed_output, 0, MAXIMUM_TEST_BUFFER_LEN);
|
||||
ret = chacha20poly1305_decrypt(computed_output,
|
||||
@@ -7301,6 +7325,27 @@ bool __init chacha20poly1305_selftest(vo
|
||||
}
|
||||
}
|
||||
|
||||
+ for (i = 0; i < ARRAY_SIZE(chacha20poly1305_dec_vectors); ++i) {
|
||||
+ memcpy(heap_src, chacha20poly1305_dec_vectors[i].input,
|
||||
+ chacha20poly1305_dec_vectors[i].ilen);
|
||||
+ sg_init_one(&sg_src, heap_src,
|
||||
+ chacha20poly1305_dec_vectors[i].ilen);
|
||||
+ ret = chacha20poly1305_decrypt_sg_inplace(&sg_src,
|
||||
+ chacha20poly1305_dec_vectors[i].ilen,
|
||||
+ chacha20poly1305_dec_vectors[i].assoc,
|
||||
+ chacha20poly1305_dec_vectors[i].alen,
|
||||
+ get_unaligned_le64(chacha20poly1305_dec_vectors[i].nonce),
|
||||
+ chacha20poly1305_dec_vectors[i].key);
|
||||
+ if (!decryption_success(ret,
|
||||
+ chacha20poly1305_dec_vectors[i].failure,
|
||||
+ memcmp(heap_src, chacha20poly1305_dec_vectors[i].output,
|
||||
+ chacha20poly1305_dec_vectors[i].ilen -
|
||||
+ POLY1305_DIGEST_SIZE))) {
|
||||
+ pr_err("chacha20poly1305 sg decryption self-test %zu: FAIL\n",
|
||||
+ i + 1);
|
||||
+ success = false;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(xchacha20poly1305_enc_vectors); ++i) {
|
||||
memset(computed_output, 0, MAXIMUM_TEST_BUFFER_LEN);
|
||||
--- a/lib/crypto/chacha20poly1305.c
|
||||
+++ b/lib/crypto/chacha20poly1305.c
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <crypto/chacha20poly1305.h>
|
||||
#include <crypto/chacha.h>
|
||||
#include <crypto/poly1305.h>
|
||||
+#include <crypto/scatterwalk.h>
|
||||
|
||||
#include <asm/unaligned.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -205,6 +206,155 @@ bool xchacha20poly1305_decrypt(u8 *dst,
|
||||
}
|
||||
EXPORT_SYMBOL(xchacha20poly1305_decrypt);
|
||||
|
||||
+static
|
||||
+bool chacha20poly1305_crypt_sg_inplace(struct scatterlist *src,
|
||||
+ const size_t src_len,
|
||||
+ const u8 *ad, const size_t ad_len,
|
||||
+ const u64 nonce,
|
||||
+ const u8 key[CHACHA20POLY1305_KEY_SIZE],
|
||||
+ int encrypt)
|
||||
+{
|
||||
+ const u8 *pad0 = page_address(ZERO_PAGE(0));
|
||||
+ struct poly1305_desc_ctx poly1305_state;
|
||||
+ u32 chacha_state[CHACHA_STATE_WORDS];
|
||||
+ struct sg_mapping_iter miter;
|
||||
+ size_t partial = 0;
|
||||
+ unsigned int flags;
|
||||
+ bool ret = true;
|
||||
+ int sl;
|
||||
+ union {
|
||||
+ struct {
|
||||
+ u32 k[CHACHA_KEY_WORDS];
|
||||
+ __le64 iv[2];
|
||||
+ };
|
||||
+ u8 block0[POLY1305_KEY_SIZE];
|
||||
+ u8 chacha_stream[CHACHA_BLOCK_SIZE];
|
||||
+ struct {
|
||||
+ u8 mac[2][POLY1305_DIGEST_SIZE];
|
||||
+ };
|
||||
+ __le64 lens[2];
|
||||
+ } b __aligned(16);
|
||||
+
|
||||
+ chacha_load_key(b.k, key);
|
||||
+
|
||||
+ b.iv[0] = 0;
|
||||
+ b.iv[1] = cpu_to_le64(nonce);
|
||||
+
|
||||
+ chacha_init(chacha_state, b.k, (u8 *)b.iv);
|
||||
+ chacha_crypt(chacha_state, b.block0, pad0, sizeof(b.block0), 20);
|
||||
+ poly1305_init(&poly1305_state, b.block0);
|
||||
+
|
||||
+ if (unlikely(ad_len)) {
|
||||
+ poly1305_update(&poly1305_state, ad, ad_len);
|
||||
+ if (ad_len & 0xf)
|
||||
+ poly1305_update(&poly1305_state, pad0, 0x10 - (ad_len & 0xf));
|
||||
+ }
|
||||
+
|
||||
+ flags = SG_MITER_TO_SG;
|
||||
+ if (!preemptible())
|
||||
+ flags |= SG_MITER_ATOMIC;
|
||||
+
|
||||
+ sg_miter_start(&miter, src, sg_nents(src), flags);
|
||||
+
|
||||
+ for (sl = src_len; sl > 0 && sg_miter_next(&miter); sl -= miter.length) {
|
||||
+ u8 *addr = miter.addr;
|
||||
+ size_t length = min_t(size_t, sl, miter.length);
|
||||
+
|
||||
+ if (!encrypt)
|
||||
+ poly1305_update(&poly1305_state, addr, length);
|
||||
+
|
||||
+ if (unlikely(partial)) {
|
||||
+ size_t l = min(length, CHACHA_BLOCK_SIZE - partial);
|
||||
+
|
||||
+ crypto_xor(addr, b.chacha_stream + partial, l);
|
||||
+ partial = (partial + l) & (CHACHA_BLOCK_SIZE - 1);
|
||||
+
|
||||
+ addr += l;
|
||||
+ length -= l;
|
||||
+ }
|
||||
+
|
||||
+ if (likely(length >= CHACHA_BLOCK_SIZE || length == sl)) {
|
||||
+ size_t l = length;
|
||||
+
|
||||
+ if (unlikely(length < sl))
|
||||
+ l &= ~(CHACHA_BLOCK_SIZE - 1);
|
||||
+ chacha_crypt(chacha_state, addr, addr, l, 20);
|
||||
+ addr += l;
|
||||
+ length -= l;
|
||||
+ }
|
||||
+
|
||||
+ if (unlikely(length > 0)) {
|
||||
+ chacha_crypt(chacha_state, b.chacha_stream, pad0,
|
||||
+ CHACHA_BLOCK_SIZE, 20);
|
||||
+ crypto_xor(addr, b.chacha_stream, length);
|
||||
+ partial = length;
|
||||
+ }
|
||||
+
|
||||
+ if (encrypt)
|
||||
+ poly1305_update(&poly1305_state, miter.addr,
|
||||
+ min_t(size_t, sl, miter.length));
|
||||
+ }
|
||||
+
|
||||
+ if (src_len & 0xf)
|
||||
+ poly1305_update(&poly1305_state, pad0, 0x10 - (src_len & 0xf));
|
||||
+
|
||||
+ b.lens[0] = cpu_to_le64(ad_len);
|
||||
+ b.lens[1] = cpu_to_le64(src_len);
|
||||
+ poly1305_update(&poly1305_state, (u8 *)b.lens, sizeof(b.lens));
|
||||
+
|
||||
+ if (likely(sl <= -POLY1305_DIGEST_SIZE)) {
|
||||
+ if (encrypt) {
|
||||
+ poly1305_final(&poly1305_state,
|
||||
+ miter.addr + miter.length + sl);
|
||||
+ ret = true;
|
||||
+ } else {
|
||||
+ poly1305_final(&poly1305_state, b.mac[0]);
|
||||
+ ret = !crypto_memneq(b.mac[0],
|
||||
+ miter.addr + miter.length + sl,
|
||||
+ POLY1305_DIGEST_SIZE);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ sg_miter_stop(&miter);
|
||||
+
|
||||
+ if (unlikely(sl > -POLY1305_DIGEST_SIZE)) {
|
||||
+ poly1305_final(&poly1305_state, b.mac[1]);
|
||||
+ scatterwalk_map_and_copy(b.mac[encrypt], src, src_len,
|
||||
+ sizeof(b.mac[1]), encrypt);
|
||||
+ ret = encrypt ||
|
||||
+ !crypto_memneq(b.mac[0], b.mac[1], POLY1305_DIGEST_SIZE);
|
||||
+ }
|
||||
+
|
||||
+ memzero_explicit(chacha_state, sizeof(chacha_state));
|
||||
+ memzero_explicit(&b, sizeof(b));
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+bool chacha20poly1305_encrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
+ const u8 *ad, const size_t ad_len,
|
||||
+ const u64 nonce,
|
||||
+ const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
+{
|
||||
+ return chacha20poly1305_crypt_sg_inplace(src, src_len, ad, ad_len,
|
||||
+ nonce, key, 1);
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha20poly1305_encrypt_sg_inplace);
|
||||
+
|
||||
+bool chacha20poly1305_decrypt_sg_inplace(struct scatterlist *src, size_t src_len,
|
||||
+ const u8 *ad, const size_t ad_len,
|
||||
+ const u64 nonce,
|
||||
+ const u8 key[CHACHA20POLY1305_KEY_SIZE])
|
||||
+{
|
||||
+ if (unlikely(src_len < POLY1305_DIGEST_SIZE))
|
||||
+ return false;
|
||||
+
|
||||
+ return chacha20poly1305_crypt_sg_inplace(src,
|
||||
+ src_len - POLY1305_DIGEST_SIZE,
|
||||
+ ad, ad_len, nonce, key, 0);
|
||||
+}
|
||||
+EXPORT_SYMBOL(chacha20poly1305_decrypt_sg_inplace);
|
||||
+
|
||||
static int __init mod_init(void)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS) &&
|
||||
@@ -1,68 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Biggers <ebiggers@google.com>
|
||||
Date: Sun, 17 Nov 2019 23:21:29 -0800
|
||||
Subject: [PATCH] crypto: chacha_generic - remove unnecessary setkey()
|
||||
functions
|
||||
|
||||
commit 2043323a799a660bc84bbee404cf7a2617ec6157 upstream.
|
||||
|
||||
Use chacha20_setkey() and chacha12_setkey() from
|
||||
<crypto/internal/chacha.h> instead of defining them again in
|
||||
chacha_generic.c.
|
||||
|
||||
Signed-off-by: Eric Biggers <ebiggers@google.com>
|
||||
Acked-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/chacha_generic.c | 18 +++---------------
|
||||
1 file changed, 3 insertions(+), 15 deletions(-)
|
||||
|
||||
--- a/crypto/chacha_generic.c
|
||||
+++ b/crypto/chacha_generic.c
|
||||
@@ -37,18 +37,6 @@ static int chacha_stream_xor(struct skci
|
||||
return err;
|
||||
}
|
||||
|
||||
-static int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize)
|
||||
-{
|
||||
- return chacha_setkey(tfm, key, keysize, 20);
|
||||
-}
|
||||
-
|
||||
-static int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
- unsigned int keysize)
|
||||
-{
|
||||
- return chacha_setkey(tfm, key, keysize, 12);
|
||||
-}
|
||||
-
|
||||
static int crypto_chacha_crypt(struct skcipher_request *req)
|
||||
{
|
||||
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
|
||||
@@ -91,7 +79,7 @@ static struct skcipher_alg algs[] = {
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = CHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
+ .setkey = chacha20_setkey,
|
||||
.encrypt = crypto_chacha_crypt,
|
||||
.decrypt = crypto_chacha_crypt,
|
||||
}, {
|
||||
@@ -106,7 +94,7 @@ static struct skcipher_alg algs[] = {
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha20_setkey,
|
||||
+ .setkey = chacha20_setkey,
|
||||
.encrypt = crypto_xchacha_crypt,
|
||||
.decrypt = crypto_xchacha_crypt,
|
||||
}, {
|
||||
@@ -121,7 +109,7 @@ static struct skcipher_alg algs[] = {
|
||||
.max_keysize = CHACHA_KEY_SIZE,
|
||||
.ivsize = XCHACHA_IV_SIZE,
|
||||
.chunksize = CHACHA_BLOCK_SIZE,
|
||||
- .setkey = crypto_chacha12_setkey,
|
||||
+ .setkey = chacha12_setkey,
|
||||
.encrypt = crypto_xchacha_crypt,
|
||||
.decrypt = crypto_xchacha_crypt,
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Biggers <ebiggers@google.com>
|
||||
Date: Sun, 17 Nov 2019 23:21:58 -0800
|
||||
Subject: [PATCH] crypto: x86/chacha - only unregister algorithms if registered
|
||||
|
||||
commit b62755aed3a3f5ca9edd2718339ccea3b6bbbe57 upstream.
|
||||
|
||||
It's not valid to call crypto_unregister_skciphers() without a prior
|
||||
call to crypto_register_skciphers().
|
||||
|
||||
Fixes: 84e03fa39fbe ("crypto: x86/chacha - expose SIMD ChaCha routine as library function")
|
||||
Signed-off-by: Eric Biggers <ebiggers@google.com>
|
||||
Acked-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/chacha_glue.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/arch/x86/crypto/chacha_glue.c
|
||||
+++ b/arch/x86/crypto/chacha_glue.c
|
||||
@@ -304,7 +304,8 @@ static int __init chacha_simd_mod_init(v
|
||||
|
||||
static void __exit chacha_simd_mod_fini(void)
|
||||
{
|
||||
- crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+ if (boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
+ crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
module_init(chacha_simd_mod_init);
|
||||
@@ -1,83 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Biggers <ebiggers@google.com>
|
||||
Date: Sun, 17 Nov 2019 23:22:16 -0800
|
||||
Subject: [PATCH] crypto: lib/chacha20poly1305 - use chacha20_crypt()
|
||||
|
||||
commit 413808b71e6204b0cc1eeaa77960f7c3cd381d33 upstream.
|
||||
|
||||
Use chacha20_crypt() instead of chacha_crypt(), since it's not really
|
||||
appropriate for users of the ChaCha library API to be passing the number
|
||||
of rounds as an argument.
|
||||
|
||||
Signed-off-by: Eric Biggers <ebiggers@google.com>
|
||||
Acked-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
lib/crypto/chacha20poly1305.c | 16 ++++++++--------
|
||||
1 file changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/lib/crypto/chacha20poly1305.c
|
||||
+++ b/lib/crypto/chacha20poly1305.c
|
||||
@@ -66,14 +66,14 @@ __chacha20poly1305_encrypt(u8 *dst, cons
|
||||
__le64 lens[2];
|
||||
} b;
|
||||
|
||||
- chacha_crypt(chacha_state, b.block0, pad0, sizeof(b.block0), 20);
|
||||
+ chacha20_crypt(chacha_state, b.block0, pad0, sizeof(b.block0));
|
||||
poly1305_init(&poly1305_state, b.block0);
|
||||
|
||||
poly1305_update(&poly1305_state, ad, ad_len);
|
||||
if (ad_len & 0xf)
|
||||
poly1305_update(&poly1305_state, pad0, 0x10 - (ad_len & 0xf));
|
||||
|
||||
- chacha_crypt(chacha_state, dst, src, src_len, 20);
|
||||
+ chacha20_crypt(chacha_state, dst, src, src_len);
|
||||
|
||||
poly1305_update(&poly1305_state, dst, src_len);
|
||||
if (src_len & 0xf)
|
||||
@@ -140,7 +140,7 @@ __chacha20poly1305_decrypt(u8 *dst, cons
|
||||
if (unlikely(src_len < POLY1305_DIGEST_SIZE))
|
||||
return false;
|
||||
|
||||
- chacha_crypt(chacha_state, b.block0, pad0, sizeof(b.block0), 20);
|
||||
+ chacha20_crypt(chacha_state, b.block0, pad0, sizeof(b.block0));
|
||||
poly1305_init(&poly1305_state, b.block0);
|
||||
|
||||
poly1305_update(&poly1305_state, ad, ad_len);
|
||||
@@ -160,7 +160,7 @@ __chacha20poly1305_decrypt(u8 *dst, cons
|
||||
|
||||
ret = crypto_memneq(b.mac, src + dst_len, POLY1305_DIGEST_SIZE);
|
||||
if (likely(!ret))
|
||||
- chacha_crypt(chacha_state, dst, src, dst_len, 20);
|
||||
+ chacha20_crypt(chacha_state, dst, src, dst_len);
|
||||
|
||||
memzero_explicit(&b, sizeof(b));
|
||||
|
||||
@@ -241,7 +241,7 @@ bool chacha20poly1305_crypt_sg_inplace(s
|
||||
b.iv[1] = cpu_to_le64(nonce);
|
||||
|
||||
chacha_init(chacha_state, b.k, (u8 *)b.iv);
|
||||
- chacha_crypt(chacha_state, b.block0, pad0, sizeof(b.block0), 20);
|
||||
+ chacha20_crypt(chacha_state, b.block0, pad0, sizeof(b.block0));
|
||||
poly1305_init(&poly1305_state, b.block0);
|
||||
|
||||
if (unlikely(ad_len)) {
|
||||
@@ -278,14 +278,14 @@ bool chacha20poly1305_crypt_sg_inplace(s
|
||||
|
||||
if (unlikely(length < sl))
|
||||
l &= ~(CHACHA_BLOCK_SIZE - 1);
|
||||
- chacha_crypt(chacha_state, addr, addr, l, 20);
|
||||
+ chacha20_crypt(chacha_state, addr, addr, l);
|
||||
addr += l;
|
||||
length -= l;
|
||||
}
|
||||
|
||||
if (unlikely(length > 0)) {
|
||||
- chacha_crypt(chacha_state, b.chacha_stream, pad0,
|
||||
- CHACHA_BLOCK_SIZE, 20);
|
||||
+ chacha20_crypt(chacha_state, b.chacha_stream, pad0,
|
||||
+ CHACHA_BLOCK_SIZE);
|
||||
crypto_xor(addr, b.chacha_stream, length);
|
||||
partial = length;
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Mon, 25 Nov 2019 11:31:12 +0100
|
||||
Subject: [PATCH] crypto: arch - conditionalize crypto api in arch glue for lib
|
||||
code
|
||||
|
||||
commit 8394bfec51e0e565556101bcc4e2fe7551104cd8 upstream.
|
||||
|
||||
For glue code that's used by Zinc, the actual Crypto API functions might
|
||||
not necessarily exist, and don't need to exist either. Before this
|
||||
patch, there are valid build configurations that lead to a unbuildable
|
||||
kernel. This fixes it to conditionalize those symbols on the existence
|
||||
of the proper config entry.
|
||||
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Acked-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/chacha-glue.c | 26 ++++++++++++++++----------
|
||||
arch/arm/crypto/curve25519-glue.c | 5 +++--
|
||||
arch/arm/crypto/poly1305-glue.c | 9 ++++++---
|
||||
arch/arm64/crypto/chacha-neon-glue.c | 5 +++--
|
||||
arch/arm64/crypto/poly1305-glue.c | 5 +++--
|
||||
arch/mips/crypto/chacha-glue.c | 6 ++++--
|
||||
arch/mips/crypto/poly1305-glue.c | 6 ++++--
|
||||
arch/x86/crypto/blake2s-glue.c | 6 ++++--
|
||||
arch/x86/crypto/chacha_glue.c | 5 +++--
|
||||
arch/x86/crypto/curve25519-x86_64.c | 7 ++++---
|
||||
arch/x86/crypto/poly1305_glue.c | 5 +++--
|
||||
11 files changed, 53 insertions(+), 32 deletions(-)
|
||||
|
||||
--- a/arch/arm/crypto/chacha-glue.c
|
||||
+++ b/arch/arm/crypto/chacha-glue.c
|
||||
@@ -286,11 +286,13 @@ static struct skcipher_alg neon_algs[] =
|
||||
|
||||
static int __init chacha_simd_mod_init(void)
|
||||
{
|
||||
- int err;
|
||||
+ int err = 0;
|
||||
|
||||
- err = crypto_register_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
- if (err)
|
||||
- return err;
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER)) {
|
||||
+ err = crypto_register_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+ }
|
||||
|
||||
if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && (elf_hwcap & HWCAP_NEON)) {
|
||||
int i;
|
||||
@@ -310,18 +312,22 @@ static int __init chacha_simd_mod_init(v
|
||||
static_branch_enable(&use_neon);
|
||||
}
|
||||
|
||||
- err = crypto_register_skciphers(neon_algs, ARRAY_SIZE(neon_algs));
|
||||
- if (err)
|
||||
- crypto_unregister_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER)) {
|
||||
+ err = crypto_register_skciphers(neon_algs, ARRAY_SIZE(neon_algs));
|
||||
+ if (err)
|
||||
+ crypto_unregister_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
+ }
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
static void __exit chacha_simd_mod_fini(void)
|
||||
{
|
||||
- crypto_unregister_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
- if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && (elf_hwcap & HWCAP_NEON))
|
||||
- crypto_unregister_skciphers(neon_algs, ARRAY_SIZE(neon_algs));
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER)) {
|
||||
+ crypto_unregister_skciphers(arm_algs, ARRAY_SIZE(arm_algs));
|
||||
+ if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && (elf_hwcap & HWCAP_NEON))
|
||||
+ crypto_unregister_skciphers(neon_algs, ARRAY_SIZE(neon_algs));
|
||||
+ }
|
||||
}
|
||||
|
||||
module_init(chacha_simd_mod_init);
|
||||
--- a/arch/arm/crypto/curve25519-glue.c
|
||||
+++ b/arch/arm/crypto/curve25519-glue.c
|
||||
@@ -108,14 +108,15 @@ static int __init mod_init(void)
|
||||
{
|
||||
if (elf_hwcap & HWCAP_NEON) {
|
||||
static_branch_enable(&have_neon);
|
||||
- return crypto_register_kpp(&curve25519_alg);
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_KPP) ?
|
||||
+ crypto_register_kpp(&curve25519_alg) : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit mod_exit(void)
|
||||
{
|
||||
- if (elf_hwcap & HWCAP_NEON)
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_KPP) && elf_hwcap & HWCAP_NEON)
|
||||
crypto_unregister_kpp(&curve25519_alg);
|
||||
}
|
||||
|
||||
--- a/arch/arm/crypto/poly1305-glue.c
|
||||
+++ b/arch/arm/crypto/poly1305-glue.c
|
||||
@@ -249,16 +249,19 @@ static int __init arm_poly1305_mod_init(
|
||||
if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) &&
|
||||
(elf_hwcap & HWCAP_NEON))
|
||||
static_branch_enable(&have_neon);
|
||||
- else
|
||||
+ else if (IS_REACHABLE(CONFIG_CRYPTO_HASH))
|
||||
/* register only the first entry */
|
||||
return crypto_register_shash(&arm_poly1305_algs[0]);
|
||||
|
||||
- return crypto_register_shashes(arm_poly1305_algs,
|
||||
- ARRAY_SIZE(arm_poly1305_algs));
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_HASH) ?
|
||||
+ crypto_register_shashes(arm_poly1305_algs,
|
||||
+ ARRAY_SIZE(arm_poly1305_algs)) : 0;
|
||||
}
|
||||
|
||||
static void __exit arm_poly1305_mod_exit(void)
|
||||
{
|
||||
+ if (!IS_REACHABLE(CONFIG_CRYPTO_HASH))
|
||||
+ return;
|
||||
if (!static_branch_likely(&have_neon)) {
|
||||
crypto_unregister_shash(&arm_poly1305_algs[0]);
|
||||
return;
|
||||
--- a/arch/arm64/crypto/chacha-neon-glue.c
|
||||
+++ b/arch/arm64/crypto/chacha-neon-glue.c
|
||||
@@ -211,12 +211,13 @@ static int __init chacha_simd_mod_init(v
|
||||
|
||||
static_branch_enable(&have_neon);
|
||||
|
||||
- return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) ?
|
||||
+ crypto_register_skciphers(algs, ARRAY_SIZE(algs)) : 0;
|
||||
}
|
||||
|
||||
static void __exit chacha_simd_mod_fini(void)
|
||||
{
|
||||
- if (cpu_have_named_feature(ASIMD))
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) && cpu_have_named_feature(ASIMD))
|
||||
crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
--- a/arch/arm64/crypto/poly1305-glue.c
|
||||
+++ b/arch/arm64/crypto/poly1305-glue.c
|
||||
@@ -220,12 +220,13 @@ static int __init neon_poly1305_mod_init
|
||||
|
||||
static_branch_enable(&have_neon);
|
||||
|
||||
- return crypto_register_shash(&neon_poly1305_alg);
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_HASH) ?
|
||||
+ crypto_register_shash(&neon_poly1305_alg) : 0;
|
||||
}
|
||||
|
||||
static void __exit neon_poly1305_mod_exit(void)
|
||||
{
|
||||
- if (cpu_have_named_feature(ASIMD))
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_HASH) && cpu_have_named_feature(ASIMD))
|
||||
crypto_unregister_shash(&neon_poly1305_alg);
|
||||
}
|
||||
|
||||
--- a/arch/mips/crypto/chacha-glue.c
|
||||
+++ b/arch/mips/crypto/chacha-glue.c
|
||||
@@ -128,12 +128,14 @@ static struct skcipher_alg algs[] = {
|
||||
|
||||
static int __init chacha_simd_mod_init(void)
|
||||
{
|
||||
- return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) ?
|
||||
+ crypto_register_skciphers(algs, ARRAY_SIZE(algs)) : 0;
|
||||
}
|
||||
|
||||
static void __exit chacha_simd_mod_fini(void)
|
||||
{
|
||||
- crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER))
|
||||
+ crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
module_init(chacha_simd_mod_init);
|
||||
--- a/arch/mips/crypto/poly1305-glue.c
|
||||
+++ b/arch/mips/crypto/poly1305-glue.c
|
||||
@@ -187,12 +187,14 @@ static struct shash_alg mips_poly1305_al
|
||||
|
||||
static int __init mips_poly1305_mod_init(void)
|
||||
{
|
||||
- return crypto_register_shash(&mips_poly1305_alg);
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_HASH) ?
|
||||
+ crypto_register_shash(&mips_poly1305_alg) : 0;
|
||||
}
|
||||
|
||||
static void __exit mips_poly1305_mod_exit(void)
|
||||
{
|
||||
- crypto_unregister_shash(&mips_poly1305_alg);
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_HASH))
|
||||
+ crypto_unregister_shash(&mips_poly1305_alg);
|
||||
}
|
||||
|
||||
module_init(mips_poly1305_mod_init);
|
||||
--- a/arch/x86/crypto/blake2s-glue.c
|
||||
+++ b/arch/x86/crypto/blake2s-glue.c
|
||||
@@ -210,12 +210,14 @@ static int __init blake2s_mod_init(void)
|
||||
XFEATURE_MASK_AVX512, NULL))
|
||||
static_branch_enable(&blake2s_use_avx512);
|
||||
|
||||
- return crypto_register_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_HASH) ?
|
||||
+ crypto_register_shashes(blake2s_algs,
|
||||
+ ARRAY_SIZE(blake2s_algs)) : 0;
|
||||
}
|
||||
|
||||
static void __exit blake2s_mod_exit(void)
|
||||
{
|
||||
- if (boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_HASH) && boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
crypto_unregister_shashes(blake2s_algs, ARRAY_SIZE(blake2s_algs));
|
||||
}
|
||||
|
||||
--- a/arch/x86/crypto/chacha_glue.c
|
||||
+++ b/arch/x86/crypto/chacha_glue.c
|
||||
@@ -299,12 +299,13 @@ static int __init chacha_simd_mod_init(v
|
||||
boot_cpu_has(X86_FEATURE_AVX512BW)) /* kmovq */
|
||||
static_branch_enable(&chacha_use_avx512vl);
|
||||
}
|
||||
- return crypto_register_skciphers(algs, ARRAY_SIZE(algs));
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) ?
|
||||
+ crypto_register_skciphers(algs, ARRAY_SIZE(algs)) : 0;
|
||||
}
|
||||
|
||||
static void __exit chacha_simd_mod_fini(void)
|
||||
{
|
||||
- if (boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_BLKCIPHER) && boot_cpu_has(X86_FEATURE_SSSE3))
|
||||
crypto_unregister_skciphers(algs, ARRAY_SIZE(algs));
|
||||
}
|
||||
|
||||
--- a/arch/x86/crypto/curve25519-x86_64.c
|
||||
+++ b/arch/x86/crypto/curve25519-x86_64.c
|
||||
@@ -2457,13 +2457,14 @@ static int __init curve25519_mod_init(vo
|
||||
static_branch_enable(&curve25519_use_adx);
|
||||
else
|
||||
return 0;
|
||||
- return crypto_register_kpp(&curve25519_alg);
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_KPP) ?
|
||||
+ crypto_register_kpp(&curve25519_alg) : 0;
|
||||
}
|
||||
|
||||
static void __exit curve25519_mod_exit(void)
|
||||
{
|
||||
- if (boot_cpu_has(X86_FEATURE_BMI2) ||
|
||||
- boot_cpu_has(X86_FEATURE_ADX))
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_KPP) &&
|
||||
+ (boot_cpu_has(X86_FEATURE_BMI2) || boot_cpu_has(X86_FEATURE_ADX)))
|
||||
crypto_unregister_kpp(&curve25519_alg);
|
||||
}
|
||||
|
||||
--- a/arch/x86/crypto/poly1305_glue.c
|
||||
+++ b/arch/x86/crypto/poly1305_glue.c
|
||||
@@ -224,12 +224,13 @@ static int __init poly1305_simd_mod_init
|
||||
cpu_has_xfeatures(XFEATURE_MASK_SSE | XFEATURE_MASK_YMM, NULL))
|
||||
static_branch_enable(&poly1305_use_avx2);
|
||||
|
||||
- return crypto_register_shash(&alg);
|
||||
+ return IS_REACHABLE(CONFIG_CRYPTO_HASH) ? crypto_register_shash(&alg) : 0;
|
||||
}
|
||||
|
||||
static void __exit poly1305_simd_mod_exit(void)
|
||||
{
|
||||
- crypto_unregister_shash(&alg);
|
||||
+ if (IS_REACHABLE(CONFIG_CRYPTO_HASH))
|
||||
+ crypto_unregister_shash(&alg);
|
||||
}
|
||||
|
||||
module_init(poly1305_simd_mod_init);
|
||||
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Valdis=20Kl=C4=93tnieks?= <valdis.kletnieks@vt.edu>
|
||||
Date: Thu, 5 Dec 2019 20:58:36 -0500
|
||||
Subject: [PATCH] crypto: chacha - fix warning message in header file
|
||||
|
||||
commit 579d705cd64e44f3fcda1a6cfd5f37468a5ddf63 upstream.
|
||||
|
||||
Building with W=1 causes a warning:
|
||||
|
||||
CC [M] arch/x86/crypto/chacha_glue.o
|
||||
In file included from arch/x86/crypto/chacha_glue.c:10:
|
||||
./include/crypto/internal/chacha.h:37:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]
|
||||
37 | static int inline chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
| ^~~~~~
|
||||
|
||||
Straighten out the order to match the rest of the header file.
|
||||
|
||||
Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
include/crypto/internal/chacha.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/include/crypto/internal/chacha.h
|
||||
+++ b/include/crypto/internal/chacha.h
|
||||
@@ -34,7 +34,7 @@ static inline int chacha20_setkey(struct
|
||||
return chacha_setkey(tfm, key, keysize, 20);
|
||||
}
|
||||
|
||||
-static int inline chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
+static inline int chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
|
||||
unsigned int keysize)
|
||||
{
|
||||
return chacha_setkey(tfm, key, keysize, 12);
|
||||
@@ -1,38 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Wed, 11 Dec 2019 10:26:39 +0100
|
||||
Subject: [PATCH] crypto: arm/curve25519 - add arch-specific key generation
|
||||
function
|
||||
|
||||
commit 84faa307249b341f6ad8de3e1869d77a65e26669 upstream.
|
||||
|
||||
Somehow this was forgotten when Zinc was being split into oddly shaped
|
||||
pieces, resulting in linker errors. The x86_64 glue has a specific key
|
||||
generation implementation, but the Arm one does not. However, it can
|
||||
still receive the NEON speedups by calling the ordinary DH function
|
||||
using the base point.
|
||||
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Acked-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/curve25519-glue.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
--- a/arch/arm/crypto/curve25519-glue.c
|
||||
+++ b/arch/arm/crypto/curve25519-glue.c
|
||||
@@ -38,6 +38,13 @@ void curve25519_arch(u8 out[CURVE25519_K
|
||||
}
|
||||
EXPORT_SYMBOL(curve25519_arch);
|
||||
|
||||
+void curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE],
|
||||
+ const u8 secret[CURVE25519_KEY_SIZE])
|
||||
+{
|
||||
+ return curve25519_arch(pub, secret, curve25519_base_point);
|
||||
+}
|
||||
+EXPORT_SYMBOL(curve25519_base_arch);
|
||||
+
|
||||
static int curve25519_set_secret(struct crypto_kpp *tfm, const void *buf,
|
||||
unsigned int len)
|
||||
{
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,171 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Sun, 5 Jan 2020 22:40:49 -0500
|
||||
Subject: [PATCH] crypto: {arm,arm64,mips}/poly1305 - remove redundant
|
||||
non-reduction from emit
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
commit 31899908a0d248b030b4464425b86c717e0007d4 upstream.
|
||||
|
||||
This appears to be some kind of copy and paste error, and is actually
|
||||
dead code.
|
||||
|
||||
Pre: f = 0 ⇒ (f >> 32) = 0
|
||||
f = (f >> 32) + le32_to_cpu(digest[0]);
|
||||
Post: 0 ≤ f < 2³²
|
||||
put_unaligned_le32(f, dst);
|
||||
|
||||
Pre: 0 ≤ f < 2³² ⇒ (f >> 32) = 0
|
||||
f = (f >> 32) + le32_to_cpu(digest[1]);
|
||||
Post: 0 ≤ f < 2³²
|
||||
put_unaligned_le32(f, dst + 4);
|
||||
|
||||
Pre: 0 ≤ f < 2³² ⇒ (f >> 32) = 0
|
||||
f = (f >> 32) + le32_to_cpu(digest[2]);
|
||||
Post: 0 ≤ f < 2³²
|
||||
put_unaligned_le32(f, dst + 8);
|
||||
|
||||
Pre: 0 ≤ f < 2³² ⇒ (f >> 32) = 0
|
||||
f = (f >> 32) + le32_to_cpu(digest[3]);
|
||||
Post: 0 ≤ f < 2³²
|
||||
put_unaligned_le32(f, dst + 12);
|
||||
|
||||
Therefore this sequence is redundant. And Andy's code appears to handle
|
||||
misalignment acceptably.
|
||||
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Tested-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/poly1305-glue.c | 18 ++----------------
|
||||
arch/arm64/crypto/poly1305-glue.c | 18 ++----------------
|
||||
arch/mips/crypto/poly1305-glue.c | 18 ++----------------
|
||||
3 files changed, 6 insertions(+), 48 deletions(-)
|
||||
|
||||
--- a/arch/arm/crypto/poly1305-glue.c
|
||||
+++ b/arch/arm/crypto/poly1305-glue.c
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
void poly1305_init_arm(void *state, const u8 *key);
|
||||
void poly1305_blocks_arm(void *state, const u8 *src, u32 len, u32 hibit);
|
||||
-void poly1305_emit_arm(void *state, __le32 *digest, const u32 *nonce);
|
||||
+void poly1305_emit_arm(void *state, u8 *digest, const u32 *nonce);
|
||||
|
||||
void __weak poly1305_blocks_neon(void *state, const u8 *src, u32 len, u32 hibit)
|
||||
{
|
||||
@@ -179,9 +179,6 @@ EXPORT_SYMBOL(poly1305_update_arch);
|
||||
|
||||
void poly1305_final_arch(struct poly1305_desc_ctx *dctx, u8 *dst)
|
||||
{
|
||||
- __le32 digest[4];
|
||||
- u64 f = 0;
|
||||
-
|
||||
if (unlikely(dctx->buflen)) {
|
||||
dctx->buf[dctx->buflen++] = 1;
|
||||
memset(dctx->buf + dctx->buflen, 0,
|
||||
@@ -189,18 +186,7 @@ void poly1305_final_arch(struct poly1305
|
||||
poly1305_blocks_arm(&dctx->h, dctx->buf, POLY1305_BLOCK_SIZE, 0);
|
||||
}
|
||||
|
||||
- poly1305_emit_arm(&dctx->h, digest, dctx->s);
|
||||
-
|
||||
- /* mac = (h + s) % (2^128) */
|
||||
- f = (f >> 32) + le32_to_cpu(digest[0]);
|
||||
- put_unaligned_le32(f, dst);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[1]);
|
||||
- put_unaligned_le32(f, dst + 4);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[2]);
|
||||
- put_unaligned_le32(f, dst + 8);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[3]);
|
||||
- put_unaligned_le32(f, dst + 12);
|
||||
-
|
||||
+ poly1305_emit_arm(&dctx->h, dst, dctx->s);
|
||||
*dctx = (struct poly1305_desc_ctx){};
|
||||
}
|
||||
EXPORT_SYMBOL(poly1305_final_arch);
|
||||
--- a/arch/arm64/crypto/poly1305-glue.c
|
||||
+++ b/arch/arm64/crypto/poly1305-glue.c
|
||||
@@ -21,7 +21,7 @@
|
||||
asmlinkage void poly1305_init_arm64(void *state, const u8 *key);
|
||||
asmlinkage void poly1305_blocks(void *state, const u8 *src, u32 len, u32 hibit);
|
||||
asmlinkage void poly1305_blocks_neon(void *state, const u8 *src, u32 len, u32 hibit);
|
||||
-asmlinkage void poly1305_emit(void *state, __le32 *digest, const u32 *nonce);
|
||||
+asmlinkage void poly1305_emit(void *state, u8 *digest, const u32 *nonce);
|
||||
|
||||
static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_neon);
|
||||
|
||||
@@ -162,9 +162,6 @@ EXPORT_SYMBOL(poly1305_update_arch);
|
||||
|
||||
void poly1305_final_arch(struct poly1305_desc_ctx *dctx, u8 *dst)
|
||||
{
|
||||
- __le32 digest[4];
|
||||
- u64 f = 0;
|
||||
-
|
||||
if (unlikely(dctx->buflen)) {
|
||||
dctx->buf[dctx->buflen++] = 1;
|
||||
memset(dctx->buf + dctx->buflen, 0,
|
||||
@@ -172,18 +169,7 @@ void poly1305_final_arch(struct poly1305
|
||||
poly1305_blocks(&dctx->h, dctx->buf, POLY1305_BLOCK_SIZE, 0);
|
||||
}
|
||||
|
||||
- poly1305_emit(&dctx->h, digest, dctx->s);
|
||||
-
|
||||
- /* mac = (h + s) % (2^128) */
|
||||
- f = (f >> 32) + le32_to_cpu(digest[0]);
|
||||
- put_unaligned_le32(f, dst);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[1]);
|
||||
- put_unaligned_le32(f, dst + 4);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[2]);
|
||||
- put_unaligned_le32(f, dst + 8);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[3]);
|
||||
- put_unaligned_le32(f, dst + 12);
|
||||
-
|
||||
+ poly1305_emit(&dctx->h, dst, dctx->s);
|
||||
*dctx = (struct poly1305_desc_ctx){};
|
||||
}
|
||||
EXPORT_SYMBOL(poly1305_final_arch);
|
||||
--- a/arch/mips/crypto/poly1305-glue.c
|
||||
+++ b/arch/mips/crypto/poly1305-glue.c
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
asmlinkage void poly1305_init_mips(void *state, const u8 *key);
|
||||
asmlinkage void poly1305_blocks_mips(void *state, const u8 *src, u32 len, u32 hibit);
|
||||
-asmlinkage void poly1305_emit_mips(void *state, __le32 *digest, const u32 *nonce);
|
||||
+asmlinkage void poly1305_emit_mips(void *state, u8 *digest, const u32 *nonce);
|
||||
|
||||
void poly1305_init_arch(struct poly1305_desc_ctx *dctx, const u8 *key)
|
||||
{
|
||||
@@ -134,9 +134,6 @@ EXPORT_SYMBOL(poly1305_update_arch);
|
||||
|
||||
void poly1305_final_arch(struct poly1305_desc_ctx *dctx, u8 *dst)
|
||||
{
|
||||
- __le32 digest[4];
|
||||
- u64 f = 0;
|
||||
-
|
||||
if (unlikely(dctx->buflen)) {
|
||||
dctx->buf[dctx->buflen++] = 1;
|
||||
memset(dctx->buf + dctx->buflen, 0,
|
||||
@@ -144,18 +141,7 @@ void poly1305_final_arch(struct poly1305
|
||||
poly1305_blocks_mips(&dctx->h, dctx->buf, POLY1305_BLOCK_SIZE, 0);
|
||||
}
|
||||
|
||||
- poly1305_emit_mips(&dctx->h, digest, dctx->s);
|
||||
-
|
||||
- /* mac = (h + s) % (2^128) */
|
||||
- f = (f >> 32) + le32_to_cpu(digest[0]);
|
||||
- put_unaligned_le32(f, dst);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[1]);
|
||||
- put_unaligned_le32(f, dst + 4);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[2]);
|
||||
- put_unaligned_le32(f, dst + 8);
|
||||
- f = (f >> 32) + le32_to_cpu(digest[3]);
|
||||
- put_unaligned_le32(f, dst + 12);
|
||||
-
|
||||
+ poly1305_emit_mips(&dctx->h, dst, dctx->s);
|
||||
*dctx = (struct poly1305_desc_ctx){};
|
||||
}
|
||||
EXPORT_SYMBOL(poly1305_final_arch);
|
||||
@@ -1,102 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Date: Wed, 8 Jan 2020 12:37:35 +0800
|
||||
Subject: [PATCH] crypto: curve25519 - Fix selftest build error
|
||||
|
||||
commit a8bdf2c42ee4d1ee42af1f3601f85de94e70a421 upstream.
|
||||
|
||||
If CRYPTO_CURVE25519 is y, CRYPTO_LIB_CURVE25519_GENERIC will be
|
||||
y, but CRYPTO_LIB_CURVE25519 may be set to m, this causes build
|
||||
errors:
|
||||
|
||||
lib/crypto/curve25519-selftest.o: In function `curve25519':
|
||||
curve25519-selftest.c:(.text.unlikely+0xc): undefined reference to `curve25519_arch'
|
||||
lib/crypto/curve25519-selftest.o: In function `curve25519_selftest':
|
||||
curve25519-selftest.c:(.init.text+0x17e): undefined reference to `curve25519_base_arch'
|
||||
|
||||
This is because the curve25519 self-test code is being controlled
|
||||
by the GENERIC option rather than the overall CURVE25519 option,
|
||||
as is the case with blake2s. To recap, the GENERIC and ARCH options
|
||||
for CURVE25519 are internal only and selected by users such as
|
||||
the Crypto API, or the externally visible CURVE25519 option which
|
||||
in turn is selected by wireguard. The self-test is specific to the
|
||||
the external CURVE25519 option and should not be enabled by the
|
||||
Crypto API.
|
||||
|
||||
This patch fixes this by splitting the GENERIC module from the
|
||||
CURVE25519 module with the latter now containing just the self-test.
|
||||
|
||||
Reported-by: Hulk Robot <hulkci@huawei.com>
|
||||
Fixes: aa127963f1ca ("crypto: lib/curve25519 - re-add selftests")
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
lib/crypto/Makefile | 9 ++++++---
|
||||
lib/crypto/curve25519-generic.c | 24 ++++++++++++++++++++++++
|
||||
lib/crypto/curve25519.c | 7 -------
|
||||
3 files changed, 30 insertions(+), 10 deletions(-)
|
||||
create mode 100644 lib/crypto/curve25519-generic.c
|
||||
|
||||
--- a/lib/crypto/Makefile
|
||||
+++ b/lib/crypto/Makefile
|
||||
@@ -19,9 +19,12 @@ libblake2s-y += blake2s.o
|
||||
obj-$(CONFIG_CRYPTO_LIB_CHACHA20POLY1305) += libchacha20poly1305.o
|
||||
libchacha20poly1305-y += chacha20poly1305.o
|
||||
|
||||
-obj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += libcurve25519.o
|
||||
-libcurve25519-y := curve25519-fiat32.o
|
||||
-libcurve25519-$(CONFIG_ARCH_SUPPORTS_INT128) := curve25519-hacl64.o
|
||||
+obj-$(CONFIG_CRYPTO_LIB_CURVE25519_GENERIC) += libcurve25519-generic.o
|
||||
+libcurve25519-generic-y := curve25519-fiat32.o
|
||||
+libcurve25519-generic-$(CONFIG_ARCH_SUPPORTS_INT128) := curve25519-hacl64.o
|
||||
+libcurve25519-generic-y += curve25519-generic.o
|
||||
+
|
||||
+obj-$(CONFIG_CRYPTO_LIB_CURVE25519) += libcurve25519.o
|
||||
libcurve25519-y += curve25519.o
|
||||
|
||||
obj-$(CONFIG_CRYPTO_LIB_DES) += libdes.o
|
||||
--- /dev/null
|
||||
+++ b/lib/crypto/curve25519-generic.c
|
||||
@@ -0,0 +1,24 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0 OR MIT
|
||||
+/*
|
||||
+ * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||
+ *
|
||||
+ * This is an implementation of the Curve25519 ECDH algorithm, using either
|
||||
+ * a 32-bit implementation or a 64-bit implementation with 128-bit integers,
|
||||
+ * depending on what is supported by the target compiler.
|
||||
+ *
|
||||
+ * Information: https://cr.yp.to/ecdh.html
|
||||
+ */
|
||||
+
|
||||
+#include <crypto/curve25519.h>
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+const u8 curve25519_null_point[CURVE25519_KEY_SIZE] __aligned(32) = { 0 };
|
||||
+const u8 curve25519_base_point[CURVE25519_KEY_SIZE] __aligned(32) = { 9 };
|
||||
+
|
||||
+EXPORT_SYMBOL(curve25519_null_point);
|
||||
+EXPORT_SYMBOL(curve25519_base_point);
|
||||
+EXPORT_SYMBOL(curve25519_generic);
|
||||
+
|
||||
+MODULE_LICENSE("GPL v2");
|
||||
+MODULE_DESCRIPTION("Curve25519 scalar multiplication");
|
||||
+MODULE_AUTHOR("Jason A. Donenfeld <Jason@zx2c4.com>");
|
||||
--- a/lib/crypto/curve25519.c
|
||||
+++ b/lib/crypto/curve25519.c
|
||||
@@ -15,13 +15,6 @@
|
||||
|
||||
bool curve25519_selftest(void);
|
||||
|
||||
-const u8 curve25519_null_point[CURVE25519_KEY_SIZE] __aligned(32) = { 0 };
|
||||
-const u8 curve25519_base_point[CURVE25519_KEY_SIZE] __aligned(32) = { 9 };
|
||||
-
|
||||
-EXPORT_SYMBOL(curve25519_null_point);
|
||||
-EXPORT_SYMBOL(curve25519_base_point);
|
||||
-EXPORT_SYMBOL(curve25519_generic);
|
||||
-
|
||||
static int __init mod_init(void)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_CRYPTO_MANAGER_DISABLE_TESTS) &&
|
||||
@@ -1,23 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Thu, 16 Jan 2020 18:23:55 +0100
|
||||
Subject: [PATCH] crypto: x86/poly1305 - fix .gitignore typo
|
||||
|
||||
commit 1f6868995326cc82102049e349d8dbd116bdb656 upstream.
|
||||
|
||||
Admist the kbuild robot induced changes, the .gitignore file for the
|
||||
generated file wasn't updated with the non-clashing filename. This
|
||||
commit adjusts that.
|
||||
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/.gitignore | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/arch/x86/crypto/.gitignore
|
||||
+++ b/arch/x86/crypto/.gitignore
|
||||
@@ -1 +1 @@
|
||||
-poly1305-x86_64.S
|
||||
+poly1305-x86_64-cryptogams.S
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Fri, 17 Jan 2020 11:42:22 +0100
|
||||
Subject: [PATCH] crypto: x86/poly1305 - emit does base conversion itself
|
||||
|
||||
commit f9e7fe32a792726186301423ff63a465d63386e1 upstream.
|
||||
|
||||
The emit code does optional base conversion itself in assembly, so we
|
||||
don't need to do that here. Also, neither one of these functions uses
|
||||
simd instructions, so checking for that doesn't make sense either.
|
||||
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/x86/crypto/poly1305_glue.c | 8 ++------
|
||||
1 file changed, 2 insertions(+), 6 deletions(-)
|
||||
|
||||
--- a/arch/x86/crypto/poly1305_glue.c
|
||||
+++ b/arch/x86/crypto/poly1305_glue.c
|
||||
@@ -123,13 +123,9 @@ static void poly1305_simd_blocks(void *c
|
||||
static void poly1305_simd_emit(void *ctx, u8 mac[POLY1305_DIGEST_SIZE],
|
||||
const u32 nonce[4])
|
||||
{
|
||||
- struct poly1305_arch_internal *state = ctx;
|
||||
-
|
||||
- if (!IS_ENABLED(CONFIG_AS_AVX) || !static_branch_likely(&poly1305_use_avx) ||
|
||||
- !state->is_base2_26 || !crypto_simd_usable()) {
|
||||
- convert_to_base2_64(ctx);
|
||||
+ if (!IS_ENABLED(CONFIG_AS_AVX) || !static_branch_likely(&poly1305_use_avx))
|
||||
poly1305_emit_x86_64(ctx, mac, nonce);
|
||||
- } else
|
||||
+ else
|
||||
poly1305_emit_avx(ctx, mac, nonce);
|
||||
}
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ard Biesheuvel <ardb@kernel.org>
|
||||
Date: Fri, 17 Jan 2020 17:43:18 +0100
|
||||
Subject: [PATCH] crypto: arm/chacha - fix build failured when kernel mode NEON
|
||||
is disabled
|
||||
|
||||
commit 0bc81767c5bd9d005fae1099fb39eb3688370cb1 upstream.
|
||||
|
||||
When the ARM accelerated ChaCha driver is built as part of a configuration
|
||||
that has kernel mode NEON disabled, we expect the compiler to propagate
|
||||
the build time constant expression IS_ENABLED(CONFIG_KERNEL_MODE_NEON) in
|
||||
a way that eliminates all the cross-object references to the actual NEON
|
||||
routines, which allows the chacha-neon-core.o object to be omitted from
|
||||
the build entirely.
|
||||
|
||||
Unfortunately, this fails to work as expected in some cases, and we may
|
||||
end up with a build error such as
|
||||
|
||||
chacha-glue.c:(.text+0xc0): undefined reference to `chacha_4block_xor_neon'
|
||||
|
||||
caused by the fact that chacha_doneon() has not been eliminated from the
|
||||
object code, even though it will never be called in practice.
|
||||
|
||||
Let's fix this by adding some IS_ENABLED(CONFIG_KERNEL_MODE_NEON) tests
|
||||
that are not strictly needed from a logical point of view, but should
|
||||
help the compiler infer that the NEON code paths are unreachable in
|
||||
those cases.
|
||||
|
||||
Fixes: b36d8c09e710c71f ("crypto: arm/chacha - remove dependency on generic ...")
|
||||
Reported-by: Russell King <linux@armlinux.org.uk>
|
||||
Cc: Arnd Bergmann <arnd@arndb.de>
|
||||
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
arch/arm/crypto/chacha-glue.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/arch/arm/crypto/chacha-glue.c
|
||||
+++ b/arch/arm/crypto/chacha-glue.c
|
||||
@@ -115,7 +115,7 @@ static int chacha_stream_xor(struct skci
|
||||
if (nbytes < walk.total)
|
||||
nbytes = round_down(nbytes, walk.stride);
|
||||
|
||||
- if (!neon) {
|
||||
+ if (!IS_ENABLED(CONFIG_KERNEL_MODE_NEON) || !neon) {
|
||||
chacha_doarm(walk.dst.virt.addr, walk.src.virt.addr,
|
||||
nbytes, state, ctx->nrounds);
|
||||
state[12] += DIV_ROUND_UP(nbytes, CHACHA_BLOCK_SIZE);
|
||||
@@ -159,7 +159,7 @@ static int do_xchacha(struct skcipher_re
|
||||
|
||||
chacha_init_generic(state, ctx->key, req->iv);
|
||||
|
||||
- if (!neon) {
|
||||
+ if (!IS_ENABLED(CONFIG_KERNEL_MODE_NEON) || !neon) {
|
||||
hchacha_block_arm(state, subctx.key, ctx->nrounds);
|
||||
} else {
|
||||
kernel_neon_begin();
|
||||
@@ -1,42 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Fri, 17 Jan 2020 12:01:36 +0100
|
||||
Subject: [PATCH] crypto: Kconfig - allow tests to be disabled when manager is
|
||||
disabled
|
||||
|
||||
commit 2343d1529aff8b552589f622c23932035ed7a05d upstream.
|
||||
|
||||
The library code uses CRYPTO_MANAGER_DISABLE_TESTS to conditionalize its
|
||||
tests, but the library code can also exist without CRYPTO_MANAGER. That
|
||||
means on minimal configs, the test code winds up being built with no way
|
||||
to disable it.
|
||||
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
crypto/Kconfig | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
|
||||
Index: linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/crypto/Kconfig
|
||||
===================================================================
|
||||
--- linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac.orig/crypto/Kconfig
|
||||
+++ linux-5.4.164-qsdk-d5fcb18e5420670c8734c6a659873e73adab6dac/crypto/Kconfig
|
||||
@@ -143,8 +143,6 @@ config CRYPTO_MANAGER_DISABLE_TESTS
|
||||
Disable run-time self tests that normally take place at
|
||||
algorithm registration.
|
||||
|
||||
-if CRYPTO_MANAGER2
|
||||
-
|
||||
config CRYPTO_MANAGER_EXTRA_TESTS
|
||||
bool "Enable extra run-time crypto self tests"
|
||||
depends on DEBUG_KERNEL && !CRYPTO_MANAGER_DISABLE_TESTS
|
||||
@@ -155,8 +153,6 @@ config CRYPTO_MANAGER_EXTRA_TESTS
|
||||
This is intended for developer use only, as these tests take much
|
||||
longer to run than the normal self tests.
|
||||
|
||||
-endif # if CRYPTO_MANAGER2
|
||||
-
|
||||
config CRYPTO_GF128MUL
|
||||
tristate
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
|
||||
Date: Thu, 6 Feb 2020 12:42:01 +0100
|
||||
Subject: [PATCH] crypto: chacha20poly1305 - prevent integer overflow on large
|
||||
input
|
||||
|
||||
commit c9cc0517bba9f0213f1e55172feceb99e5512daf upstream.
|
||||
|
||||
This code assigns src_len (size_t) to sl (int), which causes problems
|
||||
when src_len is very large. Probably nobody in the kernel should be
|
||||
passing this much data to chacha20poly1305 all in one go anyway, so I
|
||||
don't think we need to change the algorithm or introduce larger types
|
||||
or anything. But we should at least error out early in this case and
|
||||
print a warning so that we get reports if this does happen and can look
|
||||
into why anybody is possibly passing it that much data or if they're
|
||||
accidently passing -1 or similar.
|
||||
|
||||
Fixes: d95312a3ccc0 ("crypto: lib/chacha20poly1305 - reimplement crypt_from_sg() routine")
|
||||
Cc: Ard Biesheuvel <ardb@kernel.org>
|
||||
Cc: stable@vger.kernel.org # 5.5+
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
Acked-by: Ard Biesheuvel <ardb@kernel.org>
|
||||
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
|
||||
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
|
||||
---
|
||||
lib/crypto/chacha20poly1305.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
--- a/lib/crypto/chacha20poly1305.c
|
||||
+++ b/lib/crypto/chacha20poly1305.c
|
||||
@@ -235,6 +235,9 @@ bool chacha20poly1305_crypt_sg_inplace(s
|
||||
__le64 lens[2];
|
||||
} b __aligned(16);
|
||||
|
||||
+ if (WARN_ON(src_len > INT_MAX))
|
||||
+ return false;
|
||||
+
|
||||
chacha_load_key(b.k, key);
|
||||
|
||||
b.iv[0] = 0;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user