Skip to contentSkip to conversation

updated fw_cfg option ROM 2016-07-13

GIT PULL Paolo Bonzini 2 participants 4 messages Jul 13, 2016 – Jul 14, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

The following changes since commit a91a4e7d8cfe6ece610aacf7c52738188f5b5cb5:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-07-11 15:08:47 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream-fwcfg

for you to fetch changes up to 7282d40ba0937512ec94c30895e2ef0299069569:

Add optionrom compatible with fw_cfg DMA version (2016-07-13 14:49:03 +0200)

----------------------------------------------------------------
* Updated fw_cfg option ROM to include DMA support

----------------------------------------------------------------
Marc Marí (1):
Add optionrom compatible with fw_cfg DMA version

 .gitignore                        |   4 +
 Makefile                          |   2 +-
 hw/i386/pc.c                      |  10 +-
 hw/nvram/fw_cfg.c                 |   2 +-
 include/hw/nvram/fw_cfg.h         |   1 +
 pc-bios/linuxboot_dma.bin         | Bin 0 -> 2560 bytes
 pc-bios/optionrom/Makefile        |  30 +++-
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 291 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 335 insertions(+), 8 deletions(-)
 create mode 100644 pc-bios/linuxboot_dma.bin
 create mode 100644 pc-bios/optionrom/code16gcc.h
 create mode 100644 pc-bios/optionrom/linuxboot_dma.c
Signature · 1 line
1.8.3.1
#1 lore raw

[Qemu-devel] [PULL 1/1] Add optionrom compatible with fw_cfg DMA version

From: Marc Marí <[email protected]>

This optionrom is based on linuxboot.S.

Message-Id: <[email protected]>

[Add -fno-toplevel-reorder, support clang without -m16. - Paolo]
---
 .gitignore                        |   4 +
 Makefile                          |   2 +-
 hw/i386/pc.c                      |  10 +-
 hw/nvram/fw_cfg.c                 |   2 +-
 include/hw/nvram/fw_cfg.h         |   1 +
 pc-bios/linuxboot_dma.bin         | Bin 0 -> 2560 bytes
 pc-bios/optionrom/Makefile        |  30 +++-
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 291 ++++++++++++++++++++++++++++++++++++++
 9 files changed, 335 insertions(+), 8 deletions(-)
 create mode 100644 pc-bios/linuxboot_dma.bin
 create mode 100644 pc-bios/optionrom/code16gcc.h
 create mode 100644 pc-bios/optionrom/linuxboot_dma.c
.gitignore +4 -0
index 9b6a968..88ec249 100644
@@ -95,6 +95,10 @@
 /pc-bios/optionrom/linuxboot.bin
 /pc-bios/optionrom/linuxboot.raw
 /pc-bios/optionrom/linuxboot.img
+/pc-bios/optionrom/linuxboot_dma.asm
+/pc-bios/optionrom/linuxboot_dma.bin
+/pc-bios/optionrom/linuxboot_dma.raw
+/pc-bios/optionrom/linuxboot_dma.img
 /pc-bios/optionrom/multiboot.asm
 /pc-bios/optionrom/multiboot.bin
 /pc-bios/optionrom/multiboot.raw
Makefile +1 -1
index c054bc6..ba92f9e 100644
@@ -419,7 +419,7 @@ efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
 efi-e1000e.rom efi-vmxnet3.rom \
 qemu-icon.bmp qemu_logo_no_text.svg \
 bamboo.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
-multiboot.bin linuxboot.bin kvmvapic.bin \
+multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin \
 s390-ccw.img \
 spapr-rtas.bin slof.bin \
 palcode-clipper \
hw/i386/pc.c +8 -2
index f56e225..1b8baa8 100644
@@ -998,8 +998,13 @@ static void load_linux(PCMachineState *pcms,
     fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
     fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
 
-    option_rom[nb_option_roms].name = "linuxboot.bin";
-    option_rom[nb_option_roms].bootindex = 0;
+    if (fw_cfg_dma_enabled(fw_cfg)) {
+        option_rom[nb_option_roms].name = "linuxboot_dma.bin";
+        option_rom[nb_option_roms].bootindex = 0;
+    } else {
+        option_rom[nb_option_roms].name = "linuxboot.bin";
+        option_rom[nb_option_roms].bootindex = 0;
+    }
     nb_option_roms++;
 }
 
@@ -1291,6 +1296,7 @@ void xen_load_linux(PCMachineState *pcms)
     load_linux(pcms, fw_cfg);
     for (i = 0; i < nb_option_roms; i++) {
         assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
+               !strcmp(option_rom[i].name, "linuxboot_dma.bin") ||
                !strcmp(option_rom[i].name, "multiboot.bin"));
         rom_add_option(option_rom[i].name, option_rom[i].bootindex);
     }
hw/nvram/fw_cfg.c +1 -1
index 74a0079..2873030 100644
@@ -552,7 +552,7 @@ static bool is_version_1(void *opaque, int version_id)
     return version_id == 1;
 }
 
-static bool fw_cfg_dma_enabled(void *opaque)
+bool fw_cfg_dma_enabled(void *opaque)
 {
     FWCfgState *s = opaque;
 
include/hw/nvram/fw_cfg.h +1 -0
index d008112..5c27a1f 100644
@@ -182,5 +182,6 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,
                                  hwaddr dma_addr, AddressSpace *dma_as);
 
 FWCfgState *fw_cfg_find(void);
+bool fw_cfg_dma_enabled(void *opaque);
 
 #endif
pc-bios/linuxboot_dma.bin new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..a318d63aa53944d2048a46060d6000b88e238cda
GIT binary patch
pc-bios/optionrom/Makefile +26 -4
index 2cdda87..4e3b908 100644
@@ -10,21 +10,43 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
 .PHONY : all clean build-all
 
 CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
-CFLAGS += -I$(SRC_PATH)
 CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector)
 CFLAGS += $(CFLAGS_NOPIE)
+CFLAGS += $(call cc-option, $(CFLAGS), -m16)
+ifeq ($(filter -m16, $(CFLAGS)),)
+# Attempt to work around compilers that lack -m16 (GCC <= 4.8, clang <= ??)
+# On GCC we add -fno-toplevel-reorder to keep the order of asm blocks with
+# respect to the rest of the code.  clang does not have -fno-toplevel-reorder,
+# but it places all asm blocks at the beginning and we're relying on it for
+# the option ROM header.  So just force clang not to use the integrated
+# assembler, which doesn't support .code16gcc.
+CFLAGS += $(call cc-option, $(CFLAGS), -fno-toplevel-reorder)
+CFLAGS += $(call cc-option, $(CFLAGS), -no-integrated-as)
+CFLAGS += -m32 -include $(SRC_PATH)/pc-bios/optionrom/code16gcc.h
+endif
+
+QEMU_INCLUDES += -I$(SRC_PATH)
 QEMU_CFLAGS = $(CFLAGS)
 
-build-all: multiboot.bin linuxboot.bin kvmvapic.bin
+ASFLAGS += -32
+
+build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin
 
 # suppress auto-removal of intermediate files
 .SECONDARY:
 
+
 %.o: %.S
-	$(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) $(CFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@,"  AS    $(TARGET_DIR)$@")
+	$(call quiet-command,$(CPP) $(QEMU_INCLUDES) $(QEMU_DGFLAGS) -c -o - $< | $(AS) $(ASFLAGS) -o $@,"  AS    $(TARGET_DIR)$@")
+
+ifdef CONFIG_WIN32
+LD_EMULATION = i386pe
+else
+LD_EMULATION = elf_i386
+endif
 
 %.img: %.o
-	$(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
+	$(call quiet-command,$(LD) $(LDFLAGS_NOPIE) -m $(LD_EMULATION) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
 
 %.raw: %.img
 	$(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@,"  Building $(TARGET_DIR)$@")
pc-bios/optionrom/code16gcc.h new file +3 -0
new file mode 100644
index 0000000..9c8d25d
@@ -0,0 +1,3 @@
+asm(
+".code16gcc\n"
+);
pc-bios/optionrom/linuxboot_dma.c new file +291 -0

291 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Paolo Bonzini
Quoted 11 lines · Paolo Bonzini

The following changes since commit a91a4e7d8cfe6ece610aacf7c52738188f5b5cb5:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-07-11 15:08:47 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream-fwcfg

for you to fetch changes up to 7282d40ba0937512ec94c30895e2ef0299069569:

Quoted 8 lines

Add optionrom compatible with fw_cfg DMA version (2016-07-13 14:49:03 +0200)

----------------------------------------------------------------
* Updated fw_cfg option ROM to include DMA support

----------------------------------------------------------------
Marc Marí (1):
Add optionrom compatible with fw_cfg DMA version

Hi. I'm afraid this fails to build with the win32 build:

CC optionrom/linuxboot_dma.o
Building optionrom/linuxboot_dma.img
linuxboot_dma.o:linuxboot_dma.c:(.text+0x57): undefined reference to `load_kernel'

This thread has the discussion for the same problem from May:
https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg04978.html

thanks
-- PMM

#3 lore raw
Quoted 23 lines · Peter Maydell
Quoted 11 lines · Paolo Bonzini

The following changes since commit a91a4e7d8cfe6ece610aacf7c52738188f5b5cb5:

Merge remote-tracking branch 'remotes/ehabkost/tags/x86-pull-request' into staging (2016-07-11 15:08:47 +0100)

are available in the git repository at:

git://github.com/bonzini/qemu.git tags/for-upstream-fwcfg

for you to fetch changes up to 7282d40ba0937512ec94c30895e2ef0299069569:

Quoted 8 lines

Add optionrom compatible with fw_cfg DMA version (2016-07-13 14:49:03 +0200)

----------------------------------------------------------------
* Updated fw_cfg option ROM to include DMA support

----------------------------------------------------------------
Marc Marí (1):
Add optionrom compatible with fw_cfg DMA version

Hi. I'm afraid this fails to build with the win32 build:

Quoted 7 lines

CC optionrom/linuxboot_dma.o
Building optionrom/linuxboot_dma.img
linuxboot_dma.o:linuxboot_dma.c:(.text+0x57): undefined reference to `load_kernel'

This thread has the discussion for the same problem from May:
https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg04978.html

Aha, I fixed another issue (that was not discussed on the mailing list and only found by the docker tests) but forgot about this one. Well, that's why I separated this patch from the other pull request.

Paolo