From 9a7b230b5b6cb37f73952eb1fcccae0b40781b61 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 12 Jul 2024 18:07:25 +0200 Subject: [PATCH] Rollback to OpenSBI 1.4 --- JOURNAL.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ lagarto-ox.nix | 8 ++++-- 2 files changed, 79 insertions(+), 3 deletions(-) diff --git a/JOURNAL.md b/JOURNAL.md index 99a6e6f..6ed6ce6 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -2325,3 +2325,77 @@ arch/riscv/kernel/copy-unaligned.S: 2: ret SYM_FUNC_END(__riscv_copy_bytes_unaligned) + +Booted again with simpler output: + + + > + + +So here is the simplified output using the format `` where X is one character +that differentiates the type of trap. + +Based on the code that performs the check: + + /* + * For a fixed amount of time, repeatedly try the function, and take + * the best time in cycles as the measurement. + */ + while (time_before(jiffies, now + (1 << MISALIGNED_ACCESS_JIFFIES_LG2))) { + start_cycles = get_cycles64(); + /* Ensure the CSR read can't reorder WRT to the copy. */ + mb(); + __riscv_copy_words_unaligned(dst, src, MISALIGNED_COPY_SIZE); + /* Ensure the copy ends before the end time is snapped. */ + mb(); + end_cycles = get_cycles64(); + if ((end_cycles - start_cycles) < word_cycles) + word_cycles = end_cycles - start_cycles; + } + + byte_cycles = -1ULL; + __riscv_copy_bytes_unaligned(dst, src, MISALIGNED_COPY_SIZE); + start_jiffies = jiffies; + while ((now = jiffies) == start_jiffies) + cpu_relax(); + + while (time_before(jiffies, now + (1 << MISALIGNED_ACCESS_JIFFIES_LG2))) { + start_cycles = get_cycles64(); + mb(); + __riscv_copy_bytes_unaligned(dst, src, MISALIGNED_COPY_SIZE); + mb(); + end_cycles = get_cycles64(); + if ((end_cycles - start_cycles) < byte_cycles) + byte_cycles = end_cycles - start_cycles; + } + + preempt_enable(); + + /* Don't divide by zero. */ + if (!word_cycles || !byte_cycles) { + pr_warn("cpu%d: rdtime lacks granularity needed to measure unaligned access speed\n", + cpu); + + return 0; + } + + if (word_cycles < byte_cycles) + speed = RISCV_HWPROBE_MISALIGNED_FAST; + + ratio = div_u64((byte_cycles * 100), word_cycles); + pr_info("cpu%d: Ratio of byte access time to unaligned word access is %d.%02d, unaligned accesses are %s\n", + cpu, + ratio / 100, + ratio % 100, + (speed == RISCV_HWPROBE_MISALIGNED_FAST) ? "fast" : "slow"); + +The fact that the print line with the "Ratio of byte access..." doesn't appear, +puts the hang place at some point in between the check and the `pr_info()` call. + +If this is a problem on the OpenSBI side, we can bisect the code to find out +where the problem was introduced. But first, I would have to try OpenSBI 1.4 and +ensure we can reproduce it. diff --git a/lagarto-ox.nix b/lagarto-ox.nix index 2cecee9..b03be3d 100644 --- a/lagarto-ox.nix +++ b/lagarto-ox.nix @@ -301,12 +301,14 @@ ''; opensbi = prev.opensbi.overrideAttrs (old: rec { - version = "1.5"; + version = "1.4"; + #version = "1.5"; src = prev.fetchFromGitHub { owner = "riscv-software-src"; repo = "opensbi"; rev = "v${version}"; - hash = "sha256-vK14P97FcaVz4GDr/0055Z6s/k7BPKPQGZ/MQxbOWu0="; + hash = "sha256-T8ZeAzjM9aeTXitjE7s+m+jjGGtDo2jK1qO5EuKiVLU="; #1.4 + #hash = "sha256-vK14P97FcaVz4GDr/0055Z6s/k7BPKPQGZ/MQxbOWu0="; #1.5 }; #NIX_DEBUG=5; makeFlags = [ @@ -323,7 +325,7 @@ "FW_PAYLOAD_FDT_ADDR=0x80100000" ]; patches = [ - ./opensbi-timer-debug.patch + #./opensbi-timer-debug.patch #./ox-alveo-platform-plic.patch ]; });