Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2292184pxb; Wed, 9 Feb 2022 15:20:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2NbG+CHh5QKYjlY6qXkhzMZ5WVOiRvjgoAGeWOUkdCUTTwRy/5gcksNdAr4oQ/uc0TgNx X-Received: by 2002:a65:6a55:: with SMTP id o21mr659040pgu.409.1644448855855; Wed, 09 Feb 2022 15:20:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644448855; cv=none; d=google.com; s=arc-20160816; b=cL8rCA51dH3/YqwBy6rhyiVibFXcNgzgccRjujN2kzfYHm73/qCp5XapJHNk+6CKjU 5wdLmIYNrncQQJykK3HRgtkEUTY6EfuqwgPpzCppTGsRcE500pT1BK/JkWWJj3ymxR+Q 9XA2XhL/TuQmTalJUmtKII4d5kc84Zu2Ra3bfIWWVO/U3R2Q83bl7nutF5WDrfe4+P1f X8S6Gp7pH8j4aWHQejcv6r7tadt4URmEw9AC2s/dpcj4M7sFccO+InjqStkXfXNotHal 8PBBiU411lc+lt5lEN9/fDyv+OTvdl4x/gTJvf7oyFVp0yh5jtmrmIU7mNkOhfhI+qpL LwdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=Yu7rnLL3w7P71+brwsaJd8fgIjDrLF6hoK9ARSWM5ps=; b=sT7Awzra5L1YuBLjQKC0SdnJy3s+1M+ZXjF/Exx/LJYVT+PSZwXCp1ZGWbrL7YnZTA j3YzJO4/l826L5XHQVlYSnkNv0t2JBWQyWLZN6AZha+FfIVbcmf5UhGzYLc01J3xYAoX pTqU/oMKr2/cW1Kzo8isLQOMFkp1WWvNHUqSAzIN6ahQVsnxmykly/vQau3rZ7w1tdLB GDEIOxNEAG/OFWxAW/d15hEHQxvzdEV89JKurTSnoeCiPobkPE6vRJds0YCO2pSfyido cuKz6ZKWapgu12Xga5+B3Gq3noX7gYvXQiWIkOn8UXBo3kJLtIx+SbuPAfiJz2FVQuIC fEcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lly4Pgpp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k7si5981490pjm.137.2022.02.09.15.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 15:20:55 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lly4Pgpp; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 85D19E057C3E; Wed, 9 Feb 2022 15:17:27 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235708AbiBIW2r (ORCPT + 99 others); Wed, 9 Feb 2022 17:28:47 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:57790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235632AbiBIW2Z (ORCPT ); Wed, 9 Feb 2022 17:28:25 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86480E01A2DD; Wed, 9 Feb 2022 14:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644445677; x=1675981677; h=message-id:date:mime-version:to:cc:references:from: subject:in-reply-to:content-transfer-encoding; bh=SfeEZ6Op0bvafHg5MlJ6fjdSi90N4yjAydK+PCRbadk=; b=lly4Pgpp4F2zK0o/xha6ocMtS/XxRo1XzPkLQ2tCtu17LSx0wu34pJrw uOkr52lfHWnHNO7wrwas5AzAgoHk/a2k2KaubN38xYrLC20HgYFFRHO0Q fAxiC2S9gkb0bff4S0hrYkhKrGko3Ls9dfOcgCiMizHZZffGEDhmg1yHk 1zcmSMJ0ePiUKYN2X5TAgGHfdX9wWeuYiG5n6f8nt72MqbmOrjUytZYHN Uwgd1Rz/0cBTED8y+AsSsApbls5l2kM3wVQMbHiQmSiDRkOHApzzU0eK+ u6dN7qe4BkhpeC2FjL9Lmi3O7BHC4CFelB/KmXL8IwIbBCKXYlb9y3+P5 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10253"; a="230003811" X-IronPort-AV: E=Sophos;i="5.88,356,1635231600"; d="scan'208";a="230003811" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 14:27:57 -0800 X-IronPort-AV: E=Sophos;i="5.88,356,1635231600"; d="scan'208";a="585744850" Received: from sanvery-mobl.amr.corp.intel.com (HELO [10.212.232.139]) ([10.212.232.139]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 14:27:55 -0800 Message-ID: <804adbac-61e6-0fd2-f726-5735fb290199@intel.com> Date: Wed, 9 Feb 2022 14:27:53 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US To: Rick Edgecombe , x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V . Shankar" , Dave Martin , Weijiang Yang , "Kirill A . Shutemov" , joao.moreira@intel.com, John Allen , kcc@google.com, eranian@google.com Cc: Yu-cheng Yu References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> <20220130211838.8382-20-rick.p.edgecombe@intel.com> From: Dave Hansen Subject: Re: [PATCH 19/35] mm/mmap: Add shadow stack pages to memory accounting In-Reply-To: <20220130211838.8382-20-rick.p.edgecombe@intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 1/30/22 13:18, Rick Edgecombe wrote: > +bool is_shadow_stack_mapping(vm_flags_t vm_flags) > +{ > + return vm_flags & VM_SHADOW_STACK; > +} > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index bc8713a76e03..21fdb1273571 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -911,6 +911,14 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma, > __ptep_modify_prot_commit(vma, addr, ptep, pte); > } > #endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */ > + > +#ifndef is_shadow_stack_mapping > +static inline bool is_shadow_stack_mapping(vm_flags_t vm_flags) > +{ > + return false; > +} > +#endif Hold your horses there. Remember: +#ifdef CONFIG_X86_SHADOW_STACK +# define VM_SHADOW_STACK VM_HIGH_ARCH_5 +#else +# define VM_SHADOW_STACK VM_NONE +#endif Plus: #define VM_NONE 0x00000000 That means the arch-generic version, when CONFIG_X86_SHADOW_STACK is off compiles down to: bool is_shadow_stack_mapping(vm_flags_t vm_flags) { return vm_flags & 0x00000000; } I _suspect_ the compiler *might* compile that down to the same thing as: return false; So, why not just have one version, no additional #ifdefs, and be done with it? Heck, why have the helper in the first place? Just check VM_SHADOW_STACK directly.