Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp222107rwb; Mon, 26 Sep 2022 17:41:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5T43gnaswT9TiwNi/dKS/D6sGtQRMs7UvZtOVVAgqPJzwYjCeoj0qCaa8SNG73mS/O3n9Z X-Received: by 2002:a17:907:2d2a:b0:782:3b7d:a848 with SMTP id gs42-20020a1709072d2a00b007823b7da848mr19915554ejc.569.1664239261985; Mon, 26 Sep 2022 17:41:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664239261; cv=none; d=google.com; s=arc-20160816; b=Avbc13v58pGc6cJVDvpKqVWhwZmBczZvbe9JAJSs/fgxVKKrXlfHZTKPqugxqhLi6F Ap77Ff437pPPA87hk4Q+WiuRsapstLhbUPHEjAJuRXWRVwRi4VGsLbALaN1pqvG1vDUV 0SxLIO561EHrYksDHoTGWK6/0aZIbP6ukEMMbAu+p0QdgjZm+0Vyt77xrGB/sl9Pm1wq oMBYKIZkD8RVg2m+wssGW5xRJy5m1pleEqFFF04ukqrO5hzah6m12FEBs7kwpOeuHATj 7UWbB42Pm4pCmIshY8JEWyu8iaeuFjGDujlRMIJoZdlTSWxAKuHMYk2wpmmMKHJHM9WL e8XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e3EFDm+T82hxyncI9jeToko6qY7+KcRPCey/YNyUolg=; b=Qk213Z/qQsuGFC2AIEjcavfq/RHaRXn1HktUFE+FJVXJKLyFQdJPFrML4B1sPzCrxc 7mgdxX2KC1Z1F3CpoGMIg5SvE5SYqjsWMiaki0Ccic2yPaBOLJadlto6yDdPEjKOEa+6 it1wP6RoGpsMLRbke/6p/9j8SZJkaFnI3NpuZRy1xzxfO9Lzplda+IFHxg3jPipHav37 sXvHM9pZ1JxPAIZPsfgy3dv0VwMyJ6izTyDBP1IPU+0kjEYF4lEPVgS5lY7nAFjINIM+ 21b97hnWpF42fTooXZAt930KBAHcpC4WIQGcbYcPJ72ejest1WrpQjz0JxWlxVCB4tgj AXAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JrBcJhnw; 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 y9-20020a056402270900b0044f1b7b8713si205074edd.281.2022.09.26.17.40.34; Mon, 26 Sep 2022 17:41:01 -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=JrBcJhnw; 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 S229834AbiI0A2L (ORCPT + 99 others); Mon, 26 Sep 2022 20:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbiI0A2I (ORCPT ); Mon, 26 Sep 2022 20:28:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40FC579A73 for ; Mon, 26 Sep 2022 17:28:07 -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 C4DEB61524 for ; Tue, 27 Sep 2022 00:28:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3603AC433D6; Tue, 27 Sep 2022 00:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664238486; bh=196d/MXQhFQtb6lq5NyscBwIT4g5hA6PUW5f6L4dGTo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JrBcJhnw70G986UbtQOdtITn/sEzt1I6kEhCpGaLMYD+O6fYxwWJWlzq7png6q8qV WvsfliYUlQ5myg7DVRJ0qAh6JuB7nDreSL86qUEc3BGbrX0ccxnvv3YrgNWOdlc5Sg iWn8Bi6RigPzYv2HOKbyZkDVtOoRHQlH+Y3XF+V8PgjeLUcNNC40ZvmMOm8e5DNDCi ZWWZToeFdVQK1M6t/TnYV4rPGcP/VtGNPuW1dlv01Xxmg5e6DDXkOLQJ49PMWI9gfX szMz2zEUWhMe/f4fSlrp8OZ8Kadzj5XgZjz2BUvh6+katb6S/64hK1/RalOnFmhVCx S0ZvJwJhHG6XA== Date: Tue, 27 Sep 2022 08:18:38 +0800 From: Jisheng Zhang To: Guo Ren Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Nathan Chancellor , Nick Desaulniers , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH 3/4] riscv: fix race when vmap stack overflow and remove shadow_stack Message-ID: References: <20220925175356.681-1-jszhang@kernel.org> <20220925175356.681-4-jszhang@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.2 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 > > #ifdef CONFIG_VMAP_STACK > > -static DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], > > - overflow_stack)__aligned(16); > > -/* > > - * shadow stack, handled_ kernel_ stack_ overflow(in kernel/entry.S) is used > > - * to get per-cpu overflow stack(get_overflow_stack). > > - */ > > -long shadow_stack[SHADOW_OVERFLOW_STACK_SIZE/sizeof(long)]; > > -asmlinkage unsigned long get_overflow_stack(void) > > -{ > > - return (unsigned long)this_cpu_ptr(overflow_stack) + > > - OVERFLOW_STACK_SIZE; > > -} > > +unsigned long overflow_stack[NR_CPUS][OVERFLOW_STACK_SIZE/sizeof(long)] __aligned(16); If NR_CPUS is large, there's a non-trival memory waste, I have a solution for this case, will send a new version today. Thanks