Skip to contentSkip to conversation

optee-os: Extend clang pragma fixes to core_mmu_v7.c for 3.18

PATCH Applied Khem Raj 2 participants 7 messages Sep 22, 2022 – Sep 23, 2022

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/4 optee-os: Extend clang pragma fixes to core_mmu_v7.c for 3.18

3.18 builds are failing since the section stuff is also done in core_mmu_v7.c therefore extend the patch to include this file as well

---
v2: Rebased

 ...-Define-section-attributes-for-clang.patch | 120 +++++++++---------
 1 file changed, 59 insertions(+), 61 deletions(-)
meta-arm/recipes-security/optee/optee-os/0001-core-Define-section-attributes-for-clang.patch +59 -61
index d30fa5a..a69d777 100644
@@ -1,4 +1,4 @@
-From 4ff172196d399217992110a47312c626954a844c Mon Sep 17 00:00:00 2001
+From f189457b79989543f65b8a4e8729eff2cdf9a758 Mon Sep 17 00:00:00 2001
 From: Khem Raj <[email protected]>
 Date: Sat, 13 Aug 2022 19:24:55 -0700
 Subject: [PATCH] core: Define section attributes for clang
@@ -30,20 +30,16 @@ going and match the functionality with gcc.
 
 Upstream-Status: Pending
 Signed-off-by: Khem Raj <[email protected]>
-
 ---
  core/arch/arm/kernel/thread.c    | 19 +++++++++++++++--
  core/arch/arm/mm/core_mmu_lpae.c | 35 ++++++++++++++++++++++++++++----
- core/arch/arm/mm/core_mmu_v7.c   | 27 +++++++++++++++++++++---
  core/arch/arm/mm/pgt_cache.c     | 12 ++++++++++-
  core/kernel/thread.c             | 13 +++++++++++-
- 5 files changed, 95 insertions(+), 11 deletions(-)
+ 4 files changed, 71 insertions(+), 8 deletions(-)
 
-diff --git a/core/arch/arm/kernel/thread.c b/core/arch/arm/kernel/thread.c
-index f083b159..432983c8 100644
 --- a/core/arch/arm/kernel/thread.c
 +++ b/core/arch/arm/kernel/thread.c
-@@ -44,15 +44,30 @@ static size_t thread_user_kcode_size __nex_bss;
+@@ -44,16 +44,31 @@ static size_t thread_user_kcode_size __n
  #if defined(CFG_CORE_UNMAP_CORE_AT_EL0) && \
  	defined(CFG_CORE_WORKAROUND_SPECTRE_BP_SEC) && defined(ARM64)
  long thread_user_kdata_sp_offset __nex_bss;
@@ -66,18 +62,17 @@ index f083b159..432983c8 100644
 -	__section(".nex_nozi.kdata_page");
 +	__section(".nex_nozi.kdata_page")
  #endif
-+#endif
+ #endif
 +    ;
 +#endif
 +
 +/* reset BSS section to default ( .bss ) */
 +#ifdef __clang__
 +#pragma clang section bss=""
- #endif
++#endif
  
  #ifdef ARM32
-diff --git a/core/arch/arm/mm/core_mmu_lpae.c b/core/arch/arm/mm/core_mmu_lpae.c
-index 3f08eec6..e6dc9261 100644
+ uint32_t __nostackcheck thread_get_exceptions(void)
 --- a/core/arch/arm/mm/core_mmu_lpae.c
 +++ b/core/arch/arm/mm/core_mmu_lpae.c
 @@ -233,19 +233,46 @@ typedef uint16_t l1_idx_t;
@@ -131,53 +126,6 @@ index 3f08eec6..e6dc9261 100644
  /*
   * TAs page table entry inside a level 1 page table.
   *
-diff --git a/core/arch/arm/mm/core_mmu_v7.c b/core/arch/arm/mm/core_mmu_v7.c
-index cd85bd22..ee78e6ee 100644
---- a/core/arch/arm/mm/core_mmu_v7.c
-+++ b/core/arch/arm/mm/core_mmu_v7.c
-@@ -204,16 +204,37 @@ typedef uint32_t l1_xlat_tbl_t[NUM_L1_ENTRIES];
- typedef uint32_t l2_xlat_tbl_t[NUM_L2_ENTRIES];
- typedef uint32_t ul1_xlat_tbl_t[NUM_UL1_ENTRIES];
- 
-+#ifdef __clang__
-+#pragma clang section bss=".nozi.mmu.l1"
-+#endif
- static l1_xlat_tbl_t main_mmu_l1_ttb
--		__aligned(L1_ALIGNMENT) __section(".nozi.mmu.l1");
-+		__aligned(L1_ALIGNMENT)
-+#ifndef __clang__
-+	__section(".nozi.mmu.l1")
-+#endif
-+;
- 
- /* L2 MMU tables */
-+#ifdef __clang__
-+#pragma clang section bss=".nozi.mmu.l2"
-+#endif
- static l2_xlat_tbl_t main_mmu_l2_ttb[MAX_XLAT_TABLES]
--		__aligned(L2_ALIGNMENT) __section(".nozi.mmu.l2");
-+		__aligned(L2_ALIGNMENT)
-+#ifndef __clang__
-+	__section(".nozi.mmu.l2")
-+#endif
-+;
- 
- /* MMU L1 table for TAs, one for each thread */
-+#ifdef __clang__
-+#pragma clang section bss=".nozi.mmu.ul1"
-+#endif
- static ul1_xlat_tbl_t main_mmu_ul1_ttb[CFG_NUM_THREADS]
--		__aligned(UL1_ALIGNMENT) __section(".nozi.mmu.ul1");
-+		__aligned(UL1_ALIGNMENT)
-+#ifndef __clang__
-+	__section(".nozi.mmu.ul1")
-+#endif
-+;
- 
- struct mmu_partition {
- 	l1_xlat_tbl_t *l1_table;
-diff --git a/core/arch/arm/mm/pgt_cache.c b/core/arch/arm/mm/pgt_cache.c
-index dee1d207..382cae1c 100644
 --- a/core/arch/arm/mm/pgt_cache.c
 +++ b/core/arch/arm/mm/pgt_cache.c
 @@ -104,8 +104,18 @@ void pgt_init(void)
@@ -200,11 +148,9 @@ index dee1d207..382cae1c 100644
  	size_t n;
  
  	for (n = 0; n < ARRAY_SIZE(pgt_tables); n++) {
-diff --git a/core/kernel/thread.c b/core/kernel/thread.c
-index 18d34e6a..086129e2 100644
 --- a/core/kernel/thread.c
 +++ b/core/kernel/thread.c
-@@ -37,13 +37,24 @@ struct thread_core_local thread_core_local[CFG_TEE_CORE_NB_CORE] __nex_bss;
+@@ -37,13 +37,24 @@ struct thread_core_local thread_core_loc
  	name[stack_num][sizeof(name[stack_num]) / sizeof(uint32_t) - 1]
  #endif
  
@@ -230,3 +176,55 @@ index 18d34e6a..086129e2 100644
  #define GET_STACK(stack) ((vaddr_t)(stack) + STACK_SIZE(stack))
  
  DECLARE_STACK(stack_tmp, CFG_TEE_CORE_NB_CORE,
+--- a/core/arch/arm/mm/core_mmu_v7.c
++++ b/core/arch/arm/mm/core_mmu_v7.c
+@@ -204,16 +204,46 @@ typedef uint32_t l1_xlat_tbl_t[NUM_L1_EN
+ typedef uint32_t l2_xlat_tbl_t[NUM_L2_ENTRIES];
+ typedef uint32_t ul1_xlat_tbl_t[NUM_UL1_ENTRIES];
+ 
++#ifdef __clang__
++#pragma clang section bss=".nozi.mmu.l1"
++#endif
+ static l1_xlat_tbl_t main_mmu_l1_ttb
+-		__aligned(L1_ALIGNMENT) __section(".nozi.mmu.l1");
++		__aligned(L1_ALIGNMENT)
++#ifndef __clang__
++       __section(".nozi.mmu.l1")
++#endif
++;
++#ifdef __clang__
++#pragma clang section bss=""
++#endif
+ 
+ /* L2 MMU tables */
++#ifdef __clang__
++#pragma clang section bss=".nozi.mmu.l2"
++#endif
+ static l2_xlat_tbl_t main_mmu_l2_ttb[MAX_XLAT_TABLES]
+-		__aligned(L2_ALIGNMENT) __section(".nozi.mmu.l2");
++		__aligned(L2_ALIGNMENT)
++#ifndef __clang__
++       __section(".nozi.mmu.l2")
++#endif
++;
++#ifdef __clang__
++#pragma clang section bss=""
++#endif
+ 
+ /* MMU L1 table for TAs, one for each thread */
++#ifdef __clang__
++#pragma clang section bss=".nozi.mmu.ul1"
++#endif
+ static ul1_xlat_tbl_t main_mmu_ul1_ttb[CFG_NUM_THREADS]
+-		__aligned(UL1_ALIGNMENT) __section(".nozi.mmu.ul1");
++		__aligned(UL1_ALIGNMENT)
++#ifndef __clang__
++       __section(".nozi.mmu.ul1")
++#endif
++;
++#ifdef __clang__
++#pragma clang section bss=""
++#endif
+ 
+ struct mmu_partition {
+ 	l1_xlat_tbl_t *l1_table;
Signature · 1 line
2.37.3
author
#1 lore raw

PATCH v2 2/4 trusted-services: Pin to use gcc

These recipes are not buildable with clang in its current state

---
v2: Rebased

 meta-arm/recipes-security/trusted-services/trusted-services.inc | 2 ++
 1 file changed, 2 insertions(+)
meta-arm/recipes-security/trusted-services/trusted-services.inc +2 -0
index 80c0849..a8f49a5 100644
@@ -50,3 +50,5 @@ EXTRA_OECMAKE += "${@oe.utils.conditional('TS_ENV', 'opteesp', \
 EXTRA_OECMAKE += "-Dlibts_DIR=${STAGING_DIR_HOST}${TS_INSTALL}/lib/cmake/ \
                   -DNEWLIB_INSTALL_DIR=${STAGING_DIR_HOST}${TS_INSTALL}/newlib_install \
                  "
+# Newlib does not compile with clang
+TOOLCHAIN = "gcc"
Signature · 1 line
2.37.3
author
#2 lore raw

PATCH v2 3/4 linux-yocto: Add bbappend for 5.19

In reply to Khem Raj

Enable tee and arm-ffa driver on qemuarm/qemuarm64 by default

---
v2: Rebased

 meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend
meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend new file +9 -0
new file mode 100644
index 0000000..7dec2f5
@@ -0,0 +1,9 @@
+# enable arm_ffa regardless on 5.19
+SRC_URI:append:qemuarm = " \
+    file://tee.cfg \
+    file://arm-ffa-transport.cfg \
+"
+SRC_URI:append:qemuarm64 = " \
+    file://tee.cfg \
+    file://arm-ffa-transport.cfg \
+"
Signature · 1 line
2.37.3
author
#5 lore raw

PATCH v2 4/4 ffa-debugfs-mod: Exclude from world builds

In reply to Khem Raj

It installs arm_ffa_user.h and so does arm-ffa-user recipe, lets not build ffa-debugfs-mod in world builds since it does not appear as much in other package dependencies as arm-ffa-user

---
v2: Rebased

 meta-arm/recipes-kernel/ffa-debugfs/ffa-debugfs-mod_2.1.0.bb | 2 ++
 1 file changed, 2 insertions(+)
meta-arm/recipes-kernel/ffa-debugfs/ffa-debugfs-mod_2.1.0.bb +2 -0
index 1b265a5..2b5dd64 100644
@@ -37,3 +37,5 @@ python remove_kernel_dependency() {
   key = "RDEPENDS:kernel-module-arm-ffa-user-" + d.getVar("KERNEL_VERSION")
   d.delVar(key)
 }
+# Conflicts installing arm_ffa_user.h with arm-ffa-user recipe, lets build only one during world builds
+EXCLUDE_FROM_WORLD = "1"
Signature · 1 line
2.37.3
#3 lore raw

Re: [PATCH v2 3/4] linux-yocto: Add bbappend for 5.19

In reply to Khem Raj
Quoted 1 line · Khem Raj

Enable tee and arm-ffa driver on qemuarm/qemuarm64 by default

Per Anton's comment, I don't see why this is necessary for qemuarm/qemuarm64 by default. Can you explain a little more please?

Aside from this, the series looks fine.

Thanks,
Jon

Quoted 28 lines

---
v2: Rebased

 meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend
meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend new file +9 -0
new file mode 100644
index 0000000..7dec2f5
@@ -0,0 +1,9 @@
+# enable arm_ffa regardless on 5.19
+SRC_URI:append:qemuarm = " \
+    file://tee.cfg \
+    file://arm-ffa-transport.cfg \
+"
+SRC_URI:append:qemuarm64 = " \
+    file://tee.cfg \
+    file://arm-ffa-transport.cfg \
+"
Signature · 1 line
2.37.3
author
#4 lore raw

Re: [PATCH v2 3/4] linux-yocto: Add bbappend for 5.19

Quoted 7 lines · Jon Mason
Quoted 1 line · Khem Raj

Enable tee and arm-ffa driver on qemuarm/qemuarm64 by default

Per Anton's comment, I don't see why this is necessary for qemuarm/qemuarm64 by default. Can you explain a little more please?

since meta-arm has these kernel module recipes which fail in world builds. We can also do it other way
where these modules are excluded from world builds and then we dont need to enable them.

Quoted 33 lines

Aside from this, the series looks fine.

Thanks,
Jon

Quoted 28 lines

---
v2: Rebased

 meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend
meta-arm/recipes-kernel/linux/linux-yocto_5.19%.bbappend new file +9 -1
new file mode 100644
index 0000000..7dec2f5
@@ -0,0 +1,9 @@
+# enable arm_ffa regardless on 5.19
+SRC_URI:append:qemuarm = " \
+    file://tee.cfg \
+    file://arm-ffa-transport.cfg \
+"
+SRC_URI:append:qemuarm64 = " \
+    file://tee.cfg \
+    file://arm-ffa-transport.cfg \
+"
--

2.37.3

Applied
#6 lore raw
In reply to Khem Raj
Quoted 2 lines · Khem Raj

3.18 builds are failing since the section stuff is also done in core_mmu_v7.c therefore extend the patch to include this file as well

Applied, thanks!

[1/4] optee-os: Extend clang pragma fixes to core_mmu_v7.c for 3.18

      commit: 7d8b252405153ac0af5affedbe9423c993c0f483
[2/4] trusted-services: Pin to use gcc
      commit: 2c2ed8f727fa194754013dde9e8e566f2a1b7c43
[3/4] linux-yocto: Add bbappend for 5.19
      commit: 75ccc7847d8af5bfff4d6261a49530bb571d1a12
[4/4] ffa-debugfs-mod: Exclude from world builds
      commit: a0658a6682a537330f5619962504e675d7540f40

Best regards,

Signature · 1 line
Jon Mason <[email protected]>