Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2445882ybk; Mon, 11 May 2020 22:50:32 -0700 (PDT) X-Google-Smtp-Source: APiQypKp5NJRuxsKRR2B9rqtFqNLWqNyNIns2MoAEX42a4zP09rWkhz1lL7eWG6aoiiKQh3KPEVD X-Received: by 2002:a05:6402:21cc:: with SMTP id bi12mr16383669edb.294.1589262632710; Mon, 11 May 2020 22:50:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589262632; cv=none; d=google.com; s=arc-20160816; b=DXMtkovLxP9xCTUlDwJotvLuG9ZolJraIv/UGei1aIhY2fSVqLP4xORTv8F94GTY4x WLdfEYNbi/mH6+7w/O9dxjlvq1vVifGHE09u1wOyGEonY2cUOGZtNR9cskVA4SgKxhkY 8e5zznZi2Y1D6m9p1KLzVdpqaSZlX7XC7/9XE+CEjcmTxBaA9F6gRFBGglRtfrVPdJQp SiYyn9VDRsSwzoRx05fZ42+RV/rUkTVIYg+duTZVE8ZJ4d5aAINEMxYmzduksVGMvQH/ IOmk5+uh2746fmYXkWid38KDqt6J7o0/OKpJP1BHmTBlh2kum94sldNjNcSfpcQczduV 7FhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=vLH6v1d1pUz0QiDrSwDRRrZzE6dA+tEWCbGeGafXQkM=; b=g5qOKLZRBbTNoc2213k6ySpfzANH0ZRQaPRVBqYtaiYzqW7TsXODrnTGEn6yQtSyT/ wm1NuwhbKOq1CWSyzVPTa+ktae1yJeKZIfdFEkmbu2eDu/u1seQPQ6Ea4p13Dc8E868D Xsm9KBaUibOVIT79FyshFlDu+Ok4es+doGgV8ImT9VfqwG7q0WcrmWggq1m2TRGChHL3 SJZT4EqpiTt9AGo5IJfRCBcYFKC/7N3La0g2P8fmuj8UosCW5HSDWg17airTr0sa5i3n PGF2N5Ptc+Sxpu2mcsRqUEbdCtbtZaRMVCrJjGobRP6GgK2Xe0T3Jlu69jVilj/6ecmB kHOQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si7524314edr.528.2020.05.11.22.50.09; Mon, 11 May 2020 22:50:32 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728353AbgELFry (ORCPT + 99 others); Tue, 12 May 2020 01:47:54 -0400 Received: from smtp2207-205.mail.aliyun.com ([121.197.207.205]:43038 "EHLO smtp2207-205.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbgELFry (ORCPT ); Tue, 12 May 2020 01:47:54 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.074523|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0724473-0.00134074-0.926212;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03301;MF=liaoweixiong@allwinnertech.com;NM=1;PH=DS;RN=12;RT=12;SR=0;TI=SMTPD_---.HXEAwpL_1589262465; Received: from 172.16.10.102(mailfrom:liaoweixiong@allwinnertech.com fp:SMTPD_---.HXEAwpL_1589262465) by smtp.aliyun-inc.com(10.147.44.129); Tue, 12 May 2020 13:47:46 +0800 Subject: Re: [PATCH v8 01/11] pstore/zone: Introduce common layer to manage storage zones To: Kees Cook Cc: Anton Vorontsov , Colin Cross , Tony Luck , Jonathan Corbet , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org References: <20200511233229.27745-1-keescook@chromium.org> <20200511233229.27745-2-keescook@chromium.org> <202005112212.2E75B83@keescook> From: WeiXiong Liao Message-ID: <57efa2b5-d598-a600-5f74-8fd81299fc58@allwinnertech.com> Date: Tue, 12 May 2020 13:47:56 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <202005112212.2E75B83@keescook> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi Kees Cook, On 2020/5/12 PM 1:15, Kees Cook wrote: > On Tue, May 12, 2020 at 11:55:20AM +0800, WeiXiong Liao wrote: >> On 2020/5/12 AM 7:32, Kees Cook wrote: >>> [...] >>> +struct psz_context { >>> + struct pstore_zone **kpszs; >>> + unsigned int kmsg_max_cnt; >>> + unsigned int kmsg_read_cnt; >>> + unsigned int kmsg_write_cnt; >>> + /* >>> + * These counters should be calculated during recovery. >>> + * It records the oops/panic times after crashes rather than boots. >>> + */ >>> + unsigned int oops_counter; >>> + unsigned int panic_counter; >> >> oops/panic_counter is designed to count the crash times since the >> linux kernel was installed. pstore/zone lookup the max counter from all >> valid kmsg zones when recovery and saves them to oops/panic_counter. >> However, they are unable to get real number if we remove files. It's >> not serious, we can fix it after this series. > > Since the kernel was installed? I don't see a kernel version check in > here? Or do you mean "since ever", in that it's a rolling count? > Yes, "since ever". >> And since pstore supports "max_reason", should pstore/zone count for >> other reason? > > For now, no. I opted to try to keep this as simple as possible a port > from dump_oops to max_reason for now. > OK. >>> +static inline int psz_kmsg_erase(struct psz_context *cxt, >>> + struct pstore_zone *zone, struct pstore_record *record) >>> +{ >>> + struct psz_buffer *buffer = zone->buffer; >>> + struct psz_kmsg_header *hdr = >>> + (struct psz_kmsg_header *)buffer->data; >>> + >>> + if (unlikely(!psz_ok(zone))) >>> + return 0; >>> + /* this zone is already updated, no need to erase */ >>> + if (record->count != hdr->counter) >>> + return 0; >> >> These codes is to fix bug that user remove files on pstore filesystem >> but kmsg zone is already updated and pstore/zone should not erase >> zone. It work for oops and panic because the count number is increasing. >> However, it's useless for other reason of kmsg. We can fix it after this >> series. > > Okay, sounds good. > -- WeiXiong Liao