From patchwork Wed Jan 31 22:50:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 195011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp75281dyc; Wed, 31 Jan 2024 14:59:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfegOjkqLosPonH/+KN7MqwyPBuGd9AA4LFyxuwYPHfSqKYTS4Sn4csoq0HThPqoUJXp3m X-Received: by 2002:a05:6a00:93a1:b0:6da:c9e8:486f with SMTP id ka33-20020a056a0093a100b006dac9e8486fmr6331897pfb.3.1706741992658; Wed, 31 Jan 2024 14:59:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706741992; cv=pass; d=google.com; s=arc-20160816; b=vTKURZWf63HpxxqHYK1uTHtQWpxM2CVVZW15LUjBPgvBczN9G+6AyEapgcbEBfz3Vr KQR1VYAZtDxJ2gXs0b8TORX+PES9Gyc8YAkt63NeTK6HrsGzbBMWuwCb+JqAZJA4bin0 zpQk6PySBoDlp4V284FwRVP76nWaSJzymHZQptcdjoiqJ5Cz9gDH4szWojaDkYVK1qew 2NUltWUYKDZrUHzZmxtRjUu9IFywHxquJpE//w/oUyQE8kG7aUDs1/q70qz72W/VBlo3 RDqwf8CXr9bYdhKzoo/SqakzcAeD4XStNfmRfa5U0WY/A/H70Fr0Eam9v4UxWlbhU5BB e5TA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=8s9Z4w0oeoXTNZwVmUdV7m8lOeT75qbXwsQyi6Cf5T8=; fh=P1iKDyBZOuJdqmi2S2+JEY3mSAHq+fdJEOL38v2mRoY=; b=ftxnodCe/qMpH7yRpLmcUUe6ZCLEAka6bm9BlKW9fCHV9bM88j3vg6dlvmCbh5DNTQ NVVX3QrdrVYXCzurK+vZ/dHxHnofX2mmmaRFs7o6NFIjBH29ZRvZDPnIUYuCRzXQguLF ouQLiCB28sgjzPRryqi6xbeSlj/DrX1QeCgDH8y9K8r4HL0AGWSho9nBzlnqC99Lo1w9 ChLmug7qaDaX3gJvKoK2OMaHsp+SxyCCoKkC3vNLxyvq/6IdaH1GQsoi0wl0FdX9ftQu m1aCrwxP/mSKNNXr48bNQ8Fgod3MVuo6MLWGwY/mR230imRPH55U/yKrvIv6KThPStBr aUVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Joqiy+3I; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47274-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47274-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUPwzNL9CvId78pMZRc1RqX6VlC26d/gKwvWVw6vWir6m/TG7YP+NXUESYOyR/mpaOrHi+ZJp3LgIDnfyFu0wcnpx0aUA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t42-20020a056a0013aa00b006d990db77besi10917957pfg.135.2024.01.31.14.59.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 14:59:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47274-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Joqiy+3I; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47274-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47274-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 70EB5292BE9 for ; Wed, 31 Jan 2024 22:50:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9528D3AC1B; Wed, 31 Jan 2024 22:50:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Joqiy+3I" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4153D3A1CF for ; Wed, 31 Jan 2024 22:50:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706741417; cv=none; b=bVCWlpB2oLTGtoyPTPsRX3CsmtHBWhS9F6FjASRuKa6kGztTHiZ6d600RV/GKW4l36oXftJh1wg/ZE6NTvlxNGZTjwggu8HfzyzS+rkr6OZ97SpFKe4MJ4gjZ5PsyM35COUG1fzLGylqhSkiaQAXs/jiBfRnmSOayVyp1mI7BnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706741417; c=relaxed/simple; bh=Lpb3WwW/AoBdR5r08zXNH24gj3WmL9Y6tGHn7yyMmas=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=JiiXkiiq0aC6l17pipJ5DDgOceLtVqvF2Xehy89ULi99I37OdqdFBC8aAyMXeXBUamksievL4h5vo3wCzvhAMpPLIVDSeSas3PsU/y2zEy50UZarTvbZbZk9xbLCt/9YZkOcU0/ZfcpJiljMsoECUllHaTSQMySP2miyrAwFfuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Joqiy+3I; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706741415; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8s9Z4w0oeoXTNZwVmUdV7m8lOeT75qbXwsQyi6Cf5T8=; b=Joqiy+3I8OtPd7zti6MIWAlZVBBANtCbLe/0XwxJ/QdKBluBnzr6gx/KEntViRhbNqd0/G +j6UpMKRTNidN97dmegjZWFQF5UEyfUc7uiyseFirJ2AE73tT4Wt1iVDiEDMn82d+Qw/uX sZXr13D65xhPwojOnvBsK5ItB9tGD7Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-152-JX0H0HIiNS2UuuLmby9pVA-1; Wed, 31 Jan 2024 17:50:11 -0500 X-MC-Unique: JX0H0HIiNS2UuuLmby9pVA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 320F58493E5; Wed, 31 Jan 2024 22:50:11 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10D9C2166B31; Wed, 31 Jan 2024 22:50:11 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: dionnaglaze@google.com, seanjc@google.com Subject: [PATCH 1/3] uapi: introduce uapi-friendly macros for GENMASK Date: Wed, 31 Jan 2024 17:50:08 -0500 Message-Id: <20240131225010.2872733-2-pbonzini@redhat.com> In-Reply-To: <20240131225010.2872733-1-pbonzini@redhat.com> References: <20240131225010.2872733-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789648691770690754 X-GMAIL-MSGID: 1789648691770690754 Move __GENMASK and __GENMASK_ULL from include/ to include/uapi/ so that they can be used to define masks in userspace API headers. Compared to what is already in include/linux/bits.h, the definitions need to use the uglified versions of UL(), ULL(), BITS_PER_LONG and BITS_PER_LONG_LONG (which did not even exist), but otherwise expand to the same content. Signed-off-by: Paolo Bonzini --- include/linux/bits.h | 8 +------- include/uapi/asm-generic/bitsperlong.h | 4 ++++ include/uapi/linux/bits.h | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 include/uapi/linux/bits.h diff --git a/include/linux/bits.h b/include/linux/bits.h index 7c0cf5031abe..0eb24d21aac2 100644 --- a/include/linux/bits.h +++ b/include/linux/bits.h @@ -4,6 +4,7 @@ #include #include +#include #include #define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG)) @@ -30,15 +31,8 @@ #define GENMASK_INPUT_CHECK(h, l) 0 #endif -#define __GENMASK(h, l) \ - (((~UL(0)) - (UL(1) << (l)) + 1) & \ - (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) #define GENMASK(h, l) \ (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) - -#define __GENMASK_ULL(h, l) \ - (((~ULL(0)) - (ULL(1) << (l)) + 1) & \ - (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h)))) #define GENMASK_ULL(h, l) \ (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l)) diff --git a/include/uapi/asm-generic/bitsperlong.h b/include/uapi/asm-generic/bitsperlong.h index 352cb81947b8..fadb3f857f28 100644 --- a/include/uapi/asm-generic/bitsperlong.h +++ b/include/uapi/asm-generic/bitsperlong.h @@ -24,4 +24,8 @@ #endif #endif +#ifndef __BITS_PER_LONG_LONG +#define __BITS_PER_LONG_LONG 64 +#endif + #endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */ diff --git a/include/uapi/linux/bits.h b/include/uapi/linux/bits.h new file mode 100644 index 000000000000..3c2a101986a3 --- /dev/null +++ b/include/uapi/linux/bits.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* bits.h: Macros for dealing with bitmasks. */ + +#ifndef _UAPI_LINUX_BITS_H +#define _UAPI_LINUX_BITS_H + +#define __GENMASK(h, l) \ + (((~_UL(0)) - (_UL(1) << (l)) + 1) & \ + (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) + +#define __GENMASK_ULL(h, l) \ + (((~_ULL(0)) - (_ULL(1) << (l)) + 1) & \ + (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) + +#endif /* _UAPI_LINUX_BITS_H */ From patchwork Wed Jan 31 22:50:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 195012 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp77004dyc; Wed, 31 Jan 2024 15:02:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBB1ogffSAfS1sD4f9HuyKh7VnSKx4xAwXip2FG7wv81BG53swYnIIpVNGloqc9LmO93+a X-Received: by 2002:a17:902:ed45:b0:1d5:f255:d386 with SMTP id y5-20020a170902ed4500b001d5f255d386mr2702266plb.11.1706742133084; Wed, 31 Jan 2024 15:02:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742133; cv=pass; d=google.com; s=arc-20160816; b=CBSKJQxQRbZEeuiDdwh6w6GOFi7phIlfhH8dRHyLf8xpSODBnZq11WTPLADKX6r7XN AZDKzug9uwM7b7oNFNjyZjlCJj7pBySLoGnR5xwNiHGEHz4T/jOQp+0gl6rf/luvl3AT F9ueXM1Nx1advI52Q1PIRLHNrSCYDqdJTG04m6cDxYbL9X0VAkZQisUJscCz4w35vr6q C3HrqtWKWUvFZuDna1nTcbkxqgbljzpUT7HI15gROIaPVlkljjzqOsysHBx8TGlaF2Oy QHhplDyLY317hu89mHj5p/1zLu1T6x3Zd50sIoQlswiKwmdlD3O9StoDSq/ZLb4/p4AS uoFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=w4Bff5uM3q8eLthCYLMVDr14Of+ziM6eQHIEK7k2YKg=; fh=KkTLd6hN7Hqrog+TOpwExO4ugn+Bj4wFY0WDTtLz5Sg=; b=Amc28MuITVwsROdNjlPnFlh7h8RGni6G26nlVWhJFeV5Di776fjJhkfyWJ7cs1debp VplZNAvB1HhMR4G/Kp6QCMc9ilhW0HPZyZ5s3pXc3wd9WahHASerAxpmjjfPd7w9Xp51 GBcZ40iQchIFxm7Am8lbRpXzOD4oHSXeWg/nrZwtBvRQjTAmXDlIOnc66Xt75O9snGF6 EIotibpbkljvICehw5EJdQl8EHABnsgcJS4G+WjLpLZog+LTupOkeB33hkQAitdpI9nA JQmxa6YcLrW5r1DbXidYgLcliL7tsOHOZzPK3tVlNnEVk+HQ56G1tn1XsGo/b+mYelZQ 9dtg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ihPIffyt; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47275-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47275-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCV/xmtoPdY1YbXsrJMYC8MfrCTNh2a5EFEzJX9VUx0zd2YPv34N2huB1EvgmzOrk8veJfDP3JYoUCAgZMuL+nQEKcpVwA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n4-20020a170902968400b001d4891f73f0si10184755plp.549.2024.01.31.15.02.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:02:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47275-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ihPIffyt; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47275-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47275-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4C877293488 for ; Wed, 31 Jan 2024 22:51:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D27623B295; Wed, 31 Jan 2024 22:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ihPIffyt" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FDDA3A1DF for ; Wed, 31 Jan 2024 22:50:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706741419; cv=none; b=ZEFTBALMCPP+uZoBJFhcUmaZbynijcfyafOcPCgBwenrHCT3I+LY4lFxJmA1eXDbIZ5lisgq7eu1giqXeoPux73XhH18t93tRD5/IqbGrTsoMczASHaVr3Xnwnu9Ka6rbbPkaGh1D2WYH5cf4+T2ZBMxadZquUzDCN4vykPm1O0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706741419; c=relaxed/simple; bh=1/4WEIAIKqQBXE0ZhDljCAFK3p148tD/jCshuVONiGI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=LayH1714v+TRldMAGmTYbpgNYPqSsRs2PGQkZ8hgJNb5euG8adDkIWxrAEcNoE9nZBJPEhns9xZakvhKk+CB87bDEmrQ0XFGHSN97W509qs44LM9Di+ZlOEppWVk1lT7sceewgMiXvKv+MSf/3DSrxBzwB78QRbid70WGNI8wTU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ihPIffyt; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706741416; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w4Bff5uM3q8eLthCYLMVDr14Of+ziM6eQHIEK7k2YKg=; b=ihPIffyt/4ppT4ubaRNL4bw0/FjO+Cxvkp5FBj1Fv3lmOl8Ha2zs8+URPgcV5P4qVh/dvz 4SCZk2b5eRTXCi1bUptOgrY6R16tsD8cwd62IiHtp3bDSL1sXNpxPdQKZNWyl6sZ+AKuRT ZHDlUDklaSpfG1vj1AjPPV3nkbnRPSg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-4ALEoIVjPnW3OisOpzO0ow-1; Wed, 31 Jan 2024 17:50:11 -0500 X-MC-Unique: 4ALEoIVjPnW3OisOpzO0ow-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C1D4185A785; Wed, 31 Jan 2024 22:50:11 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A6AE2166B31; Wed, 31 Jan 2024 22:50:11 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: dionnaglaze@google.com, seanjc@google.com Subject: [PATCH 2/3] kvm: x86: use a uapi-friendly macro for BIT Date: Wed, 31 Jan 2024 17:50:09 -0500 Message-Id: <20240131225010.2872733-3-pbonzini@redhat.com> In-Reply-To: <20240131225010.2872733-1-pbonzini@redhat.com> References: <20240131225010.2872733-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789648838589596458 X-GMAIL-MSGID: 1789648838589596458 From: Dionna Glaze Change uapi header uses of BIT to instead use the uapi/linux/const.h bit macros, since BIT is not defined in uapi headers. The PMU mask uses _BITUL since it targets a 32 bit flag field, whereas the longmode definition is meant for a 64 bit flag field. Cc: Sean Christophersen Cc: Paolo Bonzini Signed-off-by: Dionna Glaze Message-Id: <20231207001142.3617856-1-dionnaglaze@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/include/uapi/asm/kvm.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index a448d0964fc0..9ae91a21ffea 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -7,6 +7,7 @@ * */ +#include #include #include #include @@ -526,7 +527,7 @@ struct kvm_pmu_event_filter { #define KVM_PMU_EVENT_ALLOW 0 #define KVM_PMU_EVENT_DENY 1 -#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0) +#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS _BITUL(0) #define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS) /* @@ -552,7 +553,7 @@ struct kvm_pmu_event_filter { (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32)) #define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56)) #define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8)) -#define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55)) +#define KVM_PMU_MASKED_ENTRY_EXCLUDE (_BITULL(55)) #define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56) /* for KVM_{GET,SET,HAS}_DEVICE_ATTR */ @@ -560,7 +561,7 @@ struct kvm_pmu_event_filter { #define KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */ /* x86-specific KVM_EXIT_HYPERCALL flags. */ -#define KVM_EXIT_HYPERCALL_LONG_MODE BIT(0) +#define KVM_EXIT_HYPERCALL_LONG_MODE _BITULL(0) #define KVM_X86_DEFAULT_VM 0 #define KVM_X86_SW_PROTECTED_VM 1 From patchwork Wed Jan 31 22:50:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 195009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp72352dyc; Wed, 31 Jan 2024 14:51:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKn/e+YSPBi8BrGfuNToFBsf0yaVw9n6I5AxNDnpWE9avw12KZQU3tCK3qf1DR5pgE249C X-Received: by 2002:a05:620a:6893:b0:784:99b:fe3c with SMTP id rv19-20020a05620a689300b00784099bfe3cmr1222610qkn.28.1706741491513; Wed, 31 Jan 2024 14:51:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706741491; cv=pass; d=google.com; s=arc-20160816; b=bWdpXXiyw+HRGtb8UbqP/tyYw7+Mlfrs93p0KErm50oYjj2+GjP6TfeX4MjT36d+g7 0OE3gvDGJKvBpBgyst+GTm0Zp1gX5BupRlJWWO8b1GOtSdyocCBdqyFx6x5AwZdtiSV6 FdmCtmN7VCVl0q6V+O4UIAMDilQPHZLd7frvsw/d+lHrw/FZp6Lv5ffg/MAkh3d8np1t A9c6qQTbUu079+plc7sI73qUp2rSyEjgdDlIrAEydK6AXEgjwd+vnOBYDQ1yKi2dD/OM 667DNHrShFpixIXQ9sv4I2jg0HQ+NM26MJGgQebmsu6Ghw9hWRhVk7Y8QcNQXN8CJ5ng /NWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FcW4aA4QUlOADw+pKX0iGEX+H00vP76wOtrVID4JVvo=; fh=42w2tA7GvqOmE71riqvaGEvZ4V5QVy/RkBtArpU57vM=; b=Z+/LWhTCG+kVf3HVEBGZ30L18K0E7tLdisDi5dR126zxHEb5OKbyUyRcDz7930hAef 7Nzx69aO4gcy81+zdtxb2eRI9Wd/P9cgNxrkj/asOd5OaA/onzdV5la/AxNN/BOAhRjW nP018d5mMYarih5YLcZMxxzbMYGeiZIRzafOAguY86TDfklfcW/cSbCBp/p7ybDyk6A8 3STaauyKUM9gpTTET8082Hy7njo+0hpMBdqhLo6uo5ykPO7xDW4w/a6lU3UJTMDXzy6r OEwljlLyPIaC8ITECw8c1N0Sh074Tv6fWGJ5GIwG8pWKpKOGw9MfrPjYXN0zwa+Rpm0k hicQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SveXXnsB; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47277-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47277-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUZ+srx7611hzHAxRPe7lbeJVeY21pX6iCCKYd0RdEWScu3lxJHoS9JptokpG9ZXSt5ymmq9K/2WsjnWyJBHFwmmf+Vrg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y18-20020a05620a09d200b00783f6cfcd81si8546329qky.249.2024.01.31.14.51.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 14:51:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47277-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SveXXnsB; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-47277-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47277-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 510931C244BB for ; Wed, 31 Jan 2024 22:51:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B47133A8C2; Wed, 31 Jan 2024 22:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SveXXnsB" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73BA03B797 for ; Wed, 31 Jan 2024 22:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706741425; cv=none; b=kdJKIkSgjCUpucu0BeLWXOlXWuRjg4QvLykreb/GARQbDXHOof6J3VnqYWoEd704p2MFFjYbYvRT0gDXZHFKf5CS0ne25cpTilwh3UuBwA3AP0pYmbsP+jgHs934A94967xwzLLi2Pxs0z+ZvUTC/v1zK+tOio4KZVNj/P6oMvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706741425; c=relaxed/simple; bh=AYdMEWZrrFVOE5/Y3TiS+Iapcw8zW/FHFD57cTayr5Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Qaw65lZcz5S8p4oraaEfz4sKer74xtghQJkd4MI+OWkqMeyOdJtgkI74aMycRma6Z2+gbQC3e6WiIqEorY0w+PaeCt0JAc0/MXEL0X5SWascDv0YIW0ABZEQK8u2T52tskN+F2bBZTBcs1JxmqTb0a7BkxJUffLciIhdCsUmBOA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SveXXnsB; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706741422; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FcW4aA4QUlOADw+pKX0iGEX+H00vP76wOtrVID4JVvo=; b=SveXXnsBu5hYvZ5clmg3TN6vUaNje4HL10VCW4dcW0xn9gbFKeupEfQFAnx07AI5kidcUn PscGN7S2mbGKmUSfhXM5bzgeUxLc9nK6yTaLAPGtsStoSafrzvn+8FpJ9/mIAhNUP1mgWM Pd4OUH9ga8BY84PZYhXSnCwBk8XZ2rY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-PhiVAquEOmSRTXpoEibaxg-1; Wed, 31 Jan 2024 17:50:11 -0500 X-MC-Unique: PhiVAquEOmSRTXpoEibaxg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85444185A787; Wed, 31 Jan 2024 22:50:11 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 63A5D2166B31; Wed, 31 Jan 2024 22:50:11 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: dionnaglaze@google.com, seanjc@google.com Subject: [PATCH 3/3] kvm: x86: use a uapi-friendly macro for GENMASK Date: Wed, 31 Jan 2024 17:50:10 -0500 Message-Id: <20240131225010.2872733-4-pbonzini@redhat.com> In-Reply-To: <20240131225010.2872733-1-pbonzini@redhat.com> References: <20240131225010.2872733-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789648166230922479 X-GMAIL-MSGID: 1789648166230922479 Change uapi header uses of GENMASK to instead use the uapi/linux/bits.h bit macros, since GENMASK is not defined in uapi headers. Signed-off-by: Paolo Bonzini --- arch/arm64/include/uapi/asm/kvm.h | 8 ++++---- arch/x86/include/uapi/asm/kvm.h | 7 ++++--- arch/x86/include/uapi/asm/kvm_para.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h index 89d2fc872d9f..6b8b57b97228 100644 --- a/arch/arm64/include/uapi/asm/kvm.h +++ b/arch/arm64/include/uapi/asm/kvm.h @@ -76,11 +76,11 @@ struct kvm_regs { /* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */ #define KVM_ARM_DEVICE_TYPE_SHIFT 0 -#define KVM_ARM_DEVICE_TYPE_MASK GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \ - KVM_ARM_DEVICE_TYPE_SHIFT) +#define KVM_ARM_DEVICE_TYPE_MASK __GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \ + KVM_ARM_DEVICE_TYPE_SHIFT) #define KVM_ARM_DEVICE_ID_SHIFT 16 -#define KVM_ARM_DEVICE_ID_MASK GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \ - KVM_ARM_DEVICE_ID_SHIFT) +#define KVM_ARM_DEVICE_ID_MASK __GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \ + KVM_ARM_DEVICE_ID_SHIFT) /* Supported device IDs */ #define KVM_ARM_DEVICE_VGIC_V2 0 diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index 9ae91a21ffea..bd36d74b593b 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -550,9 +551,9 @@ struct kvm_pmu_event_filter { ((__u64)(!!(exclude)) << 55)) #define KVM_PMU_MASKED_ENTRY_EVENT_SELECT \ - (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32)) -#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56)) -#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8)) + (__GENMASK_ULL(7, 0) | __GENMASK_ULL(35, 32)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (__GENMASK_ULL(63, 56)) +#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (__GENMASK_ULL(15, 8)) #define KVM_PMU_MASKED_ENTRY_EXCLUDE (_BITULL(55)) #define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56) diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h index 6e64b27b2c1e..6bc3456a8ebf 100644 --- a/arch/x86/include/uapi/asm/kvm_para.h +++ b/arch/x86/include/uapi/asm/kvm_para.h @@ -92,7 +92,7 @@ struct kvm_clock_pairing { #define KVM_ASYNC_PF_DELIVERY_AS_INT (1 << 3) /* MSR_KVM_ASYNC_PF_INT */ -#define KVM_ASYNC_PF_VEC_MASK GENMASK(7, 0) +#define KVM_ASYNC_PF_VEC_MASK __GENMASK(7, 0) /* MSR_KVM_MIGRATION_CONTROL */ #define KVM_MIGRATION_READY (1 << 0)