Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_X86_IOBITMAP_H
0003 #define _ASM_X86_IOBITMAP_H
0004 
0005 #include <linux/refcount.h>
0006 #include <asm/processor.h>
0007 
0008 struct io_bitmap {
0009     u64     sequence;
0010     refcount_t  refcnt;
0011     /* The maximum number of bytes to copy so all zero bits are covered */
0012     unsigned int    max;
0013     unsigned long   bitmap[IO_BITMAP_LONGS];
0014 };
0015 
0016 struct task_struct;
0017 
0018 #ifdef CONFIG_X86_IOPL_IOPERM
0019 void io_bitmap_share(struct task_struct *tsk);
0020 void io_bitmap_exit(struct task_struct *tsk);
0021 
0022 static inline void native_tss_invalidate_io_bitmap(void)
0023 {
0024     /*
0025      * Invalidate the I/O bitmap by moving io_bitmap_base outside the
0026      * TSS limit so any subsequent I/O access from user space will
0027      * trigger a #GP.
0028      *
0029      * This is correct even when VMEXIT rewrites the TSS limit
0030      * to 0x67 as the only requirement is that the base points
0031      * outside the limit.
0032      */
0033     this_cpu_write(cpu_tss_rw.x86_tss.io_bitmap_base,
0034                IO_BITMAP_OFFSET_INVALID);
0035 }
0036 
0037 void native_tss_update_io_bitmap(void);
0038 
0039 #ifdef CONFIG_PARAVIRT_XXL
0040 #include <asm/paravirt.h>
0041 #else
0042 #define tss_update_io_bitmap native_tss_update_io_bitmap
0043 #define tss_invalidate_io_bitmap native_tss_invalidate_io_bitmap
0044 #endif
0045 
0046 #else
0047 static inline void io_bitmap_share(struct task_struct *tsk) { }
0048 static inline void io_bitmap_exit(struct task_struct *tsk) { }
0049 static inline void tss_update_io_bitmap(void) { }
0050 #endif
0051 
0052 #endif