From patchwork Wed Mar 1 17:42:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 94728 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp1913095qgi; Wed, 1 Mar 2017 09:43:19 -0800 (PST) X-Received: by 10.98.216.202 with SMTP id e193mr10170295pfg.80.1488390199103; Wed, 01 Mar 2017 09:43:19 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h16si5170504pli.228.2017.03.01.09.43.18; Wed, 01 Mar 2017 09:43:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752855AbdCARnS (ORCPT + 9 others); Wed, 1 Mar 2017 12:43:18 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:36355 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752602AbdCARnR (ORCPT ); Wed, 1 Mar 2017 12:43:17 -0500 Received: by mail-qk0-f194.google.com with SMTP id u188so12511918qkc.3 for ; Wed, 01 Mar 2017 09:43:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iVuDvFMM2Y4THVozKw/bCFX9ee2F55I+HdSO5VP+tHI=; b=BRGY0ftCCFhPpOTuizFwZIKn9LxY4J0hnJLe2us5LJ4spIeRTZ6oCYtzhPWnrBte9Y aeWbnyLlcGIXB/crICE73ZWaKU0ZWSF6Lkn+lfXiCSnA+rYrIJlc6jksEXcBsk1mvLtT AA/BAKCx2iXietmjPxMgxNr5lp1czcWTuM8M4+5oDzfFwszcSka74NSjER+Mh5zMeJeq Cri0+DMM63iQkK0hSFtZJ08X3YGFxEh/yUMjuRIOVI2qSn7GkAotLn6XNVzC+03QC+NP WEfT7XuYyY4ZOU6AalOOAavQBf0eAzt7BfyKVf2vjw01qkTa5S9b7YbH19u1Y7Vf2L2o Y0KA== 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=iVuDvFMM2Y4THVozKw/bCFX9ee2F55I+HdSO5VP+tHI=; b=qH/+sZvyE20/4Om1ROE8euT1vvs8KvyGPK5HGeQ4219gZXdi/wwDdXRakW6OfOtDZK /yjG9xgdq7MhFMWhE7AuQn+Ic6ecXu2D1J1xTK28A15isObZ/g5KaJXMmbYG+SaBIN/6 so4RCuZSc5O1x9YX70q7SbJcprh9DBRgdKYxBtGebBKupkhB7SwjCSQ9AbdX6/W7Mnrh 0NGDoffr4pdUnhvNv109nRnrYm0Kt7J9DmfHV/YxKV7I9PLcdVU7nqn14Um1NhZl+5IM 5lEHk0UZrzRXFBXOAvCKm4dMAK16E67IbzVudV39fNUIK9tGiIwmeMdl0X2KCQFIuHYB eljg== X-Gm-Message-State: AMke39labWt+zrH5rsvQn1uBskeGejkjPPREMJxMPei5hAfK4nhGUB4X0/9LrS/TK1W4Eg== X-Received: by 10.55.162.204 with SMTP id l195mr10636052qke.272.1488390196496; Wed, 01 Mar 2017 09:43:16 -0800 (PST) Received: from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a]) by smtp.gmail.com with ESMTPSA id 21sm3604604qkh.14.2017.03.01.09.43.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Mar 2017 09:43:15 -0800 (PST) From: Rob Clark To: iommu@lists.linux-foundation.org Cc: linux-arm-msm@vger.kernel.org, Robin Murphy , Will Deacon , Sricharan , Mark Rutland , Stanimir Varbanov , Rob Clark Subject: [PATCH 2/9] firmware: qcom_scm: add two scm calls for iommu secure page table Date: Wed, 1 Mar 2017 12:42:51 -0500 Message-Id: <20170301174258.14618-3-robdclark@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170301174258.14618-1-robdclark@gmail.com> References: <20170301174258.14618-1-robdclark@gmail.com> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Stanimir Varbanov Those two new SCM calls are needed from qcom-iommu driver in order to initialize secure iommu page table. Signed-off-by: Stanimir Varbanov Signed-off-by: Rob Clark --- drivers/firmware/qcom_scm-64.c | 42 ++++++++++++++++++++++++++++++++++++++++++ drivers/firmware/qcom_scm.c | 12 ++++++++++++ drivers/firmware/qcom_scm.h | 6 ++++++ include/linux/qcom_scm.h | 2 ++ 4 files changed, 62 insertions(+) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/firmware/qcom_scm-64.c b/drivers/firmware/qcom_scm-64.c index 550e3a3..6e6d561 100644 --- a/drivers/firmware/qcom_scm-64.c +++ b/drivers/firmware/qcom_scm-64.c @@ -397,3 +397,45 @@ int __qcom_scm_restore_sec_cfg(struct device *dev, u32 device_id, u32 spare) return ret ? : res.a1; } + +int __qcom_scm_iommu_secure_ptbl_size(struct device *dev, u32 spare, + size_t *size) +{ + struct qcom_scm_desc desc = {0}; + struct arm_smccc_res res; + int ret; + + desc.args[0] = spare; + desc.arginfo = QCOM_SCM_ARGS(1); + + ret = qcom_scm_call(dev, QCOM_SCM_SVC_MP, + QCOM_SCM_IOMMU_SECURE_PTBL_SIZE, &desc, &res); + + if (size) + *size = res.a1; + + return ret ? : res.a2; +} + +int __qcom_scm_iommu_secure_ptbl_init(struct device *dev, u64 addr, u32 size, + u32 spare) +{ + struct qcom_scm_desc desc = {0}; + struct arm_smccc_res res; + int ret; + + desc.args[0] = addr; + desc.args[1] = size; + desc.args[2] = spare; + desc.arginfo = QCOM_SCM_ARGS(3, QCOM_SCM_RW, QCOM_SCM_VAL, + QCOM_SCM_VAL); + + ret = qcom_scm_call(dev, QCOM_SCM_SVC_MP, + QCOM_SCM_IOMMU_SECURE_PTBL_INIT, &desc, &res); + + /* the pg table has been initialized already, ignore the error */ + if (ret == -EPERM) + ret = 0; + + return ret; +} diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index ae1f473..bb16510 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -321,6 +321,18 @@ int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare) } EXPORT_SYMBOL(qcom_scm_restore_sec_cfg); +int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size) +{ + return __qcom_scm_iommu_secure_ptbl_size(__scm->dev, spare, size); +} +EXPORT_SYMBOL(qcom_scm_iommu_secure_ptbl_size); + +int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare) +{ + return __qcom_scm_iommu_secure_ptbl_init(__scm->dev, addr, size, spare); +} +EXPORT_SYMBOL(qcom_scm_iommu_secure_ptbl_init); + /** * qcom_scm_is_available() - Checks if SCM is available */ diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index 31fc732..9bea691 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -89,5 +89,11 @@ static inline int qcom_scm_remap_error(int err) #define QCOM_SCM_RESTORE_SEC_CFG 2 extern int __qcom_scm_restore_sec_cfg(struct device *dev, u32 device_id, u32 spare); +#define QCOM_SCM_IOMMU_SECURE_PTBL_SIZE 3 +#define QCOM_SCM_IOMMU_SECURE_PTBL_INIT 4 +extern int __qcom_scm_iommu_secure_ptbl_size(struct device *dev, u32 spare, + size_t *size); +extern int __qcom_scm_iommu_secure_ptbl_init(struct device *dev, u64 addr, + u32 size, u32 spare); #endif diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index 22017f5d..c46c3c2 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -41,6 +41,8 @@ extern void qcom_scm_cpu_power_down(u32 flags); extern u32 qcom_scm_get_version(void); extern int qcom_scm_set_remote_state(u32 state, u32 id); extern int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare); +extern int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size); +extern int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare); #else static inline int qcom_scm_set_cold_boot_addr(void *entry, const cpumask_t *cpus)