Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5974551rwb; Tue, 1 Aug 2023 10:21:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHG/vbIiuX337Yt3JqRzBewFX9z93qlbn3atCFC2dkmsI1Gm0C4Ngu4C+aO7nOkogVg4KNP X-Received: by 2002:a05:6a21:a109:b0:127:76ab:a707 with SMTP id aq9-20020a056a21a10900b0012776aba707mr11128216pzc.30.1690910476779; Tue, 01 Aug 2023 10:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690910476; cv=none; d=google.com; s=arc-20160816; b=s+wf9NhevioLr4FSsnWAps0t5iE5YLcU0Aytnqf4WdB5uBP9WX8u0nI70lF2V4hdkr k/b2JNYC93UsUsNmQX4WhjKPTEcwJXYKOEjjUm0RxIji2ce3Ui4AREvTYa4vZstOR2aX 4JXB9d/RtXs6ShD7z2Aox62LEWrdZUy2C/juMgGCBd5NzrJjXG7ujvWakW5WQD7z4KVM LBKpfk5TE1FYNtQ8FPcJ22ZjKGwDIpvtm3B398tRoR28s1GeSN7mKHYuLxK4BsdwI8Ft h0R4+k6CyDft4CoCoRfuXj8hTGoeUWSePPX5mk5eRaI0k36NIQ8+jFkINuYzAoZFR5Lh TBUA== 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=rNqqoE7VYu9ueVY1r+VjeKbX/tuKgWJmH4QZB2iVOcU=; fh=ftlHRuJ5/ZArKI7a/HVutviFcs2zMDcn+5TXYZGM9pY=; b=lw/EpYCGtOmxYe+uqYlOEXibCNI5oKrmF17vkq2kP/apUREBRspC6OR2XCEr/Kki3+ 7a4uSZidv8CERJ10MZAz25CCNEo2i9/AoB0uVoxxu+HG5uOSzJf4EfFOH3EcF1ohnpFs 0n8n2MAcxal8VMieaoNSA0nceXoAsvU6XHZ2LEls9u+LujIEXn561P0JdCt3rWs8cjtn 5XsXmFGqDpmRW3jBrswCQRfSzRQHM56y7PWDrf4MtKNg81sid8paBXe/QdjwHzC4AzkM Ai2oPFBFiCJGnw2bscH1IEjdc9xLfKQNpAWAu53I2t12GbiD2Bw7UPUWHISycauKDvUW UKcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AA0UkNhQ; 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 b23-20020a63d817000000b00563d7685903si9390145pgh.703.2023.08.01.10.21.04; Tue, 01 Aug 2023 10:21:16 -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=AA0UkNhQ; 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 S233948AbjHARDo (ORCPT + 99 others); Tue, 1 Aug 2023 13:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233873AbjHARD1 (ORCPT ); Tue, 1 Aug 2023 13:03:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75FBF270B; Tue, 1 Aug 2023 10:03:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83F116164B; Tue, 1 Aug 2023 17:03:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14158C433C8; Tue, 1 Aug 2023 17:03:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690909400; bh=n2/9ktpmINrFVuBWg1KAR2bAcG2NpG4kfEtaUDByDfs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AA0UkNhQxwECDyCEaDtc6JhBhvuvyCYYCaSh4HblOm5/sFOqJy8oy4lzt1PHsqe/d TNp/HD+vd9HlKtv5qMTIS+koyMnH6IxwcAdwNwXp4F5+zwZgvrnFbpNoU+QmQ8b5J3 ddlGURjkJRGzvvXYAv/2/xdGEsvIazcCS7ipemT/wemv7xW5NPdaO+scLqNwkzr3kd QYfygusILQtsW8OYGbFyAk8m/i1xYFxg47ufEb41rqQx5La8ZysCvnd1hWLGpVELSo 6atnVwdyqVnvxRrlqLIxYCR2TAHb6qdezWZ2QfOYTjqX/DgeT6WtV9UpJOx4DAmJz+ ldxqcY8ezOQig== Date: Tue, 1 Aug 2023 20:02:31 +0300 From: Mike Rapoport To: Mark Brown Cc: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v3 11/36] arm64/mm: Map pages for guarded control stack Message-ID: <20230801170231.GC2607694@kernel.org> References: <20230731-arm64-gcs-v3-0-cddf9f980d98@kernel.org> <20230731-arm64-gcs-v3-11-cddf9f980d98@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230731-arm64-gcs-v3-11-cddf9f980d98@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 Mon, Jul 31, 2023 at 02:43:20PM +0100, Mark Brown wrote: > Map pages flagged as being part of a GCS as such rather than using the > full set of generic VM flags. > > This is done using a conditional rather than extending the size of > protection_map since that would make for a very sparse array. > > Signed-off-by: Mark Brown > --- > arch/arm64/mm/mmap.c | 17 ++++++++++++++++- > 1 file changed, 16 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/mm/mmap.c b/arch/arm64/mm/mmap.c > index 8f5b7ce857ed..e2ca770920ed 100644 > --- a/arch/arm64/mm/mmap.c > +++ b/arch/arm64/mm/mmap.c > @@ -79,8 +79,23 @@ arch_initcall(adjust_protection_map); > > pgprot_t vm_get_page_prot(unsigned long vm_flags) > { > - pteval_t prot = pgprot_val(protection_map[vm_flags & > + pteval_t prot; > + > + /* > + * If this is a GCS then only interpret VM_WRITE. > + * > + * TODO: Just make protection_map[] bigger? Nothing seems > + * ideal here. > + */ I think extending protection_map and updating adjust_protection_map() is cleaner and probably faster. > + if (system_supports_gcs() && (vm_flags & VM_SHADOW_STACK)) { > + if (vm_flags & VM_WRITE) > + prot = _PAGE_GCS; > + else > + prot = _PAGE_GCS_RO; > + } else { > + prot = pgprot_val(protection_map[vm_flags & > (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]); > + } > > if (vm_flags & VM_ARM64_BTI) > prot |= PTE_GP; > > -- > 2.30.2 > > -- Sincerely yours, Mike.