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 X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85ECAC76191 for ; Thu, 18 Jul 2019 09:08:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 552A021783 for ; Thu, 18 Jul 2019 09:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726551AbfGRJIC (ORCPT ); Thu, 18 Jul 2019 05:08:02 -0400 Received: from mx2.suse.de ([195.135.220.15]:52048 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726513AbfGRJIB (ORCPT ); Thu, 18 Jul 2019 05:08:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B9942AF95; Thu, 18 Jul 2019 09:08:00 +0000 (UTC) Date: Thu, 18 Jul 2019 11:08:00 +0200 From: Petr Mladek To: Jiri Kosina , Josh Poimboeuf , Miroslav Benes Cc: Joe Lawrence , Kamalesh Babulal , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC 3/5] livepatch: Allow to distinguish different version of system state changes Message-ID: <20190718090800.gd2neswknsnmey2h@pathway.suse.cz> References: <20190611135627.15556-1-pmladek@suse.com> <20190611135627.15556-4-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190611135627.15556-4-pmladek@suse.com> User-Agent: NeoMutt/20170912 (1.9.0) Sender: live-patching-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: live-patching@vger.kernel.org On Tue 2019-06-11 15:56:25, Petr Mladek wrote: > It might happen that an older change is not enough and the same system > state has to be modified another way. Different changes need to get > distinguished by a version number added to struct klp_state. > > The version can also be used to prevent loading incompatible livepatches. > The check is done when the livepatch is enabled. The rules are: > > + Any completely new system state modification is allowed. > > + System state modifications with the same or higher version are allowed > for already modified system states. > > + Cumulative livepatches must handle all system state modifications from > already installed livepatches. > > + Non-cumulative livepatches are allowed to touch already modified > system states. > > Signed-off-by: Petr Mladek > --- > include/linux/livepatch.h | 2 ++ > kernel/livepatch/core.c | 8 ++++++++ > kernel/livepatch/state.c | 40 +++++++++++++++++++++++++++++++++++++++- > kernel/livepatch/state.h | 9 +++++++++ > 4 files changed, 58 insertions(+), 1 deletion(-) > create mode 100644 kernel/livepatch/state.h > > diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h > index 591abdee30d7..8bc4c6cc3f3f 100644 > --- a/include/linux/livepatch.h > +++ b/include/linux/livepatch.h > @@ -135,10 +135,12 @@ struct klp_object { > /** > * struct klp_state - state of the system modified by the livepatch > * @id: system state identifier (non zero) > + * @version: version of the change (non-zero) > * @data: custom data > */ > struct klp_state { > int id; As suggested by Nicolay, there will be in v2: unsigned long id; > + int version; It would make sense to make "version" unsigned as well. I am just unsure about the size: + "unsigned long" looks like an overhead to me + "u8" might be enough But I would stay on the safe side and use: unsigned int version; Is anyone against? Best Regards, Petr