ia64/xen-unstable

changeset 18688:02c8733e2d91

[IA64] Add head files and helper functions for VTD/ia64

Add head files and helper functions for VTD/ia64.

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Wed Oct 22 17:20:15 2008 +0900 (2008-10-22)
parents d9b70fc0ee0f
children 7ad8c47f5c4b 0978bdc056c8
files xen/arch/ia64/vmx/viosapic.c xen/arch/ia64/vmx/vmx_interrupt.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/mm.c xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/domain.h xen/include/asm-ia64/hvm/iommu.h xen/include/asm-ia64/hvm/irq.h xen/include/asm-ia64/linux-xen/asm/iosapic.h xen/include/asm-ia64/linux/asm/hw_irq.h xen/include/asm-ia64/vmx_platform.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/viosapic.c	Wed Oct 22 12:41:52 2008 +0900
     1.2 +++ b/xen/arch/ia64/vmx/viosapic.c	Wed Oct 22 17:20:15 2008 +0900
     1.3 @@ -315,10 +315,6 @@ out:
     1.4      spin_unlock(&viosapic->lock);
     1.5  }
     1.6  
     1.7 -#define hvm_pci_intx_gsi(dev, intx)  \
     1.8 -    (((((dev) << 2) + ((dev) >> 3) + (intx)) & 31) + 16)
     1.9 -        
    1.10 -
    1.11  void viosapic_set_pci_irq(struct domain *d, int device, int intx, int level)
    1.12  {
    1.13      int irq;
     2.1 --- a/xen/arch/ia64/vmx/vmx_interrupt.c	Wed Oct 22 12:41:52 2008 +0900
     2.2 +++ b/xen/arch/ia64/vmx/vmx_interrupt.c	Wed Oct 22 17:20:15 2008 +0900
     2.3 @@ -112,3 +112,45 @@ inject_guest_interruption(VCPU *vcpu, u6
     2.4      debugger_event(vec == IA64_EXTINT_VECTOR ?
     2.5                     XEN_IA64_DEBUG_ON_EXTINT : XEN_IA64_DEBUG_ON_EXCEPT);
     2.6  }
     2.7 +
     2.8 +void hvm_pci_intx_assert(
     2.9 +        struct domain *d, unsigned int device, unsigned int intx)
    2.10 +{
    2.11 +    struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
    2.12 +    unsigned int gsi;
    2.13 +
    2.14 +    ASSERT((device <= 31) && (intx <= 3));
    2.15 +
    2.16 +    if ( __test_and_set_bit(device * 4 + intx, &hvm_irq->pci_intx.i) )
    2.17 +        return;
    2.18 +    gsi = hvm_pci_intx_gsi(device, intx);
    2.19 +    if ( ++hvm_irq->gsi_assert_count[gsi] == 1 )
    2.20 +        viosapic_set_irq(d, gsi, 1);
    2.21 +}
    2.22 +
    2.23 +void hvm_pci_intx_deassert(
    2.24 +        struct domain *d, unsigned int device, unsigned int intx)
    2.25 +{
    2.26 +    struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;
    2.27 +    unsigned int gsi;
    2.28 +
    2.29 +    ASSERT((device <= 31) && (intx <= 3));
    2.30 +
    2.31 +    if ( !__test_and_clear_bit(device * 4 + intx, &hvm_irq->pci_intx.i) )
    2.32 +        return;
    2.33 +
    2.34 +    gsi = hvm_pci_intx_gsi(device, intx);
    2.35 +
    2.36 +    if (--hvm_irq->gsi_assert_count[gsi] == 0)
    2.37 +        viosapic_set_irq(d, gsi, 0);
    2.38 +}
    2.39 +
    2.40 +void hvm_isa_irq_assert(struct domain *d, unsigned int isa_irq)
    2.41 +{
    2.42 +    /* dummy */
    2.43 +}
    2.44 +
    2.45 +void hvm_isa_irq_deassert(struct domain *d, unsigned int isa_irq)
    2.46 +{
    2.47 +    /* dummy */
    2.48 +}
     3.1 --- a/xen/arch/ia64/xen/domain.c	Wed Oct 22 12:41:52 2008 +0900
     3.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Oct 22 17:20:15 2008 +0900
     3.3 @@ -569,6 +569,7 @@ int arch_domain_create(struct domain *d,
     3.4  	if (is_idle_domain(d))
     3.5  	    return 0;
     3.6  
     3.7 +	INIT_LIST_HEAD(&d->arch.pdev_list);
     3.8  	foreign_p2m_init(d);
     3.9  #ifdef CONFIG_XEN_IA64_PERVCPU_VHPT
    3.10  	d->arch.has_pervcpu_vhpt = opt_pervcpu_vhpt;
     4.1 --- a/xen/arch/ia64/xen/mm.c	Wed Oct 22 12:41:52 2008 +0900
     4.2 +++ b/xen/arch/ia64/xen/mm.c	Wed Oct 22 17:20:15 2008 +0900
     4.3 @@ -3445,18 +3445,6 @@ void xencomm_mark_dirty(unsigned long ad
     4.4      __xencomm_mark_dirty(current->domain, addr, len);
     4.5  }
     4.6  
     4.7 -int iommu_map_page(struct domain *d, unsigned long gfn, unsigned long mfn)
     4.8 -{
     4.9 -    /* STUB to compile */
    4.10 -    return -ENOSYS;
    4.11 -}
    4.12 -
    4.13 -int iommu_unmap_page(struct domain *d, unsigned long gfn)
    4.14 -{
    4.15 -    /* STUB to compile */
    4.16 -    return -ENOSYS;
    4.17 -}
    4.18 -
    4.19  /*
    4.20   * Local variables:
    4.21   * mode: C
     5.1 --- a/xen/arch/ia64/xen/xensetup.c	Wed Oct 22 12:41:52 2008 +0900
     5.2 +++ b/xen/arch/ia64/xen/xensetup.c	Wed Oct 22 17:20:15 2008 +0900
     5.3 @@ -740,3 +740,15 @@ void arch_get_xen_caps(xen_capabilities_
     5.4      }
     5.5  }
     5.6  
     5.7 +int xen_in_range(paddr_t start, paddr_t end)
     5.8 +{
     5.9 +    start = max_t(paddr_t, start, xen_pstart);
    5.10 +    end = min_t(paddr_t, end, xen_pstart + XENHEAP_DEFAULT_SIZE);
    5.11 +
    5.12 +    return start < end;
    5.13 +}
    5.14 +
    5.15 +int tboot_in_range(paddr_t start, paddr_t end)
    5.16 +{
    5.17 +    return 0;
    5.18 +}
     6.1 --- a/xen/include/asm-ia64/domain.h	Wed Oct 22 12:41:52 2008 +0900
     6.2 +++ b/xen/include/asm-ia64/domain.h	Wed Oct 22 17:20:15 2008 +0900
     6.3 @@ -43,6 +43,8 @@ extern int shadow_mode_control(struct do
     6.4  extern void panic_domain(struct pt_regs *, const char *, ...)
     6.5       __attribute__ ((noreturn, format (printf, 2, 3)));
     6.6  
     6.7 +#define has_arch_pdevs(d)    (!list_empty(&(d)->arch.pdev_list))
     6.8 +
     6.9  struct mm_struct {
    6.10  	volatile pgd_t * pgd;
    6.11      //	atomic_t mm_users;			/* How many users with user space? */
    6.12 @@ -166,6 +168,7 @@ struct arch_domain {
    6.13      unsigned char rid_bits;		/* number of virtual rid bits (default: 18) */
    6.14      int breakimm;               /* The imm value for hypercalls.  */
    6.15  
    6.16 +    struct list_head pdev_list;
    6.17      struct virtual_platform_def     vmx_platform;
    6.18  #define	hvm_domain vmx_platform /* platform defs are not vmx specific */
    6.19  
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/xen/include/asm-ia64/hvm/iommu.h	Wed Oct 22 17:20:15 2008 +0900
     7.3 @@ -0,0 +1,35 @@
     7.4 +#ifndef __ASM_IA64_HVM_IOMMU_H__
     7.5 +#define __ASM_IA64_HVM_IOMMU_H__
     7.6 +
     7.7 +#include <asm/hvm/irq.h>
     7.8 +#include <public/event_channel.h>
     7.9 +#include <public/arch-ia64/hvm/save.h>
    7.10 +#include <asm/linux-xen/asm/iosapic.h>
    7.11 +
    7.12 +struct iommu_ops;
    7.13 +extern struct iommu_ops intel_iommu_ops;
    7.14 +extern int intel_vtd_setup(void);
    7.15 +
    7.16 +#define iommu_get_ops() (&intel_iommu_ops)
    7.17 +#define iommu_hardware_setup()  (intel_vtd_setup())
    7.18 +
    7.19 +static inline int domain_irq_to_vector(struct domain *d, int irq)
    7.20 +{
    7.21 +    return irq;
    7.22 +}
    7.23 +
    7.24 +static inline void ack_APIC_irq(void)
    7.25 +{
    7.26 +    /* TODO */
    7.27 +}
    7.28 +
    7.29 +static inline void pci_cleanup_msi(struct pci_dev *pdev)
    7.30 +{
    7.31 +    /* TODO */
    7.32 +}
    7.33 +
    7.34 +#define AUTO_ASSIGN         -1
    7.35 +
    7.36 +extern int assign_irq_vector (int irq);
    7.37 +
    7.38 +#endif /* __ASM_IA64_HVM_IOMMU_H__ */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/xen/include/asm-ia64/hvm/irq.h	Wed Oct 22 17:20:15 2008 +0900
     8.3 @@ -0,0 +1,106 @@
     8.4 +/******************************************************************************
     8.5 + * irq.h
     8.6 + *
     8.7 + * Interrupt distribution and delivery logic.
     8.8 + *
     8.9 + * Copyright (c) 2006, K A Fraser, XenSource Inc.
    8.10 + *
    8.11 + * This program is free software; you can redistribute it and/or modify it
    8.12 + * under the terms and conditions of the GNU General Public License,
    8.13 + * version 2, as published by the Free Software Foundation.
    8.14 + *
    8.15 + * This program is distributed in the hope it will be useful, but WITHOUT
    8.16 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.17 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    8.18 + * more details.
    8.19 + *
    8.20 + * You should have received a copy of the GNU General Public License along with
    8.21 + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    8.22 + * Place - Suite 330, Boston, MA 02111-1307 USA.
    8.23 + */
    8.24 +
    8.25 +#ifndef __ASM_IA64_HVM_IRQ_H__
    8.26 +#define __ASM_IA64_HVM_IRQ_H__
    8.27 +
    8.28 +#include <xen/irq.h>
    8.29 +
    8.30 +#define NR_VECTORS 256
    8.31 +#define VIOAPIC_NUM_PINS  48
    8.32 +#define NR_PIRQS   256
    8.33 +
    8.34 +#include <xen/hvm/irq.h>
    8.35 +
    8.36 +struct hvm_hw_pci_irqs {
    8.37 +    /*
    8.38 +     * Virtual interrupt wires for a single PCI bus.
    8.39 +     * Indexed by: device*4 + INTx#.
    8.40 +     */
    8.41 +    union {
    8.42 +        DECLARE_BITMAP(i, 32*4);
    8.43 +        uint64_t pad[2];
    8.44 +    };
    8.45 +};
    8.46 +
    8.47 +struct hvm_irq {
    8.48 +    /*
    8.49 +     * Virtual interrupt wires for a single PCI bus.
    8.50 +     * Indexed by: device*4 + INTx#.
    8.51 +     */
    8.52 +    struct hvm_hw_pci_irqs pci_intx;
    8.53 +
    8.54 +    /* Virtual interrupt and via-link for paravirtual platform driver. */
    8.55 +    uint32_t callback_via_asserted;
    8.56 +    union {
    8.57 +        enum {
    8.58 +            HVMIRQ_callback_none,
    8.59 +            HVMIRQ_callback_gsi,
    8.60 +            HVMIRQ_callback_pci_intx
    8.61 +        } callback_via_type;
    8.62 +    };
    8.63 +    union {
    8.64 +        uint32_t gsi;
    8.65 +        struct { uint8_t dev, intx; } pci;
    8.66 +    } callback_via;
    8.67 +
    8.68 +    /*
    8.69 +     * Number of wires asserting each GSI.
    8.70 +     *
    8.71 +     * GSIs 0-15 are the ISA IRQs. ISA devices map directly into this space
    8.72 +     * except ISA IRQ 0, which is connected to GSI 2.
    8.73 +     * PCI links map into this space via the PCI-ISA bridge.
    8.74 +     *
    8.75 +     * GSIs 16+ are used only be PCI devices. The mapping from PCI device to
    8.76 +     * GSI is as follows: ((device*4 + device/8 + INTx#) & 31) + 16
    8.77 +     */
    8.78 +    u8 gsi_assert_count[VIOAPIC_NUM_PINS];
    8.79 +
    8.80 +    /*
    8.81 +     * GSIs map onto PIC/IO-APIC in the usual way:
    8.82 +     *  0-7:  Master 8259 PIC, IO-APIC pins 0-7
    8.83 +     *  8-15: Slave  8259 PIC, IO-APIC pins 8-15
    8.84 +     *  16+ : IO-APIC pins 16+
    8.85 +     */
    8.86 +
    8.87 +    /* Last VCPU that was delivered a LowestPrio interrupt. */
    8.88 +    u8 round_robin_prev_vcpu;
    8.89 +
    8.90 +    struct hvm_irq_dpci *dpci;
    8.91 +};
    8.92 +
    8.93 +#define hvm_pci_intx_gsi(dev, intx)  \
    8.94 +    (((((dev)<<2) + ((dev)>>3) + (intx)) & 31) + 16)
    8.95 +#define hvm_pci_intx_link(dev, intx) \
    8.96 +    (((dev) + (intx)) & 3)
    8.97 +
    8.98 +/* Extract the IA-64 vector that corresponds to IRQ.  */
    8.99 +static inline int
   8.100 +irq_to_vector (int irq)
   8.101 +{
   8.102 +    return irq;
   8.103 +}
   8.104 +
   8.105 +
   8.106 +extern u8 irq_vector[NR_IRQ_VECTORS];
   8.107 +extern int vector_irq[NR_VECTORS];
   8.108 +
   8.109 +#endif /* __ASM_IA64_HVM_IRQ_H__ */
     9.1 --- a/xen/include/asm-ia64/linux-xen/asm/iosapic.h	Wed Oct 22 12:41:52 2008 +0900
     9.2 +++ b/xen/include/asm-ia64/linux-xen/asm/iosapic.h	Wed Oct 22 17:20:15 2008 +0900
     9.3 @@ -175,5 +175,8 @@ extern unsigned long ia64_vector_mask[];
     9.4  extern unsigned long ia64_xen_vector[];
     9.5  #endif /* XEN */
     9.6  
     9.7 +#define IO_APIC_BASE(idx) ((unsigned int *)iosapic_lists[idx].addr)
     9.8 +#define IO_APIC_ID(idx)   (iosapic_lists[idx].id)
     9.9 +
    9.10  # endif /* !__ASSEMBLY__ */
    9.11  #endif /* __ASM_IA64_IOSAPIC_H */
    10.1 --- a/xen/include/asm-ia64/linux/asm/hw_irq.h	Wed Oct 22 12:41:52 2008 +0900
    10.2 +++ b/xen/include/asm-ia64/linux/asm/hw_irq.h	Wed Oct 22 17:20:15 2008 +0900
    10.3 @@ -124,13 +124,6 @@ irq_descp (int irq)
    10.4  	return irq_desc + irq;
    10.5  }
    10.6  
    10.7 -/* Extract the IA-64 vector that corresponds to IRQ.  */
    10.8 -static inline ia64_vector
    10.9 -irq_to_vector (int irq)
   10.10 -{
   10.11 -	return (ia64_vector) irq;
   10.12 -}
   10.13 -
   10.14  /*
   10.15   * Convert the local IA-64 vector to the corresponding irq number.  This translation is
   10.16   * done in the context of the interrupt domain that the currently executing CPU belongs
    11.1 --- a/xen/include/asm-ia64/vmx_platform.h	Wed Oct 22 12:41:52 2008 +0900
    11.2 +++ b/xen/include/asm-ia64/vmx_platform.h	Wed Oct 22 17:20:15 2008 +0900
    11.3 @@ -21,8 +21,10 @@
    11.4  
    11.5  #include <public/xen.h>
    11.6  #include <public/hvm/params.h>
    11.7 +#include <asm/hvm/irq.h>
    11.8  #include <asm/viosapic.h>
    11.9  #include <asm/hvm/vacpi.h>
   11.10 +#include <xen/hvm/iommu.h>
   11.11  
   11.12  struct vmx_ioreq_page {
   11.13      spinlock_t          lock;
   11.14 @@ -41,6 +43,9 @@ typedef struct virtual_platform_def {
   11.15      /* One IOSAPIC now... */
   11.16      struct viosapic             viosapic;
   11.17      struct vacpi                vacpi;
   11.18 +    /* Pass-throgh VT-d */
   11.19 +    struct hvm_irq              irq;
   11.20 +    struct hvm_iommu            hvm_iommu;
   11.21  } vir_plat_t;
   11.22  
   11.23  static inline int __fls(uint32_t word)