 e12f3a13e2
			
		
	
	
		e12f3a13e2
		
	
	
	
	
		
			
			We'd like to raise the value of FW_CFG_FILE_SLOTS. Doing it naively could lead to problems with backward migration: a more recent QEMU (running an older machine type) would allow the guest, in fw_cfg_select(), to select a high key value that is unavailable in the same machine type implemented by the older (target) QEMU. On the target host, fw_cfg_data_read() for example could dereference nonexistent entries. As first step, size the FWCfgState.entries[*] and FWCfgState.entry_order arrays dynamically. All three array sizes will be influenced by the new field FWCfgState.file_slots (and matching device property). Make the following changes: - Replace the FW_CFG_FILE_SLOTS macro with FW_CFG_FILE_SLOTS_MIN (minimum count of fw_cfg file slots) in the header file. The value remains 0x10. - Replace all uses of FW_CFG_FILE_SLOTS with a helper function called fw_cfg_file_slots(), returning the new property. - Eliminate the macro FW_CFG_MAX_ENTRY, and replace all its uses with a helper function called fw_cfg_max_entry(). - In the MMIO- and IO-mapped realize functions both, allocate all three arrays dynamically, based on the new property. - The new property defaults to FW_CFG_FILE_SLOTS_MIN. This is going to be customized in the following patches. Cc: "Gabriel L. Somlo" <somlo@cmu.edu> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Igor Mammedov <imammedo@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Acked-by: Gabriel Somlo <somlo@cmu.edu> Tested-by: Gabriel Somlo <somlo@cmu.edu> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #ifndef FW_CFG_KEYS_H
 | |
| #define FW_CFG_KEYS_H
 | |
| 
 | |
| #define FW_CFG_SIGNATURE        0x00
 | |
| #define FW_CFG_ID               0x01
 | |
| #define FW_CFG_UUID             0x02
 | |
| #define FW_CFG_RAM_SIZE         0x03
 | |
| #define FW_CFG_NOGRAPHIC        0x04
 | |
| #define FW_CFG_NB_CPUS          0x05
 | |
| #define FW_CFG_MACHINE_ID       0x06
 | |
| #define FW_CFG_KERNEL_ADDR      0x07
 | |
| #define FW_CFG_KERNEL_SIZE      0x08
 | |
| #define FW_CFG_KERNEL_CMDLINE   0x09
 | |
| #define FW_CFG_INITRD_ADDR      0x0a
 | |
| #define FW_CFG_INITRD_SIZE      0x0b
 | |
| #define FW_CFG_BOOT_DEVICE      0x0c
 | |
| #define FW_CFG_NUMA             0x0d
 | |
| #define FW_CFG_BOOT_MENU        0x0e
 | |
| #define FW_CFG_MAX_CPUS         0x0f
 | |
| #define FW_CFG_KERNEL_ENTRY     0x10
 | |
| #define FW_CFG_KERNEL_DATA      0x11
 | |
| #define FW_CFG_INITRD_DATA      0x12
 | |
| #define FW_CFG_CMDLINE_ADDR     0x13
 | |
| #define FW_CFG_CMDLINE_SIZE     0x14
 | |
| #define FW_CFG_CMDLINE_DATA     0x15
 | |
| #define FW_CFG_SETUP_ADDR       0x16
 | |
| #define FW_CFG_SETUP_SIZE       0x17
 | |
| #define FW_CFG_SETUP_DATA       0x18
 | |
| #define FW_CFG_FILE_DIR         0x19
 | |
| 
 | |
| #define FW_CFG_FILE_FIRST       0x20
 | |
| #define FW_CFG_FILE_SLOTS_MIN   0x10
 | |
| 
 | |
| #define FW_CFG_WRITE_CHANNEL    0x4000
 | |
| #define FW_CFG_ARCH_LOCAL       0x8000
 | |
| #define FW_CFG_ENTRY_MASK       (~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL))
 | |
| 
 | |
| #define FW_CFG_INVALID          0xffff
 | |
| 
 | |
| /* width in bytes of fw_cfg control register */
 | |
| #define FW_CFG_CTL_SIZE         0x02
 | |
| 
 | |
| #define FW_CFG_MAX_FILE_PATH    56
 | |
| 
 | |
| #endif
 |