1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21965aae3SH. Peter Anvin #ifndef _ASM_X86_IO_H
31965aae3SH. Peter Anvin #define _ASM_X86_IO_H
4bb898558SAl Viro
51c5b9069SBrian Gerst /*
61c5b9069SBrian Gerst * This file contains the definitions for the x86 IO instructions
71c5b9069SBrian Gerst * inb/inw/inl/outb/outw/outl and the "string versions" of the same
81c5b9069SBrian Gerst * (insb/insw/insl/outsb/outsw/outsl). You can also use "pausing"
91c5b9069SBrian Gerst * versions of the single-IO instructions (inb_p/inw_p/..).
101c5b9069SBrian Gerst *
111c5b9069SBrian Gerst * This file is not meant to be obfuscating: it's just complicated
121c5b9069SBrian Gerst * to (a) handle it all in a way that makes gcc able to optimize it
131c5b9069SBrian Gerst * as well as possible and (b) trying to avoid writing the same thing
141c5b9069SBrian Gerst * over and over again with slight variations and possibly making a
151c5b9069SBrian Gerst * mistake somewhere.
161c5b9069SBrian Gerst */
171c5b9069SBrian Gerst
181c5b9069SBrian Gerst /*
191c5b9069SBrian Gerst * Thanks to James van Artsdalen for a better timing-fix than
201c5b9069SBrian Gerst * the two short jumps: using outb's to a nonexistent port seems
211c5b9069SBrian Gerst * to guarantee better timings even on fast machines.
221c5b9069SBrian Gerst *
231c5b9069SBrian Gerst * On the other hand, I'd like to be sure of a non-existent port:
241c5b9069SBrian Gerst * I feel a bit unsafe about using 0x80 (should be safe, though)
251c5b9069SBrian Gerst *
261c5b9069SBrian Gerst * Linus
271c5b9069SBrian Gerst */
281c5b9069SBrian Gerst
291c5b9069SBrian Gerst /*
301c5b9069SBrian Gerst * Bit simplified and optimized by Jan Hubicka
311c5b9069SBrian Gerst * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
321c5b9069SBrian Gerst *
331c5b9069SBrian Gerst * isa_memset_io, isa_memcpy_fromio, isa_memcpy_toio added,
341c5b9069SBrian Gerst * isa_read[wl] and isa_write[wl] fixed
351c5b9069SBrian Gerst * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
361c5b9069SBrian Gerst */
371c5b9069SBrian Gerst
381c5b9069SBrian Gerst #include <linux/string.h>
39bb898558SAl Viro #include <linux/compiler.h>
408260b982SKuppuswamy Sathyanarayanan #include <linux/cc_platform.h>
41976e8f67SJeremy Fitzhardinge #include <asm/page.h>
425b7c73e0SMark Salter #include <asm/early_ioremap.h>
43d6472302SStephen Rothwell #include <asm/pgtable_types.h>
44*1e8f93e1SKirill A. Shutemov #include <asm/shared/io.h>
45bb898558SAl Viro
46bb898558SAl Viro #define build_mmio_read(name, size, type, reg, barrier) \
47bb898558SAl Viro static inline type name(const volatile void __iomem *addr) \
48bb898558SAl Viro { type ret; asm volatile("mov" size " %1,%0":reg (ret) \
49bb898558SAl Viro :"m" (*(volatile type __force *)addr) barrier); return ret; }
50bb898558SAl Viro
51bb898558SAl Viro #define build_mmio_write(name, size, type, reg, barrier) \
52bb898558SAl Viro static inline void name(type val, volatile void __iomem *addr) \
53bb898558SAl Viro { asm volatile("mov" size " %0,%1": :reg (val), \
54bb898558SAl Viro "m" (*(volatile type __force *)addr) barrier); }
55bb898558SAl Viro
56bb898558SAl Viro build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
57bb898558SAl Viro build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
58bb898558SAl Viro build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
59bb898558SAl Viro
60bb898558SAl Viro build_mmio_read(__readb, "b", unsigned char, "=q", )
61bb898558SAl Viro build_mmio_read(__readw, "w", unsigned short, "=r", )
62bb898558SAl Viro build_mmio_read(__readl, "l", unsigned int, "=r", )
63bb898558SAl Viro
64bb898558SAl Viro build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
65bb898558SAl Viro build_mmio_write(writew, "w", unsigned short, "r", :"memory")
66bb898558SAl Viro build_mmio_write(writel, "l", unsigned int, "r", :"memory")
67bb898558SAl Viro
68bb898558SAl Viro build_mmio_write(__writeb, "b", unsigned char, "q", )
69bb898558SAl Viro build_mmio_write(__writew, "w", unsigned short, "r", )
70bb898558SAl Viro build_mmio_write(__writel, "l", unsigned int, "r", )
71bb898558SAl Viro
7280b9ece1SAndy Shevchenko #define readb readb
7380b9ece1SAndy Shevchenko #define readw readw
7480b9ece1SAndy Shevchenko #define readl readl
75bb898558SAl Viro #define readb_relaxed(a) __readb(a)
76bb898558SAl Viro #define readw_relaxed(a) __readw(a)
77bb898558SAl Viro #define readl_relaxed(a) __readl(a)
78bb898558SAl Viro #define __raw_readb __readb
79bb898558SAl Viro #define __raw_readw __readw
80bb898558SAl Viro #define __raw_readl __readl
81bb898558SAl Viro
8280b9ece1SAndy Shevchenko #define writeb writeb
8380b9ece1SAndy Shevchenko #define writew writew
8480b9ece1SAndy Shevchenko #define writel writel
85cbc908efSWill Deacon #define writeb_relaxed(v, a) __writeb(v, a)
86cbc908efSWill Deacon #define writew_relaxed(v, a) __writew(v, a)
87cbc908efSWill Deacon #define writel_relaxed(v, a) __writel(v, a)
88bb898558SAl Viro #define __raw_writeb __writeb
89bb898558SAl Viro #define __raw_writew __writew
90bb898558SAl Viro #define __raw_writel __writel
91bb898558SAl Viro
92bb898558SAl Viro #ifdef CONFIG_X86_64
9393093d09SIngo Molnar
946469a0eeSAndy Shevchenko build_mmio_read(readq, "q", u64, "=r", :"memory")
956469a0eeSAndy Shevchenko build_mmio_read(__readq, "q", u64, "=r", )
966469a0eeSAndy Shevchenko build_mmio_write(writeq, "q", u64, "r", :"memory")
976469a0eeSAndy Shevchenko build_mmio_write(__writeq, "q", u64, "r", )
98bb898558SAl Viro
999683a64fSAndy Shevchenko #define readq_relaxed(a) __readq(a)
1009683a64fSAndy Shevchenko #define writeq_relaxed(v, a) __writeq(v, a)
10193093d09SIngo Molnar
1029683a64fSAndy Shevchenko #define __raw_readq __readq
1039683a64fSAndy Shevchenko #define __raw_writeq __writeq
10493093d09SIngo Molnar
105a0b1131eSIngo Molnar /* Let people know that we have them */
1062c5643b1SHitoshi Mitake #define readq readq
1072c5643b1SHitoshi Mitake #define writeq writeq
1082c5643b1SHitoshi Mitake
109dbee8a0aSRoland Dreier #endif
110dbee8a0aSRoland Dreier
111be62a320SCraig Bergstrom #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
112be62a320SCraig Bergstrom extern int valid_phys_addr_range(phys_addr_t addr, size_t size);
113be62a320SCraig Bergstrom extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
114be62a320SCraig Bergstrom
115976e8f67SJeremy Fitzhardinge /**
116976e8f67SJeremy Fitzhardinge * virt_to_phys - map virtual addresses to physical
117976e8f67SJeremy Fitzhardinge * @address: address to remap
118976e8f67SJeremy Fitzhardinge *
119976e8f67SJeremy Fitzhardinge * The returned physical address is the physical (CPU) mapping for
120976e8f67SJeremy Fitzhardinge * the memory address given. It is only valid to use this function on
121976e8f67SJeremy Fitzhardinge * addresses directly mapped or allocated via kmalloc.
122976e8f67SJeremy Fitzhardinge *
123976e8f67SJeremy Fitzhardinge * This function does not give bus mappings for DMA transfers. In
124976e8f67SJeremy Fitzhardinge * almost all conceivable cases a device driver should not be using
125976e8f67SJeremy Fitzhardinge * this function
126976e8f67SJeremy Fitzhardinge */
127976e8f67SJeremy Fitzhardinge
virt_to_phys(volatile void * address)128976e8f67SJeremy Fitzhardinge static inline phys_addr_t virt_to_phys(volatile void *address)
129976e8f67SJeremy Fitzhardinge {
130976e8f67SJeremy Fitzhardinge return __pa(address);
131976e8f67SJeremy Fitzhardinge }
13280b9ece1SAndy Shevchenko #define virt_to_phys virt_to_phys
133976e8f67SJeremy Fitzhardinge
134976e8f67SJeremy Fitzhardinge /**
135976e8f67SJeremy Fitzhardinge * phys_to_virt - map physical address to virtual
136976e8f67SJeremy Fitzhardinge * @address: address to remap
137976e8f67SJeremy Fitzhardinge *
138976e8f67SJeremy Fitzhardinge * The returned virtual address is a current CPU mapping for
139976e8f67SJeremy Fitzhardinge * the memory address given. It is only valid to use this function on
140976e8f67SJeremy Fitzhardinge * addresses that have a kernel mapping
141976e8f67SJeremy Fitzhardinge *
142976e8f67SJeremy Fitzhardinge * This function does not handle bus mappings for DMA transfers. In
143976e8f67SJeremy Fitzhardinge * almost all conceivable cases a device driver should not be using
144976e8f67SJeremy Fitzhardinge * this function
145976e8f67SJeremy Fitzhardinge */
146976e8f67SJeremy Fitzhardinge
phys_to_virt(phys_addr_t address)147976e8f67SJeremy Fitzhardinge static inline void *phys_to_virt(phys_addr_t address)
148976e8f67SJeremy Fitzhardinge {
149976e8f67SJeremy Fitzhardinge return __va(address);
150976e8f67SJeremy Fitzhardinge }
15180b9ece1SAndy Shevchenko #define phys_to_virt phys_to_virt
152976e8f67SJeremy Fitzhardinge
153976e8f67SJeremy Fitzhardinge /*
154976e8f67SJeremy Fitzhardinge * Change "struct page" to physical address.
155976e8f67SJeremy Fitzhardinge */
156976e8f67SJeremy Fitzhardinge #define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
157976e8f67SJeremy Fitzhardinge
158976e8f67SJeremy Fitzhardinge /*
159976e8f67SJeremy Fitzhardinge * ISA I/O bus memory addresses are 1:1 with the physical address.
160a7eb5189SH. Peter Anvin * However, we truncate the address to unsigned int to avoid undesirable
161d9f6e12fSIngo Molnar * promotions in legacy drivers.
162976e8f67SJeremy Fitzhardinge */
isa_virt_to_bus(volatile void * address)163a7eb5189SH. Peter Anvin static inline unsigned int isa_virt_to_bus(volatile void *address)
164a7eb5189SH. Peter Anvin {
165a7eb5189SH. Peter Anvin return (unsigned int)virt_to_phys(address);
166a7eb5189SH. Peter Anvin }
167976e8f67SJeremy Fitzhardinge #define isa_bus_to_virt phys_to_virt
168976e8f67SJeremy Fitzhardinge
169976e8f67SJeremy Fitzhardinge /*
170f5857666SJonathan Corbet * The default ioremap() behavior is non-cached; if you need something
171f5857666SJonathan Corbet * else, you probably want one of the following.
172f5857666SJonathan Corbet */
173f5857666SJonathan Corbet extern void __iomem *ioremap_uc(resource_size_t offset, unsigned long size);
174f5857666SJonathan Corbet #define ioremap_uc ioremap_uc
175f5857666SJonathan Corbet extern void __iomem *ioremap_cache(resource_size_t offset, unsigned long size);
17680b9ece1SAndy Shevchenko #define ioremap_cache ioremap_cache
177f5857666SJonathan Corbet extern void __iomem *ioremap_prot(resource_size_t offset, unsigned long size, unsigned long prot_val);
17880b9ece1SAndy Shevchenko #define ioremap_prot ioremap_prot
179c3a7a61cSLianbo Jiang extern void __iomem *ioremap_encrypted(resource_size_t phys_addr, unsigned long size);
180c3a7a61cSLianbo Jiang #define ioremap_encrypted ioremap_encrypted
181f5857666SJonathan Corbet
182133822c5SJeremy Fitzhardinge /**
183133822c5SJeremy Fitzhardinge * ioremap - map bus memory into CPU space
184133822c5SJeremy Fitzhardinge * @offset: bus address of the memory
185133822c5SJeremy Fitzhardinge * @size: size of the resource to map
186133822c5SJeremy Fitzhardinge *
187133822c5SJeremy Fitzhardinge * ioremap performs a platform specific sequence of operations to
188133822c5SJeremy Fitzhardinge * make bus memory CPU accessible via the readb/readw/readl/writeb/
189133822c5SJeremy Fitzhardinge * writew/writel functions and the other mmio helpers. The returned
190133822c5SJeremy Fitzhardinge * address is not guaranteed to be usable directly as a virtual
191133822c5SJeremy Fitzhardinge * address.
192133822c5SJeremy Fitzhardinge *
193133822c5SJeremy Fitzhardinge * If the area you are trying to map is a PCI BAR you should have a
194133822c5SJeremy Fitzhardinge * look at pci_iomap().
195133822c5SJeremy Fitzhardinge */
196c0d94aa5SChristoph Hellwig void __iomem *ioremap(resource_size_t offset, unsigned long size);
19780b9ece1SAndy Shevchenko #define ioremap ioremap
198133822c5SJeremy Fitzhardinge
199133822c5SJeremy Fitzhardinge extern void iounmap(volatile void __iomem *addr);
20080b9ece1SAndy Shevchenko #define iounmap iounmap
201133822c5SJeremy Fitzhardinge
2021c5b9069SBrian Gerst #ifdef __KERNEL__
2031c5b9069SBrian Gerst
204170d13caSLinus Torvalds void memcpy_fromio(void *, const volatile void __iomem *, size_t);
205170d13caSLinus Torvalds void memcpy_toio(volatile void __iomem *, const void *, size_t);
206170d13caSLinus Torvalds void memset_io(volatile void __iomem *, int, size_t);
207170d13caSLinus Torvalds
208170d13caSLinus Torvalds #define memcpy_fromio memcpy_fromio
209170d13caSLinus Torvalds #define memcpy_toio memcpy_toio
210170d13caSLinus Torvalds #define memset_io memset_io
211170d13caSLinus Torvalds
2121c5b9069SBrian Gerst /*
2131c5b9069SBrian Gerst * ISA space is 'always mapped' on a typical x86 system, no need to
2141c5b9069SBrian Gerst * explicitly ioremap() it. The fact that the ISA IO space is mapped
2151c5b9069SBrian Gerst * to PAGE_OFFSET is pure coincidence - it does not mean ISA values
2161c5b9069SBrian Gerst * are physical addresses. The following constant pointer can be
2171c5b9069SBrian Gerst * used as the IO-area pointer (it can be iounmapped as well, so the
2181c5b9069SBrian Gerst * analogy with PCI is quite large):
2191c5b9069SBrian Gerst */
2201c5b9069SBrian Gerst #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
2211c5b9069SBrian Gerst
2221c5b9069SBrian Gerst #endif /* __KERNEL__ */
2231c5b9069SBrian Gerst
2241c5b9069SBrian Gerst extern void native_io_delay(void);
2251c5b9069SBrian Gerst
2261c5b9069SBrian Gerst extern int io_delay_type;
2271c5b9069SBrian Gerst extern void io_delay_init(void);
2281c5b9069SBrian Gerst
2291c5b9069SBrian Gerst #if defined(CONFIG_PARAVIRT)
2301c5b9069SBrian Gerst #include <asm/paravirt.h>
2311c5b9069SBrian Gerst #else
2321c5b9069SBrian Gerst
slow_down_io(void)2331c5b9069SBrian Gerst static inline void slow_down_io(void)
2341c5b9069SBrian Gerst {
2351c5b9069SBrian Gerst native_io_delay();
2361c5b9069SBrian Gerst #ifdef REALLY_SLOW_IO
2371c5b9069SBrian Gerst native_io_delay();
2381c5b9069SBrian Gerst native_io_delay();
2391c5b9069SBrian Gerst native_io_delay();
2401c5b9069SBrian Gerst #endif
2411c5b9069SBrian Gerst }
2421c5b9069SBrian Gerst
2431c5b9069SBrian Gerst #endif
2441c5b9069SBrian Gerst
2451c5b9069SBrian Gerst #define BUILDIO(bwl, bw, type) \
24615104de1SKirill A. Shutemov static inline void out##bwl##_p(type value, u16 port) \
2471c5b9069SBrian Gerst { \
2481c5b9069SBrian Gerst out##bwl(value, port); \
2491c5b9069SBrian Gerst slow_down_io(); \
2501c5b9069SBrian Gerst } \
2511c5b9069SBrian Gerst \
25215104de1SKirill A. Shutemov static inline type in##bwl##_p(u16 port) \
2531c5b9069SBrian Gerst { \
25415104de1SKirill A. Shutemov type value = in##bwl(port); \
2551c5b9069SBrian Gerst slow_down_io(); \
2561c5b9069SBrian Gerst return value; \
2571c5b9069SBrian Gerst } \
2581c5b9069SBrian Gerst \
25915104de1SKirill A. Shutemov static inline void outs##bwl(u16 port, const void *addr, unsigned long count) \
2601c5b9069SBrian Gerst { \
2618260b982SKuppuswamy Sathyanarayanan if (cc_platform_has(CC_ATTR_GUEST_UNROLL_STRING_IO)) { \
26215104de1SKirill A. Shutemov type *value = (type *)addr; \
263606b21d4STom Lendacky while (count) { \
264606b21d4STom Lendacky out##bwl(*value, port); \
265606b21d4STom Lendacky value++; \
266606b21d4STom Lendacky count--; \
267606b21d4STom Lendacky } \
268606b21d4STom Lendacky } else { \
2691c5b9069SBrian Gerst asm volatile("rep; outs" #bwl \
270606b21d4STom Lendacky : "+S"(addr), "+c"(count) \
271606b21d4STom Lendacky : "d"(port) : "memory"); \
272606b21d4STom Lendacky } \
2731c5b9069SBrian Gerst } \
2741c5b9069SBrian Gerst \
27515104de1SKirill A. Shutemov static inline void ins##bwl(u16 port, void *addr, unsigned long count) \
2761c5b9069SBrian Gerst { \
2778260b982SKuppuswamy Sathyanarayanan if (cc_platform_has(CC_ATTR_GUEST_UNROLL_STRING_IO)) { \
27815104de1SKirill A. Shutemov type *value = (type *)addr; \
279606b21d4STom Lendacky while (count) { \
280606b21d4STom Lendacky *value = in##bwl(port); \
281606b21d4STom Lendacky value++; \
282606b21d4STom Lendacky count--; \
283606b21d4STom Lendacky } \
284606b21d4STom Lendacky } else { \
2851c5b9069SBrian Gerst asm volatile("rep; ins" #bwl \
286606b21d4STom Lendacky : "+D"(addr), "+c"(count) \
287606b21d4STom Lendacky : "d"(port) : "memory"); \
288606b21d4STom Lendacky } \
2891c5b9069SBrian Gerst }
2901c5b9069SBrian Gerst
29115104de1SKirill A. Shutemov BUILDIO(b, b, u8)
29215104de1SKirill A. Shutemov BUILDIO(w, w, u16)
29315104de1SKirill A. Shutemov BUILDIO(l, , u32)
294*1e8f93e1SKirill A. Shutemov #undef BUILDIO
295bb898558SAl Viro
29680b9ece1SAndy Shevchenko #define inb_p inb_p
29780b9ece1SAndy Shevchenko #define inw_p inw_p
29880b9ece1SAndy Shevchenko #define inl_p inl_p
29980b9ece1SAndy Shevchenko #define insb insb
30080b9ece1SAndy Shevchenko #define insw insw
30180b9ece1SAndy Shevchenko #define insl insl
30280b9ece1SAndy Shevchenko
30380b9ece1SAndy Shevchenko #define outb_p outb_p
30480b9ece1SAndy Shevchenko #define outw_p outw_p
30580b9ece1SAndy Shevchenko #define outl_p outl_p
30680b9ece1SAndy Shevchenko #define outsb outsb
30780b9ece1SAndy Shevchenko #define outsw outsw
30880b9ece1SAndy Shevchenko #define outsl outsl
30980b9ece1SAndy Shevchenko
3104707a341SThierry Reding extern void *xlate_dev_mem_ptr(phys_addr_t phys);
3114707a341SThierry Reding extern void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
312bb898558SAl Viro
31380b9ece1SAndy Shevchenko #define xlate_dev_mem_ptr xlate_dev_mem_ptr
31480b9ece1SAndy Shevchenko #define unxlate_dev_mem_ptr unxlate_dev_mem_ptr
31580b9ece1SAndy Shevchenko
316bb898558SAl Viro extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
317b14097bdSJuergen Gross enum page_cache_mode pcm);
318d639bab8Svenkatesh.pallipadi@intel.com extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size);
31980b9ece1SAndy Shevchenko #define ioremap_wc ioremap_wc
320d838270eSToshi Kani extern void __iomem *ioremap_wt(resource_size_t offset, unsigned long size);
32180b9ece1SAndy Shevchenko #define ioremap_wt ioremap_wt
322bb898558SAl Viro
323fef5ba79SJeremy Fitzhardinge extern bool is_early_ioremap_ptep(pte_t *ptep);
324bb898558SAl Viro
325a448720cSJeremy Fitzhardinge #define IO_SPACE_LIMIT 0xffff
326bb898558SAl Viro
32731952011SAndy Shevchenko #include <asm-generic/io.h>
32831952011SAndy Shevchenko #undef PCI_IOBASE
32931952011SAndy Shevchenko
330d0d98eedSAndy Lutomirski #ifdef CONFIG_MTRR
3317d010fdfSLuis R. Rodriguez extern int __must_check arch_phys_wc_index(int handle);
3327d010fdfSLuis R. Rodriguez #define arch_phys_wc_index arch_phys_wc_index
3337d010fdfSLuis R. Rodriguez
334d0d98eedSAndy Lutomirski extern int __must_check arch_phys_wc_add(unsigned long base,
335d0d98eedSAndy Lutomirski unsigned long size);
336d0d98eedSAndy Lutomirski extern void arch_phys_wc_del(int handle);
337d0d98eedSAndy Lutomirski #define arch_phys_wc_add arch_phys_wc_add
338d0d98eedSAndy Lutomirski #endif
339d0d98eedSAndy Lutomirski
3408ef42276SDave Airlie #ifdef CONFIG_X86_PAT
3418ef42276SDave Airlie extern int arch_io_reserve_memtype_wc(resource_size_t start, resource_size_t size);
3428ef42276SDave Airlie extern void arch_io_free_memtype_wc(resource_size_t start, resource_size_t size);
3438ef42276SDave Airlie #define arch_io_reserve_memtype_wc arch_io_reserve_memtype_wc
3448ef42276SDave Airlie #endif
3458ef42276SDave Airlie
346402fe0cbSTom Lendacky #ifdef CONFIG_AMD_MEM_ENCRYPT
3478f716c9bSTom Lendacky extern bool arch_memremap_can_ram_remap(resource_size_t offset,
3488f716c9bSTom Lendacky unsigned long size,
3498f716c9bSTom Lendacky unsigned long flags);
3508f716c9bSTom Lendacky #define arch_memremap_can_ram_remap arch_memremap_can_ram_remap
3518f716c9bSTom Lendacky
3528458bf94STom Lendacky extern bool phys_mem_access_encrypted(unsigned long phys_addr,
3538458bf94STom Lendacky unsigned long size);
354402fe0cbSTom Lendacky #else
phys_mem_access_encrypted(unsigned long phys_addr,unsigned long size)355402fe0cbSTom Lendacky static inline bool phys_mem_access_encrypted(unsigned long phys_addr,
356402fe0cbSTom Lendacky unsigned long size)
357402fe0cbSTom Lendacky {
358402fe0cbSTom Lendacky return true;
359402fe0cbSTom Lendacky }
360402fe0cbSTom Lendacky #endif
3618458bf94STom Lendacky
362232bb01bSDave Jiang /**
363232bb01bSDave Jiang * iosubmit_cmds512 - copy data to single MMIO location, in 512-bit units
3640888e103SDave Jiang * @dst: destination, in MMIO space (must be 512-bit aligned)
365232bb01bSDave Jiang * @src: source
366232bb01bSDave Jiang * @count: number of 512 bits quantities to submit
367232bb01bSDave Jiang *
368232bb01bSDave Jiang * Submit data from kernel space to MMIO space, in units of 512 bits at a
369232bb01bSDave Jiang * time. Order of access is not guaranteed, nor is a memory barrier
370232bb01bSDave Jiang * performed afterwards.
371232bb01bSDave Jiang *
372232bb01bSDave Jiang * Warning: Do not use this helper unless your driver has checked that the CPU
373232bb01bSDave Jiang * instruction is supported on the platform.
374232bb01bSDave Jiang */
iosubmit_cmds512(void __iomem * dst,const void * src,size_t count)3750888e103SDave Jiang static inline void iosubmit_cmds512(void __iomem *dst, const void *src,
376232bb01bSDave Jiang size_t count)
377232bb01bSDave Jiang {
378232bb01bSDave Jiang const u8 *from = src;
379232bb01bSDave Jiang const u8 *end = from + count * 64;
380232bb01bSDave Jiang
381232bb01bSDave Jiang while (from < end) {
3820888e103SDave Jiang movdir64b(dst, from);
383232bb01bSDave Jiang from += 64;
384232bb01bSDave Jiang }
385232bb01bSDave Jiang }
386232bb01bSDave Jiang
3871965aae3SH. Peter Anvin #endif /* _ASM_X86_IO_H */
388