Re: [PATCH, RFC 51/62] iommu/vt-d: Support MKTME in DMA remapping

From: Peter Zijlstra
Date: Fri Jun 14 2019 - 08:09:17 EST


On Wed, May 08, 2019 at 05:44:11PM +0300, Kirill A. Shutemov wrote:
> @@ -603,7 +605,12 @@ static inline void dma_clear_pte(struct dma_pte *pte)
> static inline u64 dma_pte_addr(struct dma_pte *pte)
> {
> #ifdef CONFIG_64BIT
> - return pte->val & VTD_PAGE_MASK;

I don't know this code, but going by the below cmpxchg64, this wants to
be READ_ONCE().

> + u64 addr = pte->val;
> + addr &= VTD_PAGE_MASK;
> +#ifdef CONFIG_X86_INTEL_MKTME
> + addr &= ~mktme_keyid_mask;
> +#endif
> + return addr;
> #else
> /* Must have a full atomic 64-bit read */
> return __cmpxchg64(&pte->val, 0ULL, 0ULL) & VTD_PAGE_MASK;
> --
> 2.20.1
>