https://source.android.com/docs/security/bulletin/2023-03-01 CVE-2021-33655 * tag 'ASB-2023-03-05_4.19-stable' of https://android.googlesource.com/kernel/common: Linux 4.19.275 USB: core: Don't hold device lock while reading the "descriptors" sysfs file USB: serial: option: add support for VW/Skoda "Carstick LTE" dmaengine: sh: rcar-dmac: Check for error num after dma_set_max_seg_size vc_screen: don't clobber return value in vcs_read net: Remove WARN_ON_ONCE(sk->sk_forward_alloc) from sk_stream_kill_queues(). IB/hfi1: Assign npages earlier btrfs: send: limit number of clones and allocated memory size ACPI: NFIT: fix a potential deadlock during NFIT teardown ARM: dts: rockchip: add power-domains property to dp node on rk3288 UPSTREAM: selinux: check return value of sel_make_avc_files UPSTREAM: lib/test_meminit: destroy cache in kmem_cache_alloc_bulk() test UPSTREAM: wireguard: ratelimiter: use kvcalloc() instead of kvzalloc() UPSTREAM: wireguard: receive: drop handshakes if queue lock is contended UPSTREAM: wireguard: receive: use ring buffer for incoming handshakes UPSTREAM: wireguard: device: reset peer src endpoint when netns exits UPSTREAM: wireguard: selftests: actually test for routing loops UPSTREAM: kasan: fix tag for large allocations when using CONFIG_SLAB UPSTREAM: usb: musb: select GENERIC_PHY instead of depending on it UPSTREAM: driver core: Reject pointless SYNC_STATE_ONLY device links BACKPORT: PM: EM: Fix inefficient states detection UPSTREAM: cfg80211: scan: fix RCU in cfg80211_add_nontrans_list() UPSTREAM: thermal/core: Fix thermal_cooling_device_register() prototype UPSTREAM: PM: EM: Increase energy calculation precision UPSTREAM: lib/test_stackinit: Fix static initializer test BACKPORT: userfaultfd: do not untag user pointers UPSTREAM: net/xfrm/compat: Copy xfrm_spdattr_type_t atributes UPSTREAM: sched/uclamp: Ignore max aggregation if rq is idle UPSTREAM: net: xfrm: fix memory leak in xfrm_user_rcv_msg UPSTREAM: f2fs: Advertise encrypted casefolding in sysfs UPSTREAM: fuse: ignore PG_workingset after stealing BACKPORT: loop: Fix missing discard support when using LOOP_CONFIGURE BACKPORT: nvmem: core: add a missing of_node_put UPSTREAM: usb: typec: mux: Fix copy-paste mistake in typec_mux_match Linux 4.19.274 bpf: add missing header file include ext4: Fix function prototype mismatch for ext4_feat_ktype wifi: mwifiex: Add missing compatible string for SD8787 uaccess: Add speculation barrier to copy_from_user() mac80211: mesh: embedd mesh_paths and mpp_paths into ieee80211_if_mesh drm/i915/gvt: fix double free bug in split_2MB_gtt_entry alarmtimer: Prevent starvation by small intervals and SIG_IGN powerpc: dts: t208x: Disable 10G on MAC1 and MAC2 can: kvaser_usb: hydra: help gcc-13 to figure out cmd_len random: always mix cycle counter in add_latent_entropy() powerpc: dts: t208x: Mark MAC1 and MAC2 as 10G wifi: rtl8xxxu: gen2: Turn on the rate control BACKPORT: fscrypt: fix derivation of SipHash keys on big endian CPUs UPSTREAM: wireguard: allowedips: free empty intermediate nodes when removing single node BACKPORT: wireguard: allowedips: allocate nodes in kmem_cache Linux 4.19.273 net: phy: meson-gxl: Add generic dummy stubs for MMD register access nilfs2: fix underflow in second superblock position calculations kvm: initialize all of the kvm_debugregs structure before sending it to userspace i40e: Add checking for null for nlmsg_find_attr() ipv6: Fix tcp socket connection with DSCP. ipv6: Fix datagram socket connection with DSCP. net: mpls: fix stale pointer if allocation fails during device rename net: stmmac: Restrict warning on disabling DMA store and fwd mode bnxt_en: Fix mqprio and XDP ring checking logic net: stmmac: fix order of dwmac5 FlexPPS parametrization sequence net/usb: kalmia: Don't pass act_len in usb_bulk_msg error path dccp/tcp: Avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions. net: bgmac: fix BCM5358 support by setting correct flags i40e: add double of VLAN header when computing the max MTU revert "squashfs: harden sanity check in squashfs_read_xattr_id_table" hugetlb: check for undefined shift on 32 bit architectures ALSA: hda/realtek - fixed wrong gpio assigned ALSA: hda/conexant: add a new hda codec SN6180 mmc: sdio: fix possible resource leaks in some error paths Revert "x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN" netfilter: nft_tproxy: restrict to prerouting hook aio: fix mremap after fork null-deref nvme-fc: fix a missing queue put in nvmet_fc_ls_create_association net/rose: Fix to not accept on connected socket tools/virtio: fix the vringh test for virtio ring changes ASoC: cs42l56: fix DT probe migrate: hugetlb: check for hugetlb shared PMD in node migration bpf: Always return target ifindex in bpf_fib_lookup arm64: dts: meson-axg: Make mmc host controller interrupts level-sensitive arm64: dts: meson-gx: Make mmc host controller interrupts level-sensitive riscv: Fixup race condition on PG_dcache_clean in flush_icache_pte usb: typec: altmodes/displayport: Fix probe pin assign check usb: core: add quirk for Alcor Link AK9563 smartcard reader net: USB: Fix wrong-direction WARNING in plusb.c pinctrl: intel: Restore the pins that used to be in Direct IRQ mode pinctrl: intel: Convert unsigned to unsigned int pinctrl: single: fix potential NULL dereference pinctrl: aspeed: Fix confusing types in return value ALSA: pci: lx6464es: fix a debug loop selftests: forwarding: lib: quote the sysctl values rds: rds_rm_zerocopy_callback() use list_first_entry() net: phy: meson-gxl: use MMD access dummy stubs for GXL, internal PHY net: phy: meson-gxl: add g12a support net: phy: add macros for PHYID matching IB/hfi1: Restore allocated resources on failed copyout ALSA: emux: Avoid potential array out-of-bound in snd_emux_xg_control() btrfs: limit device extents to the device size iio:adc:twl6030: Enable measurement of VAC thermal: intel: int340x: Add locking to int340x_thermal_get_trip_type() serial: 8250_dma: Fix DMA Rx rearm race serial: 8250_dma: Fix DMA Rx completion race Squashfs: fix handling and sanity checking of xattr_ids count mm/swapfile: add cond_resched() in get_swap_pages() mm: hugetlb: proc: check for hugetlb shared PMD in /proc/PID/smaps riscv: disable generation of unwind tables parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case parisc: Fix return code of pdc_iodc_print() iio:adc:twl6030: Enable measurements of VUSB, VBAT and others iio: adc: berlin2-adc: Add missing of_node_put() in error path iio: hid: fix the retval in accel_3d_capture_sample efi: Accept version 2 of memory attributes table watchdog: diag288_wdt: fix __diag288() inline assembly watchdog: diag288_wdt: do not use stack buffers for hardware data fbcon: Check font dimension limits thermal: intel: int340x: Protect trip temperature from concurrent updates KVM: x86/vmx: Do not skip segment attributes if unusable bit is set KVM: VMX: Move caching of MSR_IA32_XSS to hardware_setup() KVM: VMX: Move VMX specific files to a "vmx" subdirectory nVMX x86: Check VMX-preemption timer controls on vmentry of L2 guests Input: i8042 - add Clevo PCX0DX to i8042 quirk table Input: i8042 - add TUXEDO devices to i8042 quirk tables Input: i8042 - merge quirk tables Input: i8042 - move __initconst to fix code styling warning vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF usb: gadget: f_fs: Fix unbalanced spinlock in __ffs_ep0_queue_wait usb: dwc3: qcom: enable vbus override when in OTG dr-mode usb: dwc3: dwc3-qcom: Fix typo in the dwc3 vbus override API iio: adc: stm32-dfsdm: fill module aliases net/x25: Fix to not accept on connected socket i2c: rk3x: fix a bunch of kernel-doc warnings scsi: iscsi_tcp: Fix UAF during login when accessing the shost ipaddress scsi: target: core: Fix warning on RT kernels net: openvswitch: fix flow memory leak in ovs_flow_cmd_new ata: libata: Fix sata_down_spd_limit() when no link speed is reported squashfs: harden sanity check in squashfs_read_xattr_id_table netrom: Fix use-after-free caused by accept on already connected socket ALSA: hda/via: Avoid potential array out-of-bound in add_secret_dac_path() bus: sunxi-rsb: Fix error handling in sunxi_rsb_init() firewire: fix memory leak for payload of request subaction to IEC 61883-1 FCP region UPSTREAM: wireguard: allowedips: remove nodes in O(1) UPSTREAM: wireguard: allowedips: initialize list head in selftest UPSTREAM: wireguard: use synchronize_net rather than synchronize_rcu UPSTREAM: wireguard: do not use -O3 UPSTREAM: wireguard: selftests: make sure rp_filter is disabled on vethc BACKPORT: wireguard: selftests: remove old conntrack kconfig value BACKPORT: usb: typec: mux: Fix matching with typec_altmode_desc UPSTREAM: sched/uclamp: Fix locking around cpu_util_update_eff() UPSTREAM: sched/uclamp: Fix wrong implementation of cpu.uclamp.min UPSTREAM: usb: musb: Fix an error message UPSTREAM: arm64: doc: Add brk/mmap/mremap() to the Tagged Address ABI Exceptions BACKPORT: selinux: add proper NULL termination to the secclass_map permissions UPSTREAM: crypto: arm/curve25519 - Move '.fpu' after '.arch' UPSTREAM: libnvdimm/region: Fix nvdimm_has_flush() to handle ND_REGION_ASYNC UPSTREAM: of: property: fw_devlink: do not link ".*,nr-gpios" UPSTREAM: xfrm/compat: Cleanup WARN()s that can be user-triggered UPSTREAM: wireguard: selftests: test multiple parallel streams UPSTREAM: crypto: mips: add poly1305-core.S to .gitignore BACKPORT: arm64: kasan: fix page_alloc tagging with DEBUG_VIRTUAL UPSTREAM: crypto: mips/poly1305 - enable for all MIPS processors UPSTREAM: kbuild: do not include include/config/auto.conf from adjust_autoksyms.sh UPSTREAM: wireguard: kconfig: use arm chacha even with no neon UPSTREAM: wireguard: queueing: get rid of per-peer ring buffers UPSTREAM: wireguard: device: do not generate ICMP for non-IP packets BACKPORT: mac80211_hwsim: notify wmediumd of used MAC addresses BACKPORT: mac80211_hwsim: add concurrent channels scanning support over virtio BACKPORT: perf_event_open: switch to copy_struct_from_user() BACKPORT: sched_setattr: switch to copy_struct_from_user() Conflicts: kernel/power/energy_model.c net/wireless/scan.c Change-Id: I55c29a161fd214642259ddfb19fb749a416babb2
207 lines
6.5 KiB
C
207 lines
6.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_ENERGY_MODEL_H
|
|
#define _LINUX_ENERGY_MODEL_H
|
|
#include <linux/cpumask.h>
|
|
#include <linux/jump_label.h>
|
|
#include <linux/kobject.h>
|
|
#include <linux/rcupdate.h>
|
|
#include <linux/sched/cpufreq.h>
|
|
#include <linux/sched/topology.h>
|
|
#include <linux/types.h>
|
|
|
|
#ifdef CONFIG_ENERGY_MODEL
|
|
/**
|
|
* em_cap_state - Capacity state of a performance domain
|
|
* @frequency: The CPU frequency in KHz, for consistency with CPUFreq
|
|
* @power: The power consumed by 1 CPU at this level, in milli-watts
|
|
* @cost: The cost coefficient associated with this level, used during
|
|
* energy calculation. Equal to: power * max_frequency / frequency
|
|
*/
|
|
struct em_cap_state {
|
|
unsigned long frequency;
|
|
unsigned long power;
|
|
unsigned long cost;
|
|
};
|
|
|
|
/**
|
|
* em_perf_domain - Performance domain
|
|
* @table: List of capacity states, in ascending order
|
|
* @nr_cap_states: Number of capacity states
|
|
* @cpus: Cpumask covering the CPUs of the domain
|
|
*
|
|
* A "performance domain" represents a group of CPUs whose performance is
|
|
* scaled together. All CPUs of a performance domain must have the same
|
|
* micro-architecture. Performance domains often have a 1-to-1 mapping with
|
|
* CPUFreq policies.
|
|
*/
|
|
struct em_perf_domain {
|
|
struct em_cap_state *table;
|
|
int nr_cap_states;
|
|
unsigned long cpus[0];
|
|
};
|
|
|
|
#define EM_CPU_MAX_POWER 0xFFFF
|
|
|
|
/*
|
|
* Increase resolution of energy estimation calculations for 64-bit
|
|
* architectures. The extra resolution improves decision made by EAS for the
|
|
* task placement when two Performance Domains might provide similar energy
|
|
* estimation values (w/o better resolution the values could be equal).
|
|
*
|
|
* We increase resolution only if we have enough bits to allow this increased
|
|
* resolution (i.e. 64-bit). The costs for increasing resolution when 32-bit
|
|
* are pretty high and the returns do not justify the increased costs.
|
|
*/
|
|
#ifdef CONFIG_64BIT
|
|
#define em_scale_power(p) ((p) * 1000)
|
|
#else
|
|
#define em_scale_power(p) (p)
|
|
#endif
|
|
|
|
struct em_data_callback {
|
|
/**
|
|
* active_power() - Provide power at the next capacity state of a CPU
|
|
* @power : Active power at the capacity state in mW (modified)
|
|
* @freq : Frequency at the capacity state in kHz (modified)
|
|
* @cpu : CPU for which we do this operation
|
|
*
|
|
* active_power() must find the lowest capacity state of 'cpu' above
|
|
* 'freq' and update 'power' and 'freq' to the matching active power
|
|
* and frequency.
|
|
*
|
|
* The power is the one of a single CPU in the domain, expressed in
|
|
* milli-watts. It is expected to fit in the [0, EM_CPU_MAX_POWER]
|
|
* range.
|
|
*
|
|
* Return 0 on success.
|
|
*/
|
|
int (*active_power)(unsigned long *power, unsigned long *freq, int cpu);
|
|
};
|
|
#define EM_DATA_CB(_active_power_cb) { .active_power = &_active_power_cb }
|
|
|
|
struct em_perf_domain *em_cpu_get(int cpu);
|
|
int em_register_perf_domain(cpumask_t *span, unsigned int nr_states,
|
|
struct em_data_callback *cb);
|
|
|
|
/**
|
|
* em_pd_energy() - Estimates the energy consumed by the CPUs of a perf. domain
|
|
* @pd : performance domain for which energy has to be estimated
|
|
* @max_util : highest utilization among CPUs of the domain
|
|
* @sum_util : sum of the utilization of all CPUs in the domain
|
|
*
|
|
* Return: the sum of the energy consumed by the CPUs of the domain assuming
|
|
* a capacity state satisfying the max utilization of the domain.
|
|
*/
|
|
static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
|
|
unsigned long max_util, unsigned long sum_util)
|
|
{
|
|
unsigned long freq, scale_cpu;
|
|
struct em_cap_state *cs;
|
|
int i, cpu;
|
|
|
|
if (!sum_util)
|
|
return 0;
|
|
|
|
/*
|
|
* In order to predict the capacity state, map the utilization of the
|
|
* most utilized CPU of the performance domain to a requested frequency,
|
|
* like schedutil.
|
|
*/
|
|
cpu = cpumask_first(to_cpumask(pd->cpus));
|
|
scale_cpu = arch_scale_cpu_capacity(NULL, cpu);
|
|
cs = &pd->table[pd->nr_cap_states - 1];
|
|
freq = map_util_freq(max_util, cs->frequency, scale_cpu);
|
|
|
|
/*
|
|
* Find the lowest capacity state of the Energy Model above the
|
|
* requested frequency.
|
|
*/
|
|
for (i = 0; i < pd->nr_cap_states; i++) {
|
|
cs = &pd->table[i];
|
|
if (cs->frequency >= freq)
|
|
break;
|
|
}
|
|
|
|
/*
|
|
* The capacity of a CPU in the domain at that capacity state (cs)
|
|
* can be computed as:
|
|
*
|
|
* cs->freq * scale_cpu
|
|
* cs->cap = -------------------- (1)
|
|
* cpu_max_freq
|
|
*
|
|
* So, ignoring the costs of idle states (which are not available in
|
|
* the EM), the energy consumed by this CPU at that capacity state is
|
|
* estimated as:
|
|
*
|
|
* cs->power * cpu_util
|
|
* cpu_nrg = -------------------- (2)
|
|
* cs->cap
|
|
*
|
|
* since 'cpu_util / cs->cap' represents its percentage of busy time.
|
|
*
|
|
* NOTE: Although the result of this computation actually is in
|
|
* units of power, it can be manipulated as an energy value
|
|
* over a scheduling period, since it is assumed to be
|
|
* constant during that interval.
|
|
*
|
|
* By injecting (1) in (2), 'cpu_nrg' can be re-expressed as a product
|
|
* of two terms:
|
|
*
|
|
* cs->power * cpu_max_freq cpu_util
|
|
* cpu_nrg = ------------------------ * --------- (3)
|
|
* cs->freq scale_cpu
|
|
*
|
|
* The first term is static, and is stored in the em_cap_state struct
|
|
* as 'cs->cost'.
|
|
*
|
|
* Since all CPUs of the domain have the same micro-architecture, they
|
|
* share the same 'cs->cost', and the same CPU capacity. Hence, the
|
|
* total energy of the domain (which is the simple sum of the energy of
|
|
* all of its CPUs) can be factorized as:
|
|
*
|
|
* cs->cost * \Sum cpu_util
|
|
* pd_nrg = ------------------------ (4)
|
|
* scale_cpu
|
|
*/
|
|
return cs->cost * sum_util / scale_cpu;
|
|
}
|
|
|
|
/**
|
|
* em_pd_nr_cap_states() - Get the number of capacity states of a perf. domain
|
|
* @pd : performance domain for which this must be done
|
|
*
|
|
* Return: the number of capacity states in the performance domain table
|
|
*/
|
|
static inline int em_pd_nr_cap_states(struct em_perf_domain *pd)
|
|
{
|
|
return pd->nr_cap_states;
|
|
}
|
|
|
|
#else
|
|
struct em_perf_domain {};
|
|
struct em_data_callback {};
|
|
#define EM_DATA_CB(_active_power_cb) { }
|
|
|
|
static inline int em_register_perf_domain(cpumask_t *span,
|
|
unsigned int nr_states, struct em_data_callback *cb)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
static inline struct em_perf_domain *em_cpu_get(int cpu)
|
|
{
|
|
return NULL;
|
|
}
|
|
static inline unsigned long em_pd_energy(struct em_perf_domain *pd,
|
|
unsigned long max_util, unsigned long sum_util)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int em_pd_nr_cap_states(struct em_perf_domain *pd)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif
|