From owner-svn-src-all@freebsd.org Thu Oct 5 12:16:46 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C0FD5E370E2; Thu, 5 Oct 2017 12:16:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E97F6E86D; Thu, 5 Oct 2017 12:16:46 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v95CGjB9035746; Thu, 5 Oct 2017 12:16:45 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v95CGjoe035745; Thu, 5 Oct 2017 12:16:45 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710051216.v95CGjoe035745@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 5 Oct 2017 12:16:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324307 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 324307 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Oct 2017 12:16:46 -0000 Author: kib Date: Thu Oct 5 12:16:45 2017 New Revision: 324307 URL: https://svnweb.freebsd.org/changeset/base/324307 Log: Complete r323772 on amd64. Compilers are allowed to combine plain reads into group operations, e.g. 64bit element copies of one array into another can be legitimately optimized back to a memcpy() call, which r323772 tried to prevent. Qualify accesses to LDT descriptors with volatile dereference to ensure that each write indeed occurs. After that, our usual claim of native-size aligned writes being atomic applies. This is equivalent to atomic_store(memory_order_relaxed) C11 accesses, but our machine/atomic.h does not provide corresponding primitive. Noted and reviewed by: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/amd64/amd64/sys_machdep.c Modified: head/sys/amd64/amd64/sys_machdep.c ============================================================================== --- head/sys/amd64/amd64/sys_machdep.c Thu Oct 5 12:07:38 2017 (r324306) +++ head/sys/amd64/amd64/sys_machdep.c Thu Oct 5 12:16:45 2017 (r324307) @@ -616,7 +616,7 @@ amd64_set_ldt(struct thread *td, struct i386_ldt_args return (EINVAL); mtx_lock(&dt_lock); for (i = uap->start; i < largest_ld; i++) - ((uint64_t *)(pldt->ldt_base))[i] = 0; + ((volatile uint64_t *)(pldt->ldt_base))[i] = 0; mtx_unlock(&dt_lock); return (0); } @@ -734,15 +734,15 @@ amd64_set_ldt_data(struct thread *td, int start, int n { struct mdproc *mdp; struct proc_ldt *pldt; - uint64_t *dst, *src; + volatile uint64_t *dst, *src; int i; mtx_assert(&dt_lock, MA_OWNED); mdp = &td->td_proc->p_md; pldt = mdp->md_ldt; - dst = (uint64_t *)(pldt->ldt_base); - src = (uint64_t *)descs; + dst = (volatile uint64_t *)(pldt->ldt_base); + src = (volatile uint64_t *)descs; for (i = 0; i < num; i++) dst[start + i] = src[i]; return (0);