From 0b4895cca6a6c6c79cb869db1dded17ba4f3b9b6 Mon Sep 17 00:00:00 2001 From: zhangdengyu Date: Sat, 7 Jan 2023 18:20:48 +0800 Subject: [PATCH] =?UTF-8?q?fixed=2084d1c20=20from=20https://gitee.com/zhan?= =?UTF-8?q?gdengyu/kernel=5Fliteos=5Fm/pulls/1000=20fix=EF=BC=9Amutex=20tr?= =?UTF-8?q?ace=E4=B8=ADArchLRGet=E6=8E=A5=E5=8F=A3=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 方案描述: 将ArchLRGet接口的实现方式由内联函数修改为宏, 防止产品添加--no_inline等编译选项导致函数无法在调用点展开, 造成由于函数调用过程中函数栈帧的变化带来的LR寄存器中存储的值的变化。 Close #I69D9N Signed-off-by: zhangdengyu Change-Id: If417bc2ec9febf064c63da198faf4ac000d70c52 --- arch/include/los_arch.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/arch/include/los_arch.h b/arch/include/los_arch.h index 4f7311b7..cd12cd72 100644 --- a/arch/include/los_arch.h +++ b/arch/include/los_arch.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. - * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. + * Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: @@ -63,12 +63,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID) return msp; } -STATIC INLINE UINTPTR ArchLRGet(VOID) -{ - UINTPTR lr; - __asm("mov %0, lr" : "=r" (lr)); - return lr; -} +#define ARCH_LR_GET() \ +({ \ + UINTPTR lr; \ + __asm("mov %0, lr" : "=r" (lr)); \ + (lr); \ +}) +#define ArchLRGet ARCH_LR_GET #elif defined(__CLANG_ARM) || defined(__GNUC__) STATIC INLINE UINTPTR ArchSpGet(VOID) { @@ -91,12 +92,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID) return msp; } -STATIC INLINE UINTPTR ArchLRGet(VOID) -{ - UINTPTR lr; - __asm volatile("mov %0, lr" : "=r" (lr)); - return lr; -} +#define ARCH_LR_GET() \ +({ \ + UINTPTR lr; \ + __asm volatile("mov %0, lr" : "=r" (lr)); \ + (lr); \ +}) +#define ArchLRGet ARCH_LR_GET #else /* Other platforms to be improved */ #endif -- GitLab