Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1920843rwn; Fri, 16 Sep 2022 02:58:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5wagxmBr1F4jA9k5vyCYLhGXk/73QM/437iX1M4lg60dQqUC5jsKU4lDpSf5EmqLEHXncs X-Received: by 2002:a63:e118:0:b0:438:7603:8d6e with SMTP id z24-20020a63e118000000b0043876038d6emr3918098pgh.72.1663322338750; Fri, 16 Sep 2022 02:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663322338; cv=none; d=google.com; s=arc-20160816; b=u74l6bqfH6RZXcH4ukb9xhWN+gYORNjhu07d74fbeiseVZ8+Ge2Dh+P6jdkNObruBy t331XDF74b+mDxQ2mLa75f8xibnYUAfmjt0AWLpR5Sj0nZ2kRgHOp1ulKIlPf2xkE4Tu Uq4WJliX/BHH7RyFDjk4UcMkfFsPq1ykPCslng6SkluPziZPe207oCQcmW4p6imZcbLe WoFQXlfk6CvTUObUq8akNQkFdkWUU2TjipZSpXHB1EAS1PlkxttHR+OARa4+OEhPvezE Fk0/8i034HV7fQAsN8iJQx9wATRurM/qcaBxwQosz8xod4R342AunPDdPjor0Vrp68SR i4oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=wj5OSFKMaMShL9kPf9grhYXO/iiEFQNYTLIygfPbFF0=; b=E9JLOt+msoMsu3+iyTMwM+I5ImkR0YUepqOl+G/AFy8PUJ96C0zMp13zJPTnwpsQV3 zYn4UZBmAa/kLP4vUZEts/HlfP7zRCHMwDbfjJYudD9AKJWXmE+9JuUpeFhW4bzEfhXK iLquJaq6Rr9hD8sm/ziNtF87WIpjQKHUomFRFkLLSoz5JgUIsYKTGNcYZ3mgNDmx9vB4 uN/wCYTyiWsIGLNwMXnFURIijxjjOZOaBKXTocLgcEciHw6ghTP2vDfos7adWkXH1QmR jHdJftlhWpvwZeS7/BU4ZjR+Z+pf+8kl8+iIt5MmBdkCwv0R7o8S/3i14pmdcAa/M7PJ 3AXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=S6xb6kIu; 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 a23-20020a63d417000000b0042bc2bd5797si21888199pgh.278.2022.09.16.02.58.47; Fri, 16 Sep 2022 02:58:58 -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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=S6xb6kIu; 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 S230181AbiIPJye (ORCPT + 99 others); Fri, 16 Sep 2022 05:54:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiIPJyd (ORCPT ); Fri, 16 Sep 2022 05:54:33 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 444641012 for ; Fri, 16 Sep 2022 02:54:30 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id sb3so18584479ejb.9 for ; Fri, 16 Sep 2022 02:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date; bh=wj5OSFKMaMShL9kPf9grhYXO/iiEFQNYTLIygfPbFF0=; b=S6xb6kIuhT4wmw6S0ZJybtoz5CCAknGQsMFFQnrGHHo3d2Ll9idaadbGuZs6jO7l+D dr/azVWd76TnRURvVGtfM6Oiy8Dp7zpdkmw8uSUsmnXQofb+o6pku/GY1GfzqM1FWbVi cKwp/4kSV9G/KVvg8EtC+T3Vj9o/TBA8G3eMQ2AJZrdLJE4Z2diCTtswodnQoQ8nRx2o PB2FP1KgRsl6kPuxLYHw66MJfF7QBL9+m9eeE97hAbSIDqOHPEq+ts90j9a1wCZg5mTj +CUPvMcXHgYwye+YV8XA+I02UgkEIMkzEzwNYmCjBecIRWqD0wvteipHzfMOxWOBjIAS aX0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date; bh=wj5OSFKMaMShL9kPf9grhYXO/iiEFQNYTLIygfPbFF0=; b=Q/S5kmHTIyUHq2J8MtTNC48iqyM85OkLd0qYNr/hUJkzA2o3hOLWnwh2//spAeB/fW 3kkUai+a6AIeYyQEGwdfY1dYnRk8aGvLr0vuSBij5oZ0XFfz5mbc0gARfXnL9yOYjV8F QZuEIFrI53Bmmk5BeboDOoxMHhWioeGfA3HI+zIRHefytWI8tg3bV/kzFyin4vwaTQPd Pg1yRYJLK21kDZ9w15xvVYWg84VgKOG8N+/v68vE5Wq8S4RyzJLxy8YB74t5lvIINwPy qjWwiUbly/YbqGWeycyrb7kcczJ4uIWngKajMAJtohp7I76qriG8CWUQKPYTdHq78RwI +dQg== X-Gm-Message-State: ACrzQf2AINXuIDQ7aaMCoOq0M4zbARBj6wU0TLrYeR73vcdX8zjJj5Hp YhKrOnfFVBnMRx5et98NkBfWug== X-Received: by 2002:a17:906:fc6:b0:72f:d080:416 with SMTP id c6-20020a1709060fc600b0072fd0800416mr2995012ejk.1.1663322068752; Fri, 16 Sep 2022 02:54:28 -0700 (PDT) Received: from localhost (guests-out.ms.mff.cuni.cz. [195.113.20.231]) by smtp.gmail.com with ESMTPSA id x17-20020a170906297100b0074136cac2e7sm9984592ejd.81.2022.09.16.02.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 02:54:28 -0700 (PDT) Date: Fri, 16 Sep 2022 02:54:28 -0700 (PDT) X-Google-Original-Date: Fri, 16 Sep 2022 02:54:22 PDT (-0700) Subject: Re: [PATCH v2] riscv: ztso: disallow elf binaries needing TSO In-Reply-To: <9b9ff287-75e5-3ee5-e6c5-1daca6c562dc@microchip.com> CC: Vineet Gupta , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, cmuellner@ventanamicro.com, linux@rivosinc.com From: Palmer Dabbelt To: Conor.Dooley@microchip.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Thu, 15 Sep 2022 23:58:05 PDT (-0700), Conor.Dooley@microchip.com wrote: > On 16/09/2022 07:34, Conor Dooley wrote: >> On 16/09/2022 05:23, Vineet Gupta wrote: >>> [You don't often get email from vineetg@rivosinc.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] >>> >>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe >>> >>> As of now the software stack needs work to support ztso. Until that work >>> is finished, disallow binaries needing TSO. >>> >>> This patch is needed to help ztso ratification and prolifiration of tso >>> bits in tooling. >> >> I have to admit to being a little confused here, if Ztso is not ratified >> why do we need to protect ourselves from it? > > Also, since this is not marked as a fix, why would we not just apply the > patchset from Palmer that looks like a more complete version of this > patch: > https://lore.kernel.org/linux-riscv/20220902034352.8825-1-palmer@rivosinc.com/ > > Maybe you could offer an R-b or some comments on that patch instead? IMO that's the better way to go, Ztso is frozen so we can expect software to start using it. Might as well let it run if the machine is going to be TSO anyway (and IIRC some of the T-Head stuff either is or can be TSO, so we'll need to detection soon anyway). I was also planning on re-spinning the QEMU stuff so we can test it, but given how simple the Linux patch is I think it's fine to just go ahead and take it. Happy to hear any comments, though. > > Thanks, > Conor. > >> >>> >>> Signed-off-by: Vineet Gupta >>> --- >>> Changes since v1 >>>    - Build error (and boot tested on qemu) >>>    - Improved the comments a bit >>> --- >>>   arch/riscv/include/asm/elf.h      | 11 ++++++++++- >>>   arch/riscv/include/uapi/asm/elf.h |  2 ++ >>>   2 files changed, 12 insertions(+), 1 deletion(-) >>> >>> diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h >>> index f53c40026c7a..b6b4542b3039 100644 >>> --- a/arch/riscv/include/asm/elf.h >>> +++ b/arch/riscv/include/asm/elf.h >>> @@ -26,10 +26,19 @@ >>> >>>   #define ELF_DATA       ELFDATA2LSB >>> >>> +/* >>> + * Make sure the elf being loaded is compatible with extensions. >>> + * >>> + * In the final incarnation this will get the extension list from DT and >>> + * make sure elf can run on given hardware+kernel. >>> + * For now disallow TSO built binaries. >>> + */ >>> +#define rv_ext_ok(x)   (!((x)->e_flags & EF_RISCV_TSO)) >>> + >>>   /* >>>    * This is used to ensure we don't load something for the wrong architecture. >>>    */ >>> -#define elf_check_arch(x) ((x)->e_machine == EM_RISCV) >>> +#define elf_check_arch(x) ((x)->e_machine == EM_RISCV && rv_ext_ok(x)) >>> >>>   #define CORE_DUMP_USE_REGSET >>>   #define ELF_EXEC_PAGESIZE      (PAGE_SIZE) >>> diff --git a/arch/riscv/include/uapi/asm/elf.h b/arch/riscv/include/uapi/asm/elf.h >>> index d696d6610231..fa9e4c52c7ac 100644 >>> --- a/arch/riscv/include/uapi/asm/elf.h >>> +++ b/arch/riscv/include/uapi/asm/elf.h >>> @@ -32,6 +32,8 @@ typedef union __riscv_fp_state elf_fpregset_t; >>>   #define ELF_RISCV_R_TYPE(r_info)       ELF32_R_TYPE(r_info) >>>   #endif >>> >>> +#define EF_RISCV_TSO           (1 << 3) >> >> s/EF/ELF ? >> >> Thanks, >> Conor. >> >>> + >>>   /* >>>    * RISC-V relocation types >>>    */ >>> -- >>> 2.34.1 >>> >>> >>> _______________________________________________ >>> linux-riscv mailing list >>> linux-riscv@lists.infradead.org >>> http://lists.infradead.org/mailman/listinfo/linux-riscv >> >