This commit is contained in:
committed by
Git OBS Bridge
parent
8a8c811c02
commit
5545adae8a
@@ -1,13 +1,24 @@
|
||||
Index: xen-3.3.1-testing/xen/arch/x86/hvm/mtrr.c
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/arch/x86/hvm/mtrr.c
|
||||
+++ xen-3.3.1-testing/xen/arch/x86/hvm/mtrr.c
|
||||
# HG changeset patch
|
||||
# User Keir Fraser <keir.fraser@citrix.com>
|
||||
# Date 1232721749 0
|
||||
# Node ID 175a425e9b55e63c240b0a2ad61f5ed251e85ead
|
||||
# Parent f3240cd3cd2b9d48acf3d82caa2ca1cab1f66325
|
||||
EPT/VT-d: Enhance MTRR/PAT virtualization when EPT/VT-d both enabled
|
||||
|
||||
Set effective memory type for EPT according to the VT-d snoop control
|
||||
capability, and also includes some cleanups for EPT & VT-d both enabled.
|
||||
|
||||
Signed-off-by: Edwin Zhai <Edwin.Zhai@intel.com>
|
||||
Signed-off-by: Xiaohui Xin <xiaohui.xin@intel.com>
|
||||
|
||||
--- a/xen/arch/x86/hvm/mtrr.c
|
||||
+++ b/xen/arch/x86/hvm/mtrr.c
|
||||
@@ -702,12 +702,15 @@ HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save
|
||||
1, HVMSR_PER_VCPU);
|
||||
|
||||
uint8_t epte_get_entry_emt(
|
||||
- struct domain *d, unsigned long gfn, unsigned long mfn)
|
||||
+ struct domain *d, unsigned long gfn,
|
||||
+ struct domain *d, unsigned long gfn,
|
||||
+ unsigned long mfn, uint8_t *igmt, int direct_mmio)
|
||||
{
|
||||
uint8_t gmtrr_mtype, hmtrr_mtype;
|
||||
@@ -41,10 +52,8 @@ Index: xen-3.3.1-testing/xen/arch/x86/hvm/mtrr.c
|
||||
gmtrr_mtype = get_mtrr_type(&v->arch.hvm_vcpu.mtrr, (gfn << PAGE_SHIFT));
|
||||
hmtrr_mtype = get_mtrr_type(&mtrr_state, (mfn << PAGE_SHIFT));
|
||||
return ((gmtrr_mtype <= hmtrr_mtype) ? gmtrr_mtype : hmtrr_mtype);
|
||||
Index: xen-3.3.1-testing/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
+++ xen-3.3.1-testing/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
--- a/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
+++ b/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
@@ -66,6 +66,7 @@ static int ept_set_middle_entry(struct d
|
||||
list_add_tail(&pg->list, &d->arch.p2m->pages);
|
||||
|
||||
@@ -53,29 +62,23 @@ Index: xen-3.3.1-testing/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
ept_entry->sp_avail = 0;
|
||||
ept_entry->avail1 = 0;
|
||||
ept_entry->mfn = page_to_mfn(pg);
|
||||
@@ -114,9 +115,19 @@ static int ept_next_level(struct domain
|
||||
@@ -114,9 +115,13 @@ static int ept_next_level(struct domain
|
||||
}
|
||||
}
|
||||
|
||||
+/* The parameter need_modify_vtd_table in _ept_set_entry():
|
||||
+ *
|
||||
+ * Usually VT-d page table is created during the p2m table creation time,
|
||||
+ * and it only cares about the gfn to mfn translations,
|
||||
+ * EPT table takes the same effect as the p2m table, so we create
|
||||
+ * VT-d page table in ept_set_entry() function.
|
||||
+ * But when EPT entires are modified not related to the gfn and mfn translations * We don't need to recreat the same VT-d page tables.
|
||||
+ * The need_modify_vtd_table parameter is used for this.
|
||||
+/*
|
||||
+ * TODO: ept_set_entry() computes 'need_modify_vtd_table' for itself,
|
||||
+ * by observing whether any gfn->mfn translations are modified.
|
||||
+ */
|
||||
+
|
||||
static int
|
||||
-ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
|
||||
- unsigned int order, p2m_type_t p2mt)
|
||||
+_ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
|
||||
+_ept_set_entry(struct domain *d, unsigned long gfn, mfn_t mfn,
|
||||
+ unsigned int order, p2m_type_t p2mt, int need_modify_vtd_table)
|
||||
{
|
||||
ept_entry_t *table = NULL;
|
||||
unsigned long gfn_remainder = gfn, offset = 0;
|
||||
@@ -124,6 +135,8 @@ ept_set_entry(struct domain *d, unsigned
|
||||
@@ -124,6 +129,8 @@ ept_set_entry(struct domain *d, unsigned
|
||||
u32 index;
|
||||
int i, rv = 0, ret = 0;
|
||||
int walk_level = order / EPT_TABLE_ORDER;
|
||||
@@ -84,7 +87,7 @@ Index: xen-3.3.1-testing/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
|
||||
/* we only support 4k and 2m pages now */
|
||||
|
||||
@@ -157,7 +170,9 @@ ept_set_entry(struct domain *d, unsigned
|
||||
@@ -157,7 +164,9 @@ ept_set_entry(struct domain *d, unsigned
|
||||
{
|
||||
if ( mfn_valid(mfn_x(mfn)) || (p2mt == p2m_mmio_direct) )
|
||||
{
|
||||
@@ -95,41 +98,41 @@ Index: xen-3.3.1-testing/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
ept_entry->sp_avail = walk_level ? 1 : 0;
|
||||
|
||||
if ( ret == GUEST_TABLE_SUPER_PAGE )
|
||||
@@ -208,7 +223,10 @@ ept_set_entry(struct domain *d, unsigned
|
||||
@@ -208,7 +217,10 @@ ept_set_entry(struct domain *d, unsigned
|
||||
{
|
||||
split_ept_entry = split_table + i;
|
||||
split_ept_entry->emt = epte_get_entry_emt(d,
|
||||
- gfn-offset+i, split_mfn+i);
|
||||
+ gfn-offset+i, split_mfn+i,
|
||||
+ gfn-offset+i, split_mfn+i,
|
||||
+ &igmt, direct_mmio);
|
||||
+ split_ept_entry->igmt = igmt;
|
||||
+
|
||||
split_ept_entry->sp_avail = 0;
|
||||
|
||||
split_ept_entry->mfn = split_mfn+i;
|
||||
@@ -223,7 +241,10 @@ ept_set_entry(struct domain *d, unsigned
|
||||
@@ -223,7 +235,10 @@ ept_set_entry(struct domain *d, unsigned
|
||||
|
||||
/* Set the destinated 4k page as normal */
|
||||
split_ept_entry = split_table + offset;
|
||||
- split_ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn));
|
||||
+ split_ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn),
|
||||
+ split_ept_entry->emt = epte_get_entry_emt(d, gfn, mfn_x(mfn),
|
||||
+ &igmt, direct_mmio);
|
||||
+ split_ept_entry->igmt = igmt;
|
||||
+
|
||||
split_ept_entry->mfn = mfn_x(mfn);
|
||||
split_ept_entry->avail1 = p2mt;
|
||||
ept_p2m_type_to_flags(split_ept_entry, p2mt);
|
||||
@@ -246,7 +267,8 @@ out:
|
||||
@@ -246,7 +261,8 @@ out:
|
||||
|
||||
/* Now the p2m table is not shared with vt-d page table */
|
||||
|
||||
- if ( iommu_enabled && is_hvm_domain(d) )
|
||||
+ if ( iommu_enabled && is_hvm_domain(d)
|
||||
+ if ( iommu_enabled && is_hvm_domain(d)
|
||||
+ && need_modify_vtd_table )
|
||||
{
|
||||
if ( p2mt == p2m_ram_rw )
|
||||
{
|
||||
@@ -273,6 +295,17 @@ out:
|
||||
@@ -273,6 +289,17 @@ out:
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -138,16 +141,16 @@ Index: xen-3.3.1-testing/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
+ unsigned int order, p2m_type_t p2mt)
|
||||
+{
|
||||
+ /* ept_set_entry() are called from set_entry(),
|
||||
+ * We should always create VT-d page table acording
|
||||
+ * We should always create VT-d page table acording
|
||||
+ * to the gfn to mfn translations changes.
|
||||
+ */
|
||||
+ return _ept_set_entry(d, gfn, mfn, order, p2mt, 1);
|
||||
+ return _ept_set_entry(d, gfn, mfn, order, p2mt, 1);
|
||||
+}
|
||||
+
|
||||
/* Read ept p2m entries */
|
||||
static mfn_t ept_get_entry(struct domain *d, unsigned long gfn, p2m_type_t *t)
|
||||
{
|
||||
@@ -393,18 +426,30 @@ void ept_change_entry_emt_with_range(str
|
||||
@@ -393,18 +420,30 @@ void ept_change_entry_emt_with_range(str
|
||||
* Set emt for super page.
|
||||
*/
|
||||
order = EPT_TABLE_ORDER;
|
||||
@@ -183,10 +186,8 @@ Index: xen-3.3.1-testing/xen/arch/x86/mm/hap/p2m-ept.c
|
||||
}
|
||||
}
|
||||
|
||||
Index: xen-3.3.1-testing/xen/drivers/passthrough/iommu.c
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/drivers/passthrough/iommu.c
|
||||
+++ xen-3.3.1-testing/xen/drivers/passthrough/iommu.c
|
||||
--- a/xen/drivers/passthrough/iommu.c
|
||||
+++ b/xen/drivers/passthrough/iommu.c
|
||||
@@ -40,6 +40,7 @@ int iommu_enabled = 0;
|
||||
int iommu_pv_enabled = 0;
|
||||
int force_iommu = 0;
|
||||
@@ -195,10 +196,8 @@ Index: xen-3.3.1-testing/xen/drivers/passthrough/iommu.c
|
||||
|
||||
static void __init parse_iommu_param(char *s)
|
||||
{
|
||||
Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/dmar.c
|
||||
+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c
|
||||
--- a/xen/drivers/passthrough/vtd/dmar.c
|
||||
+++ b/xen/drivers/passthrough/vtd/dmar.c
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <xen/pci_regs.h>
|
||||
#include <asm/string.h>
|
||||
@@ -238,10 +237,8 @@ Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/dmar.c
|
||||
|
||||
return 0;
|
||||
|
||||
Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/iommu.c
|
||||
+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c
|
||||
--- a/xen/drivers/passthrough/vtd/iommu.c
|
||||
+++ b/xen/drivers/passthrough/vtd/iommu.c
|
||||
@@ -1495,6 +1495,11 @@ int intel_iommu_map_page(
|
||||
pte_present = dma_pte_present(*pte);
|
||||
dma_set_pte_addr(*pte, (paddr_t)mfn << PAGE_SHIFT_4K);
|
||||
@@ -254,10 +251,8 @@ Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.c
|
||||
iommu_flush_cache_entry(pte);
|
||||
unmap_vtd_domain_page(page);
|
||||
|
||||
Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.h
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/drivers/passthrough/vtd/iommu.h
|
||||
+++ xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.h
|
||||
--- a/xen/drivers/passthrough/vtd/iommu.h
|
||||
+++ b/xen/drivers/passthrough/vtd/iommu.h
|
||||
@@ -104,6 +104,7 @@
|
||||
#define ecap_ext_intr(e) ((e >> 4) & 0x1)
|
||||
#define ecap_cache_hints(e) ((e >> 5) & 0x1)
|
||||
@@ -279,10 +274,8 @@ Index: xen-3.3.1-testing/xen/drivers/passthrough/vtd/iommu.h
|
||||
#define dma_set_pte_prot(p, prot) \
|
||||
do {(p).val = ((p).val & ~3) | ((prot) & 3); } while (0)
|
||||
#define dma_pte_addr(p) ((p).val & PAGE_MASK_4K)
|
||||
Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/vmx/vmx.h
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/include/asm-x86/hvm/vmx/vmx.h
|
||||
+++ xen-3.3.1-testing/xen/include/asm-x86/hvm/vmx/vmx.h
|
||||
--- a/xen/include/asm-x86/hvm/vmx/vmx.h
|
||||
+++ b/xen/include/asm-x86/hvm/vmx/vmx.h
|
||||
@@ -33,7 +33,8 @@ typedef union {
|
||||
u64 r : 1,
|
||||
w : 1,
|
||||
@@ -293,23 +286,25 @@ Index: xen-3.3.1-testing/xen/include/asm-x86/hvm/vmx/vmx.h
|
||||
sp_avail : 1,
|
||||
avail1 : 4,
|
||||
mfn : 45,
|
||||
Index: xen-3.3.1-testing/xen/include/asm-x86/mtrr.h
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/include/asm-x86/mtrr.h
|
||||
+++ xen-3.3.1-testing/xen/include/asm-x86/mtrr.h
|
||||
@@ -64,7 +64,7 @@ extern int mtrr_del_page(int reg, unsign
|
||||
--- a/xen/include/asm-x86/mtrr.h
|
||||
+++ b/xen/include/asm-x86/mtrr.h
|
||||
@@ -64,9 +64,11 @@ extern int mtrr_del_page(int reg, unsign
|
||||
extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
|
||||
extern u32 get_pat_flags(struct vcpu *v, u32 gl1e_flags, paddr_t gpaddr,
|
||||
paddr_t spaddr);
|
||||
-extern uint8_t epte_get_entry_emt(struct domain *d, unsigned long gfn, unsigned long mfn);
|
||||
+extern uint8_t epte_get_entry_emt(struct domain *d, unsigned long gfn, unsigned long mfn, uint8_t *igmt, int direct_mmio);
|
||||
extern void ept_change_entry_emt_with_range(struct domain *d, unsigned long start_gfn,
|
||||
unsigned long end_gfn);
|
||||
-extern void ept_change_entry_emt_with_range(struct domain *d, unsigned long start_gfn,
|
||||
- unsigned long end_gfn);
|
||||
+extern uint8_t epte_get_entry_emt(
|
||||
+ struct domain *d, unsigned long gfn, unsigned long mfn,
|
||||
+ uint8_t *igmt, int direct_mmio);
|
||||
+extern void ept_change_entry_emt_with_range(
|
||||
+ struct domain *d, unsigned long start_gfn, unsigned long end_gfn);
|
||||
extern unsigned char pat_type_2_pte_flags(unsigned char pat_type);
|
||||
Index: xen-3.3.1-testing/xen/include/xen/iommu.h
|
||||
===================================================================
|
||||
--- xen-3.3.1-testing.orig/xen/include/xen/iommu.h
|
||||
+++ xen-3.3.1-testing/xen/include/xen/iommu.h
|
||||
|
||||
#endif /* __ASM_X86_MTRR_H__ */
|
||||
--- a/xen/include/xen/iommu.h
|
||||
+++ b/xen/include/xen/iommu.h
|
||||
@@ -32,6 +32,7 @@ extern int iommu_enabled;
|
||||
extern int iommu_pv_enabled;
|
||||
extern int force_iommu;
|
||||
|
Reference in New Issue
Block a user