From 827811389010b28ece0838c5055dbf63f9f07c34 Mon Sep 17 00:00:00 2001
From: Katsuhiro Suzuki <katsuhiro@katsuster.net>
Date: Thu, 22 Oct 2020 15:37:31 +0900
Subject: [PATCH] logging: (tentative) add padding for RISC-V 64bits
 environment

This patch add padding in filter structure of log system.
In RISCV && 64BIT environment. Log system is facing alignment bug.

struct log_source_dynamic_data {
	uint32_t filters;
};

static inline uint32_t *log_dynamic_filters_get(uint32_t source_id)
{
	return &__log_dynamic_start[source_id].filters;
}

A sizeof(log_source_dynamic_data) = 4, address offset of
&__log_dynamic_start[] are:
  - &__log_dynamic_start[0]: +0
  - &__log_dynamic_start[1]: +4
  - &__log_dynamic_start[2]: +8

But RISCV 64bit gcc/ld places each log_dynamic_log, log_dynamic_os
and log_dynamic_test per 8bytes alignment. So address offset of
log_dynamic_* are:
  - &log_dynamic_log : +0
  - &log_dynamic_os  : +8
  - &log_dynamic_test: +16

tests/subsys/logging/log_core cannot set correct log filters in
RISCV && 64BIT environment, so test is always going to fail.

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
---
 include/logging/log_instance.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/logging/log_instance.h b/include/logging/log_instance.h
index 25eb47f3f2c..11b614abcfe 100644
--- a/include/logging/log_instance.h
+++ b/include/logging/log_instance.h
@@ -35,6 +35,9 @@ struct log_source_dynamic_data {
 	 */
 	uint32_t dummy[2];
 #endif
+#if defined(CONFIG_RISCV) && defined(CONFIG_64BIT)
+	uint32_t dummy;
+#endif
 };
 
 /** @brief Creates name of variable and section for constant log data.
-- 
GitLab