Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2983224pxa; Tue, 25 Aug 2020 08:23:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRwx1jsCF8ml3W1nzrw469O9KpXUbRi//5th/KAeA/RibqejWGv3Q7dbmJpB6d5vIsFXcA X-Received: by 2002:a17:906:1b04:: with SMTP id o4mr11764341ejg.332.1598369004103; Tue, 25 Aug 2020 08:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598369004; cv=none; d=google.com; s=arc-20160816; b=mPTOMJfH/yrUAxoFF0W9Ae/2bRRNds3Wp5CkmqnhxSnTiFQHmHTlh3ALymaMq2uC3t CNq/9R2a56dsQkFIIcZoh6oFPxMtZ/ozx1TV+XOjACDWNjWMLSdB7Swh4QFc+TTgC+bb e9JZQscfkEke3dumKxEAK3Y5QtMkWQ0NRYIAOY3vcIwu7ceGr55cQT6otk05spngacUs WBoFB1B+YOcy7f80zuwbqux83CC/iuagsSYCB2Q5iwGVCiiY4wo1VOr/sHv4fC6IsgX6 P0ya4iJNZimoUUt1HeMXNy7Q0aqMzYoDTzPt/15ySXDee68IjvaqZ6AyYl8OH8mgswUQ KR3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:dkim-signature; bh=fUzRthWoB95qJoATouB2WhM9wBqkFWmCuiCwuyo/jvo=; b=YhB+wg9bGujul3sy3rPVtCMiFYm3wAVZBF8sqPXtUctXUKzI2nnJxsXkT+3LnH1uQ5 CWqZLTtRuPxag+Ua/RwUnb90uwNJAAw9B1iTfgycATMnn3IxVzod+IdUZvv2zRQgP55Z BZpOSXmBEOL72XLEXSdvauqkPt3uYHeNSdsIR8umsExjpnR/TORf6V97h5ujJ6R6qeaV tzTGdYR5zseV86PlF8GmBly88FwxVQEyl/RXD99hJaI3uCXJjVwbD3rksQxtg9u/LdhT az+dpeJp2Z4nT91Sog0wJNx0lUNxO9YaujV0U4VVJ8XsG8I77OfzJb2/KwGSfMuCp9Fu szPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="j9EnQDL/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qp17si4997263ejb.3.2020.08.25.08.23.00; Tue, 25 Aug 2020 08:23:24 -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=pass header.i=@gmail.com header.s=20161025 header.b="j9EnQDL/"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726611AbgHYPWH (ORCPT + 99 others); Tue, 25 Aug 2020 11:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726096AbgHYPWE (ORCPT ); Tue, 25 Aug 2020 11:22:04 -0400 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0868C061574 for ; Tue, 25 Aug 2020 08:22:04 -0700 (PDT) Received: by mail-oi1-x243.google.com with SMTP id j7so11912771oij.9 for ; Tue, 25 Aug 2020 08:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=fUzRthWoB95qJoATouB2WhM9wBqkFWmCuiCwuyo/jvo=; b=j9EnQDL/9vRo7973OSxTeKsTHu3+YwVj4aspv8D6Td6creaRrVt2CPyO6KXxMod/U9 UWieCgngo2TqcsJC0G5crciN6vc0p90gRKfsue2kYacgwnxjTIWTJw958ndfrBcGd4JN OhTIMaez9f1m1FhwhW5ZDcqzxE+i5+Wsb3bIfhHuzSNG7ux1XFbsXRziOMGKKTzVzhDq gu8UrQ8/WNXxbpYCWOzkLUjfcVUUDGIOr6z9MuywHOakNJ7ByzhlJF5/0Dmzuwwtz+qC 7HINv95foLvXK/nz8ZWADrR/88N63yNYBXhxHAdiDt1IAN4rueXMXuLaJhLauQIXoeyP r0Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=fUzRthWoB95qJoATouB2WhM9wBqkFWmCuiCwuyo/jvo=; b=ZN6xg48YCkbgUXx/YV3WJ3YAHBKuyBDXYuVuB+MYyVwJkcKDR1Z8Ar/OkZgOSMZxGK hVRkUmJ34MHMA0WkWb5lny6F+ReG+aSuY8dVcOuMljC3hdb/tA7H2yU3MF7OKcb8KhQv qsoZM+oIomeWdH+Cz9Efr0rpHUVF+euopmu8pV8Om1lWJTO5tqGKFQzjBRj7kQwVljAg 6kFIaYjjWPn/nnPk2L2709YwXFRHecBp5TqqZbpD+pAt/xYzbF7q8QPKl84wi7x3dv21 PVDv5KkqeU8bnDIyzQDV1NRT9fnpZwZHBXb97vhPv5CTSEFlaC0tWKQ2B1rDtAkM2+FB 8NDQ== X-Gm-Message-State: AOAM531AP67VqOXlVs9ex7rz1hdiF2McrQjz2OXljhAtLsw1++l7OwDA Ihxy8Yn/jvGHPxandbmti1i+Ddutkh1CEJkShzU= X-Received: by 2002:a05:6808:311:: with SMTP id i17mr1403276oie.72.1598368924153; Tue, 25 Aug 2020 08:22:04 -0700 (PDT) MIME-Version: 1.0 References: <20200823011652.GA1910689@rani.riverdale.lan> <20200823212550.3377591-1-nivedita@alum.mit.edu> <20200825151910.GA786059@rani.riverdale.lan> In-Reply-To: <20200825151910.GA786059@rani.riverdale.lan> Reply-To: sedat.dilek@gmail.com From: Sedat Dilek Date: Tue, 25 Aug 2020 17:21:52 +0200 Message-ID: Subject: Re: [PATCH] x86/asm: Replace __force_order with memory clobber To: Arvind Sankar Cc: Miguel Ojeda , Linus Torvalds , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 25, 2020 at 5:19 PM Arvind Sankar wrote: > > 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. Thanks for taking care and your patch. I have tested this on top of Linux v5.9-rc2 with LLVM toolchain v11.0.0-rc2 (ThinLTO). Tested-by: Sedat Dilek - Sedat -