Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp367006rdb; Thu, 5 Oct 2023 08:11:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5zlcVXKsZ3dwOOB6QoqpLXQHssdC6cmGkdmS+n+nKd2fYad4Ymku7nOJVVWTftfHRaO3b X-Received: by 2002:a05:6a20:9191:b0:152:4615:cb9d with SMTP id v17-20020a056a20919100b001524615cb9dmr2640987pzd.12.1696518695194; Thu, 05 Oct 2023 08:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696518695; cv=none; d=google.com; s=arc-20160816; b=eiLi/qXYR8or/YpBEEKAJgA98ZcuOLqU+ppU80stOjPqkX36RIV8N5mcgyB4jkXzUb oc/u2LPjCZUqaykq7yAgiagqSeK7BoLN67N72JecXPRocR8sPCiDIbM0cjqVsGBA3SeI rVVXQFWqRXr3YNzG4ad4lj+VqQVTLEtGjxWOp+pGMOlClqwRwUcLZV9d+B/7ESRy+OLs AZDWPnphx/EzwGL0NuowF95QAGhSICwRx4nTZvqqQ3LXKkJTnn5aQxu3eMINr22pERre nahfFccpS7hMkVTBNf2UVXHed75cIuGiIGXIvfZ8Am4aiHk2+azljq5h7uxZQp7f35FI aSYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6iqp3ucQ3RQ+1mL13py2HXc9u+mQpb7fMzOEiq3Un3g=; fh=Wy5r6TGqwyea2eJTun6/5GwpIHB6dcQsM9z7AB+d3UM=; b=DQgwsP0TL9n8b04fBb4orgfqEAhvsWrQBIEcmeTunV+axlex6rP2VrmgZXK+RnxCdW PliMvJx91/+Fr5O3noiAvkEZOzGWqx0z9jJ5GS8UXd0c9aRLRG3JEg+NgiH/YG7L1beD iXWNNzisWEwzJnZxbszRcfWDs8YmNkzGPTzHdBAULAMl9HmSZo6YekcfWi0sgIMkx0+b FgEUA0ZncgWS2PVenbWz52t7QojyCRNtetuUqcSUZEc7fCK42jqBRuhRrI8vRs8NCSsc 1sPwJfklmaOpsOyJ76J2B5jVIYghDsRoYaET9z1XTleVrfD1grphe0EHKRwxTF8kGcoz qTqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jLcSNkQ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id g123-20020a636b81000000b0057c7341d55bsi1592515pgc.391.2023.10.05.08.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="jLcSNkQ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DEBA483D51F8; Thu, 5 Oct 2023 08:11:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231442AbjJEPLE (ORCPT + 99 others); Thu, 5 Oct 2023 11:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbjJEPKJ (ORCPT ); Thu, 5 Oct 2023 11:10:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACADC3693; Thu, 5 Oct 2023 07:42:31 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D80EC433AD; Thu, 5 Oct 2023 06:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1696487200; bh=9xyNVyN7N7MBzA9UwuP9xPWMA9I3taWkS2jqsvKhr3s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jLcSNkQ/LCUGlX23x7bKHMrm6O+lCfLyVyl4lJFpqj9ZiSYYzwxEp9jZma31Pfllr wdUrN6biBfOS5V6bMBNu6EAM0Sq3HUrUansreS7bmBd3mLFduc2pF/kqcY06+yQC5z D87SMtm/bM/1USoOdPqeLZaEubagHNYsjEKm7koc= Date: Thu, 5 Oct 2023 08:26:38 +0200 From: Greg KH To: Nuno Das Neves Cc: Dexuan Cui , Wei Liu , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-arch@vger.kernel.org" , "patches@lists.linux.dev" , "Michael Kelley (LINUX)" , KY Srinivasan , Haiyang Zhang , "apais@linux.microsoft.com" , Tianyu Lan , "ssengar@linux.microsoft.com" , MUKESH RATHOR , "stanislav.kinsburskiy@gmail.com" , "jinankjain@linux.microsoft.com" , vkuznets , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "hpa@zytor.com" , "will@kernel.org" , "catalin.marinas@arm.com" Subject: Re: [PATCH v4 13/15] uapi: hyperv: Add mshv driver headers defining hypervisor ABIs Message-ID: <2023100540-linked-remote-3da7@gregkh> References: <1696010501-24584-1-git-send-email-nunodasneves@linux.microsoft.com> <1696010501-24584-14-git-send-email-nunodasneves@linux.microsoft.com> <2023093057-eggplant-reshoot-8513@gregkh> <2023100154-ferret-rift-acef@gregkh> <2023100443-wrinkly-romp-79d9@gregkh> <2023100415-diving-clapper-a2a7@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:11:31 -0700 (PDT) On Wed, Oct 04, 2023 at 11:16:46AM -0700, Nuno Das Neves wrote: > On 10/4/2023 10:50 AM, Greg KH wrote: > > On Wed, Oct 04, 2023 at 05:36:32PM +0000, Dexuan Cui wrote: > > > > From: Greg KH > > > > Sent: Tuesday, October 3, 2023 11:10 PM > > > > [...] > > > > On Tue, Oct 03, 2023 at 04:37:01PM -0700, Nuno Das Neves wrote: > > > > > On 9/30/2023 11:19 PM, Greg KH wrote: > > > > > > On Sat, Sep 30, 2023 at 10:01:58PM +0000, Wei Liu wrote: > > > > > > > On Sat, Sep 30, 2023 at 08:09:19AM +0200, Greg KH wrote: > > > > > > > > On Fri, Sep 29, 2023 at 11:01:39AM -0700, Nuno Das Neves wrote: > > > > > > > > > +/* Define connection identifier type. */ > > > > > > > > > +union hv_connection_id { > > > > > > > > > + __u32 asu32; > > > > > > > > > + struct { > > > > > > > > > + __u32 id:24; > > > > > > > > > + __u32 reserved:8; > > > > > > > > > + } __packed u; > > > > > > IMO the "__packed" is unnecessary. > > > > > > > > > > > bitfields will not work properly in uapi .h files, please never do that. > > > > > > > > > > > > > > Can you clarify a bit more why it wouldn't work? Endianess? Alignment? > > > > > > > > > > > > Yes to both. > > > > > > > > > > > > Did you all read the documentation for how to write a kernel api? If > > > > > > not, please do so. I think it mentions bitfields, but it not, it really > > > > > > should as of course, this will not work properly with different endian > > > > > > systems or many compilers. > > > > > > > > > > Yes, in > > > > https://docs.k/ > > > > ernel.org%2Fdriver- > > > > api%2Fioctl.html&data=05%7C01%7Cdecui%40microsoft.com%7Ce404769e0f > > > > 85493f0aa108dbc4a08a27%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C > > > > 0%7C638319966071263290%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj > > > > AwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C% > > > > 7C%7C&sdata=RiLNA5DRviWBQK6XXhxC4m77raSDBb%2F0BB6BDpFPUJY%3D > > > > &reserved=0 it says that it is > > > > > "better to avoid" bitfields. > > > > > > > > > > Unfortunately bitfields are used in the definition of the hypervisor > > > > > ABI. We import these definitions directly from the hypervisor code. > > > > > > > > So why do you feel you have to use this specific format for your > > > > user/kernel api? That is not what is going to the hypervisor. > > > > These *are* going to the hypervisor - we use these same definitions in > our driver for the kernel/hypervisor API. This is so we don't have to > maintain two separate definitions for user/kernel and kernel/hypervisor > APIs. So these fields are just pass-through from userspace to the hypervisor and are not touched at all by the kernel? If so, I hope the hypervisor is doing some validation of the data :) > > > If it's hard to avoid bitfield here, maybe we can refer to the definition of > > > struct iphdr in include/uapi/linux/ip.h > > > > It is not hard to avoid using bitfields, just use the proper definitions > > to make this portable for all compilers. And ick, ip.h is not a good > > thing to follow :) > > > Greg, there is nothing making us use bitfields. It just makes the work > of porting the hypervisor definitions to Linux easier - aided by the > fact that in practice, all the compilers in our stack produce the same > code for these. "our stack" is not how Linux works, you have to write files that work for all compilers here. Just use a normal variable and define the bits in them with proper bit shifts or masks and that will be portable everywhere. This isn't rocket science... thanks, greg k-h