Re: [PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-19 Thread Lu Baolu
Hi Yonghyun, On 2020/2/20 8:12, Yonghyun Hwang wrote: Hello Baolu, Yes, pfn_to_dma_pte() doesn't put 0 for level. However, it's hard for me to get that without comment, which is the reason why I put a dummy "if" there. Anyway, what about the following code? static inline unsigned long offset_m

Re: [PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-19 Thread Yonghyun Hwang via iommu
Hello Baolu, Yes, pfn_to_dma_pte() doesn't put 0 for level. However, it's hard for me to get that without comment, which is the reason why I put a dummy "if" there. Anyway, what about the following code? static inline unsigned long offset_mask(int level) { return BIT_MASK(level_to_offset_bits

Re: [PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-19 Thread Lu Baolu
Hi, On 2020/2/20 2:51, Yonghyun Hwang wrote: Hello Lu and Moritz, I think it's better to keep "if (level > 1)" because level_to_offset_bits() returns (unsigned int) -1 * LEVEL_STRIDE if level becomes 0. @level will never be 0 in this case. Best regards, baolu static inline unsigned int

[PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-19 Thread Yonghyun Hwang via iommu
intel_iommu_iova_to_phys() has a bug when it translates an IOVA for a huge page onto its corresponding physical address. This commit fixes the bug by accomodating the level of page entry for the IOVA and adds IOVA's lower address to the physical address. Signed-off-by: Yonghyun Hwang --- drivers

Re: [PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-19 Thread Yonghyun Hwang via iommu
Hello Lu and Moritz, I think it's better to keep "if (level > 1)" because level_to_offset_bits() returns (unsigned int) -1 * LEVEL_STRIDE if level becomes 0. static inline unsigned int level_to_offset_bits(int level) { return (level - 1) * LEVEL_STRIDE; } On Tue, Feb 18, 2020 at 8:42 PM Moritz

Re: [PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-18 Thread Moritz Fischer
Hi Baolu, Yonghyun On Wed, Feb 19, 2020 at 11:15:36AM +0800, Lu Baolu wrote: > Hi Yonghyun, > > Thanks for the patch. > > On 2020/2/19 6:23, Yonghyun Hwang wrote: > > intel_iommu_iova_to_phys() has a bug when it translates an IOVA for a huge > > page onto its corresponding physical address. This

Re: [PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-18 Thread Lu Baolu
Hi Yonghyun, Thanks for the patch. On 2020/2/19 6:23, Yonghyun Hwang wrote: intel_iommu_iova_to_phys() has a bug when it translates an IOVA for a huge page onto its corresponding physical address. This commit fixes the bug by accomodating the level of page entry for the IOVA and adds IOVA's low

[PATCH] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page

2020-02-18 Thread Yonghyun Hwang via iommu
intel_iommu_iova_to_phys() has a bug when it translates an IOVA for a huge page onto its corresponding physical address. This commit fixes the bug by accomodating the level of page entry for the IOVA and adds IOVA's lower address to the physical address. Signed-off-by: Yonghyun Hwang --- drivers