@@ -47,6 +47,16 @@ struct hbind_params {
*/
#define HBIND_CMD_DEFAULT 0
+/*
+ * HBIND_CMD_BIND strict policy ie new allocations will comes from one of the
+ * listed targets until they run of memory. Other targets can be use if the
+ * none of the listed targets can be accessed by the initiator that did fault.
+ *
+ * Additional dwords:
+ * NONE (DWORDS MUST BE 0 !)
+ */
+#define HBIND_CMD_BIND 1
+
#define HBIND_IOCTL _IOWR('H', 0x00, struct hbind_params)
@@ -338,6 +338,36 @@ static struct hms_policy *hms_policy_get(struct mm_struct *mm)
}
+static int hbind_bind(struct mm_struct *mm, struct hbind_params *params,
+ const uint32_t *targets, uint32_t *atoms)
+{
+ struct hms_policy_range *prange;
+ struct hms_policy *hpolicy;
+ int ret;
+
+ hpolicy = hms_policy_get(mm);
+ if (hpolicy == NULL)
+ return -ENOMEM;
+
+ prange = hms_policy_range_new(targets, params->start, params->end,
+ params->ntargets);
+ if (prange == NULL)
+ return -ENOMEM;
+
+ down_write(&hpolicy->sem);
+ ret = hbind_default_locked(hpolicy, params);
+ if (ret)
+ goto out;
+
+ interval_tree_insert(&prange->node, &hpolicy->ranges);
+
+out:
+ up_write(&hpolicy->sem);
+
+ return ret;
+}
+
+
static long hbind_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
uint32_t *targets, *_dtargets = NULL, _ftargets[HBIND_FIX_ARRAY];
@@ -418,6 +448,16 @@ static long hbind_ioctl(struct file *file, unsigned cmd, unsigned long arg)
if (ret)
goto out_mm;
break;
+ case HBIND_CMD_BIND:
+ if (ndwords != 1) {
+ ret = -EINVAL;
+ goto out_mm;
+ }
+ ret = hbind_bind(current->mm, ¶ms,
+ targets, atoms);
+ if (ret)
+ goto out_mm;
+ break;
default:
ret = -EINVAL;
goto out_mm;