src/worker.cc
// C implementation of Adler memory copy, with memory tagging.
C implementation of Adler memory copy, with memory tagging.
C implementation of Adler memory copy with memory tagging .
bool WorkerThread::AdlerAddrMemcpyC(uint64 *dstmem64,
                                    uint64 *srcmem64,
                                    unsigned int size_in_bytes,
                                    AdlerChecksum *checksum,
                                    struct page_entry *pe) {
  datacast_t data;
  datacast_t dstdata;
  unsigned int count = size_in_bytes / sizeof(data);
  if (count > ((1U) << 19)) {
    return false;
  }
  uint64 a1 = 1;
  uint64 a2 = 1;
  uint64 b1 = 0;
  uint64 b2 = 0;
  class Pattern *pattern = pe->pattern;
  unsigned int i = 0;
  while (i < count) {
    if ((i & 0x7) == 0) {
      data.l64 = srcmem64[i];
      dstdata.l64 = dstmem64[i];
      uint64 src_tag = addr_to_tag(&srcmem64[i]);
      uint64 dst_tag = addr_to_tag(&dstmem64[i]);
      if (data.l64 != src_tag)
        ReportTagError(&srcmem64[i], data.l64, src_tag);
      if (dstdata.l64 != dst_tag)
        ReportTagError(&dstmem64[i], dstdata.l64, dst_tag);
      data.l32.l = pattern->pattern(i << 1);
      data.l32.h = pattern->pattern((i << 1) + 1);
      a1 = a1 + data.l32.l;
      b1 = b1 + a1;
      a1 = a1 + data.l32.h;
      b1 = b1 + a1;
      data.l64  = dst_tag;
      dstmem64[i] = data.l64;
    } else {
      data.l64 = srcmem64[i];
      a1 = a1 + data.l32.l;
      b1 = b1 + a1;
      a1 = a1 + data.l32.h;
      b1 = b1 + a1;
      dstmem64[i] = data.l64;
    }
    i++;
    data.l64 = srcmem64[i];
    a2 = a2 + data.l32.l;
    b2 = b2 + a2;
    a2 = a2 + data.l32.h;
    b2 = b2 + a2;
    dstmem64[i] = data.l64;
    i++;
  }
  checksum->Set(a1, a2, b1, b2);
  return true;
}
bool WorkerThread :: AdlerAddrMemcpyC ( uint64 * dstmem64 , uint64 * srcmem64 , unsigned int size_in_bytes , AdlerChecksum * checksum , struct page_entry * pe ) { datacast_t data ; datacast_t dstdata ; unsigned int count = size_in_bytes / sizeof ( data ) ; if ( count > ( ( 1U ) << 19 ) ) { return false ; } uint64 a1 = 1 ; uint64 a2 = 1 ; uint64 b1 = 0 ; uint64 b2 = 0 ; class Pattern * pattern = pe -> pattern ; unsigned int i = 0 ; while ( i < count ) { if ( ( i & 0x7 ) == 0 ) { data . l64 = srcmem64 [ i ] ; dstdata . l64 = dstmem64 [ i ] ; uint64 src_tag = addr_to_tag ( & srcmem64 [ i ] ) ; uint64 dst_tag = addr_to_tag ( & dstmem64 [ i ] ) ; if ( data . l64 != src_tag ) ReportTagError ( & srcmem64 [ i ] , data . l64 , src_tag ) ; if ( dstdata . l64 != dst_tag ) ReportTagError ( & dstmem64 [ i ] , dstdata . l64 , dst_tag ) ; data . l32 . l = pattern -> pattern ( i << 1 ) ; data . l32 . h = pattern -> pattern ( ( i << 1 ) + 1 ) ; a1 = a1 + data . l32 . l ; b1 = b1 + a1 ; a1 = a1 + data . l32 . h ; b1 = b1 + a1 ; data . l64 = dst_tag ; dstmem64 [ i ] = data . l64 ; } else { data . l64 = srcmem64 [ i ] ; a1 = a1 + data . l32 . l ; b1 = b1 + a1 ; a1 = a1 + data . l32 . h ; b1 = b1 + a1 ; dstmem64 [ i ] = data . l64 ; } i ++ ; data . l64 = srcmem64 [ i ] ; a2 = a2 + data . l32 . l ; b2 = b2 + a2 ; a2 = a2 + data . l32 . h ; b2 = b2 + a2 ; dstmem64 [ i ] = data . l64 ; i ++ ; } checksum -> Set ( a1 , a2 , b1 , b2 ) ; return true ; }
C implementation of Adler memory copy, with memory tagging.
C implementation of Adler memory copy with memory tagging .
// Use this data wrapper to access memory with 64bit read/write. // Size is too large, must be strictly less than 512 KB. // Process 64 bits at a time. // Detect if tags have been corrupted.