git: b6ff9345a46a - main - xen: create VM_MEMATTR_XEN for Xen memory mappings

Roger Pau Monné royger at FreeBSD.org
Wed Jul 28 15:27:48 UTC 2021


The branch main has been updated by royger:

URL: https://cgit.FreeBSD.org/src/commit/?id=b6ff9345a46af564da32ad480490eaa97840d0b6

commit b6ff9345a46af564da32ad480490eaa97840d0b6
Author:     Elliott Mitchell <ehem+freebsd at m5p.com>
AuthorDate: 2021-04-06 07:59:30 +0000
Commit:     Roger Pau Monné <royger at FreeBSD.org>
CommitDate: 2021-07-28 15:27:02 +0000

    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 at xen.org>, 2014-01-14 06:44:08
    Approach suggested by: royger
    Reviewed by: royger, mhorne
    Differential Revision: https://reviews.freebsd.org/D29351
---
 sys/dev/xen/bus/xenpv.c           | 2 +-
 sys/dev/xen/console/xen_console.c | 2 +-
 sys/dev/xen/xenstore/xenstore.c   | 2 +-
 sys/x86/include/xen/xen-os.h      | 3 +++
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/sys/dev/xen/bus/xenpv.c b/sys/dev/xen/bus/xenpv.c
index d9db10b7005d..080c82c73f08 100644
--- a/sys/dev/xen/bus/xenpv.c
+++ b/sys/dev/xen/bus/xenpv.c
@@ -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);
diff --git a/sys/dev/xen/console/xen_console.c b/sys/dev/xen/console/xen_console.c
index 7eed30885e6b..8ad755dbf214 100644
--- a/sys/dev/xen/console/xen_console.c
+++ b/sys/dev/xen/console/xen_console.c
@@ -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();
 }
 
diff --git a/sys/dev/xen/xenstore/xenstore.c b/sys/dev/xen/xenstore/xenstore.c
index 890cfe009411..dc00ed0d50b8 100644
--- a/sys/dev/xen/xenstore/xenstore.c
+++ b/sys/dev/xen/xenstore/xenstore.c
@@ -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;
 	}
 
diff --git a/sys/x86/include/xen/xen-os.h b/sys/x86/include/xen/xen-os.h
index 86bacadc8521..78d44ad7c9d7 100644
--- a/sys/x86/include/xen/xen-os.h
+++ b/sys/x86/include/xen/xen-os.h
@@ -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__
 


More information about the dev-commits-src-main mailing list