Dear list,

I am trying to run some binary code on x86 full-system simulated mode of
gem5. While most of my test binaries work well on the full-system simulated
mode, I am trapped in running a C++ test case for several days. In general,
the output of running my C++ binary code is inconsistent comparing the
physical machine with the gem5's full-system simulated mode.

I dig into the code for a while and figure out that actually *performing
big integer multiplication can lead to incorrect results on the gem5's
full-system simulated mode*. I attached a very simple test case I use (the
source code; note that this source code leverages the bigint implementation
of Botan <https://botan.randombit.net/> library version 1.10.13). I also
uploaded the compiled x86 64-bit binary code here
<https://www.dropbox.com/s/bkw2ym2clizum4f/bigintm.gz?dl=0>. By running the
compiled binary code on my full-system simulation environment, I would get
incorrect multiplication results (detailed information is given in the
source code).

It is really painful to compile/debug on the simulated platform; I cannot
make much progress by debugging the code. I also tried to add some logging
code and rerun the binary code on the simulated OS, however, some
segmentation faults happened at this time....

This seems to me some simulation issue on certain x86 opcodes. However, I
am not sure. So I am writing to ask, is there anyone that happen to see
similar issue like this one?  Any suggestion would be greatly appreciated,
thank you!

Sincerely,
Shuai
#include <iostream>
#include <fstream>
#include <string>
#include <memory>

#include <botan/botan.h>
using namespace Botan;


int main(int argc, char* argv[])
   {
    BigInt p("146644379823533680002907103383562626455622871667770465934147284694533934105822305623693801971376422367411788778276662497189789476046870734777910356266559387328711272835446788442744755734136036055564484323726838234478961178572740332886380411244670537003370404054182422843508294046797831982231959866601801666787");
    BigInt q("173101895610110662029194078101022043593296414295952869228394129775882998217693826413337459037414030556466242498339529051664716074370856977402736699961997347289133651678622342609491651926040879448011734545711844975520647854021730163017165794462147746726093005084037547155092851361105443638823533587425156158643");
    // BigInt p("123123123123");
    // BigInt q("31321312312");

    // std::cout << p << std::endl;
    // std::cout << q << std::endl;
    std::cout << q * p << std::endl;
    // running it on the physical machine would give the result:
    // 25384420128022745261823549268169600681370133198423684810389865865808408851064197115301195887137289781969726265579727545973854118396215144112138291824111965757359576903589479314384502242798081167024383817270952956935879809444179219823741639835910125394584269303029717460461327658306745484995898576641843572134142246381324076158070237650112002568297183096588450965355028629415968865942564346050298973124401604014634403512502230145902046778993934874428730337805164253358496561876730564218488067815975061335734006330625954742315722458390394846783299017702210158281730656327638641600207807576378564687441581723115596090041

    // however, running it on a gem5 full-system simulation mode would give the result:
    // 25384420128022745261823549267761702718754975828593160077441473995423425604256024785277209029873768971101521095215339755639905679795687231586821249032738163811044748029315569805152281214658729135678467891318762128941740910542948118150700255055174360968565380575857325230784340160303761228854266933985185512540045523145385702269855083755905899720061398697908347801916623451389836228353660869651995988154066385305880898566580795791095772925680470432046831740652117397754277907662633706524552700856045172810579411300769337225176063146693709699898295244953754949987203215048643304761183477760279210972942672875708680833721
    return 0;
   }
_______________________________________________
gem5-users mailing list
[email protected]
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to