aboutsummaryrefslogtreecommitdiff
path: root/target-ppc/cpu.h
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2016-04-14 17:14:52 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2016-04-18 15:14:38 +1000
commitafbee7128c2399b6fca7b744ee560e3a1851118e (patch)
tree4ff672e1ae2b7a74012571f5efd1fd84f0195030 /target-ppc/cpu.h
parentc7b45f12828c1ba7105dbc029c63d7de68eaa91c (diff)
downloadqemu-afbee7128c2399b6fca7b744ee560e3a1851118e.zip
qemu-afbee7128c2399b6fca7b744ee560e3a1851118e.tar.gz
qemu-afbee7128c2399b6fca7b744ee560e3a1851118e.tar.bz2
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/cpu.h')
-rw-r--r--target-ppc/cpu.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 9d4e43c..5282533 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -2415,6 +2415,16 @@ static inline bool msr_is_64bit(CPUPPCState *env, target_ulong msr)
return msr & (1ULL << MSR_SF);
}
+/**
+ * Check whether register rx is in the range between start and
+ * start + nregs (as needed by the LSWX and LSWI instructions)
+ */
+static inline bool lsw_reg_in_range(int start, int nregs, int rx)
+{
+ return (start + nregs <= 32 && rx >= start && rx < start + nregs) ||
+ (start + nregs > 32 && (rx >= start || rx < start + nregs - 32));
+}
+
extern void (*cpu_ppc_hypercall)(PowerPCCPU *);
#include "exec/exec-all.h"