Received: by 2002:a05:7412:4e10:b0:e2:908c:2ebd with SMTP id gb16csp27290rdb; Mon, 6 Nov 2023 22:33:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOn6T0D3HBrXGgfmQK893sBGCi5o6RR0GAjWnVvbqcmcDFueVDV1H1PVchZWQYLW6nlKyA X-Received: by 2002:a17:902:ec84:b0:1cc:4cb0:d273 with SMTP id x4-20020a170902ec8400b001cc4cb0d273mr29503230plg.56.1699338780656; Mon, 06 Nov 2023 22:33:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699338780; cv=none; d=google.com; s=arc-20160816; b=F331E+74WWR2idHSzJADKZajL1i4Wl5J+ctuMObz8pAmGaAybYEHJnJRgvQdg9GV5Q 80QggmU2Fi/1PM2Gxa66qAEkWBjzbwqaTsKppnaiiiF9Ki9TVLiML+z/irbHErhYID3L 4wMcqmgSwo1AfNgY/xpPGDO6hcRnucK2rJ14Zju9RWMPKrnm2ZRMbhhH+SOQ9Qgc042U U9LAPpxFkup4uzEg0oclMFdW22mqLozQAFujtLx+L0DRDv4/5Yzu7nEfKIWxBqkPYSUO FsuMf57iIO1kEZOkju632fIJVYyNP4nbdMYIOBmifpKObNFxb5L/pgaTcVcC2J63hSjb Cdxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=MKuaj0jg90e1Nx29apttkt6YjYFsc3MzYDII/TbtDLs=; fh=MQKibY1gp03oHfoDc5Rz7YuTEvyytF8k3oA40d6PJLM=; b=yLJn7yK/mkjNZj5cDQKHvEGjfFsQqLCv5dHHwQ1JBYCeSlu3B395MosqmEGSsTocnV 0XJ1gQc3Y1KNcv5BzZ5gZ7AoZErOregPkYDnwxojLYVoRcBN0CaYYJfzyOFFKT3MIQm0 m7X/9OoIStSN1TMrib2Pg8pBpvzgDBlI8ajmLEtY63s3tYUuno+sggLu306HGgUuNElN 3kNiRjX6kDuEijK8KKVq2MXmfGP+1qtQCUTgjmUFKpnN5ywUixJTj6+M0F3HLgA/mZE4 4eaM7RjFd+oUYy6876SODAA7CMfwqffleXuuvVYwPt6ztuMiSA6Iz8OSUUiAEV3BkRsn JC0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=OKC3cG2T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id h10-20020a170902f54a00b001c9d4f08c3asi10372349plf.277.2023.11.06.22.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 22:33:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@codeconstruct.com.au header.s=2022a header.b=OKC3cG2T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeconstruct.com.au Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2502A803D01B; Mon, 6 Nov 2023 22:32:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232524AbjKGGcu (ORCPT + 99 others); Tue, 7 Nov 2023 01:32:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232095AbjKGGcs (ORCPT ); Tue, 7 Nov 2023 01:32:48 -0500 Received: from codeconstruct.com.au (pi.codeconstruct.com.au [203.29.241.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3E510D for ; Mon, 6 Nov 2023 22:32:45 -0800 (PST) Received: from [192.168.68.112] (ppp14-2-79-67.adl-apt-pir-bras31.tpg.internode.on.net [14.2.79.67]) by mail.codeconstruct.com.au (Postfix) with ESMTPSA id DD00F20059; Tue, 7 Nov 2023 14:32:38 +0800 (AWST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codeconstruct.com.au; s=2022a; t=1699338759; bh=MKuaj0jg90e1Nx29apttkt6YjYFsc3MzYDII/TbtDLs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=OKC3cG2TFWGZ9o+reKKcP6G0mzAazWfzL2qpO1XHXV+3XlCMdogJ5ovQFkJ2Soi8A ZC8tzFfP/8oF9wTyjxTcgduoi3u7HR7IAFJd96I/HuJu2QKWs1aUuPXnHRfpiJHQsZ NJNOLwRFHmaFfJG3LqGzga4KGCntU3vQ5LdrhVXAbjOOOXQ20rAp0YHL1sc23qXw1T 14xGxreH9kflNL12456nlkJMA0dLCj7DzpoLqbhs20nCEVezHKVLsaktJR3VSp0UzG nhM3q0cxhNU94y3+C6vvr6tvMpjlMPn/2eNGjV/cFcCHiyGyGaneqzSSYIxwUaK0Qq Ja7WJHIzH4MAw== Message-ID: Subject: Re: [PATCH 05/10] ipmi: kcs_bmc: Define client actions in terms of kcs_bmc_client From: Andrew Jeffery To: Jonathan Cameron Cc: minyard@acm.org, openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, aladyshev22@gmail.com, jk@codeconstruct.com.au Date: Tue, 07 Nov 2023 17:02:37 +1030 In-Reply-To: <20231103151651.000045ae@Huawei.com> References: <20231103061522.1268637-1-andrew@codeconstruct.com.au> <20231103061522.1268637-6-andrew@codeconstruct.com.au> <20231103151651.000045ae@Huawei.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 22:32:58 -0800 (PST) On Fri, 2023-11-03 at 15:16 +0000, Jonathan Cameron wrote: > On Fri, 3 Nov 2023 16:45:17 +1030 > Andrew Jeffery wrote: >=20 > > Operations such as reading and writing from hardware and updating the > > events of interest are operations in which the client is interested, bu= t > > are applied to the device. Strengthen the concept of the client in the > > subsystem and clean up some call-sites by translating between the clien= t > > and device types in the core of the KCS subsystem. > >=20 > > Signed-off-by: Andrew Jeffery > > --- > > drivers/char/ipmi/kcs_bmc.c | 67 ++++++++++++++++++--------- > > drivers/char/ipmi/kcs_bmc_cdev_ipmi.c | 50 ++++++++++---------- > > drivers/char/ipmi/kcs_bmc_client.h | 15 +++--- > > drivers/char/ipmi/kcs_bmc_serio.c | 10 ++-- > > 4 files changed, 81 insertions(+), 61 deletions(-) > >=20 > > diff --git a/drivers/char/ipmi/kcs_bmc.c b/drivers/char/ipmi/kcs_bmc.c > > index 5a3f199241d2..d70e503041bd 100644 > > --- a/drivers/char/ipmi/kcs_bmc.c > > +++ b/drivers/char/ipmi/kcs_bmc.c > > @@ -22,33 +22,53 @@ static LIST_HEAD(kcs_bmc_drivers); > > =20 > > /* Consumer data access */ > > =20 > > -u8 kcs_bmc_read_data(struct kcs_bmc_device *kcs_bmc) > > +static void kcs_bmc_client_validate(struct kcs_bmc_client *client) > > { > > - return kcs_bmc->ops->io_inputb(kcs_bmc, kcs_bmc->ioreg.idr); > > + WARN_ONCE(client !=3D READ_ONCE(client->dev->client), "KCS client con= fusion detected"); >=20 > Is this intended as runtime validation or to catch bugs? > If just catch bugs then fair enough. Ah, I think I missed replying here. So for "runtime validation" I assume you mean "things userspace might do that are not valid - the error condition should be detected and punted back to userspace", vs "catch bugs" meaning "the implementation in the kernel failed to uphold an invariant and now there are Problems". If that sounds accurate, then it's the latter: The WARN_ONCE() is asserting "don't operate on a client that doesn't own the device". It isn't an error that can be punted back for handling in userspace as it should not be possible for the kernel to get into this state to begin with. If we reach this state it's an error in the programming of the kernel module that's a client of the KCS subsystem. >=20 > With that question answered based on my somewhat vague understanding of t= he kcs subsystem. > Reviewed-by: Jonathan Cameron Thanks, Andrew