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: 118250 Delivered-To: patches@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5242578qgn; Wed, 8 Nov 2017 04:48:02 -0800 (PST) X-Received: by 10.46.101.4 with SMTP id z4mr200398ljb.42.1510145282511; Wed, 08 Nov 2017 04:48:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510145282; cv=none; d=google.com; s=arc-20160816; b=q7SJ0EQjKinz8BHofPEm/j1DOU9ECL2ZZzlB4AX+aNSfheruqrOenZ1PaYNWd7JAto PaQt6If65RLXvBz2qt7N+ymG9X9Fa3iTAd1kBYOlFyOnoN103QCXO7btYXSdQfwFgJnJ +gWLkXTSEFHL0o1oLKmWuS1sw7WqDP3Ykb9KG8zW/Htj2lpyVGumjvrC4uevfx8i3/Uo rNapThia1v3bKX9BhC+bjITzXRqOjzhiMOIh+cLQz1wBRX2JHU4lXXNU+7IPKd9LpqW4 Juv+Ejw0BB/0uzxKMFkgMdnWMhIhSOWhTo3SRYMc3tdy4HcQKj/E66YshBlyZWQW0FPh Mikg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=mSo6yKgh7N0IqFVDF75e/sjQ7W6F2AlEX4kmNsHCRrs=; b=lx/UGf1+rsFooR3JEWUDC7Ni/MVIzDJciQOUgxxXwEudMNQ0h1srawb+0BDtG1lx78 ZNIuJgLeXmgdguAHTfr82vuL1judaOH1lMaXW9+p9NcnL4s5lBK3ifDGDdaziiHuO4rR q/JHiPbvQWFkJ+O970CFioH0HFHtuTcn1COsXQvN3jf/xJCRL/pZZm11LiUmIkrNkI1/ 4IPrfksHdGHusIx09HdOUqHZtvo+N3rPAjBrqVizqA5hT8KXY0JpkKh4MC9aXFNpk5Sw LsJPa0PXpFMKCmNgbbWR01Dc9GQuOf86ALQ1R4+7pAckZaTKRqhlAfYPw7FRYR4SQRYF sD9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L6AKUPBH; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id b16sor680034lfe.21.2017.11.08.04.48.02 for (Google Transport Security); Wed, 08 Nov 2017 04:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L6AKUPBH; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=W0RwGyQb2fhONjIJ/yRhsog1S4EfhLPVjDrqn5ezV+vReFS0zUsZAIPhPPHNNYShoy SPuPdSVJFb7qg+/sQ2Q5PifY89cqQr3IUt2hPcFubtJSDeoSWBM/t2O9vfCZbKibrjlW oX4DDFBGTzXiiz2tPPahFVzeMriQpTlno0gZi5q4+pQNlHYD0fC+nWWrvvVg//Q/qqkQ Fq0pTKLxYeTCvhm9tdtKCkh/fVvnMYygBQu6fm4o3/wYdwF92d5ZJVOE0phxZym8y3T6 ZK53u0tQAwjRuxxCi2IE9rc9lN9NuC+R5Wldvym55j5roY2WOg3U7bYzCDSgIRMeba5l Stnw== X-Gm-Message-State: AJaThX4WB5AqkBLsBoHHPX3cmVMkftZzFRk6ZXhNJzSeYI2+6efYD2aW f7v8z2gBzUuymrDO0fCLvclsjeYEl488Xg== 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) Return-Path: 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 Cc: Jens Wiklander 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> 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(-) -- 2.7.4 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*/