Message ID | 1543848532-12604-4-git-send-email-lizhijian@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | allow to load initrd below 4G for recent kernel | expand |
On 12/3/18 8:48 AM, Li Zhijian wrote: > #include "hw/net/ne2000-isa.h" > +#include <asm/bootparam.h> > > /* debug PC/ISA interrupts */ > //#define DEBUG_IRQ > @@ -820,20 +821,6 @@ static long get_file_size(FILE *f) > return size; > } > > -/* setup_data types */ > -#define SETUP_NONE 0 > -#define SETUP_E820_EXT 1 > -#define SETUP_DTB 2 > -#define SETUP_PCI 3 > -#define SETUP_EFI 4 > - > -struct setup_data { > - uint64_t next; > - uint32_t type; > - uint32_t len; > - uint8_t data[0]; > -} __attribute__((packed)); > - No, this will fail to build for a non-x86 host, which will not have <asm/bootparam.h>. Or, perhaps, have a *different* asm/bootparam.h that will be specific to a different host cpu. r~
On Mon, Dec 03, 2018 at 10:48:51PM +0800, Li Zhijian wrote: > It provides setup_data struct and header fields > > CC: Michael S. Tsirkin <mst@redhat.com> > Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> Sorry I was unclear when I said "import it from Linux". The way to import it is to copy the header from the linux kernel by adding it to ./scripts/update-linux-headers.sh and placing a copy into include/standard-headers/ Hope that helps. > --- > V3: new patch > --- > hw/i386/pc.c | 15 +-------------- > 1 file changed, 1 insertion(+), 14 deletions(-) > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > index 067d23a..8db7417 100644 > --- a/hw/i386/pc.c > +++ b/hw/i386/pc.c > @@ -74,6 +74,7 @@ > #include "hw/nmi.h" > #include "hw/i386/intel_iommu.h" > #include "hw/net/ne2000-isa.h" > +#include <asm/bootparam.h> > > /* debug PC/ISA interrupts */ > //#define DEBUG_IRQ > @@ -820,20 +821,6 @@ static long get_file_size(FILE *f) > return size; > } > > -/* setup_data types */ > -#define SETUP_NONE 0 > -#define SETUP_E820_EXT 1 > -#define SETUP_DTB 2 > -#define SETUP_PCI 3 > -#define SETUP_EFI 4 > - > -struct setup_data { > - uint64_t next; > - uint32_t type; > - uint32_t len; > - uint8_t data[0]; > -} __attribute__((packed)); > - > static void load_linux(PCMachineState *pcms, > FWCfgState *fw_cfg) > { > -- > 2.7.4
On 12/04/2018 09:06 AM, Michael S. Tsirkin wrote: > On Mon, Dec 03, 2018 at 10:48:51PM +0800, Li Zhijian wrote: >> It provides setup_data struct and header fields >> >> CC: Michael S. Tsirkin<mst@redhat.com> >> Signed-off-by: Li Zhijian<lizhijian@cn.fujitsu.com> > Sorry I was unclear when I said "import it from Linux". Sorry, it's my fault. > > The way to import it is to copy the header > from the linux kernel by adding it to ./scripts/update-linux-headers.sh > and placing a copy into include/standard-headers/ > > Hope that helps. that's really helpful. i wonder which type copy should i use 'cp' or 'cp_portable' this header includes several sub-headers $ grep include /tmp/tmp.MBF10Z9MeS/include/asm/bootparam.h #include <linux/types.h> #include <linux/screen_info.h> #include <linux/apm_bios.h> #include <linux/edd.h> #include <asm/ist.h> #include <video/edid.h> Thanks Zhijian > > >
Hi Michael I cooked a draft with cp_portable to import bootparam.h, could you have a look. diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh index 0a964fe..1beeceb 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -44,6 +44,12 @@ cp_portable() { -e 'linux/kernel' \ -e 'linux/sysinfo' \ -e 'asm-generic/kvm_para' \ + -e 'linux/screen_info.h' \ + -e 'linux/apm_bios.h' \ + -e 'linux/edd.h' \ + -e 'video/edid.h' \ + -e 'asm/ist.h' \ + -e 'linux/ioctl.h' \ > /dev/null then echo "Unexpected #include in input file $f". @@ -59,6 +65,8 @@ cp_portable() { -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \ -e 's/"\(input-event-codes\.h\)"/"standard-headers\/linux\/\1"/' \ -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \ + -e "s/<asm\/\([^>]*\)>/\"standard-headers\/asm-$arch\/\1\"/" \ + -e 's/<video\/\([^>]*\)>/"standard-headers\/video\/\1"/' \ -e 's/__bitwise//' \ -e 's/__attribute__((packed))/QEMU_PACKED/' \ -e 's/__inline__/inline/' \ @@ -74,6 +82,23 @@ cp_portable() { "$f" > "$to/$header"; } +rm -rf "$output/include/standard-headers/linux" +mkdir -p "$output/include/standard-headers/linux" + +cp_bootparam() +{ + mkdir -p $output/include/standard-headers/video + cp "$tmpdir"/include/linux/ioctl.h "$output/include/standard-headers/linux" + cp_portable "$tmpdir"/include/linux/screen_info.h "$output/include/standard-headers/linux" + cp_portable "$tmpdir/include/linux/apm_bios.h" "$output/include/standard-headers/linux" + cp_portable "$tmpdir/include/linux/edd.h" "$output/include/standard-headers/linux" + cp_portable "$tmpdir/include/asm/ist.h" $output/include/standard-headers/asm-$arch + cp_portable "$tmpdir/include/video/edid.h" $output/include/standard-headers/video + + # bootparam.h includes above headers + cp_portable "$tmpdir/include/asm/bootparam.h" "$output/include/standard-headers/asm-$arch" +} + # This will pick up non-directories too (eg "Kconfig") but we will # ignore them in the next loop. ARCHLIST=$(cd "$linux/arch" && echo *) @@ -120,6 +145,7 @@ for arch in $ARCHLIST; do cp "$tmpdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/" cp "$tmpdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/" cp_portable "$tmpdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch" + cp_bootparam fi done @@ -163,8 +189,6 @@ cat <<EOF >$output/linux-headers/linux/virtio_ring.h #include "standard-headers/linux/virtio_ring.h" EOF -rm -rf "$output/include/standard-headers/linux" -mkdir -p "$output/include/standard-headers/linux" for i in "$tmpdir"/include/linux/*virtio*.h \ "$tmpdir/include/linux/qemu_fw_cfg.h" \ "$tmpdir/include/linux/input.h" \ Thanks Zhijian On 12/04/2018 04:09 PM, Li Zhijian wrote: > > > > On 12/04/2018 09:06 AM, Michael S. Tsirkin wrote: >> On Mon, Dec 03, 2018 at 10:48:51PM +0800, Li Zhijian wrote: >>> It provides setup_data struct and header fields >>> >>> CC: Michael S. Tsirkin<mst@redhat.com> >>> Signed-off-by: Li Zhijian<lizhijian@cn.fujitsu.com> >> Sorry I was unclear when I said "import it from Linux". > Sorry, it's my fault. > >> The way to import it is to copy the header >> from the linux kernel by adding it to ./scripts/update-linux-headers.sh >> and placing a copy into include/standard-headers/ >> >> Hope that helps. > that's really helpful. > > i wonder which type copy should i use 'cp' or 'cp_portable' > this header includes several sub-headers > > $ grep include /tmp/tmp.MBF10Z9MeS/include/asm/bootparam.h > #include <linux/types.h> > #include <linux/screen_info.h> > #include <linux/apm_bios.h> > #include <linux/edd.h> > #include <asm/ist.h> > #include <video/edid.h> > > Thanks > Zhijian > >> > > > > > >
On Wed, Dec 05, 2018 at 06:28:11PM +0800, Li Zhijian wrote: > Hi Michael > > I cooked a draft with cp_portable to import bootparam.h, could you have a look. > > diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh > index 0a964fe..1beeceb 100755 > --- a/scripts/update-linux-headers.sh > +++ b/scripts/update-linux-headers.sh > @@ -44,6 +44,12 @@ cp_portable() { > -e 'linux/kernel' \ > -e 'linux/sysinfo' \ > -e 'asm-generic/kvm_para' \ > + -e 'linux/screen_info.h' \ > + -e 'linux/apm_bios.h' \ > + -e 'linux/edd.h' \ > + -e 'video/edid.h' \ > + -e 'asm/ist.h' \ > + -e 'linux/ioctl.h' \ > > /dev/null > then > echo "Unexpected #include in input file $f". > @@ -59,6 +65,8 @@ cp_portable() { > -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \ > -e 's/"\(input-event-codes\.h\)"/"standard-headers\/linux\/\1"/' \ > -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \ > + -e "s/<asm\/\([^>]*\)>/\"standard-headers\/asm-$arch\/\1\"/" \ > + -e 's/<video\/\([^>]*\)>/"standard-headers\/video\/\1"/' \ > -e 's/__bitwise//' \ > -e 's/__attribute__((packed))/QEMU_PACKED/' \ > -e 's/__inline__/inline/' \ > @@ -74,6 +82,23 @@ cp_portable() { > "$f" > "$to/$header"; > } > > +rm -rf "$output/include/standard-headers/linux" > +mkdir -p "$output/include/standard-headers/linux" > + > +cp_bootparam() > +{ > + mkdir -p $output/include/standard-headers/video > + cp "$tmpdir"/include/linux/ioctl.h "$output/include/standard-headers/linux" > + cp_portable "$tmpdir"/include/linux/screen_info.h "$output/include/standard-headers/linux" > + cp_portable "$tmpdir/include/linux/apm_bios.h" "$output/include/standard-headers/linux" > + cp_portable "$tmpdir/include/linux/edd.h" "$output/include/standard-headers/linux" > + cp_portable "$tmpdir/include/asm/ist.h" $output/include/standard-headers/asm-$arch > + cp_portable "$tmpdir/include/video/edid.h" $output/include/standard-headers/video > + > + # bootparam.h includes above headers > + cp_portable "$tmpdir/include/asm/bootparam.h" "$output/include/standard-headers/asm-$arch" > +} > + > # This will pick up non-directories too (eg "Kconfig") but we will > # ignore them in the next loop. > ARCHLIST=$(cd "$linux/arch" && echo *) > @@ -120,6 +145,7 @@ for arch in $ARCHLIST; do > cp "$tmpdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/" > cp "$tmpdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/" > cp_portable "$tmpdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch" > + cp_bootparam > fi > done > > @@ -163,8 +189,6 @@ cat <<EOF >$output/linux-headers/linux/virtio_ring.h > #include "standard-headers/linux/virtio_ring.h" > EOF > > -rm -rf "$output/include/standard-headers/linux" > -mkdir -p "$output/include/standard-headers/linux" > for i in "$tmpdir"/include/linux/*virtio*.h \ > "$tmpdir/include/linux/qemu_fw_cfg.h" \ > "$tmpdir/include/linux/input.h" \ > > Thanks > Zhijian > So arch specific asm including asm doesn't work well right now :( You can either fix the path to ist to pull it from asm-x86, or if you don't actually need anything in that header the macros, you can just cut out everything around __ASSEMBLY__ with a bit of e.g. sed magic. E.g. pvrdma does this. Something like: # Remove everything except the macros from bootparam.h avoiding the unnecessary # import of several video/ist/etc headers sed -e '/__ASSEMBLY__/,/__ASSEMBLY__/d' arch/x86/include/uapi/asm/bootparam.h should do the job. > > On 12/04/2018 04:09 PM, Li Zhijian wrote: > > > > > On 12/04/2018 09:06 AM, Michael S. Tsirkin wrote: > > On Mon, Dec 03, 2018 at 10:48:51PM +0800, Li Zhijian wrote: > > It provides setup_data struct and header fields > > CC: Michael S. Tsirkin <mst@redhat.com> > Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> > > Sorry I was unclear when I said "import it from Linux". > > Sorry, it's my fault. > > > The way to import it is to copy the header > from the linux kernel by adding it to ./scripts/update-linux-headers.sh > and placing a copy into include/standard-headers/ > > Hope that helps. > > that's really helpful. > > i wonder which type copy should i use 'cp' or 'cp_portable' > this header includes several sub-headers > > $ grep include /tmp/tmp.MBF10Z9MeS/include/asm/bootparam.h > #include <linux/types.h> > #include <linux/screen_info.h> > #include <linux/apm_bios.h> > #include <linux/edd.h> > #include <asm/ist.h> > #include <video/edid.h> > > Thanks > Zhijian > > > > > > > > > > > >
On 12/05/2018 11:33 PM, Michael S. Tsirkin wrote: > On Wed, Dec 05, 2018 at 06:28:11PM +0800, Li Zhijian wrote: >> Hi Michael >> >> I cooked a draft with cp_portable to import bootparam.h, could you have a look. >> >> diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh >> index 0a964fe..1beeceb 100755 >> --- a/scripts/update-linux-headers.sh >> +++ b/scripts/update-linux-headers.sh >> @@ -44,6 +44,12 @@ cp_portable() { >> -e 'linux/kernel' \ >> -e 'linux/sysinfo' \ >> -e 'asm-generic/kvm_para' \ >> + -e 'linux/screen_info.h' \ >> + -e 'linux/apm_bios.h' \ >> + -e 'linux/edd.h' \ >> + -e 'video/edid.h' \ >> + -e 'asm/ist.h' \ >> + -e 'linux/ioctl.h' \ >> > /dev/null >> then >> echo "Unexpected #include in input file $f". >> @@ -59,6 +65,8 @@ cp_portable() { >> -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \ >> -e 's/"\(input-event-codes\.h\)"/"standard-headers\/linux\/\1"/' \ >> -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \ >> + -e "s/<asm\/\([^>]*\)>/\"standard-headers\/asm-$arch\/\1\"/" \ >> + -e 's/<video\/\([^>]*\)>/"standard-headers\/video\/\1"/' \ >> -e 's/__bitwise//' \ >> -e 's/__attribute__((packed))/QEMU_PACKED/' \ >> -e 's/__inline__/inline/' \ >> @@ -74,6 +82,23 @@ cp_portable() { >> "$f" > "$to/$header"; >> } >> >> +rm -rf "$output/include/standard-headers/linux" >> +mkdir -p "$output/include/standard-headers/linux" >> + >> +cp_bootparam() >> +{ >> + mkdir -p $output/include/standard-headers/video >> + cp "$tmpdir"/include/linux/ioctl.h "$output/include/standard-headers/linux" >> + cp_portable "$tmpdir"/include/linux/screen_info.h "$output/include/standard-headers/linux" >> + cp_portable "$tmpdir/include/linux/apm_bios.h" "$output/include/standard-headers/linux" >> + cp_portable "$tmpdir/include/linux/edd.h" "$output/include/standard-headers/linux" >> + cp_portable "$tmpdir/include/asm/ist.h" $output/include/standard-headers/asm-$arch >> + cp_portable "$tmpdir/include/video/edid.h" $output/include/standard-headers/video >> + >> + # bootparam.h includes above headers >> + cp_portable "$tmpdir/include/asm/bootparam.h" "$output/include/standard-headers/asm-$arch" >> +} >> + >> # This will pick up non-directories too (eg "Kconfig") but we will >> # ignore them in the next loop. >> ARCHLIST=$(cd "$linux/arch" && echo *) >> @@ -120,6 +145,7 @@ for arch in $ARCHLIST; do >> cp "$tmpdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/" >> cp "$tmpdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/" >> cp_portable "$tmpdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch" >> + cp_bootparam >> fi >> done >> >> @@ -163,8 +189,6 @@ cat <<EOF >$output/linux-headers/linux/virtio_ring.h >> #include "standard-headers/linux/virtio_ring.h" >> EOF >> >> -rm -rf "$output/include/standard-headers/linux" >> -mkdir -p "$output/include/standard-headers/linux" >> for i in "$tmpdir"/include/linux/*virtio*.h \ >> "$tmpdir/include/linux/qemu_fw_cfg.h" \ >> "$tmpdir/include/linux/input.h" \ >> >> Thanks >> Zhijian >> > So arch specific asm including asm doesn't work well right now :( > You can either fix the path to ist to pull it from asm-x86, > + -e "s/<asm\/\([^>]*\)>/\"standard-headers\/asm-$arch\/\1\"/" \ > + -e 's/<video\/\([^>]*\)>/"standard-headers\/video\/\1"/' \ Actually above changes fix the path with asm as well. But I'd like below solution which is simpler and clearer > or if you don't actually need anything in that header the > macros, you can just cut out everything around __ASSEMBLY__ > with a bit of e.g. sed magic. E.g. pvrdma does this. > > Something like: > > # Remove everything except the macros from bootparam.h avoiding the unnecessary > # import of several video/ist/etc headers > sed -e '/__ASSEMBLY__/,/__ASSEMBLY__/d' arch/x86/include/uapi/asm/bootparam.h > > should do the job. Thanks Zhijian
diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 067d23a..8db7417 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -74,6 +74,7 @@ #include "hw/nmi.h" #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" +#include <asm/bootparam.h> /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -820,20 +821,6 @@ static long get_file_size(FILE *f) return size; } -/* setup_data types */ -#define SETUP_NONE 0 -#define SETUP_E820_EXT 1 -#define SETUP_DTB 2 -#define SETUP_PCI 3 -#define SETUP_EFI 4 - -struct setup_data { - uint64_t next; - uint32_t type; - uint32_t len; - uint8_t data[0]; -} __attribute__((packed)); - static void load_linux(PCMachineState *pcms, FWCfgState *fw_cfg) {
It provides setup_data struct and header fields CC: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com> --- V3: new patch --- hw/i386/pc.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)