Browse Source
Declare probe methods in "accel/tcg/probe.h" to emphasize they are specific to TCG accelerator. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Mark Cave-Ayland <mark.caveayland@nutanix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20250424202412.91612-13-philmd@linaro.org>pull/291/head
committed by
Richard Henderson
24 changed files with 128 additions and 100 deletions
@ -0,0 +1,106 @@ |
|||
/*
|
|||
* Probe guest virtual addresses for access permissions. |
|||
* |
|||
* Copyright (c) 2003 Fabrice Bellard |
|||
* SPDX-License-Identifier: LGPL-2.1-or-later |
|||
*/ |
|||
#ifndef ACCEL_TCG_PROBE_H |
|||
#define ACCEL_TCG_PROBE_H |
|||
|
|||
#include "exec/mmu-access-type.h" |
|||
#include "exec/vaddr.h" |
|||
|
|||
/**
|
|||
* probe_access: |
|||
* @env: CPUArchState |
|||
* @addr: guest virtual address to look up |
|||
* @size: size of the access |
|||
* @access_type: read, write or execute permission |
|||
* @mmu_idx: MMU index to use for lookup |
|||
* @retaddr: return address for unwinding |
|||
* |
|||
* Look up the guest virtual address @addr. Raise an exception if the |
|||
* page does not satisfy @access_type. Raise an exception if the |
|||
* access (@addr, @size) hits a watchpoint. For writes, mark a clean |
|||
* page as dirty. |
|||
* |
|||
* Finally, return the host address for a page that is backed by RAM, |
|||
* or NULL if the page requires I/O. |
|||
*/ |
|||
void *probe_access(CPUArchState *env, vaddr addr, int size, |
|||
MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); |
|||
|
|||
static inline void *probe_write(CPUArchState *env, vaddr addr, int size, |
|||
int mmu_idx, uintptr_t retaddr) |
|||
{ |
|||
return probe_access(env, addr, size, MMU_DATA_STORE, mmu_idx, retaddr); |
|||
} |
|||
|
|||
static inline void *probe_read(CPUArchState *env, vaddr addr, int size, |
|||
int mmu_idx, uintptr_t retaddr) |
|||
{ |
|||
return probe_access(env, addr, size, MMU_DATA_LOAD, mmu_idx, retaddr); |
|||
} |
|||
|
|||
/**
|
|||
* probe_access_flags: |
|||
* @env: CPUArchState |
|||
* @addr: guest virtual address to look up |
|||
* @size: size of the access |
|||
* @access_type: read, write or execute permission |
|||
* @mmu_idx: MMU index to use for lookup |
|||
* @nonfault: suppress the fault |
|||
* @phost: return value for host address |
|||
* @retaddr: return address for unwinding |
|||
* |
|||
* Similar to probe_access, loosely returning the TLB_FLAGS_MASK for |
|||
* the page, and storing the host address for RAM in @phost. |
|||
* |
|||
* If @nonfault is set, do not raise an exception but return TLB_INVALID_MASK. |
|||
* Do not handle watchpoints, but include TLB_WATCHPOINT in the returned flags. |
|||
* Do handle clean pages, so exclude TLB_NOTDIRY from the returned flags. |
|||
* For simplicity, all "mmio-like" flags are folded to TLB_MMIO. |
|||
*/ |
|||
int probe_access_flags(CPUArchState *env, vaddr addr, int size, |
|||
MMUAccessType access_type, int mmu_idx, |
|||
bool nonfault, void **phost, uintptr_t retaddr); |
|||
|
|||
#ifndef CONFIG_USER_ONLY |
|||
|
|||
/**
|
|||
* probe_access_full: |
|||
* Like probe_access_flags, except also return into @pfull. |
|||
* |
|||
* The CPUTLBEntryFull structure returned via @pfull is transient |
|||
* and must be consumed or copied immediately, before any further |
|||
* access or changes to TLB @mmu_idx. |
|||
* |
|||
* This function will not fault if @nonfault is set, but will |
|||
* return TLB_INVALID_MASK if the page is not mapped, or is not |
|||
* accessible with @access_type. |
|||
* |
|||
* This function will return TLB_MMIO in order to force the access |
|||
* to be handled out-of-line if plugins wish to instrument the access. |
|||
*/ |
|||
int probe_access_full(CPUArchState *env, vaddr addr, int size, |
|||
MMUAccessType access_type, int mmu_idx, |
|||
bool nonfault, void **phost, |
|||
CPUTLBEntryFull **pfull, uintptr_t retaddr); |
|||
|
|||
/**
|
|||
* probe_access_full_mmu: |
|||
* Like probe_access_full, except: |
|||
* |
|||
* This function is intended to be used for page table accesses by |
|||
* the target mmu itself. Since such page walking happens while |
|||
* handling another potential mmu fault, this function never raises |
|||
* exceptions (akin to @nonfault true for probe_access_full). |
|||
* Likewise this function does not trigger plugin instrumentation. |
|||
*/ |
|||
int probe_access_full_mmu(CPUArchState *env, vaddr addr, int size, |
|||
MMUAccessType access_type, int mmu_idx, |
|||
void **phost, CPUTLBEntryFull **pfull); |
|||
|
|||
#endif /* !CONFIG_USER_ONLY */ |
|||
|
|||
#endif |
|||
Loading…
Reference in new issue