Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp916171pxj; Sat, 8 May 2021 02:27:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJtYwXOxJMCTDiUrXG5PbrO6SKxnIMCKPEYgT6jXNlSXnxjjtW/JOXX2GTkawrCuU/tkIM X-Received: by 2002:a17:903:2302:b029:ee:e330:3f81 with SMTP id d2-20020a1709032302b02900eee3303f81mr14584908plh.10.1620466065662; Sat, 08 May 2021 02:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620466065; cv=none; d=google.com; s=arc-20160816; b=mSShgRmSg9WI/KjTHP57Ft82URj8iDt/hnMTpoS0EuPTVNc2SLRBNRXEIoFXirUnaW fWB5Oj9GInELWNxPM2gyaTbkZ6e3cJWlUf8cpI+Uggb1m4c3GRBW568dm0H9h/C9lsck lvIMVIu5y68pgvPV+zVfZiUCT51pWbULAF0sFbXI/AZDyYxUN07B/x54c4iIBJOx0Yu0 sZRtd66mAShnP15ZmLGoJNKOg86l686DPWsE86VJf5VhojY63kOcZlDQgGcdxULjWshM 2BE2ALymg4nElQKWkxCoJgvVj7GeaX6Ah4ByJrWE7uLmVb60zXHY8PQksh2YcvYgHclj mAcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=rDS1qsYKUBaca4opgdDxI+PYFeYey0NLpLzOj+MIX8U=; b=bg31j/yeQaFL9LogG6/0vqSxwQ7c+inIp+1QcUuwj9oKitvzH2DpCVvfGuNHTheiaG ncFgX+Tav6n7kSa0Wp/mu2JTgDshbt6NTRmD+DFJdZor63trcUsGCv85PuChycJ6CRt1 su3MI1HiK13OYroqb0R8S/Db9V5Msxcr6isMpZagnpskDLpwFNfb81L65HMyBX+ECHt+ tcG90cgxht/BfhTvwNB2mj5EHNouGjvBMBKix7/xuJElbTrSltNLzBpjG2mAG1biZJe9 M8LY7aKOFJ1OhGIoP/Zk5CRwHXkkKYT/r4w+uPbJbge/XGbEjNZFUJfFsUhf27wlEHp/ gGMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si10218574plt.306.2021.05.08.02.27.31; Sat, 08 May 2021 02:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbhEHJ0n (ORCPT + 99 others); Sat, 8 May 2021 05:26:43 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:43155 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbhEHJ0m (ORCPT ); Sat, 8 May 2021 05:26:42 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4FchkN58TWz9sbC; Sat, 8 May 2021 11:25:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QhezB7fxWmgn; Sat, 8 May 2021 11:25:32 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4FchkN4FGCz9sZs; Sat, 8 May 2021 11:25:32 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 736498B774; Sat, 8 May 2021 11:25:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id DxA6PDEBwgZ9; Sat, 8 May 2021 11:25:32 +0200 (CEST) Received: from localhost.localdomain (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 3FB708B76B; Sat, 8 May 2021 11:25:32 +0200 (CEST) Received: by localhost.localdomain (Postfix, from userid 0) id 0C01E64921; Sat, 8 May 2021 09:25:32 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] powerpc/uaccess: Fix __get_user() with CONFIG_CC_HAS_ASM_GOTO_OUTPUT To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Sat, 8 May 2021 09:25:32 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Building kernel mainline with GCC 11 leads to following failure when starting 'init': init[1]: bad frame in sys_sigreturn: 7ff5a900 nip 001083cc lr 001083c4 Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b This is an issue due to a segfault happening in __unsafe_restore_general_regs() in a loop copying registers from user to kernel: 10: 7d 09 03 a6 mtctr r8 14: 80 ca 00 00 lwz r6,0(r10) 18: 80 ea 00 04 lwz r7,4(r10) 1c: 90 c9 00 08 stw r6,8(r9) 20: 90 e9 00 0c stw r7,12(r9) 24: 39 0a 00 08 addi r8,r10,8 28: 39 29 00 08 addi r9,r9,8 2c: 81 4a 00 08 lwz r10,8(r10) <== r10 is clobbered here 30: 81 6a 00 0c lwz r11,12(r10) 34: 91 49 00 08 stw r10,8(r9) 38: 91 69 00 0c stw r11,12(r9) 3c: 39 48 00 08 addi r10,r8,8 40: 39 29 00 08 addi r9,r9,8 44: 42 00 ff d0 bdnz 14 <__unsafe_restore_general_regs+0x14> As shown above, this is due to r10 being re-used by GCC. This didn't happen with CLANG. This is fixed by tagging 'x' output as an earlyclobber operand in __get_user_asm2_goto(). Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/uaccess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index a09e4240c5b1..22c79ab40006 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -157,7 +157,7 @@ do { \ "2: lwz%X1 %L0, %L1\n" \ EX_TABLE(1b, %l2) \ EX_TABLE(2b, %l2) \ - : "=r" (x) \ + : "=&r" (x) \ : "m" (*addr) \ : \ : label) -- 2.25.0