From: Kunkun Jiang jiangkunkun@huawei.com
virt inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I61SPO CVE: NA
--------------------------------
This reverts commit 524f1339c8a5eba5cc59161679f643f01edd89ec.
Signed-off-by: Kunkun Jiang jiangkunkun@huawei.com Reviewed-by: Keqian Zhu zhukeqian1@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- drivers/iommu/io-pgtable-arm.c | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 34f6366dcc6c..2740a35fe714 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -159,23 +159,6 @@ static inline bool iopte_leaf(arm_lpae_iopte pte, int lvl, return iopte_type(pte, lvl) == ARM_LPAE_PTE_TYPE_BLOCK; }
-static inline bool arm_lpae_pte_writable(struct arm_lpae_io_pgtable *data, - arm_lpae_iopte pte, int lvl) -{ - if (iopte_leaf(pte, lvl, data->iop.fmt)) { - if (data->iop.fmt == ARM_64_LPAE_S1 || - data->iop.fmt == ARM_32_LPAE_S1) { - if (!(pte & ARM_LPAE_PTE_AP_RDONLY)) - return true; - } else { - if (pte & ARM_LPAE_PTE_HAP_WRITE) - return true; - } - } - - return false; -} - static arm_lpae_iopte paddr_to_iopte(phys_addr_t paddr, struct arm_lpae_io_pgtable *data) { @@ -769,7 +752,7 @@ static size_t __arm_lpae_split_block(struct arm_lpae_io_pgtable *data, if (size == ARM_LPAE_BLOCK_SIZE(lvl, data)) { if (iopte_leaf(pte, lvl, iop->fmt)) { if (lvl == (ARM_LPAE_MAX_LEVELS - 1) || - !arm_lpae_pte_writable(data, pte, lvl)) + (pte & ARM_LPAE_PTE_AP_RDONLY)) return size;
/* We find a writable block, split it. */ @@ -923,7 +906,7 @@ static int __arm_lpae_sync_dirty_log(struct arm_lpae_io_pgtable *data,
if (size == ARM_LPAE_BLOCK_SIZE(lvl, data)) { if (iopte_leaf(pte, lvl, iop->fmt)) { - if (!arm_lpae_pte_writable(data, pte, lvl)) + if (pte & ARM_LPAE_PTE_AP_RDONLY) return 0;
/* It is writable, set the bitmap */ @@ -944,7 +927,7 @@ static int __arm_lpae_sync_dirty_log(struct arm_lpae_io_pgtable *data, } return 0; } else if (iopte_leaf(pte, lvl, iop->fmt)) { - if (!arm_lpae_pte_writable(data, pte, lvl)) + if (pte & ARM_LPAE_PTE_AP_RDONLY) return 0;
/* Though the size is too small, also set bitmap */ @@ -1011,7 +994,7 @@ static int __arm_lpae_clear_dirty_log(struct arm_lpae_io_pgtable *data,
if (size == ARM_LPAE_BLOCK_SIZE(lvl, data)) { if (iopte_leaf(pte, lvl, iop->fmt)) { - if (!arm_lpae_pte_writable(data, pte, lvl)) + if (pte & ARM_LPAE_PTE_AP_RDONLY) return 0;
/* Ensure all corresponding bits are set */ @@ -1023,11 +1006,7 @@ static int __arm_lpae_clear_dirty_log(struct arm_lpae_io_pgtable *data, }
/* Race does not exist */ - if ((data->iop.fmt == ARM_64_LPAE_S1) || - (data->iop.fmt == ARM_32_LPAE_S1)) - pte |= ARM_LPAE_PTE_AP_RDONLY; - else - pte &= ~ARM_LPAE_PTE_HAP_WRITE; + pte |= ARM_LPAE_PTE_AP_RDONLY; __arm_lpae_set_pte(ptep, pte, &iop->cfg); return 0; } @@ -1044,7 +1023,7 @@ static int __arm_lpae_clear_dirty_log(struct arm_lpae_io_pgtable *data, return 0; } else if (iopte_leaf(pte, lvl, iop->fmt)) { /* Though the size is too small, it is already clean */ - if (!arm_lpae_pte_writable(data, pte, lvl)) + if (pte & ARM_LPAE_PTE_AP_RDONLY) return 0;
return -EINVAL;