2015-10-06 17:11:48 +02:00
|
|
|
# Commit cf6d39f81992c29a637c603dbabf1e21a0ea563f
|
|
|
|
# Date 2015-09-25 09:05:29 +0200
|
|
|
|
# Author Jan Beulich <jbeulich@suse.com>
|
|
|
|
# Committer Jan Beulich <jbeulich@suse.com>
|
|
|
|
x86/PV: properly populate descriptor tables
|
|
|
|
|
|
|
|
Us extending the GDT limit past the Xen descriptors so far meant that
|
|
|
|
guests (including user mode programs) accessing any descriptor table
|
|
|
|
slot above the original OS'es limit but below the first Xen descriptor
|
|
|
|
caused a #PF, converted to a #GP in our #PF handler. Which is quite
|
|
|
|
different from the native behavior, where some of such accesses (LAR
|
|
|
|
and LSL) don't fault. Mimic that behavior by mapping a blank page into
|
|
|
|
unused slots.
|
|
|
|
|
|
|
|
While not strictly required, treat the LDT the same for consistency.
|
|
|
|
|
|
|
|
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
|
|
|
|
Signed-off-by: Jan Beulich <jbeulich@suse.com>
|
|
|
|
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
|
|
|
|
|
2015-10-29 23:28:05 +01:00
|
|
|
# Commit 61031e64d3dafd2fb1953436444bf02eccb9b146
|
|
|
|
# Date 2015-10-27 14:46:12 +0100
|
|
|
|
# Author Jan Beulich <jbeulich@suse.com>
|
|
|
|
# Committer Jan Beulich <jbeulich@suse.com>
|
|
|
|
x86/PV: don't zero-map LDT
|
|
|
|
|
|
|
|
This effectvely reverts the LDT related part of commit cf6d39f819
|
|
|
|
("x86/PV: properly populate descriptor tables"), which broke demand
|
|
|
|
paged LDT handling in guests.
|
|
|
|
|
|
|
|
Reported-by: David Vrabel <david.vrabel@citrix.com>
|
|
|
|
Diagnosed-by: Andrew Cooper <andrew.cooper3@citrix.com>
|
|
|
|
Signed-off-by: Jan Beulich <jbeulich@suse.com>
|
|
|
|
Tested-by: David Vrabel <david.vrabel@citrix.com>
|
|
|
|
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
|
|
|
|
|
2015-11-04 21:30:31 +01:00
|
|
|
Index: xen-4.5.2-testing/xen/arch/x86/mm.c
|
|
|
|
===================================================================
|
|
|
|
--- xen-4.5.2-testing.orig/xen/arch/x86/mm.c
|
|
|
|
+++ xen-4.5.2-testing/xen/arch/x86/mm.c
|
|
|
|
@@ -508,12 +508,12 @@ void update_cr3(struct vcpu *v)
|
2015-10-06 17:11:48 +02:00
|
|
|
make_cr3(v, cr3_mfn);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static const char __section(".bss.page_aligned") zero_page[PAGE_SIZE];
|
|
|
|
|
|
|
|
static void invalidate_shadow_ldt(struct vcpu *v, int flush)
|
|
|
|
{
|
|
|
|
l1_pgentry_t *pl1e;
|
|
|
|
- int i;
|
|
|
|
- unsigned long pfn;
|
|
|
|
+ unsigned int i;
|
|
|
|
struct page_info *page;
|
|
|
|
|
|
|
|
BUG_ON(unlikely(in_irq()));
|
2015-11-04 21:30:31 +01:00
|
|
|
@@ -528,10 +528,10 @@ static void invalidate_shadow_ldt(struct
|
2015-10-29 23:28:05 +01:00
|
|
|
|
2015-10-06 17:11:48 +02:00
|
|
|
for ( i = 16; i < 32; i++ )
|
|
|
|
{
|
2015-10-29 23:28:05 +01:00
|
|
|
- pfn = l1e_get_pfn(pl1e[i]);
|
2015-10-06 17:11:48 +02:00
|
|
|
- if ( pfn == 0 ) continue;
|
2015-10-29 23:28:05 +01:00
|
|
|
+ if ( !(l1e_get_flags(pl1e[i]) & _PAGE_PRESENT) )
|
2015-10-06 17:11:48 +02:00
|
|
|
+ continue;
|
2015-10-29 23:28:05 +01:00
|
|
|
+ page = l1e_get_page(pl1e[i]);
|
|
|
|
l1e_write(&pl1e[i], l1e_empty());
|
|
|
|
- page = mfn_to_page(pfn);
|
2015-10-06 17:11:48 +02:00
|
|
|
ASSERT_PAGE_IS_TYPE(page, PGT_seg_desc_page);
|
|
|
|
ASSERT_PAGE_IS_DOMAIN(page, v->domain);
|
2015-10-29 23:28:05 +01:00
|
|
|
put_page_and_type(page);
|
2015-11-04 21:30:31 +01:00
|
|
|
@@ -4366,16 +4366,18 @@ long do_update_va_mapping_otherdomain(un
|
2015-10-06 17:11:48 +02:00
|
|
|
void destroy_gdt(struct vcpu *v)
|
|
|
|
{
|
|
|
|
l1_pgentry_t *pl1e;
|
|
|
|
- int i;
|
|
|
|
- unsigned long pfn;
|
|
|
|
+ unsigned int i;
|
|
|
|
+ unsigned long pfn, zero_pfn = PFN_DOWN(__pa(zero_page));
|
|
|
|
|
|
|
|
v->arch.pv_vcpu.gdt_ents = 0;
|
|
|
|
pl1e = gdt_ldt_ptes(v->domain, v);
|
|
|
|
for ( i = 0; i < FIRST_RESERVED_GDT_PAGE; i++ )
|
|
|
|
{
|
|
|
|
- if ( (pfn = l1e_get_pfn(pl1e[i])) != 0 )
|
|
|
|
+ pfn = l1e_get_pfn(pl1e[i]);
|
|
|
|
+ if ( (l1e_get_flags(pl1e[i]) & _PAGE_PRESENT) && pfn != zero_pfn )
|
|
|
|
put_page_and_type(mfn_to_page(pfn));
|
|
|
|
- l1e_write(&pl1e[i], l1e_empty());
|
|
|
|
+ l1e_write(&pl1e[i],
|
|
|
|
+ l1e_from_pfn(zero_pfn, __PAGE_HYPERVISOR & ~_PAGE_RW));
|
|
|
|
v->arch.pv_vcpu.gdt_frames[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-11-04 21:30:31 +01:00
|
|
|
@@ -4388,7 +4390,7 @@ long set_gdt(struct vcpu *v,
|
2015-10-06 17:11:48 +02:00
|
|
|
struct domain *d = v->domain;
|
|
|
|
l1_pgentry_t *pl1e;
|
|
|
|
/* NB. There are 512 8-byte entries per GDT page. */
|
|
|
|
- int i, nr_pages = (entries + 511) / 512;
|
|
|
|
+ unsigned int i, nr_pages = (entries + 511) / 512;
|
|
|
|
|
|
|
|
if ( entries > FIRST_RESERVED_GDT_ENTRY )
|
|
|
|
return -EINVAL;
|