From patchwork Tue Mar 28 04:06:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 744064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vscmB4lgNz9s7D for ; Tue, 28 Mar 2017 15:07:06 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d10Fcc4O"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vscmB3jk3zDqZQ for ; Tue, 28 Mar 2017 15:07:06 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d10Fcc4O"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vscm52j8LzDqY6 for ; Tue, 28 Mar 2017 15:07:00 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d10Fcc4O"; dkim-atps=neutral Received: by mail-pg0-x242.google.com with SMTP id o123so15284495pga.1 for ; Mon, 27 Mar 2017 21:07:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=HAQvU6deTPNdOgMGJNAISAwpUWG0YEAIV6Lz7BE75ww=; b=d10Fcc4OetJSB/Ipm7O2usJoH8nmZIOvnkOhm+juWqN4vvyWhGQ9VLruAV7WWbXEWV zMvBxjoDFTWWmjBQ8CpJRPYLysaoQ0Ff4Iy7LFyM3p9aM7LDagSfPpvEaF36iIrd6S0W rwCjJ9Eq/BEaVEDE6Vkm9OOLSpq8bHRtpjr4nFtrbIOdbgbi9VOHfkEA9YpYLWlXt5H1 EEXPo5pDQ9wV1dHt4Dp1HaUxRuTF/uweUf6Hvrh0zk/VUvJmnNto87Z+MxZCrQKO7bVg EbGWSnOLIHJnvlsu42MZqAZzpxWj72iqZ7wtvFUkEBb2RDUvtM6yUtsbYcqvz1TP2Jas QnbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HAQvU6deTPNdOgMGJNAISAwpUWG0YEAIV6Lz7BE75ww=; b=B/uhYYRfmrO2AIws2dJVUrd6v/XELCcJsm6b1iPQdbAMhTJ04Lywi3mW+n7xMhnwZK ttXG297JRJeW2pzctcQ0gDEKxKJhFxacAS7LGwdErQOeuZUUnbESY1N+ew0vxWofY1sm z5as7VUGvLw2J6JbU49wWqryHB9fDFU7izdclAJw16Sk25NnziypXD1CrBSX/ogrS9EK qTmd4V0uGWjy9g5UN4gcvA47RRivDJSU2Ra2AFOxbFPbJV6EnGXElLJAd+5lNJfFsq5q 8pbaBXseOCcu7Q0i1miqOPaDHhFVlErLVCar4NDLCLOEz+wf4nkfluThLs6qyzFcWWqu ffbQ== X-Gm-Message-State: AFeK/H1QBrx6Z/NGxD0ClFiib3/dHYXEKNnbH4v3PScaYiaGp/Qj4SzOgZTB4dPrrUHBNQ== X-Received: by 10.99.114.25 with SMTP id n25mr27811280pgc.206.1490674018613; Mon, 27 Mar 2017 21:06:58 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id n8sm3911228pgd.5.2017.03.27.21.06.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Mar 2017 21:06:58 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 28 Mar 2017 15:06:44 +1100 Message-Id: <20170328040644.1374-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.3 Subject: [Skiboot] [PATCH] hdat: ignore zero length reserves X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Hostboot can export reserved regions with a length of zero and these should be ignored rather than being turned into reserved range. While we're here fix a memory leak by moving the "too large" region check to before we allocate space for the label. Signed-off-by: Oliver O'Halloran --- hdata/memory.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/hdata/memory.c b/hdata/memory.c index 657090da8b0c..7ab83f8b6134 100644 --- a/hdata/memory.c +++ b/hdata/memory.c @@ -436,6 +436,21 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd) start_addr = be64_to_cpu(hb_resv_mem->start_addr); end_addr = be64_to_cpu(hb_resv_mem->end_addr); + /* Zero length regions are a normal, but should be ignored */ + if (start_addr - end_addr == 0) { + prlog(PR_DEBUG, "MEM: Ignoring zero length range\n"); + continue; + } + + /* + * Workaround broken HDAT reserve regions which are + * bigger than 512MB + */ + if ((end_addr - start_addr) > 0x20000000) { + prlog(PR_ERR, "MEM: Ignoring Bad HDAT reserve: too big\n"); + continue; + } + /* remove the HRMOR bypass bit */ start_addr &= ~HRMOR_BIT; end_addr &= ~HRMOR_BIT; @@ -454,20 +469,6 @@ static void get_hb_reserved_mem(struct HDIF_common_hdr *ms_vpd) prlog(PR_DEBUG, "MEM: Reserve '%s' %#" PRIx64 "-%#" PRIx64 " (type/inst=0x%08x)\n", label, start_addr, end_addr, be32_to_cpu(hb_resv_mem->type_instance)); - if (start_addr == 0) { - prlog(PR_DEBUG, "MEM: .. skipping\n"); - continue; - } - - /* - * Workaround broken HDAT reserve regions which are - * bigger than 512MB - */ - if ((end_addr - start_addr) > 0x20000000) { - prlog(PR_ERR, "MEM: Ignoring Bad HDAT reserve: too big\n"); - continue; - } - if ((start_addr & 65535) || (end_addr & 65535)) prerror("MEM: '%s' does not start and end on a 64K boundary!", label);