x86: introduce ioremap_wc()
authorJan Beulich <jbeulich@suse.com>
Fri, 18 Feb 2022 13:42:39 +0000 (14:42 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 18 Feb 2022 13:42:39 +0000 (14:42 +0100)
commit81d195c6c0e2ee1b706d19dbbb57f73bbf6b81b4
treed374f53bba5553d5c57dd8f0929350c75a26c16d
parent8518f96f13fb0ac2dd9791014bfb0d1b01f34e4c
x86: introduce ioremap_wc()

In order for a to-be-introduced ERMS form of memcpy() to not regress
boot performance on certain systems when video output is active, we
first need to arrange for avoiding further dependency on firmware
setting up MTRRs in a way we can actually further modify. On many
systems, due to the continuously growing amounts of installed memory,
MTRRs get configured with at least one huge WB range, and with MMIO
ranges below 4Gb then forced to UC via overlapping MTRRs. mtrr_add(), as
it is today, can't deal with such a setup. Hence on such systems we
presently leave the frame buffer mapped UC, leading to significantly
reduced performance when using REP STOSB / REP MOVSB.

On post-PentiumII hardware (i.e. any that's capable of running 64-bit
code), an effective memory type of WC can be achieved without MTRRs, by
simply referencing the respective PAT entry from the PTEs. While this
will leave the switch to ERMS forms of memset() and memcpy() with
largely unchanged performance, the change here on its own improves
performance on affected systems quite significantly: Measuring just the
individual affected memcpy() invocations yielded a speedup by a factor
of over 250 on my initial (Skylake) test system. memset() isn't getting
improved by as much there, but still by a factor of about 20.

While adding {__,}PAGE_HYPERVISOR_WC, also add {__,}PAGE_HYPERVISOR_WT
to, at the very least, make clear what PTE flags this memory type uses.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/include/asm/mm.h
xen/arch/x86/include/asm/page.h
xen/arch/x86/include/asm/x86_64/page.h
xen/arch/x86/mm.c
xen/drivers/video/vesa.c
xen/drivers/video/vga.c