Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp560004imm; Mon, 2 Jul 2018 17:20:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCIQ9lNYwY1PCL3c27FhlcZLl5HGJMwufvOxC+SG2hgrYeF4XnZBoLKJa+F/G/vgyP+5v0 X-Received: by 2002:a63:82c7:: with SMTP id w190-v6mr23538549pgd.253.1530577214199; Mon, 02 Jul 2018 17:20:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530577214; cv=none; d=google.com; s=arc-20160816; b=h7E7WfWyCQTGnw7/WKcPAWJckzp55Zfi9bZCav6xkAnQUeCYEJ8E6eQ9Nwcd6Z8gn3 +1DBNBMatEHcynTHwtnKBfH7j9ISCHPadLqSk2fsHJkH2iWKNj03UQhq2TkJm8I6O5Js UvMqaYuv/GwvbBqluNgFIRYlb7TSsTjLVToyk8EdEUfeBXqpzUCtPjDLtFmRnSrpDH+y mpb7Dkfm7fOVsiCQr6IGiCqMSoPywt/ScoWvIUl4Re58VG/F4qoms1MFCPbx2eI+6StE SE7HSk2vMy/ThgrFvK2NGAf0LJ1/KWMSfm/BnUuLrR4RTNxWyw2WGPi78fxYANnngBDH AiiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=RQU1jAGk60ABGvTib7k+xOaAi4kPSl51pi+dTRI2Ga8=; b=uilBVOpNi/Q2cGdi9VPRl4+InjOcWlisNkZnVsZM4BpsYXeHy55qS7EMikV+9GEXyH YIGa4yyH+6vHhKx5TT8Jf2Rodke+97/SmfA5EaK625NPyHKBgrwaTp1PHz76a11o/W6t SRuct5cewCvvO2ggpnDUX3BnjERta16LfV05njmonRWwVWueVHafI5k+48Vvha2M2hwL VVyhN6DGtZwQgkQvOuMPY8I4UaYbL/EooIPBgb046xcvh4O6NdNg0nsYvH9OjlS7I/Rj kpBsOy9tG0sx39HTKwLYojf50T2lRg9hH22lN+ZqxYpl+cGxY+hlgmBFd/fhhx+hBXU/ WLaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=KrLv1eou; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j129-v6si15234778pgc.186.2018.07.02.17.19.57; Mon, 02 Jul 2018 17:20:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazonses.com header.s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug header.b=KrLv1eou; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752819AbeGCATS (ORCPT + 99 others); Mon, 2 Jul 2018 20:19:18 -0400 Received: from a9-99.smtp-out.amazonses.com ([54.240.9.99]:53894 "EHLO a9-99.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752185AbeGCATQ (ORCPT ); Mon, 2 Jul 2018 20:19:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ug7nbtf4gccmlpwj322ax3p6ow6yfsug; d=amazonses.com; t=1530577155; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=RQU1jAGk60ABGvTib7k+xOaAi4kPSl51pi+dTRI2Ga8=; b=KrLv1eouBFXt3uEaesSE2ICRg8N6YbAnQpa3nRsv7jP3jV+kjOgQ9I6uMvQFDDEJ jAausQocx7BL1mwcNy0IMeCZfKD/OpZkZrfateqCpiM+uUYmjMtPkQuR2UT4RBKkW7V urKf8Bipvb4dWyKuIkWwgVfVaq/MqKvTpkZKszq4= Date: Tue, 3 Jul 2018 00:19:15 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Mathieu Desnoyers cc: Linus Torvalds , Thomas Gleixner , linux-kernel , linux-api , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Andy Lutomirski , Dave Watson , Paul Turner , Andrew Morton , Russell King , Ingo Molnar , "H. Peter Anvin" , Andi Kleen , Ben Maurer , rostedt , Josh Triplett , Catalin Marinas , Will Deacon , Michael Kerrisk , Joel Fernandes Subject: Re: [RFC PATCH for 4.18] rseq: use __u64 for rseq_cs fields, validate user inputs In-Reply-To: <825871008.10839.1530573419561.JavaMail.zimbra@efficios.com> Message-ID: <010001645d81f652-8a506dd2-cd49-47f9-950a-24ef52bda9f7-000000@email.amazonses.com> References: <20180702223143.4663-1-mathieu.desnoyers@efficios.com> <415287289.10831.1530572418907.JavaMail.zimbra@efficios.com> <825871008.10839.1530573419561.JavaMail.zimbra@efficios.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2018.07.03-54.240.9.99 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2 Jul 2018, Mathieu Desnoyers wrote: > Are there any kind of guarantees that a __u64 update on a 32-bit architecture > won't be torn into something daft like byte-per-byte stores when performed > from C code ? > > I don't worry whether the upper bits get updated or how, but I really care > about not having store tearing of the low bits update. Platforms with 32 bit word size only guarantee atomicity of a 32 bit write or RMV instruction. Special instructions may exist on a platform to perform 64 bit atomic updates. We use cmpxchg64 f.e. on Intel 32 bit platforms to guarantee atomicity8. So use the macros that we have to guarantee 64 bit ops and you should be fine. See linux/arch/x86/include/asm/atomic64_32.h