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 7BD53EA4FD8 for ; Mon, 23 Feb 2026 15:58:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1239157.1540594 (Exim 4.92) (envelope-from ) id 1vuYJg-0006CS-Cc; Mon, 23 Feb 2026 15:57:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1239157.1540594; Mon, 23 Feb 2026 15:57:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vuYJg-0006CL-8A; Mon, 23 Feb 2026 15:57:48 +0000 Received: by outflank-mailman (input) for mailman id 1239157; Mon, 23 Feb 2026 15:57:47 +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 1vuYJf-0006CF-4f for xen-devel@lists.xenproject.org; Mon, 23 Feb 2026 15:57:47 +0000 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [2a00:1450:4864:20::336]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 64152514-10d0-11f1-9ccf-f158ae23cfc8; Mon, 23 Feb 2026 16:57:44 +0100 (CET) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-48334ee0aeaso33230925e9.1 for ; Mon, 23 Feb 2026 07:57:44 -0800 (PST) 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 5b1f17b1804b1-483a31bc068sm262920025e9.4.2026.02.23.07.57.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 23 Feb 2026 07:57:43 -0800 (PST) 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: 64152514-10d0-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1771862264; x=1772467064; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=ds/RoTQe03K5D71BFLV3I6HxMYBKXTEWzKepx1kqI+E=; b=Q9zO7Eretz2mVJl2K/LCf+bq18tmg2PsFofeVdwAK0B+ZgI9UrvfKIcqIN9FrYbCgI FM11juKLamQC/lymWo7keqyzDpJeNm5SeqjVbc7z3bRGGS1MNOHVR+Xy1KVCvD6ONizU geXZG/FnE7Ah6LcPRcXGMfM+30DgeNL5XK4xDZxSHpl44ea9P2sft5GEcHHbEYvOKKre IvCi0fgRtD1e73pD06RcawaOlc8izzLIcOILwG+jY7u0dAKiiTM+O2IX3SNmkIy9HGuP B6/EwvG6CpEcfqmJVXZfomPClFaY10/pUfqRUK7cKOsk2jgTcjn+ymHvyabZkVXcOQf8 zHHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771862264; x=1772467064; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ds/RoTQe03K5D71BFLV3I6HxMYBKXTEWzKepx1kqI+E=; b=ULy9586DTFuPzrZHPcsmqirPwfCraNnksBmaBqr39RD7R5o+m7JAaQypvslo/PCXfE dh7C1N6/YTeTT9oqi2NJEFFZo0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a05:600c:8b31:b0:483:2c98:435e with SMTP id 5b1f17b1804b1-483a95ee684mr152402285e9.34.1771862263853; Mon, 23 Feb 2026 07:57:43 -0800 (PST) Message-ID: <4711b676-82f8-48ec-a7dd-5c33bc7cd967@suse.com> Date: Mon, 23 Feb 2026 16:57:44 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] tools/tests/x86_emulator: avoid duplicating loop body To: =?UTF-8?B?RWR3aW4gVMO2csO2aw==?= Cc: Andrew Cooper , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Anthony PERARD , xen-devel@lists.xenproject.org References: Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+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: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 23.02.2026 11:04, Edwin Török wrote: > clang would duplicate the loop body and end up with a double definition > of the symbol: > ``` > /tmp/test_x86_emulator-0f3576.s:27823: Error: symbol `vmovsh_to_mem' is already defined > /tmp/test_x86_emulator-0f3576.s:27825: Error: symbol `.Lvmovsh_to_mem_end' is already defined > ``` > > This is a valid transformation, that even GCC might do, see > https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile-1 which > says that `%=` should be used instead. However the C code here also > needs to know the name of the label, so I don't immediately see how to > solve that. > > For now mark the loop variable `volatile` to prevent the optimization as a > workaround. > (another way to fix this could be to move the loop body into a function, > but a compiler might inline it, or specialize it, leading to the same problem) Hmm, moving decl and asm() out of the loop wouldn't really work. One option would be to extend the long-pending [1] to also cover test_x86_emulator.c. Another might be to make the upper loop bound not a literal 2, but one loaded from memory, suitably arranged for the compiler to not be able to const-propagate the value. But I wonder how many other transformations the compiler could do, causing the same issue elsewhere. Maybe we need to overhaul how this instruction instantiation works. (I further wonder how many such issues are lurking in the many patches I have out for review, plus the yet further ones I didn't post yet to not pointlessly increase the pile.) > --- a/tools/tests/x86_emulator/test_x86_emulator.c > +++ b/tools/tests/x86_emulator/test_x86_emulator.c > @@ -5248,7 +5248,7 @@ int main(int argc, char **argv) > memset(res + 3, ~0, 8); > regs.eax = (unsigned long)res; > regs.ecx = ~0; > - for ( i = 0; i < 2; ++i ) > + for (volatile int i = 0; i < 2; ++i ) Even if we went with this as a workaround, style should please not be screwed up. Also, whichever the workaround, I think a comment wants leaving. And then I don't think it is a good idea to introduce a shadowing induction variable. Jan [1] https://lists.xen.org/archives/html/xen-devel/2023-04/msg00283.html