summaryrefslogtreecommitdiffstats
path: root/target-ppc/translate.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2016-04-14 17:14:52 +0200
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 20:03:49 -0600
commit84bafa0e4622c3f83f0bfacdf80842f8f444480b (patch)
tree20952530db11b6cfbc651c98f2f8dd45a36e636b /target-ppc/translate.c
parente9b927e8ae87dd3df46a81687c3fe4e710ab70c7 (diff)
downloadhqemu-84bafa0e4622c3f83f0bfacdf80842f8f444480b.zip
hqemu-84bafa0e4622c3f83f0bfacdf80842f8f444480b.tar.gz
ppc: Fix the range check in the LSWI instruction
There are two issues: First, the number of registers that are used has to be calculated with "(nb + 3) / 4" (i.e. round always up, not down). Second, the "start <= ra && (start + nr - 32) > ra" condition for the wrap-around case is wrong: It has to be tested with "||" instead of "&&". Since we can reuse this check later for the LSWX instruction, let's place the fixed code into a helper function, too. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target-ppc/translate.c')
-rw-r--r--target-ppc/translate.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index e229723..30b8953 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -3235,10 +3235,8 @@ static void gen_lswi(DisasContext *ctx)
if (nb == 0)
nb = 32;
- nr = nb / 4;
- if (unlikely(((start + nr) > 32 &&
- start <= ra && (start + nr - 32) > ra) ||
- ((start + nr) <= 32 && start <= ra && (start + nr) > ra))) {
+ nr = (nb + 3) / 4;
+ if (unlikely(lsw_reg_in_range(start, nr, ra))) {
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX);
return;
}
OpenPOWER on IntegriCloud