From 69d419f31383ac7801e1debb62d5bbf7cb899e3c Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Mon, 7 Jan 2013 13:05:33 -0500 Subject: o3: Fix issue with LLSC ordering and speculation This patch unlocks the cpu-local monitor when the CPU sees a snoop to a locked address. Previously we relied on the cache to handle the locking for us, however some users on the gem5 mailing list reported a case where the cpu speculatively executes a ll operation after a pending sc operation in the pipeline and that makes the cache monitor valid. This should handle that case by invaliding the local monitor. --- src/arch/arm/locked_mem.hh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/arch/arm') diff --git a/src/arch/arm/locked_mem.hh b/src/arch/arm/locked_mem.hh index f95542bb0..37973ff98 100644 --- a/src/arch/arm/locked_mem.hh +++ b/src/arch/arm/locked_mem.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2012 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2006 The Regents of The University of Michigan * Copyright (c) 2007-2008 The Florida State University * All rights reserved. @@ -41,10 +53,27 @@ */ #include "arch/arm/miscregs.hh" +#include "mem/packet.hh" #include "mem/request.hh" namespace ArmISA { +template +inline void +handleLockedSnoop(XC *xc, PacketPtr pkt, Addr cacheBlockMask) +{ + if (!xc->readMiscReg(MISCREG_LOCKFLAG)) + return; + + Addr locked_addr = xc->readMiscReg(MISCREG_LOCKADDR) & cacheBlockMask; + Addr snoop_addr = pkt->getAddr(); + + assert((cacheBlockMask & snoop_addr) == snoop_addr); + + if (locked_addr == snoop_addr) + xc->setMiscReg(MISCREG_LOCKFLAG, false); +} + template inline void handleLockedRead(XC *xc, Request *req) -- cgit v1.2.3