diff --git a/JOURNAL.md b/JOURNAL.md index 351dd6c..ae07f53 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -885,3 +885,8 @@ Continues to hang just after those perl messages: May be a long shot, but if we are experiencing the same page fault loop as in cincoranch we may as well try. + +### QUESTION: Maybe we can try without out-of-order? + +I made a small tool in C to view and change the CSR register that controls the +in-order/out-of-order. Maybe we can try with the "in-order" setting. diff --git a/csrtool.c b/csrtool.c new file mode 100644 index 0000000..1ae6cee --- /dev/null +++ b/csrtool.c @@ -0,0 +1,34 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + /* Print */ + if (argc > 1) { + // Wait for all memory operations to finish + __asm__ volatile ("fence"); + + if (strcmp(argv[1], "mem-in-order") == 0) { + __asm__ volatile ("fence"); + __asm__ volatile ("csrwi 0x801, 2"); + } else if (strcmp(argv[1], "all-in-order") == 0) { + __asm__ volatile ("fence"); + __asm__ volatile ("csrwi 0x801, 7"); + } else if (strcmp(argv[1], "all-out-of-order") == 0) { + __asm__ volatile ("fence"); + __asm__ volatile ("csrwi 0x801, 0"); + } else { + fprintf(stderr, "unknown '%s', use: mem-in-order, all-in-order or all-out-of-order\n", argv[1]); + exit(1); + } + } + + // Wait for all memory operations to finish + __asm__ volatile ("fence"); + unsigned result; + asm("csrr %0, 0x801" : "=r"(result) : ); + printf("CSR 0x801 = %xu\n", result); + + return 0; +} diff --git a/lagarto-ox.nix b/lagarto-ox.nix index 9cc4aa6..35e53bf 100644 --- a/lagarto-ox.nix +++ b/lagarto-ox.nix @@ -81,6 +81,12 @@ compressor = "gzip"; kernelModules = [ ]; + # Add the csrtool to the initrd so we can change the + # in-order/out-of-order. + extraUtilsCommands = '' + cp -a ${pkgs.csrtool}/bin/csrtool $out/bin + ''; + # Write a counter to the DMA region, so we can check the kernel is not # dead. Monitor from the host with: # while [ 1 ]; do xxd -s $((0x1bfff0000 - 0x60000000)) \ diff --git a/overlay.nix b/overlay.nix index 0ad4189..1614a9a 100644 --- a/overlay.nix +++ b/overlay.nix @@ -37,6 +37,22 @@ final: prev: ''; }; + csrtool = prev.pkgsStatic.stdenv.mkDerivation { + name = "csrtool"; + src = ./csrtool.c; + unpackPhase = '' + cp ${./csrtool.c} csrtool.c + ''; + dontConfigure = true; + buildPhase = '' + $CC -static csrtool.c -o csrtool + ''; + installPhase = '' + mkdir -p $out/bin + cp csrtool $out/bin/ + ''; + }; + bitstreams = builtins.fetchGit { url = "git@bscpm03.bsc.es:rarias/bitstreams.git"; rev = "ad901b0c21ffbdb310ff1dfb269f169f6ac6bde6";