From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A006B1F5AE for ; Mon, 3 Aug 2020 16:05:30 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBC68386181D; Mon, 3 Aug 2020 16:05:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBC68386181D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1596470728; bh=qracm5hKNGhyJKbBGscnoMg3rLZJoO0MdoR5qKkemm0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=f1ir8RO7RVsl4E8qjO+pPgSpci8m1whGZMd4NLsamkUduubqAfka5PJbayg1LoIHX Iy+3Nq8rfNT8qZW7FGqlDzXudfwgO0cadEpgJifk735BA+tpNGLWcS43FnWZ6WsMtK sKb8UFHG+tdsE1yfMRDHd5TvoVpqeVtA06auaHno= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 47BAE3858D35 for ; Mon, 3 Aug 2020 16:05:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 47BAE3858D35 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-147-GiTlzlBkNO6ZwKKoY-IxGg-1; Mon, 03 Aug 2020 12:05:23 -0400 X-MC-Unique: GiTlzlBkNO6ZwKKoY-IxGg-1 Received: by mail-qk1-f198.google.com with SMTP id h185so26404114qke.21 for ; Mon, 03 Aug 2020 09:05:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=qracm5hKNGhyJKbBGscnoMg3rLZJoO0MdoR5qKkemm0=; b=tH6zNIsOJleL5KNPZC8grzlTsq9XvIZtp3BfPTEmOOZHj049wRDbQdyse1pGtKtr9u MkeXW+BZEgWDUP0v2JzRC4+aemhZxTz8VaOIox84m8IjnIPTMn44mh+eQe3PItbHifLC 8kFmH24ucvECTANhLoc8/xHIS1SSct0AbWlEnxZG5gNznrRfM7v168ItfwA5fx/fdT3c XY74kgZFRP8XGJaAcl4nFmpyZBsrpiRXLGC7YSONT92I5qPaFaT4bL4gljSSJkCOUx2Z Zrh+ge4sfj2++T3gNes6TVkINrQahJ5BW5hNPMA+cdGk00pr5/eNOUMSmR4rGx1b2AZO JVWA== X-Gm-Message-State: AOAM533AbLdd7BvRk274wr1Mj6zT1Yu76Rj4Tvdy3jx9QTjFNW2kj7V8 l4nHggkgijHk4y8rRVmck+7LH5BdzhpqEPQ3PfuLEwC3P0bMCylax90x0tY3XQXTRxI+Be7Hg7s AaTD82PPLlxk57EbAxGVs X-Received: by 2002:a0c:ea8e:: with SMTP id d14mr17306936qvp.37.1596470723041; Mon, 03 Aug 2020 09:05:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1vq65bss7cCke5yIAoydK4payXjewtSVsqEfyp0D7lGZ+qpNu7OJHoBMxZIyREVX/KNYf0Q== X-Received: by 2002:a0c:ea8e:: with SMTP id d14mr17306919qvp.37.1596470722809; Mon, 03 Aug 2020 09:05:22 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id e23sm19912123qto.15.2020.08.03.09.05.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Aug 2020 09:05:21 -0700 (PDT) Subject: Re: [PATCH] powerpc: Fix incorrect cache line size load in memset (bug 26332) To: Florian Weimer , libc-alpha@sourceware.org References: <87wo2g8639.fsf@oldenburg2.str.redhat.com> Organization: Red Hat Message-ID: <31303210-1cf1-d201-68d7-e119bbe439d1@redhat.com> Date: Mon, 3 Aug 2020 12:05:20 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <87wo2g8639.fsf@oldenburg2.str.redhat.com> Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Carlos O'Donell via Libc-alpha Reply-To: Carlos O'Donell Cc: Tulio Magno Quites Machado Filho Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On 8/3/20 4:51 AM, Florian Weimer wrote: > __GLRO loaded the word after the requested variable on big-endian > PowerPC, where LOWORD is 4. This can cause the memset implement > go wrong because the masking with the cache line size produces > wrong results, particularly if the loaded value happens to be 1. > > The __GLRO macro is not used in any place where loading the lower > 32-bit word of a 64-bit value is desired, so the +4 offset is always > wrong. Agreed. I reviewed sysdeps/powerpc/powerpc32/sysdep.h, and: sysdeps/powerpc/powerpc32/power4/multiarch/init-arch.h sysdeps/powerpc/powerpc32/sysdep.h sysdeps/powerpc/powerpc32/memset.S sysdeps/powerpc/powerpc32/a2/memcpy.S I see only 32-bit word accesses and so the +4 offset is wrong. This was likely just a copy-and-paste that came from similar code which accesses the 64-bit HWCAP/HWCAP2 e.g. uint64_t _dl_hwcap. The 64-bit sysdeps/powerpc/powerpc64/sysdep.h is different and doesn't have this problem for obvious reasons (it can load a 64-bit value). > Fixes commit 18363b4f010da9ba459b13310b113ac0647c2fcc > ("powerpc: Move cache line size to rtld_global_ro") and bug 26332. Reviewed-by: Carlos O'Donell > --- > sysdeps/powerpc/powerpc32/sysdep.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h > index 2ba009e919..829eec266a 100644 > --- a/sysdeps/powerpc/powerpc32/sysdep.h > +++ b/sysdeps/powerpc/powerpc32/sysdep.h > @@ -179,8 +179,8 @@ GOT_LABEL: ; \ > #else > /* Position-dependent code does not require access to the GOT. */ > # define __GLRO(rOUT, rGOT, member, offset) \ > - lis rOUT,(member+LOWORD)@ha; \ > - lwz rOUT,(member+LOWORD)@l(rOUT) > + lis rOUT,(member)@ha; \ > + lwz rOUT,(member)@l(rOUT) OK. > #endif /* PIC */ > > #endif /* __ASSEMBLER__ */ > -- Cheers, Carlos.