Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp860197pxf; Wed, 7 Apr 2021 13:30:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0FWiAFnp0uYFjlwzRpcBYOLMQ0O3Y12V+VvDokJyoccxRDuLM0a/R+85GM6WbBw5kzqht X-Received: by 2002:a17:907:24c9:: with SMTP id e9mr5901623ejn.517.1617827408426; Wed, 07 Apr 2021 13:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617827408; cv=none; d=google.com; s=arc-20160816; b=q5XJfnvvO8Z2CF2u0SZXZl4/RB2D4sfgzlesEU0LICUKv9ae92W8aRBpIeG686i+Vn 7zc5D7Qwi0AcjjvgJg0U0ikazI2kQdLv40+BxWclGbGhigsSzpeLlCFq9jqK25EZ6mNR H3a8mmXZ2iukFRFest19M6/e9L9d7oT4nJNNuEzFdEfkjT7ARCZaBW1IbPDprjTYLYrY 84UbsVC2ZzJHlFytEvKouDnxaT5VLWiczv7oa+Gdzg+ljMcCZF/1iK5eJ27nV9VHzXv0 Q40ST/ntd3DJUCzIdH/7j9YW5AL7dATcjMDO4XxVypQLOqgbxE1cp57XWFNEXrFQk6KB n4qw== 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=3F/RC/fvqCURdl1YYUj40I8I1hZvQBl3Hi/4LGAyDow=; b=VJrG4g7NKhm8onQg4wzZ6lukFyUoNII69wVlqbT4bTMPZeDagsJRgFk04CgE1Gwjmy e75Eh9fjiNT9WpN1H+R6xu5FX7AjArwhJMCJ6JuLCrTdtAIvOULXeiGPa9Gv2SbMGvii MrFK1lUB8vmeMAdoeZYzzHwbDSL9vy3V8qH4oMyeExh0mh5tAhZvy2zxtqZrA8iFm3Rr YAhe+hR8PKgd4ybad/MSDa/Er7fQzJVPL7B05wVQaVSClpg3oXsZ8xJ0zBdkDUl1WKRd msfx3MU20lAMXHO0Ky5RDJk9Yynt1AfR0eYkNTtHvZv/Ms59OCd147KlagvV8KDfZ71L vhQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gx84uPm0; 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 k19si10863475eds.343.2021.04.07.13.29.45; Wed, 07 Apr 2021 13:30:08 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gx84uPm0; 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 S233509AbhDGHif (ORCPT + 99 others); Wed, 7 Apr 2021 03:38:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60106 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233326AbhDGHif (ORCPT ); Wed, 7 Apr 2021 03:38:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617781105; 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=3F/RC/fvqCURdl1YYUj40I8I1hZvQBl3Hi/4LGAyDow=; b=gx84uPm06MR9UriepQ5AFT0G8lFsIndfdd14gxMqZnVCHo6eLIyndbMoRIlp311RWR1FzS bTjP1IhiRraH9q9QUghbtBD6W91WEQD/ABGRu81MXyLlvt6mwM0Yb8m2gMf4idLhZO6dB2 rFTZZAtve+3MqDtRd9jTHl75LBzuMm4= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-QUn7dwiaN0yy2j9AQNg-RQ-1; Wed, 07 Apr 2021 03:38:24 -0400 X-MC-Unique: QUn7dwiaN0yy2j9AQNg-RQ-1 Received: by mail-ej1-f70.google.com with SMTP id l1so2464912eji.9 for ; Wed, 07 Apr 2021 00:38:24 -0700 (PDT) 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=3F/RC/fvqCURdl1YYUj40I8I1hZvQBl3Hi/4LGAyDow=; b=DOFFoQKFQ5UryCFt2VXyioDOqhwDfFNHnreMNrYj7iCM2c6iZenjWINUbVbbWbhnf0 Mtdbt1rzkntjje1WzN0tYCgPomdBvv52Su6zpCdGszybb8KssIeOakck+AnrGRXESi4b JmRfM1B82GRfnMY7sKyvpLtjPqGcGlJPbAnCJhQJgcFfMNNIXOolF+umVZwkCy8nDxv4 8RNmcr3uwcgxBAaHe7W3fdqATRZwhor3nNLU05ppoU6Ku2cndqIwj19MU4i3OtYsjeXg x5BjJT+AC2u+IOHQ6SDO/qmkDcoUD2XNwe15Rmq8NTOmCUNwiKhUKixhvk+HxQbjgdYI m54g== X-Gm-Message-State: AOAM5302z/bPtV9PV8aU3VO6Tdtmc7n/U+d5e2ZwhdYgvq22CyK+N3IR HqrDVCx7umOgMB4Kc+xYPvgnnhEla285uV+9M1xj3fGf/bo7RiSoAbpvQG99Tz9b3bsUU51ZRY2 3bwiGatB6VXanOZPXAwANMIhg X-Received: by 2002:a17:907:9611:: with SMTP id gb17mr2237663ejc.325.1617781102974; Wed, 07 Apr 2021 00:38:22 -0700 (PDT) X-Received: by 2002:a17:907:9611:: with SMTP id gb17mr2237651ejc.325.1617781102784; Wed, 07 Apr 2021 00:38:22 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id bo19sm8418004edb.17.2021.04.07.00.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Apr 2021 00:38:22 -0700 (PDT) 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: 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> <87eeguc61d.fsf@vitty.brq.redhat.com> Date: Wed, 07 Apr 2021 09:38:21 +0200 Message-ID: <87eefmczo2.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 3/5/2021 1:18 AM, Vitaly Kuznetsov wrote: >> 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. >> > > We've had some internal discussion on this. > > There is bound to be some iteration before this ABI is stable, since even the > underlying Microsoft hypervisor interfaces aren't stable just yet. > > It might make more sense to just have an IOCTL to check if the API is stable yet. > This would be analogous to checking if kVM_GET_API_VERSION returns 12. > > How does this sound as a proposal? > An MSHV_CHECK_EXTENSION ioctl to query extensions to the core /dev/mshv API. > > It takes a single argument, an integer named MSHV_CAP_* corresponding to > the extension to check the existence of. > > The ioctl will return 0 if the extension is unsupported, or a positive integer > if supported. > > We can initially include a capability called MSHV_CAP_CORE_API_STABLE. > If supported, the core APIs are stable. This sounds reasonable, I'd suggest you reserve MSHV_CAP_CORE_API_STABLE right away but don't expose it yet so it's clear the API is not yet stable. Test userspace you have may always assume it's running with the latest kernel. Also, please be clear about the fact that /dev/mshv doesn't provide a stable API yet so nobody builds an application on top of it. One more though: it is probably a good idea to introduce selftests for /dev/mshv (similar to KVM's selftests in /tools/testing/selftests/kvm). Selftests don't really need a stable ABI as they live in the same linux.git and can be updated in the same patch series which changes /dev/mshv behavior. Selftests are very useful for checking there are no regressions, especially in the situation when there's no publicly available userspace for /dev/mshv. -- Vitaly