4.9.215-stable review
Subsystems (7)
Greg Kroah-Hartman
maintainercover 4.9.215-stable review
This is the start of the stable review cycle for the 4.9.215 release. There are 165 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 29 Feb 2020 13:21:24 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.215-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.9.215-rc1
Nathan Chancellor <[email protected]>
s390/mm: Explicitly compare PAGE_DEFAULT_KEY against zero in storage_key_init_range
Thomas Gleixner <[email protected]>
xen: Enable interrupts when calling _cond_resched()
Prabhakar Kushwaha <[email protected]>
ata: ahci: Add shutdown to freeze hardware resources of ahci
Cong Wang <[email protected]>
netfilter: xt_hashlimit: limit the max size of hashtable
Takashi Iwai <[email protected]>
ALSA: seq: Fix concurrent access to queue current tick/time
Takashi Iwai <[email protected]>
ALSA: seq: Avoid concurrent access to queue flags
Takashi Iwai <[email protected]>
ALSA: rawmidi: Avoid bit fields for state flags
Aditya Pakki <[email protected]>
ecryptfs: replace BUG_ON with error handling code
Dan Carpenter <[email protected]>
staging: greybus: use after free in gb_audio_manager_remove_all()
Jack Pham <[email protected]>
usb: gadget: composite: Fix bMaxPower for SuperSpeedPlus
Bart Van Assche <[email protected]>
scsi: Revert "target: iscsi: Wait for all commands to finish before freeing a session"
Bart Van Assche <[email protected]>
scsi: Revert "RDMA/isert: Fix a recently introduced regression related to logout"
Filipe Manana <[email protected]>
Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
Miaohe Lin <[email protected]>
KVM: apic: avoid calculating pending eoi from an uninitialized val
Oliver Upton <[email protected]>
KVM: nVMX: Check IO instruction VM-exit conditions
Oliver Upton <[email protected]>
KVM: nVMX: Refactor IO bitmap checks into helper function
Eric Biggers <[email protected]>
ext4: fix race between writepages and enabling EXT4_EXTENTS_FL
Eric Biggers <[email protected]>
ext4: rename s_journal_flag_rwsem to s_writepages_rwsem
Jan Kara <[email protected]>
ext4: fix mount failure with quota configured as module
Shijie Luo <[email protected]>
ext4: add cond_resched() to __ext4_find_entry()
Qian Cai <[email protected]>
ext4: fix a data race in EXT4_I(inode)->i_disksize
Jann Horn <[email protected]>
netfilter: xt_bpf: add overflow checks
Paolo Bonzini <[email protected]>
KVM: nVMX: Don't emulate instructions in guest mode
Alexander Potapenko <[email protected]>
lib/stackdepot.c: fix global out-of-bounds in stack_slabs
Miles Chen <[email protected]>
lib/stackdepot: Fix outdated comments
Gustavo Luiz Duarte <[email protected]>
powerpc/tm: Fix clearing MSR[TS] in current when reclaiming on signal delivery
Gustavo Romero <[email protected]>
powerpc/tm: Fix endianness flip on trap
Michael Neuling <[email protected]>
powerpc/tm: P9 disable transactionally suspended sigcontexts
Eric Dumazet <[email protected]>
vt: vt_ioctl: fix race in VT_RESIZEX
Al Viro <[email protected]>
VT_RESIZEX: get rid of field-by-field copyin
Miaohe Lin <[email protected]>
KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI
Mathias Nyman <[email protected]>
xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms
Ioanna Alifieraki <[email protected]>
Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()"
Fugang Duan <[email protected]>
tty: serial: imx: setup the correct sg entry for tx dma
Nicolas Ferre <[email protected]>
tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode
Thomas Gleixner <[email protected]>
x86/mce/amd: Fix kobject lifetime
Borislav Petkov <[email protected]>
x86/mce/amd: Publish the bank pointer only after setup has succeeded
Larry Finger <[email protected]>
staging: rtl8188eu: Fix potential overuse of kernel memory
Larry Finger <[email protected]>
staging: rtl8188eu: Fix potential security hole
Alan Stern <[email protected]>
USB: hub: Don't record a connect-change event during reset-resume
Richard Dodd <[email protected]>
USB: Fix novation SourceControl XL after suspend
EJ Hsu <[email protected]>
usb: uas: fix a plug & unplug racing
Mathias Nyman <[email protected]>
xhci: Force Maximum Packet size for Full-speed bulk devices to valid range.
Malcolm Priestley <[email protected]>
staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi.
Suren Baghdasaryan <[email protected]>
staging: android: ashmem: Disallow ashmem memory from being remapped
Jiri Slaby <[email protected]>
vt: selection, handle pending signals in paste_selection
Linus Torvalds <[email protected]>
floppy: check FDC index for errors before assigning it
Davide Caratti <[email protected]>
net/sched: flower: add missing validation of TCA_FLOWER_FLAGS
Davide Caratti <[email protected]>
net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS
Firo Yang <[email protected]>
enic: prevent waking up stopped tx queues over watchdog reset
Jaihind Yadav <[email protected]>
selinux: ensure we cleanup the internal AVC counters on error in avc_update()
Vasily Averin <[email protected]>
help_next should increase position index
Zhiqiang Liu <[email protected]>
brd: check and limit max_part par
Shubhrajyoti Datta <[email protected]>
microblaze: Prevent the overflow of the start
Andrei Otcheretianski <[email protected]>
iwlwifi: mvm: Fix thermal zone registration
Zenghui Yu <[email protected]>
irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL
Coly Li <[email protected]>
bcache: explicity type cast in bset_bkey_last()
Yunfeng Ye <[email protected]>
reiserfs: prevent NULL pointer dereference in reiserfs_insert_item()
Nathan Chancellor <[email protected]>
lib/scatterlist.c: adjust indentation in __sg_alloc_table
wangyan <[email protected]>
ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans()
Daniel Vetter <[email protected]>
radeon: insert 10ms sleep in dce5_crtc_load_lut
Vasily Averin <[email protected]>
trigger_next should increase position index
Vasily Averin <[email protected]>
ftrace: fpid_next() should increase position index
Ben Skeggs <[email protected]>
drm/nouveau/disp/nv50-: prevent oops when no channel method map provided
Marc Zyngier <[email protected]>
irqchip/gic-v3: Only provision redistributors that are enabled in ACPI
Ronnie Sahlberg <[email protected]>
cifs: fix NULL dereference in match_prepath
Colin Ian King <[email protected]>
iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop
Nathan Chancellor <[email protected]>
hostap: Adjust indentation in prism2_hostapd_add_sta
Vincenzo Frascino <[email protected]>
ARM: 8951/1: Fix Kexec compilation issue.
zhangyi (F) <[email protected]>
jbd2: switch to use jbd2_journal_abort() when failed to submit the commit record
Oliver O'Halloran <[email protected]>
powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV
Peter Große <[email protected]>
ALSA: hda - Add docking station support for Lenovo Thinkpad T420s
Colin Ian King <[email protected]>
driver core: platform: fix u32 greater or equal to zero comparison
Vasily Gorbik <[email protected]>
s390/ftrace: generate traced function stack frame
Masami Hiramatsu <[email protected]>
x86/decoder: Add TEST opcode to Group3-2
Brandon Maier <[email protected]>
remoteproc: Initialize rproc_class before use
Dan Carpenter <[email protected]>
ide: serverworks: potential overflow in svwks_set_pio_mode()
Dan Carpenter <[email protected]>
cmd64x: potential buffer overflow in cmd64x_program_timings()
Uwe Kleine-König <[email protected]>
pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctional
Sami Tolvanen <[email protected]>
arm64: fix alternatives with LLVM's integrated assembler
Nick Black <[email protected]>
scsi: iscsi: Don't destroy session if there are outstanding connections
Will Deacon <[email protected]>
iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE
Tony Lindgren <[email protected]>
usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue
Navid Emamdoost <[email protected]>
drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
YueHaibing <[email protected]>
drm/nouveau: Fix copy-paste error in nouveau_fence_wait_uevent_handler
Ben Skeggs <[email protected]>
drm/nouveau/gr/gk20a,gm200-: add terminators to method lists read from fw
Arnd Bergmann <[email protected]>
vme: bridges: reduce stack usage
Geert Uytterhoeven <[email protected]>
driver core: Print device when resources present in really_probe()
Simon Schwartz <[email protected]>
driver core: platform: Prevent resouce overflow from causing infinite loops
Nathan Chancellor <[email protected]>
tty: synclink_gt: Adjust indentation in several functions
Nathan Chancellor <[email protected]>
tty: synclinkmp: Adjust indentation in several functions
Chen Zhou <[email protected]>
ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m
Arnd Bergmann <[email protected]>
wan: ixp4xx_hss: fix compile-testing on 64-bit
Philipp Zabel <[email protected]>
Input: edt-ft5x06 - work around first register access error
Paul E. McKenney <[email protected]>
rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls
Dmitry Osipenko <[email protected]>
soc/tegra: fuse: Correct straps' address for older Tegra124 device trees
Jan Kara <[email protected]>
udf: Fix free space reporting for metadata and virtual partitions
Shuah Khan <[email protected]>
usbip: Fix unsafe unaligned pointer usage
Andrey Zhizhikin <[email protected]>
tools lib api fs: Fix gcc9 stringop-truncation compilation error
Takashi Iwai <[email protected]>
ALSA: sh: Fix compile warning wrt const
Jiewei Ke <[email protected]>
RDMA/rxe: Fix error type of mmap_offset
Geert Uytterhoeven <[email protected]>
pinctrl: sh-pfc: sh7269: Fix CAN function GPIOs
Chanwoo Choi <[email protected]>
PM / devfreq: rk3399_dmc: Add COMPILE_TEST and HAVE_ARM_SMCCC dependency
Valdis Kletnieks <[email protected]>
x86/vdso: Provide missing include file
Geert Uytterhoeven <[email protected]>
ARM: dts: r8a7779: Add device node for ARM global timer
Bibby Hsieh <[email protected]>
drm/mediatek: handle events when enabling/disabling crtc
Nathan Chancellor <[email protected]>
scsi: aic7xxx: Adjust indentation in ahc_find_syncrate
Erik Kaneda <[email protected]>
ACPICA: Disassembler: create buffer fields in ACPI_PARSE_LOAD_PASS1
Aditya Pakki <[email protected]>
orinoco: avoid assertion in case of NULL pointer
Phong Tran <[email protected]>
rtlwifi: rtl_pci: Fix -Wcast-function-type
Phong Tran <[email protected]>
iwlegacy: Fix -Wcast-function-type
Phong Tran <[email protected]>
ipw2x00: Fix -Wcast-function-type
Phong Tran <[email protected]>
b43legacy: Fix -Wcast-function-type
Nathan Chancellor <[email protected]>
ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_status
Jan Kara <[email protected]>
reiserfs: Fix spurious unlock in reiserfs_fill_super() error handling
Nathan Chancellor <[email protected]>
media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros
Mao Wenan <[email protected]>
NFC: port100: Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu().
Navid Emamdoost <[email protected]>
PCI/IOV: Fix memory leak in pci_iov_add_virtfn()
Rasmus Villemoes <[email protected]>
net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
Miquel Raynal <[email protected]>
regulator: rk808: Lower log level on optional GPIOs being not available
yu kuai <[email protected]>
drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table
Douglas Anderson <[email protected]>
clk: qcom: rcg2: Don't crash if our parent can't be found; return an error
Masahiro Yamada <[email protected]>
kconfig: fix broken dependency in randconfig-generated .config
zhangyi (F) <[email protected]>
ext4, jbd2: ensure panic when aborting with zero errno
Steven Rostedt (VMware) <[email protected]>
tracing: Fix very unlikely race of registering two stat tracers
Luis Henriques <[email protected]>
tracing: Fix tracing_stat return values in error handling paths
Arvind Sankar <[email protected]>
x86/sysfb: Fix check for bad VRAM size
Kai Li <[email protected]>
jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal
Jia-Ju Bai <[email protected]>
usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe()
Jia-Ju Bai <[email protected]>
uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()
David S. Miller <[email protected]>
sparc: Add .exit.data section.
Tiezhu Yang <[email protected]>
MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
Ard Biesheuvel <[email protected]>
efi/x86: Map the entire EFI vendor string before copying it
Hans de Goede <[email protected]>
pinctrl: baytrail: Do not clear IRQ flags on direct-irq enabled pins
Jia-Ju Bai <[email protected]>
media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run()
Jia-Ju Bai <[email protected]>
gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_irq_map/unmap()
Oliver O'Halloran <[email protected]>
powerpc/powernv/iov: Ensure the pdn for VFs always contains a valid PE number
Eugen Hristev <[email protected]>
media: i2c: mt9v032: fix enum mbus codes and frame sizes
Christophe JAILLET <[email protected]>
pxa168fb: Fix the function used to release some memory in an error handling path
Geert Uytterhoeven <[email protected]>
pinctrl: sh-pfc: sh7264: Fix CAN function GPIOs
Vladimir Oltean <[email protected]>
gianfar: Fix TX timestamping with a stacked DSA driver
Dan Carpenter <[email protected]>
brcmfmac: Fix use after free in brcmf_sdio_readframes()
Peter Zijlstra <[email protected]>
cpu/hotplug, stop_machine: Fix stop_machine vs hotplug order
Paul Kocialkowski <[email protected]>
drm/gma500: Fixup fbdev stolen size usage evaluation
Sasha Levin <[email protected]>
Revert "KVM: VMX: Add non-canonical check on writes to RTIT address MSRs"
Allen Pais <[email protected]>
scsi: qla2xxx: fix a potential NULL pointer dereference
David Sterba <[email protected]>
btrfs: print message when tree-log replay starts
zhangyi (F) <[email protected]>
jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer
zhangyi (F) <[email protected]>
jbd2: move the clearing of b_modified flag to the journal_unmap_buffer()
Mike Jones <[email protected]>
hwmon: (pmbus/ltc2978) Fix PMBus polling of MFR_COMMON definitions.
Kan Liang <[email protected]>
perf/x86/intel: Fix inaccurate period in context switch for auto-reload
Nathan Chancellor <[email protected]>
s390/time: Fix clk type in get_tod_clock
Herbert Xu <[email protected]>
padata: Remove broken queue flushing
Kim Phillips <[email protected]>
perf/x86/amd: Add missing L2 misses event spec to AMD Family 17h's event map
David Sterba <[email protected]>
btrfs: log message when rw remount is attempted with unclean tree-log
Filipe Manana <[email protected]>
Btrfs: fix race between using extent maps and merging them
Theodore Ts'o <[email protected]>
ext4: improve explanation of a mount failure caused by a misconfigured kernel
Jan Kara <[email protected]>
ext4: fix checksum errors with indexed dirs
Andreas Dilger <[email protected]>
ext4: don't assume that mmp_nodename/bdevname have NUL
Arvind Sankar <[email protected]>
ALSA: usb-audio: Apply sample rate quirk for Audioengine D1
Wenwen Wang <[email protected]>
ecryptfs: fix a memory leak bug in ecryptfs_init_messaging()
Wenwen Wang <[email protected]>
ecryptfs: fix a memory leak bug in parse_tag_1_packet()
Takashi Iwai <[email protected]>
ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs
Paolo Bonzini <[email protected]>
KVM: x86: emulate RDPID
Andy Lutomirski <[email protected]>
x86/vdso: Use RDPID in preference to LSL when available
-------------
Diffstat:
Makefile | 4 +- arch/arm/Kconfig | 2 +- arch/arm/boot/dts/r8a7779.dtsi | 8 + arch/arm64/include/asm/alternative.h | 32 +- arch/microblaze/kernel/cpu/cache.c | 3 +- arch/mips/loongson64/loongson-3/platform.c | 3 + arch/powerpc/kernel/eeh_driver.c | 6 - arch/powerpc/kernel/pci_dn.c | 15 +- arch/powerpc/kernel/process.c | 2 + arch/powerpc/kernel/signal.c | 17 +- arch/powerpc/kernel/signal_32.c | 30 +- arch/powerpc/kernel/signal_64.c | 29 +- arch/powerpc/platforms/powernv/pci-ioda.c | 19 +- arch/powerpc/platforms/powernv/pci.c | 4 - arch/s390/include/asm/page.h | 2 +- arch/s390/include/asm/timex.h | 2 +- arch/s390/kernel/mcount.S | 15 +- arch/sh/include/cpu-sh2a/cpu/sh7269.h | 11 +- arch/sparc/kernel/vmlinux.lds.S | 6 +- arch/x86/entry/vdso/vdso32-setup.c | 1 + arch/x86/events/amd/core.c | 1 + arch/x86/events/intel/ds.c | 2 + arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/vgtod.h | 7 +- arch/x86/kernel/cpu/mcheck/mce_amd.c | 50 +- arch/x86/kernel/sysfb_simplefb.c | 2 +- arch/x86/kvm/cpuid.c | 7 +- arch/x86/kvm/emulate.c | 22 +- arch/x86/kvm/irq_comm.c | 2 +- arch/x86/kvm/lapic.c | 4 +- arch/x86/kvm/vmx.c | 102 +- arch/x86/kvm/vmx/vmx.c | 8033 -------------------- arch/x86/lib/x86-opcode-map.txt | 2 +- arch/x86/platform/efi/efi.c | 13 +- drivers/acpi/acpica/dsfield.c | 2 +- drivers/acpi/acpica/dswload.c | 21 + drivers/ata/ahci.c | 7 + drivers/ata/libata-core.c | 21 + drivers/base/dd.c | 5 +- drivers/base/platform.c | 12 +- drivers/block/brd.c | 22 +- drivers/block/floppy.c | 7 +- drivers/clk/qcom/clk-rcg2.c | 3 + drivers/devfreq/Kconfig | 3 +- drivers/devfreq/event/Kconfig | 2 +- drivers/gpio/gpio-grgpio.c | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 19 +- drivers/gpu/drm/gma500/framebuffer.c | 8 +- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 8 + drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +- .../gpu/drm/nouveau/nvkm/engine/disp/channv50.c | 2 + drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c | 21 +- drivers/gpu/drm/radeon/radeon_display.c | 2 + drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +- drivers/hwmon/pmbus/ltc2978.c | 4 +- drivers/ide/cmd64x.c | 3 + drivers/ide/serverworks.c | 6 + drivers/infiniband/sw/rxe/rxe_verbs.h | 2 +- drivers/infiniband/ulp/isert/ib_isert.c | 12 + drivers/input/touchscreen/edt-ft5x06.c | 7 + drivers/iommu/arm-smmu-v3.c | 3 +- drivers/irqchip/irq-gic-v3-its.c | 2 +- drivers/irqchip/irq-gic-v3.c | 9 +- drivers/md/bcache/bset.h | 3 +- drivers/media/i2c/mt9v032.c | 10 +- drivers/media/platform/sti/bdisp/bdisp-hw.c | 6 +- drivers/net/ethernet/cisco/enic/enic_main.c | 2 +- drivers/net/ethernet/freescale/gianfar.c | 10 +- drivers/net/wan/fsl_ucc_hdlc.c | 5 + drivers/net/wan/ixp4xx_hss.c | 4 +- drivers/net/wireless/broadcom/b43legacy/main.c | 5 +- .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 1 + drivers/net/wireless/intel/ipw2x00/ipw2100.c | 7 +- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 5 +- drivers/net/wireless/intel/iwlegacy/3945-mac.c | 5 +- drivers/net/wireless/intel/iwlegacy/4965-mac.c | 5 +- drivers/net/wireless/intel/iwlegacy/common.c | 2 +- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 4 +- drivers/net/wireless/intersil/hostap/hostap_ap.c | 2 +- .../net/wireless/intersil/orinoco/orinoco_usb.c | 3 +- drivers/net/wireless/realtek/rtlwifi/pci.c | 10 +- drivers/nfc/port100.c | 2 +- drivers/pci/iov.c | 1 + drivers/pinctrl/intel/pinctrl-baytrail.c | 8 +- drivers/pinctrl/sh-pfc/pfc-sh7264.c | 9 +- drivers/pinctrl/sh-pfc/pfc-sh7269.c | 39 +- drivers/pwm/pwm-omap-dmtimer.c | 7 +- drivers/regulator/rk808-regulator.c | 2 +- drivers/remoteproc/remoteproc_core.c | 2 +- drivers/scsi/aic7xxx/aic7xxx_core.c | 2 +- drivers/scsi/iscsi_tcp.c | 4 + drivers/scsi/qla2xxx/qla_os.c | 19 +- drivers/scsi/scsi_transport_iscsi.c | 26 +- drivers/soc/tegra/fuse/tegra-apbmisc.c | 2 +- drivers/staging/android/ashmem.c | 28 + drivers/staging/greybus/audio_manager.c | 2 +- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 +- drivers/staging/vt6656/dpc.c | 2 +- drivers/target/iscsi/iscsi_target.c | 16 +- drivers/tty/serial/atmel_serial.c | 3 +- drivers/tty/serial/imx.c | 2 +- drivers/tty/synclink_gt.c | 18 +- drivers/tty/synclinkmp.c | 24 +- drivers/tty/vt/selection.c | 7 +- drivers/tty/vt/vt_ioctl.c | 75 +- drivers/uio/uio_dmem_genirq.c | 6 +- drivers/usb/core/hub.c | 5 - drivers/usb/core/quirks.c | 3 + drivers/usb/gadget/composite.c | 8 +- drivers/usb/gadget/udc/gr_udc.c | 16 +- drivers/usb/host/xhci-mem.c | 12 +- drivers/usb/host/xhci-pci.c | 4 +- drivers/usb/musb/omap2430.c | 2 - drivers/usb/storage/uas.c | 23 +- drivers/video/fbdev/pxa168fb.c | 6 +- drivers/vme/bridges/vme_fake.c | 30 +- drivers/xen/preempt.c | 4 +- fs/btrfs/disk-io.c | 1 + fs/btrfs/extent_map.c | 11 + fs/btrfs/ordered-data.c | 7 +- fs/btrfs/super.c | 2 + fs/cifs/connect.c | 6 +- fs/ecryptfs/crypto.c | 6 +- fs/ecryptfs/keystore.c | 2 +- fs/ecryptfs/messaging.c | 1 + fs/ext4/dir.c | 14 +- fs/ext4/ext4.h | 14 +- fs/ext4/inode.c | 24 +- fs/ext4/migrate.c | 27 +- fs/ext4/mmp.c | 12 +- fs/ext4/namei.c | 8 + fs/ext4/super.c | 20 +- fs/jbd2/checkpoint.c | 2 +- fs/jbd2/commit.c | 50 +- fs/jbd2/journal.c | 21 +- fs/jbd2/transaction.c | 10 +- fs/ocfs2/journal.h | 8 +- fs/orangefs/orangefs-debugfs.c | 1 + fs/reiserfs/stree.c | 3 +- fs/reiserfs/super.c | 2 +- fs/udf/super.c | 22 +- include/linux/libata.h | 1 + include/linux/list_nulls.h | 8 +- include/linux/rculist_nulls.h | 8 +- include/media/v4l2-device.h | 12 +- include/scsi/iscsi_proto.h | 1 - include/sound/rawmidi.h | 6 +- ipc/sem.c | 6 +- kernel/cpu.c | 13 +- kernel/padata.c | 45 +- kernel/trace/ftrace.c | 5 +- kernel/trace/trace_events_trigger.c | 5 +- kernel/trace/trace_stat.c | 31 +- lib/scatterlist.c | 2 +- lib/stackdepot.c | 12 +- net/netfilter/xt_bpf.c | 3 + net/netfilter/xt_hashlimit.c | 10 + net/sched/cls_flower.c | 1 + net/sched/cls_matchall.c | 1 + scripts/kconfig/confdata.c | 2 +- security/selinux/avc.c | 2 +- sound/core/seq/seq_clientmgr.c | 4 +- sound/core/seq/seq_queue.c | 29 +- sound/core/seq/seq_timer.c | 13 +- sound/core/seq/seq_timer.h | 3 +- sound/hda/hdmi_chmap.c | 2 +- sound/pci/hda/hda_codec.c | 2 +- sound/pci/hda/hda_eld.c | 2 +- sound/pci/hda/hda_sysfs.c | 4 +- sound/pci/hda/patch_conexant.c | 1 + sound/sh/aica.c | 4 +- sound/soc/atmel/Kconfig | 2 + sound/usb/quirks.c | 1 + sound/usb/usx2y/usX2Yhwdep.c | 2 +- tools/lib/api/fs/fs.c | 4 +- tools/objtool/arch/x86/lib/x86-opcode-map.txt | 2 +- tools/usb/usbip/src/usbip_network.c | 40 +- tools/usb/usbip/src/usbip_network.h | 12 +- 178 files changed, 1158 insertions(+), 8617 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/165 x86/vdso: Use RDPID in preference to LSL when available
From: Andy Lutomirski <[email protected]>
commit a582c540ac1b10f0a7d37415e04c4af42409fd08 upstream.
RDPID is a new instruction that reads MSR_TSC_AUX quickly. This should be considerably faster than reading the GDT. Add a cpufeature for it and use it from __vdso_getcpu() when available.
--- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/vgtod.h | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
arch/x86/include/asm/cpufeatures.h +1 -0
@@ -305,6 +305,7 @@/* Intel-defined CPU features, CPUID level 0x00000007:0 (ecx), word 16 */ #define X86_FEATURE_PKU (16*32+ 3)/* Protection Keys for Userspace */ #define X86_FEATURE_OSPKE (16*32+ 4)/* OS Protection Keys Enable */ +#define X86_FEATURE_RDPID (16*32+ 22)/* RDPID instruction */ /* AMD-defined CPU features, CPUID level 0x80000007 (ebx), word 17 */ #define X86_FEATURE_OVERFLOW_RECOV (17*32+0)/* MCA overflow recovery support */
arch/x86/include/asm/vgtod.h +6 -1
@@ -89,8 +89,13 @@ static inline unsigned int __getcpu(void* works on all CPUs. This is volatile so that it orders * correctly wrt barrier() and to keep gcc from cleverly * hoisting it out of the calling function. +* +* If RDPID is available, use it. */ - asmvolatile ("lsl %1,%0" :"=r" (p) :"r" (__PER_CPU_SEG)); +alternative_io ("lsl %[p],%[seg]" , +".byte 0xf3,0x0f,0xc7,0xf8" ,/* RDPID %eax/rax */ + X86_FEATURE_RDPID, + [p] "=a" (p), [seg] "r" (__PER_CPU_SEG)); return p; }
Greg Kroah-Hartman
maintainerPATCH 2/165 KVM: x86: emulate RDPID
In reply to Greg Kroah-HartmanFrom: Paolo Bonzini <[email protected]>
commit fb6d4d340e0532032c808a9933eaaa7b8de435ab upstream.
This is encoded as F3 0F C7 /7 with a register argument. The register argument is the second array in the group9 GroupDual, while F3 is the fourth element of a Prefix.
--- arch/x86/kvm/cpuid.c | 7 ++++++- arch/x86/kvm/emulate.c | 22 +++++++++++++++++++++- arch/x86/kvm/vmx.c | 15 +++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-)
arch/x86/kvm/cpuid.c +6 -1
@@ -279,13 +279,18 @@ static int __do_cpuid_ent_emulated(struc {switch (func) {case 0 : - entry->eax =1 ;/* only one leaf currently */ + entry->eax =7 ; ++*nent;break ;case 1 : entry->ecx =F (MOVBE ); ++*nent;break ; +case 7 : + entry->flags |=KVM_CPUID_FLAG_SIGNIFCANT_INDEX ; +if (index ==0 ) + entry->ecx =F (RDPID ); + ++*nent;default :break ; }
arch/x86/kvm/emulate.c +21 -1
@@ -3531,6 +3531,16 @@ static int em_cwd(struct x86_emulate_ctxreturn X86EMUL_CONTINUE ; } +static int em_rdpid (struct x86_emulate_ctxt *ctxt) +{ +u64 tsc_aux =0 ; + +if (ctxt->ops->get_msr (ctxt,MSR_TSC_AUX , &tsc_aux)) +return emulate_gp (ctxt,0 ); + ctxt->dst.val = tsc_aux; +return X86EMUL_CONTINUE ; +} +static int em_rdtsc (struct x86_emulate_ctxt *ctxt) {u64 tsc =0 ;
@@ -4391,10 +4401,20 @@ static const struct opcode group8[] = { F(DstMem | SrcImmByte | Lock | PageTable, em_btc), }; +/* +* The "memory" destination is actually always a register, since we come +* from the register case of group9. +*/ +static const struct gprefix pfx_0f_c7_7 = { +N ,N ,N ,II (DstMem | ModRM | Op3264 | EmulateOnUD, em_rdpid, rdtscp), +}; + +static const struct group_dual group9 = { {N ,I (DstMem64 | Lock | PageTable, em_cmpxchg8b),N ,N ,N ,N ,N ,N , }, { -N ,N ,N ,N ,N ,N ,N ,N , +N ,N ,N ,N ,N ,N ,N , +GP (0 , &pfx_0f_c7_7), } };static const struct opcode group11[] = {
arch/x86/kvm/vmx.c +15 -0
@@ -11339,6 +11339,21 @@ static int vmx_check_intercept(struct kvstruct x86_instruction_info *info, enum x86_intercept_stage stage) { + struct vmcs12 *vmcs12 = get_vmcs12(vcpu); +struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; + +/* +* RDPID causes #UD if disabled through secondary execution controls. +* Because it is marked as EmulateOnUD, we need to intercept it here. +*/ +if (info->intercept == x86_intercept_rdtscp && + !nested_cpu_has2 (vmcs12,SECONDARY_EXEC_RDTSCP )) { + ctxt->exception.vector =UD_VECTOR ; + ctxt->exception.error_code_valid = false; +return X86EMUL_PROPAGATE_FAULT ; + } + +/* TODO: check more intercepts... */ return X86EMUL_CONTINUE ; }
Greg Kroah-Hartman
maintainerPATCH 3/165 ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit 44eeb081b8630bb3ad3cd381d1ae1831463e48bb upstream.
Some code in HD-audio driver calls snprintf() in a loop and still expects that the return value were actually written size, while snprintf() returns the expected would-be length instead. When the given buffer limit were small, this leads to a buffer overflow.
Use scnprintf() for addressing those issues. It returns the actually written size unlike snprintf().
--- sound/hda/hdmi_chmap.c | 2 +- sound/pci/hda/hda_codec.c | 2 +- sound/pci/hda/hda_eld.c | 2 +- sound/pci/hda/hda_sysfs.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)
sound/hda/hdmi_chmap.c +1 -1
@@ -249,7 +249,7 @@ void snd_hdac_print_channel_allocation(ifor (i =0 , j =0 ; i <ARRAY_SIZE (cea_speaker_allocation_names); i++) {if (spk_alloc & (1 << i)) - j +=snprintf (buf + j, buflen - j," %s" , + j +=scnprintf (buf + j, buflen - j," %s" , cea_speaker_allocation_names[i]); } buf[j] ='\0' ;/* necessary when j == 0 */
sound/pci/hda/hda_codec.c +1 -1
@@ -4104,7 +4104,7 @@ void snd_print_pcm_bits(int pcm, char *bfor (i =0 , j =0 ; i <ARRAY_SIZE (bits); i++)if (pcm & (AC_SUPPCM_BITS_8 << i)) - j +=snprintf (buf + j, buflen - j," %d" , bits[i]); + j +=scnprintf (buf + j, buflen - j," %d" , bits[i]); buf[j] ='\0' ;/* necessary when j == 0 */ }
sound/pci/hda/hda_eld.c +1 -1
@@ -373,7 +373,7 @@ static void hdmi_print_pcm_rates(int pcmfor (i =0 , j =0 ; i <ARRAY_SIZE (alsa_rates); i++)if (pcm & (1 << i)) - j +=snprintf (buf + j, buflen - j," %d" , + j +=scnprintf (buf + j, buflen - j," %d" , alsa_rates[i]); buf[j] ='\0' ;/* necessary when j == 0 */
sound/pci/hda/hda_sysfs.c +2 -2
@@ -221,7 +221,7 @@ static ssize_t init_verbs_show(struct demutex_lock (&codec->user_mutex);for (i =0 ; i < codec->init_verbs.used; i++) {struct hda_verb *v =snd_array_elem (&codec->init_verbs, i); - len +=snprintf (buf + len,PAGE_SIZE - len, + len +=scnprintf (buf + len,PAGE_SIZE - len,"0x%02x 0x%03x 0x%04x\n" , v->nid, v->verb, v->param); }
@@ -271,7 +271,7 @@ static ssize_t hints_show(struct devicemutex_lock (&codec->user_mutex);for (i =0 ; i < codec->hints.used; i++) {struct hda_hint *hint =snd_array_elem (&codec->hints, i); - len +=snprintf (buf + len,PAGE_SIZE - len, + len +=scnprintf (buf + len,PAGE_SIZE - len,"%s = %s\n" , hint->key, hint->val); }mutex_unlock (&codec->user_mutex);
Greg Kroah-Hartman
maintainerPATCH 4/165 ecryptfs: fix a memory leak bug in parse_tag_1_packet()
In reply to Greg Kroah-HartmanFrom: Wenwen Wang <[email protected]>
commit fe2e082f5da5b4a0a92ae32978f81507ef37ec66 upstream.
In parse_tag_1_packet(), if tag 1 packet contains a key larger than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES, no cleanup is executed, leading to a memory leak on the allocated 'auth_tok_list_item'. To fix this issue, go to the label 'out_free' to perform the cleanup work.
--- fs/ecryptfs/keystore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ecryptfs/keystore.c +1 -1
@@ -1285,7 +1285,7 @@ parse_tag_1_packet(struct ecryptfs_cryptprintk (KERN_ERR "Enter w/ first byte != 0x%.2x\n" ,ECRYPTFS_TAG_1_PACKET_TYPE ); rc = -EINVAL ; - goto out; + goto out_free; }/* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or * at end of function upon failure */
Greg Kroah-Hartman
maintainerPATCH 5/165 ecryptfs: fix a memory leak bug in ecryptfs_init_messaging()
In reply to Greg Kroah-HartmanFrom: Wenwen Wang <[email protected]>
commit b4a81b87a4cfe2bb26a4a943b748d96a43ef20e8 upstream.
In ecryptfs_init_messaging(), if the allocation for 'ecryptfs_msg_ctx_arr' fails, the previously allocated 'ecryptfs_daemon_hash' is not deallocated, leading to a memory leak bug. To fix this issue, free 'ecryptfs_daemon_hash' before returning the error.
--- fs/ecryptfs/messaging.c | 1 + 1 file changed, 1 insertion(+)
fs/ecryptfs/messaging.c +1 -0
@@ -397,6 +397,7 @@ int __init ecryptfs_init_messaging(void) * ecryptfs_message_buf_len), GFP_KERNEL);if (!ecryptfs_msg_ctx_arr) { +kfree (ecryptfs_daemon_hash); rc = -ENOMEM ;printk (KERN_ERR "%s: Failed to allocate memory\n" , __func__); goto out;
Greg Kroah-Hartman
maintainerPATCH 6/165 ALSA: usb-audio: Apply sample rate quirk for Audioengine D1
In reply to Greg Kroah-HartmanFrom: Arvind Sankar <[email protected]>
commit 93f9d1a4ac5930654c17412e3911b46ece73755a upstream.
The Audioengine D1 (0x2912:0x30c8) does support reading the sample rate, but it returns the rate in byte-reversed order.
When setting sampling rate, the driver produces these warning messages:
[168840.944226] usb 3-2.2: current rate 4500480 is different from the runtime rate 44100 [168854.930414] usb 3-2.2: current rate 8436480 is different from the runtime rate 48000 [168905.185825] usb 3-2.1.2: current rate 30465 is different from the runtime rate 96000
As can be seen from the hexadecimal conversion, the current rate read back is byte-reversed from the rate that was set.
44100 == 0x00ac44, 4500480 == 0x44ac00
48000 == 0x00bb80, 8436480 == 0x80bb00
96000 == 0x017700, 30465 == 0x007701
Rather than implementing a new quirk to reverse the order, just skip checking the rate to avoid spamming the log.
--- sound/usb/quirks.c | 1 + 1 file changed, 1 insertion(+)
sound/usb/quirks.c +1 -0
@@ -1149,6 +1149,7 @@ bool snd_usb_get_sample_rate_quirk(struccase USB_ID (0x1de7 ,0x0014 ):/* Phoenix Audio TMX320 */ case USB_ID (0x1de7 ,0x0114 ):/* Phoenix Audio MT202pcs */ case USB_ID (0x21B4 ,0x0081 ):/* AudioQuest DragonFly */ +case USB_ID (0x2912 ,0x30c8 ):/* Audioengine D1 */ return true; }return false;
Greg Kroah-Hartman
maintainerPATCH 7/165 ext4: dont assume that mmp_nodename/bdevname have NUL
In reply to Greg Kroah-HartmanFrom: Andreas Dilger <[email protected]>
commit 14c9ca0583eee8df285d68a0e6ec71053efd2228 upstream.
Don't assume that the mmp_nodename and mmp_bdevname strings are NUL terminated, since they are filled in by snprintf(), which is not guaranteed to do so.
--- fs/ext4/mmp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/ext4/mmp.c +7 -5
@@ -119,10 +119,10 @@ void __dump_mmp_msg(struct super_block * {__ext4_warning (sb, function, line,"%s" , msg);__ext4_warning (sb, function, line, -"MMP failure info: last update time: %llu, last update " -"node: %s, last update device: %s" , - (long long unsigned int )le64_to_cpu (mmp->mmp_time), - mmp->mmp_nodename, mmp->mmp_bdevname); +"MMP failure info: last update time: %llu, last update node: %.*s, last update device: %.*s" , + (unsigned long long )le64_to_cpu (mmp->mmp_time), + (int )sizeof (mmp->mmp_nodename), mmp->mmp_nodename, + (int )sizeof (mmp->mmp_bdevname), mmp->mmp_bdevname); }/*
@@ -153,6 +153,7 @@ static int kmmpd(void *data) mmp_check_interval =max (EXT4_MMP_CHECK_MULT * mmp_update_interval,EXT4_MMP_MIN_CHECK_INTERVAL ); mmp->mmp_check_interval =cpu_to_le16 (mmp_check_interval); +BUILD_BUG_ON (sizeof (mmp->mmp_bdevname) <BDEVNAME_SIZE );bdevname (bh->b_bdev, mmp->mmp_bdevname); memcpy(mmp->mmp_nodename, init_utsname()->nodename,
@@ -377,7 +378,8 @@ skip:/* * Start a kernel thread to update the MMP block periodically. */ -EXT4_SB (sb)->s_mmp_tsk =kthread_run (kmmpd, mmpd_data,"kmmpd-%s" , +EXT4_SB (sb)->s_mmp_tsk =kthread_run (kmmpd, mmpd_data,"kmmpd-%.*s" , + (int )sizeof (mmp->mmp_bdevname),bdevname (bh->b_bdev, mmp->mmp_bdevname));if (IS_ERR (EXT4_SB (sb)->s_mmp_tsk)) {
Greg Kroah-Hartman
maintainerPATCH 8/165 ext4: fix checksum errors with indexed dirs
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 48a34311953d921235f4d7bbd2111690d2e469cf upstream.
DIR_INDEX has been introduced as a compat ext4 feature. That means that even kernels / tools that don't understand the feature may modify the filesystem. This works because for kernels not understanding indexed dir format, internal htree nodes appear just as empty directory entries. Index dir aware kernels then check the htree structure is still consistent before using the data. This all worked reasonably well until metadata checksums were introduced. The problem is that these effectively made DIR_INDEX only ro-compatible because internal htree nodes store checksums in a different place than normal directory blocks. Thus any modification ignorant to DIR_INDEX (or just clearing EXT4_INDEX_FL from the inode) will effectively cause checksum mismatch and trigger kernel errors. So we have to be more careful when dealing with indexed directories on filesystems with checksumming enabled.
1) We just disallow loading any directory inodes with EXT4_INDEX_FL when DIR_INDEX is not enabled. This is harsh but it should be very rare (it means someone disabled DIR_INDEX on existing filesystem and didn't run e2fsck), e2fsck can fix the problem, and we don't want to answer the difficult question: "Should we rather corrupt the directory more or should we ignore that DIR_INDEX feature is not set?"
2) When we find out htree structure is corrupted (but the filesystem and the directory should in support htrees), we continue just ignoring htree information for reading but we refuse to add new entries to the directory to avoid corrupting it more.
--- fs/ext4/dir.c | 14 ++++++++------ fs/ext4/ext4.h | 5 ++++- fs/ext4/inode.c | 12 ++++++++++++ fs/ext4/namei.c | 7 +++++++ 4 files changed, 31 insertions(+), 7 deletions(-)
fs/ext4/dir.c +8 -6
@@ -124,12 +124,14 @@ static int ext4_readdir(struct file *filif (err !=ERR_BAD_DX_DIR ) {return err; } -/* -* We don't set the inode dirty flag since it's not -* critical that it get flushed back to the disk. -*/ -ext4_clear_inode_flag (file_inode (file), -EXT4_INODE_INDEX ); +/* Can we just clear INDEX flag to ignore htree information? */ +if (!ext4_has_metadata_csum (sb)) { +/* +* We don't set the inode dirty flag since it's not +* critical that it gets flushed back to the disk. +*/ +ext4_clear_inode_flag (inode,EXT4_INODE_INDEX ); + } }if (ext4_has_inline_data (inode)) {
fs/ext4/ext4.h +4 -1
@@ -2375,8 +2375,11 @@ int ext4_insert_dentry(struct inode *dir struct ext4_filename *fname);static inline void ext4_update_dx_flag (struct inode *inode) { -if (!ext4_has_feature_dir_index (inode->i_sb)) +if (!ext4_has_feature_dir_index (inode->i_sb)) { +/* ext4_iget() should have caught this... */ +WARN_ON_ONCE (ext4_has_feature_metadata_csum (inode->i_sb));ext4_clear_inode_flag (inode,EXT4_INODE_INDEX ); + } }static unsigned char ext4_filetype_table[] = {DT_UNKNOWN ,DT_REG ,DT_DIR ,DT_CHR ,DT_BLK ,DT_FIFO ,DT_SOCK ,DT_LNK
fs/ext4/inode.c +12 -0
@@ -4594,6 +4594,18 @@ struct inode *ext4_iget(struct super_blo ret = -EFSCORRUPTED ; goto bad_inode; } +/* +* If dir_index is not enabled but there's dir with INDEX flag set, +* we'd normally treat htree data as empty space. But with metadata +* checksumming that corrupts checksums so forbid that. +*/ +if (!ext4_has_feature_dir_index (sb) &&ext4_has_metadata_csum (sb) && +ext4_test_inode_flag (inode,EXT4_INODE_INDEX )) { +EXT4_ERROR_INODE (inode, +"iget: Dir with htree data on filesystem without dir_index feature." ); + ret = -EFSCORRUPTED ; + goto bad_inode; + } ei->i_disksize = inode->i_size;#ifdef CONFIG_QUOTA ei->i_reserved_quota =0 ;
fs/ext4/namei.c +7 -0
@@ -2148,6 +2148,13 @@ static int ext4_add_entry(handle_t *hand retval =ext4_dx_add_entry (handle, &fname, dir, inode);if (!retval || (retval !=ERR_BAD_DX_DIR )) goto out; +/* Can we just ignore htree data? */ +if (ext4_has_metadata_csum (sb)) { +EXT4_ERROR_INODE (dir, +"Directory has corrupted htree index." ); + retval = -EFSCORRUPTED ; + goto out; + }ext4_clear_inode_flag (dir,EXT4_INODE_INDEX ); dx_fallback++;ext4_mark_inode_dirty (handle, dir);
Greg Kroah-Hartman
maintainerPATCH 9/165 ext4: improve explanation of a mount failure caused by a misconfigured kernel
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit d65d87a07476aa17df2dcb3ad18c22c154315bec upstream.
If CONFIG_QFMT_V2 is not enabled, but CONFIG_QUOTA is enabled, when a user tries to mount a file system with the quota or project quota enabled, the kernel will emit a very confusing messsage:
EXT4-fs warning (device vdc): ext4_enable_quotas:5914: Failed to enable quota tracking (type=0, err=-3). Please run e2fsck to fix. EXT4-fs (vdc): mount failed
We will now report an explanatory message indicating which kernel configuration options have to be enabled, to avoid customer/sysadmin confusion.
Google-Bug-Id: 149093531
--- fs/ext4/super.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
fs/ext4/super.c +4 -10
@@ -2743,17 +2743,11 @@ static int ext4_feature_set_ok(struct sureturn 0 ; } -#ifndef CONFIG_QUOTA -if (ext4_has_feature_quota (sb) && !readonly) { +#if !defined(CONFIG_QUOTA ) || !defined(CONFIG_QFMT_V2 ) +if (!readonly && (ext4_has_feature_quota (sb) || +ext4_has_feature_project (sb))) {ext4_msg (sb,KERN_ERR , -"Filesystem with quota feature cannot be mounted RDWR " -"without CONFIG_QUOTA" ); -return 0 ; - } -if (ext4_has_feature_project (sb) && !readonly) { -ext4_msg (sb,KERN_ERR , -"Filesystem with project quota feature cannot be mounted RDWR " -"without CONFIG_QUOTA" ); +"The kernel was not built with CONFIG_QUOTA and CONFIG_QFMT_V2" );return 0 ; }#endif /* CONFIG_QUOTA */
Greg Kroah-Hartman
maintainerPATCH 10/165 Btrfs: fix race between using extent maps and merging them
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit ac05ca913e9f3871126d61da275bfe8516ff01ca upstream.
We have a few cases where we allow an extent map that is in an extent map tree to be merged with other extents in the tree. Such cases include the unpinning of an extent after the respective ordered extent completed or after logging an extent during a fast fsync. This can lead to subtle and dangerous problems because when doing the merge some other task might be using the same extent map and as consequence see an inconsistent state of the extent map - for example sees the new length but has seen the old start offset.
With luck this triggers a BUG_ON(), and not some silent bug, such as the following one in __do_readpage():
$ cat -n fs/btrfs/extent_io.c
3061 static int __do_readpage(struct extent_io_tree *tree,
3062 struct page *page,
(...)
3127 em = __get_extent_map(inode, page, pg_offset, cur,
3128 end - cur + 1, get_extent, em_cached);
3129 if (IS_ERR_OR_NULL(em)) {
3130 SetPageError(page);
3131 unlock_extent(tree, cur, end);
3132 break;
3133 }
3134 extent_offset = cur - em->start;
3135 BUG_ON(extent_map_end(em) <= cur);
(...)Consider the following example scenario, where we end up hitting the BUG_ON() in __do_readpage().
We have an inode with a size of 8KiB and 2 extent maps:
extent A: file offset 0, length 4KiB, disk_bytenr = X, persisted on disk by
a previous transaction
extent B: file offset 4KiB, length 4KiB, disk_bytenr = X + 4KiB, not yet
persisted but writeback started for it already. The extent map is pinned since there's writeback and an ordered extent in progress, so it can not be merged with extent map A yet
The following sequence of steps leads to the BUG_ON():
1) The ordered extent for extent B completes, the respective page gets its writeback bit cleared and the extent map is unpinned, at that point it is not yet merged with extent map A because it's in the list of modified extents;
2) Due to memory pressure, or some other reason, the MM subsystem releases the page corresponding to extent B - btrfs_releasepage() is called and returns 1, meaning the page can be released as it's not dirty, not under writeback anymore and the extent range is not locked in the inode's iotree. However the extent map is not released, either because we are not in a context that allows memory allocations to block or because the inode's size is smaller than 16MiB - in this case our inode has a size of 8KiB;
3) Task B needs to read extent B and ends up __do_readpage() through the btrfs_readpage() callback. At __do_readpage() it gets a reference to extent map B;
4) Task A, doing a fast fsync, calls clear_em_loggin() against extent map B while holding the write lock on the inode's extent map tree - this results in try_merge_map() being called and since it's possible to merge extent map B with extent map A now (the extent map B was removed from the list of modified extents), the merging begins - it sets extent map B's start offset to 0 (was 4KiB), but before it increments the map's length to 8KiB (4kb + 4KiB), task A is at:
BUG_ON(extent_map_end(em) <= cur);
The call to extent_map_end() sees the extent map has a start of 0 and a length still at 4KiB, so it returns 4KiB and 'cur' is 4KiB, so the BUG_ON() is triggered.
So it's dangerous to modify an extent map that is in the tree, because some other task might have got a reference to it before and still using it, and needs to see a consistent map while using it. Generally this is very rare since most paths that lookup and use extent maps also have the file range locked in the inode's iotree. The fsync path is pretty much the only exception where we don't do it to avoid serialization with concurrent reads.
Fix this by not allowing an extent map do be merged if if it's being used by tasks other then the one attempting to merge the extent map (when the reference count of the extent map is greater than 2).
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=206211
--- fs/btrfs/extent_map.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
fs/btrfs/extent_map.c +11 -0
@@ -227,6 +227,17 @@ static void try_merge_map(struct extent_struct extent_map *merge =NULL ;struct rb_node *rb; +/* +* We can't modify an extent map that is in the tree and that is being +* used by another task, as it can cause that other task to see it in +* inconsistent state during the merging. We always have 1 reference for +* the tree and 1 for this task (which is unpinning the extent map or +* clearing the logging flag), so anything > 2 means it's being used by +* other tasks too. +*/ +if (atomic_read (&em->refs) >2 ) +return ; +if (em->start !=0 ) { rb =rb_prev (&em->rb_node);if (rb)
Greg Kroah-Hartman
maintainerPATCH 11/165 btrfs: log message when rw remount is attempted with unclean tree-log
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
commit 10a3a3edc5b89a8cd095bc63495fb1e0f42047d9 upstream.
A remount to a read-write filesystem is not safe when there's tree-log to be replayed. Files that could be opened until now might be affected by the changes in the tree-log.
A regular mount is needed to replay the log so the filesystem presents the consistent view with the pending changes included.
--- fs/btrfs/super.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/super.c +2 -0
@@ -1809,6 +1809,8 @@ static int btrfs_remount(struct super_bl }if (btrfs_super_log_root (fs_info->super_copy) !=0 ) { +btrfs_warn (fs_info, +"mount required to replay tree-log, cannot remount read-write" ); ret = -EINVAL ; goto restore; }
Greg Kroah-Hartman
maintainerPATCH 12/165 perf/x86/amd: Add missing L2 misses event spec to AMD Family 17hs event map
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 25d387287cf0330abf2aad761ce6eee67326a355 upstream.
Commit 3fe3331bb285 ("perf/x86/amd: Add event map for AMD Family 17h"), claimed L2 misses were unsupported, due to them not being found in its referenced documentation, whose link has now moved [1].
That old documentation listed PMCx064 unit mask bit 3 as:
"LsRdBlkC: LS Read Block C S L X Change to X Miss."
and bit 0 as:
"IcFillMiss: IC Fill Miss"
We now have new public documentation [2] with improved descriptions, that clearly indicate what events those unit mask bits represent:
Bit 3 now clearly states:
"LsRdBlkC: Data Cache Req Miss in L2 (all types)"
and bit 0 is:
"IcFillMiss: Instruction Cache Req Miss in L2."
So we can now add support for L2 misses in perf's genericised events as PMCx064 with both the above unit masks.
[1] The commit's original documentation reference, "Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors", originally available here:
https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf
is now available here:
https://developer.amd.com/wordpress/media/2017/11/54945_PPR_Family_17h_Models_00h-0Fh.pdf
[2] "Processor Programming Reference (PPR) for Family 17h Model 31h, Revision B0 Processors", available here:
https://developer.amd.com/wp-content/resources/55803_0.54-PUB.pdf
--- arch/x86/events/amd/core.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/events/amd/core.c +1 -0
@@ -239,6 +239,7 @@ static const u64 amd_f17h_perfmon_event_ [PERF_COUNT_HW_CPU_CYCLES] = 0x0076, [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, [PERF_COUNT_HW_CACHE_REFERENCES] = 0xff60, + [PERF_COUNT_HW_CACHE_MISSES] = 0x0964, [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c2, [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c3, [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x0287,
Greg Kroah-Hartman
maintainerPATCH 13/165 padata: Remove broken queue flushing
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
commit 07928d9bfc81640bab36f5190e8725894d93b659 upstream.
The function padata_flush_queues is fundamentally broken because it cannot force padata users to complete the request that is underway. IOW padata has to passively wait for the completion of any outstanding work.
As it stands flushing is used in two places. Its use in padata_stop is simply unnecessary because nothing depends on the queues to be flushed afterwards.
The other use in padata_replace is more substantial as we depend on it to free the old pd structure. This patch instead uses the pd->refcnt to dynamically free the pd structure once all requests are complete.
--- kernel/padata.c | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-)
kernel/padata.c +12 -33
@@ -34,6 +34,8 @@#define MAX_OBJ_NUM 1000 +static void padata_free_pd (struct parallel_data *pd); +static int padata_index_to_cpu (struct parallel_data *pd,int cpu_index) {int cpu, target_cpu;
@@ -301,6 +303,7 @@ static void padata_serial_worker(structstruct padata_serial_queue *squeue;struct parallel_data *pd;LIST_HEAD (local_list); +int cnt;local_bh_disable (); squeue = container_of(serial_work, struct padata_serial_queue, work);
@@ -310,6 +313,8 @@ static void padata_serial_worker(structlist_replace_init (&squeue->serial.list, &local_list);spin_unlock (&squeue->serial.lock); + cnt =0 ; +while (!list_empty (&local_list)) {struct padata_priv *padata;
@@ -319,9 +324,12 @@ static void padata_serial_worker(structlist_del_init (&padata->list); padata->serial (padata); -atomic_dec (&pd->refcnt); + cnt++; }local_bh_enable (); + +if (atomic_sub_and_test (cnt, &pd->refcnt)) +padata_free_pd (pd); }/**
@@ -444,7 +452,7 @@ static struct parallel_data *padata_allosetup_timer (&pd->timer, padata_reorder_timer, (unsigned long )pd);atomic_set (&pd->seq_nr,-1 );atomic_set (&pd->reorder_objects,0 ); -atomic_set (&pd->refcnt,0 ); +atomic_set (&pd->refcnt,1 ); pd->pinst = pinst;spin_lock_init (&pd->lock);
@@ -469,31 +477,6 @@ static void padata_free_pd(struct parallkfree (pd); } -/* Flush all objects out of the padata queues. */ -static void padata_flush_queues (struct parallel_data *pd) -{ -int cpu; -struct padata_parallel_queue *pqueue; -struct padata_serial_queue *squeue; - -for_each_cpu (cpu, pd->cpumask.pcpu) { - pqueue =per_cpu_ptr (pd->pqueue, cpu); -flush_work (&pqueue->work); - } - -del_timer_sync (&pd->timer); - -if (atomic_read (&pd->reorder_objects)) -padata_reorder (pd); - -for_each_cpu (cpu, pd->cpumask.cbcpu) { - squeue =per_cpu_ptr (pd->squeue, cpu); -flush_work (&squeue->work); - } - -BUG_ON (atomic_read (&pd->refcnt) !=0 ); -} -static void __padata_start (struct padata_instance *pinst) { pinst->flags |=PADATA_INIT ;
@@ -507,10 +490,6 @@ static void __padata_stop(struct padata_ pinst->flags &= ~PADATA_INIT ;synchronize_rcu (); - -get_online_cpus (); -padata_flush_queues (pinst->pd); -put_online_cpus (); }/* Replace the internal control structure with a new one. */
@@ -531,8 +510,8 @@ static void padata_replace(struct padataif (!cpumask_equal (pd_old->cpumask.cbcpu, pd_new->cpumask.cbcpu)) notification_mask |=PADATA_CPU_SERIAL ; -padata_flush_queues (pd_old); -padata_free_pd (pd_old); +if (atomic_dec_and_test (&pd_old->refcnt)) +padata_free_pd (pd_old);if (notification_mask) blocking_notifier_call_chain(&pinst->cpumask_change_notifier,
Greg Kroah-Hartman
maintainerPATCH 14/165 s390/time: Fix clk type in get_tod_clock
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
commit 0f8a206df7c920150d2aa45574fba0ab7ff6be4f upstream.
Clang warns:
In file included from ../arch/s390/boot/startup.c:3:
In file included from ../include/linux/elf.h:5:
In file included from ../arch/s390/include/asm/elf.h:132:
In file included from ../include/linux/compat.h:10:
In file included from ../include/linux/time.h:74:
In file included from ../include/linux/time32.h:13:
In file included from ../include/linux/timex.h:65:../arch/s390/include/asm/timex.h:160:20: warning: passing 'unsigned char [16]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
get_tod_clock_ext(clk);
^~~
../arch/s390/include/asm/timex.h:149:44: note: passing argument to
parameter 'clk' here
static inline void get_tod_clock_ext(char *clk)
^Change clk's type to just be char so that it matches what happens in get_tod_clock_ext.
--- arch/s390/include/asm/timex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/include/asm/timex.h +1 -1
@@ -146,7 +146,7 @@ static inline void get_tod_clock_ext(chastatic inline unsigned long long get_tod_clock (void ) { -unsigned char clk[STORE_CLOCK_EXT_SIZE ]; +char clk[STORE_CLOCK_EXT_SIZE ];get_tod_clock_ext (clk);return *((unsigned long long *)&clk[1 ]);
Greg Kroah-Hartman
maintainerPATCH 15/165 perf/x86/intel: Fix inaccurate period in context switch for auto-reload
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit f861854e1b435b27197417f6f90d87188003cb24 upstream.
Perf doesn't take the left period into account when auto-reload is enabled with fixed period sampling mode in context switch.
Here is the MSR trace of the perf command as below. (The MSR trace is simplified from a ftrace log.)
#perf record -e cycles:p -c 2000000 -- ./triad_loop
//The MSR trace of task schedule out
//perf disable all counters, disable PEBS, disable GP counter 0,
//read GP counter 0, and re-enable all counters.
//The counter 0 stops at 0xfffffff82840
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value 0
write_msr: MSR_IA32_PEBS_ENABLE(3f1), value 0
write_msr: MSR_P6_EVNTSEL0(186), value 40003003c
rdpmc: 0, value fffffff82840
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value f000000ff
//The MSR trace of the same task schedule in again
//perf disable all counters, enable and set GP counter 0,
//enable PEBS, and re-enable all counters.
//0xffffffe17b80 (-2000000) is written to GP counter 0.
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value 0
write_msr: MSR_IA32_PMC0(4c1), value ffffffe17b80
write_msr: MSR_P6_EVNTSEL0(186), value 40043003c
write_msr: MSR_IA32_PEBS_ENABLE(3f1), value 1
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value f000000ffWhen the same task schedule in again, the counter should starts from previous left. However, it starts from the fixed period -2000000 again.
A special variant of intel_pmu_save_and_restart() is used for auto-reload, which doesn't update the hwc->period_left. When the monitored task schedules in again, perf doesn't know the left period. The fixed period is used, which is inaccurate.
With auto-reload, the counter always has a negative counter value. So the left period is -value. Update the period_left in intel_pmu_save_and_restart_reload().
With the patch:
//The MSR trace of task schedule out
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value 0
write_msr: MSR_IA32_PEBS_ENABLE(3f1), value 0
write_msr: MSR_P6_EVNTSEL0(186), value 40003003c
rdpmc: 0, value ffffffe25cbc
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value f000000ff
//The MSR trace of the same task schedule in again
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value 0
write_msr: MSR_IA32_PMC0(4c1), value ffffffe25cbc
write_msr: MSR_P6_EVNTSEL0(186), value 40043003c
write_msr: MSR_IA32_PEBS_ENABLE(3f1), value 1
write_msr: MSR_CORE_PERF_GLOBAL_CTRL(38f), value f000000ff--- arch/x86/events/intel/ds.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/events/intel/ds.c +2 -0
@@ -1326,6 +1326,8 @@ intel_pmu_save_and_restart_reload(struct old = ((s64)(prev_raw_count << shift) >> shift);local64_add (new - old + count * period, &event->count); +local64_set (&hwc->period_left, -new); +perf_event_update_userpage (event);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 16/165 hwmon: (pmbus/ltc2978) Fix PMBus polling of MFR_COMMON definitions.
In reply to Greg Kroah-HartmanFrom: Mike Jones <[email protected]>
commit cf2b012c90e74e85d8aea7d67e48868069cfee0c upstream.
Change 21537dc driver PMBus polling of MFR_COMMON from bits 5/4 to bits 6/5. This fixs a LTC297X family bug where polling always returns not busy even when the part is busy. This fixes a LTC388X and LTM467X bug where polling used PEND and NOT_IN_TRANS, and BUSY was not polled, which can lead to NACKing of commands. LTC388X and LTM467X modules now poll BUSY and PEND, increasing reliability by eliminating NACKing of commands.
--- drivers/hwmon/pmbus/ltc2978.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/pmbus/ltc2978.c +2 -2
@@ -89,8 +89,8 @@ enum chips { ltc2974, ltc2975, ltc2977,#define LTC_POLL_TIMEOUT 100/* in milli-seconds */ -#define LTC_NOT_BUSY BIT(5) -#define LTC_NOT_PENDING BIT(4) +#define LTC_NOT_BUSY BIT(6) +#define LTC_NOT_PENDING BIT(5)/* * LTC2978 clears peak data whenever the CLEAR_FAULTS command is executed, which
Greg Kroah-Hartman
maintainerPATCH 17/165 jbd2: move the clearing of b_modified flag to the journal_unmap_buffer()
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
[ Upstream commit 6a66a7ded12baa6ebbb2e3e82f8cb91382814839 ]
There is no need to delay the clearing of b_modified flag to the transaction committing time when unmapping the journalled buffer, so just move it to the journal_unmap_buffer().
--- fs/jbd2/commit.c | 43 +++++++++++++++---------------------------- fs/jbd2/transaction.c | 10 ++++++---- 2 files changed, 21 insertions(+), 32 deletions(-)
fs/jbd2/commit.c +15 -28
@@ -969,34 +969,21 @@ void jbd2_journal_commit_transaction(journal_t *journal)* it. */ /* -* A buffer which has been freed while still being journaled by -* a previous transaction. -*/ -if (buffer_freed (bh)) { -/* -* If the running transaction is the one containing -* "add to orphan" operation (b_next_transaction != -* NULL), we have to wait for that transaction to -* commit before we can really get rid of the buffer. -* So just clear b_modified to not confuse transaction -* credit accounting and refile the buffer to -* BJ_Forget of the running transaction. If the just -* committed transaction contains "add to orphan" -* operation, we can completely invalidate the buffer -* now. We are rather through in that since the -* buffer may be still accessible when blocksize < -* pagesize and it is attached to the last partial -* page. -*/ - jh->b_modified =0 ; -if (!jh->b_next_transaction) { -clear_buffer_freed (bh); -clear_buffer_jbddirty (bh); -clear_buffer_mapped (bh); -clear_buffer_new (bh); -clear_buffer_req (bh); - bh->b_bdev =NULL ; - } +* A buffer which has been freed while still being journaled +* by a previous transaction, refile the buffer to BJ_Forget of +* the running transaction. If the just committed transaction +* contains "add to orphan" operation, we can completely +* invalidate the buffer now. We are rather through in that +* since the buffer may be still accessible when blocksize < +* pagesize and it is attached to the last partial page. +*/ +if (buffer_freed (bh) && !jh->b_next_transaction) { +clear_buffer_freed (bh); +clear_buffer_jbddirty (bh); +clear_buffer_mapped (bh); +clear_buffer_new (bh); +clear_buffer_req (bh); + bh->b_bdev =NULL ; }if (buffer_jbddirty (bh)) {
fs/jbd2/transaction.c +6 -4
@@ -2213,14 +2213,16 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,return -EBUSY ; }/* -* OK, buffer won't be reachable after truncate. We just set -* j_next_transaction to the running transaction (if there is -* one) and mark buffer as freed so that commit code knows it -* should clear dirty bits when it is done with the buffer. +* OK, buffer won't be reachable after truncate. We just clear +* b_modified to not confuse transaction credit accounting, and +* set j_next_transaction to the running transaction (if there +* is one) and mark buffer as freed so that commit code knows +* it should clear dirty bits when it is done with the buffer. */ set_buffer_freed (bh);if (journal->j_running_transaction &&buffer_jbddirty (bh)) jh->b_next_transaction = journal->j_running_transaction; + jh->b_modified =0 ;jbd2_journal_put_journal_head (jh);spin_unlock (&journal->j_list_lock);jbd_unlock_bh_state (bh);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 18/165 jbd2: do not clear the BH_Mapped flag when forgetting a metadata buffer
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
[ Upstream commit c96dceeabf765d0b1b1f29c3bf50a5c01315b820 ]
Commit 904cdbd41d74 ("jbd2: clear dirty flag when revoking a buffer from an older transaction") set the BH_Freed flag when forgetting a metadata buffer which belongs to the committing transaction, it indicate the committing process clear dirty bits when it is done with the buffer. But it also clear the BH_Mapped flag at the same time, which may trigger below NULL pointer oops when block_size < PAGE_SIZE.
rmdir 1 kjournald2 mkdir 2
jbd2_journal_commit_transaction commit transaction Njbd2_journal_forgetset_buffer_freed(bh1)
jbd2_journal_commit_transaction
commit transaction N+1
...
clear_buffer_mapped(bh1)
ext4_getblk(bh2 ummapped)
...
grow_dev_page
init_page_buffers
bh1->b_private=NULL
bh2->b_private=NULL
jbd2_journal_put_journal_head(jh1)
__journal_remove_journal_head(hb1)
jh1 is NULL and trigger oops*) Dir entry block bh1 and bh2 belongs to one page, and the bh2 has
already been unmapped.
For the metadata buffer we forgetting, we should always keep the mapped flag and clear the dirty flags is enough, so this patch pick out the these buffers and keep their BH_Mapped flag.
--- fs/jbd2/commit.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
fs/jbd2/commit.c +21 -4
@@ -978,12 +978,29 @@ void jbd2_journal_commit_transaction(journal_t *journal)* pagesize and it is attached to the last partial page. */ if (buffer_freed (bh) && !jh->b_next_transaction) { +struct address_space *mapping; +clear_buffer_freed (bh);clear_buffer_jbddirty (bh); -clear_buffer_mapped (bh); -clear_buffer_new (bh); -clear_buffer_req (bh); - bh->b_bdev =NULL ; + +/* +* Block device buffers need to stay mapped all the +* time, so it is enough to clear buffer_jbddirty and +* buffer_freed bits. For the file mapping buffers (i.e. +* journalled data) we need to unmap buffer and clear +* more bits. We also need to be careful about the check +* because the data page mapping can get cleared under +* out hands, which alse need not to clear more bits +* because the page and buffers will be freed and can +* never be reused once we are done with them. +*/ + mapping =READ_ONCE (bh->b_page->mapping); +if (mapping && !sb_is_blkdev_sb (mapping->host->i_sb)) { +clear_buffer_mapped (bh); +clear_buffer_new (bh); +clear_buffer_req (bh); + bh->b_bdev =NULL ; + } }if (buffer_jbddirty (bh)) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 19/165 btrfs: print message when tree-log replay starts
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
[ Upstream commit e8294f2f6aa6208ed0923aa6d70cea3be178309a ]
There's no logged information about tree-log replay although this is something that points to previous unclean unmount. Other filesystems report that as well.
--- fs/btrfs/disk-io.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/disk-io.c +1 -0
@@ -2979,6 +2979,7 @@ int open_ctree(struct super_block *sb,/* do not make disk changes in broken FS or nologreplay is given */ if (btrfs_super_log_root (disk_super) !=0 && !btrfs_test_opt (tree_root->fs_info,NOLOGREPLAY )) { +btrfs_info (fs_info,"start tree-log replay" ); ret =btrfs_replay_log (fs_info, fs_devices);if (ret) { err = ret;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 20/165 scsi: qla2xxx: fix a potential NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Allen Pais <[email protected]>
commit 35a79a63517981a8aea395497c548776347deda8 upstream.
alloc_workqueue is not checked for errors and as a result a potential NULL dereference could occur.
--- drivers/scsi/qla2xxx/qla_os.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +13 -6
@@ -451,6 +451,12 @@ static int qla25xx_setup_mode(struct scs goto fail; }if (ql2xmultique_tag) { + ha->wq =alloc_workqueue ("qla2xxx_wq" ,WQ_MEM_RECLAIM ,1 ); +if (unlikely (!ha->wq)) { +ql_log (ql_log_warn, vha,0x01e0 , +"Failed to alloc workqueue.\n" ); + goto fail; + }/* create a request queue for IO */ options |=BIT_7 ; req = qla25xx_create_req_que(ha, options, 0, 0, -1,
@@ -458,9 +464,8 @@ static int qla25xx_setup_mode(struct scsif (!req) {ql_log (ql_log_warn, vha,0x00e0 ,"Failed to create request queue.\n" ); - goto fail; + goto fail2; } - ha->wq =alloc_workqueue ("qla2xxx_wq" ,WQ_MEM_RECLAIM ,1 ); vha->req = ha->req_q_map[req]; options |=BIT_1 ;for (ques =1 ; ques < ha->max_rsp_queues; ques++) {
@@ -468,7 +473,7 @@ static int qla25xx_setup_mode(struct scsif (!ret) {ql_log (ql_log_warn, vha,0x00e8 ,"Failed to create response queue.\n" ); - goto fail2; + goto fail3; } } ha->flags.cpu_affinity_enabled =1 ;
@@ -482,11 +487,13 @@ static int qla25xx_setup_mode(struct scs ha->max_rsp_queues, ha->max_req_queues); }return 0 ; -fail2: + +fail3:qla25xx_delete_queues (vha); -destroy_workqueue (ha->wq); - ha->wq =NULL ; vha->req = ha->req_q_map[0 ]; +fail2: +destroy_workqueue (ha->wq); + ha->wq =NULL ; fail: ha->mqenable =0 ;kfree (ha->req_q_map);
Greg Kroah-Hartman
maintainerPATCH 21/165 Revert "KVM: VMX: Add non-canonical check on writes to RTIT address MSRs"
In reply to Greg Kroah-HartmanThis reverts commit 57211b7366cc2abf784c35e537b256e7fcddc91e.
This patch isn't needed on 4.19 and older.
--- arch/x86/kvm/vmx/vmx.c | 8033 ---------------------------------------- 1 file changed, 8033 deletions(-) delete mode 100644 arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/vmx/vmx.c deleted +0 -8033
@@ -1,8033 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* -* Kernel-based Virtual Machine driver for Linux -* -* This module enables machines with Intel VT-x extensions to run virtual -* machines without emulation or binary translation. -* -* Copyright (C) 2006 Qumranet, Inc. -* Copyright 2010 Red Hat, Inc. and/or its affiliates. -* -* Authors: -* Avi Kivity <[email protected]> -* Yaniv Kamay <[email protected]> -*/ - -#include <linux/frame.h> -#include <linux/highmem.h> -#include <linux/hrtimer.h> -#include <linux/kernel.h> -#include <linux/kvm_host.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/mod_devicetable.h> -#include <linux/mm.h> -#include <linux/sched.h> -#include <linux/sched/smt.h> -#include <linux/slab.h> -#include <linux/tboot.h> -#include <linux/trace_events.h> - -#include <asm/apic.h> -#include <asm/asm.h> -#include <asm/cpu.h> -#include <asm/debugreg.h> -#include <asm/desc.h> -#include <asm/fpu/internal.h> -#include <asm/io.h> -#include <asm/irq_remapping.h> -#include <asm/kexec.h> -#include <asm/perf_event.h> -#include <asm/mce.h> -#include <asm/mmu_context.h> -#include <asm/mshyperv.h> -#include <asm/spec-ctrl.h> -#include <asm/virtext.h> -#include <asm/vmx.h> - -#include "capabilities.h" -#include "cpuid.h" -#include "evmcs.h" -#include "irq.h" -#include "kvm_cache_regs.h" -#include "lapic.h" -#include "mmu.h" -#include "nested.h" -#include "ops.h" -#include "pmu.h" -#include "trace.h" -#include "vmcs.h" -#include "vmcs12.h" -#include "vmx.h" -#include "x86.h" - -MODULE_AUTHOR ("Qumranet" ); -MODULE_LICENSE ("GPL" ); - -static const struct x86_cpu_id vmx_cpu_id[] = { -X86_FEATURE_MATCH (X86_FEATURE_VMX ), - {} -}; -MODULE_DEVICE_TABLE (x86cpu, vmx_cpu_id); - -bool __read_mostly enable_vpid =1 ; -module_param_named (vpid, enable_vpid, bool,0444 ); - -static bool __read_mostly enable_vnmi =1 ; -module_param_named (vnmi, enable_vnmi, bool,S_IRUGO ); - -bool __read_mostly flexpriority_enabled =1 ; -module_param_named (flexpriority, flexpriority_enabled, bool,S_IRUGO ); - -bool __read_mostly enable_ept =1 ; -module_param_named (ept, enable_ept, bool,S_IRUGO ); - -bool __read_mostly enable_unrestricted_guest =1 ; -module_param_named (unrestricted_guest, - enable_unrestricted_guest, bool,S_IRUGO ); - -bool __read_mostly enable_ept_ad_bits =1 ; -module_param_named (eptad, enable_ept_ad_bits, bool,S_IRUGO ); - -static bool __read_mostly emulate_invalid_guest_state = true; -module_param (emulate_invalid_guest_state, bool,S_IRUGO ); - -static bool __read_mostly fasteoi =1 ; -module_param (fasteoi, bool,S_IRUGO ); - -static bool __read_mostly enable_apicv =1 ; -module_param (enable_apicv, bool,S_IRUGO ); - -/* -* If nested=1, nested virtualization is supported, i.e., guests may use -* VMX and be a hypervisor for its own guests. If nested=0, guests may not -* use VMX instructions. -*/ -static bool __read_mostly nested =1 ; -module_param (nested, bool,S_IRUGO ); - -bool __read_mostly enable_pml =1 ; -module_param_named (pml, enable_pml, bool,S_IRUGO ); - -static bool __read_mostly dump_invalid_vmcs =0 ; -module_param (dump_invalid_vmcs, bool,0644 ); - -#define MSR_BITMAP_MODE_X2APIC 1 -#define MSR_BITMAP_MODE_X2APIC_APICV 2 - -#define KVM_VMX_TSC_MULTIPLIER_MAX 0xffffffffffffffffULL - -/* Guest_tsc -> host_tsc conversion requires 64-bit division. */ -static int __read_mostly cpu_preemption_timer_multi; -static bool __read_mostly enable_preemption_timer =1 ; -#ifdef CONFIG_X86_64 -module_param_named (preemption_timer, enable_preemption_timer, bool,S_IRUGO ); -#endif - -#define KVM_VM_CR0_ALWAYS_OFF (X86_CR0_NW | X86_CR0_CD) -#define KVM_VM_CR0_ALWAYS_ON_UNRESTRICTED_GUEST X86_CR0_NE -#define KVM_VM_CR0_ALWAYS_ON \ - (KVM_VM_CR0_ALWAYS_ON_UNRESTRICTED_GUEST | \ - X86_CR0_WP | X86_CR0_PG | X86_CR0_PE) -#define KVM_CR4_GUEST_OWNED_BITS \ - (X86_CR4_PVI | X86_CR4_DE | X86_CR4_PCE | X86_CR4_OSFXSR \ - | X86_CR4_OSXMMEXCPT | X86_CR4_LA57 | X86_CR4_TSD) - -#define KVM_VM_CR4_ALWAYS_ON_UNRESTRICTED_GUEST X86_CR4_VMXE -#define KVM_PMODE_VM_CR4_ALWAYS_ON (X86_CR4_PAE | X86_CR4_VMXE) -#define KVM_RMODE_VM_CR4_ALWAYS_ON (X86_CR4_VME | X86_CR4_PAE | X86_CR4_VMXE) - -#define RMODE_GUEST_OWNED_EFLAGS_BITS (~(X86_EFLAGS_IOPL | X86_EFLAGS_VM)) - -#define MSR_IA32_RTIT_STATUS_MASK (~(RTIT_STATUS_FILTEREN | \ - RTIT_STATUS_CONTEXTEN | RTIT_STATUS_TRIGGEREN | \ - RTIT_STATUS_ERROR | RTIT_STATUS_STOPPED | \ - RTIT_STATUS_BYTECNT)) - -#define MSR_IA32_RTIT_OUTPUT_BASE_MASK \ - (~((1UL << cpuid_query_maxphyaddr(vcpu)) - 1) | 0x7f) - -/* -* These 2 parameters are used to config the controls for Pause-Loop Exiting: -* ple_gap: upper bound on the amount of time between two successive -* executions of PAUSE in a loop. Also indicate if ple enabled. -* According to test, this time is usually smaller than 128 cycles. -* ple_window: upper bound on the amount of time a guest is allowed to execute -* in a PAUSE loop. Tests indicate that most spinlocks are held for -* less than 2^12 cycles -* Time is measured based on a counter that runs at the same rate as the TSC, -* refer SDM volume 3b section 21.6.13 & 22.1.3. -*/ -static unsigned int ple_gap =KVM_DEFAULT_PLE_GAP ; -module_param (ple_gap, uint,0444 ); - -static unsigned int ple_window =KVM_VMX_DEFAULT_PLE_WINDOW ; -module_param (ple_window, uint,0444 ); - -/* Default doubles per-vcpu window every exit. */ -static unsigned int ple_window_grow =KVM_DEFAULT_PLE_WINDOW_GROW ; -module_param (ple_window_grow, uint,0444 ); - -/* Default resets per-vcpu window every exit to ple_window. */ -static unsigned int ple_window_shrink =KVM_DEFAULT_PLE_WINDOW_SHRINK ; -module_param (ple_window_shrink, uint,0444 ); - -/* Default is to compute the maximum so we can never overflow. */ -static unsigned int ple_window_max =KVM_VMX_DEFAULT_PLE_WINDOW_MAX ; -module_param (ple_window_max, uint,0444 ); - -/* Default is SYSTEM mode, 1 for host-guest mode */ -int __read_mostly pt_mode =PT_MODE_SYSTEM ; -module_param (pt_mode, int,S_IRUGO ); - -static DEFINE_STATIC_KEY_FALSE (vmx_l1d_should_flush); -static DEFINE_STATIC_KEY_FALSE (vmx_l1d_flush_cond); -static DEFINE_MUTEX (vmx_l1d_flush_mutex); - -/* Storage for pre module init parameter parsing */ -static enum vmx_l1d_flush_state __read_mostly vmentry_l1d_flush_param =VMENTER_L1D_FLUSH_AUTO ; - -static const struct { -const char *option; -bool for_parse; -} vmentry_l1d_param[] = { - [VMENTER_L1D_FLUSH_AUTO ] = {"auto" , true}, - [VMENTER_L1D_FLUSH_NEVER ] = {"never" , true}, - [VMENTER_L1D_FLUSH_COND ] = {"cond" , true}, - [VMENTER_L1D_FLUSH_ALWAYS ] = {"always" , true}, - [VMENTER_L1D_FLUSH_EPT_DISABLED ] = {"EPT disabled" , false}, - [VMENTER_L1D_FLUSH_NOT_REQUIRED ] = {"not required" , false}, -}; - -#define L1D_CACHE_ORDER 4 -static void *vmx_l1d_flush_pages; - -static int vmx_setup_l1d_flush (enum vmx_l1d_flush_state l1tf) -{ -struct page *page; -unsigned int i; - -if (!boot_cpu_has_bug (X86_BUG_L1TF )) { - l1tf_vmx_mitigation =VMENTER_L1D_FLUSH_NOT_REQUIRED ; -return 0 ; - } - -if (!enable_ept) { - l1tf_vmx_mitigation =VMENTER_L1D_FLUSH_EPT_DISABLED ; -return 0 ; - } - -if (boot_cpu_has (X86_FEATURE_ARCH_CAPABILITIES )) { -u64 msr; - -rdmsrl (MSR_IA32_ARCH_CAPABILITIES , msr); -if (msr &ARCH_CAP_SKIP_VMENTRY_L1DFLUSH ) { - l1tf_vmx_mitigation =VMENTER_L1D_FLUSH_NOT_REQUIRED ; -return 0 ; - } - } - -/* If set to auto use the default l1tf mitigation method */ -if (l1tf ==VMENTER_L1D_FLUSH_AUTO ) { -switch (l1tf_mitigation) { -case L1TF_MITIGATION_OFF : - l1tf =VMENTER_L1D_FLUSH_NEVER ; -break ; -case L1TF_MITIGATION_FLUSH_NOWARN : -case L1TF_MITIGATION_FLUSH : -case L1TF_MITIGATION_FLUSH_NOSMT : - l1tf =VMENTER_L1D_FLUSH_COND ; -break ; -case L1TF_MITIGATION_FULL : -case L1TF_MITIGATION_FULL_FORCE : - l1tf =VMENTER_L1D_FLUSH_ALWAYS ; -break ; - } - }else if (l1tf_mitigation ==L1TF_MITIGATION_FULL_FORCE ) { - l1tf =VMENTER_L1D_FLUSH_ALWAYS ; - } - -if (l1tf !=VMENTER_L1D_FLUSH_NEVER && !vmx_l1d_flush_pages && - !boot_cpu_has (X86_FEATURE_FLUSH_L1D )) { -/* -* This allocation for vmx_l1d_flush_pages is not tied to a VM -* lifetime and so should not be charged to a memcg. -*/ - page =alloc_pages (GFP_KERNEL ,L1D_CACHE_ORDER ); -if (!page) -return -ENOMEM ; - vmx_l1d_flush_pages =page_address (page); - -/* -* Initialize each page with a different pattern in -* order to protect against KSM in the nested -* virtualization case. -*/ -for (i =0 ; i <1u <<L1D_CACHE_ORDER ; ++i) { -memset (vmx_l1d_flush_pages + i *PAGE_SIZE , i +1 , -PAGE_SIZE ); - } - } - - l1tf_vmx_mitigation = l1tf; - -if (l1tf !=VMENTER_L1D_FLUSH_NEVER ) -static_branch_enable (&vmx_l1d_should_flush); -else -static_branch_disable (&vmx_l1d_should_flush); - -if (l1tf ==VMENTER_L1D_FLUSH_COND ) -static_branch_enable (&vmx_l1d_flush_cond); -else -static_branch_disable (&vmx_l1d_flush_cond); -return 0 ; -} - -static int vmentry_l1d_flush_parse (const char *s) -{ -unsigned int i; - -if (s) { -for (i =0 ; i <ARRAY_SIZE (vmentry_l1d_param); i++) { -if (vmentry_l1d_param[i].for_parse && -sysfs_streq (s, vmentry_l1d_param[i].option)) -return i; - } - } -return -EINVAL ; -} - -static int vmentry_l1d_flush_set (const char *s,const struct kernel_param *kp) -{ -int l1tf, ret; - - l1tf =vmentry_l1d_flush_parse (s); -if (l1tf <0 ) -return l1tf; - -if (!boot_cpu_has (X86_BUG_L1TF )) -return 0 ; - -/* -* Has vmx_init() run already? If not then this is the pre init -* parameter parsing. In that case just store the value and let -* vmx_init() do the proper setup after enable_ept has been -* established. -*/ -if (l1tf_vmx_mitigation ==VMENTER_L1D_FLUSH_AUTO ) { - vmentry_l1d_flush_param = l1tf; -return 0 ; - } - -mutex_lock (&vmx_l1d_flush_mutex); - ret =vmx_setup_l1d_flush (l1tf); -mutex_unlock (&vmx_l1d_flush_mutex); -return ret; -} - -static int vmentry_l1d_flush_get (char *s,const struct kernel_param *kp) -{ -if (WARN_ON_ONCE (l1tf_vmx_mitigation >=ARRAY_SIZE (vmentry_l1d_param))) -return sprintf (s,"???\n" ); - -return sprintf (s,"%s\n" , vmentry_l1d_param[l1tf_vmx_mitigation].option); -} - -static const struct kernel_param_ops vmentry_l1d_flush_ops = { - .set = vmentry_l1d_flush_set, - .get = vmentry_l1d_flush_get, -}; -module_param_cb (vmentry_l1d_flush, &vmentry_l1d_flush_ops,NULL ,0644 ); - -static bool guest_state_valid (struct kvm_vcpu *vcpu); -static u32 vmx_segment_access_rights (struct kvm_segment *var); -static __always_inline void vmx_disable_intercept_for_msr(unsigned long *msr_bitmap, -u32 msr,int type); - -void vmx_vmexit (void ); - -#define vmx_insn_failed(fmt...) \ -do { \ - WARN_ONCE(1, fmt); \ - pr_warn_ratelimited(fmt); \ -} while (0) - -asmlinkage void vmread_error(unsigned long field, bool fault) -{ -if (fault) -kvm_spurious_fault (); -else -vmx_insn_failed ("kvm: vmread failed: field=%lx\n" , field); -} - -noinline void vmwrite_error(unsigned long field, unsigned long value) -{ -vmx_insn_failed ("kvm: vmwrite failed: field=%lx val=%lx err=%d\n" , - field, value,vmcs_read32 (VM_INSTRUCTION_ERROR )); -} - -noinline void vmclear_error(struct vmcs *vmcs, u64 phys_addr) -{ -vmx_insn_failed ("kvm: vmclear failed: %p/%llx\n" , vmcs, phys_addr); -} - -noinline void vmptrld_error(struct vmcs *vmcs, u64 phys_addr) -{ -vmx_insn_failed ("kvm: vmptrld failed: %p/%llx\n" , vmcs, phys_addr); -} - -noinline void invvpid_error(unsigned long ext, u16 vpid, gva_t gva) -{ -vmx_insn_failed ("kvm: invvpid failed: ext=0x%lx vpid=%u gva=0x%lx\n" , - ext, vpid, gva); -} - -noinline void invept_error(unsigned long ext, u64 eptp, gpa_t gpa) -{ -vmx_insn_failed ("kvm: invept failed: ext=0x%lx eptp=%llx gpa=0x%llx\n" , - ext, eptp, gpa); -} - -static DEFINE_PER_CPU(struct vmcs *, vmxarea); -DEFINE_PER_CPU (struct vmcs *, current_vmcs); -/* -* We maintain a per-CPU linked-list of VMCS loaded on that CPU. This is needed -* when a CPU is brought down, and we need to VMCLEAR all VMCSs loaded on it. -*/ -static DEFINE_PER_CPU(struct list_head, loaded_vmcss_on_cpu); - -/* -* We maintian a per-CPU linked-list of vCPU, so in wakeup_handler() we -* can find which vCPU should be waken up. -*/ -static DEFINE_PER_CPU(struct list_head, blocked_vcpu_on_cpu); -static DEFINE_PER_CPU(spinlock_t, blocked_vcpu_on_cpu_lock); - -static DECLARE_BITMAP(vmx_vpid_bitmap, VMX_NR_VPIDS); -static DEFINE_SPINLOCK (vmx_vpid_lock); - -struct vmcs_config vmcs_config; -struct vmx_capability vmx_capability; - -#define VMX_SEGMENT_FIELD (seg) \ - [VCPU_SREG_##seg] = { \ - .selector = GUEST_##seg##_SELECTOR, \ - .base = GUEST_##seg##_BASE, \ - .limit = GUEST_##seg##_LIMIT, \ - .ar_bytes = GUEST_##seg##_AR_BYTES, \ - } - -static const struct kvm_vmx_segment_field { -unsigned selector; -unsigned base; -unsigned limit; -unsigned ar_bytes; -} kvm_vmx_segment_fields[] = { -VMX_SEGMENT_FIELD (CS ), -VMX_SEGMENT_FIELD (DS ), -VMX_SEGMENT_FIELD (ES ), -VMX_SEGMENT_FIELD (FS ), -VMX_SEGMENT_FIELD (GS ), -VMX_SEGMENT_FIELD (SS ), -VMX_SEGMENT_FIELD (TR ), -VMX_SEGMENT_FIELD (LDTR ), -}; - -u64 host_efer; -static unsigned long host_idt_base; - -/* -* Though SYSCALL is only supported in 64-bit mode on Intel CPUs, kvm -* will emulate SYSCALL in legacy mode if the vendor string in guest -* CPUID.0:{EBX,ECX,EDX} is "AuthenticAMD" or "AMDisbetter!" To -* support this emulation, IA32_STAR must always be included in -* vmx_msr_index[], even in i386 builds. -*/ -const u32 vmx_msr_index[] = { -#ifdef CONFIG_X86_64 - MSR_SYSCALL_MASK, MSR_LSTAR, MSR_CSTAR, -#endif - MSR_EFER, MSR_TSC_AUX, MSR_STAR, - MSR_IA32_TSX_CTRL, -}; - -#if IS_ENABLED(CONFIG_HYPERV) -static bool __read_mostly enlightened_vmcs = true; -module_param(enlightened_vmcs, bool, 0444); - -/* check_ept_pointer() should be under protection of ept_pointer_lock. */ -static void check_ept_pointer_match(struct kvm *kvm) -{ - struct kvm_vcpu *vcpu; - u64 tmp_eptp = INVALID_PAGE; - int i; - - kvm_for_each_vcpu(i, vcpu, kvm) { - if (!VALID_PAGE(tmp_eptp)) { - tmp_eptp = to_vmx(vcpu)->ept_pointer; - } else if (tmp_eptp != to_vmx(vcpu)->ept_pointer) { - to_kvm_vmx(kvm)->ept_pointers_match - = EPT_POINTERS_MISMATCH; - return; - } - } - - to_kvm_vmx(kvm)->ept_pointers_match = EPT_POINTERS_MATCH; -} - -static int kvm_fill_hv_flush_list_func(struct hv_guest_mapping_flush_list *flush, - void *data) -{ - struct kvm_tlb_range *range = data; - - return hyperv_fill_flush_guest_mapping_list(flush, range->start_gfn, - range->pages); -} - -static inline int __hv_remote_flush_tlb_with_range(struct kvm *kvm, - struct kvm_vcpu *vcpu, struct kvm_tlb_range *range) -{ - u64 ept_pointer = to_vmx(vcpu)->ept_pointer; - - /* - * FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE hypercall needs address - * of the base of EPT PML4 table, strip off EPT configuration - * information. - */ - if (range) - return hyperv_flush_guest_mapping_range(ept_pointer & PAGE_MASK, - kvm_fill_hv_flush_list_func, (void *)range); - else - return hyperv_flush_guest_mapping(ept_pointer & PAGE_MASK); -} - -static int hv_remote_flush_tlb_with_range(struct kvm *kvm, - struct kvm_tlb_range *range) -{ - struct kvm_vcpu *vcpu; - int ret = 0, i; - - spin_lock(&to_kvm_vmx(kvm)->ept_pointer_lock); - - if (to_kvm_vmx(kvm)->ept_pointers_match == EPT_POINTERS_CHECK) - check_ept_pointer_match(kvm); - - if (to_kvm_vmx(kvm)->ept_pointers_match != EPT_POINTERS_MATCH) { - kvm_for_each_vcpu(i, vcpu, kvm) { - /* If ept_pointer is invalid pointer, bypass flush request. */ - if (VALID_PAGE(to_vmx(vcpu)->ept_pointer)) - ret |= __hv_remote_flush_tlb_with_range( - kvm, vcpu, range); - } - } else { - ret = __hv_remote_flush_tlb_with_range(kvm, - kvm_get_vcpu(kvm, 0), range); - } - - spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock); - return ret; -} -static int hv_remote_flush_tlb(struct kvm *kvm) -{ - return hv_remote_flush_tlb_with_range(kvm, NULL); -} - -static int hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu) -{ - struct hv_enlightened_vmcs *evmcs; - struct hv_partition_assist_pg **p_hv_pa_pg = - &vcpu->kvm->arch.hyperv.hv_pa_pg; - /* - * Synthetic VM-Exit is not enabled in current code and so All - * evmcs in singe VM shares same assist page. - */ - if (!*p_hv_pa_pg) - *p_hv_pa_pg = kzalloc(PAGE_SIZE, GFP_KERNEL); - - if (!*p_hv_pa_pg) - return -ENOMEM; - - evmcs = (struct hv_enlightened_vmcs *)to_vmx(vcpu)->loaded_vmcs->vmcs; - - evmcs->partition_assist_page = - __pa(*p_hv_pa_pg); - evmcs->hv_vm_id = (unsigned long)vcpu->kvm; - evmcs->hv_enlightenments_control.nested_flush_hypercall = 1; - - return 0; -} - -#endif /* IS_ENABLED(CONFIG_HYPERV) */ - -/* - * Comment's format: document - errata name - stepping - processor name. - * Refer from - * https://www.virtualbox.org/svn/vbox/trunk/src/VBox/VMM/VMMR0/HMR0.cpp - */ -static u32 vmx_preemption_cpu_tfms[] = { -/* 323344.pdf - BA86 - D0 - Xeon 7500 Series */ -0x000206E6, -/* 323056.pdf - AAX65 - C2 - Xeon L3406 */ -/* 322814.pdf - AAT59 - C2 - i7-600, i5-500, i5-400 and i3-300 Mobile */ -/* 322911.pdf - AAU65 - C2 - i5-600, i3-500 Desktop and Pentium G6950 */ -0x00020652, -/* 322911.pdf - AAU65 - K0 - i5-600, i3-500 Desktop and Pentium G6950 */ -0x00020655, -/* 322373.pdf - AAO95 - B1 - Xeon 3400 Series */ -/* 322166.pdf - AAN92 - B1 - i7-800 and i5-700 Desktop */ -/* - * 320767.pdf - AAP86 - B1 - - * i7-900 Mobile Extreme, i7-800 and i7-700 Mobile - */ -0x000106E5, -/* 321333.pdf - AAM126 - C0 - Xeon 3500 */ -0x000106A0, -/* 321333.pdf - AAM126 - C1 - Xeon 3500 */ -0x000106A1, -/* 320836.pdf - AAJ124 - C0 - i7-900 Desktop Extreme and i7-900 Desktop */ -0x000106A4, - /* 321333.pdf - AAM126 - D0 - Xeon 3500 */ - /* 321324.pdf - AAK139 - D0 - Xeon 5500 */ - /* 320836.pdf - AAJ124 - D0 - i7-900 Extreme and i7-900 Desktop */ -0x000106A5, - /* Xeon E3-1220 V2 */ -0x000306A8, -}; - -static inline bool cpu_has_broken_vmx_preemption_timer(void) -{ - u32 eax = cpuid_eax(0x00000001), i; - - /* Clear the reserved bits */ - eax &= ~(0x3U << 14 | 0xfU << 28); - for (i = 0; i < ARRAY_SIZE(vmx_preemption_cpu_tfms); i++) - if (eax == vmx_preemption_cpu_tfms[i]) - return true; - - return false; -} - -static inline bool cpu_need_virtualize_apic_accesses(struct kvm_vcpu *vcpu) -{ - return flexpriority_enabled && lapic_in_kernel(vcpu); -} - -static inline bool report_flexpriority(void) -{ - return flexpriority_enabled; -} - -static inline int __find_msr_index(struct vcpu_vmx *vmx, u32 msr) -{ - int i; - - for (i = 0; i < vmx->nmsrs; ++i) - if (vmx_msr_index[vmx->guest_msrs[i].index] == msr) - return i; - return -1; -} - -struct shared_msr_entry *find_msr_entry(struct vcpu_vmx *vmx, u32 msr) -{ - int i; - - i = __find_msr_index(vmx, msr); - if (i >= 0) - return &vmx->guest_msrs[i]; - return NULL; -} - -static int vmx_set_guest_msr(struct vcpu_vmx *vmx, struct shared_msr_entry *msr, u64 data) -{ - int ret = 0; - - u64 old_msr_data = msr->data; - msr->data = data; - if (msr - vmx->guest_msrs < vmx->save_nmsrs) { - preempt_disable(); - ret = kvm_set_shared_msr(msr->index, msr->data, - msr->mask); - preempt_enable(); - if (ret) - msr->data = old_msr_data; - } - return ret; -} - -void loaded_vmcs_init(struct loaded_vmcs *loaded_vmcs) -{ - vmcs_clear(loaded_vmcs->vmcs); - if (loaded_vmcs->shadow_vmcs && loaded_vmcs->launched) - vmcs_clear(loaded_vmcs->shadow_vmcs); - loaded_vmcs->cpu = -1; - loaded_vmcs->launched = 0; -} - -#ifdef CONFIG_KEXEC_CORE -/* - * This bitmap is used to indicate whether the vmclear - * operation is enabled on all cpus. All disabled by - * default. - */ -static cpumask_t crash_vmclear_enabled_bitmap = CPU_MASK_NONE; - -static inline void crash_enable_local_vmclear(int cpu) -{ - cpumask_set_cpu(cpu, &crash_vmclear_enabled_bitmap); -} - -static inline void crash_disable_local_vmclear(int cpu) -{ - cpumask_clear_cpu(cpu, &crash_vmclear_enabled_bitmap); -} - -static inline int crash_local_vmclear_enabled(int cpu) -{ - return cpumask_test_cpu(cpu, &crash_vmclear_enabled_bitmap); -} - -static void crash_vmclear_local_loaded_vmcss(void) -{ - int cpu = raw_smp_processor_id(); - struct loaded_vmcs *v; - - if (!crash_local_vmclear_enabled(cpu)) - return; - - list_for_each_entry(v, &per_cpu(loaded_vmcss_on_cpu, cpu), - loaded_vmcss_on_cpu_link) - vmcs_clear(v->vmcs); -} -#else -static inline void crash_enable_local_vmclear(int cpu) { } -static inline void crash_disable_local_vmclear(int cpu) { } -#endif /* CONFIG_KEXEC_CORE */ - -static void __loaded_vmcs_clear(void *arg) -{ - struct loaded_vmcs *loaded_vmcs = arg; - int cpu = raw_smp_processor_id(); - - if (loaded_vmcs->cpu != cpu) - return; /* vcpu migration can race with cpu offline */ - if (per_cpu(current_vmcs, cpu) == loaded_vmcs->vmcs) - per_cpu(current_vmcs, cpu) = NULL; - crash_disable_local_vmclear(cpu); - list_del(&loaded_vmcs->loaded_vmcss_on_cpu_link); - - /* - * we should ensure updating loaded_vmcs->loaded_vmcss_on_cpu_link - * is before setting loaded_vmcs->vcpu to -1 which is done in - * loaded_vmcs_init. Otherwise, other cpu can see vcpu = -1 fist - * then adds the vmcs into percpu list before it is deleted. - */ - smp_wmb(); - - loaded_vmcs_init(loaded_vmcs); - crash_enable_local_vmclear(cpu); -} - -void loaded_vmcs_clear(struct loaded_vmcs *loaded_vmcs) -{ - int cpu = loaded_vmcs->cpu; - - if (cpu != -1) - smp_call_function_single(cpu, - __loaded_vmcs_clear, loaded_vmcs, 1); -} - -static bool vmx_segment_cache_test_set(struct vcpu_vmx *vmx, unsigned seg, - unsigned field) -{ - bool ret; - u32 mask = 1 << (seg * SEG_FIELD_NR + field); - - if (!kvm_register_is_available(&vmx->vcpu, VCPU_EXREG_SEGMENTS)) { - kvm_register_mark_available(&vmx->vcpu, VCPU_EXREG_SEGMENTS); - vmx->segment_cache.bitmask = 0; - } - ret = vmx->segment_cache.bitmask & mask; - vmx->segment_cache.bitmask |= mask; - return ret; -} - -static u16 vmx_read_guest_seg_selector(struct vcpu_vmx *vmx, unsigned seg) -{ - u16 *p = &vmx->segment_cache.seg[seg].selector; - - if (!vmx_segment_cache_test_set(vmx, seg, SEG_FIELD_SEL)) - *p = vmcs_read16(kvm_vmx_segment_fields[seg].selector); - return *p; -} - -static ulong vmx_read_guest_seg_base(struct vcpu_vmx *vmx, unsigned seg) -{ - ulong *p = &vmx->segment_cache.seg[seg].base; - - if (!vmx_segment_cache_test_set(vmx, seg, SEG_FIELD_BASE)) - *p = vmcs_readl(kvm_vmx_segment_fields[seg].base); - return *p; -} - -static u32 vmx_read_guest_seg_limit(struct vcpu_vmx *vmx, unsigned seg) -{ - u32 *p = &vmx->segment_cache.seg[seg].limit; - - if (!vmx_segment_cache_test_set(vmx, seg, SEG_FIELD_LIMIT)) - *p = vmcs_read32(kvm_vmx_segment_fields[seg].limit); - return *p; -} - -static u32 vmx_read_guest_seg_ar(struct vcpu_vmx *vmx, unsigned seg) -{ - u32 *p = &vmx->segment_cache.seg[seg].ar; - - if (!vmx_segment_cache_test_set(vmx, seg, SEG_FIELD_AR)) - *p = vmcs_read32(kvm_vmx_segment_fields[seg].ar_bytes); - return *p; -} - -void update_exception_bitmap(struct kvm_vcpu *vcpu) -{ - u32 eb; - - eb = (1u << PF_VECTOR) | (1u << UD_VECTOR) | (1u << MC_VECTOR) | - (1u << DB_VECTOR) | (1u << AC_VECTOR); - /* - * Guest access to VMware backdoor ports could legitimately - * trigger #GP because of TSS I/O permission bitmap. - * We intercept those #GP and allow access to them anyway - * as VMware does. - */ - if (enable_vmware_backdoor) - eb |= (1u << GP_VECTOR); - if ((vcpu->guest_debug & - (KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP)) == - (KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP)) - eb |= 1u << BP_VECTOR; - if (to_vmx(vcpu)->rmode.vm86_active) - eb = ~0; - if (enable_ept) - eb &= ~(1u << PF_VECTOR); /* bypass_guest_pf = 0 */ - - /* When we are running a nested L2 guest and L1 specified for it a - * certain exception bitmap, we must trap the same exceptions and pass - * them to L1. When running L2, we will only handle the exceptions - * specified above if L1 did not want them. - */ - if (is_guest_mode(vcpu)) - eb |= get_vmcs12(vcpu)->exception_bitmap; - - vmcs_write32(EXCEPTION_BITMAP, eb); -} - -/* - * Check if MSR is intercepted for currently loaded MSR bitmap. - */ -static bool msr_write_intercepted(struct kvm_vcpu *vcpu, u32 msr) -{ - unsigned long *msr_bitmap; - int f = sizeof(unsigned long); - - if (!cpu_has_vmx_msr_bitmap()) - return true; - - msr_bitmap = to_vmx(vcpu)->loaded_vmcs->msr_bitmap; - - if (msr <= 0x1fff) { - return !!test_bit(msr, msr_bitmap + 0x800 / f); - } else if ((msr >= 0xc0000000) && (msr <= 0xc0001fff)) { - msr &= 0x1fff; - return !!test_bit(msr, msr_bitmap + 0xc00 / f); - } - - return true; -} - -static void clear_atomic_switch_msr_special(struct vcpu_vmx *vmx, - unsigned long entry, unsigned long exit) -{ - vm_entry_controls_clearbit(vmx, entry); - vm_exit_controls_clearbit(vmx, exit); -} - -int vmx_find_msr_index(struct vmx_msrs *m, u32 msr) -{ - unsigned int i; - - for (i = 0; i < m->nr; ++i) { - if (m->val[i].index == msr) - return i; - } - return -ENOENT; -} - -static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr) -{ - int i; - struct msr_autoload *m = &vmx->msr_autoload; - - switch (msr) { - case MSR_EFER: - if (cpu_has_load_ia32_efer()) { - clear_atomic_switch_msr_special(vmx, - VM_ENTRY_LOAD_IA32_EFER, - VM_EXIT_LOAD_IA32_EFER); - return; - } - break; - case MSR_CORE_PERF_GLOBAL_CTRL: - if (cpu_has_load_perf_global_ctrl()) { - clear_atomic_switch_msr_special(vmx, - VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL, - VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL); - return; - } - break; - } - i = vmx_find_msr_index(&m->guest, msr); - if (i < 0) - goto skip_guest; - --m->guest.nr; - m->guest.val[i] = m->guest.val[m->guest.nr]; - vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, m->guest.nr); - -skip_guest: - i = vmx_find_msr_index(&m->host, msr); - if (i < 0) - return; - - --m->host.nr; - m->host.val[i] = m->host.val[m->host.nr]; - vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, m->host.nr); -} - -static void add_atomic_switch_msr_special(struct vcpu_vmx *vmx, - unsigned long entry, unsigned long exit, - unsigned long guest_val_vmcs, unsigned long host_val_vmcs, - u64 guest_val, u64 host_val) -{ - vmcs_write64(guest_val_vmcs, guest_val); - if (host_val_vmcs != HOST_IA32_EFER) - vmcs_write64(host_val_vmcs, host_val); - vm_entry_controls_setbit(vmx, entry); - vm_exit_controls_setbit(vmx, exit); -} - -static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr, - u64 guest_val, u64 host_val, bool entry_only) -{ - int i, j = 0; - struct msr_autoload *m = &vmx->msr_autoload; - - switch (msr) { - case MSR_EFER: - if (cpu_has_load_ia32_efer()) { - add_atomic_switch_msr_special(vmx, - VM_ENTRY_LOAD_IA32_EFER, - VM_EXIT_LOAD_IA32_EFER, - GUEST_IA32_EFER, - HOST_IA32_EFER, - guest_val, host_val); - return; - } - break; - case MSR_CORE_PERF_GLOBAL_CTRL: - if (cpu_has_load_perf_global_ctrl()) { - add_atomic_switch_msr_special(vmx, - VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL, - VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL, - GUEST_IA32_PERF_GLOBAL_CTRL, - HOST_IA32_PERF_GLOBAL_CTRL, - guest_val, host_val); - return; - } - break; - case MSR_IA32_PEBS_ENABLE: - /* PEBS needs a quiescent period after being disabled (to write - * a record). Disabling PEBS through VMX MSR swapping doesn't - * provide that period, so a CPU could write host's record into - * guest's memory. - */ - wrmsrl(MSR_IA32_PEBS_ENABLE, 0); - } - - i = vmx_find_msr_index(&m->guest, msr); - if (!entry_only) - j = vmx_find_msr_index(&m->host, msr); - - if ((i < 0 && m->guest.nr == NR_LOADSTORE_MSRS) || - (j < 0 && m->host.nr == NR_LOADSTORE_MSRS)) { - printk_once(KERN_WARNING "Not enough msr switch entries. " - "Can't add msr %x\n", msr); - return; - } - if (i < 0) { - i = m->guest.nr++; - vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, m->guest.nr); - } - m->guest.val[i].index = msr; - m->guest.val[i].value = guest_val; - - if (entry_only) - return; - - if (j < 0) { - j = m->host.nr++; - vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, m->host.nr); - } - m->host.val[j].index = msr; - m->host.val[j].value = host_val; -} - -static bool update_transition_efer(struct vcpu_vmx *vmx, int efer_offset) -{ - u64 guest_efer = vmx->vcpu.arch.efer; - u64 ignore_bits = 0; - - /* Shadow paging assumes NX to be available. */ - if (!enable_ept) - guest_efer |= EFER_NX; - - /* - * LMA and LME handled by hardware; SCE meaningless outside long mode. - */ - ignore_bits |= EFER_SCE; -#ifdef CONFIG_X86_64 - ignore_bits |= EFER_LMA | EFER_LME; - /* SCE is meaningful only in long mode on Intel */ - if (guest_efer & EFER_LMA) - ignore_bits &= ~(u64)EFER_SCE; -#endif - - /* - * On EPT, we can't emulate NX, so we must switch EFER atomically. - * On CPUs that support "load IA32_EFER", always switch EFER - * atomically, since it's faster than switching it manually. - */ - if (cpu_has_load_ia32_efer() || - (enable_ept && ((vmx->vcpu.arch.efer ^ host_efer) & EFER_NX))) { - if (!(guest_efer & EFER_LMA)) - guest_efer &= ~EFER_LME; - if (guest_efer != host_efer) - add_atomic_switch_msr(vmx, MSR_EFER, - guest_efer, host_efer, false); - else - clear_atomic_switch_msr(vmx, MSR_EFER); - return false; - } else { - clear_atomic_switch_msr(vmx, MSR_EFER); - - guest_efer &= ~ignore_bits; - guest_efer |= host_efer & ignore_bits; - - vmx->guest_msrs[efer_offset].data = guest_efer; - vmx->guest_msrs[efer_offset].mask = ~ignore_bits; - - return true; - } -} - -#ifdef CONFIG_X86_32 -/* - * On 32-bit kernels, VM exits still load the FS and GS bases from the - * VMCS rather than the segment table. KVM uses this helper to figure - * out the current bases to poke them into the VMCS before entry. - */ -static unsigned long segment_base(u16 selector) -{ - struct desc_struct *table; - unsigned long v; - - if (!(selector & ~SEGMENT_RPL_MASK)) - return 0; - - table = get_current_gdt_ro(); - - if ((selector & SEGMENT_TI_MASK) == SEGMENT_LDT) { - u16 ldt_selector = kvm_read_ldt(); - - if (!(ldt_selector & ~SEGMENT_RPL_MASK)) - return 0; - - table = (struct desc_struct *)segment_base(ldt_selector); - } - v = get_desc_base(&table[selector >> 3]); - return v; -} -#endif - -static inline void pt_load_msr(struct pt_ctx *ctx, u32 addr_range) -{ - u32 i; - - wrmsrl(MSR_IA32_RTIT_STATUS, ctx->status); - wrmsrl(MSR_IA32_RTIT_OUTPUT_BASE, ctx->output_base); - wrmsrl(MSR_IA32_RTIT_OUTPUT_MASK, ctx->output_mask); - wrmsrl(MSR_IA32_RTIT_CR3_MATCH, ctx->cr3_match); - for (i = 0; i < addr_range; i++) { - wrmsrl(MSR_IA32_RTIT_ADDR0_A + i * 2, ctx->addr_a[i]); - wrmsrl(MSR_IA32_RTIT_ADDR0_B + i * 2, ctx->addr_b[i]); - } -} - -static inline void pt_save_msr(struct pt_ctx *ctx, u32 addr_range) -{ - u32 i; - - rdmsrl(MSR_IA32_RTIT_STATUS, ctx->status); - rdmsrl(MSR_IA32_RTIT_OUTPUT_BASE, ctx->output_base); - rdmsrl(MSR_IA32_RTIT_OUTPUT_MASK, ctx->output_mask); - rdmsrl(MSR_IA32_RTIT_CR3_MATCH, ctx->cr3_match); - for (i = 0; i < addr_range; i++) { - rdmsrl(MSR_IA32_RTIT_ADDR0_A + i * 2, ctx->addr_a[i]); - rdmsrl(MSR_IA32_RTIT_ADDR0_B + i * 2, ctx->addr_b[i]); - } -} - -static void pt_guest_enter(struct vcpu_vmx *vmx) -{ - if (pt_mode == PT_MODE_SYSTEM) - return; - - /* - * GUEST_IA32_RTIT_CTL is already set in the VMCS. - * Save host state before VM entry. - */ - rdmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl); - if (vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) { - wrmsrl(MSR_IA32_RTIT_CTL, 0); - pt_save_msr(&vmx->pt_desc.host, vmx->pt_desc.addr_range); - pt_load_msr(&vmx->pt_desc.guest, vmx->pt_desc.addr_range); - } -} - -static void pt_guest_exit(struct vcpu_vmx *vmx) -{ - if (pt_mode == PT_MODE_SYSTEM) - return; - - if (vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) { - pt_save_msr(&vmx->pt_desc.guest, vmx->pt_desc.addr_range); - pt_load_msr(&vmx->pt_desc.host, vmx->pt_desc.addr_range); - } - - /* Reload host state (IA32_RTIT_CTL will be cleared on VM exit). */ - wrmsrl(MSR_IA32_RTIT_CTL, vmx->pt_desc.host.ctl); -} - -void vmx_set_host_fs_gs(struct vmcs_host_state *host, u16 fs_sel, u16 gs_sel, - unsigned long fs_base, unsigned long gs_base) -{ - if (unlikely(fs_sel != host->fs_sel)) { - if (!(fs_sel & 7)) - vmcs_write16(HOST_FS_SELECTOR, fs_sel); - else - vmcs_write16(HOST_FS_SELECTOR, 0); - host->fs_sel = fs_sel; - } - if (unlikely(gs_sel != host->gs_sel)) { - if (!(gs_sel & 7)) - vmcs_write16(HOST_GS_SELECTOR, gs_sel); - else - vmcs_write16(HOST_GS_SELECTOR, 0); - host->gs_sel = gs_sel; - } - if (unlikely(fs_base != host->fs_base)) { - vmcs_writel(HOST_FS_BASE, fs_base); - host->fs_base = fs_base; - } - if (unlikely(gs_base != host->gs_base)) { - vmcs_writel(HOST_GS_BASE, gs_base); - host->gs_base = gs_base; - } -} - -void vmx_prepare_switch_to_guest(struct kvm_vcpu *vcpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - struct vmcs_host_state *host_state; -#ifdef CONFIG_X86_64 - int cpu = raw_smp_processor_id(); -#endif - unsigned long fs_base, gs_base; - u16 fs_sel, gs_sel; - int i; - - vmx->req_immediate_exit = false; - - /* - * Note that guest MSRs to be saved/restored can also be changed - * when guest state is loaded. This happens when guest transitions - * to/from long-mode by setting MSR_EFER.LMA. - */ - if (!vmx->guest_msrs_ready) { - vmx->guest_msrs_ready = true; - for (i = 0; i < vmx->save_nmsrs; ++i) - kvm_set_shared_msr(vmx->guest_msrs[i].index, - vmx->guest_msrs[i].data, - vmx->guest_msrs[i].mask); - - } - if (vmx->guest_state_loaded) - return; - - host_state = &vmx->loaded_vmcs->host_state; - - /* - * Set host fs and gs selectors. Unfortunately, 22.2.3 does not - * allow segment selectors with cpl > 0 or ti == 1. - */ - host_state->ldt_sel = kvm_read_ldt(); - -#ifdef CONFIG_X86_64 - savesegment(ds, host_state->ds_sel); - savesegment(es, host_state->es_sel); - - gs_base = cpu_kernelmode_gs_base(cpu); - if (likely(is_64bit_mm(current->mm))) { - save_fsgs_for_kvm(); - fs_sel = current->thread.fsindex; - gs_sel = current->thread.gsindex; - fs_base = current->thread.fsbase; - vmx->msr_host_kernel_gs_base = current->thread.gsbase; - } else { - savesegment(fs, fs_sel); - savesegment(gs, gs_sel); - fs_base = read_msr(MSR_FS_BASE); - vmx->msr_host_kernel_gs_base = read_msr(MSR_KERNEL_GS_BASE); - } - - wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); -#else - savesegment(fs, fs_sel); - savesegment(gs, gs_sel); - fs_base = segment_base(fs_sel); - gs_base = segment_base(gs_sel); -#endif - - vmx_set_host_fs_gs(host_state, fs_sel, gs_sel, fs_base, gs_base); - vmx->guest_state_loaded = true; -} - -static void vmx_prepare_switch_to_host(struct vcpu_vmx *vmx) -{ - struct vmcs_host_state *host_state; - - if (!vmx->guest_state_loaded) - return; - - host_state = &vmx->loaded_vmcs->host_state; - - ++vmx->vcpu.stat.host_state_reload; - -#ifdef CONFIG_X86_64 - rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); -#endif - if (host_state->ldt_sel || (host_state->gs_sel & 7)) { - kvm_load_ldt(host_state->ldt_sel); -#ifdef CONFIG_X86_64 - load_gs_index(host_state->gs_sel); -#else - loadsegment(gs, host_state->gs_sel); -#endif - } - if (host_state->fs_sel & 7) - loadsegment(fs, host_state->fs_sel); -#ifdef CONFIG_X86_64 - if (unlikely(host_state->ds_sel | host_state->es_sel)) { - loadsegment(ds, host_state->ds_sel); - loadsegment(es, host_state->es_sel); - } -#endif - invalidate_tss_limit(); -#ifdef CONFIG_X86_64 - wrmsrl(MSR_KERNEL_GS_BASE, vmx->msr_host_kernel_gs_base); -#endif - load_fixmap_gdt(raw_smp_processor_id()); - vmx->guest_state_loaded = false; - vmx->guest_msrs_ready = false; -} - -#ifdef CONFIG_X86_64 -static u64 vmx_read_guest_kernel_gs_base(struct vcpu_vmx *vmx) -{ - preempt_disable(); - if (vmx->guest_state_loaded) - rdmsrl(MSR_KERNEL_GS_BASE, vmx->msr_guest_kernel_gs_base); - preempt_enable(); - return vmx->msr_guest_kernel_gs_base; -} - -static void vmx_write_guest_kernel_gs_base(struct vcpu_vmx *vmx, u64 data) -{ - preempt_disable(); - if (vmx->guest_state_loaded) - wrmsrl(MSR_KERNEL_GS_BASE, data); - preempt_enable(); - vmx->msr_guest_kernel_gs_base = data; -} -#endif - -static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu) -{ - struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); - struct pi_desc old, new; - unsigned int dest; - - /* - * In case of hot-plug or hot-unplug, we may have to undo - * vmx_vcpu_pi_put even if there is no assigned device. And we - * always keep PI.NDST up to date for simplicity: it makes the - * code easier, and CPU migration is not a fast path. - */ - if (!pi_test_sn(pi_desc) && vcpu->cpu == cpu) - return; - - /* - * If the 'nv' field is POSTED_INTR_WAKEUP_VECTOR, do not change - * PI.NDST: pi_post_block is the one expected to change PID.NDST and the - * wakeup handler expects the vCPU to be on the blocked_vcpu_list that - * matches PI.NDST. Otherwise, a vcpu may not be able to be woken up - * correctly. - */ - if (pi_desc->nv == POSTED_INTR_WAKEUP_VECTOR || vcpu->cpu == cpu) { - pi_clear_sn(pi_desc); - goto after_clear_sn; - } - - /* The full case. */ - do { - old.control = new.control = pi_desc->control; - - dest = cpu_physical_id(cpu); - - if (x2apic_enabled()) - new.ndst = dest; - else - new.ndst = (dest << 8) & 0xFF00; - - new.sn = 0; - } while (cmpxchg64(&pi_desc->control, old.control, - new.control) != old.control); - -after_clear_sn: - - /* - * Clear SN before reading the bitmap. The VT-d firmware - * writes the bitmap and reads SN atomically (5.2.3 in the - * spec), so it doesn't really have a memory barrier that - * pairs with this, but we cannot do that and we need one. - */ - smp_mb__after_atomic(); - - if (!pi_is_pir_empty(pi_desc)) - pi_set_on(pi_desc); -} - -void vmx_vcpu_load_vmcs(struct kvm_vcpu *vcpu, int cpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - bool already_loaded = vmx->loaded_vmcs->cpu == cpu; - - if (!already_loaded) { - loaded_vmcs_clear(vmx->loaded_vmcs); - local_irq_disable(); - crash_disable_local_vmclear(cpu); - - /* - * Read loaded_vmcs->cpu should be before fetching - * loaded_vmcs->loaded_vmcss_on_cpu_link. - * See the comments in __loaded_vmcs_clear(). - */ - smp_rmb(); - - list_add(&vmx->loaded_vmcs->loaded_vmcss_on_cpu_link, - &per_cpu(loaded_vmcss_on_cpu, cpu)); - crash_enable_local_vmclear(cpu); - local_irq_enable(); - } - - if (per_cpu(current_vmcs, cpu) != vmx->loaded_vmcs->vmcs) { - per_cpu(current_vmcs, cpu) = vmx->loaded_vmcs->vmcs; - vmcs_load(vmx->loaded_vmcs->vmcs); - indirect_branch_prediction_barrier(); - } - - if (!already_loaded) { - void *gdt = get_current_gdt_ro(); - unsigned long sysenter_esp; - - kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); - - /* - * Linux uses per-cpu TSS and GDT, so set these when switching - * processors. See 22.2.4. - */ - vmcs_writel(HOST_TR_BASE, - (unsigned long)&get_cpu_entry_area(cpu)->tss.x86_tss); - vmcs_writel(HOST_GDTR_BASE, (unsigned long)gdt); /* 22.2.4 */ - - rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); - vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */ - - vmx->loaded_vmcs->cpu = cpu; - } - - /* Setup TSC multiplier */ - if (kvm_has_tsc_control && - vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) - decache_tsc_multiplier(vmx); -} - -/* - * Switches to specified vcpu, until a matching vcpu_put(), but assumes - * vcpu mutex is already taken. - */ -void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - - vmx_vcpu_load_vmcs(vcpu, cpu); - - vmx_vcpu_pi_load(vcpu, cpu); - - vmx->host_pkru = read_pkru(); - vmx->host_debugctlmsr = get_debugctlmsr(); -} - -static void vmx_vcpu_pi_put(struct kvm_vcpu *vcpu) -{ - struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu); - - if (!kvm_arch_has_assigned_device(vcpu->kvm) || - !irq_remapping_cap(IRQ_POSTING_CAP) || - !kvm_vcpu_apicv_active(vcpu)) - return; - - /* Set SN when the vCPU is preempted */ - if (vcpu->preempted) - pi_set_sn(pi_desc); -} - -static void vmx_vcpu_put(struct kvm_vcpu *vcpu) -{ - vmx_vcpu_pi_put(vcpu); - - vmx_prepare_switch_to_host(to_vmx(vcpu)); -} - -static bool emulation_required(struct kvm_vcpu *vcpu) -{ - return emulate_invalid_guest_state && !guest_state_valid(vcpu); -} - -static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu); - -unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned long rflags, save_rflags; - - if (!kvm_register_is_available(vcpu, VCPU_EXREG_RFLAGS)) { - kvm_register_mark_available(vcpu, VCPU_EXREG_RFLAGS); - rflags = vmcs_readl(GUEST_RFLAGS); - if (vmx->rmode.vm86_active) { - rflags &= RMODE_GUEST_OWNED_EFLAGS_BITS; - save_rflags = vmx->rmode.save_rflags; - rflags |= save_rflags & ~RMODE_GUEST_OWNED_EFLAGS_BITS; - } - vmx->rflags = rflags; - } - return vmx->rflags; -} - -void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned long old_rflags; - - if (enable_unrestricted_guest) { - kvm_register_mark_available(vcpu, VCPU_EXREG_RFLAGS); - vmx->rflags = rflags; - vmcs_writel(GUEST_RFLAGS, rflags); - return; - } - - old_rflags = vmx_get_rflags(vcpu); - vmx->rflags = rflags; - if (vmx->rmode.vm86_active) { - vmx->rmode.save_rflags = rflags; - rflags |= X86_EFLAGS_IOPL | X86_EFLAGS_VM; - } - vmcs_writel(GUEST_RFLAGS, rflags); - - if ((old_rflags ^ vmx->rflags) & X86_EFLAGS_VM) - vmx->emulation_required = emulation_required(vcpu); -} - -u32 vmx_get_interrupt_shadow(struct kvm_vcpu *vcpu) -{ - u32 interruptibility = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO); - int ret = 0; - - if (interruptibility & GUEST_INTR_STATE_STI) - ret |= KVM_X86_SHADOW_INT_STI; - if (interruptibility & GUEST_INTR_STATE_MOV_SS) - ret |= KVM_X86_SHADOW_INT_MOV_SS; - - return ret; -} - -void vmx_set_interrupt_shadow(struct kvm_vcpu *vcpu, int mask) -{ - u32 interruptibility_old = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO); - u32 interruptibility = interruptibility_old; - - interruptibility &= ~(GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS); - - if (mask & KVM_X86_SHADOW_INT_MOV_SS) - interruptibility |= GUEST_INTR_STATE_MOV_SS; - else if (mask & KVM_X86_SHADOW_INT_STI) - interruptibility |= GUEST_INTR_STATE_STI; - - if ((interruptibility != interruptibility_old)) - vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, interruptibility); -} - -static int vmx_rtit_ctl_check(struct kvm_vcpu *vcpu, u64 data) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned long value; - - /* - * Any MSR write that attempts to change bits marked reserved will - * case a #GP fault. - */ - if (data & vmx->pt_desc.ctl_bitmask) - return 1; - - /* - * Any attempt to modify IA32_RTIT_CTL while TraceEn is set will - * result in a #GP unless the same write also clears TraceEn. - */ - if ((vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) && - ((vmx->pt_desc.guest.ctl ^ data) & ~RTIT_CTL_TRACEEN)) - return 1; - - /* - * WRMSR to IA32_RTIT_CTL that sets TraceEn but clears this bit - * and FabricEn would cause #GP, if - * CPUID.(EAX=14H, ECX=0):ECX.SNGLRGNOUT[bit 2] = 0 - */ - if ((data & RTIT_CTL_TRACEEN) && !(data & RTIT_CTL_TOPA) && - !(data & RTIT_CTL_FABRIC_EN) && - !intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_single_range_output)) - return 1; - - /* - * MTCFreq, CycThresh and PSBFreq encodings check, any MSR write that - * utilize encodings marked reserved will casue a #GP fault. - */ - value = intel_pt_validate_cap(vmx->pt_desc.caps, PT_CAP_mtc_periods); - if (intel_pt_validate_cap(vmx->pt_desc.caps, PT_CAP_mtc) && - !test_bit((data & RTIT_CTL_MTC_RANGE) >> - RTIT_CTL_MTC_RANGE_OFFSET, &value)) - return 1; - value = intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_cycle_thresholds); - if (intel_pt_validate_cap(vmx->pt_desc.caps, PT_CAP_psb_cyc) && - !test_bit((data & RTIT_CTL_CYC_THRESH) >> - RTIT_CTL_CYC_THRESH_OFFSET, &value)) - return 1; - value = intel_pt_validate_cap(vmx->pt_desc.caps, PT_CAP_psb_periods); - if (intel_pt_validate_cap(vmx->pt_desc.caps, PT_CAP_psb_cyc) && - !test_bit((data & RTIT_CTL_PSB_FREQ) >> - RTIT_CTL_PSB_FREQ_OFFSET, &value)) - return 1; - - /* - * If ADDRx_CFG is reserved or the encodings is >2 will - * cause a #GP fault. - */ - value = (data & RTIT_CTL_ADDR0) >> RTIT_CTL_ADDR0_OFFSET; - if ((value && (vmx->pt_desc.addr_range < 1)) || (value > 2)) - return 1; - value = (data & RTIT_CTL_ADDR1) >> RTIT_CTL_ADDR1_OFFSET; - if ((value && (vmx->pt_desc.addr_range < 2)) || (value > 2)) - return 1; - value = (data & RTIT_CTL_ADDR2) >> RTIT_CTL_ADDR2_OFFSET; - if ((value && (vmx->pt_desc.addr_range < 3)) || (value > 2)) - return 1; - value = (data & RTIT_CTL_ADDR3) >> RTIT_CTL_ADDR3_OFFSET; - if ((value && (vmx->pt_desc.addr_range < 4)) || (value > 2)) - return 1; - - return 0; -} - -static int skip_emulated_instruction(struct kvm_vcpu *vcpu) -{ - unsigned long rip; - - /* - * Using VMCS.VM_EXIT_INSTRUCTION_LEN on EPT misconfig depends on - * undefined behavior: Intel's SDM doesn't mandate the VMCS field be - * set when EPT misconfig occurs. In practice, real hardware updates - * VM_EXIT_INSTRUCTION_LEN on EPT misconfig, but other hypervisors - * (namely Hyper-V) don't set it due to it being undefined behavior, - * i.e. we end up advancing IP with some random value. - */ - if (!static_cpu_has(X86_FEATURE_HYPERVISOR) || - to_vmx(vcpu)->exit_reason != EXIT_REASON_EPT_MISCONFIG) { - rip = kvm_rip_read(vcpu); - rip += vmcs_read32(VM_EXIT_INSTRUCTION_LEN); - kvm_rip_write(vcpu, rip); - } else { - if (!kvm_emulate_instruction(vcpu, EMULTYPE_SKIP)) - return 0; - } - - /* skipping an emulated instruction also counts */ - vmx_set_interrupt_shadow(vcpu, 0); - - return 1; -} - -static void vmx_clear_hlt(struct kvm_vcpu *vcpu) -{ - /* - * Ensure that we clear the HLT state in the VMCS. We don't need to - * explicitly skip the instruction because if the HLT state is set, - * then the instruction is already executing and RIP has already been - * advanced. - */ - if (kvm_hlt_in_guest(vcpu->kvm) && - vmcs_read32(GUEST_ACTIVITY_STATE) == GUEST_ACTIVITY_HLT) - vmcs_write32(GUEST_ACTIVITY_STATE, GUEST_ACTIVITY_ACTIVE); -} - -static void vmx_queue_exception(struct kvm_vcpu *vcpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned nr = vcpu->arch.exception.nr; - bool has_error_code = vcpu->arch.exception.has_error_code; - u32 error_code = vcpu->arch.exception.error_code; - u32 intr_info = nr | INTR_INFO_VALID_MASK; - - kvm_deliver_exception_payload(vcpu); - - if (has_error_code) { - vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code); - intr_info |= INTR_INFO_DELIVER_CODE_MASK; - } - - if (vmx->rmode.vm86_active) { - int inc_eip = 0; - if (kvm_exception_is_soft(nr)) - inc_eip = vcpu->arch.event_exit_inst_len; - kvm_inject_realmode_interrupt(vcpu, nr, inc_eip); - return; - } - - WARN_ON_ONCE(vmx->emulation_required); - - if (kvm_exception_is_soft(nr)) { - vmcs_write32(VM_ENTRY_INSTRUCTION_LEN, - vmx->vcpu.arch.event_exit_inst_len); - intr_info |= INTR_TYPE_SOFT_EXCEPTION; - } else - intr_info |= INTR_TYPE_HARD_EXCEPTION; - - vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr_info); - - vmx_clear_hlt(vcpu); -} - -static bool vmx_rdtscp_supported(void) -{ - return cpu_has_vmx_rdtscp(); -} - -static bool vmx_invpcid_supported(void) -{ - return cpu_has_vmx_invpcid(); -} - -/* - * Swap MSR entry in host/guest MSR entry array. - */ -static void move_msr_up(struct vcpu_vmx *vmx, int from, int to) -{ - struct shared_msr_entry tmp; - - tmp = vmx->guest_msrs[to]; - vmx->guest_msrs[to] = vmx->guest_msrs[from]; - vmx->guest_msrs[from] = tmp; -} - -/* - * Set up the vmcs to automatically save and restore system - * msrs. Don't touch the 64-bit msrs if the guest is in legacy - * mode, as fiddling with msrs is very expensive. - */ -static void setup_msrs(struct vcpu_vmx *vmx) -{ - int save_nmsrs, index; - - save_nmsrs = 0; -#ifdef CONFIG_X86_64 - /* - * The SYSCALL MSRs are only needed on long mode guests, and only - * when EFER.SCE is set. - */ - if (is_long_mode(&vmx->vcpu) && (vmx->vcpu.arch.efer & EFER_SCE)) { - index = __find_msr_index(vmx, MSR_STAR); - if (index >= 0) - move_msr_up(vmx, index, save_nmsrs++); - index = __find_msr_index(vmx, MSR_LSTAR); - if (index >= 0) - move_msr_up(vmx, index, save_nmsrs++); - index = __find_msr_index(vmx, MSR_SYSCALL_MASK); - if (index >= 0) - move_msr_up(vmx, index, save_nmsrs++); - } -#endif - index = __find_msr_index(vmx, MSR_EFER); - if (index >= 0 && update_transition_efer(vmx, index)) - move_msr_up(vmx, index, save_nmsrs++); - index = __find_msr_index(vmx, MSR_TSC_AUX); - if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP)) - move_msr_up(vmx, index, save_nmsrs++); - index = __find_msr_index(vmx, MSR_IA32_TSX_CTRL); - if (index >= 0) - move_msr_up(vmx, index, save_nmsrs++); - - vmx->save_nmsrs = save_nmsrs; - vmx->guest_msrs_ready = false; - - if (cpu_has_vmx_msr_bitmap()) - vmx_update_msr_bitmap(&vmx->vcpu); -} - -static u64 vmx_read_l1_tsc_offset(struct kvm_vcpu *vcpu) -{ - struct vmcs12 *vmcs12 = get_vmcs12(vcpu); - - if (is_guest_mode(vcpu) && - (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETTING)) - return vcpu->arch.tsc_offset - vmcs12->tsc_offset; - - return vcpu->arch.tsc_offset; -} - -static u64 vmx_write_l1_tsc_offset(struct kvm_vcpu *vcpu, u64 offset) -{ - struct vmcs12 *vmcs12 = get_vmcs12(vcpu); - u64 g_tsc_offset = 0; - - /* - * We're here if L1 chose not to trap WRMSR to TSC. According - * to the spec, this should set L1's TSC; The offset that L1 - * set for L2 remains unchanged, and still needs to be added - * to the newly set TSC to get L2's TSC. - */ - if (is_guest_mode(vcpu) && - (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETTING)) - g_tsc_offset = vmcs12->tsc_offset; - - trace_kvm_write_tsc_offset(vcpu->vcpu_id, - vcpu->arch.tsc_offset - g_tsc_offset, - offset); - vmcs_write64(TSC_OFFSET, offset + g_tsc_offset); - return offset + g_tsc_offset; -} - -/* - * nested_vmx_allowed() checks whether a guest should be allowed to use VMX - * instructions and MSRs (i.e., nested VMX). Nested VMX is disabled for - * all guests if the "nested" module option is off, and can also be disabled - * for a single guest by disabling its VMX cpuid bit. - */ -bool nested_vmx_allowed(struct kvm_vcpu *vcpu) -{ - return nested && guest_cpuid_has(vcpu, X86_FEATURE_VMX); -} - -static inline bool vmx_feature_control_msr_valid(struct kvm_vcpu *vcpu, - uint64_t val) -{ - uint64_t valid_bits = to_vmx(vcpu)->msr_ia32_feature_control_valid_bits; - - return !(val & ~valid_bits); -} - -static int vmx_get_msr_feature(struct kvm_msr_entry *msr) -{ - switch (msr->index) { - case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC: - if (!nested) - return 1; - return vmx_get_vmx_msr(&vmcs_config.nested, msr->index, &msr->data); - default: - return 1; - } -} - -/* - * Reads an msr value (of 'msr_index') into 'pdata'. - * Returns 0 on success, non-0 otherwise. - * Assumes vcpu_load() was already called. - */ -static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - struct shared_msr_entry *msr; - u32 index; - - switch (msr_info->index) { -#ifdef CONFIG_X86_64 - case MSR_FS_BASE: - msr_info->data = vmcs_readl(GUEST_FS_BASE); - break; - case MSR_GS_BASE: - msr_info->data = vmcs_readl(GUEST_GS_BASE); - break; - case MSR_KERNEL_GS_BASE: - msr_info->data = vmx_read_guest_kernel_gs_base(vmx); - break; -#endif - case MSR_EFER: - return kvm_get_msr_common(vcpu, msr_info); - case MSR_IA32_TSX_CTRL: - if (!msr_info->host_initiated && - !(vcpu->arch.arch_capabilities & ARCH_CAP_TSX_CTRL_MSR)) - return 1; - goto find_shared_msr; - case MSR_IA32_UMWAIT_CONTROL: - if (!msr_info->host_initiated && !vmx_has_waitpkg(vmx)) - return 1; - - msr_info->data = vmx->msr_ia32_umwait_control; - break; - case MSR_IA32_SPEC_CTRL: - if (!msr_info->host_initiated && - !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL)) - return 1; - - msr_info->data = to_vmx(vcpu)->spec_ctrl; - break; - case MSR_IA32_SYSENTER_CS: - msr_info->data = vmcs_read32(GUEST_SYSENTER_CS); - break; - case MSR_IA32_SYSENTER_EIP: - msr_info->data = vmcs_readl(GUEST_SYSENTER_EIP); - break; - case MSR_IA32_SYSENTER_ESP: - msr_info->data = vmcs_readl(GUEST_SYSENTER_ESP); - break; - case MSR_IA32_BNDCFGS: - if (!kvm_mpx_supported() || - (!msr_info->host_initiated && - !guest_cpuid_has(vcpu, X86_FEATURE_MPX))) - return 1; - msr_info->data = vmcs_read64(GUEST_BNDCFGS); - break; - case MSR_IA32_MCG_EXT_CTL: - if (!msr_info->host_initiated && - !(vmx->msr_ia32_feature_control & - FEATURE_CONTROL_LMCE)) - return 1; - msr_info->data = vcpu->arch.mcg_ext_ctl; - break; - case MSR_IA32_FEATURE_CONTROL: - msr_info->data = vmx->msr_ia32_feature_control; - break; - case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC: - if (!nested_vmx_allowed(vcpu)) - return 1; - return vmx_get_vmx_msr(&vmx->nested.msrs, msr_info->index, - &msr_info->data); - case MSR_IA32_RTIT_CTL: - if (pt_mode != PT_MODE_HOST_GUEST) - return 1; - msr_info->data = vmx->pt_desc.guest.ctl; - break; - case MSR_IA32_RTIT_STATUS: - if (pt_mode != PT_MODE_HOST_GUEST) - return 1; - msr_info->data = vmx->pt_desc.guest.status; - break; - case MSR_IA32_RTIT_CR3_MATCH: - if ((pt_mode != PT_MODE_HOST_GUEST) || - !intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_cr3_filtering)) - return 1; - msr_info->data = vmx->pt_desc.guest.cr3_match; - break; - case MSR_IA32_RTIT_OUTPUT_BASE: - if ((pt_mode != PT_MODE_HOST_GUEST) || - (!intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_topa_output) && - !intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_single_range_output))) - return 1; - msr_info->data = vmx->pt_desc.guest.output_base; - break; - case MSR_IA32_RTIT_OUTPUT_MASK: - if ((pt_mode != PT_MODE_HOST_GUEST) || - (!intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_topa_output) && - !intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_single_range_output))) - return 1; - msr_info->data = vmx->pt_desc.guest.output_mask; - break; - case MSR_IA32_RTIT_ADDR0_A ... MSR_IA32_RTIT_ADDR3_B: - index = msr_info->index - MSR_IA32_RTIT_ADDR0_A; - if ((pt_mode != PT_MODE_HOST_GUEST) || - (index >= 2 * intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_num_address_ranges))) - return 1; - if (is_noncanonical_address(data, vcpu)) - return 1; - if (index % 2) - msr_info->data = vmx->pt_desc.guest.addr_b[index / 2]; - else - msr_info->data = vmx->pt_desc.guest.addr_a[index / 2]; - break; - case MSR_TSC_AUX: - if (!msr_info->host_initiated && - !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) - return 1; - goto find_shared_msr; - default: - find_shared_msr: - msr = find_msr_entry(vmx, msr_info->index); - if (msr) { - msr_info->data = msr->data; - break; - } - return kvm_get_msr_common(vcpu, msr_info); - } - - return 0; -} - -/* - * Writes msr value into the appropriate "register". - * Returns 0 on success, non-0 otherwise. - * Assumes vcpu_load() was already called. - */ -static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - struct shared_msr_entry *msr; - int ret = 0; - u32 msr_index = msr_info->index; - u64 data = msr_info->data; - u32 index; - - switch (msr_index) { - case MSR_EFER: - ret = kvm_set_msr_common(vcpu, msr_info); - break; -#ifdef CONFIG_X86_64 - case MSR_FS_BASE: - vmx_segment_cache_clear(vmx); - vmcs_writel(GUEST_FS_BASE, data); - break; - case MSR_GS_BASE: - vmx_segment_cache_clear(vmx); - vmcs_writel(GUEST_GS_BASE, data); - break; - case MSR_KERNEL_GS_BASE: - vmx_write_guest_kernel_gs_base(vmx, data); - break; -#endif - case MSR_IA32_SYSENTER_CS: - if (is_guest_mode(vcpu)) - get_vmcs12(vcpu)->guest_sysenter_cs = data; - vmcs_write32(GUEST_SYSENTER_CS, data); - break; - case MSR_IA32_SYSENTER_EIP: - if (is_guest_mode(vcpu)) - get_vmcs12(vcpu)->guest_sysenter_eip = data; - vmcs_writel(GUEST_SYSENTER_EIP, data); - break; - case MSR_IA32_SYSENTER_ESP: - if (is_guest_mode(vcpu)) - get_vmcs12(vcpu)->guest_sysenter_esp = data; - vmcs_writel(GUEST_SYSENTER_ESP, data); - break; - case MSR_IA32_DEBUGCTLMSR: - if (is_guest_mode(vcpu) && get_vmcs12(vcpu)->vm_exit_controls & - VM_EXIT_SAVE_DEBUG_CONTROLS) - get_vmcs12(vcpu)->guest_ia32_debugctl = data; - - ret = kvm_set_msr_common(vcpu, msr_info); - break; - - case MSR_IA32_BNDCFGS: - if (!kvm_mpx_supported() || - (!msr_info->host_initiated && - !guest_cpuid_has(vcpu, X86_FEATURE_MPX))) - return 1; - if (is_noncanonical_address(data & PAGE_MASK, vcpu) || - (data & MSR_IA32_BNDCFGS_RSVD)) - return 1; - vmcs_write64(GUEST_BNDCFGS, data); - break; - case MSR_IA32_UMWAIT_CONTROL: - if (!msr_info->host_initiated && !vmx_has_waitpkg(vmx)) - return 1; - - /* The reserved bit 1 and non-32 bit [63:32] should be zero */ - if (data & (BIT_ULL(1) | GENMASK_ULL(63, 32))) - return 1; - - vmx->msr_ia32_umwait_control = data; - break; - case MSR_IA32_SPEC_CTRL: - if (!msr_info->host_initiated && - !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL)) - return 1; - - /* The STIBP bit doesn't fault even if it's not advertised */ - if (data & ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_SSBD)) - return 1; - - vmx->spec_ctrl = data; - - if (!data) - break; - - /* - * For non-nested: - * When it's written (to non-zero) for the first time, pass - * it through. - * - * For nested: - * The handling of the MSR bitmap for L2 guests is done in - * nested_vmx_prepare_msr_bitmap. We should not touch the - * vmcs02.msr_bitmap here since it gets completely overwritten - * in the merging. We update the vmcs01 here for L1 as well - * since it will end up touching the MSR anyway now. - */ - vmx_disable_intercept_for_msr(vmx->vmcs01.msr_bitmap, - MSR_IA32_SPEC_CTRL, - MSR_TYPE_RW); - break; - case MSR_IA32_TSX_CTRL: - if (!msr_info->host_initiated && - !(vcpu->arch.arch_capabilities & ARCH_CAP_TSX_CTRL_MSR)) - return 1; - if (data & ~(TSX_CTRL_RTM_DISABLE | TSX_CTRL_CPUID_CLEAR)) - return 1; - goto find_shared_msr; - case MSR_IA32_PRED_CMD: - if (!msr_info->host_initiated && - !guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL)) - return 1; - - if (data & ~PRED_CMD_IBPB) - return 1; - - if (!data) - break; - - wrmsrl(MSR_IA32_PRED_CMD, PRED_CMD_IBPB); - - /* - * For non-nested: - * When it's written (to non-zero) for the first time, pass - * it through. - * - * For nested: - * The handling of the MSR bitmap for L2 guests is done in - * nested_vmx_prepare_msr_bitmap. We should not touch the - * vmcs02.msr_bitmap here since it gets completely overwritten - * in the merging. - */ - vmx_disable_intercept_for_msr(vmx->vmcs01.msr_bitmap, MSR_IA32_PRED_CMD, - MSR_TYPE_W); - break; - case MSR_IA32_CR_PAT: - if (!kvm_pat_valid(data)) - return 1; - - if (is_guest_mode(vcpu) && - get_vmcs12(vcpu)->vm_exit_controls & VM_EXIT_SAVE_IA32_PAT) - get_vmcs12(vcpu)->guest_ia32_pat = data; - - if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) { - vmcs_write64(GUEST_IA32_PAT, data); - vcpu->arch.pat = data; - break; - } - ret = kvm_set_msr_common(vcpu, msr_info); - break; - case MSR_IA32_TSC_ADJUST: - ret = kvm_set_msr_common(vcpu, msr_info); - break; - case MSR_IA32_MCG_EXT_CTL: - if ((!msr_info->host_initiated && - !(to_vmx(vcpu)->msr_ia32_feature_control & - FEATURE_CONTROL_LMCE)) || - (data & ~MCG_EXT_CTL_LMCE_EN)) - return 1; - vcpu->arch.mcg_ext_ctl = data; - break; - case MSR_IA32_FEATURE_CONTROL: - if (!vmx_feature_control_msr_valid(vcpu, data) || - (to_vmx(vcpu)->msr_ia32_feature_control & - FEATURE_CONTROL_LOCKED && !msr_info->host_initiated)) - return 1; - vmx->msr_ia32_feature_control = data; - if (msr_info->host_initiated && data == 0) - vmx_leave_nested(vcpu); - break; - case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_VMFUNC: - if (!msr_info->host_initiated) - return 1; /* they are read-only */ - if (!nested_vmx_allowed(vcpu)) - return 1; - return vmx_set_vmx_msr(vcpu, msr_index, data); - case MSR_IA32_RTIT_CTL: - if ((pt_mode != PT_MODE_HOST_GUEST) || - vmx_rtit_ctl_check(vcpu, data) || - vmx->nested.vmxon) - return 1; - vmcs_write64(GUEST_IA32_RTIT_CTL, data); - vmx->pt_desc.guest.ctl = data; - pt_update_intercept_for_msr(vmx); - break; - case MSR_IA32_RTIT_STATUS: - if ((pt_mode != PT_MODE_HOST_GUEST) || - (vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) || - (data & MSR_IA32_RTIT_STATUS_MASK)) - return 1; - vmx->pt_desc.guest.status = data; - break; - case MSR_IA32_RTIT_CR3_MATCH: - if ((pt_mode != PT_MODE_HOST_GUEST) || - (vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) || - !intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_cr3_filtering)) - return 1; - vmx->pt_desc.guest.cr3_match = data; - break; - case MSR_IA32_RTIT_OUTPUT_BASE: - if ((pt_mode != PT_MODE_HOST_GUEST) || - (vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) || - (!intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_topa_output) && - !intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_single_range_output)) || - (data & MSR_IA32_RTIT_OUTPUT_BASE_MASK)) - return 1; - vmx->pt_desc.guest.output_base = data; - break; - case MSR_IA32_RTIT_OUTPUT_MASK: - if ((pt_mode != PT_MODE_HOST_GUEST) || - (vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) || - (!intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_topa_output) && - !intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_single_range_output))) - return 1; - vmx->pt_desc.guest.output_mask = data; - break; - case MSR_IA32_RTIT_ADDR0_A ... MSR_IA32_RTIT_ADDR3_B: - index = msr_info->index - MSR_IA32_RTIT_ADDR0_A; - if ((pt_mode != PT_MODE_HOST_GUEST) || - (vmx->pt_desc.guest.ctl & RTIT_CTL_TRACEEN) || - (index >= 2 * intel_pt_validate_cap(vmx->pt_desc.caps, - PT_CAP_num_address_ranges))) - return 1; - if (is_noncanonical_address(data, vcpu)) - return 1; - if (index % 2) - vmx->pt_desc.guest.addr_b[index / 2] = data; - else - vmx->pt_desc.guest.addr_a[index / 2] = data; - break; - case MSR_TSC_AUX: - if (!msr_info->host_initiated && - !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) - return 1; - /* Check reserved bit, higher 32 bits should be zero */ - if ((data >> 32) != 0) - return 1; - goto find_shared_msr; - - default: - find_shared_msr: - msr = find_msr_entry(vmx, msr_index); - if (msr) - ret = vmx_set_guest_msr(vmx, msr, data); - else - ret = kvm_set_msr_common(vcpu, msr_info); - } - - return ret; -} - -static void vmx_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg) -{ - kvm_register_mark_available(vcpu, reg); - - switch (reg) { - case VCPU_REGS_RSP: - vcpu->arch.regs[VCPU_REGS_RSP] = vmcs_readl(GUEST_RSP); - break; - case VCPU_REGS_RIP: - vcpu->arch.regs[VCPU_REGS_RIP] = vmcs_readl(GUEST_RIP); - break; - case VCPU_EXREG_PDPTR: - if (enable_ept) - ept_save_pdptrs(vcpu); - break; - case VCPU_EXREG_CR3: - if (enable_unrestricted_guest || (enable_ept && is_paging(vcpu))) - vcpu->arch.cr3 = vmcs_readl(GUEST_CR3); - break; - default: - WARN_ON_ONCE(1); - break; - } -} - -static __init int cpu_has_kvm_support(void) -{ - return cpu_has_vmx(); -} - -static __init int vmx_disabled_by_bios(void) -{ - u64 msr; - - rdmsrl(MSR_IA32_FEATURE_CONTROL, msr); - if (msr & FEATURE_CONTROL_LOCKED) { - /* launched w/ TXT and VMX disabled */ - if (!(msr & FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX) - && tboot_enabled()) - return 1; - /* launched w/o TXT and VMX only enabled w/ TXT */ - if (!(msr & FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX) - && (msr & FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX) - && !tboot_enabled()) { - printk(KERN_WARNING "kvm: disable TXT in the BIOS or " - "activate TXT before enabling KVM\n"); - return 1; - } - /* launched w/o TXT and VMX disabled */ - if (!(msr & FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX) - && !tboot_enabled()) - return 1; - } - - return 0; -} - -static void kvm_cpu_vmxon(u64 addr) -{ - cr4_set_bits(X86_CR4_VMXE); - intel_pt_handle_vmx(1); - - asm volatile ("vmxon %0" : : "m"(addr)); -} - -static int hardware_enable(void) -{ - int cpu = raw_smp_processor_id(); - u64 phys_addr = __pa(per_cpu(vmxarea, cpu)); - u64 old, test_bits; - - if (cr4_read_shadow() & X86_CR4_VMXE) - return -EBUSY; - - /* - * This can happen if we hot-added a CPU but failed to allocate - * VP assist page for it. - */ - if (static_branch_unlikely(&enable_evmcs) && - !hv_get_vp_assist_page(cpu)) - return -EFAULT; - - INIT_LIST_HEAD(&per_cpu(loaded_vmcss_on_cpu, cpu)); - INIT_LIST_HEAD(&per_cpu(blocked_vcpu_on_cpu, cpu)); - spin_lock_init(&per_cpu(blocked_vcpu_on_cpu_lock, cpu)); - - /* - * Now we can enable the vmclear operation in kdump - * since the loaded_vmcss_on_cpu list on this cpu - * has been initialized. - * - * Though the cpu is not in VMX operation now, there - * is no problem to enable the vmclear operation - * for the loaded_vmcss_on_cpu list is empty! - */ - crash_enable_local_vmclear(cpu); - - rdmsrl(MSR_IA32_FEATURE_CONTROL, old); - - test_bits = FEATURE_CONTROL_LOCKED; - test_bits |= FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; - if (tboot_enabled()) - test_bits |= FEATURE_CONTROL_VMXON_ENABLED_INSIDE_SMX; - - if ((old & test_bits) != test_bits) { - /* enable and lock */ - wrmsrl(MSR_IA32_FEATURE_CONTROL, old | test_bits); - } - kvm_cpu_vmxon(phys_addr); - if (enable_ept) - ept_sync_global(); - - return 0; -} - -static void vmclear_local_loaded_vmcss(void) -{ - int cpu = raw_smp_processor_id(); - struct loaded_vmcs *v, *n; - - list_for_each_entry_safe(v, n, &per_cpu(loaded_vmcss_on_cpu, cpu), - loaded_vmcss_on_cpu_link) - __loaded_vmcs_clear(v); -} - - -/* Just like cpu_vmxoff(), but with the __kvm_handle_fault_on_reboot() - * tricks. - */ -static void kvm_cpu_vmxoff(void) -{ - asm volatile (__ex("vmxoff")); - - intel_pt_handle_vmx(0); - cr4_clear_bits(X86_CR4_VMXE); -} - -static void hardware_disable(void) -{ - vmclear_local_loaded_vmcss(); - kvm_cpu_vmxoff(); -} - -static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, - u32 msr, u32 *result) -{ - u32 vmx_msr_low, vmx_msr_high; - u32 ctl = ctl_min | ctl_opt; - - rdmsr(msr, vmx_msr_low, vmx_msr_high); - - ctl &= vmx_msr_high; /* bit == 0 in high word ==> must be zero */ - ctl |= vmx_msr_low; /* bit == 1 in low word ==> must be one */ - - /* Ensure minimum (required) set of control bits are supported. */ - if (ctl_min & ~ctl) - return -EIO; - - *result = ctl; - return 0; -} - -static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf, - struct vmx_capability *vmx_cap) -{ - u32 vmx_msr_low, vmx_msr_high; - u32 min, opt, min2, opt2; - u32 _pin_based_exec_control = 0; - u32 _cpu_based_exec_control = 0; - u32 _cpu_based_2nd_exec_control = 0; - u32 _vmexit_control = 0; - u32 _vmentry_control = 0; - - memset(vmcs_conf, 0, sizeof(*vmcs_conf)); - min = CPU_BASED_HLT_EXITING | -#ifdef CONFIG_X86_64 - CPU_BASED_CR8_LOAD_EXITING | - CPU_BASED_CR8_STORE_EXITING | -#endif - CPU_BASED_CR3_LOAD_EXITING | - CPU_BASED_CR3_STORE_EXITING | - CPU_BASED_UNCOND_IO_EXITING | - CPU_BASED_MOV_DR_EXITING | - CPU_BASED_USE_TSC_OFFSETTING | - CPU_BASED_MWAIT_EXITING | - CPU_BASED_MONITOR_EXITING | - CPU_BASED_INVLPG_EXITING | - CPU_BASED_RDPMC_EXITING; - - opt = CPU_BASED_TPR_SHADOW | - CPU_BASED_USE_MSR_BITMAPS | - CPU_BASED_ACTIVATE_SECONDARY_CONTROLS; - if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PROCBASED_CTLS, - &_cpu_based_exec_control) < 0) - return -EIO; -#ifdef CONFIG_X86_64 - if ((_cpu_based_exec_control & CPU_BASED_TPR_SHADOW)) - _cpu_based_exec_control &= ~CPU_BASED_CR8_LOAD_EXITING & - ~CPU_BASED_CR8_STORE_EXITING; -#endif - if (_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS) { - min2 = 0; - opt2 = SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | - SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | - SECONDARY_EXEC_WBINVD_EXITING | - SECONDARY_EXEC_ENABLE_VPID | - SECONDARY_EXEC_ENABLE_EPT | - SECONDARY_EXEC_UNRESTRICTED_GUEST | - SECONDARY_EXEC_PAUSE_LOOP_EXITING | - SECONDARY_EXEC_DESC | - SECONDARY_EXEC_RDTSCP | - SECONDARY_EXEC_ENABLE_INVPCID | - SECONDARY_EXEC_APIC_REGISTER_VIRT | - SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY | - SECONDARY_EXEC_SHADOW_VMCS | - SECONDARY_EXEC_XSAVES | - SECONDARY_EXEC_RDSEED_EXITING | - SECONDARY_EXEC_RDRAND_EXITING | - SECONDARY_EXEC_ENABLE_PML | - SECONDARY_EXEC_TSC_SCALING | - SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE | - SECONDARY_EXEC_PT_USE_GPA | - SECONDARY_EXEC_PT_CONCEAL_VMX | - SECONDARY_EXEC_ENABLE_VMFUNC | - SECONDARY_EXEC_ENCLS_EXITING; - if (adjust_vmx_controls(min2, opt2, - MSR_IA32_VMX_PROCBASED_CTLS2, - &_cpu_based_2nd_exec_control) < 0) - return -EIO; - } -#ifndef CONFIG_X86_64 - if (!(_cpu_based_2nd_exec_control & - SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) - _cpu_based_exec_control &= ~CPU_BASED_TPR_SHADOW; -#endif - - if (!(_cpu_based_exec_control & CPU_BASED_TPR_SHADOW)) - _cpu_based_2nd_exec_control &= ~( - SECONDARY_EXEC_APIC_REGISTER_VIRT | - SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE | - SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY); - - rdmsr_safe(MSR_IA32_VMX_EPT_VPID_CAP, - &vmx_cap->ept, &vmx_cap->vpid); - - if (_cpu_based_2nd_exec_control & SECONDARY_EXEC_ENABLE_EPT) { - /* CR3 accesses and invlpg don't need to cause VM Exits when EPT - enabled */ - _cpu_based_exec_control &= ~(CPU_BASED_CR3_LOAD_EXITING | - CPU_BASED_CR3_STORE_EXITING | - CPU_BASED_INVLPG_EXITING); - } else if (vmx_cap->ept) { - vmx_cap->ept = 0; - pr_warn_once("EPT CAP should not exist if not support " - "1-setting enable EPT VM-execution control\n"); - } - if (!(_cpu_based_2nd_exec_control & SECONDARY_EXEC_ENABLE_VPID) && - vmx_cap->vpid) { - vmx_cap->vpid = 0; - pr_warn_once("VPID CAP should not exist if not support " - "1-setting enable VPID VM-execution control\n"); - } - - min = VM_EXIT_SAVE_DEBUG_CONTROLS | VM_EXIT_ACK_INTR_ON_EXIT; -#ifdef CONFIG_X86_64 - min |= VM_EXIT_HOST_ADDR_SPACE_SIZE; -#endif - opt = VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL | - VM_EXIT_LOAD_IA32_PAT | - VM_EXIT_LOAD_IA32_EFER | - VM_EXIT_CLEAR_BNDCFGS | - VM_EXIT_PT_CONCEAL_PIP | - VM_EXIT_CLEAR_IA32_RTIT_CTL; - if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_EXIT_CTLS, - &_vmexit_control) < 0) - return -EIO; - - min = PIN_BASED_EXT_INTR_MASK | PIN_BASED_NMI_EXITING; - opt = PIN_BASED_VIRTUAL_NMIS | PIN_BASED_POSTED_INTR | - PIN_BASED_VMX_PREEMPTION_TIMER; - if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_PINBASED_CTLS, - &_pin_based_exec_control) < 0) - return -EIO; - - if (cpu_has_broken_vmx_preemption_timer()) - _pin_based_exec_control &= ~PIN_BASED_VMX_PREEMPTION_TIMER; - if (!(_cpu_based_2nd_exec_control & - SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY)) - _pin_based_exec_control &= ~PIN_BASED_POSTED_INTR; - - min = VM_ENTRY_LOAD_DEBUG_CONTROLS; - opt = VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL | - VM_ENTRY_LOAD_IA32_PAT | - VM_ENTRY_LOAD_IA32_EFER | - VM_ENTRY_LOAD_BNDCFGS | - VM_ENTRY_PT_CONCEAL_PIP | - VM_ENTRY_LOAD_IA32_RTIT_CTL; - if (adjust_vmx_controls(min, opt, MSR_IA32_VMX_ENTRY_CTLS, - &_vmentry_control) < 0) - return -EIO; - - /* - * Some cpus support VM_{ENTRY,EXIT}_IA32_PERF_GLOBAL_CTRL but they - * can't be used due to an errata where VM Exit may incorrectly clear - * IA32_PERF_GLOBAL_CTRL[34:32]. Workaround the errata by using the - * MSR load mechanism to switch IA32_PERF_GLOBAL_CTRL. - */ - if (boot_cpu_data.x86 == 0x6) { - switch (boot_cpu_data.x86_model) { - case 26: /* AAK155 */ - case 30: /* AAP115 */ - case 37: /* AAT100 */ - case 44: /* BC86,AAY89,BD102 */ - case 46: /* BA97 */ - _vmentry_control &= ~VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL; - _vmexit_control &= ~VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL; - pr_warn_once("kvm: VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL " - "does not work properly. Using workaround\n"); - break; - default: - break; - } - } - - - rdmsr(MSR_IA32_VMX_BASIC, vmx_msr_low, vmx_msr_high); - - /* IA-32 SDM Vol 3B: VMCS size is never greater than 4kB. */ - if ((vmx_msr_high & 0x1fff) > PAGE_SIZE) - return -EIO; - -#ifdef CONFIG_X86_64 - /* IA-32 SDM Vol 3B: 64-bit CPUs always have VMX_BASIC_MSR[48]==0. */ - if (vmx_msr_high & (1u<<16)) - return -EIO; -#endif - - /* Require Write-Back (WB) memory type for VMCS accesses. */ - if (((vmx_msr_high >> 18) & 15) != 6) - return -EIO; - - vmcs_conf->size = vmx_msr_high & 0x1fff; - vmcs_conf->order = get_order(vmcs_conf->size); - vmcs_conf->basic_cap = vmx_msr_high & ~0x1fff; - - vmcs_conf->revision_id = vmx_msr_low; - - vmcs_conf->pin_based_exec_ctrl = _pin_based_exec_control; - vmcs_conf->cpu_based_exec_ctrl = _cpu_based_exec_control; - vmcs_conf->cpu_based_2nd_exec_ctrl = _cpu_based_2nd_exec_control; - vmcs_conf->vmexit_ctrl = _vmexit_control; - vmcs_conf->vmentry_ctrl = _vmentry_control; - - if (static_branch_unlikely(&enable_evmcs)) - evmcs_sanitize_exec_ctrls(vmcs_conf); - - return 0; -} - -struct vmcs *alloc_vmcs_cpu(bool shadow, int cpu, gfp_t flags) -{ - int node = cpu_to_node(cpu); - struct page *pages; - struct vmcs *vmcs; - - pages = __alloc_pages_node(node, flags, vmcs_config.order); - if (!pages) - return NULL; - vmcs = page_address(pages); - memset(vmcs, 0, vmcs_config.size); - - /* KVM supports Enlightened VMCS v1 only */ - if (static_branch_unlikely(&enable_evmcs)) - vmcs->hdr.revision_id = KVM_EVMCS_VERSION; - else - vmcs->hdr.revision_id = vmcs_config.revision_id; - - if (shadow) - vmcs->hdr.shadow_vmcs = 1; - return vmcs; -} - -void free_vmcs(struct vmcs *vmcs) -{ - free_pages((unsigned long)vmcs, vmcs_config.order); -} - -/* - * Free a VMCS, but before that VMCLEAR it on the CPU where it was last loaded - */ -void free_loaded_vmcs(struct loaded_vmcs *loaded_vmcs) -{ - if (!loaded_vmcs->vmcs) - return; - loaded_vmcs_clear(loaded_vmcs); - free_vmcs(loaded_vmcs->vmcs); - loaded_vmcs->vmcs = NULL; - if (loaded_vmcs->msr_bitmap) - free_page((unsigned long)loaded_vmcs->msr_bitmap); - WARN_ON(loaded_vmcs->shadow_vmcs != NULL); -} - -int alloc_loaded_vmcs(struct loaded_vmcs *loaded_vmcs) -{ - loaded_vmcs->vmcs = alloc_vmcs(false); - if (!loaded_vmcs->vmcs) - return -ENOMEM; - - loaded_vmcs->shadow_vmcs = NULL; - loaded_vmcs->hv_timer_soft_disabled = false; - loaded_vmcs_init(loaded_vmcs); - - if (cpu_has_vmx_msr_bitmap()) { - loaded_vmcs->msr_bitmap = (unsigned long *) - __get_free_page(GFP_KERNEL_ACCOUNT); - if (!loaded_vmcs->msr_bitmap) - goto out_vmcs; - memset(loaded_vmcs->msr_bitmap, 0xff, PAGE_SIZE); - - if (IS_ENABLED(CONFIG_HYPERV) && - static_branch_unlikely(&enable_evmcs) && - (ms_hyperv.nested_features & HV_X64_NESTED_MSR_BITMAP)) { - struct hv_enlightened_vmcs *evmcs = - (struct hv_enlightened_vmcs *)loaded_vmcs->vmcs; - - evmcs->hv_enlightenments_control.msr_bitmap = 1; - } - } - - memset(&loaded_vmcs->host_state, 0, sizeof(struct vmcs_host_state)); - memset(&loaded_vmcs->controls_shadow, 0, - sizeof(struct vmcs_controls_shadow)); - - return 0; - -out_vmcs: - free_loaded_vmcs(loaded_vmcs); - return -ENOMEM; -} - -static void free_kvm_area(void) -{ - int cpu; - - for_each_possible_cpu(cpu) { - free_vmcs(per_cpu(vmxarea, cpu)); - per_cpu(vmxarea, cpu) = NULL; - } -} - -static __init int alloc_kvm_area(void) -{ - int cpu; - - for_each_possible_cpu(cpu) { - struct vmcs *vmcs; - - vmcs = alloc_vmcs_cpu(false, cpu, GFP_KERNEL); - if (!vmcs) { - free_kvm_area(); - return -ENOMEM; - } - - /* - * When eVMCS is enabled, alloc_vmcs_cpu() sets - * vmcs->revision_id to KVM_EVMCS_VERSION instead of - * revision_id reported by MSR_IA32_VMX_BASIC. - * - * However, even though not explicitly documented by - * TLFS, VMXArea passed as VMXON argument should - * still be marked with revision_id reported by - * physical CPU. - */ - if (static_branch_unlikely(&enable_evmcs)) - vmcs->hdr.revision_id = vmcs_config.revision_id; - - per_cpu(vmxarea, cpu) = vmcs; - } - return 0; -} - -static void fix_pmode_seg(struct kvm_vcpu *vcpu, int seg, - struct kvm_segment *save) -{ - if (!emulate_invalid_guest_state) { - /* - * CS and SS RPL should be equal during guest entry according - * to VMX spec, but in reality it is not always so. Since vcpu - * is in the middle of the transition from real mode to - * protected mode it is safe to assume that RPL 0 is a good - * default value. - */ - if (seg == VCPU_SREG_CS || seg == VCPU_SREG_SS) - save->selector &= ~SEGMENT_RPL_MASK; - save->dpl = save->selector & SEGMENT_RPL_MASK; - save->s = 1; - } - vmx_set_segment(vcpu, save, seg); -} - -static void enter_pmode(struct kvm_vcpu *vcpu) -{ - unsigned long flags; - struct vcpu_vmx *vmx = to_vmx(vcpu); - - /* - * Update real mode segment cache. It may be not up-to-date if sement - * register was written while vcpu was in a guest mode. - */ - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_ES], VCPU_SREG_ES); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_DS], VCPU_SREG_DS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_FS], VCPU_SREG_FS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_GS], VCPU_SREG_GS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_SS], VCPU_SREG_SS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_CS], VCPU_SREG_CS); - - vmx->rmode.vm86_active = 0; - - vmx_segment_cache_clear(vmx); - - vmx_set_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_TR], VCPU_SREG_TR); - - flags = vmcs_readl(GUEST_RFLAGS); - flags &= RMODE_GUEST_OWNED_EFLAGS_BITS; - flags |= vmx->rmode.save_rflags & ~RMODE_GUEST_OWNED_EFLAGS_BITS; - vmcs_writel(GUEST_RFLAGS, flags); - - vmcs_writel(GUEST_CR4, (vmcs_readl(GUEST_CR4) & ~X86_CR4_VME) | - (vmcs_readl(CR4_READ_SHADOW) & X86_CR4_VME)); - - update_exception_bitmap(vcpu); - - fix_pmode_seg(vcpu, VCPU_SREG_CS, &vmx->rmode.segs[VCPU_SREG_CS]); - fix_pmode_seg(vcpu, VCPU_SREG_SS, &vmx->rmode.segs[VCPU_SREG_SS]); - fix_pmode_seg(vcpu, VCPU_SREG_ES, &vmx->rmode.segs[VCPU_SREG_ES]); - fix_pmode_seg(vcpu, VCPU_SREG_DS, &vmx->rmode.segs[VCPU_SREG_DS]); - fix_pmode_seg(vcpu, VCPU_SREG_FS, &vmx->rmode.segs[VCPU_SREG_FS]); - fix_pmode_seg(vcpu, VCPU_SREG_GS, &vmx->rmode.segs[VCPU_SREG_GS]); -} - -static void fix_rmode_seg(int seg, struct kvm_segment *save) -{ - const struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; - struct kvm_segment var = *save; - - var.dpl = 0x3; - if (seg == VCPU_SREG_CS) - var.type = 0x3; - - if (!emulate_invalid_guest_state) { - var.selector = var.base >> 4; - var.base = var.base & 0xffff0; - var.limit = 0xffff; - var.g = 0; - var.db = 0; - var.present = 1; - var.s = 1; - var.l = 0; - var.unusable = 0; - var.type = 0x3; - var.avl = 0; - if (save->base & 0xf) - printk_once(KERN_WARNING "kvm: segment base is not " - "paragraph aligned when entering " - "protected mode (seg=%d)", seg); - } - - vmcs_write16(sf->selector, var.selector); - vmcs_writel(sf->base, var.base); - vmcs_write32(sf->limit, var.limit); - vmcs_write32(sf->ar_bytes, vmx_segment_access_rights(&var)); -} - -static void enter_rmode(struct kvm_vcpu *vcpu) -{ - unsigned long flags; - struct vcpu_vmx *vmx = to_vmx(vcpu); - struct kvm_vmx *kvm_vmx = to_kvm_vmx(vcpu->kvm); - - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_TR], VCPU_SREG_TR); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_ES], VCPU_SREG_ES); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_DS], VCPU_SREG_DS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_FS], VCPU_SREG_FS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_GS], VCPU_SREG_GS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_SS], VCPU_SREG_SS); - vmx_get_segment(vcpu, &vmx->rmode.segs[VCPU_SREG_CS], VCPU_SREG_CS); - - vmx->rmode.vm86_active = 1; - - /* - * Very old userspace does not call KVM_SET_TSS_ADDR before entering - * vcpu. Warn the user that an update is overdue. - */ - if (!kvm_vmx->tss_addr) - printk_once(KERN_WARNING "kvm: KVM_SET_TSS_ADDR need to be " - "called before entering vcpu\n"); - - vmx_segment_cache_clear(vmx); - - vmcs_writel(GUEST_TR_BASE, kvm_vmx->tss_addr); - vmcs_write32(GUEST_TR_LIMIT, RMODE_TSS_SIZE - 1); - vmcs_write32(GUEST_TR_AR_BYTES, 0x008b); - - flags = vmcs_readl(GUEST_RFLAGS); - vmx->rmode.save_rflags = flags; - - flags |= X86_EFLAGS_IOPL | X86_EFLAGS_VM; - - vmcs_writel(GUEST_RFLAGS, flags); - vmcs_writel(GUEST_CR4, vmcs_readl(GUEST_CR4) | X86_CR4_VME); - update_exception_bitmap(vcpu); - - fix_rmode_seg(VCPU_SREG_SS, &vmx->rmode.segs[VCPU_SREG_SS]); - fix_rmode_seg(VCPU_SREG_CS, &vmx->rmode.segs[VCPU_SREG_CS]); - fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.segs[VCPU_SREG_ES]); - fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.segs[VCPU_SREG_DS]); - fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.segs[VCPU_SREG_GS]); - fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.segs[VCPU_SREG_FS]); - - kvm_mmu_reset_context(vcpu); -} - -void vmx_set_efer(struct kvm_vcpu *vcpu, u64 efer) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - struct shared_msr_entry *msr = find_msr_entry(vmx, MSR_EFER); - - if (!msr) - return; - - vcpu->arch.efer = efer; - if (efer & EFER_LMA) { - vm_entry_controls_setbit(to_vmx(vcpu), VM_ENTRY_IA32E_MODE); - msr->data = efer; - } else { - vm_entry_controls_clearbit(to_vmx(vcpu), VM_ENTRY_IA32E_MODE); - - msr->data = efer & ~EFER_LME; - } - setup_msrs(vmx); -} - -#ifdef CONFIG_X86_64 - -static void enter_lmode(struct kvm_vcpu *vcpu) -{ - u32 guest_tr_ar; - - vmx_segment_cache_clear(to_vmx(vcpu)); - - guest_tr_ar = vmcs_read32(GUEST_TR_AR_BYTES); - if ((guest_tr_ar & VMX_AR_TYPE_MASK) != VMX_AR_TYPE_BUSY_64_TSS) { - pr_debug_ratelimited("%s: tss fixup for long mode. \n", - __func__); - vmcs_write32(GUEST_TR_AR_BYTES, - (guest_tr_ar & ~VMX_AR_TYPE_MASK) - | VMX_AR_TYPE_BUSY_64_TSS); - } - vmx_set_efer(vcpu, vcpu->arch.efer | EFER_LMA); -} - -static void exit_lmode(struct kvm_vcpu *vcpu) -{ - vm_entry_controls_clearbit(to_vmx(vcpu), VM_ENTRY_IA32E_MODE); - vmx_set_efer(vcpu, vcpu->arch.efer & ~EFER_LMA); -} - -#endif - -static void vmx_flush_tlb_gva(struct kvm_vcpu *vcpu, gva_t addr) -{ - int vpid = to_vmx(vcpu)->vpid; - - if (!vpid_sync_vcpu_addr(vpid, addr)) - vpid_sync_context(vpid); - - /* - * If VPIDs are not supported or enabled, then the above is a no-op. - * But we don't really need a TLB flush in that case anyway, because - * each VM entry/exit includes an implicit flush when VPID is 0. - */ -} - -static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu) -{ - ulong cr0_guest_owned_bits = vcpu->arch.cr0_guest_owned_bits; - - vcpu->arch.cr0 &= ~cr0_guest_owned_bits; - vcpu->arch.cr0 |= vmcs_readl(GUEST_CR0) & cr0_guest_owned_bits; -} - -static void vmx_decache_cr4_guest_bits(struct kvm_vcpu *vcpu) -{ - ulong cr4_guest_owned_bits = vcpu->arch.cr4_guest_owned_bits; - - vcpu->arch.cr4 &= ~cr4_guest_owned_bits; - vcpu->arch.cr4 |= vmcs_readl(GUEST_CR4) & cr4_guest_owned_bits; -} - -static void ept_load_pdptrs(struct kvm_vcpu *vcpu) -{ - struct kvm_mmu *mmu = vcpu->arch.walk_mmu; - - if (!kvm_register_is_dirty(vcpu, VCPU_EXREG_PDPTR)) - return; - - if (is_pae_paging(vcpu)) { - vmcs_write64(GUEST_PDPTR0, mmu->pdptrs[0]); - vmcs_write64(GUEST_PDPTR1, mmu->pdptrs[1]); - vmcs_write64(GUEST_PDPTR2, mmu->pdptrs[2]); - vmcs_write64(GUEST_PDPTR3, mmu->pdptrs[3]); - } -} - -void ept_save_pdptrs(struct kvm_vcpu *vcpu) -{ - struct kvm_mmu *mmu = vcpu->arch.walk_mmu; - - if (is_pae_paging(vcpu)) { - mmu->pdptrs[0] = vmcs_read64(GUEST_PDPTR0); - mmu->pdptrs[1] = vmcs_read64(GUEST_PDPTR1); - mmu->pdptrs[2] = vmcs_read64(GUEST_PDPTR2); - mmu->pdptrs[3] = vmcs_read64(GUEST_PDPTR3); - } - - kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR); -} - -static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, - unsigned long cr0, - struct kvm_vcpu *vcpu) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - - if (!kvm_register_is_available(vcpu, VCPU_EXREG_CR3)) - vmx_cache_reg(vcpu, VCPU_EXREG_CR3); - if (!(cr0 & X86_CR0_PG)) { - /* From paging/starting to nonpaging */ - exec_controls_setbit(vmx, CPU_BASED_CR3_LOAD_EXITING | - CPU_BASED_CR3_STORE_EXITING); - vcpu->arch.cr0 = cr0; - vmx_set_cr4(vcpu, kvm_read_cr4(vcpu)); - } else if (!is_paging(vcpu)) { - /* From nonpaging to paging */ - exec_controls_clearbit(vmx, CPU_BASED_CR3_LOAD_EXITING | - CPU_BASED_CR3_STORE_EXITING); - vcpu->arch.cr0 = cr0; - vmx_set_cr4(vcpu, kvm_read_cr4(vcpu)); - } - - if (!(cr0 & X86_CR0_WP)) - *hw_cr0 &= ~X86_CR0_WP; -} - -void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) -{ - struct vcpu_vmx *vmx = to_vmx(vcpu); - unsigned long hw_cr0; - - hw_cr0 = (cr0 & ~KVM_VM_CR0_ALWAYS_OFF); - if (enable_unrestricted_guest) - hw_cr0 |= KVM_VM_CR0_ALWAYS_ON_UNRESTRICTED_GUEST; - else { - hw_cr0 |= KVM_VM_CR0_ALWAYS_ON; - - if (vmx->rmode.vm86_active && (cr0 & X86_CR0_PE)) - enter_pmode(vcpu); - - if (!vmx->rmode.vm86_active && !(cr0 & X86_CR0_PE)) - enter_rmode(vcpu); - } - -#ifdef CONFIG_X86_64 - if (vcpu->arch.efer & EFER_LME) { - if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) - enter_lmode(vcpu); - if (is_paging(vcpu) && !(cr0 & X86_CR0_PG)) - exit_lmode(vcpu); - } -#endif - - if (enable_ept && !enable_unrestricted_guest) - ept_update_paging_mode_cr0(&hw_cr0, cr0, vcpu); - - vmcs_writel(CR0_READ_SHADOW, cr0); - vmcs_writel(GUEST_CR0, hw_cr0); - vcpu->arch.cr0 = cr0; - - /* depends on vcpu->arch.cr0 to be set to a new value */ - vmx->emulation_required = emulation_required(vcpu); -} - -static int get_ept_level(struct kvm_vcpu *vcpu) -{ - if (cpu_has_vmx_ept_5levels() && (cpuid_maxphyaddr(vcpu) > 48)) - return 5; - return 4; -} - -u64 construct_eptp(struct kvm_vcpu *vcpu, unsigned long root_hpa) -{ - u64 eptp = VMX_EPTP_MT_WB; - - eptp |= (get_ept_level(vcpu) == 5) ? VMX_EPTP_PWL_5 : VMX_EPTP_PWL_4; - - if (enable_ept_ad_bits && - (!is_guest_mode(vcpu) || nested_ept_ad_enabled(vcpu))) - eptp |= VMX_EPTP_AD_ENABLE_BIT; - eptp |= (root_hpa & PAGE_MASK); - - return eptp; -} - -void vmx_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) -{ - struct kvm *kvm = vcpu->kvm; - bool update_guest_cr3 = true; - unsigned long guest_cr3; - u64 eptp; - - guest_cr3 = cr3; - if (enable_ept) { - eptp = construct_eptp(vcpu, cr3); - vmcs_write64(EPT_POINTER, eptp);
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.20.1
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerPATCH 22/165 drm/gma500: Fixup fbdev stolen size usage evaluation
In reply to Greg Kroah-HartmanFrom: Paul Kocialkowski <[email protected]>
[ Upstream commit fd1a5e521c3c083bb43ea731aae0f8b95f12b9bd ]
psbfb_probe performs an evaluation of the required size from the stolen GTT memory, but gets it wrong in two distinct ways:
- The resulting size must be page-size-aligned;
- The size to allocate is derived from the surface dimensions, not the fb dimensions.
When two connectors are connected with different modes, the smallest will be stored in the fb dimensions, but the size that needs to be allocated must match the largest (surface) dimensions. This is what is used in the actual allocation code.
Fix this by correcting the evaluation to conform to the two points above. It allows correctly switching to 16bpp when one connector is e.g. 1920x1080 and the other is 1024x768.
--- drivers/gpu/drm/gma500/framebuffer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/gma500/framebuffer.c +6 -2
@@ -516,6 +516,7 @@ static int psbfb_probe(struct drm_fb_helper *helper, container_of(helper, struct psb_fbdev, psb_fb_helper);struct drm_device *dev = psb_fbdev->psb_fb_helper.dev;struct drm_psb_private *dev_priv = dev->dev_private; +unsigned int fb_size;int bytespp; bytespp = sizes->surface_bpp /8 ;
@@ -525,8 +526,11 @@ static int psbfb_probe(struct drm_fb_helper *helper,/* If the mode will not fit in 32bit then switch to 16bit to get a console on full resolution. The X mode setting server will allocate its own 32bit GEM framebuffer */ -if (ALIGN (sizes->fb_width * bytespp,64 ) * sizes->fb_height > - dev_priv->vram_stolen_size) { + fb_size =ALIGN (sizes->surface_width * bytespp,64 ) * + sizes->surface_height; + fb_size =ALIGN (fb_size,PAGE_SIZE ); + +if (fb_size > dev_priv->vram_stolen_size) { sizes->surface_bpp =16 ; sizes->surface_depth =16 ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 23/165 cpu/hotplug, stop_machine: Fix stop_machine vs hotplug order
In reply to Greg Kroah-HartmanFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 45178ac0cea853fe0e405bf11e101bdebea57b15 ]
Paul reported a very sporadic, rcutorture induced, workqueue failure. When the planets align, the workqueue rescuer's self-migrate fails and then triggers a WARN for running a work on the wrong CPU.
Tejun then figured that set_cpus_allowed_ptr()'s stop_one_cpu() call could be ignored! When stopper->enabled is false, stop_machine will insta complete the work, without actually doing the work. Worse, it will not WARN about this (we really should fix this).
It turns out there is a small window where a freshly online'ed CPU is marked 'online' but doesn't yet have the stopper task running:
BP AP bringup_cpu() __cpu_up(cpu, idle) --> start_secondary() ... cpu_startup_entry() bringup_wait_for_ap() wait_for_ap_thread() <-- cpuhp_online_idle() while (1) do_idle() ... available to run kthreads ... stop_machine_unpark() stopper->enable = true;
Close this by moving the stop_machine_unpark() into cpuhp_online_idle(), such that the stopper thread is ready before we start the idle loop and schedule.
--- kernel/cpu.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/cpu.c +9 -4
@@ -515,8 +515,7 @@ static int bringup_wait_for_ap(unsigned int cpu)if (WARN_ON_ONCE ((!cpu_online (cpu))))return -ECANCELED ; -/* Unpark the stopper thread and the hotplug thread of the target cpu */ -stop_machine_unpark (cpu); +/* Unpark the hotplug thread of the target cpu */ kthread_unpark (st->thread);/*
@@ -1115,8 +1114,8 @@ void notify_cpu_starting(unsigned int cpu)/* * Called from the idle task. Wake up the controlling task which brings the -* stopper and the hotplug thread of the upcoming CPU up and then delegates -* the rest of the online bringup to the hotplug thread. +* hotplug thread of the upcoming CPU up and then delegates the rest of the +* online bringup to the hotplug thread. */ void cpuhp_online_idle (enum cpuhp_state state) {
@@ -1126,6 +1125,12 @@ void cpuhp_online_idle(enum cpuhp_state state)if (state !=CPUHP_AP_ONLINE_IDLE )return ; +/* +* Unpart the stopper thread before we start the idle loop (and start +* scheduling); this ensures the stopper task is always available. +*/ +stop_machine_unpark (smp_processor_id ()); + st->state =CPUHP_AP_ONLINE_IDLE ;complete (&st->done); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 24/165 brcmfmac: Fix use after free in brcmf_sdio_readframes()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 216b44000ada87a63891a8214c347e05a4aea8fe ]
The brcmu_pkt_buf_free_skb() function frees "pkt" so it leads to a static checker warning:
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:1974 brcmf_sdio_readframes()
error: dereferencing freed memory 'pkt'
It looks like there was supposed to be a continue after we free "pkt".
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +1 -0
@@ -1921,6 +1921,7 @@ static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes) BRCMF_SDIO_FT_NORMAL)) { rd->len =0 ;brcmu_pkt_buf_free_skb (pkt); +continue ; } bus->sdcnt.rx_readahead_cnt++;if (rd->len !=roundup (rd_new.len,16 )) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 25/165 gianfar: Fix TX timestamping with a stacked DSA driver
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit c26a2c2ddc0115eb088873f5c309cf46b982f522 ]
The driver wrongly assumes that it is the only entity that can set the SKBTX_IN_PROGRESS bit of the current skb. Therefore, in the gfar_clean_tx_ring function, where the TX timestamp is collected if necessary, the aforementioned bit is used to discriminate whether or not the TX timestamp should be delivered to the socket's error queue.
But a stacked driver such as a DSA switch can also set the SKBTX_IN_PROGRESS bit, which is actually exactly what it should do in order to denote that the hardware timestamping process is undergoing.
Therefore, gianfar would misinterpret the "in progress" bit as being its own, and deliver a second skb clone in the socket's error queue, completely throwing off a PTP process which is not expecting to receive it, _even though_ TX timestamping is not enabled for gianfar.
There have been discussions [0] as to whether non-MAC drivers need or not to set SKBTX_IN_PROGRESS at all (whose purpose is to avoid sending 2 timestamps, a sw and a hw one, to applications which only expect one). But as of this patch, there are at least 2 PTP drivers that would break in conjunction with gianfar: the sja1105 DSA switch and the felix switch, by way of its ocelot core driver.
So regardless of that conclusion, fix the gianfar driver to not do stuff based on flags set by others and not intended for it.
[0]: https://www.spinics.net/lists/netdev/msg619699.html
--- drivers/net/ethernet/freescale/gianfar.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar.c +7 -3
@@ -2688,13 +2688,17 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) skb_dirtytx = tx_queue->skb_dirtytx;while ((skb = tx_queue->tx_skbuff[skb_dirtytx])) { +bool do_tstamp; + + do_tstamp = (skb_shinfo (skb)->tx_flags &SKBTX_HW_TSTAMP ) && + priv->hwts_tx_en; frags =skb_shinfo (skb)->nr_frags;/* When time stamping, one additional TxBD must be freed. * Also, we need to dma_unmap_single() the TxPAL. */ -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_IN_PROGRESS )) +if (unlikely (do_tstamp)) nr_txbds = frags +2 ;else nr_txbds = frags +1 ;
@@ -2708,7 +2712,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue) (lstatus & BD_LENGTH_MASK))break ; -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_IN_PROGRESS )) { +if (unlikely (do_tstamp)) { next =next_txbd (bdp, base, tx_ring_size); buflen =be16_to_cpu (next->length) +GMAC_FCB_LEN +GMAC_TXPAL_LEN ;
@@ -2718,7 +2722,7 @@ static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)dma_unmap_single (priv->dev,be32_to_cpu (bdp->bufPtr), buflen,DMA_TO_DEVICE ); -if (unlikely (skb_shinfo (skb)->tx_flags &SKBTX_IN_PROGRESS )) { +if (unlikely (do_tstamp)) {struct skb_shared_hwtstamps shhwtstamps;u64 *ns = (u64 *)(((uintptr_t )skb->data +0x10 ) & ~0x7UL );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 26/165 pinctrl: sh-pfc: sh7264: Fix CAN function GPIOs
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 55b1cb1f03ad5eea39897d0c74035e02deddcff2 ]
pinmux_func_gpios[] contains a hole due to the missing function GPIO definition for the "CTX0&CTX1" signal, which is the logical "AND" of the two CAN outputs.
Fix this by:
- Renaming CRX0_CRX1_MARK to CTX0_CTX1_MARK, as PJ2MD[2:0]=010 configures the combined "CTX0&CTX1" output signal,
- Renaming CRX0X1_MARK to CRX0_CRX1_MARK, as PJ3MD[1:0]=10 configures the shared "CRX0/CRX1" input signal, which is fed to both CAN inputs,
- Adding the missing function GPIO definition for "CTX0&CTX1" to
pinmux_func_gpios[],
- Moving all CAN enums next to each other.
See SH7262 Group, SH7264 Group User's Manual: Hardware, Rev. 4.00:
[1] Figure 1.2 (3) (Pin Assignment for the SH7264 Group (1-Mbyte Version),
[2] Figure 1.2 (4) Pin Assignment for the SH7264 Group (640-Kbyte Version,
[3] Table 1.4 List of Pins,
[4] Figure 20.29 Connection Example when Using This Module as 1-Channel Module (64 Mailboxes x 1 Channel),
[5] Table 32.10 Multiplexed Pins (Port J),
[6] Section 32.2.30 (3) Port J Control Register 0 (PJCR0).
Note that the last 2 disagree about PJ2MD[2:0], which is probably the root cause of this bug. But considering [4], "CTx0&CTx1" in [5] must be correct, and "CRx0&CRx1" in [6] must be wrong.
--- drivers/pinctrl/sh-pfc/pfc-sh7264.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/pinctrl/sh-pfc/pfc-sh7264.c +4 -5
@@ -500,17 +500,15 @@ enum {SD_WP_MARK ,SD_CLK_MARK ,SD_CMD_MARK ,CRX0_MARK ,CRX1_MARK ,CTX0_MARK ,CTX1_MARK , +CRX0_CRX1_MARK ,CTX0_CTX1_MARK ,PWM1A_MARK ,PWM1B_MARK ,PWM1C_MARK ,PWM1D_MARK ,PWM1E_MARK ,PWM1F_MARK ,PWM1G_MARK ,PWM1H_MARK ,PWM2A_MARK ,PWM2B_MARK ,PWM2C_MARK ,PWM2D_MARK ,PWM2E_MARK ,PWM2F_MARK ,PWM2G_MARK ,PWM2H_MARK ,IERXD_MARK ,IETXD_MARK , -CRX0_CRX1_MARK ,WDTOVF_MARK , -CRX0X1_MARK , -/* DMAC */ TEND0_MARK ,DACK0_MARK ,DREQ0_MARK , TEND1_MARK, DACK1_MARK, DREQ1_MARK,
@@ -998,12 +996,12 @@ static const u16 pinmux_data[] = {PINMUX_DATA (PJ3_DATA ,PJ3MD_00 ),PINMUX_DATA (CRX1_MARK ,PJ3MD_01 ), -PINMUX_DATA (CRX0X1_MARK ,PJ3MD_10 ), +PINMUX_DATA (CRX0_CRX1_MARK ,PJ3MD_10 ),PINMUX_DATA (IRQ1_PJ_MARK ,PJ3MD_11 ),PINMUX_DATA (PJ2_DATA ,PJ2MD_000 ),PINMUX_DATA (CTX1_MARK ,PJ2MD_001 ), -PINMUX_DATA (CRX0_CRX1_MARK ,PJ2MD_010 ), +PINMUX_DATA (CTX0_CTX1_MARK ,PJ2MD_010 ),PINMUX_DATA (CS2_MARK ,PJ2MD_011 ),PINMUX_DATA (SCK0_MARK ,PJ2MD_100 ), PINMUX_DATA(LCD_M_DISP_MARK, PJ2MD_101),
@@ -1248,6 +1246,7 @@ static const struct pinmux_func pinmux_func_gpios[] = {GPIO_FN (CTX1 ),GPIO_FN (CRX1 ),GPIO_FN (CTX0 ), +GPIO_FN (CTX0_CTX1 ),GPIO_FN (CRX0 ), GPIO_FN(CRX0_CRX1),
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 27/165 pxa168fb: Fix the function used to release some memory in an error handling path
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 3c911fe799d1c338d94b78e7182ad452c37af897 ]
In the probe function, some resources are allocated using 'dma_alloc_wc()', they should be released with 'dma_free_wc()', not 'dma_free_coherent()'.
We already use 'dma_free_wc()' in the remove function, but not in the error handling path of the probe function.
Also, remove a useless 'PAGE_ALIGN()'. 'info->fix.smem_len' is already PAGE_ALIGNed.
--- drivers/video/fbdev/pxa168fb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/fbdev/pxa168fb.c +3 -3
@@ -769,8 +769,8 @@ failed_free_cmap: failed_free_clk:clk_disable_unprepare (fbi->clk); failed_free_fbmem: -dma_free_coherent (fbi->dev, info->fix.smem_len, - info->screen_base, fbi->fb_start_dma); +dma_free_wc (fbi->dev, info->fix.smem_len, + info->screen_base, fbi->fb_start_dma); failed_free_info:kfree (info);
@@ -804,7 +804,7 @@ static int pxa168fb_remove(struct platform_device *pdev) irq =platform_get_irq (pdev,0 ); -dma_free_wc (fbi->dev,PAGE_ALIGN (info->fix.smem_len), +dma_free_wc (fbi->dev, info->fix.smem_len, info->screen_base, info->fix.smem_start);clk_disable_unprepare (fbi->clk);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 28/165 media: i2c: mt9v032: fix enum mbus codes and frame sizes
In reply to Greg Kroah-HartmanFrom: Eugen Hristev <[email protected]>
[ Upstream commit 1451d5ae351d938a0ab1677498c893f17b9ee21d ]
This driver supports both the mt9v032 (color) and the mt9v022 (mono) sensors. Depending on which sensor is used, the format from the sensor is different. The format.code inside the dev struct holds this information. The enum mbus and enum frame sizes need to take into account both type of sensors, not just the color one. To solve this, use the format.code in these functions instead of the hardcoded bayer color format (which is only used for mt9v032).
[Sakari Ailus: rewrapped commit message]
--- drivers/media/i2c/mt9v032.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/i2c/mt9v032.c +8 -2
@@ -423,10 +423,12 @@ static int mt9v032_enum_mbus_code(struct v4l2_subdev *subdev,struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_mbus_code_enum *code) { + struct mt9v032 *mt9v032 = to_mt9v032(subdev); +if (code->index >0 )return -EINVAL ; - code->code =MEDIA_BUS_FMT_SGRBG10_1X10 ; + code->code = mt9v032->format.code;return 0 ; }
@@ -434,7 +436,11 @@ static int mt9v032_enum_frame_size(struct v4l2_subdev *subdev,struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_frame_size_enum *fse) { -if (fse->index >=3 || fse->code !=MEDIA_BUS_FMT_SGRBG10_1X10 ) + struct mt9v032 *mt9v032 = to_mt9v032(subdev); + +if (fse->index >=3 ) +return -EINVAL ; +if (mt9v032->format.code != fse->code)return -EINVAL ; fse->min_width =MT9V032_WINDOW_WIDTH_DEF / (1 << fse->index);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 29/165 powerpc/powernv/iov: Ensure the pdn for VFs always contains a valid PE number
In reply to Greg Kroah-HartmanFrom: Oliver O'Halloran <[email protected]>
[ Upstream commit 3b5b9997b331e77ce967eba2c4bc80dc3134a7fe ]
On pseries there is a bug with adding hotplugged devices to an IOMMU group. For a number of dumb reasons fixing that bug first requires re-working how VFs are configured on PowerNV. For background, on PowerNV we use the pcibios_sriov_enable() hook to do two things:
1. Create a pci_dn structure for each of the VFs, and
2. Configure the PHB's internal BARs so the MMIO range for each VF maps to a unique PE.
Roughly speaking a PE is the hardware counterpart to a Linux IOMMU group since all the devices in a PE share the same IOMMU table. A PE also defines the set of devices that should be isolated in response to a PCI error (i.e. bad DMA, UR/CA, AER events, etc). When isolated all MMIO and DMA traffic to and from devicein the PE is blocked by the root complex until the PE is recovered by the OS.
The requirement to block MMIO causes a giant headache because the P8 PHB generally uses a fixed mapping between MMIO addresses and PEs. As a result we need to delay configuring the IOMMU groups for device until after MMIO resources are assigned. For physical devices (i.e. non-VFs) the PE assignment is done in pcibios_setup_bridge() which is called immediately after the MMIO resources for downstream devices (and the bridge's windows) are assigned. For VFs the setup is more complicated because:
a) pcibios_setup_bridge() is not called again when VFs are activated, and
b) The pci_dev for VFs are created by generic code which runs after pcibios_sriov_enable() is called.
The work around for this is a two step process:
1. A fixup in pcibios_add_device() is used to initialised the cached pe_number in pci_dn, then
2. A bus notifier then adds the device to the IOMMU group for the PE
specified in pci_dn->pe_number.
A side effect fixing the pseries bug mentioned in the first paragraph is moving the fixup out of pcibios_add_device() and into pcibios_bus_add_device(), which is called much later. This results in step 2. failing because pci_dn->pe_number won't be initialised when the bus notifier is run.
We can fix this by removing the need for the fixup. The PE for a VF is known before the VF is even scanned so we can initialise pci_dn->pe_number pcibios_sriov_enable() instead. Unfortunately, moving the initialisation causes two problems:
1. We trip the WARN_ON() in the current fixup code, and
2. The EEH core clears pdn->pe_number when recovering a VF and relies on the fixup to correctly re-set it.
The only justification for either of these is a comment in eeh_rmv_device() suggesting that pdn->pe_number *must* be set to IODA_INVALID_PE in order for the VF to be scanned. However, this comment appears to have no basis in reality. Both bugs can be fixed by just deleting the code.
--- arch/powerpc/kernel/eeh_driver.c | 6 ------ arch/powerpc/platforms/powernv/pci-ioda.c | 19 +++++++++++++++---- arch/powerpc/platforms/powernv/pci.c | 4 ---- 3 files changed, 15 insertions(+), 14 deletions(-)
arch/powerpc/kernel/eeh_driver.c +0 -6
@@ -520,12 +520,6 @@ static void *eeh_rmv_device(void *data, void *userdata)pci_iov_remove_virtfn (edev->physfn, pdn->vf_index,0 ); edev->pdev =NULL ; - -/* -* We have to set the VF PE number to invalid one, which is -* required to plug the VF successfully. -*/ - pdn->pe_number =IODA_INVALID_PE ;#endif if (rmv_data)list_add (&edev->rmv_list, &rmv_data->edev_list);
arch/powerpc/platforms/powernv/pci-ioda.c +15 -4
@@ -1524,6 +1524,10 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)/* Reserve PE for each VF */ for (vf_index =0 ; vf_index < num_vfs; vf_index++) { +int vf_devfn =pci_iov_virtfn_devfn (pdev, vf_index); +int vf_bus =pci_iov_virtfn_bus (pdev, vf_index); +struct pci_dn *vf_pdn; +if (pdn->m64_single_mode) pe_num = pdn->pe_num_map[vf_index];else
@@ -1536,13 +1540,11 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) pe->pbus =NULL ; pe->parent_dev = pdev; pe->mve_number =-1 ; - pe->rid = (pci_iov_virtfn_bus (pdev, vf_index) <<8 ) | -pci_iov_virtfn_devfn (pdev, vf_index); + pe->rid = (vf_bus <<8 ) | vf_devfn;pe_info (pe,"VF %04d:%02d:%02d.%d associated with PE#%d\n" , hose->global_number, pdev->bus->number, -PCI_SLOT (pci_iov_virtfn_devfn (pdev, vf_index)), -PCI_FUNC (pci_iov_virtfn_devfn (pdev, vf_index)), pe_num); +PCI_SLOT (vf_devfn),PCI_FUNC (vf_devfn), pe_num);if (pnv_ioda_configure_pe (phb, pe)) {/* XXX What do we do here ? */
@@ -1556,6 +1558,15 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs)list_add_tail (&pe->list, &phb->ioda.pe_list);mutex_unlock (&phb->ioda.pe_list_mutex); +/* associate this pe to it's pdn */ +list_for_each_entry (vf_pdn, &pdn->parent->child_list, list) { +if (vf_pdn->busno == vf_bus && + vf_pdn->devfn == vf_devfn) { + vf_pdn->pe_number = pe_num; +break ; + } + } +pnv_pci_ioda2_setup_dma_pe (phb, pe); } }
arch/powerpc/platforms/powernv/pci.c +0 -4
@@ -856,16 +856,12 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev)struct pnv_phb *phb = hose->private_data;#ifdef CONFIG_PCI_IOV struct pnv_ioda_pe *pe; -struct pci_dn *pdn;/* Fix the VF pdn PE number */ if (pdev->is_virtfn) { - pdn =pci_get_pdn (pdev); -WARN_ON (pdn->pe_number !=IODA_INVALID_PE );list_for_each_entry (pe, &phb->ioda.pe_list, list) {if (pe->rid == ((pdev->bus->number <<8 ) | (pdev->devfn &0xff ))) { - pdn->pe_number = pe->pe_number; pe->pdev = pdev;break ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 30/165 gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_irq_map/unmap()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit e36eaf94be8f7bc4e686246eed3cf92d845e2ef8 ]
The driver may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:
drivers/gpio/gpio-grgpio.c, 261:
request_irq in grgpio_irq_mapdrivers/gpio/gpio-grgpio.c, 255:
_raw_spin_lock_irqsave in grgpio_irq_map
drivers/gpio/gpio-grgpio.c, 318:
free_irq in grgpio_irq_unmapdrivers/gpio/gpio-grgpio.c, 299:
_raw_spin_lock_irqsave in grgpio_irq_unmap
request_irq() and free_irq() can sleep at runtime.
To fix these bugs, request_irq() and free_irq() are called without holding the spinlock.
These bugs are found by a static analysis tool STCheck written by myself.
--- drivers/gpio/gpio-grgpio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpio/gpio-grgpio.c +6 -4
@@ -259,17 +259,16 @@ static int grgpio_irq_map(struct irq_domain *d, unsigned int irq, lirq->irq = irq; uirq = &priv->uirqs[lirq->index];if (uirq->refcnt ==0 ) { +spin_unlock_irqrestore (&priv->gc.bgpio_lock, flags); ret =request_irq (uirq->uirq, grgpio_irq_handler,0 ,dev_name (priv->dev), priv);if (ret) {dev_err (priv->dev,"Could not request underlying irq %d\n" , uirq->uirq); - -spin_unlock_irqrestore (&priv->gc.bgpio_lock, flags); -return ret; } +spin_lock_irqsave (&priv->gc.bgpio_lock, flags); } uirq->refcnt++;
@@ -315,8 +314,11 @@ static void grgpio_irq_unmap(struct irq_domain *d, unsigned int irq)if (index >=0 ) { uirq = &priv->uirqs[lirq->index]; uirq->refcnt--; -if (uirq->refcnt ==0 ) +if (uirq->refcnt ==0 ) { +spin_unlock_irqrestore (&priv->gc.bgpio_lock, flags);free_irq (uirq->uirq, priv); +return ; + } }spin_unlock_irqrestore (&priv->gc.bgpio_lock, flags);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 31/165 media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit bb6d42061a05d71dd73f620582d9e09c8fbf7f5b ]
The driver may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:
drivers/media/platform/sti/bdisp/bdisp-hw.c, 385:
msleep in bdisp_hw_resetdrivers/media/platform/sti/bdisp/bdisp-v4l2.c, 341:
bdisp_hw_reset in bdisp_device_rundrivers/media/platform/sti/bdisp/bdisp-v4l2.c, 317:
_raw_spin_lock_irqsave in bdisp_device_run
To fix this bug, msleep() is replaced with udelay().
This bug is found by a static analysis tool STCheck written by myself.
--- drivers/media/platform/sti/bdisp/bdisp-hw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/sti/bdisp/bdisp-hw.c +3 -3
@@ -14,8 +14,8 @@#define MAX_SRC_WIDTH 2048/* Reset & boot poll config */ -#define POLL_RST_MAX 50 -#define POLL_RST_DELAY_MS 20 +#define POLL_RST_MAX 500 +#define POLL_RST_DELAY_MS 2enum bdisp_target_plan {BDISP_RGB ,
@@ -382,7 +382,7 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp)for (i =0 ; i <POLL_RST_MAX ; i++) {if (readl (bdisp->regs +BLT_STA1 ) &BLT_STA1_IDLE )break ; -msleep (POLL_RST_DELAY_MS ); +udelay (POLL_RST_DELAY_MS *1000 ); }if (i ==POLL_RST_MAX )dev_err (bdisp->dev,"Reset timeout\n" );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 32/165 pinctrl: baytrail: Do not clear IRQ flags on direct-irq enabled pins
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit a23680594da7a9e2696dbcf4f023e9273e2fa40b ]
Suspending Goodix touchscreens requires changing the interrupt pin to output before sending them a power-down command. Followed by wiggling the interrupt pin to wake the device up, after which it is put back in input mode.
On Bay Trail devices with a Goodix touchscreen direct-irq mode is used in combination with listing the pin as a normal GpioIo resource.
This works fine, until the goodix driver gets rmmod-ed and then insmod-ed again. In this case byt_gpio_disable_free() calls byt_gpio_clear_triggering() which clears the IRQ flags and after that the (direct) IRQ no longer triggers.
This commit fixes this by adding a check for the BYT_DIRECT_IRQ_EN flag to byt_gpio_clear_triggering().
Note that byt_gpio_clear_triggering() only gets called from byt_gpio_disable_free() for direct-irq enabled pins, as these are excluded from the irq_valid mask by byt_init_irq_valid_mask().
--- drivers/pinctrl/intel/pinctrl-baytrail.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/pinctrl/intel/pinctrl-baytrail.c +7 -1
@@ -958,7 +958,13 @@ static void byt_gpio_clear_triggering(struct byt_gpio *vg, unsigned int offset)raw_spin_lock_irqsave (&byt_lock, flags); value =readl (reg); - value &= ~(BYT_TRIG_POS |BYT_TRIG_NEG |BYT_TRIG_LVL ); + +/* Do not clear direct-irq enabled IRQs (from gpio_disable_free) */ +if (value &BYT_DIRECT_IRQ_EN ) +/* nothing to do */ ; +else + value &= ~(BYT_TRIG_POS |BYT_TRIG_NEG |BYT_TRIG_LVL ); +writel (value, reg);raw_spin_unlock_irqrestore (&byt_lock, flags); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 33/165 efi/x86: Map the entire EFI vendor string before copying it
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit ffc2760bcf2dba0dbef74013ed73eea8310cc52c ]
Fix a couple of issues with the way we map and copy the vendor string:
- we map only 2 bytes, which usually works since you get at least a page, but if the vendor string happens to cross a page boundary, a crash will result
- only call early_memunmap() if early_memremap() succeeded, or we will call it with a NULL address which it doesn't like,
- while at it, switch to early_memremap_ro(), and array indexing rather than pointer dereferencing to read the CHAR16 characters.
--- arch/x86/platform/efi/efi.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/x86/platform/efi/efi.c +7 -6
@@ -478,7 +478,6 @@ void __init efi_init(void)efi_char16_t *c16;char vendor[100 ] ="unknown" ;int i =0 ; -void *tmp;#ifdef CONFIG_X86_32 if (boot_params.efi_info.efi_systab_hi ||
@@ -503,14 +502,16 @@ void __init efi_init(void)/* * Show what we know for posterity */ - c16 = tmp =early_memremap (efi.systab->fw_vendor,2 ); + c16 =early_memremap_ro (efi.systab->fw_vendor, +sizeof (vendor) *sizeof (efi_char16_t));if (c16) { -for (i =0 ; i <sizeof (vendor) -1 && *c16; ++i) - vendor[i] = *c16++; +for (i =0 ; i <sizeof (vendor) -1 && c16[i]; ++i) + vendor[i] = c16[i]; vendor[i] ='\0' ; - }else +early_memunmap (c16,sizeof (vendor) *sizeof (efi_char16_t)); + }else {pr_err ("Could not map the firmware vendor!\n" ); -early_memunmap (tmp,2 ); + } pr_info("EFI v%u.%.02u by %s\n", efi.systab->hdr.revision >> 16,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 34/165 MIPS: Loongson: Fix potential NULL dereference in loongson3_platform_init()
In reply to Greg Kroah-HartmanFrom: Tiezhu Yang <[email protected]>
[ Upstream commit 72d052e28d1d2363f9107be63ef3a3afdea6143c ]
If kzalloc fails, it should return -ENOMEM, otherwise may trigger a NULL pointer dereference.
--- arch/mips/loongson64/loongson-3/platform.c | 3 +++ 1 file changed, 3 insertions(+)
arch/mips/loongson64/loongson-3/platform.c +3 -0
@@ -31,6 +31,9 @@ static int __init loongson3_platform_init(void)continue ; pdev =kzalloc (sizeof (struct platform_device ),GFP_KERNEL ); +if (!pdev) +return -ENOMEM ; + pdev->name = loongson_sysconf.sensors[i].name; pdev->id = loongson_sysconf.sensors[i].id; pdev->dev.platform_data = &loongson_sysconf.sensors[i];
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 35/165 sparc: Add .exit.data section.
In reply to Greg Kroah-HartmanFrom: David S. Miller <[email protected]>
[ Upstream commit 548f0b9a5f4cffa0cecf62eb12aa8db682e4eee6 ]
This fixes build errors of all sorts.
Also, emit .exit.text unconditionally.
--- arch/sparc/kernel/vmlinux.lds.S | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/sparc/kernel/vmlinux.lds.S +4 -2
@@ -151,12 +151,14 @@ SECTIONS } PERCPU_SECTION(SMP_CACHE_BYTES) -#ifdef CONFIG_JUMP_LABEL . = ALIGN(PAGE_SIZE); .exit.text : { EXIT_TEXT } -#endif + + .exit.data : { + EXIT_DATA + } . = ALIGN(PAGE_SIZE); __init_end = .;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 36/165 uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit b74351287d4bd90636c3f48bc188c2f53824c2d4 ]
The driver may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:
kernel/irq/manage.c, 523:
synchronize_irq in disable_irqdrivers/uio/uio_dmem_genirq.c, 140:
disable_irq in uio_dmem_genirq_irqcontroldrivers/uio/uio_dmem_genirq.c, 134:
_raw_spin_lock_irqsave in uio_dmem_genirq_irqcontrol
synchronize_irq() can sleep at runtime.
To fix this bug, disable_irq() is called without holding the spinlock.
This bug is found by a static analysis tool STCheck written by myself.
--- drivers/uio/uio_dmem_genirq.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/uio/uio_dmem_genirq.c +4 -2
@@ -135,11 +135,13 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)if (irq_on) {if (test_and_clear_bit (0 , &priv->flags))enable_irq (dev_info->irq); +spin_unlock_irqrestore (&priv->lock, flags); }else { -if (!test_and_set_bit (0 , &priv->flags)) +if (!test_and_set_bit (0 , &priv->flags)) { +spin_unlock_irqrestore (&priv->lock, flags);disable_irq (dev_info->irq); + } } -spin_unlock_irqrestore (&priv->lock, flags);return 0 ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 37/165 usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 9c1ed62ae0690dfe5d5e31d8f70e70a95cb48e52 ]
The driver may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:
drivers/usb/gadget/udc/core.c, 1175:
kzalloc(GFP_KERNEL) in usb_add_gadget_udc_releasedrivers/usb/gadget/udc/core.c, 1272:
usb_add_gadget_udc_release in usb_add_gadget_udcdrivers/usb/gadget/udc/gr_udc.c, 2186:
usb_add_gadget_udc in gr_probedrivers/usb/gadget/udc/gr_udc.c, 2183:
spin_lock in gr_probe
drivers/usb/gadget/udc/core.c, 1195:
mutex_lock in usb_add_gadget_udc_releasedrivers/usb/gadget/udc/core.c, 1272:
usb_add_gadget_udc_release in usb_add_gadget_udcdrivers/usb/gadget/udc/gr_udc.c, 2186:
usb_add_gadget_udc in gr_probedrivers/usb/gadget/udc/gr_udc.c, 2183:
spin_lock in gr_probe
drivers/usb/gadget/udc/gr_udc.c, 212:
debugfs_create_file in gr_probedrivers/usb/gadget/udc/gr_udc.c, 2197:
gr_dfs_create in gr_probedrivers/usb/gadget/udc/gr_udc.c, 2183:
spin_lock in gr_probe
drivers/usb/gadget/udc/gr_udc.c, 2114:
devm_request_threaded_irq in gr_request_irqdrivers/usb/gadget/udc/gr_udc.c, 2202:
gr_request_irq in gr_probedrivers/usb/gadget/udc/gr_udc.c, 2183:
spin_lock in gr_probe
kzalloc(GFP_KERNEL), mutex_lock(), debugfs_create_file() and devm_request_threaded_irq() can sleep at runtime.
To fix these possible bugs, usb_add_gadget_udc(), gr_dfs_create() and gr_request_irq() are called without handling the spinlock.
These bugs are found by a static analysis tool STCheck written by myself.
--- drivers/usb/gadget/udc/gr_udc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/usb/gadget/udc/gr_udc.c +9 -7
@@ -2200,8 +2200,6 @@ static int gr_probe(struct platform_device *pdev)return -ENOMEM ; } -spin_lock (&dev->lock); -/* Inside lock so that no gadget can use this udc until probe is done */ retval =usb_add_gadget_udc (dev->dev, &dev->gadget);if (retval) {
@@ -2210,15 +2208,21 @@ static int gr_probe(struct platform_device *pdev) } dev->added =1 ; +spin_lock (&dev->lock); + retval =gr_udc_init (dev); -if (retval) +if (retval) { +spin_unlock (&dev->lock); goto out; - -gr_dfs_create (dev); + }/* Clear all interrupt enables that might be left on since last boot */ gr_disable_interrupts_and_pullup (dev); +spin_unlock (&dev->lock); + +gr_dfs_create (dev); + retval =gr_request_irq (dev, dev->irq);if (retval) {dev_err (dev->dev,"Failed to request irq %d\n" , dev->irq);
@@ -2247,8 +2251,6 @@ static int gr_probe(struct platform_device *pdev)dev_info (dev->dev,"regs: %p, irq %d\n" , dev->regs, dev->irq); out: -spin_unlock (&dev->lock); -if (retval)gr_remove (pdev);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 38/165 jbd2: clear JBD2_ABORT flag before journal_reset to update log tail info when load journal
In reply to Greg Kroah-HartmanFrom: Kai Li <[email protected]>
[ Upstream commit a09decff5c32060639a685581c380f51b14e1fc2 ]
If the journal is dirty when the filesystem is mounted, jbd2 will replay the journal but the journal superblock will not be updated by journal_reset() because JBD2_ABORT flag is still set (it was set in journal_init_common()). This is problematic because when a new transaction is then committed, it will be recorded in block 1 (journal->j_tail was set to 1 in journal_reset()). If unclean shutdown happens again before the journal superblock is updated, the new recorded transaction will not be replayed during the next mount (because of stale sb->s_start and sb->s_sequence values) which can lead to filesystem corruption.
--- fs/jbd2/journal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/jbd2/journal.c +5 -1
@@ -1670,6 +1670,11 @@ int jbd2_journal_load(journal_t *journal) journal->j_devname);return -EFSCORRUPTED ; } +/* +* clear JBD2_ABORT flag initialized in journal_init_common +* here to update log tail information with the newest seq. +*/ + journal->j_flags &= ~JBD2_ABORT ;/* OK, we've finished with the dynamic journal bits: * reinitialise the dynamic contents of the superblock in memory
@@ -1677,7 +1682,6 @@ int jbd2_journal_load(journal_t *journal)if (journal_reset (journal)) goto recovery_error; - journal->j_flags &= ~JBD2_ABORT ; journal->j_flags |=JBD2_LOADED ;return 0 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 39/165 x86/sysfb: Fix check for bad VRAM size
In reply to Greg Kroah-HartmanFrom: Arvind Sankar <[email protected]>
[ Upstream commit dacc9092336be20b01642afe1a51720b31f60369 ]
When checking whether the reported lfb_size makes sense, the height
* stride result is page-aligned before seeing whether it exceeds the reported size.
This doesn't work if height * stride is not an exact number of pages. For example, as reported in the kernel bugzilla below, an 800x600x32 EFI framebuffer gets skipped because of this.
Move the PAGE_ALIGN to after the check vs size.
--- arch/x86/kernel/sysfb_simplefb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/sysfb_simplefb.c +1 -1
@@ -94,11 +94,11 @@ __init int create_simplefb(const struct screen_info *si,if (si->orig_video_isVGA ==VIDEO_TYPE_VLFB ) size <<=16 ; length = mode->height * mode->stride; - length =PAGE_ALIGN (length);if (length > size) {printk (KERN_WARNING "sysfb: VRAM smaller than advertised\n" );return -EINVAL ; } + length =PAGE_ALIGN (length);/* setup IORESOURCE_MEM as framebuffer memory */ memset (&res,0 ,sizeof (res));
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 40/165 tracing: Fix tracing_stat return values in error handling paths
In reply to Greg Kroah-HartmanFrom: Luis Henriques <[email protected]>
[ Upstream commit afccc00f75bbbee4e4ae833a96c2d29a7259c693 ]
tracing_stat_init() was always returning '0', even on the error paths. It now returns -ENODEV if tracing_init_dentry() fails or -ENOMEM if it fails to created the 'trace_stat' debugfs directory.
--- kernel/trace/trace_stat.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
kernel/trace/trace_stat.c +8 -4
@@ -277,18 +277,22 @@ static int tracing_stat_init(void) d_tracing =tracing_init_dentry ();if (IS_ERR (d_tracing)) -return 0 ; +return -ENODEV ; stat_dir =tracefs_create_dir ("trace_stat" , d_tracing); -if (!stat_dir) +if (!stat_dir) {pr_warn ("Could not create tracefs 'trace_stat' entry\n" ); +return -ENOMEM ; + }return 0 ; }static int init_stat_file (struct stat_session *session) { -if (!stat_dir &&tracing_stat_init ()) -return -ENODEV ; +int ret; + +if (!stat_dir && (ret =tracing_stat_init ())) +return ret; session->file = tracefs_create_file(session->ts->name, 0644, stat_dir,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 41/165 tracing: Fix very unlikely race of registering two stat tracers
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (VMware) <[email protected]>
[ Upstream commit dfb6cd1e654315168e36d947471bd2a0ccd834ae ]
Looking through old emails in my INBOX, I came across a patch from Luis Henriques that attempted to fix a race of two stat tracers registering the same stat trace (extremely unlikely, as this is done in the kernel, and probably doesn't even exist). The submitted patch wasn't quite right as it needed to deal with clean up a bit better (if two stat tracers were the same, it would have the same files).
But to make the code cleaner, all we needed to do is to keep the all_stat_sessions_mutex held for most of the registering function.
--- kernel/trace/trace_stat.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
kernel/trace/trace_stat.c +9 -10
@@ -305,7 +305,7 @@ static int init_stat_file(struct stat_session *session)int register_stat_tracer (struct tracer_stat *trace) {struct stat_session *session, *node; -int ret; +int ret = -EINVAL ;if (!trace)return -EINVAL ;
@@ -316,17 +316,15 @@ int register_stat_tracer(struct tracer_stat *trace)/* Already registered? */ mutex_lock (&all_stat_sessions_mutex);list_for_each_entry (node, &all_stat_sessions, session_list) { -if (node->ts == trace) { -mutex_unlock (&all_stat_sessions_mutex); -return -EINVAL ; - } +if (node->ts == trace) + goto out; } -mutex_unlock (&all_stat_sessions_mutex); + ret = -ENOMEM ;/* Init the session */ session =kzalloc (sizeof (*session),GFP_KERNEL );if (!session) -return -ENOMEM ; + goto out; session->ts = trace;INIT_LIST_HEAD (&session->session_list);
@@ -335,15 +333,16 @@ int register_stat_tracer(struct tracer_stat *trace) ret =init_stat_file (session);if (ret) {destroy_session (session); -return ret; + goto out; } + ret =0 ;/* Register */ -mutex_lock (&all_stat_sessions_mutex);list_add_tail (&session->session_list, &all_stat_sessions); + out:mutex_unlock (&all_stat_sessions_mutex); -return 0 ; +return ret; }void unregister_stat_tracer (struct tracer_stat *trace)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 42/165 ext4, jbd2: ensure panic when aborting with zero errno
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
[ Upstream commit 51f57b01e4a3c7d7bdceffd84de35144e8c538e7 ]
JBD2_REC_ERR flag used to indicate the errno has been updated when jbd2 aborted, and then __ext4_abort() and ext4_handle_error() can invoke panic if ERRORS_PANIC is specified. But if the journal has been aborted with zero errno, jbd2_journal_abort() didn't set this flag so we can no longer panic. Fix this by always record the proper errno in the journal superblock.
--- fs/jbd2/checkpoint.c | 2 +- fs/jbd2/journal.c | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-)
fs/jbd2/checkpoint.c +1 -1
@@ -168,7 +168,7 @@ void __jbd2_log_wait_for_space(journal_t *journal)"journal space in %s\n" , __func__, journal->j_devname);WARN_ON (1 ); -jbd2_journal_abort (journal,0 ); +jbd2_journal_abort (journal, -EIO ); }write_lock (&journal->j_state_lock); }else {
fs/jbd2/journal.c +4 -11
@@ -2100,12 +2100,10 @@ static void __journal_abort_soft (journal_t *journal, int errno)__jbd2_journal_abort_hard (journal); -if (errno) { -jbd2_journal_update_sb_errno (journal); -write_lock (&journal->j_state_lock); - journal->j_flags |=JBD2_REC_ERR ; -write_unlock (&journal->j_state_lock); - } +jbd2_journal_update_sb_errno (journal); +write_lock (&journal->j_state_lock); + journal->j_flags |=JBD2_REC_ERR ; +write_unlock (&journal->j_state_lock); }/**
@@ -2147,11 +2145,6 @@ static void __journal_abort_soft (journal_t *journal, int errno)* failure to disk. ext3_error, for example, now uses this * functionality. * -* Errors which originate from within the journaling layer will NOT -* supply an errno; a null errno implies that absolutely no further -* writes are done to the journal (unless there are any already in -* progress). -* */ void jbd2_journal_abort (journal_t *journal,int errno)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 43/165 kconfig: fix broken dependency in randconfig-generated .config
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
[ Upstream commit c8fb7d7e48d11520ad24808cfce7afb7b9c9f798 ]
Running randconfig on arm64 using KCONFIG_SEED=0x40C5E904 (e.g. on v5.5) produces the .config with CONFIG_EFI=y and CONFIG_CPU_BIG_ENDIAN=y, which does not meet the !CONFIG_CPU_BIG_ENDIAN dependency.
This is because the user choice for CONFIG_CPU_LITTLE_ENDIAN vs CONFIG_CPU_BIG_ENDIAN is set by randomize_choice_values() after the value of CONFIG_EFI is calculated.
When this happens, the has_changed flag should be set.
Currently, it takes the result from the last iteration. It should accumulate all the results of the loop.
--- scripts/kconfig/confdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/confdata.c +1 -1
@@ -1238,7 +1238,7 @@ bool conf_set_all_new_symbols(enum conf_def_mode mode)sym_calc_value (csym);if (mode == def_random) - has_changed =randomize_choice_values (csym); + has_changed |=randomize_choice_values (csym);else {set_all_choice_values (csym); has_changed = true;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 44/165 clk: qcom: rcg2: Dont crash if our parent cant be found; return an error
In reply to Greg Kroah-HartmanFrom: Douglas Anderson <[email protected]>
[ Upstream commit 908b050114d8fefdddc57ec9fbc213c3690e7f5f ]
When I got my clock parenting slightly wrong I ended up with a crash that looked like this:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 ... pc : clk_hw_get_rate+0x14/0x44 ... Call trace: clk_hw_get_rate+0x14/0x44 _freq_tbl_determine_rate+0x94/0xfc clk_rcg2_determine_rate+0x2c/0x38 clk_core_determine_round_nolock+0x4c/0x88 clk_core_round_rate_nolock+0x6c/0xa8 clk_core_round_rate_nolock+0x9c/0xa8 clk_core_set_rate_nolock+0x70/0x180 clk_set_rate+0x3c/0x6c of_clk_set_defaults+0x254/0x360 platform_drv_probe+0x28/0xb0 really_probe+0x120/0x2dc driver_probe_device+0x64/0xfc device_driver_attach+0x4c/0x6c __driver_attach+0xac/0xc0 bus_for_each_dev+0x84/0xcc driver_attach+0x2c/0x38 bus_add_driver+0xfc/0x1d0 driver_register+0x64/0xf8 __platform_driver_register+0x4c/0x58 msm_drm_register+0x5c/0x60 ...
It turned out that clk_hw_get_parent_by_index() was returning NULL and we weren't checking. Let's check it so that we don't crash.
--- drivers/clk/qcom/clk-rcg2.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clk/qcom/clk-rcg2.c +3 -0
@@ -194,6 +194,9 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, clk_flags =clk_hw_get_flags (hw); p =clk_hw_get_parent_by_index (hw, index); +if (!p) +return -EINVAL ; +if (clk_flags &CLK_SET_RATE_PARENT ) {if (f->pre_div) {if (!rate)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 45/165 drm/amdgpu: remove 4 set but not used variable in amdgpu_atombios_get_connector_info_from_object_table
In reply to Greg Kroah-HartmanFrom: yu kuai <[email protected]>
[ Upstream commit bae028e3e521e8cb8caf2cc16a455ce4c55f2332 ]
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c: In function 'amdgpu_atombios_get_connector_info_from_object_table':drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:376:26: warning: variable 'grph_obj_num' set but not used [-Wunused-but-set-variable] drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:376:13: warning: variable 'grph_obj_id' set but not used [-Wunused-but-set-variable] drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:341:37: warning: variable 'con_obj_type' set but not used [-Wunused-but-set-variable] drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c:341:24: warning: variable 'con_obj_num' set but not used [-Wunused-but-set-variable]
They are never used, so can be removed.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +2 -17
@@ -336,17 +336,9 @@ bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device * path_size +=le16_to_cpu (path->usSize);if (device_support &le16_to_cpu (path->usDeviceTag)) { -uint8_t con_obj_id, con_obj_num, con_obj_type; - - con_obj_id = +uint8_t con_obj_id = (le16_to_cpu (path->usConnObjectId) &OBJECT_ID_MASK ) >>OBJECT_ID_SHIFT ; - con_obj_num = - (le16_to_cpu (path->usConnObjectId) &ENUM_ID_MASK ) - >>ENUM_ID_SHIFT ; - con_obj_type = - (le16_to_cpu (path->usConnObjectId) & -OBJECT_TYPE_MASK ) >>OBJECT_TYPE_SHIFT ;/* Skip TV/CV support */ if ((le16_to_cpu(path->usDeviceTag) ==
@@ -371,14 +363,7 @@ bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device * router.ddc_valid = false; router.cd_valid = false;for (j =0 ; j < ((le16_to_cpu (path->usSize) -8 ) /2 ); j++) { -uint8_t grph_obj_id, grph_obj_num, grph_obj_type; - - grph_obj_id = - (le16_to_cpu (path->usGraphicObjIds[j]) & -OBJECT_ID_MASK ) >>OBJECT_ID_SHIFT ; - grph_obj_num = - (le16_to_cpu (path->usGraphicObjIds[j]) & -ENUM_ID_MASK ) >>ENUM_ID_SHIFT ; +uint8_t grph_obj_type= grph_obj_type = (le16_to_cpu (path->usGraphicObjIds[j]) &OBJECT_TYPE_MASK ) >>OBJECT_TYPE_SHIFT ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 46/165 regulator: rk808: Lower log level on optional GPIOs being not available
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit b8a039d37792067c1a380dc710361905724b9b2f ]
RK808 can leverage a couple of GPIOs to tweak the ramp rate during DVS (Dynamic Voltage Scaling). These GPIOs are entirely optional but a dev_warn() appeared when cleaning this driver to use a more up-to-date gpiod API. At least reduce the log level to 'info' as it is totally fine to not populate these GPIO on a hardware design.
This change is trivial but it is worth not polluting the logs during bringup phase by having real warnings and errors sorted out correctly.
--- drivers/regulator/rk808-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/rk808-regulator.c +1 -1
@@ -589,7 +589,7 @@ static int rk808_regulator_dt_parse_pdata(struct device *dev, }if (!pdata->dvs_gpio[i]) { -dev_warn (dev,"there is no dvs%d gpio\n" , i); +dev_info (dev,"there is no dvs%d gpio\n" , i);continue ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 47/165 net/wan/fsl_ucc_hdlc: reject muram offsets above 64K
In reply to Greg Kroah-HartmanFrom: Rasmus Villemoes <[email protected]>
[ Upstream commit 148587a59f6b85831695e0497d9dd1af5f0495af ]
Qiang Zhao points out that these offsets get written to 16-bit registers, and there are some QE platforms with more than 64K muram. So it is possible that qe_muram_alloc() gives us an allocation that can't actually be used by the hardware, so detect and reject that.
--- drivers/net/wan/fsl_ucc_hdlc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wan/fsl_ucc_hdlc.c +5 -0
@@ -209,6 +209,11 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) ret = -ENOMEM ; goto free_riptr; } +if (riptr != (u16 )riptr || tiptr != (u16 )tiptr) { +dev_err (priv->dev,"MURAM allocation out of addressable range\n" ); + ret = -ENOMEM ; + goto free_tiptr; + }/* Set RIPTR, TIPTR */ iowrite16be (riptr, &priv->ucc_pram->riptr);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 48/165 PCI/IOV: Fix memory leak in pci_iov_add_virtfn()
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 8c386cc817878588195dde38e919aa6ba9409d58 ]
In the implementation of pci_iov_add_virtfn() the allocated virtfn is leaked if pci_setup_device() fails. The error handling is not calling pci_stop_and_remove_bus_device(). Change the goto label to failed2.
--- drivers/pci/iov.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/iov.c +1 -0
@@ -181,6 +181,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id, int reset) failed2:sysfs_remove_link (&dev->dev.kobj, buf); failed1: +pci_stop_and_remove_bus_device (virtfn);pci_dev_put (dev);mutex_lock (&iov->dev->sriov->lock);pci_stop_and_remove_bus_device (virtfn);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 49/165 NFC: port100: Convert cpu_to_le16(le16_to_cpu(E1) + E2) to use le16_add_cpu().
In reply to Greg Kroah-HartmanFrom: Mao Wenan <[email protected]>
[ Upstream commit 718eae277e62a26e5862eb72a830b5e0fe37b04a ]
Convert cpu_to_le16(le16_to_cpu(frame->datalen) + len) to use le16_add_cpu(), which is more concise and does the same thing.
--- drivers/nfc/port100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/port100.c +1 -1
@@ -573,7 +573,7 @@ static void port100_tx_update_payload_len(void *_frame, int len) {struct port100_frame *frame = _frame; - frame->datalen =cpu_to_le16 (le16_to_cpu (frame->datalen) + len); +le16_add_cpu (&frame->datalen, len); }static bool port100_rx_frame_is_valid (void *_frame)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 50/165 media: v4l2-device.h: Explicitly compare grp{id,mask} to zero in v4l2_device macros
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit afb34781620274236bd9fc9246e22f6963ef5262 ]
When building with Clang + -Wtautological-constant-compare, several of the ivtv and cx18 drivers warn along the lines of:
drivers/media/pci/cx18/cx18-driver.c:1005:21: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL,
^
drivers/media/pci/cx18/cx18-cards.h:18:37: note: expanded from macro
'CX18_HW_GPIO_RESET_CTRL'
#define CX18_HW_GPIO_RESET_CTRL (1 << 6)
^1 warning generated.
This warning happens because the shift operation is implicitly converted to a boolean in v4l2_device_mask_call_all before being negated. This can be solved by just comparing the mask result to 0 explicitly so that there is no boolean conversion. The ultimate goal is to enable -Wtautological-compare globally because there are several subwarnings that would be helpful to have.
For visual consistency and avoidance of these warnings in the future, all of the implicitly boolean conversions in the v4l2_device macros are converted to explicit ones as well.
--- include/media/v4l2-device.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/media/v4l2-device.h +6 -6
@@ -268,7 +268,7 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,struct v4l2_subdev *__sd; \ \__v4l2_device_call_subdevs_p (v4l2_dev, __sd, \ - !(grpid) || __sd->grp_id == (grpid), o, f , \ + (grpid) == 0 || __sd->grp_id == (grpid), o, f , \ ##args); \ }while (0 )
@@ -280,7 +280,7 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ({ \struct v4l2_subdev *__sd; \__v4l2_device_call_subdevs_until_err_p (v4l2_dev, __sd, \ - !(grpid) || __sd->grp_id == (grpid), o, f , \ + (grpid) == 0 || __sd->grp_id == (grpid), o, f , \ ##args); \ })
@@ -294,8 +294,8 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd,struct v4l2_subdev *__sd; \ \__v4l2_device_call_subdevs_p (v4l2_dev, __sd, \ - !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \ - ##args); \ + (grpmsk) ==0 || (__sd->grp_id & (grpmsk)), o, \ + f , ##args); \ }while (0 )/*
@@ -308,8 +308,8 @@ static inline void v4l2_subdev_notify(struct v4l2_subdev *sd, ({ \struct v4l2_subdev *__sd; \__v4l2_device_call_subdevs_until_err_p (v4l2_dev, __sd, \ - !(grpmsk) || (__sd->grp_id & (grpmsk)), o, f , \ - ##args); \ + (grpmsk) ==0 || (__sd->grp_id & (grpmsk)), o, \ + f , ##args); \ })/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 51/165 reiserfs: Fix spurious unlock in reiserfs_fill_super() error handling
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit 4d5c1adaf893b8aa52525d2b81995e949bcb3239 ]
When we fail to allocate string for journal device name we jump to 'error' label which tries to unlock reiserfs write lock which is not held. Jump to 'error_unlocked' instead.
--- fs/reiserfs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/reiserfs/super.c +1 -1
@@ -1928,7 +1928,7 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)if (!sbi->s_jdev) {SWARN (silent, s,"" ,"Cannot allocate memory for " "journal device name" ); - goto error; + goto error_unlocked; } }#ifdef CONFIG_QUOTA
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 52/165 ALSA: usx2y: Adjust indentation in snd_usX2Y_hwdep_dsp_status
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit df4654bd6e42125d9b85ce3a26eaca2935290b98 ]
Clang warns:
../sound/usb/usx2y/usX2Yhwdep.c:122:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
info->version = USX2Y_DRIVER_VERSION;
^
../sound/usb/usx2y/usX2Yhwdep.c:120:2: note: previous statement is here
if (us428->chip_status & USX2Y_STAT_CHIP_INIT)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
This was introduced before the beginning of git history so no fixes tag.
--- sound/usb/usx2y/usX2Yhwdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/usb/usx2y/usX2Yhwdep.c +1 -1
@@ -132,7 +132,7 @@ static int snd_usX2Y_hwdep_dsp_status(struct snd_hwdep *hw, info->num_dsps =2 ;// 0: Prepad Data, 1: FPGA Code if (us428->chip_status &USX2Y_STAT_CHIP_INIT ) info->chip_ready =1 ; - info->version =USX2Y_DRIVER_VERSION ; + info->version =USX2Y_DRIVER_VERSION ;return 0 ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 53/165 b43legacy: Fix -Wcast-function-type
In reply to Greg Kroah-HartmanFrom: Phong Tran <[email protected]>
[ Upstream commit 475eec112e4267232d10f4afe2f939a241692b6c ]
correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20
--- drivers/net/wireless/broadcom/b43legacy/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/broadcom/b43legacy/main.c +3 -2
@@ -1304,8 +1304,9 @@ static void handle_irq_ucode_debug(struct b43legacy_wldev *dev) }/* Interrupt handler bottom-half */ -static void b43legacy_interrupt_tasklet (struct b43legacy_wldev *dev) +static void b43legacy_interrupt_tasklet (unsigned long data) { +struct b43legacy_wldev *dev = (struct b43legacy_wldev *)data;u32 reason;u32 dma_reason[ARRAY_SIZE (dev->dma_reason)];u32 merged_dma_reason =0 ;
@@ -3775,7 +3776,7 @@ static int b43legacy_one_core_attach(struct ssb_device *dev,b43legacy_set_status (wldev, B43legacy_STAT_UNINIT); wldev->bad_frames_preempt = modparam_bad_frames_preempt;tasklet_init (&wldev->isr_tasklet, - (void (*)(unsigned long ))b43legacy_interrupt_tasklet, + b43legacy_interrupt_tasklet, (unsigned long )wldev);if (modparam_pio) wldev->__using_pio = true;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 54/165 ipw2x00: Fix -Wcast-function-type
In reply to Greg Kroah-HartmanFrom: Phong Tran <[email protected]>
[ Upstream commit ebd77feb27e91bb5fe35a7818b7c13ea7435fb98 ]
correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20
--- drivers/net/wireless/intel/ipw2x00/ipw2100.c | 7 ++++--- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/ipw2x00/ipw2100.c +4 -3
@@ -3220,8 +3220,9 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv) } } -static void ipw2100_irq_tasklet (struct ipw2100_priv *priv) +static void ipw2100_irq_tasklet (unsigned long data) { +struct ipw2100_priv *priv = (struct ipw2100_priv *)data;struct net_device *dev = priv->net_dev;unsigned long flags;u32 inta, tmp;
@@ -6029,7 +6030,7 @@ static void ipw2100_rf_kill(struct work_struct *work)spin_unlock_irqrestore (&priv->low_lock, flags); } -static void ipw2100_irq_tasklet (struct ipw2100_priv *priv); +static void ipw2100_irq_tasklet (unsigned long data);static const struct net_device_ops ipw2100_netdev_ops = { .ndo_open = ipw2100_open,
@@ -6158,7 +6159,7 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,INIT_DELAYED_WORK (&priv->rf_kill, ipw2100_rf_kill);INIT_DELAYED_WORK (&priv->scan_event, ipw2100_scan_event); -tasklet_init (&priv->irq_tasklet, (void (*)(unsigned long )) +tasklet_init (&priv->irq_tasklet, ipw2100_irq_tasklet, (unsigned long )priv);/* NOTE: We do not start the deferred work for status checks yet */
drivers/net/wireless/intel/ipw2x00/ipw2200.c +3 -2
@@ -1968,8 +1968,9 @@ static void notify_wx_assoc_event(struct ipw_priv *priv)wireless_send_event (priv->net_dev,SIOCGIWAP , &wrqu,NULL ); } -static void ipw_irq_tasklet (struct ipw_priv *priv) +static void ipw_irq_tasklet (unsigned long data) { +struct ipw_priv *priv = (struct ipw_priv *)data;u32 inta, inta_mask, handled =0 ;unsigned long flags;int rc =0 ;
@@ -10705,7 +10706,7 @@ static int ipw_setup_deferred_work(struct ipw_priv *priv)INIT_WORK (&priv->qos_activate, ipw_bg_qos_activate);#endif /* CONFIG_IPW2200_QOS */ -tasklet_init (&priv->irq_tasklet, (void (*)(unsigned long )) +tasklet_init (&priv->irq_tasklet, ipw_irq_tasklet, (unsigned long )priv);return ret;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 55/165 iwlegacy: Fix -Wcast-function-type
In reply to Greg Kroah-HartmanFrom: Phong Tran <[email protected]>
[ Upstream commit da5e57e8a6a3e69dac2937ba63fa86355628fbb2 ]
correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20
--- drivers/net/wireless/intel/iwlegacy/3945-mac.c | 5 +++-- drivers/net/wireless/intel/iwlegacy/4965-mac.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/iwlegacy/3945-mac.c +3 -2
@@ -1399,8 +1399,9 @@ il3945_dump_nic_error_log(struct il_priv *il) }static void -il3945_irq_tasklet (struct il_priv *il) +il3945_irq_tasklet (unsigned long data) { +struct il_priv *il = (struct il_priv *)data;u32 inta, handled =0 ;u32 inta_fh;unsigned long flags;
@@ -3432,7 +3433,7 @@ il3945_setup_deferred_work(struct il_priv *il)setup_timer (&il->watchdog, il_bg_watchdog, (unsigned long )il);tasklet_init (&il->irq_tasklet, - (void (*)(unsigned long ))il3945_irq_tasklet, + il3945_irq_tasklet, (unsigned long )il); }
drivers/net/wireless/intel/iwlegacy/4965-mac.c +3 -2
@@ -4361,8 +4361,9 @@ il4965_synchronize_irq(struct il_priv *il) }static void -il4965_irq_tasklet (struct il_priv *il) +il4965_irq_tasklet (unsigned long data) { +struct il_priv *il = (struct il_priv *)data;u32 inta, handled =0 ;u32 inta_fh;unsigned long flags;
@@ -6260,7 +6261,7 @@ il4965_setup_deferred_work(struct il_priv *il)setup_timer (&il->watchdog, il_bg_watchdog, (unsigned long )il);tasklet_init (&il->irq_tasklet, - (void (*)(unsigned long ))il4965_irq_tasklet, + il4965_irq_tasklet, (unsigned long )il); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 56/165 rtlwifi: rtl_pci: Fix -Wcast-function-type
In reply to Greg Kroah-HartmanFrom: Phong Tran <[email protected]>
[ Upstream commit cb775c88da5d48a85d99d95219f637b6fad2e0e9 ]
correct usage prototype of callback in tasklet_init(). Report by https://github.com/KSPP/linux/issues/20
--- drivers/net/wireless/realtek/rtlwifi/pci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +6 -4
@@ -1095,13 +1095,15 @@ done:return ret; } -static void _rtl_pci_irq_tasklet (struct ieee80211_hw *hw) +static void _rtl_pci_irq_tasklet (unsigned long data) { +struct ieee80211_hw *hw = (struct ieee80211_hw *)data;_rtl_pci_tx_chk_waitq (hw); } -static void _rtl_pci_prepare_bcn_tasklet (struct ieee80211_hw *hw) +static void _rtl_pci_prepare_bcn_tasklet (unsigned long data) { +struct ieee80211_hw *hw = (struct ieee80211_hw *)data;struct rtl_priv *rtlpriv =rtl_priv (hw);struct rtl_pci *rtlpci =rtl_pcidev (rtl_pcipriv (hw));struct rtl_mac *mac =rtl_mac (rtl_priv (hw));
@@ -1223,10 +1225,10 @@ static void _rtl_pci_init_struct(struct ieee80211_hw *hw,/*task */ tasklet_init (&rtlpriv->works.irq_tasklet, - (void (*)(unsigned long ))_rtl_pci_irq_tasklet, + _rtl_pci_irq_tasklet, (unsigned long )hw);tasklet_init (&rtlpriv->works.irq_prepare_bcn_tasklet, - (void (*)(unsigned long ))_rtl_pci_prepare_bcn_tasklet, + _rtl_pci_prepare_bcn_tasklet, (unsigned long )hw);INIT_WORK (&rtlpriv->works.lps_change_work, rtl_lps_change_work_callback);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 57/165 orinoco: avoid assertion in case of NULL pointer
In reply to Greg Kroah-HartmanFrom: Aditya Pakki <[email protected]>
[ Upstream commit c705f9fc6a1736dcf6ec01f8206707c108dca824 ]
In ezusb_init, if upriv is NULL, the code crashes. However, the caller in ezusb_probe can handle the error and print the failure message. The patch replaces the BUG_ON call to error return.
--- drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intersil/orinoco/orinoco_usb.c +2 -1
@@ -1351,7 +1351,8 @@ static int ezusb_init(struct hermes *hw)int retval;BUG_ON (in_interrupt ()); -BUG_ON (!upriv); +if (!upriv) +return -EINVAL ; upriv->reply_count =0 ;/* Write the MAGIC number on the simulated registers to keep
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 58/165 ACPICA: Disassembler: create buffer fields in ACPI_PARSE_LOAD_PASS1
In reply to Greg Kroah-HartmanFrom: Erik Kaneda <[email protected]>
[ Upstream commit 5ddbd77181dfca61b16d2e2222382ea65637f1b9 ]
ACPICA commit 29cc8dbc5463a93625bed87d7550a8bed8913bf4
create_buffer_field is a deferred op that is typically processed in load pass 2. However, disassembly of control method contents walk the parse tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed in a later walk. This is a problem when there is a control method that has the same name as the AML_CREATE object. In this case, any use of the name segment will be detected as a method call rather than a reference to a buffer field. If this is detected as a method call, it can result in a mal-formed parse tree if the control methods have parameters.
This change in processing AML_CREATE ops earlier solves this issue by inserting the named object in the ACPI namespace so that references to this name would be detected as a name string rather than a method call.
--- drivers/acpi/acpica/dsfield.c | 2 +- drivers/acpi/acpica/dswload.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-)
drivers/acpi/acpica/dsfield.c +1 -1
@@ -272,7 +272,7 @@ cleanup:* FUNCTION: acpi_ds_get_field_names * * PARAMETERS: info - create_field info structure -* ` walk_state - Current method state +* walk_state - Current method state * arg - First parser arg for the field name list * * RETURN: Status
drivers/acpi/acpica/dswload.c +21 -0
@@ -440,6 +440,27 @@ acpi_status acpi_ds_load1_end_op(struct acpi_walk_state *walk_state)ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH ,"Op=%p State=%p\n" , op, walk_state)); +/* +* Disassembler: handle create field operators here. +* +* create_buffer_field is a deferred op that is typically processed in load +* pass 2. However, disassembly of control method contents walk the parse +* tree with ACPI_PARSE_LOAD_PASS1 and AML_CREATE operators are processed +* in a later walk. This is a problem when there is a control method that +* has the same name as the AML_CREATE object. In this case, any use of the +* name segment will be detected as a method call rather than a reference +* to a buffer field. +* +* This earlier creation during disassembly solves this issue by inserting +* the named object in the ACPI namespace so that references to this name +* would be a name string rather than a method call. +*/ +if ((walk_state->parse_flags &ACPI_PARSE_DISASSEMBLE ) && + (walk_state->op_info->flags &AML_CREATE )) { + status =acpi_ds_create_buffer_field (op, walk_state); +return_ACPI_STATUS (status); + } +/* We are only interested in opcodes that have an associated name */ if (!(walk_state->op_info->flags & (AML_NAMED |AML_FIELD ))) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 59/165 scsi: aic7xxx: Adjust indentation in ahc_find_syncrate
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 4dbc96ad65c45cdd4e895ed7ae4c151b780790c5 ]
Clang warns:
../drivers/scsi/aic7xxx/aic7xxx_core.c:2317:5: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if ((syncrate->sxfr_u2 & ST_SXFR) != 0)
^
../drivers/scsi/aic7xxx/aic7xxx_core.c:2310:4: note: previous statement
is here
if (syncrate == &ahc_syncrates[maxsync])
^1 warning generated.
This warning occurs because there is a space amongst the tabs on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
This has been a problem since the beginning of git history hence no fixes tag.
--- drivers/scsi/aic7xxx/aic7xxx_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/aic7xxx/aic7xxx_core.c +1 -1
@@ -2321,7 +2321,7 @@ ahc_find_syncrate(struct ahc_softc *ahc, u_int *period,* At some speeds, we only support * ST transfers. */ -if ((syncrate->sxfr_u2 &ST_SXFR ) !=0 ) +if ((syncrate->sxfr_u2 &ST_SXFR ) !=0 ) *ppr_options &= ~MSG_EXT_PPR_DT_REQ ;break ; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 60/165 drm/mediatek: handle events when enabling/disabling crtc
In reply to Greg Kroah-HartmanFrom: Bibby Hsieh <[email protected]>
[ Upstream commit 411f5c1eacfebb1f6e40b653d29447cdfe7282aa ]
The driver currently handles vblank events only when updating planes on an already enabled CRTC. The atomic update API however allows requesting an event when enabling or disabling a CRTC. This currently leads to event objects being leaked in the kernel and to events not being sent out. Fix it.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +8 -0
@@ -306,6 +306,7 @@ err_pm_runtime_put:static void mtk_crtc_ddp_hw_fini (struct mtk_drm_crtc *mtk_crtc) {struct drm_device *drm = mtk_crtc->base.dev; +struct drm_crtc *crtc = &mtk_crtc->base;int i;DRM_DEBUG_DRIVER ("%s\n" , __func__);
@@ -327,6 +328,13 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc)mtk_disp_mutex_unprepare (mtk_crtc->mutex);pm_runtime_put (drm->dev); + +if (crtc->state->event && !crtc->state->active) { +spin_lock_irq (&crtc->dev->event_lock); +drm_crtc_send_vblank_event (crtc, crtc->state->event); + crtc->state->event =NULL ; +spin_unlock_irq (&crtc->dev->event_lock); + } }static void mtk_drm_crtc_enable (struct drm_crtc *crtc)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 61/165 ARM: dts: r8a7779: Add device node for ARM global timer
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 8443ffd1bbd5be74e9b12db234746d12e8ea93e2 ]
Add a device node for the global timer, which is part of the Cortex-A9 MPCore.
The global timer can serve as an accurate (4 ns) clock source for scheduling and delay loops.
--- arch/arm/boot/dts/r8a7779.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/boot/dts/r8a7779.dtsi +8 -0
@@ -67,6 +67,14 @@ <0xf0000100 0x100>; }; + timer@f0000200 { + compatible = "arm,cortex-a9-global-timer"; + reg = <0xf0000200 0x100>; + interrupts = <GIC_PPI 11 + (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>; + clocks = <&cpg_clocks R8A7779_CLK_ZS>; + }; + timer@f0000600 { compatible = "arm,cortex-a9-twd-timer"; reg = <0xf0000600 0x20>;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 62/165 x86/vdso: Provide missing include file
In reply to Greg Kroah-HartmanFrom: Valdis Klētnieks <[email protected]>
[ Upstream commit bff47c2302cc249bcd550b17067f8dddbd4b6f77 ]
When building with C=1, sparse issues a warning:
CHECK arch/x86/entry/vdso/vdso32-setup.c
arch/x86/entry/vdso/vdso32-setup.c:28:28: warning: symbol 'vdso32_enabled' was not declared. Should it be static?
Provide the missing header file.
--- arch/x86/entry/vdso/vdso32-setup.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/entry/vdso/vdso32-setup.c +1 -0
@@ -10,6 +10,7 @@#include <linux/smp.h> #include <linux/kernel.h> #include <linux/mm_types.h> +#include <linux/elf.h> #include <asm/processor.h> #include <asm/vdso.h>
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 63/165 PM / devfreq: rk3399_dmc: Add COMPILE_TEST and HAVE_ARM_SMCCC dependency
In reply to Greg Kroah-HartmanFrom: Chanwoo Choi <[email protected]>
[ Upstream commit eff5d31f7407fa9d31fb840106f1593399457298 ]
To build test, add COMPILE_TEST depedency to both ARM_RK3399_DMC_DEVFREQ and DEVFREQ_EVENT_ROCKCHIP_DFI configuration. And ARM_RK3399_DMC_DEVFREQ used the SMCCC interface so that add HAVE_ARM_SMCCC dependency to prevent the build break.
--- drivers/devfreq/Kconfig | 3 ++- drivers/devfreq/event/Kconfig | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/devfreq/Kconfig +2 -1
@@ -102,7 +102,8 @@ config ARM_TEGRA_DEVFREQ config ARM_RK3399_DMC_DEVFREQ tristate "ARM RK3399 DMC DEVFREQ Driver" - depends on ARCH_ROCKCHIP + depends on (ARCH_ROCKCHIP && HAVE_ARM_SMCCC) || \ + (COMPILE_TEST && HAVE_ARM_SMCCC) select DEVFREQ_EVENT_ROCKCHIP_DFI select DEVFREQ_GOV_SIMPLE_ONDEMAND select PM_DEVFREQ_EVENT
drivers/devfreq/event/Kconfig +1 -1
@@ -33,7 +33,7 @@ config DEVFREQ_EVENT_EXYNOS_PPMU config DEVFREQ_EVENT_ROCKCHIP_DFI tristate "ROCKCHIP DFI DEVFREQ event Driver" - depends on ARCH_ROCKCHIP + depends on ARCH_ROCKCHIP || COMPILE_TEST help This add the devfreq-event driver for Rockchip SoC. It provides DFI (DDR Monitor Module) driver to count ddr load.
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 64/165 pinctrl: sh-pfc: sh7269: Fix CAN function GPIOs
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 02aeb2f21530c98fc3ca51028eda742a3fafbd9f ]
pinmux_func_gpios[] contains a hole due to the missing function GPIO definition for the "CTX0&CTX1" signal, which is the logical "AND" of the first two CAN outputs.
A closer look reveals other issues:
- Some functionality is available on alternative pins, but the PINMUX_DATA() entries is using the wrong marks,
- Several configurations are missing.
Fix this by:
- Renaming CTX0CTX1CTX2_MARK, CRX0CRX1_PJ22_MARK, and CRX0CRX1CRX2_PJ20_MARK to CTX0_CTX1_CTX2_MARK, CRX0_CRX1_PJ22_MARK, resp. CRX0_CRX1_CRX2_PJ20_MARK for consistency with the corresponding enum IDs,
- Adding all missing enum IDs and marks,
- Use the right (*_PJ2x) variants for alternative pins,
- Adding all missing configurations to pinmux_data[],
- Adding all missing function GPIO definitions to pinmux_func_gpios[].
See SH7268 Group, SH7269 Group User’s Manual: Hardware, Rev. 2.00:
[1] Table 1.4 List of Pins
[2] Figure 23.29 Connection Example when Using Channels 0 and 1 as One Channel (64 Mailboxes × 1 Channel) and Channel 2 as One Channel (32 Mailboxes × 1 Channel),
[3] Figure 23.30 Connection Example when Using Channels 0, 1, and 2 as One Channel (96 Mailboxes × 1 Channel),
[4] Table 48.3 Multiplexed Pins (Port B),
[5] Table 48.4 Multiplexed Pins (Port C),
[6] Table 48.10 Multiplexed Pins (Port J),
[7] Section 48.2.4 Port B Control Registers 0 to 5 (PBCR0 to PBCR5).
--- arch/sh/include/cpu-sh2a/cpu/sh7269.h | 11 ++++++-- drivers/pinctrl/sh-pfc/pfc-sh7269.c | 39 ++++++++++++++++++--------- 2 files changed, 36 insertions(+), 14 deletions(-)
arch/sh/include/cpu-sh2a/cpu/sh7269.h +9 -2
@@ -79,8 +79,15 @@ enum {GPIO_FN_WDTOVF ,/* CAN */ -GPIO_FN_CTX1 ,GPIO_FN_CRX1 ,GPIO_FN_CTX0 ,GPIO_FN_CTX0_CTX1 , -GPIO_FN_CRX0 ,GPIO_FN_CRX0_CRX1 ,GPIO_FN_CRX0_CRX1_CRX2 , +GPIO_FN_CTX2 ,GPIO_FN_CRX2 , +GPIO_FN_CTX1 ,GPIO_FN_CRX1 , +GPIO_FN_CTX0 ,GPIO_FN_CRX0 , +GPIO_FN_CTX0_CTX1 ,GPIO_FN_CRX0_CRX1 , +GPIO_FN_CTX0_CTX1_CTX2 ,GPIO_FN_CRX0_CRX1_CRX2 , +GPIO_FN_CTX2_PJ21 ,GPIO_FN_CRX2_PJ20 , +GPIO_FN_CTX1_PJ23 ,GPIO_FN_CRX1_PJ22 , +GPIO_FN_CTX0_CTX1_PJ23 ,GPIO_FN_CRX0_CRX1_PJ22 , +GPIO_FN_CTX0_CTX1_CTX2_PJ21 ,GPIO_FN_CRX0_CRX1_CRX2_PJ20 ,/* DMAC */ GPIO_FN_TEND0, GPIO_FN_DACK0, GPIO_FN_DREQ0,
drivers/pinctrl/sh-pfc/pfc-sh7269.c +27 -12
@@ -740,13 +740,12 @@ enum {CRX0_MARK ,CTX0_MARK ,CRX1_MARK ,CTX1_MARK ,CRX2_MARK ,CTX2_MARK , -CRX0_CRX1_MARK , -CRX0_CRX1_CRX2_MARK , -CTX0CTX1CTX2_MARK , +CRX0_CRX1_MARK ,CTX0_CTX1_MARK , +CRX0_CRX1_CRX2_MARK ,CTX0_CTX1_CTX2_MARK ,CRX1_PJ22_MARK ,CTX1_PJ23_MARK ,CRX2_PJ20_MARK ,CTX2_PJ21_MARK , -CRX0CRX1_PJ22_MARK , -CRX0CRX1CRX2_PJ20_MARK , +CRX0_CRX1_PJ22_MARK ,CTX0_CTX1_PJ23_MARK , +CRX0_CRX1_CRX2_PJ20_MARK ,CTX0_CTX1_CTX2_PJ21_MARK ,/* VDC */ DV_CLK_MARK,
@@ -824,6 +823,7 @@ static const u16 pinmux_data[] = {PINMUX_DATA (CS3_MARK ,PC8MD_001 ),PINMUX_DATA (TXD7_MARK ,PC8MD_010 ),PINMUX_DATA (CTX1_MARK ,PC8MD_011 ), +PINMUX_DATA (CTX0_CTX1_MARK ,PC8MD_100 ),PINMUX_DATA (PC7_DATA ,PC7MD_000 ), PINMUX_DATA(CKE_MARK, PC7MD_001),
@@ -836,11 +836,12 @@ static const u16 pinmux_data[] = {PINMUX_DATA (CAS_MARK ,PC6MD_001 ),PINMUX_DATA (SCK7_MARK ,PC6MD_010 ),PINMUX_DATA (CTX0_MARK ,PC6MD_011 ), +PINMUX_DATA (CTX0_CTX1_CTX2_MARK ,PC6MD_100 ),PINMUX_DATA (PC5_DATA ,PC5MD_000 ),PINMUX_DATA (RAS_MARK ,PC5MD_001 ),PINMUX_DATA (CRX0_MARK ,PC5MD_011 ), -PINMUX_DATA (CTX0CTX1CTX2_MARK ,PC5MD_100 ), +PINMUX_DATA (CTX0_CTX1_CTX2_MARK ,PC5MD_100 ),PINMUX_DATA (IRQ0_PC_MARK ,PC5MD_101 ), PINMUX_DATA(PC4_DATA, PC4MD_00),
@@ -1292,30 +1293,32 @@ static const u16 pinmux_data[] = {PINMUX_DATA (LCD_DATA23_PJ23_MARK ,PJ23MD_010 ),PINMUX_DATA (LCD_TCON6_MARK ,PJ23MD_011 ),PINMUX_DATA (IRQ3_PJ_MARK ,PJ23MD_100 ), -PINMUX_DATA (CTX1_MARK ,PJ23MD_101 ), +PINMUX_DATA (CTX1_PJ23_MARK ,PJ23MD_101 ), +PINMUX_DATA (CTX0_CTX1_PJ23_MARK ,PJ23MD_110 ),PINMUX_DATA (PJ22_DATA ,PJ22MD_000 ),PINMUX_DATA (DV_DATA22_MARK ,PJ22MD_001 ),PINMUX_DATA (LCD_DATA22_PJ22_MARK ,PJ22MD_010 ),PINMUX_DATA (LCD_TCON5_MARK ,PJ22MD_011 ),PINMUX_DATA (IRQ2_PJ_MARK ,PJ22MD_100 ), -PINMUX_DATA (CRX1_MARK ,PJ22MD_101 ), -PINMUX_DATA (CRX0_CRX1_MARK ,PJ22MD_110 ), +PINMUX_DATA (CRX1_PJ22_MARK ,PJ22MD_101 ), +PINMUX_DATA (CRX0_CRX1_PJ22_MARK ,PJ22MD_110 ),PINMUX_DATA (PJ21_DATA ,PJ21MD_000 ),PINMUX_DATA (DV_DATA21_MARK ,PJ21MD_001 ),PINMUX_DATA (LCD_DATA21_PJ21_MARK ,PJ21MD_010 ),PINMUX_DATA (LCD_TCON4_MARK ,PJ21MD_011 ),PINMUX_DATA (IRQ1_PJ_MARK ,PJ21MD_100 ), -PINMUX_DATA (CTX2_MARK ,PJ21MD_101 ), +PINMUX_DATA (CTX2_PJ21_MARK ,PJ21MD_101 ), +PINMUX_DATA (CTX0_CTX1_CTX2_PJ21_MARK ,PJ21MD_110 ),PINMUX_DATA (PJ20_DATA ,PJ20MD_000 ),PINMUX_DATA (DV_DATA20_MARK ,PJ20MD_001 ),PINMUX_DATA (LCD_DATA20_PJ20_MARK ,PJ20MD_010 ),PINMUX_DATA (LCD_TCON3_MARK ,PJ20MD_011 ),PINMUX_DATA (IRQ0_PJ_MARK ,PJ20MD_100 ), -PINMUX_DATA (CRX2_MARK ,PJ20MD_101 ), -PINMUX_DATA (CRX0CRX1CRX2_PJ20_MARK ,PJ20MD_110 ), +PINMUX_DATA (CRX2_PJ20_MARK ,PJ20MD_101 ), +PINMUX_DATA (CRX0_CRX1_CRX2_PJ20_MARK ,PJ20MD_110 ),PINMUX_DATA (PJ19_DATA ,PJ19MD_000 ), PINMUX_DATA(DV_DATA19_MARK, PJ19MD_001),
@@ -1666,12 +1669,24 @@ static const struct pinmux_func pinmux_func_gpios[] = {GPIO_FN (WDTOVF ),/* CAN */ +GPIO_FN (CTX2 ), +GPIO_FN (CRX2 ),GPIO_FN (CTX1 ),GPIO_FN (CRX1 ),GPIO_FN (CTX0 ),GPIO_FN (CRX0 ), +GPIO_FN (CTX0_CTX1 ),GPIO_FN (CRX0_CRX1 ), +GPIO_FN (CTX0_CTX1_CTX2 ),GPIO_FN (CRX0_CRX1_CRX2 ), +GPIO_FN (CTX2_PJ21 ), +GPIO_FN (CRX2_PJ20 ), +GPIO_FN (CTX1_PJ23 ), +GPIO_FN (CRX1_PJ22 ), +GPIO_FN (CTX0_CTX1_PJ23 ), +GPIO_FN (CRX0_CRX1_PJ22 ), +GPIO_FN (CTX0_CTX1_CTX2_PJ21 ), +GPIO_FN (CRX0_CRX1_CRX2_PJ20 ),/* DMAC */ GPIO_FN(TEND0),
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 65/165 RDMA/rxe: Fix error type of mmap_offset
In reply to Greg Kroah-HartmanFrom: Jiewei Ke <[email protected]>
[ Upstream commit 6ca18d8927d468c763571f78c9a7387a69ffa020 ]
The type of mmap_offset should be u64 instead of int to match the type of mminfo.offset. If otherwise, after we create several thousands of CQs, it will run into overflow issues.
--- drivers/infiniband/sw/rxe/rxe_verbs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_verbs.h +1 -1
@@ -422,7 +422,7 @@ struct rxe_dev {struct list_head pending_mmaps;spinlock_t mmap_offset_lock;/* guard mmap_offset */ -int mmap_offset; +u64 mmap_offset;struct rxe_port port;struct list_head list;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 66/165 ALSA: sh: Fix compile warning wrt const
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit f1dd4795b1523fbca7ab4344dd5a8bb439cc770d ]
A long-standing compile warning was seen during build test:
sound/sh/aica.c: In function 'load_aica_firmware':
sound/sh/aica.c:521:25: warning: passing argument 2 of 'spu_memload' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
--- sound/sh/aica.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/sh/aica.c +2 -2
@@ -117,10 +117,10 @@ static void spu_memset(u32 toi, u32 what, int length) }/* spu_memload - write to SPU address space */ -static void spu_memload (u32 toi,void *from,int length) +static void spu_memload (u32 toi,const void *from,int length) {unsigned long flags; -u32 *froml = from; +const u32 *froml = from;u32 __iomem *to = (u32 __iomem *) (SPU_MEMORY_BASE + toi);int i;u32 val;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 67/165 tools lib api fs: Fix gcc9 stringop-truncation compilation error
In reply to Greg Kroah-HartmanFrom: Andrey Zhizhikin <[email protected]>
[ Upstream commit 6794200fa3c9c3e6759dae099145f23e4310f4f7 ]
GCC9 introduced string hardening mechanisms, which exhibits the error during fs api compilation:
error: '__builtin_strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation]
This comes when the length of copy passed to strncpy is is equal to destination size, which could potentially lead to buffer overflow.
There is a need to mitigate this potential issue by limiting the size of destination by 1 and explicitly terminate the destination with NULL.
--- tools/lib/api/fs/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/api/fs/fs.c +3 -1
@@ -194,6 +194,7 @@ static bool fs__env_override(struct fs *fs)size_t name_len =strlen (fs->name);/* name + "_PATH" + '\0' */ char upper_name[name_len +5 +1 ]; +memcpy (upper_name, fs->name, name_len);mem_toupper (upper_name, name_len);strcpy (&upper_name[name_len],"_PATH" );
@@ -203,7 +204,8 @@ static bool fs__env_override(struct fs *fs)return false; fs->found = true; -strncpy (fs->path, override_path,sizeof (fs->path)); +strncpy (fs->path, override_path,sizeof (fs->path) -1 ); + fs->path[sizeof (fs->path) -1 ] ='\0' ;return true; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 68/165 usbip: Fix unsafe unaligned pointer usage
In reply to Greg Kroah-HartmanFrom: Shuah Khan <[email protected]>
[ Upstream commit 585c91f40d201bc564d4e76b83c05b3b5363fe7e ]
Fix unsafe unaligned pointer usage in usbip network interfaces. usbip tool build fails with new gcc -Werror=address-of-packed-member checks.
usbip_network.c: In function ‘usbip_net_pack_usb_device’:
usbip_network.c:79:32: error: taking address of packed member of ‘struct usbip_usb_device’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
79 | usbip_net_pack_uint32_t(pack, &udev->busnum);
Fix with minor changes to pass by value instead of by address.
--- tools/usb/usbip/src/usbip_network.c | 40 +++++++++++++++++------------ tools/usb/usbip/src/usbip_network.h | 12 +++------ 2 files changed, 27 insertions(+), 25 deletions(-)
tools/usb/usbip/src/usbip_network.c +24 -16
@@ -62,39 +62,39 @@ void usbip_setup_port_number(char *arg)info ("using port %d (\"%s\")" , usbip_port, usbip_port_string); } -void usbip_net_pack_uint32_t (int pack,uint32_t *num) +uint32_t usbip_net_pack_uint32_t (int pack,uint32_t num) {uint32_t i;if (pack) - i =htonl (*num); + i =htonl (num);else - i =ntohl (*num); + i =ntohl (num); - *num = i; +return i; } -void usbip_net_pack_uint16_t (int pack,uint16_t *num) +uint16_t usbip_net_pack_uint16_t (int pack,uint16_t num) {uint16_t i;if (pack) - i =htons (*num); + i =htons (num);else - i =ntohs (*num); + i =ntohs (num); - *num = i; +return i; }void usbip_net_pack_usb_device (int pack,struct usbip_usb_device *udev) { -usbip_net_pack_uint32_t (pack, &udev->busnum); -usbip_net_pack_uint32_t (pack, &udev->devnum); -usbip_net_pack_uint32_t (pack, &udev->speed); + udev->busnum =usbip_net_pack_uint32_t (pack, udev->busnum); + udev->devnum =usbip_net_pack_uint32_t (pack, udev->devnum); + udev->speed =usbip_net_pack_uint32_t (pack, udev->speed); -usbip_net_pack_uint16_t (pack, &udev->idVendor); -usbip_net_pack_uint16_t (pack, &udev->idProduct); -usbip_net_pack_uint16_t (pack, &udev->bcdDevice); + udev->idVendor =usbip_net_pack_uint16_t (pack, udev->idVendor); + udev->idProduct =usbip_net_pack_uint16_t (pack, udev->idProduct); + udev->bcdDevice =usbip_net_pack_uint16_t (pack, udev->bcdDevice); } void usbip_net_pack_usb_interface(int pack __attribute__((unused)),
@@ -141,6 +141,14 @@ ssize_t usbip_net_send(int sockfd, void *buff, size_t bufflen)return usbip_net_xmit (sockfd, buff, bufflen,1 ); } +static inline void usbip_net_pack_op_common (int pack, +struct op_common *op_common) +{ + op_common->version =usbip_net_pack_uint16_t (pack, op_common->version); + op_common->code =usbip_net_pack_uint16_t (pack, op_common->code); + op_common->status =usbip_net_pack_uint32_t (pack, op_common->status); +} +int usbip_net_send_op_common (int sockfd,uint32_t code,uint32_t status) {struct op_common op_common;
@@ -152,7 +160,7 @@ int usbip_net_send_op_common(int sockfd, uint32_t code, uint32_t status) op_common.code = code; op_common.status = status; -PACK_OP_COMMON (1 , &op_common); +usbip_net_pack_op_common (1 , &op_common); rc =usbip_net_send (sockfd, &op_common,sizeof (op_common));if (rc <0 ) {
@@ -176,7 +184,7 @@ int usbip_net_recv_op_common(int sockfd, uint16_t *code) goto err; } -PACK_OP_COMMON (0 , &op_common); +usbip_net_pack_op_common (0 , &op_common);if (op_common.version !=USBIP_VERSION ) { dbg("version mismatch: %d %d", op_common.version,
tools/usb/usbip/src/usbip_network.h +3 -9
@@ -33,12 +33,6 @@ struct op_common { } __attribute__((packed)); -#define PACK_OP_COMMON (pack, op_common) do {\ - usbip_net_pack_uint16_t(pack, &(op_common)->version);\ - usbip_net_pack_uint16_t(pack, &(op_common)->code);\ - usbip_net_pack_uint32_t(pack, &(op_common)->status);\ -} while (0) -/* ---------------------------------------------------------------------- */ /* Dummy Code */ #define OP_UNSPEC 0x00
@@ -164,11 +158,11 @@ struct op_devlist_reply_extra { } while (0)#define PACK_OP_DEVLIST_REPLY (pack, reply) do {\ - usbip_net_pack_uint32_t(pack, &(reply)->ndev);\ + (reply)->ndev = usbip_net_pack_uint32_t(pack, (reply)->ndev);\ } while (0) -void usbip_net_pack_uint32_t (int pack,uint32_t *num); -void usbip_net_pack_uint16_t (int pack,uint16_t *num); +uint32_t usbip_net_pack_uint32_t (int pack,uint32_t num); +uint16_t usbip_net_pack_uint16_t (int pack,uint16_t num);void usbip_net_pack_usb_device (int pack,struct usbip_usb_device *udev);void usbip_net_pack_usb_interface (int pack,struct usbip_usb_interface *uinf);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 69/165 udf: Fix free space reporting for metadata and virtual partitions
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit a4a8b99ec819ca60b49dc582a4287ef03411f117 ]
Free space on filesystems with metadata or virtual partition maps currently gets misreported. This is because these partitions are just remapped onto underlying real partitions from which keep track of free blocks. Take this remapping into account when counting free blocks as well.
--- fs/udf/super.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
fs/udf/super.c +17 -5
@@ -2460,17 +2460,29 @@ static unsigned int udf_count_free_table(struct super_block *sb,static unsigned int udf_count_free (struct super_block *sb) {unsigned int accum =0 ; -struct udf_sb_info *sbi; +struct udf_sb_info *sbi =UDF_SB (sb);struct udf_part_map *map; +unsigned int part = sbi->s_partition; +int ptype = sbi->s_partmaps[part].s_partition_type; + +if (ptype ==UDF_METADATA_MAP25 ) { + part = sbi->s_partmaps[part].s_type_specific.s_metadata. + s_phys_partition_ref; + }else if (ptype ==UDF_VIRTUAL_MAP15 || ptype ==UDF_VIRTUAL_MAP20 ) { +/* +* Filesystems with VAT are append-only and we cannot write to +* them. Let's just report 0 here. +*/ +return 0 ; + } - sbi =UDF_SB (sb);if (sbi->s_lvid_bh) {struct logicalVolIntegrityDesc *lvid = (struct logicalVolIntegrityDesc *) sbi->s_lvid_bh->b_data; -if (le32_to_cpu (lvid->numOfPartitions) > sbi->s_partition) { +if (le32_to_cpu (lvid->numOfPartitions) > part) { accum =le32_to_cpu ( - lvid->freeSpaceTable[sbi->s_partition]); + lvid->freeSpaceTable[part]);if (accum ==0xFFFFFFFF ) accum =0 ; }
@@ -2479,7 +2491,7 @@ static unsigned int udf_count_free(struct super_block *sb)if (accum)return accum; - map = &sbi->s_partmaps[sbi->s_partition]; + map = &sbi->s_partmaps[part];if (map->s_partition_flags &UDF_PART_FLAG_UNALLOC_BITMAP ) { accum +=udf_count_free_bitmap (sb, map->s_uspace.s_bitmap);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 70/165 soc/tegra: fuse: Correct straps address for older Tegra124 device trees
In reply to Greg Kroah-HartmanFrom: Dmitry Osipenko <[email protected]>
[ Upstream commit 2d9ea1934f8ef0dfb862d103389562cc28b4fc03 ]
Trying to read out Chip ID before APBMISC registers are mapped won't succeed, in a result Tegra124 gets a wrong address for the HW straps register if machine uses an old outdated device tree.
--- drivers/soc/tegra/fuse/tegra-apbmisc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/fuse/tegra-apbmisc.c +1 -1
@@ -134,7 +134,7 @@ void __init tegra_init_apbmisc(void) apbmisc.flags =IORESOURCE_MEM ;/* strapping options */ -if (tegra_get_chip_id () ==TEGRA124 ) { +if (of_machine_is_compatible ("nvidia,tegra124" )) { straps.start =0x7000e864 ; straps.end =0x7000e867 ; }else {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 71/165 rcu: Use WRITE_ONCE() for assignments to ->pprev for hlist_nulls
In reply to Greg Kroah-HartmanFrom: Paul E. McKenney <[email protected]>
[ Upstream commit 860c8802ace14c646864795e057349c9fb2d60ad ]
Eric Dumazet supplied a KCSAN report of a bug that forces use of hlist_unhashed_lockless() from sk_unhashed():
------------------------------------------------------------------------
BUG: KCSAN: data-race in inet_unhash / inet_unhash
write to 0xffff8880a69a0170 of 8 bytes by interrupt on cpu 1:
__hlist_nulls_del include/linux/list_nulls.h:88 [inline] hlist_nulls_del_init_rcu include/linux/rculist_nulls.h:36 [inline] __sk_nulls_del_node_init_rcu include/net/sock.h:676 [inline] inet_unhash+0x38f/0x4a0 net/ipv4/inet_hashtables.c:612 tcp_set_state+0xfa/0x3e0 net/ipv4/tcp.c:2249 tcp_done+0x93/0x1e0 net/ipv4/tcp.c:3854 tcp_write_err+0x7e/0xc0 net/ipv4/tcp_timer.c:56 tcp_retransmit_timer+0x9b8/0x16d0 net/ipv4/tcp_timer.c:479 tcp_write_timer_handler+0x42d/0x510 net/ipv4/tcp_timer.c:599 tcp_write_timer+0xd1/0xf0 net/ipv4/tcp_timer.c:619 call_timer_fn+0x5f/0x2f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0xc0c/0xcd0 kernel/time/timer.c:1786 __do_softirq+0x115/0x33f kernel/softirq.c:292 invoke_softirq kernel/softirq.c:373 [inline] irq_exit+0xbb/0xe0 kernel/softirq.c:413 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0xe6/0x280 arch/x86/kernel/apic/apic.c:1137 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:830 native_safe_halt+0xe/0x10 arch/x86/kernel/paravirt.c:71 arch_cpu_idle+0x1f/0x30 arch/x86/kernel/process.c:571 default_idle_call+0x1e/0x40 kernel/sched/idle.c:94 cpuidle_idle_call kernel/sched/idle.c:154 [inline] do_idle+0x1af/0x280 kernel/sched/idle.c:263 cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:355 start_secondary+0x208/0x260 arch/x86/kernel/smpboot.c:264 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:241
read to 0xffff8880a69a0170 of 8 bytes by interrupt on cpu 0:
sk_unhashed include/net/sock.h:607 [inline] inet_unhash+0x3d/0x4a0 net/ipv4/inet_hashtables.c:592 tcp_set_state+0xfa/0x3e0 net/ipv4/tcp.c:2249 tcp_done+0x93/0x1e0 net/ipv4/tcp.c:3854 tcp_write_err+0x7e/0xc0 net/ipv4/tcp_timer.c:56 tcp_retransmit_timer+0x9b8/0x16d0 net/ipv4/tcp_timer.c:479 tcp_write_timer_handler+0x42d/0x510 net/ipv4/tcp_timer.c:599 tcp_write_timer+0xd1/0xf0 net/ipv4/tcp_timer.c:619 call_timer_fn+0x5f/0x2f0 kernel/time/timer.c:1404 expire_timers kernel/time/timer.c:1449 [inline] __run_timers kernel/time/timer.c:1773 [inline] __run_timers kernel/time/timer.c:1740 [inline] run_timer_softirq+0xc0c/0xcd0 kernel/time/timer.c:1786 __do_softirq+0x115/0x33f kernel/softirq.c:292 invoke_softirq kernel/softirq.c:373 [inline] irq_exit+0xbb/0xe0 kernel/softirq.c:413 exiting_irq arch/x86/include/asm/apic.h:536 [inline] smp_apic_timer_interrupt+0xe6/0x280 arch/x86/kernel/apic/apic.c:1137 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:830 native_safe_halt+0xe/0x10 arch/x86/kernel/paravirt.c:71 arch_cpu_idle+0x1f/0x30 arch/x86/kernel/process.c:571 default_idle_call+0x1e/0x40 kernel/sched/idle.c:94 cpuidle_idle_call kernel/sched/idle.c:154 [inline] do_idle+0x1af/0x280 kernel/sched/idle.c:263 cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:355 rest_init+0xec/0xf6 init/main.c:452 arch_call_rest_init+0x17/0x37 start_kernel+0x838/0x85e init/main.c:786 x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:490 x86_64_start_kernel+0x72/0x76 arch/x86/kernel/head64.c:471 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:241
Reported by Kernel Concurrency Sanitizer on:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.0-rc6+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine,
BIOS Google 01/01/2011
------------------------------------------------------------------------
This commit therefore replaces C-language assignments with WRITE_ONCE() in include/linux/list_nulls.h and include/linux/rculist_nulls.h.
--- include/linux/list_nulls.h | 8 ++++---- include/linux/rculist_nulls.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
include/linux/list_nulls.h +4 -4
@@ -71,10 +71,10 @@ static inline void hlist_nulls_add_head(struct hlist_nulls_node *n,struct hlist_nulls_node *first = h->first; n->next = first; - n->pprev = &h->first; +WRITE_ONCE (n->pprev, &h->first); h->first = n;if (!is_a_nulls (first)) - first->pprev = &n->next; +WRITE_ONCE (first->pprev, &n->next); }static inline void __hlist_nulls_del (struct hlist_nulls_node *n)
@@ -84,13 +84,13 @@ static inline void __hlist_nulls_del(struct hlist_nulls_node *n)WRITE_ONCE (*pprev, next);if (!is_a_nulls (next)) - next->pprev = pprev; +WRITE_ONCE (next->pprev, pprev); }static inline void hlist_nulls_del (struct hlist_nulls_node *n) {__hlist_nulls_del (n); - n->pprev =LIST_POISON2 ; +WRITE_ONCE (n->pprev,LIST_POISON2 ); }/**
include/linux/rculist_nulls.h +4 -4
@@ -33,7 +33,7 @@ static inline void hlist_nulls_del_init_rcu(struct hlist_nulls_node *n) {if (!hlist_nulls_unhashed (n)) {__hlist_nulls_del (n); - n->pprev =NULL ; +WRITE_ONCE (n->pprev,NULL ); } }
@@ -65,7 +65,7 @@ static inline void hlist_nulls_del_init_rcu(struct hlist_nulls_node *n)static inline void hlist_nulls_del_rcu (struct hlist_nulls_node *n) {__hlist_nulls_del (n); - n->pprev =LIST_POISON2 ; +WRITE_ONCE (n->pprev,LIST_POISON2 ); }/**
@@ -93,10 +93,10 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,struct hlist_nulls_node *first = h->first; n->next = first; - n->pprev = &h->first; +WRITE_ONCE (n->pprev, &h->first);rcu_assign_pointer (hlist_nulls_first_rcu (h), n);if (!is_a_nulls (first)) - first->pprev = &n->next; +WRITE_ONCE (first->pprev, &n->next); }/**
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 72/165 Input: edt-ft5x06 - work around first register access error
In reply to Greg Kroah-HartmanFrom: Philipp Zabel <[email protected]>
[ Upstream commit e112324cc0422c046f1cf54c56f333d34fa20885 ]
The EP0700MLP1 returns bogus data on the first register read access (reading the threshold parameter from register 0x00):
edt_ft5x06 2-0038: crc error: 0xfc expected, got 0x40
It ignores writes until then. This patch adds a dummy read after which the number of sensors and parameter read/writes work correctly.
--- drivers/input/touchscreen/edt-ft5x06.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/touchscreen/edt-ft5x06.c +7 -0
@@ -887,6 +887,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, {const struct edt_i2c_chip_data *chip_data;struct edt_ft5x06_ts_data *tsdata; +u8 buf[2 ] = {0xfc ,0x00 };struct input_dev *input;unsigned long irq_flags;int error;
@@ -956,6 +957,12 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,return error; } +/* +* Dummy read access. EP0700MLP1 returns bogus data on the first +* register read access and ignores writes. +*/ +edt_ft5x06_ts_readwrite (tsdata->client,2 , buf,2 , buf); +edt_ft5x06_ts_set_regs (tsdata);edt_ft5x06_ts_get_defaults (&client->dev, tsdata);edt_ft5x06_ts_get_parameters (tsdata);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 73/165 wan: ixp4xx_hss: fix compile-testing on 64-bit
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 504c28c853ec5c626900b914b5833daf0581a344 ]
Change the driver to use portable integer types to avoid warnings during compile testing:
drivers/net/wan/ixp4xx_hss.c:863:21: error: cast to 'u32 *' (aka 'unsigned int *') from smaller integer type 'int' [-Werror,-Wint-to-pointer-cast]
memcpy_swab32(mem, (u32 *)((int)skb->data & ~3), bytes / 4);
^
drivers/net/wan/ixp4xx_hss.c:979:12: error: incompatible pointer types passing 'u32 *' (aka 'unsigned int *') to parameter of type 'dma_addr_t *' (aka 'unsigned long long *') [-Werror,-Wincompatible-pointer-types]
&port->desc_tab_phys)))
^~~~~~~~~~~~~~~~~~~~
include/linux/dmapool.h:27:20: note: passing argument to parameter 'handle' here
dma_addr_t *handle);
^--- drivers/net/wan/ixp4xx_hss.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wan/ixp4xx_hss.c +2 -2
@@ -261,7 +261,7 @@ struct port {struct hss_plat_info *plat;buffer_t *rx_buff_tab[RX_DESCS ], *tx_buff_tab[TX_DESCS ];struct desc *desc_tab;/* coherent */ -u32 desc_tab_phys; +dma_addr_t desc_tab_phys;unsigned int id;unsigned int clock_type, clock_rate, loopback;unsigned int initialized, carrier;
@@ -861,7 +861,7 @@ static int hss_hdlc_xmit(struct sk_buff *skb, struct net_device *dev) dev->stats.tx_dropped++; return NETDEV_TX_OK; } -memcpy_swab32 (mem, (u32 *)((int )skb->data & ~3 ), bytes /4 ); +memcpy_swab32 (mem, (u32 *)((uintptr_t )skb->data & ~3 ), bytes /4 );dev_kfree_skb (skb);#endif
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 74/165 ASoC: atmel: fix build error with CONFIG_SND_ATMEL_SOC_DMA=m
In reply to Greg Kroah-HartmanFrom: Chen Zhou <[email protected]>
[ Upstream commit 8fea78029f5e6ed734ae1957bef23cfda1af4354 ]
If CONFIG_SND_ATMEL_SOC_DMA=m, build error:
sound/soc/atmel/atmel_ssc_dai.o: In function `atmel_ssc_set_audio':
(.text+0x7cd): undefined reference to `atmel_pcm_dma_platform_register'
Function atmel_pcm_dma_platform_register is defined under CONFIG SND_ATMEL_SOC_DMA, so select SND_ATMEL_SOC_DMA in CONFIG SND_ATMEL_SOC_SSC, same to CONFIG_SND_ATMEL_SOC_PDC.
--- sound/soc/atmel/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/atmel/Kconfig +2 -0
@@ -25,6 +25,8 @@ config SND_ATMEL_SOC_DMA config SND_ATMEL_SOC_SSC_DMA tristate + select SND_ATMEL_SOC_DMA + select SND_ATMEL_SOC_PDC config SND_ATMEL_SOC_SSC tristate
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 75/165 tty: synclinkmp: Adjust indentation in several functions
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 1feedf61e7265128244f6993f23421f33dd93dbc ]
Clang warns:
../drivers/tty/synclinkmp.c:1456:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (C_CRTSCTS(tty)) {
^
../drivers/tty/synclinkmp.c:1453:2: note: previous statement is here
if (I_IXOFF(tty))
^
../drivers/tty/synclinkmp.c:2473:8: warning: misleading indentation;
statement is not part of the previous 'if' [-Wmisleading-indentation]
info->port.tty->hw_stopped = 0;
^../drivers/tty/synclinkmp.c:2471:7: note: previous statement is here
if ( debug_level >= DEBUG_LEVEL_ISR ) ^../drivers/tty/synclinkmp.c:2482:8: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
info->port.tty->hw_stopped = 1;
^../drivers/tty/synclinkmp.c:2480:7: note: previous statement is here
if ( debug_level >= DEBUG_LEVEL_ISR ) ^../drivers/tty/synclinkmp.c:2809:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
^
../drivers/tty/synclinkmp.c:2807:2: note: previous statement is here
if (I_INPCK(info->port.tty))
^
../drivers/tty/synclinkmp.c:3246:3: warning: misleading indentation;
statement is not part of the previous 'else' [-Wmisleading-indentation]
set_signals(info);
^
../drivers/tty/synclinkmp.c:3244:2: note: previous statement is here
else
^5 warnings generated.
The indentation on these lines is not at all consistent, tabs and spaces are mixed together. Convert to just using tabs to be consistent with the Linux kernel coding style and eliminate these warnings from clang.
--- drivers/tty/synclinkmp.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/tty/synclinkmp.c +12 -12
@@ -1467,10 +1467,10 @@ static void throttle(struct tty_struct * tty)if (I_IXOFF (tty))send_xchar (tty,STOP_CHAR (tty)); -if (C_CRTSCTS (tty)) { +if (C_CRTSCTS (tty)) {spin_lock_irqsave (&info->lock,flags); info->serial_signals &= ~SerialSignal_RTS; -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags); } }
@@ -1496,10 +1496,10 @@ static void unthrottle(struct tty_struct * tty)send_xchar (tty,START_CHAR (tty)); } -if (C_CRTSCTS (tty)) { +if (C_CRTSCTS (tty)) {spin_lock_irqsave (&info->lock,flags); info->serial_signals |= SerialSignal_RTS; -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags); } }
@@ -2485,7 +2485,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )if (status & SerialSignal_CTS) {if ( debug_level >=DEBUG_LEVEL_ISR )printk ("CTS tx start..." ); - info->port.tty->hw_stopped =0 ; + info->port.tty->hw_stopped =0 ;tx_start (info); info->pending_bh |=BH_TRANSMIT ;return ;
@@ -2494,7 +2494,7 @@ static void isr_io_pin( SLMP_INFO *info, u16 status )if (!(status & SerialSignal_CTS)) {if ( debug_level >=DEBUG_LEVEL_ISR )printk ("CTS tx stop..." ); - info->port.tty->hw_stopped =1 ; + info->port.tty->hw_stopped =1 ;tx_stop (info); } }
@@ -2821,8 +2821,8 @@ static void change_params(SLMP_INFO *info) info->read_status_mask2 =OVRN ;if (I_INPCK (info->port.tty)) info->read_status_mask2 |=PE |FRME ; -if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) - info->read_status_mask1 |=BRKD ; +if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) + info->read_status_mask1 |=BRKD ;if (I_IGNPAR (info->port.tty)) info->ignore_status_mask2 |=PE |FRME ;if (I_IGNBRK (info->port.tty)) {
@@ -3192,7 +3192,7 @@ static int tiocmget(struct tty_struct *tty)unsigned long flags;spin_lock_irqsave (&info->lock,flags); -get_signals (info); +get_signals (info);spin_unlock_irqrestore (&info->lock,flags); result = ((info->serial_signals & SerialSignal_RTS) ? TIOCM_RTS : 0) |
@@ -3230,7 +3230,7 @@ static int tiocmset(struct tty_struct *tty, info->serial_signals &= ~SerialSignal_DTR;spin_lock_irqsave (&info->lock,flags); -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags);return 0 ;
@@ -3242,7 +3242,7 @@ static int carrier_raised(struct tty_port *port)unsigned long flags;spin_lock_irqsave (&info->lock,flags); -get_signals (info); +get_signals (info);spin_unlock_irqrestore (&info->lock,flags);return (info->serial_signals & SerialSignal_DCD) ?1 :0 ;
@@ -3258,7 +3258,7 @@ static void dtr_rts(struct tty_port *port, int on) info->serial_signals |= SerialSignal_RTS | SerialSignal_DTR; else info->serial_signals &= ~(SerialSignal_RTS | SerialSignal_DTR); -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 76/165 tty: synclink_gt: Adjust indentation in several functions
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 446e76873b5e4e70bdee5db2f2a894d5b4a7d081 ]
Clang warns:
../drivers/tty/synclink_gt.c:1337:3: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (C_CRTSCTS(tty)) {
^
../drivers/tty/synclink_gt.c:1335:2: note: previous statement is here
if (I_IXOFF(tty))
^
../drivers/tty/synclink_gt.c:2563:3: warning: misleading indentation;
statement is not part of the previous 'if' [-Wmisleading-indentation]
if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
^
../drivers/tty/synclink_gt.c:2561:2: note: previous statement is here
if (I_INPCK(info->port.tty))
^
../drivers/tty/synclink_gt.c:3221:3: warning: misleading indentation;
statement is not part of the previous 'else' [-Wmisleading-indentation]
set_signals(info);
^
../drivers/tty/synclink_gt.c:3219:2: note: previous statement is here
else
^3 warnings generated.
The indentation on these lines is not at all consistent, tabs and spaces are mixed together. Convert to just using tabs to be consistent with the Linux kernel coding style and eliminate these warnings from clang.
--- drivers/tty/synclink_gt.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/tty/synclink_gt.c +9 -9
@@ -1349,10 +1349,10 @@ static void throttle(struct tty_struct * tty)DBGINFO (("%s throttle\n" , info->device_name));if (I_IXOFF (tty))send_xchar (tty,STOP_CHAR (tty)); -if (C_CRTSCTS (tty)) { +if (C_CRTSCTS (tty)) {spin_lock_irqsave (&info->lock,flags); info->signals &= ~SerialSignal_RTS; -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags); } }
@@ -1374,10 +1374,10 @@ static void unthrottle(struct tty_struct * tty)else send_xchar (tty,START_CHAR (tty)); } -if (C_CRTSCTS (tty)) { +if (C_CRTSCTS (tty)) {spin_lock_irqsave (&info->lock,flags); info->signals |= SerialSignal_RTS; -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags); } }
@@ -2576,8 +2576,8 @@ static void change_params(struct slgt_info *info) info->read_status_mask =IRQ_RXOVER ;if (I_INPCK (info->port.tty)) info->read_status_mask |=MASK_PARITY |MASK_FRAMING ; -if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) - info->read_status_mask |=MASK_BREAK ; +if (I_BRKINT (info->port.tty) ||I_PARMRK (info->port.tty)) + info->read_status_mask |=MASK_BREAK ;if (I_IGNPAR (info->port.tty)) info->ignore_status_mask |=MASK_PARITY |MASK_FRAMING ;if (I_IGNBRK (info->port.tty)) {
@@ -3208,7 +3208,7 @@ static int tiocmset(struct tty_struct *tty, info->signals &= ~SerialSignal_DTR;spin_lock_irqsave (&info->lock,flags); -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags);return 0 ; }
@@ -3219,7 +3219,7 @@ static int carrier_raised(struct tty_port *port) struct slgt_info *info = container_of(port, struct slgt_info, port);spin_lock_irqsave (&info->lock,flags); -get_signals (info); +get_signals (info);spin_unlock_irqrestore (&info->lock,flags);return (info->signals & SerialSignal_DCD) ?1 :0 ; }
@@ -3234,7 +3234,7 @@ static void dtr_rts(struct tty_port *port, int on) info->signals |= SerialSignal_RTS | SerialSignal_DTR; else info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR); -set_signals (info); +set_signals (info);spin_unlock_irqrestore (&info->lock,flags); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 77/165 driver core: platform: Prevent resouce overflow from causing infinite loops
In reply to Greg Kroah-HartmanFrom: Simon Schwartz <[email protected]>
[ Upstream commit 39cc539f90d035a293240c9443af50be55ee81b8 ]
num_resources in the platform_device struct is declared as a u32. The for loops that iterate over num_resources use an int as the counter, which can cause infinite loops on architectures with smaller ints. Change the loop counters to u32.
--- drivers/base/platform.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/base/platform.c +6 -4
@@ -28,6 +28,7 @@#include <linux/limits.h> #include <linux/property.h> #include <linux/kmemleak.h> +#include <linux/types.h> #include "base.h" #include "power/power.h"
@@ -68,7 +69,7 @@ void __weak arch_setup_pdev_archdata(struct platform_device *pdev)struct resource *platform_get_resource (struct platform_device *dev,unsigned int type,unsigned int num) { -int i; +u32 i;for (i =0 ; i < dev->num_resources; i++) {struct resource *r = &dev->resource[i];
@@ -153,7 +154,7 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,unsigned int type, const char *name) { - int i; + u32 i;for (i =0 ; i < dev->num_resources; i++) {struct resource *r = &dev->resource[i];
@@ -350,7 +351,8 @@ EXPORT_SYMBOL_GPL(platform_device_add_properties);*/ int platform_device_add (struct platform_device *pdev) { -int i, ret; +u32 i; +int ret;if (!pdev)return -EINVAL ;
@@ -437,7 +439,7 @@ EXPORT_SYMBOL_GPL(platform_device_add);*/ void platform_device_del (struct platform_device *pdev) { -int i; +u32 i;if (pdev) {device_remove_properties (&pdev->dev);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 78/165 driver core: Print device when resources present in really_probe()
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit 7c35e699c88bd60734277b26962783c60e04b494 ]
If a device already has devres items attached before probing, a warning backtrace is printed. However, this backtrace does not reveal the offending device, leaving the user uninformed. Furthermore, using WARN_ON() causes systems with panic-on-warn to reboot.
Fix this by replacing the WARN_ON() by a dev_crit() message. Abort probing the device, to prevent doing more damage to the device's resources.
--- drivers/base/dd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/base/dd.c +4 -1
@@ -341,7 +341,10 @@ static int really_probe(struct device *dev, struct device_driver *drv)atomic_inc (&probe_count);pr_debug ("bus: '%s': %s: probing driver %s with device %s\n" , drv->bus->name, __func__, drv->name,dev_name (dev)); -WARN_ON (!list_empty (&dev->devres_head)); +if (!list_empty (&dev->devres_head)) { +dev_crit (dev,"Resources present before probing\n" ); +return -EBUSY ; + } re_probe: dev->driver = drv;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 79/165 vme: bridges: reduce stack usage
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 7483e7a939c074d887450ef1c4d9ccc5909405f8 ]
With CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, the stack usage in vme_fake grows above the warning limit:
drivers/vme/bridges/vme_fake.c: In function 'fake_master_read':drivers/vme/bridges/vme_fake.c:610:1: error: the frame size of 1160 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/vme/bridges/vme_fake.c: In function 'fake_master_write':drivers/vme/bridges/vme_fake.c:797:1: error: the frame size of 1160 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
The problem is that in some configurations, each call to fake_vmereadX() puts another variable on the stack.
Reduce the amount of inlining to get back to the previous state, with no function using more than 200 bytes each.
--- drivers/vme/bridges/vme_fake.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/vme/bridges/vme_fake.c +18 -12
@@ -418,8 +418,9 @@ static void fake_lm_check(struct fake_driver *bridge, unsigned long long addr, } } -static u8 fake_vmeread8 (struct fake_driver *bridge,unsigned long long addr, -u32 aspace,u32 cycle) +static noinline_for_stack u8 fake_vmeread8(struct fake_driver *bridge, +unsigned long long addr, +u32 aspace,u32 cycle) {u8 retval =0xff ;int i;
@@ -450,8 +451,9 @@ static u8 fake_vmeread8(struct fake_driver *bridge, unsigned long long addr,return retval; } -static u16 fake_vmeread16 (struct fake_driver *bridge,unsigned long long addr, -u32 aspace,u32 cycle) +static noinline_for_stack u16 fake_vmeread16(struct fake_driver *bridge, +unsigned long long addr, +u32 aspace,u32 cycle) {u16 retval =0xffff ;int i;
@@ -482,8 +484,9 @@ static u16 fake_vmeread16(struct fake_driver *bridge, unsigned long long addr,return retval; } -static u32 fake_vmeread32 (struct fake_driver *bridge,unsigned long long addr, -u32 aspace,u32 cycle) +static noinline_for_stack u32 fake_vmeread32(struct fake_driver *bridge, +unsigned long long addr, +u32 aspace,u32 cycle) {u32 retval =0xffffffff ;int i;
@@ -613,8 +616,9 @@ out:return retval; } -static void fake_vmewrite8 (struct fake_driver *bridge,u8 *buf, -unsigned long long addr,u32 aspace,u32 cycle) +static noinline_for_stack void fake_vmewrite8(struct fake_driver *bridge, +u8 *buf,unsigned long long addr, +u32 aspace,u32 cycle) {int i;unsigned long long start, end, offset;
@@ -643,8 +647,9 @@ static void fake_vmewrite8(struct fake_driver *bridge, u8 *buf, } -static void fake_vmewrite16 (struct fake_driver *bridge,u16 *buf, -unsigned long long addr,u32 aspace,u32 cycle) +static noinline_for_stack void fake_vmewrite16(struct fake_driver *bridge, +u16 *buf,unsigned long long addr, +u32 aspace,u32 cycle) {int i;unsigned long long start, end, offset;
@@ -673,8 +678,9 @@ static void fake_vmewrite16(struct fake_driver *bridge, u16 *buf, } -static void fake_vmewrite32 (struct fake_driver *bridge,u32 *buf, -unsigned long long addr,u32 aspace,u32 cycle) +static noinline_for_stack void fake_vmewrite32(struct fake_driver *bridge, +u32 *buf,unsigned long long addr, +u32 aspace,u32 cycle) {int i;unsigned long long start, end, offset;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 80/165 drm/nouveau/gr/gk20a,gm200-: add terminators to method lists read from fw
In reply to Greg Kroah-HartmanFrom: Ben Skeggs <[email protected]>
[ Upstream commit 7adc77aa0e11f25b0e762859219c70852cd8d56f ]
Method init is typically ordered by class in the FW image as ThreeD, TwoD, Compute.
Due to a bug in parsing the FW into our internal format, we've been accidentally sending Twod + Compute methods to the ThreeD class, as well as Compute methods to the TwoD class - oops.
--- .../gpu/drm/nouveau/nvkm/engine/gr/gk20a.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/nouveau/nvkm/engine/gr/gk20a.c +11 -10
@@ -143,23 +143,24 @@ gk20a_gr_av_to_method(struct gf100_gr *gr, const char *fw_name, nent = (fuc.size /sizeof (struct gk20a_fw_av )); - pack =vzalloc ((sizeof (*pack) * max_classes) + - (sizeof (*init) * (nent +1 ))); + pack =vzalloc ((sizeof (*pack) * (max_classes +1 )) + + (sizeof (*init) * (nent + max_classes +1 )));if (!pack) { ret = -ENOMEM ; goto end; } - init = (void *)(pack + max_classes); + init = (void *)(pack + max_classes +1 ); -for (i =0 ; i < nent; i++) { -struct gf100_gr_init *ent = &init[i]; +for (i =0 ; i < nent; i++, init++) {struct gk20a_fw_av *av = &((struct gk20a_fw_av *)fuc.data)[i];u32 class = av->addr &0xffff ;u32 addr = (av->addr &0xffff0000 ) >>14 ;if (prevclass != class) { - pack[classidx].init = ent; +if (prevclass)/* Add terminator to the method list. */ + init++; + pack[classidx].init = init; pack[classidx].type = class; prevclass = class;if (++classidx >= max_classes) {
@@ -169,10 +170,10 @@ gk20a_gr_av_to_method(struct gf100_gr *gr, const char *fw_name, } } - ent->addr = addr; - ent->data = av->data; - ent->count =1 ; - ent->pitch =1 ; + init->addr = addr; + init->data = av->data; + init->count =1 ; + init->pitch =1 ; } *ppack = pack;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 81/165 drm/nouveau: Fix copy-paste error in nouveau_fence_wait_uevent_handler
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit 1eb013473bff5f95b6fe1ca4dd7deda47257b9c2 ]
Like other cases, it should use rcu protected 'chan' rather than 'fence->channel' in nouveau_fence_wait_uevent_handler.
--- drivers/gpu/drm/nouveau/nouveau_fence.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_fence.c +1 -1
@@ -158,7 +158,7 @@ nouveau_fence_wait_uevent_handler(struct nvif_notify *notify) fence =list_entry (fctx->pending.next,typeof (*fence), head); chan =rcu_dereference_protected (fence->channel,lockdep_is_held (&fctx->lock)); -if (nouveau_fence_update (fence->channel, fctx)) +if (nouveau_fence_update (chan, fctx)) ret =NVIF_NOTIFY_DROP ; }spin_unlock_irqrestore (&fctx->lock, flags);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 82/165 drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add
In reply to Greg Kroah-HartmanFrom: Navid Emamdoost <[email protected]>
[ Upstream commit 40efb09a7f53125719e49864da008495e39aaa1e ]
In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory for cres should be released.
--- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +3 -1
@@ -210,8 +210,10 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man, cres->hash.key = user_key | (res_type <<24 ); ret =drm_ht_insert_item (&man->resources, &cres->hash); -if (unlikely (ret !=0 )) +if (unlikely (ret !=0 )) { +kfree (cres); goto out_invalid_key; + } cres->state =VMW_CMDBUF_RES_ADD ; cres->res =vmw_resource_reference (res);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 83/165 usb: musb: omap2430: Get rid of musb .set_vbus for omap2430 glue
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 91b6dec32e5c25fbdbb564d1e5af23764ec17ef1 ]
We currently have musb_set_vbus() called from two different paths. Mostly it gets called from the USB PHY via omap_musb_set_mailbox(), but in some cases it can get also called from musb_stage0_irq() rather via .set_vbus:
(musb_set_host [musb_hdrc])
(omap2430_musb_set_vbus [omap2430])
(musb_stage0_irq [musb_hdrc])
(musb_interrupt [musb_hdrc])
(omap2430_musb_interrupt [omap2430])
This is racy and will not work with introducing generic helper functions for musb_set_host() and musb_set_peripheral(). We want to get rid of the busy loops in favor of usleep_range().
Let's just get rid of .set_vbus for omap2430 glue layer and let the PHY code handle VBUS with musb_set_vbus(). Note that in the follow-up patch we can completely remove omap2430_musb_set_vbus(), but let's do it in a separate patch as this change may actually turn out to be needed as a fix.
--- drivers/usb/musb/omap2430.c | 2 -- 1 file changed, 2 deletions(-)
drivers/usb/musb/omap2430.c +0 -2
@@ -388,8 +388,6 @@ static const struct musb_platform_ops omap2430_ops = { .init = omap2430_musb_init, .exit = omap2430_musb_exit, - .set_vbus = omap2430_musb_set_vbus, - .enable = omap2430_musb_enable, .disable = omap2430_musb_disable,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 84/165 iommu/arm-smmu-v3: Use WRITE_ONCE() when changing validity of an STE
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
[ Upstream commit d71e01716b3606a6648df7e5646ae12c75babde4 ]
If, for some bizarre reason, the compiler decided to split up the write of STE DWORD 0, we could end up making a partial structure valid.
Although this probably won't happen, follow the example of the context-descriptor code and use WRITE_ONCE() to ensure atomicity of the write.
--- drivers/iommu/arm-smmu-v3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/arm-smmu-v3.c +2 -1
@@ -1103,7 +1103,8 @@ static void arm_smmu_write_strtab_ent(struct arm_smmu_device *smmu, u32 sid, }arm_smmu_sync_ste_for_sid (smmu, sid); - dst[0 ] =cpu_to_le64 (val); +/* See comment in arm_smmu_write_ctx_desc() */ +WRITE_ONCE (dst[0 ],cpu_to_le64 (val));arm_smmu_sync_ste_for_sid (smmu, sid);/* It's likely that we'll want to use the new STE soon */
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 85/165 scsi: iscsi: Dont destroy session if there are outstanding connections
In reply to Greg Kroah-HartmanFrom: Nick Black <[email protected]>
[ Upstream commit 54155ed4199c7aa3fd20866648024ab63c96d579 ]
A faulty userspace that calls destroy_session() before destroying the connections can trigger the failure. This patch prevents the issue by refusing to destroy the session if there are outstanding connections.
------------[ cut here ]------------ kernel BUG at mm/slub.c:306! invalid opcode: 0000 [#1] SMP PTI CPU: 1 PID: 1224 Comm: iscsid Not tainted 5.4.0-rc2.iscsi+ #7 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 RIP: 0010:__slab_free+0x181/0x350 [...] [ 1209.686056] RSP: 0018:ffffa93d4074fae0 EFLAGS: 00010246 [ 1209.686694] RAX: ffff934efa5ad800 RBX: 000000008010000a RCX: ffff934efa5ad800 [ 1209.687651] RDX: ffff934efa5ad800 RSI: ffffeb4041e96b00 RDI: ffff934efd402c40 [ 1209.688582] RBP: ffffa93d4074fb80 R08: 0000000000000001 R09: ffffffffbb5dfa26 [ 1209.689425] R10: ffff934efa5ad800 R11: 0000000000000001 R12: ffffeb4041e96b00 [ 1209.690285] R13: ffff934efa5ad800 R14: ffff934efd402c40 R15: 0000000000000000 [ 1209.691213] FS: 00007f7945dfb540(0000) GS:ffff934efda80000(0000) knlGS:0000000000000000 [ 1209.692316] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 1209.693013] CR2: 000055877fd3da80 CR3: 0000000077384000 CR4: 00000000000006e0 [ 1209.693897] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1209.694773] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 1209.695631] Call Trace: [ 1209.695957] ? __wake_up_common_lock+0x8a/0xc0 [ 1209.696712] iscsi_pool_free+0x26/0x40 [ 1209.697263] iscsi_session_teardown+0x2f/0xf0 [ 1209.698117] iscsi_sw_tcp_session_destroy+0x45/0x60 [ 1209.698831] iscsi_if_rx+0xd88/0x14e0 [ 1209.699370] netlink_unicast+0x16f/0x200 [ 1209.699932] netlink_sendmsg+0x21a/0x3e0 [ 1209.700446] sock_sendmsg+0x4f/0x60 [ 1209.700902] ___sys_sendmsg+0x2ae/0x320 [ 1209.701451] ? cp_new_stat+0x150/0x180 [ 1209.701922] __sys_sendmsg+0x59/0xa0 [ 1209.702357] do_syscall_64+0x52/0x160 [ 1209.702812] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 1209.703419] RIP: 0033:0x7f7946433914 [...] [ 1209.706084] RSP: 002b:00007fffb99f2378 EFLAGS: 00000246 ORIG_RAX: 000000000000002e [ 1209.706994] RAX: ffffffffffffffda RBX: 000055bc869eac20 RCX: 00007f7946433914 [ 1209.708082] RDX: 0000000000000000 RSI: 00007fffb99f2390 RDI: 0000000000000005 [ 1209.709120] RBP: 00007fffb99f2390 R08: 000055bc84fe9320 R09: 00007fffb99f1f07 [ 1209.710110] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000038 [ 1209.711085] R13: 000055bc8502306e R14: 0000000000000000 R15: 0000000000000000 Modules linked in: ---[ end trace a2d933ede7f730d8 ]---
--- drivers/scsi/iscsi_tcp.c | 4 ++++ drivers/scsi/scsi_transport_iscsi.c | 26 +++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-)
drivers/scsi/iscsi_tcp.c +4 -0
@@ -882,6 +882,10 @@ free_host:static void iscsi_sw_tcp_session_destroy (struct iscsi_cls_session *cls_session) {struct Scsi_Host *shost =iscsi_session_to_shost (cls_session); +struct iscsi_session *session = cls_session->dd_data; + +if (WARN_ON_ONCE (session->leadconn)) +return ;iscsi_tcp_r2tpool_free (cls_session->dd_data);iscsi_session_teardown (cls_session);
drivers/scsi/scsi_transport_iscsi.c +23 -3
@@ -2964,6 +2964,24 @@ iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)return err; } +static int iscsi_session_has_conns (int sid) +{ +struct iscsi_cls_conn *conn; +unsigned long flags; +int found =0 ; + +spin_lock_irqsave (&connlock, flags); +list_for_each_entry (conn, &connlist, conn_list) { +if (iscsi_conn_get_sid (conn) == sid) { + found =1 ; +break ; + } + } +spin_unlock_irqrestore (&connlock, flags); + +return found; +} +static int iscsi_set_iface_params (struct iscsi_transport *transport,struct iscsi_uevent *ev,uint32_t len)
@@ -3538,10 +3556,12 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)break ;case ISCSI_UEVENT_DESTROY_SESSION : session =iscsi_session_lookup (ev->u.d_session.sid); -if (session) - transport->destroy_session (session); -else +if (!session) err = -EINVAL ; +else if (iscsi_session_has_conns (ev->u.d_session.sid)) + err = -EBUSY ; +else + transport->destroy_session (session);break ;case ISCSI_UEVENT_UNBIND_SESSION : session =iscsi_session_lookup (ev->u.d_session.sid);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 86/165 arm64: fix alternatives with LLVMs integrated assembler
In reply to Greg Kroah-HartmanFrom: Sami Tolvanen <[email protected]>
[ Upstream commit c54f90c2627cc316d365e3073614731e17dbc631 ]
LLVM's integrated assembler fails with the following error when building KVM:
<inline asm>:12:6: error: expected absolute expression
.if kvm_update_va_mask == 0
^
<inline asm>:21:6: error: expected absolute expression
.if kvm_update_va_mask == 0
^
<inline asm>:24:2: error: unrecognized instruction mnemonic
NOT_AN_INSTRUCTION
^LLVM ERROR: Error parsing inline asm
These errors come from ALTERNATIVE_CB and __ALTERNATIVE_CFG, which test for the existence of the callback parameter in inline assembly using the following expression:
" .if " __stringify(cb) " == 0\n"
This works with GNU as, but isn't supported by LLVM. This change splits __ALTERNATIVE_CFG and ALTINSTR_ENTRY into separate macros to fix the LLVM build.
--- arch/arm64/include/asm/alternative.h | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-)
arch/arm64/include/asm/alternative.h +21 -11
@@ -29,13 +29,16 @@ typedef void (*alternative_cb_t)(struct alt_instr *alt,void __init apply_alternatives_all (void );void apply_alternatives (void *start,size_t length); -#define ALTINSTR_ENTRY (feature,cb) \ +#define ALTINSTR_ENTRY (feature) \ " .word 661b - .\n"/* label */ \ - " .if " __stringify(cb) " == 0\n" \" .word 663f - .\n" /* new instruction */ \ -" .else\n" \ + " .hword " __stringify(feature) "\n" /* feature bit */ \ +" .byte 662b-661b\n" /* source len */ \ + " .byte 664f-663f\n" /* replacement len */ + +#define ALTINSTR_ENTRY_CB (feature, cb) \ + " .word 661b - .\n"/* label */ \ " .word " __stringify(cb) "- .\n" /* callback */ \ -" .endif\n" \ " .hword " __stringify(feature) "\n" /* feature bit */ \" .byte 662b-661b\n" /* source len */ \" .byte 664f-663f\n" /* replacement len */
@@ -56,15 +59,14 @@ void apply_alternatives(void *start, size_t length);* * Alternatives with callbacks do not generate replacement instructions. */ -#define __ALTERNATIVE_CFG (oldinstr, newinstr, feature, cfg_enabled, cb) \ +#define __ALTERNATIVE_CFG (oldinstr, newinstr, feature, cfg_enabled) \ ".if "__stringify(cfg_enabled)" == 1\n" \ "661:\n\t" \ oldinstr "\n" \ "662:\n" \ ".pushsection .altinstructions,\"a\"\n" \ - ALTINSTR_ENTRY(feature,cb) \ + ALTINSTR_ENTRY(feature) \ ".popsection\n" \ - " .if " __stringify(cb) " == 0\n" \ ".pushsection .altinstr_replacement, \"a\"\n" \ "663:\n\t" \ newinstr "\n" \
@@ -72,17 +74,25 @@ void apply_alternatives(void *start, size_t length);".popsection\n\t" \".org . - (664b-663b) + (662b-661b)\n\t" \".org . - (662b-661b) + (664b-663b)\n" \ -".else\n\t" \ + ".endif\n" + +#define __ALTERNATIVE_CFG_CB (oldinstr, feature, cfg_enabled, cb) \ + ".if "__stringify(cfg_enabled)" == 1\n" \ + "661:\n\t" \ + oldinstr "\n" \ + "662:\n" \ + ".pushsection .altinstructions,\"a\"\n" \ + ALTINSTR_ENTRY_CB(feature, cb) \ + ".popsection\n" \ "663:\n\t" \ "664:\n\t" \ -".endif\n" \ ".endif\n"#define _ALTERNATIVE_CFG (oldinstr, newinstr, feature, cfg, ...) \ - __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg), 0) + __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg))#define ALTERNATIVE_CB (oldinstr, cb) \ - __ALTERNATIVE_CFG(oldinstr, "NOT_AN_INSTRUCTION", ARM64_CB_PATCH, 1, cb) + __ALTERNATIVE_CFG_CB(oldinstr, ARM64_CB_PATCH, 1, cb)#else #include <asm/assembler.h>
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 87/165 pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctional
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 43efdc8f0e6d7088ec61bd55a73bf853f002d043 ]
In the old code (e.g.) mutex_destroy() was called before pwmchip_remove(). Between these two calls it is possible that a PWM callback is used which tries to grab the mutex.
--- drivers/pwm/pwm-omap-dmtimer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pwm/pwm-omap-dmtimer.c +6 -1
@@ -337,6 +337,11 @@ static int pwm_omap_dmtimer_probe(struct platform_device *pdev)static int pwm_omap_dmtimer_remove (struct platform_device *pdev) {struct pwm_omap_dmtimer_chip *omap =platform_get_drvdata (pdev); +int ret; + + ret =pwmchip_remove (&omap->chip); +if (ret) +return ret;if (pm_runtime_active (&omap->dm_timer_pdev->dev)) omap->pdata->stop (omap->dm_timer);
@@ -345,7 +350,7 @@ static int pwm_omap_dmtimer_remove(struct platform_device *pdev)mutex_destroy (&omap->mutex); -return pwmchip_remove (&omap->chip); +return 0 ; }static const struct of_device_id pwm_omap_dmtimer_of_match[] = {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 88/165 cmd64x: potential buffer overflow in cmd64x_program_timings()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 117fcc3053606d8db5cef8821dca15022ae578bb ]
The "drive->dn" value is a u8 and it is controlled by root only, but it could be out of bounds here so let's check.
--- drivers/ide/cmd64x.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/ide/cmd64x.c +3 -0
@@ -65,6 +65,9 @@ static void cmd64x_program_timings(ide_drive_t *drive, u8 mode)struct ide_timing t;u8 arttim =0 ; +if (drive->dn >=ARRAY_SIZE (drwtim_regs)) +return ; +ide_timing_compute (drive, mode, &t,T ,0 );/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 89/165 ide: serverworks: potential overflow in svwks_set_pio_mode()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit ce1f31b4c0b9551dd51874dd5364654ed4ca13ae ]
The "drive->dn" variable is a u8 controlled by root.
--- drivers/ide/serverworks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/ide/serverworks.c +6 -0
@@ -114,6 +114,9 @@ static void svwks_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive)struct pci_dev *dev =to_pci_dev (hwif->dev);const u8 pio = drive->pio_mode -XFER_PIO_0 ; +if (drive->dn >=ARRAY_SIZE (drive_pci)) +return ; +pci_write_config_byte (dev, drive_pci[drive->dn], pio_modes[pio]);if (svwks_csb_check (dev)) {
@@ -140,6 +143,9 @@ static void svwks_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)u8 ultra_enable =0 , ultra_timing =0 , dma_timing =0 ; +if (drive->dn >=ARRAY_SIZE (drive_pci2)) +return ; +pci_read_config_byte (dev, (0x56 |hwif->channel), &ultra_timing);pci_read_config_byte (dev,0x54 , &ultra_enable);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 90/165 remoteproc: Initialize rproc_class before use
In reply to Greg Kroah-HartmanFrom: Brandon Maier <[email protected]>
[ Upstream commit a8f40111d184098cd2b3dc0c7170c42250a5fa09 ]
The remoteproc_core and remoteproc drivers all initialize with module_init(). However remoteproc drivers need the rproc_class during their probe. If one of the remoteproc drivers runs init and gets through probe before remoteproc_init() runs, a NULL pointer access of rproc_class's glue_dirs spinlock occurs.
Quoted 16 lines
Unable to handle kernel NULL pointer dereference at virtual address 000000dc pgd = c0004000 [000000dc] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT ARM Modules linked in: CPU: 0 PID: 1 Comm: swapper Tainted: G W 4.14.106-rt56 #1 Hardware name: Generic OMAP36xx (Flattened Device Tree) task: c6050000 task.stack: c604a000 PC is at rt_spin_lock+0x40/0x6c LR is at rt_spin_lock+0x28/0x6c pc : [<c0523c90>] lr : [<c0523c78>] psr: 60000013sp :
c604bdc0ip : 00000000 fp : 00000000
r10: 00000000 r9 :c61c7c10r8 :c6269c20
r7 :c0905888r6 :c6269c20r5 : 00000000 r4 :000000d4r3 :000000dcr2 :c6050000r1 : 00000002 r0 :000000d4
Flags: nZCv IRQs on FIQs on ModeSVC_32ISA ARM Segment none
...
Quoted 14 lines
[<
c0523c90>] (rt_spin_lock) from [<c03b65a4>] (get_device_parent+0x54/0x17c) [<c03b65a4>] (get_device_parent) from [<c03b6bec>] (device_add+0xe0/0x5b4) [<c03b6bec>] (device_add) from [<c042adf4>] (rproc_add+0x18/0xd8) [<c042adf4>] (rproc_add) from [<c01110e4>] (my_rproc_probe+0x158/0x204) [<c01110e4>] (my_rproc_probe) from [<c03bb6b8>] (platform_drv_probe+0x34/0x70) [<c03bb6b8>] (platform_drv_probe) from [<c03b9dd4>] (driver_probe_device+0x2c8/0x420) [<c03b9dd4>] (driver_probe_device) from [<c03ba02c>] (__driver_attach+0x100/0x11c) [<c03ba02c>] (__driver_attach) from [<c03b7d08>] (bus_for_each_dev+0x7c/0xc0) [<c03b7d08>] (bus_for_each_dev) from [<c03b910c>] (bus_add_driver+0x1cc/0x264) [<c03b910c>] (bus_add_driver) from [<c03ba714>] (driver_register+0x78/0xf8) [<c03ba714>] (driver_register) from [<c010181c>] (do_one_initcall+0x100/0x190) [<c010181c>] (do_one_initcall) from [<c0800de8>] (kernel_init_freeable+0x130/0x1d0) [<c0800de8>] (kernel_init_freeable) from [<c051eee8>] (kernel_init+0x8/0x114) [<c051eee8>] (kernel_init) from [<c01175b0>] (ret_from_fork+0x14/0x24)
Quoted 2 lines
Code: e2843008 e3c2203f f5d3f000 e5922010 (e193cf9f) ---[ end trace 0000000000000002 ]---
--- drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
@@ -1488,7 +1488,7 @@ static int __init remoteproc_init(void)return 0 ; } -module_init (remoteproc_init); +subsys_initcall (remoteproc_init); static void __exit remoteproc_exit(void) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 91/165 x86/decoder: Add TEST opcode to Group3-2
In reply to Greg Kroah-HartmanFrom: Masami Hiramatsu <[email protected]>
[ Upstream commit 8b7e20a7ba54836076ff35a28349dabea4cec48f ]
Add TEST opcode to Group3-2 reg=001b as same as Group3-1 does.
Commit
12a78d43de76 ("x86/decoder: Add new TEST instruction pattern")
added a TEST opcode assignment to f6 XX/001/XXX (Group 3-1), but did not add f7 XX/001/XXX (Group 3-2).
Actually, this TEST opcode variant (ModRM.reg /1) is not described in the Intel SDM Vol2 but in AMD64 Architecture Programmer's Manual Vol.3, Appendix A.2 Table A-6. ModRM.reg Extensions for the Primary Opcode Map.
Without this fix, Randy found a warning by insn_decoder_test related to this issue as below.
HOSTCC arch/x86/tools/insn_decoder_test
HOSTCC arch/x86/tools/insn_sanity
TEST posttest arch/x86/tools/insn_decoder_test: warning: Found an x86 instruction decoder bug, please report this.
arch/x86/tools/insn_decoder_test: warning: ffffffff81000bf1: f7 0b 00 01 08 00 testl $0x80100,(%rbx)
arch/x86/tools/insn_decoder_test: warning: objdump says 6 bytes, but insn_get_length() says 2 arch/x86/tools/insn_decoder_test: warning: Decoded and checked 11913894 instructions with 1 failures
TEST posttest
arch/x86/tools/insn_sanity: Success: decoded and checked 1000000 random instructions with 0 errors (seed:0x871ce29c)
To fix this error, add the TEST opcode according to AMD64 APM Vol.3.
[ bp: Massage commit message. ]
--- arch/x86/lib/x86-opcode-map.txt | 2 +- tools/objtool/arch/x86/lib/x86-opcode-map.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/x86/lib/x86-opcode-map.txt +1 -1
@@ -909,7 +909,7 @@ EndTable GrpTable: Grp3_2 0: TEST Ev,Iz -1: +1: TEST Ev,Iz 2: NOT Ev 3: NEG Ev 4: MUL rAX,Ev
tools/objtool/arch/x86/lib/x86-opcode-map.txt +1 -1
@@ -909,7 +909,7 @@ EndTable GrpTable: Grp3_2 0: TEST Ev,Iz -1: +1: TEST Ev,Iz 2: NOT Ev 3: NEG Ev 4: MUL rAX,Ev
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 92/165 s390/ftrace: generate traced function stack frame
In reply to Greg Kroah-HartmanFrom: Vasily Gorbik <[email protected]>
[ Upstream commit 45f7a0da600d3c409b5ad8d5ddddacd98ddc8840 ]
Currently backtrace from ftraced function does not contain ftraced function itself. e.g. for "path_openat":
arch_stack_walk+0x15c/0x2d8 stack_trace_save+0x50/0x68 stack_trace_call+0x15e/0x3d8 ftrace_graph_caller+0x0/0x1c <-- ftrace code do_filp_open+0x7c/0xe8 <-- ftraced function caller do_open_execat+0x76/0x1b8 open_exec+0x52/0x78 load_elf_binary+0x180/0x1160 search_binary_handler+0x8e/0x288 load_script+0x2a8/0x2b8 search_binary_handler+0x8e/0x288 __do_execve_file.isra.39+0x6fa/0xb40 __s390x_sys_execve+0x56/0x68 system_call+0xdc/0x2d8
Ftraced function is expected in the backtrace by ftrace kselftests, which are now failing. It would also be nice to have it for clarity reasons.
"ftrace_caller" itself is called without stack frame allocated for it and does not store its caller (ftraced function). Instead it simply allocates a stack frame for "ftrace_trace_function" and sets backchain to point to ftraced function stack frame (which contains ftraced function caller in saved r14).
To fix this issue make "ftrace_caller" allocate a stack frame for itself just to store ftraced function for the stack unwinder. As a result backtrace looks like the following:
arch_stack_walk+0x15c/0x2d8 stack_trace_save+0x50/0x68 stack_trace_call+0x15e/0x3d8 ftrace_graph_caller+0x0/0x1c <-- ftrace code path_openat+0x6/0xd60 <-- ftraced function do_filp_open+0x7c/0xe8 <-- ftraced function caller do_open_execat+0x76/0x1b8 open_exec+0x52/0x78 load_elf_binary+0x180/0x1160 search_binary_handler+0x8e/0x288 load_script+0x2a8/0x2b8 search_binary_handler+0x8e/0x288 __do_execve_file.isra.39+0x6fa/0xb40 __s390x_sys_execve+0x56/0x68 system_call+0xdc/0x2d8
--- arch/s390/kernel/mcount.S | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/s390/kernel/mcount.S +14 -1
@@ -24,6 +24,12 @@ ENTRY(ftrace_stub) #define STACK_PTREGS (STACK_FRAME_OVERHEAD) #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS) #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW) +#ifdef __PACK_STACK +/* allocate just enough for r14, r15 and backchain */ +#define TRACED_FUNC_FRAME_SIZE 24 +#else +#define TRACED_FUNC_FRAME_SIZE STACK_FRAME_OVERHEAD +#endif ENTRY(_mcount) BR_EX %r14
@@ -37,9 +43,16 @@ ENTRY(ftrace_caller) #ifndef CC_USING_HOTPATCH aghi %r0,MCOUNT_RETURN_FIXUP #endif - aghi %r15,-STACK_FRAME_SIZE + # allocate stack frame for ftrace_caller to contain traced function + aghi %r15,-TRACED_FUNC_FRAME_SIZE stg %r1,__SF_BACKCHAIN(%r15) + stg %r0,(__SF_GPRS+8*8)(%r15) + stg %r15,(__SF_GPRS+9*8)(%r15) + # allocate pt_regs and stack frame for ftrace_trace_function + aghi %r15,-STACK_FRAME_SIZE stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15) + aghi %r1,-TRACED_FUNC_FRAME_SIZE + stg %r1,__SF_BACKCHAIN(%r15) stg %r0,(STACK_PTREGS_PSW+8)(%r15) stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15) #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 93/165 driver core: platform: fix u32 greater or equal to zero comparison
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 0707cfa5c3ef58effb143db9db6d6e20503f9dec ]
Currently the check that a u32 variable i is >= 0 is always true because the unsigned variable will never be negative, causing the loop to run forever. Fix this by changing the pre-decrement check to a zero check on i followed by a decrement of i.
Addresses-Coverity: ("Unsigned compared against 0")
--- drivers/base/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/platform.c +1 -1
@@ -418,7 +418,7 @@ int platform_device_add(struct platform_device *pdev) pdev->id =PLATFORM_DEVID_AUTO ; } -while (--i >=0 ) { +while (i--) {struct resource *r = &pdev->resource[i];if (r->parent)release_resource (r);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 94/165 ALSA: hda - Add docking station support for Lenovo Thinkpad T420s
In reply to Greg Kroah-HartmanFrom: Peter Große <[email protected]>
[ Upstream commit ef7d84caa5928b40b1c93a26dbe5a3f12737c6ab ]
Lenovo Thinkpad T420s uses the same codec as T420, so apply the same quirk to enable audio output on a docking station.
--- sound/pci/hda/patch_conexant.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_conexant.c +1 -0
@@ -853,6 +853,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {SND_PCI_QUIRK (0x17aa ,0x215f ,"Lenovo T510" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21ce ,"Lenovo T420" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21cf ,"Lenovo T520" ,CXT_PINCFG_LENOVO_TP410 ), +SND_PCI_QUIRK (0x17aa ,0x21d2 ,"Lenovo T420s" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21da ,"Lenovo X220" ,CXT_PINCFG_LENOVO_TP410 ),SND_PCI_QUIRK (0x17aa ,0x21db ,"Lenovo X220-tablet" ,CXT_PINCFG_LENOVO_TP410 ), SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 95/165 powerpc/sriov: Remove VF eeh_dev state when disabling SR-IOV
In reply to Greg Kroah-HartmanFrom: Oliver O'Halloran <[email protected]>
[ Upstream commit 1fb4124ca9d456656a324f1ee29b7bf942f59ac8 ]
When disabling virtual functions on an SR-IOV adapter we currently do not correctly remove the EEH state for the now-dead virtual functions. When removing the pci_dn that was created for the VF when SR-IOV was enabled we free the corresponding eeh_dev without removing it from the child device list of the eeh_pe that contained it. This can result in crashes due to the use-after-free.
--- arch/powerpc/kernel/pci_dn.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/powerpc/kernel/pci_dn.c +14 -1
@@ -271,9 +271,22 @@ void remove_dev_pci_data(struct pci_dev *pdev)continue ;#ifdef CONFIG_EEH -/* Release EEH device for the VF */ +/* +* Release EEH state for this VF. The PCI core +* has already torn down the pci_dev for this VF, but +* we're responsible to removing the eeh_dev since it +* has the same lifetime as the pci_dn that spawned it. +*/ edev =pdn_to_eeh_dev (pdn);if (edev) { +/* +* We allocate pci_dn's for the totalvfs count, +* but only only the vfs that were activated +* have a configured PE. +*/ +if (edev->pe) +eeh_rmv_from_parent_pe (edev); + pdn->edev =NULL ;kfree (edev); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 96/165 jbd2: switch to use jbd2_journal_abort() when failed to submit the commit record
In reply to Greg Kroah-HartmanFrom: zhangyi (F) <[email protected]>
[ Upstream commit d0a186e0d3e7ac05cc77da7c157dae5aa59f95d9 ]
We invoke jbd2_journal_abort() to abort the journal and record errno in the jbd2 superblock when committing journal transaction besides the failure on submitting the commit record. But there is no need for the case and we can also invoke jbd2_journal_abort() instead of __jbd2_journal_abort_hard().
--- fs/jbd2/commit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/jbd2/commit.c +2 -2
@@ -779,7 +779,7 @@ start_journal_io: err =journal_submit_commit_record (journal, commit_transaction, &cbh, crc32_sum);if (err) -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, err); }blk_finish_plug (&plug);
@@ -872,7 +872,7 @@ start_journal_io: err =journal_submit_commit_record (journal, commit_transaction, &cbh, crc32_sum);if (err) -__jbd2_journal_abort_hard (journal); +jbd2_journal_abort (journal, err); }if (cbh) err =journal_wait_on_commit_record (journal, cbh);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 97/165 ARM: 8951/1: Fix Kexec compilation issue.
In reply to Greg Kroah-HartmanFrom: Vincenzo Frascino <[email protected]>
[ Upstream commit 76950f7162cad51d2200ebd22c620c14af38f718 ]
To perform the reserve_crashkernel() operation kexec uses SECTION_SIZE to find a memblock in a range.SECTION_SIZE is not defined for nommu systems. Trying to compile kexec in these conditions results in a build error:
linux/arch/arm/kernel/setup.c: In function ‘reserve_crashkernel’:
linux/arch/arm/kernel/setup.c:1016:25: error: ‘SECTION_SIZE’ undeclared
(first use in this function); did you mean ‘SECTIONS_WIDTH’?
crash_size, SECTION_SIZE);
^~~~~~~~~~~~
SECTIONS_WIDTH linux/arch/arm/kernel/setup.c:1016:25: note: each undeclared identifier
is reported only once for each function it appears in
linux/scripts/Makefile.build:265: recipe for target 'arch/arm/kernel/setup.o'
failed
Make KEXEC depend on MMU to fix the compilation issue.
--- arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -2020,7 +2020,7 @@ config XIP_PHYS_ADDR config KEXEC bool "Kexec system call (EXPERIMENTAL)" depends on (!SMP || PM_SLEEP_SMP) - depends on !CPU_V7M + depends on MMU select KEXEC_CORE help kexec is a system call that implements the ability to shutdown your
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 98/165 hostap: Adjust indentation in prism2_hostapd_add_sta
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit b61156fba74f659d0bc2de8f2dbf5bad9f4b8faf ]
Clang warns:
../drivers/net/wireless/intersil/hostap/hostap_ap.c:2511:3: warning:
misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
if (sta->tx_supp_rates & WLAN_RATE_5M5)
^
../drivers/net/wireless/intersil/hostap/hostap_ap.c:2509:2: note:
previous statement is here
if (sta->tx_supp_rates & WLAN_RATE_2M)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- drivers/net/wireless/intersil/hostap/hostap_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intersil/hostap/hostap_ap.c +1 -1
@@ -2570,7 +2570,7 @@ static int prism2_hostapd_add_sta(struct ap_data *ap, sta->supported_rates[0 ] =2 ;if (sta->tx_supp_rates &WLAN_RATE_2M ) sta->supported_rates[1 ] =4 ; -if (sta->tx_supp_rates &WLAN_RATE_5M5 ) +if (sta->tx_supp_rates &WLAN_RATE_5M5 ) sta->supported_rates[2 ] =11 ;if (sta->tx_supp_rates &WLAN_RATE_11M ) sta->supported_rates[3 ] =22 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 99/165 iwlegacy: ensure loop counter addr does not wrap and cause an infinite loop
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit c2f9a4e4a5abfc84c01b738496b3fd2d471e0b18 ]
The loop counter addr is a u16 where as the upper limit of the loop is an int. In the unlikely event that the il->cfg->eeprom_size is greater than 64K then we end up with an infinite loop since addr will wrap around an never reach upper loop limit. Fix this by making addr an int.
Addresses-Coverity: ("Infinite loop")
--- drivers/net/wireless/intel/iwlegacy/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlegacy/common.c +1 -1
@@ -717,7 +717,7 @@ il_eeprom_init(struct il_priv *il)u32 gp =_il_rd (il,CSR_EEPROM_GP );int sz;int ret; -u16 addr; +int addr;/* allocate eeprom */ sz = il->cfg->eeprom_size;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 100/165 cifs: fix NULL dereference in match_prepath
In reply to Greg Kroah-HartmanFrom: Ronnie Sahlberg <[email protected]>
[ Upstream commit fe1292686333d1dadaf84091f585ee903b9ddb84 ]
RHBZ: 1760879
Fix an oops in match_prepath() by making sure that the prepath string is not NULL before we pass it into strcmp().
This is similar to other checks we make for example in cifs_root_iget()
--- fs/cifs/connect.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/connect.c +4 -2
@@ -2927,8 +2927,10 @@ match_prepath(struct super_block *sb, struct cifs_mnt_data *mnt_data) {struct cifs_sb_info *old =CIFS_SB (sb);struct cifs_sb_info *new = mnt_data->cifs_sb; -bool old_set = old->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ; -bool new_set = new->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ; +bool old_set = (old->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) && + old->prepath; +bool new_set = (new->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) && + new->prepath;if (old_set && new_set && !strcmp (new->prepath, old->prepath))return 1 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 101/165 irqchip/gic-v3: Only provision redistributors that are enabled in ACPI
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
[ Upstream commit 926b5dfa6b8dc666ff398044af6906b156e1d949 ]
We currently allocate redistributor region structures for individual redistributors when ACPI doesn't present us with compact MMIO regions covering multiple redistributors.
It turns out that we allocate these structures even when the redistributor is flagged as disabled by ACPI. It works fine until someone actually tries to tarse one of these structures, and access the corresponding MMIO region.
Instead, track the number of enabled redistributors, and only allocate what is required. This makes sure that there is no invalid data to misuse.
--- drivers/irqchip/irq-gic-v3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v3.c +7 -2
@@ -1195,6 +1195,7 @@ static structstruct redist_region *redist_regs;u32 nr_redist_regions;bool single_redist; +int enabled_rdists;u32 maint_irq;int maint_irq_mode;phys_addr_t vcpu_base;
@@ -1289,8 +1290,10 @@ static int __init gic_acpi_match_gicc(struct acpi_subtable_header *header,* If GICC is enabled and has valid gicr base address, then it means * GICR base is presented via GICC */ -if ((gicc->flags &ACPI_MADT_ENABLED ) && gicc->gicr_base_address) +if ((gicc->flags &ACPI_MADT_ENABLED ) && gicc->gicr_base_address) { + acpi_data.enabled_rdists++;return 0 ; + }/* * It's perfectly valid firmware can pass disabled GICC entry, driver
@@ -1320,8 +1323,10 @@ static int __init gic_acpi_count_gicr_regions(void) count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , gic_acpi_match_gicc,0 ); -if (count >0 ) +if (count >0 ) { acpi_data.single_redist = true; + count = acpi_data.enabled_rdists; + }return count; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 102/165 drm/nouveau/disp/nv50-: prevent oops when no channel method map provided
In reply to Greg Kroah-HartmanFrom: Ben Skeggs <[email protected]>
[ Upstream commit 0e6176c6d286316e9431b4f695940cfac4ffe6c2 ]
The implementations for most channel types contains a map of methods to priv registers in order to provide debugging info when a disp exception has been raised.
This info is missing from the implementation of PIO channels as they're rather simplistic already, however, if an exception is raised by one of them, we'd end up triggering a NULL-pointer deref. Not ideal...
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=206299
--- drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nvkm/engine/disp/channv50.c +2 -0
@@ -72,6 +72,8 @@ nv50_disp_chan_mthd(struct nv50_disp_chan *chan, int debug)if (debug > subdev->debug)return ; +if (!mthd) +return ;for (i =0 ; (list = mthd->data[i].mthd) !=NULL ; i++) {u32 base = chan->head * mthd->addr;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 103/165 ftrace: fpid_next() should increase position index
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
[ Upstream commit e4075e8bdffd93a9b6d6e1d52fabedceeca5a91b ]
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
Without patch:
# dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset id no pid 2+1 records in 2+1 records out 10 bytes copied, 0.000213285 s, 46.9 kB/s
Notice the "id" followed by "no pid".
With the patch:
# dd bs=4 skip=1 if=/sys/kernel/tracing/set_ftrace_pid dd: /sys/kernel/tracing/set_ftrace_pid: cannot skip to specified offset id 0+1 records in 0+1 records out 3 bytes copied, 0.000202112 s, 14.8 kB/s
Notice that it only prints "id" and not the "no pid" afterward.
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- kernel/trace/ftrace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/ftrace.c +3 -2
@@ -5455,9 +5455,10 @@ static void *fpid_next(struct seq_file *m, void *v, loff_t *pos)struct trace_array *tr = m->private;struct trace_pid_list *pid_list =rcu_dereference_sched (tr->function_pids); -if (v ==FTRACE_NO_PIDS ) +if (v ==FTRACE_NO_PIDS ) { + (*pos)++;return NULL ; - + }return trace_pid_next (pid_list, v, pos); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 104/165 trigger_next should increase position index
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
[ Upstream commit 6722b23e7a2ace078344064a9735fb73e554e9ef ]
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
Without patch:
# dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist # Available triggers: # traceon traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist 6+1 records in 6+1 records out 206 bytes copied, 0.00027916 s, 738 kB/s
Notice the printing of "# Available triggers:..." after the line.
With the patch:
# dd bs=30 skip=1 if=/sys/kernel/tracing/events/sched/sched_switch/trigger dd: /sys/kernel/tracing/events/sched/sched_switch/trigger: cannot skip to specified offset n traceoff snapshot stacktrace enable_event disable_event enable_hist disable_hist hist 2+1 records in 2+1 records out 88 bytes copied, 0.000526867 s, 167 kB/s
It only prints the end of the file, and does not restart.
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- kernel/trace/trace_events_trigger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
kernel/trace/trace_events_trigger.c +3 -2
@@ -126,9 +126,10 @@ static void *trigger_next(struct seq_file *m, void *t, loff_t *pos) {struct trace_event_file *event_file =event_file_data (m->private); -if (t ==SHOW_AVAILABLE_TRIGGERS ) +if (t ==SHOW_AVAILABLE_TRIGGERS ) { + (*pos)++;return NULL ; - + }return seq_list_next (t, &event_file->triggers, pos); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 105/165 radeon: insert 10ms sleep in dce5_crtc_load_lut
In reply to Greg Kroah-HartmanFrom: Daniel Vetter <[email protected]>
[ Upstream commit ec3d65082d7dabad6fa8f66a8ef166f2d522d6b2 ]
Per at least one tester this is enough magic to recover the regression introduced for some people (but not all) in
commit b8e2b0199cc377617dc238f5106352c06dcd3fa2
Author: Peter Rosin <[email protected]> Date: Tue Jul 4 12:36:57 2017 +0200
drm/fb-helper: factor out pseudo-palette
which for radeon had the side-effect of refactoring out a seemingly redudant writing of the color palette.
10ms in a fairly slow modeset path feels like an acceptable form of duct-tape, so maybe worth a shot and see what sticks.
--- drivers/gpu/drm/radeon/radeon_display.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/radeon/radeon_display.c +2 -0
@@ -110,6 +110,8 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)DRM_DEBUG_KMS ("%d\n" , radeon_crtc->crtc_id); +msleep (10 ); +WREG32 (NI_INPUT_CSC_CONTROL + radeon_crtc->crtc_offset, (NI_INPUT_CSC_GRPH_MODE (NI_INPUT_CSC_BYPASS ) |NI_INPUT_CSC_OVL_MODE (NI_INPUT_CSC_BYPASS )));
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 106/165 ocfs2: fix a NULL pointer dereference when call ocfs2_update_inode_fsync_trans()
In reply to Greg Kroah-HartmanFrom: wangyan <[email protected]>
[ Upstream commit 9f16ca48fc818a17de8be1f75d08e7f4addc4497 ]
I found a NULL pointer dereference in ocfs2_update_inode_fsync_trans(), handle->h_transaction may be NULL in this situation:
ocfs2_file_write_iter
->__generic_file_write_iter
->generic_perform_write
->ocfs2_write_begin
->ocfs2_write_begin_nolock
->ocfs2_write_cluster_by_desc
->ocfs2_write_cluster
->ocfs2_mark_extent_written
->ocfs2_change_extent_flag
->ocfs2_split_extent
->ocfs2_try_to_merge_extent
->ocfs2_extend_rotate_transaction
->ocfs2_extend_trans
->jbd2_journal_restart
->jbd2__journal_restart
// handle->h_transaction is NULL here
->handle->h_transaction = NULL;
->start_this_handle
/* journal aborted due to storage
network disconnection, return error */
->return -EROFS;
/* line 3806 in ocfs2_try_to_merge_extent (),
it will ignore ret error. */
->ret = 0;
->...
->ocfs2_write_end
->ocfs2_write_end_nolock
->ocfs2_update_inode_fsync_trans
// NULL pointer dereference
->oi->i_sync_tid = handle->h_transaction->t_tid;The information of NULL pointer dereference as follows:
JBD2: Detected IO errors while flushing file data on dm-11-45
Aborting journal on device dm-11-45.
JBD2: Error -5 detected when updating journal superblock for dm-11-45.
(dd,22081,3):ocfs2_extend_trans:474 ERROR: status = -30
(dd,22081,3):ocfs2_try_to_merge_extent:3877 ERROR: status = -30
Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000008
Mem abort info:
ESR = 0x96000004
Exception class = DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
Data abort info:
ISV = 0, ISS = 0x00000004
CM = 0, WnR = 0
user pgtable: 4k pages, 48-bit VAs, pgdp = 00000000e74e1338
[0000000000000008] pgd=0000000000000000
Internal error: Oops: 96000004 [#1] SMP
Process dd (pid: 22081, stack limit = 0x00000000584f35a9)
CPU: 3 PID: 22081 Comm: dd Kdump: loaded
Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 0.98 08/25/2019
pstate: 60400009 (nZCv daif +PAN -UAO)
pc : ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
lr : ocfs2_write_end_nolock+0x2a0/0x550 [ocfs2]
sp : ffff0000459fba70
x29: ffff0000459fba70 x28: 0000000000000000
x27: ffff807ccf7f1000 x26: 0000000000000001
x25: ffff807bdff57970 x24: ffff807caf1d4000
x23: ffff807cc79e9000 x22: 0000000000001000
x21: 000000006c6cd000 x20: ffff0000091d9000
x19: ffff807ccb239db0 x18: ffffffffffffffff
x17: 000000000000000e x16: 0000000000000007
x15: ffff807c5e15bd78 x14: 0000000000000000
x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000000 x10: 0000000000000001
x9 : 0000000000000228 x8 : 000000000000000c
x7 : 0000000000000fff x6 : ffff807a308ed6b0
x5 : ffff7e01f10967c0 x4 : 0000000000000018
x3 : d0bc661572445600 x2 : 0000000000000000
x1 : 000000001b2e0200 x0 : 0000000000000000
Call trace:
ocfs2_write_end_nolock+0x2b8/0x550 [ocfs2]
ocfs2_write_end+0x4c/0x80 [ocfs2]
generic_perform_write+0x108/0x1a8
__generic_file_write_iter+0x158/0x1c8
ocfs2_file_write_iter+0x668/0x950 [ocfs2]
__vfs_write+0x11c/0x190
vfs_write+0xac/0x1c0
ksys_write+0x6c/0xd8
__arm64_sys_write+0x24/0x30
el0_svc_common+0x78/0x130
el0_svc_handler+0x38/0x78
el0_svc+0x8/0xcTo prevent NULL pointer dereference in this situation, we use is_handle_aborted() before using handle->h_transaction->t_tid.
--- fs/ocfs2/journal.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ocfs2/journal.h +5 -3
@@ -637,9 +637,11 @@ static inline void ocfs2_update_inode_fsync_trans(handle_t *handle, {struct ocfs2_inode_info *oi =OCFS2_I (inode); - oi->i_sync_tid = handle->h_transaction->t_tid; -if (datasync) - oi->i_datasync_tid = handle->h_transaction->t_tid; +if (!is_handle_aborted (handle)) { + oi->i_sync_tid = handle->h_transaction->t_tid; +if (datasync) + oi->i_datasync_tid = handle->h_transaction->t_tid; + } }#endif /* OCFS2_JOURNAL_H */
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 107/165 lib/scatterlist.c: adjust indentation in __sg_alloc_table
In reply to Greg Kroah-HartmanFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 4e456fee215677584cafa7f67298a76917e89c64 ]
Clang warns:
../lib/scatterlist.c:314:5: warning: misleading indentation; statement is not part of the previous 'if' [-Wmisleading-indentation]
return -ENOMEM;
^
../lib/scatterlist.c:311:4: note: previous statement is here
if (prv)
^1 warning generated.
This warning occurs because there is a space before the tab on this line. Remove it so that the indentation is consistent with the Linux kernel coding style and clang no longer warns.
--- lib/scatterlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/scatterlist.c +1 -1
@@ -317,7 +317,7 @@ int __sg_alloc_table(struct sg_table *table, unsigned int nents,if (prv) table->nents = ++table->orig_nents; -return -ENOMEM ; +return -ENOMEM ; }sg_init_table (sg, alloc_size);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 108/165 reiserfs: prevent NULL pointer dereference in reiserfs_insert_item()
In reply to Greg Kroah-HartmanFrom: Yunfeng Ye <[email protected]>
[ Upstream commit aacee5446a2a1aa35d0a49dab289552578657fb4 ]
The variable inode may be NULL in reiserfs_insert_item(), but there is no check before accessing the member of inode.
Fix this by adding NULL pointer check before calling reiserfs_debug().
--- fs/reiserfs/stree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/reiserfs/stree.c +2 -1
@@ -2249,7 +2249,8 @@ error_out:/* also releases the path */ unfix_nodes (&s_ins_balance);#ifdef REISERQUOTA_DEBUG -reiserfs_debug (th->t_super,REISERFS_DEBUG_CODE , +if (inode) +reiserfs_debug (th->t_super,REISERFS_DEBUG_CODE ,"reiserquota insert_item(): freeing %u id=%u type=%c" , quota_bytes, inode->i_uid,head2type (ih));#endif
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 109/165 bcache: explicity type cast in bset_bkey_last()
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
[ Upstream commit 7c02b0055f774ed9afb6e1c7724f33bf148ffdc0 ]
In bset.h, macro bset_bkey_last() is defined as,
bkey_idx((struct bkey *) (i)->d, (i)->keys)
Parameter i can be variable type of data structure, the macro always works once the type of struct i has member 'd' and 'keys'.
bset_bkey_last() is also used in macro csum_set() to calculate the checksum of a on-disk data structure. When csum_set() is used to calculate checksum of on-disk bcache super block, the parameter 'i' data type is struct cache_sb_disk. Inside struct cache_sb_disk (also in struct cache_sb) the member keys is __u16 type. But bkey_idx() expects unsigned int (a 32bit width), so there is problem when sending parameters via stack to call bkey_idx().
Sparse tool from Intel 0day kbuild system reports this incompatible problem. bkey_idx() is part of user space API, so the simplest fix is to cast the (i)->keys to unsigned int type in macro bset_bkey_last().
--- drivers/md/bcache/bset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/bcache/bset.h +2 -1
@@ -380,7 +380,8 @@ void bch_btree_keys_stats(struct btree_keys *, struct bset_stats *);/* Bkey utility code */ -#define bset_bkey_last (i) bkey_idx((struct bkey *) (i)->d, (i)->keys) +#define bset_bkey_last (i) bkey_idx((struct bkey *) (i)->d, \ + (unsigned int)(i)->keys)static inline struct bkey *bset_bkey_idx (struct bset *i,unsigned idx) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 110/165 irqchip/gic-v3-its: Reference to its_invall_cmd descriptor when building INVALL
In reply to Greg Kroah-HartmanFrom: Zenghui Yu <[email protected]>
[ Upstream commit 107945227ac5d4c37911c7841b27c64b489ce9a9 ]
It looks like an obvious mistake to use its_mapc_cmd descriptor when building the INVALL command block. It so far worked by luck because both its_mapc_cmd.col and its_invall_cmd.col sit at the same offset of the ITS command descriptor, but we should not rely on it.
--- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +1 -1
@@ -365,7 +365,7 @@ static struct its_collection *its_build_invall_cmd(struct its_cmd_block *cmd, struct its_cmd_desc *desc) {its_encode_cmd (cmd,GITS_CMD_INVALL ); -its_encode_collection (cmd, desc->its_mapc_cmd.col->col_id); +its_encode_collection (cmd, desc->its_invall_cmd.col->col_id);its_fixup_cmd (cmd);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 111/165 iwlwifi: mvm: Fix thermal zone registration
In reply to Greg Kroah-HartmanFrom: Andrei Otcheretianski <[email protected]>
[ Upstream commit baa6cf8450b72dcab11f37c47efce7c5b9b8ad0f ]
Use a unique name when registering a thermal zone. Otherwise, with multiple NICS, we hit the following warning during the unregistration.
WARNING: CPU: 2 PID: 3525 at fs/sysfs/group.c:255 RIP: 0010:sysfs_remove_group+0x80/0x90 Call Trace: dpm_sysfs_remove+0x57/0x60 device_del+0x5a/0x350 ? sscanf+0x4e/0x70 device_unregister+0x1a/0x60 hwmon_device_unregister+0x4a/0xa0 thermal_remove_hwmon_sysfs+0x175/0x1d0 thermal_zone_device_unregister+0x188/0x1e0 iwl_mvm_thermal_exit+0xe7/0x100 [iwlmvm] iwl_op_mode_mvm_stop+0x27/0x180 [iwlmvm] _iwl_op_mode_stop.isra.3+0x2b/0x50 [iwlwifi] iwl_opmode_deregister+0x90/0xa0 [iwlwifi] __exit_compat+0x10/0x2c7 [iwlmvm] __x64_sys_delete_module+0x13f/0x270 do_syscall_64+0x5a/0x110 entry_SYSCALL_64_after_hwframe+0x44/0xa9
--- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/mvm/tt.c +3 -1
@@ -736,7 +736,8 @@ static struct thermal_zone_device_ops tzone_ops = {static void iwl_mvm_thermal_zone_register (struct iwl_mvm *mvm) {int i; -char name[] ="iwlwifi" ; +char name[16 ]; +static atomic_t counter =ATOMIC_INIT (0 );if (!iwl_mvm_is_tt_in_fw (mvm)) { mvm->tz_device.tzone =NULL ;
@@ -746,6 +747,7 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)BUILD_BUG_ON (ARRAY_SIZE (name) >=THERMAL_NAME_LENGTH ); +sprintf (name,"iwlwifi_%u" ,atomic_inc_return (&counter) &0xFF ); mvm->tz_device.tzone = thermal_zone_device_register(name, IWL_MAX_DTS_TRIPS, IWL_WRITABLE_TRIPS_MSK,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 112/165 microblaze: Prevent the overflow of the start
In reply to Greg Kroah-HartmanFrom: Shubhrajyoti Datta <[email protected]>
[ Upstream commit 061d2c1d593076424c910cb1b64ecdb5c9a6923f ]
In case the start + cache size is more than the max int the start overflows.
Prevent the same.
--- arch/microblaze/kernel/cpu/cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/microblaze/kernel/cpu/cache.c +2 -1
@@ -92,7 +92,8 @@ static inline void __disable_dcache_nomsr(void)#define CACHE_LOOP_LIMITS (start, end, cache_line_length, cache_size) \ do { \ int align = ~(cache_line_length - 1); \ - end = min(start + cache_size, end); \ + if (start < UINT_MAX - cache_size) \ + end = min(start + cache_size, end); \ start &= align; \ } while (0)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 113/165 brd: check and limit max_part par
In reply to Greg Kroah-HartmanFrom: Zhiqiang Liu <[email protected]>
[ Upstream commit c8ab422553c81a0eb070329c63725df1cd1425bc ]
In brd_init func, rd_nr num of brd_device are firstly allocated and add in brd_devices, then brd_devices are traversed to add each brd_device by calling add_disk func. When allocating brd_device, the disk->first_minor is set to i * max_part, if rd_nr * max_part is larger than MINORMASK, two different brd_device may have the same devt, then only one of them can be successfully added. when rmmod brd.ko, it will cause oops when calling brd_exit.
Follow those steps:
# modprobe brd rd_nr=3 rd_size=102400 max_part=1048576 # rmmod brd then, the oops will appear.
Oops log:
[ 726.613722] Call trace: [ 726.614175] kernfs_find_ns+0x24/0x130 [ 726.614852] kernfs_find_and_get_ns+0x44/0x68 [ 726.615749] sysfs_remove_group+0x38/0xb0 [ 726.616520] blk_trace_remove_sysfs+0x1c/0x28 [ 726.617320] blk_unregister_queue+0x98/0x100 [ 726.618105] del_gendisk+0x144/0x2b8 [ 726.618759] brd_exit+0x68/0x560 [brd] [ 726.619501] __arm64_sys_delete_module+0x19c/0x2a0 [ 726.620384] el0_svc_common+0x78/0x130 [ 726.621057] el0_svc_handler+0x38/0x78 [ 726.621738] el0_svc+0x8/0xc [ 726.622259] Code: aa0203f6 aa0103f7 aa1e03e0 d503201f (7940e260)
Here, we add brd_check_and_reset_par func to check and limit max_part par.
--V5->V6:
- remove useless code
V4->V5:(suggested by Ming Lei)
- make sure max_part is not larger than DISK_MAX_PARTS
V3->V4:(suggested by Ming Lei)
- remove useless change
- add one limit of max_part
V2->V3: (suggested by Ming Lei)
- clear .minors when running out of consecutive minor space in brd_alloc
- remove limit of rd_nr
V1->V2:
- add more checks in brd_check_par_valid as suggested by Ming Lei.
--- drivers/block/brd.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
drivers/block/brd.c +20 -2
@@ -581,6 +581,25 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)return kobj; } +static inline void brd_check_and_reset_par (void ) +{ +if (unlikely (!max_part)) + max_part =1 ; + +/* +* make sure 'max_part' can be divided exactly by (1U << MINORBITS), +* otherwise, it is possiable to get same dev_t when adding partitions. +*/ +if ((1U <<MINORBITS ) % max_part !=0 ) + max_part =1UL <<fls (max_part); + +if (max_part >DISK_MAX_PARTS ) { +pr_info ("brd: max_part can't be larger than %d, reset max_part = %d.\n" , +DISK_MAX_PARTS ,DISK_MAX_PARTS ); + max_part =DISK_MAX_PARTS ; + } +} +static int __init brd_init (void ) {struct brd_device *brd, *next;
@@ -604,8 +623,7 @@ static int __init brd_init(void)if (register_blkdev (RAMDISK_MAJOR ,"ramdisk" ))return -EIO ; -if (unlikely (!max_part)) - max_part =1 ; +brd_check_and_reset_par ();for (i =0 ; i < rd_nr; i++) { brd =brd_alloc (i);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 114/165 help_next should increase position index
In reply to Greg Kroah-HartmanFrom: Vasily Averin <[email protected]>
[ Upstream commit 9f198a2ac543eaaf47be275531ad5cbd50db3edf ]
if seq_file .next fuction does not change position index, read after some lseek can generate unexpected output.
https://bugzilla.kernel.org/show_bug.cgi?id=206283
--- fs/orangefs/orangefs-debugfs.c | 1 + 1 file changed, 1 insertion(+)
fs/orangefs/orangefs-debugfs.c +1 -0
@@ -304,6 +304,7 @@ static void *help_start(struct seq_file *m, loff_t *pos)static void *help_next (struct seq_file *m,void *v,loff_t *pos) { + (*pos)++;gossip_debug (GOSSIP_DEBUGFS_DEBUG ,"help_next: start\n" );return NULL ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 115/165 selinux: ensure we cleanup the internal AVC counters on error in avc_update()
In reply to Greg Kroah-HartmanFrom: Jaihind Yadav <[email protected]>
[ Upstream commit 030b995ad9ece9fa2d218af4429c1c78c2342096 ]
In AVC update we don't call avc_node_kill() when avc_xperms_populate() fails, resulting in the avc->avc_cache.active_nodes counter having a false value. In last patch this changes was missed , so correcting it.
--- security/selinux/avc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/avc.c +1 -1
@@ -865,7 +865,7 @@ static int avc_update_node(u32 event, u32 perms, u8 driver, u8 xperm, u32 ssid,if (orig->ae.xp_node) { rc =avc_xperms_populate (node, orig->ae.xp_node);if (rc) { -kmem_cache_free (avc_node_cachep, node); +avc_node_kill (node); goto out_unlock; } }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 116/165 enic: prevent waking up stopped tx queues over watchdog reset
In reply to Greg Kroah-HartmanFrom: Firo Yang <[email protected]>
[ Upstream commit 0f90522591fd09dd201065c53ebefdfe3c6b55cb ]
Recent months, our customer reported several kernel crashes all preceding with following message:
NETDEV WATCHDOG: eth2 (enic): transmit queue 0 timed out Error message of one of those crashes:
BUG: unable to handle kernel paging request at ffffffffa007e090
After analyzing severl vmcores, I found that most of crashes are caused by memory corruption. And all the corrupted memory areas are overwritten by data of network packets. Moreover, I also found that the tx queues were enabled over watchdog reset.
After going through the source code, I found that in enic_stop(), the tx queues stopped by netif_tx_disable() could be woken up over a small time window between netif_tx_disable() and the napi_disable() by the following code path:
napi_poll->
enic_poll_msix_wq->
vnic_cq_service->
enic_wq_service->
netif_wake_subqueue(enic->netdev, q_number)->
test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state)In turn, upper netowrk stack could queue skb to ENIC NIC though enic_hard_start_xmit(). And this might introduce some race condition.
Our customer comfirmed that this kind of kernel crash doesn't occur over 90 days since they applied this patch.
--- drivers/net/ethernet/cisco/enic/enic_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/cisco/enic/enic_main.c +1 -1
@@ -1806,10 +1806,10 @@ static int enic_stop(struct net_device * }netif_carrier_off (netdev); -netif_tx_disable (netdev);if (vnic_dev_get_intr_mode (enic->vdev) ==VNIC_DEV_INTR_MODE_MSIX )for (i =0 ; i < enic->wq_count; i++)napi_disable (&enic->napi[enic_cq_wq (enic, i)]); +netif_tx_disable (netdev);if (!enic_is_dynamic (enic) && !enic_is_sriov_vf (enic))enic_dev_del_station_addr (enic);
Greg Kroah-Hartman
maintainerPATCH 117/165 net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS
In reply to Greg Kroah-HartmanFrom: Davide Caratti <[email protected]>
[ Upstream commit 1afa3cc90f8fb745c777884d79eaa1001d6927a6 ]
unlike other classifiers that can be offloaded (i.e. users can set flags like 'skip_hw' and 'skip_sw'), 'cls_matchall' doesn't validate the size of netlink attribute 'TCA_MATCHALL_FLAGS' provided by user: add a proper entry to mall_policy.
--- net/sched/cls_matchall.c | 1 + 1 file changed, 1 insertion(+)
net/sched/cls_matchall.c +1 -0
@@ -111,6 +111,7 @@ static unsigned long mall_get(struct tcfstatic const struct nla_policy mall_policy[TCA_MATCHALL_MAX +1 ] = { [TCA_MATCHALL_UNSPEC ] = { .type =NLA_UNSPEC }, [TCA_MATCHALL_CLASSID ] = { .type =NLA_U32 }, + [TCA_MATCHALL_FLAGS ] = { .type =NLA_U32 }, }; static int mall_set_parms(struct net *net, struct tcf_proto *tp,
Greg Kroah-Hartman
maintainerPATCH 118/165 net/sched: flower: add missing validation of TCA_FLOWER_FLAGS
In reply to Greg Kroah-HartmanFrom: Davide Caratti <[email protected]>
[ Upstream commit e2debf0852c4d66ba1a8bde12869b196094c70a7 ]
unlike other classifiers that can be offloaded (i.e. users can set flags like 'skip_hw' and 'skip_sw'), 'cls_flower' doesn't validate the size of netlink attribute 'TCA_FLOWER_FLAGS' provided by user: add a proper entry to fl_policy.
--- net/sched/cls_flower.c | 1 + 1 file changed, 1 insertion(+)
net/sched/cls_flower.c +1 -0
@@ -364,6 +364,7 @@ static const struct nla_policy fl_policy [TCA_FLOWER_KEY_TCP_DST_MASK] = { .type = NLA_U16 }, [TCA_FLOWER_KEY_UDP_SRC_MASK] = { .type = NLA_U16 }, [TCA_FLOWER_KEY_UDP_DST_MASK] = { .type = NLA_U16 }, + [TCA_FLOWER_FLAGS] = { .type = NLA_U32 }, }; static void fl_set_key_val(struct nlattr **tb,
Greg Kroah-Hartman
maintainerPATCH 119/165 floppy: check FDC index for errors before assigning it
In reply to Greg Kroah-HartmanFrom: Linus Torvalds <[email protected]>
commit 2e90ca68b0d2f5548804f22f0dd61145516171e3 upstream.
Jordy Zomer reported a KASAN out-of-bounds read in the floppy driver in wait_til_ready().
Which on the face of it can't happen, since as Willy Tarreau points out, the function does no particular memory access. Except through the FDCS macro, which just indexes a static allocation through teh current fdc, which is always checked against N_FDC.
Except the checking happens after we've already assigned the value.
The floppy driver is a disgrace (a lot of it going back to my original horrd "design"), and has no real maintainer. Nobody has the hardware, and nobody really cares. But it still gets used in virtual environment because it's one of those things that everybody supports.
The whole thing should be re-written, or at least parts of it should be seriously cleaned up. The 'current fdc' index, which is used by the FDCS macro, and which is often shadowed by a local 'fdc' variable, is a prime example of how not to write code.
But because nobody has the hardware or the motivation, let's just fix up the immediate problem with a nasty band-aid: test the fdc index before actually assigning it to the static 'fdc' variable.
--- drivers/block/floppy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/block/floppy.c +5 -2
@@ -848,14 +848,17 @@ static void reset_fdc_info(int mode)/* selects the fdc and drive, and enables the fdc's input/dma. */ static void set_fdc (int drive) { +unsigned int new_fdc = fdc; +if (drive >=0 && drive <N_DRIVE ) { - fdc =FDC (drive); + new_fdc =FDC (drive); current_drive = drive; } -if (fdc !=1 && fdc !=0 ) { +if (new_fdc >=N_FDC ) {pr_info ("bad fdc value\n" );return ; } + fdc = new_fdc;set_dor (fdc, ~0 ,8 );#if N_FDC >1 set_dor (1 - fdc, ~8 ,0 );
Greg Kroah-Hartman
maintainerPATCH 120/165 vt: selection, handle pending signals in paste_selection
In reply to Greg Kroah-HartmanFrom: Jiri Slaby <[email protected]>
commit 687bff0cd08f790d540cfb7b2349f0d876cdddec upstream.
When pasting a selection to a vt, the task is set as INTERRUPTIBLE while waiting for a tty to unthrottle. But signals are not handled at all. Normally, this is not a problem as tty_ldisc_receive_buf receives all the goods and a user has no reason to interrupt the task.
There are two scenarios where this matters:
1) when the tty is throttled and a signal is sent to the process, it spins on a CPU until the tty is unthrottled. schedule() does not really echedule, but returns immediately, of course.
2) when the sel_buffer becomes invalid, KASAN prevents any reads from it and the loop simply does not proceed and spins forever (causing the tty to throttle, but the code never sleeps, the same as above). This sometimes happens as there is a race in the sel_buffer handling code.
So add signal handling to this ioctl (TIOCL_PASTESEL) and return -EINTR in case a signal is pending.
--- drivers/tty/vt/selection.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/tty/vt/selection.c +6 -1
@@ -341,6 +341,7 @@ int paste_selection(struct tty_struct *tunsigned int count;struct tty_ldisc *ld;DECLARE_WAITQUEUE (wait, current); +int ret =0 ;console_lock ();poke_blanked_console ();
@@ -354,6 +355,10 @@ int paste_selection(struct tty_struct *tadd_wait_queue (&vc->paste_wait, &wait);while (sel_buffer && sel_buffer_lth > pasted) {set_current_state (TASK_INTERRUPTIBLE ); +if (signal_pending (current)) { + ret = -EINTR ; +break ; + }if (tty_throttled (tty)) {schedule ();continue ;
@@ -369,5 +374,5 @@ int paste_selection(struct tty_struct *ttty_buffer_unlock_exclusive (&vc->port);tty_ldisc_deref (ld); -return 0 ; +return ret; }
Greg Kroah-Hartman
maintainerPATCH 121/165 staging: android: ashmem: Disallow ashmem memory from being remapped
In reply to Greg Kroah-HartmanFrom: Suren Baghdasaryan <[email protected]>
commit 6d67b0290b4b84c477e6a2fc6e005e174d3c7786 upstream.
When ashmem file is mmapped, the resulting vma->vm_file points to the backing shmem file with the generic fops that do not check ashmem permissions like fops of ashmem do. If an mremap is done on the ashmem region, then the permission checks will be skipped. Fix that by disallowing mapping operation on the backing shmem file.
--- drivers/staging/android/ashmem.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/staging/android/ashmem.c +28 -0
@@ -370,8 +370,23 @@ static inline vm_flags_t calc_vm_may_fla_calc_vm_trans (prot,PROT_EXEC ,VM_MAYEXEC ); } +static int ashmem_vmfile_mmap (struct file *file,struct vm_area_struct *vma) +{ +/* do not allow to mmap ashmem backing shmem file directly */ +return -EPERM ; +} + +static unsigned long +ashmem_vmfile_get_unmapped_area (struct file *file,unsigned long addr, +unsigned long len,unsigned long pgoff, +unsigned long flags) +{ +return current->mm->get_unmapped_area (file, addr, len, pgoff, flags); +} +static int ashmem_mmap (struct file *file,struct vm_area_struct *vma) { +static struct file_operations vmfile_fops;struct ashmem_area *asma = file->private_data;int ret =0 ;
@@ -412,6 +427,19 @@ static int ashmem_mmap(struct file *file } vmfile->f_mode |=FMODE_LSEEK ; asma->file = vmfile; +/* +* override mmap operation of the vmfile so that it can't be +* remapped which would lead to creation of a new vma with no +* asma permission checks. Have to override get_unmapped_area +* as well to prevent VM_BUG_ON check for f_ops modification. +*/ +if (!vmfile_fops.mmap) { + vmfile_fops = *vmfile->f_op; + vmfile_fops.mmap = ashmem_vmfile_mmap; + vmfile_fops.get_unmapped_area = + ashmem_vmfile_get_unmapped_area; + } + vmfile->f_op = &vmfile_fops; }get_file (asma->file);
Greg Kroah-Hartman
maintainerPATCH 122/165 staging: vt6656: fix sign of rx_dbm to bb_pre_ed_rssi.
In reply to Greg Kroah-HartmanFrom: Malcolm Priestley <[email protected]>
commit 93134df520f23f4e9998c425b8987edca7016817 upstream.
bb_pre_ed_rssi is an u8 rx_dm always returns negative signed values add minus operator to always yield positive.
fixes issue where rx sensitivity is always set to maximum because the unsigned numbers were always greater then 100.
--- drivers/staging/vt6656/dpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vt6656/dpc.c +1 -1
@@ -140,7 +140,7 @@ int vnt_rx_data(struct vnt_private *privvnt_rf_rssi_to_dbm (priv, *rssi, &rx_dbm); - priv->bb_pre_ed_rssi = (u8 )rx_dbm +1 ; + priv->bb_pre_ed_rssi = (u8)-rx_dbm +1 ; priv->current_rssi = priv->bb_pre_ed_rssi; frame = skb_data +8 ;
Greg Kroah-Hartman
maintainerPATCH 123/165 xhci: Force Maximum Packet size for Full-speed bulk devices to valid range.
In reply to Greg Kroah-HartmanFrom: Mathias Nyman <[email protected]>
commit f148b9f402ef002b57bcff3964d45abc8ffb6c3f upstream.
A Full-speed bulk USB audio device (DJ-Tech CTRL) with a invalid Maximum Packet Size of 4 causes a xHC "Parameter Error" at enumeration.
This is because valid Maximum packet sizes for Full-speed bulk endpoints are 8, 16, 32 and 64 bytes. Hosts are not required to support other values than these. See usb 2 specs section 5.8.3 for details.
The device starts working after forcing the maximum packet size to 8. This is most likely the case with other devices as well, so force the maximum packet size to a valid range.
--- drivers/usb/host/xhci-mem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/usb/host/xhci-mem.c +9 -3
@@ -1532,9 +1532,15 @@ int xhci_endpoint_init(struct xhci_hcd */* Allow 3 retries for everything but isoc, set CErr = 3 */ if (!usb_endpoint_xfer_isoc (&ep->desc)) err_count =3 ; -/* Some devices get this wrong */ -if (usb_endpoint_xfer_bulk (&ep->desc) && udev->speed ==USB_SPEED_HIGH ) - max_packet =512 ; +/* HS bulk max packet should be 512, FS bulk supports 8, 16, 32 or 64 */ +if (usb_endpoint_xfer_bulk (&ep->desc)) { +if (udev->speed ==USB_SPEED_HIGH ) + max_packet =512 ; +if (udev->speed ==USB_SPEED_FULL ) { + max_packet =rounddown_pow_of_two (max_packet); + max_packet =clamp_val (max_packet,8 ,64 ); + } + }/* xHCI 1.0 and 1.1 indicates that ctrl ep avg TRB Length should be 8 */ if (usb_endpoint_xfer_control (&ep->desc) && xhci->hci_version >=0x100 ) avg_trb_len =8 ;
Greg Kroah-Hartman
maintainerPATCH 124/165 usb: uas: fix a plug & unplug racing
In reply to Greg Kroah-HartmanFrom: EJ Hsu <[email protected]>
commit 3e99862c05a9caa5a27969f41566b428696f5a9a upstream.
When a uas disk is plugged into an external hub, uas_probe() will be called by the hub thread to do the probe. It will first create a SCSI host and then do the scan for this host. During the scan, it will probe the LUN using SCSI INQUERY command which will be packed in the URB and submitted to uas disk.
There might be a chance that this external hub with uas disk attached is unplugged during the scan. In this case, uas driver will fail to submit the URB (due to the NOTATTACHED state of uas device) and try to put this SCSI command back to request queue waiting for next chance to run.
In normal case, this cycle will terminate when hub thread gets disconnection event and calls into uas_disconnect() accordingly. But in this case, uas_disconnect() will not be called because hub thread of external hub gets stuck waiting for the completion of this SCSI command. A deadlock happened.
In this fix, uas will call scsi_scan_host() asynchronously to avoid the blocking of hub thread.
--- drivers/usb/storage/uas.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/usb/storage/uas.c +22 -1
@@ -46,6 +46,7 @@ struct uas_dev_info {struct scsi_cmnd *cmnd[MAX_CMNDS ];spinlock_t lock;struct work_struct work; +struct work_struct scan_work;/* for async scanning */ };enum {
@@ -115,6 +116,17 @@ out:spin_unlock_irqrestore (&devinfo->lock, flags); } +static void uas_scan_work (struct work_struct *work) +{ +struct uas_dev_info *devinfo = + container_of(work, struct uas_dev_info, scan_work); +struct Scsi_Host *shost =usb_get_intfdata (devinfo->intf); + +dev_dbg (&devinfo->intf->dev,"starting scan\n" ); +scsi_scan_host (shost); +dev_dbg (&devinfo->intf->dev,"scan complete\n" ); +} +static void uas_add_work (struct uas_cmd_info *cmdinfo) {struct scsi_pointer *scp = (void *)cmdinfo;
@@ -989,6 +1001,7 @@ static int uas_probe(struct usb_interfacinit_usb_anchor (&devinfo->data_urbs);spin_lock_init (&devinfo->lock);INIT_WORK (&devinfo->work, uas_do_work); +INIT_WORK (&devinfo->scan_work, uas_scan_work); result =uas_configure_endpoints (devinfo);if (result)
@@ -1005,7 +1018,9 @@ static int uas_probe(struct usb_interfacif (result) goto free_streams; -scsi_scan_host (shost); +/* Submit the delayed_work for SCSI-device scanning */ +schedule_work (&devinfo->scan_work); +return result; free_streams:
@@ -1173,6 +1188,12 @@ static void uas_disconnect(struct usb_inusb_kill_anchored_urbs (&devinfo->data_urbs);uas_zap_pending (devinfo,DID_NO_CONNECT ); +/* +* Prevent SCSI scanning (if it hasn't started yet) +* or wait for the SCSI-scanning routine to stop. +*/ +cancel_work_sync (&devinfo->scan_work); +scsi_remove_host (shost);uas_free_streams (devinfo);scsi_host_put (shost);
Greg Kroah-Hartman
maintainerPATCH 125/165 USB: Fix novation SourceControl XL after suspend
In reply to Greg Kroah-HartmanFrom: Richard Dodd <[email protected]>
commit b692056db8ecc7f452b934f016c17348282b7699 upstream.
Currently, the SourceControl will stay in power-down mode after resuming from suspend. This patch resets the device after suspend to power it up.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -291,6 +291,9 @@ static const struct usb_device_id usb_qu/* INTEL VALUE SSD */ { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + /* novation SoundControl XL */ + { USB_DEVICE(0x1235, 0x0061), .driver_info = USB_QUIRK_RESET_RESUME }, + { }/* terminating entry must be last */ };
Greg Kroah-Hartman
maintainerPATCH 126/165 USB: hub: Dont record a connect-change event during reset-resume
In reply to Greg Kroah-HartmanFrom: Alan Stern <[email protected]>
commit 8099f58f1ecddf4f374f4828a3dff8397c7cbd74 upstream.
Paul Zimmerman reports that his USB Bluetooth adapter sometimes crashes following system resume, when it receives a Get-Device-Descriptor request while it is busy doing something else.
Such a request was added by commit a4f55d8b8c14 ("usb: hub: Check device descriptor before resusciation"). It gets sent when the hub driver's work thread checks whether a connect-change event on an enabled port really indicates a new device has been connected, as opposed to an old device momentarily disconnecting and then reconnecting (which can happen with xHCI host controllers, since they automatically enable connected ports).
The same kind of thing occurs when a port's power session is lost during system suspend. When the system wakes up it sees a connect-change event on the port, and if the child device's persist_enabled flag was set then hub_activate() sets the device's reset_resume flag as well as the port's bit in hub->change_bits. The reset-resume code then takes responsibility for checking that the same device is still attached to the port, and it does this as part of the device's resume pathway. By the time the hub driver's work thread starts up again, the device has already been fully reinitialized and is busy doing its own thing. There's no need for the work thread to do the same check a second time, and in fact this unnecessary check is what caused the problem that Paul observed.
Note that performing the unnecessary check is not actually a bug. Devices are supposed to be able to send descriptors back to the host even when they are busy doing something else. The underlying cause of Paul's problem lies in his Bluetooth adapter. Nevertheless, we shouldn't perform the same check twice in a row -- and as a nice side benefit, removing the extra check allows the Bluetooth adapter to work more reliably.
The work thread performs its check when it sees that the port's bit is set in hub->change_bits. In this situation that bit is interpreted as though a connect-change event had occurred on the port _after_ the reset-resume, which is not what actually happened.
One possible fix would be to make the reset-resume code clear the port's bit in hub->change_bits. But it seems simpler to just avoid setting the bit during hub_activate() in the first place. That's what this patch does.
(Proving that the patch is correct when CONFIG_PM is disabled requires a little thought. In that setting hub_activate() will be called only for initialization and resets, since there won't be any resumes or reset-resumes. During initialization and hub resets the hub doesn't have any child devices, and so this code path never gets executed.)
--- drivers/usb/core/hub.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/usb/core/hub.c +0 -5
@@ -1187,11 +1187,6 @@ static void hub_activate(struct usb_hub#ifdef CONFIG_PM udev->reset_resume =1 ;#endif -/* Don't set the change_bits when the device -* was powered off. -*/ -if (test_bit (port1, hub->power_bits)) -set_bit (port1, hub->change_bits); }else {/* The power session is gone; tell hub_wq */
Greg Kroah-Hartman
maintainerPATCH 127/165 staging: rtl8188eu: Fix potential security hole
In reply to Greg Kroah-HartmanFrom: Larry Finger <[email protected]>
commit 499c405b2b80bb3a04425ba3541d20305e014d3e upstream.
In routine rtw_hostapd_ioctl(), the user-controlled p->length is assumed to be at least the size of struct ieee_param size, but this assumption is never checked. This could result in out-of-bounds read/write on kernel heap in case a p->length less than the size of struct ieee_param is specified by the user. If p->length is allowed to be greater than the size of the struct, then a malicious user could be wasting kernel memory. Fixes commit a2c60d42d97c ("Add files for new driver - part 16").
Reported by: Pietro Oliva <[email protected]>
--- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +1 -1
@@ -2859,7 +2859,7 @@ static int rtw_hostapd_ioctl(struct net_ goto out; } -if (!p->pointer) { +if (!p->pointer || p->length !=sizeof (struct ieee_param )) { ret = -EINVAL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 128/165 staging: rtl8188eu: Fix potential overuse of kernel memory
In reply to Greg Kroah-HartmanFrom: Larry Finger <[email protected]>
commit 4ddf8ab8d15ddbc52eefb44eb64e38466ce1f70f upstream.
In routine wpa_supplicant_ioctl(), the user-controlled p->length is checked to be at least the size of struct ieee_param size, but the code does not detect the case where p->length is greater than the size of the struct, thus a malicious user could be wasting kernel memory. Fixes commit a2c60d42d97c ("Add files for new driver - part 16").
Reported by: Pietro Oliva <[email protected]>
Cc: Pietro Oliva <[email protected]>
Cc: Stable <[email protected]>
Fixes commit a2c60d42d97c ("Add files for new driver - part 16").
--- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +1 -1
@@ -2052,7 +2052,7 @@ static int wpa_supplicant_ioctl(struct nstruct ieee_param *param;uint ret =0 ; -if (p->length <sizeof (struct ieee_param ) || !p->pointer) { +if (!p->pointer || p->length !=sizeof (struct ieee_param )) { ret = -EINVAL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 129/165 x86/mce/amd: Publish the bank pointer only after setup has succeeded
In reply to Greg Kroah-HartmanFrom: Borislav Petkov <[email protected]>
commit 6e5cf31fbe651bed7ba1df768f2e123531132417 upstream.
threshold_create_bank() creates a bank descriptor per MCA error thresholding counter which can be controlled over sysfs. It publishes the pointer to that bank in a per-CPU variable and then goes on to create additional thresholding blocks if the bank has such.
However, that creation of additional blocks in allocate_threshold_blocks() can fail, leading to a use-after-free through the per-CPU pointer.
Therefore, publish that pointer only after all blocks have been setup successfully.
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +16 -17
@@ -879,8 +879,9 @@ static const char *get_name(unsigned intreturn buf_mcatype; } -static int allocate_threshold_blocks (unsigned int cpu,unsigned int bank, -unsigned int block,u32 address) +static int allocate_threshold_blocks (unsigned int cpu,struct threshold_bank *tb, +unsigned int bank,unsigned int block, +u32 address) {struct threshold_block *b =NULL ;u32 low, high;
@@ -924,16 +925,12 @@ static int allocate_threshold_blocks(unsINIT_LIST_HEAD (&b->miscj); -if (per_cpu (threshold_banks, cpu)[bank]->blocks) { -list_add (&b->miscj, - &per_cpu (threshold_banks, cpu)[bank]->blocks->miscj); - }else { -per_cpu (threshold_banks, cpu)[bank]->blocks = b; - } +if (tb->blocks) +list_add (&b->miscj, &tb->blocks->miscj); +else + tb->blocks = b; - err =kobject_init_and_add (&b->kobj, &threshold_ktype, -per_cpu (threshold_banks, cpu)[bank]->kobj, -get_name (bank, b)); + err =kobject_init_and_add (&b->kobj, &threshold_ktype, tb->kobj,get_name (bank, b));if (err) goto out_free; recurse:
@@ -941,7 +938,7 @@ recurse:if (!address)return 0 ; - err =allocate_threshold_blocks (cpu, bank, block, address); + err =allocate_threshold_blocks (cpu, tb, bank, block, address);if (err) goto out_free;
@@ -1026,8 +1023,6 @@ static int threshold_create_bank(unsigne goto out_free; } -per_cpu (threshold_banks, cpu)[bank] = b; -if (is_shared_bank (bank)) {atomic_set (&b->cpus,1 );
@@ -1038,9 +1033,13 @@ static int threshold_create_bank(unsigne } } - err =allocate_threshold_blocks (cpu, bank,0 , msr_ops.misc (bank)); -if (!err) - goto out; + err =allocate_threshold_blocks (cpu, b, bank,0 , msr_ops.misc (bank)); +if (err) + goto out_free; + +per_cpu (threshold_banks, cpu)[bank] = b; + +return 0 ; out_free:kfree (b);
Greg Kroah-Hartman
maintainerPATCH 130/165 x86/mce/amd: Fix kobject lifetime
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 51dede9c05df2b78acd6dcf6a17d21f0877d2d7b upstream.
Accessing the MCA thresholding controls in sysfs concurrently with CPU hotplug can lead to a couple of KASAN-reported issues:
BUG: KASAN: use-after-free in sysfs_file_ops+0x155/0x180 Read of size 8 at addr ffff888367578940 by task grep/4019
and
BUG: KASAN: use-after-free in show_error_count+0x15c/0x180 Read of size 2 at addr ffff888368a05514 by task grep/4454
for example. Both result from the fact that the threshold block creation/teardown code frees the descriptor memory itself instead of defining proper ->release function and leaving it to the driver core to take care of that, after all sysfs accesses have completed.
Do that and get rid of the custom freeing code, fixing the above UAFs in the process.
[ bp: write commit message. ]
--- arch/x86/kernel/cpu/mcheck/mce_amd.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
arch/x86/kernel/cpu/mcheck/mce_amd.c +11 -6
@@ -846,9 +846,12 @@ static const struct sysfs_ops threshold_ .store = store, }; +static void threshold_block_release (struct kobject *kobj); +static struct kobj_type threshold_ktype = { .sysfs_ops = &threshold_ops, .default_attrs = default_attrs, + .release = threshold_block_release, };static const char *get_name (unsigned int bank,struct threshold_block *b)
@@ -1073,8 +1076,12 @@ static int threshold_create_device(unsigreturn err; } -static void deallocate_threshold_block (unsigned int cpu, -unsigned int bank) +static void threshold_block_release (struct kobject *kobj) +{ +kfree (to_block (kobj)); +} + +static void deallocate_threshold_block (unsigned int cpu,unsigned int bank) {struct threshold_block *pos =NULL ;struct threshold_block *tmp =NULL ;
@@ -1084,13 +1091,11 @@ static void deallocate_threshold_block(ureturn ;list_for_each_entry_safe (pos, tmp, &head->blocks->miscj, miscj) { -kobject_put (&pos->kobj);list_del (&pos->miscj); -kfree (pos); +kobject_put (&pos->kobj); } -kfree (per_cpu (threshold_banks, cpu)[bank]->blocks); -per_cpu (threshold_banks, cpu)[bank]->blocks =NULL ; +kobject_put (&head->blocks->kobj); }static void __threshold_remove_blocks (struct threshold_bank *b)
Greg Kroah-Hartman
maintainerPATCH 131/165 tty/serial: atmel: manage shutdown in case of RS485 or ISO7816 mode
In reply to Greg Kroah-HartmanFrom: Nicolas Ferre <[email protected]>
commit 04b5bfe3dc94e64d0590c54045815cb5183fb095 upstream.
In atmel_shutdown() we call atmel_stop_rx() and atmel_stop_tx() functions. Prevent the rx restart that is implemented in RS485 or ISO7816 modes when calling atmel_stop_tx() by using the atomic information tasklet_shutdown that is already in place for this purpose.
--- drivers/tty/serial/atmel_serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/atmel_serial.c +2 -1
@@ -501,7 +501,8 @@ static void atmel_stop_tx(struct uart_poatmel_uart_writel (port,ATMEL_US_IDR , atmel_port->tx_done_mask);if (atmel_uart_is_half_duplex (port)) -atmel_start_rx (port); +if (!atomic_read (&atmel_port->tasklet_shutdown)) +atmel_start_rx (port); }
Greg Kroah-Hartman
maintainerPATCH 132/165 tty: serial: imx: setup the correct sg entry for tx dma
In reply to Greg Kroah-HartmanFrom: Fugang Duan <[email protected]>
commit f76707831829530ffdd3888bebc108aecefccaa0 upstream.
There has oops as below happen on i.MX8MP EVK platform that has 6G bytes DDR memory.
when (xmit->tail < xmit->head) && (xmit->head == 0), it setups one sg entry with sg->length is zero:
sg_set_buf(sgl + 1, xmit->buf, xmit->head);
if xmit->buf is allocated from >4G address space, and SDMA only support <4G address space, then dma_map_sg() will call swiotlb_map() to do bounce buffer copying and mapping.
But swiotlb_map() don't allow sg entry's length is zero, otherwise report BUG_ON().
So the patch is to correct the tx DMA scatter list.
Oops:
[ 287.675715] kernel BUG at kernel/dma/swiotlb.c:497! [ 287.680592] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP [ 287.686075] Modules linked in: [ 287.689133] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.4.3-00016-g3fdc4e0-dirty #10 [ 287.696872] Hardware name: FSL i.MX8MP EVK (DT) [ 287.701402] pstate: 80000085 (Nzcv daIf -PAN -UAO) [ 287.706199] pc : swiotlb_tbl_map_single+0x1fc/0x310 [ 287.711076] lr : swiotlb_map+0x60/0x148 [ 287.714909] sp : ffff800010003c00 [ 287.718221] x29: ffff800010003c00 x28: 0000000000000000 [ 287.723533] x27: 0000000000000040 x26: ffff800011ae0000 [ 287.728844] x25: ffff800011ae09f8 x24: 0000000000000000 [ 287.734155] x23: 00000001b7af9000 x22: 0000000000000000 [ 287.739465] x21: ffff000176409c10 x20: 00000000001f7ffe [ 287.744776] x19: ffff000176409c10 x18: 000000000000002e [ 287.750087] x17: 0000000000000000 x16: 0000000000000000 [ 287.755397] x15: 0000000000000000 x14: 0000000000000000 [ 287.760707] x13: ffff00017f334000 x12: 0000000000000001 [ 287.766018] x11: 00000000001fffff x10: 0000000000000000 [ 287.771328] x9 : 0000000000000003 x8 : 0000000000000000 [ 287.776638] x7 : 0000000000000000 x6 : 0000000000000000 [ 287.781949] x5 : 0000000000200000 x4 : 0000000000000000 [ 287.787259] x3 : 0000000000000001 x2 : 00000001b7af9000 [ 287.792570] x1 : 00000000fbfff000 x0 : 0000000000000000 [ 287.797881] Call trace: [ 287.800328] swiotlb_tbl_map_single+0x1fc/0x310 [ 287.804859] swiotlb_map+0x60/0x148 [ 287.808347] dma_direct_map_page+0xf0/0x130 [ 287.812530] dma_direct_map_sg+0x78/0xe0 [ 287.816453] imx_uart_dma_tx+0x134/0x2f8 [ 287.820374] imx_uart_dma_tx_callback+0xd8/0x168 [ 287.824992] vchan_complete+0x194/0x200 [ 287.828828] tasklet_action_common.isra.0+0x154/0x1a0 [ 287.833879] tasklet_action+0x24/0x30 [ 287.837540] __do_softirq+0x120/0x23c [ 287.841202] irq_exit+0xb8/0xd8 [ 287.844343] __handle_domain_irq+0x64/0xb8 [ 287.848438] gic_handle_irq+0x5c/0x148 [ 287.852185] el1_irq+0xb8/0x180 [ 287.855327] cpuidle_enter_state+0x84/0x360 [ 287.859508] cpuidle_enter+0x34/0x48 [ 287.863083] call_cpuidle+0x18/0x38 [ 287.866571] do_idle+0x1e0/0x280 [ 287.869798] cpu_startup_entry+0x20/0x40 [ 287.873721] rest_init+0xd4/0xe0 [ 287.876949] arch_call_rest_init+0xc/0x14 [ 287.880958] start_kernel+0x420/0x44c [ 287.884622] Code: 9124c021 9417aff8 a94363f7 17ffffd5 (d4210000) [ 287.890718] ---[ end trace 5bc44c4ab6b009ce ]--- [ 287.895334] Kernel panic - not syncing: Fatal exception in interrupt [ 287.901686] SMP: stopping secondary CPUs [ 288.905607] SMP: failed to stop secondary CPUs 0-1 [ 288.910395] Kernel Offset: disabled [ 288.913882] CPU features: 0x0002,2000200c [ 288.917888] Memory Limit: none [ 288.920944] ---[ end Kernel panic - not syncing: Fatal exception in interrupt ]---
--- drivers/tty/serial/imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/imx.c +1 -1
@@ -532,7 +532,7 @@ static void imx_dma_tx(struct imx_port * sport->tx_bytes =uart_circ_chars_pending (xmit); -if (xmit->tail < xmit->head) { +if (xmit->tail < xmit->head || xmit->head ==0 ) { sport->dma_tx_nents =1 ;sg_init_one (sgl, xmit->buf + xmit->tail, sport->tx_bytes); }else {
Greg Kroah-Hartman
maintainerPATCH 133/165 Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()"
In reply to Greg Kroah-HartmanFrom: Ioanna Alifieraki <[email protected]>
commit edf28f4061afe4c2d9eb1c3323d90e882c1d6800 upstream.
This reverts commit a97955844807e327df11aa33869009d14d6b7de0.
Commit a97955844807 ("ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()") removes a lock that is needed. This leads to a process looping infinitely in exit_sem() and can also lead to a crash. There is a reproducer available in [1] and with the commit reverted the issue does not reproduce anymore.
Using the reproducer found in [1] is fairly easy to reach a point where one of the child processes is looping infinitely in exit_sem between for(;;) and if (semid == -1) block, while it's trying to free its last sem_undo structure which has already been freed by freeary().
Each sem_undo struct is on two lists: one per semaphore set (list_id) and one per process (list_proc). The list_id list tracks undos by semaphore set, and the list_proc by process.
Undo structures are removed either by freeary() or by exit_sem(). The freeary function is invoked when the user invokes a syscall to remove a semaphore set. During this operation freeary() traverses the list_id associated with the semaphore set and removes the undo structures from both the list_id and list_proc lists.
For this case, exit_sem() is called at process exit. Each process contains a struct sem_undo_list (referred to as "ulp") which contains the head for the list_proc list. When the process exits, exit_sem() traverses this list to remove each sem_undo struct. As in freeary(), whenever a sem_undo struct is removed from list_proc, it is also removed from the list_id list.
Removing elements from list_id is safe for both exit_sem() and freeary() due to sem_lock(). Removing elements from list_proc is not safe; freeary() locks &un->ulp->lock when it performs list_del_rcu(&un->list_proc) but exit_sem() does not (locking was removed by commit a97955844807 ("ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()").
This can result in the following situation while executing the reproducer [1] : Consider a child process in exit_sem() and the parent in freeary() (because of semctl(sid[i], NSEM, IPC_RMID)).
- The list_proc for the child contains the last two undo structs A and B (the rest have been removed either by exit_sem() or freeary()).
- The semid for A is 1 and semid for B is 2.
- exit_sem() removes A and at the same time freeary() removes B.
- Since A and B have different semid sem_lock() will acquire different locks for each process and both can proceed.
The bug is that they remove A and B from the same list_proc at the same time because only freeary() acquires the ulp lock. When exit_sem() removes A it makes ulp->list_proc.next to point at B and at the same time freeary() removes B setting B->semid=-1.
At the next iteration of for(;;) loop exit_sem() will try to remove B.
The only way to break from for(;;) is for (&un->list_proc == &ulp->list_proc) to be true which is not. Then exit_sem() will check if B->semid=-1 which is and will continue looping in for(;;) until the memory for B is reallocated and the value at B->semid is changed.
At that point, exit_sem() will crash attempting to unlink B from the lists (this can be easily triggered by running the reproducer [1] a second time).
To prove this scenario instrumentation was added to keep information about each sem_undo (un) struct that is removed per process and per semaphore set (sma).
CPU0 CPU1
[caller holds sem_lock(sma for A)] ... freeary() exit_sem() ... ... ... sem_lock(sma for B) spin_lock(A->ulp->lock) ... list_del_rcu(un_A->list_proc) list_del_rcu(un_B->list_proc)
Undo structures A and B have different semid and sem_lock() operations proceed. However they belong to the same list_proc list and they are removed at the same time. This results into ulp->list_proc.next pointing to the address of B which is already removed.
After reverting commit a97955844807 ("ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()") the issue was no longer reproducible.
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1694779
--- ipc/sem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
ipc/sem.c +2 -4
@@ -2159,11 +2159,9 @@ void exit_sem(struct task_struct *tsk)ipc_assert_locked_object (&sma->sem_perm);list_del (&un->list_id); -/* we are the last process using this ulp, acquiring ulp->lock -* isn't required. Besides that, we are also protected against -* IPC_RMID as we hold sma->sem_perm lock now -*/ +spin_lock (&ulp->lock);list_del_rcu (&un->list_proc); +spin_unlock (&ulp->lock);/* perform adjustments registered in un */ for (i =0 ; i < sma->sem_nsems; i++) {
Greg Kroah-Hartman
maintainerPATCH 134/165 xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms
In reply to Greg Kroah-HartmanFrom: Mathias Nyman <[email protected]>
commit a3ae87dce3a5abe0b57c811bab02b2564b574106 upstream.
Intel Comet Lake based platform require the XHCI_PME_STUCK_QUIRK quirk as well. Without this xHC can not enter D3 in runtime suspend.
--- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -53,6 +53,7 @@#define PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI 0x1aa8#define PCI_DEVICE_ID_INTEL_APL_XHCI 0x5aa8#define PCI_DEVICE_ID_INTEL_DNV_XHCI 0x19d0 +#define PCI_DEVICE_ID_INTEL_CML_XHCI 0xa3af#define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142
@@ -170,7 +171,8 @@ static void xhci_pci_quirks(struct devic pdev->device ==PCI_DEVICE_ID_INTEL_BROXTON_M_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_BROXTON_B_XHCI || pdev->device ==PCI_DEVICE_ID_INTEL_APL_XHCI || - pdev->device == PCI_DEVICE_ID_INTEL_DNV_XHCI)) { + pdev->device ==PCI_DEVICE_ID_INTEL_DNV_XHCI || + pdev->device == PCI_DEVICE_ID_INTEL_CML_XHCI)) { xhci->quirks |= XHCI_PME_STUCK_QUIRK; } if (pdev->vendor == PCI_VENDOR_ID_INTEL &&
Greg Kroah-Hartman
maintainerPATCH 135/165 KVM: x86: dont notify userspace IOAPIC on edge-triggered interrupt EOI
In reply to Greg Kroah-HartmanFrom: Miaohe Lin <[email protected]>
commit 7455a8327674e1a7c9a1f5dd1b0743ab6713f6d1 upstream.
Commit 13db77347db1 ("KVM: x86: don't notify userspace IOAPIC on edge EOI") said, edge-triggered interrupts don't set a bit in TMR, which means that IOAPIC isn't notified on EOI. And var level indicates level-triggered interrupt.
But commit 3159d36ad799 ("KVM: x86: use generic function for MSI parsing") replace var level with irq.level by mistake. Fix it by changing irq.level to irq.trig_mode.
--- arch/x86/kvm/irq_comm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/irq_comm.c +1 -1
@@ -436,7 +436,7 @@ void kvm_scan_ioapic_routes(struct kvm_vkvm_set_msi_irq (vcpu->kvm, entry, &irq); -if (irq.level &&kvm_apic_match_dest (vcpu,NULL ,0 , +if (irq.trig_mode &&kvm_apic_match_dest (vcpu,NULL ,0 , irq.dest_id, irq.dest_mode))__set_bit (irq.vector, ioapic_handled_vectors); }
Greg Kroah-Hartman
maintainerPATCH 136/165 VT_RESIZEX: get rid of field-by-field copyin
In reply to Greg Kroah-HartmanFrom: Al Viro <[email protected]>
[ Upstream commit 1b3bce4d6bf839304a90951b4b25a5863533bf2a ]
--- drivers/tty/vt/vt_ioctl.c | 68 ++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 41 deletions(-)
drivers/tty/vt/vt_ioctl.c +27 -41
@@ -850,58 +850,44 @@ int vt_ioctl(struct tty_struct *tty,case VT_RESIZEX : { -struct vt_consize __user *vtconsize = up; -ushort ll,cc,vlin,clin,vcol,ccol; +struct vt_consize v;if (!perm)return -EPERM ; -if (!access_ok (VERIFY_READ , vtconsize, -sizeof (struct vt_consize ))) { - ret = -EFAULT ; -break ; - } +if (copy_from_user (&v, up,sizeof (struct vt_consize ))) +return -EFAULT ;/* FIXME: Should check the copies properly */ -__get_user (ll, &vtconsize->v_rows); -__get_user (cc, &vtconsize->v_cols); -__get_user (vlin, &vtconsize->v_vlin); -__get_user (clin, &vtconsize->v_clin); -__get_user (vcol, &vtconsize->v_vcol); -__get_user (ccol, &vtconsize->v_ccol); - vlin = vlin ? vlin : vc->vc_scan_lines; -if (clin) { -if (ll) { -if (ll != vlin/clin) { -/* Parameters don't add up */ - ret = -EINVAL ; -break ; - } - }else - ll = vlin/clin; +if (!v.v_vlin) + v.v_vlin = vc->vc_scan_lines; +if (v.v_clin) { +int rows = v.v_vlin/v.v_clin; +if (v.v_rows != rows) { +if (v.v_rows)/* Parameters don't add up */ +return -EINVAL ; + v.v_rows = rows; + } } -if (vcol && ccol) { -if (cc) { -if (cc != vcol/ccol) { - ret = -EINVAL ; -break ; - } - }else - cc = vcol/ccol; +if (v.v_vcol && v.v_ccol) { +int cols = v.v_vcol/v.v_ccol; +if (v.v_cols != cols) { +if (v.v_cols) +return -EINVAL ; + v.v_cols = cols; + } } -if (clin >32 ) { - ret = -EINVAL ; -break ; - } - +if (v.v_clin >32 ) +return -EINVAL ; +for (i =0 ; i <MAX_NR_CONSOLES ; i++) {if (!vc_cons[i].d)continue ;console_lock (); -if (vlin) - vc_cons[i].d->vc_scan_lines = vlin; -if (clin) - vc_cons[i].d->vc_font.height = clin; +if (v.v_vlin) + vc_cons[i].d->vc_scan_lines = v.v_vlin; +if (v.v_clin) + vc_cons[i].d->vc_font.height = v.v_clin; vc_cons[i].d->vc_resize_user =1 ; -vc_resize (vc_cons[i].d, cc, ll); +vc_resize (vc_cons[i].d, v.v_cols, v.v_rows);console_unlock (); }break ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 137/165 vt: vt_ioctl: fix race in VT_RESIZEX
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 6cd1ed50efd88261298577cd92a14f2768eddeeb ]
We need to make sure vc_cons[i].d is not NULL after grabbing console_lock(), or risk a crash.
general protection fault, probably for non-canonical address 0xdffffc0000000068: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000340-0x0000000000000347] CPU: 1 PID: 19462 Comm: syz-executor.5 Not tainted 5.5.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:vt_ioctl+0x1f96/0x26d0 drivers/tty/vt/vt_ioctl.c:883 Code: 74 41 e8 bd a6 84 fd 48 89 d8 48 c1 e8 03 42 80 3c 28 00 0f 85 e4 04 00 00 48 8b 03 48 8d b8 40 03 00 00 48 89 fa 48 c1 ea 03 <42> 0f b6 14 2a 84 d2 74 09 80 fa 03 0f 8e b1 05 00 00 44 89 b8 40 RSP: 0018:ffffc900086d7bb0 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffffffff8c34ee88 RCX: ffffc9001415c000 RDX: 0000000000000068 RSI: ffffffff83f0e6e3 RDI: 0000000000000340 RBP: ffffc900086d7cd0 R08: ffff888054ce0100 R09: fffffbfff16a2f6d R10: ffff888054ce0998 R11: ffff888054ce0100 R12: 000000000000001d R13: dffffc0000000000 R14: 1ffff920010daf79 R15: 000000000000ff7f FS: 00007f7d13c12700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd477e3c38 CR3: 0000000095d0a000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: tty_ioctl+0xa37/0x14f0 drivers/tty/tty_io.c:2660 vfs_ioctl fs/ioctl.c:47 [inline] ksys_ioctl+0x123/0x180 fs/ioctl.c:763 __do_sys_ioctl fs/ioctl.c:772 [inline] __se_sys_ioctl fs/ioctl.c:770 [inline] __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:770 do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x45b399 Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007f7d13c11c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f7d13c126d4 RCX: 000000000045b399 RDX: 0000000020000080 RSI: 000000000000560a RDI: 0000000000000003 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 0000000000000666 R14: 00000000004c7f04 R15: 000000000075bf2c Modules linked in: ---[ end trace 80970faf7a67eb77 ]--- RIP: 0010:vt_ioctl+0x1f96/0x26d0 drivers/tty/vt/vt_ioctl.c:883 Code: 74 41 e8 bd a6 84 fd 48 89 d8 48 c1 e8 03 42 80 3c 28 00 0f 85 e4 04 00 00 48 8b 03 48 8d b8 40 03 00 00 48 89 fa 48 c1 ea 03 <42> 0f b6 14 2a 84 d2 74 09 80 fa 03 0f 8e b1 05 00 00 44 89 b8 40 RSP: 0018:ffffc900086d7bb0 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffffffff8c34ee88 RCX: ffffc9001415c000 RDX: 0000000000000068 RSI: ffffffff83f0e6e3 RDI: 0000000000000340 RBP: ffffc900086d7cd0 R08: ffff888054ce0100 R09: fffffbfff16a2f6d R10: ffff888054ce0998 R11: ffff888054ce0100 R12: 000000000000001d R13: dffffc0000000000 R14: 1ffff920010daf79 R15: 000000000000ff7f FS: 00007f7d13c12700(0000) GS:ffff8880ae900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffd477e3c38 CR3: 0000000095d0a000 CR4: 00000000001406e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
--- drivers/tty/vt/vt_ioctl.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/tty/vt/vt_ioctl.c +11 -6
@@ -879,15 +879,20 @@ int vt_ioctl(struct tty_struct *tty,return -EINVAL ;for (i =0 ; i <MAX_NR_CONSOLES ; i++) { +struct vc_data *vcp; +if (!vc_cons[i].d)continue ;console_lock (); -if (v.v_vlin) - vc_cons[i].d->vc_scan_lines = v.v_vlin; -if (v.v_clin) - vc_cons[i].d->vc_font.height = v.v_clin; - vc_cons[i].d->vc_resize_user =1 ; -vc_resize (vc_cons[i].d, v.v_cols, v.v_rows); + vcp = vc_cons[i].d; +if (vcp) { +if (v.v_vlin) + vcp->vc_scan_lines = v.v_vlin; +if (v.v_clin) + vcp->vc_font.height = v.v_clin; + vcp->vc_resize_user =1 ; +vc_resize (vcp, v.v_cols, v.v_rows); + }console_unlock (); }break ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 138/165 powerpc/tm: P9 disable transactionally suspended sigcontexts
In reply to Greg Kroah-HartmanFrom: Michael Neuling <[email protected]>
[ Upstream commit 92fb8690bd04cb421d987d246deac60eef85d272 ]
Unfortunately userspace can construct a sigcontext which enables suspend. Thus userspace can force Linux into a path where trechkpt is executed.
This patch blocks this from happening on POWER9 by sanity checking sigcontexts passed in.
ptrace doesn't have this problem as only MSR SE and BE can be changed via ptrace.
This patch also adds a number of WARN_ON()s in case we ever enter suspend when we shouldn't. This should not happen, but if it does the symptoms are soft lockup warnings which are not obviously TM related, so the WARN_ON()s should make it obvious what's happening.
--- arch/powerpc/kernel/process.c | 2 ++ arch/powerpc/kernel/signal_32.c | 4 ++++ arch/powerpc/kernel/signal_64.c | 5 +++++ 3 files changed, 11 insertions(+)
arch/powerpc/kernel/process.c +2 -0
@@ -890,6 +890,8 @@ static inline void tm_reclaim_task(struct task_struct *tsk)if (!MSR_TM_ACTIVE (thr->regs->msr)) goto out_and_saveregs; +WARN_ON (tm_suspend_disabled); + TM_DEBUG("--- tm_reclaim on pid %d (NIP=%lx, " "ccr=%lx, msr=%lx, trap=%lx)\n", tsk->pid, thr->regs->nip,
arch/powerpc/kernel/signal_32.c +4 -0
@@ -519,6 +519,8 @@ static int save_tm_user_regs(struct pt_regs *regs, {unsigned long msr = regs->msr; +WARN_ON (tm_suspend_disabled); +/* Remove TM bits from thread's MSR. The MSR in the sigcontext * just indicates to userland that we were doing a transaction, but we * don't want to return in transactional state. This also ensures
@@ -769,6 +771,8 @@ static long restore_tm_user_regs(struct pt_regs *regs,int i;#endif +if (tm_suspend_disabled) +return 1 ;/* * restore general registers but not including MSR or SOFTE. Also * take care of keeping r2 (TLS) intact if not a signal.
arch/powerpc/kernel/signal_64.c +5 -0
@@ -214,6 +214,8 @@ static long setup_tm_sigcontexts(struct sigcontext __user *sc,BUG_ON (!MSR_TM_ACTIVE (regs->msr)); +WARN_ON (tm_suspend_disabled); +/* Remove TM bits from thread's MSR. The MSR in the sigcontext * just indicates to userland that we were doing a transaction, but we * don't want to return in transactional state. This also ensures
@@ -430,6 +432,9 @@ static long restore_tm_sigcontexts(struct task_struct *tsk,BUG_ON (tsk != current); +if (tm_suspend_disabled) +return -EINVAL ; +/* copy the GPRs */ err |=__copy_from_user (regs->gpr, tm_sc->gp_regs,sizeof (regs->gpr)); err |= __copy_from_user(&tsk->thread.ckpt_regs, sc->gp_regs,
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 139/165 powerpc/tm: Fix endianness flip on trap
In reply to Greg Kroah-HartmanFrom: Gustavo Romero <[email protected]>
[ Upstream commit 1c200e63d055ec0125e44a5e386b9b78aada7eb3 ]
Currently it's possible that a thread on PPC64 LE has its endianness flipped inadvertently to Big-Endian resulting in a crash once the process is back from the signal handler.
If giveup_all() is called when regs->msr has the bits MSR.FP and MSR.VEC disabled (and hence MSR.VSX disabled too) it returns without calling check_if_tm_restore_required() which copies regs->msr to ckpt_regs->msr if the process caught a signal whilst in transactional mode. Then once in setup_tm_sigcontexts() MSR from ckpt_regs.msr is used, but since check_if_tm_restore_required() was not called previuosly, gp_regs[PT_MSR] gets a copy of invalid MSR bits as MSR in ckpt_regs was not updated from regs->msr and so is zeroed. Later when leaving the signal handler once in sys_rt_sigreturn() the TS bits of gp_regs[PT_MSR] are checked to determine if restore_tm_sigcontexts() must be called to pull in the correct MSR state into the user context. Because TS bits are zeroed restore_tm_sigcontexts() is never called and MSR restored from the user context on returning from the signal handler has the MSR.LE (the endianness bit) forced to zero (Big-Endian). That leads, for instance, to 'nop' being treated as an illegal instruction in the following sequence:
tbegin. beq 1f trap tend.
1: nop
on PPC64 LE machines and the process dies just after returning from the signal handler.
PPC64 BE is also affected but in a subtle way since forcing Big-Endian on a BE machine does not change the endianness.
This commit fixes the issue described above by ensuring that once in setup_tm_sigcontexts() the MSR used is from regs->msr instead of from ckpt_regs->msr and by ensuring that we pull in only the MSR.FP, MSR.VEC, and MSR.VSX bits from ckpt_regs->msr.
The fix was tested both on LE and BE machines and no regression regarding the powerpc/tm selftests was observed.
--- arch/powerpc/kernel/signal_64.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/kernel/signal_64.c +7 -1
@@ -207,7 +207,7 @@ static long setup_tm_sigcontexts(struct sigcontext __user *sc,elf_vrreg_t __user *tm_v_regs =sigcontext_vmx_regs (tm_sc);#endif struct pt_regs *regs = tsk->thread.regs; -unsigned long msr = tsk->thread.ckpt_regs.msr; +unsigned long msr = tsk->thread.regs->msr;long err =0 ;BUG_ON (tsk != current);
@@ -216,6 +216,12 @@ static long setup_tm_sigcontexts(struct sigcontext __user *sc,WARN_ON (tm_suspend_disabled); +/* Restore checkpointed FP, VEC, and VSX bits from ckpt_regs as +* it contains the correct FP, VEC, VSX state after we treclaimed +* the transaction and giveup_all() was called on reclaiming. +*/ + msr |= tsk->thread.ckpt_regs.msr & (MSR_FP |MSR_VEC |MSR_VSX ); +/* Remove TM bits from thread's MSR. The MSR in the sigcontext * just indicates to userland that we were doing a transaction, but we * don't want to return in transactional state. This also ensures
Signature · 1 line
2.20.1