summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2026-01-17 02:30:23 +0300
committerSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2026-01-17 03:03:20 +0300
commit6588b8845e7387438d4b91ea86e7cb6d838b3108 (patch)
treed6c6c4de3afb50de3e83ac08aa5db3a0bf535654 /tools
parent8ca7515d3c76a8b629f703ff8301a75f503bcc50 (diff)
downloadlinux-6588b8845e7387438d4b91ea86e7cb6d838b3108.tar.xz
tools/power/x86/intel-speed-select: Allow non root users
When permitted by the file /dev/isst_interface, allow to issue commands for non root users. When user id is non root, check if "/dev/isst_interface" can still be opened. If this file can be opened, allow all read only commands. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/x86/intel-speed-select/isst-config.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/tools/power/x86/intel-speed-select/isst-config.c b/tools/power/x86/intel-speed-select/isst-config.c
index 558138eea75e..807feb17bb81 100644
--- a/tools/power/x86/intel-speed-select/isst-config.c
+++ b/tools/power/x86/intel-speed-select/isst-config.c
@@ -80,6 +80,18 @@ struct cpu_topology {
short die_id;
};
+static int read_only;
+
+static void check_privilege(void)
+{
+ if (!read_only)
+ return;
+
+ isst_display_error_info_message(1, "Insufficient privileges", 0, 0);
+ isst_ctdp_display_information_end(outf);
+ exit(1);
+}
+
FILE *get_output_file(void)
{
return outf;
@@ -1578,6 +1590,8 @@ free_mask:
static void set_tdp_level(int arg)
{
+ check_privilege();
+
if (cmd_help) {
fprintf(stderr, "Set Config TDP level\n");
fprintf(stderr,
@@ -2046,6 +2060,8 @@ static void set_pbf_enable(int arg)
{
int enable = arg;
+ check_privilege();
+
if (cmd_help) {
if (enable) {
fprintf(stderr,
@@ -2212,6 +2228,8 @@ static void set_fact_enable(int arg)
int i, ret, enable = arg;
struct isst_id id;
+ check_privilege();
+
if (cmd_help) {
if (enable) {
fprintf(stderr,
@@ -2361,6 +2379,8 @@ static void set_clos_enable(int arg)
{
int enable = arg;
+ check_privilege();
+
if (cmd_help) {
if (enable) {
fprintf(stderr,
@@ -2491,6 +2511,8 @@ static void set_clos_config_for_cpu(struct isst_id *id, void *arg1, void *arg2,
static void set_clos_config(int arg)
{
+ check_privilege();
+
if (cmd_help) {
fprintf(stderr,
"Set core-power configuration for one of the four clos ids\n");
@@ -2556,6 +2578,8 @@ static void set_clos_assoc_for_cpu(struct isst_id *id, void *arg1, void *arg2, v
static void set_clos_assoc(int arg)
{
+ check_privilege();
+
if (cmd_help) {
fprintf(stderr, "Associate a clos id to a CPU\n");
fprintf(stderr,
@@ -2637,6 +2661,8 @@ static void set_turbo_mode(int arg)
int i, disable = arg;
struct isst_id id;
+ check_privilege();
+
if (cmd_help) {
if (disable)
fprintf(stderr, "Set turbo mode disable\n");
@@ -2682,6 +2708,7 @@ static void get_set_trl(struct isst_id *id, void *arg1, void *arg2, void *arg3,
}
if (set) {
+ check_privilege();
ret = isst_set_trl(id, fact_trl);
isst_display_result(id, outf, "turbo-mode", "set-trl", ret);
return;
@@ -3204,8 +3231,16 @@ static void cmdline(int argc, char **argv)
};
if (geteuid() != 0) {
- fprintf(stderr, "Must run as root\n");
- exit(0);
+ int fd;
+
+ fd = open(pathname, O_RDWR);
+ if (fd < 0) {
+ fprintf(stderr, "Must run as root\n");
+ exit(0);
+ }
+ fprintf(stderr, "\nNot running as root, Only read only operations are supported\n");
+ close(fd);
+ read_only = 1;
}
ret = update_cpu_model();