Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD8E1C25B74 for ; Mon, 27 May 2024 08:24:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.730632.1135766 (Exim 4.92) (envelope-from ) id 1sBVeX-0007op-U7; Mon, 27 May 2024 08:24:21 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 730632.1135766; Mon, 27 May 2024 08:24:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBVeX-0007oi-RU; Mon, 27 May 2024 08:24:21 +0000 Received: by outflank-mailman (input) for mailman id 730632; Mon, 27 May 2024 08:24:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sBVeW-0007oc-9M for xen-devel@lists.xenproject.org; Mon, 27 May 2024 08:24:20 +0000 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [2a00:1450:4864:20::52a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 82aa0e91-1c02-11ef-b4bb-af5377834399; Mon, 27 May 2024 10:24:18 +0200 (CEST) Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-57864327f6eso3282063a12.1 for ; Mon, 27 May 2024 01:24:18 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-57860a2eab3sm4401359a12.28.2024.05.27.01.24.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 May 2024 01:24:17 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 82aa0e91-1c02-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1716798257; x=1717403057; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BaTlOnCaTA/1XHNDwnVyAuCDZhHsZEyVzojdDKal27s=; b=XxdvfbM28j5EisTjHpqxQfQfSflHXClW7ikd9KKZ0XuXsc4c4I6iLoVGlDAR7zFOiO r9bWslAXRosyWiHkp1Avj+YERK5ZOmmzjEvKU0nQ1GJjs02hzJQTZrTg2tK1eeWebCN/ FrtPXKeb704iKWXbRK7lzPh+7hwCMrpjEGvnqiMhmkFeSdu2VmIpidssSpVfPhf5/yaY 2NRHkzZjeNVRfdXhW8R4JpODAe4zoMVPM5AbIDAPm1GSpNZz0XOBrQmqkulEn0Dqy9zh nPCVrnXALtFm86Q1kGzlA9ZAYjiojcLU+cWa+MebKcDG6Vq+UCLpamI5fsxXX/T3Dfyc iNpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716798257; x=1717403057; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BaTlOnCaTA/1XHNDwnVyAuCDZhHsZEyVzojdDKal27s=; b=KumRrXNYV6O09uz2YxqKROy0l/achY3NLCM19uXRT5lZGFtMqjSLogqoPZPZpRxh0O AqCL6chS3GykoBn/6eUwEb+H/sF/zUE1EI7LHA4wD5EM0FjnOrh+QqawzYy4YOsUbc+Y dsmKu0I0LzcwXThGRXzMuYpbACaUiDP2pInYCjKHA8r38FxSb3MYr6VnWqrB0NS4eGtm NU+SPlsaEDtNI50/yS2flWW4VooMCXWsEBUxvCu3Pbv9Q2RrBwHJ2KY7Wct+KLsv/8p5 2yTmV1lpVYrQQwYH8lYkhJOrApAC9xz1uXDPP0BnmxE48OT2Z25FZkNdpA8bO8SXvHpn d+hQ== X-Forwarded-Encrypted: i=1; AJvYcCU0oUpcyA4FtL+IqJGjC2H7C+6pYhdiTry6Nt9s7RLwsk/zri7C9kR26kLAKZWCgLQ+gwkVYtCst85WHRP2J5mliUy0dMB+7wksyPqUENM= X-Gm-Message-State: AOJu0Yw7d4SkP/V08m6vnEjaTj4EppXTWHLIwHwRpjQeLLpl744K08NI BiEc371i3SlLmUVU/VVZyt7Yvf0Sc5CQ1XhN8CYoPFqC+nQ6QTwX9dOdBT+LZA== X-Google-Smtp-Source: AGHT+IGgnmxEyutQ0DzAbAPiRUjk+mU6UIbJa0hcLR8dIaVnTVUrpe34xgvjHGLwUjoZB/2FFfcHyg== X-Received: by 2002:a50:8d4c:0:b0:572:3fac:e085 with SMTP id 4fb4d7f45d1cf-57843f1589fmr10741572a12.13.1716798257439; Mon, 27 May 2024 01:24:17 -0700 (PDT) Message-ID: Date: Mon, 27 May 2024 10:24:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 02/13] xen/bitops: Cleanup ahead of rearrangements Content-Language: en-US To: Andrew Cooper Cc: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Wei Liu , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio , "consulting @ bugseng . com" , Simone Ballarin , Federico Serafini , Nicola Vetrini , Xen-devel References: <20240524200338.1232391-1-andrew.cooper3@citrix.com> <20240524200338.1232391-3-andrew.cooper3@citrix.com> From: Jan Beulich Autocrypt: add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vRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <20240524200338.1232391-3-andrew.cooper3@citrix.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 24.05.2024 22:03, Andrew Cooper wrote: > * Rename __attribute_pure__ to just __pure before it gains users. > * Introduce __constructor which is going to be used in lib/, and is > unconditionally cf_check. > * Identify the areas of xen/bitops.h which are a mess. > * Introduce xen/boot-check.h as helpers for compile and boot time testing. > This provides a statement of the ABI, and a confirmation that arch-specific > implementations behave as expected. > > Sadly Clang 7 and older isn't happy with the compile time checks. Skip them, > and just rely on the runtime checks. > > Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Further remarks, though: > --- > xen/include/xen/bitops.h | 13 ++++++-- > xen/include/xen/boot-check.h | 60 ++++++++++++++++++++++++++++++++++++ > xen/include/xen/compiler.h | 3 +- > 3 files changed, 72 insertions(+), 4 deletions(-) > create mode 100644 xen/include/xen/boot-check.h The bulk of the changes isn't about bitops; it's just that you're intending to first use it for testing there. The subject prefix therefore is somewhat misleading. > --- /dev/null > +++ b/xen/include/xen/boot-check.h > @@ -0,0 +1,60 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > + > +/* > + * Helpers for boot-time checks of basic logic, including confirming that > + * examples which should be calculated by the compiler are. > + */ > +#ifndef XEN_BOOT_CHECK_H > +#define XEN_BOOT_CHECK_H > + > +#include > + > +/* Hide a value from the optimiser. */ > +#define HIDE(x) \ > + ({ typeof(x) _x = (x); asm volatile ( "" : "+r" (_x) ); _x; }) In principle this is a macro that could be of use elsewhere. That's also reflected in its entirely generic name. It therefore feels mis-placed in this header. Otoh though the use of "+r" is more restricting than truly necessary: While I'm not sure if "+g" would work, i.e. if that wouldn't cause issues with literals, pretty surely "+rm" ought to work, removing the strict requirement for the compiler to put a certain value in a register. Assuming you may have reservations against "+g" / "+rm" (and hence the construct wants keeping here), maybe rename to e.g. BOOT_CHECK_HIDE()? Alternatively, if generalized, moving to xen/macros.h would seem appropriate to me. Finally, plainly as a remark with no request for any change (but possibly a minor argument against moving to xen/macros.h), this construct won't, afaict, work if x is of array(-of-const) type. A more specialized variant may need introducing, should any such use ever appear. Jan