From patchwork Mon Jan 8 09:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 185882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp923000dyq; Mon, 8 Jan 2024 02:00:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFmlLkRteNT2nzC5+5KdqJJWzqA84opHX0XYTz1/dbXu1Xzx/FKlM/maQUr3+cgiAMR6HPb X-Received: by 2002:a05:622a:4a:b0:429:9b38:bfa8 with SMTP id y10-20020a05622a004a00b004299b38bfa8mr264447qtw.62.1704708042638; Mon, 08 Jan 2024 02:00:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704708042; cv=none; d=google.com; s=arc-20160816; b=Mh0GIvPeRBKqbSDeyPvVOgtz3BGQ8/p2f+01RL6K7dt0UNEvSd+KGI1WvHOFDQ89gT IcvBzYJ3w4AfoIJpOQrJJakya7IxHqxGfBLuD9zSo7Nzh69ZWQfQFZYKQvgyNZEEv5rX OvUJD+82ouezsDt+9BhnbOMu9vneziub39lm9Z6u9Zxjq+5XDdLuvBXu9cYWibFuEh1D ZNK1eEKIlX7imSIrZT0n2NmlpzdGRtUfa6IE8tg6cJW6Ur/MlzzoSgsybUFr3H029o22 oFz3qdPu7+HWQZJ4j0aj4jZ2hwhU4K4D1FEssNX0NplWOZwvovSsssKY1SeH/7fDzVF4 qD3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=+9cuiaFBoH53rifqhpcKmv1PSCTBZIUqSH8muwBZX6s=; fh=3EXpYsI7hLQV0a9eUbfkxmF0Cz25dlM5iw5kZeQ5VbU=; b=iJ9Mm895DnOWF1PYfBh4YPgMg4/JZGF7BmxTqLS2Ejxp5wHT1UaEeMWaaA0iA3E8G6 ewQd79/VHyLNv426mRmvtrp77/qQRZjWA3Gobc2AQ7d6o16He0NRwPMct0wplYriVG9x yfC4njmyQoLsjP4il06hTmyAKpvaK7mFI1iII6YOgUnyBztFUvSxg1zzsiM/Hw9D1A5J eh3iKtPfgPYzoq9tDobgsyCj+w322Kg92je3E6MYfdHWYGVSVrMWsKzM3knyMdvQRqAa //03Yc+qgEkew+icNQ8NeSv5mDBClg93QLFVZghFZ/+/pwwk1c8jQGAc6VMLfo422Db6 AR/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s9-20020a05622a178900b0042836732deesi7327716qtk.630.2024.01.08.02.00.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 02:00:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-19308-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 39EFE1C21ED7 for ; Mon, 8 Jan 2024 10:00:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3A9A2575C; Mon, 8 Jan 2024 09:59:12 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89D2D12B84; Mon, 8 Jan 2024 09:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AB47E1F799; Mon, 8 Jan 2024 09:59:07 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 34C0A1392C; Mon, 8 Jan 2024 09:59:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GDHEC2vHm2XFMwAAD6G6ig (envelope-from ); Mon, 08 Jan 2024 09:59:07 +0000 From: Thomas Zimmermann To: ardb@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, bhelgaas@google.com, arnd@arndb.de, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, javierm@redhat.com Cc: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v4 3/4] arch/x86: Implement arch_ima_efi_boot_mode() in source file Date: Mon, 8 Jan 2024 10:57:29 +0100 Message-ID: <20240108095903.8427-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240108095903.8427-1-tzimmermann@suse.de> References: <20240108095903.8427-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: AB47E1F799 Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: -4.00 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-4.00 / 50.00]; TAGGED_RCPT(0.00)[]; REPLY(-4.00)[] X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787515940602812719 X-GMAIL-MSGID: 1787515940602812719 The x86 implementation of arch_ima_efi_boot_mode() uses the global boot_param state. Move it into a source file to clean up the header. Avoid potential rebuilds of unrelated source files if boot_params changes. Suggested-by: Ard Biesheuvel Signed-off-by: Thomas Zimmermann --- arch/x86/include/asm/efi.h | 5 +++-- arch/x86/platform/efi/efi.c | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index a5d7a83e4c2a..1dc600fa3ba5 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -409,8 +409,9 @@ extern int __init efi_memmap_split_count(efi_memory_desc_t *md, extern void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf, struct efi_mem_range *mem); -#define arch_ima_efi_boot_mode \ - ({ extern struct boot_params boot_params; boot_params.secure_boot; }) +extern enum efi_secureboot_mode __x86_ima_efi_boot_mode(void); + +#define arch_ima_efi_boot_mode __x86_ima_efi_boot_mode() #ifdef CONFIG_EFI_RUNTIME_MAP int efi_get_runtime_map_size(void); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index e9f99c56f3ce..f090ec972d7b 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -950,3 +950,8 @@ umode_t efi_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n) } return attr->mode; } + +enum efi_secureboot_mode __x86_ima_efi_boot_mode(void) +{ + return boot_params.secure_boot; +}