lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <da7128660bd6d7d62a3ac1070a02c7c9d15cfcd2.1674531462.git.quic_schowdhu@quicinc.com>
Date:   Tue, 24 Jan 2023 09:22:37 +0530
From:   Souradeep Chowdhury <quic_schowdhu@...cinc.com>
To:     Andy Gross <agross@...nel.org>,
        Konrad Dybcio <konrad.dybcio@...ainline.org>,
        Bjorn Andersson <andersson@...nel.org>,
        "Alex Elder" <elder@...e.org>
CC:     <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <linux-arm-msm@...r.kernel.org>,
        Sai Prakash Ranjan <quic_saipraka@...cinc.com>,
        Sibi Sankar <quic_sibis@...cinc.com>,
        "Rajendra Nayak" <quic_rjendra@...cinc.com>, <vkoul@...nel.org>,
        Souradeep Chowdhury <quic_schowdhu@...cinc.com>
Subject: [PATCH V2 3/3] soc: qcom: dcc: Add QAD support for DCC

Add QAD debugfs file for DCC which can be used to enable/disable
the QAD for a list. QAD is used to specify the access control
for DCC configurations, on enabling it the access control to
dcc configuration space is restricted. On setting the QAD value,
the list gets locked out for a particular component and cannot
be used by the rest.

Signed-off-by: Souradeep Chowdhury <quic_schowdhu@...cinc.com>
---
 Documentation/ABI/testing/debugfs-driver-dcc |  8 ++++
 drivers/soc/qcom/dcc.c                       | 68 ++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)

diff --git a/Documentation/ABI/testing/debugfs-driver-dcc b/Documentation/ABI/testing/debugfs-driver-dcc
index 6f5d965..a3c4657 100644
--- a/Documentation/ABI/testing/debugfs-driver-dcc
+++ b/Documentation/ABI/testing/debugfs-driver-dcc
@@ -141,3 +141,11 @@ Description:
 	        This debugfs interface is used for enabling the
 	        hwtrigger. Hwtrigger can be enabled by writing
 		a '1' to the file.
+
+What:           /sys/kernel/debug/dcc/.../[list-number]/QAD
+Date:           January 2023
+Contact:        Souradeep Chowdhury <quic_schowdhu@...cinc.com>
+Description:
+		This debugfs interface is used for enabling the
+		QAD. QAD can be enabled by writing a '1' to the
+		file.
diff --git a/drivers/soc/qcom/dcc.c b/drivers/soc/qcom/dcc.c
index a75b9af..eeeaa8b 100644
--- a/drivers/soc/qcom/dcc.c
+++ b/drivers/soc/qcom/dcc.c
@@ -38,6 +38,7 @@
 #define DCC_LL_SW_TRIGGER		0x2c
 #define DCC_LL_BUS_ACCESS_STATUS	0x30
 #define DCC_CTI_TRIG			0x34
+#define DCC_QAD_OUTPUT                  0x38
 
 /* Default value used if a bit 6 in the HW_INFO register is set. */
 #define DCC_FIX_LOOP_OFFSET		16
@@ -118,6 +119,7 @@ struct dcc_config_entry {
  * @enable_bitmap:	Bitmap to capture the enabled status of each linked list of addresses
  * @cti_bitmap:		Bitmap to capture the cti-trigger status of each linked list of addresses
  * @hwtrig_bitmap:	Bitmap to capture the hwtrig status of each linked list of addresses
+ * @qad_bitmap:		Bitmap to capture the qad status of each linked list of addresses
  */
 struct dcc_drvdata {
 	void __iomem		*base;
@@ -137,6 +139,7 @@ struct dcc_drvdata {
 	unsigned long		*enable_bitmap;
 	unsigned long		*cti_bitmap;
 	unsigned long		*hwtrig_bitmap;
+	unsigned long           *qad_bitmap;
 };
 
 struct dcc_cfg_attr {
@@ -599,6 +602,8 @@ static int dcc_enable(struct dcc_drvdata *drvdata, unsigned int curr_list)
 	dcc_list_writel(drvdata, DCC_TRIGGER_MASK,
 			curr_list, DCC_LL_CFG);
 	if (drvdata->mem_map_ver == 3) {
+		dcc_list_writel(drvdata, test_bit(curr_list, drvdata->qad_bitmap), curr_list,
+				DCC_QAD_OUTPUT);
 		dcc_list_writel(drvdata, test_bit(curr_list, drvdata->cti_bitmap), curr_list,
 				DCC_CTI_TRIG);
 		if (test_bit(curr_list, drvdata->hwtrig_bitmap))
@@ -1245,6 +1250,64 @@ static const struct file_operations hwtrigger_fops = {
 	.llseek = generic_file_llseek,
 };
 
+static ssize_t qad_read(struct file *filp, char __user *userbuf,
+			size_t count, loff_t *ppos)
+{
+	char *buf;
+	int curr_list;
+
+	struct dcc_drvdata *drvdata = filp->private_data;
+
+	curr_list = dcc_filp_curr_list(filp);
+
+	mutex_lock(&drvdata->mutex);
+
+	if (test_bit(curr_list, drvdata->qad_bitmap))
+		buf = "Y\n";
+	else
+		buf = "N\n";
+
+	mutex_unlock(&drvdata->mutex);
+
+	return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+}
+
+static ssize_t qad_write(struct file *filp, const char __user *userbuf,
+			 size_t count, loff_t *ppos)
+{
+	int ret, curr_list;
+	bool val;
+	struct dcc_drvdata *drvdata = filp->private_data;
+
+	curr_list = dcc_filp_curr_list(filp);
+
+	if (drvdata->mem_map_ver != 3) {
+		dev_err(drvdata->dev, "QAD is not supported\n");
+		return -EINVAL;
+	}
+
+	if (test_bit(curr_list, drvdata->enable_bitmap))
+		return -EBUSY;
+
+	ret = kstrtobool_from_user(userbuf, count, &val);
+	if (ret < 0)
+		return ret;
+
+	if (val)
+		set_bit(curr_list, drvdata->qad_bitmap);
+	else
+		clear_bit(curr_list, drvdata->qad_bitmap);
+
+	return count;
+}
+
+static const struct file_operations qad_fops = {
+	.read = qad_read,
+	.write = qad_write,
+	.open = simple_open,
+	.llseek = generic_file_llseek,
+};
+
 static void dcc_delete_debug_dir(struct dcc_drvdata *drvdata)
 {
 	 debugfs_remove_recursive(drvdata->dbg_dir);
@@ -1276,6 +1339,7 @@ static void dcc_create_debug_dir(struct dcc_drvdata *drvdata)
 			    drvdata, &config_reset_fops);
 	debugfs_create_file("ctitrigger", 0600, list, drvdata, &ctitrigger_fops);
 	debugfs_create_file("hwtrigger", 0600, list, drvdata, &hwtrigger_fops);
+	debugfs_create_file("QAD", 0600, list, drvdata, &qad_fops);
 }
 
 static ssize_t dcc_sram_read(struct file *file, char __user *data,
@@ -1447,6 +1511,10 @@ static int __init dcc_probe(struct platform_device *pdev)
 	if (!drvdata->hwtrig_bitmap)
 		return -ENOMEM;
 
+	drvdata->qad_bitmap = devm_bitmap_alloc(dev, drvdata->nr_link_list, GFP_KERNEL);
+	if (!drvdata->qad_bitmap)
+		return -ENOMEM;
+
 	drvdata->cfg_head = devm_kcalloc(dev, drvdata->nr_link_list,
 					 sizeof(*drvdata->cfg_head), GFP_KERNEL);
 	if (!drvdata->cfg_head)
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ