Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3364777rwo; Mon, 24 Jul 2023 09:55:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFYnE1RGdDs95lhTrmlejkPaWQRFksINk/mPIRXs4FNn1Xd5s9/PQpg4sa6P3BmSAkjSht8 X-Received: by 2002:a17:902:f7d4:b0:1bb:a834:696 with SMTP id h20-20020a170902f7d400b001bba8340696mr1412771plw.29.1690217731840; Mon, 24 Jul 2023 09:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690217731; cv=none; d=google.com; s=arc-20160816; b=HaAcNGTckD3ZybD2r82dhLKuwlG5G9/iXTkLldVPXvOoRUbKqnxArGW/eBCviQUeb7 1a4hDIN+GNc1TYeUSTiz+ADbBAzYxnHXFe81VpZ9xyVoWH1odEmk3fhTYnThzavjA8o6 WBj9iMKENUV46xjdVTTwyr4PEdGv+CxdZ7/hRf/yxBhSxSFMgLKrjn889/whn/Ex0mdz qwSCe3NhxfmGr3vdKbvprxIuUImml/JilRTYiido9pbetu/FgDSu6DbjOmo7tO0RhhOx ihr1ywyaffuRMZJjJPIOnU/h2/6G+cPoAmwq+I7dasz7SVElFQiEgW+AkX2OENaFZssO DV8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=L0f7dDULSRSGbAiEBcGCpBzTqX0S4cgJ92lbxxwD/4M=; fh=rVlQbbOqwFIADCXKz8AT6hIvjGHVrHw4QnKhHTgfW+I=; b=LBAJjxkGy9d7DQr/UYeBnS5UYBl4JfA3SoQt69NhsiXIxQNbceDR1pelKpnwR21ied tMzelQaGNn0jQBnXuiIKLAdK8sRqhV4z9wGRQsH+s2nRioRh1sxKxCfXeAgwsM2Ph2By Cr/FFT7hgsJFpzqxULjEKUwIk9TFR4NsnlB5BgWBDk85FrMj1+CMAnATBERcPRm7TPyo MVaNL5hBM65JBEv2A8SH91mWsiSeecT8GUBlR4gMOXqox1BMkiOOyOTCWLI7pXjzkUfM n26PPAhkFyFX7vtuTNLlicVVFMTDCFC1yKA91aXT9x3Lipi5uA8UF+PvFSpIzyNLsiqU xdcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=G0xhoaWq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a170902d4d100b001bba3bfd21asi2530246plg.260.2023.07.24.09.55.18; Mon, 24 Jul 2023 09:55:31 -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=@google.com header.s=20221208 header.b=G0xhoaWq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbjGXQep (ORCPT + 99 others); Mon, 24 Jul 2023 12:34:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231260AbjGXQen (ORCPT ); Mon, 24 Jul 2023 12:34:43 -0400 Received: from mail-oi1-x22e.google.com (mail-oi1-x22e.google.com [IPv6:2607:f8b0:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4991E53 for ; Mon, 24 Jul 2023 09:34:41 -0700 (PDT) Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3a5ad21a1f9so923732b6e.2 for ; Mon, 24 Jul 2023 09:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690216481; x=1690821281; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=L0f7dDULSRSGbAiEBcGCpBzTqX0S4cgJ92lbxxwD/4M=; b=G0xhoaWqCsA49wfGwRvWd3+cpyYiXn3zFV4GCVj2lRlGOBDB+NohaPhagTznarEdVf eBGN9YqI39qIUwiWiMicV/0u7Y8NkEONBFzjlZiuRyrZPbP/9CKN0poTBNP/4Y586IjX HBIEM/KZbHmUU0K2FsYMz66CvUJW5//bEsmJDTm56Qu/E3dBZUUa63FHP7vDhixLaEqg 3VCsV9xvoJiQVrixrKfi19YCtZPg+GFuK3Y6MVUbtNZzecL+mvpvlcskhUTkNSjwcpeV 43zdG2u2rNa40fvxl6Wg7IXxc8KEYozgxXQjOzHqJ/khKKQEDXx8yb+5ycpSSYfhCtAT 4fzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690216481; x=1690821281; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L0f7dDULSRSGbAiEBcGCpBzTqX0S4cgJ92lbxxwD/4M=; b=Ihz5gtkKdf+5TwrNynPF84R/xebj7OjhQ4ygtrmUkLmqeedszaIHWdEaz3iha1ZD5D ZIEW+/IiL8OA3qqWMEtplUYoVkQXYHNvzccyErVWWoth9uSmcg6x/SbniZQynuac81pN 2bPrEI6aBUSLAlj5eWjArAk36jXEHfWZUSwtUk5DFrf3bm1yx/4KWcth9xY/zpuIJdbi KItZ4O5CtMZBvvKpJUpwvBERIY7KQ/FGuv1j963x8jgA2m/A4pCmfDXI8LRkkKMQblaw jvi+IG0TGIRaMHD0xrOSra4vgnEotjoYnM8j1IQj8IzwTMKk8WpPQonEVT1pcb7eaAbN Vr7A== X-Gm-Message-State: ABy/qLaC3Px9TzgiDtse3KrFnd/1AdnXt5a2A4BJ28XdIteltPcwu27y 9z/rZ+1Z/kL1MXV8nJph1OBYZDOBZATl1mOk/bsEjw== X-Received: by 2002:a05:6808:1389:b0:3a4:8a13:98a1 with SMTP id c9-20020a056808138900b003a48a1398a1mr14481780oiw.49.1690216480904; Mon, 24 Jul 2023 09:34:40 -0700 (PDT) MIME-Version: 1.0 References: <20221124094845.1907443-1-debug@rivosinc.com> <20230720001852.GA572618@google.com> In-Reply-To: From: Sami Tolvanen Date: Mon, 24 Jul 2023 09:34:04 -0700 Message-ID: Subject: Re: [PATCH v2] riscv: VMAP_STACK overflow detection thread-safe To: Guo Ren Cc: Deepak Gupta , palmer@dabbelt.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Jisheng Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Jul 20, 2023 at 8:06=E2=80=AFAM Guo Ren wrote: > > On Thu, Jul 20, 2023 at 8:19=E2=80=AFAM Sami Tolvanen wrote: > > > > Are you planning on resending this patch? I see it didn't gain much > > traction last time, but this looks like a much cleaner solution for > > selecting the overflow stack than having a `shadow_stack` and calling > > to C to compute the per-CPU offset. The asm_per_cpu macro also would > > come in handy when implementing CONFIG_SHADOW_CALL_STACK, which we'd > > like to have on RISC-V too. > I remember we ended up with an atomic lock mechanism instead of percpu > offset, so what's the benefit of percpu style in overflow_stack path? The benefit is not needing a separate temporary stack and locks just to compute the per-CPU offset. With CONFIG_SHADOW_CALL_STACK, we would also need a "shadow" shadow call stack in this case before calling to C code, at which point computing the offsets directly in assembly is just significantly cleaner and without concurrency issues. Sami