1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * domain.h: HVM per domain definitions 4 * 5 * Copyright (c) 2004, Intel Corporation. 6 * Copyright (c) 2005, International Business Machines Corporation 7 */ 8 9 #ifndef __ASM_X86_HVM_DOMAIN_H__ 10 #define __ASM_X86_HVM_DOMAIN_H__ 11 12 #include <xen/list.h> 13 #include <xen/mm.h> 14 #include <xen/radix-tree.h> 15 16 #include <asm/hvm/io.h> 17 #include <asm/hvm/vmx/vmcs.h> 18 #include <asm/hvm/svm/vmcb.h> 19 20 #ifdef CONFIG_MEM_SHARING 21 struct mem_sharing_domain 22 { 23 bool enabled, block_interrupts; 24 25 /* 26 * When releasing shared gfn's in a preemptible manner, recall where 27 * to resume the search. 28 */ 29 unsigned long next_shared_gfn_to_relinquish; 30 }; 31 #endif 32 33 /* 34 * This structure defines function hooks to support hardware-assisted 35 * virtual interrupt delivery to guest. (e.g. VMX PI and SVM AVIC). 36 * 37 * These hooks are defined by the underlying arch-specific code 38 * as needed. For example: 39 * - When the domain is enabled with virtual IPI delivery 40 * - When the domain is enabled with virtual I/O int delivery 41 * and actually has a physical device assigned . 42 */ 43 struct hvm_pi_ops { 44 unsigned int flags; 45 46 /* 47 * Hook into arch_vcpu_block(), which is called 48 * from vcpu_block() and vcpu_do_poll(). 49 */ 50 void (*vcpu_block)(struct vcpu *v); 51 }; 52 53 struct hvm_domain { 54 /* Guest page range used for non-default ioreq servers */ 55 struct { 56 unsigned long base; 57 unsigned long mask; /* indexed by GFN minus base */ 58 unsigned long legacy_mask; /* indexed by HVM param number */ 59 } ioreq_gfn; 60 61 /* Cached CF8 for guest PCI config cycles */ 62 uint32_t pci_cf8; 63 64 struct pl_time *pl_time; 65 66 struct hvm_io_handler *io_handler; 67 unsigned int io_handler_count; 68 69 /* Lock protects access to irq, vpic and vioapic. */ 70 spinlock_t irq_lock; 71 struct hvm_irq *irq; 72 struct hvm_hw_vpic vpic[2]; /* 0=master; 1=slave */ 73 struct hvm_vioapic **vioapic; 74 unsigned int nr_vioapics; 75 76 /* 77 * hvm_hw_pmtimer is a publicly-visible name. We will defer renaming 78 * it to the more appropriate hvm_hw_acpi until the expected 79 * comprehensive rewrte of migration code, thus avoiding code churn 80 * in public header files. 81 * Internally, however, we will be using hvm_hw_acpi. 82 */ 83 #define hvm_hw_acpi hvm_hw_pmtimer 84 struct hvm_hw_acpi acpi; 85 86 /* VCPU which is current target for 8259 interrupts. */ 87 struct vcpu *i8259_target; 88 89 /* emulated irq to pirq */ 90 struct radix_tree_root emuirq_pirq; 91 92 uint64_t *params; 93 94 /* Memory ranges with pinned cache attributes. */ 95 struct list_head pinned_cacheattr_ranges; 96 97 /* VRAM dirty support. Protect with the domain paging lock. */ 98 struct sh_dirty_vram *dirty_vram; 99 100 /* If one of vcpus of this domain is in no_fill_mode or 101 * mtrr/pat between vcpus is not the same, set is_in_uc_mode 102 */ 103 spinlock_t uc_lock; 104 bool is_in_uc_mode; 105 106 bool is_s3_suspended; 107 108 /* Compatibility setting for a bug in x2APIC LDR */ 109 bool bug_x2apic_ldr_vcpu_id; 110 111 /* hypervisor intercepted msix table */ 112 struct list_head msixtbl_list; 113 114 struct viridian_domain *viridian; 115 116 /* 117 * TSC value that VCPUs use to calculate their tsc_offset value. 118 * Used during initialization and save/restore. 119 */ 120 uint64_t sync_tsc; 121 122 uint64_t tsc_scaling_ratio; 123 124 unsigned long *io_bitmap; 125 126 /* List of guest to machine IO ports mapping. */ 127 struct list_head g2m_ioport_list; 128 129 /* List of MMCFG regions trapped by Xen. */ 130 struct list_head mmcfg_regions; 131 rwlock_t mmcfg_lock; 132 133 /* List of MSI-X tables. */ 134 struct list_head msix_tables; 135 136 /* List of permanently write-mapped pages. */ 137 struct { 138 spinlock_t lock; 139 struct list_head list; 140 } write_map; 141 142 struct hvm_pi_ops pi_ops; 143 144 union { 145 struct vmx_domain vmx; 146 struct svm_domain svm; 147 }; 148 149 #ifdef CONFIG_MEM_SHARING 150 struct mem_sharing_domain mem_sharing; 151 #endif 152 }; 153 154 #endif /* __ASM_X86_HVM_DOMAIN_H__ */ 155 156 /* 157 * Local variables: 158 * mode: C 159 * c-file-style: "BSD" 160 * c-basic-offset: 4 161 * tab-width: 4 162 * indent-tabs-mode: nil 163 * End: 164 */ 165