Skip to contentSkip to conversation

updated fw_cfg option ROM 2016-07-13

GIT PULL Applied Paolo Bonzini 4 participants 9 messages Jul 14, 2016 – Aug 10, 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 b2a575a1c652904600869e774e45bf4c9ed72c55:

Add optionrom compatible with fw_cfg DMA version (2016-07-14 15:50:52 +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/i386/pc.h              |   4 +
 include/hw/nvram/fw_cfg.h         |   1 +
 pc-bios/linuxboot_dma.bin         | Bin 0 -> 1024 bytes
 pc-bios/optionrom/Makefile        |  42 ++++--
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 294 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 349 insertions(+), 13 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
2.7.4
#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/i386/pc.h              |   4 +
 include/hw/nvram/fw_cfg.h         |   1 +
 pc-bios/linuxboot_dma.bin         | Bin 0 -> 1024 bytes
 pc-bios/optionrom/Makefile        |  42 ++++--
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 294 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 349 insertions(+), 13 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/i386/pc.h +4 -0
index 2123532..e38c95a 100644
@@ -366,6 +366,10 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 #define PC_COMPAT_2_6 \
     HW_COMPAT_2_6 \
     {\
+        .driver   = "fw_cfg_io",\
+        .property = "dma_enabled",\
+        .value    = "off",\
+    },{\
         .driver   = TYPE_X86_CPU,\
         .property = "cpuid-0xb",\
         .value    = "off",\
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..e1f623a1245efff0d46ea5b685e0f18e4ef98d74
GIT binary patch
pc-bios/optionrom/Makefile +33 -9

55 lines not on this page · raw message

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 +294 -0

294 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

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

Quoted 9 lines · Paolo Bonzini

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]
Quoted 15 lines
---
 .gitignore                        |   4 +
 Makefile                          |   2 +-
 hw/i386/pc.c                      |  10 +-
 hw/nvram/fw_cfg.c                 |   2 +-
 include/hw/i386/pc.h              |   4 +
 include/hw/nvram/fw_cfg.h         |   1 +
 pc-bios/linuxboot_dma.bin         | Bin 0 -> 1024 bytes
 pc-bios/optionrom/Makefile        |  42 ++++--
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 294 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 349 insertions(+), 13 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

CC optionrom/linuxboot_dma.o
clang-3.8: error: unsupported argument '-32' to option 'Wa,'

$ rpm -qi clang
Name        : clang
Version     : 3.8.0
Release     : 2.fc24
Architecture: x86_64

Stefan

#3 lore raw

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

Quoted 26 lines · Stefan Hajnoczi
Quoted 9 lines · Paolo Bonzini

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]
Quoted 15 lines
---
 .gitignore                        |   4 +
 Makefile                          |   2 +-
 hw/i386/pc.c                      |  10 +-
 hw/nvram/fw_cfg.c                 |   2 +-
 include/hw/i386/pc.h              |   4 +
 include/hw/nvram/fw_cfg.h         |   1 +
 pc-bios/linuxboot_dma.bin         | Bin 0 -> 1024 bytes
 pc-bios/optionrom/Makefile        |  42 ++++--
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 294 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 349 insertions(+), 13 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
Quoted 8 lines

CC optionrom/linuxboot_dma.o
clang-3.8: error: unsupported argument '-32' to option 'Wa,'

$ rpm -qi clang
Name        : clang
Version     : 3.8.0
Release     : 2.fc24
Architecture: x86_64

This is strange, the Makefile does check whether the compiler supports the argument:

+QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), $(Wa)-32)

Can you send the V=1 output?

Paolo

#4 lore raw

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

In reply to Stefan Hajnoczi
Quoted 11 lines · Stefan Hajnoczi
Quoted 8 lines
 pc-bios/linuxboot_dma.bin         | Bin 0 -> 1024 bytes
 pc-bios/optionrom/Makefile        |  42 ++++--
 pc-bios/optionrom/code16gcc.h     |   3 +
 pc-bios/optionrom/linuxboot_dma.c | 294 ++++++++++++++++++++++++++++++++++++++
 10 files changed, 349 insertions(+), 13 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

CC optionrom/linuxboot_dma.o
clang-3.8: error: unsupported argument '-32' to option 'Wa,'

Please try this patch:

pc-bios/optionrom/Makefile +1 -1
index d88ce11..72abb3c 100644
@@ -30,7 +30,7 @@ QEMU_INCLUDES += -I$(SRC_PATH)
 
 Wa = -Wa,
 ASFLAGS += -32
-QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), $(Wa)-32)
+QEMU_CFLAGS += $(call cc-c-option, $(QEMU_CFLAGS), $(Wa)-32)
 
 build-all: multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin
 
roms/ipxe +1 -1
index 0418631..4e03af8 160000
@@ -1 +1 @@
-Subproject commit 04186319181298083ef28695a8309028b26fe83c
+Subproject commit 4e03af8ec2d497e725566a91fd5c19dd604c18a6
rules.mak +2 -0
index ed8e482..99cd0b3 100644
@@ -113,6 +113,8 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
 
 cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
               >/dev/null 2>&1 && echo OK), $2, $3)
+cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \
+                >/dev/null 2>&1 && echo OK), $2, $3)
 
 VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc
 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1)))
#5 lore raw

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

In reply to Paolo Bonzini
Quoted 8 lines · Paolo Bonzini
pc-bios/optionrom/Makefile +0 -0
index 2cdda87..d88ce11 100644
@@ -9,22 +9,46 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
 
 .PHONY : all clean build-all
 

pc-bios/optionrom/Makefile $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) · line 14

Quoted 10 lines
pc-bios/optionrom/Makefile +3 -7
-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)
-QEMU_CFLAGS = $(CFLAGS)
-
-build-all: multiboot.bin linuxboot.bin kvmvapic.bin
+# Drop -fstack-protector and the like
+QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding
+QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -m16)

This change in CFLAGS handling broke the build on OpenBSD. Filtering -fstack-protector is not enough and is why the Makefile had an explicit -fno-stack-protector provided.

Adding this back in fixes the issue..

QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)

ld -nopie -m elf_i386 -Ttext 0 -e _start -s -o linuxboot_dma.img linuxboot_dma.o linuxboot_dma.o: In function `bios_cfg_read_entry':
linuxboot_dma.c:(.text+0x90): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x12d): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x149): undefined reference to __stack_smash_handler' linuxboot_dma.o: In function load_kernel':
linuxboot_dma.c:(.text+0x168): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x381): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x3b6): undefined reference to `__stack_smash_handler' gmake[1]: *** [Makefile:52: linuxboot_dma.img] Error 1

#6 lore raw

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

Quoted 26 lines · Brad Smith
Quoted 10 lines · Paolo Bonzini
pc-bios/optionrom/Makefile +0 -2
index 2cdda87..d88ce11 100644
@@ -9,22 +9,46 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
 
 .PHONY : all clean build-all
 
-CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer
-fno-builtin

pc-bios/optionrom/Makefile $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) · line 14

Quoted 10 lines
pc-bios/optionrom/Makefile +3 -7
-CFLAGS += -I$(SRC_PATH)
-CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector)
-CFLAGS += $(CFLAGS_NOPIE)
-QEMU_CFLAGS = $(CFLAGS)
-
-build-all: multiboot.bin linuxboot.bin kvmvapic.bin
+# Drop -fstack-protector and the like
+QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE)
-ffreestanding
+QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -m16)

This change in CFLAGS handling broke the build on OpenBSD. Filtering

(quoted diff) +0 -2
-fstack-protector is not enough and is why the Makefile had an explicit
-fno-stack-protector provided.
Quoted 3 lines

Adding this back in fixes the issue..

QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)

Ok, will add back.

Paolo

Quoted 15 lines

ld -nopie -m elf_i386 -Ttext 0 -e _start -s -o linuxboot_dma.img linuxboot_dma.o
linuxboot_dma.o: In function `bios_cfg_read_entry':
linuxboot_dma.c:(.text+0x90): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x12d): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x149): undefined reference to `__stack_smash_handler'
linuxboot_dma.o: In function `load_kernel':
linuxboot_dma.c:(.text+0x168): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x381): undefined reference to __guard_local' linuxboot_dma.c:(.text+0x3b6): undefined reference to `__stack_smash_handler'
gmake[1]: *** [Makefile:52: linuxboot_dma.img] Error 1

#7 lore raw

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

Quoted 29 lines · Paolo Bonzini
Quoted 26 lines · Brad Smith
Quoted 10 lines · Paolo Bonzini
pc-bios/optionrom/Makefile +0 -2
index 2cdda87..d88ce11 100644
@@ -9,22 +9,46 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom)
 
 .PHONY : all clean build-all
 
-CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer
-fno-builtin

pc-bios/optionrom/Makefile $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) · line 14

Quoted 10 lines
pc-bios/optionrom/Makefile +3 -7
-CFLAGS += -I$(SRC_PATH)
-CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector)
-CFLAGS += $(CFLAGS_NOPIE)
-QEMU_CFLAGS = $(CFLAGS)
-
-build-all: multiboot.bin linuxboot.bin kvmvapic.bin
+# Drop -fstack-protector and the like
+QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE)
-ffreestanding
+QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -m16)

This change in CFLAGS handling broke the build on OpenBSD. Filtering

(quoted diff) +0 -2
-fstack-protector is not enough and is why the Makefile had an explicit
-fno-stack-protector provided.
Quoted 5 lines
Quoted 3 lines

Adding this back in fixes the issue..

QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)

Ok, will add back.

Great, thank you.

#8 lore raw
In reply to Paolo Bonzini
Quoted 10 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 b2a575a1c652904600869e774e45bf4c9ed72c55:

Quoted 9 lines

Add optionrom compatible with fw_cfg DMA version (2016-07-14 15:50:52 +0200)

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

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

Applied, thanks.

-- PMM