Merge 4.19.215 into android-4.19-stable
Linux 4.19.215
* sctp: add vtag check in sctp_sf_ootb
net/sctp/sm_statefuns.c
* sctp: add vtag check in sctp_sf_do_8_5_1_E_sa
net/sctp/sm_statefuns.c
* sctp: add vtag check in sctp_sf_violation
net/sctp/sm_statefuns.c
* sctp: fix the processing for COOKIE_ECHO chunk
net/sctp/sm_statefuns.c
* sctp: use init_tag from inithdr for ABORT chunk
net/sctp/sm_statefuns.c
* net: nxp: lpc_eth.c: avoid hang when bringing interface down
drivers/net/ethernet/nxp/lpc_eth.c
* net: ethernet: microchip: lan743x: Fix dma allocation failure by using dma_set_mask_and_coherent
drivers/net/ethernet/microchip/lan743x_main.c
* net: ethernet: microchip: lan743x: Fix driver crash when lan743x_pm_resume fails
drivers/net/ethernet/microchip/lan743x_main.c
* nios2: Make NIOS2_DTB_SOURCE_BOOL depend on !COMPILE_TEST
arch/nios2/platform/Kconfig.platform
* net: Prevent infinite while loop in skb_tx_hash()
net/core/dev.c
* net: batman-adv: fix error handling
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/main.c
net/batman-adv/network-coding.c
net/batman-adv/translation-table.c
* regmap: Fix possible double-free in regcache_rbtree_exit()
drivers/base/regmap/regcache-rbtree.c
* arm64: dts: allwinner: h5: NanoPI Neo 2: Fix ethernet node
arch/arm64/boot/dts/allwinner/sun50i-h5-nanopi-neo2.dts
* RDMA/mlx5: Set user priority for DCT
drivers/infiniband/hw/mlx5/qp.c
* net: lan78xx: fix division by zero in send path
drivers/net/usb/lan78xx.c
* mmc: sdhci-esdhc-imx: clear the buffer_read_ready to reset standard tuning circuit
drivers/mmc/host/sdhci-esdhc-imx.c
* mmc: sdhci: Map more voltage level to SDHCI_POWER_330
drivers/mmc/host/sdhci.c
* mmc: dw_mmc: exynos: fix the finding clock sample value
drivers/mmc/host/dw_mmc-exynos.c
* mmc: cqhci: clear HALT state after CQE enable
drivers/mmc/host/cqhci.c
* mmc: vub300: fix control-message timeouts
drivers/mmc/host/vub300.c
* ipv6: make exception cache less predictible
net/ipv6/route.c
* ipv6: use siphash in rt6_exception_hash()
net/ipv6/route.c
* ipv4: use siphash instead of Jenkins in fnhe_hashfun()
net/ipv4/route.c
* Revert "net: mdiobus: Fix memory leak in __mdiobus_register"
drivers/net/phy/mdio_bus.c
* nfc: port100: fix using -ERRNO as command type mask
drivers/nfc/port100.c
* ata: sata_mv: Fix the error handling of mv_chip_id()
drivers/ata/sata_mv.c
* usbnet: fix error return code in usbnet_probe()
drivers/net/usb/usbnet.c
* usbnet: sanity check for maxpacket
drivers/net/usb/usbnet.c
* ARM: 8819/1: Remove '-p' from LDFLAGS
arch/arm/Makefile
arch/arm/boot/bootp/Makefile
arch/arm/boot/compressed/Makefile
* arm64: Avoid premature usercopy failure
arch/arm64/lib/copy_from_user.S
arch/arm64/lib/copy_in_user.S
arch/arm64/lib/copy_to_user.S
* powerpc/bpf: Fix BPF_MOD when imm == 1
arch/powerpc/net/bpf_jit_comp64.c
* ARM: 9141/1: only warn about XIP address when not compile testing
arch/arm/kernel/vmlinux-xip.lds.S
* ARM: 9139/1: kprobes: fix arch_init_kprobes() prototype
arch/arm/probes/kprobes/core.c
* ARM: 9134/1: remove duplicate memcpy() definition
arch/arm/boot/compressed/decompress.c
* ARM: 9133/1: mm: proc-macros: ensure *_tlb_fns are 4B aligned
arch/arm/mm/proc-macros.S
Merge 4.19.214 into android-4.19-stable
* ANDROID: Incremental fs: Fix dentry get/put imbalance on vfs_mkdir() failure
fs/incfs/vfs.c
Linux 4.19.214
* ARM: 9122/1: select HAVE_FUTEX_CMPXCHG
arch/arm/Kconfig
* tracing: Have all levels of checks prevent recursion
kernel/trace/ftrace.c
kernel/trace/trace.h
kernel/trace/trace_functions.c
* net: mdiobus: Fix memory leak in __mdiobus_register
drivers/net/phy/mdio_bus.c
* scsi: core: Fix shost->cmd_per_lun calculation in scsi_add_host_with_dma()
drivers/scsi/hosts.c
* ALSA: hda: avoid write to STATESTS if controller is in reset
sound/hda/hdac_controller.c
* platform/x86: intel_scu_ipc: Update timeout value in comment
drivers/platform/x86/intel_scu_ipc.c
* isdn: mISDN: Fix sleeping function called from invalid context
drivers/isdn/hardware/mISDN/netjet.c
* ARM: dts: spear3xx: Fix gmac node
arch/arm/boot/dts/spear3xx.dtsi
* net: stmmac: add support for dwmac 3.40a
drivers/net/ethernet/stmicro/stmmac/dwmac-generic.c
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
* btrfs: deal with errors when checking if a dir entry exists during log replay
fs/btrfs/tree-log.c
* gcc-plugins/structleak: add makefile var for disabling structleak
scripts/Makefile.gcc-plugins
* netfilter: Kconfig: use 'default y' instead of 'm' for bool config option
net/netfilter/Kconfig
* isdn: cpai: check ctr->cnr to avoid array index out of bound
drivers/isdn/capi/kcapi.c
* nfc: nci: fix the UAF of rf_conn_info object
net/nfc/nci/rsp.c
* mm, slub: fix mismatch between reconstructed freelist depth and cnt
mm/slub.c
* ASoC: DAPM: Fix missing kctl change notifications
sound/soc/soc-dapm.c
* ALSA: hda/realtek: Add quirk for Clevo PC50HS
sound/pci/hda/patch_realtek.c
* ALSA: usb-audio: Provide quirk for Sennheiser GSP670 Headset
sound/usb/quirks-table.h
* vfs: check fd has read access in kernel_read_file_from_fd()
fs/exec.c
* elfcore: correct reference to CONFIG_UML
include/linux/elfcore.h
* ocfs2: mount fails with buffer overflow in strlen
fs/ocfs2/super.c
* ocfs2: fix data corruption after conversion from inline format
fs/ocfs2/alloc.c
* can: peak_pci: peak_pci_remove(): fix UAF
drivers/net/can/sja1000/peak_pci.c
* can: peak_usb: pcan_usb_fd_decode_status(): fix back to ERROR_ACTIVE state notification
drivers/net/can/usb/peak_usb/pcan_usb_fd.c
* can: rcar_can: fix suspend/resume
drivers/net/can/rcar/rcar_can.c
* net: hns3: disable sriov before unload hclge layer
drivers/net/ethernet/hisilicon/hns3/hnae3.c
drivers/net/ethernet/hisilicon/hns3/hnae3.h
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c
* net: hns3: add limit ets dwrr bandwidth cannot be 0
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c
* NIOS2: irqflags: rename a redefined register name
arch/nios2/include/asm/irqflags.h
arch/nios2/include/asm/registers.h
* lan78xx: select CRC32
drivers/net/usb/Kconfig
* netfilter: ipvs: make global sysctl readonly in non-init netns
net/netfilter/ipvs/ip_vs_ctl.c
* ASoC: wm8960: Fix clock configuration on slave mode
sound/soc/codecs/wm8960.c
* dma-debug: fix sg checks in debug_dma_map_sg()
kernel/dma/debug.c
* NFSD: Keep existing listeners on portlist error
fs/nfsd/nfsctl.c
* xtensa: xtfpga: Try software restart before simulating CPU reset
arch/xtensa/platforms/xtfpga/setup.c
* xtensa: xtfpga: use CONFIG_USE_OF instead of CONFIG_OF
arch/xtensa/platforms/xtfpga/setup.c
* ARM: dts: at91: sama5d2_som1_ek: disable ISC node by default
arch/arm/boot/dts/at91-sama5d27_som1_ek.dts
Merge 4.19.213 into android-4.19-stable
* UPSTREAM: crypto: arm/blake2s - fix for big endian
arch/arm/crypto/blake2s-core.S
* ANDROID: gki_defconfig: enable BLAKE2b support
arch/arm64/configs/gki_defconfig
arch/x86/configs/gki_defconfig
* BACKPORT: crypto: arm/blake2b - add NEON-accelerated BLAKE2b
arch/arm/crypto/Kconfig
arch/arm/crypto/Makefile
arch/arm/crypto/blake2b-neon-core.S
arch/arm/crypto/blake2b-neon-glue.c
* BACKPORT: crypto: blake2b - update file comment
crypto/blake2b_generic.c
* BACKPORT: crypto: blake2b - sync with blake2s implementation
crypto/blake2b_generic.c
include/crypto/blake2b.h
include/crypto/internal/blake2b.h
* UPSTREAM: wireguard: Kconfig: select CRYPTO_BLAKE2S_ARM
drivers/net/Kconfig
* UPSTREAM: crypto: arm/blake2s - add ARM scalar optimized BLAKE2s
arch/arm/crypto/Kconfig
arch/arm/crypto/Makefile
arch/arm/crypto/blake2s-core.S
arch/arm/crypto/blake2s-glue.c
* UPSTREAM: crypto: blake2s - include <linux/bug.h> instead of <asm/bug.h>
include/crypto/blake2s.h
* UPSTREAM: crypto: blake2s - adjust include guard naming
include/crypto/blake2s.h
include/crypto/internal/blake2s.h
* UPSTREAM: crypto: blake2s - add comment for blake2s_state fields
include/crypto/blake2s.h
* UPSTREAM: crypto: blake2s - optimize blake2s initialization
include/crypto/blake2s.h
include/crypto/internal/blake2s.h
* BACKPORT: crypto: blake2s - share the "shash" API boilerplate code
arch/x86/crypto/blake2s-glue.c
crypto/blake2s_generic.c
include/crypto/internal/blake2s.h
* UPSTREAM: crypto: blake2s - move update and final logic to internal/blake2s.h
include/crypto/internal/blake2s.h
lib/crypto/blake2s.c
* UPSTREAM: crypto: blake2s - remove unneeded includes
crypto/blake2s_generic.c
* UPSTREAM: crypto: x86/blake2s - define shash_alg structs using macros
arch/x86/crypto/blake2s-glue.c
* UPSTREAM: crypto: blake2s - define shash_alg structs using macros
crypto/blake2s_generic.c
* UPSTREAM: crypto: lib/blake2s - Move selftest prototype into header file
include/crypto/internal/blake2s.h
lib/crypto/blake2s-selftest.c
lib/crypto/blake2s.c
* UPSTREAM: crypto: blake2b - Fix clang optimization for ARMv7-M
crypto/blake2b_generic.c
* UPSTREAM: crypto: blake2b - rename tfm context and _setkey callback
crypto/blake2b_generic.c
* UPSTREAM: crypto: blake2b - merge _update to api callback
crypto/blake2b_generic.c
* UPSTREAM: crypto: blake2b - open code set last block helper
crypto/blake2b_generic.c
* UPSTREAM: crypto: blake2b - delete unused structs or members
crypto/blake2b_generic.c
* UPSTREAM: crypto: blake2b - simplify key init
crypto/blake2b_generic.c
* UPSTREAM: crypto: blake2b - merge blake2 init to api callback
crypto/blake2b_generic.c
* UPSTREAM: crypto: blake2b - merge _final implementation to callback
crypto/blake2b_generic.c
* BACKPORT: crypto: testmgr - add test vectors for blake2b
crypto/testmgr.c
crypto/testmgr.h
* BACKPORT: crypto: blake2b - add blake2b generic implementation
crypto/Kconfig
crypto/Makefile
crypto/blake2b_generic.c
Linux 4.19.213
* r8152: select CRC32 and CRYPTO/CRYPTO_HASH/CRYPTO_SHA256
drivers/net/usb/Kconfig
* qed: Fix missing error code in qed_slowpath_start()
drivers/net/ethernet/qlogic/qed/qed_main.c
* mqprio: Correct stats in mqprio_dump_class_stats().
net/sched/sch_mqprio.c
* acpi/arm64: fix next_platform_timer() section mismatch error
drivers/acpi/arm64/gtdt.c
* drm/msm/dsi: fix off by one in dsi_bus_clk_enable error handling
drivers/gpu/drm/msm/dsi/dsi_host.c
* drm/msm/dsi: Fix an error code in msm_dsi_modeset_init()
drivers/gpu/drm/msm/dsi/dsi.c
* drm/msm: Fix null pointer dereference on pointer edp
drivers/gpu/drm/msm/edp/edp_ctrl.c
* platform/mellanox: mlxreg-io: Fix argument base in kstrtou32() call
drivers/platform/mellanox/mlxreg-io.c
* pata_legacy: fix a couple uninitialized variable bugs
drivers/ata/pata_legacy.c
* NFC: digital: fix possible memory leak in digital_in_send_sdd_req()
net/nfc/digital_technology.c
* NFC: digital: fix possible memory leak in digital_tg_listen_mdaa()
net/nfc/digital_core.c
* nfc: fix error handling of nfc_proto_register()
net/nfc/af_nfc.c
* ethernet: s2io: fix setting mac address during resume
drivers/net/ethernet/neterion/s2io.c
* net: encx24j600: check error in devm_regmap_init_encx24j600
drivers/net/ethernet/microchip/encx24j600-regmap.c
drivers/net/ethernet/microchip/encx24j600.c
drivers/net/ethernet/microchip/encx24j600_hw.h
* net: korina: select CRC32
drivers/net/ethernet/Kconfig
* net: arc: select CRC32
drivers/net/ethernet/arc/Kconfig
* sctp: account stream padding length for reconf chunk
net/sctp/sm_make_chunk.c
* iio: dac: ti-dac5571: fix an error code in probe()
drivers/iio/dac/ti-dac5571.c
* iio: ssp_sensors: fix error code in ssp_print_mcu_debug()
drivers/iio/common/ssp_sensors/ssp_spi.c
* iio: ssp_sensors: add more range checking in ssp_parse_dataframe()
drivers/iio/common/ssp_sensors/ssp_spi.c
* iio: light: opt3001: Fixed timeout error when 0 lux
drivers/iio/light/opt3001.c
* iio: adc128s052: Fix the error handling path of 'adc128_probe()'
drivers/iio/adc/ti-adc128s052.c
* iio: adc: aspeed: set driver data when adc probe.
drivers/iio/adc/aspeed_adc.c
* x86/Kconfig: Do not enable AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT automatically
arch/x86/Kconfig
* nvmem: Fix shift-out-of-bound (UBSAN) with byte size cells
drivers/nvmem/core.c
* virtio: write back F_VERSION_1 before validate
drivers/virtio/virtio.c
* USB: serial: option: add prod. id for Quectel EG91
drivers/usb/serial/option.c
* USB: serial: option: add Telit LE910Cx composition 0x1204
drivers/usb/serial/option.c
* USB: serial: option: add Quectel EC200S-CN module support
drivers/usb/serial/option.c
* USB: serial: qcserial: add EM9191 QDL support
drivers/usb/serial/qcserial.c
* Input: xpad - add support for another USB ID of Nacon GC-100
drivers/input/joystick/xpad.c
* usb: musb: dsps: Fix the probe error path
drivers/usb/musb/musb_dsps.c
* efi: Change down_interruptible() in virt_efi_reset_system() to down_trylock()
drivers/firmware/efi/runtime-wrappers.c
* efi/cper: use stack buffer for error record decoding
drivers/firmware/efi/cper.c
* cb710: avoid NULL pointer subtraction
drivers/misc/cb710/sgbuf2.c
* xhci: Enable trust tx length quirk for Fresco FL11 USB controller
drivers/usb/host/xhci-pci.c
* xhci: Fix command ring pointer corruption while aborting a command
drivers/usb/host/xhci-ring.c
* xhci: guard accesses to ep_state in xhci_endpoint_reset()
drivers/usb/host/xhci.c
* mei: me: add Ice Lake-N device id.
drivers/misc/mei/hw-me-regs.h
drivers/misc/mei/pci-me.c
* x86/resctrl: Free the ctrlval arrays when domain_setup_mon_state() fails
arch/x86/kernel/cpu/intel_rdt.c
* btrfs: check for error when looking up inode during dir entry replay
fs/btrfs/tree-log.c
* btrfs: deal with errors when adding inode reference during log replay
fs/btrfs/tree-log.c
* btrfs: deal with errors when replaying dir entry during log replay
fs/btrfs/tree-log.c
* s390: fix strrchr() implementation
arch/s390/lib/string.c
* nds32/ftrace: Fix Error: invalid operands (*UND* and *UND* sections) for `^'
scripts/recordmcount.pl
* ALSA: hda/realtek - ALC236 headset MIC recording issue
sound/pci/hda/patch_realtek.c
* ALSA: hda/realtek: Add quirk for Clevo X170KM-G
sound/pci/hda/patch_realtek.c
* ALSA: hda/realtek: Complete partial device name to avoid ambiguity
sound/pci/hda/patch_realtek.c
* ALSA: seq: Fix a potential UAF by wrong private_free call order
sound/core/seq_device.c
Merge 4.19.212 into android-4.19-stable
Linux 4.19.212
* sched: Always inline is_percpu_thread()
include/linux/sched.h
* perf/x86: Reset destroy callback on event init failure
arch/x86/events/core.c
* scsi: virtio_scsi: Fix spelling mistake "Unsupport" -> "Unsupported"
drivers/scsi/virtio_scsi.c
* scsi: ses: Fix unsigned comparison with less than zero
drivers/scsi/ses.c
* net: sun: SUNVNET_COMMON should depend on INET
drivers/net/ethernet/sun/Kconfig
* mac80211: check return value of rhashtable_init
net/mac80211/mesh_pathtbl.c
* net: prevent user from passing illegal stab size
include/net/pkt_sched.h
net/sched/sch_api.c
* m68k: Handle arrivals of multiple signals correctly
arch/m68k/kernel/signal.c
* mac80211: Drop frames from invalid MAC address in ad-hoc mode
net/mac80211/rx.c
* netfilter: ip6_tables: zero-initialize fragment offset
net/ipv6/netfilter/ip6_tables.c
* HID: apple: Fix logical maximum and usage maximum of Magic Keyboard JIS
drivers/hid/hid-apple.c
* net: phy: bcm7xxx: Fixed indirect MMD operations
drivers/net/phy/bcm7xxx.c
Merge 4.19.211 into android-4.19-stable
* Revert "lib/timerqueue: Rely on rbtree semantics for next timer"
include/linux/timerqueue.h
lib/timerqueue.c
Merge 4.19.210 into android-4.19-stable
Linux 4.19.211
* x86/Kconfig: Correct reference to MWINCHIP3D
arch/x86/Kconfig
* i2c: acpi: fix resource leak in reconfiguration device addition
drivers/i2c/i2c-core-acpi.c
* i40e: Fix freeing of uninitialized misc IRQ vector
drivers/net/ethernet/intel/i40e/i40e_main.c
* i40e: fix endless loop under rtnl
drivers/net/ethernet/intel/i40e/i40e_main.c
* rtnetlink: fix if_nlmsg_stats_size() under estimation
net/core/rtnetlink.c
* drm/nouveau/debugfs: fix file release memory leak
drivers/gpu/drm/nouveau/nouveau_debugfs.c
* netlink: annotate data races around nlk->bound
net/netlink/af_netlink.c
* net: sfp: Fix typo in state machine debug string
drivers/net/phy/sfp.c
* net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size()
net/bridge/br_netlink.c
* ARM: imx6: disable the GIC CPU interface before calling stby-poweroff sequence
arch/arm/mach-imx/pm-imx6.c
* ptp_pch: Load module automatically if ID matches
drivers/ptp/ptp_pch.c
* powerpc/fsl/dts: Fix phy-connection-type for fm1mac3
arch/powerpc/boot/dts/fsl/t1023rdb.dts
* net_sched: fix NULL deref in fifo_set_limit()
net/sched/sch_fifo.c
* phy: mdio: fix memory leak
drivers/net/phy/mdio_bus.c
* bpf: Fix integer overflow in prealloc_elems_and_freelist()
kernel/bpf/stackmap.c
* bpf, arm: Fix register clobbering in div/mod implementation
arch/arm/net/bpf_jit_32.c
* xtensa: call irqchip_init only when CONFIG_USE_OF is selected
arch/xtensa/kernel/irq.c
* bpf, mips: Validate conditional branch offsets
arch/mips/net/bpf_jit.c
* ARM: dts: qcom: apq8064: use compatible which contains chipid
arch/arm/boot/dts/qcom-apq8064.dtsi
* ARM: dts: omap3430-sdp: Fix NAND device node
arch/arm/boot/dts/omap3430-sdp.dts
* xen/balloon: fix cancelled balloon action
drivers/xen/balloon.c
* nfsd4: Handle the NFSv4 READDIR 'dircount' hint being zero
fs/nfsd/nfs4xdr.c
* ovl: fix missing negative dentry check in ovl_rename()
fs/overlayfs/dir.c
* xen/privcmd: fix error handling in mmap-resource processing
drivers/xen/privcmd.c
* USB: cdc-acm: fix break reporting
drivers/usb/class/cdc-acm.c
* USB: cdc-acm: fix racy tty buffer accesses
drivers/usb/class/cdc-acm.c
* Partially revert "usb: Kconfig: using select for USB_COMMON dependency"
drivers/usb/Kconfig
* ANDROID: Different fix for KABI breakage in 4.19.209 in struct sock
include/net/sock.h
* ANDROID: GKI: update .xml file for struct sock change
android/abi_gki_aarch64.xml
Linux 4.19.210
* lib/timerqueue: Rely on rbtree semantics for next timer
include/linux/timerqueue.h
lib/timerqueue.c
* libata: Add ATA_HORKAGE_NO_NCQ_ON_ATI for Samsung 860 and 870 SSD.
drivers/ata/libata-core.c
include/linux/libata.h
* tools/vm/page-types: remove dependency on opt_file for idle page tracking
tools/vm/page-types.c
* scsi: ses: Retry failed Send/Receive Diagnostic commands
drivers/scsi/ses.c
* selftests: be sure to make khdr before other targets
tools/testing/selftests/lib.mk
* usb: dwc2: check return value after calling platform_get_resource()
drivers/usb/dwc2/hcd.c
* usb: testusb: Fix for showing the connection speed
tools/usb/testusb.c
* scsi: sd: Free scsi_disk device via put_device()
drivers/scsi/sd.c
* ext2: fix sleeping in atomic bugs on error
fs/ext2/balloc.c
* sparc64: fix pci_iounmap() when CONFIG_PCI is not set
arch/sparc/lib/iomap.c
* xen-netback: correct success/error reporting for the SKB-with-fraglist case
drivers/net/xen-netback/netback.c
* net: mdio: introduce a shutdown method to mdio device drivers
drivers/net/phy/mdio_device.c
include/linux/mdio.h
* ANDROID: Fix up KABI breakage in 4.19.209 in struct sock
include/net/sock.h
Merge 4.19.209 into android-4.19-stable
* FROMLIST: dm-verity: skip verity_handle_error on I/O errors
drivers/md/dm-verity-target.c
Linux 4.19.209
* cred: allow get_cred() and put_cred() to be given NULL.
include/linux/cred.h
* HID: usbhid: free raw_report buffers in usbhid_stop
drivers/hid/usbhid/hid-core.c
* netfilter: ipset: Fix oversized kvmalloc() calls
net/netfilter/ipset/ip_set_hash_gen.h
* HID: betop: fix slab-out-of-bounds Write in betop_probe
drivers/hid/hid-betopff.c
* crypto: ccp - fix resource leaks in ccp_run_aes_gcm_cmd()
drivers/crypto/ccp/ccp-ops.c
* usb: hso: remove the bailout parameter
drivers/net/usb/hso.c
* usb: hso: fix error handling code of hso_create_net_device
drivers/net/usb/hso.c
* hso: fix bailout in error case of probe
drivers/net/usb/hso.c
* ARM: 9098/1: ftrace: MODULE_PLT: Fix build problem without DYNAMIC_FTRACE
arch/arm/kernel/module-plts.c
* ARM: 9079/1: ftrace: Add MODULE_PLTS support
arch/arm/include/asm/ftrace.h
arch/arm/include/asm/module.h
arch/arm/kernel/ftrace.c
arch/arm/kernel/module-plts.c
* ARM: 9078/1: Add warn suppress parameter to arm_gen_branch_link()
arch/arm/include/asm/insn.h
arch/arm/kernel/ftrace.c
arch/arm/kernel/insn.c
* ARM: 9077/1: PLT: Move struct plt_entries definition to header
arch/arm/include/asm/module.h
arch/arm/kernel/module-plts.c
* EDAC/synopsys: Fix wrong value type assignment for edac_mode
drivers/edac/synopsys_edac.c
* net: udp: annotate data race around udp_sk(sk)->corkflag
net/ipv4/udp.c
net/ipv6/udp.c
* ext4: fix potential infinite loop in ext4_dx_readdir()
fs/ext4/dir.c
* ipack: ipoctal: fix module reference leak
drivers/ipack/devices/ipoctal.c
* ipack: ipoctal: fix missing allocation-failure check
drivers/ipack/devices/ipoctal.c
* ipack: ipoctal: fix tty-registration error handling
drivers/ipack/devices/ipoctal.c
* ipack: ipoctal: fix tty registration race
drivers/ipack/devices/ipoctal.c
* ipack: ipoctal: fix stack information leak
drivers/ipack/devices/ipoctal.c
* elf: don't use MAP_FIXED_NOREPLACE for elf interpreter mappings
fs/binfmt_elf.c
* af_unix: fix races in sk_peer_pid and sk_peer_cred accesses
include/net/sock.h
net/core/sock.c
net/unix/af_unix.c
* scsi: csiostor: Add module softdep on cxgb4
drivers/scsi/csiostor/csio_init.c
* Revert "block, bfq: honor already-setup queue merges"
block/bfq-iosched.c
* e100: fix buffer overrun in e100_get_regs
drivers/net/ethernet/intel/e100.c
* e100: fix length calculation in e100_get_regs_len
drivers/net/ethernet/intel/e100.c
* hwmon: (tmp421) fix rounding for negative values
drivers/hwmon/tmp421.c
* hwmon: (tmp421) report /PVLD condition as fault
drivers/hwmon/tmp421.c
* hwmon: (tmp421) Replace S_<PERMS> with octal values
drivers/hwmon/tmp421.c
* sctp: break out if skb_header_pointer returns NULL in sctp_rcv_ootb
net/sctp/input.c
* mac80211: limit injected vht mcs/nss in ieee80211_parse_tx_radiotap
net/mac80211/tx.c
* mac80211: Fix ieee80211_amsdu_aggregate frag_tail bug
net/mac80211/tx.c
* hwmon: (mlxreg-fan) Return non-zero value when fan current state is enforced from sysfs
drivers/hwmon/mlxreg-fan.c
* ipvs: check that ip_vs_conn_tab_bits is between 8 and 20
net/netfilter/ipvs/ip_vs_conn.c
* drm/amd/display: Pass PCI deviceid into DC
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
* x86/kvmclock: Move this_cpu_pvti into kvmclock.h
arch/x86/include/asm/kvmclock.h
arch/x86/kernel/kvmclock.c
* mac80211: fix use-after-free in CCMP/GCMP RX
net/mac80211/wpa.c
* cpufreq: schedutil: Destroy mutex before kobject_put() frees the memory
drivers/cpufreq/cpufreq_governor_attr_set.c
* cpufreq: schedutil: Use kobject release() method to free sugov_tunables
kernel/sched/cpufreq_schedutil.c
* tty: Fix out-of-bound vmalloc access in imageblit
drivers/tty/vt/vt.c
* qnx4: work around gcc false positive warning bug
fs/qnx4/dir.c
* xen/balloon: fix balloon kthread freezing
drivers/xen/balloon.c
* tcp: adjust rto_base in retransmits_timed_out()
net/ipv4/tcp_timer.c
* tcp: create a helper to model exponential backoff
net/ipv4/tcp_timer.c
* tcp: always set retrans_stamp on recovery
net/ipv4/tcp_output.c
net/ipv4/tcp_timer.c
* tcp: address problems caused by EDT misshaps
net/ipv4/tcp_input.c
net/ipv4/tcp_timer.c
* PCI: aardvark: Fix checking for PIO status
drivers/pci/controller/pci-aardvark.c
* arm64: dts: marvell: armada-37xx: Extend PCIe MEM space
arch/arm64/boot/dts/marvell/armada-37xx.dtsi
* erofs: fix up erofs_lookup tracepoint
drivers/staging/erofs/include/trace/events/erofs.h
* spi: Fix tegra20 build with CONFIG_PM=n
drivers/spi/spi-tegra20-slink.c
* net: 6pack: Fix tx timeout and slot time
drivers/net/hamradio/6pack.c
* alpha: Declare virt_to_phys and virt_to_bus parameter as pointer to volatile
arch/alpha/include/asm/io.h
* arm64: Mark __stack_chk_guard as __ro_after_init
arch/arm64/kernel/process.c
* parisc: Use absolute_pointer() to define PAGE0
arch/parisc/include/asm/page.h
* qnx4: avoid stringop-overread errors
fs/qnx4/dir.c
* sparc: avoid stringop-overread errors
arch/sparc/kernel/mdesc.c
* net: i825xx: Use absolute_pointer for memcpy from fixed memory location
drivers/net/ethernet/i825xx/82596.c
* compiler.h: Introduce absolute_pointer macro
include/linux/compiler.h
* nvme-multipath: fix ANA state updates when a namespace is not present
drivers/nvme/host/multipath.c
* xen/balloon: use a kernel thread instead a workqueue
drivers/xen/balloon.c
* m68k: Double cast io functions to unsigned long
arch/m68k/include/asm/raw_io.h
* net: stmmac: allow CSR clock of 300MHz
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
* net: macb: fix use after free on rmmod
drivers/net/ethernet/cadence/macb_pci.c
* blktrace: Fix uaf in blk_trace access after removing by sysfs
kernel/trace/blktrace.c
* md: fix a lock order reversal in md_alloc
drivers/md/md.c
* irqchip/gic-v3-its: Fix potential VPE leak on error
drivers/irqchip/irq-gic-v3-its.c
* irqchip/goldfish-pic: Select GENERIC_IRQ_CHIP to fix build
drivers/irqchip/Kconfig
* thermal/core: Potential buffer overflow in thermal_build_list_of_policies()
drivers/thermal/thermal_core.c
* fpga: machxo2-spi: Fix missing error code in machxo2_write_complete()
drivers/fpga/machxo2-spi.c
* fpga: machxo2-spi: Return an error on failure
drivers/fpga/machxo2-spi.c
* tty: synclink_gt: rename a conflicting function name
drivers/tty/synclink_gt.c
* tty: synclink_gt, drop unneeded forward declarations
drivers/tty/synclink_gt.c
* scsi: iscsi: Adjust iface sysfs attr detection
drivers/scsi/scsi_transport_iscsi.c
* net/mlx4_en: Don't allow aRFS for encapsulated packets
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
* gpio: uniphier: Fix void functions to remove return value
drivers/gpio/gpio-uniphier.c
* net/smc: add missing error check in smc_clc_prfx_set()
net/smc/smc_clc.c
* bnxt_en: Fix TX timeout when TX ring size is set to the smallest
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
* net: hso: fix muxed tty registration
drivers/net/usb/hso.c
* serial: mvebu-uart: fix driver's tx_empty callback
drivers/tty/serial/mvebu-uart.c
* mcb: fix error handling in mcb_alloc_bus()
drivers/mcb/mcb-core.c
* USB: serial: option: add device id for Foxconn T99W265
drivers/usb/serial/option.c
* USB: serial: option: remove duplicate USB device ID
drivers/usb/serial/option.c
* USB: serial: option: add Telit LN920 compositions
drivers/usb/serial/option.c
* USB: serial: mos7840: remove duplicated 0xac24 device ID
drivers/usb/serial/mos7840.c
* Re-enable UAS for LaCie Rugged USB3-FW with fk quirk
drivers/usb/storage/unusual_uas.h
* staging: greybus: uart: fix tty use after free
drivers/staging/greybus/uart.c
* USB: cdc-acm: fix minor-number release
drivers/usb/class/cdc-acm.c
drivers/usb/class/cdc-acm.h
* USB: serial: cp210x: add ID for GW Instek GDM-834x Digital Multimeter
drivers/usb/serial/cp210x.c
* usb-storage: Add quirk for ScanLogic SL11R-IDE older than 2.6c
drivers/usb/storage/unusual_devs.h
* xen/x86: fix PV trap handling on secondary processors
arch/x86/xen/enlighten_pv.c
* cifs: fix incorrect check for null pointer in header_assemble
fs/cifs/connect.c
* usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned()
drivers/usb/musb/tusb6010.c
* usb: dwc2: gadget: Fix ISOC transfer complete handling for DDMA
drivers/usb/dwc2/gadget.c
* usb: gadget: r8a66597: fix a loop in set_feature()
drivers/usb/gadget/udc/r8a66597-udc.c
* ocfs2: drop acl cache for directories too
fs/ocfs2/dlmglue.c
Merge 4.19.208 into android-4.19-stable
* ANDROID: GKI: update ABI xml
android/abi_gki_aarch64
android/abi_gki_aarch64.xml
* ANDROID: GKI: Update aarch64 cuttlefish symbol list
android/abi_gki_aarch64_cuttlefish
* ANDROID: GKI: rework the ANDROID_KABI_USE() macro to not use __UNIQUE()
include/linux/android_kabi.h
* BACKPORT: loop: Set correct device size when using LOOP_CONFIGURE
drivers/block/loop.c
Linux 4.19.208
* drm/nouveau/nvkm: Replace -ENOSYS with -ENODEV
drivers/gpu/drm/nouveau/nvkm/engine/device/ctrl.c
* blk-throttle: fix UAF by deleteing timer in blk_throtl_exit()
block/blk-throttle.c
* pwm: stm32-lp: Don't modify HW state in .remove() callback
drivers/pwm/pwm-stm32-lp.c
* pwm: rockchip: Don't modify HW state in .remove() callback
drivers/pwm/pwm-rockchip.c
* pwm: img: Don't modify HW state in .remove() callback
drivers/pwm/pwm-img.c
* nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group
fs/nilfs2/sysfs.c
* nilfs2: fix memory leak in nilfs_sysfs_create_snapshot_group
fs/nilfs2/sysfs.c
* nilfs2: fix memory leak in nilfs_sysfs_delete_##name##_group
fs/nilfs2/sysfs.c
* nilfs2: fix memory leak in nilfs_sysfs_create_##name##_group
fs/nilfs2/sysfs.c
* nilfs2: fix NULL pointer in nilfs_##name##_attr_release
fs/nilfs2/sysfs.c
* nilfs2: fix memory leak in nilfs_sysfs_create_device_group
fs/nilfs2/sysfs.c
* ceph: lockdep annotations for try_nonblocking_invalidate
fs/ceph/caps.c
* dmaengine: xilinx_dma: Set DMA mask for coherent APIs
drivers/dma/xilinx/xilinx_dma.c
* dmaengine: ioat: depends on !UML
drivers/dma/Kconfig
* dmaengine: sprd: Add missing MODULE_DEVICE_TABLE
drivers/dma/sprd-dma.c
* parisc: Move pci_dev_is_behind_card_dino to where it is used
drivers/parisc/dino.c
* drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION()
arch/arm64/kernel/cacheinfo.c
arch/mips/kernel/cacheinfo.c
arch/riscv/kernel/cacheinfo.c
arch/x86/kernel/cpu/cacheinfo.c
include/linux/cacheinfo.h
* Kconfig.debug: drop selecting non-existing HARDLOCKUP_DETECTOR_ARCH
lib/Kconfig.debug
* pwm: lpc32xx: Don't modify HW state in .probe() after the PWM chip was registered
drivers/pwm/pwm-lpc32xx.c
* profiling: fix shift-out-of-bounds bugs
kernel/profile.c
* nilfs2: use refcount_dec_and_lock() to fix potential UAF
fs/nilfs2/the_nilfs.c
* prctl: allow to setup brk for et_dyn executables
kernel/sys.c
* 9p/trans_virtio: Remove sysfs file on probe failure
net/9p/trans_virtio.c
* thermal/drivers/exynos: Fix an error code in exynos_tmu_probe()
drivers/thermal/samsung/exynos_tmu.c
* dmaengine: acpi: Avoid comparison GSI with Linux vIRQ
drivers/dma/acpi-dma.c
* sctp: add param size validation for SCTP_PARAM_SET_PRIMARY
net/sctp/sm_make_chunk.c
* sctp: validate chunk size in __rcv_asconf_lookup
net/sctp/input.c
* tracing/kprobe: Fix kprobe_on_func_entry() modification
kernel/trace/trace_kprobe.c
* crypto: talitos - fix max key size for sha384 and sha512
drivers/crypto/talitos.c
* apparmor: remove duplicate macro list_entry_is_head()
security/apparmor/apparmorfs.c
* rcu: Fix missed wakeup of exp_wq waiters
kernel/rcu/tree_exp.h
* KVM: remember position in kvm->vcpus array
include/linux/kvm_host.h
virt/kvm/kvm_main.c
* s390/bpf: Fix optimizing out zero-extensions
arch/s390/net/bpf_jit_comp.c
Bug: 205088357
Change-Id: Ifdb3da9a34bc271beb7ba680c041b10081d7e74c
Signed-off-by: JohnnLee <johnnlee@google.com>
431 lines
13 KiB
C
431 lines
13 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LINUX_COMPILER_H
|
|
#define __LINUX_COMPILER_H
|
|
|
|
#include <linux/compiler_types.h>
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
/*
|
|
* Note: DISABLE_BRANCH_PROFILING can be used by special lowlevel code
|
|
* to disable branch tracing on a per file basis.
|
|
*/
|
|
#if defined(CONFIG_TRACE_BRANCH_PROFILING) \
|
|
&& !defined(DISABLE_BRANCH_PROFILING) && !defined(__CHECKER__)
|
|
void ftrace_likely_update(struct ftrace_likely_data *f, int val,
|
|
int expect, int is_constant);
|
|
|
|
#define likely_notrace(x) __builtin_expect(!!(x), 1)
|
|
#define unlikely_notrace(x) __builtin_expect(!!(x), 0)
|
|
|
|
#define __branch_check__(x, expect, is_constant) ({ \
|
|
long ______r; \
|
|
static struct ftrace_likely_data \
|
|
__attribute__((__aligned__(4))) \
|
|
__attribute__((section("_ftrace_annotated_branch"))) \
|
|
______f = { \
|
|
.data.func = __func__, \
|
|
.data.file = __FILE__, \
|
|
.data.line = __LINE__, \
|
|
}; \
|
|
______r = __builtin_expect(!!(x), expect); \
|
|
ftrace_likely_update(&______f, ______r, \
|
|
expect, is_constant); \
|
|
______r; \
|
|
})
|
|
|
|
/*
|
|
* Using __builtin_constant_p(x) to ignore cases where the return
|
|
* value is always the same. This idea is taken from a similar patch
|
|
* written by Daniel Walker.
|
|
*/
|
|
# ifndef likely
|
|
# define likely(x) (__branch_check__(x, 1, __builtin_constant_p(x)))
|
|
# endif
|
|
# ifndef unlikely
|
|
# define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
|
|
# endif
|
|
|
|
#ifdef CONFIG_PROFILE_ALL_BRANCHES
|
|
/*
|
|
* "Define 'is'", Bill Clinton
|
|
* "Define 'if'", Steven Rostedt
|
|
*/
|
|
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
|
|
#define __trace_if(cond) \
|
|
if (__builtin_constant_p(!!(cond)) ? !!(cond) : \
|
|
({ \
|
|
int ______r; \
|
|
static struct ftrace_branch_data \
|
|
__attribute__((__aligned__(4))) \
|
|
__attribute__((section("_ftrace_branch"))) \
|
|
______f = { \
|
|
.func = __func__, \
|
|
.file = __FILE__, \
|
|
.line = __LINE__, \
|
|
}; \
|
|
______r = !!(cond); \
|
|
______f.miss_hit[______r]++; \
|
|
______r; \
|
|
}))
|
|
#endif /* CONFIG_PROFILE_ALL_BRANCHES */
|
|
|
|
#else
|
|
# define likely(x) __builtin_expect(!!(x), 1)
|
|
# define unlikely(x) __builtin_expect(!!(x), 0)
|
|
#endif
|
|
|
|
/* Optimization barrier */
|
|
#ifndef barrier
|
|
/* The "volatile" is due to gcc bugs */
|
|
# define barrier() __asm__ __volatile__("": : :"memory")
|
|
#endif
|
|
|
|
#ifndef barrier_data
|
|
/*
|
|
* This version is i.e. to prevent dead stores elimination on @ptr
|
|
* where gcc and llvm may behave differently when otherwise using
|
|
* normal barrier(): while gcc behavior gets along with a normal
|
|
* barrier(), llvm needs an explicit input variable to be assumed
|
|
* clobbered. The issue is as follows: while the inline asm might
|
|
* access any memory it wants, the compiler could have fit all of
|
|
* @ptr into memory registers instead, and since @ptr never escaped
|
|
* from that, it proved that the inline asm wasn't touching any of
|
|
* it. This version works well with both compilers, i.e. we're telling
|
|
* the compiler that the inline asm absolutely may see the contents
|
|
* of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
|
|
*/
|
|
# define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
|
|
#endif
|
|
|
|
/* workaround for GCC PR82365 if needed */
|
|
#ifndef barrier_before_unreachable
|
|
# define barrier_before_unreachable() do { } while (0)
|
|
#endif
|
|
|
|
/* Unreachable code */
|
|
#ifdef CONFIG_STACK_VALIDATION
|
|
/*
|
|
* These macros help objtool understand GCC code flow for unreachable code.
|
|
* The __COUNTER__ based labels are a hack to make each instance of the macros
|
|
* unique, to convince GCC not to merge duplicate inline asm statements.
|
|
*/
|
|
#define annotate_reachable() ({ \
|
|
asm volatile("%c0:\n\t" \
|
|
".pushsection .discard.reachable\n\t" \
|
|
".long %c0b - .\n\t" \
|
|
".popsection\n\t" : : "i" (__COUNTER__)); \
|
|
})
|
|
#define annotate_unreachable() ({ \
|
|
asm volatile("%c0:\n\t" \
|
|
".pushsection .discard.unreachable\n\t" \
|
|
".long %c0b - .\n\t" \
|
|
".popsection\n\t" : : "i" (__COUNTER__)); \
|
|
})
|
|
#define ASM_UNREACHABLE \
|
|
"999:\n\t" \
|
|
".pushsection .discard.unreachable\n\t" \
|
|
".long 999b - .\n\t" \
|
|
".popsection\n\t"
|
|
|
|
#ifdef CONFIG_DEBUG_ENTRY
|
|
/* Begin/end of an instrumentation safe region */
|
|
#define instrumentation_begin() ({ \
|
|
asm volatile("%c0:\n\t" \
|
|
".pushsection .discard.instr_begin\n\t" \
|
|
".long %c0b - .\n\t" \
|
|
".popsection\n\t" : : "i" (__COUNTER__)); \
|
|
})
|
|
|
|
/*
|
|
* Because instrumentation_{begin,end}() can nest, objtool validation considers
|
|
* _begin() a +1 and _end() a -1 and computes a sum over the instructions.
|
|
* When the value is greater than 0, we consider instrumentation allowed.
|
|
*
|
|
* There is a problem with code like:
|
|
*
|
|
* noinstr void foo()
|
|
* {
|
|
* instrumentation_begin();
|
|
* ...
|
|
* if (cond) {
|
|
* instrumentation_begin();
|
|
* ...
|
|
* instrumentation_end();
|
|
* }
|
|
* bar();
|
|
* instrumentation_end();
|
|
* }
|
|
*
|
|
* If instrumentation_end() would be an empty label, like all the other
|
|
* annotations, the inner _end(), which is at the end of a conditional block,
|
|
* would land on the instruction after the block.
|
|
*
|
|
* If we then consider the sum of the !cond path, we'll see that the call to
|
|
* bar() is with a 0-value, even though, we meant it to happen with a positive
|
|
* value.
|
|
*
|
|
* To avoid this, have _end() be a NOP instruction, this ensures it will be
|
|
* part of the condition block and does not escape.
|
|
*/
|
|
#define instrumentation_end() ({ \
|
|
asm volatile("%c0: nop\n\t" \
|
|
".pushsection .discard.instr_end\n\t" \
|
|
".long %c0b - .\n\t" \
|
|
".popsection\n\t" : : "i" (__COUNTER__)); \
|
|
})
|
|
#endif /* CONFIG_DEBUG_ENTRY */
|
|
|
|
#else
|
|
#define annotate_reachable()
|
|
#define annotate_unreachable()
|
|
#endif
|
|
|
|
#ifndef instrumentation_begin
|
|
#define instrumentation_begin() do { } while(0)
|
|
#define instrumentation_end() do { } while(0)
|
|
#endif
|
|
|
|
#ifndef ASM_UNREACHABLE
|
|
# define ASM_UNREACHABLE
|
|
#endif
|
|
#ifndef unreachable
|
|
# define unreachable() do { \
|
|
annotate_unreachable(); \
|
|
__builtin_unreachable(); \
|
|
} while (0)
|
|
#endif
|
|
|
|
/*
|
|
* KENTRY - kernel entry point
|
|
* This can be used to annotate symbols (functions or data) that are used
|
|
* without their linker symbol being referenced explicitly. For example,
|
|
* interrupt vector handlers, or functions in the kernel image that are found
|
|
* programatically.
|
|
*
|
|
* Not required for symbols exported with EXPORT_SYMBOL, or initcalls. Those
|
|
* are handled in their own way (with KEEP() in linker scripts).
|
|
*
|
|
* KENTRY can be avoided if the symbols in question are marked as KEEP() in the
|
|
* linker script. For example an architecture could KEEP() its entire
|
|
* boot/exception vector code rather than annotate each function and data.
|
|
*/
|
|
#ifndef KENTRY
|
|
# define KENTRY(sym) \
|
|
extern typeof(sym) sym; \
|
|
static const unsigned long __kentry_##sym \
|
|
__used \
|
|
__attribute__((section("___kentry" "+" #sym ), used)) \
|
|
= (unsigned long)&sym;
|
|
#endif
|
|
|
|
#ifndef RELOC_HIDE
|
|
# define RELOC_HIDE(ptr, off) \
|
|
({ unsigned long __ptr; \
|
|
__ptr = (unsigned long) (ptr); \
|
|
(typeof(ptr)) (__ptr + (off)); })
|
|
#endif
|
|
|
|
#define absolute_pointer(val) RELOC_HIDE((void *)(val), 0)
|
|
|
|
#ifndef OPTIMIZER_HIDE_VAR
|
|
/* Make the optimizer believe the variable can be manipulated arbitrarily. */
|
|
#define OPTIMIZER_HIDE_VAR(var) \
|
|
__asm__ ("" : "=r" (var) : "0" (var))
|
|
#endif
|
|
|
|
/* Not-quite-unique ID. */
|
|
#ifndef __UNIQUE_ID
|
|
# define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__)
|
|
#endif
|
|
|
|
#include <uapi/linux/types.h>
|
|
|
|
#define __READ_ONCE_SIZE \
|
|
({ \
|
|
switch (size) { \
|
|
case 1: *(__u8 *)res = *(volatile __u8 *)p; break; \
|
|
case 2: *(__u16 *)res = *(volatile __u16 *)p; break; \
|
|
case 4: *(__u32 *)res = *(volatile __u32 *)p; break; \
|
|
case 8: *(__u64 *)res = *(volatile __u64 *)p; break; \
|
|
default: \
|
|
barrier(); \
|
|
__builtin_memcpy((void *)res, (const void *)p, size); \
|
|
barrier(); \
|
|
} \
|
|
})
|
|
|
|
static __always_inline
|
|
void __read_once_size(const volatile void *p, void *res, int size)
|
|
{
|
|
__READ_ONCE_SIZE;
|
|
}
|
|
|
|
#ifdef CONFIG_KASAN
|
|
/*
|
|
* We can't declare function 'inline' because __no_sanitize_address confilcts
|
|
* with inlining. Attempt to inline it may cause a build failure.
|
|
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368
|
|
* '__maybe_unused' allows us to avoid defined-but-not-used warnings.
|
|
*/
|
|
# define __no_kasan_or_inline __no_sanitize_address notrace __maybe_unused
|
|
#else
|
|
# define __no_kasan_or_inline __always_inline
|
|
#endif
|
|
|
|
static __no_kasan_or_inline
|
|
void __read_once_size_nocheck(const volatile void *p, void *res, int size)
|
|
{
|
|
__READ_ONCE_SIZE;
|
|
}
|
|
|
|
static __always_inline void __write_once_size(volatile void *p, void *res, int size)
|
|
{
|
|
switch (size) {
|
|
case 1: *(volatile __u8 *)p = *(__u8 *)res; break;
|
|
case 2: *(volatile __u16 *)p = *(__u16 *)res; break;
|
|
case 4: *(volatile __u32 *)p = *(__u32 *)res; break;
|
|
case 8: *(volatile __u64 *)p = *(__u64 *)res; break;
|
|
default:
|
|
barrier();
|
|
__builtin_memcpy((void *)p, (const void *)res, size);
|
|
barrier();
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Prevent the compiler from merging or refetching reads or writes. The
|
|
* compiler is also forbidden from reordering successive instances of
|
|
* READ_ONCE and WRITE_ONCE, but only when the compiler is aware of some
|
|
* particular ordering. One way to make the compiler aware of ordering is to
|
|
* put the two invocations of READ_ONCE or WRITE_ONCE in different C
|
|
* statements.
|
|
*
|
|
* These two macros will also work on aggregate data types like structs or
|
|
* unions. If the size of the accessed data type exceeds the word size of
|
|
* the machine (e.g., 32 bits or 64 bits) READ_ONCE() and WRITE_ONCE() will
|
|
* fall back to memcpy(). There's at least two memcpy()s: one for the
|
|
* __builtin_memcpy() and then one for the macro doing the copy of variable
|
|
* - '__u' allocated on the stack.
|
|
*
|
|
* Their two major use cases are: (1) Mediating communication between
|
|
* process-level code and irq/NMI handlers, all running on the same CPU,
|
|
* and (2) Ensuring that the compiler does not fold, spindle, or otherwise
|
|
* mutilate accesses that either do not require ordering or that interact
|
|
* with an explicit memory barrier or atomic instruction that provides the
|
|
* required ordering.
|
|
*/
|
|
#include <asm/barrier.h>
|
|
#include <linux/kasan-checks.h>
|
|
|
|
#define __READ_ONCE(x, check) \
|
|
({ \
|
|
union { typeof(x) __val; char __c[1]; } __u; \
|
|
if (check) \
|
|
__read_once_size(&(x), __u.__c, sizeof(x)); \
|
|
else \
|
|
__read_once_size_nocheck(&(x), __u.__c, sizeof(x)); \
|
|
smp_read_barrier_depends(); /* Enforce dependency ordering from x */ \
|
|
__u.__val; \
|
|
})
|
|
#define READ_ONCE(x) __READ_ONCE(x, 1)
|
|
|
|
/*
|
|
* Use READ_ONCE_NOCHECK() instead of READ_ONCE() if you need
|
|
* to hide memory access from KASAN.
|
|
*/
|
|
#define READ_ONCE_NOCHECK(x) __READ_ONCE(x, 0)
|
|
|
|
static __no_kasan_or_inline
|
|
unsigned long read_word_at_a_time(const void *addr)
|
|
{
|
|
kasan_check_read(addr, 1);
|
|
return *(unsigned long *)addr;
|
|
}
|
|
|
|
#define WRITE_ONCE(x, val) \
|
|
({ \
|
|
union { typeof(x) __val; char __c[1]; } __u = \
|
|
{ .__val = (__force typeof(x)) (val) }; \
|
|
__write_once_size(&(x), __u.__c, sizeof(x)); \
|
|
__u.__val; \
|
|
})
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
/*
|
|
* Force the compiler to emit 'sym' as a symbol, so that we can reference
|
|
* it from inline assembler. Necessary in case 'sym' could be inlined
|
|
* otherwise, or eliminated entirely due to lack of references that are
|
|
* visible to the compiler.
|
|
*/
|
|
#define __ADDRESSABLE(sym) \
|
|
static void * __attribute__((section(".discard.addressable"), used)) \
|
|
__PASTE(__addressable_##sym, __LINE__) = (void *)&sym;
|
|
|
|
/**
|
|
* offset_to_ptr - convert a relative memory offset to an absolute pointer
|
|
* @off: the address of the 32-bit offset value
|
|
*/
|
|
static inline void *offset_to_ptr(const int *off)
|
|
{
|
|
return (void *)((unsigned long)off + *off);
|
|
}
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
|
|
#ifndef __optimize
|
|
# define __optimize(level)
|
|
#endif
|
|
|
|
/* Compile time object size, -1 for unknown */
|
|
#ifndef __compiletime_object_size
|
|
# define __compiletime_object_size(obj) -1
|
|
#endif
|
|
#ifndef __compiletime_warning
|
|
# define __compiletime_warning(message)
|
|
#endif
|
|
#ifndef __compiletime_error
|
|
# define __compiletime_error(message)
|
|
#endif
|
|
|
|
#ifdef __OPTIMIZE__
|
|
# define __compiletime_assert(condition, msg, prefix, suffix) \
|
|
do { \
|
|
extern void prefix ## suffix(void) __compiletime_error(msg); \
|
|
if (!(condition)) \
|
|
prefix ## suffix(); \
|
|
} while (0)
|
|
#else
|
|
# define __compiletime_assert(condition, msg, prefix, suffix) do { } while (0)
|
|
#endif
|
|
|
|
#define _compiletime_assert(condition, msg, prefix, suffix) \
|
|
__compiletime_assert(condition, msg, prefix, suffix)
|
|
|
|
/**
|
|
* compiletime_assert - break build and emit msg if condition is false
|
|
* @condition: a compile-time constant condition to check
|
|
* @msg: a message to emit if condition is false
|
|
*
|
|
* In tradition of POSIX assert, this macro will break the build if the
|
|
* supplied condition is *false*, emitting the supplied error message if the
|
|
* compiler has support to do so.
|
|
*/
|
|
#define compiletime_assert(condition, msg) \
|
|
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
|
|
|
|
#define compiletime_assert_atomic_type(t) \
|
|
compiletime_assert(__native_word(t), \
|
|
"Need native word sized stores/loads for atomicity.")
|
|
|
|
/*
|
|
* This is needed in functions which generate the stack canary, see
|
|
* arch/x86/kernel/smpboot.c::start_secondary() for an example.
|
|
*/
|
|
#define prevent_tail_call_optimization() mb()
|
|
|
|
#endif /* __LINUX_COMPILER_H */
|