Message ID | 20240123132335.2034611-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-35382-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2553:b0:103:945f:af90 with SMTP id p19csp331900dyi; Tue, 23 Jan 2024 05:29:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1l7WvmDW76J3o5RRW6ljm5WTN0WjPsSNvKPKv4H+xKCaBOz2ZwaQI6yiwy/J0PEReLpcX X-Received: by 2002:a17:906:2604:b0:a2f:6486:3a79 with SMTP id h4-20020a170906260400b00a2f64863a79mr1686749ejc.192.1706016577975; Tue, 23 Jan 2024 05:29:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706016577; cv=pass; d=google.com; s=arc-20160816; b=CMA7JuObcE1Aj+/oG74uTePCU2SMH45zLuFptY031dWD+8+EwRXrYPC7K1Y16RynqF a9q3/0ZVrQwF0iIOCq84MuPD15gAsXcX9XRGWwA8jNUWd24MW3SZQeiWqTxb/GOt1v0/ Pfcjlq/L8QiyrH0L6dg5OTm1TEldCaK1X5PjLkFH7+f0lCcoBq5DhRyMZi0C+Na1nlOT hk7K2bBLsVypNW5TbQjaIrnbjsA/UMCXmmxc+pd3K8nNaaz6PRc4s3jvPc9frd2M3hn4 KkNAnX94zAdFLjAgb6MM5qjf4XHJ43MuuuRA6LhdxQaSKBZrfFyER3iMYCdHySJYnb1H 5ujA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=zuDBuArVy5/CW7YFPKgts5ZJ1lP4HsyqjF3AU+tXFdQ=; fh=SBoOpoWvXPtflU4fHSmq9Vhz6jB+wkrt+RY2vksG08Q=; b=HoCFQFUE+nT8dH30NO4b4Kd50rexaVry3YwVCm33pKc+4Lyl8N6Mp0prU4KMMH1MhV LZSn9vI7cTXCX0nJWZkGloGrf8Kst+00q9C7EU1BGGuVwvbmM4yu5DALbZwvrGQ5CAcM 8TTacVcEx4GRAhibch3VBa99JECrIo2lIcDHkvYoK0b84OHsCA1NC8M8CqImzU9hA4xl WoGq2mn1nqG3daGi7AbdEXq2PQVHKNkmX0azv1fRij53ff+I6SNN9JsLquTQPOa1bUfy RrR6/n1ZaZjoxrNCqbOJTcsWNFrcWYXKf4phtaa0BCpejWBm7QP8ecz95KpzwvK2kyzx BE5g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HDsdxTCP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35382-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35382-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id bj24-20020a170906b05800b00a2c2b089242si11925572ejb.433.2024.01.23.05.29.37 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 05:29:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35382-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HDsdxTCP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35382-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35382-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9AED51F293F7 for <ouuuleilei@gmail.com>; Tue, 23 Jan 2024 13:29:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A84AB605D1; Tue, 23 Jan 2024 13:23:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HDsdxTCP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15406605B8; Tue, 23 Jan 2024 13:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706016221; cv=none; b=EJXbW5NpQy4lm1CqGpjXH2u8MvtfoBH66D31QaHYh1us6LkBDuoG0OQeF/Rro6vPUDytkfFcxGl0B5yJfytNj6HliIikT93FCqWaMy8y9iPfvFnnA14sg9zrUjryEbT9u9rqZ4GnQY7cOe30DJi8uBX5TpKY9OAC9fm+21YX5Sw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706016221; c=relaxed/simple; bh=0RGNHFInxFQRBM29nCBUXg7rUT8MFbgsXfxi0b/Mf3o=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=a62pOEOsdkpSjQ5RGZYmNrCOxz2lsrHJl9P4ykb4XCJB1YmmBev15wy5pmfix+gjeLjGxXwVaDjy62OREPADanI23ZBoHoTEbtlz0TrLyPKNjJGIaRe6V3SG/t6t2Xm9BqJW8jEeFPq8FY9vB7a8DZ8fMitUPh1N6P9C1HR7FFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HDsdxTCP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C0F6C433F1; Tue, 23 Jan 2024 13:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706016220; bh=0RGNHFInxFQRBM29nCBUXg7rUT8MFbgsXfxi0b/Mf3o=; h=From:To:Cc:Subject:Date:From; b=HDsdxTCPF2P8K6rIbqpCVoXFAaJMHGYEHl/5rvQT08ljmM5S+A1N+8n6SEbg37UrZ haKP5Mxsx78xdiZzUoW6l8J0KNzhBUuO3BoyKjQBZ73dosoIMGDg2m52H7psIuxJQH 5Jcugn+deUs8HeTfr5/b9S07L942RzQmS0UesSgWhrRaJTAVCLW7PS9CXmLeK0XcnB E5yj4eC33L7JH5ENXkgFu65QRES6Lml1d4qXR/YtnVIYSvW145uoed3RHgHz4i5XKm lnn5/r67EHpwzNIUz3i34+oy1CxWQQujKy5WS7FaZnDSZsrqN6BGUccYHDLGnGUnN1 p/ssMhEAlE7sA== From: Arnd Bergmann <arnd@kernel.org> To: Yoshinori Sato <ysato@users.sourceforge.jp>, Rich Felker <dalias@libc.org>, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> Cc: Arnd Bergmann <arnd@arndb.de>, linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH] sh: use generic uaccess Date: Tue, 23 Jan 2024 14:23:20 +0100 Message-Id: <20240123132335.2034611-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788888038988434313 X-GMAIL-MSGID: 1788888038988434313 |
Series |
sh: use generic uaccess
|
|
Commit Message
Arnd Bergmann
Jan. 23, 2024, 1:23 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de> As reported by many people, the nommu SH code runs into a compiler error with a newly added syscall: + {standard input}: Error: displacement to undefined symbol .L105 overflows 8-bit field : => 590, 593 + {standard input}: Error: displacement to undefined symbol .L135 overflows 8-bit field : => 603 + {standard input}: Error: displacement to undefined symbol .L140 overflows 8-bit field : => 606 + {standard input}: Error: displacement to undefined symbol .L76 overflows 12-bit field: => 591, 594 + {standard input}: Error: displacement to undefined symbol .L77 overflows 8-bit field : 607 => 607, 582, 585 + {standard input}: Error: displacement to undefined symbol .L97 overflows 12-bit field: => 607 + {standard input}: Error: pcrel too far: 604, 590, 577, 593, 572, 569, 598, 599, 596, 610 => 610, 574, 599, 569, 598, 596, 601, 590, 604, 595, 572, 577, 593 Avoid the code that triggers this entirely by using the same generic uaccess code that m68k and riscv have on nommu. Link: https://lore.kernel.org/all/07d8877b-d933-46f4-8ca4-c10ed602f37e@app.fastmail.com/ Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- arch/sh/include/asm/uaccess.h | 5 +++++ arch/sh/include/asm/uaccess_32.h | 23 ----------------------- 2 files changed, 5 insertions(+), 23 deletions(-)
Comments
Hi Arnd, On Tue, 2024-01-23 at 14:23 +0100, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > As reported by many people, the nommu SH code runs into a compiler error > with a newly added syscall: > > + {standard input}: Error: displacement to undefined symbol .L105 overflows 8-bit field : => 590, 593 > + {standard input}: Error: displacement to undefined symbol .L135 overflows 8-bit field : => 603 > + {standard input}: Error: displacement to undefined symbol .L140 overflows 8-bit field : => 606 > + {standard input}: Error: displacement to undefined symbol .L76 overflows 12-bit field: => 591, 594 > + {standard input}: Error: displacement to undefined symbol .L77 overflows 8-bit field : 607 => 607, 582, 585 > + {standard input}: Error: displacement to undefined symbol .L97 overflows 12-bit field: => 607 > + {standard input}: Error: pcrel too far: 604, 590, 577, 593, 572, 569, 598, 599, 596, 610 => 610, 574, 599, 569, 598, 596, 601, 590, 604, 595, 572, 577, 593 > > Avoid the code that triggers this entirely by using the same generic > uaccess code that m68k and riscv have on nommu. > > Link: https://lore.kernel.org/all/07d8877b-d933-46f4-8ca4-c10ed602f37e@app.fastmail.com/ > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > arch/sh/include/asm/uaccess.h | 5 +++++ > arch/sh/include/asm/uaccess_32.h | 23 ----------------------- > 2 files changed, 5 insertions(+), 23 deletions(-) > > diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h > index a79609eb14be..b42764d55901 100644 > --- a/arch/sh/include/asm/uaccess.h > +++ b/arch/sh/include/asm/uaccess.h > @@ -2,6 +2,7 @@ > #ifndef __ASM_SH_UACCESS_H > #define __ASM_SH_UACCESS_H > > +#ifdef CONFIG_MMU > #include <asm/extable.h> > #include <asm-generic/access_ok.h> > > @@ -130,4 +131,8 @@ struct mem_access { > int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs, > struct mem_access *ma, int, unsigned long address); > > +#else > +#include <asm-generic/uaccess.h> > +#endif > + > #endif /* __ASM_SH_UACCESS_H */ > diff --git a/arch/sh/include/asm/uaccess_32.h b/arch/sh/include/asm/uaccess_32.h > index 5d7ddc092afd..e053f2fd245c 100644 > --- a/arch/sh/include/asm/uaccess_32.h > +++ b/arch/sh/include/asm/uaccess_32.h > @@ -35,7 +35,6 @@ do { \ > } \ > } while (0) > > -#ifdef CONFIG_MMU > #define __get_user_asm(x, addr, err, insn) \ > ({ \ > __asm__ __volatile__( \ > @@ -56,16 +55,6 @@ __asm__ __volatile__( \ > ".previous" \ > :"=&r" (err), "=&r" (x) \ > :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) > -#else > -#define __get_user_asm(x, addr, err, insn) \ > -do { \ > - __asm__ __volatile__ ( \ > - "mov." insn " %1, %0\n\t" \ > - : "=&r" (x) \ > - : "m" (__m(addr)) \ > - ); \ > -} while (0) > -#endif /* CONFIG_MMU */ > > extern void __get_user_unknown(void); > > @@ -140,7 +129,6 @@ do { \ > } \ > } while (0) > > -#ifdef CONFIG_MMU > #define __put_user_asm(x, addr, err, insn) \ > do { \ > __asm__ __volatile__ ( \ > @@ -164,17 +152,6 @@ do { \ > : "memory" \ > ); \ > } while (0) > -#else > -#define __put_user_asm(x, addr, err, insn) \ > -do { \ > - __asm__ __volatile__ ( \ > - "mov." insn " %0, %1\n\t" \ > - : /* no outputs */ \ > - : "r" (x), "m" (__m(addr)) \ > - : "memory" \ > - ); \ > -} while (0) > -#endif /* CONFIG_MMU */ > > #if defined(CONFIG_CPU_LITTLE_ENDIAN) > #define __put_user_u64(val,addr,retval) \ Wouldn't that make these operations slower or do you think that GCC is able to optimize this well enough? Also, this is something that should definitely be boot-tested to make sure this doesn't introduce any regressions. Adrian
On Tue, Jan 23, 2024, at 14:55, John Paul Adrian Glaubitz wrote: > > Wouldn't that make these operations slower or do you think that GCC is able > to optimize this well enough? It's only single load/store instructions, so it should make no difference. If anything, the generic code should allow the compiler to have better register allocation and produce better output than the assembler version (which is how this avoids the ICE), but it's unlikely to be noticeably either. > Also, this is something that should definitely be boot-tested to make sure > this doesn't introduce any regressions. Agree. Arnd
Hi Arnd, On Tue, 2024-01-23 at 15:14 +0100, Arnd Bergmann wrote: > On Tue, Jan 23, 2024, at 14:55, John Paul Adrian Glaubitz wrote: > > > > Wouldn't that make these operations slower or do you think that GCC is able > > to optimize this well enough? > > It's only single load/store instructions, so it should make no > difference. If anything, the generic code should allow the compiler > to have better register allocation and produce better output than > the assembler version (which is how this avoids the ICE), but it's > unlikely to be noticeably either. I have not seen an ICE on v6.8-rc1 so far. What config was it that triggered it? > > Also, this is something that should definitely be boot-tested to make sure > > this doesn't introduce any regressions. > > Agree. Adrian
Hi Adrian, On Tue, Jan 23, 2024 at 3:20 PM John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> wrote: > On Tue, 2024-01-23 at 15:14 +0100, Arnd Bergmann wrote: > > On Tue, Jan 23, 2024, at 14:55, John Paul Adrian Glaubitz wrote: > > > > > > Wouldn't that make these operations slower or do you think that GCC is able > > > to optimize this well enough? > > > > It's only single load/store instructions, so it should make no > > difference. If anything, the generic code should allow the compiler > > to have better register allocation and produce better output than > > the assembler version (which is how this avoids the ICE), but it's > > unlikely to be noticeably either. > > I have not seen an ICE on v6.8-rc1 so far. What config was it that triggered it? v6.8-rc1/sh4-gcc12/sh-allmodconfig v6.8-rc1/sh4-gcc11/sh-allyesconfig v6.8-rc1/sh4-gcc13/sh-allmodconfig v6.8-rc1/sh4-gcc13/sh-allyesconfig e.g. http://kisskb.ellerman.id.au/kisskb/buildresult/15111229/ Gr{oetje,eeting}s, Geert
diff --git a/arch/sh/include/asm/uaccess.h b/arch/sh/include/asm/uaccess.h index a79609eb14be..b42764d55901 100644 --- a/arch/sh/include/asm/uaccess.h +++ b/arch/sh/include/asm/uaccess.h @@ -2,6 +2,7 @@ #ifndef __ASM_SH_UACCESS_H #define __ASM_SH_UACCESS_H +#ifdef CONFIG_MMU #include <asm/extable.h> #include <asm-generic/access_ok.h> @@ -130,4 +131,8 @@ struct mem_access { int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs, struct mem_access *ma, int, unsigned long address); +#else +#include <asm-generic/uaccess.h> +#endif + #endif /* __ASM_SH_UACCESS_H */ diff --git a/arch/sh/include/asm/uaccess_32.h b/arch/sh/include/asm/uaccess_32.h index 5d7ddc092afd..e053f2fd245c 100644 --- a/arch/sh/include/asm/uaccess_32.h +++ b/arch/sh/include/asm/uaccess_32.h @@ -35,7 +35,6 @@ do { \ } \ } while (0) -#ifdef CONFIG_MMU #define __get_user_asm(x, addr, err, insn) \ ({ \ __asm__ __volatile__( \ @@ -56,16 +55,6 @@ __asm__ __volatile__( \ ".previous" \ :"=&r" (err), "=&r" (x) \ :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) -#else -#define __get_user_asm(x, addr, err, insn) \ -do { \ - __asm__ __volatile__ ( \ - "mov." insn " %1, %0\n\t" \ - : "=&r" (x) \ - : "m" (__m(addr)) \ - ); \ -} while (0) -#endif /* CONFIG_MMU */ extern void __get_user_unknown(void); @@ -140,7 +129,6 @@ do { \ } \ } while (0) -#ifdef CONFIG_MMU #define __put_user_asm(x, addr, err, insn) \ do { \ __asm__ __volatile__ ( \ @@ -164,17 +152,6 @@ do { \ : "memory" \ ); \ } while (0) -#else -#define __put_user_asm(x, addr, err, insn) \ -do { \ - __asm__ __volatile__ ( \ - "mov." insn " %0, %1\n\t" \ - : /* no outputs */ \ - : "r" (x), "m" (__m(addr)) \ - : "memory" \ - ); \ -} while (0) -#endif /* CONFIG_MMU */ #if defined(CONFIG_CPU_LITTLE_ENDIAN) #define __put_user_u64(val,addr,retval) \