Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp15353444ybl; Tue, 31 Dec 2019 06:17:37 -0800 (PST) X-Google-Smtp-Source: APXvYqyp7ohyXpyTUb2187RaToPsQoxIktBTAqkhB+rJRmqesCFjs/71IFgzHMuYPnNHK0EWuuEw X-Received: by 2002:a50:9f65:: with SMTP id b92mr76575943edf.275.1577801857434; Tue, 31 Dec 2019 06:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577801857; cv=none; d=google.com; s=arc-20160816; b=V1GqJxJK5YACwTT+xcrMZZ3J9MDh6e9ay/ytKdpLAoS206jkhnN6ut8NiCFoPKzUPS hWrJepsnZJ1Hp1xcht8HIbYwJ6G8DeKJ2HIc/PFRf8h0pN+wBLc9r63vJNmI9Otb23Sg td+5L78VXTSCqSD48onKvUefJYouiprEV6LGSp7qyZm3UN484zUIL8XyPbBy5soE3e3J fZbEoSfqmgyZRQayE5MntSf181S0a/yPkDqdMHLLID2kCea86DhLO+K9j369M4qAXVDr LYVAgrhbz2vOLDAMe2qmAvw0boNRchsEPi6DB+Z8Juq+LMVSiB6ozxW9ZIkC+Kkv83gl Elmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=EJB+347/hZzCPDyyFGufiFPJiUpNsE2kCK5B7L4ZJxY=; b=veTQZ0gZ+K+LT4EF2SPz4ht765pqt4+HvmXbV7GSFMC499w541nnXTZ3JT6aifIamE yhz7u32x3Cmp5Jhgwf5w6uRaCZ7l2GqNEDwfMNqHyc2FIOj5OdIG2z8AKn1eWmcZPWDR KHAMUlR8tbWhjvgehnrkos9/NYTxyEsTxDnT7+zADea5re9xtKDZ9wp5yV3STc5sRRGZ oZh5hrCW/o3KTxy8HcyJ1lw92e2haBl6MR10EZkdk7vqbmvArj2NEiZ82AadVpxkc3Pb jjvfd1LwMiZpKBAK7qSMNS002uk6xVIEJZu+fQ3Zf8RSUHTUb7ffNeZsRQMkEfjActST WC1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=A3MbETPx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o23si20363854ejg.280.2019.12.31.06.17.10; Tue, 31 Dec 2019 06:17:37 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=A3MbETPx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727056AbfLaOPr (ORCPT + 99 others); Tue, 31 Dec 2019 09:15:47 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:59860 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726229AbfLaOPq (ORCPT ); Tue, 31 Dec 2019 09:15:46 -0500 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBVEFh32078307; Tue, 31 Dec 2019 08:15:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1577801743; bh=EJB+347/hZzCPDyyFGufiFPJiUpNsE2kCK5B7L4ZJxY=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=A3MbETPxbbCJSgb0KR8+Cfzm8XrDHf9hLnKhKoRS+AxAoGsfjNViobI7wPZVEUKy/ M6NO1Gi6dlpXj885c4H1uNkJsxcSN0Y62BNJegGzPUpdx8Ch/I0+d31kEpsTLckj1O eSk4JKhuzyGFGC3bCIJyuqM20zHujG+M1MSLZtYE= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id xBVEFhn1065621 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 31 Dec 2019 08:15:43 -0600 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Tue, 31 Dec 2019 08:15:42 -0600 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Tue, 31 Dec 2019 08:15:42 -0600 Received: from [10.250.65.50] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBVEFgWR048770; Tue, 31 Dec 2019 08:15:42 -0600 Subject: Re: [PATCH v3 2/4] ARM: OMAP2+: Introduce check for OP-TEE in omap_secure_init() To: Lokesh Vutla , Tony Lindgren CC: , References: <20191230185004.32279-1-afd@ti.com> <20191230185004.32279-3-afd@ti.com> From: "Andrew F. Davis" Message-ID: Date: Tue, 31 Dec 2019 09:15:42 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/31/19 1:32 AM, Lokesh Vutla wrote: > > > On 31/12/19 12:20 AM, Andrew F. Davis wrote: >> This check and associated flag can be used to signal the presence >> of OP-TEE on the platform. This can be used to determine which >> SMC calls to make to perform secure operations. >> >> Signed-off-by: Andrew F. Davis >> --- >> arch/arm/mach-omap2/omap-secure.c | 14 ++++++++++++++ >> arch/arm/mach-omap2/omap-secure.h | 3 +++ >> 2 files changed, 17 insertions(+) >> >> diff --git a/arch/arm/mach-omap2/omap-secure.c b/arch/arm/mach-omap2/omap-secure.c >> index e936732cdc4f..39d8070aede6 100644 >> --- a/arch/arm/mach-omap2/omap-secure.c >> +++ b/arch/arm/mach-omap2/omap-secure.c >> @@ -12,6 +12,7 @@ >> #include >> #include >> #include >> +#include >> >> #include >> #include >> @@ -20,6 +21,18 @@ >> >> static phys_addr_t omap_secure_memblock_base; >> >> +bool optee_available; >> + >> +static void __init omap_optee_init_check(void) >> +{ >> + struct device_node *np; >> + >> + np = of_find_node_by_path("/firmware/optee"); >> + if (np && of_device_is_available(np)) > > This doesn't guarantee that optee driver is probed successfully or firmware > installed correctly. Isn't there a better way to detect? Doesn't tee core layer > exposes anything? We don't actually need the kernel-side OP-TEE driver at all here, we are making raw SMCCC calls which get handled by OP-TEE using platform specific code then emulates the function previously handled by ROM[0] and execution is returned. No driver involved for these types of calls. U-Boot will not add this node to the DT unless OP-TEE is installed correctly, but you are right that is no perfect guarantee. OP-TEE's kernel driver does do a handshake to verify it is working but this is not exposed outside of that driver and happens *way* too late for our uses here. Plus as above, we don't need the OP-TEE driver at all and we should boot the same without it even enabled. So my opinion is that if DT says OP-TEE is installed, but it is not, then that is a misconfiguration and we usually just have to trust DT for most things. If DT is wrong here then the only thing that happens is this call safely fails, a message is printed informing the user of the problem, and kernel keeps booting (although probably not stable given we need these calls for important system configuration). Andrew [0] https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/plat-ti/sm_platform_handler_a9.c https://github.com/OP-TEE/optee_os/blob/master/core/arch/arm/plat-ti/sm_platform_handler_a15.c > > Thanks and regards, > Lokesh > >> + optee_available = true; >> + of_node_put(np); >> +} >> + >> /** >> * omap_sec_dispatcher: Routine to dispatch low power secure >> * service routines >> @@ -166,4 +179,5 @@ u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag) >> >> void __init omap_secure_init(void) >> { >> + omap_optee_init_check(); >> } >> diff --git a/arch/arm/mach-omap2/omap-secure.h b/arch/arm/mach-omap2/omap-secure.h >> index 9aeeb236a224..78a1c4f04bbe 100644 >> --- a/arch/arm/mach-omap2/omap-secure.h >> +++ b/arch/arm/mach-omap2/omap-secure.h >> @@ -10,6 +10,8 @@ >> #ifndef OMAP_ARCH_OMAP_SECURE_H >> #define OMAP_ARCH_OMAP_SECURE_H >> >> +#include >> + >> /* Monitor error code */ >> #define API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR 0xFFFFFFFE >> #define API_HAL_RET_VALUE_SERVICE_UNKNWON 0xFFFFFFFF >> @@ -72,6 +74,7 @@ extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs, >> extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits); >> extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag); >> >> +extern bool optee_available; >> void omap_secure_init(void); >> >> #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER >>