[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YfvpPowvlz0reOZ/@zn.tnic>
Date: Thu, 3 Feb 2022 15:39:58 +0100
From: Borislav Petkov <bp@...en8.de>
To: Brijesh Singh <brijesh.singh@....com>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
linux-efi@...r.kernel.org, platform-driver-x86@...r.kernel.org,
linux-coco@...ts.linux.dev, linux-mm@...ck.org,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Joerg Roedel <jroedel@...e.de>,
Tom Lendacky <thomas.lendacky@....com>,
"H. Peter Anvin" <hpa@...or.com>, Ard Biesheuvel <ardb@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Jim Mattson <jmattson@...gle.com>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Sergio Lopez <slp@...hat.com>, Peter Gonda <pgonda@...gle.com>,
Peter Zijlstra <peterz@...radead.org>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
David Rientjes <rientjes@...gle.com>,
Dov Murik <dovmurik@...ux.ibm.com>,
Tobin Feldman-Fitzthum <tobin@....com>,
Michael Roth <michael.roth@....com>,
Vlastimil Babka <vbabka@...e.cz>,
"Kirill A . Shutemov" <kirill@...temov.name>,
Andi Kleen <ak@...ux.intel.com>,
"Dr . David Alan Gilbert" <dgilbert@...hat.com>,
brijesh.ksingh@...il.com, tony.luck@...el.com, marcorr@...gle.com,
sathyanarayanan.kuppuswamy@...ux.intel.com
Subject: Re: [PATCH v9 24/43] x86/compressed/acpi: Move EFI detection to
helper
On Fri, Jan 28, 2022 at 11:17:45AM -0600, Brijesh Singh wrote:
> diff --git a/arch/x86/boot/compressed/efi.c b/arch/x86/boot/compressed/efi.c
> new file mode 100644
> index 000000000000..daa73efdc7a5
> --- /dev/null
> +++ b/arch/x86/boot/compressed/efi.c
> @@ -0,0 +1,50 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Helpers for early access to EFI configuration table.
> + *
> + * Originally derived from arch/x86/boot/compressed/acpi.c
> + */
> +
> +#include "misc.h"
> +#include <linux/efi.h>
> +#include <asm/efi.h>
Yap, it is includes like that which cause this whole decompressor
include hell. One day...
> +
> +/**
> + * efi_get_type - Given boot_params, determine the type of EFI environment.
> + *
> + * @boot_params: pointer to boot_params
> + *
> + * Return: EFI_TYPE_{32,64} for valid EFI environments, EFI_TYPE_NONE otherwise.
> + */
> +enum efi_type efi_get_type(struct boot_params *boot_params)
struct boot_params *bp
> +{
> + struct efi_info *ei;
> + enum efi_type et;
> + const char *sig;
> +
> + ei = &boot_params->efi_info;
> + sig = (char *)&ei->efi_loader_signature;
> +
> + if (!strncmp(sig, EFI64_LOADER_SIGNATURE, 4)) {
> + et = EFI_TYPE_64;
> + } else if (!strncmp(sig, EFI32_LOADER_SIGNATURE, 4)) {
> + et = EFI_TYPE_32;
> + } else {
> + debug_putstr("No EFI environment detected.\n");
> + et = EFI_TYPE_NONE;
> + }
> +
> +#ifndef CONFIG_X86_64
> + /*
> + * Existing callers like acpi.c treat this case as an indicator to
> + * fall-through to non-EFI, rather than an error, so maintain that
> + * functionality here as well.
> + */
> + if (ei->efi_systab_hi || ei->efi_memmap_hi) {
> + debug_putstr("EFI system table is located above 4GB and cannot be accessed.\n");
> + et = EFI_TYPE_NONE;
> + }
> +#endif
> +
> + return et;
> +}
> diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
> index 01cc13c12059..a26244c0fe01 100644
> --- a/arch/x86/boot/compressed/misc.h
> +++ b/arch/x86/boot/compressed/misc.h
> @@ -176,4 +176,20 @@ void boot_stage2_vc(void);
>
> unsigned long sev_verify_cbit(unsigned long cr3);
>
> +enum efi_type {
> + EFI_TYPE_64,
> + EFI_TYPE_32,
> + EFI_TYPE_NONE,
> +};
Haha, EFI folks will be wondering where in the spec that thing is... :-)))
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists