From 184fefbb3bbaf93bccd65e73d3d08c7decc16e8a Mon Sep 17 00:00:00 2001 From: Andreas Sandberg Date: Tue, 23 Dec 2014 09:31:17 -0500 Subject: arm: Raise an alignment fault if a PC has illegal alignment We currently don't handle unaligned PCs correctly. There is one check for unaligned PCs in the TLB when running in aarch64 mode, but this check does not cover cases where the CPU does not do a TLB lookup when decoding an instruction (e.g., a branch stays within the same cache line). Additionally, the Decoder class sometimes throws an assertion for unaligned PCs which breaks speculation. This changeset introduces a decoder fault bit field in the ExtMachInst structure. This field can be used to signal a decoder failure. If set, the decoder generates an internal gem5fault instruction instead of a normal instruction. This instruction in turns either panics (fault type PANIC), returns an PCAlignmentFault (fault type UNALIGNED, aarch64) or PrefetchAbort (fault type UNALIGNED, aarch32). The patch causes minor changes to the realview64 regressions, and a stats bump will follow. --- src/arch/arm/decoder.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/arch/arm/decoder.cc') diff --git a/src/arch/arm/decoder.cc b/src/arch/arm/decoder.cc index f57e340de..23fa89a3f 100644 --- a/src/arch/arm/decoder.cc +++ b/src/arch/arm/decoder.cc @@ -139,7 +139,7 @@ void Decoder::consumeBytes(int numBytes) { offset += numBytes; - assert(offset <= sizeof(MachInst)); + assert(offset <= sizeof(MachInst) || emi.decoderFault); if (offset == sizeof(MachInst)) outOfBytes = true; } @@ -154,6 +154,10 @@ Decoder::moreBytes(const PCState &pc, Addr fetchPC, MachInst inst) emi.fpscrLen = fpscrLen; emi.fpscrStride = fpscrStride; + const Addr alignment(pc.thumb() ? 0x1 : 0x3); + emi.decoderFault = static_cast( + pc.instAddr() & alignment ? DecoderFault::UNALIGNED : DecoderFault::OK); + outOfBytes = false; process(); } -- cgit v1.2.3