From patchwork Thu Sep 10 07:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 249573 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6011:0:0:0:0 with SMTP id o17csp1165543ejj; Thu, 10 Sep 2020 00:53:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0KpeeOriL2mSnpzU7JgRuUzVgWQ2z74hKrgNrqhJ+bcyxWoDbSWZP9jLXQX66gN6btDTS X-Received: by 2002:a17:906:2ac5:: with SMTP id m5mr7285165eje.210.1599724393335; Thu, 10 Sep 2020 00:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599724393; cv=none; d=google.com; s=arc-20160816; b=OPnuR9hFx8utSOpJDtZ1OyZPFfJWsyrx/ylpxIxEgBZj8INI+nUYzboOz7nDJIjFVY 24u5euJB75CubxLsF2S0VeurFtyAzKb64br6mRQdh/RDYqZyB24I2oFvsQF38cfxwqAj SYdXmtWu7D1y5b+FtsRIpGFldyNwTTGV+2uWJdNvDAK5lxA8eYgI3ZjCc9jPd3wZt5+L iapXC3pg70hY7jqAXPYJ38FTwd3sE1G8r6kBZwv5NkiJEWfAGVhv4KwrxGLRiH8ozzn4 Il7/blZhq11iS5WSDgrfSQlgfc4p9Zl8N4HpjE/QRDBuvI+SeJGqVnZ+V2oStkOiUvcw Nr9g== 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=CHubz0brBEwmMQnBM1waB6q/QSDzur+5k9FicpsHZg0=; b=Si9AeJObilOi75l9lh7LHTWLxcNcbtSXsehSJqipSgQEd7kWMOkJxvvQE+vmDkIECu Ftdhv/inO4RqSW1UkKKqbj8PXpMzqnkzwGxi8/EDqNpqsB5hSBY8ayiXv2uORzNtc1HT y2WayHi8Iovl4+CEQQSXy6vxAKPlqzNZccB4HIIDByjQWfid9j7GiCGX65gxc85nLi28 RlIMRXO64WnfH2vShMreJXQHTPqEEmaQ44irfxAHIKH5Co1VUESb7JJYw93I8bFStSq8 Uanq61mZn2gHIXqnJJIBudGnwOVl695b/EPrsHCn0sj+vXzk4ckbgXAiM/p0mjYHUBi6 rOWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aHsNrbag; 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 y3si3172258edr.538.2020.09.10.00.53.13; Thu, 10 Sep 2020 00:53:13 -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=aHsNrbag; 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 S1730085AbgIJHxJ (ORCPT + 4 others); Thu, 10 Sep 2020 03:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730082AbgIJHw6 (ORCPT ); Thu, 10 Sep 2020 03:52:58 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C63DC061786 for ; Thu, 10 Sep 2020 00:52:57 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id r7so7274902ejs.11 for ; Thu, 10 Sep 2020 00:52:57 -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=CHubz0brBEwmMQnBM1waB6q/QSDzur+5k9FicpsHZg0=; b=aHsNrbagatWzrrMT0MBF+MbTsTOmc1ArzI9UDkz88DfgcLqmHf6s7zGTOW5A4C7w2i YnYc4KvQar7G4t+dc6b1b1uLf6Go0zwyYE2foDHddnsQbDcOoYeEZgJJarVuhpd+7vfD 2jjQTkLlW7SDX37fyMcwmhDixkAz+dXU61b/ZxX0xaVB31hulBFQBV1FOIgwmGKDRMub ix1gf+9WyZmV8f6PMcrgd57D92Bgf8fHCYLZ0tALl6qbYuc6vqNucmqAifDOvDMHmt1N XpVPBHokDRR86Twufzn9/VcOpMe6qvCSquvHLfLOhsjKYM76lefY/MqQU9BnUH4ULEiV DrDg== 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=CHubz0brBEwmMQnBM1waB6q/QSDzur+5k9FicpsHZg0=; b=qoYpCwoUL3ZqHLSLvAzE5dmzF4RTr1wZo3wnRc2CaHqaI0VqnxZMBybsVf91Vn4fci 1RH5cMk7WOX15MFXz7dOId+dAkNImiUQnK2ntxwTPG3/s7iGl2PVJOHBmke9/3nvUYKH 5fgpsZ0E2fKpyDSvFt9xiurPPgJ4f6EcaVjQpH8/yTcOT667urLWwMYoEoMKNDId8IiV OVUNJ7q8YahulBhqw1D3ZhOH4PzFv8c3oykQT23TJLpGYl/AXD2Kv1qftseDe/xs2MLw e7yFWv3yOo0vzTE8/gqV2Ik/V2FOo7lIVklG72D15th9UaAp3vpphKSAenupaOocH+Cs Abfw== X-Gm-Message-State: AOAM531oAiWRWNTRgD9DEaXkfZdv7zJ5CNGMlIReTtog/j9CdnDLqI+T 90GPPL+VXSWCt6jQk1oAPdJtqA== X-Received: by 2002:a17:906:bc98:: with SMTP id lv24mr7812319ejb.411.1599724376600; Thu, 10 Sep 2020 00:52:56 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id q26sm5742838ejr.97.2020.09.10.00.52.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 00:52:56 -0700 (PDT) From: Stanimir Varbanov To: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Cc: Bjorn Andersson , Elliot Berman , Stanimir Varbanov Subject: [PATCH v3 1/2] firmware: qcom_scm: Add memory protect virtual address ranges Date: Thu, 10 Sep 2020 10:52:26 +0300 Message-Id: <20200910075227.950-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200910075227.950-1-stanimir.varbanov@linaro.org> References: <20200910075227.950-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 Reviewed-by: Elliot Berman Acked-by: Bjorn Andersson --- drivers/firmware/qcom_scm.c | 24 ++++++++++++++++++++++++ drivers/firmware/qcom_scm.h | 1 + include/linux/qcom_scm.h | 7 +++++++ 3 files changed, 32 insertions(+) -- 2.17.1 diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c index e8bbf2d38ae7..7be48c1bec96 100644 --- a/drivers/firmware/qcom_scm.c +++ b/drivers/firmware/qcom_scm.c @@ -756,6 +756,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 38ea614d29fe..95cd1ac30ab0 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 2e1193a3fb5f..0165824c5128 100644 --- a/include/linux/qcom_scm.h +++ b/include/linux/qcom_scm.h @@ -84,6 +84,9 @@ 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, @@ -141,6 +144,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; }