4.14.172-stable review
Subsystems (7)
Greg Kroah-Hartman
maintainercover 4.14.172-stable review
This is the start of the stable review cycle for the 4.14.172 release. There are 237 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.14.172-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.14.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 4.14.172-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
Thomas Gleixner <[email protected]>
genirq/proc: Reject invalid affinity masks (again)
Joerg Roedel <[email protected]>
iommu/vt-d: Fix compile warning from intel-svm.h
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()
Colin Ian King <[email protected]>
staging: rtl8723bs: fix copy of overlapping memory
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
Josef Bacik <[email protected]>
btrfs: do not check delayed items are empty for single transaction cleanup
Josef Bacik <[email protected]>
btrfs: fix bytes_may_use underflow in prealloc error condtition
Miaohe Lin <[email protected]>
KVM: apic: avoid calculating pending eoi from an uninitialized val
Vitaly Kuznetsov <[email protected]>
KVM: nVMX: handle nested posted interrupts when apicv is disabled for L1
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
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
Andy Shevchenko <[email protected]>
serial: 8250: Check UPF_IRQ_SHARED in advance
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
Mathias Nyman <[email protected]>
xhci: apply XHCI_PME_STUCK_QUIRK to Intel Comet Lake platforms
Miaohe Lin <[email protected]>
KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI
Alex Deucher <[email protected]>
drm/amdgpu/soc15: fix xclk for raven
Gavin Shan <[email protected]>
mm/vmscan.c: don't round up scan size for online memory cgroup
Ioanna Alifieraki <[email protected]>
Revert "ipc,sem: remove uneeded sem_undo_list lock usage in exit_sem()"
Jani Nikula <[email protected]>
MAINTAINERS: Update drm/i915 bug filing URL
Johan Hovold <[email protected]>
serdev: ttyport: restore client ops on deregistration
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: rtl8723bs: Fix potential overuse of kernel memory
Larry Finger <[email protected]>
staging: rtl8723bs: Fix potential security hole
Larry Finger <[email protected]>
staging: rtl8188eu: Fix potential overuse of kernel memory
Larry Finger <[email protected]>
staging: rtl8188eu: Fix potential security hole
Hardik Gajjar <[email protected]>
USB: hub: Fix the broken detection of USB3 device in SMSC hub
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
Peter Chen <[email protected]>
usb: host: xhci: update event ring dequeue pointer on purpose
Mathias Nyman <[email protected]>
xhci: fix runtime pm enabling for quirky Intel hosts
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
Greg Kroah-Hartman <[email protected]>
USB: misc: iowarrior: add support for the 100 device
Greg Kroah-Hartman <[email protected]>
USB: misc: iowarrior: add support for the 28 and 28L devices
Greg Kroah-Hartman <[email protected]>
USB: misc: iowarrior: add support for 2 OEMed devices
Mika Westerberg <[email protected]>
thunderbolt: Prevent crash if non-active NVMem file is read
Eric Dumazet <[email protected]>
net/smc: fix leak of kernel memory to user space
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
Per Forlin <[email protected]>
net: dsa: tag_qca: Make sure there is headroom for tag
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()
Ido Schimmel <[email protected]>
mlxsw: spectrum_dpipe: Add missing error path
Michael S. Tsirkin <[email protected]>
virtio_balloon: prevent pfn array overflow
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
Xiubo Li <[email protected]>
ceph: check availability of mds cluster on mount after wait timeout
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: make sure ESHUTDOWN to be recorded in the journal superblock
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
Kai Vehmanen <[email protected]>
ALSA: hda/hdmi - add retry logic to parse_intel_hdmi()
John Garry <[email protected]>
irqchip/mbigen: Set driver .suppress_bind_attrs to avoid remove problems
Brandon Maier <[email protected]>
remoteproc: Initialize rproc_class before use
Anand Jain <[email protected]>
btrfs: device stats, log when stats are zeroed
David Sterba <[email protected]>
btrfs: safely advance counter when looking up bio csums
Johannes Thumshirn <[email protected]>
btrfs: fix possible NULL-pointer dereference in integrity checks
yu kuai <[email protected]>
pwm: Remove set but not set variable 'pwm'
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
Ard Biesheuvel <[email protected]>
x86/mm: Fix NX bit clearing issue in kernel_map_pages_in_pgd
Chao Yu <[email protected]>
f2fs: fix memleak of kobject
Thomas Gleixner <[email protected]>
watchdog/softlockup: Enforce that timestamp is valid on boot
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
Jaegeuk Kim <[email protected]>
f2fs: free sysfs kobject
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
Dan Carpenter <[email protected]>
drm/nouveau/secboot/gm20b: initialize pointer in gm20b_secboot_new()
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
Ard Biesheuvel <[email protected]>
efi/x86: Don't panic or BUG() on non-critical error conditions
Dmitry Osipenko <[email protected]>
soc/tegra: fuse: Correct straps' address for older Tegra124 device trees
Mike Marciniszyn <[email protected]>
IB/hfi1: Add software counter for ctxt0 seq drop
Jan Kara <[email protected]>
udf: Fix free space reporting for metadata and virtual partitions
Shuah Khan <[email protected]>
usbip: Fix unsafe unaligned pointer usage
Dingchen Zhang <[email protected]>
drm: remove the newline for CRC source name.
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
Takashi Iwai <[email protected]>
ALSA: sh: Fix unused variable warnings
Icenowy Zheng <[email protected]>
clk: sunxi-ng: add mux and pll notifiers for A64 CPU clock
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
Logan Gunthorpe <[email protected]>
dmaengine: Store module owner in dma_device struct
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
Can Guo <[email protected]>
scsi: ufs: Complete pending requests in host reset and restore path
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
Aditya Pakki <[email protected]>
fore200e: Fix incorrect checks of NULL pointer dereference
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
Andrey Smirnov <[email protected]>
ARM: dts: imx6: rdu2: Disable WP for USDHC2 and USDHC3
Manu Gautam <[email protected]>
arm64: dts: qcom: msm8996: Disable USB2 PHY suspend by core
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
Christian Borntraeger <[email protected]>
KVM: s390: ENOTSUPP -> EOPNOTSUPP fixups
Sun Ke <[email protected]>
nbd: add a flush_workqueue in nbd_start_device
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
Siddhesh Poyarekar <[email protected]>
kselftest: Minimise dependency of get_size on C library interfaces
Colin Ian King <[email protected]>
clocksource/drivers/bcm2835_timer: Fix memory leak of timer
John Keeping <[email protected]>
usb: dwc2: Fix IN FIFO allocation
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()
Sergey Senozhatsky <[email protected]>
char/random: silence a lockdep splat with printk()
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
Takashi Sakamoto <[email protected]>
ALSA: ctl: allow TLV read operation for callback type of element in locked case
Ritesh Harjani <[email protected]>
ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT
Zahari Petkov <[email protected]>
leds: pca963x: Fix open-drain initialization
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
Sean Christopherson <[email protected]>
KVM: nVMX: Use correct root level for nested EPT shadow page tables - again
Sasha Levin <[email protected]>
Revert "KVM: VMX: Add non-canonical check on writes to RTIT address MSRs"
Sasha Levin <[email protected]>
Revert "KVM: nVMX: Use correct root level for nested EPT shadow page tables"
Allen Pais <[email protected]>
scsi: qla2xxx: fix a potential NULL pointer dereference
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
Leon Romanovsky <[email protected]>
RDMA/core: Fix protection fault in get_pkey_idx_qp_list
Mike Marciniszyn <[email protected]>
IB/hfi1: Close window for pq and request coliding
Uwe Kleine-König <[email protected]>
serial: imx: Only handle irqs that are actually enabled
Uwe Kleine-König <[email protected]>
serial: imx: ensure that RX irqs are off if RX is off
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
Sean Christopherson <[email protected]>
KVM: nVMX: Use correct root level for nested EPT shadow page tables
Will Deacon <[email protected]>
arm64: ssbs: Fix context-switch when SSBS is present on all CPUs
David Sterba <[email protected]>
btrfs: log message when rw remount is attempted with unclean tree-log
David Sterba <[email protected]>
btrfs: print message when tree-log replay starts
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
Theodore Ts'o <[email protected]>
ext4: fix support for inode sizes > 1024 bytes
Andreas Dilger <[email protected]>
ext4: don't assume that mmp_nodename/bdevname have NUL
Nicolas Pitre <[email protected]>
ARM: 8723/2: always assume the "unified" syntax for assembly code
Suzuki K Poulose <[email protected]>
arm64: nofpsimd: Handle TIF_FOREIGN_FPSTATE flag cleanly
Suzuki K Poulose <[email protected]>
arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations
Suzuki K Poulose <[email protected]>
arm64: cpufeature: Set the FP/SIMD compat HWCAP bits properly
Arvind Sankar <[email protected]>
ALSA: usb-audio: Apply sample rate quirk for Audioengine D1
Benjamin Tissoires <[email protected]>
Input: synaptics - remove the LEN0049 dmi id from topbuttonpad list
Gaurav Agrawal <[email protected]>
Input: synaptics - enable SMBus on ThinkPad L470
Lyude Paul <[email protected]>
Input: synaptics - switch T470s to RMI4 by default
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()
Samuel Holland <[email protected]>
ASoC: sun8i-codec: Fix setting DAI data format
Takashi Iwai <[email protected]>
ALSA: hda: Use scnprintf() for printing texts for sysfs/procfs
Robin Murphy <[email protected]>
iommu/qcom: Fix bogus detach logic
Paolo Bonzini <[email protected]>
KVM: x86: emulate RDPID
-------------
Diffstat:
MAINTAINERS | 2 +- Makefile | 4 +- arch/arm/Kconfig | 9 +- arch/arm/Makefile | 6 +- arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi | 6 +- arch/arm/boot/dts/r8a7779.dtsi | 8 + arch/arm/include/asm/unified.h | 77 +- arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 + arch/arm64/include/asm/alternative.h | 32 +- arch/arm64/kernel/cpufeature.c | 52 +- arch/arm64/kernel/fpsimd.c | 15 +- arch/arm64/kernel/process.c | 7 + arch/arm64/kernel/ptrace.c | 21 + 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/s390/kvm/interrupt.c | 6 +- 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/kvm_host.h | 2 +- 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 | 9 +- arch/x86/kvm/svm.c | 7 +- arch/x86/kvm/vmx.c | 118 +- arch/x86/kvm/vmx/vmx.c | 8033 -------------------- arch/x86/lib/x86-opcode-map.txt | 2 +- arch/x86/mm/pageattr.c | 8 +- arch/x86/platform/efi/efi.c | 41 +- arch/x86/platform/efi/efi_64.c | 9 +- drivers/acpi/acpica/dsfield.c | 2 +- drivers/acpi/acpica/dswload.c | 21 + drivers/ata/ahci.c | 7 + drivers/ata/libata-core.c | 21 + drivers/atm/fore200e.c | 25 +- drivers/base/dd.c | 5 +- drivers/base/platform.c | 12 +- drivers/block/brd.c | 22 +- drivers/block/floppy.c | 7 +- drivers/block/nbd.c | 10 + drivers/char/random.c | 5 +- drivers/clk/qcom/clk-rcg2.c | 3 + drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 28 +- drivers/clocksource/bcm2835_timer.c | 5 +- drivers/devfreq/Kconfig | 3 +- drivers/devfreq/event/Kconfig | 2 +- drivers/dma/dmaengine.c | 4 +- drivers/gpio/gpio-grgpio.c | 10 +- drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 19 +- drivers/gpu/drm/amd/amdgpu/soc15.c | 7 +- drivers/gpu/drm/drm_debugfs_crc.c | 4 +- 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 +- .../gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c | 5 +- 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/core/security.c | 24 +- drivers/infiniband/hw/hfi1/chip.c | 10 + drivers/infiniband/hw/hfi1/chip.h | 1 + drivers/infiniband/hw/hfi1/driver.c | 1 + drivers/infiniband/hw/hfi1/file_ops.c | 52 +- drivers/infiniband/hw/hfi1/hfi.h | 7 +- drivers/infiniband/hw/hfi1/user_exp_rcv.c | 3 - drivers/infiniband/hw/hfi1/user_sdma.c | 17 +- drivers/infiniband/sw/rxe/rxe_verbs.h | 2 +- drivers/infiniband/ulp/isert/ib_isert.c | 12 + drivers/input/mouse/synaptics.c | 4 +- drivers/input/touchscreen/edt-ft5x06.c | 7 + drivers/iommu/arm-smmu-v3.c | 3 +- drivers/iommu/qcom_iommu.c | 28 +- drivers/irqchip/irq-gic-v3-its.c | 2 +- drivers/irqchip/irq-gic-v3.c | 9 +- drivers/irqchip/irq-mbigen.c | 1 + drivers/leds/leds-pca963x.c | 8 +- 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 +- .../net/ethernet/mellanox/mlxsw/spectrum_dpipe.c | 3 +- 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/pwm/pwm-pca9685.c | 4 - 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 | 4 + drivers/scsi/scsi_transport_iscsi.c | 26 +- drivers/scsi/ufs/ufshcd.c | 24 +- drivers/scsi/ufs/ufshcd.h | 2 + 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/rtl8723bs/hal/rtl8723bs_xmit.c | 5 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 4 +- drivers/staging/vt6656/dpc.c | 2 +- drivers/target/iscsi/iscsi_target.c | 16 +- drivers/thunderbolt/switch.c | 7 + drivers/tty/serdev/serdev-ttyport.c | 6 +- drivers/tty/serial/8250/8250_aspeed_vuart.c | 1 - drivers/tty/serial/8250/8250_core.c | 5 +- drivers/tty/serial/8250/8250_port.c | 4 + drivers/tty/serial/atmel_serial.c | 3 +- drivers/tty/serial/imx.c | 171 +- drivers/tty/synclink_gt.c | 18 +- drivers/tty/synclinkmp.c | 24 +- drivers/tty/tty_port.c | 5 +- drivers/tty/vt/selection.c | 9 +- drivers/tty/vt/vt_ioctl.c | 75 +- drivers/uio/uio_dmem_genirq.c | 6 +- drivers/usb/core/hub.c | 20 +- drivers/usb/core/hub.h | 1 + drivers/usb/core/quirks.c | 3 + drivers/usb/dwc2/gadget.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 | 10 +- drivers/usb/host/xhci-ring.c | 60 +- drivers/usb/misc/iowarrior.c | 31 +- drivers/usb/musb/omap2430.c | 2 - drivers/usb/storage/uas.c | 23 +- drivers/video/fbdev/pxa168fb.c | 6 +- drivers/virtio/virtio_balloon.c | 2 + drivers/vme/bridges/vme_fake.c | 30 +- drivers/xen/preempt.c | 4 +- fs/btrfs/check-integrity.c | 3 +- fs/btrfs/disk-io.c | 2 +- fs/btrfs/extent_map.c | 11 + fs/btrfs/file-item.c | 3 +- fs/btrfs/inode.c | 16 +- fs/btrfs/ordered-data.c | 7 +- fs/btrfs/super.c | 2 + fs/btrfs/volumes.c | 2 + fs/ceph/mds_client.c | 3 +- fs/ceph/super.c | 5 + 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/file.c | 10 +- fs/ext4/inode.c | 24 +- fs/ext4/migrate.c | 27 +- fs/ext4/mmp.c | 12 +- fs/ext4/namei.c | 8 + fs/ext4/super.c | 38 +- fs/f2fs/sysfs.c | 12 +- fs/jbd2/checkpoint.c | 2 +- fs/jbd2/commit.c | 50 +- fs/jbd2/journal.c | 24 +- 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/dmaengine.h | 2 + include/linux/intel-svm.h | 2 +- include/linux/libata.h | 1 + include/linux/list_nulls.h | 8 +- include/linux/rculist_nulls.h | 8 +- include/linux/tty.h | 2 + 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/irq/internals.h | 2 - kernel/irq/manage.c | 18 +- kernel/irq/proc.c | 22 + kernel/padata.c | 45 +- kernel/trace/ftrace.c | 5 +- kernel/trace/trace_events_trigger.c | 5 +- kernel/trace/trace_stat.c | 31 +- kernel/watchdog.c | 10 +- lib/scatterlist.c | 2 +- lib/stackdepot.c | 12 +- mm/vmscan.c | 9 +- net/dsa/tag_qca.c | 2 +- net/netfilter/xt_hashlimit.c | 10 + net/sched/cls_flower.c | 1 + net/sched/cls_matchall.c | 1 + net/smc/smc_diag.c | 5 +- scripts/kconfig/confdata.c | 2 +- security/selinux/avc.c | 2 +- sound/core/control.c | 5 +- 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/pci/hda/patch_hdmi.c | 7 +- sound/sh/aica.c | 4 +- sound/sh/sh_dac_audio.c | 3 - sound/soc/atmel/Kconfig | 2 + sound/soc/sunxi/sun8i-codec.c | 3 +- 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/testing/selftests/size/get_size.c | 24 +- tools/usb/usbip/src/usbip_network.c | 40 +- tools/usb/usbip/src/usbip_network.h | 12 +- 250 files changed, 1822 insertions(+), 9005 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/237 KVM: x86: emulate RDPID
From: 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
@@ -291,13 +291,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
@@ -3539,6 +3539,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 ;
@@ -4431,10 +4441,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
@@ -12322,6 +12322,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 2/237 iommu/qcom: Fix bogus detach logic
In reply to Greg Kroah-HartmanFrom: Robin Murphy <[email protected]>
commit faf305c51aeabd1ea2d7131e798ef5f55f4a7750 upstream.
Currently, the implementation of qcom_iommu_domain_free() is guaranteed to do one of two things: WARN() and leak everything, or dereference NULL and crash. That alone is terrible, but in fact the whole idea of trying to track the liveness of a domain via the qcom_domain->iommu pointer as a sanity check is full of fundamentally flawed assumptions. Make things robust and actually functional by not trying to be quite so clever.
--- drivers/iommu/qcom_iommu.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
drivers/iommu/qcom_iommu.c +12 -16
@@ -327,21 +327,19 @@ static void qcom_iommu_domain_free(struc {struct qcom_iommu_domain *qcom_domain =to_qcom_iommu_domain (domain); -if (WARN_ON (qcom_domain->iommu))/* forgot to detach? */ -return ; -iommu_put_dma_cookie (domain); -/* NOTE: unmap can be called after client device is powered off, -* for example, with GPUs or anything involving dma-buf. So we -* cannot rely on the device_link. Make sure the IOMMU is on to -* avoid unclocked accesses in the TLB inv path: -*/ -pm_runtime_get_sync (qcom_domain->iommu->dev); - -free_io_pgtable_ops (qcom_domain->pgtbl_ops); - -pm_runtime_put_sync (qcom_domain->iommu->dev); +if (qcom_domain->iommu) { +/* +* NOTE: unmap can be called after client device is powered +* off, for example, with GPUs or anything involving dma-buf. +* So we cannot rely on the device_link. Make sure the IOMMU +* is on to avoid unclocked accesses in the TLB inv path: +*/ +pm_runtime_get_sync (qcom_domain->iommu->dev); +free_io_pgtable_ops (qcom_domain->pgtbl_ops); +pm_runtime_put_sync (qcom_domain->iommu->dev); + }kfree (qcom_domain); }
@@ -386,7 +384,7 @@ static void qcom_iommu_detach_dev(structstruct qcom_iommu_domain *qcom_domain =to_qcom_iommu_domain (domain);unsigned i; -if (!qcom_domain->iommu) +if (WARN_ON (!qcom_domain->iommu))return ;pm_runtime_get_sync (qcom_iommu->dev);
@@ -397,8 +395,6 @@ static void qcom_iommu_detach_dev(structiommu_writel (ctx,ARM_SMMU_CB_SCTLR ,0 ); }pm_runtime_put_sync (qcom_iommu->dev); - - qcom_domain->iommu =NULL ; } static int qcom_iommu_map(struct iommu_domain *domain, unsigned long iova,
Greg Kroah-Hartman
maintainerPATCH 3/237 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
@@ -4002,7 +4002,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/237 ASoC: sun8i-codec: Fix setting DAI data format
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
commit 96781fd941b39e1f78098009344ebcd7af861c67 upstream.
Use the correct mask for this two-bit field. This fixes setting the DAI data format to RIGHT_J or DSP_A.
--- sound/soc/sunxi/sun8i-codec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sunxi/sun8i-codec.c +2 -1
@@ -71,6 +71,7 @@#define SUN8I_SYS_SR_CTRL_AIF1_FS_MASK GENMASK(15, 12)#define SUN8I_SYS_SR_CTRL_AIF2_FS_MASK GENMASK(11, 8) +#define SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT_MASK GENMASK(3, 2)#define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK GENMASK(5, 4)#define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK GENMASK(8, 6)#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK GENMASK(12, 9)
@@ -221,7 +222,7 @@ static int sun8i_set_fmt(struct snd_soc_return -EINVAL ; }regmap_update_bits (scodec->regmap,SUN8I_AIF1CLK_CTRL , -BIT (SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT ), +SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT_MASK , value <<SUN8I_AIF1CLK_CTRL_AIF1_DATA_FMT );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 5/237 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 6/237 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 7/237 Input: synaptics - switch T470s to RMI4 by default
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
commit bf502391353b928e63096127e5fd8482080203f5 upstream.
This supports RMI4 and everything seems to work, including the touchpad buttons. So, let's enable this by default.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -172,6 +172,7 @@ static const char * const smbus_pnp_ids["LEN004a" ,/* W541 */ "LEN005b" ,/* P50 */ "LEN005e" ,/* T560 */ +"LEN006c" ,/* T470s */ "LEN0071" ,/* T480 */ "LEN0072" ,/* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ "LEN0073", /* X1 Carbon G5 (Elantech) */
Greg Kroah-Hartman
maintainerPATCH 8/237 Input: synaptics - enable SMBus on ThinkPad L470
In reply to Greg Kroah-HartmanFrom: Gaurav Agrawal <[email protected]>
commit b8a3d819f872e0a3a0a6db0dbbcd48071042fb98 upstream.
Add touchpad LEN2044 to the list, as it is capable of working with psmouse.synaptics_intertouch=1
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -183,6 +183,7 @@ static const char * const smbus_pnp_ids["LEN0097" ,/* X280 -> ALPS trackpoint */ "LEN009b" ,/* T580 */ "LEN200f" ,/* T450s */ +"LEN2044" ,/* L470 */ "LEN2054" ,/* E480 */ "LEN2055" ,/* E580 */ "SYN3052", /* HP EliteBook 840 G4 */
Greg Kroah-Hartman
maintainerPATCH 9/237 Input: synaptics - remove the LEN0049 dmi id from topbuttonpad list
In reply to Greg Kroah-HartmanFrom: Benjamin Tissoires <[email protected]>
commit 5179a9dfa9440c1781816e2c9a183d1d2512dc61 upstream.
The Yoga 11e is using LEN0049, but it doesn't have a trackstick.
Thus, there is no need to create a software top buttons row.
However, it seems that the device works under SMBus, so keep it as part of the smbus_pnp_ids.
--- drivers/input/mouse/synaptics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/synaptics.c +1 -1
@@ -149,7 +149,6 @@ static const char * const topbuttonpad_p"LEN0042" ,/* Yoga */ "LEN0045" ,"LEN0047" , -"LEN0049" ,"LEN2000" ,/* S540 */ "LEN2001" ,/* Edge E431 */ "LEN2002", /* Edge E531 */
@@ -169,6 +168,7 @@ static const char * const smbus_pnp_ids[/* all of the topbuttonpad_pnp_ids are valid, we just add some extras */ "LEN0048" ,/* X1 Carbon 3 */ "LEN0046" ,/* X250 */ +"LEN0049" ,/* Yoga 11e */ "LEN004a" ,/* W541 */ "LEN005b" ,/* P50 */ "LEN005e", /* T560 */
Greg Kroah-Hartman
maintainerPATCH 10/237 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
@@ -1151,6 +1151,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 11/237 arm64: cpufeature: Set the FP/SIMD compat HWCAP bits properly
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit 7559950aef1ab8792c50797c6c5c7c5150a02460 upstream
We set the compat_elf_hwcap bits unconditionally on arm64 to include the VFP and NEON support. However, the FP/SIMD unit is optional on Arm v8 and thus could be missing. We already handle this properly in the kernel, but still advertise to the COMPAT applications that the VFP is available. Fix this to make sure we only advertise when we really have them.
--- arch/arm64/kernel/cpufeature.c | 52 +++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 7 deletions(-)
arch/arm64/kernel/cpufeature.c +45 -7
@@ -41,9 +41,7 @@ EXPORT_SYMBOL_GPL(elf_hwcap);#define COMPAT_ELF_HWCAP_DEFAULT \ (COMPAT_HWCAP_HALF|COMPAT_HWCAP_THUMB|\ COMPAT_HWCAP_FAST_MULT|COMPAT_HWCAP_EDSP|\ - COMPAT_HWCAP_TLS|COMPAT_HWCAP_VFP|\ - COMPAT_HWCAP_VFPv3|COMPAT_HWCAP_VFPv4|\ - COMPAT_HWCAP_NEON|COMPAT_HWCAP_IDIV|\ + COMPAT_HWCAP_TLS|COMPAT_HWCAP_IDIV|\ COMPAT_HWCAP_LPAE)unsigned int compat_elf_hwcap__read_mostly =COMPAT_ELF_HWCAP_DEFAULT ;unsigned int compat_elf_hwcap2__read_mostly ;
@@ -1134,17 +1132,30 @@ static const struct arm64_cpu_capabilities arm64_features[] = { {}, }; -#define HWCAP_CAP (reg, field, s, min_value, cap_type, cap) \ - { \ - .desc = #cap, \ - .type = ARM64_CPUCAP_SYSTEM_FEATURE, \ + +#define HWCAP_CPUID_MATCH (reg, field, s, min_value) \ .matches = has_cpuid_feature, \ .sys_reg = reg, \ .field_pos = field, \ .sign = s, \ .min_field_value = min_value, \ + +#define __HWCAP_CAP (name, cap_type, cap) \ + .desc = name, \ + .type = ARM64_CPUCAP_SYSTEM_FEATURE, \ .hwcap_type = cap_type, \ .hwcap = cap, \ + +#define HWCAP_CAP (reg, field, s, min_value, cap_type, cap) \ + { \ + __HWCAP_CAP(#cap, cap_type, cap) \ + HWCAP_CPUID_MATCH(reg, field, s, min_value) \ + } + +#define HWCAP_CAP_MATCH (match, cap_type, cap) \ + { \ + __HWCAP_CAP(#cap, cap_type, cap) \ + .matches = match, \ }static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = {
@@ -1177,8 +1188,35 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = { {}, }; +#ifdef CONFIG_COMPAT +static bool compat_has_neon (const struct arm64_cpu_capabilities *cap,int scope) +{ +/* +* Check that all of MVFR1_EL1.{SIMDSP, SIMDInt, SIMDLS} are available, +* in line with that of arm32 as in vfp_init(). We make sure that the +* check is future proof, by making sure value is non-zero. +*/ +u32 mvfr1; + +WARN_ON (scope ==SCOPE_LOCAL_CPU &&preemptible ()); +if (scope ==SCOPE_SYSTEM ) + mvfr1 =read_sanitised_ftr_reg (SYS_MVFR1_EL1 ); +else + mvfr1 =read_sysreg_s (SYS_MVFR1_EL1 ); + +return cpuid_feature_extract_unsigned_field (mvfr1,MVFR1_SIMDSP_SHIFT ) && +cpuid_feature_extract_unsigned_field (mvfr1,MVFR1_SIMDINT_SHIFT ) && +cpuid_feature_extract_unsigned_field (mvfr1,MVFR1_SIMDLS_SHIFT ); +} +#endif +static const struct arm64_cpu_capabilities compat_elf_hwcaps[] = { #ifdef CONFIG_COMPAT +HWCAP_CAP_MATCH (compat_has_neon,CAP_COMPAT_HWCAP ,COMPAT_HWCAP_NEON ), +HWCAP_CAP (SYS_MVFR1_EL1 ,MVFR1_SIMDFMAC_SHIFT ,FTR_UNSIGNED ,1 ,CAP_COMPAT_HWCAP , COMPAT_HWCAP_VFPv4), +/* Arm v8 mandates MVFR0.FPDP == {0, 2}. So, piggy back on this for the presence of VFP support */ +HWCAP_CAP (SYS_MVFR0_EL1 ,MVFR0_FPDP_SHIFT ,FTR_UNSIGNED ,2 ,CAP_COMPAT_HWCAP ,COMPAT_HWCAP_VFP ), +HWCAP_CAP (SYS_MVFR0_EL1 ,MVFR0_FPDP_SHIFT ,FTR_UNSIGNED ,2 ,CAP_COMPAT_HWCAP , COMPAT_HWCAP_VFPv3),HWCAP_CAP (SYS_ID_ISAR5_EL1 ,ID_ISAR5_AES_SHIFT ,FTR_UNSIGNED ,2 ,CAP_COMPAT_HWCAP2 ,COMPAT_HWCAP2_PMULL ),HWCAP_CAP (SYS_ID_ISAR5_EL1 ,ID_ISAR5_AES_SHIFT ,FTR_UNSIGNED ,1 ,CAP_COMPAT_HWCAP2 ,COMPAT_HWCAP2_AES ), HWCAP_CAP(SYS_ID_ISAR5_EL1, ID_ISAR5_SHA1_SHIFT, FTR_UNSIGNED, 1, CAP_COMPAT_HWCAP2, COMPAT_HWCAP2_SHA1),
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 12/237 arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit c9d66999f064947e6b577ceacc1eb2fbca6a8d3c upstream
When fp/simd is not supported on the system, fail the operations of FP/SIMD regsets.
--- arch/arm64/kernel/ptrace.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/arm64/kernel/ptrace.c +21 -0
@@ -624,6 +624,13 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,return 0 ; } +static int fpr_active (struct task_struct *target,const struct user_regset *regset) +{ +if (!system_supports_fpsimd ()) +return -ENODEV ; +return regset->n; +} +/* * TODO: update fp accessors for lazy context switching (sync/flush hwstate) */
@@ -634,6 +641,9 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,struct user_fpsimd_state *uregs; uregs = &target->thread.fpsimd_state.user_fpsimd; +if (!system_supports_fpsimd ()) +return -EINVAL ; +if (target == current)fpsimd_preserve_current_state ();
@@ -648,6 +658,9 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,struct user_fpsimd_state newstate = target->thread.fpsimd_state.user_fpsimd; +if (!system_supports_fpsimd ()) +return -EINVAL ; + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &newstate,0 ,-1 );if (ret)return ret;
@@ -740,6 +753,7 @@ static const struct user_regset aarch64_regsets[] = {*/ .size = sizeof(u32), .align = sizeof(u32), + .active = fpr_active, .get = fpr_get, .set = fpr_set },
@@ -914,6 +928,9 @@ static int compat_vfp_get(struct task_struct *target,compat_ulong_t fpscr;int ret, vregs_end_pos; +if (!system_supports_fpsimd ()) +return -EINVAL ; + uregs = &target->thread.fpsimd_state.user_fpsimd;if (target == current)
@@ -947,6 +964,9 @@ static int compat_vfp_set(struct task_struct *target,compat_ulong_t fpscr;int ret, vregs_end_pos; +if (!system_supports_fpsimd ()) +return -EINVAL ; + uregs = &target->thread.fpsimd_state.user_fpsimd; vregs_end_pos =VFP_STATE_SIZE -sizeof (compat_ulong_t);
@@ -1004,6 +1024,7 @@ static const struct user_regset aarch32_regsets[] = { .n = VFP_STATE_SIZE / sizeof(compat_ulong_t), .size = sizeof(compat_ulong_t), .align = sizeof(compat_ulong_t), + .active = fpr_active, .get = compat_vfp_get, .set = compat_vfp_set },
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 13/237 arm64: nofpsimd: Handle TIF_FOREIGN_FPSTATE flag cleanly
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit 52f73c383b2418f2d31b798e765ae7d596c35021 upstream
We detect the absence of FP/SIMD after an incapable CPU is brought up, and by then we have kernel threads running already with TIF_FOREIGN_FPSTATE set which could be set for early userspace applications (e.g, modprobe triggered from initramfs) and init. This could cause the applications to loop forever in do_nofity_resume() as we never clear the TIF flag, once we now know that we don't support FP.
Fix this by making sure that we clear the TIF_FOREIGN_FPSTATE flag for tasks which may have them set, as we would have done in the normal case, but avoiding touching the hardware state (since we don't support any).
--- arch/arm64/kernel/fpsimd.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
arch/arm64/kernel/fpsimd.c +13 -2
@@ -206,8 +206,19 @@ void fpsimd_preserve_current_state(void)*/ void fpsimd_restore_current_state (void ) { -if (!system_supports_fpsimd ()) +/* +* For the tasks that were created before we detected the absence of +* FP/SIMD, the TIF_FOREIGN_FPSTATE could be set via fpsimd_thread_switch(), +* e.g, init. This could be then inherited by the children processes. +* If we later detect that the system doesn't support FP/SIMD, +* we must clear the flag for all the tasks to indicate that the +* FPSTATE is clean (as we can't have one) to avoid looping for ever in +* do_notify_resume(). +*/ +if (!system_supports_fpsimd ()) { +clear_thread_flag (TIF_FOREIGN_FPSTATE );return ; + }local_bh_disable ();
@@ -229,7 +240,7 @@ void fpsimd_restore_current_state(void)*/ void fpsimd_update_current_state (struct fpsimd_state *state) { -if (!system_supports_fpsimd ()) +if (WARN_ON (!system_supports_fpsimd ()))return ;local_bh_disable ();
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 14/237 ARM: 8723/2: always assume the "unified" syntax for assembly code
In reply to Greg Kroah-HartmanFrom: Nicolas Pitre <[email protected]>
[ Upstream commit 75fea300d73ae5b18957949a53ec770daaeb6fc2 ]
The GNU assembler has implemented the "unified syntax" parsing since 2005. This "unified" syntax is required when the kernel is built in Thumb2 mode. However the "unified" syntax is a mixed bag of features, including not requiring a `#' prefix with immediate operands. This leads to situations where some code builds just fine in Thumb2 mode and fails to build in ARM mode if that prefix is missing. This behavior discrepancy makes build tests less valuable, forcing both ARM and Thumb2 builds for proper coverage.
Let's "fix" this issue by always using the "unified" syntax for both ARM and Thumb2 mode. Given that the documented minimum binutils version that properly builds the kernel is version 2.20 released in 2010, we can assume that any toolchain capable of building the latest kernel is also "unified syntax" capable.
Whith this, a bunch of macros used to mask some differences between both syntaxes can be removed, with the side effect of making LTO easier.
--- arch/arm/Kconfig | 7 +--- arch/arm/Makefile | 6 ++- arch/arm/include/asm/unified.h | 77 ++-------------------------------- 3 files changed, 8 insertions(+), 82 deletions(-)
arch/arm/Kconfig +1 -6
@@ -1533,12 +1533,10 @@ config THUMB2_KERNEL bool "Compile the kernel in Thumb-2 mode" if !CPU_THUMBONLY depends on (CPU_V7 || CPU_V7M) && !CPU_V6 && !CPU_V6K default y if CPU_THUMBONLY - select ARM_ASM_UNIFIED select ARM_UNWIND help By enabling this option, the kernel will be compiled in - Thumb-2 mode. A compiler/assembler that understand the unified - ARM-Thumb syntax is needed. + Thumb-2 mode. If unsure, say N.
@@ -1573,9 +1571,6 @@ config THUMB2_AVOID_R_ARM_THM_JUMP11 Unless you are sure your tools don't have this problem, say Y. -config ARM_ASM_UNIFIED - bool - config ARM_PATCH_IDIV bool "Runtime patch udiv/sdiv instructions into __aeabi_{u}idiv()" depends on CPU_32v7 && !XIP_KERNEL
arch/arm/Makefile +4 -2
@@ -115,9 +115,11 @@ ifeq ($(CONFIG_ARM_UNWIND),y) CFLAGS_ABI +=-funwind-tables endif +# Accept old syntax despite ".syntax unified" +AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) + ifeq ($(CONFIG_THUMB2_KERNEL),y) AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it) -AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) CFLAGS_ISA :=-mthumb $(AFLAGS_AUTOIT) $(AFLAGS_NOWARN) AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb # Work around buggy relocation from gas if requested:
@@ -125,7 +127,7 @@ ifeq ($(CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11),y) CFLAGS_MODULE +=-fno-optimize-sibling-calls endif else -CFLAGS_ISA :=$(call cc-option,-marm,) +CFLAGS_ISA :=$(call cc-option,-marm,) $(AFLAGS_NOWARN) AFLAGS_ISA :=$(CFLAGS_ISA) endif
arch/arm/include/asm/unified.h +3 -74
88 lines not on this page · raw message
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 15/237 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
@@ -120,10 +120,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); }/*
@@ -154,6 +154,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,
@@ -375,7 +376,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 16/237 ext4: fix support for inode sizes > 1024 bytes
In reply to Greg Kroah-HartmanFrom: Theodore Ts'o <[email protected]>
commit 4f97a68192bd33b9963b400759cef0ca5963af00 upstream.
A recent commit, 9803387c55f7 ("ext4: validate the debug_want_extra_isize mount option at parse time"), moved mount-time checks around. One of those changes moved the inode size check before the blocksize variable was set to the blocksize of the file system. After 9803387c55f7 was set to the minimum allowable blocksize, which in practice on most systems would be 1024 bytes. This cuased file systems with inode sizes larger than 1024 bytes to be rejected with a message:
EXT4-fs (sdXX): unsupported inode size: 4096
--- fs/ext4/super.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
fs/ext4/super.c +10 -8
@@ -3668,6 +3668,15 @@ static int ext4_fill_super(struct super_*/ sbi->s_li_wait_mult =EXT4_DEF_LI_WAIT_MULT ; + blocksize =BLOCK_SIZE <<le32_to_cpu (es->s_log_block_size); +if (blocksize <EXT4_MIN_BLOCK_SIZE || + blocksize >EXT4_MAX_BLOCK_SIZE ) { +ext4_msg (sb,KERN_ERR , +"Unsupported filesystem blocksize %d (%d log_block_size)" , + blocksize,le32_to_cpu (es->s_log_block_size)); + goto failed_mount; + } +if (le32_to_cpu (es->s_rev_level) ==EXT4_GOOD_OLD_REV ) { sbi->s_inode_size =EXT4_GOOD_OLD_INODE_SIZE ; sbi->s_first_ino =EXT4_GOOD_OLD_FIRST_INO ;
@@ -3685,6 +3694,7 @@ static int ext4_fill_super(struct super_ext4_msg (sb,KERN_ERR ,"unsupported inode size: %d" , sbi->s_inode_size); +ext4_msg (sb,KERN_ERR ,"blocksize: %d" , blocksize); goto failed_mount; }/*
@@ -3848,14 +3858,6 @@ static int ext4_fill_super(struct super_if (!ext4_feature_set_ok (sb, (sb_rdonly (sb)))) goto failed_mount; - blocksize =BLOCK_SIZE <<le32_to_cpu (es->s_log_block_size); -if (blocksize <EXT4_MIN_BLOCK_SIZE || - blocksize >EXT4_MAX_BLOCK_SIZE ) { -ext4_msg (sb,KERN_ERR , -"Unsupported filesystem blocksize %d (%d log_block_size)" , - blocksize,le32_to_cpu (es->s_log_block_size)); - goto failed_mount; - }if (le32_to_cpu (es->s_log_block_size) > (EXT4_MAX_BLOCK_LOG_SIZE -EXT4_MIN_BLOCK_LOG_SIZE )) { ext4_msg(sb, KERN_ERR,
Greg Kroah-Hartman
maintainerPATCH 17/237 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
@@ -125,12 +125,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
@@ -2386,8 +2386,11 @@ void ext4_insert_dentry(struct inode *in 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 const 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
@@ -4817,6 +4817,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
@@ -2094,6 +2094,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 18/237 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
@@ -2863,17 +2863,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 19/237 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
@@ -228,6 +228,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 (refcount_read (&em->refs) >2 ) +return ; +if (em->start !=0 ) { rb =rb_prev (&em->rb_node);if (rb)
Greg Kroah-Hartman
maintainerPATCH 20/237 btrfs: print message when tree-log replay starts
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
commit e8294f2f6aa6208ed0923aa6d70cea3be178309a upstream.
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
@@ -2913,6 +2913,7 @@ retry_root_backup:/* do not make disk changes in broken FS or nologreplay is given */ if (btrfs_super_log_root (disk_super) !=0 && !btrfs_test_opt (fs_info,NOLOGREPLAY )) { +btrfs_info (fs_info,"start tree-log replay" ); ret =btrfs_replay_log (fs_info, fs_devices);if (ret) { err = ret;
Greg Kroah-Hartman
maintainerPATCH 21/237 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
@@ -1801,6 +1801,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 22/237 arm64: ssbs: Fix context-switch when SSBS is present on all CPUs
In reply to Greg Kroah-HartmanFrom: Will Deacon <[email protected]>
commit fca3d33d8ad61eb53eca3ee4cac476d1e31b9008 upstream.
When all CPUs in the system implement the SSBS extension, the SSBS field in PSTATE is the definitive indication of the mitigation state. Further, when the CPUs implement the SSBS manipulation instructions (advertised to userspace via an HWCAP), EL0 can toggle the SSBS field directly and so we cannot rely on any shadow state such as TIF_SSBD at all.
Avoid forcing the SSBS field in context-switch on such a system, and simply rely on the PSTATE register instead.
--- arch/arm64/kernel/process.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm64/kernel/process.c +7 -0
@@ -354,6 +354,13 @@ static void ssbs_thread_switch(struct taif (unlikely (next->flags &PF_KTHREAD ))return ; +/* +* If all CPUs implement the SSBS extension, then we just need to +* context-switch the PSTATE field. +*/ +if (cpu_have_feature (cpu_feature (SSBS ))) +return ; +/* If the mitigation is enabled, then we leave SSBS clear. */ if ((arm64_get_ssbd_state () ==ARM64_SSBD_FORCE_ENABLE ) ||test_tsk_thread_flag (next,TIF_SSBD ))
Greg Kroah-Hartman
maintainerPATCH 23/237 KVM: nVMX: Use correct root level for nested EPT shadow page tables
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
commit 148d735eb55d32848c3379e460ce365f2c1cbe4b upstream.
Hardcode the EPT page-walk level for L2 to be 4 levels, as KVM's MMU currently also hardcodes the page walk level for nested EPT to be 4 levels. The L2 guest is all but guaranteed to soft hang on its first instruction when L1 is using EPT, as KVM will construct 4-level page tables and then tell hardware to use 5-level page tables.
--- arch/x86/kvm/vmx/vmx.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/vmx/vmx.c +3 -0
@@ -2968,6 +2968,9 @@ void vmx_set_cr0(struct kvm_vcpu *vcpu,static int get_ept_level (struct kvm_vcpu *vcpu) { +/* Nested EPT currently only supports 4-level walks. */ +if (is_guest_mode (vcpu) &&nested_cpu_has_ept (get_vmcs12 (vcpu))) +return 4 ;if (cpu_has_vmx_ept_5levels () && (cpuid_maxphyaddr (vcpu) >48 ))return 5 ;return 4 ;
Greg Kroah-Hartman
maintainerPATCH 24/237 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
@@ -245,6 +245,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 25/237 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;
@@ -292,6 +294,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);
@@ -301,6 +304,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;
@@ -310,9 +315,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); }/**
@@ -435,7 +443,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);
@@ -460,31 +468,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 ;
@@ -498,10 +481,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. */
@@ -522,8 +501,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 26/237 serial: imx: ensure that RX irqs are off if RX is off
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
commit 76821e222c189b81d553b855ee7054340607eb46 upstream.
Make sure that UCR1.RXDMAEN and UCR1.ATDMAEN (for the DMA case) and UCR1.RRDYEN (for the PIO case) are off iff UCR1.RXEN is disabled. This ensures that the fifo isn't read with RX disabled which results in an exception.
--- drivers/tty/serial/imx.c | 116 +++++++++++++++++++++++++++++++---------------- 1 file changed, 78 insertions(+), 38 deletions(-)
drivers/tty/serial/imx.c +78 -38
@@ -80,7 +80,7 @@#define UCR1_IDEN (1<<12)/* Idle condition interrupt */ #define UCR1_ICD_REG (x) (((x) & 3) << 10)/* idle condition detect */ #define UCR1_RRDYEN (1<<9)/* Recv ready interrupt enable */ -#define UCR1_RDMAEN (1<<8)/* Recv ready DMA enable */ +#define UCR1_RXDMAEN (1<<8)/* Recv ready DMA enable */ #define UCR1_IREN (1<<7)/* Infrared interface enable */ #define UCR1_TXMPTYEN (1<<6)/* Transimitter empty interrupt enable */ #define UCR1_RTSDEN (1<<5)/* RTS delta interrupt enable */
@@ -355,6 +355,30 @@ static void imx_port_rts_auto(struct imx/* * interrupts disabled on entry */ +static void imx_start_rx (struct uart_port *port) +{ +struct imx_port *sport = (struct imx_port *)port; +unsigned int ucr1, ucr2; + + ucr1 =readl (port->membase +UCR1 ); + ucr2 =readl (port->membase +UCR2 ); + + ucr2 |=UCR2_RXEN ; + +if (sport->dma_is_enabled) { + ucr1 |=UCR1_RXDMAEN |UCR1_ATDMAEN ; + }else { + ucr1 |=UCR1_RRDYEN ; + } + +/* Write UCR2 first as it includes RXEN */ +writel (ucr2, port->membase +UCR2 ); +writel (ucr1, port->membase +UCR1 ); +} + +/* +* interrupts disabled on entry +*/ static void imx_stop_tx (struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port;
@@ -378,9 +402,10 @@ static void imx_stop_tx(struct uart_portimx_port_rts_active (sport, &temp); else imx_port_rts_inactive(sport, &temp); - temp |=UCR2_RXEN ;writel (temp, port->membase +UCR2 ); +imx_start_rx (port); + temp =readl (port->membase +UCR4 ); temp &= ~UCR4_TCEN ;writel (temp, port->membase +UCR4 );
@@ -393,7 +418,7 @@ static void imx_stop_tx(struct uart_portstatic void imx_stop_rx (struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port; -unsigned long temp; +unsigned long ucr1, ucr2;if (sport->dma_is_enabled && sport->dma_is_rxing) {if (sport->port.suspended) {
@@ -404,12 +429,18 @@ static void imx_stop_rx(struct uart_port } } - temp =readl (sport->port.membase +UCR2 ); -writel (temp & ~UCR2_RXEN , sport->port.membase +UCR2 ); + ucr1 =readl (sport->port.membase +UCR1 ); + ucr2 =readl (sport->port.membase +UCR2 ); -/* disable the `Receiver Ready Interrrupt` */ - temp =readl (sport->port.membase +UCR1 ); -writel (temp & ~UCR1_RRDYEN , sport->port.membase +UCR1 ); +if (sport->dma_is_enabled) { + ucr1 &= ~(UCR1_RXDMAEN |UCR1_ATDMAEN ); + }else { + ucr1 &= ~UCR1_RRDYEN ; + } +writel (ucr1, port->membase +UCR1 ); + + ucr2 &= ~UCR2_RXEN ; +writel (ucr2, port->membase +UCR2 ); }/*
@@ -581,10 +612,11 @@ static void imx_start_tx(struct uart_porimx_port_rts_active (sport, &temp); else imx_port_rts_inactive(sport, &temp); -if (!(port->rs485.flags &SER_RS485_RX_DURING_TX )) - temp &= ~UCR2_RXEN ;writel (temp, port->membase +UCR2 ); +if (!(port->rs485.flags &SER_RS485_RX_DURING_TX )) +imx_stop_rx (port); +/* enable transmitter and shifter empty irq */ temp =readl (port->membase +UCR4 ); temp |=UCR4_TCEN ;
@@ -1206,7 +1238,7 @@ static void imx_enable_dma(struct imx_po/* set UCR1 */ temp =readl (sport->port.membase +UCR1 ); - temp |=UCR1_RDMAEN |UCR1_TDMAEN |UCR1_ATDMAEN ; + temp |=UCR1_RXDMAEN |UCR1_TDMAEN |UCR1_ATDMAEN ;writel (temp, sport->port.membase +UCR1 ); temp =readl (sport->port.membase +UCR2 );
@@ -1224,7 +1256,7 @@ static void imx_disable_dma(struct imx_p/* clear UCR1 */ temp =readl (sport->port.membase +UCR1 ); - temp &= ~(UCR1_RDMAEN |UCR1_TDMAEN |UCR1_ATDMAEN ); + temp &= ~(UCR1_RXDMAEN |UCR1_TDMAEN |UCR1_ATDMAEN );writel (temp, sport->port.membase +UCR1 );/* clear UCR2 */
@@ -1289,11 +1321,9 @@ static int imx_startup(struct uart_portwritel (USR1_RTSD |USR1_DTRD , sport->port.membase +USR1 );writel (USR2_ORE , sport->port.membase +USR2 ); -if (sport->dma_is_inited && !sport->dma_is_enabled) -imx_enable_dma (sport); - temp =readl (sport->port.membase +UCR1 ); - temp |=UCR1_RRDYEN |UCR1_UARTEN ; + temp &= ~UCR1_RRDYEN ; + temp |=UCR1_UARTEN ;if (sport->have_rtscts) temp |=UCR1_RTSDEN ;
@@ -1332,14 +1362,13 @@ static int imx_startup(struct uart_port*/ imx_enable_ms (&sport->port); -/* -* Start RX DMA immediately instead of waiting for RX FIFO interrupts. -* In our iMX53 the average delay for the first reception dropped from -* approximately 35000 microseconds to 1000 microseconds. -*/ -if (sport->dma_is_enabled) { -imx_disable_rx_int (sport); +if (sport->dma_is_inited) { +imx_enable_dma (sport);start_rx_dma (sport); + }else { + temp =readl (sport->port.membase +UCR1 ); + temp |=UCR1_RRDYEN ; +writel (temp, sport->port.membase +UCR1 ); }spin_unlock_irqrestore (&sport->port.lock, flags);
@@ -1386,7 +1415,8 @@ static void imx_shutdown(struct uart_porspin_lock_irqsave (&sport->port.lock, flags); temp =readl (sport->port.membase +UCR1 ); - temp &= ~(UCR1_TXMPTYEN |UCR1_RRDYEN |UCR1_RTSDEN |UCR1_UARTEN ); + temp &= ~(UCR1_TXMPTYEN |UCR1_RRDYEN |UCR1_RTSDEN |UCR1_UARTEN | +UCR1_RXDMAEN |UCR1_ATDMAEN );writel (temp, sport->port.membase +UCR1 );spin_unlock_irqrestore (&sport->port.lock, flags);
@@ -1659,7 +1689,7 @@ static int imx_poll_init(struct uart_por {struct imx_port *sport = (struct imx_port *)port;unsigned long flags; -unsigned long temp; +unsigned long ucr1, ucr2;int retval; retval =clk_prepare_enable (sport->clk_ipg);
@@ -1673,16 +1703,29 @@ static int imx_poll_init(struct uart_porspin_lock_irqsave (&sport->port.lock, flags); - temp =readl (sport->port.membase +UCR1 ); +/* +* Be careful about the order of enabling bits here. First enable the +* receiver (UARTEN + RXEN) and only then the corresponding irqs. +* This prevents that a character that already sits in the RX fifo is +* triggering an irq but the try to fetch it from there results in an +* exception because UARTEN or RXEN is still off. +*/ + ucr1 =readl (port->membase +UCR1 ); + ucr2 =readl (port->membase +UCR2 ); +if (is_imx1_uart (sport)) - temp |=IMX1_UCR1_UARTCLKEN ; - temp |=UCR1_UARTEN |UCR1_RRDYEN ; - temp &= ~(UCR1_TXMPTYEN |UCR1_RTSDEN ); -writel (temp, sport->port.membase +UCR1 ); + ucr1 |=IMX1_UCR1_UARTCLKEN ; - temp =readl (sport->port.membase +UCR2 ); - temp |=UCR2_RXEN ; -writel (temp, sport->port.membase +UCR2 ); + ucr1 |=UCR1_UARTEN ; + ucr1 &= ~(UCR1_TXMPTYEN |UCR1_RTSDEN |UCR1_RRDYEN ); + + ucr2 |=UCR2_RXEN ; + +writel (ucr1, sport->port.membase +UCR1 ); +writel (ucr2, sport->port.membase +UCR2 ); + +/* now enable irqs */ +writel (ucr1 |UCR1_RRDYEN , sport->port.membase +UCR1 );spin_unlock_irqrestore (&sport->port.lock, flags);
@@ -1742,11 +1785,8 @@ static int imx_rs485_config(struct uart_/* Make sure Rx is enabled in case Tx is active with Rx disabled */ if (!(rs485conf->flags &SER_RS485_ENABLED ) || - rs485conf->flags &SER_RS485_RX_DURING_TX ) { - temp =readl (sport->port.membase +UCR2 ); - temp |=UCR2_RXEN ; -writel (temp, sport->port.membase +UCR2 ); - } + rs485conf->flags &SER_RS485_RX_DURING_TX ) +imx_start_rx (port); port->rs485 = *rs485conf;
Greg Kroah-Hartman
maintainerPATCH 27/237 serial: imx: Only handle irqs that are actually enabled
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
commit 437768962f754d9501e5ba4d98b1f2a89dc62028 upstream.
Handling an irq that isn't enabled can have some undesired side effects. Some of these are mentioned in the newly introduced code comment. Some of the irq sources already had their handling right, some don't. Handle them all in the same consistent way.
The change for USR1_RRDY and USR1_AGTIM drops the check for dma_is_enabled. This is correct as UCR1_RRDYEN and UCR2_ATEN are always off if dma is enabled.
--- drivers/tty/serial/imx.c | 53 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 14 deletions(-)
drivers/tty/serial/imx.c +39 -14
@@ -843,14 +843,42 @@ static void imx_mctrl_check(struct imx_pstatic irqreturn_t imx_int (int irq,void *dev_id) {struct imx_port *sport = dev_id; -unsigned int sts; -unsigned int sts2; +unsigned int usr1, usr2, ucr1, ucr2, ucr3, ucr4;irqreturn_t ret =IRQ_NONE ; - sts =readl (sport->port.membase +USR1 ); - sts2 =readl (sport->port.membase +USR2 ); + usr1 =readl (sport->port.membase +USR1 ); + usr2 =readl (sport->port.membase +USR2 ); + ucr1 =readl (sport->port.membase +UCR1 ); + ucr2 =readl (sport->port.membase +UCR2 ); + ucr3 =readl (sport->port.membase +UCR3 ); + ucr4 =readl (sport->port.membase +UCR4 ); + +/* +* Even if a condition is true that can trigger an irq only handle it if +* the respective irq source is enabled. This prevents some undesired +* actions, for example if a character that sits in the RX FIFO and that +* should be fetched via DMA is tried to be fetched using PIO. Or the +* receiver is currently off and so reading from URXD0 results in an +* exception. So just mask the (raw) status bits for disabled irqs. +*/ +if ((ucr1 &UCR1_RRDYEN ) ==0 ) + usr1 &= ~USR1_RRDY ; +if ((ucr2 &UCR2_ATEN ) ==0 ) + usr1 &= ~USR1_AGTIM ; +if ((ucr1 &UCR1_TXMPTYEN ) ==0 ) + usr1 &= ~USR1_TRDY ; +if ((ucr4 &UCR4_TCEN ) ==0 ) + usr2 &= ~USR2_TXDC ; +if ((ucr3 &UCR3_DTRDEN ) ==0 ) + usr1 &= ~USR1_DTRD ; +if ((ucr1 &UCR1_RTSDEN ) ==0 ) + usr1 &= ~USR1_RTSD ; +if ((ucr3 &UCR3_AWAKEN ) ==0 ) + usr1 &= ~USR1_AWAKE ; +if ((ucr4 &UCR4_OREN ) ==0 ) + usr2 &= ~USR2_ORE ; -if (sts & (USR1_RRDY |USR1_AGTIM )) { +if (usr1 & (USR1_RRDY |USR1_AGTIM )) {if (sport->dma_is_enabled)imx_dma_rxint (sport);else
@@ -858,18 +886,15 @@ static irqreturn_t imx_int(int irq, void ret =IRQ_HANDLED ; } -if ((sts &USR1_TRDY && -readl (sport->port.membase +UCR1 ) &UCR1_TXMPTYEN ) || - (sts2 &USR2_TXDC && -readl (sport->port.membase +UCR4 ) &UCR4_TCEN )) { +if ((usr1 &USR1_TRDY ) || (usr2 &USR2_TXDC )) {imx_txint (irq, dev_id); ret =IRQ_HANDLED ; } -if (sts &USR1_DTRD ) { +if (usr1 &USR1_DTRD ) {unsigned long flags; -if (sts &USR1_DTRD ) +if (usr1 &USR1_DTRD )writel (USR1_DTRD , sport->port.membase +USR1 );spin_lock_irqsave (&sport->port.lock, flags);
@@ -879,17 +904,17 @@ static irqreturn_t imx_int(int irq, void ret =IRQ_HANDLED ; } -if (sts &USR1_RTSD ) { +if (usr1 &USR1_RTSD ) {imx_rtsint (irq, dev_id); ret =IRQ_HANDLED ; } -if (sts &USR1_AWAKE ) { +if (usr1 &USR1_AWAKE ) {writel (USR1_AWAKE , sport->port.membase +USR1 ); ret =IRQ_HANDLED ; } -if (sts2 &USR2_ORE ) { +if (usr2 &USR2_ORE ) { sport->port.icount.overrun++;writel (USR2_ORE , sport->port.membase +USR2 ); ret =IRQ_HANDLED ;
Greg Kroah-Hartman
maintainerPATCH 28/237 IB/hfi1: Close window for pq and request coliding
In reply to Greg Kroah-HartmanFrom: Mike Marciniszyn <[email protected]>
commit be8638344c70bf492963ace206a9896606b6922d upstream.
Cleaning up a pq can result in the following warning and panic:
WARNING: CPU: 52 PID: 77418 at lib/list_debug.c:53 __list_del_entry+0x63/0xd0 list_del corruption, ffff88cb2c6ac068->next is LIST_POISON1 (dead000000000100) Modules linked in: mmfs26(OE) mmfslinux(OE) tracedev(OE) 8021q garp mrp ib_isert iscsi_target_mod target_core_mod crc_t10dif crct10dif_generic opa_vnic rpcrdma ib_iser libiscsi scsi_transport_iscsi ib_ipoib(OE) bridge stp llc iTCO_wdt iTCO_vendor_support intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm irqbypass crct10dif_pclmul crct10dif_common crc32_pclmul ghash_clmulni_intel ast aesni_intel ttm lrw gf128mul glue_helper ablk_helper drm_kms_helper cryptd syscopyarea sysfillrect sysimgblt fb_sys_fops drm pcspkr joydev lpc_ich mei_me drm_panel_orientation_quirks i2c_i801 mei wmi ipmi_si ipmi_devintf ipmi_msghandler nfit libnvdimm acpi_power_meter acpi_pad hfi1(OE) rdmavt(OE) rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm ib_core binfmt_misc numatools(OE) xpmem(OE) ip_tables nfsv3 nfs_acl nfs lockd grace sunrpc fscache igb ahci i2c_algo_bit libahci dca ptp libata pps_core crc32c_intel [last unloaded: i2c_algo_bit] CPU: 52 PID: 77418 Comm: pvbatch Kdump: loaded Tainted: G OE ------------ 3.10.0-957.38.3.el7.x86_64 #1 Hardware name: HPE.COM HPE SGI 8600-XA730i Gen10/X11DPT-SB-SG007, BIOS SBED1229 01/22/2019 Call Trace: [<ffffffff90365ac0>] dump_stack+0x19/0x1b [<ffffffff8fc98b78>] __warn+0xd8/0x100 [<ffffffff8fc98bff>] warn_slowpath_fmt+0x5f/0x80 [<ffffffff8ff970c3>] __list_del_entry+0x63/0xd0 [<ffffffff8ff9713d>] list_del+0xd/0x30 [<ffffffff8fddda70>] kmem_cache_destroy+0x50/0x110 [<ffffffffc0328130>] hfi1_user_sdma_free_queues+0xf0/0x200 [hfi1] [<ffffffffc02e2350>] hfi1_file_close+0x70/0x1e0 [hfi1] [<ffffffff8fe4519c>] __fput+0xec/0x260 [<ffffffff8fe453fe>] ____fput+0xe/0x10 [<ffffffff8fcbfd1b>] task_work_run+0xbb/0xe0 [<ffffffff8fc2bc65>] do_notify_resume+0xa5/0xc0 [<ffffffff90379134>] int_signal+0x12/0x17 BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 IP: [<ffffffff8fe1f93e>] kmem_cache_close+0x7e/0x300 PGD 2cdab19067 PUD 2f7bfdb067 PMD 0 Oops: 0000 [#1] SMP Modules linked in: mmfs26(OE) mmfslinux(OE) tracedev(OE) 8021q garp mrp ib_isert iscsi_target_mod target_core_mod crc_t10dif crct10dif_generic opa_vnic rpcrdma ib_iser libiscsi scsi_transport_iscsi ib_ipoib(OE) bridge stp llc iTCO_wdt iTCO_vendor_support intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel kvm irqbypass crct10dif_pclmul crct10dif_common crc32_pclmul ghash_clmulni_intel ast aesni_intel ttm lrw gf128mul glue_helper ablk_helper drm_kms_helper cryptd syscopyarea sysfillrect sysimgblt fb_sys_fops drm pcspkr joydev lpc_ich mei_me drm_panel_orientation_quirks i2c_i801 mei wmi ipmi_si ipmi_devintf ipmi_msghandler nfit libnvdimm acpi_power_meter acpi_pad hfi1(OE) rdmavt(OE) rdma_ucm ib_ucm ib_uverbs ib_umad rdma_cm ib_cm iw_cm ib_core binfmt_misc numatools(OE) xpmem(OE) ip_tables nfsv3 nfs_acl nfs lockd grace sunrpc fscache igb ahci i2c_algo_bit libahci dca ptp libata pps_core crc32c_intel [last unloaded: i2c_algo_bit] CPU: 52 PID: 77418 Comm: pvbatch Kdump: loaded Tainted: G W OE ------------ 3.10.0-957.38.3.el7.x86_64 #1 Hardware name: HPE.COM HPE SGI 8600-XA730i Gen10/X11DPT-SB-SG007, BIOS SBED1229 01/22/2019 task: ffff88cc26db9040 ti: ffff88b5393a8000 task.ti: ffff88b5393a8000 RIP: 0010:[<ffffffff8fe1f93e>] [<ffffffff8fe1f93e>] kmem_cache_close+0x7e/0x300 RSP: 0018:ffff88b5393abd60 EFLAGS: 00010287 RAX: 0000000000000000 RBX: ffff88cb2c6ac000 RCX: 0000000000000003 RDX: 0000000000000400 RSI: 0000000000000400 RDI: ffffffff9095b800 RBP: ffff88b5393abdb0 R08: ffffffff9095b808 R09: ffffffff8ff77c19 R10: ffff88b73ce1f160 R11: ffffddecddde9800 R12: ffff88cb2c6ac000 R13: 000000000000000c R14: ffff88cf3fdca780 R15: 0000000000000000 FS: 00002aaaaab52500(0000) GS:ffff88b73ce00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 0000002d27664000 CR4: 00000000007607e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: [<ffffffff8fe20d44>] __kmem_cache_shutdown+0x14/0x80 [<ffffffff8fddda78>] kmem_cache_destroy+0x58/0x110 [<ffffffffc0328130>] hfi1_user_sdma_free_queues+0xf0/0x200 [hfi1] [<ffffffffc02e2350>] hfi1_file_close+0x70/0x1e0 [hfi1] [<ffffffff8fe4519c>] __fput+0xec/0x260 [<ffffffff8fe453fe>] ____fput+0xe/0x10 [<ffffffff8fcbfd1b>] task_work_run+0xbb/0xe0 [<ffffffff8fc2bc65>] do_notify_resume+0xa5/0xc0 [<ffffffff90379134>] int_signal+0x12/0x17 Code: 00 00 ba 00 04 00 00 0f 4f c2 3d 00 04 00 00 89 45 bc 0f 84 e7 01 00 00 48 63 45 bc 49 8d 04 c4 48 89 45 b0 48 8b 80 c8 00 00 00 <48> 8b 78 10 48 89 45 c0 48 83 c0 10 48 89 45 d0 48 8b 17 48 39 RIP [<ffffffff8fe1f93e>] kmem_cache_close+0x7e/0x300 RSP <ffff88b5393abd60> CR2: 0000000000000010
The panic is the result of slab entries being freed during the destruction of the pq slab.
The code attempts to quiesce the pq, but looking for n_req == 0 doesn't account for new requests.
Fix the issue by using SRCU to get a pq pointer and adjust the pq free logic to NULL the fd pq pointer prior to the quiesce.
--- drivers/infiniband/hw/hfi1/file_ops.c | 52 ++++++++++++++++++------------ drivers/infiniband/hw/hfi1/hfi.h | 5 ++ drivers/infiniband/hw/hfi1/user_exp_rcv.c | 3 - drivers/infiniband/hw/hfi1/user_sdma.c | 17 ++++++--- 4 files changed, 48 insertions(+), 29 deletions(-)
drivers/infiniband/hw/hfi1/file_ops.c +32 -20
@@ -195,23 +195,24 @@ static int hfi1_file_open(struct inode * fd =kzalloc (sizeof (*fd),GFP_KERNEL ); -if (fd) { - fd->rec_cpu_num =-1 ;/* no cpu affinity by default */ - fd->mm = current->mm; -mmgrab (fd->mm); - fd->dd = dd; -kobject_get (&fd->dd->kobj); - fp->private_data = fd; - }else { - fp->private_data =NULL ; - -if (atomic_dec_and_test (&dd->user_refcount)) -complete (&dd->user_comp); - -return -ENOMEM ; - } - +if (!fd ||init_srcu_struct (&fd->pq_srcu)) + goto nomem; +spin_lock_init (&fd->pq_rcu_lock); +spin_lock_init (&fd->tid_lock); +spin_lock_init (&fd->invalid_lock); + fd->rec_cpu_num =-1 ;/* no cpu affinity by default */ + fd->mm = current->mm; +mmgrab (fd->mm); + fd->dd = dd; +kobject_get (&fd->dd->kobj); + fp->private_data = fd;return 0 ; +nomem: +kfree (fd); + fp->private_data =NULL ; +if (atomic_dec_and_test (&dd->user_refcount)) +complete (&dd->user_comp); +return -ENOMEM ; } static long hfi1_file_ioctl(struct file *fp, unsigned int cmd,
@@ -417,21 +418,30 @@ static long hfi1_file_ioctl(struct filestatic ssize_t hfi1_write_iter (struct kiocb *kiocb,struct iov_iter *from) {struct hfi1_filedata *fd = kiocb->ki_filp->private_data; -struct hfi1_user_sdma_pkt_q *pq = fd->pq; +struct hfi1_user_sdma_pkt_q *pq;struct hfi1_user_sdma_comp_q *cq = fd->cq;int done =0 , reqs =0 ;unsigned long dim = from->nr_segs; +int idx; -if (!cq || !pq) + idx =srcu_read_lock (&fd->pq_srcu); + pq =srcu_dereference (fd->pq, &fd->pq_srcu); +if (!cq || !pq) { +srcu_read_unlock (&fd->pq_srcu, idx);return -EIO ; + } -if (!iter_is_iovec (from) || !dim) +if (!iter_is_iovec (from) || !dim) { +srcu_read_unlock (&fd->pq_srcu, idx);return -EINVAL ; + }trace_hfi1_sdma_request (fd->dd, fd->uctxt->ctxt, fd->subctxt, dim); -if (atomic_read (&pq->n_reqs) == pq->n_max_reqs) +if (atomic_read (&pq->n_reqs) == pq->n_max_reqs) { +srcu_read_unlock (&fd->pq_srcu, idx);return -ENOSPC ; + }while (dim) {int ret;
@@ -449,6 +459,7 @@ static ssize_t hfi1_write_iter(struct ki reqs++; } +srcu_read_unlock (&fd->pq_srcu, idx);return reqs; }
@@ -824,6 +835,7 @@ done:if (atomic_dec_and_test (&dd->user_refcount))complete (&dd->user_comp); +cleanup_srcu_struct (&fdata->pq_srcu);kfree (fdata);return 0 ; }
drivers/infiniband/hw/hfi1/hfi.h +4 -1
@@ -1353,10 +1353,13 @@ struct mmu_rb_handler;/* Private data for file operations */ struct hfi1_filedata { +struct srcu_struct pq_srcu;struct hfi1_devdata *dd;struct hfi1_ctxtdata *uctxt;struct hfi1_user_sdma_comp_q *cq; -struct hfi1_user_sdma_pkt_q *pq; +/* update side lock for SRCU */ +spinlock_t pq_rcu_lock; +struct hfi1_user_sdma_pkt_q __rcu *pq;u16 subctxt;/* for cpu affinity; -1 if none */ int rec_cpu_num;
drivers/infiniband/hw/hfi1/user_exp_rcv.c +0 -3
@@ -90,9 +90,6 @@ int hfi1_user_exp_rcv_init(struct hfi1_fstruct hfi1_devdata *dd = uctxt->dd;int ret =0 ; -spin_lock_init (&fd->tid_lock); -spin_lock_init (&fd->invalid_lock); - fd->entry_to_rb =kcalloc (uctxt->expected_count,sizeof (struct rb_node *),GFP_KERNEL );
drivers/infiniband/hw/hfi1/user_sdma.c +12 -5
@@ -179,7 +179,6 @@ int hfi1_user_sdma_alloc_queues(struct h pq =kzalloc (sizeof (*pq),GFP_KERNEL );if (!pq)return -ENOMEM ; - pq->dd = dd; pq->ctxt = uctxt->ctxt; pq->subctxt = fd->subctxt;
@@ -236,7 +235,7 @@ int hfi1_user_sdma_alloc_queues(struct h goto pq_mmu_fail; } - fd->pq = pq; +rcu_assign_pointer (fd->pq, pq); fd->cq = cq;return 0 ;
@@ -264,8 +263,14 @@ int hfi1_user_sdma_free_queues(struct hftrace_hfi1_sdma_user_free_queues (uctxt->dd, uctxt->ctxt, fd->subctxt); - pq = fd->pq; +spin_lock (&fd->pq_rcu_lock); + pq =srcu_dereference_check (fd->pq, &fd->pq_srcu, +lockdep_is_held (&fd->pq_rcu_lock));if (pq) { +rcu_assign_pointer (fd->pq,NULL ); +spin_unlock (&fd->pq_rcu_lock); +synchronize_srcu (&fd->pq_srcu); +/* at this point there can be no more new requests */ if (pq->handler)hfi1_mmu_rb_unregister (pq->handler);iowait_sdma_drain (&pq->busy);
@@ -277,7 +282,8 @@ int hfi1_user_sdma_free_queues(struct hfkfree (pq->req_in_use);kmem_cache_destroy (pq->txreq_cache);kfree (pq); - fd->pq =NULL ; + }else { +spin_unlock (&fd->pq_rcu_lock); }if (fd->cq) {vfree (fd->cq->comps);
@@ -321,7 +327,8 @@ int hfi1_user_sdma_process_request(struc {int ret =0 , i;struct hfi1_ctxtdata *uctxt = fd->uctxt; -struct hfi1_user_sdma_pkt_q *pq = fd->pq; +struct hfi1_user_sdma_pkt_q *pq = +srcu_dereference (fd->pq, &fd->pq_srcu);struct hfi1_user_sdma_comp_q *cq = fd->cq;struct hfi1_devdata *dd = pq->dd;unsigned long idx =0 ;
Greg Kroah-Hartman
maintainerPATCH 29/237 RDMA/core: Fix protection fault in get_pkey_idx_qp_list
In reply to Greg Kroah-HartmanFrom: Leon Romanovsky <[email protected]>
commit 1dd017882e01d2fcd9c5dbbf1eb376211111c393 upstream.
We don't need to set pkey as valid in case that user set only one of pkey index or port number, otherwise it will be resulted in NULL pointer dereference while accessing to uninitialized pkey list. The following crash from Syzkaller revealed it.
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN PTI CPU: 1 PID: 14753 Comm: syz-executor.2 Not tainted 5.5.0-rc5 #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014 RIP: 0010:get_pkey_idx_qp_list+0x161/0x2d0 Code: 01 00 00 49 8b 5e 20 4c 39 e3 0f 84 b9 00 00 00 e8 e4 42 6e fe 48 8d 7b 10 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 01 0f 8e d0 00 00 00 48 8d 7d 04 48 b8 RSP: 0018:ffffc9000bc6f950 EFLAGS: 00010202 RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff82c8bdec RDX: 0000000000000002 RSI: ffffc900030a8000 RDI: 0000000000000010 RBP: ffff888112c8ce80 R08: 0000000000000004 R09: fffff5200178df1f R10: 0000000000000001 R11: fffff5200178df1f R12: ffff888115dc4430 R13: ffff888115da8498 R14: ffff888115dc4410 R15: ffff888115da8000 FS: 00007f20777de700(0000) GS:ffff88811b100000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000001b2f721000 CR3: 00000001173ca002 CR4: 0000000000360ee0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: port_pkey_list_insert+0xd7/0x7c0 ib_security_modify_qp+0x6fa/0xfc0 _ib_modify_qp+0x8c4/0xbf0 modify_qp+0x10da/0x16d0 ib_uverbs_modify_qp+0x9a/0x100 ib_uverbs_write+0xaa5/0xdf0 __vfs_write+0x7c/0x100 vfs_write+0x168/0x4a0 ksys_write+0xc8/0x200 do_syscall_64+0x9c/0x390 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Message-Id: <20200212080651.GB679970@unreal>
--- drivers/infiniband/core/security.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
drivers/infiniband/core/security.c +9 -15
@@ -338,22 +338,16 @@ static struct ib_ports_pkeys *get_new_ppif (!new_pps)return NULL ; -if (qp_attr_mask & (IB_QP_PKEY_INDEX |IB_QP_PORT )) { -if (!qp_pps) { - new_pps->main.port_num = qp_attr->port_num; - new_pps->main.pkey_index = qp_attr->pkey_index; - }else { - new_pps->main.port_num = (qp_attr_mask &IB_QP_PORT ) ? - qp_attr->port_num : - qp_pps->main.port_num; - - new_pps->main.pkey_index = - (qp_attr_mask &IB_QP_PKEY_INDEX ) ? - qp_attr->pkey_index : - qp_pps->main.pkey_index; - } +if (qp_attr_mask &IB_QP_PORT ) + new_pps->main.port_num = + (qp_pps) ? qp_pps->main.port_num : qp_attr->port_num; +if (qp_attr_mask &IB_QP_PKEY_INDEX ) + new_pps->main.pkey_index = (qp_pps) ? qp_pps->main.pkey_index : + qp_attr->pkey_index; +if ((qp_attr_mask &IB_QP_PKEY_INDEX ) && (qp_attr_mask &IB_QP_PORT )) new_pps->main.state =IB_PORT_PKEY_VALID ; - }else if (qp_pps) { + +if (!(qp_attr_mask & (IB_QP_PKEY_INDEX ||IB_QP_PORT )) && qp_pps) { new_pps->main.port_num = qp_pps->main.port_num; new_pps->main.pkey_index = qp_pps->main.pkey_index;if (qp_pps->main.state !=IB_PORT_PKEY_NOT_VALID )
Greg Kroah-Hartman
maintainerPATCH 30/237 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
@@ -155,7 +155,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 31/237 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
@@ -1368,6 +1368,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 32/237 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 33/237 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
@@ -973,34 +973,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
@@ -2231,14 +2231,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 34/237 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
@@ -982,12 +982,29 @@ restart_loop:* 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)) {
Greg Kroah-Hartman
maintainerPATCH 35/237 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 | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/qla2xxx/qla_os.c +4 -0
@@ -3178,6 +3178,10 @@ qla2x00_probe_one(struct pci_dev *pdev, base_vha->mgmt_svr_loop_id, host->sg_tablesize); ha->wq =alloc_workqueue ("qla2xxx_wq" ,WQ_MEM_RECLAIM ,0 ); +if (unlikely (!ha->wq)) { + ret = -ENOMEM ; + goto probe_failed; + }if (ha->mqenable) {bool mq = false;
Greg Kroah-Hartman
maintainerPATCH 36/237 Revert "KVM: nVMX: Use correct root level for nested EPT shadow page tables"
In reply to Greg Kroah-HartmanThis reverts commit 740d876bd9565857a695ce7c05efda4eba5bc585.
--- arch/x86/kvm/vmx/vmx.c | 3 --- 1 file changed, 3 deletions(-)
arch/x86/kvm/vmx/vmx.c +0 -3
@@ -2968,9 +2968,6 @@ void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)static int get_ept_level (struct kvm_vcpu *vcpu) { -/* Nested EPT currently only supports 4-level walks. */ -if (is_guest_mode (vcpu) &&nested_cpu_has_ept (get_vmcs12 (vcpu))) -return 4 ;if (cpu_has_vmx_ept_5levels () && (cpuid_maxphyaddr (vcpu) >48 ))return 5 ;return 4 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 37/237 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 38/237 KVM: nVMX: Use correct root level for nested EPT shadow page tables - again
In reply to Greg Kroah-HartmanFrom: Sean Christopherson <[email protected]>
[ Upstream commit 148d735eb55d32848c3379e460ce365f2c1cbe4b ]
Hardcode the EPT page-walk level for L2 to be 4 levels, as KVM's MMU currently also hardcodes the page walk level for nested EPT to be 4 levels. The L2 guest is all but guaranteed to soft hang on its first instruction when L1 is using EPT, as KVM will construct 4-level page tables and then tell hardware to use 5-level page tables.
--- arch/x86/kvm/vmx.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/vmx.c +3 -0
@@ -4597,6 +4597,9 @@ static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)static int get_ept_level (struct kvm_vcpu *vcpu) { +/* Nested EPT currently only supports 4-level walks. */ +if (is_guest_mode (vcpu) &&nested_cpu_has_ept (get_vmcs12 (vcpu))) +return 4 ;if (cpu_has_vmx_ept_5levels () && (cpuid_maxphyaddr (vcpu) >48 ))return 5 ;return 4 ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 39/237 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
@@ -486,6 +486,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 ;
@@ -495,8 +496,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 40/237 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
@@ -494,8 +494,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);/*
@@ -1064,8 +1063,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) {
@@ -1075,6 +1074,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_ap_thread (st, true); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 41/237 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
@@ -1932,6 +1932,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 42/237 leds: pca963x: Fix open-drain initialization
In reply to Greg Kroah-HartmanFrom: Zahari Petkov <[email protected]>
[ Upstream commit 697529091ac7a0a90ca349b914bb30641c13c753 ]
Before commit bb29b9cccd95 ("leds: pca963x: Add bindings to invert polarity") Mode register 2 was initialized directly with either 0x01 or 0x05 for open-drain or totem pole (push-pull) configuration.
Afterwards, MODE2 initialization started using bitwise operations on top of the default MODE2 register value (0x05). Using bitwise OR for setting OUTDRV with 0x01 and 0x05 does not produce correct results. When open-drain is used, instead of setting OUTDRV to 0, the driver keeps it as 1:
Open-drain: 0x05 | 0x01 -> 0x05 (0b101 - incorrect) Totem pole: 0x05 | 0x05 -> 0x05 (0b101 - correct but still wrong)
Now OUTDRV setting uses correct bitwise operations for initialization:
Open-drain: 0x05 & ~0x04 -> 0x01 (0b001 - correct) Totem pole: 0x05 | 0x04 -> 0x05 (0b101 - correct)
Additional MODE2 register definitions are introduced now as well.
--- drivers/leds/leds-pca963x.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/leds/leds-pca963x.c +5 -3
@@ -43,6 +43,8 @@#define PCA963X_LED_PWM 0x2/* Controlled through PWM */ #define PCA963X_LED_GRP_PWM 0x3/* Controlled through PWM/GRPPWM */ +#define PCA963X_MODE2_OUTDRV 0x04/* Open-drain or totem pole */ +#define PCA963X_MODE2_INVRT 0x10/* Normal or inverted direction */ #define PCA963X_MODE2_DMBLNK 0x20/* Enable blinking */ #define PCA963X_MODE1 0x00
@@ -462,12 +464,12 @@ static int pca963x_probe(struct i2c_client *client, PCA963X_MODE2);/* Configure output: open-drain or totem pole (push-pull) */ if (pdata->outdrv ==PCA963X_OPEN_DRAIN ) - mode2 |=0x01 ; + mode2 &= ~PCA963X_MODE2_OUTDRV ;else - mode2 |=0x05 ; + mode2 |=PCA963X_MODE2_OUTDRV ;/* Configure direction: normal or inverted */ if (pdata->dir ==PCA963X_INVERTED ) - mode2 |=0x10 ; + mode2 |=PCA963X_MODE2_INVRT ;i2c_smbus_write_byte_data (pca963x->chip->client,PCA963X_MODE2 , mode2); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 43/237 ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT
In reply to Greg Kroah-HartmanFrom: Ritesh Harjani <[email protected]>
[ Upstream commit f629afe3369e9885fd6e9cc7a4f514b6a65cf9e9 ]
Apparently our current rwsem code doesn't like doing the trylock, then lock for real scheme. So change our dax read/write methods to just do the trylock for the RWF_NOWAIT case.
This seems to fix AIM7 regression in some scalable filesystems upto ~25% in some cases. Claimed in commit 942491c9e6d6 ("xfs: fix AIM7 regression")
--- fs/ext4/file.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
fs/ext4/file.c +6 -4
@@ -38,9 +38,10 @@ static ssize_t ext4_dax_read_iter(struct kiocb *iocb, struct iov_iter *to)struct inode *inode =file_inode (iocb->ki_filp);ssize_t ret; -if (!inode_trylock_shared (inode)) { -if (iocb->ki_flags &IOCB_NOWAIT ) +if (iocb->ki_flags &IOCB_NOWAIT ) { +if (!inode_trylock_shared (inode))return -EAGAIN ; + }else {inode_lock_shared (inode); }/*
@@ -188,9 +189,10 @@ ext4_dax_write_iter(struct kiocb *iocb, struct iov_iter *from)struct inode *inode =file_inode (iocb->ki_filp);ssize_t ret; -if (!inode_trylock (inode)) { -if (iocb->ki_flags &IOCB_NOWAIT ) +if (iocb->ki_flags &IOCB_NOWAIT ) { +if (!inode_trylock (inode))return -EAGAIN ; + }else {inode_lock (inode); } ret =ext4_write_checks (iocb, from);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 44/237 ALSA: ctl: allow TLV read operation for callback type of element in locked case
In reply to Greg Kroah-HartmanFrom: Takashi Sakamoto <[email protected]>
[ Upstream commit d61fe22c2ae42d9fd76c34ef4224064cca4b04b0 ]
A design of ALSA control core allows applications to execute three operations for TLV feature; read, write and command. Furthermore, it allows driver developers to process the operations by two ways; allocated array or callback function. In the former, read operation is just allowed, thus developers uses the latter when device driver supports variety of models or the target model is expected to dynamically change information stored in TLV container.
The core also allows applications to lock any element so that the other applications can't perform write operation to the element for element value and TLV information. When the element is locked, write and command operation for TLV information are prohibited as well as element value. Any read operation should be allowed in the case.
At present, when an element has callback function for TLV information, TLV read operation returns EPERM if the element is locked. On the other hand, the read operation is success when an element has allocated array for TLV information. In both cases, read operation is success for element value expectedly.
This commit fixes the bug. This change can be backported to v4.14 kernel or later.
--- sound/core/control.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/core/control.c +3 -2
@@ -1467,8 +1467,9 @@ static int call_tlv_handler(struct snd_ctl_file *file, int op_flag,if (kctl->tlv.c ==NULL )return -ENXIO ; -/* When locked, this is unavailable. */ -if (vd->owner !=NULL && vd->owner != file) +/* Write and command operations are not allowed for locked element. */ +if (op_flag !=SNDRV_CTL_TLV_OP_READ && + vd->owner !=NULL && vd->owner != file)return -EPERM ;return kctl->tlv.c (kctl, op_flag, size, buf);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 45/237 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
@@ -2685,13 +2685,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 ;
@@ -2705,7 +2709,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 ;
@@ -2715,7 +2719,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 46/237 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 47/237 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 48/237 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 49/237 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
@@ -1523,6 +1523,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
@@ -1535,13 +1539,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#%x\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 ? */
@@ -1555,6 +1557,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
@@ -978,16 +978,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 50/237 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 51/237 char/random: silence a lockdep splat with printk()
In reply to Greg Kroah-HartmanFrom: Sergey Senozhatsky <[email protected]>
[ Upstream commit 1b710b1b10eff9d46666064ea25f079f70bc67a8 ]
Sergey didn't like the locking order,
uart_port->lock -> tty_port->lock
uart_write (uart_port->lock)
__uart_start
pl011_start_tx
pl011_tx_chars
uart_write_wakeup
tty_port_tty_wakeup
tty_port_default
tty_port_tty_get (tty_port->lock)but those code is so old, and I have no clue how to de-couple it after checking other locks in the splat. There is an onging effort to make all printk() as deferred, so until that happens, workaround it for now as a short-term fix.
LTP: starting iogen01 (export LTPROOT; rwtest -N iogen01 -i 120s -s read,write -Da -Dv -n 2 500b:$TMPDIR/doio.f1.$$ 1000b:$TMPDIR/doio.f2.$$)
WARNING: possible circular locking dependency detected
------------------------------------------------------
doio/49441 is trying to acquire lock:ffff008b7cff7290 (&(&zone->lock)->rlock){..-.}, at: rmqueue+0x138/0x2050
but task is already holding lock:60ff000822352818 (&pool->lock/1){-.-.}, at: start_flush_work+0xd8/0x3f0
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #4 (&pool->lock/1){-.-.}:
lock_acquire+0x320/0x360
_raw_spin_lock+0x64/0x80
__queue_work+0x4b4/0xa10
queue_work_on+0xac/0x11c
tty_schedule_flip+0x84/0xbc
tty_flip_buffer_push+0x1c/0x28
pty_write+0x98/0xd0
n_tty_write+0x450/0x60c
tty_write+0x338/0x474
__vfs_write+0x88/0x214
vfs_write+0x12c/0x1a4
redirected_tty_write+0x90/0xdc
do_loop_readv_writev+0x140/0x180
do_iter_write+0xe0/0x10c
vfs_writev+0x134/0x1cc
do_writev+0xbc/0x130
__arm64_sys_writev+0x58/0x8c
el0_svc_handler+0x170/0x240
el0_sync_handler+0x150/0x250
el0_sync+0x164/0x180-> #3 (&(&port->lock)->rlock){-.-.}:
lock_acquire+0x320/0x360
_raw_spin_lock_irqsave+0x7c/0x9c
tty_port_tty_get+0x24/0x60
tty_port_default_wakeup+0x1c/0x3c
tty_port_tty_wakeup+0x34/0x40
uart_write_wakeup+0x28/0x44
pl011_tx_chars+0x1b8/0x270
pl011_start_tx+0x24/0x70
__uart_start+0x5c/0x68
uart_write+0x164/0x1c8
do_output_char+0x33c/0x348
n_tty_write+0x4bc/0x60c
tty_write+0x338/0x474
redirected_tty_write+0xc0/0xdc
do_loop_readv_writev+0x140/0x180
do_iter_write+0xe0/0x10c
vfs_writev+0x134/0x1cc
do_writev+0xbc/0x130
__arm64_sys_writev+0x58/0x8c
el0_svc_handler+0x170/0x240
el0_sync_handler+0x150/0x250
el0_sync+0x164/0x180-> #2 (&port_lock_key){-.-.}:
lock_acquire+0x320/0x360
_raw_spin_lock+0x64/0x80
pl011_console_write+0xec/0x2cc
console_unlock+0x794/0x96c
vprintk_emit+0x260/0x31c
vprintk_default+0x54/0x7c
vprintk_func+0x218/0x254
printk+0x7c/0xa4
register_console+0x734/0x7b0
uart_add_one_port+0x734/0x834
pl011_register_port+0x6c/0xac
sbsa_uart_probe+0x234/0x2ec
platform_drv_probe+0xd4/0x124
really_probe+0x250/0x71c
driver_probe_device+0xb4/0x200
__device_attach_driver+0xd8/0x188
bus_for_each_drv+0xbc/0x110
__device_attach+0x120/0x220
device_initial_probe+0x20/0x2c
bus_probe_device+0x54/0x100
device_add+0xae8/0xc2c
platform_device_add+0x278/0x3b8
platform_device_register_full+0x238/0x2ac
acpi_create_platform_device+0x2dc/0x3a8
acpi_bus_attach+0x390/0x3cc
acpi_bus_attach+0x108/0x3cc
acpi_bus_attach+0x108/0x3cc
acpi_bus_attach+0x108/0x3cc
acpi_bus_scan+0x7c/0xb0
acpi_scan_init+0xe4/0x304
acpi_init+0x100/0x114
do_one_initcall+0x348/0x6a0
do_initcall_level+0x190/0x1fc
do_basic_setup+0x34/0x4c
kernel_init_freeable+0x19c/0x260
kernel_init+0x18/0x338
ret_from_fork+0x10/0x18-> #1 (console_owner){-...}:
lock_acquire+0x320/0x360
console_lock_spinning_enable+0x6c/0x7c
console_unlock+0x4f8/0x96c
vprintk_emit+0x260/0x31c
vprintk_default+0x54/0x7c
vprintk_func+0x218/0x254
printk+0x7c/0xa4
get_random_u64+0x1c4/0x1dc
shuffle_pick_tail+0x40/0xac
__free_one_page+0x424/0x710
free_one_page+0x70/0x120
__free_pages_ok+0x61c/0xa94
__free_pages_core+0x1bc/0x294
memblock_free_pages+0x38/0x48
__free_pages_memory+0xcc/0xfc
__free_memory_core+0x70/0x78
free_low_memory_core_early+0x148/0x18c
memblock_free_all+0x18/0x54
mem_init+0xb4/0x17c
mm_init+0x14/0x38
start_kernel+0x19c/0x530-> #0 (&(&zone->lock)->rlock){..-.}:
validate_chain+0xf6c/0x2e2c
__lock_acquire+0x868/0xc2c
lock_acquire+0x320/0x360
_raw_spin_lock+0x64/0x80
rmqueue+0x138/0x2050
get_page_from_freelist+0x474/0x688
__alloc_pages_nodemask+0x3b4/0x18dc
alloc_pages_current+0xd0/0xe0
alloc_slab_page+0x2b4/0x5e0
new_slab+0xc8/0x6bc
___slab_alloc+0x3b8/0x640
kmem_cache_alloc+0x4b4/0x588
__debug_object_init+0x778/0x8b4
debug_object_init_on_stack+0x40/0x50
start_flush_work+0x16c/0x3f0
__flush_work+0xb8/0x124
flush_work+0x20/0x30
xlog_cil_force_lsn+0x88/0x204 [xfs]
xfs_log_force_lsn+0x128/0x1b8 [xfs]
xfs_file_fsync+0x3c4/0x488 [xfs]
vfs_fsync_range+0xb0/0xd0
generic_write_sync+0x80/0xa0 [xfs]
xfs_file_buffered_aio_write+0x66c/0x6e4 [xfs]
xfs_file_write_iter+0x1a0/0x218 [xfs]
__vfs_write+0x1cc/0x214
vfs_write+0x12c/0x1a4
ksys_write+0xb0/0x120
__arm64_sys_write+0x54/0x88
el0_svc_handler+0x170/0x240
el0_sync_handler+0x150/0x250
el0_sync+0x164/0x180other info that might help us debug this:
Chain exists of: &(&zone->lock)->rlock --> &(&port->lock)->rlock --> &pool->lock/1 Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&pool->lock/1);
lock(&(&port->lock)->rlock);
lock(&pool->lock/1);lock(&(&zone->lock)->rlock);
*** DEADLOCK ***
4 locks held by doio/49441:
#0: a0ff00886fc27408 (sb_writers#8){.+.+}, at: vfs_write+0x118/0x1a4 #1: 8fff00080810dfe0 (&xfs_nondir_ilock_class){++++}, at:
xfs_ilock+0x2a8/0x300 [xfs]
#2: ffff9000129f2390 (rcu_read_lock){....}, at:
rcu_lock_acquire+0x8/0x38
#3: 60ff000822352818 (&pool->lock/1){-.-.}, at:
start_flush_work+0xd8/0x3f0
stack backtrace:
CPU: 48 PID: 49441 Comm: doio Tainted: G W
Hardware name: HPE Apollo 70 /C01_APACHE_MB , BIOS
L50_5.13_1.11 06/18/2019
Call trace:
dump_backtrace+0x0/0x248
show_stack+0x20/0x2c
dump_stack+0xe8/0x150
print_circular_bug+0x368/0x380
check_noncircular+0x28c/0x294
validate_chain+0xf6c/0x2e2c
__lock_acquire+0x868/0xc2c
lock_acquire+0x320/0x360
_raw_spin_lock+0x64/0x80
rmqueue+0x138/0x2050
get_page_from_freelist+0x474/0x688
__alloc_pages_nodemask+0x3b4/0x18dc
alloc_pages_current+0xd0/0xe0
alloc_slab_page+0x2b4/0x5e0
new_slab+0xc8/0x6bc
___slab_alloc+0x3b8/0x640
kmem_cache_alloc+0x4b4/0x588
__debug_object_init+0x778/0x8b4
debug_object_init_on_stack+0x40/0x50
start_flush_work+0x16c/0x3f0
__flush_work+0xb8/0x124
flush_work+0x20/0x30
xlog_cil_force_lsn+0x88/0x204 [xfs]
xfs_log_force_lsn+0x128/0x1b8 [xfs]
xfs_file_fsync+0x3c4/0x488 [xfs]
vfs_fsync_range+0xb0/0xd0
generic_write_sync+0x80/0xa0 [xfs]
xfs_file_buffered_aio_write+0x66c/0x6e4 [xfs]
xfs_file_write_iter+0x1a0/0x218 [xfs]
__vfs_write+0x1cc/0x214
vfs_write+0x12c/0x1a4
ksys_write+0xb0/0x120
__arm64_sys_write+0x54/0x88
el0_svc_handler+0x170/0x240
el0_sync_handler+0x150/0x250
el0_sync+0x164/0x180--- drivers/char/random.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/char/random.c +3 -2
@@ -1598,8 +1598,9 @@ static void _warn_unseeded_randomness(const char *func_name, void *caller, print_once = true;#endif if (__ratelimit (&unseeded_warning)) -pr_notice ("random: %s called from %pS with crng_init=%d\n" , - func_name, caller, crng_init); +printk_deferred (KERN_NOTICE "random: %s called from %pS " +"with crng_init=%d\n" , func_name, caller, + crng_init); }/*
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 52/237 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 53/237 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 54/237 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
@@ -480,7 +480,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 ||
@@ -505,14 +504,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 55/237 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 56/237 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
@@ -167,12 +167,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 57/237 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 58/237 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 59/237 usb: dwc2: Fix IN FIFO allocation
In reply to Greg Kroah-HartmanFrom: John Keeping <[email protected]>
[ Upstream commit 644139f8b64d818f6345351455f14471510879a5 ]
On chips with fewer FIFOs than endpoints (for example RK3288 which has 9 endpoints, but only 6 which are cabable of input), the DPTXFSIZN registers above the FIFO count may return invalid values.
With logging added on startup, I see:
dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=1 sz=256 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=2 sz=128 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=3 sz=128 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=4 sz=64 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=5 sz=64 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=6 sz=32 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=7 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=8 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=9 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=10 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=11 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=12 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=13 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=14 sz=0 dwc2 ff580000.usb: dwc2_hsotg_init_fifo: ep=15 sz=0
but:
# cat /sys/kernel/debug/ff580000.usb/fifo Non-periodic FIFOs: RXFIFO: Size 275 NPTXFIFO: Size 16, Start 0x00000113
Periodic TXFIFOs: DPTXFIFO 1: Size 256, Start 0x00000123 DPTXFIFO 2: Size 128, Start 0x00000223 DPTXFIFO 3: Size 128, Start 0x000002a3 DPTXFIFO 4: Size 64, Start 0x00000323 DPTXFIFO 5: Size 64, Start 0x00000363 DPTXFIFO 6: Size 32, Start 0x000003a3 DPTXFIFO 7: Size 0, Start 0x000003e3 DPTXFIFO 8: Size 0, Start 0x000003a3 DPTXFIFO 9: Size 256, Start 0x00000123
so it seems that FIFO 9 is mirroring FIFO 1.
Fix the allocation by using the FIFO count instead of the endpoint count when selecting a FIFO for an endpoint.
--- drivers/usb/dwc2/gadget.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc2/gadget.c +2 -1
@@ -3933,11 +3933,12 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,* a unique tx-fifo even if it is non-periodic. */ if (dir_in && hsotg->dedicated_fifos) { +unsigned fifo_count =dwc2_hsotg_tx_fifo_count (hsotg);u32 fifo_index =0 ;u32 fifo_size =UINT_MAX ; size = hs_ep->ep.maxpacket * hs_ep->mc; -for (i =1 ; i < hsotg->num_of_eps; ++i) { +for (i =1 ; i <= fifo_count; ++i) {if (hsotg->fifo_map & (1 << i))continue ; val =dwc2_readl (hsotg->regs +DPTXFSIZN (i));
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 60/237 clocksource/drivers/bcm2835_timer: Fix memory leak of timer
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
[ Upstream commit 2052d032c06761330bca4944bb7858b00960e868 ]
Currently when setup_irq fails the error exit path will leak the recently allocated timer structure. Originally the code would throw a panic but a later commit changed the behaviour to return via the err_iounmap path and hence we now have a memory leak. Fix this by adding a err_timer_free error path that kfree's timer.
Addresses-Coverity: ("Resource Leak")
--- drivers/clocksource/bcm2835_timer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/bcm2835_timer.c +4 -1
@@ -134,7 +134,7 @@ static int __init bcm2835_timer_init(struct device_node *node) ret =setup_irq (irq, &timer->act);if (ret) {pr_err ("Can't set up timer IRQ\n" ); - goto err_iounmap; + goto err_timer_free; }clockevents_config_and_register (&timer->evt, freq,0xf ,0xffffffff );
@@ -143,6 +143,9 @@ static int __init bcm2835_timer_init(struct device_node *node)return 0 ; +err_timer_free: +kfree (timer); + err_iounmap:iounmap (base);return ret;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 61/237 kselftest: Minimise dependency of get_size on C library interfaces
In reply to Greg Kroah-HartmanFrom: Siddhesh Poyarekar <[email protected]>
[ Upstream commit 6b64a650f0b2ae3940698f401732988699eecf7a ]
It was observed[1] on arm64 that __builtin_strlen led to an infinite loop in the get_size selftest. This is because __builtin_strlen (and other builtins) may sometimes result in a call to the C library function. The C library implementation of strlen uses an IFUNC resolver to load the most efficient strlen implementation for the underlying machine and hence has a PLT indirection even for static binaries. Because this binary avoids the C library startup routines, the PLT initialization never happens and hence the program gets stuck in an infinite loop.
On x86_64 the __builtin_strlen just happens to expand inline and avoid the call but that is not always guaranteed.
Further, while testing on x86_64 (Fedora 31), it was observed that the test also failed with a segfault inside write() because the generated code for the write function in glibc seems to access TLS before the syscall (probably due to the cancellation point check) and fails because TLS is not initialised.
To mitigate these problems, this patch reduces the interface with the C library to just the syscall function. The syscall function still sets errno on failure, which is undesirable but for now it only affects cases where syscalls fail.
[1] https://bugs.linaro.org/show_bug.cgi?id=5479
--- tools/testing/selftests/size/get_size.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
tools/testing/selftests/size/get_size.c +18 -6
@@ -12,23 +12,35 @@* own execution. It also attempts to have as few dependencies * on kernel features as possible. * -* It should be statically linked, with startup libs avoided. -* It uses no library calls, and only the following 3 syscalls: +* It should be statically linked, with startup libs avoided. It uses +* no library calls except the syscall() function for the following 3 +* syscalls: * sysinfo(), write(), and _exit() * * For output, it avoids printf (which in some C libraries * has large external dependencies) by implementing it's own * number output and print routines, and using __builtin_strlen() +* +* The test may crash if any of the above syscalls fails because in some +* libc implementations (e.g. the GNU C Library) errno is saved in +* thread-local storage, which does not get initialized due to avoiding +* startup libs. */ #include <sys/sysinfo.h> #include <unistd.h> +#include <sys/syscall.h> #define STDOUT_FILENO 1static int const char *s) { -return write (STDOUT_FILENO , s,__builtin_strlen (s)); +size_t len =0 ; + +while (s[len] !='\0' ) + len++; + +return syscall (SYS_write,STDOUT_FILENO , s, len); }static inline char *num_to_str (unsigned long num,char *buf,int len)
@@ -80,12 +92,12 @@ void _start(void)"TAP version 13\n" );"# Testing system size.\n" ); - ccode =sysinfo (&info); + ccode =syscall (SYS_sysinfo, &info);if (ccode <0 ) {"not ok 1" );" ---\n reason: \"could not get sysinfo\"\n ...\n" ); -_exit (ccode); +syscall (SYS_exit, ccode); }"ok 1" );
@@ -101,5 +113,5 @@ void _start(void)" ...\n" );"1..1\n" ); -_exit (0 ); +syscall (SYS_exit,0 ); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 62/237 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
@@ -1687,6 +1687,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
@@ -1694,7 +1699,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 63/237 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 64/237 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
@@ -278,18 +278,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 65/237 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
@@ -306,7 +306,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 ;
@@ -317,17 +317,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);
@@ -336,15 +334,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 66/237 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
@@ -2128,12 +2128,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); }/**
@@ -2175,11 +2173,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 67/237 nbd: add a flush_workqueue in nbd_start_device
In reply to Greg Kroah-HartmanFrom: Sun Ke <[email protected]>
[ Upstream commit 5c0dd228b5fc30a3b732c7ae2657e0161ec7ed80 ]
When kzalloc fail, may cause trying to destroy the workqueue from inside the workqueue.
If num_connections is m (2 < m), and NO.1 ~ NO.n (1 < n < m) kzalloc are successful. The NO.(n + 1) failed. Then, nbd_start_device will return ENOMEM to nbd_start_device_ioctl, and nbd_start_device_ioctl will return immediately without running flush_workqueue. However, we still have n recv threads. If nbd_release run first, recv threads may have to drop the last config_refs and try to destroy the workqueue from inside the workqueue.
To fix it, add a flush_workqueue in nbd_start_device.
--- drivers/block/nbd.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/block/nbd.c +10 -0
@@ -1203,6 +1203,16 @@ static int nbd_start_device(struct nbd_device *nbd) args =kzalloc (sizeof (*args),GFP_KERNEL );if (!args) {sock_shutdown (nbd); +/* +* If num_connections is m (2 < m), +* and NO.1 ~ NO.n(1 < n < m) kzallocs are successful. +* But NO.(n + 1) failed. We still have n recv threads. +* So, add flush_workqueue here to prevent recv threads +* dropping the last config_refs and trying to destroy +* the workqueue from inside the workqueue. +*/ +if (i) +flush_workqueue (nbd->recv_workq);return -ENOMEM ; }sk_set_memalloc (config->socks[i]->sock->sk);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 68/237 KVM: s390: ENOTSUPP -> EOPNOTSUPP fixups
In reply to Greg Kroah-HartmanFrom: Christian Borntraeger <[email protected]>
[ Upstream commit c611990844c28c61ca4b35ff69d3a2ae95ccd486 ]
There is no ENOTSUPP for userspace.
--- arch/s390/kvm/interrupt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kvm/interrupt.c +3 -3
@@ -1913,7 +1913,7 @@ static int flic_ais_mode_get_all(struct kvm *kvm, struct kvm_device_attr *attr)return -EINVAL ;if (!test_kvm_facility (kvm,72 )) -return -ENOTSUPP ; +return -EOPNOTSUPP ;mutex_lock (&fi->ais_lock); ais.simm = fi->simm;
@@ -2214,7 +2214,7 @@ static int modify_ais_mode(struct kvm *kvm, struct kvm_device_attr *attr)int ret =0 ;if (!test_kvm_facility (kvm,72 )) -return -ENOTSUPP ; +return -EOPNOTSUPP ;if (copy_from_user (&req, (void __user *)attr->addr,sizeof (req)))return -EFAULT ;
@@ -2294,7 +2294,7 @@ static int flic_ais_mode_set_all(struct kvm *kvm, struct kvm_device_attr *attr)struct kvm_s390_ais_all ais;if (!test_kvm_facility (kvm,72 )) -return -ENOTSUPP ; +return -EOPNOTSUPP ;if (copy_from_user (&ais, (void __user *)attr->addr,sizeof (ais)))return -EFAULT ;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 69/237 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 70/237 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
@@ -210,6 +210,9 @@ static int _freq_tbl_determine_rate(struct clk_hw *hw, const struct freq_tbl *f, 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 71/237 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 72/237 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
@@ -714,7 +714,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 73/237 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
@@ -240,6 +240,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 74/237 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
@@ -179,6 +179,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);pci_stop_and_remove_bus_device (virtfn); failed0:
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 75/237 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
@@ -574,7 +574,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 76/237 arm64: dts: qcom: msm8996: Disable USB2 PHY suspend by core
In reply to Greg Kroah-HartmanFrom: Manu Gautam <[email protected]>
[ Upstream commit d026c96b25b7ce5df89526aad2df988d553edb4d ]
QUSB2 PHY on msm8996 doesn't work well when autosuspend by dwc3 core using USB2PHYCFG register is enabled. One of the issue seen is that PHY driver reports PLL lock failure and fails phy_init() if dwc3 core has USB2 PHY suspend enabled. Fix this by using quirks to disable USB2 PHY LPM/suspend and dwc3 core already takes care of explicitly suspending PHY during suspend if quirks are specified.
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/qcom/msm8996.dtsi +4 -0
@@ -788,6 +788,8 @@ interrupts = <0 138 0>; phys = <&hsusb_phy2>; phy-names = "usb2-phy"; + snps,dis_u2_susphy_quirk; + snps,dis_enblslpm_quirk; }; };
@@ -817,6 +819,8 @@ interrupts = <0 131 0>; phys = <&hsusb_phy1>, <&ssusb_phy_0>; phy-names = "usb2-phy", "usb3-phy"; + snps,dis_u2_susphy_quirk; + snps,dis_enblslpm_quirk; }; }; };
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 77/237 ARM: dts: imx6: rdu2: Disable WP for USDHC2 and USDHC3
In reply to Greg Kroah-HartmanFrom: Andrey Smirnov <[email protected]>
[ Upstream commit cd58a174e58649426fb43d7456e5f7d7eab58af1 ]
RDU2 production units come with resistor connecting WP pin to correpsonding GPIO DNPed for both SD card slots. Drop any WP related configuration and mark both slots with "disable-wp".
--- arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi +2 -4
@@ -587,7 +587,7 @@ pinctrl-0 = <&pinctrl_usdhc2>; bus-width = <4>; cd-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>; - wp-gpios = <&gpio2 3 GPIO_ACTIVE_HIGH>; + disable-wp; vmmc-supply = <®_3p3v_sd>; vqmmc-supply = <®_3p3v>; status = "okay";
@@ -598,7 +598,7 @@ pinctrl-0 = <&pinctrl_usdhc3>; bus-width = <4>; cd-gpios = <&gpio2 0 GPIO_ACTIVE_LOW>; - wp-gpios = <&gpio2 1 GPIO_ACTIVE_HIGH>; + disable-wp; vmmc-supply = <®_3p3v_sd>; vqmmc-supply = <®_3p3v>; status = "okay";
@@ -1001,7 +1001,6 @@ MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17059 MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17059 MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x17059 - MX6QDL_PAD_NANDF_D3__GPIO2_IO03 0x40010040 MX6QDL_PAD_NANDF_D2__GPIO2_IO02 0x40010040 >; };
@@ -1014,7 +1013,6 @@ MX6QDL_PAD_SD3_DAT1__SD3_DATA1 0x17059 MX6QDL_PAD_SD3_DAT2__SD3_DATA2 0x17059 MX6QDL_PAD_SD3_DAT3__SD3_DATA3 0x17059 - MX6QDL_PAD_NANDF_D1__GPIO2_IO01 0x40010040 MX6QDL_PAD_NANDF_D0__GPIO2_IO00 0x40010040 >;
Signature · 9 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Greg Kroah-Hartman
maintainerPATCH 78/237 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 79/237 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
@@ -1954,7 +1954,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 80/237 fore200e: Fix incorrect checks of NULL pointer dereference
In reply to Greg Kroah-HartmanFrom: Aditya Pakki <[email protected]>
[ Upstream commit bbd20c939c8aa3f27fa30e86691af250bf92973a ]
In fore200e_send and fore200e_close, the pointers from the arguments are dereferenced in the variable declaration block and then checked for NULL. The patch fixes these issues by avoiding NULL pointer dereferences.
--- drivers/atm/fore200e.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/atm/fore200e.c +18 -7
@@ -1496,12 +1496,14 @@ fore200e_open(struct atm_vcc *vcc)static void fore200e_close (struct atm_vcc * vcc) { -struct fore200e * fore200e =FORE200E_DEV (vcc->dev);struct fore200e_vcc * fore200e_vcc; +struct fore200e * fore200e;struct fore200e_vc_map * vc_map;unsigned long flags;ASSERT (vcc); + fore200e =FORE200E_DEV (vcc->dev); +ASSERT ((vcc->vpi >=0 ) && (vcc->vpi <1 <<FORE200E_VPI_BITS ));ASSERT ((vcc->vci >=0 ) && (vcc->vci <1 <<FORE200E_VCI_BITS ));
@@ -1546,10 +1548,10 @@ fore200e_close(struct atm_vcc* vcc)static int fore200e_send (struct atm_vcc *vcc,struct sk_buff *skb) { -struct fore200e * fore200e =FORE200E_DEV (vcc->dev); -struct fore200e_vcc * fore200e_vcc =FORE200E_VCC (vcc); +struct fore200e * fore200e; +struct fore200e_vcc * fore200e_vcc;struct fore200e_vc_map * vc_map; -struct host_txq * txq = &fore200e->host_txq; +struct host_txq * txq;struct host_txq_entry * entry;struct tpd * tpd;struct tpd_haddr tpd_haddr;
@@ -1562,9 +1564,18 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)unsigned char * data;unsigned long flags; -ASSERT (vcc); -ASSERT (fore200e); -ASSERT (fore200e_vcc); +if (!vcc) +return -EINVAL ; + + fore200e =FORE200E_DEV (vcc->dev); + fore200e_vcc =FORE200E_VCC (vcc); + +if (!fore200e) +return -EINVAL ; + + txq = &fore200e->host_txq; +if (!fore200e_vcc) +return -EINVAL ;if (!test_bit (ATM_VF_READY , &vcc->flags)) {DPRINTK (1 ,"VC %d.%d.%d not ready for tx\n" , vcc->itf, vcc->vpi, vcc->vpi);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 81/237 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
@@ -131,7 +131,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 82/237 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 83/237 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;
@@ -6027,7 +6028,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,
@@ -6157,7 +6158,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
@@ -1966,8 +1966,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 ;
@@ -10702,7 +10703,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 84/237 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
@@ -4363,8 +4363,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;
@@ -6264,7 +6265,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 85/237 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
@@ -1091,13 +1091,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 86/237 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
@@ -1364,7 +1364,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 87/237 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
@@ -273,7 +273,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
@@ -444,6 +444,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 88/237 scsi: ufs: Complete pending requests in host reset and restore path
In reply to Greg Kroah-HartmanFrom: Can Guo <[email protected]>
[ Upstream commit 2df74b6985b51e77756e2e8faa16c45ca3ba53c5 ]
In UFS host reset and restore path, before probe, we stop and start the host controller once. After host controller is stopped, the pending requests, if any, are cleared from the doorbell, but no completion IRQ would be raised due to the hba is stopped. These pending requests shall be completed along with the first NOP_OUT command (as it is the first command which can raise a transfer completion IRQ) sent during probe. Since the OCSs of these pending requests are not SUCCESS (because they are not yet literally finished), their UPIUs shall be dumped. When there are multiple pending requests, the UPIU dump can be overwhelming and may lead to stability issues because it is in atomic context. Therefore, before probe, complete these pending requests right after host controller is stopped and silence the UPIU dump from them.
--- drivers/scsi/ufs/ufshcd.c | 24 ++++++++++-------------- drivers/scsi/ufs/ufshcd.h | 2 ++ 2 files changed, 12 insertions(+), 14 deletions(-)
drivers/scsi/ufs/ufshcd.c +10 -14
@@ -4580,7 +4580,7 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)break ; }/* end of switch */ -if (host_byte (result) !=DID_OK ) +if ((host_byte (result) !=DID_OK ) && !hba->silence_err_logs)ufshcd_print_trs (hba,1 << lrbp->task_tag, true);return result; }
@@ -5109,8 +5109,8 @@ static void ufshcd_err_handler(struct work_struct *work)/* * if host reset is required then skip clearing the pending -* transfers forcefully because they will automatically get -* cleared after link startup. +* transfers forcefully because they will get cleared during +* host reset and restore */ if (needs_reset) goto skip_pending_xfer_clear;
@@ -5749,9 +5749,15 @@ static int ufshcd_host_reset_and_restore(struct ufs_hba *hba)int err;unsigned long flags; -/* Reset the host controller */ +/* +* Stop the host controller and complete the requests +* cleared by h/w +*/ spin_lock_irqsave (hba->host->host_lock, flags);ufshcd_hba_stop (hba, false); + hba->silence_err_logs = true; +ufshcd_complete_requests (hba); + hba->silence_err_logs = false;spin_unlock_irqrestore (hba->host->host_lock, flags);/* scale up clocks to max frequency before full reinitialization */
@@ -5785,22 +5791,12 @@ out:static int ufshcd_reset_and_restore (struct ufs_hba *hba) {int err =0 ; -unsigned long flags;int retries =MAX_HOST_RESET_RETRIES ;do { err =ufshcd_host_reset_and_restore (hba); }while (err && --retries); -/* -* After reset the door-bell might be cleared, complete -* outstanding requests in s/w here. -*/ -spin_lock_irqsave (hba->host->host_lock, flags); -ufshcd_transfer_req_compl (hba); -ufshcd_tmc_handler (hba); -spin_unlock_irqrestore (hba->host->host_lock, flags); -return err; }
drivers/scsi/ufs/ufshcd.h +2 -0
@@ -485,6 +485,7 @@ struct ufs_stats {* @uic_error: UFS interconnect layer error status * @saved_err: sticky error mask * @saved_uic_err: sticky UIC error mask +* @silence_err_logs: flag to silence error logs * @dev_cmd: ufs device management command information * @last_dme_cmd_tstamp: time stamp of the last completed DME command * @auto_bkops_enabled: to track whether bkops is enabled in device
@@ -621,6 +622,7 @@ struct ufs_hba {u32 saved_err;u32 saved_uic_err;struct ufs_stats ufs_stats; +bool silence_err_logs;/* Device management request data */ struct ufs_dev_cmd dev_cmd;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 89/237 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 90/237 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
@@ -307,6 +307,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__);
@@ -328,6 +329,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_crtc_ddp_config (struct drm_crtc *crtc)
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 91/237 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 92/237 dmaengine: Store module owner in dma_device struct
In reply to Greg Kroah-HartmanFrom: Logan Gunthorpe <[email protected]>
[ Upstream commit dae7a589c18a4d979d5f14b09374e871b995ceb1 ]
dma_chan_to_owner() dereferences the driver from the struct device to obtain the owner and call module_[get|put](). However, if the backing device is unbound before the dma_device is unregistered, the driver will be cleared and this will cause a NULL pointer dereference.
Instead, store a pointer to the owner module in the dma_device struct so the module reference can be properly put when the channel is put, even if the backing device was destroyed first.
This change helps to support a safer unbind of DMA engines. If the dma_device is unregistered in the driver's remove function, there's no guarantee that there are no existing clients and a users action may trigger the WARN_ONCE in dma_async_device_unregister() which is unlikely to leave the system in a consistent state. Instead, a better approach is to allow the backing driver to go away and fail any subsequent requests to it.
--- drivers/dma/dmaengine.c | 4 +++- include/linux/dmaengine.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/dma/dmaengine.c +3 -1
@@ -192,7 +192,7 @@ __dma_device_satisfies_mask(struct dma_device *device,static struct module *dma_chan_to_owner (struct dma_chan *chan) { -return chan->device->dev->driver->owner; +return chan->device->owner; }/**
@@ -928,6 +928,8 @@ int dma_async_device_register(struct dma_device *device)return -EIO ; } + device->owner = device->dev->driver->owner; +if (dma_has_cap (DMA_MEMCPY , device->cap_mask) && !device->device_prep_dma_memcpy) { dev_err(device->dev, "Device claims capability %s, but op is not defined\n",
include/linux/dmaengine.h +2 -0
@@ -677,6 +677,7 @@ struct dma_filter {* @fill_align: alignment shift for memset operations * @dev_id: unique device ID * @dev: struct device reference for dma mapping api +* @owner: owner module (automatically set based on the provided dev) * @src_addr_widths: bit mask of src addr widths the device supports * @dst_addr_widths: bit mask of dst addr widths the device supports * @directions: bit mask of slave direction the device supports since
@@ -738,6 +739,7 @@ struct dma_device {int dev_id;struct device *dev; +struct module *owner;u32 src_addr_widths;u32 dst_addr_widths;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 93/237 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
@@ -11,6 +11,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 94/237 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
@@ -103,7 +103,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 95/237 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
@@ -78,8 +78,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 96/237 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
@@ -408,7 +408,7 @@ struct rxe_dev {struct list_head pending_mmaps;spinlock_t mmap_offset_lock;/* guard mmap_offset */ -int mmap_offset; +u64 mmap_offset;atomic64_t stats_counters[RXE_NUM_OF_COUNTERS ];
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 97/237 clk: sunxi-ng: add mux and pll notifiers for A64 CPU clock
In reply to Greg Kroah-HartmanFrom: Icenowy Zheng <[email protected]>
[ Upstream commit ec97faff743b398e21f74a54c81333f3390093aa ]
The A64 PLL_CPU clock has the same instability if some factor changed without the PLL gated like other SoCs with sun6i-style CCU, e.g. A33, H3.
Add the mux and pll notifiers for A64 CPU clock to workaround the problem.
--- drivers/clk/sunxi-ng/ccu-sun50i-a64.c | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/clk/sunxi-ng/ccu-sun50i-a64.c +27 -1
@@ -884,11 +884,26 @@ static const struct sunxi_ccu_desc sun50i_a64_ccu_desc = { .num_resets = ARRAY_SIZE(sun50i_a64_ccu_resets), }; +static struct ccu_pll_nb sun50i_a64_pll_cpu_nb = { + .common = &pll_cpux_clk.common, +/* copy from pll_cpux_clk */ + .enable =BIT (31 ), + .lock =BIT (28 ), +}; + +static struct ccu_mux_nb sun50i_a64_cpu_nb = { + .common = &cpux_clk.common, + .cm = &cpux_clk.mux, + .delay_us =1 ,/* > 8 clock cycles at 24 MHz */ + .bypass_index =1 ,/* index of 24 MHz oscillator */ +}; +static int sun50i_a64_ccu_probe (struct platform_device *pdev) {struct resource *res;void __iomem *reg;u32 val; +int ret; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); reg =devm_ioremap_resource (&pdev->dev, res);
@@ -902,7 +917,18 @@ static int sun50i_a64_ccu_probe(struct platform_device *pdev)writel (0x515 , reg +SUN50I_A64_PLL_MIPI_REG ); -return sunxi_ccu_probe (pdev->dev.of_node, reg, &sun50i_a64_ccu_desc); + ret =sunxi_ccu_probe (pdev->dev.of_node, reg, &sun50i_a64_ccu_desc); +if (ret) +return ret; + +/* Gate then ungate PLL CPU after any rate changes */ +ccu_pll_notifier_register (&sun50i_a64_pll_cpu_nb); + +/* Reparent CPU during PLL CPU rate changes */ +ccu_mux_notifier_register (pll_cpux_clk.common.hw.clk, + &sun50i_a64_cpu_nb); + +return 0 ; }static const struct of_device_id sun50i_a64_ccu_ids[] = {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 98/237 ALSA: sh: Fix unused variable warnings
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
[ Upstream commit 5da116f164ce265e397b8f59af5c39e4a61d61a5 ]
Remove unused variables that are left over after the conversion of new PCM ops:
sound/sh/sh_dac_audio.c:166:26: warning: unused variable 'runtime' sound/sh/sh_dac_audio.c:186:26: warning: unused variable 'runtime' sound/sh/sh_dac_audio.c:205:26: warning: unused variable 'runtime'
--- sound/sh/sh_dac_audio.c | 3 --- 1 file changed, 3 deletions(-)
sound/sh/sh_dac_audio.c +0 -3
@@ -190,7 +190,6 @@ static int snd_sh_dac_pcm_copy(struct snd_pcm_substream *substream, {/* channel is not used (interleaved data) */ struct snd_sh_dac *chip =snd_pcm_substream_chip (substream); -struct snd_pcm_runtime *runtime = substream->runtime;if (copy_from_user_toio (chip->data_buffer + pos, src, count))return -EFAULT ;
@@ -210,7 +209,6 @@ static int snd_sh_dac_pcm_copy_kernel(struct snd_pcm_substream *substream, {/* channel is not used (interleaved data) */ struct snd_sh_dac *chip =snd_pcm_substream_chip (substream); -struct snd_pcm_runtime *runtime = substream->runtime;memcpy_toio (chip->data_buffer + pos, src, count); chip->buffer_end = chip->data_buffer + pos + count;
@@ -229,7 +227,6 @@ static int snd_sh_dac_pcm_silence(struct snd_pcm_substream *substream, {/* channel is not used (interleaved data) */ struct snd_sh_dac *chip =snd_pcm_substream_chip (substream); -struct snd_pcm_runtime *runtime = substream->runtime;memset_io (chip->data_buffer + pos,0 , count); chip->buffer_end = chip->data_buffer + pos + count;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 99/237 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 100/237 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
@@ -210,6 +210,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" );
@@ -219,7 +220,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 101/237 drm: remove the newline for CRC source name.
In reply to Greg Kroah-HartmanFrom: Dingchen Zhang <[email protected]>
[ Upstream commit 72a848f5c46bab4c921edc9cbffd1ab273b2be17 ]
userspace may transfer a newline, and this terminating newline is replaced by a '\0' to avoid followup issues.
'len-1' is the index to replace the newline of CRC source name.
v3: typo fix (Sam)
v2: update patch subject, body and format. (Sam)
--- drivers/gpu/drm/drm_debugfs_crc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_debugfs_crc.c +2 -2
@@ -101,8 +101,8 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf,if (IS_ERR (source))return PTR_ERR (source); -if (source[len] =='\n' ) - source[len] ='\0' ; +if (source[len -1 ] =='\n' ) + source[len -1 ] ='\0' ;spin_lock_irq (&crc->lock);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 102/237 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
@@ -34,12 +34,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
@@ -165,11 +159,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 103/237 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
@@ -2467,17 +2467,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 ; }
@@ -2486,7 +2498,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 104/237 IB/hfi1: Add software counter for ctxt0 seq drop
In reply to Greg Kroah-HartmanFrom: Mike Marciniszyn <[email protected]>
[ Upstream commit 5ffd048698ea5139743acd45e8ab388a683642b8 ]
All other code paths increment some form of drop counter.
This was missed in the original implementation.
--- drivers/infiniband/hw/hfi1/chip.c | 10 ++++++++++ drivers/infiniband/hw/hfi1/chip.h | 1 + drivers/infiniband/hw/hfi1/driver.c | 1 + drivers/infiniband/hw/hfi1/hfi.h | 2 ++ 4 files changed, 14 insertions(+)
drivers/infiniband/hw/hfi1/chip.c +10 -0
@@ -1686,6 +1686,14 @@ static u64 access_sw_pio_drain(const struct cntr_entry *entry,return dd->verbs_dev.n_piodrain; } +static u64 access_sw_ctx0_seq_drop (const struct cntr_entry *entry, +void *context,int vl,int mode,u64 data) +{ +struct hfi1_devdata *dd = context; + +return dd->ctx0_seq_drop; +} +static u64 access_sw_vtx_wait (const struct cntr_entry *entry,void *context,int vl,int mode,u64 data) {
@@ -4246,6 +4254,8 @@ static struct cntr_entry dev_cntrs[DEV_CNTR_LAST] = { access_sw_cpu_intr), [C_SW_CPU_RCV_LIM ] =CNTR_ELEM ("RcvLimit" ,0 ,0 ,CNTR_NORMAL , access_sw_cpu_rcv_limit), +[C_SW_CTX0_SEQ_DROP ] =CNTR_ELEM ("SeqDrop0" ,0 ,0 ,CNTR_NORMAL , + access_sw_ctx0_seq_drop), [C_SW_VTX_WAIT ] =CNTR_ELEM ("vTxWait" ,0 ,0 ,CNTR_NORMAL , access_sw_vtx_wait), [C_SW_PIO_WAIT] = CNTR_ELEM("PioWait", 0, 0, CNTR_NORMAL,
drivers/infiniband/hw/hfi1/chip.h +1 -0
@@ -864,6 +864,7 @@ enum {C_DC_PG_STS_TX_MBE_CNT ,C_SW_CPU_INTR ,C_SW_CPU_RCV_LIM , +C_SW_CTX0_SEQ_DROP ,C_SW_VTX_WAIT ,C_SW_PIO_WAIT , C_SW_PIO_DRAIN,
drivers/infiniband/hw/hfi1/driver.c +1 -0
@@ -710,6 +710,7 @@ static noinline int skip_rcv_packet(struct hfi1_packet *packet, int thread) {int ret; + packet->rcd->dd->ctx0_seq_drop++;/* Set up for the next packet */ packet->rhqoff += packet->rsize;if (packet->rhqoff >= packet->maxcnt)
drivers/infiniband/hw/hfi1/hfi.h +2 -0
@@ -1043,6 +1043,8 @@ struct hfi1_devdata {char *boardname;/* human readable board info */ +u64 ctx0_seq_drop; +/* reset value */ u64 z_int_counter;u64 z_rcv_limit;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 105/237 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 106/237 efi/x86: Dont panic or BUG() on non-critical error conditions
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit e2d68a955e49d61fd0384f23e92058dc9b79be5e ]
The logic in __efi_enter_virtual_mode() does a number of steps in sequence, all of which may fail in one way or the other. In most cases, we simply print an error and disable EFI runtime services support, but in some cases, we BUG() or panic() and bring down the system when encountering conditions that we could easily handle in the same way.
While at it, replace a pointless page-to-virt-phys conversion with one that goes straight from struct page to physical.
--- arch/x86/platform/efi/efi.c | 28 ++++++++++++++-------------- arch/x86/platform/efi/efi_64.c | 9 +++++---- 2 files changed, 19 insertions(+), 18 deletions(-)
arch/x86/platform/efi/efi.c +14 -14
@@ -930,16 +930,14 @@ static void __init __efi_enter_virtual_mode(void)if (efi_alloc_page_tables ()) {pr_err ("Failed to allocate EFI page tables\n" ); -clear_bit (EFI_RUNTIME_SERVICES , &efi.flags); -return ; + goto err; }efi_merge_regions (); new_memmap =efi_map_regions (&count, &pg_shift);if (!new_memmap) {pr_err ("Error reallocating memory, EFI runtime non-functional!\n" ); -clear_bit (EFI_RUNTIME_SERVICES , &efi.flags); -return ; + goto err; } pa =__pa (new_memmap);
@@ -953,8 +951,7 @@ static void __init __efi_enter_virtual_mode(void)if (efi_memmap_init_late (pa, efi.memmap.desc_size * count)) {pr_err ("Failed to remap late EFI memory map\n" ); -clear_bit (EFI_RUNTIME_SERVICES , &efi.flags); -return ; + goto err; }if (efi_enabled (EFI_DBG )) {
@@ -962,12 +959,11 @@ static void __init __efi_enter_virtual_mode(void)efi_print_memmap (); } -BUG_ON (!efi.systab); +if (WARN_ON (!efi.systab)) + goto err; -if (efi_setup_page_tables (pa,1 << pg_shift)) { -clear_bit (EFI_RUNTIME_SERVICES , &efi.flags); -return ; - } +if (efi_setup_page_tables (pa,1 << pg_shift)) + goto err;efi_sync_low_kernel_mappings ();
@@ -987,9 +983,9 @@ static void __init __efi_enter_virtual_mode(void) }if (status !=EFI_SUCCESS ) { -pr_alert ("Unable to switch EFI into virtual mode (status=%lx)!\n" , - status); -panic ("EFI call to SetVirtualAddressMap() failed!" ); +pr_err ("Unable to switch EFI into virtual mode (status=%lx)!\n" , + status); + goto err; }/*
@@ -1016,6 +1012,10 @@ static void __init __efi_enter_virtual_mode(void)/* clean DUMMY object */ efi_delete_dummy_variable (); +return ; + +err: +clear_bit (EFI_RUNTIME_SERVICES , &efi.flags); }void __init efi_enter_virtual_mode (void )
arch/x86/platform/efi/efi_64.c +5 -4
@@ -390,11 +390,12 @@ int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)return 0 ; page =alloc_page (GFP_KERNEL |__GFP_DMA32); -if (!page) -panic ("Unable to allocate EFI runtime stack < 4GB\n" ); +if (!page) { +pr_err ("Unable to allocate EFI runtime stack < 4GB\n" ); +return 1 ; + } - efi_scratch.phys_stack =virt_to_phys (page_address (page)); - efi_scratch.phys_stack +=PAGE_SIZE ;/* stack grows down */ + efi_scratch.phys_stack =page_to_phys (page +1 );/* stack grows down */ npages = (_etext - _text) >>PAGE_SHIFT ; text =__pa (_text);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 107/237 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
@@ -72,10 +72,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)
@@ -85,13 +85,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
@@ -34,7 +34,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 ); } }
@@ -66,7 +66,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 ); }/**
@@ -94,10 +94,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 108/237 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
@@ -888,6 +888,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;
@@ -957,6 +958,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 109/237 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 110/237 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 111/237 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); } }
@@ -2484,7 +2484,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 ;
@@ -2493,7 +2493,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); } }
@@ -2820,8 +2820,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)) {
@@ -3191,7 +3191,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) |
@@ -3229,7 +3229,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 ;
@@ -3241,7 +3241,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 ;
@@ -3257,7 +3257,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
Re: [PATCH 4.14 111/237] tty: synclinkmp: Adjust indentation in several functions
Quoted 1 line · Greg Kroah-Hartman
From: Nathan Chancellor <[email protected]>
I believe these sorts of whitespace only changes should not be applied to a stable branch unless it's useful for porting other actual defect fixes.
Quoted 149 lines
[ 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.
Signed-off-by Nathan Chancellor <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- 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); } }@@ -2484,7 +2484,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 ;@@ -2493,7 +2493,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); } }@@ -2820,8 +2820,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)) {@@ -3191,7 +3191,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) |@@ -3229,7 +3229,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 ;@@ -3241,7 +3241,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 ;@@ -3257,7 +3257,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); }
Greg Kroah-Hartman
maintainerRe: [PATCH 4.14 111/237] tty: synclinkmp: Adjust indentation in several functions
Quoted 6 lines · Joe Perches
Quoted 1 line · Greg Kroah-Hartman
From: Nathan Chancellor <[email protected]>
I believe these sorts of whitespace only changes should not be applied to a stable branch unless it's useful for porting other actual defect fixes.
I want to get clang build warnings down to the same level that gcc build warnings are, so that they become useful in detecting new issues. That is why I add these types of patches to the stable trees.
thanks,
greg k-h
Re: [PATCH 4.14 111/237] tty: synclinkmp: Adjust indentation in several functions
Quoted 11 lines · Greg Kroah-Hartman
Quoted 6 lines · Joe Perches
Quoted 1 line · Greg Kroah-Hartman
From: Nathan Chancellor <[email protected]>
I believe these sorts of whitespace only changes should not be applied to a stable branch unless it's useful for porting other actual defect fixes.
I want to get clang build warnings down to the same level that gcc build warnings are, so that they become useful in detecting new issues. That is why I add these types of patches to the stable trees.
New issues should be found in the current kernel.
Backporting whitespace changes is value-free.
Sasha Levin
maintainerRe: [PATCH 4.14 111/237] tty: synclinkmp: Adjust indentation in several functions
Quoted 9 lines · Joe Perches
Quoted 8 lines · Greg Kroah-Hartman
Quoted 6 lines · Joe Perches
Quoted 1 line · Greg Kroah-Hartman
From: Nathan Chancellor <[email protected]>
I believe these sorts of whitespace only changes should not be applied to a stable branch unless it's useful for porting other actual defect fixes.
Quoted 5 lines
Quoted 3 lines
I want to get clang build warnings down to the same level that gcc build warnings are, so that they become useful in detecting new issues. That is why I add these types of patches to the stable trees.
New issues should be found in the current kernel.
Right, but we're talking about issues with backporting patches. We catch a lot of issues where a patch applied to an older version, but is missing stuff or is outright incorrect by having the compiler warn us about it.
We're not trying to debug upstream, but rather to catch broken backports that compile but are broken.
Quoted 1 line
Backporting whitespace changes is value-free.
The value here is to make other errors obvious.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 112/237 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); } }
@@ -2575,8 +2575,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)) {
@@ -3207,7 +3207,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 ; }
@@ -3218,7 +3218,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 ; }
@@ -3233,7 +3233,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 113/237 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];
@@ -163,7 +164,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];
@@ -360,7 +361,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 ;
@@ -447,7 +449,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 114/237 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
@@ -375,7 +375,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 115/237 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 116/237 drm/nouveau/secboot/gm20b: initialize pointer in gm20b_secboot_new()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 3613a9bea95a1470dd42e4ed1cc7d86ebe0a2dc0 ]
We accidentally set "psb" which is a no-op instead of "*psb" so it generates a static checker warning. We should probably set it before the first error return so that it's always initialized.
--- drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/secboot/gm20b.c +2 -3
@@ -108,6 +108,7 @@ gm20b_secboot_new(struct nvkm_device *device, int index,struct gm200_secboot *gsb;struct nvkm_acr *acr; + *psb =NULL ; acr =acr_r352_new (BIT (NVKM_SECBOOT_FALCON_FECS ) |BIT (NVKM_SECBOOT_FALCON_PMU ));if (IS_ERR (acr))
@@ -116,10 +117,8 @@ gm20b_secboot_new(struct nvkm_device *device, int index, acr->optional_falcons =BIT (NVKM_SECBOOT_FALCON_PMU ); gsb =kzalloc (sizeof (*gsb),GFP_KERNEL ); -if (!gsb) { - psb =NULL ; +if (!gsb)return -ENOMEM ; - } *psb = &gsb->base; ret =nvkm_secboot_ctor (&gm20b_secboot, acr, device, index, &gsb->base);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 117/237 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 118/237 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 119/237 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 120/237 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 121/237 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
@@ -1145,7 +1145,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 122/237 f2fs: free sysfs kobject
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 820d366736c949ffe698d3b3fe1266a91da1766d ]
Detected kmemleak.
--- fs/f2fs/sysfs.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/sysfs.c +1 -0
@@ -557,4 +557,5 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)remove_proc_entry (sbi->sb->s_id, f2fs_proc_root); }kobject_del (&sbi->s_kobj); +kobject_put (&sbi->s_kobj); }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 123/237 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
@@ -890,6 +890,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
@@ -2945,6 +2945,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)
@@ -3522,10 +3540,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