aboutsummaryrefslogtreecommitdiff
path: root/target/ppc
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2022-01-04 07:55:34 +0100
committerCédric Le Goater <clg@kaod.org>2022-01-04 07:55:34 +0100
commit9b4eaee4d47c912eb1449953ba3258f11600153a (patch)
treea149fb85a069ab7edae408230d8f7af788a82165 /target/ppc
parent932de569708e59eb74c6c56800a4eb8d764cc97d (diff)
downloadqemu-9b4eaee4d47c912eb1449953ba3258f11600153a.zip
qemu-9b4eaee4d47c912eb1449953ba3258f11600153a.tar.gz
qemu-9b4eaee4d47c912eb1449953ba3258f11600153a.tar.bz2
target/ppc: Check effective address validity
For Radix translation, the EA range is 64-bits. when EA(2:11) are nonzero, a segment interrupt should occur. Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com> Message-Id: <20211231073122.3183583-1-clg@kaod.org> Signed-off-by: Cédric Le Goater <clg@kaod.org>
Diffstat (limited to 'target/ppc')
-rw-r--r--target/ppc/mmu-radix64.c5
-rw-r--r--target/ppc/mmu-radix64.h1
2 files changed, 6 insertions, 0 deletions
diff --git a/target/ppc/mmu-radix64.c b/target/ppc/mmu-radix64.c
index d10ae00..040c055 100644
--- a/target/ppc/mmu-radix64.c
+++ b/target/ppc/mmu-radix64.c
@@ -32,6 +32,11 @@ static bool ppc_radix64_get_fully_qualified_addr(const CPUPPCState *env,
vaddr eaddr,
uint64_t *lpid, uint64_t *pid)
{
+ /* When EA(2:11) are nonzero, raise a segment interrupt */
+ if (eaddr & ~R_EADDR_VALID_MASK) {
+ return false;
+ }
+
if (msr_hv) { /* MSR[HV] -> Hypervisor/bare metal */
switch (eaddr & R_EADDR_QUADRANT) {
case R_EADDR_QUADRANT0:
diff --git a/target/ppc/mmu-radix64.h b/target/ppc/mmu-radix64.h
index b70357c..4c768aa 100644
--- a/target/ppc/mmu-radix64.h
+++ b/target/ppc/mmu-radix64.h
@@ -5,6 +5,7 @@
/* Radix Quadrants */
#define R_EADDR_MASK 0x3FFFFFFFFFFFFFFF
+#define R_EADDR_VALID_MASK 0xC00FFFFFFFFFFFFF
#define R_EADDR_QUADRANT 0xC000000000000000
#define R_EADDR_QUADRANT0 0x0000000000000000
#define R_EADDR_QUADRANT1 0x4000000000000000