d355c0141d
* refs/heads/tmp-e5304c6: Linux 4.19.56 powerpc/mm/64s/hash: Reallocate context ids on fork x86/resctrl: Don't stop walking closids when a locksetup group is found mac80211: Do not use stack memory with scatterlist for GMAC nl80211: fix station_info pertid memory leak mac80211: handle deauthentication/disassociation from TDLS peer {nl,mac}80211: allow 4addr AP operation on crypto controlled devices mac80211: drop robust management frames from unknown TA cfg80211: fix memory leak of wiphy device name SMB3: retry on STATUS_INSUFFICIENT_RESOURCES instead of failing write Bluetooth: Fix regression with minimum encryption key size alignment Bluetooth: Align minimum encryption key size for LE and BR/EDR connections staging: erofs: add requirements field in superblock drm/vmwgfx: Use the backdoor port if the HB port is not available arm64: ssbd: explicitly depend on <linux/prctl.h> arm64/sve: <uapi/asm/ptrace.h> should not depend on <uapi/linux/prctl.h> ARM: dts: am57xx-idk: Remove support for voltage switching for SD card ARM: dts: dra76x: Update MMC2_HS200_MANUAL1 iodelay values ARM: imx: cpuidle-imx6sx: Restrict the SW2ISO increase to i.MX6SX powerpc/bpf: use unsigned division instruction for 64-bit operations riscv: mm: synchronize MMU after pte change can: purge socket error queue on sock destruct can: flexcan: fix timeout when set small bitrate can: xilinx_can: use correct bittiming_const for CAN FD core btrfs: start readahead also in seed devices nvme: Fix u32 overflow in the number of namespace list calculation arm64: Silence gcc warnings about arch ABI drift hwmon: (pmbus/core) Treat parameters as paged if on multiple pages hwmon: (core) add thermal sensors only if dev->of_node is present s390/qeth: fix VLAN attribute in bridge_hostnotify udev event net: ipvlan: Fix ipvlan device tso disabled while NETIF_F_IP_CSUM is set scsi: smartpqi: unlock on error in pqi_submit_raid_request_synchronous() scsi: ufs: Check that space was properly alloced in copy_query_response scripts/checkstack.pl: Fix arm64 wrong or unknown architecture nvmet: fix data_len to 0 for bdev-backed write_zeroes drm/arm/hdlcd: Allow a bit of clock tolerance drm/arm/hdlcd: Actually validate CRTC modes drm/arm/mali-dp: Add a loop around the second set CVAL and try 5 times net: ethernet: mediatek: Use NET_IP_ALIGN to judge if HW RX_2BYTE_OFFSET is enabled net: ethernet: mediatek: Use hw_feature to judge if HWLRO is supported sparc: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD mdesc: fix a missing-check bug in get_vdev_port_node_info() net: hns: Fix loopback test failed at copper ports net: dsa: mv88e6xxx: avoid error message on remove from VLAN 0 selftests: vm: install test_vmalloc.sh for run_vmtests kselftest/cgroup: fix incorrect test_core skip kselftest/cgroup: fix unexpected testing failure on test_core kselftest/cgroup: fix unexpected testing failure on test_memcontrol xtensa: Fix section mismatch between memblock_reserve and mem_reserve MIPS: uprobes: remove set but not used variable 'epc' IB/hfi1: Validate page aligned for a given virtual address IB/{qib, hfi1, rdmavt}: Correct ibv_devinfo max_mr value IB/hfi1: Insure freeze_work work_struct is canceled on shutdown IB/rdmavt: Fix alloc_qpn() WARN_ON() parisc: Fix compiler warnings in float emulation code parport: Fix mem leak in parport_register_dev_model fpga: dfl: Add lockdep classes for pdata->lock fpga: dfl: afu: Pass the correct device to dma_mapping_error() ARC: [plat-hsdk]: Add missing FIFO size entry in GMAC node ARC: [plat-hsdk]: Add missing multicast filter bins number to GMAC node dmaengine: sprd: Fix block length overflow dmaengine: dw-axi-dmac: fix null dereference when pointer first is null ARC: fix build warnings brcmfmac: sdio: Don't tune while the card is off brcmfmac: sdio: Disable auto-tuning around commands expected to fail apparmor: enforce nullbyte at end of tag string apparmor: fix PROFILE_MEDIATES for untrusted input Input: silead - add MSSL0017 to acpi_device_id Input: uinput - add compat ioctl number translation for UI_*_FF_UPLOAD Input: synaptics - enable SMBus on ThinkPad E480 and E580 iio: temperature: mlx90632 Relax the compatibility check IB/hfi1: Silence txreq allocation warnings IB/hfi1: Validate fault injection opcode user input usb: xhci: Don't try to recover an endpoint if port is in error state. xhci: detect USB 3.2 capable host controllers correctly usb: chipidea: udc: workaround for endpoint conflict issue scsi: ufs: Avoid runtime suspend possibly being blocked forever mmc: core: Prevent processing SDIO IRQs when the card is suspended mmc: core: Add sdio_retune_hold_now() and sdio_retune_release() mmc: core: API to temporarily disable retuning for SDIO CRC errors mmc: sdhci: sdhci-pci-o2micro: Correctly set bus width when tuning s390/ap: rework assembler functions to use unions for in/out register variables s390/jump_label: Use "jdd" constraint on gcc9 ovl: fix bogus -Wmaybe-unitialized warning ovl: don't fail with disconnected lower NFS ovl: detect overlapping layers ovl: make i_ino consistent with st_ino in more cases ovl: fix wrong flags check in FS_IOC_FS[SG]ETXATTR ioctls ovl: support the FS_IOC_FS[SG]ETXATTR ioctls gcc-9: silence 'address-of-packed-member' warning objtool: Support per-function rodata sections tracing: Silence GCC 9 array bounds warning Conflicts: Makefile drivers/mmc/core/sdio.c drivers/scsi/ufs/ufshcd-pltfrm.c Change-Id: I236ed854cc550b2953d984f4e6686ab871e42f45 Signed-off-by: Ivaylo Georgiev <irgeorgiev@codeaurora.org>
130 lines
2.9 KiB
C
130 lines
2.9 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2018 ARM Ltd, All Rights Reserved.
|
|
*/
|
|
|
|
#include <linux/compat.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/prctl.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/sched/task_stack.h>
|
|
#include <linux/thread_info.h>
|
|
|
|
#include <asm/cpufeature.h>
|
|
|
|
static void ssbd_ssbs_enable(struct task_struct *task)
|
|
{
|
|
u64 val = is_compat_thread(task_thread_info(task)) ?
|
|
PSR_AA32_SSBS_BIT : PSR_SSBS_BIT;
|
|
|
|
task_pt_regs(task)->pstate |= val;
|
|
}
|
|
|
|
static void ssbd_ssbs_disable(struct task_struct *task)
|
|
{
|
|
u64 val = is_compat_thread(task_thread_info(task)) ?
|
|
PSR_AA32_SSBS_BIT : PSR_SSBS_BIT;
|
|
|
|
task_pt_regs(task)->pstate &= ~val;
|
|
}
|
|
|
|
/*
|
|
* prctl interface for SSBD
|
|
*/
|
|
static int ssbd_prctl_set(struct task_struct *task, unsigned long ctrl)
|
|
{
|
|
int state = arm64_get_ssbd_state();
|
|
|
|
/* Unsupported */
|
|
if (state == ARM64_SSBD_UNKNOWN)
|
|
return -EINVAL;
|
|
|
|
/* Treat the unaffected/mitigated state separately */
|
|
if (state == ARM64_SSBD_MITIGATED) {
|
|
switch (ctrl) {
|
|
case PR_SPEC_ENABLE:
|
|
return -EPERM;
|
|
case PR_SPEC_DISABLE:
|
|
case PR_SPEC_FORCE_DISABLE:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Things are a bit backward here: the arm64 internal API
|
|
* *enables the mitigation* when the userspace API *disables
|
|
* speculation*. So much fun.
|
|
*/
|
|
switch (ctrl) {
|
|
case PR_SPEC_ENABLE:
|
|
/* If speculation is force disabled, enable is not allowed */
|
|
if (state == ARM64_SSBD_FORCE_ENABLE ||
|
|
task_spec_ssb_force_disable(task))
|
|
return -EPERM;
|
|
task_clear_spec_ssb_disable(task);
|
|
clear_tsk_thread_flag(task, TIF_SSBD);
|
|
ssbd_ssbs_enable(task);
|
|
break;
|
|
case PR_SPEC_DISABLE:
|
|
if (state == ARM64_SSBD_FORCE_DISABLE)
|
|
return -EPERM;
|
|
task_set_spec_ssb_disable(task);
|
|
set_tsk_thread_flag(task, TIF_SSBD);
|
|
ssbd_ssbs_disable(task);
|
|
break;
|
|
case PR_SPEC_FORCE_DISABLE:
|
|
if (state == ARM64_SSBD_FORCE_DISABLE)
|
|
return -EPERM;
|
|
task_set_spec_ssb_disable(task);
|
|
task_set_spec_ssb_force_disable(task);
|
|
set_tsk_thread_flag(task, TIF_SSBD);
|
|
ssbd_ssbs_disable(task);
|
|
break;
|
|
default:
|
|
return -ERANGE;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int arch_prctl_spec_ctrl_set(struct task_struct *task, unsigned long which,
|
|
unsigned long ctrl)
|
|
{
|
|
switch (which) {
|
|
case PR_SPEC_STORE_BYPASS:
|
|
return ssbd_prctl_set(task, ctrl);
|
|
default:
|
|
return -ENODEV;
|
|
}
|
|
}
|
|
|
|
static int ssbd_prctl_get(struct task_struct *task)
|
|
{
|
|
switch (arm64_get_ssbd_state()) {
|
|
case ARM64_SSBD_UNKNOWN:
|
|
return -EINVAL;
|
|
case ARM64_SSBD_FORCE_ENABLE:
|
|
return PR_SPEC_DISABLE;
|
|
case ARM64_SSBD_KERNEL:
|
|
if (task_spec_ssb_force_disable(task))
|
|
return PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE;
|
|
if (task_spec_ssb_disable(task))
|
|
return PR_SPEC_PRCTL | PR_SPEC_DISABLE;
|
|
return PR_SPEC_PRCTL | PR_SPEC_ENABLE;
|
|
case ARM64_SSBD_FORCE_DISABLE:
|
|
return PR_SPEC_ENABLE;
|
|
default:
|
|
return PR_SPEC_NOT_AFFECTED;
|
|
}
|
|
}
|
|
|
|
int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which)
|
|
{
|
|
switch (which) {
|
|
case PR_SPEC_STORE_BYPASS:
|
|
return ssbd_prctl_get(task);
|
|
default:
|
|
return -ENODEV;
|
|
}
|
|
}
|