From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CCD61EE0211 for ; Wed, 13 Sep 2023 23:24:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PISWrrDYQZ9zXG6Zf7xcu4sBgykfPLk3/MG5NfrQSww=; b=RcltweBjXGmZyQ +jazKfMozWt69j8NOh+2bRfC2mvdDFzgDUEdJwHxKxomSbc1OsK3WQt3H1+Q914FqZgEXvrTjIufl YoLdD38JFL2TMGjcA0Sa6d4LDL7EZEoQicmhzdJUrxFtP/C3dUbLFB8jfn77S9cycHsLOvwbha722 4nWbUMLLcG4pqsCD6OeLOCIk5UPFiUosVWjSY3Kdea0t+1Bz6P4S26zlylSAWHTh/ymHosHhPfRNo IS/p8vaD98MNYIATMMNcfP4a3HnUVz5XbnM484u/NTxrKBigKm8or0jOSFgp7LN5PLupq5iEoT94p /0evUQTBwjMYaN12AuJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgZDO-006sb8-14; Wed, 13 Sep 2023 23:24:10 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgZDL-006sa5-20 for linux-arm-kernel@lists.infradead.org; Wed, 13 Sep 2023 23:24:08 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c397ed8681so2763055ad.2 for ; Wed, 13 Sep 2023 16:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694647444; x=1695252244; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=McEVX1hx5k8f+NcqiKTD/lVS9HGO2QYi1j8mbG944+c=; b=NEMFNu6Qa0X8HHahzlHAQJBYbDXoEkm+ci3BI3Pw/uKKwyEU+gMniejefqACXAH7PG p8REu3D2Bedt/E7x6B8kBw2vKvfJPw073klw1B9bdw1Xu5qEzmn0kp04g5dMpwkt9Vup RLHuMKxXnZYmqF1BkDbNB75i18WYCfQYYr7LY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694647444; x=1695252244; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=McEVX1hx5k8f+NcqiKTD/lVS9HGO2QYi1j8mbG944+c=; b=cdZ6KTap1r/Oqhvp5lBePE0p3Q2ryGifp4UKbfVZN9yDtepzhgkHkVE/JUIwJ9jaG5 y4T6t40hR9K3WvqmHlR9Fc8KjgulZGv5uG09ta3nfVScybLrPCN2hlVkDhk18YvCFPWn sTaAFGrx6IN005s7NmMHA4WCs+f33gybIjFWa9euehWmliCs9jJkb8uUFqQcENGAz4VN MCDE78MbCGVwi9tUI9mSINHBAw0CUD2CU8RYQcMxF4dvYKXNqOJGnwydqrO1rhNEys3Q Px+8pId1d41ylaoLrrD/WKbAx4ZLEkSvFEDY2R8l+xK9HQonI16Rva6SvK41euSujjRO pX2w== X-Gm-Message-State: AOJu0Yz7SBjcAlsQHz/8RkB5RYRvIIcf/vWslr7a9WRC2KryQw4DTsAW F5M69aDfFzkETLGx9s3qZQXjLQ== X-Google-Smtp-Source: AGHT+IEhoRu0Lao0AX88usO4EFB8BidZ06eLDfk+p1OxG1nODfcmpktTieCBSCEMoiWnY1czPMaLqw== X-Received: by 2002:a17:902:d2c4:b0:1c0:d575:d28 with SMTP id n4-20020a170902d2c400b001c0d5750d28mr4287074plc.50.1694647444198; Wed, 13 Sep 2023 16:24:04 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id j21-20020a170902c3d500b001bb8895848bsm163538plj.71.2023.09.13.16.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 16:24:03 -0700 (PDT) Date: Wed, 13 Sep 2023 16:24:02 -0700 From: Kees Cook To: Mukesh Ojha Cc: corbet@lwn.net, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, tony.luck@intel.com, gpiccoli@igalia.com, mathieu.poirier@linaro.org, catalin.marinas@arm.com, will@kernel.org, linus.walleij@linaro.org, andy.shevchenko@gmail.com, vigneshr@ti.com, nm@ti.com, matthias.bgg@gmail.com, kgene@kernel.org, alim.akhtar@samsung.com, bmasney@redhat.com, quic_tsoni@quicinc.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-hardening@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-samsung-soc@vger.kernel.org, kernel@quicinc.com Subject: Re: [REBASE PATCH v5 10/17] pstore: Add pstore_region_defined() helper and export it Message-ID: <202309131620.34EB0F6972@keescook> References: <1694429639-21484-1-git-send-email-quic_mojha@quicinc.com> <1694429639-21484-11-git-send-email-quic_mojha@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1694429639-21484-11-git-send-email-quic_mojha@quicinc.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230913_162407_664132_DFF4584A X-CRM114-Status: GOOD ( 23.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 11, 2023 at 04:23:52PM +0530, Mukesh Ojha wrote: > There are users like Qualcomm minidump which is interested in > knowing the pstore frontend addresses and sizes from the backend > (ram) to be able to register it with firmware to finally collect > them during crash for debugging. > > Signed-off-by: Mukesh Ojha > --- > fs/pstore/platform.c | 15 +++++++++++++++ > fs/pstore/ram.c | 42 ++++++++++++++++++++++++++++++++++++++++++ > include/linux/pstore.h | 6 ++++++ > 3 files changed, 63 insertions(+) > > diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c > index e5bca9a004cc..fdac951059c1 100644 > --- a/fs/pstore/platform.c > +++ b/fs/pstore/platform.c > @@ -139,6 +139,21 @@ enum pstore_type_id pstore_name_to_type(const char *name) > } > EXPORT_SYMBOL_GPL(pstore_name_to_type); > > +int pstore_region_defined(struct pstore_record *record, > + void **virt, phys_addr_t *phys, > + size_t *size, unsigned int *max_dump_cnt) > +{ > + if (!psinfo) > + return -EINVAL; > + > + record->psi = psinfo; Uh, this makes no sense to me. If this is a real pstore_record, you cannot just assign psi here. > + > + return psinfo->region_info ? > + psinfo->region_info(record, virt, phys, size, max_dump_cnt) : > + -EINVAL; Common code style for this kind of thing is usually like this: if (!psinfo->region_info) return -EINVAL; return psinfo->region_info(...) > +} > +EXPORT_SYMBOL_GPL(pstore_region_defined); > + > static void pstore_timer_kick(void) > { > if (pstore_update_ms < 0) > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index ab551caa1d2a..62202f3ddf63 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -437,6 +437,47 @@ static int ramoops_pstore_erase(struct pstore_record *record) > return 0; > } > > +static int ramoops_region_info(struct pstore_record *record, > + void **virt, phys_addr_t *phys, > + size_t *size, unsigned int *max_dump_cnt) But there's a larger problem here -- "virt", "phys" and likely "max_dump_cnt" are aspects _specific to the ram backend_. This can't be a generic pstore interface. I'm not opposed to it being exposed only from ramoops, though. But I think you'll want a pstore generic way to iterate over the records... -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel