From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754458AbdCHUM4 (ORCPT ); Wed, 8 Mar 2017 15:12:56 -0500 Received: from mail-ve1eur01on0060.outbound.protection.outlook.com ([104.47.1.60]:46348 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754435AbdCHUMw (ORCPT ); Wed, 8 Mar 2017 15:12:52 -0500 From: Stuart Yoder To: Greg Kroah-Hartman , Arnd Bergmann , Olof Johansson , Andrew Morton , Jens Wiklander CC: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , Al Viro , "jean-michel.delorme@st.com" , "emmanuel.michel@st.com" , "javier@javigon.com" , Jason Gunthorpe , "Mark Rutland" , Michal Simek , "Rob Herring" , Will Deacon , "Nishanth Menon" , "Andrew F . Davis" , "broonie@kernel.org" , "scott.branden@broadcom.com" , Loic PALLARDY , "Etienne CARRIERE" , Benjamin GAIGNARD , Patrice CHOTARD , Christophe PRIOUZEAU , Eric FINCO , Franck ALBESA , Wei Xu Subject: Re: [PATCH v15 3/5] tee: add OP-TEE driver Thread-Topic: [PATCH v15 3/5] tee: add OP-TEE driver Thread-Index: AQHSmDc6SSUMwluUqEK4ZVIjdhIINqGK9wMA Date: Wed, 8 Mar 2017 19:56:05 +0000 Message-ID: <4C0FFCAE-756B-4432-9791-290337A2F5AA@arm.com> References: <1485605984-30064-1-git-send-email-jens.wiklander@linaro.org> <1485605984-30064-4-git-send-email-jens.wiklander@linaro.org> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=none action=none header.from=arm.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [217.140.111.135] x-ms-office365-filtering-correlation-id: 7bda2c25-aab6-4ef8-c486-08d4665d289c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:VI1PR0801MB1789; x-microsoft-exchange-diagnostics: 1;VI1PR0801MB1789;7:ZsrxpPR2g4/s0QRh32VJrdJt5uIzQV9NVqqNlxWjsylQQDUv6VvSQ877rozMzpqvMnK6JOvEOhp1qMxwi/DzsTg9LX3XQQEFsINAEZflw8a5TYoySccpCIHOwSiyTVG5IxoFrKv64UDSTBFg1fxFtdaWGpvJ5by/DhP7jW74eoYJAIOMaHnxbLDmvypJ5TIGqbfRufwaKjM8HFJEWyGJx+iN85cnOKoJowzSQ1yDUE3TMxFtocUgaumCSQopszd3y2fI8V7xtMlE/OotCr8eAL4Pji+dMcxtSMQ6Ha3wAsij7zDJDBfEdgXEeRS4Trf/z41p1EL/eIOhYOYmd9iH+Q== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123558025)(20161123555025)(20161123562025)(20161123564025)(6072148);SRVR:VI1PR0801MB1789;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB1789; x-forefront-prvs: 02408926C4 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39410400002)(39850400002)(39840400002)(39860400002)(40434004)(305945005)(38730400002)(83716003)(6116002)(4326008)(102836003)(8936002)(5660300001)(33656002)(81166006)(106116001)(53936002)(189998001)(8676002)(82746002)(6246003)(7416002)(3846002)(7736002)(6436002)(6506006)(54356999)(2900100001)(76176999)(3280700002)(6486002)(6512007)(2950100002)(77096006)(25786008)(99286003)(8666007)(229853002)(8656002)(5890100001)(86362001)(66066001)(54906002)(3660700001)(36756003)(122556002)(2906002)(50986999)(104396002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0801MB1789;H:VI1PR0801MB1549.eurprd08.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2017 19:56:05.9499 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1789 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v28KCxlE019790 [cut] > +static struct optee *optee_probe(struct device_node *np) > +{ > + optee_invoke_fn *invoke_fn; > + struct tee_shm_pool *pool; > + struct optee *optee = NULL; > + void *memremaped_shm = NULL; > + struct tee_device *teedev; > + u32 sec_caps; > + int rc; > + > + invoke_fn = get_invoke_func(np); > + if (IS_ERR(invoke_fn)) > + return (void *)invoke_fn; > + > + if (!optee_msg_api_uid_is_optee_api(invoke_fn)) { > + pr_warn("api uid mismatch\n"); > + return ERR_PTR(-EINVAL); > + } > + > + if (!optee_msg_api_revision_is_compatible(invoke_fn)) { > + pr_warn("api revision mismatch\n"); > + return ERR_PTR(-EINVAL); > + } > + > + if (!optee_msg_exchange_capabilities(invoke_fn, &sec_caps)) { > + pr_warn("capabilities mismatch\n"); > + return ERR_PTR(-EINVAL); > + } > + > + /* > + * We have no other option for shared memory, if secure world > + * doesn't have any reserved memory we can use we can't continue. > + */ > + if (!(sec_caps & OPTEE_SMC_SEC_CAP_HAVE_RESERVERED_SHM)) > + return ERR_PTR(-EINVAL); Typo? RESERVERED_SHM should be RESERVED_SHM > diff --git a/drivers/tee/optee/optee_smc.h b/drivers/tee/optee/optee_smc.h > +/* > + * Exchanges capabilities between normal world and secure world > + * > + * Call register usage: > + * a0 SMC Function ID, OPTEE_SMC_EXCHANGE_CAPABILITIES > + * a1 bitfield of normal world capabilities OPTEE_SMC_NSEC_CAP_* > + * a2-6 Not used > + * a7 Hypervisor Client ID register > + * > + * Normal return register usage: > + * a0 OPTEE_SMC_RETURN_OK > + * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_* > + * a2-7 Preserved > + * > + * Error return register usage: > + * a0 OPTEE_SMC_RETURN_ENOTAVAIL, can't use the capabilities from normal world > + * a1 bitfield of secure world capabilities OPTEE_SMC_SEC_CAP_* > + * a2-7 Preserved > + */ > +/* Normal world works as a uniprocessor system */ > +#define OPTEE_SMC_NSEC_CAP_UNIPROCESSOR BIT(0) > +/* Secure world has reserved shared memory for normal world to use */ > +#define OPTEE_SMC_SEC_CAP_HAVE_RESERVERED_SHM BIT(0) Same typo? s/RESERVERED_SHM/RESERVED_SHM/ Thanks, Stuart IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.