xen: create VM_MEMATTR_XEN for Xen memory mappings

The requirements for pages shared with Xen/other VMs may vary from
architecture to architecture.  As such create a macro which various
architectures can use.

Remove a use of PAT_WRITE_BACK in xenstore.c.  This is a x86-ism which
shouldn't have been present in a common area.

Original idea: Julien Grall <julien@xen.org>, 2014-01-14 06:44:08
Approach suggested by: royger
Reviewed by: royger, mhorne
Differential Revision: https://reviews.freebsd.org/D29351
This commit is contained in:
Elliott Mitchell 2021-04-06 09:59:30 +02:00 committed by Roger Pau Monné
parent a48f7ba444
commit b6ff9345a4
4 changed files with 6 additions and 3 deletions

View File

@ -125,7 +125,7 @@ xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size)
phys_addr = rman_get_start(res);
error = vm_phys_fictitious_reg_range(phys_addr, phys_addr + size,
VM_MEMATTR_DEFAULT);
VM_MEMATTR_XEN);
if (error) {
bus_release_resource(child, SYS_RES_MEMORY, *res_id, res);
return (NULL);

View File

@ -273,7 +273,7 @@ static void
xencons_early_init_ring(struct xencons_priv *cons)
{
cons->intf = pmap_mapdev_attr(ptoa(xen_get_console_mfn()), PAGE_SIZE,
VM_MEMATTR_WRITE_BACK);
VM_MEMATTR_XEN);
cons->evtchn = xen_get_console_evtchn();
}

View File

@ -1130,7 +1130,7 @@ xs_attach(device_t dev)
} else {
xs.gpfn = xen_get_xenstore_mfn();
xen_store = pmap_mapdev_attr(ptoa(xs.gpfn), PAGE_SIZE,
PAT_WRITE_BACK);
VM_MEMATTR_XEN);
xs.initialized = true;
}

View File

@ -30,6 +30,9 @@
#ifndef _MACHINE_X86_XEN_XEN_OS_H_
#define _MACHINE_X86_XEN_XEN_OS_H_
/* Shared memory needs write-back as its cache attribute for coherency. */
#define VM_MEMATTR_XEN VM_MEMATTR_WRITE_BACK
/* Everything below this point is not included by assembler (.S) files. */
#ifndef __ASSEMBLY__