LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: DT case sensitivity
From: Segher Boessenkool @ 2018-08-24 16:52 UTC (permalink / raw)
  To: Rob Herring
  Cc: Benjamin Herrenschmidt, Stephen Rothwell, Kumar Gala, devicetree,
	devicetree-spec, linuxppc-dev, Grant Likely, Frank Rowand,
	David Gibson
In-Reply-To: <CAL_Jsq+VnhT_4H4yECWsuXnmpQRnSHNRXAohRYds1LxcRjUHkw@mail.gmail.com>

On Fri, Aug 24, 2018 at 10:14:01AM -0500, Rob Herring wrote:
> Another question: Is there ever a case where the node name in the path
> aka 'driver-name' doesn't match the 'name' property? I think this
> generally can't happen on FDT as the 'name' property is generated when
> we unflatten it though I suppose one could craft an FDT with name
> properties.

In Open Firmware, it *is* the "name" property :-)

> There's also various places in the kernel that check for a NULL name
> which doesn't seem like it could happen either other than the root
> node.

In Open Firmware the root node is required to have a "name" property, too.
There are systems that violate that rule (as with most rules...)


Segher

^ permalink raw reply

* Re: [RFC PATCH 11/11] powerpc/svm: Increase SWIOTLB buffer size
From: Randy Dunlap @ 2018-08-24 17:16 UTC (permalink / raw)
  To: Thiago Jung Bauermann, linuxppc-dev
  Cc: iommu, linux-kernel, Alexey Kardashevskiy, Anshuman Khandual,
	Benjamin Herrenschmidt, Christoph Hellwig, Michael Ellerman,
	Mike Anderson, Paul Mackerras, Ram Pai, Anshuman Khandual
In-Reply-To: <20180824162535.22798-12-bauerman@linux.ibm.com>

On 08/24/2018 09:25 AM, Thiago Jung Bauermann wrote:
> From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> 
> SWIOTLB buffer default size (64MB) is not enough for large sequential write
> operations which eventually leads to kernel crash like here.
> 
> virtio-pci 0000:00:05.0: swiotlb buffer is full (sz: 327680 bytes)
> virtio-pci 0000:00:05.0: DMA: Out of SW-IOMMU space for 327680 bytes
> Kernel panic - not syncing: DMA: Random memory could be DMA read
> CPU: 12 PID: 3985 Comm: mkfs.ext4 Not tainted 4.18.0-rc4+ #285
> Call Trace:
> [c0000007d2a27020] [c000000000cfdffc] dump_stack+0xb0/0xf4 (unreliable)
> [c0000007d2a27060] [c000000000112a98] panic+0x140/0x328
> [c0000007d2a270f0] [c0000000001b4f88] swiotlb_full+0x108/0x130
> [c0000007d2a27180] [c0000000001b5f6c] swiotlb_map_page+0x25c/0x2c0
> [c0000007d2a271e0] [c0000000007bfaf8] vring_map_one_sg.isra.0+0x58/0x70
> [c0000007d2a27200] [c0000000007c08dc] virtqueue_add_sgs+0x1bc/0x690
> [c0000007d2a272f0] [d0000000042a1280] virtio_queue_rq+0x358/0x4a0 [virtio_blk]
> [c0000007d2a273d0] [c0000000006b5d68] blk_mq_dispatch_rq_list+0x1f8/0x6d0
> ..................
> 
> Increase the SWIOTLB size to 1GB on Ultravisor based secure guests.
> 
> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
> ---
>  arch/powerpc/Kconfig | 5 +++++
>  kernel/dma/swiotlb.c | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 1466d1234723..fee7194ce9e4 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -457,6 +457,11 @@ config PPC_SVM
>  
>  	 If unsure, say "N".
>  
> +config SWIOTLB_DEFAULT_SIZE
> +       int "Size of Software I/O TLB buffer (in MiB)"
> +       default "1024"

I would add a "range" to limit (restrict) how small or large that can be.  E.g.:

	range 16 102400

or even smaller for the maximum value...

> +       depends on PPC_SVM
> +
>  config PPC_TRANSACTIONAL_MEM
>         bool "Transactional Memory support for POWERPC"
>         depends on PPC_BOOK3S_64
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 04b68d9dffac..32dc67422d8a 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -146,8 +146,13 @@ void swiotlb_set_max_segment(unsigned int val)
>  		max_segment = rounddown(val, PAGE_SIZE);
>  }
>  
> +#ifdef CONFIG_SWIOTLB_DEFAULT_SIZE
> +#define IO_TLB_DEFAULT_SIZE ((unsigned long) CONFIG_SWIOTLB_DEFAULT_SIZE << 20)
> +#else
>  /* default to 64MB */
>  #define IO_TLB_DEFAULT_SIZE (64UL<<20)
> +#endif
> +
>  unsigned long swiotlb_size_or_default(void)
>  {
>  	unsigned long size;
> 


-- 
~Randy

^ permalink raw reply

* FSL/NXP P5020: USB problems with the latest Git kernels
From: Christian Zigotzky @ 2018-08-24 18:11 UTC (permalink / raw)
  To: linuxppc-dev

Hello,

There are USB problems with P5020 boards with the latest Git kernels.

Some users reported the following error messages:

skateman@X5000LNX:~$ grep -i -E 'usb.*error' /var/log/syslog
Aug 24 13:12:50 X5000LNX kernel: [ 6.552303] usb 1-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 6.649376] usb 2-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 6.794158] usb 1-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 6.883156] usb 2-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 7.139155] usb 1-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 7.226156] usb 2-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 7.363155] usb 1-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 7.451156] usb 2-1: device descriptor read=
/64, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 8.521156] usb 1-1: device not accepting a=
ddress 4, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 8.609156] usb 2-1: device not accepting a=
ddress 4, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 9.057155] usb 1-1: device not accepting a=
ddress 5, error -32
Aug 24 13:12:50 X5000LNX kernel: [ 9.145157] usb 2-1: device not accepting a=
ddress 5, error -32

I don=E2=80=99t have a P5020 board here. That means I can=E2=80=99t bisect a=
nd test. Therefore I need your help. The problematic Git commit must be some=
where between 22/08/18 1:20 PM UTC and 23/08/18 10:49 AM UTC.
The Git kernel from 22/08/18 1:20 PM UTC works with USB devices.
Could you please compile a Git kernel and test it on your P5020 board?

Thanks,
Christian=

^ permalink raw reply

* Re: [RFC PATCH 00/11] Secure Virtual Machine Enablement
From: Ram Pai @ 2018-08-24 18:16 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Thiago Jung Bauermann, linuxppc-dev, iommu, linux-kernel,
	Alexey Kardashevskiy, Anshuman Khandual, Benjamin Herrenschmidt,
	Michael Ellerman, Mike Anderson, Paul Mackerras
In-Reply-To: <20180824163330.GA15438@lst.de>

On Fri, Aug 24, 2018 at 06:33:30PM +0200, Christoph Hellwig wrote:
> On Fri, Aug 24, 2018 at 01:25:24PM -0300, Thiago Jung Bauermann wrote:
> > [ Some people didn't receive all the patches in this series, even though
> >   the linuxppc-dev list did so trying to send again. This is exactly the
> >   same series I posted yesterday. Sorry for the clutter. ]
> 
> I'm still only getting six of the patches.

We are all receving the entire series.  And I see that the mails have
also landed on the mailing lists.  Some filter on your side
is dropping the mails?

-- 
Ram Pai

^ permalink raw reply

* Re: [PATCH v2] crypto: vmx - Fix sleep-in-atomic bugs
From: Paulo Flabiano Smorigo @ 2018-08-24 19:47 UTC (permalink / raw)
  To: Marcelo Henrique Cerri
  Cc: Ondrej Mosnacek, Herbert Xu, linux-crypto, Stephan Mueller,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Leonidas S . Barbosa, linuxppc-dev, stable
In-Reply-To: <11128af3ef7474136485261b5d53b679@linux.vnet.ibm.com>

On 2018-08-23 17:34, Paulo Flabiano Smorigo wrote:
> On 2018-08-22 21:04, Marcelo Henrique Cerri wrote:
>> That looks good to me. Maybe Paulo can help testing it.
>> 
>> --
>> Regards,
>> Marcelo
>> 
>> On Wed, Aug 22, 2018 at 08:26:31AM +0200, Ondrej Mosnacek wrote:
>>> This patch fixes sleep-in-atomic bugs in AES-CBC and AES-XTS VMX
>>> implementations. The problem is that the blkcipher_* functions should
>>> not be called in atomic context.
>>> 
>>> The bugs can be reproduced via the AF_ALG interface by trying to
>>> encrypt/decrypt sufficiently large buffers (at least 64 KiB) using 
>>> the
>>> VMX implementations of 'cbc(aes)' or 'xts(aes)'. Such operations then
>>> trigger BUG in crypto_yield():
>>> 
>>> [  891.863680] BUG: sleeping function called from invalid context at 
>>> include/crypto/algapi.h:424
>>> [  891.864622] in_atomic(): 1, irqs_disabled(): 0, pid: 12347, name: 
>>> kcapi-enc
>>> [  891.864739] 1 lock held by kcapi-enc/12347:
>>> [  891.864811]  #0: 00000000f5d42c46 (sk_lock-AF_ALG){+.+.}, at: 
>>> skcipher_recvmsg+0x50/0x530
>>> [  891.865076] CPU: 5 PID: 12347 Comm: kcapi-enc Not tainted 
>>> 4.19.0-0.rc0.git3.1.fc30.ppc64le #1
>>> [  891.865251] Call Trace:
>>> [  891.865340] [c0000003387578c0] [c000000000d67ea4] 
>>> dump_stack+0xe8/0x164 (unreliable)
>>> [  891.865511] [c000000338757910] [c000000000172a58] 
>>> ___might_sleep+0x2f8/0x310
>>> [  891.865679] [c000000338757990] [c0000000006bff74] 
>>> blkcipher_walk_done+0x374/0x4a0
>>> [  891.865825] [c0000003387579e0] [d000000007e73e70] 
>>> p8_aes_cbc_encrypt+0x1c8/0x260 [vmx_crypto]
>>> [  891.865993] [c000000338757ad0] [c0000000006c0ee0] 
>>> skcipher_encrypt_blkcipher+0x60/0x80
>>> [  891.866128] [c000000338757b10] [c0000000006ec504] 
>>> skcipher_recvmsg+0x424/0x530
>>> [  891.866283] [c000000338757bd0] [c000000000b00654] 
>>> sock_recvmsg+0x74/0xa0
>>> [  891.866403] [c000000338757c10] [c000000000b00f64] 
>>> ___sys_recvmsg+0xf4/0x2f0
>>> [  891.866515] [c000000338757d90] [c000000000b02bb8] 
>>> __sys_recvmsg+0x68/0xe0
>>> [  891.866631] [c000000338757e30] [c00000000000bbe4] 
>>> system_call+0x5c/0x70
>>> 
>>> Fixes: 8c755ace357c ("crypto: vmx - Adding CBC routines for VMX 
>>> module")
>>> Fixes: c07f5d3da643 ("crypto: vmx - Adding support for XTS")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
>>> ---
>>> Still untested, please test and review if possible.
>>> 
>>> Changes in v2:
>>> - fix leaving preemtption, etc. disabled when leaving the function
>>>   (I switched to the more obvious and less efficient variant for the
>>>   sake of clarity.)
>>> 
>>>  drivers/crypto/vmx/aes_cbc.c | 30 ++++++++++++++----------------
>>>  drivers/crypto/vmx/aes_xts.c | 21 ++++++++++++++-------
>>>  2 files changed, 28 insertions(+), 23 deletions(-)
>>> 
>>> diff --git a/drivers/crypto/vmx/aes_cbc.c 
>>> b/drivers/crypto/vmx/aes_cbc.c
>>> index 5285ece4f33a..b71895871be3 100644
>>> --- a/drivers/crypto/vmx/aes_cbc.c
>>> +++ b/drivers/crypto/vmx/aes_cbc.c
>>> @@ -107,24 +107,23 @@ static int p8_aes_cbc_encrypt(struct 
>>> blkcipher_desc *desc,
>>>  		ret = crypto_skcipher_encrypt(req);
>>>  		skcipher_request_zero(req);
>>>  	} else {
>>> -		preempt_disable();
>>> -		pagefault_disable();
>>> -		enable_kernel_vsx();
>>> -
>>>  		blkcipher_walk_init(&walk, dst, src, nbytes);
>>>  		ret = blkcipher_walk_virt(desc, &walk);
>>>  		while ((nbytes = walk.nbytes)) {
>>> +			preempt_disable();
>>> +			pagefault_disable();
>>> +			enable_kernel_vsx();
>>>  			aes_p8_cbc_encrypt(walk.src.virt.addr,
>>>  					   walk.dst.virt.addr,
>>>  					   nbytes & AES_BLOCK_MASK,
>>>  					   &ctx->enc_key, walk.iv, 1);
>>> +			disable_kernel_vsx();
>>> +			pagefault_enable();
>>> +			preempt_enable();
>>> +
>>>  			nbytes &= AES_BLOCK_SIZE - 1;
>>>  			ret = blkcipher_walk_done(desc, &walk, nbytes);
>>>  		}
>>> -
>>> -		disable_kernel_vsx();
>>> -		pagefault_enable();
>>> -		preempt_enable();
>>>  	}
>>> 
>>>  	return ret;
>>> @@ -147,24 +146,23 @@ static int p8_aes_cbc_decrypt(struct 
>>> blkcipher_desc *desc,
>>>  		ret = crypto_skcipher_decrypt(req);
>>>  		skcipher_request_zero(req);
>>>  	} else {
>>> -		preempt_disable();
>>> -		pagefault_disable();
>>> -		enable_kernel_vsx();
>>> -
>>>  		blkcipher_walk_init(&walk, dst, src, nbytes);
>>>  		ret = blkcipher_walk_virt(desc, &walk);
>>>  		while ((nbytes = walk.nbytes)) {
>>> +			preempt_disable();
>>> +			pagefault_disable();
>>> +			enable_kernel_vsx();
>>>  			aes_p8_cbc_encrypt(walk.src.virt.addr,
>>>  					   walk.dst.virt.addr,
>>>  					   nbytes & AES_BLOCK_MASK,
>>>  					   &ctx->dec_key, walk.iv, 0);
>>> +			disable_kernel_vsx();
>>> +			pagefault_enable();
>>> +			preempt_enable();
>>> +
>>>  			nbytes &= AES_BLOCK_SIZE - 1;
>>>  			ret = blkcipher_walk_done(desc, &walk, nbytes);
>>>  		}
>>> -
>>> -		disable_kernel_vsx();
>>> -		pagefault_enable();
>>> -		preempt_enable();
>>>  	}
>>> 
>>>  	return ret;
>>> diff --git a/drivers/crypto/vmx/aes_xts.c 
>>> b/drivers/crypto/vmx/aes_xts.c
>>> index 8bd9aff0f55f..e9954a7d4694 100644
>>> --- a/drivers/crypto/vmx/aes_xts.c
>>> +++ b/drivers/crypto/vmx/aes_xts.c
>>> @@ -116,32 +116,39 @@ static int p8_aes_xts_crypt(struct 
>>> blkcipher_desc *desc,
>>>  		ret = enc? crypto_skcipher_encrypt(req) : 
>>> crypto_skcipher_decrypt(req);
>>>  		skcipher_request_zero(req);
>>>  	} else {
>>> +		blkcipher_walk_init(&walk, dst, src, nbytes);
>>> +
>>> +		ret = blkcipher_walk_virt(desc, &walk);
>>> +
>>>  		preempt_disable();
>>>  		pagefault_disable();
>>>  		enable_kernel_vsx();
>>> 
>>> -		blkcipher_walk_init(&walk, dst, src, nbytes);
>>> -
>>> -		ret = blkcipher_walk_virt(desc, &walk);
>>>  		iv = walk.iv;
>>>  		memset(tweak, 0, AES_BLOCK_SIZE);
>>>  		aes_p8_encrypt(iv, tweak, &ctx->tweak_key);
>>> 
>>> +		disable_kernel_vsx();
>>> +		pagefault_enable();
>>> +		preempt_enable();
>>> +
>>>  		while ((nbytes = walk.nbytes)) {
>>> +			preempt_disable();
>>> +			pagefault_disable();
>>> +			enable_kernel_vsx();
>>>  			if (enc)
>>>  				aes_p8_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
>>>  						nbytes & AES_BLOCK_MASK, &ctx->enc_key, NULL, tweak);
>>>  			else
>>>  				aes_p8_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr,
>>>  						nbytes & AES_BLOCK_MASK, &ctx->dec_key, NULL, tweak);
>>> +			disable_kernel_vsx();
>>> +			pagefault_enable();
>>> +			preempt_enable();
>>> 
>>>  			nbytes &= AES_BLOCK_SIZE - 1;
>>>  			ret = blkcipher_walk_done(desc, &walk, nbytes);
>>>  		}
>>> -
>>> -		disable_kernel_vsx();
>>> -		pagefault_enable();
>>> -		preempt_enable();
>>>  	}
>>>  	return ret;
>>>  }
>>> --
>>> 2.17.1
>>> 
> 
> Sure thing. I'll test it later today. Thanks Ondrej for the fix.

Looks good to me. I made some tests here and no problem was found.

-- 
Paulo Flabiano Smorigo
IBM Linux Technology Center

^ permalink raw reply

* Re: [PATCH v2] crypto: vmx - Fix sleep-in-atomic bugs
From: Ondrej Mosnacek @ 2018-08-24 20:01 UTC (permalink / raw)
  To: Paulo Flabiano Smorigo
  Cc: Marcelo Henrique Cerri, Herbert Xu, linux-crypto, Stephan Mueller,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Leonidas S . Barbosa, linuxppc-dev, stable
In-Reply-To: <fd3caaa4fe25a456c94bbeab6365a82b@linux.vnet.ibm.com>

On Fri, Aug 24, 2018 at 9:39 PM Paulo Flabiano Smorigo
<pfsmorigo@linux.vnet.ibm.com> wrote:
> On 2018-08-23 17:34, Paulo Flabiano Smorigo wrote:
> > On 2018-08-22 21:04, Marcelo Henrique Cerri wrote:
> >> That looks good to me. Maybe Paulo can help testing it.
> >>
> >> --
> >> Regards,
> >> Marcelo
> >>
> >> On Wed, Aug 22, 2018 at 08:26:31AM +0200, Ondrej Mosnacek wrote:
> >>> This patch fixes sleep-in-atomic bugs in AES-CBC and AES-XTS VMX
> >>> implementations. The problem is that the blkcipher_* functions should
> >>> not be called in atomic context.
> >>>
> >>> The bugs can be reproduced via the AF_ALG interface by trying to
> >>> encrypt/decrypt sufficiently large buffers (at least 64 KiB) using
> >>> the
> >>> VMX implementations of 'cbc(aes)' or 'xts(aes)'. Such operations then
> >>> trigger BUG in crypto_yield():
> >>>
> >>> [  891.863680] BUG: sleeping function called from invalid context at
> >>> include/crypto/algapi.h:424
> >>> [  891.864622] in_atomic(): 1, irqs_disabled(): 0, pid: 12347, name:
> >>> kcapi-enc
> >>> [  891.864739] 1 lock held by kcapi-enc/12347:
> >>> [  891.864811]  #0: 00000000f5d42c46 (sk_lock-AF_ALG){+.+.}, at:
> >>> skcipher_recvmsg+0x50/0x530
> >>> [  891.865076] CPU: 5 PID: 12347 Comm: kcapi-enc Not tainted
> >>> 4.19.0-0.rc0.git3.1.fc30.ppc64le #1
> >>> [  891.865251] Call Trace:
> >>> [  891.865340] [c0000003387578c0] [c000000000d67ea4]
> >>> dump_stack+0xe8/0x164 (unreliable)
> >>> [  891.865511] [c000000338757910] [c000000000172a58]
> >>> ___might_sleep+0x2f8/0x310
> >>> [  891.865679] [c000000338757990] [c0000000006bff74]
> >>> blkcipher_walk_done+0x374/0x4a0
> >>> [  891.865825] [c0000003387579e0] [d000000007e73e70]
> >>> p8_aes_cbc_encrypt+0x1c8/0x260 [vmx_crypto]
> >>> [  891.865993] [c000000338757ad0] [c0000000006c0ee0]
> >>> skcipher_encrypt_blkcipher+0x60/0x80
> >>> [  891.866128] [c000000338757b10] [c0000000006ec504]
> >>> skcipher_recvmsg+0x424/0x530
> >>> [  891.866283] [c000000338757bd0] [c000000000b00654]
> >>> sock_recvmsg+0x74/0xa0
> >>> [  891.866403] [c000000338757c10] [c000000000b00f64]
> >>> ___sys_recvmsg+0xf4/0x2f0
> >>> [  891.866515] [c000000338757d90] [c000000000b02bb8]
> >>> __sys_recvmsg+0x68/0xe0
> >>> [  891.866631] [c000000338757e30] [c00000000000bbe4]
> >>> system_call+0x5c/0x70
> >>>
> >>> Fixes: 8c755ace357c ("crypto: vmx - Adding CBC routines for VMX
> >>> module")
> >>> Fixes: c07f5d3da643 ("crypto: vmx - Adding support for XTS")
> >>> Cc: stable@vger.kernel.org
> >>> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> >>> ---
> >>> Still untested, please test and review if possible.
> >>>
> >>> Changes in v2:
> >>> - fix leaving preemtption, etc. disabled when leaving the function
> >>>   (I switched to the more obvious and less efficient variant for the
> >>>   sake of clarity.)
> >>>
> >>>  drivers/crypto/vmx/aes_cbc.c | 30 ++++++++++++++----------------
> >>>  drivers/crypto/vmx/aes_xts.c | 21 ++++++++++++++-------
> >>>  2 files changed, 28 insertions(+), 23 deletions(-)
> >>>
> >>> diff --git a/drivers/crypto/vmx/aes_cbc.c
> >>> b/drivers/crypto/vmx/aes_cbc.c
> >>> index 5285ece4f33a..b71895871be3 100644
> >>> --- a/drivers/crypto/vmx/aes_cbc.c
> >>> +++ b/drivers/crypto/vmx/aes_cbc.c
> >>> @@ -107,24 +107,23 @@ static int p8_aes_cbc_encrypt(struct
> >>> blkcipher_desc *desc,
> >>>             ret = crypto_skcipher_encrypt(req);
> >>>             skcipher_request_zero(req);
> >>>     } else {
> >>> -           preempt_disable();
> >>> -           pagefault_disable();
> >>> -           enable_kernel_vsx();
> >>> -
> >>>             blkcipher_walk_init(&walk, dst, src, nbytes);
> >>>             ret = blkcipher_walk_virt(desc, &walk);
> >>>             while ((nbytes = walk.nbytes)) {
> >>> +                   preempt_disable();
> >>> +                   pagefault_disable();
> >>> +                   enable_kernel_vsx();
> >>>                     aes_p8_cbc_encrypt(walk.src.virt.addr,
> >>>                                        walk.dst.virt.addr,
> >>>                                        nbytes & AES_BLOCK_MASK,
> >>>                                        &ctx->enc_key, walk.iv, 1);
> >>> +                   disable_kernel_vsx();
> >>> +                   pagefault_enable();
> >>> +                   preempt_enable();
> >>> +
> >>>                     nbytes &= AES_BLOCK_SIZE - 1;
> >>>                     ret = blkcipher_walk_done(desc, &walk, nbytes);
> >>>             }
> >>> -
> >>> -           disable_kernel_vsx();
> >>> -           pagefault_enable();
> >>> -           preempt_enable();
> >>>     }
> >>>
> >>>     return ret;
> >>> @@ -147,24 +146,23 @@ static int p8_aes_cbc_decrypt(struct
> >>> blkcipher_desc *desc,
> >>>             ret = crypto_skcipher_decrypt(req);
> >>>             skcipher_request_zero(req);
> >>>     } else {
> >>> -           preempt_disable();
> >>> -           pagefault_disable();
> >>> -           enable_kernel_vsx();
> >>> -
> >>>             blkcipher_walk_init(&walk, dst, src, nbytes);
> >>>             ret = blkcipher_walk_virt(desc, &walk);
> >>>             while ((nbytes = walk.nbytes)) {
> >>> +                   preempt_disable();
> >>> +                   pagefault_disable();
> >>> +                   enable_kernel_vsx();
> >>>                     aes_p8_cbc_encrypt(walk.src.virt.addr,
> >>>                                        walk.dst.virt.addr,
> >>>                                        nbytes & AES_BLOCK_MASK,
> >>>                                        &ctx->dec_key, walk.iv, 0);
> >>> +                   disable_kernel_vsx();
> >>> +                   pagefault_enable();
> >>> +                   preempt_enable();
> >>> +
> >>>                     nbytes &= AES_BLOCK_SIZE - 1;
> >>>                     ret = blkcipher_walk_done(desc, &walk, nbytes);
> >>>             }
> >>> -
> >>> -           disable_kernel_vsx();
> >>> -           pagefault_enable();
> >>> -           preempt_enable();
> >>>     }
> >>>
> >>>     return ret;
> >>> diff --git a/drivers/crypto/vmx/aes_xts.c
> >>> b/drivers/crypto/vmx/aes_xts.c
> >>> index 8bd9aff0f55f..e9954a7d4694 100644
> >>> --- a/drivers/crypto/vmx/aes_xts.c
> >>> +++ b/drivers/crypto/vmx/aes_xts.c
> >>> @@ -116,32 +116,39 @@ static int p8_aes_xts_crypt(struct
> >>> blkcipher_desc *desc,
> >>>             ret = enc? crypto_skcipher_encrypt(req) :
> >>> crypto_skcipher_decrypt(req);
> >>>             skcipher_request_zero(req);
> >>>     } else {
> >>> +           blkcipher_walk_init(&walk, dst, src, nbytes);
> >>> +
> >>> +           ret = blkcipher_walk_virt(desc, &walk);
> >>> +
> >>>             preempt_disable();
> >>>             pagefault_disable();
> >>>             enable_kernel_vsx();
> >>>
> >>> -           blkcipher_walk_init(&walk, dst, src, nbytes);
> >>> -
> >>> -           ret = blkcipher_walk_virt(desc, &walk);
> >>>             iv = walk.iv;
> >>>             memset(tweak, 0, AES_BLOCK_SIZE);
> >>>             aes_p8_encrypt(iv, tweak, &ctx->tweak_key);
> >>>
> >>> +           disable_kernel_vsx();
> >>> +           pagefault_enable();
> >>> +           preempt_enable();
> >>> +
> >>>             while ((nbytes = walk.nbytes)) {
> >>> +                   preempt_disable();
> >>> +                   pagefault_disable();
> >>> +                   enable_kernel_vsx();
> >>>                     if (enc)
> >>>                             aes_p8_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
> >>>                                             nbytes & AES_BLOCK_MASK, &ctx->enc_key, NULL, tweak);
> >>>                     else
> >>>                             aes_p8_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr,
> >>>                                             nbytes & AES_BLOCK_MASK, &ctx->dec_key, NULL, tweak);
> >>> +                   disable_kernel_vsx();
> >>> +                   pagefault_enable();
> >>> +                   preempt_enable();
> >>>
> >>>                     nbytes &= AES_BLOCK_SIZE - 1;
> >>>                     ret = blkcipher_walk_done(desc, &walk, nbytes);
> >>>             }
> >>> -
> >>> -           disable_kernel_vsx();
> >>> -           pagefault_enable();
> >>> -           preempt_enable();
> >>>     }
> >>>     return ret;
> >>>  }
> >>> --
> >>> 2.17.1
> >>>
> >
> > Sure thing. I'll test it later today. Thanks Ondrej for the fix.
>
> Looks good to me. I made some tests here and no problem was found.

Great, thanks!

-- 
Ondrej Mosnacek <omosnace at redhat dot com>
Associate Software Engineer, Security Technologies
Red Hat, Inc.

^ permalink raw reply

* Re: [RFC PATCH 10/11] powerpc/svm: Force the use of bounce buffers
From: Thiago Jung Bauermann @ 2018-08-24 23:38 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linuxppc-dev, iommu, linux-kernel, Alexey Kardashevskiy,
	Anshuman Khandual, Benjamin Herrenschmidt, Michael Ellerman,
	Mike Anderson, Paul Mackerras, Ram Pai, Anshuman Khandual
In-Reply-To: <20180824060055.GB13689@lst.de>


Hello Christoph,

Thanks for your quick review.

Christoph Hellwig <hch@lst.de> writes:

> On Thu, Aug 23, 2018 at 11:59:32PM -0300, Thiago Jung Bauermann wrote:
>> From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>>
>> SWIOTLB checks range of incoming CPU addresses to be bounced and see if the
>> device can access it through it's DMA window without requiring bouncing. In
>> such cases it just chooses to skip bouncing. But for cases like secure
>> guests on powerpc platform all addresses need to be bounced into the shared
>> pool of memory because the host cannot access it otherwise. Hence the need
>> to do the bouncing is not related to device's DMA window. Hence force the
>> use of bouncing by setting the swiotlb_force variable on secure guests.
>>
>> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
>> ---
>>  arch/powerpc/kernel/svm.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/arch/powerpc/kernel/svm.c b/arch/powerpc/kernel/svm.c
>> index 1af5caa955f5..f0576ad65cd0 100644
>> --- a/arch/powerpc/kernel/svm.c
>> +++ b/arch/powerpc/kernel/svm.c
>> @@ -17,6 +17,7 @@ static int __init init_svm(void)
>>  		return 0;
>>
>>  	ppc_swiotlb_enable = 1;
>> +	swiotlb_force = SWIOTLB_FORCE;
>>  	swiotlb_update_mem_attributes();
>
> This needs a comment.

Good point. Will add one.

If in the new scheme of things (with bus_dma_mask?) dma_capable() on a
virtio device running in a secure guest returns false, then this patch
becomes unnecessary and can be dropped.

--
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply

* Re: [RFC PATCH 11/11] powerpc/svm: Increase SWIOTLB buffer size
From: Thiago Jung Bauermann @ 2018-08-25  0:38 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: linuxppc-dev, iommu, linux-kernel, Alexey Kardashevskiy,
	Anshuman Khandual, Benjamin Herrenschmidt, Christoph Hellwig,
	Michael Ellerman, Mike Anderson, Paul Mackerras, Ram Pai,
	Anshuman Khandual
In-Reply-To: <45561478-ee75-ee62-52d6-a96d60132669@infradead.org>


Hello Randy,

Thanks for your quick review.

Randy Dunlap <rdunlap@infradead.org> writes:

> On 08/24/2018 09:25 AM, Thiago Jung Bauermann wrote:
>> From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>>
>> SWIOTLB buffer default size (64MB) is not enough for large sequential write
>> operations which eventually leads to kernel crash like here.
>>
>> virtio-pci 0000:00:05.0: swiotlb buffer is full (sz: 327680 bytes)
>> virtio-pci 0000:00:05.0: DMA: Out of SW-IOMMU space for 327680 bytes
>> Kernel panic - not syncing: DMA: Random memory could be DMA read
>> CPU: 12 PID: 3985 Comm: mkfs.ext4 Not tainted 4.18.0-rc4+ #285
>> Call Trace:
>> [c0000007d2a27020] [c000000000cfdffc] dump_stack+0xb0/0xf4 (unreliable)
>> [c0000007d2a27060] [c000000000112a98] panic+0x140/0x328
>> [c0000007d2a270f0] [c0000000001b4f88] swiotlb_full+0x108/0x130
>> [c0000007d2a27180] [c0000000001b5f6c] swiotlb_map_page+0x25c/0x2c0
>> [c0000007d2a271e0] [c0000000007bfaf8] vring_map_one_sg.isra.0+0x58/0x70
>> [c0000007d2a27200] [c0000000007c08dc] virtqueue_add_sgs+0x1bc/0x690
>> [c0000007d2a272f0] [d0000000042a1280] virtio_queue_rq+0x358/0x4a0 [virtio_blk]
>> [c0000007d2a273d0] [c0000000006b5d68] blk_mq_dispatch_rq_list+0x1f8/0x6d0
>> ..................
>>
>> Increase the SWIOTLB size to 1GB on Ultravisor based secure guests.
>>
>> Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com>
>> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.ibm.com>
>> ---
>>  arch/powerpc/Kconfig | 5 +++++
>>  kernel/dma/swiotlb.c | 5 +++++
>>  2 files changed, 10 insertions(+)
>>
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 1466d1234723..fee7194ce9e4 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -457,6 +457,11 @@ config PPC_SVM
>>
>>  	 If unsure, say "N".
>>
>> +config SWIOTLB_DEFAULT_SIZE
>> +       int "Size of Software I/O TLB buffer (in MiB)"
>> +       default "1024"
>
> I would add a "range" to limit (restrict) how small or large that can be.  E.g.:
>
> 	range 16 102400
>
> or even smaller for the maximum value...

That's an interesting idea. Since this config option is restricted to
PPC_SVM it may be possible to find out what reasonable limits would be.
I'll have to experiment a bit to find out. Though I can say that 16 MB
is too small since even with 64 MB the kernel panics with the simple
task of formatting a filesystem...

--
Thiago Jung Bauermann
IBM Linux Technology Center

^ permalink raw reply

* Re: [RFC PATCH 11/11] powerpc/svm: Increase SWIOTLB buffer size
From: Christoph Hellwig @ 2018-08-25  8:55 UTC (permalink / raw)
  To: Thiago Jung Bauermann
  Cc: linuxppc-dev, iommu, linux-kernel, Alexey Kardashevskiy,
	Anshuman Khandual, Benjamin Herrenschmidt, Christoph Hellwig,
	Michael Ellerman, Mike Anderson, Paul Mackerras, Ram Pai,
	Anshuman Khandual
In-Reply-To: <20180824025933.24319-12-bauerman@linux.ibm.com>

> +config SWIOTLB_DEFAULT_SIZE
> +       int "Size of Software I/O TLB buffer (in MiB)"
> +       default "1024"
> +       depends on PPC_SVM
> +

This belongs into kernel/dma/Kconfig.  That being said I really
don't see why this should be a user visible Kconfig.

^ permalink raw reply

* Re: [PATCH] treewide: remove current_text_addr
From: Helge Deller @ 2018-08-25 10:48 UTC (permalink / raw)
  To: Nick Desaulniers, torvalds, akpm
  Cc: ebiederm, tglx, mingo, hpa, horms, natechancellor, pombredanne,
	kstewart, gregkh, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
	Mark Salter, Aurelien Jacquiot, Yoshinori Sato, Richard Kuo,
	Tony Luck, Fenghua Yu, Geert Uytterhoeven, Michal Simek,
	Ralf Baechle, Paul Burton, James Hogan, Greentime Hu,
	Vincent Chen, Ley Foon Tan, Jonas Bonn, Stefan Kristiansson,
	Stafford Horne, James E.J. Bottomley, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Palmer Dabbelt, Albert Ou,
	Martin Schwidefsky, Heiko Carstens, Rich Felker, David S. Miller,
	Guan Xuetao, x86, Jeff Dike, Richard Weinberger, Chris Zankel,
	Max Filippov, Tobias Klauser, Noam Camus, Mickael GUENE,
	Nicolas Pitre, Kees Cook, Dave Martin, Marc Zyngier,
	Alex Bennée, Laura Abbott, Yury Norov, Mark Rutland,
	Huacai Chen, Maciej W. Rozycki, Arnd Bergmann, David Howells,
	Sukadev Bhattiprolu, Nicholas Piggin, Aneesh Kumar K.V,
	Philippe Bergheaud, Ram Pai, Christophe Leroy, Cornelia Huck,
	Vasily Gorbik, Nick Alcock, Shannon Nelson, Nagarathnam Muthusamy,
	Andy Lutomirski, Borislav Petkov, Dave Hansen, Vitaly Kuznetsov,
	Jiri Kosina, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-c6x-dev, uclinux-h8-devel, linux-hexagon,
	linux-ia64, linux-m68k, linux-mips, nios2-dev, openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, linux-um
In-Reply-To: <20180821202900.208417-1-ndesaulniers@google.com>

On 21.08.2018 22:28, Nick Desaulniers wrote:
> Prefer _THIS_IP_ defined in linux/kernel.h.
> 
> Most definitions of current_text_addr were the same as _THIS_IP_, but
> a few archs had inline assembly instead.
> 
> This patch removes the final call site of current_text_addr, making all
> of the definitions dead code.
> 
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> I suspect that current_text_addr predated GNU C extensions for statement
> expressions and/or taking the address of a label, then the macro was
> reimplemented for every new archs include/asm/processor.h, even though
> there were very few call sites, and none required an assembly
> implementation vs the C implementation.
> 
> I am sad to see a few neat arch specific ways of getting the ip/pc, but
> we should prefer the higher level C in cases where assembly is not
> required. And the definitions can always be found again in git history.

Currently alpha, s390, sparc, sh, c6x, ia64 and parisc provide an
inline assembly function to get the current instruction pointer. 
As mentioned in an earlier thread, I personally would *prefer* if 
_THIS_IP_ would use those inline assembly instructions on those
architectures instead of the (currently used) higher C-level
implementation.

Helge


>  arch/alpha/include/asm/processor.h      |  6 ------
>  arch/arc/include/asm/processor.h        |  8 --------
>  arch/arm/include/asm/processor.h        |  6 ------
>  arch/arm64/include/asm/processor.h      |  7 -------
>  arch/c6x/include/asm/processor.h        | 11 -----------
>  arch/h8300/include/asm/processor.h      |  6 ------
>  arch/hexagon/include/asm/processor.h    |  3 ---
>  arch/ia64/include/asm/processor.h       |  6 ------
>  arch/m68k/include/asm/processor.h       |  6 ------
>  arch/microblaze/include/asm/processor.h | 12 ------------
>  arch/mips/include/asm/processor.h       |  5 -----
>  arch/nds32/include/asm/processor.h      |  6 ------
>  arch/nios2/include/asm/processor.h      |  6 ------
>  arch/openrisc/include/asm/processor.h   |  5 -----
>  arch/parisc/include/asm/processor.h     | 11 -----------
>  arch/powerpc/include/asm/processor.h    |  6 ------
>  arch/riscv/include/asm/processor.h      |  6 ------
>  arch/s390/include/asm/processor.h       |  6 ------
>  arch/sh/include/asm/processor_32.h      |  6 ------
>  arch/sh/include/asm/processor_64.h      | 15 ---------------
>  arch/sparc/include/asm/processor_32.h   |  6 ------
>  arch/sparc/include/asm/processor_64.h   |  6 ------
>  arch/unicore32/include/asm/processor.h  |  6 ------
>  arch/x86/include/asm/kexec.h            |  3 ++-
>  arch/x86/include/asm/processor.h        | 12 ------------
>  arch/x86/um/asm/processor_32.h          |  8 --------
>  arch/x86/um/asm/processor_64.h          |  3 ---
>  arch/xtensa/include/asm/processor.h     |  8 --------
>  28 files changed, 2 insertions(+), 193 deletions(-)
> 
> diff --git a/arch/alpha/include/asm/processor.h b/arch/alpha/include/asm/processor.h
> index cb05d045efe3..6100431da07a 100644
> --- a/arch/alpha/include/asm/processor.h
> +++ b/arch/alpha/include/asm/processor.h
> @@ -10,12 +10,6 @@
>  
>  #include <linux/personality.h>	/* for ADDR_LIMIT_32BIT */
>  
> -/*
> - * Returns current instruction pointer ("program counter").
> - */
> -#define current_text_addr() \
> -  ({ void *__pc; __asm__ ("br %0,.+4" : "=r"(__pc)); __pc; })
> -
>  /*
>   * We have a 42-bit user address space: 4TB user VM...
>   */
> diff --git a/arch/arc/include/asm/processor.h b/arch/arc/include/asm/processor.h
> index 8ee41e988169..10346d6cf926 100644
> --- a/arch/arc/include/asm/processor.h
> +++ b/arch/arc/include/asm/processor.h
> @@ -98,14 +98,6 @@ extern void start_thread(struct pt_regs * regs, unsigned long pc,
>  
>  extern unsigned int get_wchan(struct task_struct *p);
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - * Should the PC register be read instead ? This macro does not seem to
> - * be used in many places so this wont be all that bad.
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l; })
> -
>  #endif /* !__ASSEMBLY__ */
>  
>  /*
> diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
> index 1bf65b47808a..120f4c9bbfde 100644
> --- a/arch/arm/include/asm/processor.h
> +++ b/arch/arm/include/asm/processor.h
> @@ -11,12 +11,6 @@
>  #ifndef __ASM_ARM_PROCESSOR_H
>  #define __ASM_ARM_PROCESSOR_H
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l;})
> -
>  #ifdef __KERNEL__
>  
>  #include <asm/hw_breakpoint.h>
> diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
> index 79657ad91397..966214f473b4 100644
> --- a/arch/arm64/include/asm/processor.h
> +++ b/arch/arm64/include/asm/processor.h
> @@ -25,13 +25,6 @@
>  #define USER_DS		(TASK_SIZE_64 - 1)
>  
>  #ifndef __ASSEMBLY__
> -
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l;})
> -
>  #ifdef __KERNEL__
>  
>  #include <linux/build_bug.h>
> diff --git a/arch/c6x/include/asm/processor.h b/arch/c6x/include/asm/processor.h
> index 8f7cce829f8e..a8581f5b27f6 100644
> --- a/arch/c6x/include/asm/processor.h
> +++ b/arch/c6x/include/asm/processor.h
> @@ -17,17 +17,6 @@
>  #include <asm/page.h>
>  #include <asm/current.h>
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr()			\
> -({						\
> -	void *__pc;				\
> -	asm("mvc .S2 pce1,%0\n" : "=b"(__pc));	\
> -	__pc;					\
> -})
> -
>  /*
>   * User space process size. This is mostly meaningless for NOMMU
>   * but some C6X processors may have RAM addresses up to 0xFFFFFFFF.
> diff --git a/arch/h8300/include/asm/processor.h b/arch/h8300/include/asm/processor.h
> index 985346393e4a..a060b41b2d31 100644
> --- a/arch/h8300/include/asm/processor.h
> +++ b/arch/h8300/include/asm/processor.h
> @@ -12,12 +12,6 @@
>  #ifndef __ASM_H8300_PROCESSOR_H
>  #define __ASM_H8300_PROCESSOR_H
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l; })
> -
>  #include <linux/compiler.h>
>  #include <asm/segment.h>
>  #include <asm/ptrace.h>
> diff --git a/arch/hexagon/include/asm/processor.h b/arch/hexagon/include/asm/processor.h
> index ce67940860a5..227bcb9cfdac 100644
> --- a/arch/hexagon/include/asm/processor.h
> +++ b/arch/hexagon/include/asm/processor.h
> @@ -27,9 +27,6 @@
>  #include <asm/registers.h>
>  #include <asm/hexagon_vm.h>
>  
> -/*  must be a macro  */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l; })
> -
>  /*  task_struct, defined elsewhere, is the "process descriptor" */
>  struct task_struct;
>  
> diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
> index 10061ccf0440..c91ef98ed6bf 100644
> --- a/arch/ia64/include/asm/processor.h
> +++ b/arch/ia64/include/asm/processor.h
> @@ -602,12 +602,6 @@ ia64_set_unat (__u64 *unat, void *spill_addr, unsigned long nat)
>  	*unat = (*unat & ~mask) | (nat << bit);
>  }
>  
> -/*
> - * Get the current instruction/program counter value.
> - */
> -#define current_text_addr() \
> -	({ void *_pc; _pc = (void *)ia64_getreg(_IA64_REG_IP); _pc; })
> -
>  static inline __u64
>  ia64_get_ivr (void)
>  {
> diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h
> index 464e9f5f50ee..3750819ac5a1 100644
> --- a/arch/m68k/include/asm/processor.h
> +++ b/arch/m68k/include/asm/processor.h
> @@ -8,12 +8,6 @@
>  #ifndef __ASM_M68K_PROCESSOR_H
>  #define __ASM_M68K_PROCESSOR_H
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l;})
> -
>  #include <linux/thread_info.h>
>  #include <asm/segment.h>
>  #include <asm/fpu.h>
> diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h
> index 330d556860ba..66b537b8d138 100644
> --- a/arch/microblaze/include/asm/processor.h
> +++ b/arch/microblaze/include/asm/processor.h
> @@ -45,12 +45,6 @@ extern void ret_from_kernel_thread(void);
>   */
>  # define TASK_SIZE	(0x81000000 - 0x80000000)
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -# define current_text_addr() ({ __label__ _l; _l: &&_l; })
> -
>  /*
>   * This decides where the kernel will search for a free chunk of vm
>   * space during mmap's. We won't be using it
> @@ -92,12 +86,6 @@ extern unsigned long get_wchan(struct task_struct *p);
>  
>  #  ifndef __ASSEMBLY__
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#  define current_text_addr()	({ __label__ _l; _l: &&_l; })
> -
>  /* If you change this, you must change the associated assembly-languages
>   * constants defined below, THREAD_*.
>   */
> diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
> index b2fa62922d88..f08417f8772e 100644
> --- a/arch/mips/include/asm/processor.h
> +++ b/arch/mips/include/asm/processor.h
> @@ -22,11 +22,6 @@
>  #include <asm/mipsregs.h>
>  #include <asm/prefetch.h>
>  
> -/*
> - * Return current * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l;})
> -
>  /*
>   * System setup and hardware flags..
>   */
> diff --git a/arch/nds32/include/asm/processor.h b/arch/nds32/include/asm/processor.h
> index 9c83caf4269f..c2660f566bac 100644
> --- a/arch/nds32/include/asm/processor.h
> +++ b/arch/nds32/include/asm/processor.h
> @@ -4,12 +4,6 @@
>  #ifndef __ASM_NDS32_PROCESSOR_H
>  #define __ASM_NDS32_PROCESSOR_H
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l;})
> -
>  #ifdef __KERNEL__
>  
>  #include <asm/ptrace.h>
> diff --git a/arch/nios2/include/asm/processor.h b/arch/nios2/include/asm/processor.h
> index 4944e2e1d8b0..94bcb86f679f 100644
> --- a/arch/nios2/include/asm/processor.h
> +++ b/arch/nios2/include/asm/processor.h
> @@ -38,12 +38,6 @@
>  #define KUSER_SIZE		(PAGE_SIZE)
>  #ifndef __ASSEMBLY__
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l; })
> -
>  # define TASK_SIZE		0x7FFF0000UL
>  # define TASK_UNMAPPED_BASE	(PAGE_ALIGN(TASK_SIZE / 3))
>  
> diff --git a/arch/openrisc/include/asm/processor.h b/arch/openrisc/include/asm/processor.h
> index af31a9fe736a..351d3aed7a06 100644
> --- a/arch/openrisc/include/asm/processor.h
> +++ b/arch/openrisc/include/asm/processor.h
> @@ -30,11 +30,6 @@
>  		   | SPR_SR_DCE | SPR_SR_SM)
>  #define USER_SR   (SPR_SR_DME | SPR_SR_IME | SPR_SR_ICE \
>  		   | SPR_SR_DCE | SPR_SR_IEE | SPR_SR_TEE)
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l; })
>  
>  /*
>   * User space process size. This is hardcoded into a few places,
> diff --git a/arch/parisc/include/asm/processor.h b/arch/parisc/include/asm/processor.h
> index 2dbe5580a1a4..0d7f64ef9c7d 100644
> --- a/arch/parisc/include/asm/processor.h
> +++ b/arch/parisc/include/asm/processor.h
> @@ -20,17 +20,6 @@
>  #include <asm/percpu.h>
>  #endif /* __ASSEMBLY__ */
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#ifdef CONFIG_PA20
> -#define current_ia(x)	__asm__("mfia %0" : "=r"(x))
> -#else /* mfia added in pa2.0 */
> -#define current_ia(x)	__asm__("blr 0,%0\n\tnop" : "=r"(x))
> -#endif
> -#define current_text_addr() ({ void *pc; current_ia(pc); pc; })
> -
>  #define HAVE_ARCH_PICK_MMAP_LAYOUT
>  
>  #define TASK_SIZE_OF(tsk)       ((tsk)->thread.task_size)
> diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
> index 52fadded5c1e..1fff74df06e6 100644
> --- a/arch/powerpc/include/asm/processor.h
> +++ b/arch/powerpc/include/asm/processor.h
> @@ -67,12 +67,6 @@ extern int _chrp_type;
>  
>  #endif /* defined(__KERNEL__) && defined(CONFIG_PPC32) */
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l;})
> -
>  /* Macros for adjusting thread priority (hardware multi-threading) */
>  #define HMT_very_low()   asm volatile("or 31,31,31   # very low priority")
>  #define HMT_low()	 asm volatile("or 1,1,1	     # low priority")
> diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h
> index 3fe4af8147d2..020e35947060 100644
> --- a/arch/riscv/include/asm/processor.h
> +++ b/arch/riscv/include/asm/processor.h
> @@ -33,12 +33,6 @@
>  struct task_struct;
>  struct pt_regs;
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr()	({ __label__ _l; _l: &&_l; })
> -
>  /* CPU-specific state of a task */
>  struct thread_struct {
>  	/* Callee-saved registers */
> diff --git a/arch/s390/include/asm/processor.h b/arch/s390/include/asm/processor.h
> index 7f2953c15c37..f8028d37bb18 100644
> --- a/arch/s390/include/asm/processor.h
> +++ b/arch/s390/include/asm/processor.h
> @@ -73,12 +73,6 @@ static inline int test_cpu_flag_of(int flag, int cpu)
>  
>  #define arch_needs_cpu() test_cpu_flag(CIF_NOHZ_DELAY)
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ void *pc; asm("basr %0,0" : "=a" (pc)); pc; })
> -
>  static inline void get_cpu_id(struct cpuid *ptr)
>  {
>  	asm volatile("stidp %0" : "=Q" (*ptr));
> diff --git a/arch/sh/include/asm/processor_32.h b/arch/sh/include/asm/processor_32.h
> index 95100d8a0b7b..0e0ecc0132e3 100644
> --- a/arch/sh/include/asm/processor_32.h
> +++ b/arch/sh/include/asm/processor_32.h
> @@ -16,12 +16,6 @@
>  #include <asm/types.h>
>  #include <asm/hw_breakpoint.h>
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ void *pc; __asm__("mova	1f, %0\n.align 2\n1:":"=z" (pc)); pc; })
> -
>  /* Core Processor Version Register */
>  #define CCN_PVR		0xff000030
>  #define CCN_CVR		0xff000040
> diff --git a/arch/sh/include/asm/processor_64.h b/arch/sh/include/asm/processor_64.h
> index 777a16318aff..f3d7075648d0 100644
> --- a/arch/sh/include/asm/processor_64.h
> +++ b/arch/sh/include/asm/processor_64.h
> @@ -19,21 +19,6 @@
>  #include <asm/types.h>
>  #include <cpu/registers.h>
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ \
> -void *pc; \
> -unsigned long long __dummy = 0; \
> -__asm__("gettr	tr0, %1\n\t" \
> -	"pta	4, tr0\n\t" \
> -	"gettr	tr0, %0\n\t" \
> -	"ptabs	%1, tr0\n\t"	\
> -	:"=r" (pc), "=r" (__dummy) \
> -	: "1" (__dummy)); \
> -pc; })
> -
>  #endif
>  
>  /*
> diff --git a/arch/sparc/include/asm/processor_32.h b/arch/sparc/include/asm/processor_32.h
> index 192493c257fa..3c4bc2189092 100644
> --- a/arch/sparc/include/asm/processor_32.h
> +++ b/arch/sparc/include/asm/processor_32.h
> @@ -7,12 +7,6 @@
>  #ifndef __ASM_SPARC_PROCESSOR_H
>  #define __ASM_SPARC_PROCESSOR_H
>  
> -/*
> - * Sparc32 implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; })
> -
>  #include <asm/psr.h>
>  #include <asm/ptrace.h>
>  #include <asm/head.h>
> diff --git a/arch/sparc/include/asm/processor_64.h b/arch/sparc/include/asm/processor_64.h
> index aac23d4a4ddd..5cf145f18f36 100644
> --- a/arch/sparc/include/asm/processor_64.h
> +++ b/arch/sparc/include/asm/processor_64.h
> @@ -8,12 +8,6 @@
>  #ifndef __ASM_SPARC64_PROCESSOR_H
>  #define __ASM_SPARC64_PROCESSOR_H
>  
> -/*
> - * Sparc64 implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ void *pc; __asm__("rd %%pc, %0" : "=r" (pc)); pc; })
> -
>  #include <asm/asi.h>
>  #include <asm/pstate.h>
>  #include <asm/ptrace.h>
> diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
> index 4eaa42167667..b772ed1c0f25 100644
> --- a/arch/unicore32/include/asm/processor.h
> +++ b/arch/unicore32/include/asm/processor.h
> @@ -13,12 +13,6 @@
>  #ifndef __UNICORE_PROCESSOR_H__
>  #define __UNICORE_PROCESSOR_H__
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr() ({ __label__ _l; _l: &&_l; })
> -
>  #ifdef __KERNEL__
>  
>  #include <asm/ptrace.h>
> diff --git a/arch/x86/include/asm/kexec.h b/arch/x86/include/asm/kexec.h
> index f327236f0fa7..86924d594ecd 100644
> --- a/arch/x86/include/asm/kexec.h
> +++ b/arch/x86/include/asm/kexec.h
> @@ -21,6 +21,7 @@
>  #ifndef __ASSEMBLY__
>  
>  #include <linux/string.h>
> +#include <linux/kernel.h>
>  
>  #include <asm/page.h>
>  #include <asm/ptrace.h>
> @@ -132,7 +133,7 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
>  		asm volatile("movl %%cs, %%eax;" :"=a"(newregs->cs));
>  		asm volatile("pushfq; popq %0" :"=m"(newregs->flags));
>  #endif
> -		newregs->ip = (unsigned long)current_text_addr();
> +		newregs->ip = _THIS_IP_;
>  	}
>  }
>  
> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> index 682286aca881..20080b303605 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -42,18 +42,6 @@ struct vm86;
>  #define NET_IP_ALIGN	0
>  
>  #define HBP_NUM 4
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -static inline void *current_text_addr(void)
> -{
> -	void *pc;
> -
> -	asm volatile("mov $1f, %0; 1:":"=r" (pc));
> -
> -	return pc;
> -}
>  
>  /*
>   * These alignment constraints are for performance in the vSMP case,
> diff --git a/arch/x86/um/asm/processor_32.h b/arch/x86/um/asm/processor_32.h
> index c112de81c9e1..5fb1b8449adf 100644
> --- a/arch/x86/um/asm/processor_32.h
> +++ b/arch/x86/um/asm/processor_32.h
> @@ -47,14 +47,6 @@ static inline void arch_copy_thread(struct arch_thread *from,
>          memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array));
>  }
>  
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter"). Stolen
> - * from asm-i386/processor.h
> - */
> -#define current_text_addr() \
> -	({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
> -
>  #define current_sp() ({ void *sp; __asm__("movl %%esp, %0" : "=r" (sp) : ); sp; })
>  #define current_bp() ({ unsigned long bp; __asm__("movl %%ebp, %0" : "=r" (bp) : ); bp; })
>  
> diff --git a/arch/x86/um/asm/processor_64.h b/arch/x86/um/asm/processor_64.h
> index c3be85205a65..1ef9c21877bc 100644
> --- a/arch/x86/um/asm/processor_64.h
> +++ b/arch/x86/um/asm/processor_64.h
> @@ -31,9 +31,6 @@ static inline void arch_copy_thread(struct arch_thread *from,
>  	to->fs = from->fs;
>  }
>  
> -#define current_text_addr() \
> -	({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; })
> -
>  #define current_sp() ({ void *sp; __asm__("movq %%rsp, %0" : "=r" (sp) : ); sp; })
>  #define current_bp() ({ unsigned long bp; __asm__("movq %%rbp, %0" : "=r" (bp) : ); bp; })
>  
> diff --git a/arch/xtensa/include/asm/processor.h b/arch/xtensa/include/asm/processor.h
> index 5b0027d4ecc0..68891c992105 100644
> --- a/arch/xtensa/include/asm/processor.h
> +++ b/arch/xtensa/include/asm/processor.h
> @@ -153,14 +153,6 @@ struct thread_struct {
>  	int align[0] __attribute__ ((aligned(16)));
>  };
>  
> -
> -/*
> - * Default implementation of macro that returns current
> - * instruction pointer ("program counter").
> - */
> -#define current_text_addr()  ({ __label__ _l; _l: &&_l;})
> -
> -
>  /* This decides where the kernel will search for a free chunk of vm
>   * space during mmap's.
>   */
> 

^ permalink raw reply

* Re: [PATCH v2] crypto: vmx - Fix sleep-in-atomic bugs
From: Herbert Xu @ 2018-08-25 13:28 UTC (permalink / raw)
  To: Ondrej Mosnacek
  Cc: linux-crypto, Stephan Mueller, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Marcelo Henrique Cerri,
	Leonidas S . Barbosa, Paulo Flabiano Smorigo, linuxppc-dev,
	stable
In-Reply-To: <20180822062631.5664-1-omosnace@redhat.com>

On Wed, Aug 22, 2018 at 08:26:31AM +0200, Ondrej Mosnacek wrote:
> This patch fixes sleep-in-atomic bugs in AES-CBC and AES-XTS VMX
> implementations. The problem is that the blkcipher_* functions should
> not be called in atomic context.
> 
> The bugs can be reproduced via the AF_ALG interface by trying to
> encrypt/decrypt sufficiently large buffers (at least 64 KiB) using the
> VMX implementations of 'cbc(aes)' or 'xts(aes)'. Such operations then
> trigger BUG in crypto_yield():
> 
> [  891.863680] BUG: sleeping function called from invalid context at include/crypto/algapi.h:424
> [  891.864622] in_atomic(): 1, irqs_disabled(): 0, pid: 12347, name: kcapi-enc
> [  891.864739] 1 lock held by kcapi-enc/12347:
> [  891.864811]  #0: 00000000f5d42c46 (sk_lock-AF_ALG){+.+.}, at: skcipher_recvmsg+0x50/0x530
> [  891.865076] CPU: 5 PID: 12347 Comm: kcapi-enc Not tainted 4.19.0-0.rc0.git3.1.fc30.ppc64le #1
> [  891.865251] Call Trace:
> [  891.865340] [c0000003387578c0] [c000000000d67ea4] dump_stack+0xe8/0x164 (unreliable)
> [  891.865511] [c000000338757910] [c000000000172a58] ___might_sleep+0x2f8/0x310
> [  891.865679] [c000000338757990] [c0000000006bff74] blkcipher_walk_done+0x374/0x4a0
> [  891.865825] [c0000003387579e0] [d000000007e73e70] p8_aes_cbc_encrypt+0x1c8/0x260 [vmx_crypto]
> [  891.865993] [c000000338757ad0] [c0000000006c0ee0] skcipher_encrypt_blkcipher+0x60/0x80
> [  891.866128] [c000000338757b10] [c0000000006ec504] skcipher_recvmsg+0x424/0x530
> [  891.866283] [c000000338757bd0] [c000000000b00654] sock_recvmsg+0x74/0xa0
> [  891.866403] [c000000338757c10] [c000000000b00f64] ___sys_recvmsg+0xf4/0x2f0
> [  891.866515] [c000000338757d90] [c000000000b02bb8] __sys_recvmsg+0x68/0xe0
> [  891.866631] [c000000338757e30] [c00000000000bbe4] system_call+0x5c/0x70
> 
> Fixes: 8c755ace357c ("crypto: vmx - Adding CBC routines for VMX module")
> Fixes: c07f5d3da643 ("crypto: vmx - Adding support for XTS")
> Cc: stable@vger.kernel.org
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* [PATCH RESEND 2/3] drivers/video/fbdev: use ioremap_wt() instead of __ioremap(_PAGE_WRITETHRU)
From: Christophe Leroy @ 2018-08-25 14:27 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Bartlomiej Zolnierkiewicz, Jens Axboe
  Cc: linux-fbdev, linux-kernel, dri-devel, linux-block, linux-m68k,
	linuxppc-dev

_PAGE_WRITETHRU is a target specific flag. Prefer generic functions.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/video/fbdev/controlfb.c  |  3 +--
 drivers/video/fbdev/platinumfb.c |  3 +--
 drivers/video/fbdev/valkyriefb.c | 10 ++++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c
index 8d14b29aafea..058093990218 100644
--- a/drivers/video/fbdev/controlfb.c
+++ b/drivers/video/fbdev/controlfb.c
@@ -715,8 +715,7 @@ static int __init control_of_init(struct device_node *dp)
 		goto error_out;
 	}
 	/* map at most 8MB for the frame buffer */
-	p->frame_buffer = __ioremap(p->frame_buffer_phys, 0x800000,
-				    _PAGE_WRITETHRU);
+	p->frame_buffer = ioremap_wt(p->frame_buffer_phys, 0x800000);
 
 	if (!p->control_regs_phys ||
 	    !request_mem_region(p->control_regs_phys, p->control_regs_size,
diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
index 377d3399a3ad..df79f102fbc6 100644
--- a/drivers/video/fbdev/platinumfb.c
+++ b/drivers/video/fbdev/platinumfb.c
@@ -577,8 +577,7 @@ static int platinumfb_probe(struct platform_device* odev)
 
 	/* frame buffer - map only 4MB */
 	pinfo->frame_buffer_phys = pinfo->rsrc_fb.start;
-	pinfo->frame_buffer = __ioremap(pinfo->rsrc_fb.start, 0x400000,
-					_PAGE_WRITETHRU);
+	pinfo->frame_buffer = ioremap_wt(pinfo->rsrc_fb.start, 0x400000);
 	pinfo->base_frame_buffer = pinfo->frame_buffer;
 
 	/* registers */
diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c
index 275fb98236d3..0c6c1eede800 100644
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -318,7 +318,7 @@ static void __init valkyrie_choose_mode(struct fb_info_valkyrie *p)
 int __init valkyriefb_init(void)
 {
 	struct fb_info_valkyrie	*p;
-	unsigned long frame_buffer_phys, cmap_regs_phys, flags;
+	unsigned long frame_buffer_phys, cmap_regs_phys;
 	int err;
 	char *option = NULL;
 
@@ -337,7 +337,6 @@ int __init valkyriefb_init(void)
 	/* Hardcoded addresses... welcome to 68k Macintosh country :-) */
 	frame_buffer_phys = 0xf9000000;
 	cmap_regs_phys = 0x50f24000;
-	flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */
 #else /* ppc (!CONFIG_MAC) */
 	{
 		struct device_node *dp;
@@ -354,7 +353,6 @@ int __init valkyriefb_init(void)
 
 		frame_buffer_phys = r.start;
 		cmap_regs_phys = r.start + 0x304000;
-		flags = _PAGE_WRITETHRU;
 	}
 #endif /* ppc (!CONFIG_MAC) */
 
@@ -369,7 +367,11 @@ int __init valkyriefb_init(void)
 	}
 	p->total_vram = 0x100000;
 	p->frame_buffer_phys = frame_buffer_phys;
-	p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags);
+#ifdef CONFIG_MAC
+	p->frame_buffer = ioremap_nocache(frame_buffer_phys, p->total_vram);
+#else
+	p->frame_buffer = ioremap_wt(frame_buffer_phys, p->total_vram);
+#endif
 	p->cmap_regs_phys = cmap_regs_phys;
 	p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000);
 	p->valkyrie_regs_phys = cmap_regs_phys+0x6000;
-- 
2.17.1

^ permalink raw reply related

* [PATCH RESEND 3/3] drivers/block/z2ram: use ioremap_wt() instead of __ioremap(_PAGE_WRITETHRU)
From: Christophe Leroy @ 2018-08-25 14:27 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Bartlomiej Zolnierkiewicz, Jens Axboe
  Cc: linux-fbdev, linux-kernel, dri-devel, linux-block, linux-m68k,
	linuxppc-dev

_PAGE_WRITETHRU is a target specific flag. Prefer generic functions.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/block/z2ram.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index d0c5bc4e0703..cfbd70520eeb 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -190,8 +190,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
 			vfree(vmalloc (size));
 		}
 
-		vaddr = (unsigned long) __ioremap (paddr, size, 
-						   _PAGE_WRITETHRU);
+		vaddr = (unsigned long)ioremap_wt(paddr, size);
 
 #else
 		vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
-- 
2.17.1

^ permalink raw reply related

* [PATCH RESEND 1/3] powerpc/32: Add ioremap_wt()
From: Christophe Leroy @ 2018-08-25 14:34 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Bartlomiej Zolnierkiewicz, Jens Axboe
  Cc: linux-fbdev, linux-kernel, dri-devel, linux-block, linux-m68k,
	linuxppc-dev

Other arches have ioremap_wt() to map IO areas write-through.
Implement it on PPC as well in order to avoid drivers using
__ioremap(_PAGE_WRITETHRU)

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 No change. First serie didn't apply because I generated it on a working branch.

 arch/powerpc/include/asm/io.h | 6 ++++++
 arch/powerpc/mm/pgtable_32.c  | 8 ++++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index e0331e754568..3380b5b22450 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -3,6 +3,9 @@
 #ifdef __KERNEL__
 
 #define ARCH_HAS_IOREMAP_WC
+#ifdef CONFIG_PPC32
+#define ARCH_HAS_IOREMAP_WT
+#endif
 
 /*
  * This program is free software; you can redistribute it and/or
@@ -746,6 +749,8 @@ static inline void iosync(void)
  *
  * * ioremap_wc enables write combining
  *
+ * * ioremap_wt enables write through
+ *
  * * iounmap undoes such a mapping and can be hooked
  *
  * * __ioremap_at (and the pending __iounmap_at) are low level functions to
@@ -767,6 +772,7 @@ extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
 extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size,
 				  unsigned long flags);
 extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
+void __iomem *ioremap_wt(phys_addr_t address, unsigned long size);
 #define ioremap_nocache(addr, size)	ioremap((addr), (size))
 #define ioremap_uc(addr, size)		ioremap((addr), (size))
 #define ioremap_cache(addr, size) \
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 120a49bfb9c6..528999738645 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -89,6 +89,14 @@ ioremap_wc(phys_addr_t addr, unsigned long size)
 }
 EXPORT_SYMBOL(ioremap_wc);
 
+void __iomem *
+ioremap_wt(phys_addr_t addr, unsigned long size)
+{
+	return __ioremap_caller(addr, size, _PAGE_WRITETHRU,
+				__builtin_return_address(0));
+}
+EXPORT_SYMBOL(ioremap_wt);
+
 void __iomem *
 ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags)
 {
-- 
2.17.1

^ permalink raw reply related

* [PATCH RESEND 2/3] drivers/video/fbdev: use ioremap_wt() instead of __ioremap(_PAGE_WRITETHRU)
From: Christophe Leroy @ 2018-08-25 14:34 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Bartlomiej Zolnierkiewicz, Jens Axboe
  Cc: linux-fbdev, linux-kernel, dri-devel, linux-block, linux-m68k,
	linuxppc-dev

_PAGE_WRITETHRU is a target specific flag. Prefer generic functions.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/video/fbdev/controlfb.c  |  3 +--
 drivers/video/fbdev/platinumfb.c |  3 +--
 drivers/video/fbdev/valkyriefb.c | 10 ++++++----
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c
index 8d14b29aafea..058093990218 100644
--- a/drivers/video/fbdev/controlfb.c
+++ b/drivers/video/fbdev/controlfb.c
@@ -715,8 +715,7 @@ static int __init control_of_init(struct device_node *dp)
 		goto error_out;
 	}
 	/* map at most 8MB for the frame buffer */
-	p->frame_buffer = __ioremap(p->frame_buffer_phys, 0x800000,
-				    _PAGE_WRITETHRU);
+	p->frame_buffer = ioremap_wt(p->frame_buffer_phys, 0x800000);
 
 	if (!p->control_regs_phys ||
 	    !request_mem_region(p->control_regs_phys, p->control_regs_size,
diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
index 377d3399a3ad..df79f102fbc6 100644
--- a/drivers/video/fbdev/platinumfb.c
+++ b/drivers/video/fbdev/platinumfb.c
@@ -577,8 +577,7 @@ static int platinumfb_probe(struct platform_device* odev)
 
 	/* frame buffer - map only 4MB */
 	pinfo->frame_buffer_phys = pinfo->rsrc_fb.start;
-	pinfo->frame_buffer = __ioremap(pinfo->rsrc_fb.start, 0x400000,
-					_PAGE_WRITETHRU);
+	pinfo->frame_buffer = ioremap_wt(pinfo->rsrc_fb.start, 0x400000);
 	pinfo->base_frame_buffer = pinfo->frame_buffer;
 
 	/* registers */
diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c
index 275fb98236d3..0c6c1eede800 100644
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -318,7 +318,7 @@ static void __init valkyrie_choose_mode(struct fb_info_valkyrie *p)
 int __init valkyriefb_init(void)
 {
 	struct fb_info_valkyrie	*p;
-	unsigned long frame_buffer_phys, cmap_regs_phys, flags;
+	unsigned long frame_buffer_phys, cmap_regs_phys;
 	int err;
 	char *option = NULL;
 
@@ -337,7 +337,6 @@ int __init valkyriefb_init(void)
 	/* Hardcoded addresses... welcome to 68k Macintosh country :-) */
 	frame_buffer_phys = 0xf9000000;
 	cmap_regs_phys = 0x50f24000;
-	flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */
 #else /* ppc (!CONFIG_MAC) */
 	{
 		struct device_node *dp;
@@ -354,7 +353,6 @@ int __init valkyriefb_init(void)
 
 		frame_buffer_phys = r.start;
 		cmap_regs_phys = r.start + 0x304000;
-		flags = _PAGE_WRITETHRU;
 	}
 #endif /* ppc (!CONFIG_MAC) */
 
@@ -369,7 +367,11 @@ int __init valkyriefb_init(void)
 	}
 	p->total_vram = 0x100000;
 	p->frame_buffer_phys = frame_buffer_phys;
-	p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags);
+#ifdef CONFIG_MAC
+	p->frame_buffer = ioremap_nocache(frame_buffer_phys, p->total_vram);
+#else
+	p->frame_buffer = ioremap_wt(frame_buffer_phys, p->total_vram);
+#endif
 	p->cmap_regs_phys = cmap_regs_phys;
 	p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000);
 	p->valkyrie_regs_phys = cmap_regs_phys+0x6000;
-- 
2.17.1

^ permalink raw reply related

* [PATCH RESEND 3/3] drivers/block/z2ram: use ioremap_wt() instead of __ioremap(_PAGE_WRITETHRU)
From: Christophe Leroy @ 2018-08-25 14:34 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Bartlomiej Zolnierkiewicz, Jens Axboe
  Cc: linux-fbdev, linux-kernel, dri-devel, linux-block, linux-m68k,
	linuxppc-dev

_PAGE_WRITETHRU is a target specific flag. Prefer generic functions.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/block/z2ram.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index d0c5bc4e0703..cfbd70520eeb 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -190,8 +190,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
 			vfree(vmalloc (size));
 		}
 
-		vaddr = (unsigned long) __ioremap (paddr, size, 
-						   _PAGE_WRITETHRU);
+		vaddr = (unsigned long)ioremap_wt(paddr, size);
 
 #else
 		vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
-- 
2.17.1

^ permalink raw reply related

* Re: FSL/NXP P5020: USB problems with the latest Git kernels
From: Christian Zigotzky @ 2018-08-25 20:19 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <0F797F4E-755B-499C-BA74-48CC03235393@xenosoft.de>

Hello,

With the boot argument =E2=80=9Cmem=3D3500M=E2=80=9D the USB devices work. P=
lease compile the latest Git kernel and test it on your P5020 board. There i=
s a problem with the memory management since 22/08/18. I can=E2=80=99t test b=
ecause I don=E2=80=99t have a P5020 board here and our users can=E2=80=99t c=
ompile kernels.

Thanks,
Christian

Sent from my iPhone

> On 24. Aug 2018, at 20:11, Christian Zigotzky <chzigotzky@xenosoft.de> wro=
te:
>=20
> Hello,
>=20
> There are USB problems with P5020 boards with the latest Git kernels.
>=20
> Some users reported the following error messages:
>=20
> skateman@X5000LNX:~$ grep -i -E 'usb.*error' /var/log/syslog
> Aug 24 13:12:50 X5000LNX kernel: [ 6.552303] usb 1-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 6.649376] usb 2-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 6.794158] usb 1-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 6.883156] usb 2-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 7.139155] usb 1-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 7.226156] usb 2-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 7.363155] usb 1-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 7.451156] usb 2-1: device descriptor re=
ad/64, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 8.521156] usb 1-1: device not accepting=
 address 4, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 8.609156] usb 2-1: device not accepting=
 address 4, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 9.057155] usb 1-1: device not accepting=
 address 5, error -32
> Aug 24 13:12:50 X5000LNX kernel: [ 9.145157] usb 2-1: device not accepting=
 address 5, error -32
>=20
> I don=E2=80=99t have a P5020 board here. That means I can=E2=80=99t bisect=
 and test. Therefore I need your help. The problematic Git commit must be so=
mewhere between 22/08/18 1:20 PM UTC and 23/08/18 10:49 AM UTC.
> The Git kernel from 22/08/18 1:20 PM UTC works with USB devices.
> Could you please compile a Git kernel and test it on your P5020 board?
>=20
> Thanks,
> Christian

^ permalink raw reply

* Re: [PATCH] treewide: remove current_text_addr
From: Linus Torvalds @ 2018-08-25 21:02 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, Eric W. Biederman, Thomas Gleixner, Ingo Molnar,
	Peter Anvin, Simon Horman, Nathan Chancellor, Philippe Ombredanne,
	Kate Stewart, Greg Kroah-Hartman, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, Vineet Gupta,
	Russell King - ARM Linux, Catalin Marinas, Will Deacon,
	Mark Salter, jacquiot.aurelien, Yoshinori Sato, Richard Kuo,
	Tony Luck, Fenghua Yu, Geert Uytterhoeven, Michal Simek,
	Ralf Baechle, Paul Burton, James Hogan, Greentime Hu, deanbo422,
	Ley Foon Tan, Jonas Bonn, Stefan Kristiansson, Stafford Horne,
	James E.J. Bottomley, Helge Deller, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Palmer Dabbelt, aou,
	Martin Schwidefsky, Heiko Carstens, Rich Felker, David Miller,
	gxt, the arch/x86 maintainers, Jeff Dike, Richard Weinberger,
	Chris Zankel, Max Filippov, Tobias Klauser, noamc, mickael.guene,
	Nicolas Pitre, Kees Cook, Dave Martin, Marc Zyngier, alex.bennee,
	Laura Abbott, ynorov, Mark Rutland, chenhc@lemote.com,
	Maciej W. Rozycki, Arnd Bergmann, David Howells, sukadev,
	Nick Piggin, Aneesh Kumar K. V, felix, Ram Pai, Christophe Leroy,
	Cornelia Huck, gor, nick.alcock, shannon.nelson,
	nagarathnam.muthusamy, Andrew Lutomirski, Borislav Petkov,
	Dave Hansen, Vitaly Kuznetsov, Jiri Kosina, linux-alpha,
	Linux Kernel Mailing List, arcml, linux-arm-kernel, linux-c6x-dev,
	moderated list:H8/300 ARCHITECTURE, linux-hexagon,
	linux-ia64@vger.kernel.org, Linux/m68k, linux-mips,
	moderated list:NIOS2 ARCHITECTURE, openrisc, Parisc List, ppc-dev,
	linux-riscv, linux-s390, Linux-sh list, sparclinux, linux-um,
	linux-xtensa
In-Reply-To: <20180821202900.208417-1-ndesaulniers@google.com>

On Tue, Aug 21, 2018 at 1:31 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> I suspect that current_text_addr predated GNU C extensions for statement
> expressions and/or taking the address of a label, then the macro was
> reimplemented for every new archs include/asm/processor.h, even though
> there were very few call sites, and none required an assembly
> implementation vs the C implementation.

I actually have this very dim memory that we had some compiler issues
where a label in the code resulted in gcc generating worse code
elsewhere in that same function.

But current_text_addr() predates both the git and the BK history, so
it's all shrouded in antiquity, and even if my dim recollection is
true, it may not be true any more. There aren't so many call sites
that it is likely to matter anyway.

             Linus

^ permalink raw reply

* Re: [PATCH 6/8] kbuild: consolidate Devicetree dtb build rules
From: Masahiro Yamada @ 2018-08-26  2:05 UTC (permalink / raw)
  To: Rob Herring
  Cc: DTML, Linux Kernel Mailing List, Frank Rowand, Michal Marek,
	Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
	Yoshinori Sato, Michal Simek, Ralf Baechle, Paul Burton,
	James Hogan, Ley Foon Tan, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Chris Zankel, Max Filippov,
	Linux Kbuild mailing list, linux-snps-arc, linux-arm-kernel,
	uclinux-h8-devel, Linux-MIPS, nios2-dev, linuxppc-dev,
	linux-xtensa
In-Reply-To: <20180821215524.23040-7-robh@kernel.org>

Hi Rob,


2018-08-22 6:55 GMT+09:00 Rob Herring <robh@kernel.org>:
> There is nothing arch specific about building dtb files other than their
> location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
> The dependencies and supported targets are all slightly different.
> Also, a cross-compiler for each arch is needed, but really the host
> compiler preprocessor is perfectly fine for building dtbs. Move the
> build rules to a common location and remove the arch specific ones. This
> is done in a single step to avoid warnings about overriding rules.
>
> The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
> These pull in several dependencies some of which need a target compiler
> (specifically devicetable-offsets.h) and aren't needed to build dtbs.
> All that is really needed is dtc, so adjust the dependencies to only be
> dtc.
>
> This change enables support 'dtbs_install' on some arches which were
> missing the target.
>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Michal Marek <michal.lkml@markovi.net>
> Cc: Vineet Gupta <vgupta@synopsys.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
> Cc: Michal Simek <monstr@monstr.eu>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Paul Burton <paul.burton@mips.com>
> Cc: James Hogan <jhogan@kernel.org>
> Cc: Ley Foon Tan <lftan@altera.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: linux-kbuild@vger.kernel.org
> Cc: linux-snps-arc@lists.infradead.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: uclinux-h8-devel@lists.sourceforge.jp
> Cc: linux-mips@linux-mips.org
> Cc: nios2-dev@lists.rocketboards.org
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-xtensa@linux-xtensa.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  Makefile                 | 30 ++++++++++++++++++++++++++++++
>  arch/arc/Makefile        |  6 ------
>  arch/arm/Makefile        | 20 +-------------------
>  arch/arm64/Makefile      | 17 +----------------
>  arch/c6x/Makefile        |  2 --
>  arch/h8300/Makefile      | 11 +----------
>  arch/microblaze/Makefile |  4 +---
>  arch/mips/Makefile       | 15 +--------------
>  arch/nds32/Makefile      |  2 +-
>  arch/nios2/Makefile      |  7 -------
>  arch/nios2/boot/Makefile |  4 ----
>  arch/powerpc/Makefile    |  3 ---
>  arch/xtensa/Makefile     | 12 +-----------
>  scripts/Makefile         |  1 -
>  scripts/Makefile.lib     |  2 +-
>  15 files changed, 38 insertions(+), 98 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index c13f8b85ba60..6d89e673f192 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1212,6 +1212,30 @@ kselftest-merge:
>                 $(srctree)/tools/testing/selftests/*/config
>         +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
>
> +# ---------------------------------------------------------------------------
> +# Devicetree files
> +
> +dtstree := $(wildcard arch/$(SRCARCH)/boot/dts)
> +
> +ifdef CONFIG_OF_EARLY_FLATTREE
> +
> +%.dtb %.dtb.S %.dtb.o: | dtc

I think the pipe operator is unnecessary
because Kbuild will descend to $(dtstree) anyway.


> +       $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
> +
> +PHONY += dtbs
> +dtbs: | dtc

Ditto.


> +       $(Q)$(MAKE) $(build)=$(dtstree)
> +
> +dtbs_install: dtbs
> +       $(Q)$(MAKE) $(dtbinst)=$(dtstree)
> +
> +all: dtbs
> +
> +dtc:
> +       $(Q)$(MAKE) $(build)=scripts/dtc
> +
> +endif
> +


arch/*/boot/dts/ are not only directories that
require dtc.


$ find  drivers/  -name '*.dts'
drivers/staging/mt7621-dts/gbpc1.dts
drivers/staging/pi433/Documentation/devicetree/pi433-overlay.dts
drivers/of/unittest-data/overlay_12.dts
drivers/of/unittest-data/overlay.dts
drivers/of/unittest-data/overlay_5.dts
drivers/of/unittest-data/overlay_bad_symbol.dts
drivers/of/unittest-data/overlay_1.dts
drivers/of/unittest-data/overlay_bad_phandle.dts
drivers/of/unittest-data/overlay_2.dts
drivers/of/unittest-data/overlay_15.dts
drivers/of/unittest-data/overlay_10.dts
drivers/of/unittest-data/testcases.dts
drivers/of/unittest-data/overlay_6.dts
drivers/of/unittest-data/overlay_13.dts
drivers/of/unittest-data/overlay_4.dts
drivers/of/unittest-data/overlay_9.dts
drivers/of/unittest-data/overlay_3.dts
drivers/of/unittest-data/overlay_8.dts
drivers/of/unittest-data/overlay_7.dts
drivers/of/unittest-data/overlay_11.dts
drivers/of/unittest-data/overlay_0.dts
drivers/of/unittest-data/overlay_base.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7796.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7795.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7793.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dts
drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7791.dts





dtc must be built before descending into any directory.





$ git clean -f -x
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-  defconfig
drivers/gpu/drm/rcar-du/
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'multi_v7_defconfig'
#
# configuration written to .config
#
scripts/kconfig/conf  --syncconfig Kconfig
  CC      kernel/bounds.s
  CC      arch/arm/kernel/asm-offsets.s
  CALL    scripts/checksyscalls.sh
<stdin>:1332:2: warning: #warning syscall io_pgetevents not implemented [-Wcpp]
  CC      scripts/mod/empty.o
  HOSTCC  scripts/mod/mk_elfconfig
  MKELF   scripts/mod/elfconfig.h
  HOSTCC  scripts/mod/modpost.o
  CC      scripts/mod/devicetable-offsets.s
  UPD     scripts/mod/devicetable-offsets.h
  HOSTCC  scripts/mod/file2alias.o
  HOSTCC  scripts/mod/sumversion.o
  HOSTLD  scripts/mod/modpost
  HOSTCC  scripts/kallsyms
  HOSTCC  scripts/conmakehash
  HOSTCC  scripts/sortextable
  HOSTCC  scripts/asn1_compiler
  HOSTCC  scripts/extract-cert
  CC      drivers/gpu/drm/rcar-du/rcar_lvds.o
  AR      drivers/gpu/drm/rcar-du/built-in.a
  CC [M]  drivers/gpu/drm/rcar-du/rcar_du_crtc.o
  CC [M]  drivers/gpu/drm/rcar-du/rcar_du_drv.o
  CC [M]  drivers/gpu/drm/rcar-du/rcar_du_encoder.o
  CC [M]  drivers/gpu/drm/rcar-du/rcar_du_group.o
  CC [M]  drivers/gpu/drm/rcar-du/rcar_du_kms.o
  CC [M]  drivers/gpu/drm/rcar-du/rcar_du_plane.o
  CC [M]  drivers/gpu/drm/rcar-du/rcar_du_of.o
make[2]: *** No rule to make target
'drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dtb', needed by
'drivers/gpu/drm/rcar-du/rcar_du_of_lvds_r8a7790.dtb.S'.  Stop.
Makefile:1721: recipe for target 'drivers/gpu/drm/rcar-du/' failed
make[1]: *** [drivers/gpu/drm/rcar-du/] Error 2
Makefile:286: recipe for target '__build_one_by_one' failed
make: *** [__build_one_by_one] Error 2








> diff --git a/scripts/Makefile b/scripts/Makefile
> index 61affa300d25..a716a6b10954 100644
> --- a/scripts/Makefile
> +++ b/scripts/Makefile
> @@ -39,7 +39,6 @@ build_unifdef: $(obj)/unifdef
>  subdir-$(CONFIG_MODVERSIONS) += genksyms
>  subdir-y                     += mod
>  subdir-$(CONFIG_SECURITY_SELINUX) += selinux
> -subdir-$(CONFIG_DTC)         += dtc
>  subdir-$(CONFIG_GDB_SCRIPTS) += gdb
>
>  # Let clean descend into subdirs


You need to 'dtc' here to clean-up scripts/dtc by "make mrproper".

subdir- += basic kconfig package gcc-plugins dtc







-- 
Best Regards
Masahiro Yamada

^ permalink raw reply

* Re: [PATCH] treewide: remove current_text_addr
From: H. Peter Anvin @ 2018-08-26  3:16 UTC (permalink / raw)
  To: Helge Deller, Nick Desaulniers, torvalds, akpm
  Cc: ebiederm, tglx, mingo, horms, natechancellor, pombredanne,
	kstewart, gregkh, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
	Mark Salter, Aurelien Jacquiot, Yoshinori Sato, Richard Kuo,
	Tony Luck, Fenghua Yu, Geert Uytterhoeven, Michal Simek,
	Ralf Baechle, Paul Burton, James Hogan, Greentime Hu,
	Vincent Chen, Ley Foon Tan, Jonas Bonn, Stefan Kristiansson,
	Stafford Horne, James E.J. Bottomley, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Palmer Dabbelt, Albert Ou,
	Martin Schwidefsky, Heiko Carstens, Rich Felker, David S. Miller,
	Guan Xuetao, x86, Jeff Dike, Richard Weinberger, Chris Zankel,
	Max Filippov, Tobias Klauser, Noam Camus, Mickael GUENE,
	Nicolas Pitre, Kees Cook, Dave Martin, Marc Zyngier,
	Alex Bennée, Laura Abbott, Yury Norov, Mark Rutland,
	Huacai Chen, Maciej W. Rozycki, Arnd Bergmann, David Howells,
	Sukadev Bhattiprolu, Nicholas Piggin, Aneesh Kumar K.V,
	Philippe Bergheaud, Ram Pai, Christophe Leroy, Cornelia Huck,
	Vasily Gorbik, Nick Alcock, Shannon Nelson, Nagarathnam Muthusamy,
	Andy Lutomirski, Borislav Petkov, Dave Hansen, Vitaly Kuznetsov,
	Jiri Kosina, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-c6x-dev, uclinux-h8-devel, linux-hexagon,
	linux-ia64, linux-m68k, linux-mips, nios2-dev, openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, linux-um
In-Reply-To: <c62e4e00-fb8f-19a6-f3eb-bde60118cb1a@zytor.com>

[-- Attachment #1: Type: text/plain, Size: 349 bytes --]

On 08/25/18 19:38, H. Peter Anvin wrote:
>
> If it was worthwhile it would make more sense to at least force this
> into the rodata section with the string, something like the attached
> file for an example; however, I have a hunch it doesn't matter.
> 

An even nuttier version which avoids the extra pointer indirection.
Read it and fear.

	-hpa


[-- Attachment #2: str.c --]
[-- Type: text/x-csrc, Size: 1427 bytes --]

#include <stddef.h>
#include <string.h>

#define _RET_IP_ ((unsigned long)__builtin_return_address(0))
#define no_inline __attribute__((noinline))
#define must_inline __attribute__((always_inline)) inline

struct myputs_string {
	unsigned short len;
	char str[0];
};

int _myputs_struct(const struct myputs_string * const strs);
int _myputs_string(const char *str);
int __myputs(unsigned long ip, const char *str, size_t len);

int no_inline _myputs_struct(const struct myputs_string * const strs)
{
	return __myputs(_RET_IP_, strs->str, strs->len);
}

int no_inline _myputs_string(const char *str)
{
	return __myputs(_RET_IP_, str, strlen(str)+1);
}

#define ifconst(x,y)	__builtin_choose_expr(__builtin_constant_p(x),(x),(y))

#define myputs(s)							\
({									\
	int _rv;							\
	if (__builtin_constant_p(s) &&					\
	    __builtin_constant_p(strlen(s)) &&				\
	    strlen(s)+1 == sizeof(s) &&					\
	    sizeof(s) <= (size_t)65535) {				\
	static const struct {						\
		struct myputs_string _mps_hdr;				\
		char _mps_str[sizeof(s)];				\
	} _mps = {							\
		._mps_hdr.len = sizeof(s),				\
		._mps_str = ifconst(s,""),				\
	};								\
		_rv = _myputs_struct(&_mps._mps_hdr);			\
	} else {							\
		_rv = _myputs_string(s);				\
	}								\
	_rv;								\
})

int test1(void);
int test2(const char *strx);

int test1(void)
{
	return myputs("Foobar");
}

int test2(const char *strx)
{
	return myputs(strx);
}

		

^ permalink raw reply

* Re: [PATCH] treewide: remove current_text_addr
From: H. Peter Anvin @ 2018-08-26  2:38 UTC (permalink / raw)
  To: Helge Deller, Nick Desaulniers, torvalds, akpm
  Cc: ebiederm, tglx, mingo, horms, natechancellor, pombredanne,
	kstewart, gregkh, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
	Mark Salter, Aurelien Jacquiot, Yoshinori Sato, Richard Kuo,
	Tony Luck, Fenghua Yu, Geert Uytterhoeven, Michal Simek,
	Ralf Baechle, Paul Burton, James Hogan, Greentime Hu,
	Vincent Chen, Ley Foon Tan, Jonas Bonn, Stefan Kristiansson,
	Stafford Horne, James E.J. Bottomley, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Palmer Dabbelt, Albert Ou,
	Martin Schwidefsky, Heiko Carstens, Rich Felker, David S. Miller,
	Guan Xuetao, x86, Jeff Dike, Richard Weinberger, Chris Zankel,
	Max Filippov, Tobias Klauser, Noam Camus, Mickael GUENE,
	Nicolas Pitre, Kees Cook, Dave Martin, Marc Zyngier,
	Alex Bennée, Laura Abbott, Yury Norov, Mark Rutland,
	Huacai Chen, Maciej W. Rozycki, Arnd Bergmann, David Howells,
	Sukadev Bhattiprolu, Nicholas Piggin, Aneesh Kumar K.V,
	Philippe Bergheaud, Ram Pai, Christophe Leroy, Cornelia Huck,
	Vasily Gorbik, Nick Alcock, Shannon Nelson, Nagarathnam Muthusamy,
	Andy Lutomirski, Borislav Petkov, Dave Hansen, Vitaly Kuznetsov,
	Jiri Kosina, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-c6x-dev, uclinux-h8-devel, linux-hexagon,
	linux-ia64, linux-m68k, linux-mips, nios2-dev, openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, linux-um
In-Reply-To: <207784db-4fcc-85e7-a0b2-fec26b7dab81@gmx.de>

[-- Attachment #1: Type: text/plain, Size: 3032 bytes --]

On 08/25/18 03:48, Helge Deller wrote:
> 
> Currently alpha, s390, sparc, sh, c6x, ia64 and parisc provide an
> inline assembly function to get the current instruction pointer. 
> As mentioned in an earlier thread, I personally would *prefer* if 
> _THIS_IP_ would use those inline assembly instructions on those
> architectures instead of the (currently used) higher C-level
> implementation.
> 

Older ones have as well, e.g. x86.

The only reason to retain the use of an assembly function would be in
the case where either:

a) the C implementation produces bad or invalid code on certain
   architectures;
b) there is a specific requirement that either an absolute or a relative
   value is used in the binary, e.g. due to constraints on relocation.
   The latter particularly comes to mind since the x86-64 implementation
   in assembly will produce movq $.,%reg (which requires relocation)
   instead of the more natural leaq .(%rip),%reg.

In the case (a) those architectures ought to be able to simply

#undef _THIS_IP_
#define _THIS_IP_ blah...

and in case (b) *those specific instances* should be using some kind of
specially flagged function e.g. current_true_ip() vs.
current_linktime_ip() or somesuch.

I also note that a lot of those functions are not marked
__always_inline, which is a serious error should the compiler ever get
the idea to out-of-line these functions, which could potentially happen
as gcc is rather bad at assigning weight to an assembly statement.

I'm also going to throw in a perhaps ugly bomb into this discussion:

_THIS_IP_ seems to be horribly ill-defined; there is no kind of
serialization, and no reason to believe it can't be arbitrarily hoisted
inside a function. Furthermore, *most of the uses of _THIS_IP_ seem to
be either discarded or passed to a function*, and the location of a
function call, unlike _THIS_IP_ is very well defined.

In that case, the use of this mechanism is completely pointless and
ought to be replaced with _RET_IP_.  It seems like most invocations of
_THIS_IP_ can be trivially replaced with _RET_IP_ inside the function,
which would also reduce the footprint of the function call, for example:

__trace_puts() is only ever called with _THIS_IP_ as the first argument;
drop that argument and use _RET_IP_ inside the function (also,
__trace_puts() only ever uses strlen() as the third argument, which gcc
can of course optimize into a constant for the case of a consta t
string, but *is that optimization actually worth it*?  In the case of
__trace_puts(), a variable strlen() would only ever need to be called in
the case of an allocation actually happening -- otherwise str is never
examined -- and again, it increases the *code size* of the call site.
If it was worthwhile it would make more sense to at least force this
into the rodata section with the string, something like the attached
file for an example; however, I have a hunch it doesn't matter.

I wouldn't be surprised if all or nearly all instances of _THIS_IP_ can
be completely removed.

	-hpa

[-- Attachment #2: str.c --]
[-- Type: text/x-csrc, Size: 1231 bytes --]

#include <stddef.h>
#include <string.h>

#define _RET_IP_ ((unsigned long)__builtin_return_address(0))
#define no_inline __attribute__((noinline))
#define must_inline __attribute__((always_inline)) inline

struct myputs_string {
	size_t len;
	const char *str;
};

int _myputs_struct(const struct myputs_string * const strs);
int _myputs_string(const char *str);
int __myputs(unsigned long ip, const char *str, size_t len);

int no_inline _myputs_struct(const struct myputs_string * const strs)
{
	return __myputs(_RET_IP_, strs->str, strs->len);
}

int no_inline _myputs_string(const char *str)
{
	return __myputs(_RET_IP_, str, strlen(str)+1);
}

#define myputs(s)							\
({									\
	int _rv;							\
	if (__builtin_constant_p(s) &&					\
	    __builtin_constant_p(strlen(s)) &&				\
	    strlen(s)+1 == sizeof(s)) {					\
		static const struct myputs_string _mps = {		\
			.len = sizeof(s),				\
			.str = __builtin_constant_p(s) ? s : NULL,	\
		};							\
		_rv = _myputs_struct(&_mps);				\
	} else {							\
		_rv = _myputs_string(s);				\
	}								\
	_rv;								\
})

int test1(void);
int test2(const char *strx);

int test1(void)
{
	return myputs("Foobar");
}

int test2(const char *strx)
{
	return myputs(strx);
}

		

^ permalink raw reply

* Re: [PATCH] treewide: remove current_text_addr
From: H. Peter Anvin @ 2018-08-26  4:56 UTC (permalink / raw)
  To: Helge Deller, Nick Desaulniers, torvalds, akpm
  Cc: ebiederm, tglx, mingo, horms, natechancellor, pombredanne,
	kstewart, gregkh, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
	Mark Salter, Aurelien Jacquiot, Yoshinori Sato, Richard Kuo,
	Tony Luck, Fenghua Yu, Geert Uytterhoeven, Michal Simek,
	Ralf Baechle, Paul Burton, James Hogan, Greentime Hu,
	Vincent Chen, Ley Foon Tan, Jonas Bonn, Stefan Kristiansson,
	Stafford Horne, James E.J. Bottomley, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Palmer Dabbelt, Albert Ou,
	Martin Schwidefsky, Heiko Carstens, Rich Felker, David S. Miller,
	Guan Xuetao, x86, Jeff Dike, Richard Weinberger, Chris Zankel,
	Max Filippov, Tobias Klauser, Noam Camus, Mickael GUENE,
	Nicolas Pitre, Kees Cook, Dave Martin, Marc Zyngier,
	Alex Bennée, Laura Abbott, Yury Norov, Mark Rutland,
	Huacai Chen, Maciej W. Rozycki, Arnd Bergmann, David Howells,
	Sukadev Bhattiprolu, Nicholas Piggin, Aneesh Kumar K.V,
	Philippe Bergheaud, Ram Pai, Christophe Leroy, Cornelia Huck,
	Vasily Gorbik, Nick Alcock, Shannon Nelson, Nagarathnam Muthusamy,
	Andy Lutomirski, Borislav Petkov, Dave Hansen, Vitaly Kuznetsov,
	Jiri Kosina, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-c6x-dev, uclinux-h8-devel, linux-hexagon,
	linux-ia64, linux-m68k, linux-mips, nios2-dev, openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, linux-um
In-Reply-To: <81141365-8168-799b-f34f-da5f92efaaf9@zytor.com>

On 08/25/18 20:16, H. Peter Anvin wrote:
> On 08/25/18 19:38, H. Peter Anvin wrote:
>>
>> If it was worthwhile it would make more sense to at least force this
>> into the rodata section with the string, something like the attached
>> file for an example; however, I have a hunch it doesn't matter.
>>
> 
> An even nuttier version which avoids the extra pointer indirection.
> Read it and fear.
> 
> 	-hpa
> 

OK, so one more thing, I guess: it is necessary to suppress the tailcall
optimization for _RET_IP_ to make any sense, but that should be pretty
simple:

static inline void notailcall(void)
{
	asm volatile("");
}

	-hpa

^ permalink raw reply

* Patch "usb/phy: fix PPC64 build errors in phy-fsl-usb.c" has been added to the 4.14-stable tree
From: gregkh @ 2018-08-26  7:14 UTC (permalink / raw)
  To: alexander.levin, balbi, felipe.balbi, gregkh, linuxppc-dev, mpe,
	rdunlap
  Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    usb/phy: fix PPC64 build errors in phy-fsl-usb.c

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-phy-fix-ppc64-build-errors-in-phy-fsl-usb.c.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From foo@baz Sun Aug 26 09:13:00 CEST 2018
From: Randy Dunlap <rdunlap@infradead.org>
Date: Sun, 15 Jul 2018 10:37:37 -0700
Subject: usb/phy: fix PPC64 build errors in phy-fsl-usb.c

From: Randy Dunlap <rdunlap@infradead.org>

[ Upstream commit a39ba90a1cc7010edb0a7132e1b67f3d80b994e9 ]

Fix build errors when built for PPC64:
These variables are only used on PPC32 so they don't need to be
initialized for PPC64.

../drivers/usb/phy/phy-fsl-usb.c: In function 'usb_otg_start':
../drivers/usb/phy/phy-fsl-usb.c:865:3: error: '_fsl_readl' undeclared (first use in this function); did you mean 'fsl_readl'?
   _fsl_readl = _fsl_readl_be;
../drivers/usb/phy/phy-fsl-usb.c:865:16: error: '_fsl_readl_be' undeclared (first use in this function); did you mean 'fsl_readl'?
   _fsl_readl = _fsl_readl_be;
../drivers/usb/phy/phy-fsl-usb.c:866:3: error: '_fsl_writel' undeclared (first use in this function); did you mean 'fsl_writel'?
   _fsl_writel = _fsl_writel_be;
../drivers/usb/phy/phy-fsl-usb.c:866:17: error: '_fsl_writel_be' undeclared (first use in this function); did you mean 'fsl_writel'?
   _fsl_writel = _fsl_writel_be;
../drivers/usb/phy/phy-fsl-usb.c:868:16: error: '_fsl_readl_le' undeclared (first use in this function); did you mean 'fsl_readl'?
   _fsl_readl = _fsl_readl_le;
../drivers/usb/phy/phy-fsl-usb.c:869:17: error: '_fsl_writel_le' undeclared (first use in this function); did you mean 'fsl_writel'?
   _fsl_writel = _fsl_writel_le;

and the sysfs "show" function return type should be ssize_t, not int:

../drivers/usb/phy/phy-fsl-usb.c:1042:49: error: initialization of 'ssize_t (*)(struct device *, struct device_attribute *, char *)' {aka 'long int (*)(struct device *, struct device_attribute *, char *)'} from incompatible pointer type 'int (*)(struct device *, struct device_attribute *, char *)' [-Werror=incompatible-pointer-types]
 static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL);

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: linux-usb@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/phy/phy-fsl-usb.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -874,6 +874,7 @@ int usb_otg_start(struct platform_device
 	if (pdata->init && pdata->init(pdev) != 0)
 		return -EINVAL;
 
+#ifdef CONFIG_PPC32
 	if (pdata->big_endian_mmio) {
 		_fsl_readl = _fsl_readl_be;
 		_fsl_writel = _fsl_writel_be;
@@ -881,6 +882,7 @@ int usb_otg_start(struct platform_device
 		_fsl_readl = _fsl_readl_le;
 		_fsl_writel = _fsl_writel_le;
 	}
+#endif
 
 	/* request irq */
 	p_otg->irq = platform_get_irq(pdev, 0);
@@ -971,7 +973,7 @@ int usb_otg_start(struct platform_device
 /*
  * state file in sysfs
  */
-static int show_fsl_usb2_otg_state(struct device *dev,
+static ssize_t show_fsl_usb2_otg_state(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
 	struct otg_fsm *fsm = &fsl_otg_dev->fsm;


Patches currently in stable-queue which might be from rdunlap@infradead.org are

queue-4.14/usb-phy-fix-ppc64-build-errors-in-phy-fsl-usb.c.patch
queue-4.14/arc-fix-printk-warning-in-arc-plat-eznps-mtm.c.patch
queue-4.14/arc-add-missing-struct-nps_host_reg_aux_dpc.patch
queue-4.14/net-prevent-isa-drivers-from-building-on-ppc32.patch
queue-4.14/arc-fix-build-errors-in-arc-include-asm-delay.h.patch
queue-4.14/arc-fix-data-type-errors-in-platform-headers.patch
queue-4.14/media-staging-omap4iss-include-asm-cacheflush.h-after-generic-includes.patch
queue-4.14/arc-fix-type-warnings-in-arc-mm-cache.c.patch

^ permalink raw reply

* Patch "usb/phy: fix PPC64 build errors in phy-fsl-usb.c" has been added to the 4.9-stable tree
From: gregkh @ 2018-08-26  7:16 UTC (permalink / raw)
  To: alexander.levin, balbi, felipe.balbi, gregkh, linuxppc-dev, mpe,
	rdunlap
  Cc: stable-commits


This is a note to let you know that I've just added the patch titled

    usb/phy: fix PPC64 build errors in phy-fsl-usb.c

to the 4.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-phy-fix-ppc64-build-errors-in-phy-fsl-usb.c.patch
and it can be found in the queue-4.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.


>From foo@baz Sun Aug 26 09:16:12 CEST 2018
From: Randy Dunlap <rdunlap@infradead.org>
Date: Sun, 15 Jul 2018 10:37:37 -0700
Subject: usb/phy: fix PPC64 build errors in phy-fsl-usb.c

From: Randy Dunlap <rdunlap@infradead.org>

[ Upstream commit a39ba90a1cc7010edb0a7132e1b67f3d80b994e9 ]

Fix build errors when built for PPC64:
These variables are only used on PPC32 so they don't need to be
initialized for PPC64.

../drivers/usb/phy/phy-fsl-usb.c: In function 'usb_otg_start':
../drivers/usb/phy/phy-fsl-usb.c:865:3: error: '_fsl_readl' undeclared (first use in this function); did you mean 'fsl_readl'?
   _fsl_readl = _fsl_readl_be;
../drivers/usb/phy/phy-fsl-usb.c:865:16: error: '_fsl_readl_be' undeclared (first use in this function); did you mean 'fsl_readl'?
   _fsl_readl = _fsl_readl_be;
../drivers/usb/phy/phy-fsl-usb.c:866:3: error: '_fsl_writel' undeclared (first use in this function); did you mean 'fsl_writel'?
   _fsl_writel = _fsl_writel_be;
../drivers/usb/phy/phy-fsl-usb.c:866:17: error: '_fsl_writel_be' undeclared (first use in this function); did you mean 'fsl_writel'?
   _fsl_writel = _fsl_writel_be;
../drivers/usb/phy/phy-fsl-usb.c:868:16: error: '_fsl_readl_le' undeclared (first use in this function); did you mean 'fsl_readl'?
   _fsl_readl = _fsl_readl_le;
../drivers/usb/phy/phy-fsl-usb.c:869:17: error: '_fsl_writel_le' undeclared (first use in this function); did you mean 'fsl_writel'?
   _fsl_writel = _fsl_writel_le;

and the sysfs "show" function return type should be ssize_t, not int:

../drivers/usb/phy/phy-fsl-usb.c:1042:49: error: initialization of 'ssize_t (*)(struct device *, struct device_attribute *, char *)' {aka 'long int (*)(struct device *, struct device_attribute *, char *)'} from incompatible pointer type 'int (*)(struct device *, struct device_attribute *, char *)' [-Werror=incompatible-pointer-types]
 static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL);

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: linux-usb@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/usb/phy/phy-fsl-usb.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -879,6 +879,7 @@ int usb_otg_start(struct platform_device
 	if (pdata->init && pdata->init(pdev) != 0)
 		return -EINVAL;
 
+#ifdef CONFIG_PPC32
 	if (pdata->big_endian_mmio) {
 		_fsl_readl = _fsl_readl_be;
 		_fsl_writel = _fsl_writel_be;
@@ -886,6 +887,7 @@ int usb_otg_start(struct platform_device
 		_fsl_readl = _fsl_readl_le;
 		_fsl_writel = _fsl_writel_le;
 	}
+#endif
 
 	/* request irq */
 	p_otg->irq = platform_get_irq(pdev, 0);
@@ -976,7 +978,7 @@ int usb_otg_start(struct platform_device
 /*
  * state file in sysfs
  */
-static int show_fsl_usb2_otg_state(struct device *dev,
+static ssize_t show_fsl_usb2_otg_state(struct device *dev,
 				   struct device_attribute *attr, char *buf)
 {
 	struct otg_fsm *fsm = &fsl_otg_dev->fsm;


Patches currently in stable-queue which might be from rdunlap@infradead.org are

queue-4.9/usb-phy-fix-ppc64-build-errors-in-phy-fsl-usb.c.patch
queue-4.9/net-prevent-isa-drivers-from-building-on-ppc32.patch
queue-4.9/arc-fix-build-errors-in-arc-include-asm-delay.h.patch
queue-4.9/arc-fix-data-type-errors-in-platform-headers.patch
queue-4.9/media-staging-omap4iss-include-asm-cacheflush.h-after-generic-includes.patch
queue-4.9/arc-fix-type-warnings-in-arc-mm-cache.c.patch

^ permalink raw reply

* Re: [PATCH] treewide: remove current_text_addr
From: H. Peter Anvin @ 2018-08-26 19:30 UTC (permalink / raw)
  To: Helge Deller, Nick Desaulniers, torvalds, akpm
  Cc: ebiederm, tglx, mingo, horms, natechancellor, pombredanne,
	kstewart, gregkh, Richard Henderson, Ivan Kokshaysky, Matt Turner,
	Vineet Gupta, Russell King, Catalin Marinas, Will Deacon,
	Mark Salter, Aurelien Jacquiot, Yoshinori Sato, Richard Kuo,
	Tony Luck, Fenghua Yu, Geert Uytterhoeven, Michal Simek,
	Ralf Baechle, Paul Burton, James Hogan, Greentime Hu,
	Vincent Chen, Ley Foon Tan, Jonas Bonn, Stefan Kristiansson,
	Stafford Horne, James E.J. Bottomley, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Palmer Dabbelt, Albert Ou,
	Martin Schwidefsky, Heiko Carstens, Rich Felker, David S. Miller,
	Guan Xuetao, x86, Jeff Dike, Richard Weinberger, Chris Zankel,
	Max Filippov, Tobias Klauser, Noam Camus, Mickael GUENE,
	Nicolas Pitre, Kees Cook, Dave Martin, Marc Zyngier,
	Alex Bennée, Laura Abbott, Yury Norov, Mark Rutland,
	Huacai Chen, Maciej W. Rozycki, Arnd Bergmann, David Howells,
	Sukadev Bhattiprolu, Nicholas Piggin, Aneesh Kumar K.V,
	Philippe Bergheaud, Ram Pai, Christophe Leroy, Cornelia Huck,
	Vasily Gorbik, Nick Alcock, Shannon Nelson, Nagarathnam Muthusamy,
	Andy Lutomirski, Borislav Petkov, Dave Hansen, Vitaly Kuznetsov,
	Jiri Kosina, linux-alpha, linux-kernel, linux-snps-arc,
	linux-arm-kernel, linux-c6x-dev, uclinux-h8-devel, linux-hexagon,
	linux-ia64, linux-m68k, linux-mips, nios2-dev, openrisc,
	linux-parisc, linuxppc-dev, linux-riscv, linux-s390, linux-sh,
	sparclinux, linux-um
In-Reply-To: <7f49eeab-a5cc-867f-58fb-abd266f9c2c9@zytor.com>

[-- Attachment #1: Type: text/plain, Size: 108 bytes --]

Here is a full-blown (user space) test program demonstrating the whole
technique and how to use it.

	-hpa


[-- Attachment #2: str.c --]
[-- Type: text/x-csrc, Size: 4208 bytes --]

#include <stddef.h>
#include <string.h>

#define _RET_IP_ ((unsigned long)__builtin_return_address(0))
#define noinline __attribute__((noinline))
#define used __attribute__((used))
/* __always_inline is defined in glibc already */
#define ifconst(x,y)	__builtin_choose_expr(__builtin_constant_p(x),(x),(y))
static inline void notailcall(void)
{
	asm volatile("");
}

/* Change this to a null string to make all functions global */
#define STATIC static

struct myputs_string {
	unsigned short len;
	char str[0];
};

STATIC int _myputs_struct(const struct myputs_string * const strs);
STATIC int _myputs_string(const char *str);
STATIC int __myputs(unsigned long ip, const char *str, size_t len);

#if 1

#include <stdio.h>

STATIC void dump_caller(unsigned long where)
{
	const char *opname = NULL;
	const char *wheretoname = NULL;
	char ichar;
	unsigned long whereto = 0;

#if defined(__i386__) || defined(__x86_64__)
	char opname_buf[4];
	unsigned char opcode;
	
	where -= 5;
	opcode = *(unsigned char *)where;

	switch (opcode) {
	case 0xe8:
		opname = "call";
		whereto = where + 5 + *(signed int *)(where + 1);
		break;
	case 0xe9:
		opname = "jmp";
		whereto = where + 5 + *(signed int *)(where + 1);
		break;
	default:
		snprintf(opname_buf, sizeof opname_buf, "?%02x", opcode);
		opname = opname_buf;
		break;
	}

#elif defined(__sparc__)
	const char regtype[4] = "gilo";
	unsigned int opcode, op1, op3, ibit;
	signed int simm13, simm30;
	char opname_buf[32];
	char *p;

	where -= 8;
	
	opcode = *(signed int *)where;
	op1 = opcode >> 30;
	op3 = (opcode >> 19) & 0x3f;
	ibit = (opcode >> 13) & 1;
	simm13 = (opcode & 0x1fff) << 2;
	simm30 = (opcode & 0x3fffffff) << 2;

	opname = opname_buf;
	
	if (op1 == 1) {
		opname = "call";
		whereto = where + simm30;
	} else if (op1 == 2 && op3 == 0x38) {
		if (ibit) {
			snprintf(opname_buf, sizeof opname_buf,
				 "jmpl %%%c%u %c 0x%x",
				 regtype[(opcode >> 17) & 3],
				 (opcode >> 14) & 7,
				 simm13 < 0 ? '-' : '+',
				 abs(simm13));
		} else {
			snprintf(opname_buf, sizeof opname_buf,
				 "jmpl %%%c%u + %%%c%u",
				 regtype[(opcode >> 17) & 3],
				 (opcode >> 14) & 7,
				 regtype[(opcode >> 3) & 3],
				 opcode & 7);
		}
	} else {
		snprintf(opname_buf, sizeof opname_buf,
			 "?0x08x", opcode);
	}
#else
	/* Unknown architecture */
#endif
	if (whereto == (unsigned long)_myputs_struct) {
		wheretoname = "_myputs_struct";
	} else if (whereto == (unsigned long)_myputs_string) {
		wheretoname = "_myputs_string";
	} else {
		wheretoname = "?";
	}

	ichar = '[';
	
	if (opname) {
		printf("%c%p: %s",
		       ichar, (void *)where, opname);
		ichar = ' ';
	}
	if (whereto) {
		printf("%c%p <%s>", ichar, (void *)whereto, wheretoname);
		ichar = ' ';
	}
	if (ichar != '[')
		putchar(']');
}
	
STATIC int __myputs(unsigned long where, const char *str, size_t len)
{
	size_t slen = strlen(str);
	size_t rv;
	
	len--;
	rv = printf("%p: \"%.*s\"%*s", (void *)where, (int)len, str,
		    16-(int)slen, "");
	dump_caller(where);
	if (slen != len)
		printf(" <err: strlen = %zu, len = %zu>\n", slen, len);
	else
		printf(" <ok: len = %zu>\n", len);
	
	return rv;
}

STATIC int noinline _myputs_struct(const struct myputs_string * const strs)
{
	return __myputs(_RET_IP_, strs->str, strs->len);
}

STATIC int noinline _myputs_string(const char *str)
{
	return __myputs(_RET_IP_, str, strlen(str)+1);
}
#endif

#define myputs(s)							\
({									\
	int _rv;							\
	if (__builtin_constant_p(s) &&					\
	    __builtin_constant_p(strlen(s)) &&				\
	    strlen(s)+1 == sizeof(s) &&					\
	    sizeof(s) <= (size_t)65535) {				\
	static const struct {						\
		struct myputs_string _mps_hdr;				\
		char _mps_str[sizeof(s)];				\
	} _mps = {							\
		._mps_hdr.len = sizeof(s),				\
		._mps_str = ifconst(s,""),				\
	};								\
		_rv = _myputs_struct(&_mps._mps_hdr);			\
	} else {							\
		_rv = _myputs_string(s);				\
	}								\
	notailcall();							\
	_rv;								\
})

STATIC int test1(void);
STATIC int test2(const char *strx);

STATIC int test1(void)
{
	return myputs("Foobar");
}

STATIC int test2(const char *strx)
{
	return myputs(strx);
}

int main(int argc, char *argv[])
{
	(void)argc;

	test1();
	test2(argv[0]);
	return 0;
}

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox