Changes in 4.9.180 ext4: do not delete unlinked inode from orphan list on failed truncate KVM: x86: fix return value for reserved EFER bio: fix improper use of smp_mb__before_atomic() Revert "scsi: sd: Keep disk read-only when re-reading partition" crypto: vmx - CTR: always increment IV as quadword kvm: svm/avic: fix off-by-one in checking host APIC ID libnvdimm/namespace: Fix label tracking error arm64: Save and restore OSDLR_EL1 across suspend/resume gfs2: Fix sign extension bug in gfs2_update_stats Btrfs: do not abort transaction at btrfs_update_root() after failure to COW path Btrfs: fix race between ranged fsync and writeback of adjacent ranges btrfs: sysfs: don't leak memory when failing add fsid fbdev: fix divide error in fb_var_to_videomode hugetlb: use same fault hash key for shared and private mappings fbdev: fix WARNING in __alloc_pages_nodemask bug media: cpia2: Fix use-after-free in cpia2_exit media: vivid: use vfree() instead of kfree() for dev->bitmap_cap ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit at76c50x-usb: Don't register led_trigger if usb_register_driver failed perf tools: No need to include bitops.h in util.h tools include: Adopt linux/bits.h Revert "btrfs: Honour FITRIM range constraints during free space trim" gfs2: Fix lru_count going negative cxgb4: Fix error path in cxgb4_init_module mmc: core: Verify SD bus width dmaengine: tegra210-dma: free dma controller in remove() net: ena: gcc 8: fix compilation warning ASoC: hdmi-codec: unlock the device on startup errors powerpc/boot: Fix missing check of lseek() return value ASoC: imx: fix fiq dependencies spi: pxa2xx: fix SCR (divisor) calculation brcm80211: potential NULL dereference in brcmf_cfg80211_vndr_cmds_dcmd_handler() ARM: vdso: Remove dependency with the arch_timer driver internals arm64: Fix compiler warning from pte_unmap() with -Wunused-but-set-variable sched/cpufreq: Fix kobject memleak scsi: qla2xxx: Fix a qla24xx_enable_msix() error path iwlwifi: pcie: don't crash on invalid RX interrupt rtc: 88pm860x: prevent use-after-free on device remove w1: fix the resume command API dmaengine: pl330: _stop: clear interrupt status mac80211/cfg80211: update bss channel on channel switch ASoC: fsl_sai: Update is_slave_mode with correct value mwifiex: prevent an array overflow net: cw1200: fix a NULL pointer dereference crypto: sun4i-ss - Fix invalid calculation of hash end bcache: return error immediately in bch_journal_replay() bcache: fix failure in journal relplay bcache: add failure check to run_cache_set() for journal replay bcache: avoid clang -Wunintialized warning x86/build: Move _etext to actual end of .text smpboot: Place the __percpu annotation correctly x86/mm: Remove in_nmi() warning from 64-bit implementation of vmalloc_fault() mm/uaccess: Use 'unsigned long' to placate UBSAN warnings on older GCC versions HID: logitech-hidpp: use RAP instead of FAP to get the protocol version pinctrl: pistachio: fix leaked of_node references dmaengine: at_xdmac: remove BUG_ON macro in tasklet media: coda: clear error return value before picture run media: ov6650: Move v4l2_clk_get() to ov6650_video_probe() helper media: au0828: stop video streaming only when last user stops media: ov2659: make S_FMT succeed even if requested format doesn't match audit: fix a memory leak bug media: au0828: Fix NULL pointer dereference in au0828_analog_stream_enable() media: pvrusb2: Prevent a buffer overflow powerpc/numa: improve control of topology updates sched/core: Check quota and period overflow at usec to nsec conversion sched/core: Handle overflow in cpu_shares_write_u64 USB: core: Don't unbind interfaces following device reset failure x86/irq/64: Limit IST stack overflow check to #DB stack i40e: don't allow changes to HW VLAN stripping on active port VLANs arm64: vdso: Fix clock_getres() for CLOCK_REALTIME RDMA/cxgb4: Fix null pointer dereference on alloc_skb failure hwmon: (vt1211) Use request_muxed_region for Super-IO accesses hwmon: (smsc47m1) Use request_muxed_region for Super-IO accesses hwmon: (smsc47b397) Use request_muxed_region for Super-IO accesses hwmon: (pc87427) Use request_muxed_region for Super-IO accesses hwmon: (f71805f) Use request_muxed_region for Super-IO accesses scsi: libsas: Do discovery on empty PHY to update PHY info mmc: core: make pwrseq_emmc (partially) support sleepy GPIO controllers mmc_spi: add a status check for spi_sync_locked mmc: sdhci-of-esdhc: add erratum eSDHC5 support mmc: sdhci-of-esdhc: add erratum eSDHC-A001 and A-008358 support PM / core: Propagate dev->power.wakeup_path when no callbacks extcon: arizona: Disable mic detect if running when driver is removed s390: cio: fix cio_irb declaration cpufreq: ppc_cbe: fix possible object reference leak cpufreq/pasemi: fix possible object reference leak cpufreq: pmac32: fix possible object reference leak x86/build: Keep local relocations with ld.lld iio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertion iio: hmc5843: fix potential NULL pointer dereferences iio: common: ssp_sensors: Initialize calculated_time in ssp_common_process_data rtlwifi: fix a potential NULL pointer dereference mwifiex: Fix mem leak in mwifiex_tm_cmd brcmfmac: fix missing checks for kmemdup b43: shut up clang -Wuninitialized variable warning brcmfmac: convert dev_init_lock mutex to completion brcmfmac: fix race during disconnect when USB completion is in progress brcmfmac: fix Oops when bringing up interface during USB disconnect scsi: ufs: Fix regulator load and icc-level configuration scsi: ufs: Avoid configuring regulator with undefined voltage range arm64: cpu_ops: fix a leaked reference by adding missing of_node_put x86/uaccess, signal: Fix AC=1 bloat x86/ia32: Fix ia32_restore_sigcontext() AC leak chardev: add additional check for minor range overlap HID: core: move Usage Page concatenation to Main item ASoC: eukrea-tlv320: fix a leaked reference by adding missing of_node_put ASoC: fsl_utils: fix a leaked reference by adding missing of_node_put cxgb3/l2t: Fix undefined behaviour spi: tegra114: reset controller on probe media: wl128x: prevent two potential buffer overflows virtio_console: initialize vtermno value for ports tty: ipwireless: fix missing checks for ioremap x86/mce: Fix machine_check_poll() tests for error types rcutorture: Fix cleanup path for invalid torture_type strings rcuperf: Fix cleanup path for invalid perf_type strings usb: core: Add PM runtime calls to usb_hcd_platform_shutdown scsi: qla4xxx: avoid freeing unallocated dma memory dmaengine: tegra210-adma: use devm_clk_*() helpers media: m88ds3103: serialize reset messages in m88ds3103_set_frontend media: go7007: avoid clang frame overflow warning with KASAN scsi: lpfc: Fix FDMI manufacturer attribute value media: saa7146: avoid high stack usage with clang scsi: lpfc: Fix SLI3 commands being issued on SLI4 devices spi : spi-topcliff-pch: Fix to handle empty DMA buffers spi: rspi: Fix sequencer reset during initialization spi: Fix zero length xfer bug ASoC: davinci-mcasp: Fix clang warning without CONFIG_PM drm: Wake up next in drm_read() chain if we are forced to putback the event Linux 4.9.180 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
328 lines
8.0 KiB
ArmAsm
328 lines
8.0 KiB
ArmAsm
/*
|
|
* Userspace implementations of gettimeofday() and friends.
|
|
*
|
|
* Copyright (C) 2012 ARM Limited
|
|
*
|
|
* 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.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* Author: Will Deacon <will.deacon@arm.com>
|
|
*/
|
|
|
|
#include <linux/linkage.h>
|
|
#include <asm/asm-offsets.h>
|
|
#include <asm/unistd.h>
|
|
|
|
#define NSEC_PER_SEC_LO16 0xca00
|
|
#define NSEC_PER_SEC_HI16 0x3b9a
|
|
|
|
vdso_data .req x6
|
|
seqcnt .req w7
|
|
w_tmp .req w8
|
|
x_tmp .req x8
|
|
|
|
/*
|
|
* Conventions for macro arguments:
|
|
* - An argument is write-only if its name starts with "res".
|
|
* - All other arguments are read-only, unless otherwise specified.
|
|
*/
|
|
|
|
.macro seqcnt_acquire
|
|
9999: ldr seqcnt, [vdso_data, #VDSO_TB_SEQ_COUNT]
|
|
tbnz seqcnt, #0, 9999b
|
|
dmb ishld
|
|
.endm
|
|
|
|
.macro seqcnt_check fail
|
|
dmb ishld
|
|
ldr w_tmp, [vdso_data, #VDSO_TB_SEQ_COUNT]
|
|
cmp w_tmp, seqcnt
|
|
b.ne \fail
|
|
.endm
|
|
|
|
.macro syscall_check fail
|
|
ldr w_tmp, [vdso_data, #VDSO_USE_SYSCALL]
|
|
cbnz w_tmp, \fail
|
|
.endm
|
|
|
|
.macro get_nsec_per_sec res
|
|
mov \res, #NSEC_PER_SEC_LO16
|
|
movk \res, #NSEC_PER_SEC_HI16, lsl #16
|
|
.endm
|
|
|
|
/*
|
|
* Returns the clock delta, in nanoseconds left-shifted by the clock
|
|
* shift.
|
|
*/
|
|
.macro get_clock_shifted_nsec res, cycle_last, mult
|
|
/* Read the virtual counter. */
|
|
isb
|
|
mrs x_tmp, cntvct_el0
|
|
/* Calculate cycle delta and convert to ns. */
|
|
sub \res, x_tmp, \cycle_last
|
|
/* We can only guarantee 56 bits of precision. */
|
|
movn x_tmp, #0xff00, lsl #48
|
|
and \res, x_tmp, \res
|
|
mul \res, \res, \mult
|
|
.endm
|
|
|
|
/*
|
|
* Returns in res_{sec,nsec} the REALTIME timespec, based on the
|
|
* "wall time" (xtime) and the clock_mono delta.
|
|
*/
|
|
.macro get_ts_realtime res_sec, res_nsec, \
|
|
clock_nsec, xtime_sec, xtime_nsec, nsec_to_sec
|
|
add \res_nsec, \clock_nsec, \xtime_nsec
|
|
udiv x_tmp, \res_nsec, \nsec_to_sec
|
|
add \res_sec, \xtime_sec, x_tmp
|
|
msub \res_nsec, x_tmp, \nsec_to_sec, \res_nsec
|
|
.endm
|
|
|
|
/*
|
|
* Returns in res_{sec,nsec} the timespec based on the clock_raw delta,
|
|
* used for CLOCK_MONOTONIC_RAW.
|
|
*/
|
|
.macro get_ts_clock_raw res_sec, res_nsec, clock_nsec, nsec_to_sec
|
|
udiv \res_sec, \clock_nsec, \nsec_to_sec
|
|
msub \res_nsec, \res_sec, \nsec_to_sec, \clock_nsec
|
|
.endm
|
|
|
|
/* sec and nsec are modified in place. */
|
|
.macro add_ts sec, nsec, ts_sec, ts_nsec, nsec_to_sec
|
|
/* Add timespec. */
|
|
add \sec, \sec, \ts_sec
|
|
add \nsec, \nsec, \ts_nsec
|
|
|
|
/* Normalise the new timespec. */
|
|
cmp \nsec, \nsec_to_sec
|
|
b.lt 9999f
|
|
sub \nsec, \nsec, \nsec_to_sec
|
|
add \sec, \sec, #1
|
|
9999:
|
|
cmp \nsec, #0
|
|
b.ge 9998f
|
|
add \nsec, \nsec, \nsec_to_sec
|
|
sub \sec, \sec, #1
|
|
9998:
|
|
.endm
|
|
|
|
.macro clock_gettime_return, shift=0
|
|
.if \shift == 1
|
|
lsr x11, x11, x12
|
|
.endif
|
|
stp x10, x11, [x1, #TSPEC_TV_SEC]
|
|
mov x0, xzr
|
|
ret
|
|
.endm
|
|
|
|
.macro jump_slot jumptable, index, label
|
|
.if (. - \jumptable) != 4 * (\index)
|
|
.error "Jump slot index mismatch"
|
|
.endif
|
|
b \label
|
|
.endm
|
|
|
|
.text
|
|
|
|
/* int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz); */
|
|
ENTRY(__kernel_gettimeofday)
|
|
.cfi_startproc
|
|
adr vdso_data, _vdso_data
|
|
/* If tv is NULL, skip to the timezone code. */
|
|
cbz x0, 2f
|
|
|
|
/* Compute the time of day. */
|
|
1: seqcnt_acquire
|
|
syscall_check fail=4f
|
|
ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST]
|
|
/* w11 = cs_mono_mult, w12 = cs_shift */
|
|
ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT]
|
|
ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC]
|
|
seqcnt_check fail=1b
|
|
|
|
get_nsec_per_sec res=x9
|
|
lsl x9, x9, x12
|
|
|
|
get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11
|
|
get_ts_realtime res_sec=x10, res_nsec=x11, \
|
|
clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9
|
|
|
|
/* Convert ns to us. */
|
|
mov x13, #1000
|
|
lsl x13, x13, x12
|
|
udiv x11, x11, x13
|
|
stp x10, x11, [x0, #TVAL_TV_SEC]
|
|
2:
|
|
/* If tz is NULL, return 0. */
|
|
cbz x1, 3f
|
|
ldp w4, w5, [vdso_data, #VDSO_TZ_MINWEST]
|
|
stp w4, w5, [x1, #TZ_MINWEST]
|
|
3:
|
|
mov x0, xzr
|
|
ret
|
|
4:
|
|
/* Syscall fallback. */
|
|
mov x8, #__NR_gettimeofday
|
|
svc #0
|
|
ret
|
|
.cfi_endproc
|
|
ENDPROC(__kernel_gettimeofday)
|
|
|
|
#define JUMPSLOT_MAX CLOCK_MONOTONIC_COARSE
|
|
|
|
/* int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp); */
|
|
ENTRY(__kernel_clock_gettime)
|
|
.cfi_startproc
|
|
cmp w0, #JUMPSLOT_MAX
|
|
b.hi syscall
|
|
adr vdso_data, _vdso_data
|
|
adr x_tmp, jumptable
|
|
add x_tmp, x_tmp, w0, uxtw #2
|
|
br x_tmp
|
|
|
|
ALIGN
|
|
jumptable:
|
|
jump_slot jumptable, CLOCK_REALTIME, realtime
|
|
jump_slot jumptable, CLOCK_MONOTONIC, monotonic
|
|
b syscall
|
|
b syscall
|
|
jump_slot jumptable, CLOCK_MONOTONIC_RAW, monotonic_raw
|
|
jump_slot jumptable, CLOCK_REALTIME_COARSE, realtime_coarse
|
|
jump_slot jumptable, CLOCK_MONOTONIC_COARSE, monotonic_coarse
|
|
|
|
.if (. - jumptable) != 4 * (JUMPSLOT_MAX + 1)
|
|
.error "Wrong jumptable size"
|
|
.endif
|
|
|
|
ALIGN
|
|
realtime:
|
|
seqcnt_acquire
|
|
syscall_check fail=syscall
|
|
ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST]
|
|
/* w11 = cs_mono_mult, w12 = cs_shift */
|
|
ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT]
|
|
ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC]
|
|
seqcnt_check fail=realtime
|
|
|
|
/* All computations are done with left-shifted nsecs. */
|
|
get_nsec_per_sec res=x9
|
|
lsl x9, x9, x12
|
|
|
|
get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11
|
|
get_ts_realtime res_sec=x10, res_nsec=x11, \
|
|
clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9
|
|
clock_gettime_return, shift=1
|
|
|
|
ALIGN
|
|
monotonic:
|
|
seqcnt_acquire
|
|
syscall_check fail=syscall
|
|
ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST]
|
|
/* w11 = cs_mono_mult, w12 = cs_shift */
|
|
ldp w11, w12, [vdso_data, #VDSO_CS_MONO_MULT]
|
|
ldp x13, x14, [vdso_data, #VDSO_XTIME_CLK_SEC]
|
|
ldp x3, x4, [vdso_data, #VDSO_WTM_CLK_SEC]
|
|
seqcnt_check fail=monotonic
|
|
|
|
/* All computations are done with left-shifted nsecs. */
|
|
lsl x4, x4, x12
|
|
get_nsec_per_sec res=x9
|
|
lsl x9, x9, x12
|
|
|
|
get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11
|
|
get_ts_realtime res_sec=x10, res_nsec=x11, \
|
|
clock_nsec=x15, xtime_sec=x13, xtime_nsec=x14, nsec_to_sec=x9
|
|
|
|
add_ts sec=x10, nsec=x11, ts_sec=x3, ts_nsec=x4, nsec_to_sec=x9
|
|
clock_gettime_return, shift=1
|
|
|
|
ALIGN
|
|
monotonic_raw:
|
|
seqcnt_acquire
|
|
syscall_check fail=syscall
|
|
ldr x10, [vdso_data, #VDSO_CS_CYCLE_LAST]
|
|
/* w11 = cs_raw_mult, w12 = cs_shift */
|
|
ldp w12, w11, [vdso_data, #VDSO_CS_SHIFT]
|
|
ldp x13, x14, [vdso_data, #VDSO_RAW_TIME_SEC]
|
|
seqcnt_check fail=monotonic_raw
|
|
|
|
/* All computations are done with left-shifted nsecs. */
|
|
get_nsec_per_sec res=x9
|
|
lsl x9, x9, x12
|
|
|
|
get_clock_shifted_nsec res=x15, cycle_last=x10, mult=x11
|
|
get_ts_clock_raw res_sec=x10, res_nsec=x11, \
|
|
clock_nsec=x15, nsec_to_sec=x9
|
|
|
|
add_ts sec=x10, nsec=x11, ts_sec=x13, ts_nsec=x14, nsec_to_sec=x9
|
|
clock_gettime_return, shift=1
|
|
|
|
ALIGN
|
|
realtime_coarse:
|
|
seqcnt_acquire
|
|
ldp x10, x11, [vdso_data, #VDSO_XTIME_CRS_SEC]
|
|
seqcnt_check fail=realtime_coarse
|
|
clock_gettime_return
|
|
|
|
ALIGN
|
|
monotonic_coarse:
|
|
seqcnt_acquire
|
|
ldp x10, x11, [vdso_data, #VDSO_XTIME_CRS_SEC]
|
|
ldp x13, x14, [vdso_data, #VDSO_WTM_CLK_SEC]
|
|
seqcnt_check fail=monotonic_coarse
|
|
|
|
/* Computations are done in (non-shifted) nsecs. */
|
|
get_nsec_per_sec res=x9
|
|
add_ts sec=x10, nsec=x11, ts_sec=x13, ts_nsec=x14, nsec_to_sec=x9
|
|
clock_gettime_return
|
|
|
|
ALIGN
|
|
syscall: /* Syscall fallback. */
|
|
mov x8, #__NR_clock_gettime
|
|
svc #0
|
|
ret
|
|
.cfi_endproc
|
|
ENDPROC(__kernel_clock_gettime)
|
|
|
|
/* int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); */
|
|
ENTRY(__kernel_clock_getres)
|
|
.cfi_startproc
|
|
cmp w0, #CLOCK_REALTIME
|
|
ccmp w0, #CLOCK_MONOTONIC, #0x4, ne
|
|
ccmp w0, #CLOCK_MONOTONIC_RAW, #0x4, ne
|
|
b.ne 1f
|
|
|
|
adr vdso_data, _vdso_data
|
|
ldr w2, [vdso_data, #CLOCK_REALTIME_RES]
|
|
b 2f
|
|
1:
|
|
cmp w0, #CLOCK_REALTIME_COARSE
|
|
ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne
|
|
b.ne 4f
|
|
ldr x2, 5f
|
|
2:
|
|
cbz x1, 3f
|
|
stp xzr, x2, [x1]
|
|
|
|
3: /* res == NULL. */
|
|
mov w0, wzr
|
|
ret
|
|
|
|
4: /* Syscall fallback. */
|
|
mov x8, #__NR_clock_getres
|
|
svc #0
|
|
ret
|
|
5:
|
|
.quad CLOCK_COARSE_RES
|
|
.cfi_endproc
|
|
ENDPROC(__kernel_clock_getres)
|