[PATCH] arm64: mte: Ensure the cleared tags are visible before setting the PTE

Vladimir Murzin vladimir.murzin at arm.com
Tue May 17 02:38:15 PDT 2022


On 5/17/22 10:30, Catalin Marinas wrote:
> On Tue, May 17, 2022 at 10:22:32AM +0100, Vladimir Murzin wrote:
>> On 5/13/22 11:08, Catalin Marinas wrote:
>>> @@ -72,10 +74,15 @@ void mte_sync_tags(pte_t old_pte, pte_t pte)
>>>  
>>>  	/* if PG_mte_tagged is set, tags have already been initialised */
>>>  	for (i = 0; i < nr_pages; i++, page++) {
>>> -		if (!test_and_set_bit(PG_mte_tagged, &page->flags))
>>> -			mte_sync_page_tags(page, old_pte, check_swap,
>>> -					   pte_is_tagged);
>>> +		if (!test_and_set_bit(PG_mte_tagged, &page->flags) &&
>>> +		    mte_sync_page_tags(page, old_pte, check_swap,
>>> +				       pte_is_tagged))
>>> +			updated = true;
>>>  	}
>>> +
>>> +	/* ensure the tags are visible before the PTE is set */
>>> +	if (updated)
>>> +		smp_wmb();
>>>  }
>>>  
>>>  int memcmp_pages(struct page *page1, struct page *page2)
>>
>> Tested-by: Vladimir Murzin <vladimir.murzin at arm.com>
> 
> Thanks Vladimir. Talking to Will earlier, I'll make the smp_wmb()
> unconditional, it's not worth the extra checks. I'll post the updated
> version soon but I won't add your tested-by as it's slightly different
> (or we add a Tested-old-version-by... ;)).
> 

You can carry on my Tested-by with unconditional smp_wmb() since it has
been tested in parallel to your patch ;)

Cheers
Vladimir



More information about the linux-arm-kernel mailing list