From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D7E3C2D0DC for ; Wed, 1 Jan 2020 09:47:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A4882073D for ; Wed, 1 Jan 2020 09:47:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="iOuTX6vX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725790AbgAAJrS (ORCPT ); Wed, 1 Jan 2020 04:47:18 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:39895 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbgAAJrS (ORCPT ); Wed, 1 Jan 2020 04:47:18 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id bd1be872; Wed, 1 Jan 2020 08:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=mime-version :references:in-reply-to:from:date:message-id:subject:to:cc :content-type; s=mail; bh=f4mgsSbWhcX4nb7z42nkbcoWQxI=; b=iOuTX6 vXDXalEy4fj2MK3JPzn4z1XtUrC7p+tzNZ6YaTqvuibNZZN83SNrnnoMrDAkEaTr vfClH+1tOZlQDkWKrKffSwI9FDTPbAYrEh8j8XxHa6IkoFjbWeNidMqVo84F41s4 Ff7p72Tl9YSoqEMRZbQkb0yNejek/TKQBM1/pHpB3qvfN9Ecz5P1+feFkIwn8lnX iNq86kR3cNi0+wcxbrCwirwtZYwnd0eZpOClk9fpO2o2912GvTCXsOH4dZmbMUfk zqgeMjZQsZ3nec14r+4mkhRB1zoXShLERiSRtxjv4XQGYqSaXwBN9UIbyDhhaok/ 2n+KkxuYds3CVFKw== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4ae2b616 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Wed, 1 Jan 2020 08:48:55 +0000 (UTC) Received: by mail-ot1-f48.google.com with SMTP id k8so35773047otl.13; Wed, 01 Jan 2020 01:47:16 -0800 (PST) X-Gm-Message-State: APjAAAWgtoic/A8xMvPvm3w2t210Z4KggP5i/d+SbdNyVa20mC1h9Hen 6qF0SW2+ll3DT7ea8oQkBGlI7sEB/qKTJu0Cg1I= X-Google-Smtp-Source: APXvYqyIGS/wGj0v8cKxqgpqX78Pmba4r9awIczCf4DM7aqu48j7WnOiSxJVH0qsSeYGd1jM3RtIAnq5f01SqVXXCsg= X-Received: by 2002:a9d:674f:: with SMTP id w15mr87300086otm.243.1577872035434; Wed, 01 Jan 2020 01:47:15 -0800 (PST) MIME-Version: 1.0 References: <20200101041056.xionott76qbrffih@lantea.localdomain> In-Reply-To: <20200101041056.xionott76qbrffih@lantea.localdomain> From: "Jason A. Donenfeld" Date: Wed, 1 Jan 2020 10:47:04 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mips: vdso: conditionalize 32-bit time functions on COMPAT_32BIT_TIME To: Paul Burton Cc: Arnd Bergmann , "linux-kernel@vger.kernel.org" , "open list:BROADCOM NVRAM DRIVER" , Vincenzo Frascino , Christian Brauner Content-Type: text/plain; charset="UTF-8" Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org On Wed, Jan 1, 2020 at 5:08 AM Paul Burton wrote: > > Hi Jason, > > On Tue, Dec 31, 2019 at 05:14:41PM +0100, Jason A. Donenfeld wrote: > > Here's a "one click" reproducer: > > https://data.zx2c4.com/mips-musl-libc-weird-crash-time32-compat.tar.xz > > > > Untar that and hit `make -j$(nproc)`, and you'll get a freshly built > > and crashing kernel+userland. > > Thanks for the test case. It seems like the VDSO code isn't saving & > restoring $gp/$28, even though it's meant to be callee-saved in both the > n32 & n64 ABIs. With some digging I found that the below seems to > resolve the issue. Could you check whether it works for you? > > I'm still not quite sure *why* this happens; perhaps GCC just decides it > doesn't need to save & restore $gp/$28 when it spots that it's being > "used" for __current_thread_info (even though that's never actually > referenced in the VDSO)? > > Just moving the declaration of __current_thread_info inside the > current_thread_info() function seems to do the trick too, and is > probably a bit neater. > > Thanks, > Paul > > --- > diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h > index 4993db40482c..ac33959bbb1f 100644 > --- a/arch/mips/include/asm/thread_info.h > +++ b/arch/mips/include/asm/thread_info.h > @@ -50,7 +50,11 @@ struct thread_info { > } > > /* How to get the thread information struct from C. */ > +#ifdef __VDSO__ > +register struct thread_info *__current_thread_info __asm__("$0"); > +#else > register struct thread_info *__current_thread_info __asm__("$28"); > +#endif > > static inline struct thread_info *current_thread_info(void) > { Holy guacamole, nice catch. That's interesting behavior indeed... I'll leave it to you to submit for 5.5?