Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp548747pxx; Thu, 29 Oct 2020 08:41:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjpVwIcQgqeP2qa3uKQgvQm4QAvAE271az9ICc0r5eX8yiJ4qtWx3T6zWUA9uqTN839n0g X-Received: by 2002:a17:906:2ad3:: with SMTP id m19mr4551486eje.81.1603986065124; Thu, 29 Oct 2020 08:41:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603986065; cv=none; d=google.com; s=arc-20160816; b=poo6wbG9QIED5zSQpJ3EDcL+tsvJ6B+e5ozrpram8Db1qLq60Ar/QmjRIryoXeftcb bojR/i7oiPtrNcvNil8P3xOhHPytDO9giCYeMHZMj0sXQRNO+5vrtCWqDgCURYTqlBVH srNOBnAYLnpzWhDrZOaE1/XTJ7pabGCxRCwO28D8vqZi97EyUda2b1CoEnN9xvsxM7Bt hh79LrpMgBQOc2/fwCglp26mE+o2HnECQ9dirD68UKWFR7QOmLuCxtmSRw9yjW/ogGXi Ryptn5ABW/fiwuxfsST5uvilhFkHUFVNpO8E2JHp1/nZwC4qIhGCeFSfeYAs+Vjfml7D kLEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YpMSMpdWnDI27qe4/zeIevbA7qnkbhvCd6XQnOrBtHo=; b=Pdr9X5ixHPQPg4WVng5PCdsUFyNVG4nkAT7hnQURuiTj+lKMVNh6pdMtjZu/D7WfrP P0zCEUYGE1ACBSTfW99Lq8cP4wLrRXvf9ttcDHGzqK0W2txwb+dFm0OQeYhojz3uGPuS xDdj4ncVy0WH0Ng7wArF+gKv5ro0PPbwKlzLbNnSnHaXjhZJGgGyp8SlTaiN4gsTH8m9 82J8LiNqzRGmZsKvLGHeQb3VcY6NYtkVvm9xUvnWNPDvHHL8vjdbFUddUdacfZkdlWE6 WA/Z17QQ9lcbyVc/8cVInUtHhmh9eUaFp46TDZ9RlS6wOMLqADo/5q7TQ6NWR0IPvPb3 /xOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eclypsium.com header.s=google header.b=MvRibrIY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eclypsium.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ci1si1866122ejc.31.2020.10.29.08.40.41; Thu, 29 Oct 2020 08:41:05 -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=@eclypsium.com header.s=google header.b=MvRibrIY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eclypsium.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728293AbgJ2PjU (ORCPT + 99 others); Thu, 29 Oct 2020 11:39:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727290AbgJ2PjU (ORCPT ); Thu, 29 Oct 2020 11:39:20 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31BE9C0613CF for ; Thu, 29 Oct 2020 08:39:20 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id i21so1551422qka.12 for ; Thu, 29 Oct 2020 08:39:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eclypsium.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YpMSMpdWnDI27qe4/zeIevbA7qnkbhvCd6XQnOrBtHo=; b=MvRibrIYNg0MeSZyYa9mK5H+6bXdx7o39FoBXfKv+n6NGem2zAA0tqMOm8vfI0leJw JWUs+IYXRbzpZG/oSIkGnv3ljCxoH8nNAmgGvssJ3ksWnMzN3H4TNwpgxITeXMig0MtN 4QXYfhEN73/wbEvIUXrddTw6VFRtlhh83ch7JtCfG9cwA26Sr4WcUXShte+yisZaJxo6 uUPkWv0YbHYf8wqbK1Kpw9dc9uuTSBKA0e+ROsPul5RDQCZINks6lQK7FgrD7VOnor2H CawPfyaw26oqXCdBXFBVMVYMYrzoevbsBdn0HyA0wYwYFE9emYIWAwnLVkQRFS+WmqVR U1jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YpMSMpdWnDI27qe4/zeIevbA7qnkbhvCd6XQnOrBtHo=; b=d1U0VcQmw61lbLMtU04nNU8JagbZ/xutJmlk7bT8G0X8GXwzD+4kFqY/tL2bO8RW5g /HcbKMNYWYLZ8ZZ4972rhZISII6/i0CER3l0oxVrEiu35APEIfJS4kRPMhuM4BaqubdB CiG+eiP2UHmvMd21HzPyugYc0YiuLhSmUprfCMdmATYB+eZwzgwetM9ZCpqavJq2+U2M M2n2gC7Xc0/kiSj9mQXrik6XznakDbLy2j4Mi1ZlunKq99tuNWd8mJtAe5Ygou5Wvq9V 1qJJDgcpR8VviDlFfov65olBP4bU1xa8sCWpi06xWH+BKDRIgdLvbCQvNde0O11Y0iq+ hSpw== X-Gm-Message-State: AOAM530nMipNT0sCzxUzNO9fQCi6ycFiGvE/YV3/3t5z9ac5QIITBlMR aaZXd7/G5XEN6o/fpZnzL3U+GkQthrM+iLHC7IRnMQ== X-Received: by 2002:a05:620a:21d1:: with SMTP id h17mr4460360qka.368.1603985959134; Thu, 29 Oct 2020 08:39:19 -0700 (PDT) MIME-Version: 1.0 References: <20201028214359.384918-1-daniel.gutson@eclypsium.com> <20201029054110.GA3039992@kroah.com> In-Reply-To: <20201029054110.GA3039992@kroah.com> From: Daniel Gutson Date: Thu, 29 Oct 2020 12:39:08 -0300 Message-ID: Subject: Re: [PATCH] mtd: spi-nor: intel-spi: Split intel-spi reading from writing To: Greg Kroah-Hartman Cc: Derek Kiernan , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mika Westerberg , Arnd Bergmann , Mauro Carvalho Chehab , linux-kernel , Richard Hughes , Alex Bazhaniuk , linux-mtd Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 29, 2020 at 2:40 AM Greg Kroah-Hartman wrote: > > On Wed, Oct 28, 2020 at 06:43:59PM -0300, Daniel Gutson wrote: > > This patch separates the writing part of the intel-spi drivers > > so the 'dangerous' part can be set/unset independently. > > This way, the kernel can be configured to include the reading > > parts of the driver which can be used without > > the dangerous write operations that can turn the system > > unbootable. > > > > Signed-off-by: Daniel Gutson > > --- > > drivers/mtd/spi-nor/controllers/Kconfig | 39 ++++++++++++--------- > > drivers/mtd/spi-nor/controllers/intel-spi.c | 12 +++++-- > > 2 files changed, 33 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/mtd/spi-nor/controllers/Kconfig b/drivers/mtd/spi-nor/controllers/Kconfig > > index 5c0e0ec2e6d1..491c755fea49 100644 > > --- a/drivers/mtd/spi-nor/controllers/Kconfig > > +++ b/drivers/mtd/spi-nor/controllers/Kconfig > > @@ -31,34 +31,41 @@ config SPI_INTEL_SPI > > tristate > > > > config SPI_INTEL_SPI_PCI > > - tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)" > > + tristate "Intel PCH/PCU SPI flash PCI driver" > > depends on X86 && PCI > > select SPI_INTEL_SPI > > help > > - This enables PCI support for the Intel PCH/PCU SPI controller in > > - master mode. This controller is present in modern Intel hardware > > - and is used to hold BIOS and other persistent settings. Using > > - this driver it is possible to upgrade BIOS directly from Linux. > > - > > - Say N here unless you know what you are doing. Overwriting the > > - SPI flash may render the system unbootable. > > + This enables read only PCI support for the Intel PCH/PCU SPI > > + controller in master mode. This controller is present in modern > > + Intel hardware and is used to hold BIOS and other persistent settings. > > + Using this driver it is possible to read the SPI chip directly > > + from Linux. > > > > To compile this driver as a module, choose M here: the module > > will be called intel-spi-pci. > > > > config SPI_INTEL_SPI_PLATFORM > > - tristate "Intel PCH/PCU SPI flash platform driver (DANGEROUS)" > > + tristate "Intel PCH/PCU SPI flash platform driver" > > depends on X86 > > select SPI_INTEL_SPI > > help > > - This enables platform support for the Intel PCH/PCU SPI > > + This enables read only platform support for the Intel PCH/PCU SPI > > controller in master mode. This controller is present in modern > > - Intel hardware and is used to hold BIOS and other persistent > > - settings. Using this driver it is possible to upgrade BIOS > > - directly from Linux. > > + Intel hardware and is used to hold BIOS and other persistent settings. > > + Using this driver it is possible to read the SPI chip directly > > + from Linux. > > + > > + To compile this driver as a module, choose M here: the module > > + will be called intel-spi-pci. > > + > > +config SPI_INTEL_SPI_WRITE > > + bool "Intel PCH/PCU SPI flash drivers write operations (DANGEROUS)" > > + depends on SPI_INTEL_SPI_PCI || SPI_INTEL_SPI_PLATFORM > > + help > > + This enables full read/write support for the Intel PCH/PCU SPI > > + controller. > > + Using this option it may be possible to upgrade BIOS directly > > + from Linux. > > > > Say N here unless you know what you are doing. Overwriting the > > SPI flash may render the system unbootable. > > - > > - To compile this driver as a module, choose M here: the module > > - will be called intel-spi-platform. > > diff --git a/drivers/mtd/spi-nor/controllers/intel-spi.c b/drivers/mtd/spi-nor/controllers/intel-spi.c > > index b54a56a68100..8d8053395c3d 100644 > > --- a/drivers/mtd/spi-nor/controllers/intel-spi.c > > +++ b/drivers/mtd/spi-nor/controllers/intel-spi.c > > @@ -266,6 +266,7 @@ static int intel_spi_read_block(struct intel_spi *ispi, void *buf, size_t size) > > return 0; > > } > > > > +#ifdef CONFIG_SPI_INTEL_SPI_WRITE > > > > Please do not add #ifdef to .c files, that's not the proper kernel > coding style at all, and just makes maintaining this file much much > harder over time. > > Split things out into two different files if you really need to do this. What about the static functions that I'll need to turn non-static and in a header file? I mean, the functions that the functions in the new file will have to call. Should I do that, turn static functions into non-static and declared in a header file? > > thanks, > > greg k-h -- Daniel Gutson Engineering Director Eclypsium, Inc. Below The Surface: Get the latest threat research and insights on firmware and supply chain threats from the research team at Eclypsium. https://eclypsium.com/research/#threatreport