MIPS: Ingenic: Disable broken BTB lookup optimization.
Subsystems (17)
Sasha Levin
maintainerPATCH 1/42 MIPS: Ingenic: Disable broken BTB lookup optimization.
From: Zhou Yanjie <[email protected]>
[ Upstream commit 053951dda71ecb4b554a2cdbe26f5f6f9bee9dd2 ]
In order to further reduce power consumption, the XBurst core by default attempts to avoid branch target buffer lookups by detecting & special casing loops. This feature will cause BogoMIPS and lpj calculate in error. Set cp0 config7 bit 4 to disable this feature.
--- arch/mips/include/asm/mipsregs.h | 4 ++++ arch/mips/kernel/cpu-probe.c | 7 +++++++ 2 files changed, 11 insertions(+)
arch/mips/include/asm/mipsregs.h +4 -0
@@ -689,6 +689,9 @@#define MIPS_CONF7_IAR (_ULCAST_(1) << 10)#define MIPS_CONF7_AR (_ULCAST_(1) << 16) +/* Ingenic Config7 bits */ +#define MIPS_CONF7_BTB_LOOP_EN (_ULCAST_(1) << 4) +/* Config7 Bits specific to MIPS Technologies. */ /* Performance counters implemented Per TC */
@@ -2813,6 +2816,7 @@ __BUILD_SET_C0(status) __BUILD_SET_C0(cause) __BUILD_SET_C0(config) __BUILD_SET_C0(config5) +__BUILD_SET_C0(config7) __BUILD_SET_C0(intcontrol) __BUILD_SET_C0(intctl) __BUILD_SET_C0(srsmap)
arch/mips/kernel/cpu-probe.c +7 -0
@@ -1964,6 +1964,13 @@ static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu) c->cputype =CPU_JZRISC ; c->writecombine = _CACHE_UNCACHED_ACCELERATED; __cpu_name[cpu] ="Ingenic JZRISC" ; +/* +* The XBurst core by default attempts to avoid branch target +* buffer lookups by detecting & special casing loops. This +* feature will cause BogoMIPS and lpj calculate in error. +* Set cp0 config7 bit 4 to disable this feature. +*/ +set_c0_config7 (MIPS_CONF7_BTB_LOOP_EN );break ;default :panic ("Unknown Ingenic Processor ID!" );
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/42 clk: jz4740: Add TCU clock
From: Paul Cercueil <[email protected]>
[ Upstream commit 73dd11dc1a883d4c994d729dc9984f4890001157 ]
Add the missing TCU clock to the list of clocks supplied by the CGU for the JZ4740 SoC.
--- drivers/clk/ingenic/jz4740-cgu.c | 6 ++++++ include/dt-bindings/clock/jz4740-cgu.h | 1 + 2 files changed, 7 insertions(+)
drivers/clk/ingenic/jz4740-cgu.c +6 -0
@@ -203,6 +203,12 @@ static const struct ingenic_cgu_clk_info jz4740_cgu_clocks[] = { .parents = { JZ4740_CLK_EXT, -1, -1, -1 }, .gate = { CGU_REG_CLKGR, 5 }, }, + + [JZ4740_CLK_TCU] = { +"tcu" ,CGU_CLK_GATE , + .parents = { JZ4740_CLK_EXT, -1, -1, -1 }, + .gate = { CGU_REG_CLKGR, 1 }, + }, };static void __init jz4740_cgu_init (struct device_node *np)
include/dt-bindings/clock/jz4740-cgu.h +1 -0
@@ -34,5 +34,6 @@#define JZ4740_CLK_ADC 19#define JZ4740_CLK_I2C 20#define JZ4740_CLK_AIC 21 +#define JZ4740_CLK_TCU 22#endif /* __DT_BINDINGS_CLOCK_JZ4740_CGU_H__ */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/42 MIPS: Don't use bc_false uninitialized in __mm_isBranchInstr
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit c2869aafe7191d366d74c55cb8a93c6d0baba317 ]
clang warns:
arch/mips/kernel/branch.c:148:8: error: variable 'bc_false' is used uninitialized whenever switch case is taken [-Werror,-Wsometimes-uninitialized]
case mm_bc2t_op:
^~~~~~~~~~
arch/mips/kernel/branch.c:157:8: note: uninitialized use occurs here
if (bc_false)
^~~~~~~~
arch/mips/kernel/branch.c:149:8: error: variable 'bc_false' is used
uninitialized whenever switch case is taken
[-Werror,-Wsometimes-uninitialized]
case mm_bc1t_op:
^~~~~~~~~~
arch/mips/kernel/branch.c:157:8: note: uninitialized use occurs here
if (bc_false)
^~~~~~~~
arch/mips/kernel/branch.c:142:4: note: variable 'bc_false' is declared
here
int bc_false = 0;
^2 errors generated.
When mm_bc1t_op and mm_bc2t_op are taken, the bc_false initialization does not happen, which leads to a garbage value upon use, as illustrated below with a small sample program.
$ mipsel-linux-gnu-gcc --version | head -n1 mipsel-linux-gnu-gcc (Debian 8.3.0-2) 8.3.0
$ clang --version | head -n1 ClangBuiltLinux clang version 9.0.0 (git://github.com/llvm/llvm-project 544315b4197034a3be8acd12cba56a75fb1f08dc) (based on LLVM 9.0.0svn)
$ cat test.c #include <stdio.h>
static void switch_scoped(int opcode)
{
switch (opcode) {
case 1:
case 2: {
int bc_false = 0;
bc_false = 4;
case 3:
case 4:
printf("\t* switch scoped bc_false = %d\n", bc_false);
}
}}
static void function_scoped(int opcode)
{
int bc_false = 0;
switch (opcode) {
case 1:
case 2: {
bc_false = 4;
case 3:
case 4:
printf("\t* function scoped bc_false = %d\n", bc_false);
}
}}
int main(void)
{
int opcode;
for (opcode = 1; opcode < 5; opcode++) {
printf("opcode = %d:\n", opcode);
switch_scoped(opcode);
function_scoped(opcode);
printf("\n");
}
return 0;}
$ mipsel-linux-gnu-gcc -std=gnu89 -static test.c && \
qemu-mipsel a.out
opcode = 1:
* switch scoped bc_false = 4
* function scoped bc_false = 4opcode = 2:
* switch scoped bc_false = 4
* function scoped bc_false = 4
opcode = 3:
* switch scoped bc_false = 2147483004
* function scoped bc_false = 0
opcode = 4:
* switch scoped bc_false = 2147483004
* function scoped bc_false = 0
$ clang -std=gnu89 --target=mipsel-linux-gnu -m32 -static test.c && \
qemu-mipsel a.out
opcode = 1:
* switch scoped bc_false = 4
* function scoped bc_false = 4opcode = 2:
* switch scoped bc_false = 4
* function scoped bc_false = 4
opcode = 3:
* switch scoped bc_false = 2147483004
* function scoped bc_false = 0
opcode = 4:
* switch scoped bc_false = 2147483004
* function scoped bc_false = 0
Move the definition up so that we get the right behavior and mark it __maybe_unused as it will not be used when CONFIG_MIPS_FP_SUPPORT isn't enabled.
--- arch/mips/kernel/branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/branch.c +1 -1
@@ -58,6 +58,7 @@ int __mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn, unsigned long *contpc) {union mips_instruction insn = (union mips_instruction )dec_insn.insn; +int __maybe_unused bc_false =0 ;if (!cpu_has_mmips)return 0 ;
@@ -139,7 +140,6 @@ int __mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,#ifdef CONFIG_MIPS_FP_SUPPORT case mm_bc2f_op:case mm_bc1f_op: { -int bc_false =0 ;unsigned int fcr31;unsigned int bit;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/42 MIPS: tlbex: Explicitly cast _PAGE_NO_EXEC to a boolean
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit c59ae0a1055127dd3828a88e111a0db59b254104 ]
clang warns:
arch/mips/mm/tlbex.c:634:19: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand]
if (cpu_has_rixi && _PAGE_NO_EXEC) {
^ ~~~~~~~~~~~~~
arch/mips/mm/tlbex.c:634:19: note: use '&' for a bitwise operation
if (cpu_has_rixi && _PAGE_NO_EXEC) {
^~
&
arch/mips/mm/tlbex.c:634:19: note: remove constant to silence this
warning
if (cpu_has_rixi && _PAGE_NO_EXEC) {
~^~~~~~~~~~~~~~~~1 error generated.
Explicitly cast this value to a boolean so that clang understands we intend for this to be a non-zero value.
--- arch/mips/mm/tlbex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/mm/tlbex.c +1 -1
@@ -631,7 +631,7 @@ static __maybe_unused void build_convert_pte_to_entrylo(u32 **p,return ; } -if (cpu_has_rixi && _PAGE_NO_EXEC) { +if (cpu_has_rixi && !!_PAGE_NO_EXEC) {if (fill_includes_sw_bits) {UASM_i_ROTR (p, reg, reg,ilog2 (_PAGE_GLOBAL)); }else {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/42 i2c-cht-wc: Fix lockdep warning
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 232219b9a464c2479c98aa589acb1bd3383ae9d6 ]
When the kernel is build with lockdep support and the i2c-cht-wc driver is used, the following warning is shown:
[ 66.674334] ======================================================
[ 66.674337] WARNING: possible circular locking dependency detected
[ 66.674340] 5.3.0-rc4+ #83 Not tainted
[ 66.674342] ------------------------------------------------------
[ 66.674345] systemd-udevd/1232 is trying to acquire lock:
[ 66.674349] 00000000a74dab07 (intel_soc_pmic_chtwc:167:(&cht_wc_regmap_cfg)->lock){+.+.}, at: regmap_write+0x31/0x70
[ 66.674360]
but task is already holding lock:
[ 66.674362] 00000000d44a85b7 (i2c_register_adapter){+.+.}, at: i2c_smbus_xfer+0x49/0xf0
[ 66.674370]
which lock already depends on the new lock.[ 66.674371]
the existing dependency chain (in reverse order) is:
[ 66.674374]
-> #1 (i2c_register_adapter){+.+.}:
[ 66.674381] rt_mutex_lock_nested+0x46/0x60
[ 66.674384] i2c_smbus_xfer+0x49/0xf0
[ 66.674387] i2c_smbus_read_byte_data+0x45/0x70
[ 66.674391] cht_wc_byte_reg_read+0x35/0x50
[ 66.674394] _regmap_read+0x63/0x1a0
[ 66.674396] _regmap_update_bits+0xa8/0xe0
[ 66.674399] regmap_update_bits_base+0x63/0xa0
[ 66.674403] regmap_irq_update_bits.isra.0+0x3b/0x50
[ 66.674406] regmap_add_irq_chip+0x592/0x7a0
[ 66.674409] devm_regmap_add_irq_chip+0x89/0xed
[ 66.674412] cht_wc_probe+0x102/0x158
[ 66.674415] i2c_device_probe+0x95/0x250
[ 66.674419] really_probe+0xf3/0x380
[ 66.674422] driver_probe_device+0x59/0xd0
[ 66.674425] device_driver_attach+0x53/0x60
[ 66.674428] __driver_attach+0x92/0x150
[ 66.674431] bus_for_each_dev+0x7d/0xc0
[ 66.674434] bus_add_driver+0x14d/0x1f0
[ 66.674437] driver_register+0x6d/0xb0
[ 66.674440] i2c_register_driver+0x45/0x80
[ 66.674445] do_one_initcall+0x60/0x2f4
[ 66.674450] kernel_init_freeable+0x20d/0x2b4
[ 66.674453] kernel_init+0xa/0x10c
[ 66.674457] ret_from_fork+0x3a/0x50
[ 66.674459]
-> #0 (intel_soc_pmic_chtwc:167:(&cht_wc_regmap_cfg)->lock){+.+.}:
[ 66.674465] __lock_acquire+0xe07/0x1930
[ 66.674468] lock_acquire+0x9d/0x1a0
[ 66.674472] __mutex_lock+0xa8/0x9a0
[ 66.674474] regmap_write+0x31/0x70
[ 66.674480] cht_wc_i2c_adap_smbus_xfer+0x72/0x240 [i2c_cht_wc]
[ 66.674483] __i2c_smbus_xfer+0x1a3/0x640
[ 66.674486] i2c_smbus_xfer+0x67/0xf0
[ 66.674489] i2c_smbus_read_byte_data+0x45/0x70
[ 66.674494] bq24190_probe+0x26b/0x410 [bq24190_charger]
[ 66.674497] i2c_device_probe+0x189/0x250
[ 66.674500] really_probe+0xf3/0x380
[ 66.674503] driver_probe_device+0x59/0xd0
[ 66.674506] device_driver_attach+0x53/0x60
[ 66.674509] __driver_attach+0x92/0x150
[ 66.674512] bus_for_each_dev+0x7d/0xc0
[ 66.674515] bus_add_driver+0x14d/0x1f0
[ 66.674518] driver_register+0x6d/0xb0
[ 66.674521] i2c_register_driver+0x45/0x80
[ 66.674524] do_one_initcall+0x60/0x2f4
[ 66.674528] do_init_module+0x5c/0x230
[ 66.674531] load_module+0x2707/0x2a20
[ 66.674534] __do_sys_init_module+0x188/0x1b0
[ 66.674537] do_syscall_64+0x5c/0xb0
[ 66.674541] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 66.674543]
other info that might help us debug this:[ 66.674545] Possible unsafe locking scenario:
[ 66.674547] CPU0 CPU1
[ 66.674548] ---- ----
[ 66.674550] lock(i2c_register_adapter);
[ 66.674553] lock(intel_soc_pmic_chtwc:167:(&cht_wc_regmap_cfg)->lock);
[ 66.674556] lock(i2c_register_adapter);
[ 66.674559] lock(intel_soc_pmic_chtwc:167:(&cht_wc_regmap_cfg)->lock);
[ 66.674561]
*** DEADLOCK ***The problem is that the CHT Whiskey Cove PMIC's builtin i2c-adapter is itself a part of an i2c-client (the PMIC). This means that transfers done through it take adapter->bus_lock twice, once for the parent i2c-adapter and once for its own bus_lock. Lockdep does not like this nested locking.
To make lockdep happy in the case of busses with muxes, the i2c-core's i2c_adapter_lock_bus function calls:
rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter));
But i2c_adapter_depth only works when the direct parent of the adapter is another adapter, as it is only meant for muxes. In this case there is an i2c-client and MFD instantiated platform_device in the parent->child chain between the 2 devices.
This commit overrides the default i2c_lock_operations, passing a hardcoded depth of 1 to rt_mutex_lock_nested, making lockdep happy.
Note that if there were to be a mux attached to the i2c-wc-cht adapter, this would break things again since the i2c-mux code expects the root-adapter to have a locking depth of 0. But the i2c-wc-cht adapter always has only 1 client directly attached in the form of the charger IC paired with the CHT Whiskey Cove PMIC.
--- drivers/i2c/busses/i2c-cht-wc.c | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
drivers/i2c/busses/i2c-cht-wc.c +46 -0
@@ -178,6 +178,51 @@ static const struct i2c_algorithm cht_wc_i2c_adap_algo = { .smbus_xfer = cht_wc_i2c_adap_smbus_xfer, }; +/* +* We are an i2c-adapter which itself is part of an i2c-client. This means that +* transfers done through us take adapter->bus_lock twice, once for our parent +* i2c-adapter and once to take our own bus_lock. Lockdep does not like this +* nested locking, to make lockdep happy in the case of busses with muxes, the +* i2c-core's i2c_adapter_lock_bus function calls: +* rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter)); +* +* But i2c_adapter_depth only works when the direct parent of the adapter is +* another adapter, as it is only meant for muxes. In our case there is an +* i2c-client and MFD instantiated platform_device in the parent->child chain +* between the 2 devices. +* +* So we override the default i2c_lock_operations and pass a hardcoded +* depth of 1 to rt_mutex_lock_nested, to make lockdep happy. +* +* Note that if there were to be a mux attached to our adapter, this would +* break things again since the i2c-mux code expects the root-adapter to have +* a locking depth of 0. But we always have only 1 client directly attached +* in the form of the Charger IC paired with the CHT Whiskey Cove PMIC. +*/ +static void cht_wc_i2c_adap_lock_bus (struct i2c_adapter *adapter, +unsigned int flags) +{ +rt_mutex_lock_nested (&adapter->bus_lock,1 ); +} + +static int cht_wc_i2c_adap_trylock_bus (struct i2c_adapter *adapter, +unsigned int flags) +{ +return rt_mutex_trylock (&adapter->bus_lock); +} + +static void cht_wc_i2c_adap_unlock_bus (struct i2c_adapter *adapter, +unsigned int flags) +{ +rt_mutex_unlock (&adapter->bus_lock); +} + +static const struct i2c_lock_operations cht_wc_i2c_adap_lock_ops = { + .lock_bus = cht_wc_i2c_adap_lock_bus, + .trylock_bus = cht_wc_i2c_adap_trylock_bus, + .unlock_bus = cht_wc_i2c_adap_unlock_bus, +}; +/**** irqchip for the client connected to the extchgr i2c adapter ****/ static void cht_wc_i2c_irq_lock (struct irq_data *data) {
@@ -286,6 +331,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) adap->adapter.owner =THIS_MODULE ; adap->adapter.class =I2C_CLASS_HWMON ; adap->adapter.algo = &cht_wc_i2c_adap_algo; + adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops;strlcpy (adap->adapter.name,"PMIC I2C Adapter" ,sizeof (adap->adapter.name)); adap->adapter.dev.parent = &pdev->dev;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/42 mfd: intel-lpss: Remove D3cold delay
In reply to Sasha LevinFrom: Kai-Heng Feng <[email protected]>
[ Upstream commit 76380a607ba0b28627c9b4b55cd47a079a59624b ]
Goodix touchpad may drop its first couple input events when i2c-designware-platdrv and intel-lpss it connects to took too long to runtime resume from runtime suspended state.
This issue happens becuase the touchpad has a rather small buffer to store up to 13 input events, so if the host doesn't read those events in time (i.e. runtime resume takes too long), events are dropped from the touchpad's buffer.
The bottleneck is D3cold delay it waits when transitioning from D3cold to D0, hence remove the delay to make the resume faster. I've tested some systems with intel-lpss and haven't seen any regression.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202683
--- drivers/mfd/intel-lpss-pci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/intel-lpss-pci.c +2 -0
@@ -35,6 +35,8 @@ static int intel_lpss_pci_probe(struct pci_dev *pdev, info->mem = &pdev->resource[0 ]; info->irq = pdev->irq; + pdev->d3cold_delay =0 ; +/* Probably it is enough to set this for iDMA capable devices only */ pci_set_master (pdev);pci_try_set_mwi (pdev);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/42 PCI: tegra: Fix OF node reference leak
In reply to Sasha LevinFrom: Nishka Dasgupta <[email protected]>
[ Upstream commit 9e38e690ace3e7a22a81fc02652fc101efb340cf ]
Each iteration of for_each_child_of_node() executes of_node_put() on the previous node, but in some return paths in the middle of the loop of_node_put() is missing thus causing a reference leak.
Hence stash these mid-loop return values in a variable 'err' and add a new label err_node_put which executes of_node_put() on the previous node and returns 'err' on failure.
Change mid-loop return statements to point to jump to this label to fix the reference leak.
Issue found with Coccinelle.
--- drivers/pci/controller/pci-tegra.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
drivers/pci/controller/pci-tegra.c +15 -7
@@ -1994,14 +1994,15 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) err =of_pci_get_devfn (port);if (err <0 ) {dev_err (dev,"failed to parse address: %d\n" , err); -return err; + goto err_node_put; } index =PCI_SLOT (err);if (index <1 || index > soc->num_ports) {dev_err (dev,"invalid port number: %d\n" , index); -return -EINVAL ; + err = -EINVAL ; + goto err_node_put; } index--;
@@ -2010,12 +2011,13 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)if (err <0 ) {dev_err (dev,"failed to parse # of lanes: %d\n" , err); -return err; + goto err_node_put; }if (value >16 ) {dev_err (dev,"invalid # of lanes: %u\n" , value); -return -EINVAL ; + err = -EINVAL ; + goto err_node_put; } lanes |= value << (index <<3 );
@@ -2029,13 +2031,15 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie) lane += value; rp =devm_kzalloc (dev,sizeof (*rp),GFP_KERNEL ); -if (!rp) -return -ENOMEM ; +if (!rp) { + err = -ENOMEM ; + goto err_node_put; + } err =of_address_to_resource (port,0 , &rp->regs);if (err <0 ) {dev_err (dev,"failed to parse address: %d\n" , err); -return err; + goto err_node_put; }INIT_LIST_HEAD (&rp->list);
@@ -2062,6 +2066,10 @@ static int tegra_pcie_parse_dt(struct tegra_pcie *pcie)return err;return 0 ; + +err_node_put: +of_node_put (port); +return err; }/*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/42 HID: wacom: Fix several minor compiler warnings
In reply to Sasha LevinFrom: Jason Gerecke <[email protected]>
[ Upstream commit 073b50bccbbf99a3b79a1913604c656d0e1a56c9 ]
Addresses a few issues that were noticed when compiling with non-default warnings enabled. The trimmed-down warnings in the order they are fixed below are:
* declaration of 'size' shadows a parameter
* '%s' directive output may be truncated writing up to 5 bytes into a region of size between 1 and 64
* pointer targets in initialization of 'char *' from 'unsigned char *' differ in signedness
* left shift of negative value
--- drivers/hid/wacom_sys.c | 7 ++++--- drivers/hid/wacom_wac.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/hid/wacom_sys.c +4 -3
@@ -88,7 +88,7 @@ static void wacom_wac_queue_flush(struct hid_device *hdev, }static int wacom_wac_pen_serial_enforce (struct hid_device *hdev, -struct hid_report *report,u8 *raw_data,int size) +struct hid_report *report,u8 *raw_data,int report_size) {struct wacom *wacom =hid_get_drvdata (hdev);struct wacom_wac *wacom_wac = &wacom->wacom_wac;
@@ -149,7 +149,8 @@ static int wacom_wac_pen_serial_enforce(struct hid_device *hdev,if (flush)wacom_wac_queue_flush (hdev, &wacom_wac->pen_fifo);else if (insert) -wacom_wac_queue_insert (hdev, &wacom_wac->pen_fifo, raw_data, size); +wacom_wac_queue_insert (hdev, &wacom_wac->pen_fifo, + raw_data, report_size);return insert && !flush; }
@@ -2176,7 +2177,7 @@ static void wacom_update_name(struct wacom *wacom, const char *suffix) {struct wacom_wac *wacom_wac = &wacom->wacom_wac;struct wacom_features *features = &wacom_wac->features; -char name[WACOM_NAME_MAX ]; +char name[WACOM_NAME_MAX -20 ];/* Leave some room for suffixes */ /* Generic devices name unspecified */ if ((features->type ==HID_GENERIC ) && !strcmp ("Wacom HID" , features->name)) {
drivers/hid/wacom_wac.c +2 -2
@@ -251,7 +251,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)static int wacom_dtus_irq (struct wacom_wac *wacom) { -char *data = wacom->data; +unsigned char *data = wacom->data;struct input_dev *input = wacom->pen_input;unsigned short prox, pressure =0 ;
@@ -572,7 +572,7 @@ static int wacom_intuos_pad(struct wacom_wac *wacom) strip2 = ((data[3 ] &0x1f ) <<8 ) | data[4 ]; } - prox = (buttons & ~(~0 << nbuttons)) | (keys & ~(~0 << nkeys)) | + prox = (buttons & ~(~0U << nbuttons)) | (keys & ~(~0U << nkeys)) | (ring1 &0x80 ) | (ring2 &0x80 ) | strip1 | strip2;wacom_report_numbered_buttons (input, nbuttons, buttons);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/42 mips/atomic: Fix loongson_llsc_mb() wreckage
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 1c6c1ca318585f1096d4d04bc722297c85e9fb8a ]
The comment describing the loongson_llsc_mb() reorder case doesn't make any sense what so ever. Instruction re-ordering is not an SMP artifact, but rather a CPU local phenomenon. Clarify the comment by explaining that these issue cause a coherence fail.
For the branch speculation case; if futex_atomic_cmpxchg_inatomic() needs one at the bne branch target, then surely the normal __cmpxch_asm() implementation does too. We cannot rely on the barriers from cmpxchg() because cmpxchg_local() is implemented with the same macro, and branch prediction and speculation are, too, CPU local.
--- arch/mips/include/asm/atomic.h | 5 +++-- arch/mips/include/asm/barrier.h | 32 ++++++++++++++++++-------------- arch/mips/include/asm/bitops.h | 5 +++++ arch/mips/include/asm/cmpxchg.h | 5 +++++ arch/mips/kernel/syscall.c | 1 + 5 files changed, 32 insertions(+), 16 deletions(-)
arch/mips/include/asm/atomic.h +3 -2
@@ -193,6 +193,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)if (kernel_uses_llsc) {int temp; +loongson_llsc_mb (); __asm__ __volatile__(" .set push \n" " .set "MIPS_ISA_LEVEL" \n"
@@ -200,12 +201,12 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)" .set pop \n" " subu %0, %1, %3 \n" " move %1, %0 \n" -" bltz %0, 1f \n" +" bltz %0, 2f \n" " .set push \n" " .set " MIPS_ISA_LEVEL " \n" " sc %1, %2 \n" "\t" __scbeqz" %1, 1b \n" -"1: \n" +"2: \n" " .set pop \n" : "=&r" (result), "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter)
arch/mips/include/asm/barrier.h +18 -14
@@ -238,36 +238,40 @@/* * Some Loongson 3 CPUs have a bug wherein execution of a memory access (load, -* store or pref) in between an ll & sc can cause the sc instruction to +* store or prefetch) in between an LL & SC can cause the SC instruction to * erroneously succeed, breaking atomicity. Whilst it's unusual to write code * containing such sequences, this bug bites harder than we might otherwise * expect due to reordering & speculation: * -* 1) A memory access appearing prior to the ll in program order may actually -* be executed after the ll - this is the reordering case. +* 1) A memory access appearing prior to the LL in program order may actually +* be executed after the LL - this is the reordering case. * -* In order to avoid this we need to place a memory barrier (ie. a sync -* instruction) prior to every ll instruction, in between it & any earlier -* memory access instructions. Many of these cases are already covered by -* smp_mb__before_llsc() but for the remaining cases, typically ones in -* which multiple CPUs may operate on a memory location but ordering is not -* usually guaranteed, we use loongson_llsc_mb() below. +* In order to avoid this we need to place a memory barrier (ie. a SYNC +* instruction) prior to every LL instruction, in between it and any earlier +* memory access instructions. * * This reordering case is fixed by 3A R2 CPUs, ie. 3A2000 models and later. * -* 2) If a conditional branch exists between an ll & sc with a target outside -* of the ll-sc loop, for example an exit upon value mismatch in cmpxchg() +* 2) If a conditional branch exists between an LL & SC with a target outside +* of the LL-SC loop, for example an exit upon value mismatch in cmpxchg() * or similar, then misprediction of the branch may allow speculative -* execution of memory accesses from outside of the ll-sc loop. +* execution of memory accesses from outside of the LL-SC loop. * -* In order to avoid this we need a memory barrier (ie. a sync instruction) +* In order to avoid this we need a memory barrier (ie. a SYNC instruction) * at each affected branch target, for which we also use loongson_llsc_mb() * defined below. * * This case affects all current Loongson 3 CPUs. +* +* The above described cases cause an error in the cache coherence protocol; +* such that the Invalidate of a competing LL-SC goes 'missing' and SC +* erroneously observes its core still has Exclusive state and lets the SC +* proceed. +* +* Therefore the error only occurs on SMP systems. */ #ifdef CONFIG_CPU_LOONGSON3_WORKAROUNDS /* Loongson-3's LLSC workaround */ -#define loongson_llsc_mb () __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory") +#define loongson_llsc_mb () __asm__ __volatile__("sync" : : :"memory")#else #define loongson_llsc_mb () do { } while (0)#endif
arch/mips/include/asm/bitops.h +5 -0
@@ -249,6 +249,7 @@ static inline int test_and_set_bit(unsigned long nr,unsigned long *m = ((unsigned long *) addr) + (nr >>SZLONG_LOG );unsigned long temp; +loongson_llsc_mb (); do { __asm__ __volatile__( " .set push \n"
@@ -305,6 +306,7 @@ static inline int test_and_set_bit_lock(unsigned long nr,unsigned long *m = ((unsigned long *) addr) + (nr >>SZLONG_LOG );unsigned long temp; +loongson_llsc_mb (); do { __asm__ __volatile__( " .set push \n"
@@ -364,6 +366,7 @@ static inline int test_and_clear_bit(unsigned long nr,unsigned long *m = ((unsigned long *) addr) + (nr >>SZLONG_LOG );unsigned long temp; +loongson_llsc_mb (); do { __asm__ __volatile__( " " __LL "%0, %1 # test_and_clear_bit \n"
@@ -379,6 +382,7 @@ static inline int test_and_clear_bit(unsigned long nr,unsigned long *m = ((unsigned long *) addr) + (nr >>SZLONG_LOG );unsigned long temp; +loongson_llsc_mb (); do { __asm__ __volatile__( " .set push \n"
@@ -438,6 +442,7 @@ static inline int test_and_change_bit(unsigned long nr,unsigned long *m = ((unsigned long *) addr) + (nr >>SZLONG_LOG );unsigned long temp; +loongson_llsc_mb (); do { __asm__ __volatile__( " .set push \n"
arch/mips/include/asm/cmpxchg.h +5 -0
@@ -46,6 +46,7 @@ extern unsigned long __xchg_called_with_bad_pointer(void) __typeof(*(m)) __ret; \ \if (kernel_uses_llsc) { \ +loongson_llsc_mb (); \ __asm__ __volatile__( \" .set push \n" \ " .set noat \n" \
@@ -117,6 +118,7 @@ static inline unsigned long __xchg(volatile void *ptr, unsigned long x, __typeof(*(m)) __ret; \ \if (kernel_uses_llsc) { \ +loongson_llsc_mb (); \ __asm__ __volatile__( \" .set push \n" \ " .set noat \n" \
@@ -134,6 +136,7 @@ static inline unsigned long __xchg(volatile void *ptr, unsigned long x, : "=&r" (__ret), "=" GCC_OFF_SMALL_ASM() (*m) \ : GCC_OFF_SMALL_ASM() (*m), "Jr" (old), "Jr" (new) \ : "memory"); \ +loongson_llsc_mb (); \ }else { \unsigned long __flags; \ \
@@ -229,6 +232,7 @@ static inline unsigned long __cmpxchg64(volatile void *ptr,*/ local_irq_save (flags); +loongson_llsc_mb (); asmvolatile (" .set push \n" " .set " MIPS_ISA_ARCH_LEVEL " \n"
@@ -274,6 +278,7 @@ static inline unsigned long __cmpxchg64(volatile void *ptr, "r" (old), "r" (new) : "memory"); + loongson_llsc_mb();local_irq_restore (flags);return ret;
arch/mips/kernel/syscall.c +1 -0
@@ -132,6 +132,7 @@ static inline int mips_atomic_set(unsigned long addr, unsigned long new) [efault] "i" (-EFAULT) : "memory"); }else if (cpu_has_llsc) { +loongson_llsc_mb (); __asm__ __volatile__ (" .set push \n" " .set "MIPS_ISA_ARCH_LEVEL" \n"
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/42 PCI: pci-hyperv: Fix build errors on non-SYSFS config
In reply to Sasha LevinFrom: Randy Dunlap <[email protected]>
[ Upstream commit f58ba5e3f6863ea4486952698898848a6db726c2 ]
Fix build errors when building almost-allmodconfig but with SYSFS not set (not enabled). Fixes these build errors:
ERROR: "pci_destroy_slot" [drivers/pci/controller/pci-hyperv.ko] undefined!
ERROR: "pci_create_slot" [drivers/pci/controller/pci-hyperv.ko] undefined!
drivers/pci/slot.o is only built when SYSFS is enabled, so pci-hyperv.o has an implicit dependency on SYSFS. Make that explicit.
Also, depending on X86 && X86_64 is not needed, so just change that to depend on X86_64.
--- drivers/pci/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/Kconfig +1 -1
@@ -181,7 +181,7 @@ config PCI_LABEL config PCI_HYPERV tristate "Hyper-V PCI Frontend" - depends on X86 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && X86_64 + depends on X86_64 && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && SYSFS help The PCI device frontend driver allows the kernel to import arbitrary PCI devices from a PCI backend to support PCI driver domains.
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 11/42 PCI: layerscape: Add the bar_fixed_64bit property to the endpoint driver
In reply to Sasha LevinFrom: Xiaowei Bao <[email protected]>
[ Upstream commit fd5d16531a39322c3d7433d9f8a36203c9aaeddc ]
The layerscape PCIe controller have 4 BARs.
BAR0 and BAR1 are 32bit, BAR2 and BAR4 are 64bit and that's a
fixed hardware configuration.
Set the bar_fixed_64bit variable accordingly.
--- drivers/pci/controller/dwc/pci-layerscape-ep.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pci-layerscape-ep.c +1 -0
@@ -44,6 +44,7 @@ static const struct pci_epc_features ls_pcie_epc_features = { .linkup_notifier = false, .msi_capable = true, .msix_capable = false, + .bar_fixed_64bit = (1 << BAR_2) | (1 << BAR_4), }; static const struct pci_epc_features*
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 12/42 livepatch: Nullify obj->mod in klp_module_coming()'s error path
In reply to Sasha LevinFrom: Miroslav Benes <[email protected]>
[ Upstream commit 4ff96fb52c6964ad42e0a878be8f86a2e8052ddd ]
klp_module_coming() is called for every module appearing in the system. It sets obj->mod to a patched module for klp_object obj. Unfortunately it leaves it set even if an error happens later in the function and the patched module is not allowed to be loaded.
klp_is_object_loaded() uses obj->mod variable and could currently give a wrong return value. The bug is probably harmless as of now.
--- kernel/livepatch/core.c | 1 + 1 file changed, 1 insertion(+)
kernel/livepatch/core.c +1 -0
@@ -1175,6 +1175,7 @@ int klp_module_coming(struct module *mod)pr_warn ("patch '%s' failed for module '%s', refusing to load module '%s'\n" , patch->mod->name, obj->mod->name, obj->mod->name); mod->klp_alive = false; + obj->mod =NULL ;klp_cleanup_module_patches_limited (mod, patch);mutex_unlock (&klp_mutex);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 13/42 mips/atomic: Fix smp_mb__{before,after}_atomic()
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit 42344113ba7a1ed7b5654cd5270af0d5698d8521 ]
Recent probing at the Linux Kernel Memory Model uncovered a 'surprise'. Strongly ordered architectures where the atomic RmW primitive implies full memory ordering and smp_mb__{before,after}_atomic() are a simple barrier() (such as MIPS without WEAK_REORDERING_BEYOND_LLSC) fail for:
*x = 1; atomic_inc(u); smp_mb__after_atomic(); r0 = *y;
Because, while the atomic_inc() implies memory order, it (surprisingly) does not provide a compiler barrier. This then allows the compiler to re-order like so:
atomic_inc(u); *x = 1; smp_mb__after_atomic(); r0 = *y;
Which the CPU is then allowed to re-order (under TSO rules) like:
atomic_inc(u); r0 = *y; *x = 1;
And this very much was not intended. Therefore strengthen the atomic RmW ops to include a compiler barrier.
--- arch/mips/include/asm/atomic.h | 14 +++++------ arch/mips/include/asm/barrier.h | 12 ++++++++-- arch/mips/include/asm/bitops.h | 42 ++++++++++++++++++++------------- arch/mips/include/asm/cmpxchg.h | 6 ++--- 4 files changed, 45 insertions(+), 29 deletions(-)
arch/mips/include/asm/atomic.h +7 -7
@@ -68,7 +68,7 @@ static __inline__ void atomic_##op(int i, atomic_t * v) \"\t" __scbeqz" %0, 1b \n" \" .set pop \n" \ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \ -: " Ir" (i)); \ +: " Ir" (i) : __LLSC_CLOBBER); \ } else { \ unsigned long flags; \ \
@@ -98,7 +98,7 @@ static __inline__ int atomic_##op##_return_relaxed(int i, atomic_t * v) \ " .set pop \n" \ : "=&r" (result), "=&r" (temp), \ "+" GCC_OFF_SMALL_ASM() (v->counter) \ - : "Ir" (i)); \ + : "Ir" (i) : __LLSC_CLOBBER); \ }else { \unsigned long flags; \ \
@@ -132,7 +132,7 @@ static __inline__ int atomic_fetch_##op##_relaxed(int i, atomic_t * v) \ " move %0, %1 \n" \ : "=&r" (result), "=&r" (temp), \ "+" GCC_OFF_SMALL_ASM() (v->counter) \ - : "Ir" (i)); \ + : "Ir" (i) : __LLSC_CLOBBER); \ }else { \unsigned long flags; \ \
@@ -210,7 +210,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v) " .set pop \n" : "=&r" (result), "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) - : "Ir" (i)); + : "Ir" (i) : __LLSC_CLOBBER); }else {unsigned long flags;
@@ -270,7 +270,7 @@ static __inline__ void atomic64_##op(long i, atomic64_t * v) \"\t" __scbeqz" %0, 1b \n" \" .set pop \n" \ : "=&r" (temp), "+" GCC_OFF_SMALL_ASM() (v->counter) \ -: " Ir" (i)); \ +: " Ir" (i) : __LLSC_CLOBBER); \ } else { \ unsigned long flags; \ \
@@ -300,7 +300,7 @@ static __inline__ long atomic64_##op##_return_relaxed(long i, atomic64_t * v) \ " .set pop \n" \ : "=&r" (result), "=&r" (temp), \ "+" GCC_OFF_SMALL_ASM() (v->counter) \ - : "Ir" (i)); \ + : "Ir" (i) : __LLSC_CLOBBER); \ }else { \unsigned long flags; \ \
@@ -334,7 +334,7 @@ static __inline__ long atomic64_fetch_##op##_relaxed(long i, atomic64_t * v) \ " .set pop \n" \ : "=&r" (result), "=&r" (temp), \ "+" GCC_OFF_SMALL_ASM() (v->counter) \ - : "Ir" (i)); \ + : "Ir" (i) : __LLSC_CLOBBER); \ }else { \unsigned long flags; \ \
arch/mips/include/asm/barrier.h +10 -2
@@ -211,14 +211,22 @@#define __smp_wmb () barrier()#endif +/* +* When LL/SC does imply order, it must also be a compiler barrier to avoid the +* compiler from reordering where the CPU will not. When it does not imply +* order, the compiler is also free to reorder across the LL/SC loop and +* ordering will be done by smp_llsc_mb() and friends. +*/ #if defined(CONFIG_WEAK_REORDERING_BEYOND_LLSC ) && defined(CONFIG_SMP )#define __WEAK_LLSC_MB " sync \n" +#define smp_llsc_mb () __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory") +#define __LLSC_CLOBBER#else #define __WEAK_LLSC_MB " \n" +#define smp_llsc_mb () do { } while (0) +#define __LLSC_CLOBBER "memory"#endif -#define smp_llsc_mb () __asm__ __volatile__(__WEAK_LLSC_MB : : :"memory") -#ifdef CONFIG_CPU_CAVIUM_OCTEON #define smp_mb__before_llsc () smp_wmb()#define __smp_mb__before_llsc () __smp_wmb()
arch/mips/include/asm/bitops.h +25 -17
144 lines not on this page · raw message
arch/mips/include/asm/cmpxchg.h +3 -3
@@ -61,7 +61,7 @@ extern unsigned long __xchg_called_with_bad_pointer(void) " .set pop \n" \ : "=&r" (__ret), "=" GCC_OFF_SMALL_ASM() (*m) \ : GCC_OFF_SMALL_ASM() (*m), "Jr" (val) \ - : "memory"); \ + : __LLSC_CLOBBER); \ }else { \unsigned long __flags; \ \
@@ -134,8 +134,8 @@ static inline unsigned long __xchg(volatile void *ptr, unsigned long x, " .set pop \n" \ "2: \n" \ : "=&r" (__ret), "=" GCC_OFF_SMALL_ASM() (*m) \ - : GCC_OFF_SMALL_ASM() (*m), "Jr" (old), "Jr" (new) \ - : "memory"); \ + : GCC_OFF_SMALL_ASM() (*m), "Jr" (old), "Jr" (new) \ + : __LLSC_CLOBBER); \loongson_llsc_mb (); \ }else { \unsigned long __flags; \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 14/42 ARM: 8898/1: mm: Don't treat faults reported from cache maintenance as writes
In reply to Sasha LevinFrom: Will Deacon <[email protected]>
[ Upstream commit 834020366da9ab3fb87d1eb9a3160eb22dbed63a ]
Translation faults arising from cache maintenance instructions are rather unhelpfully reported with an FSR value where the WnR field is set to 1, indicating that the faulting access was a write. Since cache maintenance instructions on 32-bit ARM do not require any particular permissions, this can cause our private 'cacheflush' system call to fail spuriously if a translation fault is generated due to page aging when targetting a read-only VMA.
In this situation, we will return -EFAULT to userspace, although this is unfortunately suppressed by the popular '__builtin___clear_cache()' intrinsic provided by GCC, which returns void.
Although it's tempting to write this off as a userspace issue, we can actually do a little bit better on CPUs that support LPAE, even if the short-descriptor format is in use. On these CPUs, cache maintenance faults additionally set the CM field in the FSR, which we can use to suppress the write permission checks in the page fault handler and succeed in performing cache maintenance to read-only areas even in the presence of a translation fault.
--- arch/arm/mm/fault.c | 4 ++-- arch/arm/mm/fault.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/mm/fault.c +2 -2
@@ -211,7 +211,7 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma) {unsigned int mask =VM_READ |VM_WRITE |VM_EXEC ; -if (fsr &FSR_WRITE ) +if ((fsr &FSR_WRITE ) && !(fsr &FSR_CM )) mask =VM_WRITE ;if (fsr &FSR_LNX_PF ) mask =VM_EXEC ;
@@ -282,7 +282,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)if (user_mode (regs)) flags |=FAULT_FLAG_USER ; -if (fsr &FSR_WRITE ) +if ((fsr &FSR_WRITE ) && !(fsr &FSR_CM )) flags |=FAULT_FLAG_WRITE ;/*
arch/arm/mm/fault.h +1 -0
@@ -6,6 +6,7 @@* Fault status register encodings. We steal bit 31 for our own purposes. */ #define FSR_LNX_PF (1 << 31) +#define FSR_CM (1 << 13)#define FSR_WRITE (1 << 11)#define FSR_FS4 (1 << 10)#define FSR_FS3_0 (15)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 15/42 soundwire: intel: fix channel number reported by hardware
In reply to Sasha LevinFrom: Pierre-Louis Bossart <[email protected]>
[ Upstream commit 18046335643de6d21327f5ae034c8fb8463f6715 ]
On all released Intel controllers (CNL/CML/ICL), PDI2 reports an invalid count, force the correct hardware-supported value
This may have to be revisited with platform-specific values if the hardware changes, but for now this is good enough.
--- drivers/soundwire/intel.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/soundwire/intel.c +10 -0
@@ -283,6 +283,16 @@ intel_pdi_get_ch_cap(struct sdw_intel *sdw, unsigned int pdi_num, bool pcm)if (pcm) { count =intel_readw (shim,SDW_SHIM_PCMSYCHC (link_id, pdi_num)); + +/* +* WORKAROUND: on all existing Intel controllers, pdi +* number 2 reports channel count as 1 even though it +* supports 8 channels. Performing hardcoding for pdi +* number 2. +*/ +if (pdi_num ==2 ) + count =7 ; + }else { count =intel_readw (shim,SDW_SHIM_PDMSCAP (link_id)); count = ((count & SDW_SHIM_PDMSCAP_CPSS) >>
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 16/42 ARM: 8875/1: Kconfig: default to AEABI w/ Clang
In reply to Sasha LevinFrom: Nick Desaulniers <[email protected]>
[ Upstream commit a05b9608456e0d4464c6f7ca8572324ace57a3f4 ]
Clang produces references to __aeabi_uidivmod and __aeabi_idivmod for arm-linux-gnueabi and arm-linux-gnueabihf targets incorrectly when AEABI is not selected (such as when OABI_COMPAT is selected).
While this means that OABI userspaces wont be able to upgraded to kernels built with Clang, it means that boards that don't enable AEABI like s3c2410_defconfig will stop failing to link in KernelCI when built with Clang.
--- arch/arm/Kconfig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm/Kconfig +3 -2
@@ -1545,8 +1545,9 @@ config ARM_PATCH_IDIV code to do integer division. config AEABI - bool "Use the ARM EABI to compile the kernel" if !CPU_V7 && !CPU_V7M && !CPU_V6 && !CPU_V6K - default CPU_V7 || CPU_V7M || CPU_V6 || CPU_V6K + bool "Use the ARM EABI to compile the kernel" if !CPU_V7 && \ + !CPU_V7M && !CPU_V6 && !CPU_V6K && !CC_IS_CLANG + default CPU_V7 || CPU_V7M || CPU_V6 || CPU_V6K || CC_IS_CLANG help This option allows for the kernel to be compiled using the latest ARM ABI (aka EABI). This is only useful if you are using a user
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 17/42 MIPS: lantiq: update the clock alias' for the mainline PCIe PHY driver
In reply to Sasha LevinFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit ed90302be64a53d9031c8ce05428c358b16a5d96 ]
The mainline PCIe PHY driver has it's own devicetree node. Update the clock alias so the mainline driver finds the clocks.
The first PCIe PHY is located at 0x1f106800 and exists on VRX200, ARX300 and GRX390.
The second PCIe PHY is located at 0x1f700400 and exists on ARX300 and GRX390.
The third PCIe PHY is located at 0x1f106a00 and exists onl on GRX390. Lantiq's board support package (called "UGW") names these registers "PDI".
--- arch/mips/lantiq/xway/sysctrl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/mips/lantiq/xway/sysctrl.c +8 -8
@@ -468,14 +468,14 @@ void __init ltq_soc_init(void)clkdev_add_pmu ("1f203018.usb2-phy" ,"phy" ,1 ,2 ,PMU_ANALOG_USB0_P );clkdev_add_pmu ("1f203034.usb2-phy" ,"phy" ,1 ,2 ,PMU_ANALOG_USB1_P );/* rc 0 */ -clkdev_add_pmu ("1d900000.pcie" ,"phy" ,1 ,2 ,PMU_ANALOG_PCIE0_P ); +clkdev_add_pmu ("1f106800.phy" ,"phy" ,1 ,2 ,PMU_ANALOG_PCIE0_P );clkdev_add_pmu ("1d900000.pcie" ,"msi" ,1 ,1 ,PMU1_PCIE_MSI ); -clkdev_add_pmu ("1d900000.pcie" ,"pdi" ,1 ,1 ,PMU1_PCIE_PDI ); +clkdev_add_pmu ("1f106800.phy" ,"pdi" ,1 ,1 ,PMU1_PCIE_PDI );clkdev_add_pmu ("1d900000.pcie" ,"ctl" ,1 ,1 ,PMU1_PCIE_CTL );/* rc 1 */ -clkdev_add_pmu ("19000000.pcie" ,"phy" ,1 ,2 ,PMU_ANALOG_PCIE1_P ); +clkdev_add_pmu ("1f700400.phy" ,"phy" ,1 ,2 ,PMU_ANALOG_PCIE1_P );clkdev_add_pmu ("19000000.pcie" ,"msi" ,1 ,1 ,PMU1_PCIE1_MSI ); -clkdev_add_pmu ("19000000.pcie" ,"pdi" ,1 ,1 ,PMU1_PCIE1_PDI ); +clkdev_add_pmu ("1f700400.phy" ,"pdi" ,1 ,1 ,PMU1_PCIE1_PDI );clkdev_add_pmu ("19000000.pcie" ,"ctl" ,1 ,1 ,PMU1_PCIE1_CTL ); }
@@ -499,9 +499,9 @@ void __init ltq_soc_init(void)clkdev_add_pmu ("1e101000.usb" ,"otg" ,1 ,0 ,PMU_USB0 );clkdev_add_pmu ("1e106000.usb" ,"otg" ,1 ,0 ,PMU_USB1 );/* rc 2 */ -clkdev_add_pmu ("1a800000.pcie" ,"phy" ,1 ,2 ,PMU_ANALOG_PCIE2_P ); +clkdev_add_pmu ("1f106a00.pcie" ,"phy" ,1 ,2 ,PMU_ANALOG_PCIE2_P );clkdev_add_pmu ("1a800000.pcie" ,"msi" ,1 ,1 ,PMU1_PCIE2_MSI ); -clkdev_add_pmu ("1a800000.pcie" ,"pdi" ,1 ,1 ,PMU1_PCIE2_PDI ); +clkdev_add_pmu ("1f106a00.pcie" ,"pdi" ,1 ,1 ,PMU1_PCIE2_PDI );clkdev_add_pmu ("1a800000.pcie" ,"ctl" ,1 ,1 ,PMU1_PCIE2_CTL );clkdev_add_pmu ("1e10b308.eth" ,NULL ,0 ,0 ,PMU_SWITCH |PMU_PPE_DP );clkdev_add_pmu ("1da00000.usif" ,"NULL" ,1 ,0 ,PMU_USIF );
@@ -526,10 +526,10 @@ void __init ltq_soc_init(void)clkdev_add_pmu ("1e101000.usb" ,"otg" ,1 ,0 ,PMU_USB0 |PMU_AHBM );clkdev_add_pmu ("1f203034.usb2-phy" ,"phy" ,1 ,0 ,PMU_USB1_P );clkdev_add_pmu ("1e106000.usb" ,"otg" ,1 ,0 ,PMU_USB1 |PMU_AHBM ); -clkdev_add_pmu ("1d900000.pcie" ,"phy" ,1 ,1 ,PMU1_PCIE_PHY ); +clkdev_add_pmu ("1f106800.phy" ,"phy" ,1 ,1 ,PMU1_PCIE_PHY );clkdev_add_pmu ("1d900000.pcie" ,"bus" ,1 ,0 ,PMU_PCIE_CLK );clkdev_add_pmu ("1d900000.pcie" ,"msi" ,1 ,1 ,PMU1_PCIE_MSI ); -clkdev_add_pmu ("1d900000.pcie" ,"pdi" ,1 ,1 ,PMU1_PCIE_PDI ); +clkdev_add_pmu ("1f106800.phy" ,"pdi" ,1 ,1 ,PMU1_PCIE_PDI );clkdev_add_pmu ("1d900000.pcie" ,"ctl" ,1 ,1 ,PMU1_PCIE_CTL );clkdev_add_pmu (NULL ,"ahb" ,1 ,0 ,PMU_AHBM |PMU_AHBS );
Signature · 1 line
2.20.1
Re: [PATCH AUTOSEL 5.2 17/42] MIPS: lantiq: update the clock alias' for the mainline PCIe PHY driver
Quoted 28 lines · Sasha Levin
From: Martin Blumenstingl <[email protected]>
[ Upstream commit
ed90302be64a53d9031c8ce05428c358b16a5d96]The mainline PCIe PHY driver has it's own devicetree node. Update the clock alias so the mainline driver finds the clocks.
The first PCIe PHY is located at
0x1f106800and exists on VRX200, ARX300 and GRX390.
The second PCIe PHY is located at0x1f700400and exists on ARX300 and GRX390.
The third PCIe PHY is located at0x1f106a00and exists onl on GRX390. Lantiq's board support package (called "UGW") names these registers "PDI".Signed-off-by Martin Blumenstingl <[email protected]>Signed-off-by Paul Burton <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Quoted 3 lines
--- arch/mips/lantiq/xway/sysctrl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Hi Sasha,
This change only makes sense with the new upstream PCIe phy driver which was added to kernel 5.4 [0], older kernel versions do not have this PCIe PHY driver. I would not backport these changes to older kernel versions.
[0]: https://git.kernel.org/linus/e52a632195bf43d1a91ae699e7536a6ead736aa7
Hauke
Sasha Levin
maintainerRe: [PATCH AUTOSEL 5.2 17/42] MIPS: lantiq: update the clock alias' for the mainline PCIe PHY driver
Quoted 33 lines · Hauke Mehrtens
Quoted 28 lines · Sasha Levin
From: Martin Blumenstingl <[email protected]>
[ Upstream commit
ed90302be64a53d9031c8ce05428c358b16a5d96]The mainline PCIe PHY driver has it's own devicetree node. Update the clock alias so the mainline driver finds the clocks.
The first PCIe PHY is located at
0x1f106800and exists on VRX200, ARX300 and GRX390.
The second PCIe PHY is located at0x1f700400and exists on ARX300 and GRX390.
The third PCIe PHY is located at0x1f106a00and exists onl on GRX390. Lantiq's board support package (called "UGW") names these registers "PDI".Signed-off-by Martin Blumenstingl <[email protected]>Signed-off-by Paul Burton <[email protected]>Signed-off-by Sasha Levin <[email protected]>Quoted 3 lines
--- arch/mips/lantiq/xway/sysctrl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Quoted 5 lines
Hi Sasha,
This change only makes sense with the new upstream PCIe phy driver which was added to kernel 5.4 [0], older kernel versions do not have this PCIe PHY driver. I would not backport these changes to older kernel versions.
I'll drop it, thank you!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 18/42 firmware: bcm47xx_nvram: Correct size_t printf format
In reply to Sasha LevinFrom: Florian Fainelli <[email protected]>
[ Upstream commit feb4eb060c3aecc3c5076bebe699cd09f1133c41 ]
When building on a 64-bit host, we will get warnings like those:
drivers/firmware/broadcom/bcm47xx_nvram.c:103:3: note: in expansion of macro 'pr_err'
pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n", ^~~~~~drivers/firmware/broadcom/bcm47xx_nvram.c:103:28: note: format string is defined here
pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
~^
%liUse %zu instead for that purpose.
--- drivers/firmware/broadcom/bcm47xx_nvram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/broadcom/bcm47xx_nvram.c +2 -2
@@ -96,7 +96,7 @@ static int nvram_find_and_copy(void __iomem *iobase, u32 lim) nvram_len = size; }if (nvram_len >=NVRAM_SPACE ) { -pr_err ("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n" , +pr_err ("nvram on flash (%zu bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n" , nvram_len,NVRAM_SPACE -1 ); nvram_len =NVRAM_SPACE -1 ; }
@@ -148,7 +148,7 @@ static int nvram_init(void) header.len > sizeof(header)) { nvram_len = header.len;if (nvram_len >=NVRAM_SPACE ) { -pr_err ("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n" , +pr_err ("nvram on flash (%zu bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n" , header.len,NVRAM_SPACE ); nvram_len =NVRAM_SPACE -1 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 19/42 rtc: snvs: fix possible race condition
In reply to Sasha LevinFrom: Anson Huang <[email protected]>
[ Upstream commit 6fd4fe9b496d9ba3382992ff4fde3871d1b6f63d ]
The RTC IRQ is requested before the struct rtc_device is allocated, this may lead to a NULL pointer dereference in IRQ handler.
To fix this issue, allocating the rtc_device struct before requesting the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device to register the RTC device.
--- drivers/rtc/rtc-snvs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/rtc/rtc-snvs.c +7 -4
@@ -279,6 +279,10 @@ static int snvs_rtc_probe(struct platform_device *pdev)if (!data)return -ENOMEM ; + data->rtc =devm_rtc_allocate_device (&pdev->dev); +if (IS_ERR (data->rtc)) +return PTR_ERR (data->rtc); + data->regmap =syscon_regmap_lookup_by_phandle (pdev->dev.of_node,"regmap" );if (IS_ERR (data->regmap)) {
@@ -343,10 +347,9 @@ static int snvs_rtc_probe(struct platform_device *pdev) goto error_rtc_device_register; } - data->rtc =devm_rtc_device_register (&pdev->dev, pdev->name, - &snvs_rtc_ops,THIS_MODULE ); -if (IS_ERR (data->rtc)) { - ret =PTR_ERR (data->rtc); + data->rtc->ops = &snvs_rtc_ops; + ret =rtc_register_device (data->rtc); +if (ret) {dev_err (&pdev->dev,"failed to register rtc: %d\n" , ret); goto error_rtc_device_register; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 20/42 rtc: pcf85363/pcf85263: fix regmap error in set_time
In reply to Sasha LevinFrom: Biwen Li <[email protected]>
[ Upstream commit 7ef66122bdb3b839e9f51b76d7e600b6e21ef648 ]
Issue:
- # hwclock -w
hwclock: RTC_SET_TIME: Invalid argument
Why:
- Relative commit: 8b9f9d4dc511 ("regmap: verify if register is writeable before writing operations"), this patch will always check for unwritable registers, it will compare reg with max_register in regmap_writeable.
- The pcf85363/pcf85263 has the capability of address wrapping which means if you access an address outside the allowed range (0x00-0x2f) hardware actually wraps the access to a lower address. The rtc-pcf85363 driver will use this feature to configure the time and execute 2 actions in the same i2c write operation (stopping the clock and configure the time). However the driver has also configured the regmap maxregister protection mechanism that will block accessing addresses outside valid range (0x00-0x2f).
How:
- Split of writing regs to two parts, first part writes control registers about stop_enable and resets, second part writes RTC time and date registers.
--- drivers/rtc/rtc-pcf85363.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/rtc/rtc-pcf85363.c +6 -1
@@ -166,7 +166,12 @@ static int pcf85363_rtc_set_time(struct device *dev, struct rtc_time *tm) buf[DT_YEARS ] =bin2bcd (tm->tm_year %100 ); ret =regmap_bulk_write (pcf85363->regmap,CTRL_STOP_EN , - tmp,sizeof (tmp)); + tmp,2 ); +if (ret) +return ret; + + ret =regmap_bulk_write (pcf85363->regmap,DT_100THS , + buf,sizeof (tmp) -2 );if (ret)return ret;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 21/42 selinux: fix residual uses of current_security() for the SELinux blob
In reply to Sasha LevinFrom: Stephen Smalley <[email protected]>
[ Upstream commit 169ce0c081cd85f78388bb6c1638c1ad7b81bde7 ]
We need to use selinux_cred() to fetch the SELinux cred blob instead of directly using current->security or current_security(). There were a couple of lingering uses of current_security() in the SELinux code that were apparently missed during the earlier conversions. IIUC, this would only manifest as a bug if multiple security modules including SELinux are enabled and SELinux is not first in the lsm order. After this change, there appear to be no other users of current_security() in-tree; perhaps we should remove it altogether.
--- security/selinux/hooks.c | 2 +- security/selinux/include/objsec.h | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-)
security/selinux/hooks.c +1 -1
@@ -3403,7 +3403,7 @@ static int selinux_inode_copy_up_xattr(const char *name)static int selinux_kernfs_init_security (struct kernfs_node *kn_dir,struct kernfs_node *kn) { -const struct task_security_struct *tsec =current_security (); +const struct task_security_struct *tsec =selinux_cred (current_cred ());u32 parent_sid, newsid, clen;int rc;char *context;
security/selinux/include/objsec.h +10 -10
@@ -37,16 +37,6 @@ struct task_security_struct {u32 sockcreate_sid;/* fscreate SID */ }; -/* -* get the subjective security ID of the current task -*/ -static inline u32 current_sid (void ) -{ -const struct task_security_struct *tsec =current_security (); - -return tsec->sid; -} -enum label_initialized {LABEL_INVALID ,/* invalid or not initialized */ LABEL_INITIALIZED ,/* initialized */
@@ -185,4 +175,14 @@ static inline struct ipc_security_struct *selinux_ipc( return ipc->security + selinux_blob_sizes.lbs_ipc; } +/* +* get the subjective security ID of the current task +*/ +static inline u32 current_sid (void ) +{ +const struct task_security_struct *tsec =selinux_cred (current_cred ()); + +return tsec->sid; +} +#endif /* _SELINUX_OBJSEC_H_ */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 22/42 PCI: Add pci_info_ratelimited() to ratelimit PCI separately
In reply to Sasha LevinFrom: Krzysztof Wilczynski <[email protected]>
[ Upstream commit 7f1c62c443a453deb6eb3515e3c05650ffe0dcf0 ]
Do not use printk_ratelimit() in drivers/pci/pci.c as it shares the rate limiting state with all other callers to the printk_ratelimit().
Add pci_info_ratelimited() (similar to pci_notice_ratelimited() added in the commit a88a7b3eb076 ("vfio: Use dev_printk() when possible")) and use it instead of printk_ratelimit() + pci_info().
--- drivers/pci/pci.c | 4 ++-- include/linux/pci.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/pci/pci.c +2 -2
@@ -884,8 +884,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr); dev->current_state = (pmcsr &PCI_PM_CTRL_STATE_MASK ); -if (dev->current_state != state &&printk_ratelimit ()) -pci_info (dev,"Refused to change power state, currently in D%d\n" , +if (dev->current_state != state) +pci_info_ratelimited (dev,"Refused to change power state, currently in D%d\n" , dev->current_state);/*
include/linux/pci.h +3 -0
@@ -2375,4 +2375,7 @@ void pci_uevent_ers(struct pci_dev *pdev, enum pci_ers_result err_type); #define pci_notice_ratelimited(pdev, fmt, arg...) \ dev_notice_ratelimited(&(pdev)->dev, fmt, ##arg) +#define pci_info_ratelimited(pdev, fmt, arg...) \ + dev_info_ratelimited(&(pdev)->dev, fmt, ##arg) +#endif /* LINUX_PCI_H */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 23/42 HID: apple: Fix stuck function keys when using FN
In reply to Sasha LevinFrom: Joao Moreno <[email protected]>
[ Upstream commit aec256d0ecd561036f188dbc8fa7924c47a9edfd ]
This fixes an issue in which key down events for function keys would be repeatedly emitted even after the user has raised the physical key. For example, the driver fails to emit the F5 key up event when going through the following steps:
- fnmode=1: hold FN, hold F5, release FN, release F5
- fnmode=2: hold F5, hold FN, release F5, release FN
The repeated F5 key down events can be easily verified using xev.
--- drivers/hid/hid-apple.c | 49 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-)
drivers/hid/hid-apple.c +28 -21
@@ -54,7 +54,6 @@ MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\")struct apple_sc {unsigned long quirks;unsigned int fn_on; - DECLARE_BITMAP(pressed_fn, KEY_CNT); DECLARE_BITMAP(pressed_numlock, KEY_CNT); };
@@ -181,6 +180,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, {struct apple_sc *asc =hid_get_drvdata (hid);const struct apple_key_translation *trans, *table; +bool do_translate; +u16 code =0 ;if (usage->code ==KEY_FN ) { asc->fn_on = !!value;
@@ -189,8 +190,6 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, }if (fnmode) { -int do_translate; -if (hid->product >=USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && hid->product <=USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS ) table = macbookair_fn_keys;
@@ -202,25 +201,33 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, trans =apple_find_translation (table, usage->code);if (trans) { -if (test_bit (usage->code, asc->pressed_fn)) - do_translate =1 ; -else if (trans->flags &APPLE_FLAG_FKEY ) - do_translate = (fnmode ==2 && asc->fn_on) || - (fnmode ==1 && !asc->fn_on); -else - do_translate = asc->fn_on; - -if (do_translate) { -if (value) -set_bit (usage->code, asc->pressed_fn); -else -clear_bit (usage->code, asc->pressed_fn); - -input_event (input, usage->type, trans->to, - value); - -return 1 ; +if (test_bit (trans->from, input->key)) + code = trans->from; +else if (test_bit (trans->to, input->key)) + code = trans->to; + +if (!code) { +if (trans->flags &APPLE_FLAG_FKEY ) { +switch (fnmode) { +case 1 : + do_translate = !asc->fn_on; +break ; +case 2 : + do_translate = asc->fn_on; +break ; +default : +/* should never happen */ + do_translate = false; + } + }else { + do_translate = asc->fn_on; + } + + code = do_translate ? trans->to : trans->from; } + +input_event (input, usage->type, code, value); +return 1 ; } if (asc->quirks & APPLE_NUMLOCK_EMULATION &&
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 24/42 PCI: rockchip: Propagate errors for optional regulators
In reply to Sasha LevinFrom: Thierry Reding <[email protected]>
[ Upstream commit 0e3ff0ac5f71bdb6be2a698de0ed0c7e6e738269 ]
regulator_get_optional() can fail for a number of reasons besides probe deferral. It can for example return -ENOMEM if it runs out of memory as it tries to allocate data structures. Propagating only -EPROBE_DEFER is problematic because it results in these legitimately fatal errors being treated as "regulator not specified in DT".
What we really want is to ignore the optional regulators only if they have not been specified in DT. regulator_get_optional() returns -ENODEV in this case, so that's the special case that we need to handle. So we propagate all errors, except -ENODEV, so that real failures will still cause the driver to fail probe.
--- drivers/pci/controller/pcie-rockchip-host.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/pci/controller/pcie-rockchip-host.c +8 -8
@@ -608,29 +608,29 @@ static int rockchip_pcie_parse_host_dt(struct rockchip_pcie *rockchip) rockchip->vpcie12v =devm_regulator_get_optional (dev,"vpcie12v" );if (IS_ERR (rockchip->vpcie12v)) { -if (PTR_ERR (rockchip->vpcie12v) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (rockchip->vpcie12v) != -ENODEV ) +return PTR_ERR (rockchip->vpcie12v);dev_info (dev,"no vpcie12v regulator found\n" ); } rockchip->vpcie3v3 =devm_regulator_get_optional (dev,"vpcie3v3" );if (IS_ERR (rockchip->vpcie3v3)) { -if (PTR_ERR (rockchip->vpcie3v3) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (rockchip->vpcie3v3) != -ENODEV ) +return PTR_ERR (rockchip->vpcie3v3);dev_info (dev,"no vpcie3v3 regulator found\n" ); } rockchip->vpcie1v8 =devm_regulator_get_optional (dev,"vpcie1v8" );if (IS_ERR (rockchip->vpcie1v8)) { -if (PTR_ERR (rockchip->vpcie1v8) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (rockchip->vpcie1v8) != -ENODEV ) +return PTR_ERR (rockchip->vpcie1v8);dev_info (dev,"no vpcie1v8 regulator found\n" ); } rockchip->vpcie0v9 =devm_regulator_get_optional (dev,"vpcie0v9" );if (IS_ERR (rockchip->vpcie0v9)) { -if (PTR_ERR (rockchip->vpcie0v9) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (rockchip->vpcie0v9) != -ENODEV ) +return PTR_ERR (rockchip->vpcie0v9);dev_info (dev,"no vpcie0v9 regulator found\n" ); }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 25/42 PCI: histb: Propagate errors for optional regulators
In reply to Sasha LevinFrom: Thierry Reding <[email protected]>
[ Upstream commit 8f9e1641ba445437095411d9fda2324121110d5d ]
regulator_get_optional() can fail for a number of reasons besides probe deferral. It can for example return -ENOMEM if it runs out of memory as it tries to allocate data structures. Propagating only -EPROBE_DEFER is problematic because it results in these legitimately fatal errors being treated as "regulator not specified in DT".
What we really want is to ignore the optional regulators only if they have not been specified in DT. regulator_get_optional() returns -ENODEV in this case, so that's the special case that we need to handle. So we propagate all errors, except -ENODEV, so that real failures will still cause the driver to fail probe.
--- drivers/pci/controller/dwc/pcie-histb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-histb.c +2 -2
@@ -340,8 +340,8 @@ static int histb_pcie_probe(struct platform_device *pdev) hipcie->vpcie =devm_regulator_get_optional (dev,"vpcie" );if (IS_ERR (hipcie->vpcie)) { -if (PTR_ERR (hipcie->vpcie) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (hipcie->vpcie) != -ENODEV ) +return PTR_ERR (hipcie->vpcie); hipcie->vpcie =NULL ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 26/42 PCI: imx6: Propagate errors for optional regulators
In reply to Sasha LevinFrom: Thierry Reding <[email protected]>
[ Upstream commit 2170a09fb4b0f66e06e5bcdcbc98c9ccbf353650 ]
regulator_get_optional() can fail for a number of reasons besides probe deferral. It can for example return -ENOMEM if it runs out of memory as it tries to allocate data structures. Propagating only -EPROBE_DEFER is problematic because it results in these legitimately fatal errors being treated as "regulator not specified in DT".
What we really want is to ignore the optional regulators only if they have not been specified in DT. regulator_get_optional() returns -ENODEV in this case, so that's the special case that we need to handle. So we propagate all errors, except -ENODEV, so that real failures will still cause the driver to fail probe.
--- drivers/pci/controller/dwc/pci-imx6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +2 -2
@@ -1173,8 +1173,8 @@ static int imx6_pcie_probe(struct platform_device *pdev) imx6_pcie->vpcie =devm_regulator_get_optional (&pdev->dev,"vpcie" );if (IS_ERR (imx6_pcie->vpcie)) { -if (PTR_ERR (imx6_pcie->vpcie) == -EPROBE_DEFER ) -return -EPROBE_DEFER ; +if (PTR_ERR (imx6_pcie->vpcie) != -ENODEV ) +return PTR_ERR (imx6_pcie->vpcie); imx6_pcie->vpcie =NULL ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 27/42 PCI: exynos: Propagate errors for optional PHYs
In reply to Sasha LevinFrom: Thierry Reding <[email protected]>
[ Upstream commit ddd6960087d4b45759434146d681a94bbb1c54ad ]
devm_of_phy_get() can fail for a number of reasons besides probe deferral. It can for example return -ENOMEM if it runs out of memory as it tries to allocate devres structures. Propagating only -EPROBE_DEFER is problematic because it results in these legitimately fatal errors being treated as "PHY not specified in DT".
What we really want is to ignore the optional PHYs only if they have not been specified in DT. devm_of_phy_get() returns -ENODEV in this case, so that's the special case that we need to handle. So we propagate all errors, except -ENODEV, so that real failures will still cause the driver to fail probe.
--- drivers/pci/controller/dwc/pci-exynos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pci-exynos.c +1 -1
@@ -465,7 +465,7 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) ep->phy =devm_of_phy_get (dev, np,NULL );if (IS_ERR (ep->phy)) { -if (PTR_ERR (ep->phy) == -EPROBE_DEFER ) +if (PTR_ERR (ep->phy) != -ENODEV )return PTR_ERR (ep->phy); ep->phy =NULL ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 28/42 security: smack: Fix possible null-pointer dereferences in smack_socket_sock_rcv_skb()
In reply to Sasha LevinFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit 3f4287e7d98a2954f20bf96c567fdffcd2b63eb9 ]
In smack_socket_sock_rcv_skb(), there is an if statement on line 3920 to check whether skb is NULL:
if (skb && skb->secmark != 0)
This check indicates skb can be NULL in some cases.
But on lines 3931 and 3932, skb is used:
ad.a.u.net->netif = skb->skb_iif;
ipv6_skb_to_auditdata(skb, &ad.a, NULL);Thus, possible null-pointer dereferences may occur when skb is NULL.
To fix these possible bugs, an if statement is added to check skb.
These bugs are found by a static analysis tool STCheck written by us.
--- security/smack/smack_lsm.c | 2 ++ 1 file changed, 2 insertions(+)
security/smack/smack_lsm.c +2 -0
@@ -3925,6 +3925,8 @@ static int smack_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb) skp =smack_ipv6host_label (&sadd);if (skp ==NULL ) skp = smack_net_ambient; +if (skb ==NULL ) +break ;#ifdef CONFIG_AUDIT smk_ad_init_net (&ad, __func__,LSM_AUDIT_DATA_NET , &net); ad.a.u.net->family = family;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 29/42 PCI: Use static const struct, not const static struct
In reply to Sasha LevinFrom: Krzysztof Wilczynski <[email protected]>
[ Upstream commit 8050f3f6645ae0f7e4c1304593f6f7eb2ee7d85c ]
Move the static keyword to the front of declarations of pci_regs_behavior[] and pcie_cap_regs_behavior[], which resolves compiler warnings when building with "W=1":
drivers/pci/pci-bridge-emul.c:41:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]
const static struct pci_bridge_reg_behavior pci_regs_behavior[] = { ^
drivers/pci/pci-bridge-emul.c:176:1: warning: ‘static’ is not at beginning of declaration [-Wold-style-declaration]
const static struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = { ^
--- drivers/pci/pci-bridge-emul.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/pci-bridge-emul.c +2 -2
@@ -38,7 +38,7 @@ struct pci_bridge_reg_behavior {u32 rsvd; }; -const static struct pci_bridge_reg_behavior pci_regs_behavior[] = { +static const struct pci_bridge_reg_behavior pci_regs_behavior[] = { [PCI_VENDOR_ID /4 ] = { .ro = ~0 }, [PCI_COMMAND /4 ] = { .rw = (PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
@@ -173,7 +173,7 @@ const static struct pci_bridge_reg_behavior pci_regs_behavior[] = { }, }; -const static struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = { +static const struct pci_bridge_reg_behavior pcie_cap_regs_behavior[] = { [PCI_CAP_LIST_ID /4 ] = {/* * Capability ID, Next Capability Pointer and
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 30/42 ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit b0fe66cf095016e0b238374c10ae366e1f087d11 ]
Currently, multi_v7_defconfig + CONFIG_FUNCTION_TRACER fails to build with clang:
arm-linux-gnueabi-ld: kernel/softirq.o: in function `_local_bh_enable':
softirq.c:(.text+0x504): undefined reference to `mcount'
arm-linux-gnueabi-ld: kernel/softirq.o: in function `__local_bh_enable_ip':
softirq.c:(.text+0x58c): undefined reference to `mcount'
arm-linux-gnueabi-ld: kernel/softirq.o: in function `do_softirq':
softirq.c:(.text+0x6c8): undefined reference to `mcount'
arm-linux-gnueabi-ld: kernel/softirq.o: in function `irq_enter':
softirq.c:(.text+0x75c): undefined reference to `mcount'
arm-linux-gnueabi-ld: kernel/softirq.o: in function `irq_exit':
softirq.c:(.text+0x840): undefined reference to `mcount'
arm-linux-gnueabi-ld: kernel/softirq.o:softirq.c:(.text+0xa50): more undefined references to `mcount' follow
clang can emit a working mcount symbol, __gnu_mcount_nc, when '-meabi gnu' is passed to it. Until r369147 in LLVM, this was broken and caused the kernel not to boot with '-pg' because the calling convention was not correct. Always build with '-meabi gnu' when using clang but ensure that '-pg' (which is added with CONFIG_FUNCTION_TRACER and its prereq CONFIG_HAVE_FUNCTION_TRACER) cannot be added with it unless this is fixed (which means using clang 10.0.0 and newer).
--- arch/arm/Kconfig | 2 +- arch/arm/Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -75,7 +75,7 @@ config ARM select HAVE_EXIT_THREAD select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG - select HAVE_FUNCTION_TRACER if !XIP_KERNEL + select HAVE_FUNCTION_TRACER if !XIP_KERNEL && (CC_IS_GCC || CLANG_VERSION >= 100000) select HAVE_GCC_PLUGINS select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7) select HAVE_IDE if PCI || ISA || PCMCIA
arch/arm/Makefile +4 -0
@@ -112,6 +112,10 @@ ifeq ($(CONFIG_ARM_UNWIND),y) CFLAGS_ABI +=-funwind-tables endif +ifeq ($(CONFIG_CC_IS_CLANG),y) +CFLAGS_ABI += -meabi gnu +endif + # Accept old syntax despite ".syntax unified" AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 31/42 ARM: 8903/1: ensure that usable memory in bank 0 starts from a PMD-aligned address
In reply to Sasha LevinFrom: Mike Rapoport <[email protected]>
[ Upstream commit 00d2ec1e6bd82c0538e6dd3e4a4040de93ba4fef ]
The calculation of memblock_limit in adjust_lowmem_bounds() assumes that bank 0 starts from a PMD-aligned address. However, the beginning of the first bank may be NOMAP memory and the start of usable memory will be not aligned to PMD boundary. In such case the memblock_limit will be set to the end of the NOMAP region, which will prevent any memblock allocations.
Mark the region between the end of the NOMAP area and the next PMD-aligned address as NOMAP as well, so that the usable memory will start at PMD-aligned address.
--- arch/arm/mm/mmu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/arm/mm/mmu.c +16 -0
@@ -1177,6 +1177,22 @@ void __init adjust_lowmem_bounds(void)*/ vmalloc_limit = (u64 )(uintptr_t )vmalloc_min -PAGE_OFFSET +PHYS_OFFSET ; +/* +* The first usable region must be PMD aligned. Mark its start +* as MEMBLOCK_NOMAP if it isn't +*/ +for_each_memblock (memory, reg) { +if (!memblock_is_nomap (reg)) { +if (!IS_ALIGNED (reg->base,PMD_SIZE )) { +phys_addr_t len; + + len =round_up (reg->base,PMD_SIZE ) - reg->base; +memblock_mark_nomap (reg->base, len); + } +break ; + } + } +for_each_memblock (memory, reg) {phys_addr_t block_start = reg->base;phys_addr_t block_end = reg->base + reg->size;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 32/42 fat: work around race with userspace's read via blockdev while mounting
In reply to Sasha LevinFrom: OGAWA Hirofumi <[email protected]>
[ Upstream commit 07bfa4415ab607e459b69bd86aa7e7602ce10b4f ]
If userspace reads the buffer via blockdev while mounting, sb_getblk()+modify can race with buffer read via blockdev.
For example,
FS userspace
bh = sb_getblk()
modify bh->b_data
read
ll_rw_block(bh)
fill bh->b_data by on-disk data
/* lost modified data by FS */
set_buffer_uptodate(bh)
set_buffer_uptodate(bh)Userspace should not use the blockdev while mounting though, the udev seems to be already doing this. Although I think the udev should try to avoid this, workaround the race by small overhead.
--- fs/fat/dir.c | 13 +++++++++++-- fs/fat/fatent.c | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-)
fs/fat/dir.c +11 -2
@@ -1100,8 +1100,11 @@ static int fat_zeroed_cluster(struct inode *dir, sector_t blknr, int nr_used, err = -ENOMEM ; goto error; } +/* Avoid race with userspace read via bdev */ +lock_buffer (bhs[n]);memset (bhs[n]->b_data,0 , sb->s_blocksize);set_buffer_uptodate (bhs[n]); +unlock_buffer (bhs[n]);mark_buffer_dirty_inode (bhs[n], dir); n++;
@@ -1158,6 +1161,8 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec64 *ts)fat_time_unix2fat (sbi, ts, &time, &date, &time_cs); de = (struct msdos_dir_entry *)bhs[0 ]->b_data; +/* Avoid race with userspace read via bdev */ +lock_buffer (bhs[0 ]);/* filling the new directory slots ("." and ".." entries) */ memcpy (de[0 ].name,MSDOS_DOT ,MSDOS_NAME );memcpy (de[1 ].name,MSDOS_DOTDOT ,MSDOS_NAME );
@@ -1180,6 +1185,7 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec64 *ts) de[0 ].size = de[1 ].size =0 ;memset (de +2 ,0 , sb->s_blocksize -2 *sizeof (*de));set_buffer_uptodate (bhs[0 ]); +unlock_buffer (bhs[0 ]);mark_buffer_dirty_inode (bhs[0 ], dir); err =fat_zeroed_cluster (dir, blknr,1 , bhs,MAX_BUF_PER_PAGE );
@@ -1237,11 +1243,14 @@ static int fat_add_new_entries(struct inode *dir, void *slots, int nr_slots,/* fill the directory entry */ copy =min (size, sb->s_blocksize); +/* Avoid race with userspace read via bdev */ +lock_buffer (bhs[n]);memcpy (bhs[n]->b_data, slots, copy); - slots += copy; - size -= copy;set_buffer_uptodate (bhs[n]); +unlock_buffer (bhs[n]);mark_buffer_dirty_inode (bhs[n], dir); + slots += copy; + size -= copy;if (!size)break ; n++;
fs/fat/fatent.c +3 -0
@@ -388,8 +388,11 @@ static int fat_mirror_bhs(struct super_block *sb, struct buffer_head **bhs, err = -ENOMEM ; goto error; } +/* Avoid race with userspace read via bdev */ +lock_buffer (c_bh);memcpy (c_bh->b_data, bhs[n]->b_data, sb->s_blocksize);set_buffer_uptodate (c_bh); +unlock_buffer (c_bh);mark_buffer_dirty_inode (c_bh, sbi->fat_inode);if (sb->s_flags &SB_SYNCHRONOUS ) err =sync_dirty_buffer (c_bh);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 33/42 pktcdvd: remove warning on attempting to register non-passthrough dev
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit eb09b3cc464d2c3bbde9a6648603c8d599ea8582 ]
Anatoly reports that he gets the below warning when booting -git on a sparc64 box on debian unstable:
...
[ 13.352975] aes_sparc64: Using sparc64 aes opcodes optimized AES implementation [ 13.428002] ------------[ cut here ]------------ [ 13.428081] WARNING: CPU: 21 PID: 586 at drivers/block/pktcdvd.c:2597 pkt_setup_dev+0x2e4/0x5a0 [pktcdvd] [ 13.428147] Attempt to register a non-SCSI queue [ 13.428184] Modules linked in: pktcdvd libdes cdrom aes_sparc64
n2_rng md5_sparc64 sha512_sparc64 rng_core sha256_sparc64 flash sha1_sparc64 ip_tables x_tables ipv6 crc_ccitt nf_defrag_ipv6 autofs4 ext4 crc16 mbcache jbd2 raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor xor async_tx raid6_pq raid1 raid0 multipath linear md_mod crc32c_sparc64
[ 13.428452] CPU: 21 PID: 586 Comm: pktsetup Not tainted 5.3.0-10169-g574cc4539762 #1234 [ 13.428507] Call Trace: [ 13.428542] [00000000004635c0] __warn+0xc0/0x100 [ 13.428582] [0000000000463634] warn_slowpath_fmt+0x34/0x60 [ 13.428626] [000000001045b244] pkt_setup_dev+0x2e4/0x5a0 [pktcdvd] [ 13.428674] [000000001045ccf4] pkt_ctl_ioctl+0x94/0x220 [pktcdvd] [ 13.428724] [00000000006b95c8] do_vfs_ioctl+0x628/0x6e0 [ 13.428764] [00000000006b96c8] ksys_ioctl+0x48/0x80 [ 13.428803] [00000000006b9714] sys_ioctl+0x14/0x40 [ 13.428847] [0000000000406294] linux_sparc_syscall+0x34/0x44 [ 13.428890] irq event stamp: 4181 [ 13.428924] hardirqs last enabled at (4189): [<00000000004e0a74>] console_unlock+0x634/0x6c0 [ 13.428984] hardirqs last disabled at (4196): [<00000000004e0540>] console_unlock+0x100/0x6c0 [ 13.429048] softirqs last enabled at (3978): [<0000000000b2e2d8>] __do_softirq+0x498/0x520 [ 13.429110] softirqs last disabled at (3967): [<000000000042cfb4>] do_softirq_own_stack+0x34/0x60 [ 13.429172] ---[ end trace 2220ca468f32967d ]--- [ 13.430018] pktcdvd: setup of pktcdvd device failed [ 13.455589] des_sparc64: Using sparc64 des opcodes optimized DES implementation [ 13.515334] camellia_sparc64: Using sparc64 camellia opcodes optimized CAMELLIA implementation [ 13.522856] pktcdvd: setup of pktcdvd device failed [ 13.529327] pktcdvd: setup of pktcdvd device failed [ 13.532932] pktcdvd: setup of pktcdvd device failed [ 13.536165] pktcdvd: setup of pktcdvd device failed [ 13.539372] pktcdvd: setup of pktcdvd device failed [ 13.542834] pktcdvd: setup of pktcdvd device failed [ 13.546536] pktcdvd: setup of pktcdvd device failed [ 15.431071] XFS (dm-0): Mounting V5 Filesystem
...
Apparently debian auto-attaches any cdrom like device to pktcdvd, which can lead to the above warning. There's really no reason to warn for this situation, kill it.
--- drivers/block/pktcdvd.c | 1 - 1 file changed, 1 deletion(-)
drivers/block/pktcdvd.c +0 -1
@@ -2594,7 +2594,6 @@ static int pkt_new_dev(struct pktcdvd_device *pd, dev_t dev)if (ret)return ret;if (!blk_queue_scsi_passthrough (bdev_get_queue (bdev))) { -WARN_ONCE (true,"Attempt to register a non-SCSI queue\n" );blkdev_put (bdev,FMODE_READ |FMODE_NDELAY );return -EINVAL ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 34/42 hypfs: Fix error number left in struct pointer member
In reply to Sasha LevinFrom: David Howells <[email protected]>
[ Upstream commit b54c64f7adeb241423cd46598f458b5486b0375e ]
In hypfs_fill_super(), if hypfs_create_update_file() fails, sbi->update_file is left holding an error number. This is passed to hypfs_kill_super() which doesn't check for this.
Fix this by not setting sbi->update_value until after we've checked for error.
--- arch/s390/hypfs/inode.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/s390/hypfs/inode.c +5 -4
@@ -269,7 +269,7 @@ static int hypfs_show_options(struct seq_file *s, struct dentry *root)static int hypfs_fill_super (struct super_block *sb,void *data,int silent) {struct inode *root_inode; -struct dentry *root_dentry; +struct dentry *root_dentry, *update_file;int rc =0 ;struct hypfs_sb_info *sbi;
@@ -300,9 +300,10 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent) rc =hypfs_diag_create_files (root_dentry);if (rc)return rc; - sbi->update_file =hypfs_create_update_file (root_dentry); -if (IS_ERR (sbi->update_file)) -return PTR_ERR (sbi->update_file); + update_file =hypfs_create_update_file (root_dentry); +if (IS_ERR (update_file)) +return PTR_ERR (update_file); + sbi->update_file = update_file;hypfs_update_update (sb);pr_info ("Hypervisor filesystem mounted\n" );return 0 ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 35/42 crypto: hisilicon - Fix double free in sec_free_hw_sgl()
In reply to Sasha LevinFrom: Yunfeng Ye <[email protected]>
[ Upstream commit 24fbf7bad888767bed952f540ac963bc57e47e15 ]
There are two problems in sec_free_hw_sgl():
First, when sgl_current->next is valid, @hw_sgl will be freed in the first loop, but it free again after the loop.
Second, sgl_current and sgl_current->next_sgl is not match when dma_pool_free() is invoked, the third parameter should be the dma address of sgl_current, but sgl_current->next_sgl is the dma address of next chain, so use sgl_current->next_sgl is wrong.
Fix this by deleting the last dma_pool_free() in sec_free_hw_sgl(), modifying the condition for while loop, and matching the address for dma_pool_free().
--- drivers/crypto/hisilicon/sec/sec_algs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/crypto/hisilicon/sec/sec_algs.c +7 -6
@@ -215,17 +215,18 @@ static void sec_free_hw_sgl(struct sec_hw_sgl *hw_sgl, dma_addr_t psec_sgl, struct sec_dev_info *info) { struct sec_hw_sgl *sgl_current, *sgl_next; +dma_addr_t sgl_next_dma; -if (!hw_sgl) -return ; sgl_current = hw_sgl; -while (sgl_current->next) { +while (sgl_current) { sgl_next = sgl_current->next; -dma_pool_free (info->hw_sgl_pool, sgl_current, - sgl_current->next_sgl); + sgl_next_dma = sgl_current->next_sgl; + +dma_pool_free (info->hw_sgl_pool, sgl_current, psec_sgl); + sgl_current = sgl_next; + psec_sgl = sgl_next_dma; } -dma_pool_free (info->hw_sgl_pool, hw_sgl, psec_sgl); } static int sec_alg_skcipher_setkey(struct crypto_skcipher *tfm,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 36/42 kbuild: clean compressed initramfs image
In reply to Sasha LevinFrom: Greg Thelen <[email protected]>
[ Upstream commit 6279eb3dd7946c69346a3b98473ed13d3a44adb5 ]
Since 9e3596b0c653 ("kbuild: initramfs cleanup, set target from Kconfig") "make clean" leaves behind compressed initramfs images. Example:
$ make defconfig $ sed -i 's|CONFIG_INITRAMFS_SOURCE=""|CONFIG_INITRAMFS_SOURCE="/tmp/ir.cpio"|' .config $ make olddefconfig $ make -s $ make -s clean $ git clean -ndxf | grep initramfs Would remove usr/initramfs_data.cpio.gz
clean rules do not have CONFIG_* context so they do not know which compression format was used. Thus they don't know which files to delete.
Tell clean to delete all possible compression formats.
Once patched usr/initramfs_data.cpio.gz and friends are deleted by "make clean".
--- usr/Makefile | 3 +++ 1 file changed, 3 insertions(+)
usr/Makefile +3 -0
@@ -11,6 +11,9 @@ datafile_y = initramfs_data.cpio$(suffix_y) datafile_d_y = .$(datafile_y).d AFLAGS_initramfs_data.o += -DINITRAMFS_IMAGE="usr/$(datafile_y)" +# clean rules do not have CONFIG_INITRAMFS_COMPRESSION. So clean up after all +# possible compression formats. +clean-files += initramfs_data.cpio* # Generate builtin.o based on initramfs_data.o obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data.o
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 37/42 ocfs2: wait for recovering done after direct unlock request
In reply to Sasha LevinFrom: Changwei Ge <[email protected]>
[ Upstream commit 0a3775e4f883912944481cf2ef36eb6383a9cc74 ]
There is a scenario causing ocfs2 umount hang when multiple hosts are rebooting at the same time.
NODE1 NODE2 NODE3
send unlock requset to NODE2
dies
become recovery master recover NODE2
find NODE2 dead
mark resource RECOVERING
directly remove lock from grant list
calculate usage but RECOVERING marked
**miss the window of purging
clear RECOVERING
To reproduce this issue, crash a host and then umount ocfs2 from another node.
To solve this, just let unlock progress wait for recovery done.
--- fs/ocfs2/dlm/dlmunlock.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
fs/ocfs2/dlm/dlmunlock.c +19 -4
@@ -90,7 +90,8 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,enum dlm_status status;int actions =0 ;int in_use; -u8 owner; +u8 owner; +int recovery_wait =0 ;mlog (0 ,"master_node = %d, valblk = %d\n" , master_node, flags &LKM_VALBLK );
@@ -193,9 +194,12 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, }if (flags &LKM_CANCEL ) lock->cancel_pending =0 ; -else - lock->unlock_pending =0 ; - +else { +if (!lock->unlock_pending) + recovery_wait =1 ; +else + lock->unlock_pending =0 ; + } }/* get an extra ref on lock. if we are just switching
@@ -229,6 +233,17 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,spin_unlock (&res->spinlock);wake_up (&res->wq); +if (recovery_wait) { +spin_lock (&res->spinlock); +/* Unlock request will directly succeed after owner dies, +* and the lock is already removed from grant list. We have to +* wait for RECOVERING done or we miss the chance to purge it +* since the removement is much faster than RECOVERING proc. +*/ +__dlm_wait_on_lockres_flags (res,DLM_LOCK_RES_RECOVERING ); +spin_unlock (&res->spinlock); + } +/* let the caller's final dlm_lock_put handle the actual kfree */ if (actions &DLM_UNLOCK_FREE_LOCK ) {/* this should always be coupled with list removal */
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 38/42 kmemleak: increase DEBUG_KMEMLEAK_EARLY_LOG_SIZE default to 16K
In reply to Sasha LevinFrom: Nicolas Boichat <[email protected]>
[ Upstream commit b751c52bb587ae66f773b15204ef7a147467f4c7 ]
The current default value (400) is too low on many systems (e.g. some ARM64 platform takes up 1000+ entries).
syzbot uses 16000 as default value, and has proved to be enough on beefy configurations, so let's pick that value.
This consumes more RAM on boot (each entry is 160 bytes, so in total ~2.5MB of RAM), but the memory would later be freed (early_log is __initdata).
--- lib/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/Kconfig.debug +1 -1
@@ -599,7 +599,7 @@ config DEBUG_KMEMLEAK_EARLY_LOG_SIZE int "Maximum kmemleak early log entries" depends on DEBUG_KMEMLEAK range 200 40000 - default 400 + default 16000 help Kmemleak must track all the memory allocations to avoid reporting false positives. Since memory may be allocated or
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 39/42 arm64: consider stack randomization for mmap base only when necessary
In reply to Sasha LevinFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit e8d54b62c55ab6201de6d195fc2c276294c1f6ae ]
Do not offset mmap base address because of stack randomization if current task does not want randomization. Note that x86 already implements this behaviour.
--- arch/arm64/mm/mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm64/mm/mmap.c +5 -1
@@ -54,7 +54,11 @@ unsigned long arch_mmap_rnd(void)static unsigned long mmap_base (unsigned long rnd,struct rlimit *rlim_stack) {unsigned long gap = rlim_stack->rlim_cur; -unsigned long pad = (STACK_RND_MASK <<PAGE_SHIFT ) + stack_guard_gap; +unsigned long pad = stack_guard_gap; + +/* Account for stack randomization if necessary */ +if (current->flags &PF_RANDOMIZE ) + pad += (STACK_RND_MASK <<PAGE_SHIFT );/* Values close to RLIM_INFINITY can overflow. */ if (gap + pad > gap)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 40/42 mips: properly account for stack randomization and stack guard gap
In reply to Sasha LevinFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit b1f61b5bde3a1f50392c97b4c8513d1b8efb1cf2 ]
This commit takes care of stack randomization and stack guard gap when computing mmap base address and checks if the task asked for randomization. This fixes the problem uncovered and not fixed for arm
here: https://lkml.kernel.org/r/[email protected]
--- arch/mips/mm/mmap.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/mips/mm/mmap.c +12 -2
@@ -21,8 +21,9 @@ unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */EXPORT_SYMBOL (shm_align_mask);/* gap between mmap and stack */ -#define MIN_GAP (128*1024*1024UL) -#define MAX_GAP ((TASK_SIZE)/6*5) +#define MIN_GAP (128*1024*1024UL) +#define MAX_GAP ((TASK_SIZE)/6*5) +#define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12))static int mmap_is_legacy (struct rlimit *rlim_stack) {
@@ -38,6 +39,15 @@ static int mmap_is_legacy(struct rlimit *rlim_stack)static unsigned long mmap_base (unsigned long rnd,struct rlimit *rlim_stack) {unsigned long gap = rlim_stack->rlim_cur; +unsigned long pad = stack_guard_gap; + +/* Account for stack randomization if necessary */ +if (current->flags &PF_RANDOMIZE ) + pad += (STACK_RND_MASK <<PAGE_SHIFT ); + +/* Values close to RLIM_INFINITY can overflow. */ +if (gap + pad > gap) + gap += pad;if (gap <MIN_GAP ) gap =MIN_GAP ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 41/42 arm: properly account for stack randomization and stack guard gap
In reply to Sasha LevinFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit af0f4297286f13a75edf93677b1fb2fc16c412a7 ]
This commit takes care of stack randomization and stack guard gap when computing mmap base address and checks if the task asked for randomization. This fixes the problem uncovered and not fixed for arm
here: https://lkml.kernel.org/r/[email protected]
--- arch/arm/mm/mmap.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
arch/arm/mm/mmap.c +12 -2
@@ -18,8 +18,9 @@ (((pgoff)<<PAGE_SHIFT) & (SHMLBA-1)))/* gap between mmap and stack */ -#define MIN_GAP (128*1024*1024UL) -#define MAX_GAP ((TASK_SIZE)/6*5) +#define MIN_GAP (128*1024*1024UL) +#define MAX_GAP ((TASK_SIZE)/6*5) +#define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12))static int mmap_is_legacy (struct rlimit *rlim_stack) {
@@ -35,6 +36,15 @@ static int mmap_is_legacy(struct rlimit *rlim_stack)static unsigned long mmap_base (unsigned long rnd,struct rlimit *rlim_stack) {unsigned long gap = rlim_stack->rlim_cur; +unsigned long pad = stack_guard_gap; + +/* Account for stack randomization if necessary */ +if (current->flags &PF_RANDOMIZE ) + pad += (STACK_RND_MASK <<PAGE_SHIFT ); + +/* Values close to RLIM_INFINITY can overflow. */ +if (gap + pad > gap) + gap += pad;if (gap <MIN_GAP ) gap =MIN_GAP ;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 42/42 arm: use STACK_TOP when computing mmap base address
In reply to Sasha LevinFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit 86e568e9c0525fc40e76d827212d5e9721cf7504 ]
mmap base address must be computed wrt stack top address, using TASK_SIZE is wrong since STACK_TOP and TASK_SIZE are not equivalent.
--- arch/arm/mm/mmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mm/mmap.c +2 -2
@@ -19,7 +19,7 @@/* gap between mmap and stack */ #define MIN_GAP (128*1024*1024UL) -#define MAX_GAP ((TASK_SIZE)/6*5) +#define MAX_GAP ((STACK_TOP)/6*5)#define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12))static int mmap_is_legacy (struct rlimit *rlim_stack)
@@ -51,7 +51,7 @@ static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack)else if (gap >MAX_GAP ) gap =MAX_GAP ; -return PAGE_ALIGN (TASK_SIZE - gap - rnd); +return PAGE_ALIGN (STACK_TOP - gap - rnd); }/*
Signature · 1 line
2.20.1