mirror of
https://github.com/openharmony/tee_tee_os_framework.git
synced 2026-07-20 23:46:14 -04:00
no message
Match-id-5d7e4a0e31c6d58f6174a6d56010e071ffb8bcda
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
ifneq ($V,)
|
||||
VER :=
|
||||
else
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
ifeq ($(CONFIG_LLVM_CFI),y)
|
||||
|
||||
ifeq ($(CONFIG_LLVM_LTO),y)
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
CFLAGS :=
|
||||
CPPFLAGS :=
|
||||
ASFLAGS :=
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
include $(BUILD_CONFIG)/var.mk
|
||||
PREBUILD_SDK := $(PREBUILD_DIR)/headers/sdk
|
||||
PREBUILD_INNER_SDK := $(PREBUILD_DIR)/headers/inner_sdk
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# extra-flags is for export.txt and extern.txt of libteec_share
|
||||
ifeq ($(CONFIG_SSA_64BIT), true)
|
||||
flags += -DTEE_SUPPORT_SSA_64BIT
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
export PLAT_AUTOCONF_FILE := $(PREBUILD_DIR)/headers/platautoconf.h
|
||||
|
||||
DEBUG_RELEASE_MACRO := release
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
#teeos-flags.mk
|
||||
#
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
#toolchain.mk
|
||||
#
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# basic dirs, these variables will be used by whole project
|
||||
override BUILD_DIR := $(OUTPUTDIR)/$(ARCH)/obj/$(ARCH)/$(MODULE_FOLDER)
|
||||
override LIB_DIR := $(OUTPUTDIR)/$(ARCH)/libs
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
MODULE_FOLDER := $(shell basename $(CURDIR))
|
||||
|
||||
ifeq ($(ARCH),)
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
#
|
||||
# FILE: project.mk
|
||||
#
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
## This function will generate $(1)_objs variables which provided
|
||||
## the objects needed to compile to the $(1) module.
|
||||
##
|
||||
|
||||
@@ -1,2 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
include $(BUILD_DRIVER)/drv-flags.mk
|
||||
include $(BUILD_OPERATION)/common.mk
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# hm entrypoint
|
||||
ENTRY_POINT ?= _hm_start
|
||||
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
TARGET_IS_TA := y
|
||||
# setup toolchain
|
||||
include $(BUILD_CONFIG)/cfg.mk
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# llvm c++ libs and headers
|
||||
PREBUILD_TOOLCHAIN := $(TOPDIR)/prebuild/toolchains/llvm_sysroot
|
||||
LLVM_INC := $(PREBUILD_TOOLCHAIN)/$(ARCH)/include
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
RAMFSMKIMG := $(PREBUILD_TOOLS)/ramfsmkimg
|
||||
|
||||
# prebuild apps
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
ifeq ($(CONFIG_TA_64BIT), true)
|
||||
product_apps += $(OUTPUTDIR)/aarch64/drivers/tarunner.elf
|
||||
endif
|
||||
|
||||
@@ -1,2 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
include $(BUILD_SERVICE)/svc-flags.mk
|
||||
include $(BUILD_OPERATION)/common.mk
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# hm entrypoint
|
||||
ENTRY_POINT ?= _hm_start
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Usage: check-syms.sh TA.elf libc.so libtee.so
|
||||
# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#set -e
|
||||
|
||||
# add ignored syms to IGNORED
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# cpio-strip compile rule.
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
override CC := gcc
|
||||
GENERAL_OPTIONS := -Wall -Werror -Wextra -Wfloat-equal -Wshadow -Wtrampolines -Wformat=2\
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
||||
* Description: cpio strip function
|
||||
* Create: 2020-06-04
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#define _XOPEN_SOURCE 700
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#!/bin/bash
|
||||
# function belong to gen_boot_image.
|
||||
# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
set -e
|
||||
function pad8_name()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Print all commands if V=3; maximum verbosity.
|
||||
# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved.]
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
set -e
|
||||
source ${BUILD_TOOLS}/generate_img/gen_boot_function.sh
|
||||
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#!/bin/bash
|
||||
# Get the elf file, judge 32 or 64, and strip off some symbol information and debugging information to make the file smaller
|
||||
# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
set -e
|
||||
|
||||
strip_file() {
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
# @TAG(HUAWEI)
|
||||
#
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved.
|
||||
* Description: Procedure for reading ramfs data (for AArch64)
|
||||
* Create: 2018-05-08
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "get_ramfs_data.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved.
|
||||
* Description: Procedure for reading ramfs data (for AArch64)
|
||||
* Create: 2018-05-08
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef _GET_RAMFS_DATA_H_
|
||||
#define _GET_RAMFS_DATA_H_
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
|
||||
* Create: 2019-06-18
|
||||
* Description: copy symtab and strtab
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
#trustedcore package header generator
|
||||
# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
"""Description:package image for phone
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
set -e
|
||||
COMPARE_IMAGE="$2"
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
|
||||
# Description: makeflie for rmfs
|
||||
# Create: 2019-08-20
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
CC = cc
|
||||
CPPFLAGS :=
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved.
|
||||
* Description: main function of ramfs
|
||||
* Create: 2019-08-20
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
# PLATFORM
|
||||
#
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
# PLATFORM
|
||||
#
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: plat_cfg defines
|
||||
* Create: 2022-01-04
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "plat_cfg.h"
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: plat_cfg defines
|
||||
* Create: 2022-01-04
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef PLAT_CFG_H
|
||||
#define PLAT_CFG_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: plat_cfg defines
|
||||
* Create: 2022-01-04
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "plat_cfg.h"
|
||||
#include "plat_cfg_public.h"
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: plat_cfg defines
|
||||
* Create: 2022-01-04
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef PLAT_CFG_H
|
||||
#define PLAT_CFG_H
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
# PLATFORM
|
||||
#
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
#
|
||||
# PLATFORM
|
||||
#
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
# Copyright Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
DRIVER := crypto_mgr.elf
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_DRIVER_ADAPTOR_OPS_H
|
||||
#define CRYPTO_DRIVER_ADAPTOR_OPS_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_MGR_SYSCALL_H
|
||||
#define CRYPTO_MGR_SYSCALL_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto hal syscall
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_common.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall ae
|
||||
* Create: 2022-01-19
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_common.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall ae
|
||||
* Create: 2022-01-19
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_AE_H
|
||||
#define CRYPTO_SYSCALL_AE_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall cipher
|
||||
* Create: 2022-01-19
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_common.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall cipher
|
||||
* Create: 2022-01-19
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_CIPHER_H
|
||||
#define CRYPTO_SYSCALL_CIPHER_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall common
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_common.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall common
|
||||
* Create: 2022-01-19
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_COMMON_H
|
||||
#define CRYPTO_SYSCALL_COMMON_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall deriver key
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_common.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto syscall derive key
|
||||
* Create: 2022-01-19
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_DERIVE_KEY_H
|
||||
#define CRYPTO_SYSCALL_DERIVE_KEY_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto ec syscall
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_ec.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_EC_H
|
||||
#define CRYPTO_SYSCALL_EC_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto hash syscall
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_hash.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_HASH_H
|
||||
#define CRYPTO_SYSCALL_HASH_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto hmac syscall
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_hmac.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_HMAC_H
|
||||
#define CRYPTO_SYSCALL_HMAC_H
|
||||
|
||||
@@ -1,65 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto oemkey syscall
|
||||
* Create: 2022-01-13
|
||||
*/
|
||||
#include "crypto_syscall_oemkey.h"
|
||||
#include <securec.h>
|
||||
#include "tee_driver_module.h"
|
||||
#include <hmlog.h>
|
||||
#include "drv_param_ops.h"
|
||||
|
||||
static int32_t get_oemkey_ops(const struct crypto_drv_ops_t *ops, struct memref_t *buf_arg)
|
||||
{
|
||||
if (ops->get_oemkey == NULL) {
|
||||
hm_error("hardware engine get oemkey fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void *buffer = NULL;
|
||||
size_t size;
|
||||
|
||||
buffer = (void *)(uintptr_t)buf_arg->buffer;
|
||||
size = buf_arg->size;
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->get_oemkey(buffer, size);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("get oemkey failed\n");
|
||||
|
||||
do_power_off(ops);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t get_oemkey_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = get_oemkey_ops(ops, buf_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_oemkey.h"
|
||||
#include <securec.h>
|
||||
#include "tee_driver_module.h"
|
||||
#include <hmlog.h>
|
||||
#include "drv_param_ops.h"
|
||||
|
||||
static int32_t get_oemkey_ops(const struct crypto_drv_ops_t *ops, struct memref_t *buf_arg)
|
||||
{
|
||||
if (ops->get_oemkey == NULL) {
|
||||
hm_error("hardware engine get oemkey fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void *buffer = NULL;
|
||||
size_t size;
|
||||
|
||||
buffer = (void *)(uintptr_t)buf_arg->buffer;
|
||||
size = buf_arg->size;
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->get_oemkey(buffer, size);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("get oemkey failed\n");
|
||||
|
||||
do_power_off(ops);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t get_oemkey_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = get_oemkey_ops(ops, buf_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_OEMKEY_H
|
||||
#define CRYPTO_SYSCALL_OEMKEY_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto_mgr suspend and resume functions
|
||||
* Create: 2022-05
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_pm.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: crypto_mgr suspend and resume functions
|
||||
* Create: 2022-05
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_PM_H
|
||||
#define CRYPTO_SYSCALL_PM_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto random syscall
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_random.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_RANDOM_H
|
||||
#define CRYPTO_SYSCALL_RANDOM_H
|
||||
|
||||
@@ -1,432 +1,438 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: implement crypto rsa syscall
|
||||
* Create: 2022-01-13
|
||||
*/
|
||||
#include "crypto_syscall_rsa.h"
|
||||
#include <securec.h>
|
||||
#include "tee_driver_module.h"
|
||||
#include <hmlog.h>
|
||||
#include "drv_param_ops.h"
|
||||
|
||||
static int32_t check_rsa_private_key_len(const struct rsa_priv_key_t *rsa_private_key)
|
||||
{
|
||||
if (rsa_private_key == NULL) {
|
||||
hm_error("rsa private key is NULL\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
bool check = (rsa_private_key->e_len > RSA_EXPONENT_LEN ||
|
||||
rsa_private_key->n_len > RSA_MAX_KEY_SIZE || rsa_private_key->d_len > RSA_MAX_KEY_SIZE ||
|
||||
rsa_private_key->p_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->q_len > RSA_MAX_KEY_SIZE_CRT ||
|
||||
rsa_private_key->dp_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->dq_len > RSA_MAX_KEY_SIZE_CRT ||
|
||||
rsa_private_key->qinv_len > RSA_MAX_KEY_SIZE_CRT);
|
||||
if (check) {
|
||||
hm_error("rsa private key size is invalid\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
return CRYPTO_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t check_rsa_pub_key_len(const struct rsa_pub_key_t *rsa_pub_key)
|
||||
{
|
||||
if (rsa_pub_key == NULL) {
|
||||
hm_error("rsa pub key is NULL\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
if (rsa_pub_key->e_len > RSA_EXPONENT_LEN || rsa_pub_key->n_len > RSA_MAX_KEY_SIZE) {
|
||||
hm_error("rsa pub key size is invalid\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
return CRYPTO_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t rsa_generate_keypair_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg,
|
||||
uint32_t key_size, bool crt_mode)
|
||||
{
|
||||
if (ops->rsa_generate_keypair == NULL) {
|
||||
hm_error("hardware engine rsa generate keypair fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct rsa_priv_key_t *key_pair = (struct rsa_priv_key_t *)(uintptr_t)crypto_arg->buffer;
|
||||
ret = check_rsa_private_key_len(key_pair);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
crypto_arg++;
|
||||
struct memref_t e_value;
|
||||
e_value.buffer = crypto_arg->buffer;
|
||||
e_value.size = crypto_arg->size;
|
||||
|
||||
ret = ops->rsa_generate_keypair(key_size, &e_value, crt_mode, key_pair);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("hardware engine do rsa generate keypair failed. ret = %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_generate_keypair_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_gen_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_gen_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_generate_keypair_ops(ops, buf_arg, ioctl_args->arg1, (bool)ioctl_args->arg2);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_gen_share_buf, ioctl_args->buf_len, ioctl_args->buf,
|
||||
ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_gen_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_encrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_encrypt == NULL) {
|
||||
hm_error("hardware engine rsa encrypt fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_encrypt_arg = crypto_arg;
|
||||
struct memref_t data_out;
|
||||
data_out.buffer = rsa_encrypt_arg->buffer;
|
||||
data_out.size = rsa_encrypt_arg->size;
|
||||
|
||||
rsa_encrypt_arg++;
|
||||
struct memref_t data_in;
|
||||
data_in.buffer = rsa_encrypt_arg->buffer;
|
||||
data_in.size = rsa_encrypt_arg->size;
|
||||
|
||||
rsa_encrypt_arg++;
|
||||
struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_encrypt_arg->buffer;
|
||||
ret = check_rsa_pub_key_len(rsa_pub_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_encrypt_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_encrypt_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_encrypt(alg_type, rsa_pub_key, &rsa_params, &data_in, &data_out);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS) {
|
||||
hm_error("hardware engine do rsa encrypt failed. ret = %d\n", ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (data_out.size > crypto_arg->size) {
|
||||
hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size);
|
||||
ret = CRYPTO_ERROR_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
crypto_arg->size = data_out.size;
|
||||
|
||||
end:
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_encrypt_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_encrypt_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_encrypt_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_encrypt_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = fill_share_mem(rsa_encrypt_share_buf, buf_arg, ioctl_args->total_nums);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_encrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_encrypt_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_decrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_decrypt == NULL) {
|
||||
hm_error("hardware engine rsa decrypt fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_decrypt_arg = crypto_arg;
|
||||
struct memref_t data_out;
|
||||
data_out.buffer = rsa_decrypt_arg->buffer;
|
||||
data_out.size = rsa_decrypt_arg->size;
|
||||
|
||||
rsa_decrypt_arg++;
|
||||
struct memref_t data_in;
|
||||
data_in.buffer = rsa_decrypt_arg->buffer;
|
||||
data_in.size = rsa_decrypt_arg->size;
|
||||
|
||||
rsa_decrypt_arg++;
|
||||
struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_decrypt_arg->buffer;
|
||||
ret = check_rsa_private_key_len(private_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_decrypt_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_decrypt_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_decrypt(alg_type, private_key, &rsa_params, &data_in, &data_out);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS) {
|
||||
hm_error("hardware engine do rsa decrypt failed. ret = %d\n", ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (data_out.size > crypto_arg->size) {
|
||||
hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size);
|
||||
ret = CRYPTO_ERROR_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
crypto_arg->size = data_out.size;
|
||||
|
||||
end:
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_decrypt_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_decrypt_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_decrypt_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_decrypt_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = fill_share_mem(rsa_decrypt_share_buf, buf_arg, ioctl_args->total_nums);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_decrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_decrypt_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_sign_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_sign_digest == NULL) {
|
||||
hm_error("hardware engine rsa sign digest fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_sign_digest_arg = crypto_arg;
|
||||
struct memref_t signature;
|
||||
signature.buffer = rsa_sign_digest_arg->buffer;
|
||||
signature.size = rsa_sign_digest_arg->size;
|
||||
|
||||
rsa_sign_digest_arg++;
|
||||
struct memref_t digest;
|
||||
digest.buffer = rsa_sign_digest_arg->buffer;
|
||||
digest.size = rsa_sign_digest_arg->size;
|
||||
|
||||
rsa_sign_digest_arg++;
|
||||
struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_sign_digest_arg->buffer;
|
||||
ret = check_rsa_private_key_len(private_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_sign_digest_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_sign_digest_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_sign_digest(alg_type, private_key, &rsa_params, &digest, &signature);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS) {
|
||||
hm_error("hardware engine do rsa sign digest failed. ret = %d\n", ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (signature.size > crypto_arg->size) {
|
||||
hm_error("new signature > origin size. origin size = %u, new size = %u\n", crypto_arg->size, signature.size);
|
||||
ret = CRYPTO_ERROR_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
crypto_arg->size = signature.size;
|
||||
|
||||
end:
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_sign_digest_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_sign_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_sign_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_sign_digest_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = fill_share_mem(rsa_sign_share_buf, buf_arg, ioctl_args->total_nums);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_sign_share_buf, ioctl_args->buf_len, ioctl_args->buf,
|
||||
ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_sign_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_verify_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_verify_digest == NULL) {
|
||||
hm_error("hardware engine rsa verify digest fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_verify_digest_arg = crypto_arg;
|
||||
struct memref_t signature;
|
||||
signature.buffer = rsa_verify_digest_arg->buffer;
|
||||
signature.size = rsa_verify_digest_arg->size;
|
||||
|
||||
rsa_verify_digest_arg++;
|
||||
struct memref_t digest;
|
||||
digest.buffer = rsa_verify_digest_arg->buffer;
|
||||
digest.size = rsa_verify_digest_arg->size;
|
||||
|
||||
rsa_verify_digest_arg++;
|
||||
struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_verify_digest_arg->buffer;
|
||||
ret = check_rsa_pub_key_len(rsa_pub_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_verify_digest_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_verify_digest_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_verify_digest(alg_type, rsa_pub_key, &rsa_params, &digest, &signature);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("hardware engine do rsa verify digest failed. ret = %d\n", ret);
|
||||
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_verify_digest_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_verify_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_verify_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_verify_digest_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("rsa verify digest ops. ret = %d\n", ret);
|
||||
|
||||
driver_free_share_mem_and_buf_arg(rsa_verify_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "crypto_syscall_rsa.h"
|
||||
#include <securec.h>
|
||||
#include "tee_driver_module.h"
|
||||
#include <hmlog.h>
|
||||
#include "drv_param_ops.h"
|
||||
|
||||
static int32_t check_rsa_private_key_len(const struct rsa_priv_key_t *rsa_private_key)
|
||||
{
|
||||
if (rsa_private_key == NULL) {
|
||||
hm_error("rsa private key is NULL\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
bool check = (rsa_private_key->e_len > RSA_EXPONENT_LEN ||
|
||||
rsa_private_key->n_len > RSA_MAX_KEY_SIZE || rsa_private_key->d_len > RSA_MAX_KEY_SIZE ||
|
||||
rsa_private_key->p_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->q_len > RSA_MAX_KEY_SIZE_CRT ||
|
||||
rsa_private_key->dp_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->dq_len > RSA_MAX_KEY_SIZE_CRT ||
|
||||
rsa_private_key->qinv_len > RSA_MAX_KEY_SIZE_CRT);
|
||||
if (check) {
|
||||
hm_error("rsa private key size is invalid\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
return CRYPTO_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t check_rsa_pub_key_len(const struct rsa_pub_key_t *rsa_pub_key)
|
||||
{
|
||||
if (rsa_pub_key == NULL) {
|
||||
hm_error("rsa pub key is NULL\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
if (rsa_pub_key->e_len > RSA_EXPONENT_LEN || rsa_pub_key->n_len > RSA_MAX_KEY_SIZE) {
|
||||
hm_error("rsa pub key size is invalid\n");
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
}
|
||||
return CRYPTO_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t rsa_generate_keypair_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg,
|
||||
uint32_t key_size, bool crt_mode)
|
||||
{
|
||||
if (ops->rsa_generate_keypair == NULL) {
|
||||
hm_error("hardware engine rsa generate keypair fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct rsa_priv_key_t *key_pair = (struct rsa_priv_key_t *)(uintptr_t)crypto_arg->buffer;
|
||||
ret = check_rsa_private_key_len(key_pair);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
crypto_arg++;
|
||||
struct memref_t e_value;
|
||||
e_value.buffer = crypto_arg->buffer;
|
||||
e_value.size = crypto_arg->size;
|
||||
|
||||
ret = ops->rsa_generate_keypair(key_size, &e_value, crt_mode, key_pair);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("hardware engine do rsa generate keypair failed. ret = %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_generate_keypair_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_gen_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_gen_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_generate_keypair_ops(ops, buf_arg, ioctl_args->arg1, (bool)ioctl_args->arg2);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_gen_share_buf, ioctl_args->buf_len, ioctl_args->buf,
|
||||
ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_gen_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_encrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_encrypt == NULL) {
|
||||
hm_error("hardware engine rsa encrypt fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_encrypt_arg = crypto_arg;
|
||||
struct memref_t data_out;
|
||||
data_out.buffer = rsa_encrypt_arg->buffer;
|
||||
data_out.size = rsa_encrypt_arg->size;
|
||||
|
||||
rsa_encrypt_arg++;
|
||||
struct memref_t data_in;
|
||||
data_in.buffer = rsa_encrypt_arg->buffer;
|
||||
data_in.size = rsa_encrypt_arg->size;
|
||||
|
||||
rsa_encrypt_arg++;
|
||||
struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_encrypt_arg->buffer;
|
||||
ret = check_rsa_pub_key_len(rsa_pub_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_encrypt_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_encrypt_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_encrypt(alg_type, rsa_pub_key, &rsa_params, &data_in, &data_out);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS) {
|
||||
hm_error("hardware engine do rsa encrypt failed. ret = %d\n", ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (data_out.size > crypto_arg->size) {
|
||||
hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size);
|
||||
ret = CRYPTO_ERROR_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
crypto_arg->size = data_out.size;
|
||||
|
||||
end:
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_encrypt_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_encrypt_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_encrypt_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_encrypt_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = fill_share_mem(rsa_encrypt_share_buf, buf_arg, ioctl_args->total_nums);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_encrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_encrypt_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_decrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_decrypt == NULL) {
|
||||
hm_error("hardware engine rsa decrypt fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_decrypt_arg = crypto_arg;
|
||||
struct memref_t data_out;
|
||||
data_out.buffer = rsa_decrypt_arg->buffer;
|
||||
data_out.size = rsa_decrypt_arg->size;
|
||||
|
||||
rsa_decrypt_arg++;
|
||||
struct memref_t data_in;
|
||||
data_in.buffer = rsa_decrypt_arg->buffer;
|
||||
data_in.size = rsa_decrypt_arg->size;
|
||||
|
||||
rsa_decrypt_arg++;
|
||||
struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_decrypt_arg->buffer;
|
||||
ret = check_rsa_private_key_len(private_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_decrypt_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_decrypt_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_decrypt(alg_type, private_key, &rsa_params, &data_in, &data_out);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS) {
|
||||
hm_error("hardware engine do rsa decrypt failed. ret = %d\n", ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (data_out.size > crypto_arg->size) {
|
||||
hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size);
|
||||
ret = CRYPTO_ERROR_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
crypto_arg->size = data_out.size;
|
||||
|
||||
end:
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_decrypt_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_decrypt_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_decrypt_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_decrypt_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = fill_share_mem(rsa_decrypt_share_buf, buf_arg, ioctl_args->total_nums);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_decrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_decrypt_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_sign_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_sign_digest == NULL) {
|
||||
hm_error("hardware engine rsa sign digest fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_sign_digest_arg = crypto_arg;
|
||||
struct memref_t signature;
|
||||
signature.buffer = rsa_sign_digest_arg->buffer;
|
||||
signature.size = rsa_sign_digest_arg->size;
|
||||
|
||||
rsa_sign_digest_arg++;
|
||||
struct memref_t digest;
|
||||
digest.buffer = rsa_sign_digest_arg->buffer;
|
||||
digest.size = rsa_sign_digest_arg->size;
|
||||
|
||||
rsa_sign_digest_arg++;
|
||||
struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_sign_digest_arg->buffer;
|
||||
ret = check_rsa_private_key_len(private_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_sign_digest_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_sign_digest_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_sign_digest(alg_type, private_key, &rsa_params, &digest, &signature);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS) {
|
||||
hm_error("hardware engine do rsa sign digest failed. ret = %d\n", ret);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (signature.size > crypto_arg->size) {
|
||||
hm_error("new signature > origin size. origin size = %u, new size = %u\n", crypto_arg->size, signature.size);
|
||||
ret = CRYPTO_ERROR_OUT_OF_MEMORY;
|
||||
goto end;
|
||||
}
|
||||
crypto_arg->size = signature.size;
|
||||
|
||||
end:
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_sign_digest_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_sign_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_sign_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_sign_digest_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = fill_share_mem(rsa_sign_share_buf, buf_arg, ioctl_args->total_nums);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
goto end;
|
||||
|
||||
ret = copy_to_client((uintptr_t)rsa_sign_share_buf, ioctl_args->buf_len, ioctl_args->buf,
|
||||
ioctl_args->buf_len);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("copy to client failed. ret = %d\n", ret);
|
||||
|
||||
end:
|
||||
driver_free_share_mem_and_buf_arg(rsa_sign_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t rsa_verify_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type)
|
||||
{
|
||||
if (ops->rsa_verify_digest == NULL) {
|
||||
hm_error("hardware engine rsa verify digest fun is null\n");
|
||||
return CRYPTO_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
int32_t ret = do_power_on(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
struct memref_t *rsa_verify_digest_arg = crypto_arg;
|
||||
struct memref_t signature;
|
||||
signature.buffer = rsa_verify_digest_arg->buffer;
|
||||
signature.size = rsa_verify_digest_arg->size;
|
||||
|
||||
rsa_verify_digest_arg++;
|
||||
struct memref_t digest;
|
||||
digest.buffer = rsa_verify_digest_arg->buffer;
|
||||
digest.size = rsa_verify_digest_arg->size;
|
||||
|
||||
rsa_verify_digest_arg++;
|
||||
struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_verify_digest_arg->buffer;
|
||||
ret = check_rsa_pub_key_len(rsa_pub_key);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
rsa_verify_digest_arg++;
|
||||
struct asymmetric_params_t rsa_params;
|
||||
ret = restore_attrs(&rsa_params, rsa_verify_digest_arg);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = ops->rsa_verify_digest(alg_type, rsa_pub_key, &rsa_params, &digest, &signature);
|
||||
do_power_off(ops);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("hardware engine do rsa verify digest failed. ret = %d\n", ret);
|
||||
|
||||
if (rsa_params.attribute != 0)
|
||||
free((void *)(uintptr_t)rsa_params.attribute);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t rsa_verify_digest_call(const struct drv_data *drv, unsigned long args,
|
||||
uint32_t args_len, const struct crypto_drv_ops_t *ops)
|
||||
{
|
||||
uint8_t *rsa_verify_share_buf = NULL;
|
||||
struct memref_t *buf_arg = NULL;
|
||||
|
||||
if (check_hal_params_is_invalid(drv, args, args_len, ops))
|
||||
return CRYPTO_BAD_PARAMETERS;
|
||||
|
||||
struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args;
|
||||
|
||||
int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_verify_share_buf, &buf_arg, ioctl_args);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = rsa_verify_digest_ops(ops, buf_arg, ioctl_args->arg1);
|
||||
if (ret != CRYPTO_SUCCESS)
|
||||
hm_error("rsa verify digest ops. ret = %d\n", ret);
|
||||
|
||||
driver_free_share_mem_and_buf_arg(rsa_verify_share_buf, ioctl_args->buf_len, buf_arg,
|
||||
ioctl_args->total_nums * sizeof(struct memref_t));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: Crypto API at driver adaptor.
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef CRYPTO_SYSCALL_RSA_H
|
||||
#define CRYPTO_SYSCALL_RSA_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: define drv main function
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
||||
* Description: shared mem API, usually copied in booting period
|
||||
* Create: 2020-06
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_BOOT_SHAREDMEM_H
|
||||
#define DRIVERS_BOOT_SHAREDMEM_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
|
||||
* Description: moved from teeos, driver module init function and structure
|
||||
* Create: 2019-11-08
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_DRV_MODULE_H
|
||||
#define DRIVERS_DRV_MODULE_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
|
||||
* Description: Header file for driver params
|
||||
* Create: 2020-04-18
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef PLATDRV_INCLUDE_DRV_PARAM_TYPE_H
|
||||
#define PLATDRV_INCLUDE_DRV_PARAM_TYPE_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
|
||||
* Description: moved from teeos, register operation marco definition
|
||||
* Create: 2019-11-08
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_REGISTER_OPS_H
|
||||
#define DRIVERS_REGISTER_OPS_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
|
||||
* Description: moved from teeos, interrupt type marco definition
|
||||
* Create: 2019-11-08
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_SECURE_GIC_COMMON_H
|
||||
#define DRIVERS_SECURE_GIC_COMMON_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
|
||||
* Description: moved from teeos, debug print function
|
||||
* Create: 2019-11-08
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_SRE_DEBUG_H
|
||||
#define DRIVERS_SRE_DEBUG_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
|
||||
* Description: moved from teeos, print function and macro definition
|
||||
* Create: 2019-11-08
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_SRE_LOG_H
|
||||
#define DRIVERS_SRE_LOG_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved.
|
||||
* Description: moved from teeos, old msg function, should change
|
||||
* Create: 2019-11-14
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVER_SRE_MSG_H
|
||||
#define DRIVER_SRE_MSG_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: task definition used by gtask and platdrv
|
||||
* Create: 2022-05-12
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef LIBTEEOS_SRE_TASK_H
|
||||
#define LIBTEEOS_SRE_TASK_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: tee driver module structure, export to driver developer
|
||||
* Create: 2021-03-01
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef TEE_DRIVER_MODULE_H
|
||||
#define TEE_DRIVER_MODULE_H
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# misc_driver compile rule
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
DRIVER := misc_driver.elf
|
||||
SCRAMBLE_ME :=
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: shared mem API
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "drv_sharedmem.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: shared mem API
|
||||
* Create: 2022-01
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_SHAREDMEM_H
|
||||
#define DRIVERS_SHAREDMEM_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: shared mem API
|
||||
* Create: 2022-01
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include <securec.h>
|
||||
#include "tee_log.h"
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: get oemkey from shared mem
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "oemkey_driver.h"
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: get oemkey from shared mem
|
||||
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef KUNPENG_DRV_SECUREBOOT_H
|
||||
#define KUNPENG_DRV_SECUREBOOT_H
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# tee_misc_driver compile rule
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
DRIVER := tee_misc_driver.elf
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: shared mem API
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "drv_sharedmem.h"
|
||||
#include <securec.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: shared mem API
|
||||
* Create: 2022-01
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRIVERS_SHAREDMEM_H
|
||||
#define DRIVERS_SHAREDMEM_H
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: shared mem API
|
||||
* Create: 2022-01
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include <securec.h>
|
||||
#include "tee_log.h"
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: get oemkey from shared mem
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "tee_oemkey_driver.h"
|
||||
#include <string.h>
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: get oemkey from shared mem
|
||||
|
||||
* Create: 2022-01-13
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef KUNPENG_DRV_SECUREBOOT_H
|
||||
#define KUNPENG_DRV_SECUREBOOT_H
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# drvmgr compile rule
|
||||
# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
# Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
# Licensed under the Mulan PSL v2.
|
||||
# You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
# You may obtain a copy of Mulan PSL v2 at:
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
# PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
DRIVER := drvmgr.elf
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: define register and init base driver node function
|
||||
* Create: 2022-01-07
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "base_drv_node.h"
|
||||
#include <procmgr_ext.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
|
||||
* Description: drvcaller and drv node structure
|
||||
* Create: 2022-01-07
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef BASE_DRV_NODE_H
|
||||
#define BASE_DRV_NODE_H
|
||||
|
||||
+111
-105
@@ -1,105 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: define auth function
|
||||
* Create: 2021-03-17
|
||||
*/
|
||||
#include "drv_auth.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <tee_log.h>
|
||||
#include <tee_drv_internal.h>
|
||||
#include "drv_dyn_conf_mgr.h"
|
||||
#include "drvcall_dyn_conf_mgr.h"
|
||||
|
||||
static int32_t get_mac_perm_by_uuid(const struct drv_conf_t *drv_conf, const struct tee_uuid *srv_uuid,
|
||||
uint64_t *mac_perm)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < drv_conf->mac_info_list_size; i++) {
|
||||
struct drv_mac_info_t drv_mac_info = drv_conf->mac_info_list[i];
|
||||
|
||||
if (memcmp(&drv_mac_info.uuid, srv_uuid, sizeof(struct tee_uuid)) == 0) {
|
||||
if (mac_perm != NULL)
|
||||
*mac_perm = drv_mac_info.perm;
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
}
|
||||
tloge("cannot find uuid %08x-%04x-%04x in mac list\n",
|
||||
srv_uuid->timeLow, srv_uuid->timeMid, srv_uuid->timeHiAndVersion);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
static int32_t get_perm_by_service_name_in_perm_apply_list(const struct task_tlv *tlv,
|
||||
const char *service_name, uint32_t service_name_size,
|
||||
uint64_t *perm)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < tlv->drvcall_perm_apply_list_size; i++) {
|
||||
struct drvcall_perm_apply_item_t item = tlv->drvcall_perm_apply_list[i];
|
||||
if (item.name_size != service_name_size)
|
||||
continue;
|
||||
|
||||
if (strncmp(item.name, service_name, item.name_size) == 0) {
|
||||
if (perm != NULL)
|
||||
*perm = item.perm;
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
tloge("cannot find service name %s in perm apply list\n", service_name);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len)
|
||||
{
|
||||
if (call_node == NULL || drv_name == NULL || name_len == 0) {
|
||||
tloge("invalid param\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if TA have registed drv name in perm apply list */
|
||||
if (get_perm_by_service_name_in_perm_apply_list(&call_node->tlv, drv_name, name_len, NULL) != TEE_SUCCESS)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid)
|
||||
{
|
||||
if (uuid == NULL || drv_conf == NULL) {
|
||||
tloge("invalid uuid or drv_conf\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* if drv not have mac list, all TA can open */
|
||||
if (drv_conf->mac_info_list_size == 0)
|
||||
return true;
|
||||
|
||||
/* check if TA in drv's mac list */
|
||||
if (get_mac_perm_by_uuid(drv_conf, uuid, NULL) == TEE_SUCCESS)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm)
|
||||
{
|
||||
if (call_node == NULL || dnode == NULL || dnode->tlv.drv_conf == NULL || perm == NULL) {
|
||||
tloge("invalid param\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ret;
|
||||
if (dnode->tlv.drv_conf->mac_info_list_size == 0) {
|
||||
tlogd("no mac perm, use drvcaller perm\n");
|
||||
ret = get_perm_by_service_name_in_perm_apply_list(&call_node->tlv,
|
||||
dnode->tlv.drv_conf->mani.service_name, dnode->tlv.drv_conf->mani.service_name_size, perm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = get_mac_perm_by_uuid(dnode->tlv.drv_conf, &call_node->tlv.uuid, perm);
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "drv_auth.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <tee_log.h>
|
||||
#include <tee_drv_internal.h>
|
||||
#include "drv_dyn_conf_mgr.h"
|
||||
#include "drvcall_dyn_conf_mgr.h"
|
||||
|
||||
static int32_t get_mac_perm_by_uuid(const struct drv_conf_t *drv_conf, const struct tee_uuid *srv_uuid,
|
||||
uint64_t *mac_perm)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < drv_conf->mac_info_list_size; i++) {
|
||||
struct drv_mac_info_t drv_mac_info = drv_conf->mac_info_list[i];
|
||||
|
||||
if (memcmp(&drv_mac_info.uuid, srv_uuid, sizeof(struct tee_uuid)) == 0) {
|
||||
if (mac_perm != NULL)
|
||||
*mac_perm = drv_mac_info.perm;
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
}
|
||||
tloge("cannot find uuid %08x-%04x-%04x in mac list\n",
|
||||
srv_uuid->timeLow, srv_uuid->timeMid, srv_uuid->timeHiAndVersion);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
static int32_t get_perm_by_service_name_in_perm_apply_list(const struct task_tlv *tlv,
|
||||
const char *service_name, uint32_t service_name_size,
|
||||
uint64_t *perm)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < tlv->drvcall_perm_apply_list_size; i++) {
|
||||
struct drvcall_perm_apply_item_t item = tlv->drvcall_perm_apply_list[i];
|
||||
if (item.name_size != service_name_size)
|
||||
continue;
|
||||
|
||||
if (strncmp(item.name, service_name, item.name_size) == 0) {
|
||||
if (perm != NULL)
|
||||
*perm = item.perm;
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
tloge("cannot find service name %s in perm apply list\n", service_name);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len)
|
||||
{
|
||||
if (call_node == NULL || drv_name == NULL || name_len == 0) {
|
||||
tloge("invalid param\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if TA have registed drv name in perm apply list */
|
||||
if (get_perm_by_service_name_in_perm_apply_list(&call_node->tlv, drv_name, name_len, NULL) != TEE_SUCCESS)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid)
|
||||
{
|
||||
if (uuid == NULL || drv_conf == NULL) {
|
||||
tloge("invalid uuid or drv_conf\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* if drv not have mac list, all TA can open */
|
||||
if (drv_conf->mac_info_list_size == 0)
|
||||
return true;
|
||||
|
||||
/* check if TA in drv's mac list */
|
||||
if (get_mac_perm_by_uuid(drv_conf, uuid, NULL) == TEE_SUCCESS)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm)
|
||||
{
|
||||
if (call_node == NULL || dnode == NULL || dnode->tlv.drv_conf == NULL || perm == NULL) {
|
||||
tloge("invalid param\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t ret;
|
||||
if (dnode->tlv.drv_conf->mac_info_list_size == 0) {
|
||||
tlogd("no mac perm, use drvcaller perm\n");
|
||||
ret = get_perm_by_service_name_in_perm_apply_list(&call_node->tlv,
|
||||
dnode->tlv.drv_conf->mani.service_name, dnode->tlv.drv_conf->mani.service_name_size, perm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = get_mac_perm_by_uuid(dnode->tlv.drv_conf, &call_node->tlv.uuid, perm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: define auth function
|
||||
* Create: 2021-03-17
|
||||
*/
|
||||
#ifndef DRVMGR_SRC_DRV_AUTH_H
|
||||
#define DRVMGR_SRC_DRV_AUTH_H
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <tee_defines.h>
|
||||
#include "drvcall_dyn_conf_mgr.h"
|
||||
#include "drv_dyn_conf_mgr.h"
|
||||
#include "task_mgr.h"
|
||||
|
||||
bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid);
|
||||
bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len);
|
||||
int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm);
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRVMGR_SRC_DRV_AUTH_H
|
||||
#define DRVMGR_SRC_DRV_AUTH_H
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <tee_defines.h>
|
||||
#include "drvcall_dyn_conf_mgr.h"
|
||||
#include "drv_dyn_conf_mgr.h"
|
||||
#include "task_mgr.h"
|
||||
|
||||
bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid);
|
||||
bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len);
|
||||
int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: drvmgr dispatch function define when receive cmd
|
||||
* Create: 2021-03-01
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#include "drv_dispatch.h"
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: declare drvmgr dispatch function when receive cmd
|
||||
* Create: 2021-03-01
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
#ifndef DRVMGR_SRC_DRV_DISPATCH_H
|
||||
#define DRVMGR_SRC_DRV_DISPATCH_H
|
||||
|
||||
@@ -1,345 +1,351 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: handle drv dyn perm info
|
||||
* Create: 2021-02-03
|
||||
*/
|
||||
|
||||
#include "drv_dyn_conf_mgr.h"
|
||||
#include <tee_log.h>
|
||||
#include <cs.h>
|
||||
#include <libdrv_frame.h>
|
||||
#include <ta_framework.h>
|
||||
#include <dyn_conf_dispatch_inf.h>
|
||||
#include <target_type.h>
|
||||
#include "drv_fd_ops.h"
|
||||
#include "drv_param_ops.h"
|
||||
#include "drv_process_mgr.h"
|
||||
|
||||
void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag)
|
||||
{
|
||||
if (drv_conf == NULL) {
|
||||
tloge("invalid drv conf\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_IO_MAP_LIST && drv_conf->io_map_list != NULL) {
|
||||
free(drv_conf->io_map_list);
|
||||
drv_conf->io_map_list = NULL;
|
||||
drv_conf->io_map_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_IRQ_LIST && drv_conf->irq_list != NULL) {
|
||||
free(drv_conf->irq_list);
|
||||
drv_conf->irq_list = NULL;
|
||||
drv_conf->irq_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_MAP_SECURE_LIST && drv_conf->map_secure_list != NULL) {
|
||||
free(drv_conf->map_secure_list);
|
||||
drv_conf->map_secure_list = NULL;
|
||||
drv_conf->map_secure_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_MAP_NOSECURE_LIST && drv_conf->map_nosecure_list != NULL) {
|
||||
free(drv_conf->map_nosecure_list);
|
||||
drv_conf->map_nosecure_list = NULL;
|
||||
drv_conf->map_nosecure_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_MAC_INFO_LIST && drv_conf->mac_info_list != NULL) {
|
||||
free(drv_conf->mac_info_list);
|
||||
drv_conf->mac_info_list = NULL;
|
||||
drv_conf->mac_info_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_CMD_PERM_LIST && drv_conf->cmd_perm_list != NULL) {
|
||||
free(drv_conf->cmd_perm_list);
|
||||
drv_conf->cmd_perm_list = NULL;
|
||||
drv_conf->cmd_perm_list_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEE_SUPPORT_DYN_CONF_DEBUG
|
||||
static void dump_drv_basic_info(const struct drv_basic_info_t *drv_basic_info)
|
||||
{
|
||||
if (drv_basic_info->upgrade)
|
||||
tlogi("[drv dyn conf] upgrade: true\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] upgrade: false\n");
|
||||
|
||||
if (drv_basic_info->virt2phys)
|
||||
tlogi("[drv dyn conf] virt2phys: true\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] virtphys: false\n");
|
||||
|
||||
tlogi("[drv dyn conf] thread_limit: %u\n", drv_basic_info->thread_limit);
|
||||
|
||||
if (drv_basic_info->exception_mode == DYN_CONF_SYSCRASH_TAG)
|
||||
tlogi("[drv dyn conf] exception_mode: syscrash\n");
|
||||
else if (drv_basic_info->exception_mode == DYN_CONF_RESTART_TAG)
|
||||
tlogi("[drv dyn conf] exception_mode: restart\n");
|
||||
else if (drv_basic_info->exception_mode == DYN_CONF_DDOS_TAG)
|
||||
tlogi("[drv dyn conf] exception_mode: ddos\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] exception_mode: unknown\n");
|
||||
}
|
||||
|
||||
static void dump_drv_mani(const struct drv_mani_t *mani)
|
||||
{
|
||||
tlogi("[drv dyn conf] UUID %x\n", mani->srv_uuid.timeLow);
|
||||
tlogi("[drv dyn conf] service name %s\n", mani->service_name);
|
||||
|
||||
if (mani->keep_alive)
|
||||
tlogi("[drv dyn conf] keep_alive is true\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] keep_alive is false\n");
|
||||
|
||||
tlogi("[drv dyn conf] data size 0x%x\n", mani->data_size);
|
||||
tlogi("[drv dyn conf] stack size 0x%x\n", mani->stack_size);
|
||||
}
|
||||
|
||||
static void dump_drv_io_map_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] io map list size %u\n", drv_conf->io_map_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->io_map_list_size; i++)
|
||||
tlogi("[drv dyn conf] iomap region size %llx\n",
|
||||
(unsigned long long)(drv_conf->io_map_list[i].end -
|
||||
drv_conf->io_map_list[i].start));
|
||||
}
|
||||
|
||||
static void dump_drv_irq_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] irq list size %u\n", drv_conf->irq_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->irq_list_size; i++)
|
||||
tlogi("[drv dyn conf] irq %llu\n", (unsigned long long)drv_conf->irq_list[i]);
|
||||
}
|
||||
|
||||
static void dump_drv_map_secure_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] map secure list size %u\n", drv_conf->map_secure_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->map_secure_list_size; i++) {
|
||||
struct tee_uuid uuid = drv_conf->map_secure_list[i].uuid;
|
||||
tlogi("[drv dyn conf] map_secure uuid %08x-%04x-%04x\n",
|
||||
uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion);
|
||||
tlogi("[drv dyn conf] map_secure region size %llx\n",
|
||||
(unsigned long long)(drv_conf->map_secure_list[i].region.end -
|
||||
drv_conf->map_secure_list[i].region.start));
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_drv_map_nosecure_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] map nosecure list size %u\n", drv_conf->map_nosecure_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->map_nosecure_list_size; i++) {
|
||||
struct tee_uuid uuid = drv_conf->map_nosecure_list[i].uuid;
|
||||
tlogi("[drv dyn conf] map_nosecure uuid %08x-%04x-%04x\n",
|
||||
uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion);
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_drv_mac_info(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] drv mac list size %u\n", drv_conf->mac_info_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->mac_info_list_size; i++) {
|
||||
struct tee_uuid uuid = drv_conf->mac_info_list[i].uuid;
|
||||
tlogi("[drv dyn conf] mac info uuid %08x-%04x-%04x perm %llx\n",
|
||||
uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion,
|
||||
(unsigned long long)drv_conf->mac_info_list[i].perm);
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_drv_cmd_perm_info(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] drv cmd perm list size %u\n", drv_conf->cmd_perm_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->cmd_perm_list_size; i++)
|
||||
tlogi("[drv dyn conf] cmd %llx permission %llx\n",
|
||||
(unsigned long long)drv_conf->cmd_perm_list[i].cmd,
|
||||
(unsigned long long)drv_conf->cmd_perm_list[i].perm);
|
||||
}
|
||||
|
||||
void dump_drv_conf(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
if (drv_conf == NULL) {
|
||||
tloge("invalid drv conf\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dump_drv_mani(&drv_conf->mani);
|
||||
dump_drv_basic_info(&drv_conf->drv_basic_info);
|
||||
dump_drv_io_map_list(drv_conf);
|
||||
dump_drv_irq_list(drv_conf);
|
||||
dump_drv_map_secure_list(drv_conf);
|
||||
dump_drv_map_nosecure_list(drv_conf);
|
||||
dump_drv_mac_info(drv_conf);
|
||||
dump_drv_cmd_perm_info(drv_conf);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t receive_drv_conf_list(void **list, uint16_t list_size, uint32_t item_size)
|
||||
{
|
||||
if (list == NULL || item_size == 0 || item_size >= MAX_IMAGE_LEN) {
|
||||
tloge("invalied params while receive drv conf list\n");
|
||||
return TEE_ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
if (*list == NULL || list_size == 0)
|
||||
return TEE_SUCCESS;
|
||||
|
||||
/* list_size < 0xffff means tmp_size cannot larger than 0xFFFFFFFF */
|
||||
uint32_t tmp_size = list_size * item_size;
|
||||
if (tmp_size >= MAX_IMAGE_LEN || list_size * item_size < item_size) {
|
||||
tloge("tmp size is too large or overflow while receive drv conf list %u\n", item_size);
|
||||
return TEE_ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
void *tmp_list = malloc(tmp_size);
|
||||
if (tmp_list == NULL) {
|
||||
tloge("malloc tmp_list failed\n");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
if (copy_from_client((uint64_t)(uintptr_t)(*list), tmp_size, (uintptr_t)tmp_list, tmp_size) != TEE_SUCCESS) {
|
||||
tloge("copy_from_client tmp_list failed\n");
|
||||
free(tmp_list);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
*list = tmp_list;
|
||||
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf)
|
||||
{
|
||||
uint32_t receive_flag = 0;
|
||||
if (drv_conf == NULL) {
|
||||
tloge("invalid receive param\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* receive drv_conf iomap list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->io_map_list,
|
||||
drv_conf->io_map_list_size, sizeof(struct addr_region_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_IO_MAP_LIST;
|
||||
|
||||
/* receive irq list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->irq_list,
|
||||
drv_conf->irq_list_size, sizeof(uint64_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_IRQ_LIST;
|
||||
|
||||
/* receive map secure list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->map_secure_list,
|
||||
drv_conf->map_secure_list_size, sizeof(struct drv_map_secure_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_MAP_SECURE_LIST;
|
||||
|
||||
/* receive map nosecure list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->map_nosecure_list,
|
||||
drv_conf->map_nosecure_list_size, sizeof(struct drv_map_nosecure_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_MAP_NOSECURE_LIST;
|
||||
|
||||
/* receive mac info list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->mac_info_list,
|
||||
drv_conf->mac_info_list_size, sizeof(struct drv_mac_info_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_MAC_INFO_LIST;
|
||||
|
||||
/* receive cmd perm list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->cmd_perm_list,
|
||||
drv_conf->cmd_perm_list_size, sizeof(struct drv_cmd_perm_info_t)) != 0)
|
||||
goto err_out;
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
free_drv_conf_list(drv_conf, receive_flag);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t check_drv_node_state(struct task_node *node)
|
||||
{
|
||||
int32_t func_ret = DRV_FAIL;
|
||||
|
||||
if (node == NULL || node->tlv.drv_conf == NULL) {
|
||||
tloge("invalid node\n");
|
||||
return DRV_FAIL;
|
||||
}
|
||||
|
||||
int32_t ret = drv_robust_mutex_lock(&node->state_mtx);
|
||||
if (ret != 0) {
|
||||
tloge("get state mtx fail\n");
|
||||
return DRV_FAIL;
|
||||
}
|
||||
|
||||
switch (node->state) {
|
||||
case TASK_LOAD:
|
||||
node->state = TASK_SPAWN;
|
||||
func_ret = DRV_NEED_SPAWN;
|
||||
break;
|
||||
case TASK_SPAWN:
|
||||
while (node->state == TASK_SPAWN) {
|
||||
tloge("drv:%s is spawn by other thread, just wait\n", node->tlv.drv_conf->mani.service_name);
|
||||
ret = pthread_cond_wait(&node->state_cond, &node->state_mtx);
|
||||
if (ret != 0) {
|
||||
tloge("something wrong, drv:%s cond wait fail:0x%x\n", node->tlv.drv_conf->mani.service_name, ret);
|
||||
goto unlock_mtx;
|
||||
}
|
||||
}
|
||||
|
||||
if (node->state == TASK_NORMAL)
|
||||
func_ret = DRV_SUCC;
|
||||
else
|
||||
tloge("something wrong, wait spawn fail state:0x%x\n", node->state);
|
||||
break;
|
||||
case TASK_NORMAL:
|
||||
func_ret = DRV_SUCC;
|
||||
break;
|
||||
default:
|
||||
/* when drv spawn fail, just return fail */
|
||||
tloge("something wrong, drv:%s state:%d\n", node->tlv.drv_conf->mani.service_name, node->state);
|
||||
}
|
||||
|
||||
unlock_mtx:
|
||||
ret = pthread_mutex_unlock(&node->state_mtx);
|
||||
if (ret != 0)
|
||||
tloge("something wrong, unlock mtx in drv state fail\n");
|
||||
|
||||
return func_ret;
|
||||
}
|
||||
|
||||
void broadcast_drv_state(struct task_node *node, bool spawn_succ)
|
||||
{
|
||||
if (node == NULL) {
|
||||
tloge("invalid node\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t ret = drv_robust_mutex_lock(&node->state_mtx);
|
||||
if (ret != 0) {
|
||||
tloge("get state mtx fail\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (node->state != TASK_SPAWN)
|
||||
tloge("something wrong, node->state:%d not DRV_SPAWN\n", node->state);
|
||||
|
||||
if (spawn_succ)
|
||||
node->state = TASK_NORMAL;
|
||||
else
|
||||
node->state = TASK_SPAWN_FAIL;
|
||||
|
||||
pthread_cond_broadcast(&node->state_cond);
|
||||
|
||||
ret = pthread_mutex_unlock(&node->state_mtx);
|
||||
if (ret != 0)
|
||||
tloge("something wrong, unlock stat mtx fail\n");
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#include "drv_dyn_conf_mgr.h"
|
||||
#include <tee_log.h>
|
||||
#include <cs.h>
|
||||
#include <libdrv_frame.h>
|
||||
#include <ta_framework.h>
|
||||
#include <dyn_conf_dispatch_inf.h>
|
||||
#include <target_type.h>
|
||||
#include "drv_fd_ops.h"
|
||||
#include "drv_param_ops.h"
|
||||
#include "drv_process_mgr.h"
|
||||
|
||||
void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag)
|
||||
{
|
||||
if (drv_conf == NULL) {
|
||||
tloge("invalid drv conf\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_IO_MAP_LIST && drv_conf->io_map_list != NULL) {
|
||||
free(drv_conf->io_map_list);
|
||||
drv_conf->io_map_list = NULL;
|
||||
drv_conf->io_map_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_IRQ_LIST && drv_conf->irq_list != NULL) {
|
||||
free(drv_conf->irq_list);
|
||||
drv_conf->irq_list = NULL;
|
||||
drv_conf->irq_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_MAP_SECURE_LIST && drv_conf->map_secure_list != NULL) {
|
||||
free(drv_conf->map_secure_list);
|
||||
drv_conf->map_secure_list = NULL;
|
||||
drv_conf->map_secure_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_MAP_NOSECURE_LIST && drv_conf->map_nosecure_list != NULL) {
|
||||
free(drv_conf->map_nosecure_list);
|
||||
drv_conf->map_nosecure_list = NULL;
|
||||
drv_conf->map_nosecure_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_MAC_INFO_LIST && drv_conf->mac_info_list != NULL) {
|
||||
free(drv_conf->mac_info_list);
|
||||
drv_conf->mac_info_list = NULL;
|
||||
drv_conf->mac_info_list_size = 0;
|
||||
}
|
||||
|
||||
if (receive_flag >= RECEIVE_CMD_PERM_LIST && drv_conf->cmd_perm_list != NULL) {
|
||||
free(drv_conf->cmd_perm_list);
|
||||
drv_conf->cmd_perm_list = NULL;
|
||||
drv_conf->cmd_perm_list_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEE_SUPPORT_DYN_CONF_DEBUG
|
||||
static void dump_drv_basic_info(const struct drv_basic_info_t *drv_basic_info)
|
||||
{
|
||||
if (drv_basic_info->upgrade)
|
||||
tlogi("[drv dyn conf] upgrade: true\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] upgrade: false\n");
|
||||
|
||||
if (drv_basic_info->virt2phys)
|
||||
tlogi("[drv dyn conf] virt2phys: true\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] virtphys: false\n");
|
||||
|
||||
tlogi("[drv dyn conf] thread_limit: %u\n", drv_basic_info->thread_limit);
|
||||
|
||||
if (drv_basic_info->exception_mode == DYN_CONF_SYSCRASH_TAG)
|
||||
tlogi("[drv dyn conf] exception_mode: syscrash\n");
|
||||
else if (drv_basic_info->exception_mode == DYN_CONF_RESTART_TAG)
|
||||
tlogi("[drv dyn conf] exception_mode: restart\n");
|
||||
else if (drv_basic_info->exception_mode == DYN_CONF_DDOS_TAG)
|
||||
tlogi("[drv dyn conf] exception_mode: ddos\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] exception_mode: unknown\n");
|
||||
}
|
||||
|
||||
static void dump_drv_mani(const struct drv_mani_t *mani)
|
||||
{
|
||||
tlogi("[drv dyn conf] UUID %x\n", mani->srv_uuid.timeLow);
|
||||
tlogi("[drv dyn conf] service name %s\n", mani->service_name);
|
||||
|
||||
if (mani->keep_alive)
|
||||
tlogi("[drv dyn conf] keep_alive is true\n");
|
||||
else
|
||||
tlogi("[drv dyn conf] keep_alive is false\n");
|
||||
|
||||
tlogi("[drv dyn conf] data size 0x%x\n", mani->data_size);
|
||||
tlogi("[drv dyn conf] stack size 0x%x\n", mani->stack_size);
|
||||
}
|
||||
|
||||
static void dump_drv_io_map_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] io map list size %u\n", drv_conf->io_map_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->io_map_list_size; i++)
|
||||
tlogi("[drv dyn conf] iomap region size %llx\n",
|
||||
(unsigned long long)(drv_conf->io_map_list[i].end -
|
||||
drv_conf->io_map_list[i].start));
|
||||
}
|
||||
|
||||
static void dump_drv_irq_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] irq list size %u\n", drv_conf->irq_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->irq_list_size; i++)
|
||||
tlogi("[drv dyn conf] irq %llu\n", (unsigned long long)drv_conf->irq_list[i]);
|
||||
}
|
||||
|
||||
static void dump_drv_map_secure_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] map secure list size %u\n", drv_conf->map_secure_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->map_secure_list_size; i++) {
|
||||
struct tee_uuid uuid = drv_conf->map_secure_list[i].uuid;
|
||||
tlogi("[drv dyn conf] map_secure uuid %08x-%04x-%04x\n",
|
||||
uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion);
|
||||
tlogi("[drv dyn conf] map_secure region size %llx\n",
|
||||
(unsigned long long)(drv_conf->map_secure_list[i].region.end -
|
||||
drv_conf->map_secure_list[i].region.start));
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_drv_map_nosecure_list(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] map nosecure list size %u\n", drv_conf->map_nosecure_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->map_nosecure_list_size; i++) {
|
||||
struct tee_uuid uuid = drv_conf->map_nosecure_list[i].uuid;
|
||||
tlogi("[drv dyn conf] map_nosecure uuid %08x-%04x-%04x\n",
|
||||
uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion);
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_drv_mac_info(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] drv mac list size %u\n", drv_conf->mac_info_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->mac_info_list_size; i++) {
|
||||
struct tee_uuid uuid = drv_conf->mac_info_list[i].uuid;
|
||||
tlogi("[drv dyn conf] mac info uuid %08x-%04x-%04x perm %llx\n",
|
||||
uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion,
|
||||
(unsigned long long)drv_conf->mac_info_list[i].perm);
|
||||
}
|
||||
}
|
||||
|
||||
static void dump_drv_cmd_perm_info(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
tlogi("[drv dyn conf] drv cmd perm list size %u\n", drv_conf->cmd_perm_list_size);
|
||||
uint32_t i;
|
||||
for (i = 0; i < drv_conf->cmd_perm_list_size; i++)
|
||||
tlogi("[drv dyn conf] cmd %llx permission %llx\n",
|
||||
(unsigned long long)drv_conf->cmd_perm_list[i].cmd,
|
||||
(unsigned long long)drv_conf->cmd_perm_list[i].perm);
|
||||
}
|
||||
|
||||
void dump_drv_conf(const struct drv_conf_t *drv_conf)
|
||||
{
|
||||
if (drv_conf == NULL) {
|
||||
tloge("invalid drv conf\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dump_drv_mani(&drv_conf->mani);
|
||||
dump_drv_basic_info(&drv_conf->drv_basic_info);
|
||||
dump_drv_io_map_list(drv_conf);
|
||||
dump_drv_irq_list(drv_conf);
|
||||
dump_drv_map_secure_list(drv_conf);
|
||||
dump_drv_map_nosecure_list(drv_conf);
|
||||
dump_drv_mac_info(drv_conf);
|
||||
dump_drv_cmd_perm_info(drv_conf);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t receive_drv_conf_list(void **list, uint16_t list_size, uint32_t item_size)
|
||||
{
|
||||
if (list == NULL || item_size == 0 || item_size >= MAX_IMAGE_LEN) {
|
||||
tloge("invalied params while receive drv conf list\n");
|
||||
return TEE_ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
if (*list == NULL || list_size == 0)
|
||||
return TEE_SUCCESS;
|
||||
|
||||
/* list_size < 0xffff means tmp_size cannot larger than 0xFFFFFFFF */
|
||||
uint32_t tmp_size = list_size * item_size;
|
||||
if (tmp_size >= MAX_IMAGE_LEN || list_size * item_size < item_size) {
|
||||
tloge("tmp size is too large or overflow while receive drv conf list %u\n", item_size);
|
||||
return TEE_ERROR_BAD_PARAMETERS;
|
||||
}
|
||||
|
||||
void *tmp_list = malloc(tmp_size);
|
||||
if (tmp_list == NULL) {
|
||||
tloge("malloc tmp_list failed\n");
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
if (copy_from_client((uint64_t)(uintptr_t)(*list), tmp_size, (uintptr_t)tmp_list, tmp_size) != TEE_SUCCESS) {
|
||||
tloge("copy_from_client tmp_list failed\n");
|
||||
free(tmp_list);
|
||||
return TEE_ERROR_GENERIC;
|
||||
}
|
||||
|
||||
*list = tmp_list;
|
||||
|
||||
return TEE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf)
|
||||
{
|
||||
uint32_t receive_flag = 0;
|
||||
if (drv_conf == NULL) {
|
||||
tloge("invalid receive param\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* receive drv_conf iomap list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->io_map_list,
|
||||
drv_conf->io_map_list_size, sizeof(struct addr_region_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_IO_MAP_LIST;
|
||||
|
||||
/* receive irq list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->irq_list,
|
||||
drv_conf->irq_list_size, sizeof(uint64_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_IRQ_LIST;
|
||||
|
||||
/* receive map secure list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->map_secure_list,
|
||||
drv_conf->map_secure_list_size, sizeof(struct drv_map_secure_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_MAP_SECURE_LIST;
|
||||
|
||||
/* receive map nosecure list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->map_nosecure_list,
|
||||
drv_conf->map_nosecure_list_size, sizeof(struct drv_map_nosecure_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_MAP_NOSECURE_LIST;
|
||||
|
||||
/* receive mac info list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->mac_info_list,
|
||||
drv_conf->mac_info_list_size, sizeof(struct drv_mac_info_t)) != 0)
|
||||
goto err_out;
|
||||
receive_flag = RECEIVE_MAC_INFO_LIST;
|
||||
|
||||
/* receive cmd perm list */
|
||||
if (receive_drv_conf_list((void **)&drv_conf->cmd_perm_list,
|
||||
drv_conf->cmd_perm_list_size, sizeof(struct drv_cmd_perm_info_t)) != 0)
|
||||
goto err_out;
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
free_drv_conf_list(drv_conf, receive_flag);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t check_drv_node_state(struct task_node *node)
|
||||
{
|
||||
int32_t func_ret = DRV_FAIL;
|
||||
|
||||
if (node == NULL || node->tlv.drv_conf == NULL) {
|
||||
tloge("invalid node\n");
|
||||
return DRV_FAIL;
|
||||
}
|
||||
|
||||
int32_t ret = drv_robust_mutex_lock(&node->state_mtx);
|
||||
if (ret != 0) {
|
||||
tloge("get state mtx fail\n");
|
||||
return DRV_FAIL;
|
||||
}
|
||||
|
||||
switch (node->state) {
|
||||
case TASK_LOAD:
|
||||
node->state = TASK_SPAWN;
|
||||
func_ret = DRV_NEED_SPAWN;
|
||||
break;
|
||||
case TASK_SPAWN:
|
||||
while (node->state == TASK_SPAWN) {
|
||||
tloge("drv:%s is spawn by other thread, just wait\n", node->tlv.drv_conf->mani.service_name);
|
||||
ret = pthread_cond_wait(&node->state_cond, &node->state_mtx);
|
||||
if (ret != 0) {
|
||||
tloge("something wrong, drv:%s cond wait fail:0x%x\n", node->tlv.drv_conf->mani.service_name, ret);
|
||||
goto unlock_mtx;
|
||||
}
|
||||
}
|
||||
|
||||
if (node->state == TASK_NORMAL)
|
||||
func_ret = DRV_SUCC;
|
||||
else
|
||||
tloge("something wrong, wait spawn fail state:0x%x\n", node->state);
|
||||
break;
|
||||
case TASK_NORMAL:
|
||||
func_ret = DRV_SUCC;
|
||||
break;
|
||||
default:
|
||||
/* when drv spawn fail, just return fail */
|
||||
tloge("something wrong, drv:%s state:%d\n", node->tlv.drv_conf->mani.service_name, node->state);
|
||||
}
|
||||
|
||||
unlock_mtx:
|
||||
ret = pthread_mutex_unlock(&node->state_mtx);
|
||||
if (ret != 0)
|
||||
tloge("something wrong, unlock mtx in drv state fail\n");
|
||||
|
||||
return func_ret;
|
||||
}
|
||||
|
||||
void broadcast_drv_state(struct task_node *node, bool spawn_succ)
|
||||
{
|
||||
if (node == NULL) {
|
||||
tloge("invalid node\n");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t ret = drv_robust_mutex_lock(&node->state_mtx);
|
||||
if (ret != 0) {
|
||||
tloge("get state mtx fail\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (node->state != TASK_SPAWN)
|
||||
tloge("something wrong, node->state:%d not DRV_SPAWN\n", node->state);
|
||||
|
||||
if (spawn_succ)
|
||||
node->state = TASK_NORMAL;
|
||||
else
|
||||
node->state = TASK_SPAWN_FAIL;
|
||||
|
||||
pthread_cond_broadcast(&node->state_cond);
|
||||
|
||||
ret = pthread_mutex_unlock(&node->state_mtx);
|
||||
if (ret != 0)
|
||||
tloge("something wrong, unlock stat mtx fail\n");
|
||||
}
|
||||
|
||||
@@ -1,128 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
|
||||
* Description: drv dyn perm info mgr
|
||||
* Create: 2021-02-03
|
||||
*/
|
||||
|
||||
#ifndef DRVMGR_DRV_DYN_CONF_MGR_H
|
||||
#define DRVMGR_DRV_DYN_CONF_MGR_H
|
||||
|
||||
#include <arch/types.h>
|
||||
#include <hm_msg_type.h>
|
||||
#include <pthread.h>
|
||||
#include <dlist.h>
|
||||
#include <tee_defines.h>
|
||||
#include <tee_drv_internal.h>
|
||||
#include "dyn_conf_common.h"
|
||||
#include "task_mgr.h"
|
||||
|
||||
struct task_node;
|
||||
|
||||
#define MAX_UUID_SIZE 36
|
||||
#define MAX_CMD_SIZE 40
|
||||
#define CMD_SET_FLAG 1
|
||||
|
||||
enum drv_receive_list_tag {
|
||||
RECEIVE_IO_MAP_LIST = 1,
|
||||
RECEIVE_IRQ_LIST,
|
||||
RECEIVE_MAP_SECURE_LIST,
|
||||
RECEIVE_MAP_NOSECURE_LIST,
|
||||
RECEIVE_MAC_INFO_LIST,
|
||||
RECEIVE_CMD_PERM_LIST,
|
||||
RECEIVE_MAX_TAG
|
||||
};
|
||||
|
||||
struct addr_region_t {
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
};
|
||||
|
||||
struct drv_basic_info_t {
|
||||
uint32_t thread_limit;
|
||||
bool upgrade;
|
||||
bool virt2phys;
|
||||
uint8_t exception_mode;
|
||||
};
|
||||
|
||||
struct drv_map_secure_t {
|
||||
struct tee_uuid uuid;
|
||||
struct addr_region_t region;
|
||||
};
|
||||
|
||||
struct drv_map_nosecure_t {
|
||||
struct tee_uuid uuid;
|
||||
};
|
||||
|
||||
struct drv_mac_info_t {
|
||||
struct tee_uuid uuid;
|
||||
uint64_t perm;
|
||||
};
|
||||
|
||||
struct drv_conf_t {
|
||||
struct drv_mani_t mani;
|
||||
struct drv_basic_info_t drv_basic_info;
|
||||
union {
|
||||
struct addr_region_t *io_map_list;
|
||||
uint64_t tmp_io_map;
|
||||
};
|
||||
union {
|
||||
uint64_t *irq_list;
|
||||
uint64_t tmp_irq;
|
||||
};
|
||||
union {
|
||||
struct drv_map_secure_t *map_secure_list;
|
||||
uint64_t tmp_map_secure;
|
||||
};
|
||||
union {
|
||||
struct drv_map_nosecure_t *map_nosecure_list;
|
||||
uint64_t tmp_nosecure;
|
||||
};
|
||||
union {
|
||||
struct drv_mac_info_t *mac_info_list;
|
||||
uint64_t tmp_mac_info;
|
||||
};
|
||||
union {
|
||||
struct drv_cmd_perm_info_t *cmd_perm_list;
|
||||
uint64_t tmp_cmd_perm;
|
||||
};
|
||||
uint16_t io_map_list_size;
|
||||
uint16_t io_map_list_index;
|
||||
uint16_t irq_list_size;
|
||||
uint16_t irq_list_index;
|
||||
uint16_t map_secure_list_size;
|
||||
uint16_t map_nosecure_list_size;
|
||||
uint16_t map_nosecure_list_index;
|
||||
uint16_t mac_info_list_size;
|
||||
uint16_t mac_info_list_index; /* the index of the newest ava mac */
|
||||
uint16_t cmd_perm_list_size;
|
||||
uint16_t cmd_perm_list_index; /* the index of the newest cmd perm */
|
||||
};
|
||||
|
||||
struct drv_conf_list_t {
|
||||
struct dlist_node list;
|
||||
pthread_mutex_t lock;
|
||||
};
|
||||
|
||||
struct drv_tlv {
|
||||
struct tee_uuid uuid;
|
||||
struct drvcall_perm_apply_t drvcall_perm_apply;
|
||||
struct drv_conf_t drv_conf;
|
||||
};
|
||||
|
||||
enum drv_error {
|
||||
DRV_FAIL = -1,
|
||||
DRV_SUCC = 0,
|
||||
DRV_NEED_SPAWN,
|
||||
DRV_WAIT,
|
||||
};
|
||||
|
||||
#ifdef TEE_SUPPORT_DYN_CONF_DEBUG
|
||||
void dump_drv_conf(const struct drv_conf_t *drv_conf);
|
||||
#endif
|
||||
|
||||
void broadcast_drv_state(struct task_node *node, bool spawn_succ);
|
||||
int32_t check_drv_node_state(struct task_node *node);
|
||||
int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf);
|
||||
void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag);
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Technologies Co., Ltd.
|
||||
* Licensed under the Mulan PSL v2.
|
||||
* You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
* You may obtain a copy of Mulan PSL v2 at:
|
||||
* http://license.coscl.org.cn/MulanPSL2
|
||||
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
|
||||
* PURPOSE.
|
||||
* See the Mulan PSL v2 for more details.
|
||||
*/
|
||||
|
||||
#ifndef DRVMGR_DRV_DYN_CONF_MGR_H
|
||||
#define DRVMGR_DRV_DYN_CONF_MGR_H
|
||||
|
||||
#include <arch/types.h>
|
||||
#include <hm_msg_type.h>
|
||||
#include <pthread.h>
|
||||
#include <dlist.h>
|
||||
#include <tee_defines.h>
|
||||
#include <tee_drv_internal.h>
|
||||
#include "dyn_conf_common.h"
|
||||
#include "task_mgr.h"
|
||||
|
||||
struct task_node;
|
||||
|
||||
#define MAX_UUID_SIZE 36
|
||||
#define MAX_CMD_SIZE 40
|
||||
#define CMD_SET_FLAG 1
|
||||
|
||||
enum drv_receive_list_tag {
|
||||
RECEIVE_IO_MAP_LIST = 1,
|
||||
RECEIVE_IRQ_LIST,
|
||||
RECEIVE_MAP_SECURE_LIST,
|
||||
RECEIVE_MAP_NOSECURE_LIST,
|
||||
RECEIVE_MAC_INFO_LIST,
|
||||
RECEIVE_CMD_PERM_LIST,
|
||||
RECEIVE_MAX_TAG
|
||||
};
|
||||
|
||||
struct addr_region_t {
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
};
|
||||
|
||||
struct drv_basic_info_t {
|
||||
uint32_t thread_limit;
|
||||
bool upgrade;
|
||||
bool virt2phys;
|
||||
uint8_t exception_mode;
|
||||
};
|
||||
|
||||
struct drv_map_secure_t {
|
||||
struct tee_uuid uuid;
|
||||
struct addr_region_t region;
|
||||
};
|
||||
|
||||
struct drv_map_nosecure_t {
|
||||
struct tee_uuid uuid;
|
||||
};
|
||||
|
||||
struct drv_mac_info_t {
|
||||
struct tee_uuid uuid;
|
||||
uint64_t perm;
|
||||
};
|
||||
|
||||
struct drv_conf_t {
|
||||
struct drv_mani_t mani;
|
||||
struct drv_basic_info_t drv_basic_info;
|
||||
union {
|
||||
struct addr_region_t *io_map_list;
|
||||
uint64_t tmp_io_map;
|
||||
};
|
||||
union {
|
||||
uint64_t *irq_list;
|
||||
uint64_t tmp_irq;
|
||||
};
|
||||
union {
|
||||
struct drv_map_secure_t *map_secure_list;
|
||||
uint64_t tmp_map_secure;
|
||||
};
|
||||
union {
|
||||
struct drv_map_nosecure_t *map_nosecure_list;
|
||||
uint64_t tmp_nosecure;
|
||||
};
|
||||
union {
|
||||
struct drv_mac_info_t *mac_info_list;
|
||||
uint64_t tmp_mac_info;
|
||||
};
|
||||
union {
|
||||
struct drv_cmd_perm_info_t *cmd_perm_list;
|
||||
uint64_t tmp_cmd_perm;
|
||||
};
|
||||
uint16_t io_map_list_size;
|
||||
uint16_t io_map_list_index;
|
||||
uint16_t irq_list_size;
|
||||
uint16_t irq_list_index;
|
||||
uint16_t map_secure_list_size;
|
||||
uint16_t map_nosecure_list_size;
|
||||
uint16_t map_nosecure_list_index;
|
||||
uint16_t mac_info_list_size;
|
||||
uint16_t mac_info_list_index; /* the index of the newest ava mac */
|
||||
uint16_t cmd_perm_list_size;
|
||||
uint16_t cmd_perm_list_index; /* the index of the newest cmd perm */
|
||||
};
|
||||
|
||||
struct drv_conf_list_t {
|
||||
struct dlist_node list;
|
||||
pthread_mutex_t lock;
|
||||
};
|
||||
|
||||
struct drv_tlv {
|
||||
struct tee_uuid uuid;
|
||||
struct drvcall_perm_apply_t drvcall_perm_apply;
|
||||
struct drv_conf_t drv_conf;
|
||||
};
|
||||
|
||||
enum drv_error {
|
||||
DRV_FAIL = -1,
|
||||
DRV_SUCC = 0,
|
||||
DRV_NEED_SPAWN,
|
||||
DRV_WAIT,
|
||||
};
|
||||
|
||||
#ifdef TEE_SUPPORT_DYN_CONF_DEBUG
|
||||
void dump_drv_conf(const struct drv_conf_t *drv_conf);
|
||||
#endif
|
||||
|
||||
void broadcast_drv_state(struct task_node *node, bool spawn_succ);
|
||||
int32_t check_drv_node_state(struct task_node *node);
|
||||
int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf);
|
||||
void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag);
|
||||
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user