我的设置包含一个 STM32MP157C-DK2,它使用 Trusted Firmware-A 将 SP-MIN 加载为 BL32,将 uBoot+Linux 加载为 BL33。
我试图让一个小例子工作,我从 Linux 内核创建一个 SMC,它传递对非安全内存的引用。该位置的数据应由处理 SMC 的运行时服务更改。
我面临的问题是,我找不到任何有关将虚拟地址从 NS:EL1 的 Linux 内核转换为 EL3 的转换机制所需的步骤的任何信息。
我的运行时服务的代码如下所示:
static int32_t my_svc_setup(void)
{
return 0;
}
static uintptr_t my_svc_smc_handler(uint32_t smc_fid,
u_register_t x1,
u_register_t x2,
u_register_t x3,
u_register_t x4,
void *cookie,
void *handle,
u_register_t flags)
{
uint16_t smc_function_number = (uint16_t) smc_fid;
uint32_t *data;
switch(smc_function_number){
case 123:
data = (uint32_t *) x1;
// Address Translation Magic ...
*data = 42;
SMC_RET1(handle, 1);
default:
SMC_RET1(handle, SMC_UNK);
}
}
DECLARE_RT_SVC(
my_svc,
OEN_OEM_START,
OEN_OEM_END,
SMC_TYPE_FAST,
my_svc_setup,
my_svc_smc_handler
);
SMC 可以毫无问题地到达处理程序,但是一旦我尝试取消引用我通过 x1 传递的物理地址,CPU(显然)就会崩溃。如果有人可以帮助我填写剩余的必需步骤以获得有效的参考,那将不胜感激。