ia64/xen-unstable

changeset 19384:33270c9a3d2f

Disable xen platform PCI device when xen_platform_pci=0 is specified

- 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.

Signed-off-by: Yuji Shimada <shimada-yxb@necst.nec.co.jp>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 18 11:37:59 2009 +0000 (2009-03-18)
parents 6e619d8eece5
children 6d65dc14d21b
files tools/examples/xmexample.hvm tools/firmware/hvmloader/config.h tools/firmware/hvmloader/hvmloader.c tools/firmware/rombios/rombios.c tools/python/xen/xend/XendConfig.py tools/python/xen/xend/image.py tools/python/xen/xm/create.py tools/python/xen/xm/xenapi_create.py
line diff
     1.1 --- a/tools/examples/xmexample.hvm	Wed Mar 18 11:34:20 2009 +0000
     1.2 +++ b/tools/examples/xmexample.hvm	Wed Mar 18 11:37:59 2009 +0000
     1.3 @@ -225,6 +225,10 @@ serial='pty'
     1.4  #keymap='ja'
     1.5  
     1.6  #-----------------------------------------------------------------------------
     1.7 +#   Enable/disable xen platform PCI device, default=1 (enabled)
     1.8 +#xen_platform_pci=1
     1.9 +
    1.10 +#-----------------------------------------------------------------------------
    1.11  #   Configure guest CPUID responses:
    1.12  #
    1.13  #cpuid=[ '1:ecx=xxxxxxxxxxx00xxxxxxxxxxxxxxxxxxx,
     2.1 --- a/tools/firmware/hvmloader/config.h	Wed Mar 18 11:34:20 2009 +0000
     2.2 +++ b/tools/firmware/hvmloader/config.h	Wed Mar 18 11:37:59 2009 +0000
     2.3 @@ -47,6 +47,7 @@ extern unsigned long pci_mem_start, pci_
     2.4  #define E820_OFFSET                   0x8
     2.5  
     2.6  /* Xen Platform Device */
     2.7 +#define XEN_PF_IOBASE   0x10
     2.8  #define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
     2.9  
    2.10  /* Located at BIOS_INFO_PHYSICAL_ADDRESS. */
    2.11 @@ -56,9 +57,7 @@ struct bios_info {
    2.12      uint8_t  hpet_present:1;    /* 0[2] - System has HPET? */
    2.13      uint32_t pci_min, pci_len;  /* 4, 8 - PCI I/O hole boundaries */
    2.14      uint32_t bios32_entry;      /* 12   - Entry point for 32-bit BIOS */
    2.15 -    uint16_t xen_pfiob;         /* 16   - Xen platform device I/O ports */
    2.16  };
    2.17  #define BIOSINFO_OFF_bios32_entry 12
    2.18 -#define BIOSINFO_OFF_xen_pfiob    16
    2.19  
    2.20  #endif /* __HVMLOADER_CONFIG_H__ */
     3.1 --- a/tools/firmware/hvmloader/hvmloader.c	Wed Mar 18 11:34:20 2009 +0000
     3.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Wed Mar 18 11:37:59 2009 +0000
     3.3 @@ -539,25 +539,6 @@ static void cmos_write_memory_size(void)
     3.4      cmos_outb(0x35, (uint8_t)( alt_mem >> 8));
     3.5  }
     3.6  
     3.7 -static uint16_t xen_platform_io_base(void)
     3.8 -{
     3.9 -    uint32_t devfn, bar_data;
    3.10 -    uint16_t vendor_id, device_id;
    3.11 -
    3.12 -    for ( devfn = 0; devfn < 128; devfn++ )
    3.13 -    {
    3.14 -        vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
    3.15 -        device_id = pci_readw(devfn, PCI_DEVICE_ID);
    3.16 -        if ( (vendor_id == 0x5853) && (device_id == 0x0001) )
    3.17 -        {
    3.18 -            bar_data = pci_readl(devfn, PCI_BASE_ADDRESS_0);
    3.19 -            return bar_data & PCI_BASE_ADDRESS_IO_MASK;
    3.20 -        }
    3.21 -    }
    3.22 -
    3.23 -    return 0;
    3.24 -}
    3.25 -
    3.26  /*
    3.27   * Set up an empty TSS area for virtual 8086 mode to use. 
    3.28   * The only important thing is that it musn't have any bits set 
    3.29 @@ -744,7 +725,6 @@ int main(void)
    3.30      bios_info->pci_min = pci_mem_start;
    3.31      bios_info->pci_len = pci_mem_end - pci_mem_start;
    3.32      bios_info->bios32_entry = bios32_addr;
    3.33 -    bios_info->xen_pfiob = xen_platform_io_base();
    3.34  
    3.35      printf("Invoking ROMBIOS ...\n");
    3.36      return 0;
     4.1 --- a/tools/firmware/rombios/rombios.c	Wed Mar 18 11:34:20 2009 +0000
     4.2 +++ b/tools/firmware/rombios/rombios.c	Wed Mar 18 11:37:59 2009 +0000
     4.3 @@ -1418,24 +1418,14 @@ fixup_base_mem_in_k()
     4.4    write_word(0x40, 0x13, base_mem >> 10);
     4.5  }
     4.6  
     4.7 -ASM_START
     4.8 -_rom_write_access_control:
     4.9 -    push ds
    4.10 -    mov ax,#(BIOS_INFO_PHYSICAL_ADDRESS >> 4)
    4.11 -    mov ds,ax
    4.12 -    mov ax,[BIOSINFO_OFF_xen_pfiob]
    4.13 -    pop ds
    4.14 -    ret
    4.15 -ASM_END
    4.16 -
    4.17  void enable_rom_write_access()
    4.18  {
    4.19 -    outb(rom_write_access_control(), 0);
    4.20 +    outb(XEN_PF_IOBASE, 0);
    4.21  }
    4.22  
    4.23  void disable_rom_write_access()
    4.24  {
    4.25 -    outb(rom_write_access_control(), PFFLAG_ROM_LOCK);
    4.26 +    outb(XEN_PF_IOBASE, PFFLAG_ROM_LOCK);
    4.27  }
    4.28      
    4.29  #endif /* HVMASSIST */
     5.1 --- a/tools/python/xen/xend/XendConfig.py	Wed Mar 18 11:34:20 2009 +0000
     5.2 +++ b/tools/python/xen/xend/XendConfig.py	Wed Mar 18 11:37:59 2009 +0000
     5.3 @@ -170,6 +170,7 @@ XENAPI_PLATFORM_CFG_TYPES = {
     5.4      'xen_extended_power_mgmt': int,
     5.5      'pci_msitranslate': int,
     5.6      'pci_power_mgmt': int,
     5.7 +    'xen_platform_pci': int,
     5.8  }
     5.9  
    5.10  # Xen API console 'other_config' keys.
    5.11 @@ -464,6 +465,8 @@ class XendConfig(dict):
    5.12                  self['platform']['rtc_timeoffset'] = 0
    5.13              if 'hpet' not in self['platform']:
    5.14                  self['platform']['hpet'] = 0
    5.15 +            if 'xen_platform_pci' not in self['platform']:
    5.16 +                self['platform']['xen_platform_pci'] = 1
    5.17              if 'vpt_align' not in self['platform']:
    5.18                  self['platform']['vpt_align'] = 1
    5.19              if 'loader' not in self['platform']:
     6.1 --- a/tools/python/xen/xend/image.py	Wed Mar 18 11:34:20 2009 +0000
     6.2 +++ b/tools/python/xen/xend/image.py	Wed Mar 18 11:37:59 2009 +0000
     6.3 @@ -716,6 +716,7 @@ class HVMImageHandler(ImageHandler):
     6.4          if 'hvm' not in info['xen_caps']:
     6.5              raise HVMRequired()
     6.6  
     6.7 +        xen_platform_pci = int(vmConfig['platform'].get('xen_platform_pci',1))
     6.8          rtc_timeoffset = vmConfig['platform'].get('rtc_timeoffset')
     6.9  
    6.10          if not self.display :
    6.11 @@ -724,13 +725,23 @@ class HVMImageHandler(ImageHandler):
    6.12                          ("image/device-model", self.device_model),
    6.13                          ("image/display", self.display))
    6.14          self.vm.permissionsVm("image/dmargs", { 'dom': self.vm.getDomid(), 'read': True } )
    6.15 +
    6.16 +        if xen_platform_pci == 0:
    6.17 +            disable_pf = 1
    6.18 +            log.info("No need to create platform device.[domid:%d]", self.vm.getDomid())
    6.19 +        else:
    6.20 +            disable_pf = 0
    6.21 +            log.info("Need to create platform device.[domid:%d]", self.vm.getDomid())
    6.22 +
    6.23 +        xstransact.Store("/local/domain/0/device-model/%i"%self.vm.getDomid(),
    6.24 +                                      ('disable_pf', disable_pf))
    6.25          self.vm.storeVm(("rtc/timeoffset", rtc_timeoffset))
    6.26          self.vm.permissionsVm("rtc/timeoffset", { 'dom': self.vm.getDomid(), 'read': True } )
    6.27  
    6.28          self.apic = int(vmConfig['platform'].get('apic', 0))
    6.29          self.acpi = int(vmConfig['platform'].get('acpi', 0))
    6.30          self.guest_os_type = vmConfig['platform'].get('guest_os_type')
    6.31 -           
    6.32 +
    6.33  
    6.34      # Return a list of cmd line args to the device models based on the
    6.35      # xm config file
     7.1 --- a/tools/python/xen/xm/create.py	Wed Mar 18 11:34:20 2009 +0000
     7.2 +++ b/tools/python/xen/xm/create.py	Wed Mar 18 11:37:59 2009 +0000
     7.3 @@ -611,6 +611,10 @@ gopts.var('pci_power_mgmt', val='POWERMG
     7.4            fn=set_int, default=0,
     7.5            use="""Global PCI Power Management flag (0=disable;1=enable).""")
     7.6  
     7.7 +gopts.var('xen_platform_pci', val='0|1',
     7.8 +           fn=set_int, default=1,
     7.9 +           use="Is xen_platform_pci used?")
    7.10 +
    7.11  def err(msg):
    7.12      """Print an error to stderr and exit.
    7.13      """
    7.14 @@ -924,7 +928,7 @@ def configure_hvm(config_image, vals):
    7.15               'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', 'hpet',
    7.16               'guest_os_type', 'hap', 'opengl', 'cpuid', 'cpuid_check',
    7.17               'viridian', 'xen_extended_power_mgmt', 'pci_msitranslate',
    7.18 -             'vpt_align', 'pci_power_mgmt' ]
    7.19 +             'vpt_align', 'pci_power_mgmt', 'xen_platform_pci' ]
    7.20  
    7.21      for a in args:
    7.22          if a in vals.__dict__ and vals.__dict__[a] is not None:
     8.1 --- a/tools/python/xen/xm/xenapi_create.py	Wed Mar 18 11:34:20 2009 +0000
     8.2 +++ b/tools/python/xen/xm/xenapi_create.py	Wed Mar 18 11:37:59 2009 +0000
     8.3 @@ -1048,6 +1048,7 @@ class sxp2xml:
     8.4              'hap',
     8.5              'pci_msitranslate',
     8.6              'pci_power_mgmt',
     8.7 +            'xen_platform_pci',
     8.8          ]
     8.9  
    8.10          platform_configs = []