Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1958213rdb; Wed, 31 Jan 2024 14:50:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHN5e3xOHwh93EEAWVkOaj00XmA94rK/qkZms9a6RpMZQodtfjalVqF28QOt9RcYn0GWYmD X-Received: by 2002:ad4:5ca5:0:b0:67f:26c9:ffdb with SMTP id q5-20020ad45ca5000000b0067f26c9ffdbmr3621969qvh.22.1706741451619; Wed, 31 Jan 2024 14:50:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706741451; cv=pass; d=google.com; s=arc-20160816; b=yF6308bZN0QJt+P1x+RrbUBNWvJHHbKV09jgc12nPMV4KMINKUkIfyUXaT1f8Evr+R QXI60lWjPKK05PWdJ8VJQ5MWc3yMqDdJClnO5rp32+J/RK7WGpf+L9DIVyHd7UiHGJLB Ntz5A9w/GqqPj64q3BqSO32/98p+7pF/MLfy+0WoyKDA1qV1V4plGIUMTSA57em2iVa9 xaOA6jaus3r9u5vvA/bKhA/H6AIhBN/nXRjzx+wjR+brMwfc1IaH01W9bCTeCB8Aze34 yIdeVbbt+yDNy3ojkd/ST6YHqSlPMIu4MPNo5PiM/XoqdgLsm/7MeavBRV9y1YuxsT4k CC3Q== 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=Mk+w1wiAvXYBuhy5mDSDO6QTfWTxMUo9+kWandnniJw=; b=t9V3o2Db57QSdf7MyqC1OOwz40sRqVCHZdbdPiNTqmLjTIRRJN5HFfJzqErKEAvIWy 2vtTtybScxRwsPd9HfycwVQ4AdHvjFQL86sw+RqfznASJIrtT9tE5Saur6uDgZ28QjWr 5MvwjGK0ifj7V14EwyJRrhf0iimxUyLjMzmQ3GWNxbauhG9fGH2WQwba3ZkEE/4xv0Mo nVWhiVhO3/G+tiMF+Lx3Nt9lx9VnsSo85zVBaM0UcOPWaATIdouhdaBju8Jp9D9Tx9Iq kQMezEKnMtGlHFlMJBBIAE/a4LjOPGz+79FnV3BApC4H8gLZOHd2F6ryDG+TVYiaw2X9 b3hg==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47274-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCXPbwLjJ8Mqh0QSyDgkyzEAjeorXyxNtWGfu5oUSsUeg/+7dw7r/mHHvMCvXn8/AiLFLtQDs/9w87gdGKLngJlNFG05/oX3Cw9I7wGEWQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gf12-20020a056214250c00b0068c4b4cb168si8262454qvb.534.2024.01.31.14.50.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 14:50:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47274-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47274-linux.lists.archive=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 113D61C24089 for ; Wed, 31 Jan 2024 22:50:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A58843A8C2; Wed, 31 Jan 2024 22:50:18 +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 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 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 */ -- 2.39.0