Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3067308img; Mon, 25 Mar 2019 03:07:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLOgeCcpR4nN+Qoh0Fqa6il3SfbrGV9KLF7OCQLmGOZD/QyHiOly1sT1VDQOT2056KF1FX X-Received: by 2002:aa7:8012:: with SMTP id j18mr24053544pfi.42.1553508455945; Mon, 25 Mar 2019 03:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553508455; cv=none; d=google.com; s=arc-20160816; b=YtVUppPPtFhVza38ohxVwfoSym53MijZ9ra3pW+9VTJw7nomDGepqAsEsEJpRklSDP VVHmN/a7R4UY30PGoW0d65BeZksH8aZeueN/JTguNOr/pywAq6Jr4EFGUFMEyqsgJ77a EHgd5iIlx//YjTFFXbs8wklC76CnMrgAUOid/zgKSjMHuafMcKQEVcVNI/ARgV8KuZw+ UzoP24I3qpz7kSXl824qbW/H5JVS+xFrA7GLs9s2hcvgubWB6ScXQBxUNSNxITmwWgv7 0IsPIEUV9+DcYpNaWpBPw15SmQdko8zRL0RWic0SE6j9LfhLw2HQlYMnqhSmuyXKhuCm caVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=ZfAvtcaD10LSRbbHpyJ6l1C9HkgDSWpRkludz+xyChM=; b=FYDbT2l4crfp8sXe8ASjRFykzoPiUoL8BVsgFbsiua4pqgcNDjby2MOPlNqULm/AS7 Vz9k7uvCOvGaNdPPHPPBUOr4c4Ka1TN9GuCs3zMOD9/NkAAc99s5GoM3R2OFq/BIzs5L +Zz/CpIa6nr0ovaIgNxzB2cAOsaS+gRBY8DkWEIgbCsBKEihReCuuExSNfx0ad8vHni6 JbFW0SeY0hZiaJtAKYCrF2CKMVt9h6p9/egQsPjn/YTyUQkwczwKjDNP6I5PgA56MbpN Ejmr0d68cCXRXnCNGrALYJMTCITDqllSb1qfi5CwIwuKT3+dzt0YobZUDycXJwjoXiGR 3n5A== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u193si8899478pgc.410.2019.03.25.03.07.21; Mon, 25 Mar 2019 03:07: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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730533AbfCYKGs (ORCPT + 99 others); Mon, 25 Mar 2019 06:06:48 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:35084 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730250AbfCYKGs (ORCPT ); Mon, 25 Mar 2019 06:06:48 -0400 Received: by mail-oi1-f196.google.com with SMTP id j132so6475066oib.2; Mon, 25 Mar 2019 03:06:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZfAvtcaD10LSRbbHpyJ6l1C9HkgDSWpRkludz+xyChM=; b=fTx5aAtV8rDgmIAsf1b80sSXeWdm4oEkas/494bnFpIUBk4M1+/g/6rKBEyxZKt5ma s814AgNK5QpuMIALGROFwAxHtS2TJl81oUX3I21jjI5m3erulWUi+HtaLCLdU00UgUV7 z8AUQwsO+YN6chAQuRPWeEXgXUCnLzI9UO3lOUaSnG2dRPMxyqKQ443tQDPSsNsVFSYe e3CKgYT3xvrnhWkROYxXrOkfXN47O1vzjOoP5IwN4YWyI7CvYtS/A+xB/P75Kr7/fbNA Ewt2H0iByO48uxua5BO/+2CO47u7NwdknUb/f1JkkrutFgl9F45Kh4UAmD0jRbLyefxQ f60A== X-Gm-Message-State: APjAAAU12KjopiUtPKQOVKjqvLQQoYbkvRvIzPKgH5iiQ++zO/ASS3/E zYyWvWyioUYmitXCRlIo2V5oc5afXwySWasv5Ds= X-Received: by 2002:aca:5c55:: with SMTP id q82mr11238738oib.95.1553508407504; Mon, 25 Mar 2019 03:06:47 -0700 (PDT) MIME-Version: 1.0 References: <1637073.gl2OfxWTjI@aspire.rjw.lan> <1605148.8jT99SsvVP@aspire.rjw.lan> <20190322142828.GA12472@zn.tnic> In-Reply-To: <20190322142828.GA12472@zn.tnic> From: "Rafael J. Wysocki" Date: Mon, 25 Mar 2019 11:06:36 +0100 Message-ID: Subject: Re: [PATCH 1/2] PM / arch: x86: Rework the MSR_IA32_ENERGY_PERF_BIAS handling To: Borislav Petkov Cc: "Rafael J. Wysocki" , x86 , LKML , Len Brown , Linux PM , Srinivas Pandruvada , Laura Abbott , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Simon Schricker , Hannes Reinecke Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 22, 2019 at 3:28 PM Borislav Petkov wrote: > > On Thu, Mar 21, 2019 at 11:18:01PM +0100, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > The current handling of MSR_IA32_ENERGY_PERF_BIAS in the kernel is > > problematic, because it may cause changes made by user space to that > > MSR (with the help of the x86_energy_perf_policy tool, for example) > > One more reason to control MSR accesses from userspace. I'm working on > a series to even completely forbid accesses to some MSRs over /dev/msr > so I think accessing MSR_IA32_ENERGY_PERF_BIAS solely over the new > interface in patch 2 would be much better. > > So, you're carrying those and you'd like to have an ACK from me? > > Btw, a couple of nitpicks below. > > > Index: linux-pm/arch/x86/kernel/cpu/intel_epb.c > > =================================================================== > > --- /dev/null > > +++ linux-pm/arch/x86/kernel/cpu/intel_epb.c > > @@ -0,0 +1,131 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > ... > > > +static DEFINE_PER_CPU(u8, saved_epb); > > + > > +#define EPB_MASK 0x0fULL > > +#define EPB_SAVED 0x10ULL > > + > > +static int intel_epb_save(void) > > I'd drop that "intel_epb_" prefix from those static functions, but your > call... They help indexing tools (elixir.bootlin.com and similar) a bit, so I'd rather retain them. > > +{ > > + u64 epb; > > + > > + rdmsrl(MSR_IA32_ENERGY_PERF_BIAS, epb); > > + /* > > + * Ensure that saved_epb will always be nonzero after this write even if > > + * the EPB value read from the MSR is 0. > > + */ > > + this_cpu_write(saved_epb, (epb & EPB_MASK) | EPB_SAVED); > > + > > + return 0; > > +} > > ... > > > Index: linux-pm/Documentation/admin-guide/pm/intel_epb.rst > > =================================================================== > > --- /dev/null > > +++ linux-pm/Documentation/admin-guide/pm/intel_epb.rst > > WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 > #345: FILE: Documentation/admin-guide/pm/intel_epb.rst:1: Well, this is documentation, so ...