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 E175DC61DA4 for ; Thu, 9 Feb 2023 16:37:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjBIQh6 (ORCPT ); Thu, 9 Feb 2023 11:37:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229767AbjBIQh5 (ORCPT ); Thu, 9 Feb 2023 11:37:57 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23FBA60315 for ; Thu, 9 Feb 2023 08:37:50 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id u9so3437759plf.3 for ; Thu, 09 Feb 2023 08:37:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=I7snu9y4j4ZVL+v+vg+ofabCCqYVVfclBVWkCwWBxUM=; b=ZJMImQuVeGX1qrWI7qRvAabc2z6zOqkLoa+HDwFosiqYCHUrwRbe+UkWPN9c8jmvvW kURGQ2/ysK4XomMeWK8D3M6wAWrG0e6Lz/faB7UAJ2+KFsQvO0rr+C3SPFeGr+0bonxV x5vvkgnDv+5LK6IyN8EhNh43YfnQdIFGjsapI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=I7snu9y4j4ZVL+v+vg+ofabCCqYVVfclBVWkCwWBxUM=; b=yMPg5AWEU5poBbhFe8bqyedn50a5E/ws7z3++uh/XrmSf56eTUJDAvuEfDWZfA5tsY TQL9CsblgD22wU37pQBayBjDHo5Tqq+Xlf0ebONOs1fVhryDGsopMdGA0cFVN2u7H9Lg +Jna99sWlw0Z6yEkOwri7AL9OFknG73n/BUvXk+ghBSm36Ir4Hbzo9JBzFa3ohgWk3FH 6Lw5hnG6U9NdTVLUFufHu7awbXOFz6UZSfNyFy54JncpkUAjLfalIwLLQ6fv8MPH1a4+ T6oLOgBmoyYC5JcclUNDrRP25QHGDapSjXT/7FCP8XKJVMGsWvjQVfG2+O/gdOCkd/L6 i0aQ== X-Gm-Message-State: AO0yUKVj97mrzIdo72VjPlqnV5uf+6ZiG/J3XUIl9d695KFCKC1I67jo IqpE1MFowbXGuh0+bbGQErwwEw== X-Google-Smtp-Source: AK7set9O+PDflVrQF9YwM/vjwNlE6aTmsdtZF+w2M9i7NB1M4FdDJtFNKNlCYweM8ShbP/zVvXV97Q== X-Received: by 2002:a05:6a21:9205:b0:bc:7dc0:6a55 with SMTP id tl5-20020a056a21920500b000bc7dc06a55mr10894875pzb.29.1675960669255; Thu, 09 Feb 2023 08:37:49 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id i15-20020a63b30f000000b004da5d3a8023sm1493295pgf.79.2023.02.09.08.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 08:37:48 -0800 (PST) Message-ID: <63e5215c.630a0220.1f01a.2993@mx.google.com> X-Google-Original-Message-ID: <202302090837.@keescook> Date: Thu, 9 Feb 2023 08:37:48 -0800 From: Kees Cook To: Ard Biesheuvel Cc: Mark Rutland , Peter Zijlstra , Dave Hansen , linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: Re: [PATCH v2 3/3] efi: x86: Wire up IBT annotation in memory attributes table References: <20230206124938.272988-1-ardb@kernel.org> <20230206124938.272988-4-ardb@kernel.org> <63e51b92.170a0220.ca7b5.2b23@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org On Thu, Feb 09, 2023 at 05:23:02PM +0100, Ard Biesheuvel wrote: > On Thu, 9 Feb 2023 at 17:13, Kees Cook wrote: > > > > On Wed, Feb 08, 2023 at 08:55:19PM +0000, Mark Rutland wrote: > > > On Wed, Feb 08, 2023 at 09:14:53PM +0100, Peter Zijlstra wrote: > > > > On Wed, Feb 08, 2023 at 07:17:15AM -0800, Dave Hansen wrote: > > > > > On 2/6/23 04:49, Ard Biesheuvel wrote: > > > > > > --- a/arch/x86/kernel/apm_32.c > > > > > > +++ b/arch/x86/kernel/apm_32.c > > > > > > @@ -609,7 +609,7 @@ static long __apm_bios_call(void *_call) > > > > > > > > > > > > apm_irq_save(flags); > > > > > > firmware_restrict_branch_speculation_start(); > > > > > > - ibt = ibt_save(); > > > > > > + ibt = ibt_save(true); > > > > > > > > > > My only nit with these is the bare use of 'true'/'false'. It's > > > > > impossible to tell at the call-site what the 'true' means. So, if you > > > > > happen to respin these and see a nice way to remedy this I'd appreciate it. > > > > > > > > I've often wished for a named argument extention to C, much like named > > > > initializers, such that one can write: > > > > > > > > ibt_save(.disable = true); > > > > > > > > Because the thing you mention is very common with boolean arguments, the > > > > what gets lost in the argument name and true/false just isn't very > > > > telling. > > > > > > > > But yeah, even if by some miracle all compiler guys were like, YES! and > > > > implemented it tomorrow, we couldn't use it for a good few years anyway > > > > :-/ > > > > > > Well... ;) > > > > > > | [mark@lakrids:~]% cat args.c > > > | #include > > > | #include > > > | > > > | struct foo_args { > > > | bool enable; > > > | unsigned long other; > > > | }; > > > | > > > | void __foo(struct foo_args args) > > > | { > > > | printf("foo:\n" > > > | " enable: %s\n" > > > | " other: 0x%lx\n", > > > | args.enable ? "YES" : "NO", > > > | args.other); > > > | } > > > | > > > | #define foo(args...) \ > > > | __foo((struct foo_args) { args }) > > > | > > > | > > > | int main(int argc, char *argv[]) > > > | { > > > | foo(true); > > > | foo(.enable = true); > > > | foo(false, .other=0xdead); > > > | } > > > | [mark@lakrids:~]% gcc args.c -o args > > > | [mark@lakrids:~]% ./args > > > | foo: > > > | enable: YES > > > | other: 0x0 > > > | foo: > > > | enable: YES > > > | other: 0x0 > > > | foo: > > > | enable: NO > > > | other: 0xdead > > > > I am horrified and delighted. > > +1 > > > And the resulting codegen is identical: > > https://godbolt.org/z/eKTMPYc17 > > > > Without this fancy solution, what I'd seen is just using an enum: > > > > enum do_the_thing { > > THING_DISABLE = 0, > > THING_ENABLE, > > }; > > > > void foo(enum do_the_thing enable) > > { > > if (enable) { ... } > > } > > > > foo(THING_ENABLE); > > > > I have no strong preference one way or the other, but given that > apm_32.c is not the epicenter of new development, and the call from > EFI code is self-documenting already (' > ibt_save(efi_disable_ibt_for_runtime)', I'm inclined to just queue the > patch as-is, and leave it to whoever feels inclined to spend more free > time on this to come up with some nice polish to put on top. > > Unless anyone minds? Yeah, this was just commentary. I think the patch is fine as-is. -- Kees Cook 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 1D03CC61DA4 for ; Thu, 9 Feb 2023 16:39:01 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FnofIc2KcFQ9Fbq2IS++HLYYeYV4SY81di3b7Y6Iv7A=; b=PeeLOQj+6ViAvY Eol7Mb+ew3D15fkP2reuNEeyOM/3fBj5xC3G7+/9o7BcxH3mfMUxTu0D6rPaopisx8oCoT78rqwn/ lrqZTrJI+1/N6wzBn5rFY6qLAAs3atAquDrXNQPHm/IEW4GvPlyWN9zH4MFdlKN8fgYnc7FtgaTWf qhHBVUKJ8OYFv3OEjiMP+RF8gsFkQP8H/kzXAYra0KxVxXCBLEZKQpWtiSUFR0TmknOnlZ12af5A2 TgG0Q/LTooWPzYMUwH3vjuRQwnLnOo31mXCZYVxEHf3oRUghPWZLXfgzXKwQghnGFMNP7Lx7qei7B pNuquWclUtqguoB70XLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ9vn-002SBR-SN; Thu, 09 Feb 2023 16:37:55 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQ9vj-002SAc-Gt for linux-arm-kernel@lists.infradead.org; Thu, 09 Feb 2023 16:37:53 +0000 Received: by mail-pj1-x1032.google.com with SMTP id s89-20020a17090a2f6200b0023125ebb4b1so2890011pjd.3 for ; Thu, 09 Feb 2023 08:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=I7snu9y4j4ZVL+v+vg+ofabCCqYVVfclBVWkCwWBxUM=; b=ZJMImQuVeGX1qrWI7qRvAabc2z6zOqkLoa+HDwFosiqYCHUrwRbe+UkWPN9c8jmvvW kURGQ2/ysK4XomMeWK8D3M6wAWrG0e6Lz/faB7UAJ2+KFsQvO0rr+C3SPFeGr+0bonxV x5vvkgnDv+5LK6IyN8EhNh43YfnQdIFGjsapI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:subject:cc :to:from:date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=I7snu9y4j4ZVL+v+vg+ofabCCqYVVfclBVWkCwWBxUM=; b=AJJv0xILiq7WZMCgu1rmStSyZenLTNPQ+mHxgWYuuYqnWhDbmNAEFDrgV8QA6J5JoC n44xNdsm9jJgUvuEL8s416HYxFvCh8tG/VANdu4YOiTNNOi2AlIj+ASDmJJ5Akzk46Xr SnrQPbhs+XnlyB6K1UW/+GKFyi1G22OtPHtS6KCll4NNL8B9HhMiKpuvRxOK7jXU1coL ZGtnMhDnLCcs5VEMF6gzX2mUskGW9mN1FF7y4ouqviC7zQ/dOPz3m7KfORMSLEoa8Bbu N28QCZguuds9q5njol7MwWhL8QViOJatnv2BgrEIxF/F58lvpCPA0Ftg6+BSDoeRiqxe 76zQ== X-Gm-Message-State: AO0yUKXf6z9TkroDXp8YXJ3dGhgL1Kcf3McyvYYfpdSyf7aRbquKs+Ym rfGtvBGP6MF0JwZxh3X30PunlQ== X-Google-Smtp-Source: AK7set9O+PDflVrQF9YwM/vjwNlE6aTmsdtZF+w2M9i7NB1M4FdDJtFNKNlCYweM8ShbP/zVvXV97Q== X-Received: by 2002:a05:6a21:9205:b0:bc:7dc0:6a55 with SMTP id tl5-20020a056a21920500b000bc7dc06a55mr10894875pzb.29.1675960669255; Thu, 09 Feb 2023 08:37:49 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id i15-20020a63b30f000000b004da5d3a8023sm1493295pgf.79.2023.02.09.08.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 08:37:48 -0800 (PST) Message-ID: <63e5215c.630a0220.1f01a.2993@mx.google.com> X-Google-Original-Message-ID: <202302090837.@keescook> Date: Thu, 9 Feb 2023 08:37:48 -0800 From: Kees Cook To: Ard Biesheuvel Cc: Mark Rutland , Peter Zijlstra , Dave Hansen , linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: Re: [PATCH v2 3/3] efi: x86: Wire up IBT annotation in memory attributes table References: <20230206124938.272988-1-ardb@kernel.org> <20230206124938.272988-4-ardb@kernel.org> <63e51b92.170a0220.ca7b5.2b23@mx.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230209_083751_568263_0DF7E4ED X-CRM114-Status: GOOD ( 31.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 09, 2023 at 05:23:02PM +0100, Ard Biesheuvel wrote: > On Thu, 9 Feb 2023 at 17:13, Kees Cook wrote: > > > > On Wed, Feb 08, 2023 at 08:55:19PM +0000, Mark Rutland wrote: > > > On Wed, Feb 08, 2023 at 09:14:53PM +0100, Peter Zijlstra wrote: > > > > On Wed, Feb 08, 2023 at 07:17:15AM -0800, Dave Hansen wrote: > > > > > On 2/6/23 04:49, Ard Biesheuvel wrote: > > > > > > --- a/arch/x86/kernel/apm_32.c > > > > > > +++ b/arch/x86/kernel/apm_32.c > > > > > > @@ -609,7 +609,7 @@ static long __apm_bios_call(void *_call) > > > > > > > > > > > > apm_irq_save(flags); > > > > > > firmware_restrict_branch_speculation_start(); > > > > > > - ibt = ibt_save(); > > > > > > + ibt = ibt_save(true); > > > > > > > > > > My only nit with these is the bare use of 'true'/'false'. It's > > > > > impossible to tell at the call-site what the 'true' means. So, if you > > > > > happen to respin these and see a nice way to remedy this I'd appreciate it. > > > > > > > > I've often wished for a named argument extention to C, much like named > > > > initializers, such that one can write: > > > > > > > > ibt_save(.disable = true); > > > > > > > > Because the thing you mention is very common with boolean arguments, the > > > > what gets lost in the argument name and true/false just isn't very > > > > telling. > > > > > > > > But yeah, even if by some miracle all compiler guys were like, YES! and > > > > implemented it tomorrow, we couldn't use it for a good few years anyway > > > > :-/ > > > > > > Well... ;) > > > > > > | [mark@lakrids:~]% cat args.c > > > | #include > > > | #include > > > | > > > | struct foo_args { > > > | bool enable; > > > | unsigned long other; > > > | }; > > > | > > > | void __foo(struct foo_args args) > > > | { > > > | printf("foo:\n" > > > | " enable: %s\n" > > > | " other: 0x%lx\n", > > > | args.enable ? "YES" : "NO", > > > | args.other); > > > | } > > > | > > > | #define foo(args...) \ > > > | __foo((struct foo_args) { args }) > > > | > > > | > > > | int main(int argc, char *argv[]) > > > | { > > > | foo(true); > > > | foo(.enable = true); > > > | foo(false, .other=0xdead); > > > | } > > > | [mark@lakrids:~]% gcc args.c -o args > > > | [mark@lakrids:~]% ./args > > > | foo: > > > | enable: YES > > > | other: 0x0 > > > | foo: > > > | enable: YES > > > | other: 0x0 > > > | foo: > > > | enable: NO > > > | other: 0xdead > > > > I am horrified and delighted. > > +1 > > > And the resulting codegen is identical: > > https://godbolt.org/z/eKTMPYc17 > > > > Without this fancy solution, what I'd seen is just using an enum: > > > > enum do_the_thing { > > THING_DISABLE = 0, > > THING_ENABLE, > > }; > > > > void foo(enum do_the_thing enable) > > { > > if (enable) { ... } > > } > > > > foo(THING_ENABLE); > > > > I have no strong preference one way or the other, but given that > apm_32.c is not the epicenter of new development, and the call from > EFI code is self-documenting already (' > ibt_save(efi_disable_ibt_for_runtime)', I'm inclined to just queue the > patch as-is, and leave it to whoever feels inclined to spend more free > time on this to come up with some nice polish to put on top. > > Unless anyone minds? Yeah, this was just commentary. I think the patch is fine as-is. -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel