return 1;
}
-int page_is_conventional_ram(unsigned long mfn) /* CS 19085 mem to page */
-{
+int page_is_ram_type(unsigned long mfn, unsigned long type) /* CS 19085 mem to page */
+{
+ /**
+ * N.B. This function should really be enhanced to return what is more in line with the e820
+ * semantics for usable and reservered RAM. For example type RAM_TYPE_CONVENTIONAL can
+ * include the areas freed after OS loader calls ExitBootServices:
+ * EFI_LOADER_CODE, EFI_LOADER_DATA, EFI_BOOT_SERVICES_CODE, EFI_BOOT_SERVICES_DATA, and EFI_CONVENTIONAL_MEMORY
+ * The reserved regions would include:
+ * EFI_RUNTIME_SERVICES_CODE, EFI_RUNTIME_SERVICES_DATA, EFI_MEMORY_MAPPED_IO, EFI_MEMORY_MAPPED_IO_PORT_SPACE and EFI_PAL_CODE
+ */
return (efi_mem_type(pfn_to_paddr(mfn)) == EFI_CONVENTIONAL_MEMORY);
}
-
long
arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
{
subarch_init_memory();
}
-int page_is_conventional_ram(unsigned long mfn) /* CS 19085 mem to page, CS 19083 fixed test */
+int page_is_ram_type(unsigned long mfn, unsigned long mem_type) /* CS 19085 mem to page, CS 19083 fixed test */
{
uint64_t maddr = pfn_to_paddr(mfn);
int i;
for ( i = 0; i < e820.nr_map; i++ )
{
- if ( (e820.map[i].type == E820_RAM) &&
- (e820.map[i].addr <= maddr) &&
+ switch (e820.map[i].type)
+ {
+ case E820_RAM:
+ if (mem_type & RAM_TYPE_CONVENTIONAL)
+ break;
+ continue;
+ case E820_RESERVED:
+ if (mem_type & RAM_TYPE_RESERVED)
+ break;
+ continue;
+ default:
+ /* unknown */
+ continue;
+ }
+
+ /* test the range */
+ if ( (e820.map[i].addr <= maddr) &&
((e820.map[i].addr + e820.map[i].size) >= (maddr + PAGE_SIZE)) )
return 1;
}
if ( opt_watchdog )
watchdog_enable();
+
+ if ( !tboot_protect_mem_regions() )
+ panic("Could not protect TXT memory regions\n");
/* Create initial domain 0. */
dom0 = domain_create(0, 0, DOM0_SSIDREF);
if ( xen_cpuidle )
xen_processor_pmbits |= XEN_PROCESSOR_PM_CX;
- if ( !tboot_protect_mem_regions() )
- panic("Could not protect TXT memory regions\n");
-
/*
* We're going to setup domain0 using the module(s) that we stashed safely
* above our heap. The second module, if present, is an initrd ramdisk.
return rc;
}
-int tboot_in_range(paddr_t start, paddr_t end)
-{
- if ( g_tboot_shared == NULL || g_tboot_shared->version < 0x02 )
- return 0;
-
- start = max_t(paddr_t, start, g_tboot_shared->tboot_base);
- end = min_t(paddr_t, end,
- g_tboot_shared->tboot_base + g_tboot_shared->tboot_size);
-
- return start < end;
-}
-
/*
* Local variables:
* mode: C
if ( d->domain_id == 0 )
{
extern int xen_in_range(paddr_t start, paddr_t end);
- extern int tboot_in_range(paddr_t start, paddr_t end);
/*
* Set up 1:1 page table for dom0 except the critical segments
*/
for ( i = 0; i < max_page; i++ )
{
- /* CS 19084 remove tboot_in_range, CS 19085 use page_is_conventional_ram */
- /*if ( !page_is_conventional_ram(i) ||
+ /* CS 19084 remove tboot_in_range, CS 19085 use page_is_conventional_ram */
+ /* Modified to include reserved memory regions - this fix will be pushed upstream */
+ if ( !page_is_ram_type(i, RAM_TYPE_CONVENTIONAL|RAM_TYPE_RESERVED) ||
xen_in_range(i << PAGE_SHIFT, (i + 1) << PAGE_SHIFT) )
- continue;*/
- if ( xen_in_range(i << PAGE_SHIFT_4K, (i + 1) << PAGE_SHIFT_4K) ||
- tboot_in_range(i << PAGE_SHIFT_4K, (i + 1) << PAGE_SHIFT_4K) )
continue;
iommu_map_page(d, i, i);
switch ( vga_console_info.video_type )
{
case XEN_VGATYPE_TEXT_MODE_3:
- if ( page_is_conventional_ram(paddr_to_pfn(0xB8000)) || /* CS 19085 mem to page */
+ if ( page_is_ram_type(paddr_to_pfn(0xB8000), RAM_TYPE_CONVENTIONAL) || /* CS 19085 mem to page */
((video = ioremap(0xB8000, 0x8000)) == NULL) )
return;
outw(0x200a, 0x3d4); /* disable cursor */
int guest_remove_page(struct domain *d, unsigned long gmfn);
-/* Returns TRUE if the whole page at @mfn is ordinary RAM. */
-int page_is_conventional_ram(unsigned long mfn);
+#define RAM_TYPE_CONVENTIONAL 0x00000001
+#define RAM_TYPE_RESERVED 0x00000002
+/* Returns TRUE if the whole page at @mfn is of the requested RAM type(s) above. */
+int page_is_ram_type(unsigned long mfn, unsigned long mem_type);
extern unsigned long *alloc_bitmap; /* for vmcoreinfo */