From: "Mr. Teo En Ming (Zhang Enming)" Subject: Re: graphics passthrough with VT-d Date: Sat, 29 Aug 2009 11:48:45 +0800 Message-ID: <4A98A51D.6070602@asiasoftsea.net> References: <7CB0A101731F44C391569BAEBF727CF9@ASOITIS16> <4A97FDE9.2060302@asiasoftsea.net> <4A980CDE.8060109@asiasoftsea.net> <4A983A73.80602@asiasoftsea.net> <14D9C9E2ED61ED41BC3B37ACDF4E880002CE4F3F9CE5@heavy-vm03.heavy.org.uk> <4A988FD4.4080602@asiasoftsea.net> Reply-To: enming.teo@asiasoftsea.net Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040707060806010909040405" Return-path: In-Reply-To: <4A988FD4.4080602@asiasoftsea.net> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: enming.teo@asiasoftsea.net Cc: "xen-devel@lists.xensource.com" , timothy.moore@expidas.net List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------040707060806010909040405 Content-Type: multipart/alternative; boundary="------------030200060002050907050308" --------------030200060002050907050308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Dear All, After applying Intel VGA passthrough patches 1, 2 and 3, I have no problems with "make xen", and "make install-xen". However, I have errors with "make tools". Here is the error output: msoft-float -I. -I.. -I../../../../tools/include -c -o build.o build.c build.c: In function 'construct_secondary_tables': build.c:194: error: 'AmlCode_TPM' undeclared (first use in this function) build.c:194: error: (Each undeclared identifier is reported only once build.c:194: error: for each function it appears in.) make[8]: *** [build.o] Error 1 make[8]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware/hvmloader/acpi' make[7]: *** [subdir-all-acpi] Error 2 make[7]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware/hvmloader' make[6]: *** [subdirs-all] Error 2 make[6]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware/hvmloader' make[5]: *** [subdir-all-hvmloader] Error 2 make[5]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware' make[4]: *** [subdirs-all] Error 2 make[4]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware' make[3]: *** [all] Error 2 make[3]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware' make[2]: *** [subdir-install-firmware] Error 2 make[2]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools' make[1]: *** [subdirs-install] Error 2 make[1]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools' make: *** [install-tools] Error 2 There is an undeclared identifier in tools/firmware/hvmloader/acpi/build.c source code. Could you guys help me resolve this issue? I had no problems compiling xen 3.5-unstable before applying the Intel vga passthrough patches and before installing the Intel ACPI Component Architecture compiler. I have also attached Intel graphics passthrough patches 1, 2 and 3 for your convenience here. Thank you very much. Hope I can get this working during the weekends. -- Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) Technical Support Engineer Information Technology Department Asiasoft Online Pte Ltd Tampines Central 1 #04-01 Tampines Plaza Singapore 529541 Republic of Singapore Company Website: http://www.asiasoft.sg/ Mobile: +65-9648-9798 MSN: teoenming@hotmail.com Alma Maters: Singapore Polytechnic, National University of Singapore On 08/29/2009 10:17 AM, Mr. Teo En Ming (Zhang Enming) wrote: > Hi Tim, > > I thought it should be gfx_passthru=2 in domU config? > -- > Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) > Technical Support Engineer > Information Technology Department > Asiasoft Online Pte Ltd > Tampines Central 1 #04-01 Tampines Plaza > Singapore 529541 > Republic of Singapore > Mobile: +65-9648-9798 > MSN:teoenming@hotmail.com > Alma Maters: Singapore Polytechnic, National University of Singapore > > > On 08/29/2009 06:42 AM, Tim Moore wrote: >> >> Teo, >> >> I have also performed the same exercise as yourself and I now have >> successfully compiled all 3x patches into Xen, Qemu and the BIOS File >> Loading in the hvmloader, this all compiles find on my system. >> Suggest you do a "make clean" on the tools and start again ! >> >> After booting with the patched xen-unstable and adding the >> gfx-passthru=1 parameter to my HVM DomU, as I suspected - it still >> doesn't work. >> >> I have both a 9500GT and GTX260(primary) in my Intel DX58SO machine, >> tried passing through either device and my primary display locks up ! >> (included hiding with pci-stub) >> >> I verified that the DomU was functional beforehand, as It also booted >> successfully without the gfx-passthru parameter (and a >> vncviewer/cirrus display) >> >> Unfortunately, I can't debug further as my Primary display corrupts >> as soon as the DomU starts. I did notice that in "xm debug" the >> "Loading Gfx BIOS File.." message was displayed and the DomU did >> continue to initialise the BIOS tables and such before finally >> locking. I then (blindly) typed on a corrupt Dom0 console and managed >> to start kdm and login, so the Dom0 was not completely trashed. But >> then after a few minutes, the machine totally froze and had to hit >> the reset switch. >> >> I`m no specialist but this looks like the VGA BIOS Re-initialisation >> is playing havoc with the DomU and possibly the Dom0 graphics. I >> notice that both are also using IRQ11 which could play a major part. >> Furthermore, there was a lot of debug output in the qemu and xend.log >> indicating Base Address Register invalid access and therefore it >> seems there may be a second obstacle. >> >> Hope you have a better success than me ! >> >> For now, I would try re-compiling a fresh xen-unstable with carefully >> applied patches .. oh! and don't forget to enable the pci-stub driver >> for Dom0 (it's not selected by default) >> >> Tim >> >> *From:* xen-devel-bounces@lists.xensource.com >> [mailto:xen-devel-bounces@lists.xensource.com] *On Behalf Of *Mr. Teo >> En Ming (Zhang Enming) >> *Sent:* 28 August 2009 21:14 >> *To:* enming.teo@asiasoftsea.net >> *Cc:* xen-devel@lists.xensource.com; 'Lin, Ben Y'; 'Kay, Allen M'; >> 'Jean Guyader'; Keir.Fraser@eu.citrix.com; weidong.han@intel.com; >> bengheng@eecs.umich.edu >> *Subject:* Re: [Xen-devel] [PATCH 2/2] graphics passthrough with VT-d >> >> After applying the 1st and 2nd patch to xen-unstable successfully, I examined the source codes Makefile and hvmloader.c in tools/firmware/hvmloader, compared them to Weidong's 3rd patch and I generated my own 3rd patch. Then I used my own generated 3rd patch to apply patching for loading vga bios from firmware file. >> >> Here is my own generated 3rd patch instead of using Weidong's 3rd patch: >> >> --- Makefile 2009-08-29 03:24:52.413083774 +0800 >> +++ Makefile 2009-08-29 03:29:12.763299633 +0800 >> @@ -50,6 +50,7 @@ >> roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \ >> ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h >> sh ./mkhex rombios ../rombios/BIOS-bochs-latest> roms.h >> + sh ./mkhex vgabios_pt ../vgabios/vgabios-pt.bin>> roms.h >> sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin>> roms.h >> sh ./mkhex vgabios_cirrusvga \ >> ../vgabios/VGABIOS-lgpl-latest.cirrus.bin>> roms.h >> --- hvmloader.c 2009-08-29 03:26:06.911085797 +0800 >> +++ hvmloader.c 2009-08-29 03:31:43.172084995 +0800 >> @@ -688,9 +688,9 @@ >> vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); >> break; >> case VGA_pt: >> - printf("Loading VGABIOS of passthroughed gfx ...\n"); >> - vgabios_sz = >> - round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); >> + printf("Loading Gfx Video BIOS from file ...\n"); >> + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, vgabios_pt, sizeof(vgabios_pt)); >> + vgabios_sz = round_option_rom(sizeof(vgabios_pt)); >> break; >> default: >> printf("No emulated VGA adaptor ...\n"); >> >> >> I can "make xen" successfully but when I proceeded to "make tools", errors were encountered. >> >> Please see attached error output. How can I solve this problem? >> >> >> -- >> Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) >> Technical Support Engineer >> Information Technology Department >> Asiasoft Online Pte Ltd >> Tampines Central 1 #04-01 Tampines Plaza >> Singapore 529541 >> Republic of Singapore >> Mobile: +65-9648-9798 >> MSN:teoenming@hotmail.com >> Alma Maters: Singapore Polytechnic, National University of Singapore >> >> >> >> On 08/29/2009 12:59 AM, Mr. Teo En Ming (Zhang Enming) wrote: >> >> OK I believe the 3rd patch is not incomplete but there's a white space issue when I copied the code from the mailing list into my vi. >> >> Seehttp://www.htdig.org/mail/2000/11/0167.html >> >> When I used the -l flag to patch using the 3rd patch, the number of errors was reduced. >> >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch -l -p1< intel-gfx-passthru-patch-3.patch >> patching file tools/firmware/hvmloader/Makefile >> patching file tools/firmware/hvmloader/hvmloader.c >> Hunk #1 FAILED at 688. >> 1 out of 1 hunk FAILED -- saving rejects to file tools/firmware/hvmloader/hvmloader.c.rej >> >> Now patching tools/firmware/hvmloader/Makefile is successful but patching tools/firmware/hvmloader/hvmloader.c still failed. >> >> -- >> Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) >> Technical Support Engineer >> Information Technology Department >> Asiasoft Online Pte Ltd >> Tampines Central 1 #04-01 Tampines Plaza >> Singapore 529541 >> Republic of Singapore >> Mobile: +65-9648-9798 >> MSN:teoenming@hotmail.com >> Alma Maters: Singapore Polytechnic, National University of Singapore >> >> >> >> >> On 08/28/2009 11:55 PM, Mr. Teo En Ming (Zhang Enming) wrote: >> >> Dear Weidong, >> >> A big big thanks for the vga passthrough patches for xen >> 3.5-unstable!!! These are eagerly anticipated patches. As I did not >> study computer science and computer architecture, I won't be able to >> write those patches you guys at Intel wrote. >> >> I applied the following patches *xen-gfx-passthrough.patch >> >> and qemu-gfx-passthrough.patch >> >> to xen 3.5-unstable without issues.* >> >> Then I tried to apply the 3rd patch you provided at >> http://lists.xensource.com/archives/html/xen-devel/2009-08/msg01047.html >> >> I saved the following code >> >> >> >> diff -r 494be76c1ad9 tools/firmware/hvmloader/Makefile >> --- a/tools/firmware/hvmloader/Makefile Thu Aug 27 16:54:33 2009 +0800 >> +++ b/tools/firmware/hvmloader/Makefile Thu Aug 27 17:22:01 2009 +0800 >> @@ -50,6 +50,7 @@ roms.h: ../rombios/BIOS-bochs-latest ../ >> roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \ >> ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h >> sh ./mkhex rombios ../rombios/BIOS-bochs-latest> roms.h >> + sh ./mkhex vgabios_pt ../vgabios/vgabios-pt.bin>> roms.h >> sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin>> roms.h >> sh ./mkhex vgabios_cirrusvga \ >> ../vgabios/VGABIOS-lgpl-latest.cirrus.bin>> roms.h >> diff -r 494be76c1ad9 tools/firmware/hvmloader/hvmloader.c >> --- a/tools/firmware/hvmloader/hvmloader.c Thu Aug 27 16:54:33 2009 +0800 >> +++ b/tools/firmware/hvmloader/hvmloader.c Thu Aug 27 17:23:00 2009 +0800 >> @@ -688,9 +688,9 @@ int main(void) >> vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); >> break; >> case VGA_pt: >> - printf("Loading Gfx Video BIOS from 0xC0000 ...\n"); >> - vgabios_sz = >> - round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); >> + printf("Loading Gfx Video BIOS from file ...\n"); >> + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, vgabios_pt, >> sizeof(vgabios_pt)); >> + vgabios_sz = round_option_rom(sizeof(vgabios_pt)); >> break; >> default: >> printf("No emulated VGA adaptor ...\n"); >> >> >> >> as intel-gfx-passthru-patch-3.patch and then I tried to apply the patch to xen 3.5-unstable. I got errors. I think it's because the 3rd patch you provided is incomplete. >> >> Here's my patching process: >> >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# find . -name vgabios >> ./tools/firmware/vgabios >> ./.hg/store/data/tools/firmware/vgabios >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# cp ~enming/vgabios-pt.bin tools/firmware/vgabios/ >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# ls tools/firmware/vgabios/ >> biossums.c clext.c Makefile TODO vbe.h vgabios.h vgatables.h >> BUGS COPYING Notes vbe.c vbetables-gen.c vgabios-pt.bin >> ChangeLog dataseghack README vbe_display_api.txt vgabios.c vgafonts.h >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# pwd >> /usr/src/xen-unstable.hg-vgapt >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# wgethttp://lists.xensource.com/archives/html/xen-devel/2009-08/bincPiiAf0QWg.bin >> --2009-08-28 23:18:21--http://lists.xensource.com/archives/html/xen-devel/2009-08/bincPiiAf0QWg.bin >> Resolving lists.xensource.com... 70.42.241.110 >> Connecting to lists.xensource.com|70.42.241.110|:80... connected. >> HTTP request sent, awaiting response... 200 OK >> Length: 12565 (12K) [application/octet-stream] >> Saving to: `bincPiiAf0QWg.bin' >> >> 100%[======================================================================>] 12,565 30.7K/s in 0.4s >> >> 2009-08-28 23:18:22 (30.7 KB/s) - `bincPiiAf0QWg.bin' saved [12565/12565] >> >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# mv bincPiiAf0QWg.bin xen-gfx-passthrough.patch >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi xen-gfx-passthrough.patch >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch< xen-gfx-passthrough.patch >> can't find file to patch at input line 4 >> Perhaps you should have used the -p or --strip option? >> The text leading up to this was: >> -------------------------- >> |diff -r 5d7e7a250267 tools/firmware/hvmloader/config.h >> |--- a/tools/firmware/hvmloader/config.h Wed Aug 26 18:28:44 2009 +0800 >> |+++ b/tools/firmware/hvmloader/config.h Thu Aug 27 16:54:24 2009 +0800 >> -------------------------- >> File to patch: ^C >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# ex xen-gfx-passthrough.patch >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch -p1< xen-gfx-passthrough.patch >> patching file tools/firmware/hvmloader/config.h >> patching file tools/firmware/hvmloader/hvmloader.c >> patching file tools/libxc/ia64/xc_ia64_hvm_build.c >> patching file tools/libxc/xc_hvm_build.c >> patching file tools/libxc/xc_linux.c >> patching file tools/libxc/xenctrl.h >> patching file tools/libxc/xenguest.h >> patching file tools/python/xen/lowlevel/xc/xc.c >> patching file tools/python/xen/xend/XendConfig.py >> Hunk #1 succeeded at 174 (offset -1 lines). >> patching file tools/python/xen/xend/image.py >> Hunk #1 succeeded at 780 (offset -6 lines). >> Hunk #3 succeeded at 895 (offset -6 lines). >> patching file tools/python/xen/xm/create.py >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# wgethttp://lists.xensource.com/archives/html/xen-devel/2009-08/binglLqkeq4Rj.bin >> --2009-08-28 23:21:35--http://lists.xensource.com/archives/html/xen-devel/2009-08/binglLqkeq4Rj.bin >> Resolving lists.xensource.com... 70.42.241.110 >> Connecting to lists.xensource.com|70.42.241.110|:80... connected. >> HTTP request sent, awaiting response... 200 OK >> Length: 9841 (9.6K) [application/octet-stream] >> Saving to: `binglLqkeq4Rj.bin' >> >> 100%[======================================================================>] 9,841 24.3K/s in 0.4s >> >> 2009-08-28 23:21:36 (24.3 KB/s) - `binglLqkeq4Rj.bin' saved [9841/9841] >> >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# mv binglLqkeq4Rj.bin qemu-gfx-passthrough.patch >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi qemu-gfx-passthrough.patch >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# find . -name hw >> ./tools/ioemu-remote/hw >> ./.hg/store/data/tools/ioemu/hw >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# mv qemu-gfx-passthrough.patch tools/ioemu-remote/ >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# cd tools/ioemu-remote/ >> [root@fedora11-x86-64-host ioemu-remote]# patch -p1< qemu- >> qemu-aio.h qemu-img.c qemu-sockets.c >> qemu-binfmt-conf.sh qemu-img.texi qemu-tech.texi >> qemu-char.c qemu-lock.h qemu-timer.h >> qemu-char.h qemu-log.h qemu-tool.c >> qemu-common.h qemu-malloc.c qemu-xen.h >> qemu-doc.texi qemu-nbd.c >> qemu-gfx-passthrough.patch qemu-nbd.texi >> [root@fedora11-x86-64-host ioemu-remote]# patch -p1< qemu-gfx-passthrough.patch >> patching file hw/pass-through.c >> patching file hw/pass-through.h >> patching file hw/pc.c >> patching file vl.c >> [root@fedora11-x86-64-host ioemu-remote]# cd .. >> [root@fedora11-x86-64-host tools]# cd .. >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi intel-gfx-passthru-patch-3.patch >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch -p1< intel-gfx-passthru-patch-3.patch >> patching file tools/firmware/hvmloader/Makefile >> Hunk #1 FAILED at 50. >> 1 out of 1 hunk FAILED -- saving rejects to file tools/firmware/hvmloader/Makefile.rej >> patching file tools/firmware/hvmloader/hvmloader.c >> patch: **** malformed patch at line 24: sizeof(vgabios_pt)); >> >> [root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi intel-gfx-passthru-patch-3.patch >> >> For everybody's convenience, I have attached intel-gfx-passthru-patch-3.patch and the firmware for my nVidia GeForce 8400 GS PCI Express x16 graphics card in this email. >> >> Please help me complete intel-gfx-passthru-patch-3.patch as I really need it. >> >> Thank you very much!!! >> >> -- >> Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) >> Technical Support Engineer >> Information Technology Department >> Asiasoft Online Pte Ltd >> Tampines Central 1 #04-01 Tampines Plaza >> Singapore 529541 >> Republic of Singapore >> Mobile: +65-9648-9798 >> MSN:teoenming@hotmail.com >> Alma Maters: Singapore Polytechnic, National University of Singapore >> >> This patch supports basic gfx passthrough on QEMU: >> >> - disable emulated VGA adpater if there is passthroughed gfx >> >> - register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfx >> >> >> >> Signed-off-by: Ben Lin >> >> Signed-off-by: Weidong Han >> >> No virus found in this incoming message. >> >> Checked by AVG -www.avg.com >> >> Version: 8.5.409 / Virus Database: 270.13.69/2328 - Release Date: 08/27/09 >> >> 18:02:00 >> >> >> >> No virus found in this outgoing message. >> >> Checked by AVG -www.avg.com >> >> Version: 8.5.409 / Virus Database: 270.13.71/2330 - Release Date: 08/27/09 >> >> 18:02:00 >> >> >> >> ------------------------------------------------------------------------ >> >> >> >> >> >> >> _______________________________________________ >> >> Xen-devel mailing list >> >> Xen-devel@lists.xensource.com >> >> http://lists.xensource.com/xen-devel >> >> >> >> >> >> ------------------------------------------------------------------------ >> >> >> >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xensource.com >> http://lists.xensource.com/xen-devel >> >> >> >> >> >> > > ------------------------------------------------------------------------ > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > --------------030200060002050907050308 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
Dear All,

After applying Intel VGA passthrough patches 1, 2 and 3, I have no problems with "make xen", and "make install-xen". However, I have errors with "make tools".

Here is the error output:

msoft-float -I. -I.. -I../../../../tools/include -c -o build.o build.c
build.c: In function ‘construct_secondary_tables’:
build.c:194: error: ‘AmlCode_TPM’ undeclared (first use in this function)
build.c:194: error: (Each undeclared identifier is reported only once
build.c:194: error: for each function it appears in.)
make[8]: *** [build.o] Error 1
make[8]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware/hvmloader/acpi'
make[7]: *** [subdir-all-acpi] Error 2
make[7]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware/hvmloader'
make[6]: *** [subdirs-all] Error 2
make[6]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware/hvmloader'
make[5]: *** [subdir-all-hvmloader] Error 2
make[5]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware'
make[4]: *** [subdirs-all] Error 2
make[4]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools/firmware'
make[2]: *** [subdir-install-firmware] Error 2
make[2]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools'
make[1]: *** [subdirs-install] Error 2
make[1]: Leaving directory `/usr/src/xen-unstable.hg-vgapt/tools'
make: *** [install-tools] Error 2

There is an undeclared identifier in tools/firmware/hvmloader/acpi/build.c source code. Could you guys help me resolve this issue?

I had no problems compiling xen 3.5-unstable before applying the Intel vga passthrough patches and before installing the Intel ACPI Component Architecture compiler.

I have also attached Intel graphics passthrough patches 1, 2 and 3 for your convenience here.

Thank you very much.

Hope I can get this working during the weekends.

-- 
Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) 
Technical Support Engineer 
Information Technology Department
Asiasoft Online Pte Ltd
Tampines Central 1 #04-01 Tampines Plaza 
Singapore 529541
Republic of Singapore
Company Website: http://www.asiasoft.sg/
Mobile: +65-9648-9798
MSN: teoenming@hotmail.com
Alma Maters: Singapore Polytechnic, National University of Singapore


On 08/29/2009 10:17 AM, Mr. Teo En Ming (Zhang Enming) wrote:
Hi Tim,

I thought it should be gfx_passthru=2 in domU config?
-- 
Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) 
Technical Support Engineer 
Information Technology Department
Asiasoft Online Pte Ltd
Tampines Central 1 #04-01 Tampines Plaza 
Singapore 529541
Republic of Singapore
Mobile: +65-9648-9798
MSN: teoenming@hotmail.com
Alma Maters: Singapore Polytechnic, National University of Singapore


On 08/29/2009 06:42 AM, Tim Moore wrote:

Teo,

 

I have also performed the same exercise as yourself and I now have successfully compiled all 3x patches into Xen, Qemu and the BIOS File Loading in the hvmloader, this all compiles find on my system. Suggest you do a "make clean" on the tools and start again !

 

After booting with the patched xen-unstable and adding the gfx-passthru=1 parameter to my HVM DomU, as I suspected - it still doesn't work.

 

I have both a 9500GT and GTX260(primary) in my Intel DX58SO machine, tried passing through either device and my primary display locks up ! (included hiding with pci-stub)

 

I verified that the DomU was functional beforehand, as It also booted successfully without the gfx-passthru parameter (and a vncviewer/cirrus display)

 

Unfortunately, I can't debug further as my Primary display corrupts as soon as the DomU starts. I did notice that in "xm debug" the "Loading Gfx BIOS File.." message was displayed and the DomU did continue to initialise the BIOS tables and such before finally locking. I then (blindly) typed on a corrupt Dom0 console and managed to start kdm and login, so the Dom0 was not completely trashed. But then after a few minutes, the machine totally froze and had to hit the reset switch.

 

I`m no specialist but this looks like the VGA BIOS Re-initialisation is playing havoc with the DomU and possibly the Dom0 graphics. I notice that both are also using IRQ11 which could play a major part. Furthermore, there was a lot of debug output in the qemu and xend.log indicating Base Address Register invalid access and therefore it seems there may be a second obstacle.

 

Hope you have a better success than me !

 

For now, I would try re-compiling a fresh xen-unstable with carefully applied patches .. oh! and don't forget to enable the pci-stub driver for Dom0 (it's not selected by default)

 

Tim

 

From: xen-devel-bounces@lists.xensource.com [mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of Mr. Teo En Ming (Zhang Enming)
Sent: 28 August 2009 21:14
To: enming.teo@asiasoftsea.net
Cc: xen-devel@lists.xensource.com; 'Lin, Ben Y'; 'Kay, Allen M'; 'Jean Guyader'; Keir.Fraser@eu.citrix.com; weidong.han@intel.com; bengheng@eecs.umich.edu
Subject: Re: [Xen-devel] [PATCH 2/2] graphics passthrough with VT-d

 

After applying the 1st and 2nd patch to xen-unstable successfully, I examined the source codes Makefile and hvmloader.c in tools/firmware/hvmloader, compared them to Weidong's 3rd patch and I generated my own 3rd patch. Then I used my own generated 3rd patch to apply patching for loading vga bios from firmware file.
 
Here is my own generated 3rd patch instead of using Weidong's 3rd patch:
 
--- Makefile    2009-08-29 03:24:52.413083774 +0800
+++ Makefile    2009-08-29 03:29:12.763299633 +0800
@@ -50,6 +50,7 @@
 roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \
        ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h
        sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h
+       sh ./mkhex vgabios_pt ../vgabios/vgabios-pt.bin >> roms.h
        sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
        sh ./mkhex vgabios_cirrusvga \
                ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h
--- hvmloader.c 2009-08-29 03:26:06.911085797 +0800
+++ hvmloader.c 2009-08-29 03:31:43.172084995 +0800
@@ -688,9 +688,9 @@
         vgabios_sz = round_option_rom(sizeof(vgabios_stdvga));
         break;
     case VGA_pt:
-        printf("Loading VGABIOS of passthroughed gfx ...\n");
-        vgabios_sz =
-            round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512);
+       printf("Loading Gfx Video BIOS from file ...\n");
+       memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, vgabios_pt, sizeof(vgabios_pt));
+       vgabios_sz = round_option_rom(sizeof(vgabios_pt));
         break;
     default:
         printf("No emulated VGA adaptor ...\n");
 
 
I can "make xen" successfully but when I proceeded to "make tools", errors were encountered.
 
Please see attached error output. How can I solve this problem?
 
 
-- 
Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) 
Technical Support Engineer 
Information Technology Department
Asiasoft Online Pte Ltd
Tampines Central 1 #04-01 Tampines Plaza 
Singapore 529541
Republic of Singapore
Mobile: +65-9648-9798
MSN: teoenming@hotmail.com
Alma Maters: Singapore Polytechnic, National University of Singapore



On 08/29/2009 12:59 AM, Mr. Teo En Ming (Zhang Enming) wrote:

OK I believe the 3rd patch is not incomplete but there's a white space issue when I copied the code from the mailing list into my vi.
 
See http://www.htdig.org/mail/2000/11/0167.html
 
When I used the -l flag to patch using the 3rd patch, the number of errors was reduced.
 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch -l -p1 < intel-gfx-passthru-patch-3.patch 
patching file tools/firmware/hvmloader/Makefile
patching file tools/firmware/hvmloader/hvmloader.c
Hunk #1 FAILED at 688.
1 out of 1 hunk FAILED -- saving rejects to file tools/firmware/hvmloader/hvmloader.c.rej
 
Now patching tools/firmware/hvmloader/Makefile is successful but patching tools/firmware/hvmloader/hvmloader.c still failed.
 
-- 
Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) 
Technical Support Engineer 
Information Technology Department
Asiasoft Online Pte Ltd
Tampines Central 1 #04-01 Tampines Plaza 
Singapore 529541
Republic of Singapore
Mobile: +65-9648-9798
MSN: teoenming@hotmail.com
Alma Maters: Singapore Polytechnic, National University of Singapore




On 08/28/2009 11:55 PM, Mr. Teo En Ming (Zhang Enming) wrote:

Dear Weidong,

A big big thanks for the vga passthrough patches for xen 3.5-unstable!!! These are eagerly anticipated patches. As I did not study computer science and computer architecture, I won't be able to write those patches you guys at Intel wrote.

I applied the following patches xen-gfx-passthrough.patch and qemu-gfx-passthrough.patch to xen 3.5-unstable without issues.

Then I tried to apply the 3rd patch you provided at http://lists.xensource.com/archives/html/xen-devel/2009-08/msg01047.html

I saved the following code

<CODE>

diff -r 494be76c1ad9 tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Thu Aug 27 16:54:33 2009 +0800
+++ b/tools/firmware/hvmloader/Makefile Thu Aug 27 17:22:01 2009 +0800
@@ -50,6 +50,7 @@ roms.h: ../rombios/BIOS-bochs-latest ../
 roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \
    ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h
    sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h
+   sh ./mkhex vgabios_pt ../vgabios/vgabios-pt.bin >> roms.h
    sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
    sh ./mkhex vgabios_cirrusvga \
        ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h
diff -r 494be76c1ad9 tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c  Thu Aug 27 16:54:33 2009 +0800
+++ b/tools/firmware/hvmloader/hvmloader.c  Thu Aug 27 17:23:00 2009 +0800
@@ -688,9 +688,9 @@ int main(void)
         vgabios_sz = round_option_rom(sizeof(vgabios_stdvga));
         break;
     case VGA_pt:
-        printf("Loading Gfx Video BIOS from 0xC0000 ...\n");
-        vgabios_sz =
-            round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512);
+         printf("Loading Gfx Video BIOS from file ...\n");
+         memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, vgabios_pt, 
sizeof(vgabios_pt));
+         vgabios_sz = round_option_rom(sizeof(vgabios_pt));
         break;
     default:
         printf("No emulated VGA adaptor ...\n");
  
</CODE>
 
as intel-gfx-passthru-patch-3.patch and then I tried to apply the patch to xen 3.5-unstable. I got errors. I think it's because the 3rd patch you provided is incomplete.
 
Here's my patching process:
 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# find . -name vgabios
./tools/firmware/vgabios
./.hg/store/data/tools/firmware/vgabios
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# cp ~enming/vgabios-pt.bin tools/firmware/vgabios/
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# ls tools/firmware/vgabios/
biossums.c  clext.c      Makefile  TODO                 vbe.h            vgabios.h       vgatables.h
BUGS        COPYING      Notes     vbe.c                vbetables-gen.c  vgabios-pt.bin
ChangeLog   dataseghack  README    vbe_display_api.txt  vgabios.c        vgafonts.h
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# pwd
/usr/src/xen-unstable.hg-vgapt
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# wget http://lists.xensource.com/archives/html/xen-devel/2009-08/bincPiiAf0QWg.bin
--2009-08-28 23:18:21--  http://lists.xensource.com/archives/html/xen-devel/2009-08/bincPiiAf0QWg.bin
Resolving lists.xensource.com... 70.42.241.110
Connecting to lists.xensource.com|70.42.241.110|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12565 (12K) [application/octet-stream]
Saving to: `bincPiiAf0QWg.bin'
 
100%[======================================================================>] 12,565      30.7K/s   in 0.4s    
 
2009-08-28 23:18:22 (30.7 KB/s) - `bincPiiAf0QWg.bin' saved [12565/12565]
 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# mv bincPiiAf0QWg.bin xen-gfx-passthrough.patch
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi xen-gfx-passthrough.patch 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch < xen-gfx-passthrough.patch 
can't find file to patch at input line 4
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff -r 5d7e7a250267 tools/firmware/hvmloader/config.h
|--- a/tools/firmware/hvmloader/config.h      Wed Aug 26 18:28:44 2009 +0800
|+++ b/tools/firmware/hvmloader/config.h      Thu Aug 27 16:54:24 2009 +0800
--------------------------
File to patch: ^C
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# ex xen-gfx-passthrough.patch 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch -p1 < xen-gfx-passthrough.patch 
patching file tools/firmware/hvmloader/config.h
patching file tools/firmware/hvmloader/hvmloader.c
patching file tools/libxc/ia64/xc_ia64_hvm_build.c
patching file tools/libxc/xc_hvm_build.c
patching file tools/libxc/xc_linux.c
patching file tools/libxc/xenctrl.h
patching file tools/libxc/xenguest.h
patching file tools/python/xen/lowlevel/xc/xc.c
patching file tools/python/xen/xend/XendConfig.py
Hunk #1 succeeded at 174 (offset -1 lines).
patching file tools/python/xen/xend/image.py
Hunk #1 succeeded at 780 (offset -6 lines).
Hunk #3 succeeded at 895 (offset -6 lines).
patching file tools/python/xen/xm/create.py
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# wget http://lists.xensource.com/archives/html/xen-devel/2009-08/binglLqkeq4Rj.bin
--2009-08-28 23:21:35--  http://lists.xensource.com/archives/html/xen-devel/2009-08/binglLqkeq4Rj.bin
Resolving lists.xensource.com... 70.42.241.110
Connecting to lists.xensource.com|70.42.241.110|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9841 (9.6K) [application/octet-stream]
Saving to: `binglLqkeq4Rj.bin'
 
100%[======================================================================>] 9,841       24.3K/s   in 0.4s    
 
2009-08-28 23:21:36 (24.3 KB/s) - `binglLqkeq4Rj.bin' saved [9841/9841]
 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# mv binglLqkeq4Rj.bin qemu-gfx-passthrough.patch
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi qemu-gfx-passthrough.patch 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# find . -name hw
./tools/ioemu-remote/hw
./.hg/store/data/tools/ioemu/hw
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# mv qemu-gfx-passthrough.patch tools/ioemu-remote/
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# cd tools/ioemu-remote/
[root@fedora11-x86-64-host ioemu-remote]# patch -p1 < qemu-
qemu-aio.h                  qemu-img.c                  qemu-sockets.c
qemu-binfmt-conf.sh         qemu-img.texi               qemu-tech.texi
qemu-char.c                 qemu-lock.h                 qemu-timer.h
qemu-char.h                 qemu-log.h                  qemu-tool.c
qemu-common.h               qemu-malloc.c               qemu-xen.h
qemu-doc.texi               qemu-nbd.c                  
qemu-gfx-passthrough.patch  qemu-nbd.texi               
[root@fedora11-x86-64-host ioemu-remote]# patch -p1 < qemu-gfx-passthrough.patch 
patching file hw/pass-through.c
patching file hw/pass-through.h
patching file hw/pc.c
patching file vl.c
[root@fedora11-x86-64-host ioemu-remote]# cd ..
[root@fedora11-x86-64-host tools]# cd ..
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi intel-gfx-passthru-patch-3.patch
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# patch -p1 < intel-gfx-passthru-patch-3.patch 
patching file tools/firmware/hvmloader/Makefile
Hunk #1 FAILED at 50.
1 out of 1 hunk FAILED -- saving rejects to file tools/firmware/hvmloader/Makefile.rej
patching file tools/firmware/hvmloader/hvmloader.c
patch: **** malformed patch at line 24: sizeof(vgabios_pt));
 
[root@fedora11-x86-64-host xen-unstable.hg-vgapt]# vi intel-gfx-passthru-patch-3.patch 
 
For everybody's convenience, I have attached intel-gfx-passthru-patch-3.patch and the firmware for my nVidia GeForce 8400 GS PCI Express x16 graphics card in this email.
 
Please help me complete intel-gfx-passthru-patch-3.patch as I really need it.
 
Thank you very much!!!
  
-- 
Mr. Teo En Ming (Zhang Enming) Dip(Mechatronics Engineering) BEng(Hons)(Mechanical Engineering) 
Technical Support Engineer 
Information Technology Department
Asiasoft Online Pte Ltd
Tampines Central 1 #04-01 Tampines Plaza 
Singapore 529541
Republic of Singapore
Mobile: +65-9648-9798
MSN: teoenming@hotmail.com
Alma Maters: Singapore Polytechnic, National University of Singapore
This patch supports basic gfx passthrough on QEMU:
  - disable emulated VGA adpater if there is passthroughed gfx
  - register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfx
 
Signed-off-by: Ben Lin <ben.y.lin@intel.com>
Signed-off-by: Weidong Han <weidong.han@intel.com>
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.409 / Virus Database: 270.13.69/2328 - Release Date: 08/27/09
18:02:00
 
No virus found in this outgoing message.
Checked by AVG - www.avg.com 
Version: 8.5.409 / Virus Database: 270.13.71/2330 - Release Date: 08/27/09
18:02:00
  

 
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
  




 
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
  

 




 


_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel


--------------030200060002050907050308-- --------------040707060806010909040405 Content-Type: text/plain; name="intel-gfx-passthru-patch01.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="intel-gfx-passthru-patch01.patch" diff -r 5d7e7a250267 tools/firmware/hvmloader/config.h --- a/tools/firmware/hvmloader/config.h Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/firmware/hvmloader/config.h Thu Aug 27 16:54:24 2009 +0800 @@ -15,7 +15,7 @@ #define PCI_ISA_IRQ_MASK 0x0c20U /* ISA IRQs 5,10,11 are PCI connected */ /* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */ -#define PCI_MEM_START 0xf0000000 +#define PCI_MEM_START 0xe0000000 #define PCI_MEM_END 0xfc000000 extern unsigned long pci_mem_start, pci_mem_end; diff -r 5d7e7a250267 tools/firmware/hvmloader/hvmloader.c --- a/tools/firmware/hvmloader/hvmloader.c Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/firmware/hvmloader/hvmloader.c Fri Aug 28 14:41:22 2009 +0800 @@ -113,7 +113,7 @@ unsigned long pci_mem_start = PCI_MEM_ST unsigned long pci_mem_start = PCI_MEM_START; unsigned long pci_mem_end = PCI_MEM_END; -static enum { VGA_none, VGA_std, VGA_cirrus } virtual_vga = VGA_none; +static enum { VGA_none, VGA_std, VGA_cirrus, VGA_pt } virtual_vga = VGA_none; static void init_hypercalls(void) { @@ -212,8 +212,10 @@ static void pci_setup(void) case 0x0300: if ( (vendor_id == 0x1234) && (device_id == 0x1111) ) virtual_vga = VGA_std; - if ( (vendor_id == 0x1013) && (device_id == 0xb8) ) + else if ( (vendor_id == 0x1013) && (device_id == 0xb8) ) virtual_vga = VGA_cirrus; + else + virtual_vga = VGA_pt; break; case 0x0680: /* PIIX4 ACPI PM. Special device with special PCI config space. */ @@ -684,6 +686,11 @@ int main(void) memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, vgabios_stdvga, sizeof(vgabios_stdvga)); vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); + break; + case VGA_pt: + printf("Loading VGABIOS of passthroughed gfx ...\n"); + vgabios_sz = + round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); break; default: printf("No emulated VGA adaptor ...\n"); diff -r 5d7e7a250267 tools/libxc/ia64/xc_ia64_hvm_build.c --- a/tools/libxc/ia64/xc_ia64_hvm_build.c Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/libxc/ia64/xc_ia64_hvm_build.c Thu Aug 27 16:54:24 2009 +0800 @@ -1109,7 +1109,9 @@ int xc_hvm_build_target_mem(int xc_handl uint32_t domid, int memsize, int target, - const char *image_name) + const char *image_name, + int gfx_passthru) + { /* XXX:PoD isn't supported yet */ return xc_hvm_build(xc_handle, domid, target, image_name); diff -r 5d7e7a250267 tools/libxc/xc_hvm_build.c --- a/tools/libxc/xc_hvm_build.c Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/libxc/xc_hvm_build.c Thu Aug 27 16:54:24 2009 +0800 @@ -64,6 +64,67 @@ static void build_hvm_info(void *hvm_inf for ( i = 0, sum = 0; i < hvm_info->length; i++ ) sum += ((uint8_t *)hvm_info)[i]; hvm_info->checksum = -sum; +} + +static int init_vgabios(int xc_handle, uint32_t dom, + unsigned char *buffer, uint32_t bios_size) +{ + char *va_bios = NULL; + uint32_t va_size = 0; + + va_size = bios_size + bios_size % XC_PAGE_SIZE; + va_bios = xc_map_foreign_range(xc_handle, dom, va_size, + PROT_READ | PROT_WRITE, 0xC0); + if ( !va_bios ) + { + IPRINTF("Unable to map vga bios!\n"); + return -1; + } + + if ( buffer != NULL ) + memcpy(va_bios, buffer, bios_size); + else + memset(va_bios, 0, bios_size); + + munmap(va_bios, va_size); + return 0; +} + +static int setup_vga_pt(int xc_handle, uint32_t dom) +{ + int rc = 0; + unsigned char *bios = NULL; + int bios_size = 0; + char *c = NULL; + char checksum = 0; + + /* Allocated 64K for the vga bios */ + if (!(bios = malloc(64 * 1024))) + return -1; + +#ifdef __linux__ + bios_size = xc_get_vgabios(bios, 64 * 1024); +#else + bios_size = 0; +#endif /* __linux__ */ + + if (bios_size == 0) + { + IPRINTF("vga bios size is 0!\n"); + rc = -1; + goto error; + } + + /* Adjust the bios checksum */ + for ( c = (char*)bios; c < ((char*)bios + bios_size); c++ ) + checksum += *c; + if (checksum) + bios[bios_size - 1] -= checksum; + + init_vgabios(xc_handle, dom, bios, bios_size); +error: + free(bios); + return rc; } static int loadelfimage( @@ -381,7 +442,8 @@ int xc_hvm_build_target_mem(int xc_handl uint32_t domid, int memsize, int target, - const char *image_name) + const char *image_name, + int gfx_passthru) { char *image; int sts; @@ -392,6 +454,11 @@ int xc_hvm_build_target_mem(int xc_handl return -1; sts = xc_hvm_build_internal(xc_handle, domid, memsize, target, image, image_size); + + if ( gfx_passthru ) + sts |= setup_vga_pt(xc_handle, domid); + else + sts |= init_vgabios(xc_handle, domid, NULL, 0x800); free(image); diff -r 5d7e7a250267 tools/libxc/xc_linux.c --- a/tools/libxc/xc_linux.c Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/libxc/xc_linux.c Thu Aug 27 16:54:24 2009 +0800 @@ -638,6 +638,56 @@ err: return gnt; } +int xc_get_vgabios(unsigned char *buf, + int len) +{ + int mem; + uint32_t start, size = 0; + uint16_t magic = 0; + + start = 0xC0000; + if (len < size) + return 0; + if ((mem = open("/dev/mem", O_RDONLY)) < 0) + return 0; + + /* + ** Check if it a real bios extension. + ** The magic number is 0xAA55. + */ + if (start != lseek(mem, start, SEEK_SET)) + goto out; + if (read(mem, &magic, 2) != 2) + goto out; + if (magic != 0xAA55) + goto out; + /* Find the size of the rom extension */ + if (start != lseek(mem, start, SEEK_SET)) + goto out; + if (lseek(mem, 2, SEEK_CUR) != (start + 2)) + goto out; + if (read(mem, &size, 1) != 1) + goto out; + /* This size is in 512K */ + size *= 512; + + /* + ** Set the file to the begining of the rombios, + ** to start the copy. + */ + if (start != lseek(mem, start, SEEK_SET)) + { + size = 0; + goto out; + } + if (size != read(mem, buf, size)) + size = 0; + +out: + close(mem); + return size; +} + /* * Local variables: * mode: C diff -r 5d7e7a250267 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/libxc/xenctrl.h Thu Aug 27 16:54:24 2009 +0800 @@ -1285,4 +1285,6 @@ int xc_tmem_restore(int xc_handle, int d int xc_tmem_restore(int xc_handle, int dom, int fd); int xc_tmem_restore_extra(int xc_handle, int dom, int fd); +int xc_get_vgabios(unsigned char *bios, int len); + #endif /* XENCTRL_H */ diff -r 5d7e7a250267 tools/libxc/xenguest.h --- a/tools/libxc/xenguest.h Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/libxc/xenguest.h Thu Aug 27 16:54:24 2009 +0800 @@ -135,7 +135,8 @@ int xc_hvm_build_target_mem(int xc_handl uint32_t domid, int memsize, int target, - const char *image_name); + const char *image_name, + int gfx_passthru); int xc_hvm_build_mem(int xc_handle, uint32_t domid, diff -r 5d7e7a250267 tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/python/xen/lowlevel/xc/xc.c Thu Aug 27 16:54:24 2009 +0800 @@ -894,21 +894,21 @@ static PyObject *pyxc_hvm_build(XcObject int i; #endif char *image; - int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1; + int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1, gfx_passthru = 0; static char *kwd_list[] = { "domid", "memsize", "image", "target", "vcpus", "acpi", - "apic", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list, + "apic", "gfx_passthru", NULL }; + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiiii", kwd_list, &dom, &memsize, &image, &target, &vcpus, - &acpi, &apic) ) + &acpi, &apic, &gfx_passthru) ) return NULL; if ( target == -1 ) target = memsize; if ( xc_hvm_build_target_mem(self->xc_handle, dom, memsize, - target, image) != 0 ) + target, image, gfx_passthru) != 0 ) return pyxc_error_to_exception(); #if !defined(__ia64__) diff -r 5d7e7a250267 tools/python/xen/xend/XendConfig.py --- a/tools/python/xen/xend/XendConfig.py Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/python/xen/xend/XendConfig.py Thu Aug 27 16:54:24 2009 +0800 @@ -175,6 +175,7 @@ XENAPI_PLATFORM_CFG_TYPES = { 'pci_msitranslate': int, 'pci_power_mgmt': int, 'xen_platform_pci': int, + "gfx_passthru": int, } # Xen API console 'other_config' keys. diff -r 5d7e7a250267 tools/python/xen/xend/image.py --- a/tools/python/xen/xend/image.py Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/python/xen/xend/image.py Thu Aug 27 16:54:24 2009 +0800 @@ -786,7 +786,7 @@ class HVMImageHandler(ImageHandler): self.apic = int(vmConfig['platform'].get('apic', 0)) self.acpi = int(vmConfig['platform'].get('acpi', 0)) self.guest_os_type = vmConfig['platform'].get('guest_os_type') - + self.gfx_passthru = int(vmConfig['platform'].get('gfx_passthru', 0)) # Return a list of cmd line args to the device models based on the # xm config file @@ -807,7 +807,7 @@ class HVMImageHandler(ImageHandler): dmargs = [ 'boot', 'fda', 'fdb', 'soundhw', 'localtime', 'serial', 'stdvga', 'isa', - 'acpi', 'usb', 'usbdevice' ] + 'acpi', 'usb', 'usbdevice', 'gfx_passthru' ] for a in dmargs: v = vmConfig['platform'].get(a) @@ -901,6 +901,7 @@ class HVMImageHandler(ImageHandler): log.debug("vcpus = %d", self.vm.getVCpuCount()) log.debug("acpi = %d", self.acpi) log.debug("apic = %d", self.apic) + log.debug("gfx_passthru = %d", self.gfx_passthru) rc = xc.hvm_build(domid = self.vm.getDomid(), image = self.loader, @@ -908,7 +909,8 @@ class HVMImageHandler(ImageHandler): target = mem_mb, vcpus = self.vm.getVCpuCount(), acpi = self.acpi, - apic = self.apic) + apic = self.apic, + gfx_passthru = self.gfx_passthru) rc['notes'] = { 'SUSPEND_CANCEL': 1 } rc['store_mfn'] = xc.hvm_get_param(self.vm.getDomid(), diff -r 5d7e7a250267 tools/python/xen/xm/create.py --- a/tools/python/xen/xm/create.py Wed Aug 26 18:28:44 2009 +0800 +++ b/tools/python/xen/xm/create.py Thu Aug 27 16:54:24 2009 +0800 @@ -546,6 +546,10 @@ gopts.var('sdl', val='', gopts.var('sdl', val='', fn=set_value, default=None, use="""Should the device model use SDL?""") + +gopts.var('gfx_passthru', val='', + fn=set_value, default=None, + use="""Passthrough graphics card?""") gopts.var('opengl', val='', fn=set_value, default=None, @@ -957,7 +961,8 @@ def configure_hvm(config_image, vals): 'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', 'hpet', 'guest_os_type', 'hap', 'opengl', 'cpuid', 'cpuid_check', 'viridian', 'xen_extended_power_mgmt', 'pci_msitranslate', - 'vpt_align', 'pci_power_mgmt', 'xen_platform_pci' ] + 'vpt_align', 'pci_power_mgmt', 'xen_platform_pci', + 'gfx_passthru' ] for a in args: if a in vals.__dict__ and vals.__dict__[a] is not None: --------------040707060806010909040405 Content-Type: text/plain; name="intel-gfx-passthru-patch02.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="intel-gfx-passthru-patch02.patch" >From fb818f1060e57dac6793187a70a79801a7c17e50 Mon Sep 17 00:00:00 2001 From: Weidong Han Date: Thu, 27 Aug 2009 16:51:01 +0800 Subject: [PATCH] qemu gfx passthrough support support basic gfx passthrough: - disable emulated VGA adpater if there is passthroughed gfx - register/unregister legacy VGA I/O ports and MMIOs for passthroughed gfx Signed-off-by: Ben Lin Signed-off-by: Weidong Han --- hw/pass-through.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pass-through.h | 6 +++++ hw/pc.c | 51 ++++++++++++++++++++++++------------------ vl.c | 32 +++++++++++++++++++++++--- 4 files changed, 126 insertions(+), 26 deletions(-) diff --git a/hw/pass-through.c b/hw/pass-through.c index 8d80755..4a9e03a 100644 --- a/hw/pass-through.c +++ b/hw/pass-through.c @@ -93,6 +93,8 @@ #include #include +extern int gfx_passthru; + struct php_dev { struct pt_dev *pt_dev; uint8_t valid; @@ -1781,12 +1783,57 @@ static int pt_dev_is_virtfn(struct pci_dev *dev) return rc; } +/* + * register VGA resources for the domain with assigned gfx + */ +static int register_vga_regions(struct pt_dev *real_device) +{ + int ret = 0; + + ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3B0, + 0x3B0, 0xC, DPCI_ADD_MAPPING); + + ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0, + 0x3C0, 0x20, DPCI_ADD_MAPPING); + + ret |= xc_domain_memory_mapping(xc_handle, domid, + 0xa0000 >> XC_PAGE_SHIFT, + 0xa0000 >> XC_PAGE_SHIFT, + 0x20, + DPCI_ADD_MAPPING); + + return ret; +} + +/* + * unregister VGA resources for the domain with assigned gfx + */ +static int unregister_vga_regions(struct pt_dev *real_device) +{ + int ret = 0; + + ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3B0, + 0x3B0, 0xC, DPCI_REMOVE_MAPPING); + + ret |= xc_domain_ioport_mapping(xc_handle, domid, 0x3C0, + 0x3C0, 0x20, DPCI_REMOVE_MAPPING); + + ret |= xc_domain_memory_mapping(xc_handle, domid, + 0xa0000 >> XC_PAGE_SHIFT, + 0xa0000 >> XC_PAGE_SHIFT, + 0x20, + DPCI_REMOVE_MAPPING); + + return ret; +} + static int pt_register_regions(struct pt_dev *assigned_device) { int i = 0; uint32_t bar_data = 0; struct pci_dev *pci_dev = assigned_device->pci_dev; PCIDevice *d = &assigned_device->dev; + int ret; /* Register PIO/MMIO BARs */ for ( i = 0; i < PCI_BAR_ENTRIES; i++ ) @@ -1842,6 +1889,16 @@ static int pt_register_regions(struct pt_dev *assigned_device) (uint32_t)(pci_dev->rom_size), (uint32_t)(pci_dev->rom_base_addr)); } + if ( gfx_passthru && (pci_dev->device_class == 0x0300) ) + { + ret = register_vga_regions(assigned_device); + if ( ret != 0 ) + { + PT_LOG("VGA region mapping failed\n"); + return ret; + } + } + return 0; } @@ -1891,6 +1948,12 @@ static void pt_unregister_regions(struct pt_dev *assigned_device) } + if ( gfx_passthru && (assigned_device->pci_dev->device_class == 0x0300) ) + { + ret = unregister_vga_regions(assigned_device); + if ( ret != 0 ) + PT_LOG("VGA region unmapping failed\n"); + } } static uint8_t find_cap_offset(struct pci_dev *pci_dev, uint8_t cap) diff --git a/hw/pass-through.h b/hw/pass-through.h index 028a03e..956e228 100644 --- a/hw/pass-through.h +++ b/hw/pass-through.h @@ -142,6 +142,12 @@ enum { GRP_TYPE_EMU, /* emul reg group */ }; +enum { + GFX_NO_PASSTHRU = 0, /* No gfx pass-through */ + GFX_IGD_PASSTHRU, /* IGD pass-through */ + GFX_DISCRETE_PASSTHRU, /* Discrete gfx pass-through */ +}; + #define PT_GET_EMUL_SIZE(flag, r_size) do { \ if (flag == PT_BAR_FLAG_MEM) {\ r_size = (((r_size) + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1)); \ diff --git a/hw/pc.c b/hw/pc.c index 129e9d9..53b59c0 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -41,6 +41,7 @@ #include "virtio-balloon.h" #include "virtio-console.h" #include "hpet_emul.h" +#include "pass-through.h" /* output Bochs bios info messages */ //#define DEBUG_BIOS @@ -65,6 +66,8 @@ void tpm_tis_init(SetIRQFunc *set_irq, void *opaque, int irq); extern uint8_t *acpi_tables; extern size_t acpi_tables_len; +extern int gfx_passthru; + static fdctrl_t *floppy_controller; static RTCState *rtc_state; static PITState *pit; @@ -983,30 +986,34 @@ vga_bios_error: register_ioport_write(0xf0, 1, 1, ioportF0_write, NULL); - if (cirrus_vga_enabled) { - if (pci_enabled) { - pci_cirrus_vga_init(pci_bus, - phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); - } else { - isa_cirrus_vga_init(phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); - } + if (gfx_passthru == GFX_NO_PASSTHRU) { + if (cirrus_vga_enabled) { + fprintf(logfile,"cirrus_vga_enabled\n"); + if (pci_enabled) { + pci_cirrus_vga_init(pci_bus, + phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + } else { + isa_cirrus_vga_init(phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + } #ifndef CONFIG_DM - } else if (vmsvga_enabled) { - if (pci_enabled) - pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); - else - fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); + } else if (vmsvga_enabled) { + if (pci_enabled) + pci_vmsvga_init(pci_bus, phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + else + fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__); #endif - } else if (std_vga_enabled) { - if (pci_enabled) { - pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size, 0, 0); - } else { - isa_vga_init(phys_ram_base + vga_ram_addr, - vga_ram_addr, vga_ram_size); + } else if (std_vga_enabled) { + fprintf(logfile,"std_vga_enabled\n"); + if (pci_enabled) { + pci_vga_init(pci_bus, phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size, 0, 0); + } else { + isa_vga_init(phys_ram_base + vga_ram_addr, + vga_ram_addr, vga_ram_size); + } } } diff --git a/vl.c b/vl.c index 62bed05..72f3479 100644 --- a/vl.c +++ b/vl.c @@ -48,6 +48,7 @@ #include #include "qemu-xen.h" +#include "hw/pass-through.h" #include #include @@ -213,6 +214,7 @@ static int rtc_date_offset = -1; /* -1 means no change */ int cirrus_vga_enabled = 1; int std_vga_enabled = 0; int vmsvga_enabled = 0; +int gfx_passthru = 0; #ifdef TARGET_SPARC int graphic_width = 1024; int graphic_height = 768; @@ -4269,6 +4271,7 @@ enum { /* Xen tree: */ QEMU_OPTION_disable_opengl, QEMU_OPTION_direct_pci, + QEMU_OPTION_gfx_passthru, QEMU_OPTION_pci_emulation, QEMU_OPTION_vncunused, QEMU_OPTION_videoram, @@ -4447,6 +4450,7 @@ static const QEMUOption qemu_options[] = { #endif { "acpi", 0, QEMU_OPTION_acpi }, /* deprecated, for xend compatibility */ { "direct_pci", HAS_ARG, QEMU_OPTION_direct_pci }, + { "gfx_passthru", HAS_ARG, QEMU_OPTION_gfx_passthru}, { "pciemulation", HAS_ARG, QEMU_OPTION_pci_emulation }, { "vncunused", 0, QEMU_OPTION_vncunused }, { "vcpus", HAS_ARG, QEMU_OPTION_vcpus }, @@ -5484,6 +5488,22 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_runas: run_as = optarg; break; + case QEMU_OPTION_gfx_passthru: + gfx_passthru = atoi(optarg); + switch (gfx_passthru) { + case GFX_NO_PASSTHRU: + break; + case GFX_IGD_PASSTHRU: + fprintf(logfile, "IGD graphics card assignment\n"); + break; + case GFX_DISCRETE_PASSTHRU: + fprintf(logfile, "Discrete graphics card assignment\n"); + break; + default: + fprintf(stderr, "unsupported gfx_passthru option: %d\n", + gfx_passthru); + } + break; } } } @@ -5897,13 +5917,17 @@ int main(int argc, char **argv, char **envp) exit(1); xenstore_write_vncport(vnc_display_port); } + + if (gfx_passthru == GFX_NO_PASSTHRU) + { #if defined(CONFIG_SDL) - if (sdl || !vnc_display) - sdl_display_init(ds, full_screen, no_frame, opengl_enabled); + if (sdl || !vnc_display) + sdl_display_init(ds, full_screen, no_frame, opengl_enabled); #elif defined(CONFIG_COCOA) - if (sdl || !vnc_display) - cocoa_display_init(ds, full_screen); + if (sdl || !vnc_display) + cocoa_display_init(ds, full_screen); #endif + } } } dpy_resize(ds); -- 1.6.0.4 --------------040707060806010909040405 Content-Type: text/plain; name="intel-gfx-passthru-patch03.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="intel-gfx-passthru-patch03.patch" Manually generated by Teo En Ming (Zhang Enming) on 29 August 2009 Saturday at 11:10 A.M. Singapore Time Email #1: enming.teo@asiasoftsea.net Email #2: space.time.universe@gmail.com MSN: teoenming@hotmail.com --- Makefile 2009-08-29 10:57:28.072084001 +0800 +++ Makefile 2009-08-29 11:03:30.650209241 +0800 @@ -50,6 +50,7 @@ roms.h: ../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin \ ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../etherboot/eb-roms.h sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h + sh ./mkhex vgabios_pt ../vgabios/vgabios-pt.bin >> roms.h sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h sh ./mkhex vgabios_cirrusvga \ ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h --- hvmloader.c 2009-08-29 10:58:52.679084845 +0800 +++ hvmloader.c 2009-08-29 11:07:40.763119203 +0800 @@ -688,10 +688,10 @@ vgabios_sz = round_option_rom(sizeof(vgabios_stdvga)); break; case VGA_pt: - printf("Loading VGABIOS of passthroughed gfx ...\n"); - vgabios_sz = - round_option_rom((*(uint8_t *)(VGABIOS_PHYSICAL_ADDRESS+2)) * 512); - break; + printf("Loading Gfx Video BIOS from file ...\n"); + memcpy((void *)VGABIOS_PHYSICAL_ADDRESS, vgabios_pt, sizeof(vgabios_pt)); + vgabios_sz = round_option_rom(sizeof(vgabios_pt)); + break; default: printf("No emulated VGA adaptor ...\n"); break; --------------040707060806010909040405 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------040707060806010909040405--