From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SUBJ_OBFU_PUNCT_FEW autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id 472937e1 for ; Wed, 22 Jan 2020 14:46:35 +0000 (UTC) Received: (qmail 26101 invoked by uid 550); 22 Jan 2020 14:46:33 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 26083 invoked from network); 22 Jan 2020 14:46:33 -0000 Date: Wed, 22 Jan 2020 09:46:20 -0500 From: Rich Felker To: =?utf-8?B?THXDrXM=?= Marques Cc: musl@lists.openwall.com Message-ID: <20200122144620.GA30412@brightrain.aerifal.cx> References: <20200115132438.5809-1-luismarques@lowrisc.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: Rich Felker Subject: Re: [musl] Re: [PATCH] Fix RISC-V a_cas inline asm operand sign extension On Wed, Jan 22, 2020 at 02:31:25PM +0000, Luís Marques wrote: > On Wed, Jan 15, 2020 at 1:33 PM Luís Marques wrote: > > This patch adds an explicit cast to the int arguments passed to the inline asm > > used in the RISC-V's implementation of `a_cas`, to ensure that they are properly > > sign extended to 64 bits. They aren't automatically sign extended by Clang, and > > GCC technically also doesn't guarantee that they will be sign extended. > > Does anyone have any feedback regarding this patch? > If not, perhaps it could be merged? Thanks for pinging this again. It's unfortunate that clang doesn't do this right to begin with, but the patch is not terribly ugly and probably okay. Can you clarify why it's needed and why sign-extending is the right thing to do, though? Does lr.w sign-extend the loaded value (vs zero-extend or something else)? Rich