Hi,
This patch is qemu parts.
Signed-off-by: Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>
Best Regards,
Akio Takebe
diff --git a/hw/pass-through.c b/hw/pass-through.c
index f23bdbb..43a5e20 100644
--- a/hw/pass-through.c
+++ b/hw/pass-through.c
@@ -27,6 +27,8 @@
#include "pci/pci.h"
#include "pt-msi.h"
#include "qemu-xen.h"
+#include "xen/hvm/hvm_info_table.h"
+#include <sys/mman.h>
#include <unistd.h>
struct php_dev {
@@ -3634,6 +3636,60 @@ static int pt_pmcsr_reg_restore(struct pt_dev *ptdev,
return 0;
}
+static int
+pt_register_bootable_device(uint32_t e_devfn, int pci_boot)
+{
+ uint8_t *hvm_info_page;
+ struct hvm_info_table *hvm_info;
+ int i;
+ uint8_t sum;
+ uint32_t devfn;
+ int rc = -1;
+
+ if (pci_boot <= 0 ) {
+ PT_LOG("Error: pci_boot=%d\n", pci_boot);
+ goto out;
+ }
+
+ hvm_info_page = xc_map_foreign_range(xc_handle, domid, XC_PAGE_SIZE,
+ PROT_READ|PROT_WRITE,
HVM_INFO_PFN);
+ if (hvm_info_page == NULL){
+ PT_LOG("Error: xc_map_foreign_rage(HVM_INFO_PFN) error %d\n", errno);
+ goto out;
+ }
+ hvm_info = (struct hvm_info_table *)(hvm_info_page+HVM_INFO_OFFSET);
+
+ if ( strncmp(hvm_info->signature, "HVM INFO", 8) ) {
+ PT_LOG("Error: Bad hvm info signature(%s)\n", hvm_info->signature);
+ goto free;
+ }
+
+ for ( i = 0; i < MAX_PCI_BOOT; i++ ) {
+ if ( hvm_info->pci_sbdf[i] == 0 ) {
+ hvm_info->pci_sbdf[i] = e_devfn;
+ break;
+ } else {
+ if ( i == MAX_PCI_BOOT ){
+ PT_LOG("Error: cannot enable bootable option (devfn=%x:%x)\n",
+ (e_devfn>>3)&&0x1f, e_devfn&&0x7);
+ goto free;
+ }
+ }
+ }
+
+ hvm_info->checksum = 0;
+ for ( i = 0, sum = 0; i < hvm_info->length; i++ )
+ sum += ((uint8_t *)hvm_info)[i];
+ hvm_info->checksum = -sum;
+ rc = 0;
+
+free:
+ munmap(hvm_info_page, XC_PAGE_SIZE);
+out:
+ return rc;
+}
+
+
struct pt_dev * register_real_device(PCIBus *e_bus,
const char *e_dev_name, int e_devfn, uint8_t r_bus, uint8_t r_dev,
uint8_t r_func, uint32_t machine_irq, struct pci_access *pci_access,
@@ -3647,6 +3703,7 @@ struct pt_dev * register_real_device(PCIBus *e_bus,
int free_slot = -1;
char *key, *val;
int msi_translate, power_mgmt;
+ int pci_boot = 0;
PT_LOG("Assigning real physical device %02x:%02x.%x ...\n",
r_bus, r_dev, r_func);
@@ -3716,6 +3773,19 @@ struct pt_dev * register_real_device(PCIBus *e_bus,
else
PT_LOG("Error: unrecognized value for power_mgmt=\n");
}
+ else if (strcmp(key, "boot") == 0)
+ if (strcmp(val, "0") == 0 || strcmp(val, "no") == 0)
+ {
+ PT_LOG("Disable boot option\n");
+ pci_boot = 0;
+ }
+ else if (strcmp(val, "1") == 0 || strcmp(val, "yes") == 0)
+ {
+ PT_LOG("Enable boot option\n");
+ pci_boot = 1;
+ }
+ else
+ PT_LOG("Error: unrecognized value for boot=\n");
else
PT_LOG("Error: unrecognized PCI assignment option \"%s=%s\"\n",
key, val);
@@ -3810,6 +3880,12 @@ struct pt_dev * register_real_device(PCIBus *e_bus,
*(uint16_t *)(&assigned_device->dev.config[0x04]));
}
+ if (pci_boot){
+ rc = pt_register_bootable_device(e_devfn, pci_boot);
+ if ( rc < 0 )
+ return NULL;
+ }
+
out:
PT_LOG("Real physical device %02x:%02x.%x registered successfuly!\n"
"IRQ type = %s\n", r_bus, r_dev, r_func,
diff --git a/hw/pc.c b/hw/pc.c
index 878069d..bd376a0 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -215,6 +215,8 @@ static int boot_device2nibble(char boot_device)
return 0x03; /* CD-ROM boot */
case 'n':
return 0x04; /* Network boot */
+ case 'p':
+ return 0x05; /* Pass-trough device */
}
return 0;
}
diff --git a/vl.c b/vl.c
index 5801e42..9476218 100644
--- a/vl.c
+++ b/vl.c
@@ -3944,7 +3944,9 @@ static void help(int exitcode)
"-mtdblock file use 'file' as on-board Flash memory image\n"
"-sd file use 'file' as SecureDigital card image\n"
"-pflash file use 'file' as a parallel flash image\n"
- "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or
network (n)\n"
+ "-boot [a|c|d|n|p]\n"
+ " boot on floppy (a), hard disk (c), CD-ROM (d),
network (n)\n"
+ " or PCI pass-through(p)\n"
"-snapshot write to temporary files instead of disk image
files\n"
"-m megs set virtual RAM size to megs MB [default=%d]\n"
#ifndef _WIN32
@@ -4982,7 +4984,8 @@ int main(int argc, char **argv, char **envp)
* a b : floppy disk drives
* c ... f : IDE disk drives
* g ... m : machine implementation dependant drives
- * n ... p : network devices
+ * n ... o : network devices
+ * p : PCI pass-through devices
* It's up to each machine implementation to check
* if the given boot devices match the actual hardware
* implementation and firmware features.
@@ -5525,7 +5528,7 @@ int main(int argc, char **argv, char **envp)
kqemu_allowed = 0;
#endif
linux_boot = (kernel_filename != NULL);
- net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0xF;
+ net_boot = (boot_devices_bitmap >> ('n' - 'a')) & 0x2;
if (!linux_boot && net_boot == 0 &&
!machine->nodisk_ok && nb_drives_opt == 0)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|