Received: by 10.213.65.68 with SMTP id h4csp2113933imn; Sun, 8 Apr 2018 20:04:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/5RuIyVdL2QCkwUrG3NhwuHkv/Ny1wM4J8pyKsyn6awqA4nlVwtFBInXlv3IzXmA6kpidm X-Received: by 10.99.100.196 with SMTP id y187mr23372589pgb.83.1523243041627; Sun, 08 Apr 2018 20:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243041; cv=none; d=google.com; s=arc-20160816; b=fp7XRNwXU7pJKgc0xAmf+uK/W0RHRikPVWxKXvjBX6unSds7boToW/tpaGEci3qVaR C+LIdKt0Vt5xWMa1TQ/wHCDZkaw0Sq1LynlTiJBkJT/6tl/i3M21XeN19OnHH4NSnRwH ZDK36i/mj1wlFoUKklQ8PTjT+yuMSWu4cXr6ksdMiCM31Ofe5eKA0ZzYdYc3mm9ekx5k vZz5XlkOeQCyNn3Kf2bv5A+VHOgf+UgEb7dFK0QNe2xX6rNo95AtoMf7pskRrOOTKLHR I+v79NxFeV8QHF0Y3XkW1uWzWpVarXeQ/opx73GgS642oUnQ9NUH94NDDF/FF5k7rqmD 4OYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=KXX9gbluy/MviwQpX5fjrJ9oQMCD37NJ+A/b3XmRiD8=; b=CysWaKvJOYJVUwm+v9K79tiXNRoQzmoAke5dkiEcbUYKD289xlLC66/IJU3wnUVnK6 hZcQ9et/WhMtbTNhyWnvmW6HE9jrlWRiiZdQq7mwJ3SHAOLUoQN2Yga43uW+984jvv+g ruDTVk2qpQnfny26A2mVchsryW3JX6QHu0X5QTICftv3fm8GMJsq0oDsLHXu+6gbxozF R5/h7Iko/DxRCXwOp7acbGkfTGQjX37uTjIItxW6Xp/Mvc3pgVZA6hp2zsYfx1//xaKQ SXoYkr2xYfHuAHwgkregcwddGTCC0UEe04NXyxSsjlzyD0VrU+VWhSIuBkP4EJBFnp8/ SCtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=cTfSk+Zf; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si10493536pgg.29.2018.04.08.20.03.24; Sun, 08 Apr 2018 20:04:01 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=cTfSk+Zf; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756234AbeDIAbS (ORCPT + 99 others); Sun, 8 Apr 2018 20:31:18 -0400 Received: from mail-dm3nam03on0090.outbound.protection.outlook.com ([104.47.41.90]:62849 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753920AbeDIAbG (ORCPT ); Sun, 8 Apr 2018 20:31:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KXX9gbluy/MviwQpX5fjrJ9oQMCD37NJ+A/b3XmRiD8=; b=cTfSk+ZfD0ULVS0i6B3afg9g01ZkuyuWwATfNiebwFt8slaWm90ScDGgpuEBUqOf9R5aZXsDsCBj3F9cluO7nBL4ftP0+uTT7aCeNy2wuQBxMd9CjwJYUKp3dAhuKWXSzw6SP15qTH79v+rHoz7ukI1fP8ee+p4VUDD44wLDPJs= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0807.namprd21.prod.outlook.com (10.167.110.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.3; Mon, 9 Apr 2018 00:31:04 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:31:04 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Adam Lessnau , "Rafael J . Wysocki" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 151/293] powercap/RAPL: prevent overridding bits outside of the mask Thread-Topic: [PATCH AUTOSEL for 4.9 151/293] powercap/RAPL: prevent overridding bits outside of the mask Thread-Index: AQHTz5ksfKp4rR/osEKcSlF7PTFMmA== Date: Mon, 9 Apr 2018 00:24:51 +0000 Message-ID: <20180409002239.163177-151-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0807;7:/jhTi0fH7amIkawR4mgfRbfuEY7IEBbngVUj1quhh+c7+ccnYVFDLirHvnl9Gz8IWoYLCAI6EX3ZtVy3p6AUroy8YKfnEI9+GIHb0B+mZEFKL5WoqTgbbxWe9V2PGWQ/xnw5fRXOSmmi9Nr2WCnmzamMqOndJGxCodIF7Lj71B9qdQq/ZbnpqVRmo65Ih5jIEoJkafOf4kMJ1S+AI3OnaYZnizykSXOCdYEo76U04otAUHDZiqhv37iNwaR4svb5;20:DeWoL7nH8h6tBXWobReBxHE+ooyuJQMuqsWmYdz4eouQz22H2Ulhzc6Ula7YnwoBy2uE1ygBIvoguU/C7Ua9x3Hu8udvYk09vPyEu6M/O1MVha+u9BLflCs3NwN3r8nXf8udV/sBLI9cx+i+BFx0mfFU2HHveTkdgDoVDp1b7ro= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 324b2ac2-f3bc-4a50-5b0a-08d59db12dd9 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0807; x-ms-traffictypediagnostic: DM5PR2101MB0807: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231221)(944501327)(52105095)(3002001)(6055026)(61426038)(61427038)(6041310)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0807;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0807; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(396003)(366004)(376002)(346002)(199004)(189003)(14454004)(4326008)(54906003)(25786009)(53936002)(2900100001)(1076002)(3280700002)(6486002)(186003)(2616005)(68736007)(110136005)(11346002)(10090500001)(6116002)(107886003)(3846002)(36756003)(8676002)(72206003)(22452003)(66066001)(26005)(6512007)(478600001)(3660700001)(81156014)(86362001)(81166006)(86612001)(7736002)(305945005)(8936002)(10290500003)(6436002)(105586002)(6666003)(316002)(575784001)(59450400001)(76176011)(5660300001)(476003)(106356001)(2906002)(6506007)(446003)(2501003)(99286004)(5250100002)(486006)(102836004)(97736004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0807;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: +ZoCrwqbZpALAa8agl5Fx8c9AwxbaO9AdiJ1FzZKh3lJz57c21GzAZMu3PRwjOQQfope3XY4zNZCP0kzFLTwkIUTljZKyfWKdOzVf3UgrqkV2To103CXYzdvvclnyROhFbzLEdkCOPIbGXPMbbU6/nPDnHL2puh32UliaBce4TDFbPT5rV0fUcJ+Ow7ZzT3y4wnGvAUrJ6NaudGEf57MqfTHbo16UEPFmVMD6oGOBBYDTVdOwoFDtXfYwbEp6dQY0X3O/rgcKJwN3AMh6o1yUkjBr+10irKmuUKwD0HCUlaV9dNMzCyekD8hkfYsCkJ4ujTA+bm41kdFtc0lbluy9M8efU4VQ3LibRbKoYM1yk8auDoJQWc2Qh3YQ8wem203u9oVfJ8Wru53D8flx3ROnmt/9bpuxltdGj34304t3wM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 324b2ac2-f3bc-4a50-5b0a-08d59db12dd9 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:51.5657 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0807 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adam Lessnau [ Upstream commit edbdabc62328ec0ac98d83ca384bf9fd5251ade6 ] Fixes wrong bits shift operation in the rapl_write_data_raw function, which might cause overridding bits outside of the mask. For example, writing new TIME_WINDOW1 value can override POWER_LIMIT1. Signed-off-by: Adam Lessnau Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/powercap/intel_rapl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/powercap/intel_rapl.c b/drivers/powercap/intel_rapl.c index 3c71f608b444..6dc27afb8527 100644 --- a/drivers/powercap/intel_rapl.c +++ b/drivers/powercap/intel_rapl.c @@ -887,7 +887,9 @@ static int rapl_write_data_raw(struct rapl_domain *rd, =20 cpu =3D rd->rp->lead_cpu; bits =3D rapl_unit_xlate(rd, rp->unit, value, 1); - bits |=3D bits << rp->shift; + bits <<=3D rp->shift; + bits &=3D rp->mask; + memset(&ma, 0, sizeof(ma)); =20 ma.msr_no =3D rd->msrs[rp->id]; --=20 2.15.1