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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE220C0219E for ; Fri, 7 Feb 2025 22:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wAkIIUYdygpf73fbUWN56sodiWFYgGw6k5Genex7S1U=; b=bAMF5a8ZXQy3WuU5K/KpcIjrP+ DVd73MFcaFP9Qu8au+Tkxi6aPirYlGGVPifgK7WGU9vU+BiDmtGLL5rWynF8xaEp/R0N1SpuFFAxS 5KXWLfbTichzTSGhgb/HdslLWdiwLKFearJImzJxwgoXKZQjWgksNsCgJ4U97fKV8rphSiycln2Lp lgsW4GISwniMgDVlgsyfYPVuzJyLRh398fm6YRh5ap0jazNOUUPyZTESGU4wxr6PijczX3nKYBxqq iAWWtm2SUglKu+Q23MKVgzF0UQ0JvE2dzEUKldT1U9Siz5iCrL9BCMTnsOo0oRiWbG0G6/sQAitWX 4azSw7EA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tgXGs-0000000BSJU-42OI; Fri, 07 Feb 2025 22:56:26 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tgX56-0000000BQq5-04BD for linux-riscv@lists.infradead.org; Fri, 07 Feb 2025 22:44:18 +0000 Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-2fa21145217so3082665a91.3 for ; Fri, 07 Feb 2025 14:44:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1738968255; x=1739573055; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=o2ipDsFh+4Wi6+DfKBkgvbX5MRHqphXmotwjlbhmRh4=; b=WFcKozbZIX+BEd9CQ/KDheMq+wgYXkpTldSUMlLBvPkOYVaes3Z3RU6fbBVPdCvrao Kp9AySjfO4VtSLZ3yEdNdFJn6S2bemYVlzp3pkC+3puczhFaoF5BAoCRztp6eGV+f/WN 0w8YjQyvHcmMdfpxWr3eRjoGngy/WfCXRsNbzRra0TdySzOLxohiWcbKJlW7nylS/0A5 VE69C42HECfyAJxFxkjRxyVvyNkluXFUZ+nzDr8h9q0Vc2by0r+dZX5WVqMebox3pXvB Gw8Sf5YkkbsAnT7+CpHs8AVRu/GxWBJOGycGKqf/ds/fS3CxubydkVldBkyv8+bKlvZG hprg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738968255; x=1739573055; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=o2ipDsFh+4Wi6+DfKBkgvbX5MRHqphXmotwjlbhmRh4=; b=rw5N7PO6sYWpChqiNbCFbCSf4iv0NL1XB66COL2N7lLtIDrjVPwb7N6tHm1N79Q1rN UY7z+pKzeNTCk2hnSVA6/VXhYaxAzVWbhMJHufj+zN+CLUPUb8K9YkveDIWDUvfziKRl EgSLAO52XdMPGpkzTswXCz7jK+6eAR8X/10Uui9B+/U4ocyzrKzPOLmiPwk1h/O3MHzB Lc+silsXPPOpAC+I7Exo35U+JI5Pgd+SmSH1zwGFpSm0ZBRw9ShXCbsD/bT5TmBKe+6/ +NuhsbB0N0INk7jfat0rIELFci93Vo3OIBK1uAyU8yKBkCnn+Q4autWn7uC8k0heKWNr g1pg== X-Forwarded-Encrypted: i=1; AJvYcCVyJIwUGsZISWajcPHdSy3TTezKzLW2jgtTOAa5suIFs+teAY0/E+b4g/nGCfzA+kNqqQxrkEaafDkH/A==@lists.infradead.org X-Gm-Message-State: AOJu0YxX42GHnqadkVHFPxvkngU4xog2AtQOCtFJIMBXsVdUK51cvT+M v+uqgWnZVFg0QV1H1qBe9hVF3cQIHixbK82IbhZQZHNZSP5XVCbFmk5SzglK7mg= X-Gm-Gg: ASbGnctF81IHHeMIZn7jEnGlruEc2+NoJnk0+8ue/LGnU9KLHGB/Yh0EDium9vKgNWd FGOEtKO36ne6XrAXiDQY6TIhuAoZqgVv08CA7osZwcQJcAvrtB+Ns09AobfVxVDDWNr26RBRdtG txZGVCzaflOn/0p9DhxcdDNv2n9a94gHLbQiUU/fb6xugEItajMPhHIhszsbuW256dJVuXjjNrE OltXHogF8SkRJmDX3+buc8BiRMYOw2dDFqSLLzKH4U4ChWtpU+LdmzU+fuInx6neGEV5TPDAhHZ AdBrKMVPSdtbQC3abwgviJniSw== X-Google-Smtp-Source: AGHT+IH0ObGSX9Z5Li4uWD9lYbrpJL6WiQ/fR0RPEu4WFLYzu4KaceG7QOyaNMgDiAsQ/fdeHHOGVA== X-Received: by 2002:a17:90b:19d8:b0:2ee:6d04:9dac with SMTP id 98e67ed59e1d1-2fa243f02dcmr6699334a91.32.1738968254644; Fri, 07 Feb 2025 14:44:14 -0800 (PST) Received: from debug.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2f9bf6f268fsm5069384a91.0.2025.02.07.14.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 14:44:14 -0800 (PST) Date: Fri, 7 Feb 2025 14:44:10 -0800 From: Deepak Gupta To: Vlastimil Babka Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andrew Morton , "Liam R. Howlett" , Lorenzo Stoakes , Paul Walmsley , Palmer Dabbelt , Albert Ou , Conor Dooley , Rob Herring , Krzysztof Kozlowski , Arnd Bergmann , Christian Brauner , Peter Zijlstra , Oleg Nesterov , Eric Biederman , Kees Cook , Jonathan Corbet , Shuah Khan , Jann Horn , Conor Dooley , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, alistair.francis@wdc.com, richard.henderson@linaro.org, jim.shu@sifive.com, andybnac@gmail.com, kito.cheng@sifive.com, charlie@rivosinc.com, atishp@rivosinc.com, evan@rivosinc.com, cleger@rivosinc.com, alexghiti@rivosinc.com, samitolvanen@google.com, broonie@kernel.org, rick.p.edgecombe@intel.com Subject: Re: [PATCH v9 01/26] mm: helper `is_shadow_stack_vma` to check shadow stack vma Message-ID: References: <20250204-v5_user_cfi_series-v9-0-b37a49c5205c@rivosinc.com> <20250204-v5_user_cfi_series-v9-1-b37a49c5205c@rivosinc.com> <6543c6b6-da86-4c10-9b8c-e5fe6f6f7da9@suse.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6543c6b6-da86-4c10-9b8c-e5fe6f6f7da9@suse.cz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250207_144416_327761_4C6F7481 X-CRM114-Status: GOOD ( 21.42 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Fri, Feb 07, 2025 at 10:27:10AM +0100, Vlastimil Babka wrote: >On 2/5/25 02:21, Deepak Gupta wrote: >> VM_SHADOW_STACK (alias to VM_HIGH_ARCH_5) is used to encode shadow stack > >I see that arm GCS uses VM_HIGH_ARCH_6. Stale commit message. I thought I had fixed it. Sorry about that, will fix it. > >> VMA on three architectures (x86 shadow stack, arm GCS and RISC-V shadow > >And RISC-V doesn't define it at all, not even in this patchset, or did I >miss it somewhere? > >> stack). In case architecture doesn't implement shadow stack, it's VM_NONE >> Introducing a helper `is_shadow_stack_vma` to determine shadow stack vma >> or not. > >This looks like an unfinished sentence. As if it was to continue with "... >will allow us to ..." what? > >I'm not against a helper but this changelog is rather confusing and also >code in arch/x86 and arch/arm64 isn't converted to the helper but testing >VM_SHADOW_STACK still. Yes I didn't pay attention during rebase, will update the commit message. > >> Signed-off-by: Deepak Gupta >> Reviewed-by: Mark Brown >> --- >> mm/gup.c | 2 +- >> mm/mmap.c | 2 +- >> mm/vma.h | 10 +++++++--- >> 3 files changed, 9 insertions(+), 5 deletions(-) >> >> diff --git a/mm/gup.c b/mm/gup.c >> index 3883b307780e..8c64f3ff34ab 100644 >> --- a/mm/gup.c >> +++ b/mm/gup.c >> @@ -1291,7 +1291,7 @@ static int check_vma_flags(struct vm_area_struct *vma, unsigned long gup_flags) >> !writable_file_mapping_allowed(vma, gup_flags)) >> return -EFAULT; >> >> - if (!(vm_flags & VM_WRITE) || (vm_flags & VM_SHADOW_STACK)) { >> + if (!(vm_flags & VM_WRITE) || is_shadow_stack_vma(vm_flags)) { >> if (!(gup_flags & FOLL_FORCE)) >> return -EFAULT; >> /* >> diff --git a/mm/mmap.c b/mm/mmap.c >> index cda01071c7b1..7b6be4eec35d 100644 >> --- a/mm/mmap.c >> +++ b/mm/mmap.c >> @@ -648,7 +648,7 @@ SYSCALL_DEFINE1(old_mmap, struct mmap_arg_struct __user *, arg) >> */ >> static inline unsigned long stack_guard_placement(vm_flags_t vm_flags) >> { >> - if (vm_flags & VM_SHADOW_STACK) >> + if (is_shadow_stack_vma(vm_flags)) >> return PAGE_SIZE; >> >> return 0; >> diff --git a/mm/vma.h b/mm/vma.h >> index a2e8710b8c47..47482a25f5c3 100644 >> --- a/mm/vma.h >> +++ b/mm/vma.h >> @@ -278,7 +278,7 @@ static inline struct vm_area_struct *vma_prev_limit(struct vma_iterator *vmi, >> } >> >> /* >> - * These three helpers classifies VMAs for virtual memory accounting. >> + * These four helpers classifies VMAs for virtual memory accounting. >> */ >> >> /* >> @@ -289,6 +289,11 @@ static inline bool is_exec_mapping(vm_flags_t flags) >> return (flags & (VM_EXEC | VM_WRITE | VM_STACK)) == VM_EXEC; >> } >> >> +static inline bool is_shadow_stack_vma(vm_flags_t vm_flags) >> +{ >> + return !!(vm_flags & VM_SHADOW_STACK); >> +} >> + >> /* >> * Stack area (including shadow stacks) >> * >> @@ -297,7 +302,7 @@ static inline bool is_exec_mapping(vm_flags_t flags) >> */ >> static inline bool is_stack_mapping(vm_flags_t flags) >> { >> - return ((flags & VM_STACK) == VM_STACK) || (flags & VM_SHADOW_STACK); >> + return ((flags & VM_STACK) == VM_STACK) || is_shadow_stack_vma(flags); >> } >> >> /* >> @@ -308,7 +313,6 @@ static inline bool is_data_mapping(vm_flags_t flags) >> return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE; >> } >> >> - >> static inline void vma_iter_config(struct vma_iterator *vmi, >> unsigned long index, unsigned long last) >> { >> > _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv