11.10Sriastrad/* $NetBSD: membar_ops.S,v 1.10 2025/09/06 02:53:21 riastradh Exp $ */ 21.1Sad 31.1Sad/*- 41.1Sad * Copyright (c) 2007 The NetBSD Foundation, Inc. 51.1Sad * All rights reserved. 61.1Sad * 71.1Sad * This code is derived from software contributed to The NetBSD Foundation 81.1Sad * by Jason R. Thorpe, and by Andrew Doran. 91.1Sad * 101.1Sad * Redistribution and use in source and binary forms, with or without 111.1Sad * modification, are permitted provided that the following conditions 121.1Sad * are met: 131.1Sad * 1. Redistributions of source code must retain the above copyright 141.1Sad * notice, this list of conditions and the following disclaimer. 151.1Sad * 2. Redistributions in binary form must reproduce the above copyright 161.1Sad * notice, this list of conditions and the following disclaimer in the 171.1Sad * documentation and/or other materials provided with the distribution. 181.6Sriastrad * 191.1Sad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sad * POSSIBILITY OF SUCH DAMAGE. 301.1Sad */ 311.1Sad 321.1Sad#include "atomic_op_asm.h" 331.1Sad 341.1Sad .text 351.1Sad 361.7Sriastrad/* 371.7Sriastrad * These assume Total Store Order (TSO), which may reorder 381.8Sriastrad * store-before-load but nothing else. Hence, only membar_sync (and 391.8Sriastrad * its deprecated alias membar_enter) must issue anything -- namely, 401.8Sriastrad * membar #StoreLoad. 411.7Sriastrad * 421.7Sriastrad * If we ran with Partial Store Order (PSO), we would also need to 431.7Sriastrad * issue membar #StoreStore for membar_exit (load/store-before-store) 441.7Sriastrad * and membar_producer (store-before-store). 451.7Sriastrad */ 461.1Sad 471.9SriastradENTRY(_membar_acquire) 481.1Sad retl 491.1Sad nop 501.9SriastradEND(_membar_acquire) 511.9SriastradATOMIC_OP_ALIAS(membar_acquire,_membar_acquire) 521.9Sriastrad 531.9SriastradENTRY(_membar_release) 541.9Sriastrad retl 551.9Sriastrad nop 561.9SriastradEND(_membar_release) 571.9SriastradATOMIC_OP_ALIAS(membar_release,_membar_release) 581.1Sad 591.7SriastradENTRY(_membar_sync) 601.7Sriastrad /* 611.7Sriastrad * Some SPARC CPUs have errata with MEMBAR in the delay slot of 621.7Sriastrad * a branch, such as the UltraSPARC-IIi: 631.7Sriastrad * 641.7Sriastrad * `Apparently, the deadlock is most easily caused if the 651.7Sriastrad * delay slot of the JMPL is a MEMBAR #Sync, or any 661.7Sriastrad * instruction that synchronizes on the load or store 671.7Sriastrad * buffers being empty.' 681.7Sriastrad * 691.7Sriastrad * UltraSPARC-IIi User's Manual, Part No. 805-0087-01, Sun 701.7Sriastrad * Microsystems, October 1997, Appendix K.2 `Errata 711.7Sriastrad * Created by UltraSPARC-I', Erratum 51, p. 476. 721.7Sriastrad * https://www.oracle.com/technetwork/server-storage/sun-sparc-enterprise/documentation/sparc-2i-usersmanual-2516677.pdf#page=518 731.7Sriastrad * 741.7Sriastrad * So let's avoid doing that. 751.10Sriastrad * 761.10Sriastrad * Sync with paravirt_membar_sync in 771.10Sriastrad * sys/arch/sparc64/sparc64/locore.s. 781.7Sriastrad */ 791.7Sriastrad membar #StoreLoad 801.1Sad retl 811.3Sad nop 821.7SriastradEND(_membar_sync) 831.9SriastradATOMIC_OP_ALIAS(membar_sync,_membar_sync) 841.1Sad 851.9SriastradATOMIC_OP_ALIAS(membar_producer,_membar_release) 861.9SriastradSTRONG_ALIAS(_membar_producer,_membar_release) 871.9SriastradATOMIC_OP_ALIAS(membar_consumer,_membar_acquire) 881.9SriastradSTRONG_ALIAS(_membar_consumer,_membar_acquire) 891.8SriastradATOMIC_OP_ALIAS(membar_enter,_membar_sync) 901.8SriastradSTRONG_ALIAS(_membar_enter,_membar_sync) 911.9SriastradATOMIC_OP_ALIAS(membar_exit,_membar_release) 921.9SriastradSTRONG_ALIAS(_membar_exit,_membar_release) 93