[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/41] ppc/pnv: Fail DMA access if page permissions are not correc
From: |
Cédric Le Goater |
Subject: |
[PULL 04/41] ppc/pnv: Fail DMA access if page permissions are not correct |
Date: |
Mon, 31 Jan 2022 12:07:34 +0100 |
From: Frederic Barrat <fbarrat@linux.ibm.com>
If an iommu page has wrong permissions, an error message is displayed,
but the access is allowed, which is odd. This patch fixes it.
Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20220121152350.381685-1-fbarrat@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/pci-host/pnv_phb3.c | 11 ++++++-----
hw/pci-host/pnv_phb4.c | 11 ++++++-----
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index 7fb35dc03147..a757f1a58ec8 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -816,18 +816,19 @@ static void pnv_phb3_translate_tve(PnvPhb3DMASpace *ds,
hwaddr addr,
}
/* We exit the loop with TCE being the final TCE */
- tce_mask = ~((1ull << tce_shift) - 1);
- tlb->iova = addr & tce_mask;
- tlb->translated_addr = tce & tce_mask;
- tlb->addr_mask = ~tce_mask;
- tlb->perm = tce & 3;
if ((is_write & !(tce & 2)) || ((!is_write) && !(tce & 1))) {
phb3_error(phb, "TCE access fault at 0x%"PRIx64, taddr);
phb3_error(phb, " xlate %"PRIx64":%c TVE=%"PRIx64, addr,
is_write ? 'W' : 'R', tve);
phb3_error(phb, " tta=%"PRIx64" lev=%d tts=%d tps=%d",
tta, lev, tts, tps);
+ return;
}
+ tce_mask = ~((1ull << tce_shift) - 1);
+ tlb->iova = addr & tce_mask;
+ tlb->translated_addr = tce & tce_mask;
+ tlb->addr_mask = ~tce_mask;
+ tlb->perm = tce & 3;
}
}
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index a78add75b043..ee56377c02be 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -1291,18 +1291,19 @@ static void pnv_phb4_translate_tve(PnvPhb4DMASpace *ds,
hwaddr addr,
}
/* We exit the loop with TCE being the final TCE */
- tce_mask = ~((1ull << tce_shift) - 1);
- tlb->iova = addr & tce_mask;
- tlb->translated_addr = tce & tce_mask;
- tlb->addr_mask = ~tce_mask;
- tlb->perm = tce & 3;
if ((is_write & !(tce & 2)) || ((!is_write) && !(tce & 1))) {
phb_error(ds->phb, "TCE access fault at 0x%"PRIx64, taddr);
phb_error(ds->phb, " xlate %"PRIx64":%c TVE=%"PRIx64, addr,
is_write ? 'W' : 'R', tve);
phb_error(ds->phb, " tta=%"PRIx64" lev=%d tts=%d tps=%d",
tta, lev, tts, tps);
+ return;
}
+ tce_mask = ~((1ull << tce_shift) - 1);
+ tlb->iova = addr & tce_mask;
+ tlb->translated_addr = tce & tce_mask;
+ tlb->addr_mask = ~tce_mask;
+ tlb->perm = tce & 3;
}
}
--
2.34.1
- [PULL 31/41] target/ppc: books: External interrupt cleanup, (continued)
- [PULL 31/41] target/ppc: books: External interrupt cleanup, Cédric Le Goater, 2022/01/31
- [PULL 28/41] target/ppc: Introduce powerpc_excp_books, Cédric Le Goater, 2022/01/31
- [PULL 39/41] target/ppc: 74xx: System Reset interrupt cleanup, Cédric Le Goater, 2022/01/31
- [PULL 15/41] target/ppc: 405: Add missing MSR_ME bit, Cédric Le Goater, 2022/01/31
- [PULL 37/41] target/ppc: 74xx: Program exception cleanup, Cédric Le Goater, 2022/01/31
- [PULL 17/41] target/ppc: Simplify powerpc_excp_40x, Cédric Le Goater, 2022/01/31
- [PULL 22/41] target/ppc: 405: Alignment exception cleanup, Cédric Le Goater, 2022/01/31
- [PULL 21/41] target/ppc: 405: System call exception cleanup, Cédric Le Goater, 2022/01/31
- [PULL 34/41] target/ppc: Simplify powerpc_excp_74xx, Cédric Le Goater, 2022/01/31
- [PULL 09/41] spapr.c: check bus != NULL in spapr_get_fw_dev_path(), Cédric Le Goater, 2022/01/31
- [PULL 04/41] ppc/pnv: Fail DMA access if page permissions are not correct,
Cédric Le Goater <=
- [PULL 03/41] target/ppc/mmu_common: Fix SRR1/MSR error code on Book-E, Cédric Le Goater, 2022/01/31
- [PULL 08/41] target/ppc: fix 'skip KVM' cond in cpu_interrupt_exittb(), Cédric Le Goater, 2022/01/31
- [PULL 20/41] target/ppc: 405: External exception cleanup, Cédric Le Goater, 2022/01/31
- [PULL 13/41] ppc/ppc405: Fix TLB flushing, Cédric Le Goater, 2022/01/31
- Re: [PULL 00/41] ppc queue, Peter Maydell, 2022/01/31