Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3530472iob; Tue, 17 May 2022 01:57:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLLHHZH94La09yIf2JSiXAkRgX5S3O/o8LUptWUwtTMpdxlpnpFdsVsG4NpUeQj1ofyZEC X-Received: by 2002:a17:902:8644:b0:153:9f01:2090 with SMTP id y4-20020a170902864400b001539f012090mr20696119plt.101.1652777820840; Tue, 17 May 2022 01:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652777820; cv=none; d=google.com; s=arc-20160816; b=l09QQsBziALKxC8qarSVGPTjI6OY9gNv6HKUfdrh0Gsj2aLeSB5AXxxrJvGAlO20AX NV7auhozjaI4430S37bluA90SmB9ZaBmJ6Z991wfPKs44uvO0ZdOxurd5PcaAWkx3GoO kowSQCCxwywt85/DUeLTSHEEVwVrEpx5pcO80QsuAba4vYBL99OANT/eAOY/qhBFZdyh 4/R710iKrcloMSC9GDsG/1DytVBASQGZ3a359tGRU4oMOhA46scPcnD+wzF7GUaFrEG3 gKiwi7JhpTa9uE/iTVpoAi13uKTSjpegdv8lk77S2Xp8wV/s34sv4BZmg20XDxhF6NHL pdKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YNIVHyUn80V86PKxp2T+1SDr/HwkAtaW1gqkh7u+Rw8=; b=Vk6maNG3UC4JFGR2nKpLds0ABUYLOhhDiX8xLzo0Sk0FCsKpgZwQpXHT2ThDT261Vz UW1vWgZUmbYM92Hk4GLj5YhYukmQ6XURwCgK0lDegG81ItvehV3+6OXhxfwYI6eVfPLn XafVQ93WewyajwjS7/xCrmYxNe2ArMxW1mXIpijSA9nahQoVZg/nx051BauskP1SDjRP Oxbq5cpvrLETTXt1q8uGcXm3y8VnSkq+NRNSK9voSjmBiKxBAznFUSueJrxcks7jQz8k tdiIw/KmjKWkbNGXu+FPkLmLpox4wVVkm56LpCLNo0DYN7k/3BjdxM1oUVnHiQZQja7d jCcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YuGeokCV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a17090341c500b00158ec58e06csi18128556ple.519.2022.05.17.01.56.47; Tue, 17 May 2022 01:57:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=YuGeokCV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230117AbiEQCId (ORCPT + 99 others); Mon, 16 May 2022 22:08:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229479AbiEQCI3 (ORCPT ); Mon, 16 May 2022 22:08:29 -0400 Received: from mail-vk1-xa2c.google.com (mail-vk1-xa2c.google.com [IPv6:2607:f8b0:4864:20::a2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78C1744A0C; Mon, 16 May 2022 19:08:26 -0700 (PDT) Received: by mail-vk1-xa2c.google.com with SMTP id e7so8408194vkh.2; Mon, 16 May 2022 19:08:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YNIVHyUn80V86PKxp2T+1SDr/HwkAtaW1gqkh7u+Rw8=; b=YuGeokCVKMdqtN5SO4Fl2AQYzmNzAb7kLE1K4NoFiQ/ZrqzXdJn9lbiFBLL0Xafc+y D9fH1HB6olFgX9O6FcEbeFpm4WaHnckt4OH0tVg07rj7c8M5Q35ANEYVa3dpCP3qQe9/ 1ZfoCUm2UPdXcykKHjjNaBU26t5Znm3b4vLBlgAWp1NXVSOBga76hUML7Iygx3WOfRUf ToTPuW167m6vHBHB3q12cIoAOaDwYit8u8vhUV5YYa1NyIj6OZMZiGK5laweZ4FKC84y 778rHm0pzSU0MiEUrM/ZXF4g0dssjKeRHwb4DTNq29xsXaNBRZlEnCNevH1nq9MdlV/A VRZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YNIVHyUn80V86PKxp2T+1SDr/HwkAtaW1gqkh7u+Rw8=; b=vsSILfFX7//WAc9gUhy3EPyUPbwY0fXpL2S8RNNx6NZ5J1lj8OB5EuiX/Y/jORqgff gmjZCdlFfe8qBlGwmDKUNKsLUggugtbCBaT8rZpzNBbTduPM/2WduH6xN9SxBM5aCmVv q5eUoCqeN/Ea35Y8OL4fX3VrveVvi1rXkyXlsurkmK0FexPspPOLNde5aB9Ea3jRmWzL T74CjpZKMYCscrhc7AGkujkeCQbsaVNunXjYKnX2EAjOmHj6sPw66nu2C47SLKIcbg08 xvw+rqTBiL8pPJhI4e/L/xMjLYx+H8DufR2fvQjZO5+xCqa1tr9Qi5HE9MTs+m+K4cUX h8Sg== X-Gm-Message-State: AOAM531/4kKCRUP2X1p64mazYC4Zq3/KzxcGCCO0Jh6Bg6QTj4gtBS10 kZgIiIrbaOXnLVhy4SjhLbQ0OcCDRoMrPu9xo2GwT6mu9i8MBg== X-Received: by 2002:a1f:1609:0:b0:34d:ff24:30ef with SMTP id 9-20020a1f1609000000b0034dff2430efmr7800818vkw.14.1652753305507; Mon, 16 May 2022 19:08:25 -0700 (PDT) MIME-Version: 1.0 References: <20220514080402.2650181-1-chenhuacai@loongson.cn> <20220514080402.2650181-15-chenhuacai@loongson.cn> <87bkvxd12b.fsf@email.froward.int.ebiederm.org> In-Reply-To: <87bkvxd12b.fsf@email.froward.int.ebiederm.org> From: Huacai Chen Date: Tue, 17 May 2022 10:08:18 +0800 Message-ID: Subject: Re: [PATCH V10 14/22] LoongArch: Add signal handling support To: "Eric W. Biederman" Cc: WANG Xuerui , Huacai Chen , Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , "" , "open list:DOCUMENTATION" , LKML , Xuefeng Li , Yanteng Si , Guo Ren , Jiaxun Yang , Stephen Rothwell , Al Viro Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Eric, On Mon, May 16, 2022 at 10:07 PM Eric W. Biederman wrote: > > WANG Xuerui writes: > > > Hi, > > > > On 5/15/22 21:48, Huacai Chen wrote: > >> diff --git a/arch/loongarch/include/uapi/asm/sigcontext.h b/arch/loongarch/include/uapi/asm/sigcontext.h > >> new file mode 100644 > >> index 000000000000..efeb8b3f8236 > >> --- /dev/null > >> +++ b/arch/loongarch/include/uapi/asm/sigcontext.h > >> @@ -0,0 +1,63 @@ > >> +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ > >> +/* > >> + * Author: Hanlu Li > >> + * Huacai Chen > >> + * > >> + * Copyright (C) 2020-2022 Loongson Technology Corporation Limited > >> + */ > >> +#ifndef _UAPI_ASM_SIGCONTEXT_H > >> +#define _UAPI_ASM_SIGCONTEXT_H > >> + > >> +#include > >> +#include > >> + > >> +/* FP context was used */ > >> +#define USED_FP (1 << 0) > >> +/* Load/Store access flags for address error */ > >> +#define ADRERR_RD (1 << 30) > >> +#define ADRERR_WR (1 << 31) > >>> I've searched GitHub globally, and my local glibc checkout, for usages > >>> of these 3 constants, and there seems to be none; please consider > >>> removing these if doable. We don't want cruft in uapi right from the > >>> beginning. > >> They will be used in our glibc, I promise. > > Okay then. Seems simple enough, and from my quick grepping these appear to be > > original creations -- not carried over from somewhere else, so it's already > > highly likely that some of the userland tools need these anyway, just not > > released yet. > > I can understand exporting these values but the names aren't very > well namespaced at all. Which means they could accidentially > conflict with things. > > It would probably be better to do: > SC_USED_FP > SC_ADDRERR_RD > SC_ADDRERR_WR SC_ prefix is good, but ADRERR_RD/ADRERR_WR is used together with SIGSEGV/SIGBUS, so I want to keep the same as BUS_ADRERR (a single D) if possible. > > And with two D's please. It breaks my fingers to have to > make a typo like that on purpose. > > This is very much a bikeshed comment, but I think the > bikeshed should be painted. > > >>>> + > >>>> +struct sigcontext { > >>>> + __u64 sc_pc; > >>>> + __u64 sc_regs[32]; > >>>> + __u32 sc_flags; > >>>> + __u64 sc_extcontext[0] __attribute__((__aligned__(16))); > >>>> +}; > >>>> + > >>>> +#define CONTEXT_INFO_ALIGN 16 > >>>> +struct _ctxinfo { > >>>> + __u32 magic; > >>>> + __u32 size; > >>>> + __u64 padding; /* padding to 16 bytes */ > >>>> +}; > >>>> + > >>>> +/* FPU context */ > >>>> +#define FPU_CTX_MAGIC 0x46505501 > >>>> +#define FPU_CTX_ALIGN 8 > >>>> +struct fpu_context { > >>>> + __u64 regs[32]; > >>>> + __u64 fcc; > >>>> + __u32 fcsr; > >>>> +}; > >>> The 3 structs above should already see usage downstream (glibc and other > >>> low-level friends), so they probably shouldn't be touched by now. At > >>> least I can't see problems. > >>>> + > >>>> +/* LSX context */ > >>>> +#define LSX_CTX_MAGIC 0x53580001 > >>>> +#define LSX_CTX_ALIGN 16 > >>>> +struct lsx_context { > >>>> + __u64 regs[2*32]; > >>>> + __u64 fcc; > >>>> + __u32 fcsr; > >>>> + __u32 vcsr; > >>>> +}; > >>>> + > >>>> +/* LASX context */ > >>>> +#define LASX_CTX_MAGIC 0x41535801 > >>>> +#define LASX_CTX_ALIGN 32 > >>>> +struct lasx_context { > >>>> + __u64 regs[4*32]; > >>>> + __u64 fcc; > >>>> + __u32 fcsr; > >>>> + __u32 vcsr; > >>>> +}; > >>> Do we want to freeze the LSX/LASX layout this early, before any detail > >>> of said extension are published? We'll need to update kernel later > >>> anyway, so I'd recommend leaving them out for the initial bring-up. > >> Yes, they are freezed. > > Okay too, I remember these are the same values as in the old world, so it should > > be easy to support both worlds at least in this regard. > > You know. I really don't like this including code for hardware that may > be frozen but is not publicly documented yet. Especially when the plan > is to publicly document the hardware. It has the real problem that no > one else can review the code. > > In ever design I have worked with there have been places where the > people putting it together have had blind spots. The only way I know to > get past blind spots is to get as many people as possible looking, > and to listen to the feedback. > > Given that neither lsx_context nor lasx_context are used in the kernel > code yet I would very much prefer that their inclusion wait until there > is actual code that needs them. > > If nothing else that will put the definitions in context so people can > more easily see the big picture and understand how the pieces fit. OK, I will remove lsx_context/lasx_context in the next version. Huacai > > Eric