Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2497382imm; Sat, 30 Jun 2018 22:21:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcNUf3J3zSmYO/1ReI3F4Ko4/gpjPRgAT2FuIFAbyyLhIZ2qqWnLHJFJLvOMw/NsVg+zuAo X-Received: by 2002:a62:a649:: with SMTP id t70-v6mr3053940pfe.149.1530422495682; Sat, 30 Jun 2018 22:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530422495; cv=none; d=google.com; s=arc-20160816; b=h6a6wJqIiogYadjPUDlCG0vhneIIkoduaGqIJ8Pu8YXeT10feyI3a4EU9TG2bK1xPb +I/Fk1msyPjDmijoPeE5kRtNaUGDxauQXSb45uejSVtxEJVDJQBN3aTvFLOZaWTAxelz n0oaxiSDvRLdd4CzAae1G57FvM0y1Yc/MBOWU4UcpGyj1SHreMUGbog3FKLxFv0wfDLq 4ze4sDhJGAKWAlPzyYmUbHI3IoE66RDlTbV81cnz2Dy5k1FiXJGUfN8QxYLmbe1dTaM/ HGpLAAAvGNzj5b2s4MEH6i5UbUrBpYpOpwvoryj6sZL5R6aQXEKVOMRdy2cSjBARrUMG 4JyA== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=5WXmzXxXkRfsGafKzJo/0U+3B8lnZeY5OjR8ownwe44=; b=uylYKdihigYmJnaNRCQUKFwfl1yoLiBm6VGR1Px+qRngQ828KnlJu/Am9YAOeooeK9 DdOioOdajnMJZG9iZ/zX5IILw9AQnJovoacURvCCNxlVUFy2/47J0s8VCd3laTPSjrz7 7wQDPHCKZyCCH5VsLUb0LdOc1IvUW9jF9TPTUiG2/JhOqtThmcNsW8/A2sGQU+NsP5Ub SLoYdoeH12LD15tq+UyJy8uUj4GgWGBVEvzY+9GIw0XBTDJ2Dh4Om/3WIudrJBs3Saj2 AvbOT2vOaWSNFPfLFcaAv6SNwk603FJIq7On3QO/E3sgBMxHjZ3z2Sg73J7SIz8WRh2/ 1ofg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s19-v6si8521794pgv.327.2018.06.30.22.21.21; Sat, 30 Jun 2018 22:21:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752158AbeGAFSU (ORCPT + 99 others); Sun, 1 Jul 2018 01:18:20 -0400 Received: from mga01.intel.com ([192.55.52.88]:16836 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751561AbeGAFRv (ORCPT ); Sun, 1 Jul 2018 01:17:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jun 2018 22:17:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,293,1526367600"; d="scan'208";a="54226736" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga006.jf.intel.com with ESMTP; 30 Jun 2018 22:17:50 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH 1/2] x86/intel_rdt: Support restoration of subset of permissions Date: Sat, 30 Jun 2018 22:17:32 -0700 Message-Id: <8773aadfade7bcb2c48a45fa294a04d2c03bb0a1.1530421961.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the mode of a resource group changes, the operations it can support may also change. One way in which the supported operations are managed is to modify the permissions of the files within the resource group's resctrl directory. At the moment only two possible permissions are supported: the default permissions or no permissions in support for when the operation is "locked down". It is possible where an operation on a resource group may have more possibilities. For example, if by default changes can be made to the resource group by writing to a resctrl file while the current settings can be obtained by reading from the file, then it may be possible that in another mode it is only possible to read the current settings, and not change them. Make it possible to modify some of the permissions of a resctrl file in support of a more flexible way to manage the operations on a resource group. In this preparation work the original behavior is maintained where all permissions are restored. Signed-off-by: Reinette Chatre --- arch/x86/kernel/cpu/intel_rdt.h | 3 ++- arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 14 +++++++------- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 6 ++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index 2d9cbb9d7a58..4e588f36228f 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -512,7 +512,8 @@ void rdt_ctrl_update(void *arg); struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn); void rdtgroup_kn_unlock(struct kernfs_node *kn); int rdtgroup_kn_mode_restrict(struct rdtgroup *r, const char *name); -int rdtgroup_kn_mode_restore(struct rdtgroup *r, const char *name); +int rdtgroup_kn_mode_restore(struct rdtgroup *r, const char *name, + umode_t mask); struct rdt_domain *rdt_find_domain(struct rdt_resource *r, int id, struct list_head **pos); ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of, diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c index 8fd79c281ee6..5dfe4008c58f 100644 --- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c +++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c @@ -590,11 +590,11 @@ static int rdtgroup_locksetup_user_restrict(struct rdtgroup *rdtgrp) goto out; err_cpus_list: - rdtgroup_kn_mode_restore(rdtgrp, "cpus_list"); + rdtgroup_kn_mode_restore(rdtgrp, "cpus_list", 0777); err_cpus: - rdtgroup_kn_mode_restore(rdtgrp, "cpus"); + rdtgroup_kn_mode_restore(rdtgrp, "cpus", 0777); err_tasks: - rdtgroup_kn_mode_restore(rdtgrp, "tasks"); + rdtgroup_kn_mode_restore(rdtgrp, "tasks", 0777); out: return ret; } @@ -615,20 +615,20 @@ static int rdtgroup_locksetup_user_restore(struct rdtgroup *rdtgrp) { int ret; - ret = rdtgroup_kn_mode_restore(rdtgrp, "tasks"); + ret = rdtgroup_kn_mode_restore(rdtgrp, "tasks", 0777); if (ret) return ret; - ret = rdtgroup_kn_mode_restore(rdtgrp, "cpus"); + ret = rdtgroup_kn_mode_restore(rdtgrp, "cpus", 0777); if (ret) goto err_tasks; - ret = rdtgroup_kn_mode_restore(rdtgrp, "cpus_list"); + ret = rdtgroup_kn_mode_restore(rdtgrp, "cpus_list", 0777); if (ret) goto err_cpus; if (rdt_mon_capable) { - ret = rdtgroup_kn_mode_restore(rdtgrp, "mon_groups"); + ret = rdtgroup_kn_mode_restore(rdtgrp, "mon_groups", 0777); if (ret) goto err_cpus_list; } diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 7b4a09d81a30..c20b51afd62d 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -1405,13 +1405,15 @@ int rdtgroup_kn_mode_restrict(struct rdtgroup *r, const char *name) * rdtgroup_kn_mode_restore - Restore user access to named resctrl file * @r: The resource group with which the file is associated. * @name: Name of the file + * @mask: Mask of permissions that should be restored * * Restore the permissions of the named file. If @name is a directory the * permissions of its parent will be used. * * Return: 0 on success, <0 on failure. */ -int rdtgroup_kn_mode_restore(struct rdtgroup *r, const char *name) +int rdtgroup_kn_mode_restore(struct rdtgroup *r, const char *name, + umode_t mask) { struct iattr iattr = {.ia_valid = ATTR_MODE,}; struct kernfs_node *kn, *parent; @@ -1423,7 +1425,7 @@ int rdtgroup_kn_mode_restore(struct rdtgroup *r, const char *name) for (rft = rfts; rft < rfts + len; rft++) { if (!strcmp(rft->name, name)) - iattr.ia_mode = rft->mode; + iattr.ia_mode = rft->mode & mask; } kn = kernfs_find_and_get_ns(r->kn, name, NULL); -- 2.17.0