From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12126 invoked by alias); 20 Jul 2004 17:17:48 -0000 Mailing-List: contact sid-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: sid-owner@sources.redhat.com Received: (qmail 12109 invoked from network); 20 Jul 2004 17:17:46 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 20 Jul 2004 17:17:46 -0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx1.redhat.com (8.12.10/8.12.10) with ESMTP id i6KHHke1010075 for ; Tue, 20 Jul 2004 13:17:46 -0400 Received: from potter.sfbay.redhat.com (potter.sfbay.redhat.com [172.16.27.15]) by int-mx2.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i6KHHjH27027 for ; Tue, 20 Jul 2004 13:17:45 -0400 Received: from redhat.com (vpn26-10.sfbay.redhat.com [172.16.26.10]) by potter.sfbay.redhat.com (8.11.6/8.11.6) with ESMTP id i6KHHiL14312 for ; Tue, 20 Jul 2004 10:17:44 -0700 Message-ID: <40FD5327.1040600@redhat.com> Date: Tue, 20 Jul 2004 17:17:00 -0000 From: Dave Brolley User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) MIME-Version: 1.0 To: sid@sources.redhat.com Subject: [patch] Checking for valid cache lines Content-Type: multipart/mixed; boundary="------------020809020303040504050109" X-SW-Source: 2004-q3/txt/msg00009.txt.bz2 This is a multi-part message in MIME format. --------------020809020303040504050109 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 272 Hi, I've committed the attached patch which adds some checks to make sure cache lines are valid before they are returned as a hit or flushed. The patch also move a call to 'addr_to_tag' past a possible return point to the place where the result is first needed. Dave --------------020809020303040504050109 Content-Type: text/plain; name="sid-cache.ChangeLog" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-cache.ChangeLog" Content-length: 345 2004-07-20 Dave Brolley * cacheutil.cxx (find): Make sure cache line is valid before returning it. * cache.cxx (write_any): Move call to addr_to_tag to a later point when the result is actually needed. Make sure cache line is valid before flushing it. (read_any): Make sure cache line is valid before flushing it. --------------020809020303040504050109 Content-Type: text/plain; name="sid-cache.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sid-cache.patch.txt" Content-length: 2908 Index: sid/component/cache/cache.cxx =================================================================== RCS file: /cvs/src/src/sid/component/cache/cache.cxx,v retrieving revision 1.18 diff -c -p -r1.18 cache.cxx *** sid/component/cache/cache.cxx 1 Jul 2004 16:55:09 -0000 1.18 --- sid/component/cache/cache.cxx 20 Jul 2004 17:07:13 -0000 *************** cache_component::write_any (host_int_4 a *** 180,186 **** if (LIKELY (collect_p)) stats.writes++; - cache_tag tag = acache.addr_to_tag (addr); if (UNLIKELY (addr % sizeof (data) != 0)) { if (LIKELY (collect_p)) --- 180,185 ---- *************** cache_component::write_any (host_int_4 a *** 191,196 **** --- 190,196 ---- if (UNLIKELY (addr % line_size + sizeof (data) > line_size)) return bus::misaligned; + cache_tag tag = acache.addr_to_tag (addr); cache_line* line = acache.find (tag); if (LIKELY (line)) { *************** cache_component::write_any (host_int_4 a *** 215,221 **** if (! write_through_p) { ! if (expelled_line->dirty_p ()) { // flush a dirty line being replaced if ((st = write_line (*expelled_line)) != bus::ok) --- 215,221 ---- if (! write_through_p) { ! if (expelled_line->valid_p () && expelled_line->dirty_p ()) { // flush a dirty line being replaced if ((st = write_line (*expelled_line)) != bus::ok) *************** cache_component::read_any (host_int_4 ad *** 291,297 **** cache_line *expelled_line = acache.expell_line (tag); assert (expelled_line); ! if (expelled_line->dirty_p ()) { // flush a dirty line being replaced if ((st = write_line (*expelled_line)) != bus::ok) --- 291,297 ---- cache_line *expelled_line = acache.expell_line (tag); assert (expelled_line); ! if (expelled_line->valid_p () && expelled_line->dirty_p ()) { // flush a dirty line being replaced if ((st = write_line (*expelled_line)) != bus::ok) Index: sid/component/cache/cacheutil.cxx =================================================================== RCS file: /cvs/src/src/sid/component/cache/cacheutil.cxx,v retrieving revision 1.9 diff -c -p -r1.9 cacheutil.cxx *** sid/component/cache/cacheutil.cxx 10 May 2004 21:51:10 -0000 1.9 --- sid/component/cache/cacheutil.cxx 20 Jul 2004 17:07:13 -0000 *************** cache_set::find (const cache_tag& tag) *** 173,179 **** // order of associativity will be small. for (const_iterator_t it = lines.begin (); it != lines.end (); it++) ! if (tag == *(*it)) { replacer.update (*this, *(*it)); return *it; --- 173,179 ---- // order of associativity will be small. for (const_iterator_t it = lines.begin (); it != lines.end (); it++) ! if (tag == *(*it) && (*it)->valid_p ()) { replacer.update (*this, *(*it)); return *it; --------------020809020303040504050109--