From patchwork Mon Jun 24 15:08:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 167626 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4349233ilk; Mon, 24 Jun 2019 08:10:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOVKnNG1Bg/0TP0bL2EcWAwkq2c1cwJU9QpjGqkaV3aP7ss4WmjxoK2a+bogrB/Ko9biXE X-Received: by 2002:a17:90a:ca11:: with SMTP id x17mr25768055pjt.107.1561389047492; Mon, 24 Jun 2019 08:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561389047; cv=none; d=google.com; s=arc-20160816; b=HnkQrV5KPmstMlrSIafeYULdib4/lbZM2ygdaGMe9LpSWSmRFZDdYXr2ak7Pc2nvaO Y/U/4ct7M8G2lX5SQ1iWFCwXkx8d0NUB8EunhOZxSN7VUBgJfWqWjSTz+Bi2lSx/EkvR 9wh+0ZuJOgrtJHwlpXutl0r1FTcf2ItZbqluRI3D5va6/jbVrxXfndauq3+Oa/6YlUyR UlNEv6W9okOZRkZcOqFKhycb/RkMjFwZGto2rsGZ0XJkl+PJUtUctAM5o+eOmoS/MqsT EDMXL1gMfN5mMJGZQs2f3jM92AQ+v9xW3MbGgFI1IoC9kK/X+WM6ceSLPZYGwJ4GQCbE v0Hw== 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 :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature; bh=6/A5zqX04PLpyB5bKH4TTNu46QmN6tpzA0tBihV9SZc=; b=lSYCZr7nox8F+7JxmXE+ZHkHmvvSlTY2tWXK6XEBD0h4xKX6lX1fz8JI32i+1dgGLc jUmTV7WwH+w0//HovU2CLppOAXTrflRUfRZHqwFkfQ4AlZOHtLxtKAdPYHtUJj+XEmXJ 8XMFDjdCmyLmndrI/lZoiuOt8UWYoPqan/HDXH82RNxTqmFZQbEibShwlnV6Ec3q0QhM 8fWDpc2rOjcYk6hj/XQYtkXWBIzg7G3zVx1rkR/OyUjJhWAGJ18HF+f4MgZnpB7zVvrn p/frdCuSZTZHLe/3HiH8akvO+MYk0Hw9HIFnYregV5sl7z98G/Ca/E11entdCFR54YK+ adww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0818 header.b=R3cFoapQ; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=Y2Pb7rnt; 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=NONE sp=NONE dis=NONE) header.from=marvell.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si10264006pgo.574.2019.06.24.08.10.47; Mon, 24 Jun 2019 08:10:47 -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=@marvell.com header.s=pfpt0818 header.b=R3cFoapQ; dkim=pass header.i=@marvell.onmicrosoft.com header.s=selector2-marvell-onmicrosoft-com header.b=Y2Pb7rnt; 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=NONE sp=NONE dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730406AbfFXPJL (ORCPT + 30 others); Mon, 24 Jun 2019 11:09:11 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:62614 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730309AbfFXPJI (ORCPT ); Mon, 24 Jun 2019 11:09:08 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x5OF053e018453; Mon, 24 Jun 2019 08:08:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=6/A5zqX04PLpyB5bKH4TTNu46QmN6tpzA0tBihV9SZc=; b=R3cFoapQluu9/y7C66MCYJ/CPBU6RCu5vy0r8QXVeeZi9kq8CgJBCnRwaXsTghWD/lUz WQwxMH8sTPnOYnHT0uk0Xw14xq+gEV8AWzJvAEULTzulqDs92HWlffk+5RAEqoj7iTCZ joM0s0eh18xqtu5p37mLHHRU1FvXRXu7r1GsCURXOxt77uKfzQEaZiuqvl7OVgazpvs0 7lR7Llklwbu0JplEwAffs+DxaEnNk4BLHO1aczTmhL69Bagi/77H1L+Dx4xILcTGzhvc 8jLINZaLw0kuvAY+m606yz10hir9iqBnyYJB8wqjIkgoEMt47Jv0HXtsoF/8hmusdN7K BQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0a-0016f401.pphosted.com with ESMTP id 2tarxr9t94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 24 Jun 2019 08:08:59 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 24 Jun 2019 08:08:58 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (104.47.42.52) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 24 Jun 2019 08:08:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6/A5zqX04PLpyB5bKH4TTNu46QmN6tpzA0tBihV9SZc=; b=Y2Pb7rntMAGdBB+PZGq7Z4Ln0y8QJwWZ97S4xWmuqiNTUBmTpGn0ntuD6Q/oykSnnzjz2pTL9HZzoRQqDtnvIGBvWgK7Ebo+sagifx9dm+jiNaA5MrIkWnL/jnrdAHa/iDonYuJL13dhWtiNnVYZuAfiUMM2pgQQawuyhsiUMuQ= Received: from MN2PR18MB3408.namprd18.prod.outlook.com (10.255.238.217) by MN2PR18MB2589.namprd18.prod.outlook.com (20.179.82.96) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Mon, 24 Jun 2019 15:08:57 +0000 Received: from MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::d3:794c:1b94:cf3]) by MN2PR18MB3408.namprd18.prod.outlook.com ([fe80::d3:794c:1b94:cf3%4]) with mapi id 15.20.2008.014; Mon, 24 Jun 2019 15:08:57 +0000 From: Robert Richter To: Borislav Petkov , James Morse , "Mauro Carvalho Chehab" CC: "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Robert Richter Subject: [PATCH v2 02/24] EDAC, ghes: Fix grain calculation Thread-Topic: [PATCH v2 02/24] EDAC, ghes: Fix grain calculation Thread-Index: AQHVKp6+pL7VEIGXA0Cki9BKQoDoyg== Date: Mon, 24 Jun 2019 15:08:57 +0000 Message-ID: <20190624150758.6695-3-rrichter@marvell.com> References: <20190624150758.6695-1-rrichter@marvell.com> In-Reply-To: <20190624150758.6695-1-rrichter@marvell.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P190CA0035.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::24) To MN2PR18MB3408.namprd18.prod.outlook.com (2603:10b6:208:16c::25) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [92.254.182.202] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 5758b553-24b4-4664-22fd-08d6f8b5e11b x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020); SRVR:MN2PR18MB2589; x-ms-traffictypediagnostic: MN2PR18MB2589: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2733; x-forefront-prvs: 007814487B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(346002)(376002)(366004)(136003)(189003)(199004)(2906002)(2616005)(486006)(476003)(52116002)(256004)(5660300002)(66446008)(73956011)(66946007)(1076003)(14454004)(6116002)(86362001)(3846002)(99286004)(6486002)(68736007)(81166006)(81156014)(6436002)(4326008)(305945005)(50226002)(53936002)(7736002)(8676002)(8936002)(478600001)(64756008)(66556008)(66476007)(6512007)(107886003)(71190400001)(71200400001)(36756003)(26005)(102836004)(386003)(186003)(11346002)(76176011)(6506007)(110136005)(316002)(54906003)(446003)(25786009)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2589; H:MN2PR18MB3408.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: tbo/VAI2B/p24PGKxYVgzIBKsL0E3YWUMNHVXZcpE7t3zb/KCapIvEMw1/Q3JfMpiDt/Xd6zvsQf8+VBNvRCS9wjP97aL0U2FRdl4yZiohCMFwPbb56xyZCJrYUsJwBY7h/UnjAdAqd1Zlfrp5ZfQtj+7JXnFp847T8fokQvRZ8CYbe0qW2DFYblRVQR9Ab5YYSXkz1rJjUPZWJY/sTOvi4eNXRivdq1+WxRPBfl6zhha2yKoLaM7c2+jf/0OF87CVbnN+HUEitzDvEuxyb0IAIzJkVsfhpzPRahRz2yN+l6rZnE5bFEC9erepDI0Xb64crmbvV8SedRnIWsAxQMBw0c5mHk8AvziEib7L8/Vm8RXPuubmRneLDVW7gtwgN560m7KnZ6hKLiDMgMft83lUcV6hmBOjddOBTWahPDmko= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 5758b553-24b4-4664-22fd-08d6f8b5e11b X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jun 2019 15:08:57.2322 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: rrichter@marvell.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2589 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-06-24_10:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The conversion from the physical address mask to a grain (defined as granularity in bytes) is broken: e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK); E.g., a physical address mask of ~0xfff should give a grain of 0x1000, instead the grain is wrong with the upper bits always set. We also remove the limitation to the page size as the granularity is unrelated to the page size used in the system. We fix this with: e->grain = ~mem_err->physical_addr_mask + 1; Note: We need to adopt the grain_bits calculation as e->grain is now a power of 2 and no longer a bit mask. The formula is now the same as in edac_mc and can later be unified. Signed-off-by: Robert Richter --- drivers/edac/ghes_edac.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c index 7f19f1c672c3..d095d98d6a8d 100644 --- a/drivers/edac/ghes_edac.c +++ b/drivers/edac/ghes_edac.c @@ -222,6 +222,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) /* Cleans the error report buffer */ memset(e, 0, sizeof (*e)); e->error_count = 1; + e->grain = 1; strcpy(e->label, "unknown label"); e->msg = pvt->msg; e->other_detail = pvt->other_detail; @@ -317,7 +318,7 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) /* Error grain */ if (mem_err->validation_bits & CPER_MEM_VALID_PA_MASK) - e->grain = ~(mem_err->physical_addr_mask & ~PAGE_MASK); + e->grain = ~mem_err->physical_addr_mask + 1; /* Memory error location, mapped on e->location */ p = e->location; @@ -433,8 +434,15 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) if (p > pvt->other_detail) *(p - 1) = '\0'; + /* + * We expect the hw to report a reasonable grain, fallback to + * 1 byte granularity otherwise. + */ + if (WARN_ON_ONCE(!e->grain)) + e->grain = 1; + grain_bits = fls_long(e->grain - 1); + /* Generate the trace event */ - grain_bits = fls_long(e->grain); snprintf(pvt->detail_location, sizeof(pvt->detail_location), "APEI location: %s %s", e->location, e->other_detail); trace_mc_event(type, e->msg, e->label, e->error_count,