mem: Fix guest corruption when caches handle uncacheable accesses
[gem5.git] / src / mem / protocol / MOESI_hammer-msg.sm
1 /*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * AMD's contributions to the MOESI hammer protocol do not constitute an
29 * endorsement of its similarity to any AMD products.
30 */
31
32 // CoherenceRequestType
33 enumeration(CoherenceRequestType, desc="...") {
34 GETX, desc="Get eXclusive";
35 GETS, desc="Get Shared";
36 MERGED_GETS, desc="Get Shared";
37 PUT, desc="Put Ownership";
38 WB_ACK, desc="Writeback ack";
39 WB_NACK, desc="Writeback neg. ack";
40 PUTF, desc="PUT on a Flush";
41 GETF, desc="Issue exclusive for Flushing";
42 BLOCK_ACK, desc="Dir Block ack";
43 INV, desc="Invalidate";
44 }
45
46 // CoherenceResponseType
47 enumeration(CoherenceResponseType, desc="...") {
48 ACK, desc="ACKnowledgment, responder does not have a copy";
49 ACK_SHARED, desc="ACKnowledgment, responder has a shared copy";
50 DATA, desc="Data, responder does not have a copy";
51 DATA_SHARED, desc="Data, responder has a shared copy";
52 DATA_EXCLUSIVE, desc="Data, responder was exclusive, gave us a copy, and they went to invalid";
53 WB_CLEAN, desc="Clean writeback";
54 WB_DIRTY, desc="Dirty writeback";
55 WB_EXCLUSIVE_CLEAN, desc="Clean writeback of exclusive data";
56 WB_EXCLUSIVE_DIRTY, desc="Dirty writeback of exclusive data";
57 UNBLOCK, desc="Unblock for writeback";
58 UNBLOCKS, desc="Unblock now in S";
59 UNBLOCKM, desc="Unblock now in M/O/E";
60 NULL, desc="Null value";
61 }
62
63 // TriggerType
64 enumeration(TriggerType, desc="...") {
65 L2_to_L1, desc="L2 to L1 transfer";
66 ALL_ACKS, desc="See corresponding event";
67 ALL_ACKS_OWNER_EXISTS,desc="See corresponding event";
68 ALL_ACKS_NO_SHARERS, desc="See corresponding event";
69 ALL_UNBLOCKS, desc="all unblockS received";
70 }
71
72 // TriggerMsg
73 structure(TriggerMsg, desc="...", interface="Message") {
74 Address Address, desc="Physical address for this request";
75 TriggerType Type, desc="Type of trigger";
76
77 bool functionalRead(Packet *pkt) {
78 // Trigger messages do not hold any data!
79 return false;
80 }
81
82 bool functionalWrite(Packet *pkt) {
83 // Trigger messages do not hold any data!
84 return false;
85 }
86 }
87
88 // RequestMsg (and also forwarded requests)
89 structure(RequestMsg, desc="...", interface="NetworkMessage") {
90 Address Address, desc="Physical address for this request";
91 CoherenceRequestType Type, desc="Type of request (GetS, GetX, PutX, etc)";
92 MachineID Requestor, desc="Node who initiated the request";
93 NetDest MergedRequestors, desc="Merge set of read requestors";
94 NetDest Destination, desc="Multicast destination mask";
95 MessageSizeType MessageSize, desc="size category of the message";
96 bool DirectedProbe, default="false", desc="probe filter directed probe";
97 Time InitialRequestTime, default="0", desc="time the initial requests was sent from the L1Cache";
98 Time ForwardRequestTime, default="0", desc="time the dir forwarded the request";
99 int SilentAcks, default="0", desc="silent acks from the full-bit directory";
100
101 bool functionalRead(Packet *pkt) {
102 // Request messages do not hold any data
103 return false;
104 }
105
106 bool functionalWrite(Packet *pkt) {
107 // Request messages do not hold any data
108 return false;
109 }
110 }
111
112 // ResponseMsg (and also unblock requests)
113 structure(ResponseMsg, desc="...", interface="NetworkMessage") {
114 Address Address, desc="Physical address for this request";
115 CoherenceResponseType Type, desc="Type of response (Ack, Data, etc)";
116 MachineID Sender, desc="Node who sent the data";
117 MachineID CurOwner, desc="current owner of the block, used for UnblockS responses";
118 NetDest Destination, desc="Node to whom the data is sent";
119 DataBlock DataBlk, desc="data for the cache line";
120 bool Dirty, desc="Is the data dirty (different than memory)?";
121 int Acks, default="0", desc="How many messages this counts as";
122 MessageSizeType MessageSize, desc="size category of the message";
123 Time InitialRequestTime, default="0", desc="time the initial requests was sent from the L1Cache";
124 Time ForwardRequestTime, default="0", desc="time the dir forwarded the request";
125 int SilentAcks, default="0", desc="silent acks from the full-bit directory";
126
127 bool functionalRead(Packet *pkt) {
128 // The check below ensures that data is read only from messages that
129 // actually hold data.
130 if (Type == CoherenceResponseType:DATA ||
131 Type == CoherenceResponseType:DATA_SHARED ||
132 Type == CoherenceResponseType:DATA_EXCLUSIVE ||
133 Type == CoherenceResponseType:WB_DIRTY ||
134 Type == CoherenceResponseType:WB_EXCLUSIVE_DIRTY) {
135 return testAndRead(Address, DataBlk, pkt);
136 }
137
138 return false;
139 }
140
141 bool functionalWrite(Packet *pkt) {
142 // Message type does not matter since all messages are written.
143 // If a protocol reads data from a packet that is not supposed
144 // to hold the data, then the fault lies with the protocol.
145 return testAndWrite(Address, DataBlk, pkt);
146 }
147 }
148
149 enumeration(DMARequestType, desc="...", default="DMARequestType_NULL") {
150 READ, desc="Memory Read";
151 WRITE, desc="Memory Write";
152 NULL, desc="Invalid";
153 }
154
155 enumeration(DMAResponseType, desc="...", default="DMAResponseType_NULL") {
156 DATA, desc="DATA read";
157 ACK, desc="ACK write";
158 NULL, desc="Invalid";
159 }
160
161 structure(DMARequestMsg, desc="...", interface="NetworkMessage") {
162 DMARequestType Type, desc="Request type (read/write)";
163 Address PhysicalAddress, desc="Physical address for this request";
164 Address LineAddress, desc="Line address for this request";
165 MachineID Requestor, desc="Node who initiated the request";
166 NetDest Destination, desc="Destination";
167 DataBlock DataBlk, desc="DataBlk attached to this request";
168 int Len, desc="The length of the request";
169 MessageSizeType MessageSize, desc="size category of the message";
170
171 bool functionalRead(Packet *pkt) {
172 return testAndRead(LineAddress, DataBlk, pkt);
173 }
174
175 bool functionalWrite(Packet *pkt) {
176 return testAndWrite(LineAddress, DataBlk, pkt);
177 }
178 }
179
180 structure(DMAResponseMsg, desc="...", interface="NetworkMessage") {
181 DMAResponseType Type, desc="Response type (DATA/ACK)";
182 Address PhysicalAddress, desc="Physical address for this request";
183 Address LineAddress, desc="Line address for this request";
184 NetDest Destination, desc="Destination";
185 DataBlock DataBlk, desc="DataBlk attached to this request";
186 MessageSizeType MessageSize, desc="size category of the message";
187
188 bool functionalRead(Packet *pkt) {
189 return testAndRead(LineAddress, DataBlk, pkt);
190 }
191
192 bool functionalWrite(Packet *pkt) {
193 return testAndWrite(LineAddress, DataBlk, pkt);
194 }
195 }