Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1298217pxa; Sat, 15 Aug 2020 14:54:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy50+W4CHoPnlaltThFLKG3lLm+OCqRXAkZ7F17ZLEnReIPFH8U8oJMPVdMK/T6KMOXRIg8 X-Received: by 2002:aa7:d948:: with SMTP id l8mr8560908eds.371.1597528491315; Sat, 15 Aug 2020 14:54:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597528491; cv=none; d=google.com; s=arc-20160816; b=LbGS/Z3AipkB6wMtZYkn2X84a/P8jki3EO6r/0VIIzqwjWDAtBdO28B7OcHIxSFJw8 qa2ENSYWsea7SOLj3omsLjboTT+WTfIhxH3gE08a2ItVGtqToFe4hO9zTOf8GaO0o+ST fVzjLF7SO3I95qUp+Vc0FOy3Y+ai3eGSZLrwyCig8gKcVxhaFdoZDhvczlR039dLEMW2 NjfXbH1BlCDFCpW3/bFEV7BPpk+fB0oPXf8i+ptYyZfADHpsty0PbRjJTQrjvo0erZL3 xFP1Z8nCwFWW6sWEbVlJaYL0sMEJNX/iY1RvKM32RvgCfkddJhLMQSotH0Oa3rM4ydus mitw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=DVkFmgVppcUdysdhmCgRYqE3/zJKAH13Ppg3uAvwVP8=; b=vhDwmujKYg0j6FwMQyOJ7Fd96rUoZjeCWmEOk2zsC9+GFaDLKupKFZ0q9j7yvMQAPu zuLHwk9tufe5WuwDexQ/c0mWpHdEI3oNIKD+U7ihEk6o98Nc7LfU9TYnMo+FnQQzV9mP /JHZ1mNSrKxoRgWzO0MRBl2UGVs9zNwdPRyqyDjN7qvZXhUIxwstcxynf4MMEl8He3sK 5nm3kZogU4CHWrvH+IDn1fHLp7FaTmzoxqpsrJbZsrDaXrUUHikQ2c1DVuBpI6+TtRMC MjPX7be7+sSOiwsVJxY1ZGuEJRfD0AxBQM096Av4xGgst6eWFmnnbEvOHmGXXvmwNZCz HBjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=FOb5lXu7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si8215078edj.113.2020.08.15.14.54.28; Sat, 15 Aug 2020 14:54:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=FOb5lXu7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728776AbgHOVv0 (ORCPT + 99 others); Sat, 15 Aug 2020 17:51:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728674AbgHOVvK (ORCPT ); Sat, 15 Aug 2020 17:51:10 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EA7AC03B3E7; Sat, 15 Aug 2020 02:32:39 -0700 (PDT) Received: from zn.tnic (p200300ec2f1c7a00329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ec:2f1c:7a00:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id A29941EC0411; Sat, 15 Aug 2020 11:32:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1597483956; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=DVkFmgVppcUdysdhmCgRYqE3/zJKAH13Ppg3uAvwVP8=; b=FOb5lXu7Kn7iS2NabxxkPOxoDuF/xer2Qu77aiDAYxskjdo45klK3RVJaZ0IF/ic4gaKoN Grp08fbd9Jmd9ZWZk69bruMIgP72l56Pi5EiNwnsDXKMyaQbCipo+ZQVuPqjJFQR17MtQ+ qhuxBZcCdDOclWH+NnhAd6ZlXjsIHbs= Date: Sat, 15 Aug 2020 11:33:32 +0200 From: Borislav Petkov To: Alex Kluver Cc: linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, ardb@kernel.org, mchehab@kernel.org, russ.anderson@hpe.com, dimitri.sivanich@hpe.com Subject: Re: [PATCH] edac,ghes,cper: Add Row Extension to Memory Error Record Message-ID: <20200815093332.GD25814@zn.tnic> References: <20200727181445.111002-1-alex.kluver@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200727181445.111002-1-alex.kluver@hpe.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 27, 2020 at 01:14:45PM -0500, Alex Kluver wrote: > Memory errors could be printed with incorrect row values since the DIMM > size has outgrown the 16 bit row field in the CPER structure. UEFI > Specification Version 2.8 has increased the size of row by allowing it to > use the first 2 bits from a previously reserved space within the structure. > > When needed, add the extension bits to the row value printed. > > Based on UEFI 2.8 Table 299. Memory Error Record > > Tested-by: Russ Anderson > Signed-off-by: Alex Kluver > --- > drivers/edac/ghes_edac.c | 10 ++++++++-- > drivers/firmware/efi/cper.c | 11 +++++++++-- > include/linux/cper.h | 9 +++++++-- > 3 files changed, 24 insertions(+), 6 deletions(-) > > diff --git a/drivers/edac/ghes_edac.c b/drivers/edac/ghes_edac.c > index cb3dab56a875..cfa3156300f5 100644 > --- a/drivers/edac/ghes_edac.c > +++ b/drivers/edac/ghes_edac.c > @@ -337,8 +337,14 @@ void ghes_edac_report_mem_error(int sev, struct cper_sec_mem_err *mem_err) > p += sprintf(p, "rank:%d ", mem_err->rank); > if (mem_err->validation_bits & CPER_MEM_VALID_BANK) > p += sprintf(p, "bank:%d ", mem_err->bank); > - if (mem_err->validation_bits & CPER_MEM_VALID_ROW) > - p += sprintf(p, "row:%d ", mem_err->row); > + if (mem_err->validation_bits & (CPER_MEM_VALID_ROW | CPER_MEM_VALID_ROW_EXT)) { > + u32 row_extended = 0; > + if (mem_err->validation_bits & CPER_MEM_VALID_ROW_EXT) > + row_extended = (mem_err->extended & CPER_MEM_EXT_ROW_MASK) > + < + row_extended |= mem_err->row; > + p += sprintf(p, "row:%d ", row_extended); > + } > if (mem_err->validation_bits & CPER_MEM_VALID_COLUMN) > p += sprintf(p, "col:%d ", mem_err->column); > if (mem_err->validation_bits & CPER_MEM_VALID_BIT_POSITION) > diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c > index f564e15fbc7e..5faaf6ecd659 100644 > --- a/drivers/firmware/efi/cper.c > +++ b/drivers/firmware/efi/cper.c > @@ -234,8 +234,14 @@ static int cper_mem_err_location(struct cper_mem_err_compact *mem, char *msg) > n += scnprintf(msg + n, len - n, "bank: %d ", mem->bank); > if (mem->validation_bits & CPER_MEM_VALID_DEVICE) > n += scnprintf(msg + n, len - n, "device: %d ", mem->device); > - if (mem->validation_bits & CPER_MEM_VALID_ROW) > - n += scnprintf(msg + n, len - n, "row: %d ", mem->row); > + if (mem->validation_bits & (CPER_MEM_VALID_ROW | CPER_MEM_VALID_ROW_EXT)) { > + u32 row_extended = 0; > + if (mem->validation_bits & CPER_MEM_VALID_ROW_EXT) > + row_extended = (mem->extended & CPER_MEM_EXT_ROW_MASK) > + < + row_extended |= mem->row; > + n += scnprintf(msg + n, len - n, "row: %d ", row_extended); > + } Both those hunks contain duplicated code which kinda wants to be an inline function in cper.h which returns row_extended and gets called by both sites. And then the call site can look very simple: if (mem_err->validation_bits & CPER_MEM_VALID_ROW) row = mem_err->row; /* add row extension */ row |= cper_get_mem_extension(); p += sprintf(p, "row:%d ", row); with static inline u32 cper_get_mem_extension(void) { if (!(mem_err->validation_bits & CPER_MEM_VALID_ROW_EXT)) return 0; return (mem_err->extended & CPER_MEM_EXT_ROW_MASK) << CPER_MEM_EXT_ROW_SHIFT; } Something along those lines... Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette