Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1912311rwb; Wed, 5 Oct 2022 06:39:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XJkFsX6rCe4kksb7kog7TpJUgqz+OOBYx6NshrmLBm9OCUFb3w+QHz9Ku616IVpSnCke9 X-Received: by 2002:a17:906:9be7:b0:78d:2b40:1031 with SMTP id de39-20020a1709069be700b0078d2b401031mr2705804ejc.350.1664977148144; Wed, 05 Oct 2022 06:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664977148; cv=none; d=google.com; s=arc-20160816; b=CkKE+9saL5f3OkCl8KRCweKMSvXtXb6jkQ5VCiIYKd3xu2J6xYujie36hAc9lr+7eC rbW2ouO98X3fAUyZ981tCjDbcOf/t7X3/WFrnQwoGXtwvG6Bp8cUX0M6S4UKvMY4KWUT tkiTRlQXAx0uFBnCN1lCNBtt+GNsQD+N5xn77b3yMcmJQj0aDha+qC0rMxAdSZQ/eBs3 OjS9EXkF862+4OtaVFlniyYwl/34zzxKOPZrLXrnILe51jdagaAcQvJVzUfJ9OUkQudB 80rAeBeM4R4Ao75KUZHP/zLfNed9P/hNZbQpT26oRuUvvyZhiukKn3HDA184BThE98H+ myBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=nOf6yNlIvThxJiOhXlH7Dy5f5P3Ef/MhfYC4AtZdhms=; b=HPmWgIexJpOOm+OK9ib/a0Sw/yR+x3LR4NhTCAsHtLC02oRr26uod9/+4aYlOjSfOH zUq2b/WJ5vVZUkoNGxHk3l+bGQJVI5Qmr+vzbp9mxuZ8k5eCuNAYvb+2FP0QnsBJy0Bl XQHlFwEv/8olIB6/2vJU9q0XDM7iHdf8e2Qs2bO1LOujTpXUJer1Ol5fOpZUMl8ATHZl 9Ysjm9OoH5RIZui/7u44U7XwyEkPY0CRbPULL6Q6iQglIR5rMSpicwMaBErxwHocdR8O Eb/cIbQKLk0aTQi4vtiUK8bFe/S9Lt1eUcDorKZluScqpUkIwWdu0/fdo6FM77SHsyQe GlOA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw11-20020a1709066a0b00b00782ece08669si14670064ejc.13.2022.10.05.06.38.42; Wed, 05 Oct 2022 06:39:08 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbiJENdD convert rfc822-to-8bit (ORCPT + 99 others); Wed, 5 Oct 2022 09:33:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbiJENdA (ORCPT ); Wed, 5 Oct 2022 09:33:00 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A987A51E for ; Wed, 5 Oct 2022 06:32:58 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-220-Ey5VsqheNgyO3SFDIVsBNQ-1; Wed, 05 Oct 2022 14:32:55 +0100 X-MC-Unique: Ey5VsqheNgyO3SFDIVsBNQ-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.38; Wed, 5 Oct 2022 14:32:53 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.040; Wed, 5 Oct 2022 14:32:53 +0100 From: David Laight To: 'Kees Cook' CC: 'Dave Hansen' , 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 , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V . Shankar" , Weijiang Yang , "Kirill A . Shutemov" , "joao.moreira@intel.com" , John Allen , "kcc@google.com" , "eranian@google.com" , "rppt@kernel.org" , "jamorris@linux.microsoft.com" , "dethoma@microsoft.com" , Yu-cheng Yu Subject: RE: [PATCH v2 24/39] x86/cet/shstk: Add user-mode shadow stack support Thread-Topic: [PATCH v2 24/39] x86/cet/shstk: Add user-mode shadow stack support Thread-Index: AQHY12Njz3/HZpf9jkaO+WwIiUYgJ63+BXnggACK/wCAAT4eAA== Date: Wed, 5 Oct 2022 13:32:53 +0000 Message-ID: References: <20220929222936.14584-1-rick.p.edgecombe@intel.com> <20220929222936.14584-25-rick.p.edgecombe@intel.com> <202210031203.EB0DC0B7DD@keescook> <474d3aca-0cf0-8962-432b-77ac914cc563@intel.com> <4b9c6208d1174c27a795cef487eb97b5@AcuMS.aculab.com> <202210041229.99F8CB38B@keescook> In-Reply-To: <202210041229.99F8CB38B@keescook> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 From: Kees Cook > Sent: 04 October 2022 20:32 ... > Oh, yes! I do this all the time with FORTIFY shenanigans. Right, so, > instead of a macro, the "cannot be un-inlined" could be enforced with > this (untested): > > static __always_inline void set_clr_bits_msrl(u32 msr, u64 set, u64 clear) > { > u64 val, new_val; > > BUILD_BUG_ON(!__builtin_constant_p(msr) || > !__builtin_constant_p(set) || > !__builtin_constant_p(clear)); You can reduce the amount of text the brain has to parse by using: BUILD_BUG_ON(!__builtin_constant_p(msr + set + clear)); Just requires the brain to do a quick 'oh yes'... David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)