Skip to contentSkip to conversation

x86/page: Minor adustments to uncacheable mappings

PATCH In review Andrew Cooper 2 participants 6 messages Aug 14, 2017

lore
Share & tools
lore
#0 lore raw

cover x86/page: Minor adustments to uncacheable mappings

Andrew Cooper (2):
x86/page: Rename PAGE_HYPERVISOR_NOCACHE to PAGE_HYPERVISOR_UCMINUS x86/page: Introduce and use PAGE_HYPERVISOR_UC

 xen/arch/x86/boot/x86_64.S        | 2 +-
 xen/arch/x86/mm.c                 | 2 +-
 xen/arch/x86/x86_64/mmconfig_64.c | 2 +-
 xen/include/asm-arm/mm.h          | 2 +-
 xen/include/asm-x86/acpi.h        | 2 +-
 xen/include/asm-x86/fixmap.h      | 2 +-
 xen/include/asm-x86/page.h        | 3 ++-
 xen/include/asm-x86/x86_64/page.h | 7 +++++--
 8 files changed, 13 insertions(+), 9 deletions(-)

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#1 lore raw

PATCH 1/2 x86/page: Rename PAGE_HYPERVISOR_NOCACHE to PAGE_HYPERVISOR_UCMINUS

To better describe its actual function.

No functional change.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/boot/x86_64.S        | 2 +-
 xen/arch/x86/mm.c                 | 2 +-
 xen/arch/x86/x86_64/mmconfig_64.c | 2 +-
 xen/include/asm-arm/mm.h          | 2 +-
 xen/include/asm-x86/acpi.h        | 2 +-
 xen/include/asm-x86/fixmap.h      | 2 +-
 xen/include/asm-x86/page.h        | 2 +-
 xen/include/asm-x86/x86_64/page.h | 4 ++--
 8 files changed, 9 insertions(+), 9 deletions(-)
xen/arch/x86/boot/x86_64.S +1 -1
index b640d9b..c3a6a02 100644
@@ -92,7 +92,7 @@ l1_identmap:
         .rept L1_PAGETABLE_ENTRIES
         /* VGA hole (0xa0000-0xc0000) should be mapped UC. */
         .if pfn >= 0xa0 && pfn < 0xc0
-        .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_NOCACHE | MAP_SMALL_PAGES
+        .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_UCMINUS | MAP_SMALL_PAGES
         .else
         .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR | MAP_SMALL_PAGES
         .endif
xen/arch/x86/mm.c +1 -1
index 88bf4f6..f53ca43 100644
@@ -6100,7 +6100,7 @@ void __iomem *ioremap(paddr_t pa, size_t len)
         unsigned int offs = pa & (PAGE_SIZE - 1);
         unsigned int nr = PFN_UP(offs + len);
 
-        va = __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR_NOCACHE, VMAP_DEFAULT) + offs;
+        va = __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR_UCMINUS, VMAP_DEFAULT) + offs;
     }
 
     return (void __force __iomem *)va;
xen/arch/x86/x86_64/mmconfig_64.c +1 -1
index e84a67d..a7d2e33 100644
@@ -140,7 +140,7 @@ int pci_mmcfg_arch_enable(unsigned int idx)
 
     if (pci_mmcfg_virt[idx].virt)
         return 0;
-    pci_mmcfg_virt[idx].virt = mcfg_ioremap(cfg, idx, PAGE_HYPERVISOR_NOCACHE);
+    pci_mmcfg_virt[idx].virt = mcfg_ioremap(cfg, idx, PAGE_HYPERVISOR_UCMINUS);
     if (!pci_mmcfg_virt[idx].virt) {
         printk(KERN_ERR "PCI: Cannot map MCFG aperture for segment %04x\n",
                cfg->pci_segment);
xen/include/asm-arm/mm.h +1 -1
index ef84b72..8999ae7 100644
@@ -176,7 +176,7 @@ void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned attributes);
 
 static inline void __iomem *ioremap_nocache(paddr_t start, size_t len)
 {
-    return ioremap_attr(start, len, PAGE_HYPERVISOR_NOCACHE);
+    return ioremap_attr(start, len, PAGE_HYPERVISOR_UCMINUS);
 }
 
 static inline void __iomem *ioremap_cache(paddr_t start, size_t len)
xen/include/asm-x86/acpi.h +1 -1
index 27ecc65..c138def 100644
@@ -160,6 +160,6 @@ void hvm_acpi_sleep_button(struct domain *d);
 void save_rest_processor_state(void);
 void restore_rest_processor_state(void);
 
-#define ACPI_MAP_MEM_ATTR	PAGE_HYPERVISOR_NOCACHE
+#define ACPI_MAP_MEM_ATTR	PAGE_HYPERVISOR_UCMINUS
 
 #endif /*__X86_ASM_ACPI_H*/
xen/include/asm-x86/fixmap.h +1 -1
index 054889c..89bf6cb 100644
@@ -72,7 +72,7 @@ extern void __set_fixmap(
     __set_fixmap(idx, (phys)>>PAGE_SHIFT, PAGE_HYPERVISOR)
 
 #define set_fixmap_nocache(idx, phys) \
-    __set_fixmap(idx, (phys)>>PAGE_SHIFT, PAGE_HYPERVISOR_NOCACHE)
+    __set_fixmap(idx, (phys)>>PAGE_SHIFT, PAGE_HYPERVISOR_UCMINUS)
 
 #define clear_fixmap(idx) __set_fixmap(idx, 0, 0)
 
xen/include/asm-x86/page.h +1 -1
index 0f843c2..0b68c5e 100644
@@ -322,7 +322,7 @@ void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t);
 #define __PAGE_HYPERVISOR_RX      (_PAGE_PRESENT | _PAGE_ACCESSED)
 #define __PAGE_HYPERVISOR         (__PAGE_HYPERVISOR_RX | \
                                    _PAGE_DIRTY | _PAGE_RW)
-#define __PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR | _PAGE_PCD)
+#define __PAGE_HYPERVISOR_UCMINUS (__PAGE_HYPERVISOR | _PAGE_PCD)
 
 #define MAP_SMALL_PAGES _PAGE_AVAIL0 /* don't use superpages mappings */
 
xen/include/asm-x86/x86_64/page.h +2 -2
index 1b48309..e102624 100644
@@ -166,10 +166,10 @@ typedef l4_pgentry_t root_pgentry_t;
 #ifdef __ASSEMBLY__
 /* Dependency on NX being available can't be expressed. */
 # define PAGE_HYPERVISOR         PAGE_HYPERVISOR_RWX
-# define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL)
+# define PAGE_HYPERVISOR_UCMINUS (__PAGE_HYPERVISOR_UCMINUS | _PAGE_GLOBAL)
 #else
 # define PAGE_HYPERVISOR         PAGE_HYPERVISOR_RW
-# define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | \
+# define PAGE_HYPERVISOR_UCMINUS (__PAGE_HYPERVISOR_UCMINUS | \
                                   _PAGE_GLOBAL | _PAGE_NX)
 #endif
 
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

Re: [PATCH 1/2] x86/page: Rename PAGE_HYPERVISOR_NOCACHE to PAGE_HYPERVISOR_UCMINUS

xen/include/asm-arm/mm.h void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned attributes); · line 180

Quoted 11 lines · Andrew Cooper
xen/include/asm-arm/mm.h +1 -1
index ef84b72..8999ae7 100644
@@ -176,7 +176,7 @@ void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned attributes);
 
 static inline void __iomem *ioremap_nocache(paddr_t start, size_t len)
 {
-    return ioremap_attr(start, len, PAGE_HYPERVISOR_NOCACHE);
+    return ioremap_attr(start, len, PAGE_HYPERVISOR_UCMINUS);
 }

Oops - this hunk shouldn't have slipped in. (I thought I'd removed all the ARM changes). The patch should be x86-specific.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] x86/page: Rename PAGE_HYPERVISOR_NOCACHE to PAGE_HYPERVISOR_UCMINUS

In reply to Andrew Cooper

xen/arch/x86/boot/x86_64.S l1_identmap: · line 95

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 14.08.17 at 12:57, <[email protected]> wrote:
xen/arch/x86/boot/x86_64.S +1 -1
@@ -92,7 +92,7 @@ l1_identmap:
         .rept L1_PAGETABLE_ENTRIES
         /* VGA hole (0xa0000-0xc0000) should be mapped UC. */
         .if pfn >= 0xa0 && pfn < 0xc0
-        .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_NOCACHE | MAP_SMALL_PAGES
+        .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_UCMINUS | MAP_SMALL_PAGES

Mind making the comment say UC- at once?

xen/include/asm-arm/mm.h void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned attributes); · line 180

Quoted 9 lines
xen/include/asm-arm/mm.h +1 -1
@@ -176,7 +176,7 @@ void __iomem *ioremap_attr(paddr_t start, size_t len, unsigned attributes);
 
 static inline void __iomem *ioremap_nocache(paddr_t start, size_t len)
 {
-    return ioremap_attr(start, len, PAGE_HYPERVISOR_NOCACHE);
+    return ioremap_attr(start, len, PAGE_HYPERVISOR_UCMINUS);
 }

Is UC- really an arch-independent term? I wouldn't mind switching the x86 side, but I don't think ARM should be changed. Oh, and now I notice your follow-up mail ... So preferably with the comment adjustment above

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw

PATCH 2/2 x86/page: Introduce and use PAGE_HYPERVISOR_UC

In reply to Andrew Cooper

Always map the PCI MMCFG region as strongly uncacheable. Nothing good will happen if stray MTRR settings end up converting UC- to WC.

---
CC: Jan Beulich <[email protected]>

---
 xen/arch/x86/x86_64/mmconfig_64.c | 2 +-
 xen/include/asm-x86/page.h        | 1 +
 xen/include/asm-x86/x86_64/page.h | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)
xen/arch/x86/x86_64/mmconfig_64.c +1 -1
index a7d2e33..958b6cf 100644
@@ -140,7 +140,7 @@ int pci_mmcfg_arch_enable(unsigned int idx)
 
     if (pci_mmcfg_virt[idx].virt)
         return 0;
-    pci_mmcfg_virt[idx].virt = mcfg_ioremap(cfg, idx, PAGE_HYPERVISOR_UCMINUS);
+    pci_mmcfg_virt[idx].virt = mcfg_ioremap(cfg, idx, PAGE_HYPERVISOR_UC);
     if (!pci_mmcfg_virt[idx].virt) {
         printk(KERN_ERR "PCI: Cannot map MCFG aperture for segment %04x\n",
                cfg->pci_segment);
xen/include/asm-x86/page.h +1 -0
index 0b68c5e..263ca5b 100644
@@ -323,6 +323,7 @@ void efi_update_l4_pgtable(unsigned int l4idx, l4_pgentry_t);
 #define __PAGE_HYPERVISOR         (__PAGE_HYPERVISOR_RX | \
                                    _PAGE_DIRTY | _PAGE_RW)
 #define __PAGE_HYPERVISOR_UCMINUS (__PAGE_HYPERVISOR | _PAGE_PCD)
+#define __PAGE_HYPERVISOR_UC      (__PAGE_HYPERVISOR | _PAGE_PCD | _PAGE_PWT)
 
 #define MAP_SMALL_PAGES _PAGE_AVAIL0 /* don't use superpages mappings */
 
xen/include/asm-x86/x86_64/page.h +3 -0
index e102624..603ecac 100644
@@ -167,10 +167,13 @@ typedef l4_pgentry_t root_pgentry_t;
 /* Dependency on NX being available can't be expressed. */
 # define PAGE_HYPERVISOR         PAGE_HYPERVISOR_RWX
 # define PAGE_HYPERVISOR_UCMINUS (__PAGE_HYPERVISOR_UCMINUS | _PAGE_GLOBAL)
+# define PAGE_HYPERVISOR_UC      (__PAGE_HYPERVISOR_UC      | _PAGE_GLOBAL)
 #else
 # define PAGE_HYPERVISOR         PAGE_HYPERVISOR_RW
 # define PAGE_HYPERVISOR_UCMINUS (__PAGE_HYPERVISOR_UCMINUS | \
                                   _PAGE_GLOBAL | _PAGE_NX)
+# define PAGE_HYPERVISOR_UC      (__PAGE_HYPERVISOR_UC | \
+                                  _PAGE_GLOBAL | _PAGE_NX)
 #endif
 
 #endif /* __X86_64_PAGE_H__ */
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] x86/page: Introduce and use PAGE_HYPERVISOR_UC

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 14.08.17 at 12:57, <[email protected]> wrote:

Always map the PCI MMCFG region as strongly uncacheable. Nothing good will happen if stray MTRR settings end up converting UC- to WC.

I was tempted to ask the question on patch 1.

Quoted 1 line

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel