Re: [ANNOUNCE] 4.19.132-rt59

2020-07-14 Thread Steven Rostedt
On Tue, 14 Jul 2020 20:35:12 +0200
Pavel Machek  wrote:

> Hi!
> 
> > 
> > I'm pleased to announce the 4.19.132-rt59 stable release.
> > 
> > This release is just an update to the new stable 4.19.132
> > version and no RT specific changes have been made.
> > 
> > You can get this release via the git tree at:
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-rt.git
> > 
> >   branch: v4.19-rt
> >   Head SHA1: 1eebf4069aa37e54330cce9a42608517ea6996fe
> > 
> > Or to build 4.19.132-rt59 directly, the following patches should be
> > applied:  
> 
> Thanks a lot.
> 
> But now I am confused, I completely missed announcements for
> v4.19.127-rt55 to v4.19.131-rt58.
> 
> And for example -rt56 is not listed in
> 
> https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.19/older/sha256sums.asc
> 
> ...aha, and the versions do not have signed tags, either:
> 
> pavel@amd:~/cip/k$ git show v4.19.131-rt58
> fatal: ambiguous argument 'v4.19.131-rt58': unknown revision or path not in 
> the working tree.
> 
> Is that because they were created just as quick steps towards -rt59?
>

Ah, I was about to say this is something that Kate keeps reminding me
to add to the wiki, but looking, I already did!

https://wiki.linuxfoundation.org/realtime/documentation/start

"Tagging policy of the PREEMPT_RT stable releases. Each PREEMPT_RT
stable release is tagged with the version number of the upstream Linux
stable kernel as well as its own “-rt” counter that is appended. The
-rt counter will increment for the following:

 - When forward ported to the latest upstream Linux stable version.
 - When any merge with a upstream Linux stable causes a conflict.
 - When a backport of the PREEMPT_RT development branch is done.

A backport will not be done with a forward port of a stable version.
They will be done separately, and tagged separately."

Tom, I sign all tags, we probably should be consistent with that too.

-- Steve


[PATCH 4/4] ixgbe/ixgbe_ethtool.c: Remove unnecessary usages of memset.

2020-07-14 Thread Suraj Upadhyay
Replace memsets of 1 byte with simple assignment.
Issue found with checkpatch.pl

Signed-off-by: Suraj Upadhyay 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 6725d892336e..71ec908266a6 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1951,8 +1951,8 @@ static void ixgbe_create_lbtest_frame(struct sk_buff *skb,
memset(skb->data, 0xFF, frame_size);
frame_size >>= 1;
memset(&skb->data[frame_size], 0xAA, frame_size / 2 - 1);
-   memset(&skb->data[frame_size + 10], 0xBE, 1);
-   memset(&skb->data[frame_size + 12], 0xAF, 1);
+   skb->data[frame_size + 10] = 0xBE;
+   skb->data[frame_size + 12] = 0xAF;
 }
 
 static bool ixgbe_check_lbtest_frame(struct ixgbe_rx_buffer *rx_buffer,
-- 
2.17.1



signature.asc
Description: PGP signature


Re: [merged][PATCH v3 00/16] Make the user mode driver code a better citizen

2020-07-14 Thread Alexei Starovoitov
On Thu, Jul 09, 2020 at 05:05:09PM -0500, Eric W. Biederman wrote:
> 
> I have merged all of this into my exec-next tree.
> 
> The code is also available on the frozen branch:
> 
>git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git 
> usermode-driver-cleanup
> 
> Declaring this set of changes done now, allows the work that depends
> upon this change to proceed.

Now I've pulled it into bpf-next as well.
In the mean time there were changes to kernel_write that broke bpfilter.ko
I fixed it up as well.
Thanks.


[PATCH 2/4] e1000e/ethtool.c : Remove unnecessary usages of memset.

2020-07-14 Thread Suraj Upadhyay
Replace memsets of 1 byte with simple assignments.
Issue found with checkpatch.pl

Signed-off-by: Suraj Upadhyay 
---
 drivers/net/ethernet/intel/e1000e/ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c 
b/drivers/net/ethernet/intel/e1000e/ethtool.c
index 64f684dc6c7a..a8fc9208382c 100644
--- a/drivers/net/ethernet/intel/e1000e/ethtool.c
+++ b/drivers/net/ethernet/intel/e1000e/ethtool.c
@@ -1608,8 +1608,8 @@ static void e1000_create_lbtest_frame(struct sk_buff *skb,
memset(skb->data, 0xFF, frame_size);
frame_size &= ~1;
memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
-   memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
-   memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
+   skb->data[frame_size / 2 + 10] = 0xBE;
+   skb->data[frame_size / 2 + 12] = 0xAF;
 }
 
 static int e1000_check_lbtest_frame(struct sk_buff *skb,
-- 
2.17.1



signature.asc
Description: PGP signature


Re: [RFC PATCH 12/15] kmap: Add stray write protection for device pages

2020-07-14 Thread Dave Hansen
On 7/14/20 12:29 PM, Peter Zijlstra wrote:
> On Tue, Jul 14, 2020 at 12:06:16PM -0700, Ira Weiny wrote:
>> On Tue, Jul 14, 2020 at 10:44:51AM +0200, Peter Zijlstra wrote:
>>> So, if I followed along correctly, you're proposing to do a WRMSR per
>>> k{,un}map{_atomic}(), sounds like excellent performance all-round :-(
>> Only to pages which have this additional protection, ie not DRAM.
>>
>> User mappings of this memory is not affected (would be covered by User PKeys 
>> if
>> desired).  User mappings to persistent memory are the primary use case and 
>> the
>> performant path.
> Because performance to non-volatile memory doesn't matter? I think Dave
> has a better answer here ...

So, these WRMSRs are less evil than normal.  They're architecturally
non-serializing instructions, just like the others in the SDM WRMSR
documentation:

Note that WRMSR to the IA32_TSC_DEADLINE MSR (MSR index 6E0H)
and the X2APIC MSRs (MSR indices 802H to 83FH) are  not
serializing.

This section of the SDM needs to be updated for the PKRS.  Also note
that the PKRS WRMSR is similar in its ordering properties to WRPKRU:

WRPKRU will never execute speculatively. Memory accesses
affected by PKRU register will not execute (even speculatively)
until all prior executions of WRPKRU have completed execution
and updated the PKRU register.

Which means we don't have to do silliness like LFENCE before WRMSR to
get ordering *back*.  This is another tidbit that needs to get added to
the SDM.  It should probably also get captured in the changelog.

But, either way, this *will* make accessing PMEM more expensive from the
kernel.  No escaping that.  But, we've also got customers saying they
won't deploy PMEM until we mitigate this stray write issue.  Those folks
are quite willing to pay the increased in-kernel cost for increased
protection from stray kernel writes.  Intel is also quite motivated
because we really like increasing the number of PMEM deployments. :)

Ira, can you make sure this all gets pulled into the changelogs somewhere?


[PATCH 3/4] igb/igb_ethtool.c : Remove unnecessary usages of memset.

2020-07-14 Thread Suraj Upadhyay
Replace memsets of 1 byte with simple assignment.
Issue found with checkpatch.pl

Signed-off-by: Suraj Upadhyay 
---
 drivers/net/ethernet/intel/igb/igb_ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c 
b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index c2cf414d126b..6e8231c1ddf0 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -1782,8 +1782,8 @@ static void igb_create_lbtest_frame(struct sk_buff *skb,
memset(skb->data, 0xFF, frame_size);
frame_size /= 2;
memset(&skb->data[frame_size], 0xAA, frame_size - 1);
-   memset(&skb->data[frame_size + 10], 0xBE, 1);
-   memset(&skb->data[frame_size + 12], 0xAF, 1);
+   skb->data[frame_size + 10] = 0xBE;
+   skb->data[frame_size + 12] = 0xAF;
 }
 
 static int igb_check_lbtest_frame(struct igb_rx_buffer *rx_buffer,
-- 
2.17.1



signature.asc
Description: PGP signature


Re: [PATCH] OPENRISC ARCHITECTURE: Replace HTTP links with HTTPS ones

2020-07-14 Thread Stafford Horne
On Tue, Jul 14, 2020 at 07:30:38PM +0200, Geert Uytterhoeven wrote:
> On Tue, Jul 14, 2020 at 3:40 PM Jonathan Corbet  wrote:
> > On Tue, 14 Jul 2020 09:22:39 +0200
> > Geert Uytterhoeven  wrote:
> > > > > - website http://openrisc.io
> > > > > + website https://openrisc.io
> > > > >   email   openr...@lists.librecores.org
> > > > >   === =
> > > >
> > > > Applied, thanks.
> > >
> > > Is that site accessible for anyone? It times out for me.
> >
> > Works for me.
> 
> Now it indeed does.

Thanks for checking,

There was an issue with our server hardware that hosts https://openrisc.io as
well as other FOSSI sites including https://www.librecores.org and
https://fossi-foundation.org.

We migrated these all to different infrastructure (github pages) to fix the
issue.  They should be more stable now.

-Stafford


Regression: squashfs issues since change "squashfs: migrate from ll_rw_block usage to BIO"

2020-07-14 Thread Bernd Amend
Hi,

With the Linux Kernel version 5.8-rc5/master I am unable to mount some
squashfs filesystems compressed with "-comp lz4".
If I try to mount them I get the following error:
[1.084246] SQUASHFS error: lz4 decompression failed, data probably corrupt
[1.084545] SQUASHFS error: Failed to read block 0x873e1001: -5
[1.084761] SQUASHFS error: Unable to read metadata cache entry [873e0fff]
[1.084983] SQUASHFS error: Unable to read directory block [873e0fff:1586]
[1.122564] SQUASHFS error: Unable to read metadata cache entry [873e0fff]
[1.122708] SQUASHFS error: Unable to read directory block [873e0fff:1586]
[1.122862] Starting init: /sbin/init exists but couldn't execute
it (error -5)
[1.123027] SQUASHFS error: Unable to read metadata cache entry [873e0fff]
[1.123152] SQUASHFS error: Unable to read directory block [873e0fff:1586]
[1.123279] Starting init: /etc/init exists but couldn't execute it
(error -5)
[1.123444] SQUASHFS error: Unable to read metadata cache entry [873e0fff]
[1.123573] SQUASHFS error: Unable to read directory block [873e0fff:1586]
[1.123713] Starting init: /bin/init exists but couldn't execute it
(error -5)
[1.123900] SQUASHFS error: Unable to read metadata cache entry [873e0fff]

or

[ 4960.910693] attempt to access beyond end of device
[ 4960.910695] loop0: rw=2048, want=46, limit=40
[ 4960.910696] SQUASHFS error: Failed to read block 0x4001: -5
[ 4960.910697] SQUASHFS error: Unable to read metadata cache entry [3fff]
[ 4960.910698] SQUASHFS error: Unable to read inode 0x20c5000c

I bisected the issue to the commit "squashfs: migrate from ll_rw_block
usage to BIO"
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/fs/squashfs?id=93e72b3c612adcaca13d874fcc86c53e6c8da541

The issue can be reproduced by downloading
https://theworldsend.eu/demo.squashfs (20K) and the following command
line.
# mount demo.squashfs mnt && ls mnt && umount mnt

The same squashfs can be mounted using Linux <=5.7.8.
The kernel config is identical to the Arch Linux Kernel configuration,
build using gcc 9 and 10 on x86_64.

Best regards,
Bernd Amend


Re: [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library

2020-07-14 Thread Alexei Starovoitov
On Wed, Jul 1, 2020 at 10:50 AM Masahiro Yamada  wrote:
>
> On Thu, Jul 2, 2020 at 2:46 AM Alexei Starovoitov
>  wrote:
> >
> > On Wed, Jul 01, 2020 at 06:26:44PM +0900, Masahiro Yamada wrote:
> > > Originally, bpfilter_umh was linked with -static only when
> > > CONFIG_BPFILTER_UMH=y.
> > >
> > > Commit 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build
> > > bpfilter_umh") silently, accidentally dropped the CONFIG_BPFILTER_UMH=y
> > > test in the Makefile. Revive it in order to link it dynamically when
> > > CONFIG_BPFILTER_UMH=m.
> > >
> > > Since commit b1183b6dca3e ("bpfilter: check if $(CC) can link static
> > > libc in Kconfig"), the compiler must be capable of static linking to
> > > enable CONFIG_BPFILTER_UMH, but it requires more than needed.
> > >
> > > To loosen the compiler requirement, I changed the dependency as follows:
> > >
> > > depends on CC_CAN_LINK
> > > depends on m || CC_CAN_LINK_STATIC
> > >
> > > If CONFIG_CC_CAN_LINK_STATIC in unset, CONFIG_BPFILTER_UMH is restricted
> > > to 'm' or 'n'.
> > >
> > > In theory, CONFIG_CC_CAN_LINK is not required for CONFIG_BPFILTER_UMH=y,
> > > but I did not come up with a good way to describe it.
> > >
> > > Fixes: 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build 
> > > bpfilter_umh")
> > > Reported-by: Michal Kubecek 
> > > Signed-off-by: Masahiro Yamada 
> >
> > lgtm
> > Do you mind I'll take it into bpf-next tree?
> > Eric is working on a bunch of patches in this area. I'll take his set
> > into bpf-next as well and then can apply this patch.
> > Just to make sure there are no conflicts.
>
> Please go ahead.

I've merged Eric's set and applied yours on top.
Thanks


[PATCH 1/4] e1000/e1000_ethtool.c: Remove unnecessary usages of memset

2020-07-14 Thread Suraj Upadhyay
Replace memsets of 1 byte with simple assignments.
Issue reported by checkpatch.pl.

Signed-off-by: Suraj Upadhyay 
---
 drivers/net/ethernet/intel/e1000/e1000_ethtool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c 
b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
index 0b4196d2cdd4..f976e9daa3d8 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
@@ -1356,8 +1356,8 @@ static void e1000_create_lbtest_frame(struct sk_buff *skb,
memset(skb->data, 0xFF, frame_size);
frame_size &= ~1;
memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
-   memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
-   memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
+   skb->data[frame_size / 2 + 10] = 0xBE;
+   skb->data[frame_size / 2 + 12] = 0xAF;
 }
 
 static int e1000_check_lbtest_frame(const unsigned char *data,
-- 
2.17.1



signature.asc
Description: PGP signature


Re: [RFC PATCH 11/15] memremap: Add zone device access protection

2020-07-14 Thread Peter Zijlstra
On Tue, Jul 14, 2020 at 12:10:47PM -0700, Ira Weiny wrote:
> On Tue, Jul 14, 2020 at 10:40:57AM +0200, Peter Zijlstra wrote:

> > That's an anti-pattern vs static_keys, I'm thinking you actually want
> > static_key_slow_{inc,dec}() instead of {enable,disable}().
> 
> Thanks.  I'll go read the doc for those as I'm not familiar with them.

Look for static_branch_{inc,dec} in include/linux/jump_label.h, it
basically does the refcount thing you need and does the actual
transition on the 0->1 and 1->0 transitions.


[PATCH] CREDITS: remove link: http://www.cs.helsinki.fi/u/penberg/

2020-07-14 Thread Alexander A. Klimov
Rationale:
A completely white page with an empty .

Signed-off-by: Alexander A. Klimov 
---
 Yes, I noted that some of the links removed by these "CREDITS: remove link:"
 patches have email addresses with the same domain nearby.

 Don't worry, I'll take care of them together with all other
 dead email addresses - but not right now.


 CREDITS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CREDITS b/CREDITS
index 0787b5872906..3da11da81152 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1063,7 +1063,6 @@ S: Sweden
 
 N: Pekka Enberg
 E: penb...@cs.helsinki.fi
-W: http://www.cs.helsinki.fi/u/penberg/
 D: Various kernel hacks, fixes, and cleanups.
 D: Slab allocators
 S: Finland
-- 
2.27.0



Re: [git pull] Input updates for v5.8-rc5

2020-07-14 Thread pr-tracker-bot
The pull request you sent on Mon, 13 Jul 2020 17:53:32 -0700:

> git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/e9919e11e219eaa5e8041b7b1a196839143e9125

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [PATCH v2] hwmon: (drivetemp) Avoid SCT usage on Toshiba DT01ACA family drives

2020-07-14 Thread Guenter Roeck
On 7/14/20 10:47 AM, Maciej S. Szmigiero wrote:
> On 14.07.2020 19:14, Guenter Roeck wrote:
>> On 7/14/20 7:11 AM, Maciej S. Szmigiero wrote:
>>> On 14.07.2020 16:02, Guenter Roeck wrote:
 On 7/11/20 1:41 PM, Maciej S. Szmigiero wrote:
> It has been observed that Toshiba DT01ACA family drives have
> WRITE FPDMA QUEUED command timeouts and sometimes just freeze until
> power-cycled under heavy write loads when their temperature is getting
> polled in SCT mode. The SMART mode seems to be fine, though.
>
> Let's make sure we don't use SCT mode for these drives then.
>
> While only the 3 TB model was actually caught exhibiting the problem let's
> play safe here to avoid data corruption and extend the ban to the whole
> family.
>
> Fixes: 5b46903d8bf3 ("hwmon: Driver for disk and solid state drives with 
> temperature sensors")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Maciej S. Szmigiero 
> ---
>
> Notes:
> This behavior was observed on two different DT01ACA3 drives.
> 
> Usually, a series of queued WRITE FPDMA QUEUED commands just time out,
> but sometimes the whole drive freezes. Merely disconnecting and
> reconnecting SATA interface cable then does not unfreeze the drive.
> 
> One has to disconnect and reconnect the drive power connector for the
> drive to be detected again (suggesting the drive firmware itself has
> crashed).
> 
> This only happens when the drive temperature is polled very often 
> (like
> every second), so occasional SCT usage via smartmontools is probably
> safe.
> 
> Changes from v1:
> 'SCT blacklist' -> 'SCT avoid models'
>
>  drivers/hwmon/drivetemp.c | 37 +
>  1 file changed, 37 insertions(+)
>
> diff --git a/drivers/hwmon/drivetemp.c b/drivers/hwmon/drivetemp.c
> index 0d4f3d97ffc6..da9cfcbecc96 100644
> --- a/drivers/hwmon/drivetemp.c
> +++ b/drivers/hwmon/drivetemp.c
> @@ -285,6 +285,36 @@ static int drivetemp_get_scttemp(struct 
> drivetemp_data *st, u32 attr, long *val)
>   return err;
>  }
>  
> +static const char * const sct_avoid_models[] = {
> +/*
> + * These drives will have WRITE FPDMA QUEUED command timeouts and 
> sometimes just
> + * freeze until power-cycled under heavy write loads when their 
> temperature is
> + * getting polled in SCT mode. The SMART mode seems to be fine, though.
> + *
> + * While only the 3 TB model was actually caught exhibiting the problem
> + * let's play safe here to avoid data corruption and ban the whole 
> family.
> + */
> + "TOSHIBA DT01ACA0",
> + "TOSHIBA DT01ACA1",
> + "TOSHIBA DT01ACA2",
> + "TOSHIBA DT01ACA3",
> +};
> +
> +static bool drivetemp_sct_avoid(struct drivetemp_data *st)
> +{
> + struct scsi_device *sdev = st->sdev;
> + unsigned int ctr;
> +
> + if (!sdev->model)
> + return false;
> +
> + for (ctr = 0; ctr < ARRAY_SIZE(sct_avoid_models); ctr++)
> + if (strncmp(sdev->model, sct_avoid_models[ctr], 16) == 0)

 Why strncmp, and why length 16 ? Both strings are, as far as I can see,
 0 terminated. A fixed length only asks for trouble later on as more models
 are added to the list.
>>>
>>> The first 16 bytes of sdev->model contain the model number, the rest
>>> seems to be the drive serial number.
>>> There is no NULL separator between them.
>>>
>>
>> If the "16" is based on some SCSI standard, there should be
>> a define for it somewhere. 
> 
> The "model" field seems to contain just the raw SCSI INQUIRY
> "product identification" field, which is space-filled to 16 bytes, but
> is not NULL-terminated.
> 
> The SCSI layer seems to just open-code the number 16 everywhere, can't
> see any specific define for this.
> 
>> Otherwise, the comparison should
>> use strlen(sct_avoid_models[ctr]) and explain the reason.
>> In the latter case, it might possibly make sense to match
>> "TOSHIBA DT01ACA" to also catch later models.
> 
> Will use strlen() for prefix matching and match on the
> "TOSHIBA DT01ACA" prefix then.
> 
sgtm

Thanks,
Guenter



[PATCH] CREDITS: remove link: http://www.andante.org

2020-07-14 Thread Alexander A. Klimov
Rationale:
A completely white page with just an  in the .

Signed-off-by: Alexander A. Klimov 
---
 Yes, I noted that some of the links removed by these "CREDITS: remove link:"
 patches have email addresses with the same domain nearby.

 Don't worry, I'll take care of them together with all other
 dead email addresses - but not right now.


 CREDITS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CREDITS b/CREDITS
index 0787b5872906..ed58df9db15b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -4113,7 +4113,6 @@ S: Japan
 
 N: Eric Youngdale
 E: e...@andante.org
-W: http://www.andante.org
 D: General kernel hacker
 D: SCSI iso9660 and ELF
 S: 6389 Hawk View Lane
-- 
2.27.0



[PATCH] CREDITS: remove link http://www.mathematik.uni-stuttgart.de/~floeff

2020-07-14 Thread Alexander A. Klimov
Rationale:
The way it redirects looks like a fallback from a dead URL to a generic one.

Signed-off-by: Alexander A. Klimov 
---
 Yes, I noted that some of the links removed by these "CREDITS: remove link:"
 patches have email addresses with the same domain nearby.

 Don't worry, I'll take care of them together with all other
 dead email addresses - but not right now.


 CREDITS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CREDITS b/CREDITS
index 0787b5872906..151083e4245d 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2241,7 +2241,6 @@ S: France
 
 N: Siegfried "Frieder" Loeffler (dg1sek)
 E: flo...@tunix.mathematik.uni-stuttgart.de, f...@lf.net
-W: http://www.mathematik.uni-stuttgart.de/~floeff
 D: Busmaster driver for HP 10/100 Mbit Network Adapters
 S: University of Stuttgart, Germany and
 S: Ecole Nationale Superieure des Telecommunications, Paris
-- 
2.27.0



[PATCH] CREDITS: remove link http://www.dementia.org/~shadow

2020-07-14 Thread Alexander A. Klimov
Rationale:
The way it redirects looks like a fallback from a dead URL to a generic one.

Signed-off-by: Alexander A. Klimov 
---
 Yes, I noted that some of the links removed by these "CREDITS: remove link:"
 patches have email addresses with the same domain nearby.

 Don't worry, I'll take care of them together with all other
 dead email addresses - but not right now.


 CREDITS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/CREDITS b/CREDITS
index 0787b5872906..92ad22b7ef56 100644
--- a/CREDITS
+++ b/CREDITS
@@ -483,7 +483,6 @@ D: Intel Wireless WiMAX Connection 2400 SDIO driver
 
 N: Derrick J. Brashear
 E: sha...@dementia.org
-W: http://www.dementia.org/~shadow
 P: 512/71EC9367 C5 29 0F BC 83 51 B9 F0  BC 05 89 A0 4F 1F 30 05
 D: Author of Sparc CS4231 audio driver, random Sparc work
 S: 403 Gilmore Avenue
-- 
2.27.0



Re: [PATCH v6 15/17] static_call: Allow early init

2020-07-14 Thread Steven Rostedt
On Tue, 14 Jul 2020 20:31:43 +0200
Peter Zijlstra  wrote:

> On Tue, Jul 14, 2020 at 12:07:01PM -0400, Steven Rostedt wrote:
> > Can we add a statement that says something like: "Because x86 now calls
> > static_call_init() before the setup of the memory allocator, we must
> > avoid using kmalloc() and friends for core kernel static calls." ?
> > 
> > This was the missing piece for me.  
> 
> It now reads like this.
> 
> ---
> Subject: static_call: Allow early init
> From: Peter Zijlstra 
> Date: Fri, 4 Oct 17:21:10 CEST 2019
> 
> In order to use static_call() to wire up x86_pmu, we need to
> initialize earlier, specifically before memory allocation works; copy
> some of the tricks from jump_label to enable this.
> 
> Primarily we overload key->next to store a sites pointer when there
> are no modules, this avoids having to use kmalloc() to initialize the
> sites and allows us to run much earlier.

All the pieces lie in place. Thanks!

Reviewed-by: Steven Rostedt (VMware) 

-- Steve

> 
> Signed-off-by: Peter Zijlstra (Intel) 
> ---


Re: decruft the early init / initrd / initramfs code v2

2020-07-14 Thread Linus Torvalds
On Tue, Jul 14, 2020 at 12:06 PM Christoph Hellwig  wrote:
>
> this series starts to move the early init code away from requiring
> KERNEL_DS to be implicitly set during early startup.  It does so by
> first removing legacy unused cruft, and the switches away the code
> from struct file based APIs to our more usual in-kernel APIs.

Looks good to me, with the added note on the utimes cruft too as a
further cleanup (separate patch).

So you can add my acked-by.

I _would_ like the md parts to get a few more acks. I see the one from
Song Liu, anybody else in md land willing to go through those patches?
They were the bulk of it, and the least obvious to me because I don't
know that code at all?

  Linus


Re: [PATCH] drm/vkms: add wait_for_vblanks in atomic_commit_tail

2020-07-14 Thread Melissa Wen
On 07/14, Daniel Vetter wrote:
> On Tue, Jul 14, 2020 at 07:39:42AM -0300, Melissa Wen wrote:
> > On Tue, Jul 14, 2020 at 7:20 AM Melissa Wen  wrote:
> > >
> > > On 07/13, Daniel Vetter wrote:
> > > > On Fri, Jul 10, 2020 at 02:05:33PM -0300, Melissa Wen wrote:
> > > > > On 07/02, Daniel Vetter wrote:
> > > > > > On Wed, Jul 01, 2020 at 03:31:34PM +, Sidong Yang wrote:
> > > > > > > there is an error when igt test is run continuously. 
> > > > > > > vkms_atomic_commit_tail()
> > > > > > > need to call drm_atomic_helper_wait_for_vblanks() for give up 
> > > > > > > ownership of
> > > > > > > vblank events. without this code, next atomic commit will not 
> > > > > > > enable vblank
> > > > > > > and raise timeout error.
> > > > > > >
> > > > > > > Signed-off-by: Sidong Yang 
> > > > > > > ---
> > > > > > >  drivers/gpu/drm/vkms/vkms_drv.c | 2 ++
> > > > > > >  1 file changed, 2 insertions(+)
> > > > > > >
> > > > > > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c 
> > > > > > > b/drivers/gpu/drm/vkms/vkms_drv.c
> > > > > > > index 1e8b2169d834..10b9be67a068 100644
> > > > > > > --- a/drivers/gpu/drm/vkms/vkms_drv.c
> > > > > > > +++ b/drivers/gpu/drm/vkms/vkms_drv.c
> > > > > > > @@ -93,6 +93,8 @@ static void vkms_atomic_commit_tail(struct 
> > > > > > > drm_atomic_state *old_state)
> > > > > > > flush_work(&vkms_state->composer_work);
> > > > > > > }
> > > > > > >
> > > > > > > +   drm_atomic_helper_wait_for_vblanks(dev, old_state);
> > > > > >
> > > > > > Uh, we have a wait_for_flip_done right above, which should be doing
> > > > > > exactly the same, but more precisely: Instead of just waiting for 
> > > > > > any
> > > > > > vblank to happen, we wait for exactly the vblank corresponding to 
> > > > > > this
> > > > > > atomic commit. So no races possible. If this is papering over some 
> > > > > > issue,
> > > > > > then I think more debugging is needed.
> > > > > >
> > > > > > What exactly is going wrong here for you?
> > > > >
> > > > > Hi Daniel and Sidong,
> > > > >
> > > > > I noticed a similar issue when running the IGT test kms_cursor_crc. 
> > > > > For
> > > > > example, a subtest that passes on the first run (alpha-opaque) fails 
> > > > > on
> > > > > the second due to a kind of busy waiting in subtest preparation (the
> > > > > subtest fails before actually running).
> > > > >
> > > > > In addition, in the same test, the dpms subtest started to fail since
> > > > > the commit that change from wait_for_vblanks to wait_for_flip_done. By
> > > > > reverting this commit, the dpms subtest passes again and the 
> > > > > sequential
> > > > > subtests return to normal.
> > > > >
> > > > > I am trying to figure out what's missing from using flip_done op on
> > > > > vkms, since I am also interested in solving this problem and I
> > > > > understand that the change for flip_done has been discussed in the 
> > > > > past.
> > > > >
> > > > > Do you have any idea?
> > > >
> > > > Uh, not at all. This is indeed rather surprising ...
> > > >
> > > > What exactly is the failure mode when running a test the 2nd time? Full
> > > > igt logs might give me an idea. But yeah this is kinda surprising.
> > >
> > > Hi Daniel,
> > >
> > > This is the IGT log of the 2nd run of kms_cursor_crc/alpha-opaque:
> > >
> > > IGT-Version: 1.25-NO-GIT (x86_64) (Linux: 5.8.0-rc2-DRM+ x86_64)
> > > Force option used: Using driver vkms
> > > Starting subtest: pipe-A-cursor-alpha-opaque
> > > Timed out: Opening crc fd, and poll for first CRC.
> > > Subtest pipe-A-cursor-alpha-opaque failed.
> > >  DEBUG 
> > > (kms_cursor_crc:2317) igt_kms-DEBUG: display: Virtual-1: set_pipe(A)
> > > (kms_cursor_crc:2317) igt_kms-DEBUG: display: Virtual-1: Selecting pipe A
> > > (kms_cursor_crc:2317) igt_fb-DEBUG: 
> > > igt_create_fb_with_bo_size(width=1024, height=768, 
> > > format=XR24(0x34325258), modifier=0x0, size=0)
> > > (kms_cursor_crc:2317) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=1, 
> > > pitch=4096)
> > > (kms_cursor_crc:2317) igt_fb-DEBUG: Test requirement passed: 
> > > cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS
> > > (kms_cursor_crc:2317) igt_fb-DEBUG: 
> > > igt_create_fb_with_bo_size(width=1024, height=768, 
> > > format=XR24(0x34325258), modifier=0x0, size=0)
> > > (kms_cursor_crc:2317) igt_fb-DEBUG: igt_create_fb_with_bo_size(handle=2, 
> > > pitch=4096)
> > > (kms_cursor_crc:2317) igt_fb-DEBUG: Test requirement passed: 
> > > cairo_surface_status(fb->cairo_surface) == CAIRO_STATUS_SUCCESS
> > > (kms_cursor_crc:2317) igt_kms-DEBUG: Test requirement passed: plane_idx 
> > > >= 0 && plane_idx < pipe->n_planes
> > > (kms_cursor_crc:2317) igt_kms-DEBUG: Test requirement passed: plane_idx 
> > > >= 0 && plane_idx < pipe->n_planes
> > > (kms_cursor_crc:2317) igt_kms-DEBUG: display: A.0: plane_set_fb(37)
> > > (kms_cursor_crc:2317) igt_kms-DEBUG: display: A.0: plane_set_size 
> > > (1024x768)
> > > (kms_cursor_crc:2317) igt_kms-DEBUG: display: A.0: fb_set_position(0,

Re: [ANNOUNCE] 4.19.132-rt59

2020-07-14 Thread Tom Zanussi
Hi Pavel,

On Tue, 2020-07-14 at 20:35 +0200, Pavel Machek wrote:
> Hi!
> 
> > 
> > I'm pleased to announce the 4.19.132-rt59 stable release.
> > 
> > This release is just an update to the new stable 4.19.132
> > version and no RT specific changes have been made.
> > 
> > You can get this release via the git tree at:
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-stable-
> > rt.git
> > 
> >   branch: v4.19-rt
> >   Head SHA1: 1eebf4069aa37e54330cce9a42608517ea6996fe
> > 
> > Or to build 4.19.132-rt59 directly, the following patches should be
> > applied:
> 
> Thanks a lot.
> 
> But now I am confused, I completely missed announcements for
> v4.19.127-rt55 to v4.19.131-rt58.
> 
> And for example -rt56 is not listed in
> 
> 
https://mirrors.edge.kernel.org/pub/linux/kernel/projects/rt/4.19/older/sha256sums.asc
> 

Right, this is because we up the rt version every time we merge a
stable version and have conflicts, and in this release there were a
lot, so it jumped from -rt55 to -rt59.  We only announce the releases
and not the intervening version bumps, which is why you couldn't find
any announcements for them. 

There are more details about exactly how the version numbers change
here:

  https://wiki.linuxfoundation.org/realtime/documentation/start

> ...aha, and the versions do not have signed tags, either:
> 
> pavel@amd:~/cip/k$ git show v4.19.131-rt58
> fatal: ambiguous argument 'v4.19.131-rt58': unknown revision or path
> not in the working tree.
> 

Yeah, thanks for pointing that out.  Looks like my script doesn't push
the intervening tags correctly, but I've pushed them out now.

> Is that because they were created just as quick steps towards -rt59?
> 

Yeah, pretty much.

Thanks,

Tom

> Best regards,
>   Pavel



Re: [PATCH 17/23] initramfs: switch initramfs unpacking to struct file based APIs

2020-07-14 Thread Linus Torvalds
On Tue, Jul 14, 2020 at 12:09 PM Christoph Hellwig  wrote:
>
> There is no good reason to mess with file descriptors from in-kernel
> code, switch the initramfs unpacking to struct file based write
> instead.

Looking at this diff, I realized this really should be cleaned up more.

 +   wfile = filp_open(collected, openflags, mode);
> +   if (IS_ERR(wfile))
> +   return 0;
> +
> +   vfs_fchown(wfile, uid, gid);
> +   vfs_fchmod(wfile, mode);
> +   if (body_len)
> +   vfs_truncate(&wfile->f_path, body_len);
> +   vcollected = kstrdup(collected, GFP_KERNEL);

That "vcollected" is ugly and broken, and seems oh-so-wrong.

Because it's only use is:


> -   ksys_close(wfd);
> +   fput(wfile);
> do_utime(vcollected, mtime);
> kfree(vcollected);

which should just have done the exact same thing that you did with
vfs_chown() and friends: we already have a "utimes_common()" that
takes a path, and it could have been made into "vfs_utimes()", and
then this whole vcollected confusion would go away and be replaced by

vfs_truncate(&wfile->f_path, mtime);

(ok, with all the "timespec64 t[2]" things going on that do_utime()
does now, but you get the idea).

Talk about de-crufting that initramfs unpacking..

But I don't hate this patch, I'm just pointing out that there's room
for improvement.

 Linus


Re: [PATCH v4 0/7] x86/boot: Remove runtime relocations from compressed kernel

2020-07-14 Thread Arvind Sankar
On Tue, Jul 14, 2020 at 08:30:14PM +0200, Sedat Dilek wrote:
> > I did a full new build...
> >
> > ...and it fails with ld.lld-11 as linker:
> >
> > ld.lld-11 -m elf_x86_64 -pie  --no-dynamic-linker -r -o
> > arch/x86/boot/compressed/.tmp_misc.o arch/x86/boot/compressed/misc.o
> > -T arch/x86/boot/compressed/.tmp_misc.ver; mv -f
> > arch/x86/boot/compressed/.tmp_misc.o arch/x86/boot/compressed/misc.o;
> > rm -f arch/x86/boot/compressed/.tmp_misc.ver; fi
> > *** ld.lld-11: error: -r and -pie may not be used together ***
> > make[5]: *** [scripts/Makefile.build:281:
> > arch/x86/boot/compressed/misc.o] Error 1
> >
> > It's annoying to fail on the last minutes of a build.
> > Sorry for being very honest.
> >
> 
> I applied this diff...
> 
> $ git diff arch/x86/boot/compressed/Makefile
> diff --git a/arch/x86/boot/compressed/Makefile
> b/arch/x86/boot/compressed/Makefile
> index 789d5d14d8b0..9ba52a656838 100644
> --- a/arch/x86/boot/compressed/Makefile
> +++ b/arch/x86/boot/compressed/Makefile
> @@ -51,7 +51,10 @@ UBSAN_SANITIZE :=n
>  KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
>  # Compressed kernel should be built as PIE since it may be loaded at any
>  # address by the bootloader.
> +# LLD linker does not allow -r and -pie options to be used together.
> +ifndef CONFIG_LD_IS_LLD
>  KBUILD_LDFLAGS += -pie $(call ld-option, --no-dynamic-linker)
> +endif
>  LDFLAGS_vmlinux := -T
> 
>  hostprogs  := mkpiggy
> 
> ...and was able to build, assemble, link arch/x86/boot/compressed/*.
> 
> - Sedat -

Thanks for the test.

Can you share your .config? The error messages look like they're coming
from running modversions on misc.o, which is unexpected as it shouldn't
have any exported symbols, and it doesn't in my builds.

In any case, I think the right fix here would be to add -pie and
--no-dynamic-linker to LDFLAGS_vmlinux instead of KBUILD_LDFLAGS.


Re: [RFC PATCH 12/15] kmap: Add stray write protection for device pages

2020-07-14 Thread Peter Zijlstra
On Tue, Jul 14, 2020 at 12:06:16PM -0700, Ira Weiny wrote:
> On Tue, Jul 14, 2020 at 10:44:51AM +0200, Peter Zijlstra wrote:

> > So, if I followed along correctly, you're proposing to do a WRMSR per
> > k{,un}map{_atomic}(), sounds like excellent performance all-round :-(
> 
> Only to pages which have this additional protection, ie not DRAM.
> 
> User mappings of this memory is not affected (would be covered by User PKeys 
> if
> desired).  User mappings to persistent memory are the primary use case and the
> performant path.

Because performance to non-volatile memory doesn't matter? I think Dave
has a better answer here ...


Re: [PATCH] ASoC: Intel: bytcht_es8316: Add missed put_device()

2020-07-14 Thread Hans de Goede

Hi,

On 7/14/20 5:32 PM, Pierre-Louis Bossart wrote:



On 7/14/20 8:33 AM, Hans de Goede wrote:

Hi,

On 7/14/20 10:09 AM, Jing Xiangfeng wrote:

snd_byt_cht_es8316_mc_probe() misses to call put_device() in an error
path. Add the missed function call to fix it.

Fixes: ba49cf6f8e4a ("ASoC: Intel: bytcht_es8316: Add quirk for inverted jack 
detect")
Signed-off-by: Jing Xiangfeng 


Patch looks good to me:

Reviewed-by: Hans de Goede 


Actually the existing code looks quite odd to me:

if (cnt) {
 ret = device_add_properties(codec_dev, props);
 if (ret)
     return ret;
}

devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
priv->speaker_en_gpio =
 gpiod_get_index(codec_dev, "speaker-enable", 0,
     /* see comment in byt_cht_es8316_resume */
     GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
put_device(codec_dev);

if the first branch is not taken the put_device() will not be balanced.


The get_device() does not come from the device_add_properties, it comes
from the earlier:

codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL, codec_name);

call.

Regards,

Hans





Shouldn't this be:

if (cnt) {
 ret = device_add_properties(codec_dev, props);
 put_device(codec_dev);
 if (ret)
     return ret;
}

devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);
priv->speaker_en_gpio =
 gpiod_get_index(codec_dev, "speaker-enable", 0,
     /* see comment in byt_cht_es8316_resume */
     GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE);
/* removed put_device(codec_dev); */



Regards,

Hans



---
  sound/soc/intel/boards/bytcht_es8316.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/boards/bytcht_es8316.c 
b/sound/soc/intel/boards/bytcht_es8316.c
index 9e5fc9430628..ecbc58e8a37f 100644
--- a/sound/soc/intel/boards/bytcht_es8316.c
+++ b/sound/soc/intel/boards/bytcht_es8316.c
@@ -543,8 +543,10 @@ static int snd_byt_cht_es8316_mc_probe(struct 
platform_device *pdev)
  if (cnt) {
  ret = device_add_properties(codec_dev, props);
-    if (ret)
+    if (ret) {
+    put_device(codec_dev);
  return ret;
+    }
  }
  devm_acpi_dev_add_driver_gpios(codec_dev, byt_cht_es8316_gpios);









Re: [PATCH] spi: spidev: Add compatible for external SPI ports on Kontron boards

2020-07-14 Thread Mark Brown
On Tue, Jul 14, 2020 at 10:54:15AM +0200, Frieder Schrempf wrote:

> It would still be quite nice to benefit from the flexibility of DT overlays
> not only for the SPI use case. But before I come up with any custom
> solution, for now I will rather have the device in the DT statically.

> I just wonder if I need to keep the DT node for the device in a separate
> patch in our own tree, or if a node with a custom compatible string like for
> example "kontron,user-spi" would be accepted upstream, without a matching
> driver?

I'm having a hard time getting enthusiastic about it TBH - can you not
just use spidev and live with the warning?


signature.asc
Description: PGP signature


Re: [PATCH 0/2] X32 syscall cleanups

2020-07-14 Thread Andy Lutomirski
On Tue, Jul 14, 2020 at 10:03 AM Brian Gerst  wrote:>
> On Tue, Jul 14, 2020 at 2:40 AM Christoph Hellwig  wrote:
> >
> > On Tue, Jun 16, 2020 at 10:23:13AM -0400, Brian Gerst wrote:
> > > Christoph Hellwig uncovered an issue with how we currently handle X32
> > > syscalls.  Currently, we can only use COMPAT_SYS_DEFINEx() for X32
> > > specific syscalls.  These changes remove that restriction and allow
> > > native syscalls.
> >
> > Did this go anywhere?
>
> This approach wasn't well received, so I'd just go with this as the
> simplest solution:
> https://lore.kernel.org/lkml/CAK8P3a17h782gO65qJ9Mmz0EuiTSKQPEyr_=nvqotnmqzuh...@mail.gmail.com/
>

I'm okay with either approach, although I think the original approach
is nicer than the simplified #define approach.

In my mind, the __x64_omg_so_many_underscores prefixes really mean
"don't think too hard about these -- we just decided to make extra
long names", so whatever.  We can clean it up more some day.

> --
> Brian Gerst


Re: [PATCH] x86/bugs/multihit: Fix mitigation reporting when KVM is not in use

2020-07-14 Thread Pawan Gupta
On Tue, Jul 14, 2020 at 07:57:53AM -0700, Dave Hansen wrote:
> Let's stick to things which are at least static per reboot.  Checking
> for X86_FEATURE_VMX or even CONFIG_KVM_INTEL seems like a good stopping
> point.  "Could this kernel run a naughty guest?"  If so, report
> "Vulnerable".  It's the same as Meltdown: "Could this kernel run
> untrusted code?"  If so, report "Vulnerable".

Thanks, These are good inputs. So what I need to add is a boot time
check for VMX feature and report "Vulnerable" or "Not
affected(VMX disabled)".

Are you suggesting to not change the reporting when KVM deploys the
"Split huge pages" mitigation? Is this because VMX can still be used by
other VMMs?

The current mitigation reporting is very specific to KVM:

- "KVM: Vulnerable"
- "KVM: Mitigation: Split huge pages"

As the kernel doesn't know about the mitigation state of out-of-tree
VMMs can we add VMX reporting to always say vulnerable when VMX is
enabled:

- "VMX: Vulnerable, KVM: Vulnerable"
- "VMX: Vulnerable, KVM: Mitigation: Split huge pages"

And if VMX is disabled report:

- "VMX: Not affected(VMX disabled)"

or something like that.

Thanks,
Pawan


Re: [PATCH 6/6] staging: qlge: qlge_ethtool: Remove one byte memset.

2020-07-14 Thread Joe Perches
On Wed, 2020-07-15 at 00:36 +0530, Suraj Upadhyay wrote:
> On Tue, Jul 14, 2020 at 11:57:23AM -0700, Joe Perches wrote:
> > On Mon, 2020-07-13 at 17:17 +0300, Dan Carpenter wrote:
> > > On Mon, Jul 13, 2020 at 05:52:22PM +0530, Suraj Upadhyay wrote:
> > > > Use direct assignment instead of using memset with just one byte as an
> > > > argument.
> > > > Issue found by checkpatch.pl.
> > > > 
> > > > Signed-off-by: Suraj Upadhyay 
> > > > ---
> > > > Hii Maintainers,
> > > > Please correct me if I am wrong here.
> > > > ---
> > > > 
> > > >  drivers/staging/qlge/qlge_ethtool.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/staging/qlge/qlge_ethtool.c 
> > > > b/drivers/staging/qlge/qlge_ethtool.c
> > > > index 16fcdefa9687..d44b2dae9213 100644
> > > > --- a/drivers/staging/qlge/qlge_ethtool.c
> > > > +++ b/drivers/staging/qlge/qlge_ethtool.c
> > > > @@ -516,8 +516,8 @@ static void ql_create_lb_frame(struct sk_buff *skb,
> > > > memset(skb->data, 0xFF, frame_size);
> > > > frame_size &= ~1;
> > > > memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
> > > > -   memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > > -   memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > > > +   skb->data[frame_size / 2 + 10] = (unsigned char)0xBE;
> > > > +   skb->data[frame_size / 2 + 12] = (unsigned char)0xAF;
> > > 
> > > Remove the casting.
> > > 
> > > I guess this is better than the original because now it looks like
> > > ql_check_lb_frame().  It's still really weird looking though.
> > 
> > There are several of these in the intel drivers too:
> > 
> > drivers/net/ethernet/intel/e1000/e1000_ethtool.c:   
> > memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > drivers/net/ethernet/intel/e1000/e1000_ethtool.c:   
> > memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > drivers/net/ethernet/intel/e1000e/ethtool.c:
> > memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > drivers/net/ethernet/intel/e1000e/ethtool.c:
> > memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > drivers/net/ethernet/intel/igb/igb_ethtool.c:   
> > memset(&skb->data[frame_size + 10], 0xBE, 1);
> > drivers/net/ethernet/intel/igb/igb_ethtool.c:   
> > memset(&skb->data[frame_size + 12], 0xAF, 1);
> > drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c:   
> > memset(&skb->data[frame_size + 10], 0xBE, 1);
> > drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c:   
> > memset(&skb->data[frame_size + 12], 0xAF, 1);
> > drivers/staging/qlge/qlge_ethtool.c:memset(&skb->data[frame_size / 2 + 
> > 10], 0xBE, 1);
> > drivers/staging/qlge/qlge_ethtool.c:memset(&skb->data[frame_size / 2 + 
> > 12], 0xAF, 1);
> 
> Thanks to point this out,
>   I will be sending a patchset for that soon.


It _might_ be useful to create and use a standard
mechanism for the loopback functions:

create_lbtest_frame
and
check_lbtest_frame

Maybe use something like:

ether_loopback_frame_create
and
ether_loopback_frame_check




[PATCH] OMAP: iommu: check for failure of a call to omap_iommu_dump_ctx

2020-07-14 Thread Colin King
From: Colin Ian King 

It is possible for the call to omap_iommu_dump_ctx to return
a negative error number, so check for the failure and return
the error number rather than pass the negative value to
simple_read_from_buffer.

Addresses-Coverity: ("Improper use of negative value")
Fixes: 14e0e6796a0d ("OMAP: iommu: add initial debugfs support")
Signed-off-by: Colin Ian King 
---
 drivers/iommu/omap-iommu-debug.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iommu/omap-iommu-debug.c b/drivers/iommu/omap-iommu-debug.c
index 8e19bfa94121..a99afb5d9011 100644
--- a/drivers/iommu/omap-iommu-debug.c
+++ b/drivers/iommu/omap-iommu-debug.c
@@ -98,8 +98,11 @@ static ssize_t debug_read_regs(struct file *file, char 
__user *userbuf,
mutex_lock(&iommu_debug_lock);
 
bytes = omap_iommu_dump_ctx(obj, p, count);
+   if (bytes < 0)
+   goto err;
bytes = simple_read_from_buffer(userbuf, count, ppos, buf, bytes);
 
+err:
mutex_unlock(&iommu_debug_lock);
kfree(buf);
 
-- 
2.27.0



Re: [PATCH v4 0/7] x86/boot: Remove runtime relocations from compressed kernel

2020-07-14 Thread Sedat Dilek
On Tue, Jul 14, 2020 at 8:33 PM Sedat Dilek  wrote:
>
> On Tue, Jul 14, 2020 at 8:30 PM Sedat Dilek  wrote:
> >
> > > I did a full new build...
> > >
> > > ...and it fails with ld.lld-11 as linker:
> > >
> > > ld.lld-11 -m elf_x86_64 -pie  --no-dynamic-linker -r -o
> > > arch/x86/boot/compressed/.tmp_misc.o arch/x86/boot/compressed/misc.o
> > > -T arch/x86/boot/compressed/.tmp_misc.ver; mv -f
> > > arch/x86/boot/compressed/.tmp_misc.o arch/x86/boot/compressed/misc.o;
> > > rm -f arch/x86/boot/compressed/.tmp_misc.ver; fi
> > > *** ld.lld-11: error: -r and -pie may not be used together ***
> > > make[5]: *** [scripts/Makefile.build:281:
> > > arch/x86/boot/compressed/misc.o] Error 1
> > >
> > > It's annoying to fail on the last minutes of a build.
> > > Sorry for being very honest.
> > >
> >
> > I applied this diff...
> >
> > $ git diff arch/x86/boot/compressed/Makefile
> > diff --git a/arch/x86/boot/compressed/Makefile
> > b/arch/x86/boot/compressed/Makefile
> > index 789d5d14d8b0..9ba52a656838 100644
> > --- a/arch/x86/boot/compressed/Makefile
> > +++ b/arch/x86/boot/compressed/Makefile
> > @@ -51,7 +51,10 @@ UBSAN_SANITIZE :=n
> >  KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE)
> >  # Compressed kernel should be built as PIE since it may be loaded at any
> >  # address by the bootloader.
> > +# LLD linker does not allow -r and -pie options to be used together.
> > +ifndef CONFIG_LD_IS_LLD
> >  KBUILD_LDFLAGS += -pie $(call ld-option, --no-dynamic-linker)
> > +endif
> >  LDFLAGS_vmlinux := -T
> >
> >  hostprogs  := mkpiggy
> >
> > ...and was able to build, assemble, link arch/x86/boot/compressed/*.
> >
>
> I checked my last succesfull build without your patchset:
>
> $ grep no-dynamic-linker build-log_5.8.0-rc5-1-amd64-llvm11-ias.txt
> [ EMPTY ]
>

I was able to boot on bare metal.

Feel free to add my...

Tested-by: Sedat Dilek 

...when you restore "old" behaviour when CONFIG_LD_IS_LLD=y (apply or
fold-in my diff with comment)...

...and use one "runtime" in your subject-line:

$ git log --oneline
v5.8-rc5..for-5.8/x86-boot-compressed-remove-runtime-relocations-nivedita-v4
| egrep 'runtime|run-time'
9547f8f08689 x86/boot: Check that there are no runtime relocations
ede02a307b30 x86/boot: Remove runtime relocations from head_{32,64}.S
525a67ac7ea9 x86/boot: Remove run-time relocations from .head.text code

Thanks.

- Sedat -


Re: [PATCH v10 00/17] mtd: spi-nor: add xSPI Octal DTR support

2020-07-14 Thread Mark Brown
On Mon, Jul 13, 2020 at 06:34:12AM +, tudor.amba...@microchip.com wrote:

> These four patches are looking good, I had just few minor comments.
> If you too think that they are ok, would you take them through the
> SPI tree? If so, I would need an immutable tag on top of v5.8-rc1
> preferably, so I can merge them back to SPI NOR and continue the
> development on top of them.

The following changes since commit b3a9e3b9622ae10064826dccb4f7a52bd88c7407:

  Linux 5.8-rc1 (2020-06-14 12:45:04 -0700)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 
tags/spi-mem-dtr

for you to fetch changes up to 4728f073bfc66b8b555274ef0d7741d7f5a48947:

  spi: spi-mtk-nor: reject DTR ops (2020-07-14 17:29:40 +0100)


spi: Support for DTR ops


Pratyush Yadav (4):
  spi: spi-mem: allow specifying whether an op is DTR or not
  spi: spi-mem: allow specifying a command's extension
  spi: atmel-quadspi: reject DTR ops
  spi: spi-mtk-nor: reject DTR ops

 drivers/spi/atmel-quadspi.c |  6 ++
 drivers/spi/spi-mem.c   | 16 ++--
 drivers/spi/spi-mtk-nor.c   | 10 --
 drivers/spi/spi-mxic.c  |  3 ++-
 drivers/spi/spi-zynq-qspi.c | 11 ++-
 include/linux/spi/spi-mem.h | 14 +-
 6 files changed, 45 insertions(+), 15 deletions(-)


signature.asc
Description: PGP signature


Re: [PATCH -v2.1] x86/msr: Filter MSR writes

2020-07-14 Thread Matthew Garrett
On Tue, Jul 14, 2020 at 9:04 AM Chris Down  wrote:
> Either way, again, this isn't really the point. :-) The point is that there
> _are_ currently widespread cases involving poking MSRs from userspace, however
> sacrilegious or ugly (which I agree with!), and while people should be told
> about that, it's excessive to have the potential to take up 80% of kmsg in the
> default configuration. It doesn't take thousands of messages to get the 
> message
> across, that's what a custom printk ratelimit is for.

Agreed - we should now offer all the necessary interfaces to avoid
userspace having to hit MSRs directly for thermal management, but that
wasn't always the case, and as a result there's tooling that still
behaves this way.


Re: [PATCH v4 09/10] net: eth: altera: add msgdma prefetcher

2020-07-14 Thread Jakub Kicinski
On Tue, 14 Jul 2020 18:51:15 + Westergreen, Dalon wrote:
> > I've seen vendors abuse fields of ethtool --coalesce to configure
> > similar settings. tx-usecs-irq and rx-usecs-irq, I think. Since this
> > part of ethtool API has been ported to netlink, could we perhaps add 
> > a new field to ethtool --coalesce?  
> 
> I don't think this is necessary, i think just having a module parameter
> meets our needs.  I don't see a need for the value to change on a per
> interface basis.  This was primarily used during testing / bringup.

It's hard to tell which knobs users will find worth turning therefore
the testing / bringup justification unfortunately has little bearing on
our upstream interface choices.

We try hard to avoid module parameters in networking drivers, so if you
want this tunable upstream a proper user interface will be required.


[PATCH] mmc: host: sdhci-of-arasan: fix timings allocation code

2020-07-14 Thread Manish Narani
The initial code that was adding delays was doing a cast over undefined
memory. This meant that the delays would be all gibberish.

This change, allocates all delays on the stack, and assigns them from the
ZynqMP & Versal macros/phase-list. And then finally copies them over the
common iclk_phase & oclk_phase variables.

Signed-off-by: Manish Narani 
---
 drivers/mmc/host/sdhci-of-arasan.c |   25 ++---
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-arasan.c 
b/drivers/mmc/host/sdhci-of-arasan.c
index db9b544..90e42d1 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -1025,7 +1025,6 @@ static void arasan_dt_read_clk_phase(struct device *dev,
 static void arasan_dt_parse_clk_phases(struct device *dev,
   struct sdhci_arasan_clk_data *clk_data)
 {
-   int *iclk_phase, *oclk_phase;
u32 mio_bank = 0;
int i;
 
@@ -1037,28 +1036,32 @@ static void arasan_dt_parse_clk_phases(struct device 
*dev,
clk_data->set_clk_delays = sdhci_arasan_set_clk_delays;
 
if (of_device_is_compatible(dev->of_node, "xlnx,zynqmp-8.9a")) {
-   iclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) ZYNQMP_ICLK_PHASE;
-   oclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) ZYNQMP_OCLK_PHASE;
+   u32 zynqmp_iclk_phase[MMC_TIMING_MMC_HS400 + 1] =
+   ZYNQMP_ICLK_PHASE;
+   u32 zynqmp_oclk_phase[MMC_TIMING_MMC_HS400 + 1] =
+   ZYNQMP_OCLK_PHASE;
 
of_property_read_u32(dev->of_node, "xlnx,mio-bank", &mio_bank);
if (mio_bank == 2) {
-   oclk_phase[MMC_TIMING_UHS_SDR104] = 90;
-   oclk_phase[MMC_TIMING_MMC_HS200] = 90;
+   zynqmp_oclk_phase[MMC_TIMING_UHS_SDR104] = 90;
+   zynqmp_oclk_phase[MMC_TIMING_MMC_HS200] = 90;
}
 
for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) {
-   clk_data->clk_phase_in[i] = iclk_phase[i];
-   clk_data->clk_phase_out[i] = oclk_phase[i];
+   clk_data->clk_phase_in[i] = zynqmp_iclk_phase[i];
+   clk_data->clk_phase_out[i] = zynqmp_oclk_phase[i];
}
}
 
if (of_device_is_compatible(dev->of_node, "xlnx,versal-8.9a")) {
-   iclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) VERSAL_ICLK_PHASE;
-   oclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) VERSAL_OCLK_PHASE;
+   u32 versal_iclk_phase[MMC_TIMING_MMC_HS400 + 1] =
+   VERSAL_ICLK_PHASE;
+   u32 versal_oclk_phase[MMC_TIMING_MMC_HS400 + 1] =
+   VERSAL_OCLK_PHASE;
 
for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) {
-   clk_data->clk_phase_in[i] = iclk_phase[i];
-   clk_data->clk_phase_out[i] = oclk_phase[i];
+   clk_data->clk_phase_in[i] = versal_iclk_phase[i];
+   clk_data->clk_phase_out[i] = versal_oclk_phase[i];
}
}
 
-- 
1.7.1



[PATCH 4.19 07/58] ARM: dts: omap4-droid4: Fix spi configuration and increase rate

2020-07-14 Thread Greg Kroah-Hartman
From: Tony Lindgren 

[ Upstream commit 0df12a01f4857495816b05f048c4c31439446e35 ]

We can currently sometimes get "RXS timed out" errors and "EOT timed out"
errors with spi transfers.

These errors can be made easy to reproduce by reading the cpcap iio
values in a loop while keeping the CPUs busy by also reading /dev/urandom.

The "RXS timed out" errors we can fix by adding spi-cpol and spi-cpha
in addition to the spi-cs-high property we already have.

The "EOT timed out" errors we can fix by increasing the spi clock rate
to 9.6 MHz. Looks similar MC13783 PMIC says it works at spi clock rates
up to 20 MHz, so let's assume we can pick any rate up to 20 MHz also
for cpcap.

Cc: maemo-le...@lists.dyne.org
Cc: Merlijn Wajer 
Cc: Pavel Machek 
Cc: Sebastian Reichel 
Signed-off-by: Tony Lindgren 
Signed-off-by: Sasha Levin 
---
 arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi 
b/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi
index f57acf8f66b95..75de8134b1d1f 100644
--- a/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi
+++ b/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi
@@ -16,8 +16,10 @@
#interrupt-cells = <2>;
#address-cells = <1>;
#size-cells = <0>;
-   spi-max-frequency = <300>;
+   spi-max-frequency = <960>;
spi-cs-high;
+   spi-cpol;
+   spi-cpha;
 
cpcap_adc: adc {
compatible = "motorola,mapphone-cpcap-adc";
-- 
2.25.1





[PATCH 4.19 22/58] block: release bip in a right way in error path

2020-07-14 Thread Greg Kroah-Hartman
From: Chengguang Xu 

[ Upstream commit 0b8eb629a700c0ef15a437758db8255f8444e76c ]

Release bip using kfree() in error path when that was allocated
by kmalloc().

Signed-off-by: Chengguang Xu 
Reviewed-by: Christoph Hellwig 
Acked-by: Martin K. Petersen 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 block/bio-integrity.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index a059fad53f1b0..0b96220d0efd4 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -38,6 +38,18 @@ void blk_flush_integrity(void)
flush_workqueue(kintegrityd_wq);
 }
 
+void __bio_integrity_free(struct bio_set *bs, struct bio_integrity_payload 
*bip)
+{
+   if (bs && mempool_initialized(&bs->bio_integrity_pool)) {
+   if (bip->bip_vec)
+   bvec_free(&bs->bvec_integrity_pool, bip->bip_vec,
+ bip->bip_slab);
+   mempool_free(bip, &bs->bio_integrity_pool);
+   } else {
+   kfree(bip);
+   }
+}
+
 /**
  * bio_integrity_alloc - Allocate integrity payload and attach it to bio
  * @bio:   bio to attach integrity metadata to
@@ -90,7 +102,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio 
*bio,
 
return bip;
 err:
-   mempool_free(bip, &bs->bio_integrity_pool);
+   __bio_integrity_free(bs, bip);
return ERR_PTR(-ENOMEM);
 }
 EXPORT_SYMBOL(bio_integrity_alloc);
@@ -111,14 +123,7 @@ static void bio_integrity_free(struct bio *bio)
kfree(page_address(bip->bip_vec->bv_page) +
  bip->bip_vec->bv_offset);
 
-   if (bs && mempool_initialized(&bs->bio_integrity_pool)) {
-   bvec_free(&bs->bvec_integrity_pool, bip->bip_vec, 
bip->bip_slab);
-
-   mempool_free(bip, &bs->bio_integrity_pool);
-   } else {
-   kfree(bip);
-   }
-
+   __bio_integrity_free(bs, bip);
bio->bi_integrity = NULL;
bio->bi_opf &= ~REQ_INTEGRITY;
 }
-- 
2.25.1





[PATCH] mips: Replace HTTP links with HTTPS ones

2020-07-14 Thread Alexander A. Klimov
Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
For each line:
  If doesn't contain `\bxmlns\b`:
For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
If both the HTTP and HTTPS versions
return 200 OK and serve the same content:
  Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov 
---
 arch/mips/Kconfig   | 2 +-
 arch/mips/include/asm/war.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 6fee1a133e9d..eaf7519e3033 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2825,7 +2825,7 @@ config SMP
  Y to "Enhanced Real Time Clock Support", below.
 
  See also the SMP-HOWTO available at
- .
+ .
 
  If you don't know what to do here, say N.
 
diff --git a/arch/mips/include/asm/war.h b/arch/mips/include/asm/war.h
index 1eedd596a064..e43f800e662d 100644
--- a/arch/mips/include/asm/war.h
+++ b/arch/mips/include/asm/war.h
@@ -121,7 +121,7 @@
  * operate correctly if the internal data cache refill buffer is empty.
 These
  * CACHE instructions should be separated from any potential data cache miss
  * by a load instruction to an uncached address to empty the response buffer."
- * (Revision 2.0 device errata from IDT available on http://www.idt.com/
+ * (Revision 2.0 device errata from IDT available on https://www.idt.com/
  * in .pdf format.)
  */
 #ifndef R4600_V2_HIT_CACHEOP_WAR
-- 
2.27.0



[PATCH 4.19 00/58] 4.19.133-rc1 review

2020-07-14 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.133 release.
There are 58 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Thu, 16 Jul 2020 18:40:38 +.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:

https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.133-rc1.gz
or in the git tree and branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-4.19.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.19.133-rc1

Janosch Frank 
s390/mm: fix huge pte soft dirty copying

Vineet Gupta 
ARC: elf: use right ELF_ARCH

Vineet Gupta 
ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE

Mikulas Patocka 
dm: use noio when sending kobject event

Tom Rix 
drm/radeon: fix double free

Boris Burkov 
btrfs: fix fatal extent_buffer readahead vs releasepage race

Greg Kroah-Hartman 
Revert "ath9k: Fix general protection fault in ath9k_hif_usb_rx_cb"

Kees Cook 
bpf: Check correct cred for CAP_SYSLOG in bpf_dump_raw_ok()

Kees Cook 
kprobes: Do not expose probe addresses to non-CAP_SYSLOG

Kees Cook 
module: Do not expose section addresses to non-CAP_SYSLOG

Kees Cook 
module: Refactor section attr into bin attribute

Gustavo A. R. Silva 
kernel: module: Use struct_size() helper

Kees Cook 
kallsyms: Refactor kallsyms_show_value() to take cred

Sean Christopherson 
KVM: x86: Mark CR4.TSD as being possibly owned by the guest

Sean Christopherson 
KVM: x86: Inject #GP if guest attempts to toggle CR4.LA57 in 64-bit mode

Paolo Bonzini 
KVM: x86: bit 8 of non-leaf PDPEs is not reserved

Andrew Scull 
KVM: arm64: Stop clobbering x0 for HVC_SOFT_RESTART

Will Deacon 
KVM: arm64: Fix definition of PAGE_HYP_DEVICE

Hector Martin 
ALSA: usb-audio: add quirk for MacroSilicon MS2109

Hui Wang 
ALSA: hda - let hs_mic be picked ahead of hp_mic

xidongwang 
ALSA: opl3: fix infoleak in opl3

Ido Schimmel 
mlxsw: spectrum_router: Remove inappropriate usage of WARN_ON()

Nicolas Ferre 
net: macb: mark device wake capable when "magic-packet" property present

Davide Caratti 
bnxt_en: fix NULL dereference in case SR-IOV configuration fails

Rahul Lakkireddy 
cxgb4: fix all-mask IP address comparison

Zheng Bin 
nbd: Fix memory leak in nbd_add_socket

Wei Li 
arm64: kgdb: Fix single-step exception handling oops

Vinod Koul 
ALSA: compress: fix partial_drain completion state

Yonglong Liu 
net: hns3: fix use-after-free when doing self test

Andre Edich 
smsc95xx: avoid memory leak in smsc95xx_bind

Andre Edich 
smsc95xx: check return value of smsc95xx_reset

Li Heng 
net: cxgb4: fix return error value in t4_prep_fw

Hsin-Yi Wang 
drm/mediatek: Check plane visibility in atomic_update

Dan Carpenter 
net: qrtr: Fix an out of bounds read qrtr_endpoint_post()

Peter Zijlstra 
x86/entry: Increase entry_stack size to a full page

Max Gurtovoy 
nvme-rdma: assign completion vector correctly

Chengguang Xu 
block: release bip in a right way in error path

Aditya Pakki 
usb: dwc3: pci: Fix reference count leak in dwc3_pci_resume_work

Tomas Henzl 
scsi: mptscsih: Fix read sense data size

yu kuai 
ARM: imx6: add missing put_device() call in imx6q_suspend_init()

Zhang Xiaoxu 
cifs: update ctime and mtime during truncate

Maxime Ripard 
drm/sun4i: mixer: Call of_dma_configure if there's an IOMMU

Vasily Gorbik 
s390/kasan: fix early pgm check handler execution

Hans de Goede 
drm: panel-orientation-quirks: Use generic orientation-data for Acer S1003

Hans de Goede 
drm: panel-orientation-quirks: Add quirk for Asus T101HA panel

Ciara Loftus 
i40e: protect ring accesses with READ- and WRITE_ONCE

Ciara Loftus 
ixgbe: protect ring accesses with READ- and WRITE_ONCE

Zhenzhong Duan 
spi: spidev: fix a potential use-after-free in spidev_release()

Zhenzhong Duan 
spi: spidev: fix a race between spidev_release and spidev_remove

Thierry Reding 
gpu: host1x: Detach driver on unregister

Nicolin Chen 
drm/tegra: hub: Do not enable orphaned window group

Tony Lindgren 
ARM: dts: omap4-droid4: Fix spi configuration and increase rate

Jens Thoms Toerring 
regmap: fix alignment issue

Krzysztof Kozlowski 
spi: spi-fsl-dspi: Fix external abort on interrupt in resume or exit paths

Chuanhua Han 
spi: spi-fsl-dspi: use IRQF_SHARED mode to request IRQ

Krzysztof Kozlowski 
spi: spi-fsl-dspi: Fix lockup if device is removed during SPI transfer

Peng Ma 
spi: spi-fsl-dspi: Adding shutdown hook

Christian Borntraeger 
KVM: s390: reduce number of IO pins to 1


-

Diffstat:

 Makefile  

[PATCH 4.19 41/58] KVM: arm64: Fix definition of PAGE_HYP_DEVICE

2020-07-14 Thread Greg Kroah-Hartman
From: Will Deacon 

commit 68cf617309b5f6f3a651165f49f20af1494753ae upstream.

PAGE_HYP_DEVICE is intended to encode attribute bits for an EL2 stage-1
pte mapping a device. Unfortunately, it includes PROT_DEVICE_nGnRE which
encodes attributes for EL1 stage-1 mappings such as UXN and nG, which are
RES0 for EL2, and DBM which is meaningless as TCR_EL2.HD is not set.

Fix the definition of PAGE_HYP_DEVICE so that it doesn't set RES0 bits
at EL2.

Acked-by: Marc Zyngier 
Cc: Marc Zyngier 
Cc: Catalin Marinas 
Cc: James Morse 
Cc: 
Link: https://lore.kernel.org/r/20200708162546.26176-1-w...@kernel.org
Signed-off-by: Will Deacon 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/arm64/include/asm/pgtable-prot.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm64/include/asm/pgtable-prot.h
+++ b/arch/arm64/include/asm/pgtable-prot.h
@@ -65,7 +65,7 @@
 #define PAGE_HYP   __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | 
PTE_HYP_XN)
 #define PAGE_HYP_EXEC  __pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | 
PTE_RDONLY)
 #define PAGE_HYP_RO__pgprot(_HYP_PAGE_DEFAULT | PTE_HYP | 
PTE_RDONLY | PTE_HYP_XN)
-#define PAGE_HYP_DEVICE__pgprot(PROT_DEVICE_nGnRE | PTE_HYP)
+#define PAGE_HYP_DEVICE__pgprot(_PROT_DEFAULT | 
PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_HYP | PTE_HYP_XN)
 
 #define PAGE_S2_MEMATTR(attr)  \
({  \




[PATCH 4.19 37/58] mlxsw: spectrum_router: Remove inappropriate usage of WARN_ON()

2020-07-14 Thread Greg Kroah-Hartman
From: Ido Schimmel 

[ Upstream commit d9d5420273997664a1c09151ca86ac993f2f89c1 ]

We should not trigger a warning when a memory allocation fails. Remove
the WARN_ON().

The warning is constantly triggered by syzkaller when it is injecting
faults:

[ 2230.758664] FAULT_INJECTION: forcing a failure.
[ 2230.758664] name failslab, interval 1, probability 0, space 0, times 0
[ 2230.762329] CPU: 3 PID: 1407 Comm: syz-executor.0 Not tainted 5.8.0-rc2+ #28
...
[ 2230.898175] WARNING: CPU: 3 PID: 1407 at 
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:6265 
mlxsw_sp_router_fib_event+0xfad/0x13e0
[ 2230.898179] Kernel panic - not syncing: panic_on_warn set ...
[ 2230.898183] CPU: 3 PID: 1407 Comm: syz-executor.0 Not tainted 5.8.0-rc2+ #28
[ 2230.898190] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014

Fixes: 3057224e014c ("mlxsw: spectrum_router: Implement FIB offload in deferred 
work")
Signed-off-by: Ido Schimmel 
Reviewed-by: Jiri Pirko 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 76960d3adfc03..93d662de106e8 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -5982,7 +5982,7 @@ static int mlxsw_sp_router_fib_event(struct 
notifier_block *nb,
}
 
fib_work = kzalloc(sizeof(*fib_work), GFP_ATOMIC);
-   if (WARN_ON(!fib_work))
+   if (!fib_work)
return NOTIFY_BAD;
 
fib_work->mlxsw_sp = router->mlxsw_sp;
-- 
2.25.1





[PATCH 4.19 40/58] ALSA: usb-audio: add quirk for MacroSilicon MS2109

2020-07-14 Thread Greg Kroah-Hartman
From: Hector Martin 

commit e337bf19f6af38d5c3fa6d06cd594e0f890ca1ac upstream.

These devices claim to be 96kHz mono, but actually are 48kHz stereo with
swapped channels and unaligned transfers.

Cc: sta...@vger.kernel.org
Signed-off-by: Hector Martin 
Link: https://lore.kernel.org/r/20200702071433.237843-1-mar...@marcan.st
Signed-off-by: Takashi Iwai 
Signed-off-by: Greg Kroah-Hartman 

---
 sound/usb/quirks-table.h |   52 +++
 1 file changed, 52 insertions(+)

--- a/sound/usb/quirks-table.h
+++ b/sound/usb/quirks-table.h
@@ -3460,4 +3460,56 @@ ALC1220_VB_DESKTOP(0x26ce, 0x0a01), /* A
}
 },
 
+/*
+ * MacroSilicon MS2109 based HDMI capture cards
+ *
+ * These claim 96kHz 1ch in the descriptors, but are actually 48kHz 2ch.
+ * They also need QUIRK_AUDIO_ALIGN_TRANSFER, which makes one wonder if
+ * they pretend to be 96kHz mono as a workaround for stereo being broken
+ * by that...
+ *
+ * They also have swapped L-R channels, but that's for userspace to deal
+ * with.
+ */
+{
+   USB_DEVICE(0x534d, 0x2109),
+   .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) {
+   .vendor_name = "MacroSilicon",
+   .product_name = "MS2109",
+   .ifnum = QUIRK_ANY_INTERFACE,
+   .type = QUIRK_COMPOSITE,
+   .data = &(const struct snd_usb_audio_quirk[]) {
+   {
+   .ifnum = 2,
+   .type = QUIRK_AUDIO_ALIGN_TRANSFER,
+   },
+   {
+   .ifnum = 2,
+   .type = QUIRK_AUDIO_STANDARD_MIXER,
+   },
+   {
+   .ifnum = 3,
+   .type = QUIRK_AUDIO_FIXED_ENDPOINT,
+   .data = &(const struct audioformat) {
+   .formats = SNDRV_PCM_FMTBIT_S16_LE,
+   .channels = 2,
+   .iface = 3,
+   .altsetting = 1,
+   .altset_idx = 1,
+   .attributes = 0,
+   .endpoint = 0x82,
+   .ep_attr = USB_ENDPOINT_XFER_ISOC |
+   USB_ENDPOINT_SYNC_ASYNC,
+   .rates = SNDRV_PCM_RATE_CONTINUOUS,
+   .rate_min = 48000,
+   .rate_max = 48000,
+   }
+   },
+   {
+   .ifnum = -1
+   }
+   }
+   }
+},
+
 #undef USB_DEVICE_VENDOR_SPEC




[PATCH 4.19 01/58] KVM: s390: reduce number of IO pins to 1

2020-07-14 Thread Greg Kroah-Hartman
From: Christian Borntraeger 

[ Upstream commit 774911290c589e98e3638e73b24b0a4d4530e97c ]

The current number of KVM_IRQCHIP_NUM_PINS results in an order 3
allocation (32kb) for each guest start/restart. This can result in OOM
killer activity even with free swap when the memory is fragmented
enough:

kernel: qemu-system-s39 invoked oom-killer: 
gfp_mask=0x440dc0(GFP_KERNEL_ACCOUNT|__GFP_COMP|__GFP_ZERO), order=3, 
oom_score_adj=0
kernel: CPU: 1 PID: 357274 Comm: qemu-system-s39 Kdump: loaded Not tainted 
5.4.0-29-generic #33-Ubuntu
kernel: Hardware name: IBM 8562 T02 Z06 (LPAR)
kernel: Call Trace:
kernel: ([<0001f848fe2a>] show_stack+0x7a/0xc0)
kernel:  [<0001f8d3437a>] dump_stack+0x8a/0xc0
kernel:  [<0001f8687032>] dump_header+0x62/0x258
kernel:  [<0001f8686122>] oom_kill_process+0x172/0x180
kernel:  [<0001f8686abe>] out_of_memory+0xee/0x580
kernel:  [<0001f86e66b8>] __alloc_pages_slowpath+0xd18/0xe90
kernel:  [<0001f86e6ad4>] __alloc_pages_nodemask+0x2a4/0x320
kernel:  [<0001f86b1ab4>] kmalloc_order+0x34/0xb0
kernel:  [<0001f86b1b62>] kmalloc_order_trace+0x32/0xe0
kernel:  [<0001f84bb806>] kvm_set_irq_routing+0xa6/0x2e0
kernel:  [<0001f84c99a4>] kvm_arch_vm_ioctl+0x544/0x9e0
kernel:  [<0001f84b8936>] kvm_vm_ioctl+0x396/0x760
kernel:  [<0001f875df66>] do_vfs_ioctl+0x376/0x690
kernel:  [<0001f875e304>] ksys_ioctl+0x84/0xb0
kernel:  [<0001f875e39a>] __s390x_sys_ioctl+0x2a/0x40
kernel:  [<0001f8d55424>] system_call+0xd8/0x2c8

As far as I can tell s390x does not use the iopins as we bail our for
anything other than KVM_IRQ_ROUTING_S390_ADAPTER and the chip/pin is
only used for KVM_IRQ_ROUTING_IRQCHIP. So let us use a small number to
reduce the memory footprint.

Signed-off-by: Christian Borntraeger 
Reviewed-by: Cornelia Huck 
Reviewed-by: David Hildenbrand 
Link: https://lore.kernel.org/r/20200617083620.5409-1-borntrae...@de.ibm.com
Signed-off-by: Sasha Levin 
---
 arch/s390/include/asm/kvm_host.h | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index dad110e9f41b3..be8fa30a6ea6d 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -30,12 +30,12 @@
 #define KVM_USER_MEM_SLOTS 32
 
 /*
- * These seem to be used for allocating ->chip in the routing table,
- * which we don't use. 4096 is an out-of-thin-air value. If we need
- * to look at ->chip later on, we'll need to revisit this.
+ * These seem to be used for allocating ->chip in the routing table, which we
+ * don't use. 1 is as small as we can get to reduce the needed memory. If we
+ * need to look at ->chip later on, we'll need to revisit this.
  */
 #define KVM_NR_IRQCHIPS 1
-#define KVM_IRQCHIP_NUM_PINS 4096
+#define KVM_IRQCHIP_NUM_PINS 1
 #define KVM_HALT_POLL_NS_DEFAULT 8
 
 /* s390-specific vcpu->requests bit members */
-- 
2.25.1





[PATCH 4.19 25/58] net: qrtr: Fix an out of bounds read qrtr_endpoint_post()

2020-07-14 Thread Greg Kroah-Hartman
From: Dan Carpenter 

commit 8ff41cc21714704ef0158a546c3c4d07fae2c952 upstream.

This code assumes that the user passed in enough data for a
qrtr_hdr_v1 or qrtr_hdr_v2 struct, but it's not necessarily true.  If
the buffer is too small then it will read beyond the end.

Reported-by: Manivannan Sadhasivam 
Reported-by: syzbot+b8fe393f999a291a9...@syzkaller.appspotmail.com
Fixes: 194ccc88297a ("net: qrtr: Support decoding incoming v2 packets")
Signed-off-by: Dan Carpenter 
Signed-off-by: David S. Miller 
Signed-off-by: Greg Kroah-Hartman 

---
 net/qrtr/qrtr.c |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -266,7 +266,7 @@ int qrtr_endpoint_post(struct qrtr_endpo
unsigned int ver;
size_t hdrlen;
 
-   if (len & 3)
+   if (len == 0 || len & 3)
return -EINVAL;
 
skb = netdev_alloc_skb(NULL, len);
@@ -280,6 +280,8 @@ int qrtr_endpoint_post(struct qrtr_endpo
 
switch (ver) {
case QRTR_PROTO_VER_1:
+   if (len < sizeof(*v1))
+   goto err;
v1 = data;
hdrlen = sizeof(*v1);
 
@@ -293,6 +295,8 @@ int qrtr_endpoint_post(struct qrtr_endpo
size = le32_to_cpu(v1->size);
break;
case QRTR_PROTO_VER_2:
+   if (len < sizeof(*v2))
+   goto err;
v2 = data;
hdrlen = sizeof(*v2) + v2->optlen;
 




[PATCH 5.4 006/109] perf/x86/rapl: Fix RAPL config variable bug

2020-07-14 Thread Greg Kroah-Hartman
From: Stephane Eranian 

[ Upstream commit 16accae3d97f97d7f61c4ee5d0002bccdef59088 ]

This patch fixes a bug introduced by:

  fd3ae1e1587d6 ("perf/x86/rapl: Move RAPL support to common x86 code")

The Kconfig variable name was wrong. It was missing the CONFIG_ prefix.

Signed-off-by: Stephane Eranian 
Signed-off-by: Ingo Molnar 
Tested-by: Kim Phillips 
Acked-by: Peter Zijlstra 
Link: https://lore.kernel.org/r/20200528201614.250182-1-eran...@google.com
Signed-off-by: Sasha Levin 
---
 arch/x86/events/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/events/Makefile b/arch/x86/events/Makefile
index b418ef6878796..726e83c0a31a1 100644
--- a/arch/x86/events/Makefile
+++ b/arch/x86/events/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 obj-y  += core.o probe.o
-obj-$(PERF_EVENTS_INTEL_RAPL)  += rapl.o
+obj-$(CONFIG_PERF_EVENTS_INTEL_RAPL)   += rapl.o
 obj-y  += amd/
 obj-$(CONFIG_X86_LOCAL_APIC)+= msr.o
 obj-$(CONFIG_CPU_SUP_INTEL)+= intel/
-- 
2.25.1





[PATCH 4.19 58/58] s390/mm: fix huge pte soft dirty copying

2020-07-14 Thread Greg Kroah-Hartman
From: Janosch Frank 

commit 528a9539348a0234375dfaa1ca5dbbb2f8f8e8d2 upstream.

If the pmd is soft dirty we must mark the pte as soft dirty (and not dirty).
This fixes some cases for guest migration with huge page backings.

Cc:  # 4.8
Fixes: bc29b7ac1d9f ("s390/mm: clean up pte/pmd encoding")
Reviewed-by: Christian Borntraeger 
Reviewed-by: Gerald Schaefer 
Signed-off-by: Janosch Frank 
Signed-off-by: Heiko Carstens 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/s390/mm/hugetlbpage.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/s390/mm/hugetlbpage.c
+++ b/arch/s390/mm/hugetlbpage.c
@@ -117,7 +117,7 @@ static inline pte_t __rste_to_pte(unsign
 _PAGE_YOUNG);
 #ifdef CONFIG_MEM_SOFT_DIRTY
pte_val(pte) |= move_set_bit(rste, _SEGMENT_ENTRY_SOFT_DIRTY,
-_PAGE_DIRTY);
+_PAGE_SOFT_DIRTY);
 #endif
pte_val(pte) |= move_set_bit(rste, _SEGMENT_ENTRY_NOEXEC,
 _PAGE_NOEXEC);




[PATCH 4.19 49/58] module: Do not expose section addresses to non-CAP_SYSLOG

2020-07-14 Thread Greg Kroah-Hartman
From: Kees Cook 

commit b25a7c5af9051850d4f3d93ca500056ab6ec724b upstream.

The printing of section addresses in /sys/module/*/sections/* was not
using the correct credentials to evaluate visibility.

Before:

 # cat /sys/module/*/sections/.*text
 0xc0458000
 ...
 # capsh --drop=CAP_SYSLOG -- -c "cat /sys/module/*/sections/.*text"
 0xc0458000
 ...

After:

 # cat /sys/module/*/sections/*.text
 0xc0458000
 ...
 # capsh --drop=CAP_SYSLOG -- -c "cat /sys/module/*/sections/.*text"
 0x
 ...

Additionally replaces the existing (safe) /proc/modules check with
file->f_cred for consistency.

Reported-by: Dominik Czarnota 
Fixes: be71eda5383f ("module: Fix display of wrong module .text address")
Cc: sta...@vger.kernel.org
Tested-by: Jessica Yu 
Acked-by: Jessica Yu 
Signed-off-by: Kees Cook 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/module.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1471,8 +1471,8 @@ static ssize_t module_sect_read(struct f
if (pos != 0)
return -EINVAL;
 
-   return sprintf(buf, "0x%px\n", kptr_restrict < 2 ?
-  (void *)sattr->address : NULL);
+   return sprintf(buf, "0x%px\n",
+  kallsyms_show_value(file->f_cred) ? (void 
*)sattr->address : NULL);
 }
 
 static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
@@ -4260,7 +4260,7 @@ static int modules_open(struct inode *in
 
if (!err) {
struct seq_file *m = file->private_data;
-   m->private = kallsyms_show_value(current_cred()) ? NULL : (void 
*)8ul;
+   m->private = kallsyms_show_value(file->f_cred) ? NULL : (void 
*)8ul;
}
 
return err;




[PATCH 4.19 27/58] net: cxgb4: fix return error value in t4_prep_fw

2020-07-14 Thread Greg Kroah-Hartman
From: Li Heng 

[ Upstream commit 8a259e6b73ad8181b0b2ef338b35043433db1075 ]

t4_prep_fw goto bye tag with positive return value when something
bad happened and which can not free resource in adap_init0.
so fix it to return negative value.

Fixes: 16e47624e76b ("cxgb4: Add new scheme to update T4/T5 firmware")
Reported-by: Hulk Robot 
Signed-off-by: Li Heng 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 5934ec9b6a31f..abc2a66754bd0 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3499,7 +3499,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info 
*fw_info,
drv_fw = &fw_info->fw_hdr;
 
/* Read the header of the firmware on the card */
-   ret = -t4_read_flash(adap, FLASH_FW_START,
+   ret = t4_read_flash(adap, FLASH_FW_START,
sizeof(*card_fw) / sizeof(uint32_t),
(uint32_t *)card_fw, 1);
if (ret == 0) {
@@ -3528,8 +3528,8 @@ int t4_prep_fw(struct adapter *adap, struct fw_info 
*fw_info,
   should_install_fs_fw(adap, card_fw_usable,
be32_to_cpu(fs_fw->fw_ver),
be32_to_cpu(card_fw->fw_ver))) {
-   ret = -t4_fw_upgrade(adap, adap->mbox, fw_data,
-fw_size, 0);
+   ret = t4_fw_upgrade(adap, adap->mbox, fw_data,
+   fw_size, 0);
if (ret != 0) {
dev_err(adap->pdev_dev,
"failed to install firmware: %d\n", ret);
@@ -3560,7 +3560,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info 
*fw_info,
FW_HDR_FW_VER_MICRO_G(c), FW_HDR_FW_VER_BUILD_G(c),
FW_HDR_FW_VER_MAJOR_G(k), FW_HDR_FW_VER_MINOR_G(k),
FW_HDR_FW_VER_MICRO_G(k), FW_HDR_FW_VER_BUILD_G(k));
-   ret = EINVAL;
+   ret = -EINVAL;
goto bye;
}
 
-- 
2.25.1





[PATCH 5.4 008/109] drm/ttm: Fix dma_fence refcnt leak when adding move fence

2020-07-14 Thread Greg Kroah-Hartman
From: Xiyu Yang 

[ Upstream commit 11425c4519e2c974a100fc984867046d905b9380 ]

ttm_bo_add_move_fence() invokes dma_fence_get(), which returns a
reference of the specified dma_fence object to "fence" with increased
refcnt.

When ttm_bo_add_move_fence() returns, local variable "fence" becomes
invalid, so the refcount should be decreased to keep refcount balanced.

The reference counting issue happens in one exception handling path of
ttm_bo_add_move_fence(). When no_wait_gpu flag is equals to true, the
function forgets to decrease the refcnt increased by dma_fence_get(),
causing a refcnt leak.

Fix this issue by calling dma_fence_put() when no_wait_gpu flag is
equals to true.

Signed-off-by: Xiyu Yang 
Signed-off-by: Xin Tan 
Reviewed-by: Christian König 
Link: https://patchwork.freedesktop.org/patch/370221/
Signed-off-by: Christian König 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index abf165b2f64fc..3ce8ad7603c7f 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -941,8 +941,10 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object 
*bo,
if (!fence)
return 0;
 
-   if (no_wait_gpu)
+   if (no_wait_gpu) {
+   dma_fence_put(fence);
return -EBUSY;
+   }
 
dma_resv_add_shared_fence(bo->base.resv, fence);
 
-- 
2.25.1





[PATCH 4.19 48/58] module: Refactor section attr into bin attribute

2020-07-14 Thread Greg Kroah-Hartman
From: Kees Cook 

commit ed66f991bb19d94cae5d38f77de81f96aac7813f upstream.

In order to gain access to the open file's f_cred for kallsym visibility
permission checks, refactor the module section attributes to use the
bin_attribute instead of attribute interface. Additionally removes the
redundant "name" struct member.

Cc: sta...@vger.kernel.org
Reviewed-by: Greg Kroah-Hartman 
Tested-by: Jessica Yu 
Acked-by: Jessica Yu 
Signed-off-by: Kees Cook 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/module.c |   45 -
 1 file changed, 24 insertions(+), 21 deletions(-)

--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1451,8 +1451,7 @@ static inline bool sect_empty(const Elf_
 }
 
 struct module_sect_attr {
-   struct module_attribute mattr;
-   char *name;
+   struct bin_attribute battr;
unsigned long address;
 };
 
@@ -1462,11 +1461,16 @@ struct module_sect_attrs {
struct module_sect_attr attrs[0];
 };
 
-static ssize_t module_sect_show(struct module_attribute *mattr,
-   struct module_kobject *mk, char *buf)
+static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
+   struct bin_attribute *battr,
+   char *buf, loff_t pos, size_t count)
 {
struct module_sect_attr *sattr =
-   container_of(mattr, struct module_sect_attr, mattr);
+   container_of(battr, struct module_sect_attr, battr);
+
+   if (pos != 0)
+   return -EINVAL;
+
return sprintf(buf, "0x%px\n", kptr_restrict < 2 ?
   (void *)sattr->address : NULL);
 }
@@ -1476,7 +1480,7 @@ static void free_sect_attrs(struct modul
unsigned int section;
 
for (section = 0; section < sect_attrs->nsections; section++)
-   kfree(sect_attrs->attrs[section].name);
+   kfree(sect_attrs->attrs[section].battr.attr.name);
kfree(sect_attrs);
 }
 
@@ -1485,42 +1489,41 @@ static void add_sect_attrs(struct module
unsigned int nloaded = 0, i, size[2];
struct module_sect_attrs *sect_attrs;
struct module_sect_attr *sattr;
-   struct attribute **gattr;
+   struct bin_attribute **gattr;
 
/* Count loaded sections and allocate structures */
for (i = 0; i < info->hdr->e_shnum; i++)
if (!sect_empty(&info->sechdrs[i]))
nloaded++;
size[0] = ALIGN(struct_size(sect_attrs, attrs, nloaded),
-   sizeof(sect_attrs->grp.attrs[0]));
-   size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.attrs[0]);
+   sizeof(sect_attrs->grp.bin_attrs[0]));
+   size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.bin_attrs[0]);
sect_attrs = kzalloc(size[0] + size[1], GFP_KERNEL);
if (sect_attrs == NULL)
return;
 
/* Setup section attributes. */
sect_attrs->grp.name = "sections";
-   sect_attrs->grp.attrs = (void *)sect_attrs + size[0];
+   sect_attrs->grp.bin_attrs = (void *)sect_attrs + size[0];
 
sect_attrs->nsections = 0;
sattr = §_attrs->attrs[0];
-   gattr = §_attrs->grp.attrs[0];
+   gattr = §_attrs->grp.bin_attrs[0];
for (i = 0; i < info->hdr->e_shnum; i++) {
Elf_Shdr *sec = &info->sechdrs[i];
if (sect_empty(sec))
continue;
+   sysfs_bin_attr_init(&sattr->battr);
sattr->address = sec->sh_addr;
-   sattr->name = kstrdup(info->secstrings + sec->sh_name,
-   GFP_KERNEL);
-   if (sattr->name == NULL)
+   sattr->battr.attr.name =
+   kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
+   if (sattr->battr.attr.name == NULL)
goto out;
sect_attrs->nsections++;
-   sysfs_attr_init(&sattr->mattr.attr);
-   sattr->mattr.show = module_sect_show;
-   sattr->mattr.store = NULL;
-   sattr->mattr.attr.name = sattr->name;
-   sattr->mattr.attr.mode = S_IRUSR;
-   *(gattr++) = &(sattr++)->mattr.attr;
+   sattr->battr.read = module_sect_read;
+   sattr->battr.size = 3 /* "0x", "\n" */ + (BITS_PER_LONG / 4);
+   sattr->battr.attr.mode = 0400;
+   *(gattr++) = &(sattr++)->battr;
}
*gattr = NULL;
 
@@ -1610,7 +1613,7 @@ static void add_notes_attrs(struct modul
continue;
if (info->sechdrs[i].sh_type == SHT_NOTE) {
sysfs_bin_attr_init(nattr);
-   nattr->attr.name = mod->sect_attrs->attrs[loaded].name;
+   nattr->attr.name = 
mod->sect_attrs->attrs[loaded].battr.attr.name;
nattr->attr.mode = S_IRUGO;
nattr->siz

[PATCH 4.19 32/58] arm64: kgdb: Fix single-step exception handling oops

2020-07-14 Thread Greg Kroah-Hartman
From: Wei Li 

[ Upstream commit 8523c006264df65aac7d77284cc69aac46a6f842 ]

After entering kdb due to breakpoint, when we execute 'ss' or 'go' (will
delay installing breakpoints, do single-step first), it won't work
correctly, and it will enter kdb due to oops.

It's because the reason gotten in kdb_stub() is not as expected, and it
seems that the ex_vector for single-step should be 0, like what arch
powerpc/sh/parisc has implemented.

Before the patch:
Entering kdb (current=0x8000119e2dc0, pid 0) on processor 0 due to Keyboard 
Entry
[0]kdb> bp printk
Instruction(i) BP #0 at 0x8000101486cc (printk)
is enabled   addr at 8000101486cc, hardtype=0 installed=0

[0]kdb> g

/ # echo h > /proc/sysrq-trigger

Entering kdb (current=0xfa878040, pid 266) on processor 3 due to 
Breakpoint @ 0x8000101486cc
[3]kdb> ss

Entering kdb (current=0xfa878040, pid 266) on processor 3 Oops: (null)
due to oops @ 0x800010082ab8
CPU: 3 PID: 266 Comm: sh Not tainted 5.7.0-rc4-13839-gf0e5ad491718 #6
Hardware name: linux,dummy-virt (DT)
pstate: 0085 (nzcv daIf -PAN -UAO)
pc : el1_irq+0x78/0x180
lr : __handle_sysrq+0x80/0x190
sp : 800015003bf0
x29: 800015003d20 x28: fa878040
x27:  x26: 80001126b1f0
x25: 800011b6a0d8 x24: 
x23: 8025 x22: 8000101486cc
x21: 800015003d30 x20: 
x19: 8000119f2000 x18: 
x17:  x16: 
x15:  x14: 
x13:  x12: 
x11:  x10: 
x9 :  x8 : 800015003e50
x7 : 0002 x6 : 380b9990
x5 : 8000106e99e8 x4 : fadd83c0
x3 :  x2 : 800011b6a0d8
x1 : 800011b6a000 x0 : 80001130c9d8
Call trace:
 el1_irq+0x78/0x180
 printk+0x0/0x84
 write_sysrq_trigger+0xb0/0x118
 proc_reg_write+0xb4/0xe0
 __vfs_write+0x18/0x40
 vfs_write+0xb0/0x1b8
 ksys_write+0x64/0xf0
 __arm64_sys_write+0x14/0x20
 el0_svc_common.constprop.2+0xb0/0x168
 do_el0_svc+0x20/0x98
 el0_sync_handler+0xec/0x1a8
 el0_sync+0x140/0x180

[3]kdb>

After the patch:
Entering kdb (current=0x8000119e2dc0, pid 0) on processor 0 due to Keyboard 
Entry
[0]kdb> bp printk
Instruction(i) BP #0 at 0x8000101486cc (printk)
is enabled   addr at 8000101486cc, hardtype=0 installed=0

[0]kdb> g

/ # echo h > /proc/sysrq-trigger

Entering kdb (current=0xfa852bc0, pid 268) on processor 0 due to 
Breakpoint @ 0x8000101486cc
[0]kdb> g

Entering kdb (current=0xfa852bc0, pid 268) on processor 0 due to 
Breakpoint @ 0x8000101486cc
[0]kdb> ss

Entering kdb (current=0xfa852bc0, pid 268) on processor 0 due to SS 
trap @ 0x800010082ab8
[0]kdb>

Fixes: 44679a4f142b ("arm64: KGDB: Add step debugging support")
Signed-off-by: Wei Li 
Tested-by: Douglas Anderson 
Reviewed-by: Douglas Anderson 
Link: https://lore.kernel.org/r/20200509214159.19680-2-liwei...@huawei.com
Signed-off-by: Will Deacon 
Signed-off-by: Sasha Levin 
---
 arch/arm64/kernel/kgdb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c
index 35f184a8fd85a..8815b5457dd0b 100644
--- a/arch/arm64/kernel/kgdb.c
+++ b/arch/arm64/kernel/kgdb.c
@@ -269,7 +269,7 @@ static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned 
int esr)
if (user_mode(regs) || !kgdb_single_step)
return DBG_HOOK_ERROR;
 
-   kgdb_handle_exception(1, SIGTRAP, 0, regs);
+   kgdb_handle_exception(0, SIGTRAP, 0, regs);
return DBG_HOOK_HANDLED;
 }
 NOKPROBE_SYMBOL(kgdb_step_brk_fn);
-- 
2.25.1





[PATCH 4.19 55/58] dm: use noio when sending kobject event

2020-07-14 Thread Greg Kroah-Hartman
From: Mikulas Patocka 

commit 6958c1c640af8c3f40fa8a2eee3b5b905d95b677 upstream.

kobject_uevent may allocate memory and it may be called while there are dm
devices suspended. The allocation may recurse into a suspended device,
causing a deadlock. We must set the noio flag when sending a uevent.

The observed deadlock was reported here:
https://www.redhat.com/archives/dm-devel/2020-March/msg00025.html

Reported-by: Khazhismel Kumykov 
Reported-by: Tahsin Erdogan 
Reported-by: Gabriel Krisman Bertazi 
Signed-off-by: Mikulas Patocka 
Cc: sta...@vger.kernel.org
Signed-off-by: Mike Snitzer 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/md/dm.c |   15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2853,17 +2854,25 @@ EXPORT_SYMBOL_GPL(dm_internal_resume_fas
 int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
   unsigned cookie)
 {
+   int r;
+   unsigned noio_flag;
char udev_cookie[DM_COOKIE_LENGTH];
char *envp[] = { udev_cookie, NULL };
 
+   noio_flag = memalloc_noio_save();
+
if (!cookie)
-   return kobject_uevent(&disk_to_dev(md->disk)->kobj, action);
+   r = kobject_uevent(&disk_to_dev(md->disk)->kobj, action);
else {
snprintf(udev_cookie, DM_COOKIE_LENGTH, "%s=%u",
 DM_COOKIE_ENV_VAR_NAME, cookie);
-   return kobject_uevent_env(&disk_to_dev(md->disk)->kobj,
- action, envp);
+   r = kobject_uevent_env(&disk_to_dev(md->disk)->kobj,
+  action, envp);
}
+
+   memalloc_noio_restore(noio_flag);
+
+   return r;
 }
 
 uint32_t dm_next_uevent_seq(struct mapped_device *md)




[PATCH 5.4 025/109] s390/kasan: fix early pgm check handler execution

2020-07-14 Thread Greg Kroah-Hartman
From: Vasily Gorbik 

[ Upstream commit 998f5bbe3dbdab81c1cfb1aef7c3892f5d24f6c7 ]

Currently if early_pgm_check_handler is called it ends up in pgm check
loop. The problem is that early_pgm_check_handler is instrumented by
KASAN but executed without DAT flag enabled which leads to addressing
exception when KASAN checks try to access shadow memory.

Fix that by executing early handlers with DAT flag on under KASAN as
expected.

Reported-and-tested-by: Alexander Egorenkov 
Reviewed-by: Heiko Carstens 
Signed-off-by: Vasily Gorbik 
Signed-off-by: Heiko Carstens 
Signed-off-by: Sasha Levin 
---
 arch/s390/kernel/early.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index b432d63d0b373..2531776cf6cf9 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -169,6 +169,8 @@ static noinline __init void setup_lowcore_early(void)
psw_t psw;
 
psw.mask = PSW_MASK_BASE | PSW_DEFAULT_KEY | PSW_MASK_EA | PSW_MASK_BA;
+   if (IS_ENABLED(CONFIG_KASAN))
+   psw.mask |= PSW_MASK_DAT;
psw.addr = (unsigned long) s390_base_ext_handler;
S390_lowcore.external_new_psw = psw;
psw.addr = (unsigned long) s390_base_pgm_handler;
-- 
2.25.1





[PATCH 08/23] md: simplify md_setup_drive

2020-07-14 Thread Christoph Hellwig
Move the loop over the possible arrays into the caller to remove a level
of indentation for the whole function.

Signed-off-by: Christoph Hellwig 
Acked-by: Song Liu 
---
 drivers/md/md-autodetect.c | 203 ++---
 1 file changed, 101 insertions(+), 102 deletions(-)

diff --git a/drivers/md/md-autodetect.c b/drivers/md/md-autodetect.c
index 6bc9b734eee6ff..a43a8f1580584c 100644
--- a/drivers/md/md-autodetect.c
+++ b/drivers/md/md-autodetect.c
@@ -27,7 +27,7 @@ static int __initdata raid_noautodetect=1;
 #endif
 static int __initdata raid_autopart;
 
-static struct {
+static struct md_setup_args {
int minor;
int partitioned;
int level;
@@ -126,122 +126,117 @@ static inline int create_dev(char *name, dev_t dev)
return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
 }
 
-static void __init md_setup_drive(void)
+static void __init md_setup_drive(struct md_setup_args *args)
 {
-   int minor, i, ent, partitioned;
+   int minor, i, partitioned;
dev_t dev;
dev_t devices[MD_SB_DISKS+1];
+   int fd;
+   int err = 0;
+   char *devname;
+   mdu_disk_info_t dinfo;
+   char name[16];
 
-   for (ent = 0; ent < md_setup_ents ; ent++) {
-   int fd;
-   int err = 0;
-   char *devname;
-   mdu_disk_info_t dinfo;
-   char name[16];
+   minor = args->minor;
+   partitioned = args->partitioned;
+   devname = args->device_names;
 
-   minor = md_setup_args[ent].minor;
-   partitioned = md_setup_args[ent].partitioned;
-   devname = md_setup_args[ent].device_names;
+   sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
+   if (partitioned)
+   dev = MKDEV(mdp_major, minor << MdpMinorShift);
+   else
+   dev = MKDEV(MD_MAJOR, minor);
+   create_dev(name, dev);
+   for (i = 0; i < MD_SB_DISKS && devname != NULL; i++) {
+   struct kstat stat;
+   char *p;
+   char comp_name[64];
 
-   sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
-   if (partitioned)
-   dev = MKDEV(mdp_major, minor << MdpMinorShift);
-   else
-   dev = MKDEV(MD_MAJOR, minor);
-   create_dev(name, dev);
-   for (i = 0; i < MD_SB_DISKS && devname != NULL; i++) {
-   struct kstat stat;
-   char *p;
-   char comp_name[64];
+   p = strchr(devname, ',');
+   if (p)
+   *p++ = 0;
 
-   p = strchr(devname, ',');
-   if (p)
-   *p++ = 0;
+   dev = name_to_dev_t(devname);
+   if (strncmp(devname, "/dev/", 5) == 0)
+   devname += 5;
+   snprintf(comp_name, 63, "/dev/%s", devname);
+   if (vfs_stat(comp_name, &stat) == 0 && S_ISBLK(stat.mode))
+   dev = new_decode_dev(stat.rdev);
+   if (!dev) {
+   printk(KERN_WARNING "md: Unknown device name: %s\n", 
devname);
+   break;
+   }
 
-   dev = name_to_dev_t(devname);
-   if (strncmp(devname, "/dev/", 5) == 0)
-   devname += 5;
-   snprintf(comp_name, 63, "/dev/%s", devname);
-   if (vfs_stat(comp_name, &stat) == 0 &&
-   S_ISBLK(stat.mode))
-   dev = new_decode_dev(stat.rdev);
-   if (!dev) {
-   printk(KERN_WARNING "md: Unknown device name: 
%s\n", devname);
-   break;
-   }
+   devices[i] = dev;
+   devname = p;
+   }
+   devices[i] = 0;
 
-   devices[i] = dev;
+   if (!i)
+   return;
 
-   devname = p;
-   }
-   devices[i] = 0;
+   printk(KERN_INFO "md: Loading md%s%d: %s\n",
+   partitioned ? "_d" : "", minor,
+   args->device_names);
 
-   if (!i)
-   continue;
+   fd = ksys_open(name, 0, 0);
+   if (fd < 0) {
+   printk(KERN_ERR "md: open failed - cannot start "
+   "array %s\n", name);
+   return;
+   }
+   if (ksys_ioctl(fd, SET_ARRAY_INFO, 0) == -EBUSY) {
+   printk(KERN_WARNING
+  "md: Ignoring md=%d, already autodetected. (Use 
raid=noautodetect)\n",
+  minor);
+   ksys_close(fd);
+   return;
+   }
 
-   printk(KERN_INFO "md: Loading md%s%d: %s\n",
-   partitioned ? "_d" : "", minor,
-   

[PATCH 06/23] md: remove the autoscan partition re-read

2020-07-14 Thread Christoph Hellwig
devfs is long gone, and autoscan works just fine without this these days.

Signed-off-by: Christoph Hellwig 
Acked-by: Song Liu 
---
 drivers/md/md-autodetect.c | 10 --
 1 file changed, 10 deletions(-)

diff --git a/drivers/md/md-autodetect.c b/drivers/md/md-autodetect.c
index 0eb746211ed53c..6bc9b734eee6ff 100644
--- a/drivers/md/md-autodetect.c
+++ b/drivers/md/md-autodetect.c
@@ -240,16 +240,6 @@ static void __init md_setup_drive(void)
err = ksys_ioctl(fd, RUN_ARRAY, 0);
if (err)
printk(KERN_WARNING "md: starting md%d failed\n", 
minor);
-   else {
-   /* reread the partition table.
-* I (neilb) and not sure why this is needed, but I 
cannot
-* boot a kernel with devfs compiled in from 
partitioned md
-* array without it
-*/
-   ksys_close(fd);
-   fd = ksys_open(name, 0, 0);
-   ksys_ioctl(fd, BLKRRPART, 0);
-   }
ksys_close(fd);
}
 }
-- 
2.27.0



Re: [RFC PATCH 11/15] memremap: Add zone device access protection

2020-07-14 Thread Ira Weiny
On Tue, Jul 14, 2020 at 10:40:57AM +0200, Peter Zijlstra wrote:
> On Tue, Jul 14, 2020 at 12:02:16AM -0700, ira.we...@intel.com wrote:
> 
> > +static pgprot_t dev_protection_enable_get(struct dev_pagemap *pgmap, 
> > pgprot_t prot)
> > +{
> > +   if (pgmap->flags & PGMAP_PROT_ENABLED && dev_page_pkey != PKEY_INVALID) 
> > {
> > +   pgprotval_t val = pgprot_val(prot);
> > +
> > +   mutex_lock(&dev_prot_enable_lock);
> > +   dev_protection_enable++;
> > +   /* Only enable the static branch 1 time */
> > +   if (dev_protection_enable == 1)
> > +   static_branch_enable(&dev_protection_static_key);
> > +   mutex_unlock(&dev_prot_enable_lock);
> > +
> > +   prot = __pgprot(val | _PAGE_PKEY(dev_page_pkey));
> > +   }
> > +   return prot;
> > +}
> > +
> > +static void dev_protection_enable_put(struct dev_pagemap *pgmap)
> > +{
> > +   if (pgmap->flags & PGMAP_PROT_ENABLED && dev_page_pkey != PKEY_INVALID) 
> > {
> > +   mutex_lock(&dev_prot_enable_lock);
> > +   dev_protection_enable--;
> > +   if (dev_protection_enable == 0)
> > +   static_branch_disable(&dev_protection_static_key);
> > +   mutex_unlock(&dev_prot_enable_lock);
> > +   }
> > +}
> 
> That's an anti-pattern vs static_keys, I'm thinking you actually want
> static_key_slow_{inc,dec}() instead of {enable,disable}().

Thanks.  I'll go read the doc for those as I'm not familiar with them.

Ira


[PATCH 04/23] md: move the early init autodetect code to drivers/md/

2020-07-14 Thread Christoph Hellwig
Just like the NFS and CIFS root code this better lives with the
driver it is tightly integrated with.

Signed-off-by: Christoph Hellwig 
Acked-by: Song Liu 
---
 drivers/md/Makefile   |  3 +++
 init/do_mounts_md.c => drivers/md/md-autodetect.c | 15 +--
 include/linux/raid/detect.h   |  8 
 init/Makefile |  1 -
 init/do_mounts.c  |  1 +
 init/do_mounts.h  | 10 --
 6 files changed, 25 insertions(+), 13 deletions(-)
 rename init/do_mounts_md.c => drivers/md/md-autodetect.c (96%)

diff --git a/drivers/md/Makefile b/drivers/md/Makefile
index 31840f95cd408b..6d3e234dc46a5d 100644
--- a/drivers/md/Makefile
+++ b/drivers/md/Makefile
@@ -43,6 +43,9 @@ obj-$(CONFIG_MD_FAULTY)   += faulty.o
 obj-$(CONFIG_MD_CLUSTER)   += md-cluster.o
 obj-$(CONFIG_BCACHE)   += bcache/
 obj-$(CONFIG_BLK_DEV_MD)   += md-mod.o
+ifeq ($(CONFIG_BLK_DEV_MD),y)
+obj-y  += md-autodetect.o
+endif
 obj-$(CONFIG_BLK_DEV_DM)   += dm-mod.o
 obj-$(CONFIG_BLK_DEV_DM_BUILTIN) += dm-builtin.o
 obj-$(CONFIG_DM_UNSTRIPED) += dm-unstripe.o
diff --git a/init/do_mounts_md.c b/drivers/md/md-autodetect.c
similarity index 96%
rename from init/do_mounts_md.c
rename to drivers/md/md-autodetect.c
index 359363e85ccd0b..fe806f7b9759a1 100644
--- a/init/do_mounts_md.c
+++ b/drivers/md/md-autodetect.c
@@ -1,10 +1,15 @@
 // SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
-#include "do_mounts.h"
-
 /*
  * When md (and any require personalities) are compiled into the kernel
  * (not a module), arrays can be assembles are boot time using with AUTODETECT
@@ -114,6 +119,12 @@ static int __init md_setup(char *str)
return 1;
 }
 
+static inline int create_dev(char *name, dev_t dev)
+{
+   ksys_unlink(name);
+   return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
+}
+
 static void __init md_setup_drive(void)
 {
int minor, i, ent, partitioned;
diff --git a/include/linux/raid/detect.h b/include/linux/raid/detect.h
index 37dd3f40cd316e..1f029a71c3ef05 100644
--- a/include/linux/raid/detect.h
+++ b/include/linux/raid/detect.h
@@ -1,3 +1,11 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
 void md_autodetect_dev(dev_t dev);
+
+#ifdef CONFIG_BLK_DEV_MD
+void md_run_setup(void);
+#else
+static inline void md_run_setup(void)
+{
+}
+#endif
diff --git a/init/Makefile b/init/Makefile
index 57499b1ff4714d..6bc37f64b3617c 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -18,7 +18,6 @@ obj-y  += init_task.o
 mounts-y   := do_mounts.o
 mounts-$(CONFIG_BLK_DEV_RAM)   += do_mounts_rd.o
 mounts-$(CONFIG_BLK_DEV_INITRD)+= do_mounts_initrd.o
-mounts-$(CONFIG_BLK_DEV_MD)+= do_mounts_md.o
 
 # dependencies on generated files need to be listed explicitly
 $(obj)/version.o: include/generated/compile.h
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 29d326b6c29d2d..1a4dfa17fb2899 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "do_mounts.h"
diff --git a/init/do_mounts.h b/init/do_mounts.h
index 7513d1c14d13fe..50d6c8941e15a1 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -41,13 +41,3 @@ bool __init initrd_load(void);
 static inline bool initrd_load(void) { return false; }
 
 #endif
-
-#ifdef CONFIG_BLK_DEV_MD
-
-void md_run_setup(void);
-
-#else
-
-static inline void md_run_setup(void) {}
-
-#endif
-- 
2.27.0



[PATCH 5.4 026/109] drm/sun4i: mixer: Call of_dma_configure if theres an IOMMU

2020-07-14 Thread Greg Kroah-Hartman
From: Maxime Ripard 

[ Upstream commit 842ec61f4006a6477a9deaedd69131e9f46e4cb5 ]

The main DRM device is actually a virtual device so it doesn't have the
iommus property, which is instead on the DMA masters, in this case the
mixers.

Add a call to of_dma_configure with the mixers DT node but on the DRM
virtual device to configure it in the same way than the mixers.

Reviewed-by: Paul Kocialkowski 
Signed-off-by: Maxime Ripard 
Link: 
https://patchwork.freedesktop.org/patch/msgid/9a4daf438dd3f2fe07afb23688bfb793a0613d7d.1589378833.git-series.max...@cerno.tech
(cherry picked from commit b718102dbdfd0285ad559687a30e27cc9124e592)
[Maxime: Applied to -fixes since it missed the merge window and display is
 broken without it]
Signed-off-by: Maxime Ripard 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/sun4i/sun8i_mixer.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c 
b/drivers/gpu/drm/sun4i/sun8i_mixer.c
index 18b4881f44814..e24f225d80f1f 100644
--- a/drivers/gpu/drm/sun4i/sun8i_mixer.c
+++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c
@@ -452,6 +452,19 @@ static int sun8i_mixer_bind(struct device *dev, struct 
device *master,
mixer->engine.ops = &sun8i_engine_ops;
mixer->engine.node = dev->of_node;
 
+   if (of_find_property(dev->of_node, "iommus", NULL)) {
+   /*
+* This assume we have the same DMA constraints for
+* all our the mixers in our pipeline. This sounds
+* bad, but it has always been the case for us, and
+* DRM doesn't do per-device allocation either, so we
+* would need to fix DRM first...
+*/
+   ret = of_dma_configure(drm->dev, dev->of_node, true);
+   if (ret)
+   return ret;
+   }
+
/*
 * While this function can fail, we shouldn't do anything
 * if this happens. Some early DE2 DT entries don't provide
-- 
2.25.1





[PATCH 12/23] initrd: switch initrd loading to struct file based APIs

2020-07-14 Thread Christoph Hellwig
There is no good reason to mess with file descriptors from in-kernel
code, switch the initrd loading to struct file based read and writes
instead.

Signed-off-by: Christoph Hellwig 
---
 fs/read_write.c  |  2 +-
 include/linux/syscalls.h |  1 -
 init/do_mounts_rd.c  | 82 
 3 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 4fb797822567a6..5db58b8c78d0dd 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -301,7 +301,7 @@ loff_t vfs_llseek(struct file *file, loff_t offset, int 
whence)
 }
 EXPORT_SYMBOL(vfs_llseek);
 
-off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence)
+static off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence)
 {
off_t retval;
struct fd f = fdget_pos(fd);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index b951a87da9877c..10843a6adb770d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1246,7 +1246,6 @@ int ksys_fchown(unsigned int fd, uid_t user, gid_t group);
 int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,
unsigned int count);
 int ksys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
-off_t ksys_lseek(unsigned int fd, off_t offset, unsigned int whence);
 ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
 void ksys_sync(void);
 int ksys_unshare(unsigned long unshare_flags);
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index 27b1bccf6f12a8..7b64390c075043 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -31,7 +31,8 @@ static int __init ramdisk_start_setup(char *str)
 }
 __setup("ramdisk_start=", ramdisk_start_setup);
 
-static int __init crd_load(int in_fd, int out_fd, decompress_fn deco);
+static int __init crd_load(struct file *in_file, struct file *out_file,
+   decompress_fn deco);
 
 /*
  * This routine tries to find a RAM disk image to load, and returns the
@@ -53,7 +54,8 @@ static int __init crd_load(int in_fd, int out_fd, 
decompress_fn deco);
  * lz4
  */
 static int __init
-identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)
+identify_ramdisk_image(struct file *file, int start_block,
+   decompress_fn *decompressor)
 {
const int size = 512;
struct minix_super_block *minixsb;
@@ -64,6 +66,7 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn 
*decompressor)
unsigned char *buf;
const char *compress_name;
unsigned long n;
+   loff_t pos;
 
buf = kmalloc(size, GFP_KERNEL);
if (!buf)
@@ -78,8 +81,8 @@ identify_ramdisk_image(int fd, int start_block, decompress_fn 
*decompressor)
/*
 * Read block 0 to test for compressed kernel
 */
-   ksys_lseek(fd, start_block * BLOCK_SIZE, 0);
-   ksys_read(fd, buf, size);
+   pos = start_block * BLOCK_SIZE;
+   kernel_read(file, buf, size, &pos);
 
*decompressor = decompress_method(buf, size, &compress_name);
if (compress_name) {
@@ -124,8 +127,8 @@ identify_ramdisk_image(int fd, int start_block, 
decompress_fn *decompressor)
/*
 * Read 512 bytes further to check if cramfs is padded
 */
-   ksys_lseek(fd, start_block * BLOCK_SIZE + 0x200, 0);
-   ksys_read(fd, buf, size);
+   pos = start_block * BLOCK_SIZE + 0x200;
+   kernel_read(file, buf, size, &pos);
 
if (cramfsb->magic == CRAMFS_MAGIC) {
printk(KERN_NOTICE
@@ -138,8 +141,8 @@ identify_ramdisk_image(int fd, int start_block, 
decompress_fn *decompressor)
/*
 * Read block 1 to test for minix and ext2 superblock
 */
-   ksys_lseek(fd, (start_block+1) * BLOCK_SIZE, 0);
-   ksys_read(fd, buf, size);
+   pos = (start_block + 1) * BLOCK_SIZE;
+   kernel_read(file, buf, size, &pos);
 
/* Try minix */
if (minixsb->s_magic == MINIX_SUPER_MAGIC ||
@@ -166,15 +169,23 @@ identify_ramdisk_image(int fd, int start_block, 
decompress_fn *decompressor)
   start_block);
 
 done:
-   ksys_lseek(fd, start_block * BLOCK_SIZE, 0);
kfree(buf);
return nblocks;
 }
 
+static unsigned long nr_blocks(struct file *file)
+{
+   struct inode *inode = file->f_mapping->host;
+
+   if (!S_ISBLK(inode->i_mode))
+   return 0;
+   return i_size_read(inode) >> 10;
+}
+
 int __init rd_load_image(char *from)
 {
int res = 0;
-   int in_fd, out_fd;
+   struct file *in_file, *out_file;
unsigned long rd_blocks, devblocks;
int nblocks, i;
char *buf = NULL;
@@ -184,20 +195,20 @@ int __init rd_load_image(char *from)
char rotator[4] = { '|' , '/' , '-' , '\\' };
 #endif
 
-   out_fd = ksys_open("/dev/ram", O_RDWR, 0);
-   if (out_fd < 0)
+   out_file = filp_open("/dev/ram", O_RDWR, 0);
+   if (IS_ERR(out_file))
goto

[PATCH 17/23] initramfs: switch initramfs unpacking to struct file based APIs

2020-07-14 Thread Christoph Hellwig
There is no good reason to mess with file descriptors from in-kernel
code, switch the initramfs unpacking to struct file based write
instead.

Signed-off-by: Christoph Hellwig 
---
 init/initramfs.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index d42ec8329cd840..c335920e5ecc2d 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -13,13 +13,13 @@
 #include 
 #include 
 
-static ssize_t __init xwrite(int fd, const char *p, size_t count)
+static ssize_t __init xwrite(struct file *file, const char *p, size_t count)
 {
ssize_t out = 0;
 
/* sys_write only can write MAX_RW_COUNT aka 2G-4K bytes at most */
while (count) {
-   ssize_t rv = ksys_write(fd, p, count);
+   ssize_t rv = kernel_write(file, p, count, &file->f_pos);
 
if (rv < 0) {
if (rv == -EINTR || rv == -EAGAIN)
@@ -317,7 +317,7 @@ static int __init maybe_link(void)
return 0;
 }
 
-static __initdata int wfd;
+static __initdata struct file *wfile;
 
 static int __init do_name(void)
 {
@@ -334,16 +334,16 @@ static int __init do_name(void)
int openflags = O_WRONLY|O_CREAT;
if (ml != 1)
openflags |= O_TRUNC;
-   wfd = ksys_open(collected, openflags, mode);
-
-   if (wfd >= 0) {
-   ksys_fchown(wfd, uid, gid);
-   ksys_fchmod(wfd, mode);
-   if (body_len)
-   ksys_ftruncate(wfd, body_len);
-   vcollected = kstrdup(collected, GFP_KERNEL);
-   state = CopyFile;
-   }
+   wfile = filp_open(collected, openflags, mode);
+   if (IS_ERR(wfile))
+   return 0;
+
+   vfs_fchown(wfile, uid, gid);
+   vfs_fchmod(wfile, mode);
+   if (body_len)
+   vfs_truncate(&wfile->f_path, body_len);
+   vcollected = kstrdup(collected, GFP_KERNEL);
+   state = CopyFile;
}
} else if (S_ISDIR(mode)) {
ksys_mkdir(collected, mode);
@@ -365,16 +365,16 @@ static int __init do_name(void)
 static int __init do_copy(void)
 {
if (byte_count >= body_len) {
-   if (xwrite(wfd, victim, body_len) != body_len)
+   if (xwrite(wfile, victim, body_len) != body_len)
error("write error");
-   ksys_close(wfd);
+   fput(wfile);
do_utime(vcollected, mtime);
kfree(vcollected);
eat(body_len);
state = SkipIt;
return 0;
} else {
-   if (xwrite(wfd, victim, byte_count) != byte_count)
+   if (xwrite(wfile, victim, byte_count) != byte_count)
error("write error");
body_len -= byte_count;
eat(byte_count);
@@ -586,21 +586,21 @@ static void __init clean_rootfs(void)
 static void __init populate_initrd_image(char *err)
 {
ssize_t written;
-   int fd;
+   struct file *file;
 
unpack_to_rootfs(__initramfs_start, __initramfs_size);
 
printk(KERN_INFO "rootfs image is not initramfs (%s); looks like an 
initrd\n",
err);
-   fd = ksys_open("/initrd.image", O_WRONLY | O_CREAT, 0700);
-   if (fd < 0)
+   file = filp_open("/initrd.image", O_WRONLY | O_CREAT, 0700);
+   if (IS_ERR(file))
return;
 
-   written = xwrite(fd, (char *)initrd_start, initrd_end - initrd_start);
+   written = xwrite(file, (char *)initrd_start, initrd_end - initrd_start);
if (written != initrd_end - initrd_start)
pr_err("/initrd.image: incomplete write (%zd != %ld)\n",
   written, initrd_end - initrd_start);
-   ksys_close(fd);
+   fput(file);
 }
 #endif /* CONFIG_BLK_DEV_RAM */
 
-- 
2.27.0



[PATCH 15/23] initramfs: remove the populate_initrd_image and clean_rootfs stubs

2020-07-14 Thread Christoph Hellwig
If initrd support is not enable just print the warning directly instead
of hiding the fact that we just failed behind two stub functions.

Signed-off-by: Christoph Hellwig 
---
 init/initramfs.c | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index 7a38012e1af742..d10404625c31f0 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -618,13 +618,7 @@ static void __init clean_rootfs(void)
ksys_close(fd);
kfree(buf);
 }
-#else
-static inline void clean_rootfs(void)
-{
-}
-#endif /* CONFIG_BLK_DEV_RAM */
 
-#ifdef CONFIG_BLK_DEV_RAM
 static void __init populate_initrd_image(char *err)
 {
ssize_t written;
@@ -644,11 +638,6 @@ static void __init populate_initrd_image(char *err)
   written, initrd_end - initrd_start);
ksys_close(fd);
 }
-#else
-static void __init populate_initrd_image(char *err)
-{
-   printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
-}
 #endif /* CONFIG_BLK_DEV_RAM */
 
 static int __init populate_rootfs(void)
@@ -668,8 +657,12 @@ static int __init populate_rootfs(void)
 
err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start);
if (err) {
+#ifdef CONFIG_BLK_DEV_RAM
clean_rootfs();
populate_initrd_image(err);
+#else
+   printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
+#endif
}
 
 done:
-- 
2.27.0



[PATCH 09/23] md: rewrite md_setup_drive to avoid ioctls

2020-07-14 Thread Christoph Hellwig
md_setup_drive knows it works with md devices, so it is rather pointless
to open a file descriptor and issue ioctls.  Just call directly into the
relevant low-level md routines after getting a handle to the device using
blkdev_get_by_dev instead.

Signed-off-by: Christoph Hellwig 
Acked-by: Song Liu 
---
 drivers/md/md-autodetect.c | 127 -
 drivers/md/md.c|  20 +++---
 drivers/md/md.h|   6 ++
 3 files changed, 71 insertions(+), 82 deletions(-)

diff --git a/drivers/md/md-autodetect.c b/drivers/md/md-autodetect.c
index a43a8f1580584c..5b24b5616d3acc 100644
--- a/drivers/md/md-autodetect.c
+++ b/drivers/md/md-autodetect.c
@@ -2,7 +2,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -120,37 +119,29 @@ static int __init md_setup(char *str)
return 1;
 }
 
-static inline int create_dev(char *name, dev_t dev)
-{
-   ksys_unlink(name);
-   return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
-}
-
 static void __init md_setup_drive(struct md_setup_args *args)
 {
-   int minor, i, partitioned;
-   dev_t dev;
-   dev_t devices[MD_SB_DISKS+1];
-   int fd;
-   int err = 0;
-   char *devname;
-   mdu_disk_info_t dinfo;
+   char *devname = args->device_names;
+   dev_t devices[MD_SB_DISKS + 1], mdev;
+   struct mdu_array_info_s ainfo = { };
+   struct block_device *bdev;
+   struct mddev *mddev;
+   int err = 0, i;
char name[16];
 
-   minor = args->minor;
-   partitioned = args->partitioned;
-   devname = args->device_names;
+   if (args->partitioned) {
+   mdev = MKDEV(mdp_major, args->minor << MdpMinorShift);
+   sprintf(name, "md_d%d", args->minor);
+   } else {
+   mdev = MKDEV(MD_MAJOR, args->minor);
+   sprintf(name, "md%d", args->minor);
+   }
 
-   sprintf(name, "/dev/md%s%d", partitioned?"_d":"", minor);
-   if (partitioned)
-   dev = MKDEV(mdp_major, minor << MdpMinorShift);
-   else
-   dev = MKDEV(MD_MAJOR, minor);
-   create_dev(name, dev);
for (i = 0; i < MD_SB_DISKS && devname != NULL; i++) {
struct kstat stat;
char *p;
char comp_name[64];
+   dev_t dev;
 
p = strchr(devname, ',');
if (p)
@@ -163,7 +154,7 @@ static void __init md_setup_drive(struct md_setup_args 
*args)
if (vfs_stat(comp_name, &stat) == 0 && S_ISBLK(stat.mode))
dev = new_decode_dev(stat.rdev);
if (!dev) {
-   printk(KERN_WARNING "md: Unknown device name: %s\n", 
devname);
+   pr_warn("md: Unknown device name: %s\n", devname);
break;
}
 
@@ -175,68 +166,64 @@ static void __init md_setup_drive(struct md_setup_args 
*args)
if (!i)
return;
 
-   printk(KERN_INFO "md: Loading md%s%d: %s\n",
-   partitioned ? "_d" : "", minor,
-   args->device_names);
+   pr_info("md: Loading %s: %s\n", name, args->device_names);
 
-   fd = ksys_open(name, 0, 0);
-   if (fd < 0) {
-   printk(KERN_ERR "md: open failed - cannot start "
-   "array %s\n", name);
+   bdev = blkdev_get_by_dev(mdev, FMODE_READ, NULL);
+   if (IS_ERR(bdev)) {
+   pr_err("md: open failed - cannot start array %s\n", name);
return;
}
-   if (ksys_ioctl(fd, SET_ARRAY_INFO, 0) == -EBUSY) {
-   printk(KERN_WARNING
-  "md: Ignoring md=%d, already autodetected. (Use 
raid=noautodetect)\n",
-  minor);
-   ksys_close(fd);
-   return;
+   mddev = bdev->bd_disk->private_data;
+
+   err = mddev_lock(mddev);
+   if (err) {
+   pr_err("md: failed to lock array %s\n", name);
+   goto out_blkdev_put;
+   }
+
+   if (!list_empty(&mddev->disks) || mddev->raid_disks) {
+   pr_warn("md: Ignoring %s, already autodetected. (Use 
raid=noautodetect)\n",
+  name);
+   goto out_unlock;
}
 
if (args->level != LEVEL_NONE) {
/* non-persistent */
-   mdu_array_info_t ainfo;
ainfo.level = args->level;
-   ainfo.size = 0;
-   ainfo.nr_disks =0;
-   ainfo.raid_disks =0;
-   while (devices[ainfo.raid_disks])
-   ainfo.raid_disks++;
-   ainfo.md_minor =minor;
+   ainfo.md_minor = args->minor;
ainfo.not_persistent = 1;
-
ainfo.state = (1 << MD_SB_CLEAN);
-   ainfo.layout = 0;
ainfo.chunk_size = args->chunk;
-   err = ksys_ioctl(fd, SET_ARRAY_INFO, (long)&ainfo);
- 

[PATCH 10/23] initrd: remove support for multiple floppies

2020-07-14 Thread Christoph Hellwig
Remove the special handling for multiple floppies in the initrd code.
No one should be using floppies for booting these days. (famous last
words..)

Signed-off-by: Christoph Hellwig 
---
 arch/arm/kernel/atags_parse.c |  2 -
 arch/sh/kernel/setup.c|  2 -
 arch/sparc/kernel/setup_32.c  |  2 -
 arch/sparc/kernel/setup_64.c  |  2 -
 arch/x86/kernel/setup.c   |  2 -
 include/linux/initrd.h|  6 ---
 init/do_mounts.c  | 69 ---
 init/do_mounts.h  |  1 -
 init/do_mounts_rd.c   | 20 +++---
 9 files changed, 12 insertions(+), 94 deletions(-)

diff --git a/arch/arm/kernel/atags_parse.c b/arch/arm/kernel/atags_parse.c
index ce02f92f4ab262..6c12d9fe694e3e 100644
--- a/arch/arm/kernel/atags_parse.c
+++ b/arch/arm/kernel/atags_parse.c
@@ -91,8 +91,6 @@ __tagtable(ATAG_VIDEOTEXT, parse_tag_videotext);
 static int __init parse_tag_ramdisk(const struct tag *tag)
 {
rd_image_start = tag->u.ramdisk.start;
-   rd_doload = (tag->u.ramdisk.flags & 1) == 0;
-   rd_prompt = (tag->u.ramdisk.flags & 2) == 0;
 
if (tag->u.ramdisk.size)
rd_size = tag->u.ramdisk.size;
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 67f5a3b44c2eff..4144be650d4106 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -290,8 +290,6 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_BLK_DEV_RAM
rd_image_start = RAMDISK_FLAGS & RAMDISK_IMAGE_START_MASK;
-   rd_prompt = ((RAMDISK_FLAGS & RAMDISK_PROMPT_FLAG) != 0);
-   rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
 #endif
 
if (!MOUNT_ROOT_RDONLY)
diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c
index 6d07b85b9e2470..eea43a1aef1b9a 100644
--- a/arch/sparc/kernel/setup_32.c
+++ b/arch/sparc/kernel/setup_32.c
@@ -353,8 +353,6 @@ void __init setup_arch(char **cmdline_p)
ROOT_DEV = old_decode_dev(root_dev);
 #ifdef CONFIG_BLK_DEV_RAM
rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
-   rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
-   rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0); 
 #endif
 
prom_setsync(prom_sync_me);
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index f765fda871eb61..d87244197d5cbb 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -659,8 +659,6 @@ void __init setup_arch(char **cmdline_p)
ROOT_DEV = old_decode_dev(root_dev);
 #ifdef CONFIG_BLK_DEV_RAM
rd_image_start = ram_flags & RAMDISK_IMAGE_START_MASK;
-   rd_prompt = ((ram_flags & RAMDISK_PROMPT_FLAG) != 0);
-   rd_doload = ((ram_flags & RAMDISK_LOAD_FLAG) != 0);
 #endif
 
task_thread_info(&init_task)->kregs = &fake_swapper_regs;
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index a3767e74c758c0..b9a68d8e06d8d1 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -870,8 +870,6 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_BLK_DEV_RAM
rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK;
-   rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0);
-   rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0);
 #endif
 #ifdef CONFIG_EFI
if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature,
diff --git a/include/linux/initrd.h b/include/linux/initrd.h
index aa591435572868..8db6f8c8030b68 100644
--- a/include/linux/initrd.h
+++ b/include/linux/initrd.h
@@ -2,12 +2,6 @@
 
 #define INITRD_MINOR 250 /* shouldn't collide with /dev/ram* too soon ... */
 
-/* 1 = load ramdisk, 0 = don't load */
-extern int rd_doload;
-
-/* 1 = prompt for ramdisk, 0 = don't prompt */
-extern int rd_prompt;
-
 /* starting block # of image */
 extern int rd_image_start;
 
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 1a4dfa17fb2899..4f4ceb35805503 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -28,8 +28,6 @@
 
 #include "do_mounts.h"
 
-int __initdata rd_doload;  /* 1 = load RAM disk, 0 = don't load */
-
 int root_mountflags = MS_RDONLY | MS_SILENT;
 static char * __initdata root_device_name;
 static char __initdata saved_root_name[64];
@@ -39,7 +37,7 @@ dev_t ROOT_DEV;
 
 static int __init load_ramdisk(char *str)
 {
-   rd_doload = simple_strtol(str,NULL,0) & 3;
+   pr_warn("ignoring the depreated load_ramdisk= option\n");
return 1;
 }
 __setup("load_ramdisk=", load_ramdisk);
@@ -553,66 +551,20 @@ static int __init mount_cifs_root(void)
 }
 #endif
 
-#if defined(CONFIG_BLK_DEV_RAM) || defined(CONFIG_BLK_DEV_FD)
-void __init change_floppy(char *fmt, ...)
-{
-   struct termios termios;
-   char buf[80];
-   char c;
-   int fd;
-   va_list args;
-   va_start(args, fmt);
-   vsprintf(buf, fmt, args);
-   va_end(args);
-   fd = ksys_open("/dev/root", O_RDWR | O_NDELAY, 0);
-   if (fd >= 0) {
-   ksys_io

[PATCH 01/23] fs: add a vfs_fchown helper

2020-07-14 Thread Christoph Hellwig
Add a helper for struct file based chown operations.  To be used by
the initramfs code soon.

Signed-off-by: Christoph Hellwig 
---
 fs/open.c  | 29 +
 include/linux/fs.h |  2 ++
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index 6cd48a61cda3b9..103c66309bee67 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -740,23 +740,28 @@ SYSCALL_DEFINE3(lchown, const char __user *, filename, 
uid_t, user, gid_t, group
   AT_SYMLINK_NOFOLLOW);
 }
 
+int vfs_fchown(struct file *file, uid_t user, gid_t group)
+{
+   int error;
+
+   error = mnt_want_write_file(file);
+   if (error)
+   return error;
+   audit_file(file);
+   error = chown_common(&file->f_path, user, group);
+   mnt_drop_write_file(file);
+   return error;
+}
+
 int ksys_fchown(unsigned int fd, uid_t user, gid_t group)
 {
struct fd f = fdget(fd);
int error = -EBADF;
 
-   if (!f.file)
-   goto out;
-
-   error = mnt_want_write_file(f.file);
-   if (error)
-   goto out_fput;
-   audit_file(f.file);
-   error = chown_common(&f.file->f_path, user, group);
-   mnt_drop_write_file(f.file);
-out_fput:
-   fdput(f);
-out:
+   if (f.file) {
+   error = vfs_fchown(f.file, user, group);
+   fdput(f);
+   }
return error;
 }
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f5abba86107d86..0ddd64ca0b45c0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1744,6 +1744,8 @@ int vfs_mkobj(struct dentry *, umode_t,
int (*f)(struct dentry *, umode_t, void *),
void *);
 
+int vfs_fchown(struct file *file, uid_t user, gid_t group);
+
 extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 
 #ifdef CONFIG_COMPAT
-- 
2.27.0



[PATCH 11/23] initrd: remove the BLKFLSBUF call in handle_initrd

2020-07-14 Thread Christoph Hellwig
BLKFLSBUF used to be overloaded for the ramdisk driver to free the whole
ramdisk, which was completely different behavior compared to all other
drivers.  But this magic overload got removed in commit ff26956875c2
("brd: remove support for BLKFLSBUF"), so this call is entirely
pointless now.

Signed-off-by: Christoph Hellwig 
---
 init/do_mounts_initrd.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index d72beda824aa79..e4f88e9e1c0839 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -115,21 +115,12 @@ static void __init handle_initrd(void)
if (!error)
printk("okay\n");
else {
-   int fd = ksys_open("/dev/root.old", O_RDWR, 0);
if (error == -ENOENT)
printk("/initrd does not exist. Ignored.\n");
else
printk("failed\n");
printk(KERN_NOTICE "Unmounting old root\n");
ksys_umount("/old", MNT_DETACH);
-   printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
-   if (fd < 0) {
-   error = fd;
-   } else {
-   error = ksys_ioctl(fd, BLKFLSBUF, 0);
-   ksys_close(fd);
-   }
-   printk(!error ? "okay\n" : "failed\n");
}
 }
 
-- 
2.27.0



[PATCH 18/23] init: open code setting up stdin/stdout/stderr

2020-07-14 Thread Christoph Hellwig
Don't rely on the implicit set_fs(KERNEL_DS) for ksys_open to work, but
instead open a struct file for /dev/console and then install it as FD
0/1/2 manually.

Signed-off-by: Christoph Hellwig 
---
 init/main.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/init/main.c b/init/main.c
index 0ead83e86b5aa2..db0621dfbb0468 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1457,15 +1457,19 @@ static int __ref kernel_init(void *unused)
  "See Linux Documentation/admin-guide/init.rst for guidance.");
 }
 
+/* Open /dev/console, for stdin/stdout/stderr, this should never fail */
 void console_on_rootfs(void)
 {
-   /* Open the /dev/console as stdin, this should never fail */
-   if (ksys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
-   pr_err("Warning: unable to open an initial console.\n");
+   struct file *file = filp_open("/dev/console", O_RDWR, 0);
 
-   /* create stdout/stderr */
-   (void) ksys_dup(0);
-   (void) ksys_dup(0);
+   if (IS_ERR(file)) {
+   pr_err("Warning: unable to open an initial console.\n");
+   return;
+   }
+   get_file_rcu_many(file, 2);
+   fd_install(get_unused_fd_flags(0), file);
+   fd_install(get_unused_fd_flags(0), file);
+   fd_install(get_unused_fd_flags(0), file);
 }
 
 static noinline void __init kernel_init_freeable(void)
-- 
2.27.0



[PATCH 19/23] fs: remove ksys_getdents64

2020-07-14 Thread Christoph Hellwig
Just open code it in the only caller.

Signed-off-by: Christoph Hellwig 
---
 fs/readdir.c | 11 ++-
 include/linux/syscalls.h |  2 --
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/fs/readdir.c b/fs/readdir.c
index a49f07c11cfbd0..19434b3c982cd3 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -348,8 +348,8 @@ static int filldir64(struct dir_context *ctx, const char 
*name, int namlen,
return -EFAULT;
 }
 
-int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,
-   unsigned int count)
+SYSCALL_DEFINE3(getdents64, unsigned int, fd,
+   struct linux_dirent64 __user *, dirent, unsigned int, count)
 {
struct fd f;
struct getdents_callback64 buf = {
@@ -380,13 +380,6 @@ int ksys_getdents64(unsigned int fd, struct linux_dirent64 
__user *dirent,
return error;
 }
 
-
-SYSCALL_DEFINE3(getdents64, unsigned int, fd,
-   struct linux_dirent64 __user *, dirent, unsigned int, count)
-{
-   return ksys_getdents64(fd, dirent, count);
-}
-
 #ifdef CONFIG_COMPAT
 struct compat_old_linux_dirent {
compat_ulong_t  d_ino;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 10843a6adb770d..a998651629c71b 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1243,8 +1243,6 @@ ssize_t ksys_write(unsigned int fd, const char __user 
*buf, size_t count);
 int ksys_chdir(const char __user *filename);
 int ksys_fchmod(unsigned int fd, umode_t mode);
 int ksys_fchown(unsigned int fd, uid_t user, gid_t group);
-int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,
-   unsigned int count);
 int ksys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
 ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
 void ksys_sync(void);
-- 
2.27.0



[PATCH 05/23] md: replace the RAID_AUTORUN ioctl with a direct function call

2020-07-14 Thread Christoph Hellwig
Instead of using a spcial RAID_AUTORUN ioctl that only exists for
non-modular builds and is only called from the early init code, just
call the actual function directly.

Signed-off-by: Christoph Hellwig 
Acked-by: Song Liu 
---
 drivers/md/md-autodetect.c | 10 ++
 drivers/md/md.c| 14 +-
 drivers/md/md.h|  3 +++
 3 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/drivers/md/md-autodetect.c b/drivers/md/md-autodetect.c
index fe806f7b9759a1..0eb746211ed53c 100644
--- a/drivers/md/md-autodetect.c
+++ b/drivers/md/md-autodetect.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include "md.h"
 
 /*
  * When md (and any require personalities) are compiled into the kernel
@@ -285,8 +286,6 @@ __setup("md=", md_setup);
 
 static void __init autodetect_raid(void)
 {
-   int fd;
-
/*
 * Since we don't want to detect and use half a raid array, we need to
 * wait for the known devices to complete their probing
@@ -295,12 +294,7 @@ static void __init autodetect_raid(void)
printk(KERN_INFO "md: If you don't use raid, use raid=noautodetect\n");
 
wait_for_device_probe();
-
-   fd = ksys_open("/dev/md0", 0, 0);
-   if (fd >= 0) {
-   ksys_ioctl(fd, RAID_AUTORUN, raid_autopart);
-   ksys_close(fd);
-   }
+   md_autostart_arrays(raid_autopart);
 }
 
 void __init md_run_setup(void)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f567f536b529bd..6e9a48da474848 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -68,10 +68,6 @@
 #include "md-bitmap.h"
 #include "md-cluster.h"
 
-#ifndef MODULE
-static void autostart_arrays(int part);
-#endif
-
 /* pers_list is a list of registered personalities protected
  * by pers_lock.
  * pers_lock does extra service to protect accesses to
@@ -7421,7 +7417,6 @@ static inline bool md_ioctl_valid(unsigned int cmd)
case GET_DISK_INFO:
case HOT_ADD_DISK:
case HOT_REMOVE_DISK:
-   case RAID_AUTORUN:
case RAID_VERSION:
case RESTART_ARRAY_RW:
case RUN_ARRAY:
@@ -7467,13 +7462,6 @@ static int md_ioctl(struct block_device *bdev, fmode_t 
mode,
case RAID_VERSION:
err = get_version(argp);
goto out;
-
-#ifndef MODULE
-   case RAID_AUTORUN:
-   err = 0;
-   autostart_arrays(arg);
-   goto out;
-#endif
default:;
}
 
@@ -9721,7 +9709,7 @@ void md_autodetect_dev(dev_t dev)
}
 }
 
-static void autostart_arrays(int part)
+void md_autostart_arrays(int part)
 {
struct md_rdev *rdev;
struct detected_devices_node *node_detected_dev;
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 612814d07d35ab..37315a3f28e97d 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -800,4 +800,7 @@ static inline void mddev_check_write_zeroes(struct mddev 
*mddev, struct bio *bio
!bio->bi_disk->queue->limits.max_write_zeroes_sectors)
mddev->queue->limits.max_write_zeroes_sectors = 0;
 }
+
+void md_autostart_arrays(int part);
+
 #endif /* _MD_MD_H */
-- 
2.27.0



[PATCH 20/23] fs: remove ksys_open

2020-07-14 Thread Christoph Hellwig
Just open code it in the two callers.

Signed-off-by: Christoph Hellwig 
---
 fs/open.c| 11 ---
 include/linux/syscalls.h | 11 ---
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index 75166f071d280a..ab3671af8a9705 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -1208,7 +1208,9 @@ long do_sys_open(int dfd, const char __user *filename, 
int flags, umode_t mode)
 
 SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
 {
-   return ksys_open(filename, flags, mode);
+   if (force_o_largefile())
+   flags |= O_LARGEFILE;
+   return do_sys_open(AT_FDCWD, filename, flags, mode);
 }
 
 SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
@@ -1270,9 +1272,12 @@ COMPAT_SYSCALL_DEFINE4(openat, int, dfd, const char 
__user *, filename, int, fla
  */
 SYSCALL_DEFINE2(creat, const char __user *, pathname, umode_t, mode)
 {
-   return ksys_open(pathname, O_CREAT | O_WRONLY | O_TRUNC, mode);
-}
+   int flags = O_CREAT | O_WRONLY | O_TRUNC;
 
+   if (force_o_largefile())
+   flags |= O_LARGEFILE;
+   return do_sys_open(AT_FDCWD, pathname, flags, mode);
+}
 #endif
 
 /*
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a998651629c71b..363baaadf8e19a 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1374,17 +1374,6 @@ static inline int ksys_close(unsigned int fd)
return __close_fd(current->files, fd);
 }
 
-extern long do_sys_open(int dfd, const char __user *filename, int flags,
-   umode_t mode);
-
-static inline long ksys_open(const char __user *filename, int flags,
-umode_t mode)
-{
-   if (force_o_largefile())
-   flags |= O_LARGEFILE;
-   return do_sys_open(AT_FDCWD, filename, flags, mode);
-}
-
 extern long do_sys_truncate(const char __user *pathname, loff_t length);
 
 static inline long ksys_truncate(const char __user *pathname, loff_t length)
-- 
2.27.0



Re: [RFC PATCH 04/15] x86/pks: Preserve the PKRS MSR on context switch

2020-07-14 Thread Ira Weiny
On Tue, Jul 14, 2020 at 09:05:39PM +0200, Peter Zijlstra wrote:
> On Tue, Jul 14, 2020 at 11:53:22AM -0700, Ira Weiny wrote:
> > On Tue, Jul 14, 2020 at 10:27:01AM +0200, Peter Zijlstra wrote:
> > > On Tue, Jul 14, 2020 at 12:02:09AM -0700, ira.we...@intel.com wrote:
> > > > From: Ira Weiny 
> > > > 
> > > > The PKRS MSR is defined as a per-core register.  This isolates memory
> > > > access by CPU.  Unfortunately, the MSR is not preserved by XSAVE.
> > > > Therefore, We must preserve the protections for individual tasks even if
> > > > they are context switched out and placed on another cpu later.
> > > 
> > > This is a contradiction and utter trainwreck.
> > 
> > I don't understand where there is a contradiction?  Perhaps I should have 
> > said
> > the MSR is not XSAVE managed vs 'preserved'?
> 
> You're stating the MSR is per-*CORE*, and then continue to talk about
> per-task state.
> 
> We've had a bunch of MSRs have exactly that problem recently, and it's
> not fun. We're not going to do that again.

Ah sorry, my mistake yes I meant 'per-logical-processor' like Dave said.  I'll
update the commit message.

Ira


[PATCH 21/23] fs: remove ksys_dup

2020-07-14 Thread Christoph Hellwig
Fold it into the only remaining caller.

Signed-off-by: Christoph Hellwig 
---
 fs/file.c| 7 +--
 include/linux/syscalls.h | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/fs/file.c b/fs/file.c
index abb8b7081d7a44..85b7993165dd2f 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -985,7 +985,7 @@ SYSCALL_DEFINE2(dup2, unsigned int, oldfd, unsigned int, 
newfd)
return ksys_dup3(oldfd, newfd, 0);
 }
 
-int ksys_dup(unsigned int fildes)
+SYSCALL_DEFINE1(dup, unsigned int, fildes)
 {
int ret = -EBADF;
struct file *file = fget_raw(fildes);
@@ -1000,11 +1000,6 @@ int ksys_dup(unsigned int fildes)
return ret;
 }
 
-SYSCALL_DEFINE1(dup, unsigned int, fildes)
-{
-   return ksys_dup(fildes);
-}
-
 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
 {
int err;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 363baaadf8e19a..b6d90057476260 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1237,7 +1237,6 @@ asmlinkage long sys_ni_syscall(void);
  */
 
 int ksys_umount(char __user *name, int flags);
-int ksys_dup(unsigned int fildes);
 int ksys_chroot(const char __user *filename);
 ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
 int ksys_chdir(const char __user *filename);
-- 
2.27.0



[PATCH 07/23] md: remove the kernel version of md_u.h

2020-07-14 Thread Christoph Hellwig
mdp_major can just move to drivers/md/md.h.

Signed-off-by: Christoph Hellwig 
Acked-by: Song Liu 
---
 drivers/md/md.h   |  1 +
 include/linux/raid/md_u.h | 13 -
 2 files changed, 1 insertion(+), 13 deletions(-)
 delete mode 100644 include/linux/raid/md_u.h

diff --git a/drivers/md/md.h b/drivers/md/md.h
index 37315a3f28e97d..6f8fff77ce10a5 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -801,6 +801,7 @@ static inline void mddev_check_write_zeroes(struct mddev 
*mddev, struct bio *bio
mddev->queue->limits.max_write_zeroes_sectors = 0;
 }
 
+extern int mdp_major;
 void md_autostart_arrays(int part);
 
 #endif /* _MD_MD_H */
diff --git a/include/linux/raid/md_u.h b/include/linux/raid/md_u.h
deleted file mode 100644
index 8dfec085a20ee1..00
--- a/include/linux/raid/md_u.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
-   md_u.h : user <=> kernel API between Linux raidtools and RAID drivers
-  Copyright (C) 1998 Ingo Molnar
- 
-*/
-#ifndef _MD_U_H
-#define _MD_U_H
-
-#include 
-
-extern int mdp_major;
-#endif 
-- 
2.27.0



[PATCH 22/23] fs: remove ksys_fchmod

2020-07-14 Thread Christoph Hellwig
Fold it into the only remaining caller.

Signed-off-by: Christoph Hellwig 
---
 fs/open.c| 7 +--
 include/linux/syscalls.h | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index ab3671af8a9705..b316dd6a86a8b9 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -608,7 +608,7 @@ int vfs_fchmod(struct file *file, umode_t mode)
return chmod_common(&file->f_path, mode);
 }
 
-int ksys_fchmod(unsigned int fd, umode_t mode)
+SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
 {
struct fd f = fdget(fd);
int err = -EBADF;
@@ -620,11 +620,6 @@ int ksys_fchmod(unsigned int fd, umode_t mode)
return err;
 }
 
-SYSCALL_DEFINE2(fchmod, unsigned int, fd, umode_t, mode)
-{
-   return ksys_fchmod(fd, mode);
-}
-
 int do_fchmodat(int dfd, const char __user *filename, umode_t mode)
 {
struct path path;
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index b6d90057476260..39ff738997a172 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1240,7 +1240,6 @@ int ksys_umount(char __user *name, int flags);
 int ksys_chroot(const char __user *filename);
 ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
 int ksys_chdir(const char __user *filename);
-int ksys_fchmod(unsigned int fd, umode_t mode);
 int ksys_fchown(unsigned int fd, uid_t user, gid_t group);
 int ksys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
 ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
-- 
2.27.0



[PATCH 23/23] fs: remove ksys_ioctl

2020-07-14 Thread Christoph Hellwig
Fold it into the only remaining caller.

Signed-off-by: Christoph Hellwig 
---
 fs/ioctl.c   | 7 +--
 include/linux/syscalls.h | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index d69786d1dd9115..4e6cc0a7d69c9f 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -736,7 +736,7 @@ static int do_vfs_ioctl(struct file *filp, unsigned int fd,
return -ENOIOCTLCMD;
 }
 
-int ksys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
+SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
 {
struct fd f = fdget(fd);
int error;
@@ -757,11 +757,6 @@ int ksys_ioctl(unsigned int fd, unsigned int cmd, unsigned 
long arg)
return error;
 }
 
-SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd, unsigned long, arg)
-{
-   return ksys_ioctl(fd, cmd, arg);
-}
-
 #ifdef CONFIG_COMPAT
 /**
  * compat_ptr_ioctl - generic implementation of .compat_ioctl file operation
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 39ff738997a172..5b0f1fca4cfb9d 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -1241,7 +1241,6 @@ int ksys_chroot(const char __user *filename);
 ssize_t ksys_write(unsigned int fd, const char __user *buf, size_t count);
 int ksys_chdir(const char __user *filename);
 int ksys_fchown(unsigned int fd, uid_t user, gid_t group);
-int ksys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
 ssize_t ksys_read(unsigned int fd, char __user *buf, size_t count);
 void ksys_sync(void);
 int ksys_unshare(unsigned long unshare_flags);
-- 
2.27.0



[PATCH 16/23] initramfs: simplify clean_rootfs

2020-07-14 Thread Christoph Hellwig
Just use d_genocide instead of iterating through the root directory with
cumbersome userspace-like APIs.  This also ensures we actually remove files
that are not direct children of the root entry, which the old code failed
to do.

Fixes: df52092f3c97 ("fastboot: remove duplicate unpack_to_rootfs()")
Signed-off-by: Christoph Hellwig 
---
 init/initramfs.c | 46 +-
 1 file changed, 5 insertions(+), 41 deletions(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index d10404625c31f0..d42ec8329cd840 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static ssize_t __init xwrite(int fd, const char *p, size_t count)
 {
@@ -572,51 +573,14 @@ static inline bool kexec_free_initrd(void)
 #endif /* CONFIG_KEXEC_CORE */
 
 #ifdef CONFIG_BLK_DEV_RAM
-#define BUF_SIZE 1024
 static void __init clean_rootfs(void)
 {
-   int fd;
-   void *buf;
-   struct linux_dirent64 *dirp;
-   int num;
+   struct path path;
 
-   fd = ksys_open("/", O_RDONLY, 0);
-   WARN_ON(fd < 0);
-   if (fd < 0)
-   return;
-   buf = kzalloc(BUF_SIZE, GFP_KERNEL);
-   WARN_ON(!buf);
-   if (!buf) {
-   ksys_close(fd);
+   if (kern_path("/", 0, &path))
return;
-   }
-
-   dirp = buf;
-   num = ksys_getdents64(fd, dirp, BUF_SIZE);
-   while (num > 0) {
-   while (num > 0) {
-   struct kstat st;
-   int ret;
-
-   ret = vfs_lstat(dirp->d_name, &st);
-   WARN_ON_ONCE(ret);
-   if (!ret) {
-   if (S_ISDIR(st.mode))
-   ksys_rmdir(dirp->d_name);
-   else
-   ksys_unlink(dirp->d_name);
-   }
-
-   num -= dirp->d_reclen;
-   dirp = (void *)dirp + dirp->d_reclen;
-   }
-   dirp = buf;
-   memset(buf, 0, BUF_SIZE);
-   num = ksys_getdents64(fd, dirp, BUF_SIZE);
-   }
-
-   ksys_close(fd);
-   kfree(buf);
+   d_genocide(path.dentry);
+   path_put(&path);
 }
 
 static void __init populate_initrd_image(char *err)
-- 
2.27.0



[PATCH 13/23] initrd: mark init_linuxrc as __init

2020-07-14 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 init/do_mounts_initrd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index e4f88e9e1c0839..57ad5b2da8f5f5 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -56,7 +56,7 @@ static int __init early_initrd(char *p)
 }
 early_param("initrd", early_initrd);
 
-static int init_linuxrc(struct subprocess_info *info, struct cred *new)
+static int __init init_linuxrc(struct subprocess_info *info, struct cred *new)
 {
ksys_unshare(CLONE_FS | CLONE_FILES);
console_on_rootfs();
-- 
2.27.0



[PATCH 14/23] initrd: mark initrd support as deprecated

2020-07-14 Thread Christoph Hellwig
The classic initial ramdisk has been replaced by the much more
flexible and efficient initramfs a long time.  Warn about it being
removed soon.

Signed-off-by: Christoph Hellwig 
---
 init/do_mounts_initrd.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 57ad5b2da8f5f5..e08669187d63be 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -75,6 +75,8 @@ static void __init handle_initrd(void)
extern char *envp_init[];
int error;
 
+   pr_warn("using deprecated initrd support, will be removed in 2021.\n");
+
real_root_dev = new_encode_dev(ROOT_DEV);
create_dev("/dev/root.old", Root_RAM0);
/* mount initrd on rootfs' /root */
-- 
2.27.0



[PATCH 5.4 018/109] ixgbe: protect ring accesses with READ- and WRITE_ONCE

2020-07-14 Thread Greg Kroah-Hartman
From: Ciara Loftus 

[ Upstream commit f140ad9fe2ae16f385f8fe4dc9cf67bb4c51d794 ]

READ_ONCE should be used when reading rings prior to accessing the
statistics pointer. Introduce this as well as the corresponding WRITE_ONCE
usage when allocating and freeing the rings, to ensure protected access.

Signed-off-by: Ciara Loftus 
Tested-by: Andrew Bowers 
Signed-off-by: Jeff Kirsher 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c  | 12 ++--
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 14 +++---
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
index cc3196ae5aea8..636e6e840afa2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
@@ -923,7 +923,7 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter 
*adapter,
ring->queue_index = txr_idx;
 
/* assign ring to adapter */
-   adapter->tx_ring[txr_idx] = ring;
+   WRITE_ONCE(adapter->tx_ring[txr_idx], ring);
 
/* update count and index */
txr_count--;
@@ -950,7 +950,7 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter 
*adapter,
set_ring_xdp(ring);
 
/* assign ring to adapter */
-   adapter->xdp_ring[xdp_idx] = ring;
+   WRITE_ONCE(adapter->xdp_ring[xdp_idx], ring);
 
/* update count and index */
xdp_count--;
@@ -993,7 +993,7 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter 
*adapter,
ring->queue_index = rxr_idx;
 
/* assign ring to adapter */
-   adapter->rx_ring[rxr_idx] = ring;
+   WRITE_ONCE(adapter->rx_ring[rxr_idx], ring);
 
/* update count and index */
rxr_count--;
@@ -1022,13 +1022,13 @@ static void ixgbe_free_q_vector(struct ixgbe_adapter 
*adapter, int v_idx)
 
ixgbe_for_each_ring(ring, q_vector->tx) {
if (ring_is_xdp(ring))
-   adapter->xdp_ring[ring->queue_index] = NULL;
+   WRITE_ONCE(adapter->xdp_ring[ring->queue_index], NULL);
else
-   adapter->tx_ring[ring->queue_index] = NULL;
+   WRITE_ONCE(adapter->tx_ring[ring->queue_index], NULL);
}
 
ixgbe_for_each_ring(ring, q_vector->rx)
-   adapter->rx_ring[ring->queue_index] = NULL;
+   WRITE_ONCE(adapter->rx_ring[ring->queue_index], NULL);
 
adapter->q_vector[v_idx] = NULL;
napi_hash_del(&q_vector->napi);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index edaa0bffa5c35..5336bfcd2d701 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7064,7 +7064,10 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
}
 
for (i = 0; i < adapter->num_rx_queues; i++) {
-   struct ixgbe_ring *rx_ring = adapter->rx_ring[i];
+   struct ixgbe_ring *rx_ring = READ_ONCE(adapter->rx_ring[i]);
+
+   if (!rx_ring)
+   continue;
non_eop_descs += rx_ring->rx_stats.non_eop_descs;
alloc_rx_page += rx_ring->rx_stats.alloc_rx_page;
alloc_rx_page_failed += rx_ring->rx_stats.alloc_rx_page_failed;
@@ -7085,15 +7088,20 @@ void ixgbe_update_stats(struct ixgbe_adapter *adapter)
packets = 0;
/* gather some stats to the adapter struct that are per queue */
for (i = 0; i < adapter->num_tx_queues; i++) {
-   struct ixgbe_ring *tx_ring = adapter->tx_ring[i];
+   struct ixgbe_ring *tx_ring = READ_ONCE(adapter->tx_ring[i]);
+
+   if (!tx_ring)
+   continue;
restart_queue += tx_ring->tx_stats.restart_queue;
tx_busy += tx_ring->tx_stats.tx_busy;
bytes += tx_ring->stats.bytes;
packets += tx_ring->stats.packets;
}
for (i = 0; i < adapter->num_xdp_queues; i++) {
-   struct ixgbe_ring *xdp_ring = adapter->xdp_ring[i];
+   struct ixgbe_ring *xdp_ring = READ_ONCE(adapter->xdp_ring[i]);
 
+   if (!xdp_ring)
+   continue;
restart_queue += xdp_ring->tx_stats.restart_queue;
tx_busy += xdp_ring->tx_stats.tx_busy;
bytes += xdp_ring->stats.bytes;
-- 
2.25.1





[PATCH 5.4 037/109] gpio: pca953x: Fix GPIO resource leak on Intel Galileo Gen 2

2020-07-14 Thread Greg Kroah-Hartman
From: Andy Shevchenko 

[ Upstream commit 5d8913504ccfeea6120df5ae1c6f4479ff09b931 ]

When adding a quirk for IRQ on Intel Galileo Gen 2 the commit ba8c90c61847
("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2")
missed GPIO resource release. We can safely do this in the same quirk, since
IRQ will be locked by GPIO framework when requested and unlocked on freeing.

Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on 
Galileo Gen 2")
Signed-off-by: Andy Shevchenko 
Cc: Mika Westerberg 
Reviewed-by: Mika Westerberg 
Reviewed-by: Linus Walleij 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Sasha Levin 
---
 drivers/gpio/gpio-pca953x.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index c935019c0257c..81f5103dccb6f 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -176,7 +176,12 @@ static int pca953x_acpi_get_irq(struct device *dev)
if (ret)
return ret;
 
-   return gpio_to_irq(pin);
+   ret = gpio_to_irq(pin);
+
+   /* When pin is used as an IRQ, no need to keep it requested */
+   gpio_free(pin);
+
+   return ret;
 }
 #endif
 
-- 
2.25.1





[PATCH 5.4 043/109] net: mvneta: fix use of state->speed

2020-07-14 Thread Greg Kroah-Hartman
From: Russell King 

[ Upstream commit f2ca673d2cd5df9a76247b670e9ffd4d63682b3f ]

When support for short preambles was added, it incorrectly keyed its
decision off state->speed instead of state->interface.  state->speed
is not guaranteed to be correct for in-band modes, which can lead to
short preambles being unexpectedly disabled.

Fix this by keying off the interface mode, which is the only way that
mvneta can operate at 2.5Gbps.

Fixes: da58a931f248 ("net: mvneta: Add support for 2500Mbps SGMII")
Signed-off-by: Russell King 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/marvell/mvneta.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index 9799253948281..ffdb7b113f172 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -3594,7 +3594,7 @@ static void mvneta_mac_config(struct phylink_config 
*config, unsigned int mode,
/* When at 2.5G, the link partner can send frames with shortened
 * preambles.
 */
-   if (state->speed == SPEED_2500)
+   if (state->interface == PHY_INTERFACE_MODE_2500BASEX)
new_ctrl4 |= MVNETA_GMAC4_SHORT_PREAMBLE_ENABLE;
 
if (pp->phy_interface != state->interface) {
-- 
2.25.1





[PATCH 03/23] init: remove the bstat helper

2020-07-14 Thread Christoph Hellwig
The only caller of the bstat function becomes cleaner and simpler when
open coding the function.

Signed-off-by: Christoph Hellwig 
Acked-by: Song Liu 
---
 init/do_mounts.h| 10 --
 init/do_mounts_md.c |  8 
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/init/do_mounts.h b/init/do_mounts.h
index 0bb0806de4ce2c..7513d1c14d13fe 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -20,16 +20,6 @@ static inline int create_dev(char *name, dev_t dev)
return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
 }
 
-static inline u32 bstat(char *name)
-{
-   struct kstat stat;
-   if (vfs_stat(name, &stat) != 0)
-   return 0;
-   if (!S_ISBLK(stat.mode))
-   return 0;
-   return stat.rdev;
-}
-
 #ifdef CONFIG_BLK_DEV_RAM
 
 int __init rd_load_disk(int n);
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index b84031528dd446..359363e85ccd0b 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -138,9 +138,9 @@ static void __init md_setup_drive(void)
dev = MKDEV(MD_MAJOR, minor);
create_dev(name, dev);
for (i = 0; i < MD_SB_DISKS && devname != NULL; i++) {
+   struct kstat stat;
char *p;
char comp_name[64];
-   u32 rdev;
 
p = strchr(devname, ',');
if (p)
@@ -150,9 +150,9 @@ static void __init md_setup_drive(void)
if (strncmp(devname, "/dev/", 5) == 0)
devname += 5;
snprintf(comp_name, 63, "/dev/%s", devname);
-   rdev = bstat(comp_name);
-   if (rdev)
-   dev = new_decode_dev(rdev);
+   if (vfs_stat(comp_name, &stat) == 0 &&
+   S_ISBLK(stat.mode))
+   dev = new_decode_dev(stat.rdev);
if (!dev) {
printk(KERN_WARNING "md: Unknown device name: 
%s\n", devname);
break;
-- 
2.27.0



[PATCH 5.4 031/109] block: release bip in a right way in error path

2020-07-14 Thread Greg Kroah-Hartman
From: Chengguang Xu 

[ Upstream commit 0b8eb629a700c0ef15a437758db8255f8444e76c ]

Release bip using kfree() in error path when that was allocated
by kmalloc().

Signed-off-by: Chengguang Xu 
Reviewed-by: Christoph Hellwig 
Acked-by: Martin K. Petersen 
Signed-off-by: Jens Axboe 
Signed-off-by: Sasha Levin 
---
 block/bio-integrity.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index ae07dd78e9518..c9dc2b17ce251 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -24,6 +24,18 @@ void blk_flush_integrity(void)
flush_workqueue(kintegrityd_wq);
 }
 
+void __bio_integrity_free(struct bio_set *bs, struct bio_integrity_payload 
*bip)
+{
+   if (bs && mempool_initialized(&bs->bio_integrity_pool)) {
+   if (bip->bip_vec)
+   bvec_free(&bs->bvec_integrity_pool, bip->bip_vec,
+ bip->bip_slab);
+   mempool_free(bip, &bs->bio_integrity_pool);
+   } else {
+   kfree(bip);
+   }
+}
+
 /**
  * bio_integrity_alloc - Allocate integrity payload and attach it to bio
  * @bio:   bio to attach integrity metadata to
@@ -75,7 +87,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio 
*bio,
 
return bip;
 err:
-   mempool_free(bip, &bs->bio_integrity_pool);
+   __bio_integrity_free(bs, bip);
return ERR_PTR(-ENOMEM);
 }
 EXPORT_SYMBOL(bio_integrity_alloc);
@@ -96,14 +108,7 @@ void bio_integrity_free(struct bio *bio)
kfree(page_address(bip->bip_vec->bv_page) +
  bip->bip_vec->bv_offset);
 
-   if (bs && mempool_initialized(&bs->bio_integrity_pool)) {
-   bvec_free(&bs->bvec_integrity_pool, bip->bip_vec, 
bip->bip_slab);
-
-   mempool_free(bip, &bs->bio_integrity_pool);
-   } else {
-   kfree(bip);
-   }
-
+   __bio_integrity_free(bs, bip);
bio->bi_integrity = NULL;
bio->bi_opf &= ~REQ_INTEGRITY;
 }
-- 
2.25.1





[PATCH 02/23] fs: add a vfs_fchmod helper

2020-07-14 Thread Christoph Hellwig
Add a helper for struct file based chmode operations.  To be used by
the initramfs code soon.

Signed-off-by: Christoph Hellwig 
---
 fs/open.c  | 9 +++--
 include/linux/fs.h | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/open.c b/fs/open.c
index 103c66309bee67..75166f071d280a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -602,14 +602,19 @@ static int chmod_common(const struct path *path, umode_t 
mode)
return error;
 }
 
+int vfs_fchmod(struct file *file, umode_t mode)
+{
+   audit_file(file);
+   return chmod_common(&file->f_path, mode);
+}
+
 int ksys_fchmod(unsigned int fd, umode_t mode)
 {
struct fd f = fdget(fd);
int err = -EBADF;
 
if (f.file) {
-   audit_file(f.file);
-   err = chmod_common(&f.file->f_path, mode);
+   err = vfs_fchmod(f.file, mode);
fdput(f);
}
return err;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 0ddd64ca0b45c0..635086726f2053 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1745,6 +1745,7 @@ int vfs_mkobj(struct dentry *, umode_t,
void *);
 
 int vfs_fchown(struct file *file, uid_t user, gid_t group);
+int vfs_fchmod(struct file *file, umode_t mode);
 
 extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
 
-- 
2.27.0



[PATCH 5.4 016/109] net: ethernet: mvneta: Fix Serdes configuration for SoCs without comphy

2020-07-14 Thread Greg Kroah-Hartman
From: Sascha Hauer 

[ Upstream commit b4748553f53f2971e07d2619f13d461daac0f3bb ]

The MVNETA_SERDES_CFG register is only available on older SoCs like the
Armada XP. On newer SoCs like the Armada 38x the fields are moved to
comphy. This patch moves the writes to this register next to the comphy
initialization, so that depending on the SoC either comphy or
MVNETA_SERDES_CFG is configured.
With this we no longer write to the MVNETA_SERDES_CFG on SoCs where it
doesn't exist.

Suggested-by: Russell King 
Signed-off-by: Sascha Hauer 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/marvell/mvneta.c | 80 +++
 1 file changed, 44 insertions(+), 36 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvneta.c 
b/drivers/net/ethernet/marvell/mvneta.c
index a10ae28ebc8aa..b0599b205b36e 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -104,6 +104,7 @@
 #define  MVNETA_TX_IN_PRGRS  BIT(1)
 #define  MVNETA_TX_FIFO_EMPTYBIT(8)
 #define MVNETA_RX_MIN_FRAME_SIZE 0x247c
+/* Only exists on Armada XP and Armada 370 */
 #define MVNETA_SERDES_CFG   0x24A0
 #define  MVNETA_SGMII_SERDES_PROTO  0x0cc7
 #define  MVNETA_QSGMII_SERDES_PROTO 0x0667
@@ -3164,26 +3165,55 @@ static int mvneta_setup_txqs(struct mvneta_port *pp)
return 0;
 }
 
-static int mvneta_comphy_init(struct mvneta_port *pp)
+static int mvneta_comphy_init(struct mvneta_port *pp, phy_interface_t 
interface)
 {
int ret;
 
-   if (!pp->comphy)
-   return 0;
-
-   ret = phy_set_mode_ext(pp->comphy, PHY_MODE_ETHERNET,
-  pp->phy_interface);
+   ret = phy_set_mode_ext(pp->comphy, PHY_MODE_ETHERNET, interface);
if (ret)
return ret;
 
return phy_power_on(pp->comphy);
 }
 
+static int mvneta_config_interface(struct mvneta_port *pp,
+  phy_interface_t interface)
+{
+   int ret = 0;
+
+   if (pp->comphy) {
+   if (interface == PHY_INTERFACE_MODE_SGMII ||
+   interface == PHY_INTERFACE_MODE_1000BASEX ||
+   interface == PHY_INTERFACE_MODE_2500BASEX) {
+   ret = mvneta_comphy_init(pp, interface);
+   }
+   } else {
+   switch (interface) {
+   case PHY_INTERFACE_MODE_QSGMII:
+   mvreg_write(pp, MVNETA_SERDES_CFG,
+   MVNETA_QSGMII_SERDES_PROTO);
+   break;
+
+   case PHY_INTERFACE_MODE_SGMII:
+   case PHY_INTERFACE_MODE_1000BASEX:
+   mvreg_write(pp, MVNETA_SERDES_CFG,
+   MVNETA_SGMII_SERDES_PROTO);
+   break;
+   default:
+   return -EINVAL;
+   }
+   }
+
+   pp->phy_interface = interface;
+
+   return ret;
+}
+
 static void mvneta_start_dev(struct mvneta_port *pp)
 {
int cpu;
 
-   WARN_ON(mvneta_comphy_init(pp));
+   WARN_ON(mvneta_config_interface(pp, pp->phy_interface));
 
mvneta_max_rx_size_set(pp, pp->pkt_size);
mvneta_txq_max_tx_size_set(pp, pp->pkt_size);
@@ -3561,14 +3591,10 @@ static void mvneta_mac_config(struct phylink_config 
*config, unsigned int mode,
if (state->speed == SPEED_2500)
new_ctrl4 |= MVNETA_GMAC4_SHORT_PREAMBLE_ENABLE;
 
-   if (pp->comphy && pp->phy_interface != state->interface &&
-   (state->interface == PHY_INTERFACE_MODE_SGMII ||
-state->interface == PHY_INTERFACE_MODE_1000BASEX ||
-state->interface == PHY_INTERFACE_MODE_2500BASEX)) {
-   pp->phy_interface = state->interface;
-
-   WARN_ON(phy_power_off(pp->comphy));
-   WARN_ON(mvneta_comphy_init(pp));
+   if (pp->phy_interface != state->interface) {
+   if (pp->comphy)
+   WARN_ON(phy_power_off(pp->comphy));
+   WARN_ON(mvneta_config_interface(pp, state->interface));
}
 
if (new_ctrl0 != gmac_ctrl0)
@@ -4464,20 +4490,10 @@ static void mvneta_conf_mbus_windows(struct mvneta_port 
*pp,
 }
 
 /* Power up the port */
-static int mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
+static void mvneta_port_power_up(struct mvneta_port *pp, int phy_mode)
 {
/* MAC Cause register should be cleared */
mvreg_write(pp, MVNETA_UNIT_INTR_CAUSE, 0);
-
-   if (phy_mode == PHY_INTERFACE_MODE_QSGMII)
-   mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_QSGMII_SERDES_PROTO);
-   else if (phy_mode == PHY_INTERFACE_MODE_SGMII ||
-phy_interface_mode_is_8023z(phy_mode))
-   mvreg_write(pp, MVNETA_SERDES_CFG, MVNETA_SGMII_SERDES_PROTO);
-   else if (!phy_interface_mode_is_rgmii(phy_mode)

[PATCH 5.4 009/109] drm/tegra: hub: Do not enable orphaned window group

2020-07-14 Thread Greg Kroah-Hartman
From: Nicolin Chen 

[ Upstream commit ef4e417eb3ec7fe657928f10ac1d2154d8a5fb38 ]

Though the unconditional enable/disable code is not a final solution,
we don't want to run into a NULL pointer situation when window group
doesn't link to its DC parent if the DC is disabled in Device Tree.

So this patch simply adds a check to make sure that window group has
a valid parent before running into tegra_windowgroup_enable/disable.

Signed-off-by: Nicolin Chen 
Signed-off-by: Thierry Reding 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/tegra/hub.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tegra/hub.c b/drivers/gpu/drm/tegra/hub.c
index 839b49c40e514..767fb440a79d9 100644
--- a/drivers/gpu/drm/tegra/hub.c
+++ b/drivers/gpu/drm/tegra/hub.c
@@ -141,7 +141,9 @@ int tegra_display_hub_prepare(struct tegra_display_hub *hub)
for (i = 0; i < hub->soc->num_wgrps; i++) {
struct tegra_windowgroup *wgrp = &hub->wgrps[i];
 
-   tegra_windowgroup_enable(wgrp);
+   /* Skip orphaned window group whose parent DC is disabled */
+   if (wgrp->parent)
+   tegra_windowgroup_enable(wgrp);
}
 
return 0;
@@ -158,7 +160,9 @@ void tegra_display_hub_cleanup(struct tegra_display_hub 
*hub)
for (i = 0; i < hub->soc->num_wgrps; i++) {
struct tegra_windowgroup *wgrp = &hub->wgrps[i];
 
-   tegra_windowgroup_disable(wgrp);
+   /* Skip orphaned window group whose parent DC is disabled */
+   if (wgrp->parent)
+   tegra_windowgroup_disable(wgrp);
}
 }
 
-- 
2.25.1





[PATCH 5.4 073/109] ALSA: hda - let hs_mic be picked ahead of hp_mic

2020-07-14 Thread Greg Kroah-Hartman
From: Hui Wang 

commit 6a6ca7881b1ab1c13fe0d70bae29211a65dd90de upstream.

We have a Dell AIO, there is neither internal speaker nor internal
mic, only a multi-function audio jack on it.

Users reported that after freshly installing the OS and plug
a headset to the audio jack, the headset can't output sound. I
reproduced this bug, at that moment, the Input Source is as below:
Simple mixer control 'Input Source',0
  Capabilities: cenum
  Items: 'Headphone Mic' 'Headset Mic'
  Item0: 'Headphone Mic'

That is because the patch_realtek will set this audio jack as mic_in
mode if Input Source's value is hp_mic.

If it is not fresh installing, this issue will not happen since the
systemd will run alsactl restore -f /var/lib/alsa/asound.state, this
will set the 'Input Source' according to history value.

If there is internal speaker or internal mic, this issue will not
happen since there is valid sink/source in the pulseaudio, the PA will
set the 'Input Source' according to active_port.

To fix this issue, change the parser function to let the hs_mic be
stored ahead of hp_mic.

Cc: sta...@vger.kernel.org
Signed-off-by: Hui Wang 
Link: https://lore.kernel.org/r/20200625083833.11264-1-hui.w...@canonical.com
Signed-off-by: Takashi Iwai 
Signed-off-by: Greg Kroah-Hartman 

---
 sound/pci/hda/hda_auto_parser.c |6 ++
 1 file changed, 6 insertions(+)

--- a/sound/pci/hda/hda_auto_parser.c
+++ b/sound/pci/hda/hda_auto_parser.c
@@ -72,6 +72,12 @@ static int compare_input_type(const void
if (a->type != b->type)
return (int)(a->type - b->type);
 
+   /* If has both hs_mic and hp_mic, pick the hs_mic ahead of hp_mic. */
+   if (a->is_headset_mic && b->is_headphone_mic)
+   return -1; /* don't swap */
+   else if (a->is_headphone_mic && b->is_headset_mic)
+   return 1; /* swap */
+
/* In case one has boost and the other one has not,
   pick the one with boost first. */
return (int)(b->has_boost_on_pin - a->has_boost_on_pin);




[PATCH] platform/x86: apple-gmux: Replace HTTP links with HTTPS ones

2020-07-14 Thread Alexander A. Klimov
Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
For each line:
  If doesn't contain `\bxmlns\b`:
For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
If both the HTTP and HTTPS versions
return 200 OK and serve the same content:
  Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov 
---
 drivers/platform/x86/apple-gmux.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/platform/x86/apple-gmux.c 
b/drivers/platform/x86/apple-gmux.c
index 7e3083deb1c5..9aae45a45200 100644
--- a/drivers/platform/x86/apple-gmux.c
+++ b/drivers/platform/x86/apple-gmux.c
@@ -277,8 +277,8 @@ static bool gmux_is_indexed(struct apple_gmux_data 
*gmux_data)
  * MBP5 2008/09 uses a `TI LP8543`_ backlight driver. All newer models
  * use a `TI LP8545`_.
  *
- * .. _TI LP8543: http://www.ti.com/lit/ds/symlink/lp8543.pdf
- * .. _TI LP8545: http://www.ti.com/lit/ds/symlink/lp8545.pdf
+ * .. _TI LP8543: https://www.ti.com/lit/ds/symlink/lp8543.pdf
+ * .. _TI LP8545: https://www.ti.com/lit/ds/symlink/lp8545.pdf
  */
 
 static int gmux_get_brightness(struct backlight_device *bd)
@@ -373,14 +373,14 @@ static const struct backlight_ops gmux_bl_ops = {
  * switch the panel and the external DP connector and allocates a framebuffer
  * for the selected GPU.
  *
- * .. _US 8,687,007 B2: http://pimg-fpiw.uspto.gov/fdd/07/870/086/0.pdf
- * .. _NXP CBTL06141:   http://www.nxp.com/documents/data_sheet/CBTL06141.pdf
- * .. _NXP CBTL06142:   http://www.nxp.com/documents/data_sheet/CBTL06141.pdf
- * .. _TI HD3SS212: http://www.ti.com/lit/ds/symlink/hd3ss212.pdf
+ * .. _US 8,687,007 B2: https://pimg-fpiw.uspto.gov/fdd/07/870/086/0.pdf
+ * .. _NXP CBTL06141:   https://www.nxp.com/documents/data_sheet/CBTL06141.pdf
+ * .. _NXP CBTL06142:   https://www.nxp.com/documents/data_sheet/CBTL06141.pdf
+ * .. _TI HD3SS212: https://www.ti.com/lit/ds/symlink/hd3ss212.pdf
  * .. _Pericom PI3VDP12412: 
https://www.pericom.com/assets/Datasheets/PI3VDP12412.pdf
- * .. _TI SN74LV4066A:  http://www.ti.com/lit/ds/symlink/sn74lv4066a.pdf
+ * .. _TI SN74LV4066A:  https://www.ti.com/lit/ds/symlink/sn74lv4066a.pdf
  * .. _NXP CBTL03062:   
http://pdf.datasheetarchive.com/indexerfiles/Datasheets-SW16/DSASW00308511.pdf
- * .. _TI TS3DS10224:   http://www.ti.com/lit/ds/symlink/ts3ds10224.pdf
+ * .. _TI TS3DS10224:   https://www.ti.com/lit/ds/symlink/ts3ds10224.pdf
  */
 
 static void gmux_read_switch_state(struct apple_gmux_data *gmux_data)
-- 
2.27.0



[PATCH 5.4 059/109] cxgb4: fix all-mask IP address comparison

2020-07-14 Thread Greg Kroah-Hartman
From: Rahul Lakkireddy 

[ Upstream commit 76c4d85c9260c3d741cbd194c30c61983d0a4303 ]

Convert all-mask IP address to Big Endian, instead, for comparison.

Fixes: f286dd8eaad5 ("cxgb4: use correct type for all-mask IP address 
comparison")
Signed-off-by: Rahul Lakkireddy 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 375e1be6a2d8d..f459313357c78 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -839,16 +839,16 @@ static bool is_addr_all_mask(u8 *ipmask, int family)
struct in_addr *addr;
 
addr = (struct in_addr *)ipmask;
-   if (ntohl(addr->s_addr) == 0x)
+   if (addr->s_addr == htonl(0x))
return true;
} else if (family == AF_INET6) {
struct in6_addr *addr6;
 
addr6 = (struct in6_addr *)ipmask;
-   if (ntohl(addr6->s6_addr32[0]) == 0x &&
-   ntohl(addr6->s6_addr32[1]) == 0x &&
-   ntohl(addr6->s6_addr32[2]) == 0x &&
-   ntohl(addr6->s6_addr32[3]) == 0x)
+   if (addr6->s6_addr32[0] == htonl(0x) &&
+   addr6->s6_addr32[1] == htonl(0x) &&
+   addr6->s6_addr32[2] == htonl(0x) &&
+   addr6->s6_addr32[3] == htonl(0x))
return true;
}
return false;
-- 
2.25.1





[PATCH 5.4 072/109] ALSA: opl3: fix infoleak in opl3

2020-07-14 Thread Greg Kroah-Hartman
From: xidongwang 

commit ad155712bb1ea2151944cf06a0e08c315c70c1e3 upstream.

The stack object “info” in snd_opl3_ioctl() has a leaking problem.
It has 2 padding bytes which are not initialized and leaked via
“copy_to_user”.

Signed-off-by: xidongwang 
Cc: 
Link: 
https://lore.kernel.org/r/1594006058-30362-1-git-send-email-wangxidong...@163.com
Signed-off-by: Takashi Iwai 
Signed-off-by: Greg Kroah-Hartman 

---
 sound/drivers/opl3/opl3_synth.c |2 ++
 1 file changed, 2 insertions(+)

--- a/sound/drivers/opl3/opl3_synth.c
+++ b/sound/drivers/opl3/opl3_synth.c
@@ -91,6 +91,8 @@ int snd_opl3_ioctl(struct snd_hwdep * hw
{
struct snd_dm_fm_info info;
 
+   memset(&info, 0, sizeof(info));
+
info.fm_mode = opl3->fm_mode;
info.rhythm = opl3->rhythm;
if (copy_to_user(argp, &info, sizeof(struct 
snd_dm_fm_info)))




[PATCH 5.4 088/109] module: Refactor section attr into bin attribute

2020-07-14 Thread Greg Kroah-Hartman
From: Kees Cook 

commit ed66f991bb19d94cae5d38f77de81f96aac7813f upstream.

In order to gain access to the open file's f_cred for kallsym visibility
permission checks, refactor the module section attributes to use the
bin_attribute instead of attribute interface. Additionally removes the
redundant "name" struct member.

Cc: sta...@vger.kernel.org
Reviewed-by: Greg Kroah-Hartman 
Tested-by: Jessica Yu 
Acked-by: Jessica Yu 
Signed-off-by: Kees Cook 
Signed-off-by: Greg Kroah-Hartman 

---
 kernel/module.c |   45 -
 1 file changed, 24 insertions(+), 21 deletions(-)

--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1507,8 +1507,7 @@ static inline bool sect_empty(const Elf_
 }
 
 struct module_sect_attr {
-   struct module_attribute mattr;
-   char *name;
+   struct bin_attribute battr;
unsigned long address;
 };
 
@@ -1518,11 +1517,16 @@ struct module_sect_attrs {
struct module_sect_attr attrs[0];
 };
 
-static ssize_t module_sect_show(struct module_attribute *mattr,
-   struct module_kobject *mk, char *buf)
+static ssize_t module_sect_read(struct file *file, struct kobject *kobj,
+   struct bin_attribute *battr,
+   char *buf, loff_t pos, size_t count)
 {
struct module_sect_attr *sattr =
-   container_of(mattr, struct module_sect_attr, mattr);
+   container_of(battr, struct module_sect_attr, battr);
+
+   if (pos != 0)
+   return -EINVAL;
+
return sprintf(buf, "0x%px\n", kptr_restrict < 2 ?
   (void *)sattr->address : NULL);
 }
@@ -1532,7 +1536,7 @@ static void free_sect_attrs(struct modul
unsigned int section;
 
for (section = 0; section < sect_attrs->nsections; section++)
-   kfree(sect_attrs->attrs[section].name);
+   kfree(sect_attrs->attrs[section].battr.attr.name);
kfree(sect_attrs);
 }
 
@@ -1541,42 +1545,41 @@ static void add_sect_attrs(struct module
unsigned int nloaded = 0, i, size[2];
struct module_sect_attrs *sect_attrs;
struct module_sect_attr *sattr;
-   struct attribute **gattr;
+   struct bin_attribute **gattr;
 
/* Count loaded sections and allocate structures */
for (i = 0; i < info->hdr->e_shnum; i++)
if (!sect_empty(&info->sechdrs[i]))
nloaded++;
size[0] = ALIGN(struct_size(sect_attrs, attrs, nloaded),
-   sizeof(sect_attrs->grp.attrs[0]));
-   size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.attrs[0]);
+   sizeof(sect_attrs->grp.bin_attrs[0]));
+   size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.bin_attrs[0]);
sect_attrs = kzalloc(size[0] + size[1], GFP_KERNEL);
if (sect_attrs == NULL)
return;
 
/* Setup section attributes. */
sect_attrs->grp.name = "sections";
-   sect_attrs->grp.attrs = (void *)sect_attrs + size[0];
+   sect_attrs->grp.bin_attrs = (void *)sect_attrs + size[0];
 
sect_attrs->nsections = 0;
sattr = §_attrs->attrs[0];
-   gattr = §_attrs->grp.attrs[0];
+   gattr = §_attrs->grp.bin_attrs[0];
for (i = 0; i < info->hdr->e_shnum; i++) {
Elf_Shdr *sec = &info->sechdrs[i];
if (sect_empty(sec))
continue;
+   sysfs_bin_attr_init(&sattr->battr);
sattr->address = sec->sh_addr;
-   sattr->name = kstrdup(info->secstrings + sec->sh_name,
-   GFP_KERNEL);
-   if (sattr->name == NULL)
+   sattr->battr.attr.name =
+   kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL);
+   if (sattr->battr.attr.name == NULL)
goto out;
sect_attrs->nsections++;
-   sysfs_attr_init(&sattr->mattr.attr);
-   sattr->mattr.show = module_sect_show;
-   sattr->mattr.store = NULL;
-   sattr->mattr.attr.name = sattr->name;
-   sattr->mattr.attr.mode = S_IRUSR;
-   *(gattr++) = &(sattr++)->mattr.attr;
+   sattr->battr.read = module_sect_read;
+   sattr->battr.size = 3 /* "0x", "\n" */ + (BITS_PER_LONG / 4);
+   sattr->battr.attr.mode = 0400;
+   *(gattr++) = &(sattr++)->battr;
}
*gattr = NULL;
 
@@ -1666,7 +1669,7 @@ static void add_notes_attrs(struct modul
continue;
if (info->sechdrs[i].sh_type == SHT_NOTE) {
sysfs_bin_attr_init(nattr);
-   nattr->attr.name = mod->sect_attrs->attrs[loaded].name;
+   nattr->attr.name = 
mod->sect_attrs->attrs[loaded].battr.attr.name;
nattr->attr.mode = S_IRUGO;
nattr->siz

[PATCH 5.4 086/109] KVM: arm64: Fix kvm_reset_vcpu() return code being incorrect with SVE

2020-07-14 Thread Greg Kroah-Hartman
From: Steven Price 

If SVE is enabled then 'ret' can be assigned the return value of
kvm_vcpu_enable_sve() which may be 0 causing future "goto out" sites to
erroneously return 0 on failure rather than -EINVAL as expected.

Remove the initialisation of 'ret' and make setting the return value
explicit to avoid this situation in the future.

Fixes: 9a3cdf26e336 ("KVM: arm64/sve: Allow userspace to enable SVE for vcpus")
Cc: sta...@vger.kernel.org
Reported-by: James Morse 
Signed-off-by: Steven Price 
Signed-off-by: Marc Zyngier 
Link: https://lore.kernel.org/r/20200617105456.28245-1-steven.pr...@arm.com
Signed-off-by: Sasha Levin 
---
 arch/arm64/kvm/reset.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -258,7 +258,7 @@ static int kvm_vcpu_enable_ptrauth(struc
 int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
 {
const struct kvm_regs *cpu_reset;
-   int ret = -EINVAL;
+   int ret;
bool loaded;
 
/* Reset PMU outside of the non-preemptible section */
@@ -281,15 +281,19 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu
 
if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, vcpu->arch.features) ||
test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features)) {
-   if (kvm_vcpu_enable_ptrauth(vcpu))
+   if (kvm_vcpu_enable_ptrauth(vcpu)) {
+   ret = -EINVAL;
goto out;
+   }
}
 
switch (vcpu->arch.target) {
default:
if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) {
-   if (!cpu_has_32bit_el1())
+   if (!cpu_has_32bit_el1()) {
+   ret = -EINVAL;
goto out;
+   }
cpu_reset = &default_regs_reset32;
} else {
cpu_reset = &default_regs_reset;




[PATCH 5.4 044/109] net: cxgb4: fix return error value in t4_prep_fw

2020-07-14 Thread Greg Kroah-Hartman
From: Li Heng 

[ Upstream commit 8a259e6b73ad8181b0b2ef338b35043433db1075 ]

t4_prep_fw goto bye tag with positive return value when something
bad happened and which can not free resource in adap_init0.
so fix it to return negative value.

Fixes: 16e47624e76b ("cxgb4: Add new scheme to update T4/T5 firmware")
Reported-by: Hulk Robot 
Signed-off-by: Li Heng 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 31fcfc58e3373..588b63473c473 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3499,7 +3499,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info 
*fw_info,
drv_fw = &fw_info->fw_hdr;
 
/* Read the header of the firmware on the card */
-   ret = -t4_read_flash(adap, FLASH_FW_START,
+   ret = t4_read_flash(adap, FLASH_FW_START,
sizeof(*card_fw) / sizeof(uint32_t),
(uint32_t *)card_fw, 1);
if (ret == 0) {
@@ -3528,8 +3528,8 @@ int t4_prep_fw(struct adapter *adap, struct fw_info 
*fw_info,
   should_install_fs_fw(adap, card_fw_usable,
be32_to_cpu(fs_fw->fw_ver),
be32_to_cpu(card_fw->fw_ver))) {
-   ret = -t4_fw_upgrade(adap, adap->mbox, fw_data,
-fw_size, 0);
+   ret = t4_fw_upgrade(adap, adap->mbox, fw_data,
+   fw_size, 0);
if (ret != 0) {
dev_err(adap->pdev_dev,
"failed to install firmware: %d\n", ret);
@@ -3560,7 +3560,7 @@ int t4_prep_fw(struct adapter *adap, struct fw_info 
*fw_info,
FW_HDR_FW_VER_MICRO_G(c), FW_HDR_FW_VER_BUILD_G(c),
FW_HDR_FW_VER_MAJOR_G(k), FW_HDR_FW_VER_MINOR_G(k),
FW_HDR_FW_VER_MICRO_G(k), FW_HDR_FW_VER_BUILD_G(k));
-   ret = EINVAL;
+   ret = -EINVAL;
goto bye;
}
 
-- 
2.25.1





[PATCH 5.4 093/109] btrfs: fix fatal extent_buffer readahead vs releasepage race

2020-07-14 Thread Greg Kroah-Hartman
From: Boris Burkov 

commit 6bf9cd2eed9aee6d742bb9296c994a91f5316949 upstream.

Under somewhat convoluted conditions, it is possible to attempt to
release an extent_buffer that is under io, which triggers a BUG_ON in
btrfs_release_extent_buffer_pages.

This relies on a few different factors. First, extent_buffer reads done
as readahead for searching use WAIT_NONE, so they free the local extent
buffer reference while the io is outstanding. However, they should still
be protected by TREE_REF. However, if the system is doing signficant
reclaim, and simultaneously heavily accessing the extent_buffers, it is
possible for releasepage to race with two concurrent readahead attempts
in a way that leaves TREE_REF unset when the readahead extent buffer is
released.

Essentially, if two tasks race to allocate a new extent_buffer, but the
winner who attempts the first io is rebuffed by a page being locked
(likely by the reclaim itself) then the loser will still go ahead with
issuing the readahead. The loser's call to find_extent_buffer must also
race with the reclaim task reading the extent_buffer's refcount as 1 in
a way that allows the reclaim to re-clear the TREE_REF checked by
find_extent_buffer.

The following represents an example execution demonstrating the race:

CPU0 CPU1   
CPU2
reada_for_searchreada_for_search
  readahead_tree_block
readahead_tree_block
find_create_tree_block  
find_create_tree_block
  alloc_extent_buffer 
alloc_extent_buffer
  
find_extent_buffer // not found
  allocates eb
  lock pages
  associate 
pages to eb
  insert eb 
into radix tree
  set TREE_REF, 
refs == 2
  unlock pages
  
read_extent_buffer_pages // WAIT_NONE
not uptodate 
(brand new eb)

lock_page
if !trylock_page
  goto 
unlock_exit // not an error
  free_extent_buffer

release_extent_buffer
  
atomic_dec_and_test refs to 1
find_extent_buffer // found

try_release_extent_buffer

  take refs_lock

  reads refs == 1; no io
  atomic_inc_not_zero refs to 2
  mark_buffer_accessed
check_buffer_tree_ref
  // not STALE, won't take refs_lock
  refs == 2; TREE_REF set // no action
read_extent_buffer_pages // WAIT_NONE

  clear TREE_REF

  release_extent_buffer

atomic_dec_and_test refs to 1

unlock_page
  still not uptodate (CPU1 read failed on trylock_page)
  locks pages
  set io_pages > 0
  submit io
  return
free_extent_buffer
  release_extent_buffer
dec refs to 0
delete from radix tree
btrfs_release_extent_buffer_pages
  BUG_ON(io_pages > 0)!!!

We observe this at a very low rate in production and were also able to
reproduce it in a test environment by introducing some spurious delays
and by introducing probabilistic trylock_page failures.

To fix it, we apply check_tree_ref at a point where it could not
possibly be unset by a competing task: after io_pages has been
incremented. All the codepaths that clear TREE_RE

[PATCH 5.4 066/109] net: macb: mark device wake capable when "magic-packet" property present

2020-07-14 Thread Greg Kroah-Hartman
From: Nicolas Ferre 

[ Upstream commit ced4799d06375929e013eea04ba6908207afabbe ]

Change the way the "magic-packet" DT property is handled in the
macb_probe() function, matching DT binding documentation.
Now we mark the device as "wakeup capable" instead of calling the
device_init_wakeup() function that would enable the wakeup source.

For Ethernet WoL, enabling the wakeup_source is done by
using ethtool and associated macb_set_wol() function that
already calls device_set_wakeup_enable() for this purpose.

That would reduce power consumption by cutting more clocks if
"magic-packet" property is set but WoL is not configured by ethtool.

Fixes: 3e2a5e153906 ("net: macb: add wake-on-lan support via magic packet")
Cc: Claudiu Beznea 
Cc: Harini Katakam 
Cc: Sergio Prado 
Reviewed-by: Florian Fainelli 
Signed-off-by: Nicolas Ferre 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c 
b/drivers/net/ethernet/cadence/macb_main.c
index 16f5c62ba6dfe..e7fafe2fcae5d 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4260,7 +4260,7 @@ static int macb_probe(struct platform_device *pdev)
bp->wol = 0;
if (of_get_property(np, "magic-packet", NULL))
bp->wol |= MACB_WOL_HAS_MAGIC_PACKET;
-   device_init_wakeup(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
+   device_set_wakeup_capable(&pdev->dev, bp->wol & 
MACB_WOL_HAS_MAGIC_PACKET);
 
spin_lock_init(&bp->lock);
 
-- 
2.25.1





[PATCH 5.4 068/109] mlxsw: spectrum_router: Remove inappropriate usage of WARN_ON()

2020-07-14 Thread Greg Kroah-Hartman
From: Ido Schimmel 

[ Upstream commit d9d5420273997664a1c09151ca86ac993f2f89c1 ]

We should not trigger a warning when a memory allocation fails. Remove
the WARN_ON().

The warning is constantly triggered by syzkaller when it is injecting
faults:

[ 2230.758664] FAULT_INJECTION: forcing a failure.
[ 2230.758664] name failslab, interval 1, probability 0, space 0, times 0
[ 2230.762329] CPU: 3 PID: 1407 Comm: syz-executor.0 Not tainted 5.8.0-rc2+ #28
...
[ 2230.898175] WARNING: CPU: 3 PID: 1407 at 
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:6265 
mlxsw_sp_router_fib_event+0xfad/0x13e0
[ 2230.898179] Kernel panic - not syncing: panic_on_warn set ...
[ 2230.898183] CPU: 3 PID: 1407 Comm: syz-executor.0 Not tainted 5.8.0-rc2+ #28
[ 2230.898190] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.12.1-0-ga5cab58e9a3f-prebuilt.qemu.org 04/01/2014

Fixes: 3057224e014c ("mlxsw: spectrum_router: Implement FIB offload in deferred 
work")
Signed-off-by: Ido Schimmel 
Reviewed-by: Jiri Pirko 
Signed-off-by: David S. Miller 
Signed-off-by: Sasha Levin 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index efdf8cb5114c2..2f013fc716985 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -6287,7 +6287,7 @@ static int mlxsw_sp_router_fib_event(struct 
notifier_block *nb,
}
 
fib_work = kzalloc(sizeof(*fib_work), GFP_ATOMIC);
-   if (WARN_ON(!fib_work))
+   if (!fib_work)
return NOTIFY_BAD;
 
fib_work->mlxsw_sp = router->mlxsw_sp;
-- 
2.25.1





Re: [PATCH v4 09/10] net: eth: altera: add msgdma prefetcher

2020-07-14 Thread Westergreen, Dalon


On Tue, 2020-07-14 at 09:29 -0700, Jakub Kicinski wrote:
> On Tue, 14 Jul 2020 15:58:53 + Westergreen, Dalon wrote:
> > On Tue, 2020-07-14 at 08:55 -0700, Jakub Kicinski wrote:
> > > On Tue, 14 Jul 2020 14:35:16 + Ooi, Joyce wrote:  
> > > > > I'm no device tree expert but these look like config options rather
> > > > > than
> > > > > HW
> > > > > description. They also don't appear to be documented in the next
> > > > > patch.
> > > > 
> > > > The poll_freq are part of the msgdma prefetcher IP, whereby it
> > > > specifies the frequency of descriptor polling operation. I can add
> > > > the poll_freq description in the next patch.  
> > > 
> > > Is the value decided at the time of synthesis or can the driver choose 
> > > the value it wants?  
> > 
> > It is not controlled at synthesis, this parameter should likely not be a
> > devicetree parameter, perhaps just make it a module parameter with a default
> > value.
> 
> Let's see if I understand the feature - instead of using a doorbell the
> HW periodically checks the contents of the next-to-use descriptor to
> see if it contains a valid tx frame or rx buffer?
> 

Yes, it checks the next-to-use descriptor to see if the descriptor is valid.

the value specifies the number of cycles to wait before checking again

> I've seen vendors abuse fields of ethtool --coalesce to configure
> similar settings. tx-usecs-irq and rx-usecs-irq, I think. Since this
> part of ethtool API has been ported to netlink, could we perhaps add 
> a new field to ethtool --coalesce?

I don't think this is necessary, i think just having a module parameter
meets our needs.  I don't see a need for the value to change on a per
interface basis.  This was primarily used during testing / bringup.

-dalon


[PATCH 5.4 050/109] perf intel-pt: Fix PEBS sample for XMM registers

2020-07-14 Thread Greg Kroah-Hartman
From: Adrian Hunter 

[ Upstream commit 4c95ad261cfac120dd66238fcae222766754c219 ]

The condition to add XMM registers was missing, the regs array needed to
be in the outer scope, and the size of the regs array was too small.

Fixes: 143d34a6b387b ("perf intel-pt: Add XMM registers to synthesized PEBS 
sample")
Signed-off-by: Adrian Hunter 
Cc: Jiri Olsa 
Cc: Luwei Kang 
Link: http://lore.kernel.org/lkml/20200630133935.11150-4-adrian.hun...@intel.com
Signed-off-by: Arnaldo Carvalho de Melo 
Signed-off-by: Sasha Levin 
---
 tools/perf/util/intel-pt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index a1c9eb6d4f40d..c5cce3a60476b 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -1707,6 +1707,7 @@ static int intel_pt_synth_pebs_sample(struct 
intel_pt_queue *ptq)
u64 sample_type = evsel->core.attr.sample_type;
u64 id = evsel->core.id[0];
u8 cpumode;
+   u64 regs[8 * sizeof(sample.intr_regs.mask)];
 
if (intel_pt_skip_event(pt))
return 0;
@@ -1756,8 +1757,8 @@ static int intel_pt_synth_pebs_sample(struct 
intel_pt_queue *ptq)
}
 
if (sample_type & PERF_SAMPLE_REGS_INTR &&
-   items->mask[INTEL_PT_GP_REGS_POS]) {
-   u64 regs[sizeof(sample.intr_regs.mask)];
+   (items->mask[INTEL_PT_GP_REGS_POS] ||
+items->mask[INTEL_PT_XMM_POS])) {
u64 regs_mask = evsel->core.attr.sample_regs_intr;
u64 *pos;
 
-- 
2.25.1





[PATCH 5.4 098/109] mmc: meson-gx: limit segments to 1 when dram-access-quirk is needed

2020-07-14 Thread Greg Kroah-Hartman
From: Neil Armstrong 

commit 27a5e7d36d383970affae801d77141deafd536a8 upstream.

The actual max_segs computation leads to failure while using the broadcom
sdio brcmfmac/bcmsdh driver, since the driver tries to make usage of
scatter gather.

But with the dram-access-quirk we use a 1,5K SRAM bounce buffer, and the
max_segs current value of 3 leads to max transfers to 4,5k, which doesn't
work.

This patch sets max_segs to 1 to better describe the hardware limitation,
and fix the SDIO functionality with the brcmfmac/bcmsdh driver on Amlogic
G12A/G12B SoCs on boards like SEI510 or Khadas VIM3.

Reported-by: Art Nikpal 
Reported-by: Christian Hewitt 
Fixes: acdc8e71d9bb ("mmc: meson-gx: add dram-access-quirk")
Signed-off-by: Neil Armstrong 
Reviewed-by: Kevin Hilman 
Cc: sta...@vger.kernel.org
Link: https://lore.kernel.org/r/20200608084458.32014-1-narmstr...@baylibre.com
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/host/meson-gx-mmc.c |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -1151,9 +1151,11 @@ static int meson_mmc_probe(struct platfo
 
mmc->caps |= MMC_CAP_CMD23;
if (host->dram_access_quirk) {
+   /* Limit segments to 1 due to low available sram memory */
+   mmc->max_segs = 1;
/* Limit to the available sram memory */
-   mmc->max_segs = SD_EMMC_SRAM_DATA_BUF_LEN / mmc->max_blk_size;
-   mmc->max_blk_count = mmc->max_segs;
+   mmc->max_blk_count = SD_EMMC_SRAM_DATA_BUF_LEN /
+mmc->max_blk_size;
} else {
mmc->max_blk_count = CMD_CFG_LENGTH_MASK;
mmc->max_segs = SD_EMMC_DESC_BUF_LEN /




[PATCH 5.4 079/109] ALSA: hda/realtek: Enable headset mic of Acer Veriton N4660G with ALC269VC

2020-07-14 Thread Greg Kroah-Hartman
From: Jian-Hong Pan 

commit 781c90c034d994c6a4e2badf189128a95ed864c2 upstream.

The Acer Veriton N4660G desktop's audio (1025:1248) with ALC269VC cannot
detect the headset microphone until ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE
quirk maps the NID 0x18 as the headset mic pin.

Signed-off-by: Jian-Hong Pan 
Cc: 
Link: https://lore.kernel.org/r/20200706071826.39726-3-jian-h...@endlessm.com
Signed-off-by: Takashi Iwai 
Signed-off-by: Greg Kroah-Hartman 

---
 sound/pci/hda/patch_realtek.c |   11 +++
 1 file changed, 11 insertions(+)

--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -6116,6 +6116,7 @@ enum {
ALC295_FIXUP_ASUS_MIC_NO_PRESENCE,
ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS,
ALC269VC_FIXUP_ACER_HEADSET_MIC,
+   ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE,
 };
 
 static const struct hda_fixup alc269_fixups[] = {
@@ -7314,6 +7315,15 @@ static const struct hda_fixup alc269_fix
.chained = true,
.chain_id = ALC269_FIXUP_HEADSET_MIC
},
+   [ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE] = {
+   .type = HDA_FIXUP_PINS,
+   .v.pins = (const struct hda_pintbl[]) {
+   { 0x18, 0x01a11130 }, /* use as headset mic, without 
its own jack detect */
+   { }
+   },
+   .chained = true,
+   .chain_id = ALC269_FIXUP_HEADSET_MIC
+   },
 };
 
 static const struct snd_pci_quirk alc269_fixup_tbl[] = {
@@ -7335,6 +7345,7 @@ static const struct snd_pci_quirk alc269
SND_PCI_QUIRK(0x1025, 0x110e, "Acer Aspire ES1-432", 
ALC255_FIXUP_ACER_MIC_NO_PRESENCE),
SND_PCI_QUIRK(0x1025, 0x1246, "Acer Predator Helios 500", 
ALC299_FIXUP_PREDATOR_SPK),
SND_PCI_QUIRK(0x1025, 0x1247, "Acer vCopperbox", 
ALC269VC_FIXUP_ACER_VCOPPERBOX_PINS),
+   SND_PCI_QUIRK(0x1025, 0x1248, "Acer Veriton N4660G", 
ALC269VC_FIXUP_ACER_MIC_NO_PRESENCE),
SND_PCI_QUIRK(0x1025, 0x128f, "Acer Veriton Z6860G", 
ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
SND_PCI_QUIRK(0x1025, 0x1290, "Acer Veriton Z4860G", 
ALC286_FIXUP_ACER_AIO_HEADSET_MIC),
SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", 
ALC286_FIXUP_ACER_AIO_HEADSET_MIC),




[PATCH] platform/x86: acerhdf: Replace HTTP links with HTTPS ones

2020-07-14 Thread Alexander A. Klimov
Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
For each line:
  If doesn't contain `\bxmlns\b`:
For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
If both the HTTP and HTTPS versions
return 200 OK and serve the same content:
  Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov 
---
 drivers/platform/x86/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 0581a54cf562..1d96e07b2a02 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -140,7 +140,7 @@ config ACERHDF
  in the same node directory will tell you if it is "acerhdf".
 
  For more information about this driver see
- 
+ 
 
  If you have an Acer Aspire One netbook, say Y or M
  here.
-- 
2.27.0



<    1   2   3   4   5   6   7   8   9   10   >