Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Ultravisor definitions
0004  *
0005  * Copyright 2019, IBM Corporation.
0006  *
0007  */
0008 #ifndef _ASM_POWERPC_ULTRAVISOR_H
0009 #define _ASM_POWERPC_ULTRAVISOR_H
0010 
0011 #include <asm/asm-prototypes.h>
0012 #include <asm/ultravisor-api.h>
0013 #include <asm/firmware.h>
0014 
0015 int early_init_dt_scan_ultravisor(unsigned long node, const char *uname,
0016                   int depth, void *data);
0017 
0018 /*
0019  * In ultravisor enabled systems, PTCR becomes ultravisor privileged only for
0020  * writing and an attempt to write to it will cause a Hypervisor Emulation
0021  * Assistance interrupt.
0022  */
0023 static inline void set_ptcr_when_no_uv(u64 val)
0024 {
0025     if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR))
0026         mtspr(SPRN_PTCR, val);
0027 }
0028 
0029 static inline int uv_register_pate(u64 lpid, u64 dw0, u64 dw1)
0030 {
0031     return ucall_norets(UV_WRITE_PATE, lpid, dw0, dw1);
0032 }
0033 
0034 static inline int uv_share_page(u64 pfn, u64 npages)
0035 {
0036     return ucall_norets(UV_SHARE_PAGE, pfn, npages);
0037 }
0038 
0039 static inline int uv_unshare_page(u64 pfn, u64 npages)
0040 {
0041     return ucall_norets(UV_UNSHARE_PAGE, pfn, npages);
0042 }
0043 
0044 static inline int uv_unshare_all_pages(void)
0045 {
0046     return ucall_norets(UV_UNSHARE_ALL_PAGES);
0047 }
0048 
0049 static inline int uv_page_in(u64 lpid, u64 src_ra, u64 dst_gpa, u64 flags,
0050                  u64 page_shift)
0051 {
0052     return ucall_norets(UV_PAGE_IN, lpid, src_ra, dst_gpa, flags,
0053                 page_shift);
0054 }
0055 
0056 static inline int uv_page_out(u64 lpid, u64 dst_ra, u64 src_gpa, u64 flags,
0057                   u64 page_shift)
0058 {
0059     return ucall_norets(UV_PAGE_OUT, lpid, dst_ra, src_gpa, flags,
0060                 page_shift);
0061 }
0062 
0063 static inline int uv_register_mem_slot(u64 lpid, u64 start_gpa, u64 size,
0064                        u64 flags, u64 slotid)
0065 {
0066     return ucall_norets(UV_REGISTER_MEM_SLOT, lpid, start_gpa,
0067                 size, flags, slotid);
0068 }
0069 
0070 static inline int uv_unregister_mem_slot(u64 lpid, u64 slotid)
0071 {
0072     return ucall_norets(UV_UNREGISTER_MEM_SLOT, lpid, slotid);
0073 }
0074 
0075 static inline int uv_page_inval(u64 lpid, u64 gpa, u64 page_shift)
0076 {
0077     return ucall_norets(UV_PAGE_INVAL, lpid, gpa, page_shift);
0078 }
0079 
0080 static inline int uv_svm_terminate(u64 lpid)
0081 {
0082     return ucall_norets(UV_SVM_TERMINATE, lpid);
0083 }
0084 
0085 #endif  /* _ASM_POWERPC_ULTRAVISOR_H */