Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1866492pxb; Fri, 5 Mar 2021 01:20:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxioNNDqowAlz0UfqQjLdCF9nHVT9RSNJdqTNjTBJLLNyLuKqk0KNg5CaKa+KMlk/u63B7h X-Received: by 2002:a50:eb97:: with SMTP id y23mr8375315edr.170.1614936039932; Fri, 05 Mar 2021 01:20:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614936039; cv=none; d=google.com; s=arc-20160816; b=smlOd0soyVlKtRN+wDNoj7LMDgxoiY3+5hVBvvKq5pdqlbFPzF8S4FZFXORA4s3Hkr RynSkSlEer3RhcBxD0RAQcSSMTeovUo/ZOPQJQmRA7v3Lpp4m6AVHoUb3sKD1QydRCsQ 6b2uTYPKkbX37Smu4d0Kp4PXos2Oidsp1sSCYMcIiO2occC+mrwst07KDxalhzIy+MVV kuQbjis/6xbx3aFc+tqZ5iUh6aw8l3OBK5XlMj7S2hjDF4LlBTtZsOFWxZuv31z39g4/ 1bOa+JCwLRT7uWf4RfD7Htpn+zav/RxyUIsJzz/5upSNwtJrYxxbZWvn5a5l3adF3so0 STIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=cAq6+R4omWqyip9PJ9aVfNyoU1PYQDYL/jyjusPSWNI=; b=nKmLyKQSZ3VaPQShhLCtQpQz3UwV9ubRojdLEqef1Mm1Lan/CH3cmqC/6fj7/dJVyW aV91j/fckfE+NJLvSrehbD/ljEy8F0gf7nb0TCHZfLD4Hknz0eBtp9CFnlevCr5kM/Qt 0uV73PmC1hRfx1NuxJC9vhBM3Oi6IiWqr2OjOGHuWqmhgXpOjDUu61/Sh07OFVqKbSrq GylMbnAErNPVcAQrb1XC89al0CAwMv1rc/sdxU6QRJzA9PdYhb+i8j159FdiRgsPo7o+ X5OeGa3db37KhemFLnB85X51AMLTqOXoHFrg8/OmxCtpaMlawiuR03/kWdHRM7RjIaFD uNWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eN9FtNDP; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si1263268edl.520.2021.03.05.01.20.16; Fri, 05 Mar 2021 01:20:39 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=eN9FtNDP; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229611AbhCEJTD (ORCPT + 99 others); Fri, 5 Mar 2021 04:19:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52510 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbhCEJSn (ORCPT ); Fri, 5 Mar 2021 04:18:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614935923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cAq6+R4omWqyip9PJ9aVfNyoU1PYQDYL/jyjusPSWNI=; b=eN9FtNDPlwxvEd6mwpuLPMmSE9IOA2t8krKUE2tmIz1YWKAM2YUzesN43lHqW/1wL3U5Tr SeREi5rzsy4LFI83c4uCzQVra1poUdFgZTcMETPJMNIuw81FGsECGaKFZOc/jJfBfuZEEi YmnjBgJkp8+sGkf+PkjxxAx20z2fjao= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-HcSqhqcMN5qVjDN5bgFLew-1; Fri, 05 Mar 2021 04:18:41 -0500 X-MC-Unique: HcSqhqcMN5qVjDN5bgFLew-1 Received: by mail-ed1-f70.google.com with SMTP id f11so631348edk.13 for ; Fri, 05 Mar 2021 01:18:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=cAq6+R4omWqyip9PJ9aVfNyoU1PYQDYL/jyjusPSWNI=; b=VPuyqz1hZaubdgyY2hJpo7fUW+bPb9DJQ7DWbGzyZ0yda5FEHWVdSgjSI8gl/W6r1W MYQUxK8yfpF3nU69ZWWFDgLTAfegW9+VvxU8ADIXaRO44lc3lHaaQvWZqvr8/8zDGJLB HqkZ/2dFph7apZHW7W7OrH2N0vB7pyjdgoZ3b57FpYVsq8ZMn3VWFytLHK4YIJCaWhm3 gh/ab03LeIDoN3AbFVRM7YoaA//cL7L9b0ETLSQn61plgwY8QNzc6otvHo+jeiM6m+Qg x1XSPsHi5T3YYvJF/5D/dgzjvpA2LsKWMOq/aAZveJ3esPVQUNbiWe0D7LQKip/tm0rT +h/g== X-Gm-Message-State: AOAM531R+bGtGr5XOh8UuAamYt3j1+mjh9yNsAqNVYZjXe4eXQ6m4VvQ XoryXO6gTU/Nm5xf8TXCbHbUb+zg/7MB7Z3UQhOkPbUKfMUQ+lOv0amBwpHqrMH5XIDdcyK/r1K QswXs4ASMJSKHp2Y6LFOBQJSp X-Received: by 2002:a05:6402:b48:: with SMTP id bx8mr8583601edb.162.1614935920335; Fri, 05 Mar 2021 01:18:40 -0800 (PST) X-Received: by 2002:a05:6402:b48:: with SMTP id bx8mr8583591edb.162.1614935920177; Fri, 05 Mar 2021 01:18:40 -0800 (PST) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id t17sm1220844edr.36.2021.03.05.01.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Mar 2021 01:18:39 -0800 (PST) From: Vitaly Kuznetsov To: Nuno Das Neves , linux-hyperv@vger.kernel.org Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com, viremana@linux.microsoft.com, sunilmut@microsoft.com, wei.liu@kernel.org, ligrassi@microsoft.com, kys@microsoft.com Subject: Re: [RFC PATCH 04/18] virt/mshv: request version ioctl In-Reply-To: <194e0dad-495e-ae94-3f51-d2c95da52139@linux.microsoft.com> References: <1605918637-12192-1-git-send-email-nunodasneves@linux.microsoft.com> <1605918637-12192-5-git-send-email-nunodasneves@linux.microsoft.com> <87y2fxmlmb.fsf@vitty.brq.redhat.com> <194e0dad-495e-ae94-3f51-d2c95da52139@linux.microsoft.com> Date: Fri, 05 Mar 2021 10:18:38 +0100 Message-ID: <87eeguc61d.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nuno Das Neves writes: > On 2/9/2021 5:11 AM, Vitaly Kuznetsov wrote: >> Nuno Das Neves writes: >> ... >>> + >>> +3.1 MSHV_REQUEST_VERSION >>> +------------------------ >>> +:Type: /dev/mshv ioctl >>> +:Parameters: pointer to a u32 >>> +:Returns: 0 on success >>> + >>> +Before issuing any other ioctls, a MSHV_REQUEST_VERSION ioctl must be called to >>> +establish the interface version with the kernel module. >>> + >>> +The caller should pass the MSHV_VERSION as an argument. >>> + >>> +The kernel module will check which interface versions it supports and return 0 >>> +if one of them matches. >>> + >>> +This /dev/mshv file descriptor will remain 'locked' to that version as long as >>> +it is open - this ioctl can only be called once per open. >>> + >> >> KVM used to have KVM_GET_API_VERSION too but this turned out to be not >> very convenient so we use capabilities (KVM_CHECK_EXTENSION/KVM_ENABLE_CAP) >> instead. >> > > The goal of MSHV_REQUEST_VERSION is to support changes to APIs in the core set. > When we add new features/ioctls beyond the core we can use an extension/capability > approach like KVM. > Driver versions is a very bad idea from distribution/stable kernel point of view as it presumes that the history is linear. It is not. Imagine you have the following history upstream: MSHV_REQUEST_VERSION = 1 <100 commits with features/fixes> MSHV_REQUEST_VERSION = 2 MSHV_REQUEST_VERSION = 2 Now I'm a linux distribution / stable kernel maintainer. My kernel is at MSHV_REQUEST_VERSION = 1. Now I want to backport 1 feature from between VER=1 and VER=2 and another feature from between VER=2 and VER=3. My history now looks like MSHV_REQUEST_VERSION = 1 <5 commits from between VER=1 and VER=2> Which version should I declare here???? <5 commits from between VER=2 and VER=3> Which version should I declare here???? If I keep VER=1 then userspace will think that I don't have any extra features added and just won't use them. If I change VER to 2/3, it'll think I have *all* features from between these versions. The only reasonable way to manage this is to attach a "capability" to every ABI change and expose this capability *in the same commit which introduces the change to the ABI*. This way userspace will now exactly which ioctls are available and what are their interfaces. Also, trying to define "core set" is hard but you don't really need to. -- Vitaly