From patchwork Wed Nov 8 12:47:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 10048447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D193360247 for ; Wed, 8 Nov 2017 12:49:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C325429148 for ; Wed, 8 Nov 2017 12:49:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7887291A5; Wed, 8 Nov 2017 12:49:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3542729148 for ; Wed, 8 Nov 2017 12:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=KG38oIsNJDrWwB44ZqjVhomNUdNJn6g63jHMO49Z1YQ=; b=BcWABX9s0QmXzafNMdzBEbE7g8 2ZAa3Drn+FJpsI4TNEvkBnLZJZrLfzjYuy2ZWcMP0IsAUGoxd3lxgrxtUCMYw8sFA2Vad/i1hASSd c+qMjPBzcQJI5tPxAbULF5/A3YoBQ+jg2seI2eZJvghHcdurdkagozKpH2Mak0uZoFFp+3y1/S7oS JqUWOs/QOfxheG66OdHw26RC/zB2xK5xzaQ+VD6+w+bYU3fMglrkYFISTiV2OR6rPmtyKFaCbzkYi rfr65jhqTfguw9FLF0Ug4JVJUsG/4Ccpop6y8IPky210USkaYq87S1LAUgMmXx+KiggWGxGXZLFbl 3Dz5sa4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eCPmx-00008r-2Q; Wed, 08 Nov 2017 12:49:03 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eCPmJ-0007mK-9j for linux-arm-kernel@lists.infradead.org; Wed, 08 Nov 2017 12:48:27 +0000 Received: by mail-lf0-x241.google.com with SMTP id r129so2985448lff.8 for ; Wed, 08 Nov 2017 04:48:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mSo6yKgh7N0IqFVDF75e/sjQ7W6F2AlEX4kmNsHCRrs=; b=L6AKUPBHhl87tDswWMVb5ZNoZkUWw6a9X4UQ8IkuTclobe7K3+7TvJEuYnE1yRVWiy 12blcGNpaumr4mAtoUOCwDDzXjXec5PwiIRgqgQOFbaaevFF6WwFBhcCMtQzP8ce+GzY FNwYrvMgJGHEYaBgyQtNle4JtdwqMmh540t0A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mSo6yKgh7N0IqFVDF75e/sjQ7W6F2AlEX4kmNsHCRrs=; b=PqJyaw/Y8cTh2aNO+1ZbVF5rdlSkq1EeA8RZAPFb938093kLQU/B2halZ1EaviRHLy r6ZhzwsWrb8Wi7mOaQlDfy04fsjnOE6xVjANe/PvBAudRHRxWqUEUGJdhZdaJf3oH99e ndLBee0dwEUd72zjZR3QQkqdEBBH+W6v7lso+pZZ3ngX+8uSpyEXcKMOyL0tWp8C0BZ3 UVh6HFHMDFxQU2mFn0TU44YjzLTfZ8/mqwV+uX8qR6C2dpGtqj3YcGuJQ3nBNT6oRsVf x8DPNm+hnWEa9LbxJY+yGNLcrMkp/4962MuoSPF3imL/EdhAYpS2ug4+P2bH0fhnqKTm edcw== X-Gm-Message-State: AJaThX46wHOm/HkUbJqBYRqBa1mYar9T42QfTYqZZKqaiBzr6xCBrw38 1nrXEwF5alwbzNO7PSEgiFgTSA== X-Google-Smtp-Source: AGs4zMbuILQ4yUblqAmmOPUBzJbdMKW5Z5eDubYbqHgyktLASjVQqsZfXxhimtci5it93QfCGLf4sA== X-Received: by 10.25.42.84 with SMTP id f81mr160750lfl.258.1510145282163; Wed, 08 Nov 2017 04:48:02 -0800 (PST) Received: from jax.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x7sm658479lff.91.2017.11.08.04.48.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Nov 2017 04:48:01 -0800 (PST) From: Jens Wiklander To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tee-dev@lists.linaro.org Subject: [PATCH 1/3] tee: add tee_param_is_memref() for driver use Date: Wed, 8 Nov 2017 13:47:50 +0100 Message-Id: <1510145272-14842-2-git-send-email-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510145272-14842-1-git-send-email-jens.wiklander@linaro.org> References: <1510145272-14842-1-git-send-email-jens.wiklander@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171108_044823_575644_2A3C88DE X-CRM114-Status: GOOD ( 11.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Wiklander MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Reviewed-by: Etienne Carriere Signed-off-by: Jens Wiklander --- drivers/tee/tee_core.c | 16 ++-------------- include/linux/tee_drv.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index 58a5009eacc3..c78104589e42 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -221,18 +221,6 @@ static int params_to_user(struct tee_ioctl_param __user *uparams, return 0; } -static bool param_is_memref(struct tee_param *param) -{ - switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) { - case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT: - case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT: - case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT: - return true; - default: - return false; - } -} - static int tee_ioctl_open_session(struct tee_context *ctx, struct tee_ioctl_buf_data __user *ubuf) { @@ -296,7 +284,7 @@ static int tee_ioctl_open_session(struct tee_context *ctx, if (params) { /* Decrease ref count for all valid shared memory pointers */ for (n = 0; n < arg.num_params; n++) - if (param_is_memref(params + n) && + if (tee_param_is_memref(params + n) && params[n].u.memref.shm) tee_shm_put(params[n].u.memref.shm); kfree(params); @@ -358,7 +346,7 @@ static int tee_ioctl_invoke(struct tee_context *ctx, if (params) { /* Decrease ref count for all valid shared memory pointers */ for (n = 0; n < arg.num_params; n++) - if (param_is_memref(params + n) && + if (tee_param_is_memref(params + n) && params[n].u.memref.shm) tee_shm_put(params[n].u.memref.shm); kfree(params); diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h index cb889afe576b..f4a0ac05ebb4 100644 --- a/include/linux/tee_drv.h +++ b/include/linux/tee_drv.h @@ -275,4 +275,16 @@ int tee_shm_get_id(struct tee_shm *shm); */ struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id); +static inline bool tee_param_is_memref(struct tee_param *param) +{ + switch (param->attr & TEE_IOCTL_PARAM_ATTR_TYPE_MASK) { + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INPUT: + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_OUTPUT: + case TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT: + return true; + default: + return false; + } +} + #endif /*__TEE_DRV_H*/