Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp16036770ybl; Tue, 31 Dec 2019 20:14:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyarkKg5QaflNVjzHRMsfRz751ybQzvNxovcqOkHSytQ5dmvbihGtxV+L15w7Pwu6M8NFCT X-Received: by 2002:a50:d5c9:: with SMTP id g9mr79482814edj.131.1577852068285; Tue, 31 Dec 2019 20:14:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577852068; cv=none; d=google.com; s=arc-20160816; b=dlDVXTUDCC0uuAOlBEuu3wQEzZEhT/YMUOPhjfPFcJf/Zt2zOqvV+ryYzeNSa/mfy1 0bH+2UH5LR/qV164kz/PzFdPempfBiWFGxYKNOTMTAePRhAmOMqw1U0RMbqp8szk1IOr LMibBKR0Nju0OGO17q7Rt4nBIv5uk+v0arEKmg+lkUl55iSZ4yA1V+rD3foWbyEJWa/A DAN9Ams8nKmlowfcQmxngiFPe/VWDfvs3jn01K9Xf/n64wkXH+RmFgliVRDGuX8rpyo+ 5nluwRh/7MKF2RR4grGOB/Wf6ouyuC7r/2XyoNSJsI+st1ooyZkggFdMH9S8d6zLBo8y CI6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=ZwEkntBzTwwdVS/4EXR74+jTw7hvRbZPVc6hQGwZlbU=; b=gqZh9VsAv6NaoIaqRZWTaOhsOnH0COTZ3O5fLifTr51LqXWwfGHJYL68TNRLGj55XJ Nt2nFO3DATdL92P8qCR+4U2f21Qcev3rwvTpGd+bnsWGXAu3Ekb8yuHlEzRNyYhFOa4r wfIfa9smJP+RCMGpfM+5fmpNlb7aPK10kTdOUh7gBbqPT7FuV54b+r/TBfDX5G3PZwCX m8A16iyPBy8HavkIuP7U3fCPB86NyoKXJSsj505V2DWXip13x0ND5rDCoW+5WkrnYBQC 7sBkQyyZVznQcfXPVJnRoDqchsD+Evrt4MMgAk4rm4DBbTSP/sKAFFsOv7YvmnYqo2Fp 7QAQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si27659991edw.376.2019.12.31.20.13.52; Tue, 31 Dec 2019 20:14:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727145AbgAAEIp (ORCPT + 99 others); Tue, 31 Dec 2019 23:08:45 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42236 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727036AbgAAEIp (ORCPT ); Tue, 31 Dec 2019 23:08:45 -0500 Received: by mail-pg1-f194.google.com with SMTP id s64so20207553pgb.9; Tue, 31 Dec 2019 20:08:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZwEkntBzTwwdVS/4EXR74+jTw7hvRbZPVc6hQGwZlbU=; b=KUSTVsOl3zGQf+Y17+zdupfoUukg92vv1tBNZ7S0CdhaQHXZ+xyVzj0PlUqLMubizz sfpZ6na2tpWo/xH1fI/7SDP2LvufjECxOHxyGIZ7x6lW5jnAqcCYbarNtAt3JMejEHxR aa8NUHvu5VmWQTd8JxcZmPNoAbHGNXaPwpwePRqn3KUrENmOVs2E4Iu+cUBQjTTmFKUh zXdpnUfIwG5W83KfnIg3C+40+vvWgeNkXqqcFQHEen5XeKWZ4D5U18Gb3lcT4fN6QBda LnM/wWnbIkpEkLJCoEPyPsT3zi0winZGkjmn57ZsfTBVSBOubGGNZVW2GbsSfZiXAnvA uLqw== X-Gm-Message-State: APjAAAWbw8DeSFxSSaJFBRz5QkPJuRoG+Mli4oT0aZZdbcM8alv2B4uP iAtfj1v44j8MJATYU/xKtEoPfjRc X-Received: by 2002:a65:5bc3:: with SMTP id o3mr80374380pgr.226.1577851724304; Tue, 31 Dec 2019 20:08:44 -0800 (PST) Received: from localhost ([2601:646:8a00:9810:5af3:56d9:f882:39d4]) by smtp.gmail.com with ESMTPSA id g8sm57261053pfh.43.2019.12.31.20.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Dec 2019 20:08:43 -0800 (PST) Date: Tue, 31 Dec 2019 20:10:56 -0800 From: Paul Burton To: "Jason A. Donenfeld" Cc: Arnd Bergmann , "linux-kernel@vger.kernel.org" , "open list:BROADCOM NVRAM DRIVER" , Vincenzo Frascino , Christian Brauner Subject: Re: [PATCH] mips: vdso: conditionalize 32-bit time functions on COMPAT_32BIT_TIME Message-ID: <20200101041056.xionott76qbrffih@lantea.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) {