Browse Source

reduce sig_len constraint to 4 bytes (#569)

* reduce sig_len constraint to 4 bytes

Spike currently asserts that the signature length should always be a multiple of 16-bytes. However, the compliance suite has agreed to upon the signature being a multiple ot 4-bytes. This prevents some of the tests to run on spike since it fails the assertion.

The proposed change fixes this issue and reduces the assertion to 4 bytes.

* Added size argument to htif arguments and zero padding for signature output. Defaultline size-16.

* Modified type of line_size to unsigned.

* Renamed size to granularity.

* Rename granularity to signature-granularity.

Co-authored-by: dracarys99 <spawan1999@gmail.com>
pull/573/head
Neel Gala 6 years ago
committed by GitHub
parent
commit
036aacbeb2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      fesvr/htif.cc
  2. 4
      fesvr/htif.h

22
fesvr/htif.cc

@ -64,7 +64,8 @@ htif_t::htif_t(const std::vector<std::string>& args) : htif_t()
for (unsigned int i = 0; i < args.size(); i++) { for (unsigned int i = 0; i < args.size(); i++) {
argv[i+1] = (char *) args[i].c_str(); argv[i+1] = (char *) args[i].c_str();
} }
//Set line size as 16 by default.
line_size = 16;
parse_arguments(argc, argv); parse_arguments(argc, argv);
register_devices(); register_devices();
} }
@ -174,12 +175,13 @@ void htif_t::stop()
assert(sigs && "can't open signature file!"); assert(sigs && "can't open signature file!");
sigs << std::setfill('0') << std::hex; sigs << std::setfill('0') << std::hex;
const addr_t incr = 16; for (addr_t i = 0; i < sig_len; i += line_size)
assert(sig_len % incr == 0);
for (addr_t i = 0; i < sig_len; i += incr)
{ {
for (addr_t j = incr; j > 0; j--) for (addr_t j = line_size; j > 0; j--)
sigs << std::setw(2) << (uint16_t)buf[i+j-1]; if (i+j < sig_len)
sigs << std::setw(2) << (uint16_t)buf[i+j-1];
else
sigs << std::setw(2) << (uint16_t)0;
sigs << '\n'; sigs << '\n';
} }
@ -275,6 +277,10 @@ void htif_t::parse_arguments(int argc, char ** argv)
break; break;
case HTIF_LONG_OPTIONS_OPTIND + 4: case HTIF_LONG_OPTIONS_OPTIND + 4:
payloads.push_back(optarg); payloads.push_back(optarg);
break;
case HTIF_LONG_OPTIONS_OPTIND + 5:
line_size = atoi(optarg);
break; break;
case '?': case '?':
if (!opterr) if (!opterr)
@ -310,6 +316,10 @@ void htif_t::parse_arguments(int argc, char ** argv)
c = HTIF_LONG_OPTIONS_OPTIND + 4; c = HTIF_LONG_OPTIONS_OPTIND + 4;
optarg = optarg + 9; optarg = optarg + 9;
} }
else if(arg.find("+signature-granularity=")==0){
c = HTIF_LONG_OPTIONS_OPTIND + 5;
optarg = optarg + 23;
}
else if (arg.find("+permissive-off") == 0) { else if (arg.find("+permissive-off") == 0) {
if (opterr) if (opterr)
throw std::invalid_argument("Found +permissive-off when not parsing permissively"); throw std::invalid_argument("Found +permissive-off when not parsing permissively");

4
fesvr/htif.h

@ -63,6 +63,7 @@ class htif_t : public chunked_memif_t
std::vector<std::string> hargs; std::vector<std::string> hargs;
std::vector<std::string> targs; std::vector<std::string> targs;
std::string sig_file; std::string sig_file;
unsigned int line_size;
addr_t sig_addr; // torture addr_t sig_addr; // torture
addr_t sig_len; // torture addr_t sig_len; // torture
addr_t tohost_addr; addr_t tohost_addr;
@ -100,6 +101,8 @@ class htif_t : public chunked_memif_t
+rfb=DISPLAY to be accessible on 5900 + DISPLAY (default = 0)\n\ +rfb=DISPLAY to be accessible on 5900 + DISPLAY (default = 0)\n\
--signature=FILE Write torture test signature to FILE\n\ --signature=FILE Write torture test signature to FILE\n\
+signature=FILE\n\ +signature=FILE\n\
--signature-granularity=VAL Size of each line in signature.\n\
+signature-granularity=VAL\n\
--chroot=PATH Use PATH as location of syscall-servicing binaries\n\ --chroot=PATH Use PATH as location of syscall-servicing binaries\n\
+chroot=PATH\n\ +chroot=PATH\n\
--payload=PATH Load PATH memory as an additional ELF payload\n\ --payload=PATH Load PATH memory as an additional ELF payload\n\
@ -121,6 +124,7 @@ TARGET (RISC-V BINARY) OPTIONS\n\
{"signature", required_argument, 0, HTIF_LONG_OPTIONS_OPTIND + 2 }, \ {"signature", required_argument, 0, HTIF_LONG_OPTIONS_OPTIND + 2 }, \
{"chroot", required_argument, 0, HTIF_LONG_OPTIONS_OPTIND + 3 }, \ {"chroot", required_argument, 0, HTIF_LONG_OPTIONS_OPTIND + 3 }, \
{"payload", required_argument, 0, HTIF_LONG_OPTIONS_OPTIND + 4 }, \ {"payload", required_argument, 0, HTIF_LONG_OPTIONS_OPTIND + 4 }, \
{"signature-granularity", optional_argument, 0, HTIF_LONG_OPTIONS_OPTIND + 5 }, \
{0, 0, 0, 0} {0, 0, 0, 0}
#endif // __HTIF_H #endif // __HTIF_H

Loading…
Cancel
Save