From patchwork Mon Aug 17 08:27:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 247781 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp2433022ilo; Mon, 17 Aug 2020 01:28:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy68/ljWMsFNXKZj8JA0LJ6xWQiAdsP/DuK5pCMHF22TDwyY+6URPC0/5yMDFcztHdwRXyI X-Received: by 2002:a05:6402:7d5:: with SMTP id u21mr13794299edy.235.1597652883252; Mon, 17 Aug 2020 01:28:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597652883; cv=none; d=google.com; s=arc-20160816; b=WQqq7uppAiajjp3E6E70keGBQbDuwxjbi8HNo+joOUjYjxc9Fl1NzX9czI3IMtquti lca84XutuYKCTgnVD5yGEC5XShD5OIOtKoigQ30D2BUMZ0W3qSidGftDg5oGTZUFW/nW omoot1oemp8F0HA/LXA4ohe7vuYrN5HwxZ/N0SyDJ11UBe1jthf5Dnj1xBeWRJ60+dFu NCtHy/0Kk3Cf3pg58/ZnaEx9hUrbO1fUVdL+Z2vRZI3V1GD2PxMVhYnb2J6B/+2BH8KQ n03Apx/g8/VNvq7kInQ0Cg964glUl4B8oy3gIrReA26YChntsuhosOe1GxMtT8w5Tqh0 k5cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=dHHx8tCCD/f7cY2UrgoF5DI2HEp6u7sbKILLzlEPxJo=; b=oKZ3389FjP1ZVbGfu7EOcQlsxepSHRqpVZAFGPPF7gHf2LLp6AKGbLtF1OyK7weZhY 6mSiKyN24dDK3AoKVg8j4p5pUQSt65TvueD8dTLtZboex1C8ViOEcYuQezBXr01tCnou oVI7ZmnFfcFqIFWv2j7e8BPj33xta23iFvIJ8KaLXEkAH8SHffe4ea7ZV70Pmb2I2VUa sGbcDxW3r4s/efw+s0hnvEFfLzml9onOGfQaq8HcbnQ1/sDsAcNIQqylDQ483htr0pK1 gUfeyS6lZVbfqGUgrqt9cX7IgwGNIvy+AbmJf8CQhn6PKCMvWfd3SDtcQG7aw4F3QAzw i7Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I1AE04mm; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si10558322ejd.617.2020.08.17.01.28.03; Mon, 17 Aug 2020 01:28:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I1AE04mm; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728388AbgHQI15 (ORCPT + 4 others); Mon, 17 Aug 2020 04:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbgHQI1u (ORCPT ); Mon, 17 Aug 2020 04:27:50 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51166C061343 for ; Mon, 17 Aug 2020 01:27:49 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id 9so12515290wmj.5 for ; Mon, 17 Aug 2020 01:27:49 -0700 (PDT) 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=dHHx8tCCD/f7cY2UrgoF5DI2HEp6u7sbKILLzlEPxJo=; b=I1AE04mm3Cu7IVOIi8qpjZg6MCi5n70hUykAwGaeJFE7bwTb1gQIAVIHzAEv+Y5Omw RgkVQw4b5L5iE8LKIL7w01TK18n0Ok1yjMshCjuYyWy0LDrw0ZsaQo8TfFAmVNpxY1tH Jm+2/+r+1CQygJMbY13/L1uQGIz5EhYgNSN3Il0PbNQnO13KFO4TlExBROgkRBXhTCJF joeA2bowB5XNZJKTSt/puj/2resoPZsPs33XpWLXO0gzTkPQoMru2iaMbszx+kjWKAwe vx/b2t17P5kYM0HlbPra4N5Pxr/TZ/Do62wZQDPDy1P1yYu2JTZAAMWYEKaS4Pv9d6hH DWgw== 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=dHHx8tCCD/f7cY2UrgoF5DI2HEp6u7sbKILLzlEPxJo=; b=Cjh/4sORSDR1E55Usf0A/SuPlCtFRJxSRYbkRcUtMfEGtkV+MHFWwnRd08YWc4R/BW 2Z8o8/AvAYi0UhVGVwOhpKtKvEFSKw3f9Siu7zxNvs4YOpbL1BNhVLMRsuqakrQlHUkI KY7aiUH3SC5UsSKQ6PzY/4ibJJ7lbe0p6fJS1bE0ceg4ZaSUO8n0bL9gCCjrRyxkaI9x 4yDioP9jVSMY1HehuY7FQHw8LQ4X/ocy0uO5IPvFxIgpjW1t8jf2H4cPVMT+/AS+hGbB gR7Q41izQd/0dXsVdveHxSOEgJrp6mz0iAEEouQTCxFt8mfjRvdee0Kto1CQENV12PJm qSPw== X-Gm-Message-State: AOAM530DF24gI4qyXJuOtyfFNAJTYnCkDH/zLG/AtB+YLndkzU58528h Z0Gm9rQhMij4Hhkh2tx5oQCHqw== X-Received: by 2002:a05:600c:202:: with SMTP id 2mr12754388wmi.147.1597652868062; Mon, 17 Aug 2020 01:27:48 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id h5sm33270888wrc.97.2020.08.17.01.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 01:27:47 -0700 (PDT) From: Stanimir Varbanov To: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Cc: Elliot Berman , Andy Gross , Bjorn Andersson , Stanimir Varbanov Subject: [PATCH v2 1/2] firmware: qcom_scm: Add memory protect virtual address ranges Date: Mon, 17 Aug 2020 11:27:22 +0300 Message-Id: <20200817082723.17458-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200817082723.17458-1-stanimir.varbanov@linaro.org> References: <20200817082723.17458-1-stanimir.varbanov@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This adds a new SCM memprotect command to set virtual address ranges. Signed-off-by: Stanimir Varbanov --- drivers/firmware/qcom_scm.c | 24 ++++++++++++++++++++++++ drivers/firmware/qcom_scm.h | 1 + include/linux/qcom_scm.h | 8 +++++++- 3 files changed, 32 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Elliot Berman diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index 0e7233a20f34..dec8dc42a6bc 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -757,6 +757,30 @@ int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare) } EXPORT_SYMBOL(qcom_scm_iommu_secure_ptbl_init); +int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size, + u32 cp_nonpixel_start, + u32 cp_nonpixel_size) +{ + int ret; + struct qcom_scm_desc desc = { + .svc = QCOM_SCM_SVC_MP, + .cmd = QCOM_SCM_MP_VIDEO_VAR, + .arginfo = QCOM_SCM_ARGS(4, QCOM_SCM_VAL, QCOM_SCM_VAL, + QCOM_SCM_VAL, QCOM_SCM_VAL), + .args[0] = cp_start, + .args[1] = cp_size, + .args[2] = cp_nonpixel_start, + .args[3] = cp_nonpixel_size, + .owner = ARM_SMCCC_OWNER_SIP, + }; + struct qcom_scm_res res; + + ret = qcom_scm_call(__scm->dev, &desc, &res); + + return ret ? : res.result[0]; +} +EXPORT_SYMBOL(qcom_scm_mem_protect_video_var); + static int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region, size_t mem_sz, phys_addr_t src, size_t src_sz, phys_addr_t dest, size_t dest_sz) diff --git a/drivers/firmware/qcom_scm.h b/drivers/firmware/qcom_scm.h index d9ed670da222..14da834ac593 100644 --- a/drivers/firmware/qcom_scm.h +++ b/drivers/firmware/qcom_scm.h @@ -97,6 +97,7 @@ extern int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc, #define QCOM_SCM_MP_RESTORE_SEC_CFG 0x02 #define QCOM_SCM_MP_IOMMU_SECURE_PTBL_SIZE 0x03 #define QCOM_SCM_MP_IOMMU_SECURE_PTBL_INIT 0x04 +#define QCOM_SCM_MP_VIDEO_VAR 0x08 #define QCOM_SCM_MP_ASSIGN 0x16 #define QCOM_SCM_SVC_OCMEM 0x0f diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h index 3d6a24697761..ba45537f688b 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -77,11 +77,13 @@ extern bool qcom_scm_restore_sec_cfg_available(void); 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); +extern int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size, + u32 cp_nonpixel_start, + u32 cp_nonpixel_size); extern int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, unsigned int *src, const struct qcom_scm_vmperm *newvm, unsigned int dest_cnt); - extern bool qcom_scm_ocmem_lock_available(void); extern int qcom_scm_ocmem_lock(enum qcom_scm_ocmem_client id, u32 offset, u32 size, u32 mode); @@ -128,6 +130,10 @@ static inline int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size) { return -ENODEV; } static inline int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare) { return -ENODEV; } +extern inline int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size, + u32 cp_nonpixel_start, + u32 cp_nonpixel_size) + { return -ENODEV; } static inline int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz, unsigned int *src, const struct qcom_scm_vmperm *newvm, unsigned int dest_cnt) { return -ENODEV; }