Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp16275312ybl; Wed, 1 Jan 2020 01:49:06 -0800 (PST) X-Google-Smtp-Source: APXvYqwDdjuwAs4cTmmSrPLZSjT9SqaZH0xCQ4XlsWvp/CHzj+g8mTa8H2giNQArUuHLmsz95LTH X-Received: by 2002:a05:6402:17f2:: with SMTP id t18mr84211790edy.9.1577872146057; Wed, 01 Jan 2020 01:49:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577872146; cv=none; d=google.com; s=arc-20160816; b=sQ4qAatlSJd9yyPNl9VVTNpaFq2vHWm4tDhvkeOFxFjlMiknvTyKSu+aHc5no1Pbul /WWJZI8qxW9wEXsHv0cysTSEOZ9P5yapmtvkyeDYhjtiRuncko08BZhb2pqieojhcATQ F16oKb21CagG5CAXb+wlCunLO7uraFmYUX88c6m4GTRrt52BZutX1owYqzfp0zqUGe8q tLiNmuHm9cFTT3cHtiRB+38V7uqJRHanAa5mLaII6RtjRdGEjkTjUuCj1QAMJPoI9/LI /RT/5XSB5yoih6LE9w2FPqIlFKb51kOt6CxnpkxRmlXSaoVZoxsG5+7vVCsZAmEGnZpQ uJjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=uHS4zK0PWCkwyjDrnK4wGGOQo9FSdmbJcLDSpJkUayk=; b=LHR1oNf9zlXSxtJBc0HjYVwbbha5z34psQNOqzFCKdtqBJgXkFh7LOscPZG5JXcR8F brCKlW2F0KBYL3DrwGQBi7Ql5EA/WqlttV8JVc0Rdq4FTyMhbKVasrKbCH3/Tb3KFTSk j0/tkNzkc/oP0Ywg3TE6n9K6Bd4jXZR/2qoSQGVwmthFPNH3EumxkpT/7uYOZZuQKKj7 dMWCZcjRb5BrsWpIRl/Z3m3l2dikWq3e4tukyxMzd01YZbYjGMxcYi+jYCvNqDyQG2w2 H3vP3F5iOqvZfkprb9dxEMf/LIeojxovVA55hS74A7mbZ1EfZmhMepESXTSqR3AxxuUI zFOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=iOuTX6vX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si32320259eds.171.2020.01.01.01.48.41; Wed, 01 Jan 2020 01:49:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zx2c4.com header.s=mail header.b=iOuTX6vX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725900AbgAAJrS (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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?