Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2309708ybl; Sat, 14 Dec 2019 09:59:15 -0800 (PST) X-Google-Smtp-Source: APXvYqwcqpLNncSVnUnaXfdU/XKSajX0+Q9kQNisvrDUdFhe+N9agIm3LvjVbaAKMpzyz2gz5DfP X-Received: by 2002:a05:6830:11d3:: with SMTP id v19mr22178956otq.322.1576346355123; Sat, 14 Dec 2019 09:59:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576346355; cv=none; d=google.com; s=arc-20160816; b=JRUwpiq838wXBpquyfsX8jpO60v0blOGmLrhllaqX4UySlrMBTs8/Aemaf01kVgy7A npobdLDxF9qOxLnTTj/wPB2s45tIyPyEQ6dR1RssnkSKq+kzrTskWY6MYKfjhLfH4mvu D+HchyZB1cwqESCx2rAnEC9rrT4hwpmcVh/WOZdbThE/U9e/YdPO9yKDfJdKC3c+FuMn 9+Lelm3siclzPjG0p5RTY5ePWShxzi70gRPPxd2lftLrpro4fbbdn2Mnzgr/mY9sC38i UblUzc+tMwI0XYeev3mc95tySSXch3GW9m2btht5WwoXnpVb4sN+tOrOpB0PCeGv506a sP6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ow9jgiWQnrlcSXsZtC4XHFP/i2SifBjD9qGUPPU/Asc=; b=fJwcp1TFZUW21BD9Pqxq0FeAeBbz6/nqL+2PDgsc688bTD+yN68qCH7Cvu9q36ViMU BkoHEw5CLJAcy1kLnjFfYqxeY6QSkGTNhO6xz2+lEZAuO/ffFU9gdzwwiir2IlKIXsVM r9LhZrIWW+35B3EPra8F5dRhaBisrtxwSi79GEibbvi8at3dHDRz+8PUoa//2Gs3HtR0 z84+wruaQG2ozxm25qi4acpI1ag5PL2+psUZOPw/iFapkMI6FPZrPc7LAdlkY3tcXVUc MgzqYP6OJACEudjZ7qDEnK9ql1y4ku4lYNAxEOWb2p+qFb78W9xjGg2Nd1kKGKsHV1RF i+uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z7j8yHeK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7si7462334otp.323.2019.12.14.09.59.04; Sat, 14 Dec 2019 09:59:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Z7j8yHeK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727152AbfLNR6E (ORCPT + 99 others); Sat, 14 Dec 2019 12:58:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:44546 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727283AbfLNR6D (ORCPT ); Sat, 14 Dec 2019 12:58:03 -0500 Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E09752465E; Sat, 14 Dec 2019 17:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576346282; bh=E+ODH1tNA1H+uHw7SgnE3Ikf13/PXAVJ/8fDpFKDCn4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7j8yHeKTWdQV8f0vFafQihw/FRbDfB7ppGlmC9bogxoGq2wZGIXp5dP8LU1Mr0Qq Canx398/WbuGT3Y8QynhNEEvIUe5079GCB8DT+1NoFRKfbNRBRCst/KQkvCOtPWV+c IAwebkrI8y5y3YcDnYYKfxrrqc36wa6rkhh6kbss= From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-efi@vger.kernel.org, Ard Biesheuvel , Hans de Goede , Matthew Garrett , Ingo Molnar , Andy Lutomirski , Thomas Gleixner , Arvind Sankar Subject: [PATCH 08/10] efi/libstub: use stricter typing for firmware function pointers Date: Sat, 14 Dec 2019 18:57:33 +0100 Message-Id: <20191214175735.22518-9-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191214175735.22518-1-ardb@kernel.org> References: <20191214175735.22518-1-ardb@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We will soon remove another level of pointer casting, so let's make sure all type handling involving firmware calls at boot time is correct. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 10 ++++++---- arch/x86/boot/compressed/eboot.h | 5 +++-- drivers/firmware/efi/libstub/efi-stub-helper.c | 5 +++-- drivers/firmware/efi/libstub/tpm.c | 4 ++-- include/linux/efi.h | 6 +++++- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index 6d833f93a878..052852eaa076 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -64,7 +64,8 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) size = romsize + sizeof(*rom); - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom); + status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, + (void **)&rom); if (status != EFI_SUCCESS) { efi_printk(sys_table, "Failed to allocate memory for 'rom'\n"); return status; @@ -191,9 +192,9 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) struct setup_data *data, *new; efi_status_t status; u32 size = 0; - void *p; + apple_properties_protocol_t *p; - status = efi_call_early(locate_protocol, &guid, NULL, &p); + status = efi_call_early(locate_protocol, &guid, NULL, (void **)&p); if (status != EFI_SUCCESS) return; @@ -208,7 +209,8 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) do { status = efi_call_early(allocate_pool, EFI_LOADER_DATA, - size + sizeof(struct setup_data), &new); + size + sizeof(struct setup_data), + (void **)&new); if (status != EFI_SUCCESS) { efi_printk(sys_table, "Failed to allocate memory for 'properties'\n"); return; diff --git a/arch/x86/boot/compressed/eboot.h b/arch/x86/boot/compressed/eboot.h index 1cf384ba1b0e..318531f128c2 100644 --- a/arch/x86/boot/compressed/eboot.h +++ b/arch/x86/boot/compressed/eboot.h @@ -18,8 +18,9 @@ typedef struct { u32 blt; } efi_uga_draw_protocol_32_t; -typedef struct { - void *get_mode; +typedef struct efi_uga_draw_protocol { + efi_status_t (*get_mode)(struct efi_uga_draw_protocol *, + u32*, u32*, u32*, u32*); void *set_mode; void *blt; } efi_uga_draw_protocol_t; diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index ff3266b9f673..5bb1715cb154 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -423,12 +423,13 @@ static efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, return status; } -static efi_status_t efi_file_read(void *handle, unsigned long *size, void *addr) +static efi_status_t efi_file_read(efi_file_handle_t *handle, + unsigned long *size, void *addr) { return efi_call_proto(efi_file_handle, read, handle, size, addr); } -static efi_status_t efi_file_close(void *handle) +static efi_status_t efi_file_close(efi_file_handle_t *handle) { return efi_call_proto(efi_file_handle, close, handle); } diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index 0354d35ebaa7..83cf204bfe8f 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -59,11 +59,11 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) size_t log_size, last_entry_size; efi_bool_t truncated; int version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2; - void *tcg2_protocol = NULL; + efi_tcg2_protocol_t *tcg2_protocol = NULL; int final_events_size = 0; status = efi_call_early(locate_protocol, &tcg2_guid, NULL, - &tcg2_protocol); + (void **)&tcg2_protocol); if (status != EFI_SUCCESS) return; diff --git a/include/linux/efi.h b/include/linux/efi.h index 87c2537b4543..7f1a99bd2c05 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -399,7 +399,11 @@ struct efi_pci_io_protocol { void *allocate_buffer; void *free_buffer; void *flush; - void *get_location; + efi_status_t (*get_location)(struct efi_pci_io_protocol *, + unsigned long *segment_nr, + unsigned long *bus_nr, + unsigned long *device_nr, + unsigned long *function_nr); void *attributes; void *get_bar_attributes; void *set_bar_attributes; -- 2.17.1