Disable xen platform PCI device when xen_platform_pci=0 is specified
cover Disable xen platform PCI device when xen_platform_pci=0 is specified
This series of patches disables xen platform PCI device of HVM domain when "xen_platform_pci=0" is specified.
- Alias the "platform_flags" byte of the ioport BAR to fixed byte port 0x10, and don't remove existing "platform_flags" byte.
- Change guest firmware to use new fixed byte port 0x10.
- Add "xen_platform_pci" option into guest config file and APIs.
xen_platform_pci=0: Disable xen platform device. xen_platform_pci=1: Enable xen platform device. (default)
- Add "disable_pf" entry into xenstore.
- Disable xen platform PCI device if "disable_pf" entry is 1. If there is not "disable_pf" entry, xen platform PCI device is enabled.
Thanks,
--
Yuji Shimada
PATCH 1/2 Disable xen platform PCI device when xen_platform_pci=0 is specified
This patch is the xen side of the series.
- Change guest firmware to use new fixed byte port 0x10.
- Add "xen_platform_pci" option into guest config file and APIs.
xen_platform_pci=0: Disable xen platform device. xen_platform_pci=1: Enable xen platform device. (default)
- Add "disable_pf" entry into xenstore.
Thanks,
--
Yuji Shimada
tools/examples/xmexample.hvm +4 -0
@@ -225,6 +225,10 @@ #keymap='ja' #----------------------------------------------------------------------------- +# Enable/disable xen platform PCI device, default=1 (enabled) +#xen_platform_pci=1 + +#----------------------------------------------------------------------------- # Configure guest CPUID responses: # #cpuid=[ '1:ecx=xxxxxxxxxxx00xxxxxxxxxxxxxxxxxxx,
tools/firmware/hvmloader/config.h +0 -2
@@ -56,9 +56,7 @@ uint8_t hpet_present:1; /* 0[2] - System has HPET? */uint32_t pci_min, pci_len;/* 4, 8 - PCI I/O hole boundaries */ uint32_t bios32_entry; /* 12 - Entry point for 32-bit BIOS */ - uint16_t xen_pfiob; /* 16 - Xen platform device I/O ports */ };#define BIOSINFO_OFF_bios32_entry 12 -#define BIOSINFO_OFF_xen_pfiob 16#endif /* __HVMLOADER_CONFIG_H__ */
tools/firmware/hvmloader/hvmloader.c +0 -20
@@ -539,25 +539,6 @@cmos_outb (0x35 , (uint8_t )( alt_mem >>8 )); } -static uint16_t xen_platform_io_base (void ) -{ -uint32_t devfn, bar_data; -uint16_t vendor_id, device_id; - -for ( devfn =0 ; devfn <128 ; devfn++ ) - { - vendor_id =pci_readw (devfn,PCI_VENDOR_ID ); - device_id =pci_readw (devfn,PCI_DEVICE_ID ); -if ( (vendor_id ==0x5853 ) && (device_id ==0x0001 ) ) - { - bar_data =pci_readl (devfn,PCI_BASE_ADDRESS_0 ); -return bar_data &PCI_BASE_ADDRESS_IO_MASK ; - } - } - -return 0 ; -} -/* * Set up an empty TSS area for virtual 8086 mode to use. * The only important thing is that it musn't have any bits set
@@ -744,7 +725,6 @@ bios_info->pci_min = pci_mem_start; bios_info->pci_len = pci_mem_end - pci_mem_start; bios_info->bios32_entry = bios32_addr; - bios_info->xen_pfiob =xen_platform_io_base ();printf ("Invoking ROMBIOS ...\n" );return 0 ;
tools/firmware/rombios/rombios.c +2 -12
@@ -1418,24 +1418,14 @@ write_word(0x40, 0x13, base_mem >> 10); } -ASM_START -_rom_write_access_control: - push ds - mov ax,#(BIOS_INFO_PHYSICAL_ADDRESS >> 4) - mov ds,ax - mov ax,[BIOSINFO_OFF_xen_pfiob] - pop ds - ret -ASM_END -void enable_rom_write_access () { - outb(rom_write_access_control(), 0); +outb (0x10 ,0 ); }void disable_rom_write_access () { -outb (rom_write_access_control (),PFFLAG_ROM_LOCK ); +outb (0x10 ,PFFLAG_ROM_LOCK ); }#endif /* HVMASSIST */
tools/python/xen/xend/XendConfig.py +3 -0
@@ -170,6 +170,7 @@ 'xen_extended_power_mgmt': int, 'pci_msitranslate': int, 'pci_power_mgmt': int, + 'xen_platform_pci': int, } # Xen API console 'other_config' keys.
@@ -464,6 +465,8 @@ self['platform']['rtc_timeoffset'] = 0 if 'hpet' not in self['platform']: self['platform']['hpet'] = 0 + if 'xen_platform_pci' not in self['platform']: + self['platform']['xen_platform_pci'] = 1 if 'vpt_align' not in self['platform']: self['platform']['vpt_align'] = 1 if 'loader' not in self['platform']:
tools/python/xen/xend/image.py +12 -1
@@ -716,6 +716,7 @@ if 'hvm' not in info['xen_caps']: raise HVMRequired() + xen_platform_pci = int(vmConfig['platform'].get('xen_platform_pci',1)) rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset') if not self.display :
@@ -724,13 +725,23 @@ ("image/device-model", self.device_model), ("image/display", self.display)) self.vm.permissionsVm("image/dmargs", { 'dom': self.vm.getDomid(), 'read': True } ) + + if xen_platform_pci == 0: + disable_pf = 1 + log.info("No need to create platform device.[domid:%d]", self.vm.getDomid()) + else: + disable_pf = 0 + log.info("Need to create platform device.[domid:%d]", self.vm.getDomid()) + + xstransact.Store("/local/domain/0/device-model/%i"%self.vm.getDomid(), + ('disable_pf', disable_pf)) self.vm.storeVm(("rtc/timeoffset", rtc_timeoffset)) self.vm.permissionsVm("rtc/timeoffset", { 'dom': self.vm.getDomid(), 'read': True } ) 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') - + # Return a list of cmd line args to the device models based on the # xm config file
tools/python/xen/xm/create.py +5 -1
@@ -611,6 +611,10 @@ fn=set_int, default=0, use="""Global PCI Power Management flag (0=disable;1=enable).""") +gopts.var('xen_platform_pci', val='0|1', + fn=set_int, default=1, + use="Is xen_platform_pci used?") + def err(msg): """Print an error to stderr and exit. """
@@ -921,7 +925,7 @@ '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' ] + 'vpt_align', 'pci_power_mgmt', 'xen_platform_pci' ] for a in args: if a in vals.__dict__ and vals.__dict__[a] is not None:
tools/python/xen/xm/xenapi_create.py +1 -0
@@ -1048,6 +1048,7 @@ 'hap', 'pci_msitranslate', 'pci_power_mgmt', + 'xen_platform_pci', ] platform_configs = []
PATCH 2/2 ioemu: Disable xen platform PCI device when xen_platform_pci=0 is specified
In reply to Yuji ShimadaThis patch is the ioemu side of the series.
- Alias the "platform_flags" byte of the ioport BAR to fixed byte port 0x10, and don't remove existing "platform_flags" byte.
- Disable xen platform PCI device if "disable_pf" entry is 1. If there is not "disable_pf" entry, xen platform PCI device is enabled.
Thanks,
--
Yuji Shimada
hw/pc.c +8 -2
@@ -33,6 +33,7 @@#include "boards.h" #include "console.h" #include "exec-all.h" +#include "qemu-xen.h" #include "xen_platform.h" #include "fw_cfg.h"
@@ -780,6 +781,7 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size, {char buf[1024 ];int ret, linux_boot, i; +int disable_pf;ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;ram_addr_t below_4g_mem_size, above_4g_mem_size =0 ;int bios_size, isa_bios_size, vga_bios_size;
@@ -1033,8 +1035,12 @@ vga_bios_error: pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic); }#endif /* !CONFIG_DM */ -if (pci_enabled) -pci_xen_platform_init (pci_bus); +if (pci_enabled) { + disable_pf =xenstore_parse_disable_pf_config (); +if (disable_pf !=1 ) +pci_xen_platform_init (pci_bus); +platform_fixed_ioport_init (); + }for (i =0 ; i <MAX_SERIAL_PORTS ; i++) {if (serial_hds[i]) {
hw/xen_platform.c +152 -118
338 lines not on this page · raw message
hw/xen_platform.h +1 -0
@@ -4,5 +4,6 @@#include "pci.h" void pci_xen_platform_init (PCIBus *bus); +void platform_fixed_ioport_init (void );#endif
qemu-xen.h +1 -0
@@ -48,6 +48,7 @@ void handle_buffered_pio(void);/* xenstore.c */ void xenstore_parse_domain_config (int domid); +int xenstore_parse_disable_pf_config (void );int xenstore_fd (void );void xenstore_process_event (void *opaque);void xenstore_record_dm (const char *subpath,const char *state);
xenstore.c +21 -0
@@ -639,6 +639,27 @@ void xenstore_parse_domain_config(int hvm_domid)return ; } +int xenstore_parse_disable_pf_config () +{ +char *params =NULL , *buf =NULL ; +int disable_pf =0 ; +unsigned int len; + +if (pasprintf (&buf,"/local/domain/0/device-model/%u/disable_pf" ,domid) ==-1 ) + goto out; + + params =xs_read (xsh,XBT_NULL , buf, &len); +if (params ==NULL ) + goto out; + + disable_pf =atoi (params); + + out: +free (buf); +free (params); +return disable_pf; +} +int xenstore_fd (void ) {if (xsh)
Re: [PATCH 2/2] ioemu: Disable xen platform PCI device when xen_platform_pci=0 is specified
Yuji Shimada writes ("[Xen-devel] [PATCH 2/2] ioemu: Disable xen platform PCI device when xen_platform_pci=0 is specified"):
Quoted 7 lines
This patch is the ioemu side of the series.
- Alias the "
platform_flags" byte of the ioport BAR to fixed byte port0x10, and don't remove existing "platform_flags" byte.- Disable xen platform PCI device if "
disable_pf" entry is 1. If there is not "disable_pf" entry, xen platform PCI device is enabled.
Before I apply this, can you confirm that it doesn't have any compatibility implications in either direction with the corresponding xen-unstable.hg change ?
Thanks,
Ian.
Re: [PATCH 2/2] ioemu: Disable xen platform PCI device when xen_platform_pci=0 is specified
Quoted 7 lines · I wrote:
Yuji Shimada writes ("[Xen-devel] [PATCH 2/2] ioemu: Disable xen platform PCI device when xen_platform_pci=0 is specified"):
Quoted 2 lines
- Disable xen platform PCI device if "
disable_pf" entry is 1. If there is not "disable_pf" entry, xen platform PCI device is enabled.Before I apply this, can you confirm that it doesn't have any compatibility implications in either direction with the corresponding xen-unstable.hg change ?
Never mind, I can see that Keir has applied the other half already so I shall go ahead.
Ian.