From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1987 invoked by alias); 12 Sep 2017 13:57:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 1631 invoked by uid 89); 12 Sep 2017 13:57:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=artifact X-HELO: mx0a-001b2d01.pphosted.com Subject: Re: [PATCH] powerpc: Use aligned stores in memset From: Steven Munroe Reply-To: munroesj@linux.vnet.ibm.com To: Zack Weinberg Cc: Florian Weimer , Rajalakshmi Srinivasaraghavan , GNU C Library In-Reply-To: References: <1503033107-20047-1-git-send-email-raji@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 12 Sep 2017 13:57:00 -0000 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17091213-0004-0000-0000-000012E93AF3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007711; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000227; SDB=6.00915962; UDB=6.00459915; IPR=6.00696194; BA=6.00005587; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017124; XFM=3.00000015; UTC=2017-09-12 13:57:30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17091213-0005-0000-0000-0000840F2867 Message-Id: <1505224647.12360.24.camel@oc7878010663> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-12_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709120195 X-SW-Source: 2017-09/txt/msg00496.txt.bz2 On Tue, 2017-09-12 at 08:18 -0400, Zack Weinberg wrote: > On Tue, Sep 12, 2017 at 6:30 AM, Florian Weimer wrote: > > > > I could not find the manual which has the requirement that the mem* > > functions do not use unaligned accesses. Unless they are worded in a > > very peculiar way, right now, the GCC/glibc combination does not comply > > with a requirement that memset & Co. can be used for device memory access. > > mem* are required to behave as-if they access memory as an array of > unsigned char. Therefore it is valid to give them arbitrarily > (un)aligned pointers. The C abstract machine doesn't specifically > contemplate the possibility of a CPU that can do unaligned word reads > but maybe not to all memory addresses, but I would argue that if there > is such a CPU, then mem* are obliged to cope with it. > > > ...the current glibc > > implementation accesses locations which are outside the specified object > > boundaries. > > I think that's technically a defect. Nothing in the C standard > licenses it to do that; we just get away with it because, on the > implementations to date, it's not observable (unless you go past the > end of a page, which you'll note there are a bunch of tests to ensure > we don't do). If an over-read by a single byte is observable, then > mem* is not allowed to do that. > Also a bit of over reaction. As long a the library routine does no cause a visible artifact (segfault or alignment check) aligned access before or after the requested start address and length is an optimization. For example accessing the source at offset 3 and length 10 with an aligned quadword load is Ok as long I clear the leading and trailing bytes. But attempting to store 7 bytes within a quadword by merging bytes in a register and storing the whole quadword would violate single copy atomicity and is not allowed. > zw >