Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp992763rdf; Sat, 4 Nov 2023 02:35:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdOrKotxunPKs6aXu4KyZm5nIciNH4IR1ygx68U8RWNrs4XMgK8wNucihR8Lar03KSw4Xu X-Received: by 2002:a92:c24f:0:b0:357:f5d4:9b12 with SMTP id k15-20020a92c24f000000b00357f5d49b12mr30518503ilo.15.1699090510020; Sat, 04 Nov 2023 02:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699090509; cv=none; d=google.com; s=arc-20160816; b=aAlmpcNvF/2yC4Uso+jrDK923SSo5ObZ5oG9Y3aut/tpBgREIZxdn0F0uS3pusJxDw /+KmURcp6Md2MSx0r2VnK/xLCPw0pFfOd/Qigxai+RJchmNKrKq+A/X/l3jzoGOHWeSa dCjhisKORTgeAnONmDG2OcuMfvSQO8ZloLhGPSwgeto+6mYIofmdY1L4fntAlpHGpgmF TqHtCfV9ZP6JUQbdXoqsHRu8MfOSCuWJK0aqP0k+pFf9ix0vdhIjZS1WiwEQEN9qtNQS NtjsZfrzZOgb2ql1Vk2JIuLaOL1XhV3++PQPQY2aRoYNAqjuKVbaiB33WJmGxnT2qB3g krPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=eSsP2TtrUBuOndSpVCpWzoP2DzEg/3kW/H18CZfJeOk=; fh=Ymw4Wzb3OfNO//L8gueQsOknzArJ0iRsxWlauiREWrs=; b=Myh/7jFhR9Bnz/1auY6/jGOvsQlZHBrsfgIE7IqhQgctmvyW1l3PZqc23vQ86uUHec AhEhhQ11K+O86Vg0kpj1s/myWvvdqf7oWJOoqWQtch45JQKM3OUS1D5YXTSielRqJGhf F9HuaAwc+qCNBn+W9VPDttXH0kvi+pRVqE+18WO5TDNCHGXvRJLEgSehVdWCthj17vg5 j7UluU7jlgmxwmrLnvcC29eFYASQzhpSIar/piRvnk4+arqQZIoQmD4KgsbxoRJFj3ZR guFOP/OdeCizwV4e/j9YTdlPiy3x8ouL+Q0zQ4qabO6eXs3Sv97RJcpOVOMy12LCLc6O bgDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id i2-20020a635402000000b005b96af23fe6si3361723pgb.284.2023.11.04.02.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 02:35:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0A3F6803E494; Sat, 4 Nov 2023 02:35:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231513AbjKDJfF (ORCPT + 99 others); Sat, 4 Nov 2023 05:35:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbjKDJfE (ORCPT ); Sat, 4 Nov 2023 05:35:04 -0400 Received: from www.kot-begemot.co.uk (ns1.kot-begemot.co.uk [217.160.28.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42038D51 for ; Sat, 4 Nov 2023 02:35:00 -0700 (PDT) Received: from [192.168.17.6] (helo=jain.kot-begemot.co.uk) by www.kot-begemot.co.uk with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qzD3H-005Hsg-R6; Sat, 04 Nov 2023 09:34:48 +0000 Received: from madding.kot-begemot.co.uk ([192.168.3.98]) by jain.kot-begemot.co.uk with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qzD3C-00AsqC-1V; Sat, 04 Nov 2023 09:34:47 +0000 Message-ID: Date: Sat, 4 Nov 2023 09:34:42 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: Missing clobber on alternative use on Linux UM 32-bit To: Nadav Amit , Richard Weinberger , linux-um@lists.infradead.org Cc: Thomas Gleixner , Linux Kernel Mailing List , Peter Zijlstra References: <24BD0906-C6FE-499C-9A4A-00C56E6EE84A@gmail.com> Content-Language: en-US From: Anton Ivanov In-Reply-To: <24BD0906-C6FE-499C-9A4A-00C56E6EE84A@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -2.0 X-Spam-Score: -2.0 X-Clacks-Overhead: GNU Terry Pratchett X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sat, 04 Nov 2023 02:35:09 -0700 (PDT) On 04/11/2023 09:25, Nadav Amit wrote: > I was reading (again) the x86 C macro of “alternative()” and I was a bit > surprised it does clobber the flags (“cc”) as a precaution. > > #define alternative(oldinstr, newinstr, ft_flags) \ > asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, ft_flags) : : : "memory") > > Actually there seems to be only one instance of problematic cases - in um/32-bit: > > #define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2) > #define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2) > #define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM) > > Presumably, if XMM or XMM2 are not supported, there would be instances where addl > would be able to change eflags arithmetic flags without the compiler being aware > of it. > > As it only affects 32-bit Linux UM - I don’t easily have an environment to test > the fix. An alternative (word-pun unintended) is to add “cc” as a precaution > to the alternative macro. > > > _______________________________________________ > linux-um mailing list > linux-um@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-um Application alternatives in um is presently a NOP. It always uses the "blunt and heavy instrument" - the most conservative option. It is on the TODO list. -- Anton R. Ivanov https://www.kot-begemot.co.uk/