Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2786183rwi; Fri, 21 Oct 2022 07:56:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5KeXqPn3dw8njGyWd/pFcxuDTmmYVaVP+ViEG0qbVo3XRz8PtwJS1i1idehmGOX6SaW/dq X-Received: by 2002:a17:907:744:b0:741:36b9:d2cc with SMTP id xc4-20020a170907074400b0074136b9d2ccmr15221235ejb.613.1666364197145; Fri, 21 Oct 2022 07:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666364197; cv=none; d=google.com; s=arc-20160816; b=Aob6nS1QUXjtwXqvuq4ZoBh1Ew4KMNTAtL9gvwOV1NClHQBh898WCXFRoP6bl86txE EfNywkhLOV/XsJD4+vv8HcvhxOpGI2KsYLQ9skpxo/Yvaa3XrjP81VoPCvk+mIXiLBzH 7n6h86ybt/McDog0kqWxphpCSfNy/NTVb54SSrpdfVwVM2GAPJRCRzRz5ZKaoLolo7vL e5a40XuBFfoxVmkeVip0bGgonNbOIQXbt7QewZ+zpl7rMgdsiCVjwL5W37/J5k8n6dSp t977+Vgwl8OJ42n5Xt9RfMhuc/aHDHNdHFFaExvhrfCTzDVoUA+Zg9b4eZf35A23TwkG K6UA== 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=icOrxZK3JkcCB2/8wol99s3eFUO3Z6JKuXVhNulix7U=; b=ZV7tO/KrkMrlD57dBMoi3eSvg26jQ2vqMpUHuUDUgmxWe0EnRadDNgbBA0/F+a0mWM bJU9+urU1gFpPb0+PItVck0kVZajIPV8MjuXwzNI4Oe3KDaCYz4hqq5KzdviGryC9xmd 6yhpTHPT1grgoJTu/fFWS1JzeqWfi2Dl3kc/iBVx00k4ud3XKuE5g62qafN3JEHYJ+Ay FYTFMoGxmQ8MNXweqQ7ahigdXCDo4/b5univDY6PaaoDPT1c7kNbw8bFUJlSet6DZ+k2 EvQEL+51WYiIEGgxqeYe3GSqQy1pCCbbGp3PkUfElWE8hZfq3FvHLpwmk0u8wYvsfa+c Wctw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kN8e2I0x; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr21-20020a170906d55500b00780837381d8si21213698ejc.591.2022.10.21.07.56.07; Fri, 21 Oct 2022 07:56:37 -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=@kernel.org header.s=k20201202 header.b=kN8e2I0x; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbiJUOlt (ORCPT + 99 others); Fri, 21 Oct 2022 10:41:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbiJUOlr (ORCPT ); Fri, 21 Oct 2022 10:41:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 086583AE5B for ; Fri, 21 Oct 2022 07:41:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 987C561E9B for ; Fri, 21 Oct 2022 14:41:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 018BEC43470 for ; Fri, 21 Oct 2022 14:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666363306; bh=ropLClIeHzFRkVhJYXOsh1KnHR2hkSkJ7NM6ho2IP+c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kN8e2I0x6jmgx9kop7mSITV8Rqm4QU+8c0Be7/Bb/5PC5JQ6zoN1hL/hIAOSqU4o1 GSAAHt9qf0c9TVi6ksvMUh5ki00dahMuKNSmlO/bDY+0IErGYa3jPBmdPi0xT1D8sz 0a002Vdep6v2Nl89ppHI3kiqyI9CW8iGERxdB4bJxQUp9ZUzunzGt04Inx8Fh57afD pXzsN1NSaSEDNxiWQcO2T8k2WvRDdyh3LWbG4HgO3RUlWwl4O09NzTLUkvM2REZTON UEEFZQg6GV7jzAXat4R3OinHjqQwKwTpQPMc4gqsinKcnavd/WlwQlS66K+KLEhsaJ FMqXcYT/zl6SQ== Received: by mail-oi1-f180.google.com with SMTP id n130so3437789oia.6 for ; Fri, 21 Oct 2022 07:41:45 -0700 (PDT) X-Gm-Message-State: ACrzQf20zNWeVyRnUYPNhsm+fq8AMFk+QEeC0WRXHj5AMbm8sMovy1K6 D8RDmRWe+sUNw7kup2Z5cLnZqeD8GPAYVmrk3kM= X-Received: by 2002:a05:6808:2222:b0:354:9c65:79ed with SMTP id bd34-20020a056808222200b003549c6579edmr23550708oib.19.1666363305134; Fri, 21 Oct 2022 07:41:45 -0700 (PDT) MIME-Version: 1.0 References: <20221019154727.2395-1-jszhang@kernel.org> In-Reply-To: From: Guo Ren Date: Fri, 21 Oct 2022 22:41:33 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] riscv: fix race when vmap stack overflow To: Tong Tiangen Cc: Andrea Parri , Jisheng Zhang , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Fri, Oct 21, 2022 at 9:46 PM Tong Tiangen wrote= : > > > > =E5=9C=A8 2022/10/21 21:22, Andrea Parri =E5=86=99=E9=81=93: > > Hi Tong, > > > >>>> I use atomic_set_release here, because I need earlier memory > >>>> operations finished to make sure the sp is ready then set the spin > >>>> flag. > > > >> Consider this implementation:) > >> > >> smp_store_mb(&spin_shadow_stack, 0); > > > > smp_store_mb() has "WRITE_ONCE(); smp_mb()" semantics; so it doesn't > > guarantee that the store to spin_shadow_stack is ordered after program > > -order earlier memory accesses. > > > > Andrea > > . > > Hi Andrea: > > IIUC, the earlier memory access amoswap.aqrl, here .aqrl guarantee it. > But anyway, consider we don't care about performance here, using > smp_store_release()(add barrier()) surely right. We use smp_store_release() is for: //load per-cpu overflow stack REG_L sp, -8(sp) Not amoswap. Actually, amoswap.aqrl guarantees nothing because all instructions depend on the sp register. > > Thanks, > Tong. --=20 Best Regards Guo Ren