1216174Snwhitehorn#- 2279252Snwhitehorn# Copyright (c) 2010,2015 Nathan Whitehorn 3216174Snwhitehorn# All rights reserved. 4216174Snwhitehorn# 5216174Snwhitehorn# Redistribution and use in source and binary forms, with or without 6216174Snwhitehorn# modification, are permitted provided that the following conditions 7216174Snwhitehorn# are met: 8216174Snwhitehorn# 1. Redistributions of source code must retain the above copyright 9216174Snwhitehorn# notice, this list of conditions and the following disclaimer. 10216174Snwhitehorn# 2. Redistributions in binary form must reproduce the above copyright 11216174Snwhitehorn# notice, this list of conditions and the following disclaimer in the 12216174Snwhitehorn# documentation and/or other materials provided with the distribution. 13216174Snwhitehorn# 14216174Snwhitehorn# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15216174Snwhitehorn# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16216174Snwhitehorn# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17216174Snwhitehorn# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18216174Snwhitehorn# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19216174Snwhitehorn# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20216174Snwhitehorn# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21216174Snwhitehorn# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22216174Snwhitehorn# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23216174Snwhitehorn# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24216174Snwhitehorn# SUCH DAMAGE. 25216174Snwhitehorn# 26216174Snwhitehorn# $FreeBSD: releng/11.0/sys/powerpc/aim/moea64_if.m 279252 2015-02-24 21:37:20Z nwhitehorn $ 27216174Snwhitehorn# 28216174Snwhitehorn 29216174Snwhitehorn 30216174Snwhitehorn#include <sys/param.h> 31216174Snwhitehorn#include <sys/lock.h> 32216174Snwhitehorn#include <sys/mutex.h> 33216174Snwhitehorn#include <sys/systm.h> 34216174Snwhitehorn 35216174Snwhitehorn#include <vm/vm.h> 36216174Snwhitehorn#include <vm/vm_page.h> 37216174Snwhitehorn 38216174Snwhitehorn#include <machine/mmuvar.h> 39216174Snwhitehorn 40216174Snwhitehorn/** 41216174Snwhitehorn * MOEA64 kobj methods for 64-bit Book-S page table 42216174Snwhitehorn * manipulation routines used, for example, by hypervisors. 43216174Snwhitehorn */ 44216174Snwhitehorn 45216174SnwhitehornINTERFACE moea64; 46216174Snwhitehorn 47279252SnwhitehornCODE { 48279252Snwhitehorn static moea64_pte_replace_t moea64_pte_replace_default; 49216174Snwhitehorn 50279252Snwhitehorn static int64_t moea64_pte_replace_default(mmu_t mmu, 51279252Snwhitehorn struct pvo_entry *pvo, int flags) 52279252Snwhitehorn { 53279252Snwhitehorn int64_t refchg; 54279252Snwhitehorn 55279252Snwhitehorn refchg = MOEA64_PTE_UNSET(mmu, pvo); 56279252Snwhitehorn MOEA64_PTE_INSERT(mmu, pvo); 57279252Snwhitehorn 58279252Snwhitehorn return (refchg); 59279252Snwhitehorn } 60279252Snwhitehorn} 61279252Snwhitehorn 62216174Snwhitehorn/** 63279252Snwhitehorn * Return ref/changed bits from PTE referenced by _pvo if _pvo is currently in 64279252Snwhitehorn * the page table. Returns -1 if _pvo not currently present in the page table. 65216174Snwhitehorn */ 66279252SnwhitehornMETHOD int64_t pte_synch { 67216174Snwhitehorn mmu_t _mmu; 68279252Snwhitehorn struct pvo_entry *_pvo; 69216174Snwhitehorn}; 70216174Snwhitehorn 71216174Snwhitehorn/** 72216174Snwhitehorn * Clear bits ptebit (a mask) from the low word of the PTE referenced by 73279252Snwhitehorn * _pvo. Return previous values of ref/changed bits or -1 if _pvo is not 74279252Snwhitehorn * currently in the page table. 75216174Snwhitehorn */ 76279252SnwhitehornMETHOD int64_t pte_clear { 77216174Snwhitehorn mmu_t _mmu; 78279252Snwhitehorn struct pvo_entry *_pvo; 79216174Snwhitehorn uint64_t _ptebit; 80216174Snwhitehorn}; 81216174Snwhitehorn 82216174Snwhitehorn/** 83279252Snwhitehorn * Invalidate the PTE referenced by _pvo, returning its ref/changed bits. 84279252Snwhitehorn * Returns -1 if PTE not currently present in page table. 85216174Snwhitehorn */ 86279252SnwhitehornMETHOD int64_t pte_unset { 87216174Snwhitehorn mmu_t _mmu; 88279252Snwhitehorn struct pvo_entry *_pvo; 89216174Snwhitehorn}; 90216174Snwhitehorn 91216174Snwhitehorn/** 92279252Snwhitehorn * Update the reference PTE to correspond to the contents of _pvo. Has the 93279252Snwhitehorn * same ref/changed semantics as pte_unset() (and should clear R/C bits). May 94279252Snwhitehorn * change the PVO's location in the page table or return with it unmapped if 95279252Snwhitehorn * PVO_WIRED is not set. By default, does unset() followed by insert(). 96279252Snwhitehorn * 97279252Snwhitehorn * _flags is a bitmask describing what level of page invalidation should occur: 98279252Snwhitehorn * 0 means no invalidation is required 99279252Snwhitehorn * MOEA64_PTE_PROT_UPDATE signifies that the page protection bits are changing 100279252Snwhitehorn * MOEA64_PTE_INVALIDATE requires an invalidation of the same strength as 101279252Snwhitehorn * pte_unset() followed by pte_insert() 102216174Snwhitehorn */ 103279252SnwhitehornMETHOD int64_t pte_replace { 104216174Snwhitehorn mmu_t _mmu; 105279252Snwhitehorn struct pvo_entry *_pvo; 106279252Snwhitehorn int _flags; 107279252Snwhitehorn} DEFAULT moea64_pte_replace_default; 108216174Snwhitehorn 109216174Snwhitehorn/** 110279252Snwhitehorn * Insert a PTE corresponding to _pvo into the page table, returning any errors 111279252Snwhitehorn * encountered and (optionally) setting the PVO slot value to some 112279252Snwhitehorn * representation of where the entry was placed. 113279252Snwhitehorn * 114279252Snwhitehorn * Must not replace PTEs marked LPTE_WIRED. If an existing valid PTE is spilled, 115279252Snwhitehorn * must synchronize ref/changed bits as in pte_unset(). 116216174Snwhitehorn */ 117216174SnwhitehornMETHOD int pte_insert { 118216174Snwhitehorn mmu_t _mmu; 119279252Snwhitehorn struct pvo_entry *_pvo; 120216174Snwhitehorn}; 121216174Snwhitehorn 122