Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-23 Thread Ard Biesheuvel
On 23 February 2018 at 14:19, Nicolas Dechesne
 wrote:
> hi,
>
> On Mon, Feb 12, 2018 at 12:38 PM, Ard Biesheuvel
>  wrote:
>> Hi Greg,
>>
>> As mentioned by Will, I have created the v4.14 counterpart of his stable
>> backport of the arm64/ARM Spectre/Meltdown mitigations that have been pulled
>> into v4.16-rc1.
>>
>> Given that this is the v4.15 version backported to v4.14, I have removed any
>> mention of 'conflicts' from the commit logs as they are now ambiguous. The
>> patches applied surprisingly cleanly, I only needed to drop two patches that
>> are already in (the same ones Will mentioned in his PR), and drop another one
>> dealing with SPE, support for which did not exist yet in v4.14. I also 
>> included
>> the patch
>>
>>   arm64: move TASK_* definitions to 
>>
>> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.
>>
>> Thanks,
>> Ard.
>>
>> Will Deacon (40):
>>   [Variant 3/Meltdown] arm64: mm: Use non-global mappings for kernel 
>> space
>>   [Variant 3/Meltdown] arm64: mm: Temporarily disable ARM64_SW_TTBR0_PAN
>>   [Variant 3/Meltdown] arm64: mm: Move ASID from TTBR0 to TTBR1
>>   [Variant 3/Meltdown] arm64: mm: Remove pre_ttbr0_update_workaround for 
>> Falkor erratum #E1003
>>   [Variant 3/Meltdown] arm64: mm: Rename post_ttbr0_update_workaround
>>   [Variant 3/Meltdown] arm64: mm: Fix and re-enable ARM64_SW_TTBR0_PAN
>>   [Variant 3/Meltdown] arm64: mm: Allocate ASIDs in pairs
>>   [Variant 3/Meltdown] arm64: mm: Add arm64_kernel_unmapped_at_el0 helper
>>   [Variant 3/Meltdown] arm64: mm: Invalidate both kernel and user ASIDs 
>> when performing TLBI
>>   [Variant 3/Meltdown] arm64: entry: Add exception trampoline page for 
>> exceptions from EL0
>>   [Variant 3/Meltdown] arm64: mm: Map entry trampoline into trampoline 
>> and kernel page tables
>>   [Variant 3/Meltdown] arm64: entry: Explicitly pass exception level to 
>> kernel_ventry macro
>>   [Variant 3/Meltdown] arm64: entry: Hook up entry trampoline to 
>> exception vectors
>>   [Variant 3/Meltdown] arm64: erratum: Work around Falkor erratum #E1003 
>> in trampoline code
>>   [Variant 3/Meltdown] arm64: tls: Avoid unconditional zeroing of 
>> tpidrro_el0 for native tasks
>>   [Variant 3/Meltdown] arm64: entry: Add fake CPU feature for unmapping 
>> the kernel at EL0
>>   [Variant 3/Meltdown] arm64: kaslr: Put kernel vectors address in 
>> separate data page
>>   [Variant 3/Meltdown] arm64: use RET instruction for exiting the 
>> trampoline
>>   [Variant 3/Meltdown] arm64: Kconfig: Add CONFIG_UNMAP_KERNEL_AT_EL0
>>   [Variant 3/Meltdown] arm64: Kconfig: Reword UNMAP_KERNEL_AT_EL0 
>> kconfig entry
>>   [Variant 3/Meltdown] arm64: Take into account ID_AA64PFR0_EL1.CSV3
>>   [Variant 3/Meltdown] arm64: mm: Introduce TTBR_ASID_MASK for getting 
>> at the ASID in the TTBR
>>   [Variant 3/Meltdown] arm64: kpti: Make use of nG dependent on 
>> arm64_kernel_unmapped_at_el0()
>
> we are seeing a regression on Qualcomm Dragonbooard 410c at this
> commit ^. we are seeing the same regression on 4.15.x, where the same
> commit exists too. However there is no regression on mainline.
>
> Starting from this commit , this is the bootlog (with earlyprintk)
>
...
> [0.239866] alternatives: patching kernel code
> [0.244070] [ cut here ]
> [0.248350] kernel BUG at ../arch/arm64/mm/mmu.c:138!
> [0.253128] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
> [0.258073] Modules linked in:
> [0.263455] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.15.3 #27
> [0.266495] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT)
> [0.272662] pstate: 0005 (nzcv daif -PAN -UAO)
> [0.279347] pc : __create_pgd_mapping+0x544/0x660
> [0.283943] lr : __create_pgd_mapping+0x4d0/0x660
> [0.288714] sp : 08033cb0
> [0.293400] x29: 08033cb0 x28: 80e2
> [0.296701] x27: 8008 x26: 8020
> [0.302083] x25: 8008 x24: 80e3
> [0.307379] x23: 7dfffe638000 x22: bfef6003
> [0.312673] x21: 8008 x20: 00e00f93
> [0.317969] x19: 80e3 x18: 0010
> [0.323264] x17: 1f8013fb x16: 0522cdac
> [0.328558] x15:  x14: 0400
> [0.333854] x13: 80008000 x12: 8008
> [0.339150] x11: 00e80f13 x10: 801f
> [0.35] x9 : 8008 x8 : 00e00f93
> [0.349739] x7 : 8009 x6 : 00400041
> [0.355034] x5 : 0041 x4 : 00e880080f93
> [0.360329] x3 : 8008 x2 : 7dfffe639400
> [0.365624] x1 : ffd7ff7f x0 : 00080880
> [0.370922] Process swapper/0 (pid: 1, stack limit = 0x95a442e7)
> [0.376216] Call trace:
> [0.382899]  

Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-23 Thread Nicolas Dechesne
hi,

On Mon, Feb 12, 2018 at 12:38 PM, Ard Biesheuvel
 wrote:
> Hi Greg,
>
> As mentioned by Will, I have created the v4.14 counterpart of his stable
> backport of the arm64/ARM Spectre/Meltdown mitigations that have been pulled
> into v4.16-rc1.
>
> Given that this is the v4.15 version backported to v4.14, I have removed any
> mention of 'conflicts' from the commit logs as they are now ambiguous. The
> patches applied surprisingly cleanly, I only needed to drop two patches that
> are already in (the same ones Will mentioned in his PR), and drop another one
> dealing with SPE, support for which did not exist yet in v4.14. I also 
> included
> the patch
>
>   arm64: move TASK_* definitions to 
>
> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.
>
> Thanks,
> Ard.
>
> Will Deacon (40):
>   [Variant 3/Meltdown] arm64: mm: Use non-global mappings for kernel space
>   [Variant 3/Meltdown] arm64: mm: Temporarily disable ARM64_SW_TTBR0_PAN
>   [Variant 3/Meltdown] arm64: mm: Move ASID from TTBR0 to TTBR1
>   [Variant 3/Meltdown] arm64: mm: Remove pre_ttbr0_update_workaround for 
> Falkor erratum #E1003
>   [Variant 3/Meltdown] arm64: mm: Rename post_ttbr0_update_workaround
>   [Variant 3/Meltdown] arm64: mm: Fix and re-enable ARM64_SW_TTBR0_PAN
>   [Variant 3/Meltdown] arm64: mm: Allocate ASIDs in pairs
>   [Variant 3/Meltdown] arm64: mm: Add arm64_kernel_unmapped_at_el0 helper
>   [Variant 3/Meltdown] arm64: mm: Invalidate both kernel and user ASIDs 
> when performing TLBI
>   [Variant 3/Meltdown] arm64: entry: Add exception trampoline page for 
> exceptions from EL0
>   [Variant 3/Meltdown] arm64: mm: Map entry trampoline into trampoline 
> and kernel page tables
>   [Variant 3/Meltdown] arm64: entry: Explicitly pass exception level to 
> kernel_ventry macro
>   [Variant 3/Meltdown] arm64: entry: Hook up entry trampoline to 
> exception vectors
>   [Variant 3/Meltdown] arm64: erratum: Work around Falkor erratum #E1003 
> in trampoline code
>   [Variant 3/Meltdown] arm64: tls: Avoid unconditional zeroing of 
> tpidrro_el0 for native tasks
>   [Variant 3/Meltdown] arm64: entry: Add fake CPU feature for unmapping 
> the kernel at EL0
>   [Variant 3/Meltdown] arm64: kaslr: Put kernel vectors address in 
> separate data page
>   [Variant 3/Meltdown] arm64: use RET instruction for exiting the 
> trampoline
>   [Variant 3/Meltdown] arm64: Kconfig: Add CONFIG_UNMAP_KERNEL_AT_EL0
>   [Variant 3/Meltdown] arm64: Kconfig: Reword UNMAP_KERNEL_AT_EL0 kconfig 
> entry
>   [Variant 3/Meltdown] arm64: Take into account ID_AA64PFR0_EL1.CSV3
>   [Variant 3/Meltdown] arm64: mm: Introduce TTBR_ASID_MASK for getting at 
> the ASID in the TTBR
>   [Variant 3/Meltdown] arm64: kpti: Make use of nG dependent on 
> arm64_kernel_unmapped_at_el0()

we are seeing a regression on Qualcomm Dragonbooard 410c at this
commit ^. we are seeing the same regression on 4.15.x, where the same
commit exists too. However there is no regression on mainline.

Starting from this commit , this is the bootlog (with earlyprintk)

[0.00] Booting Linux on physical CPU 0x00 [0x410fd030]
[0.00] Linux version 4.15.3 (nicolas.dechesne@qcom-hackbox)
(gcc version 6.2.1 20161016 (Linaro GCC 6.2-2016.11)) #27
SMP PREEMPT Tue Feb 20 15:54:58 CET 2018
[0.00] Machine model: Qualcomm Technologies, Inc. APQ 8016 SBC
[0.00] earlycon: msm_serial_dm0 at MMIO 0x078b
(options '115200n8')
[0.00] bootconsole [msm_serial_dm0] enabled
[0.00] efi: Getting EFI parameters from FDT:
[0.00] efi: UEFI not found.
[0.00] cma: Reserved 16 MiB at 0xbec0
[0.00] NUMA: No NUMA configuration found
[0.00] NUMA: Faking a node at [mem
0x-0xbfff]
[0.00] NUMA: NODE_DATA [mem 0xbfeb1c00-0xbfeb36ff]
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x8000-0xbfff]
[0.00]   Normal   empty
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x8000-0x85ff]
[0.00]   node   0: [mem 0x89f0-0x8e9f]
[0.00]   node   0: [mem 0x8eb0-0xbfff]
[0.00] Initmem setup node 0 [mem 0x8000-0xbfff]
[0.00] psci: probing for conduit method from DT.
[0.00] psci: PSCIv1.0 detected in firmware.
[0.00] psci: Using standard PSCI v0.2 function IDs
[0.00] psci: MIGRATE_INFO_TYPE not supported.
[0.00] random: fast init done
[0.00] percpu: Embedded 23 pages/cpu @(ptrval) s55064
r8192 d30952 u94208
[0.00] Detected VIPT I-cache on CPU0
[0.00] CPU features: enabling workaround for ARM errata
826319, 827319, 824069
[0.00] CPU features: enabling workaround 

Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-14 Thread Greg KH
On Wed, Feb 14, 2018 at 03:49:36PM +, Ard Biesheuvel wrote:
> On 14 February 2018 at 15:40, Greg KH  wrote:
> > On Wed, Feb 14, 2018 at 02:34:01PM +, Ard Biesheuvel wrote:
> >> On 14 February 2018 at 14:24, Ard Biesheuvel  
> >> wrote:
> >> > On 14 February 2018 at 13:54, Greg KH  wrote:
> >> >> On Mon, Feb 12, 2018 at 11:38:01AM +, Ard Biesheuvel wrote:
> >> >>> Hi Greg,
> >> >>>
> >> >>> As mentioned by Will, I have created the v4.14 counterpart of his 
> >> >>> stable
> >> >>> backport of the arm64/ARM Spectre/Meltdown mitigations that have been 
> >> >>> pulled
> >> >>> into v4.16-rc1.
> >> >>>
> >> >>> Given that this is the v4.15 version backported to v4.14, I have 
> >> >>> removed any
> >> >>> mention of 'conflicts' from the commit logs as they are now ambiguous. 
> >> >>> The
> >> >>> patches applied surprisingly cleanly, I only needed to drop two 
> >> >>> patches that
> >> >>> are already in (the same ones Will mentioned in his PR), and drop 
> >> >>> another one
> >> >>> dealing with SPE, support for which did not exist yet in v4.14. I also 
> >> >>> included
> >> >>> the patch
> >> >>>
> >> >>>   arm64: move TASK_* definitions to 
> >> >>>
> >> >>> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.
> >> >>
> >> >> I've queued these up now, but if you could pull the whole quilt tree and
> >> >> verify I got things right, that would be great.  There was some
> >> >> conflicts with a few previous patches I had already queued up that
> >> >> touched some "Falkor" errata code.
> >> >>
> >> >> Specifically 932b50c7c1c65e6f23002e075b97ee083c4a9e71 "arm64: Add
> >> >> software workaround for Falkor erratum 1041" is the offending patch.  I
> >> >> think I resolved the merge issues properly, but verifying this would be
> >> >> wonderful.
> >> >>
> >> >
> >> > No, the build is broken now. I will investigate.
> >>
> >> Your patch 977c3d2cb684e143a18e1564fbf5ecf7576a1c98
> >>
> >> arm64: Move post_ttbr_update_workaround to C code
> >>
> >> removes the pre_disable_mmu_workaround macro from asm/assembler.h but
> >> it should only remove post_ttbr_update_workaround
> >>
> >> Once I add that back, things seem to build and run as expected.
> >
> > Can you provide a "fixed" version of just this patch so I know to get it
> > correct?
> >
> 
> Sure. I will send it in a separate email, or Gmail will clobber the patch.

Thanks for that, I've now replaced it.

greg k-h


Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-14 Thread Ard Biesheuvel
On 14 February 2018 at 15:40, Greg KH  wrote:
> On Wed, Feb 14, 2018 at 02:34:01PM +, Ard Biesheuvel wrote:
>> On 14 February 2018 at 14:24, Ard Biesheuvel  
>> wrote:
>> > On 14 February 2018 at 13:54, Greg KH  wrote:
>> >> On Mon, Feb 12, 2018 at 11:38:01AM +, Ard Biesheuvel wrote:
>> >>> Hi Greg,
>> >>>
>> >>> As mentioned by Will, I have created the v4.14 counterpart of his stable
>> >>> backport of the arm64/ARM Spectre/Meltdown mitigations that have been 
>> >>> pulled
>> >>> into v4.16-rc1.
>> >>>
>> >>> Given that this is the v4.15 version backported to v4.14, I have removed 
>> >>> any
>> >>> mention of 'conflicts' from the commit logs as they are now ambiguous. 
>> >>> The
>> >>> patches applied surprisingly cleanly, I only needed to drop two patches 
>> >>> that
>> >>> are already in (the same ones Will mentioned in his PR), and drop 
>> >>> another one
>> >>> dealing with SPE, support for which did not exist yet in v4.14. I also 
>> >>> included
>> >>> the patch
>> >>>
>> >>>   arm64: move TASK_* definitions to 
>> >>>
>> >>> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.
>> >>
>> >> I've queued these up now, but if you could pull the whole quilt tree and
>> >> verify I got things right, that would be great.  There was some
>> >> conflicts with a few previous patches I had already queued up that
>> >> touched some "Falkor" errata code.
>> >>
>> >> Specifically 932b50c7c1c65e6f23002e075b97ee083c4a9e71 "arm64: Add
>> >> software workaround for Falkor erratum 1041" is the offending patch.  I
>> >> think I resolved the merge issues properly, but verifying this would be
>> >> wonderful.
>> >>
>> >
>> > No, the build is broken now. I will investigate.
>>
>> Your patch 977c3d2cb684e143a18e1564fbf5ecf7576a1c98
>>
>> arm64: Move post_ttbr_update_workaround to C code
>>
>> removes the pre_disable_mmu_workaround macro from asm/assembler.h but
>> it should only remove post_ttbr_update_workaround
>>
>> Once I add that back, things seem to build and run as expected.
>
> Can you provide a "fixed" version of just this patch so I know to get it
> correct?
>

Sure. I will send it in a separate email, or Gmail will clobber the patch.


Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-14 Thread Greg KH
On Wed, Feb 14, 2018 at 02:34:01PM +, Ard Biesheuvel wrote:
> On 14 February 2018 at 14:24, Ard Biesheuvel  
> wrote:
> > On 14 February 2018 at 13:54, Greg KH  wrote:
> >> On Mon, Feb 12, 2018 at 11:38:01AM +, Ard Biesheuvel wrote:
> >>> Hi Greg,
> >>>
> >>> As mentioned by Will, I have created the v4.14 counterpart of his stable
> >>> backport of the arm64/ARM Spectre/Meltdown mitigations that have been 
> >>> pulled
> >>> into v4.16-rc1.
> >>>
> >>> Given that this is the v4.15 version backported to v4.14, I have removed 
> >>> any
> >>> mention of 'conflicts' from the commit logs as they are now ambiguous. The
> >>> patches applied surprisingly cleanly, I only needed to drop two patches 
> >>> that
> >>> are already in (the same ones Will mentioned in his PR), and drop another 
> >>> one
> >>> dealing with SPE, support for which did not exist yet in v4.14. I also 
> >>> included
> >>> the patch
> >>>
> >>>   arm64: move TASK_* definitions to 
> >>>
> >>> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.
> >>
> >> I've queued these up now, but if you could pull the whole quilt tree and
> >> verify I got things right, that would be great.  There was some
> >> conflicts with a few previous patches I had already queued up that
> >> touched some "Falkor" errata code.
> >>
> >> Specifically 932b50c7c1c65e6f23002e075b97ee083c4a9e71 "arm64: Add
> >> software workaround for Falkor erratum 1041" is the offending patch.  I
> >> think I resolved the merge issues properly, but verifying this would be
> >> wonderful.
> >>
> >
> > No, the build is broken now. I will investigate.
> 
> Your patch 977c3d2cb684e143a18e1564fbf5ecf7576a1c98
> 
> arm64: Move post_ttbr_update_workaround to C code
> 
> removes the pre_disable_mmu_workaround macro from asm/assembler.h but
> it should only remove post_ttbr_update_workaround
> 
> Once I add that back, things seem to build and run as expected.

Can you provide a "fixed" version of just this patch so I know to get it
correct?

thanks,

greg k-h


Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-14 Thread Ard Biesheuvel
On 14 February 2018 at 14:24, Ard Biesheuvel  wrote:
> On 14 February 2018 at 13:54, Greg KH  wrote:
>> On Mon, Feb 12, 2018 at 11:38:01AM +, Ard Biesheuvel wrote:
>>> Hi Greg,
>>>
>>> As mentioned by Will, I have created the v4.14 counterpart of his stable
>>> backport of the arm64/ARM Spectre/Meltdown mitigations that have been pulled
>>> into v4.16-rc1.
>>>
>>> Given that this is the v4.15 version backported to v4.14, I have removed any
>>> mention of 'conflicts' from the commit logs as they are now ambiguous. The
>>> patches applied surprisingly cleanly, I only needed to drop two patches that
>>> are already in (the same ones Will mentioned in his PR), and drop another 
>>> one
>>> dealing with SPE, support for which did not exist yet in v4.14. I also 
>>> included
>>> the patch
>>>
>>>   arm64: move TASK_* definitions to 
>>>
>>> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.
>>
>> I've queued these up now, but if you could pull the whole quilt tree and
>> verify I got things right, that would be great.  There was some
>> conflicts with a few previous patches I had already queued up that
>> touched some "Falkor" errata code.
>>
>> Specifically 932b50c7c1c65e6f23002e075b97ee083c4a9e71 "arm64: Add
>> software workaround for Falkor erratum 1041" is the offending patch.  I
>> think I resolved the merge issues properly, but verifying this would be
>> wonderful.
>>
>
> No, the build is broken now. I will investigate.

Your patch 977c3d2cb684e143a18e1564fbf5ecf7576a1c98

arm64: Move post_ttbr_update_workaround to C code

removes the pre_disable_mmu_workaround macro from asm/assembler.h but
it should only remove post_ttbr_update_workaround

Once I add that back, things seem to build and run as expected.

Thanks,
Ard.


Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-14 Thread Ard Biesheuvel
On 14 February 2018 at 13:54, Greg KH  wrote:
> On Mon, Feb 12, 2018 at 11:38:01AM +, Ard Biesheuvel wrote:
>> Hi Greg,
>>
>> As mentioned by Will, I have created the v4.14 counterpart of his stable
>> backport of the arm64/ARM Spectre/Meltdown mitigations that have been pulled
>> into v4.16-rc1.
>>
>> Given that this is the v4.15 version backported to v4.14, I have removed any
>> mention of 'conflicts' from the commit logs as they are now ambiguous. The
>> patches applied surprisingly cleanly, I only needed to drop two patches that
>> are already in (the same ones Will mentioned in his PR), and drop another one
>> dealing with SPE, support for which did not exist yet in v4.14. I also 
>> included
>> the patch
>>
>>   arm64: move TASK_* definitions to 
>>
>> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.
>
> I've queued these up now, but if you could pull the whole quilt tree and
> verify I got things right, that would be great.  There was some
> conflicts with a few previous patches I had already queued up that
> touched some "Falkor" errata code.
>
> Specifically 932b50c7c1c65e6f23002e075b97ee083c4a9e71 "arm64: Add
> software workaround for Falkor erratum 1041" is the offending patch.  I
> think I resolved the merge issues properly, but verifying this would be
> wonderful.
>

No, the build is broken now. I will investigate.


Re: [GIT PULL] arm64 spectre and meltdown mitigations for v4.14-stable

2018-02-14 Thread Greg KH
On Mon, Feb 12, 2018 at 11:38:01AM +, Ard Biesheuvel wrote:
> Hi Greg,
> 
> As mentioned by Will, I have created the v4.14 counterpart of his stable
> backport of the arm64/ARM Spectre/Meltdown mitigations that have been pulled
> into v4.16-rc1.
> 
> Given that this is the v4.15 version backported to v4.14, I have removed any
> mention of 'conflicts' from the commit logs as they are now ambiguous. The
> patches applied surprisingly cleanly, I only needed to drop two patches that
> are already in (the same ones Will mentioned in his PR), and drop another one
> dealing with SPE, support for which did not exist yet in v4.14. I also 
> included
> the patch
> 
>   arm64: move TASK_* definitions to 
> 
> from v4.15 to make Robin's Spectre v1 patches apply more cleanly.

I've queued these up now, but if you could pull the whole quilt tree and
verify I got things right, that would be great.  There was some
conflicts with a few previous patches I had already queued up that
touched some "Falkor" errata code.

Specifically 932b50c7c1c65e6f23002e075b97ee083c4a9e71 "arm64: Add
software workaround for Falkor erratum 1041" is the offending patch.  I
think I resolved the merge issues properly, but verifying this would be
wonderful.

thanks,

greg k-h