Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3350854iob; Mon, 16 May 2022 20:22:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1+hLJub9K9XzqALzTzwLrHcV4kXhxcwX3cvEH1MksrxCvGt1vsbZ0Fahf2Kt/csUIH68C X-Received: by 2002:a17:907:3e2a:b0:6f4:d700:2e65 with SMTP id hp42-20020a1709073e2a00b006f4d7002e65mr18294962ejc.624.1652757727349; Mon, 16 May 2022 20:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652757727; cv=none; d=google.com; s=arc-20160816; b=ELtdMHAw5gV7JkkJise1g0kgVdRZOqK3ZT613oFf6R2Tbq4F1quY4nGWk/x+4ZsXwL jkuUvM6DM//2oU2E+nZwcuMKV/iK9Yj5x6pyeiVtE1GjYBP+Keatej5dSaBe/JTqd9Jj lR6ip4nyE7aRQlzfQN6Oyir8KpZ6R4okNqabckibTr82ibwYFKYns6m6MPnINC5Vn7c3 YtsNI85XzbTge4U/tSD/3IBStxzmcKEE9G16psaKVBf3H0tIv1PyXOMc/ikGc+5KFobl R6CVXc5KJPHqJqR5LkNrfgjQ8mLOgcbAdnQ6lVW6luTjVnQjtN5aBEHNKlS9GzacbbwQ RCcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=1msdPYwcQARvSlOO4/O7VcmwrUdUYzsWsGF69TVVtNI=; b=g3vuYQsBLQ2SfiQN5yPcuOcdghbopayC3ZUPzf8cGfvmzKjBnlAMAB41L7kWfbHSy3 3zu3AV/oISAEf9VilkiTdbF68Cj47X9W8quD2nj8sFgdIAbBaRiZxWnksa2frI5V7z5v 07nLbmjX+ceZhkO43IgiCi4t/E7QqE797pv0kbsBQVZDt1/VcxPp8qqVx7qOvs8S/Lc4 BngPpFFnzPKHzm9zZU7xZeXUTDch+wL9yElKaxo1+h8NNYKL+zL7ciFwAuEIIKQjbovT PyE1NuW3Vm3o9I9juPMfgjNloE5GzecPtUCwheJBI5gBaYIaDB53wgXv/CcCr2/5uM6I SD8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=ZYk45tK3; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id my28-20020a1709065a5c00b006e83fe14ac1si1278335ejc.554.2022.05.16.20.21.41; Mon, 16 May 2022 20:22:07 -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=@xen0n.name header.s=mail header.b=ZYk45tK3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244891AbiEPPDQ (ORCPT + 99 others); Mon, 16 May 2022 11:03:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbiEPPDF (ORCPT ); Mon, 16 May 2022 11:03:05 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4163B546; Mon, 16 May 2022 08:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1652713378; bh=g2WNRPhTJkGKr3gGAVCpuHs4QwNIkre+XOqlLFTxREo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=ZYk45tK3RZHkE2O1xOgac3NkJ4XhYM66poTQ7PwYwQleliXHDQaVV2T1QuajbZybG DcoCsmRm34ALRnZCfuTAXjBU2Nqkm9LWiHJ3CMEt0jw1c9p5thbhfuJv0pGlu8GBD9 zaeIH56QmV3058m0Yt+UMj+lnn6H0zS3hnR7JvOo= Received: from [192.168.9.172] (unknown [101.88.28.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id F226660691; Mon, 16 May 2022 23:02:57 +0800 (CST) Message-ID: <6bb4c861-c310-18f8-f2f2-5c3f85c541b4@xen0n.name> Date: Mon, 16 May 2022 23:02:57 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.0a1 Subject: Re: [PATCH V10 14/22] LoongArch: Add signal handling support Content-Language: en-US To: "Eric W. Biederman" , WANG Xuerui Cc: Huacai Chen , Huacai Chen , Arnd Bergmann , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Andrew Morton , David Airlie , Jonathan Corbet , Linus Torvalds , linux-arch@vger.kernel.org, "open list:DOCUMENTATION" , LKML , Xuefeng Li , Yanteng Si , Guo Ren , Jiaxun Yang , Stephen Rothwell , Al Viro References: <20220514080402.2650181-1-chenhuacai@loongson.cn> <20220514080402.2650181-15-chenhuacai@loongson.cn> <87bkvxd12b.fsf@email.froward.int.ebiederm.org> From: WANG Xuerui In-Reply-To: <87bkvxd12b.fsf@email.froward.int.ebiederm.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 On 5/16/22 22:06, 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 > > 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. IIUC, the ADRERR spelling is because of influence of BUS_ADRERR. But the prefix idea sounds good. >>>>> + >>>>> +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. Hmm, thinking twice, the code actually doesn't get destroyed, nor magically "thawed" and modified, if not upstreamed initially; just that these same lines would go in later. Maybe I overlooked the problem because I've tried to reverse-engineer the LSX/LASX back in the MIPS days of Loongson, and that I've seen early version of the port that contained the same handling, so all of this come as familiar. So actually removing the code is the sensible thing to do here. We don't really lose anything or waste too much time for that. > > Eric