From patchwork Wed Nov 8 08:59:17 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: 835730 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yX0j108wRz9sBd for ; Wed, 8 Nov 2017 20:04:05 +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="WK2dm/Ag"; 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 3yX0j05mV4zDrKd for ; Wed, 8 Nov 2017 20:04:04 +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="WK2dm/Ag"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c01::244; helo=mail-pl0-x244.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WK2dm/Ag"; dkim-atps=neutral Received: from mail-pl0-x244.google.com (mail-pl0-x244.google.com [IPv6:2607:f8b0:400e:c01::244]) (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 3yX0cH5z0lzDrCn for ; Wed, 8 Nov 2017 19:59:59 +1100 (AEDT) Received: by mail-pl0-x244.google.com with SMTP id y61so883210plh.3 for ; Wed, 08 Nov 2017 00:59:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yv4gNqUtPAnkcFqEO9I4OlvZ/T/7IblbOvxo6CxfYrU=; b=WK2dm/AguWIKEkVxRdz5Xjxct1ZULjLu3ZaNGBh/y/BO6beiiy/FRQqJ2bG7J/3p2K Y25a/y/kclka8xh3fKAjvWmuq+SLnhF4v4FMYzFkWKZZUkITdoMGEfw+qxrTf0yVUV+k EOTH0VzP0+E7AvOcndgcCmKh+ZUXIKBStZ5ZGFXKVyVH9jLbSeFWJtpL4h4+Dn3CRlIy PpvlOmZ+1cPqtHs/1KMqsnvAhXDFOkc+UQCPZ7CvQAjo0ir+YxnaNqid6JChPmaxrnXT 1eatEUMEmlHj1tCzWtqW632f6XQvzJUkPhpBvTxWJVsjpfxRxJXXFES3RGAePBzscrv2 2EaA== 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:in-reply-to :references; bh=yv4gNqUtPAnkcFqEO9I4OlvZ/T/7IblbOvxo6CxfYrU=; b=Axe/oCID2NnkzbcMUfAitWxEl7PUPPNEuEL/PYWhyvB0b9VSX/dqvjtRKTnDOt97ps S3F+K/R1XbmhS6Zj1c0GOTZjF8XTxdrJhHCv28UA2dXD2WV+ISxgBSJOTT93Ctegxe/b ZUpat3wfEpJlwY7gPtjD2K5NI4k0XreDBun9dTlkrSL/Uab/rgXOK7CSnXIAgjCttp04 A052fCX5PrStXJUmOd+E/L60pfHUnvPPoZzUHyS//Cgs/1huxPUQwvYzm922j13QzGdn JiJfYKsQwWRnsY3ykrcJwGDNVpyQ+Yg2GpwEqeEI20IhlxjbabXKdDSsuvtKyKgUZ3yx T1Nw== X-Gm-Message-State: AJaThX5JUD3rzBa+NlqKdSTXwdVjQ3egxeri/OSiibOmvM/QRX9jXTYc 59/7pPkQQ2aKDoIGSlNIrkNxJw== X-Google-Smtp-Source: ABhQp+TT7pqbzKl6B/CMHqaYVpq6W1U4moUMBoW6J1iJB0QoxaOBS58i7IrCP8Ii85AJLnQfQ0gDOA== X-Received: by 10.84.168.35 with SMTP id e32mr1611656plb.122.1510131597581; Wed, 08 Nov 2017 00:59:57 -0800 (PST) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id 24sm7005210pfk.9.2017.11.08.00.59.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 00:59:57 -0800 (PST) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 8 Nov 2017 19:59:17 +1100 Message-Id: <20171108085918.12590-13-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171108085918.12590-1-oohall@gmail.com> References: <20171108085918.12590-1-oohall@gmail.com> Subject: [Skiboot] [PATCH 12/13] gard: Always use MTD to access flash X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 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" Direct mode is generally either unsafe or unsupported. We should always access the PNOR via an MTD device so make that the default. If someone really needs direct mode, then they can use pflash. Signed-off-by: Oliver O'Halloran --- external/gard/gard.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/external/gard/gard.c b/external/gard/gard.c index 1ee54e6b3d99..815243457cf5 100644 --- a/external/gard/gard.c +++ b/external/gard/gard.c @@ -879,6 +879,14 @@ int main(int argc, char **argv) #endif } + /* + * Force libflash to do flash accesses via the MTD. Direct mode is + * generally unsafe since it fiddles with the flash controller state + * underneath the kernel. Anyone who needs direct mode can use pflash + * instead. + */ + arch_flash_access(ctx->bl, PNOR_MTD); + if (arch_flash_init(&(ctx->bl), filename, true)) { /* Can fail for a few ways, most likely couldn't open MTD device */ fprintf(stderr, "Can't open %s\n", filename ? filename : "MTD Device. Are you root?");