lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0d4df07b-da7f-3cad-7066-97ecd72c3d5e@arm.com>
Date:   Sat, 12 Nov 2022 19:22:51 +0530
From:   Anshuman Khandual <anshuman.khandual@....com>
To:     Catalin Marinas <catalin.marinas@....com>
Cc:     linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
        will@...nel.org, Suzuki K Poulose <suzuki.poulose@....com>,
        James Morse <james.morse@....com>,
        Jonathan Corbet <corbet@....net>,
        Mark Rutland <mark.rutland@....com>, linux-doc@...r.kernel.org
Subject: Re: [PATCH 2/2] arm64: errata: Workaround possible Cortex-A715
 [ESR|FAR]_ELx corruption



On 11/12/22 04:06, Catalin Marinas wrote:
> On Thu, Nov 10, 2022 at 08:45:07AM +0530, Anshuman Khandual wrote:
>> On 11/10/22 00:48, Catalin Marinas wrote:
>>> On Thu, Oct 27, 2022 at 08:09:15AM +0530, Anshuman Khandual wrote:
>>>> +#define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION
>>>> +static inline pte_t ptep_modify_prot_start(struct vm_area_struct *vma,
>>>> +					   unsigned long addr,
>>>> +					   pte_t *ptep)
>>>> +{
>>>> +	pte_t pte = ptep_get_and_clear(vma->vm_mm, addr, ptep);
>>>>  
>>>> +	if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) {
>>>> +		/*
>>>> +		 * Break-before-make (BBM) is required for all user space mappings
>>>> +		 * when the permission changes from executable to non-executable
>>>> +		 * in cases where cpu is affected with errata #2645198.
>>>> +		 */
>>>> +		if (pte_user_exec(pte) && cpus_have_const_cap(ARM64_WORKAROUND_2645198))
>>>> +			__flush_tlb_range(vma, addr, addr + PAGE_SIZE, PAGE_SIZE, false, 3);
>>>
>>> Why not flush_tlb_page() here?
>>>
>>> But more importantly, can we not use ptep_clear_flush() instead (and
>>
>> Something like ...
>>
>> ptep_modify_prot_start -
>>
>> if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) {
>> 	if (pte_user_exec(READ_ONCE(*ptep)) && cpus_have_const_cap(ARM64_WORKAROUND_2645198))
>> 		return ptep_clear_flush(vma, addr, ptep);
>> } else {
>> 	return ptep_get_and_clear(vma->vm_mm, addr, ptep);
>> }
> 
> Yes, this should work but avoid the 'else' when you have a return, so
> something like:
> 
> 	if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198) &&
> 	    cpus_have_const_cap(ARM64_WORKAROUND_2645198) &&
> 	    pte_user_exec(READ_ONCE(*ptep)))
> 		return ptep_clear_flush(vma, addr, ptep);
> 
> 	return ptep_get_and_clear(vma->vm_mm, addr, ptep);

Right, realized that later.

> 
> 
>>> huge_ptep_clear_flush())? They return the pte and do the TLBI.
>>
>> huge_ptep_modify_prot_start -
>>
>> if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) {
>> 	if (pte_user_exec(READ_ONCE(*ptep)) && cpus_have_const_cap(ARM64_WORKAROUND_2645198))
>> 		return huge_ptep_clear_flush(vma, addr, ptep);
>> } else {
>> 	return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
>> }
>>
>> pte_user_exec(READ_ONCE(*ptep) should identify an user exec mapping even though
>> ptep represents a cont PTE/PMD huge page ? OR should huge_ptep_get() helper be
>> used instead ?
> 
> This should work as a shortcut. The contiguous ptes should all be the
> same, so it's sufficient to check one of them.

Sure, will read the first one.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ