cpu: Explicitly define cache_line_size -> 64-bit unsigned int (#329)
While it's plausible to define the cache_line_size as a 32-bit unsigned int, the use of cache_line_size is way out of its original scope. cache_line_size has been used to produce an address mask, which masking out the offset bits from an address. For example, [1], [2], [3], and [4]. However, since the cache_line_size is an "unsigned int", the type of the value is not guaranteed to be 64-bit long. Subsequently, the bit twiddling hacks in [1], [2], [3], and [4] produce 32-bit mask, i.e., 0x00000000FFFFFFC0. This behavior at least caused a problem in LLSC in RISC-V [5], where the load reservation (LR) relies on the mask to produce the cache block address. Two distinct 64-bit addresses can be mapped to the same cache block using the above mask. This patch explicitly defines cache_line_size as a 64-bit unsigned int so the cache block mask can be produced correctly for 64-bit addresses. [1]3bdcfd6f7a/src/cpu/simple/atomic.hh (L147)[2]3bdcfd6f7a/src/cpu/simple/timing.hh (L224)[3]3bdcfd6f7a/src/cpu/o3/lsq_unit.cc (L241)[4]3bdcfd6f7a/src/cpu/minor/lsq.cc (L1425)[5]3bdcfd6f7a/src/arch/riscv/isa.cc (L787)
This commit is contained in:
@@ -187,7 +187,7 @@ class DmaPort : public RequestPort, public Drainable
|
||||
/** Default substreamId */
|
||||
const uint32_t defaultSSid;
|
||||
|
||||
const int cacheLineSize;
|
||||
const Addr cacheLineSize;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -257,7 +257,7 @@ class DmaDevice : public PioDevice
|
||||
|
||||
void init() override;
|
||||
|
||||
unsigned int cacheBlockSize() const { return sys->cacheLineSize(); }
|
||||
Addr cacheBlockSize() const { return sys->cacheLineSize(); }
|
||||
|
||||
Port &getPort(const std::string &if_name,
|
||||
PortID idx=InvalidPortID) override;
|
||||
@@ -526,7 +526,7 @@ class DmaReadFifo : public Drainable, public Serializable
|
||||
|
||||
DmaPort &port;
|
||||
|
||||
const int cacheLineSize;
|
||||
const Addr cacheLineSize;
|
||||
|
||||
private:
|
||||
class DmaDoneEvent : public Event
|
||||
|
||||
Reference in New Issue
Block a user