summaryrefslogtreecommitdiffstats
path: root/kernel/gsp_phys_vbios.h
blob: 5fc6e85e0bb99a2a621020b353b96742740c1454 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef GSP_PHYS_VBIOS_H
#define GSP_PHYS_VBIOS_H

#include <linux/types.h>
#include <linux/pci.h>

/*
 * Real-GSP boot stage 3c support: video-BIOS access and parsing.
 *
 * The FWSEC image that verifies and carves WPR2 is not part of the GSP-RM
 * firmware file - it ships in the GPU's own VBIOS. This module reads the
 * VBIOS through the PROM window while the physical GPU is claimed, walks the
 * legacy PCI ROM header / ROM directory, then finds the BIOS Information
 * Table (BIT) and the FWSEC falcon-ucode entry in the expansion ROM.
 *
 * All accesses are read-only. Disabled unless stage 3c is enabled
 * (gsp_phys_fwsec=1); claim must be enabled too.
 */

/* Upper bound used by the distribution driver's ROM extraction (1 MB). */
#define GSP_PHYS_VBIOS_MAX_SIZE		0x00100000

/* PROM data window in BAR0: NV_PROM_DATA(i), 32-bit reads only. */
#define GSP_PHYS_VBIOS_PROM_WINDOW	0x00300000

/* FWSEC ucode application ids in the BIT falcon-ucode table. */
#define GSP_PHYS_FWSEC_APPID_FIRMWARE_SEC_LIC	0x05
#define GSP_PHYS_FWSEC_APPID_DEBUG		0x45
#define GSP_PHYS_FWSEC_APPID_PROD		0x85

struct gsp_phys_vbios {
	u8 *data;			/* copied VBIOS image (host memory) */
	size_t size;			/* usable image size in bytes */
	u32 pci_offset;			/* image start offset of the base ROM */
	u32 expansion_rom_offset;	/* expansion ROM base, from image start */
	u64 version;			/* (binary version << 8) | OEM, 0 if absent */
};

/*
 * FWSEC falcon-ucode descriptor as found in the BIT. Only the V2 variant is
 * accepted: on this GPU generation the security falcon cannot boot the V3
 * (boot-from-HS) form, so a V3 descriptor is a hard stop.
 */
struct gsp_phys_fwsec_desc {
	u32 app_id;
	u32 target_id;
	u32 desc_version;
	u32 desc_size;
	u32 desc_offset;		/* offset of the descriptor in the image */
	u32 imem_phys_base;
	u32 imem_load_size;
	u32 imem_virt_base;
	u32 imem_sec_base;
	u32 imem_sec_size;
	u32 dmem_offset;
	u32 dmem_phys_base;
	u32 dmem_load_size;
	u32 interface_offset;
	u32 virtual_entry;
};

int gsp_phys_vbios_read(struct gsp_phys_vbios *img, struct pci_dev *pdev,
			void __iomem *bar0);
void gsp_phys_vbios_free(struct gsp_phys_vbios *img);

int gsp_phys_vbios_parse_fwsec(const struct gsp_phys_vbios *img,
			       bool use_debug_app,
			       struct gsp_phys_fwsec_desc *desc);

#endif /* GSP_PHYS_VBIOS_H */