18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Ultravisor definitions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2019, IBM Corporation. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_ULTRAVISOR_H 98c2ecf20Sopenharmony_ci#define _ASM_POWERPC_ULTRAVISOR_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/asm-prototypes.h> 128c2ecf20Sopenharmony_ci#include <asm/ultravisor-api.h> 138c2ecf20Sopenharmony_ci#include <asm/firmware.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciint early_init_dt_scan_ultravisor(unsigned long node, const char *uname, 168c2ecf20Sopenharmony_ci int depth, void *data); 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* 198c2ecf20Sopenharmony_ci * In ultravisor enabled systems, PTCR becomes ultravisor privileged only for 208c2ecf20Sopenharmony_ci * writing and an attempt to write to it will cause a Hypervisor Emulation 218c2ecf20Sopenharmony_ci * Assistance interrupt. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_cistatic inline void set_ptcr_when_no_uv(u64 val) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci if (!firmware_has_feature(FW_FEATURE_ULTRAVISOR)) 268c2ecf20Sopenharmony_ci mtspr(SPRN_PTCR, val); 278c2ecf20Sopenharmony_ci} 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistatic inline int uv_register_pate(u64 lpid, u64 dw0, u64 dw1) 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci return ucall_norets(UV_WRITE_PATE, lpid, dw0, dw1); 328c2ecf20Sopenharmony_ci} 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic inline int uv_share_page(u64 pfn, u64 npages) 358c2ecf20Sopenharmony_ci{ 368c2ecf20Sopenharmony_ci return ucall_norets(UV_SHARE_PAGE, pfn, npages); 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistatic inline int uv_unshare_page(u64 pfn, u64 npages) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci return ucall_norets(UV_UNSHARE_PAGE, pfn, npages); 428c2ecf20Sopenharmony_ci} 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic inline int uv_unshare_all_pages(void) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci return ucall_norets(UV_UNSHARE_ALL_PAGES); 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic inline int uv_page_in(u64 lpid, u64 src_ra, u64 dst_gpa, u64 flags, 508c2ecf20Sopenharmony_ci u64 page_shift) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci return ucall_norets(UV_PAGE_IN, lpid, src_ra, dst_gpa, flags, 538c2ecf20Sopenharmony_ci page_shift); 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistatic inline int uv_page_out(u64 lpid, u64 dst_ra, u64 src_gpa, u64 flags, 578c2ecf20Sopenharmony_ci u64 page_shift) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci return ucall_norets(UV_PAGE_OUT, lpid, dst_ra, src_gpa, flags, 608c2ecf20Sopenharmony_ci page_shift); 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cistatic inline int uv_register_mem_slot(u64 lpid, u64 start_gpa, u64 size, 648c2ecf20Sopenharmony_ci u64 flags, u64 slotid) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci return ucall_norets(UV_REGISTER_MEM_SLOT, lpid, start_gpa, 678c2ecf20Sopenharmony_ci size, flags, slotid); 688c2ecf20Sopenharmony_ci} 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline int uv_unregister_mem_slot(u64 lpid, u64 slotid) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci return ucall_norets(UV_UNREGISTER_MEM_SLOT, lpid, slotid); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cistatic inline int uv_page_inval(u64 lpid, u64 gpa, u64 page_shift) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci return ucall_norets(UV_PAGE_INVAL, lpid, gpa, page_shift); 788c2ecf20Sopenharmony_ci} 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistatic inline int uv_svm_terminate(u64 lpid) 818c2ecf20Sopenharmony_ci{ 828c2ecf20Sopenharmony_ci return ucall_norets(UV_SVM_TERMINATE, lpid); 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_ULTRAVISOR_H */ 86