From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AABDC00528 for ; Tue, 1 Aug 2023 17:03:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234302AbjHARDn (ORCPT ); Tue, 1 Aug 2023 13:03:43 -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> Precedence: bulk List-ID: X-Mailing-List: linux-arch@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.