Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2982786pxa; Tue, 25 Aug 2020 08:22:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/38W2JViZOyJ/nO40qr3shHv1pGG9qyjyXOOZy6BhKKprlhh14RJw4kVsmpY14lFKMruz X-Received: by 2002:a17:906:e28d:: with SMTP id gg13mr6017468ejb.96.1598368970416; Tue, 25 Aug 2020 08:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598368970; cv=none; d=google.com; s=arc-20160816; b=Mws+BrsqXjSrQo90zCOZKTwFYrHHxkTfp6U1L64HE2GJ7ClFqeMd+IhL75OeW1p6wj gVuHT2TQSpunRAac3ZnIIMHSlP4CiTHXBHQQqvyxGNyaRNwhhJwLawjKbV5BomkCsCn0 6JQN5uSB76HgSQJ0D0vvq9DlUGnu5aHu3CsikkGtqQY/XQH5oPaLiVnnSsrg5m/zSPnB GJGif8J6ykO6O9ty3mCQ/gO1ZcCRPfuC4awh+Wn8/NO8MgMXc6s4bqPGfPdGzPiAhSnO 7RlJTyJqyo7oqzSBXqY+BCkpLXVzLS3STq/deR+FhGMhwMgOEkapusxev2gkCglNhgff BNYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date:from :dkim-signature; bh=brmows/DN8FB52grSh/oKVF6r30vBH02XnLaZne+j6g=; b=wK47lIa3Nk6h1RYA+tWvJr/yTsWiGFomLaNu9xdFDeG1MKx5L62AMuxfVHWx/PY3zT Edr0DA/mP9a7/Ti9lHYrFgc1VH0fVfXMxjsYT/E6qMYnYgmIUrabmbSUisuYPwJgwZc4 vTpCzwKDzsxEw5nbBQf6X4LxGVARmVgU9TIq75uk3WYDv4/JvpaDt2lhDjfPe/tu8Cqk 8v5iyQUhNJWXXW5zRHRhKFsOdvmYJBvyAVgjhEJin3Dv9T4w0NYbBq5xvo0u8avU07ku 9tSm+bmI2qFqSULL5YatmfFseO3SRpFnZr+WHsGXqO9DHqJnx/Xv+ffopOmGkUEFbQNq Xk7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KXJTaoxh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g22si8989880edp.305.2020.08.25.08.22.27; Tue, 25 Aug 2020 08:22:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KXJTaoxh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbgHYPTU (ORCPT + 99 others); Tue, 25 Aug 2020 11:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbgHYPTO (ORCPT ); Tue, 25 Aug 2020 11:19:14 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 618D5C061574 for ; Tue, 25 Aug 2020 08:19:14 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id k20so5643819qtq.11 for ; Tue, 25 Aug 2020 08:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=brmows/DN8FB52grSh/oKVF6r30vBH02XnLaZne+j6g=; b=KXJTaoxhiqydETO8U5CeanAxKKm7Mei1X7IRqJmq3HIDSPh21lhkFhNVY1kJPZBxN7 66QT0QlHVj04ubc6k0t5ymew7vwGqhWs7i1WvChHnllaka0obVnhLGzcfnbKYKbdxC2Y wicQCkKFdpcJZiHbidS/yyHZsk5Y+OZ3aqi6Fm8uKdJMnONtst1DLYF31Zz96QGXr97X kairB7r2gx7dh1IYqN/v4mYoWkTSuejp/63vAHtcJ03JnOMArtvcck8Jh98dUwlm1CnZ nZxWzvE7SYIsYWSRyipLwq2NegNY6KKjHNcoyWXYW2VYzKdC6J8R4pwpwKQw8HcfP+Th yE5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=brmows/DN8FB52grSh/oKVF6r30vBH02XnLaZne+j6g=; b=e87K2cVF5ITcZVTCSFIUCc41EQFjhkbalml6t8OBJJGnMIdDmBrnIoHQOmvr8mHdDz LKtk9eJBaXKcSys19XIsOgoM1Xf4gAYZ/I64fnuYSd/oXWngDS6d7jZF8SsxefJCiZWq yttxL7V1Wl98c5vRMKdfrJ4bro7nVOFvPvE3qFrUgdl8Al9YDfk8usVN31gSY0X5kILH kIM8ppIgsxotw3e0EmSVGpl9zGatl6Qz6ya9d7CbBPDw7KMYGUg9yK1LfRUZlZtvp5DW QPfzSq7ddEkO1M+/q6WcoURpesS0knfZZpfVXmocIlAhqEJnjgFslsnW/5qMW9vXBhYD wnGg== X-Gm-Message-State: AOAM530LYMmkd4TDP2onOoLtiXzKQwWAxcIvJ3TWWTF3OoMpmWxh7AK4 B+pIo+JbVPqJPrzKFML5UZcnYAFT+wRoQg== X-Received: by 2002:ac8:614b:: with SMTP id d11mr9820027qtm.271.1598368753547; Tue, 25 Aug 2020 08:19:13 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id x57sm13726902qtc.61.2020.08.25.08.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 08:19:12 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Tue, 25 Aug 2020 11:19:10 -0400 To: Miguel Ojeda Cc: Arvind Sankar , Linus Torvalds , Sedat Dilek , Segher Boessenkool , Thomas Gleixner , Nick Desaulniers , "Paul E. McKenney" , Ingo Molnar , Arnd Bergmann , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "Kirill A. Shutemov" , Kees Cook , Peter Zijlstra , Juergen Gross , Andy Lutomirski , Andrew Cooper , LKML , clang-built-linux , Will Deacon Subject: Re: [PATCH] x86/asm: Replace __force_order with memory clobber Message-ID: <20200825151910.GA786059@rani.riverdale.lan> References: <20200823011652.GA1910689@rani.riverdale.lan> <20200823212550.3377591-1-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 24, 2020 at 09:13:34PM +0200, Miguel Ojeda wrote: > Hi Arvind, > > On Sun, Aug 23, 2020 at 11:25 PM Arvind Sankar wrote: > > > > - Using a dummy input operand with an arbitrary constant address for the > > read functions, instead of a global variable. This will prevent reads > > from being reordered across writes, while allowing memory loads to be > > cached/reordered across CRn reads, which should be safe. > > Assuming no surprises from compilers, this looks better than dealing > with different code for each compiler. > > > Signed-off-by: Arvind Sankar > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82602 > > A lore link to the other discussion would be nice here for context. > Ok. > > + * The compiler should not reorder volatile asm, however older versions of GCC > > + * had a bug (which was fixed in 8.1, 7.3 and 6.5) where they could sometimes > > I'd mention the state of GCC 5 here. > Ok. > > + * reorder volatile asm. The write functions are not a problem since they have > > + * memory clobbers preventing reordering. To prevent reads from being reordered > > + * with respect to writes, use a dummy memory operand. > > */ > > -extern unsigned long __force_order; > > + > > Spurious newline? > This was intentional, but I can remove it if people don't like the extra whitespace. I'll wait a few days for additional review comments before sending v2. Thanks.