sup.h revision 6f6aa1fdbf42c81b40258343b9ca3b380db4a47a
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @file
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * SUP - Support Library. (HDrv)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/*
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Copyright (C) 2006-2015 Oracle Corporation
b3eb676cebf5407921b8f535095ca7655edb9db3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * available from http://www.virtualbox.org. This file is free software;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * you can redistribute it and/or modify it under the terms of the GNU
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * General Public License (GPL) as published by the Free Software
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The contents of this file may alternatively be used under the terms
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * of the Common Development and Distribution License Version 1.0
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * VirtualBox OSE distribution, in which case the provisions of the
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * CDDL are applicable instead of those of the GPL.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * You may elect to license modified versions of this file under the
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * terms and conditions of either the GPL or the CDDL or both.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#ifndef ___VBox_sup_h
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define ___VBox_sup_h
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#include <VBox/cdefs.h>
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#include <VBox/types.h>
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#include <VBox/err.h>
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#include <iprt/assert.h>
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync#include <iprt/stdarg.h>
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#include <iprt/cpuset.h>
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# include <iprt/asm-amd64-x86.h>
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncRT_C_DECLS_BEGIN
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncstruct VTGOBJHDR;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncstruct VTGPROBELOC;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @defgroup grp_sup The Support Library API
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Physical page descriptor.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#pragma pack(4) /* space is more important. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPPAGE
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Physical memory address. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTHCPHYS Phys;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Reserved entry for internal use by the caller. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTHCUINTPTR uReserved;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPPAGE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#pragma pack()
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a page descriptor. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPPAGE *PSUPPAGE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a const page descriptor. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef const SUPPAGE *PCSUPPAGE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The paging mode.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks Users are making assumptions about the order here!
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef enum SUPPAGINGMODE
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The usual invalid entry.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is returned by SUPR3GetPagingMode() */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_INVALID = 0,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Normal 32-bit paging, no global pages */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_32_BIT,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Normal 32-bit paging with global pages. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_32_BIT_GLOBAL,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** PAE mode, no global pages, no NX. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_PAE,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** PAE mode with global pages. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_PAE_GLOBAL,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** PAE mode with NX, no global pages. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_PAE_NX,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** PAE mode with global pages and NX. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_PAE_GLOBAL_NX,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** AMD64 mode, no global pages. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_AMD64,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** AMD64 mode with global pages, no NX. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_AMD64_GLOBAL,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** AMD64 mode with NX, no global pages. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPPAGINGMODE_AMD64_NX,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** AMD64 mode with global pages and NX. */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync SUPPAGINGMODE_AMD64_GLOBAL_NX
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPPAGINGMODE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @name Flags returned by SUPR0GetKernelFeatures().
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** GDT is read-only. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPKERNELFEATURES_GDT_READ_ONLY RT_BIT(0)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @} */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Usermode probe context information.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVTRACERUSRCTX
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The probe ID from the VTG location record. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t idProbe;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** 32 if X86, 64 if AMD64. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint8_t cBits;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Reserved padding. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint8_t abReserved[3];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Data which format is dictated by the cBits member. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync union
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** X86 context info. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync struct
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t uVtgProbeLoc; /**< Location record address. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t aArgs[20]; /**< Raw arguments. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t eip;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t eflags;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t eax;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t ecx;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t edx;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t ebx;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t esp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t ebp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t esi;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t edi;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t cs;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t ss;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t ds;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t es;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t fs;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t gs;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync } X86;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** AMD64 context info. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync struct
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t uVtgProbeLoc; /**< Location record address. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t aArgs[10]; /**< Raw arguments. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rip;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rflags;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rax;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rcx;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rdx;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rbx;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rsp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rbp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rsi;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t rdi;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r8;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r9;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r10;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r11;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r12;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r13;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r14;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t r15;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync } Amd64;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync } u;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVTRACERUSRCTX;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to the usermode probe context information. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPDRVTRACERUSRCTX *PSUPDRVTRACERUSRCTX;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to the const usermode probe context information. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPDRVTRACERUSRCTX const *PCSUPDRVTRACERUSRCTX;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The result of a modification operation (SUPMSRPROBEROP_MODIFY or
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * SUPMSRPROBEROP_MODIFY_FASTER).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPMSRPROBERMODIFYRESULT
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The MSR value prior to the modifications. Valid if fBeforeGp is false */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t uBefore;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The value that was written. Valid if fBeforeGp is false */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t uWritten;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The MSR value after the modifications. Valid if AfterGp is false. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t uAfter;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Set if we GPed reading the MSR before the modification. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fBeforeGp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Set if we GPed while trying to write the modified value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is set when fBeforeGp is true. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fModifyGp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Set if we GPed while trying to read the MSR after the modification.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is set when fBeforeGp is true. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fAfterGp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Set if we GPed while trying to restore the MSR after the modification.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is set when fBeforeGp is true. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fRestoreGp;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Structure size alignment padding. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool afReserved[4];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPMSRPROBERMODIFYRESULT, *PSUPMSRPROBERMODIFYRESULT;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The CPU state.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef enum SUPGIPCPUSTATE
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Invalid CPU state / unused CPU entry. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPCPUSTATE_INVALID = 0,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The CPU is not present. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPCPUSTATE_ABSENT,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The CPU is offline. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPCPUSTATE_OFFLINE,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The CPU is online. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPCPUSTATE_ONLINE,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Force 32-bit enum type. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPCPUSTATE_32_BIT_HACK = 0x7fffffff
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPGIPCPUSTATE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Per CPU data.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPGIPCPU
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Update transaction number.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This number is incremented at the start and end of each update. It follows
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * thusly that odd numbers indicates update in progress, while even numbers
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * indicate stable data. Use this to make sure that the data items you fetch
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * are consistent. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t u32TransactionId;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The interval in TSC ticks between two NanoTS updates.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is the average interval over the last 2, 4 or 8 updates + a little slack.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The slack makes the time go a tiny tiny bit slower and extends the interval enough
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * to avoid ending up with too many 1ns increments. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t u32UpdateIntervalTSC;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Current nanosecond timestamp. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint64_t u64NanoTS;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The TSC at the time of u64NanoTS. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint64_t u64TSC;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Current CPU Frequency. */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync volatile uint64_t u64CpuHz;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The TSC delta with reference to the master TSC. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile int64_t i64TSCDelta;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Number of errors during updating.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Typical errors are under/overflows. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t cErrors;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Index of the head item in au32TSCHistory. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t iTSCHistoryHead;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Array of recent TSC interval deltas.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The most recent item is at index iTSCHistoryHead.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This history is used to calculate u32UpdateIntervalTSC.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t au32TSCHistory[8];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The interval between the last two NanoTS updates. (experiment for now) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t u32PrevUpdateIntervalNS;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Reserved for future per processor data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t au32Reserved0[5];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The TSC value read while doing TSC delta measurements across CPUs. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint64_t u64TSCSample;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Reserved for future per processor data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t au32Reserved1[1];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** @todo Add topology/NUMA info. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The CPU state. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPCPUSTATE volatile enmState;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The host CPU ID of this CPU (the SUPGIPCPU is indexed by APIC ID). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTCPUID idCpu;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The CPU set index of this CPU. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync int16_t iCpuSet;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The APIC ID of this CPU. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t idApic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPGIPCPU;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncAssertCompileSize(RTCPUID, 4);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncAssertCompileSize(SUPGIPCPU, 128);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncAssertCompileMemberAlignment(SUPGIPCPU, u64NanoTS, 8);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncAssertCompileMemberAlignment(SUPGIPCPU, u64TSC, 8);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to per cpu data.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPGIPCPU *PSUPGIPCPU;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Global Information Page.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This page contains useful information and can be mapped into any
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * process or VM. It can be accessed thru the g_pSUPGlobalInfoPage
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * pointer when a session is open.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsynctypedef struct SUPGLOBALINFOPAGE
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Magic (SUPGLOBALINFOPAGE_MAGIC). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t u32Magic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The GIP version. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t u32Version;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The GIP update mode, see SUPGIPMODE. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t u32Mode;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The number of entries in the CPU table.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * (This can work as RTMpGetArraySize().) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t cCpus;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The size of the GIP in pages. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t cPages;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The update frequency of the of the NanoTS. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t u32UpdateHz;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The update interval in nanoseconds. (10^9 / u32UpdateHz) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint32_t u32UpdateIntervalNS;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The timestamp of the last time we update the update frequency. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint64_t u64NanoTSLastUpdateHz;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The TSC frequency of the system. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t u64CpuHz;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The set of online CPUs. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTCPUSET OnlineCpuSet;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The set of present CPUs. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTCPUSET PresentCpuSet;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The set of possible CPUs. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTCPUSET PossibleCpuSet;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The number of CPUs that are online. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint16_t cOnlineCpus;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The number of CPUs present in the system. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync volatile uint16_t cPresentCpus;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The highest number of CPUs possible. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t cPossibleCpus;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t u16Padding0;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The max CPU ID (RTMpGetMaxCpuId). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTCPUID idCpuMax;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Whether the host OS has already normalized the hardware TSC deltas across
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * CPUs. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fOsTscDeltasInSync;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Whether the TSC deltas are small enough to not bother applying. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fTscDeltasRoughlyInSync;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint8_t au8Padding0[2];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Padding / reserved space for future data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t au32Padding1[26];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Table indexed by the CPU APIC ID to get the CPU table index. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t aiCpuFromApicId[256];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** CPU set index to CPU table index. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t aiCpuFromCpuSetIdx[RTCPUSET_MAX_CPUS];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Array of per-cpu data.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is index by ApicId via the aiCpuFromApicId table.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The clock and frequency information is updated for all CPUs if @c u32Mode
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * is SUPGIPMODE_ASYNC_TSC. If @c u32Mode is SUPGIPMODE_SYNC_TSC only the first
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * entry is updated. If @c u32Mode is SUPGIPMODE_SYNC_TSC the TSC frequency in
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @c u64CpuHz is copied to all CPUs. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPCPU aCPUs[1];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPGLOBALINFOPAGE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncAssertCompileMemberAlignment(SUPGLOBALINFOPAGE, u64NanoTSLastUpdateHz, 8);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#if defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncAssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs, 32);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#else
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncAssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs, 256);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to the global info page.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPGLOBALINFOPAGE *PSUPGLOBALINFOPAGE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The value of the SUPGLOBALINFOPAGE::u32Magic field. (Soryo Fuyumi) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPGLOBALINFOPAGE_MAGIC 0x19590106
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The GIP version.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Upper 16 bits is the major version. Major version is only changed with
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * incompatible changes in the GIP. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPGLOBALINFOPAGE_VERSION 0x00050000
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * SUPGLOBALINFOPAGE::u32Mode values.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef enum SUPGIPMODE
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The usual invalid null entry. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPMODE_INVALID = 0,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The TSC of the cores and cpus in the system is in sync. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPMODE_SYNC_TSC,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Each core has it's own TSC. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPMODE_ASYNC_TSC,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The TSC of the cores are non-stop and have a constant frequency. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPMODE_INVARIANT_TSC,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The usual 32-bit hack. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPGIPMODE_32BIT_HACK = 0x7fffffff
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPGIPMODE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to the Global Information Page.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This pointer is valid as long as SUPLib has a open session. Anyone using
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * the page must treat this pointer as highly volatile and not trust it beyond
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * one transaction.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark The GIP page is read-only to everyone but the support driver and
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * is actually mapped read only everywhere but in ring-0. However
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * it is not marked 'const' as this might confuse compilers into
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * thinking that values doesn't change even if members are marked
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * as volatile. Thus, there is no PCSUPGLOBALINFOPAGE type.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#if defined(IN_SUP_R0) || defined(IN_SUP_R3) || defined(IN_SUP_RC)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncextern DECLEXPORT(PSUPGLOBALINFOPAGE) g_pSUPGlobalInfoPage;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#elif !defined(IN_RING0) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncextern DECLIMPORT(PSUPGLOBALINFOPAGE) g_pSUPGlobalInfoPage;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#else /* IN_RING0 && !RT_OS_WINDOWS */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# if !defined(__GNUC__) || defined(RT_OS_DARWIN) || !defined(RT_ARCH_AMD64)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# define g_pSUPGlobalInfoPage (&g_SUPGlobalInfoPage)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# else
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# define g_pSUPGlobalInfoPage (SUPGetGIPHlp())
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Workaround for ELF+GCC problem on 64-bit hosts.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * (GCC emits a mov with a R_X86_64_32 reloc, we need R_X86_64_64.) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncDECLINLINE(PSUPGLOBALINFOPAGE) SUPGetGIPHlp(void)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync PSUPGLOBALINFOPAGE pGIP;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync __asm__ __volatile__ ("movabs $g_SUPGlobalInfoPage,%0\n\t"
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync : "=a" (pGIP));
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync return pGIP;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync}
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# endif
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The GIP.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * We save a level of indirection by exporting the GIP instead of a variable
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * pointing to it. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncextern DECLIMPORT(SUPGLOBALINFOPAGE) g_SUPGlobalInfoPage;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Gets the GIP pointer.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns Pointer to the GIP or NULL.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(PSUPGLOBALINFOPAGE) SUPGetGIP(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Whether the application of TSC-deltas is required. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define GIP_ARE_TSC_DELTAS_APPLICABLE(a_pGip) \
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync ((a_pGip)->u32Mode == SUPGIPMODE_INVARIANT_TSC && !((a_pGip)->fOsTscDeltasInSync))
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Whether the application of TSC-deltas are worth it (performance matters). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define GIP_TSC_DELTAS_ROUGHLY_IN_SYNC(a_pGip) ((a_pGip)->fTscDeltasRoughlyInSync)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Gets the TSC frequency of the calling CPU.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns TSC frequency, UINT64_MAX on failure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pGip The GIP pointer.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsyncDECLINLINE(uint64_t) SUPGetCpuHzFromGIP(PSUPGLOBALINFOPAGE pGip)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync unsigned iCpu;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if (RT_UNLIKELY(!pGip || pGip->u32Magic != SUPGLOBALINFOPAGE_MAGIC || !pGip->u64CpuHz))
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return UINT64_MAX;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if ( pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync || pGip->u32Mode == SUPGIPMODE_SYNC_TSC)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync iCpu = 0;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync else
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync Assert(pGip->u32Mode == SUPGIPMODE_ASYNC_TSC);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync iCpu = pGip->aiCpuFromApicId[ASMGetApicId()];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if (RT_UNLIKELY(iCpu >= pGip->cCpus))
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return UINT64_MAX;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync }
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return pGip->aCPUs[iCpu].u64CpuHz;
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync}
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* X86 || AMD64 */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Request for generic VMMR0Entry calls.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPVMMR0REQHDR
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The magic. (SUPVMMR0REQHDR_MAGIC) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t u32Magic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The size of the request. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t cbReq;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPVMMR0REQHDR;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a ring-0 request header. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPVMMR0REQHDR *PSUPVMMR0REQHDR;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** the SUPVMMR0REQHDR::u32Magic value (Ethan Iverson - The Bad Plus). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPVMMR0REQHDR_MAGIC UINT32_C(0x19730211)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync/** For the fast ioctl path.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @see VMMR0_DO_RAW_RUN. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUP_VMMR0_DO_RAW_RUN 0
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @see VMMR0_DO_HM_RUN. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUP_VMMR0_DO_HM_RUN 1
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @see VMMR0_DO_NOP */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUP_VMMR0_DO_NOP 2
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @} */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** SUPR3QueryVTCaps capability flags
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPVTCAPS_AMD_V RT_BIT(0)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPVTCAPS_VT_X RT_BIT(1)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPVTCAPS_NESTED_PAGING RT_BIT(2)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @} */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Request for generic FNSUPR0SERVICEREQHANDLER calls.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPR0SERVICEREQHDR
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The magic. (SUPR0SERVICEREQHDR_MAGIC) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t u32Magic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The size of the request. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t cbReq;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPR0SERVICEREQHDR;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a ring-0 service request header. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPR0SERVICEREQHDR *PSUPR0SERVICEREQHDR;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** the SUPVMMR0REQHDR::u32Magic value (Esbjoern Svensson - E.S.P.). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPR0SERVICEREQHDR_MAGIC UINT32_C(0x19640416)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Event semaphore handle. Ring-0 / ring-3. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef R0PTRTYPE(struct SUPSEMEVENTHANDLE *) SUPSEMEVENT;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to an event semaphore handle. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPSEMEVENT *PSUPSEMEVENT;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Nil event semaphore handle. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define NIL_SUPSEMEVENT ((SUPSEMEVENT)0)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Creates a single release event semaphore.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param phEvent Where to return the handle to the event semaphore.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
d4a8f6749f70bad88edc04de808643d372faa35avboxsyncSUPDECL(int) SUPSemEventCreate(PSUPDRVSESSION pSession, PSUPSEMEVENT phEvent);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Closes a single release event semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @retval VINF_OBJECT_DESTROYED if the semaphore was destroyed.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @retval VINF_SUCCESS if the handle was successfully closed but the semaphore
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * object remained alive because of other references.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync *
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param pSession The session handle of the caller.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param hEvent The handle. Nil is quietly ignored.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync */
d4a8f6749f70bad88edc04de808643d372faa35avboxsyncSUPDECL(int) SUPSemEventClose(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent);
d4a8f6749f70bad88edc04de808643d372faa35avboxsync
d4a8f6749f70bad88edc04de808643d372faa35avboxsync/**
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * Signals a single release event semaphore.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync *
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @returns VBox status code.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param pSession The session handle of the caller.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param hEvent The semaphore handle.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync */
d4a8f6749f70bad88edc04de808643d372faa35avboxsyncSUPDECL(int) SUPSemEventSignal(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent);
d4a8f6749f70bad88edc04de808643d372faa35avboxsync
d4a8f6749f70bad88edc04de808643d372faa35avboxsync#ifdef IN_RING0
d4a8f6749f70bad88edc04de808643d372faa35avboxsync/**
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * Waits on a single release event semaphore, not interruptible.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEvent The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cMillies The number of milliseconds to wait.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks Not available in ring-3.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync */
d4a8f6749f70bad88edc04de808643d372faa35avboxsyncSUPDECL(int) SUPSemEventWait(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies);
d4a8f6749f70bad88edc04de808643d372faa35avboxsync#endif
d4a8f6749f70bad88edc04de808643d372faa35avboxsync
d4a8f6749f70bad88edc04de808643d372faa35avboxsync/**
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * Waits on a single release event semaphore, interruptible.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync *
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @returns VBox status code.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param pSession The session handle of the caller.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param hEvent The semaphore handle.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param cMillies The number of milliseconds to wait.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync */
d4a8f6749f70bad88edc04de808643d372faa35avboxsyncSUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies);
d4a8f6749f70bad88edc04de808643d372faa35avboxsync
d4a8f6749f70bad88edc04de808643d372faa35avboxsync/**
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * Waits on a single release event semaphore, interruptible.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync *
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @returns VBox status code.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param pSession The session handle of the caller.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param hEvent The semaphore handle.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param uNsTimeout The deadline given on the RTTimeNanoTS() clock.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t uNsTimeout);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * Waits on a single release event semaphore, interruptible.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
d4a8f6749f70bad88edc04de808643d372faa35avboxsync * @param hEvent The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cNsTimeout The number of nanoseconds to wait.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t cNsTimeout);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync * Gets the best timeout resolution that SUPSemEventWaitNsAbsIntr and
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * SUPSemEventWaitNsAbsIntr can do.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns The resolution in nanoseconds.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(uint32_t) SUPSemEventGetResolution(PSUPDRVSESSION pSession);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Multiple release event semaphore handle. Ring-0 / ring-3. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef R0PTRTYPE(struct SUPSEMEVENTMULTIHANDLE *) SUPSEMEVENTMULTI;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to an multiple release event semaphore handle. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPSEMEVENTMULTI *PSUPSEMEVENTMULTI;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Nil multiple release event semaphore handle. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define NIL_SUPSEMEVENTMULTI ((SUPSEMEVENTMULTI)0)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Creates a multiple release event semaphore.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
2afbe132eb7931e0125141eabe3a48e08f1ffab5vboxsync * @param pSession The session handle of the caller.
a4b800433571901dfbe3fe952d6ddfe1a8be70b2vboxsync * @param phEventMulti Where to return the handle to the event semaphore.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventMultiCreate(PSUPDRVSESSION pSession, PSUPSEMEVENTMULTI phEventMulti);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Closes a multiple release event semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @retval VINF_OBJECT_DESTROYED if the semaphore was destroyed.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @retval VINF_SUCCESS if the handle was successfully closed but the semaphore
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * object remained alive because of other references.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEventMulti The handle. Nil is quietly ignored.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventMultiClose(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Signals a multiple release event semaphore.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEventMulti The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventMultiSignal(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Resets a multiple release event semaphore.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEventMulti The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventMultiReset(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#ifdef IN_RING0
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Waits on a multiple release event semaphore, not interruptible.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
2afbe132eb7931e0125141eabe3a48e08f1ffab5vboxsync * @returns VBox status code.
a4b800433571901dfbe3fe952d6ddfe1a8be70b2vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEventMulti The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cMillies The number of milliseconds to wait.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks Not available in ring-3.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif
2afbe132eb7931e0125141eabe3a48e08f1ffab5vboxsync
a4b800433571901dfbe3fe952d6ddfe1a8be70b2vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Waits on a multiple release event semaphore, interruptible.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEventMulti The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cMillies The number of milliseconds to wait.
2afbe132eb7931e0125141eabe3a48e08f1ffab5vboxsync */
a4b800433571901dfbe3fe952d6ddfe1a8be70b2vboxsyncSUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Waits on a multiple release event semaphore, interruptible.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEventMulti The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uNsTimeout The deadline given on the RTTimeNanoTS() clock.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventMultiWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Waits on a multiple release event semaphore, interruptible.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param hEventMulti The semaphore handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cNsTimeout The number of nanoseconds to wait.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(int) SUPSemEventMultiWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Gets the best timeout resolution that SUPSemEventMultiWaitNsAbsIntr and
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * SUPSemEventMultiWaitNsRelIntr can do.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns The resolution in nanoseconds.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle of the caller.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPDECL(uint32_t) SUPSemEventMultiGetResolution(PSUPDRVSESSION pSession);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#ifdef IN_RING3
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @defgroup grp_sup_r3 SUP Host Context Ring-3 API
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Installs the support library.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3Install(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Uninstalls the support library.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3Uninstall(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Trusted main entry point.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is exported as "TrustedMain" by the dynamic libraries which contains the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * "real" application binary for which the hardened stub is built. The entry
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * point is invoked upon successful initialization of the support library and
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * runtime.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns main kind of exit code.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param argc The argument count.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param argv The argument vector.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param envp The environment vector.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsynctypedef DECLCALLBACK(int) FNSUPTRUSTEDMAIN(int argc, char **argv, char **envp);
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/** Pointer to FNSUPTRUSTEDMAIN(). */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsynctypedef FNSUPTRUSTEDMAIN *PFNSUPTRUSTEDMAIN;
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/** Which operation failed. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsynctypedef enum SUPINITOP
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync{
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync /** Invalid. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync kSupInitOp_Invalid = 0,
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync /** Installation integrity error. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync kSupInitOp_Integrity,
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync /** Setuid related. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync kSupInitOp_RootCheck,
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync /** Driver related. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync kSupInitOp_Driver,
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync /** IPRT init related. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync kSupInitOp_IPRT,
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync /** Miscellaneous. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync kSupInitOp_Misc,
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync /** Place holder. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync kSupInitOp_End
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync} SUPINITOP;
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/**
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * Trusted error entry point, optional.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync *
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * This is exported as "TrustedError" by the dynamic libraries which contains
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * the "real" application binary for which the hardened stub is built. The
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * hardened main() must specify SUPSECMAIN_FLAGS_TRUSTED_ERROR when calling
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * SUPR3HardenedMain.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync *
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param pszWhere Where the error occurred (function name).
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param enmWhat Which operation went wrong.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param rc The status code.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param pszMsgFmt Error message format string.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param va The message format arguments.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsynctypedef DECLCALLBACK(void) FNSUPTRUSTEDERROR(const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, va_list va);
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/** Pointer to FNSUPTRUSTEDERROR. */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsynctypedef FNSUPTRUSTEDERROR *PFNSUPTRUSTEDERROR;
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/**
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * Secure main.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is used for the set-user-ID-on-execute binaries on unixy systems
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * and when using the open-vboxdrv-via-root-service setup on Windows.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This function will perform the integrity checks of the VirtualBox
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * installation, open the support driver, open the root service (later),
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * and load the DLL corresponding to \a pszProgName and execute its main
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * function.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync *
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @returns Return code appropriate for main().
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync *
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param pszProgName The program name. This will be used to figure out which
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * DLL/SO/DYLIB to load and execute.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param fFlags Flags.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param argc The argument count.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param argv The argument vector.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @param envp The environment vector.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsyncDECLHIDDEN(int) SUPR3HardenedMain(const char *pszProgName, uint32_t fFlags, int argc, char **argv, char **envp);
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/** @name SUPR3HardenedMain flags.
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync * @{ */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/** Don't open the device. (Intended for VirtualBox without -startvm.) */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync#define SUPSECMAIN_FLAGS_DONT_OPEN_DEV RT_BIT_32(0)
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/** The hardened DLL has a "TrustedError" function (see FNSUPTRUSTEDERROR). */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync#define SUPSECMAIN_FLAGS_TRUSTED_ERROR RT_BIT_32(1)
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/** @} */
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync
374f0b5fc4e70777b3f9ad8586ad7aa2551f37ccvboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Initializes the support library.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Each successful call to SUPR3Init() or SUPR3InitEx must be countered by a
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * call to SUPR3Term(false).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
a8c0cd113e4c194efbc13ef339c7f79137d6dd3bvboxsync * @param ppSession Where to store the session handle. Defaults to NULL.
a8c0cd113e4c194efbc13ef339c7f79137d6dd3bvboxsync */
a8c0cd113e4c194efbc13ef339c7f79137d6dd3bvboxsyncSUPR3DECL(int) SUPR3Init(PSUPDRVSESSION *ppSession);
a8c0cd113e4c194efbc13ef339c7f79137d6dd3bvboxsync
a8c0cd113e4c194efbc13ef339c7f79137d6dd3bvboxsync
a8c0cd113e4c194efbc13ef339c7f79137d6dd3bvboxsync/**
a8c0cd113e4c194efbc13ef339c7f79137d6dd3bvboxsync * Initializes the support library, extended version.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Each successful call to SUPR3Init() or SUPR3InitEx must be countered by a
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * call to SUPR3Term(false).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param fUnrestricted The desired access.
2afbe132eb7931e0125141eabe3a48e08f1ffab5vboxsync * @param ppSession Where to store the session handle. Defaults to NULL.
a4b800433571901dfbe3fe952d6ddfe1a8be70b2vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3InitEx(bool fUnrestricted, PSUPDRVSESSION *ppSession);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Terminates the support library.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
2afbe132eb7931e0125141eabe3a48e08f1ffab5vboxsync * @param fForced Forced termination. This means to ignore the
a4b800433571901dfbe3fe952d6ddfe1a8be70b2vboxsync * init call count and just terminated.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#ifdef __cplusplus
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3Term(bool fForced = false);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#else
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3Term(int fForced);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Sets the ring-0 VM handle for use with fast IOCtls.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVMR0 The ring-0 VM handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * NIL_RTR0PTR can be used to unset the handle when the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * VM is about to be destroyed.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3SetVMForFastIOCtl(PVMR0 pVMR0);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Calls the HC R0 VMM entry point.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * See VMMR0Entry() for more details.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns error code specific to uFunction.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVMR0 Pointer to the Ring-0 (Host Context) mapping of the VM structure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param idCpu The virtual CPU ID.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uOperation Operation to execute.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pvArg Argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3CallVMMR0(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation, void *pvArg);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Variant of SUPR3CallVMMR0, except that this takes the fast ioclt path
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * regardsless of compile-time defaults.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVMR0 The ring-0 VM handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uOperation The operation; only the SUP_VMMR0_DO_* ones are valid.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param idCpu The virtual CPU ID.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3CallVMMR0Fast(PVMR0 pVMR0, unsigned uOperation, VMCPUID idCpu);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Calls the HC R0 VMM entry point, in a safer but slower manner than
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * SUPR3CallVMMR0. When entering using this call the R0 components can call
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * into the host kernel (i.e. use the SUPR0 and RT APIs).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * See VMMR0Entry() for more details.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns error code specific to uFunction.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVMR0 Pointer to the Ring-0 (Host Context) mapping of the VM structure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param idCpu The virtual CPU ID.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uOperation Operation to execute.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param u64Arg Constant argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pReqHdr Pointer to a request header. Optional.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This will be copied in and out of kernel space. There currently is a size
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * limit on this, just below 4KB.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Calls a ring-0 service.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The operation and the request packet is specific to the service.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns error code specific to uFunction.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszService The service name.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cchService The length of the service name.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uReq The request number.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param u64Arg Constant argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pReqHdr Pointer to a request header. Optional.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This will be copied in and out of kernel space. There currently is a size
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * limit on this, just below 4KB.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3CallR0Service(const char *pszService, size_t cchService, uint32_t uOperation, uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Which logger. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef enum SUPLOGGER
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync{
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync SUPLOGGER_DEBUG = 1,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPLOGGER_RELEASE
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync} SUPLOGGER;
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync/**
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync * Changes the settings of the specified ring-0 logger.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync * @returns VBox status code.
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync * @param enmWhich Which logger.
f6f5b68ebbb3a264e0a27e2a5848774722fccfd2vboxsync * @param pszFlags The flags settings.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszGroups The groups settings.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszDest The destination specificier.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3LoggerSettings(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Creates a ring-0 logger instance.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param enmWhich Which logger to create.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pszFlags The flags settings.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pszGroups The groups settings.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pszDest The destination specificier.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(int) SUPR3LoggerCreate(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest);
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync/**
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Destroys a ring-0 logger instance.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns VBox status code.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param enmWhich Which logger.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(int) SUPR3LoggerDestroy(SUPLOGGER enmWhich);
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync/**
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Queries the paging mode of the host OS.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns The paging mode.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(SUPPAGINGMODE) SUPR3GetPagingMode(void);
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync/**
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Allocate zero-filled pages.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Use this to allocate a number of pages suitable for seeding / locking.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Call SUPR3PageFree() to free the pages once done with them.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns VBox status.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param cPages Number of pages to allocate.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param ppvPages Where to store the base pointer to the allocated pages.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(int) SUPR3PageAlloc(size_t cPages, void **ppvPages);
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync/**
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Frees pages allocated with SUPR3PageAlloc().
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns VBox status.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pvPages Pointer returned by SUPR3PageAlloc().
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param cPages Number of pages that was allocated.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(int) SUPR3PageFree(void *pvPages, size_t cPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Allocate non-zeroed, locked, pages with user and, optionally, kernel
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * mappings.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Use SUPR3PageFreeEx() to free memory allocated with this function.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cPages The number of pages to allocate.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param fFlags Flags, reserved. Must be zero.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param ppvPages Where to store the address of the user mapping.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pR0Ptr Where to store the address of the kernel mapping.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * NULL if no kernel mapping is desired.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param paPages Where to store the physical addresses of each page.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Optional.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3PageAllocEx(size_t cPages, uint32_t fFlags, void **ppvPages, PRTR0PTR pR0Ptr, PSUPPAGE paPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Maps a portion of a ring-3 only allocation into kernel space.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pvR3 The address SUPR3PageAllocEx return.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param off Offset to start mapping at. Must be page aligned.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param cb Number of bytes to map. Must be page aligned.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param fFlags Flags, must be zero.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pR0Ptr Where to store the address on success.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(int) SUPR3PageMapKernel(void *pvR3, uint32_t off, uint32_t cb, uint32_t fFlags, PRTR0PTR pR0Ptr);
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync/**
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Changes the protection of
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns VBox status code.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @retval VERR_NOT_SUPPORTED if the OS doesn't allow us to change page level
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * protection. See also RTR0MemObjProtect.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pvR3 The ring-3 address SUPR3PageAllocEx returned.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param R0Ptr The ring-0 address SUPR3PageAllocEx returned if it
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * is desired that the corresponding ring-0 page
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * mappings should change protection as well. Pass
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * NIL_RTR0PTR if the ring-0 pages should remain
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * unaffected.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param off Offset to start at which to start chagning the page
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * level protection. Must be page aligned.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param cb Number of bytes to change. Must be page aligned.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param fProt The new page level protection, either a combination
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * of RTMEM_PROT_READ, RTMEM_PROT_WRITE and
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * RTMEM_PROT_EXEC, or just RTMEM_PROT_NONE.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(int) SUPR3PageProtect(void *pvR3, RTR0PTR R0Ptr, uint32_t off, uint32_t cb, uint32_t fProt);
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync/**
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Free pages allocated by SUPR3PageAllocEx.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns VBox status code.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pvPages The address of the user mapping.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param cPages The number of pages.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync */
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsyncSUPR3DECL(int) SUPR3PageFreeEx(void *pvPages, size_t cPages);
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync/**
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * Allocated memory with page aligned memory with a contiguous and locked physical
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * memory backing below 4GB.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns Pointer to the allocated memory (virtual address).
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * *pHCPhys is set to the physical address of the memory.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * If ppvR0 isn't NULL, *ppvR0 is set to the ring-0 mapping.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * The returned memory must be freed using SUPR3ContFree().
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @returns NULL on failure.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param cPages Number of pages to allocate.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pR0Ptr Where to store the ring-0 mapping of the allocation. (optional)
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @param pHCPhys Where to store the physical address of the memory block.
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync *
324e9d5fe84f23a35c4feb6853ed3ee9b3b1fad9vboxsync * @remark This 2nd version of this API exists because we're not able to map the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * ring-3 mapping executable on WIN64. This is a serious problem in regard to
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * the world switchers.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(void *) SUPR3ContAlloc(size_t cPages, PRTR0PTR pR0Ptr, PRTHCPHYS pHCPhys);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Frees memory allocated with SUPR3ContAlloc().
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pv Pointer to the memory block which should be freed.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cPages Number of pages to be freed.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsyncSUPR3DECL(int) SUPR3ContFree(void *pv, size_t cPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Allocated non contiguous physical memory below 4GB.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The memory isn't zeroed.
7dfd3f41f200bede0714c89735d9cc8d310e3f1cvboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns NULL on failure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cPages Number of pages to allocate.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param ppvPages Where to store the pointer to the allocated memory.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The pointer stored here on success must be passed to
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * SUPR3LowFree when the memory should be released.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param ppvPagesR0 Where to store the ring-0 pointer to the allocated memory. optional.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param paPages Where to store the physical addresses of the individual pages.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
7dfd3f41f200bede0714c89735d9cc8d310e3f1cvboxsyncSUPR3DECL(int) SUPR3LowAlloc(size_t cPages, void **ppvPages, PRTR0PTR ppvPagesR0, PSUPPAGE paPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Frees memory allocated with SUPR3LowAlloc().
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pv Pointer to the memory block which should be freed.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @param cPages Number of pages that was allocated.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync */
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsyncSUPR3DECL(int) SUPR3LowFree(void *pv, size_t cPages);
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync/**
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * Load a module into R0 HC.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * This will verify the file integrity in a similar manner as
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * SUPR3HardenedVerifyFile before loading it.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszFilename The path to the image file.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszModule The module name. Max 32 bytes.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param ppvImageBase Where to store the image address.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pErrInfo Where to return extended error information.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Optional.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, PRTERRINFO pErrInfo);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Load a module into R0 HC.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This will verify the file integrity in a similar manner as
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync * SUPR3HardenedVerifyFile before loading it.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszFilename The path to the image file.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszModule The module name. Max 32 bytes.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszSrvReqHandler The name of the service request handler entry
7dfd3f41f200bede0714c89735d9cc8d310e3f1cvboxsync * point. See FNSUPR0SERVICEREQHANDLER.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param ppvImageBase Where to store the image address.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3LoadServiceModule(const char *pszFilename, const char *pszModule,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync const char *pszSrvReqHandler, void **ppvImageBase);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Frees a R0 HC module.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
7dfd3f41f200bede0714c89735d9cc8d310e3f1cvboxsync * @param pszModule The module to free.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark This will not actually 'free' the module, there are of course usage counting.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3FreeModule(void *pvImageBase);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Lock down the module loader interface.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * This will lock down the module loader interface. No new modules can be
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * loaded and all loaded modules can no longer be freed.
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync *
7dfd3f41f200bede0714c89735d9cc8d310e3f1cvboxsync * @returns VBox status code.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @param pErrInfo Where to return extended error information.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * Optional.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync */
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsyncSUPR3DECL(int) SUPR3LockDownLoader(PRTERRINFO pErrInfo);
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync/**
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * Get the address of a symbol in a ring-0 module.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @param pszModule The module name.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * ordinal value rather than a string pointer.
7dfd3f41f200bede0714c89735d9cc8d310e3f1cvboxsync * @param ppvValue Where to store the symbol value.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync */
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsyncSUPR3DECL(int) SUPR3GetSymbolR0(void *pvImageBase, const char *pszSymbol, void **ppvValue);
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Load R0 HC VMM code.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @returns VBox status code.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @deprecated Use SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase)
7dfd3f41f200bede0714c89735d9cc8d310e3f1cvboxsync */
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsyncSUPR3DECL(int) SUPR3LoadVMM(const char *pszFilename);
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync/**
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * Unloads R0 HC VMM code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @deprecated Use SUPR3FreeModule().
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3UnloadVMM(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Get the physical address of the GIP.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pHCPhys Where to store the physical address of the GIP.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3GipGetPhys(PRTHCPHYS pHCPhys);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Initializes only the bits relevant for the SUPR3HardenedVerify* APIs.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is for users that don't necessarily need to initialize the whole of
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * SUPLib. There is no harm in calling this one more time.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * @remarks Currently not counted, so only call once.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync */
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsyncSUPR3DECL(int) SUPR3HardenedVerifyInit(void);
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync/**
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * Reverses the effect of SUPR3HardenedVerifyInit if SUPR3InitEx hasn't been
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * called.
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Ignored if the support library was initialized using SUPR3Init or
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsync * SUPR3InitEx.
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsync *
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsync * @returns VBox status code.
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsync */
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsyncSUPR3DECL(int) SUPR3HardenedVerifyTerm(void);
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsync
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsync/**
b7640e1373d7f1eeaf6e0efd5ec8690432048342vboxsync * Verifies the integrity of a file, and optionally opens it.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The integrity check is for whether the file is suitable for loading into
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * the hypervisor or VM process. The integrity check may include verifying
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * the authenticode/elfsign/whatever signature of the file, which can take
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * a little while.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code. On failure it will have printed a LogRel message.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszFilename The file.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszWhat For the LogRel on failure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param phFile Where to store the handle to the opened file. This is optional, pass NULL
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * if the file should not be opened.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @deprecated Write a new one.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3HardenedVerifyFile(const char *pszFilename, const char *pszWhat, PRTFILE phFile);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Verifies the integrity of a the current process, including the image
a13bd47f22085c82960265c150f10f2195369630vboxsync * location and that the invocation was absolute.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * This must currently be called after initializing the runtime. The intended
a13bd47f22085c82960265c150f10f2195369630vboxsync * audience is set-uid-to-root applications, root services and similar.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code. On failure
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync * message.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pszArgv0 The first argument to main().
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fInternal Set this to @c true if this is an internal
a13bd47f22085c82960265c150f10f2195369630vboxsync * VirtualBox application. Otherwise pass @c false.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pErrInfo Where to return extended error information.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, PRTERRINFO pErrInfo);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Verifies the integrity of an installation directory.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * The integrity check verifies that the directory cannot be tampered with by
a13bd47f22085c82960265c150f10f2195369630vboxsync * normal users on the system. On Unix this translates to root ownership and
a13bd47f22085c82960265c150f10f2195369630vboxsync * no symbolic linking.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code. On failure a message will be stored in @a pszErr.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pszDirPath The directory path.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fRecursive Whether the check should be recursive or
a13bd47f22085c82960265c150f10f2195369630vboxsync * not. When set, all sub-directores will be checked,
a13bd47f22085c82960265c150f10f2195369630vboxsync * including files (@a fCheckFiles is ignored).
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fCheckFiles Whether to apply the same basic integrity check to
a13bd47f22085c82960265c150f10f2195369630vboxsync * the files in the directory as the directory itself.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pErrInfo Where to return extended error information.
a13bd47f22085c82960265c150f10f2195369630vboxsync * Optional.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Verifies the integrity of a plug-in module.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * This is similar to SUPR3HardenedLdrLoad, except it does not load the module
a13bd47f22085c82960265c150f10f2195369630vboxsync * and that the module does not have to be shipped with VirtualBox.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code. On failure a message will be stored in @a pszErr.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pszFilename The filename of the plug-in module (nothing can be
a13bd47f22085c82960265c150f10f2195369630vboxsync * omitted here).
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pErrInfo Where to return extended error information.
a13bd47f22085c82960265c150f10f2195369630vboxsync * Optional.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, PRTERRINFO pErrInfo);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Same as RTLdrLoad() but will verify the files it loads (hardened builds).
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * Will add dll suffix if missing and try load the file.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns iprt status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pszFilename Image filename. This must have a path.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param phLdrMod Where to store the handle to the loaded module.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fFlags See RTLDRLOAD_FLAGS_XXX.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pErrInfo Where to return extended error information.
a13bd47f22085c82960265c150f10f2195369630vboxsync * Optional.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Same as RTLdrLoadAppPriv() but it will verify the files it loads (hardened
a13bd47f22085c82960265c150f10f2195369630vboxsync * builds).
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * Will add dll suffix to the file if missing, then look for it in the
a13bd47f22085c82960265c150f10f2195369630vboxsync * architecture dependent application directory.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns iprt status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pszFilename Image filename.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param phLdrMod Where to store the handle to the loaded module.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fFlags See RTLDRLOAD_FLAGS_XXX.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pErrInfo Where to return extended error information.
a13bd47f22085c82960265c150f10f2195369630vboxsync * Optional.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Same as RTLdrLoad() but will verify the files it loads (hardened builds).
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * This differs from SUPR3HardenedLdrLoad() in that it can load modules from
a13bd47f22085c82960265c150f10f2195369630vboxsync * extension packs and anything else safely installed on the system, provided
a13bd47f22085c82960265c150f10f2195369630vboxsync * they pass the hardening tests.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns iprt status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pszFilename The full path to the module, with extension.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param phLdrMod Where to store the handle to the loaded module.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pErrInfo Where to return extended error information.
a13bd47f22085c82960265c150f10f2195369630vboxsync * Optional.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Check if the host kernel can run in VMX root mode.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VINF_SUCCESS if supported, error code indicating why if not.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3QueryVTxSupported(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Return VT-x/AMD-V capabilities.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VINF_SUCCESS if supported, error code indicating why if not.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pfCaps Pointer to capability dword (out).
a13bd47f22085c82960265c150f10f2195369630vboxsync * @todo Intended for main, which means we need to relax the privilege requires
a13bd47f22085c82960265c150f10f2195369630vboxsync * when accessing certain vboxdrv functions.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3QueryVTCaps(uint32_t *pfCaps);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Open the tracer.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uCookie Cookie identifying the tracer we expect to talk to.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg Tracer specific open argument.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3TracerOpen(uint32_t uCookie, uintptr_t uArg);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Closes the tracer.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3TracerClose(void);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Perform an I/O request on the tracer.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uCmd The tracer command.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg The argument.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param piRetVal Where to store the tracer return value.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3TracerIoCtl(uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Registers the user module with the tracer.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param hModNative Native module handle. Pass ~(uintptr_t)0 if not
a13bd47f22085c82960265c150f10f2195369630vboxsync * at hand.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pszModule The module name.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pVtgHdr The VTG header.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uVtgHdrAddr The address to which the VTG header is loaded
a13bd47f22085c82960265c150f10f2195369630vboxsync * in the relevant execution context.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fFlags See SUP_TRACER_UMOD_FLAGS_XXX
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3TracerRegisterModule(uintptr_t hModNative, const char *pszModule, struct VTGOBJHDR *pVtgHdr,
a13bd47f22085c82960265c150f10f2195369630vboxsync RTUINTPTR uVtgHdrAddr, uint32_t fFlags);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Deregisters the user module.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVtgHdr The VTG header.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3TracerDeregisterModule(struct VTGOBJHDR *pVtgHdr);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Fire the probe.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pVtgProbeLoc The probe location record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg0 Raw probe argument 0.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uArg1 Raw probe argument 1.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uArg2 Raw probe argument 2.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uArg3 Raw probe argument 3.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uArg4 Raw probe argument 4.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPDECL(void) SUPTracerFireProbe(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
a13bd47f22085c82960265c150f10f2195369630vboxsync uintptr_t uArg3, uintptr_t uArg4);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Attempts to read the value of an MSR.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uMsr The MSR to read.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param idCpu The CPU to read it on, NIL_RTCPUID if it doesn't
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * matter which CPU.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param puValue Where to return the value.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pfGp Where to store the \#GP indicator for the read
a13bd47f22085c82960265c150f10f2195369630vboxsync * operation.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3MsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue, bool *pfGp);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Attempts to write to an MSR.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uMsr The MSR to write to.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param idCpu The CPU to wrtie it on, NIL_RTCPUID if it
a13bd47f22085c82960265c150f10f2195369630vboxsync * doesn't matter which CPU.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uValue The value to write.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pfGp Where to store the \#GP indicator for the write
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * operation.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3MsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue, bool *pfGp);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Attempts to modify the value of an MSR.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uMsr The MSR to modify.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param idCpu The CPU to modify it on, NIL_RTCPUID if it
a13bd47f22085c82960265c150f10f2195369630vboxsync * doesn't matter which CPU.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fAndMask The bits to keep in the current MSR value.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fOrMask The bits to set before writing.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pResult The result buffer.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3MsrProberModify(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync PSUPMSRPROBERMODIFYRESULT pResult);
a13bd47f22085c82960265c150f10f2195369630vboxsync
a13bd47f22085c82960265c150f10f2195369630vboxsync/**
a13bd47f22085c82960265c150f10f2195369630vboxsync * Attempts to modify the value of an MSR, extended version.
a13bd47f22085c82960265c150f10f2195369630vboxsync *
a13bd47f22085c82960265c150f10f2195369630vboxsync * @returns VBox status code.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param uMsr The MSR to modify.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param idCpu The CPU to modify it on, NIL_RTCPUID if it
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * doesn't matter which CPU.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fAndMask The bits to keep in the current MSR value.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fOrMask The bits to set before writing.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param fFaster If set to @c true some cache/tlb invalidation is
0bbe08c3ee3c834593be35ccfbe0183116509ae2vboxsync * skipped, otherwise behave like
a13bd47f22085c82960265c150f10f2195369630vboxsync * SUPR3MsrProberModify.
a13bd47f22085c82960265c150f10f2195369630vboxsync * @param pResult The result buffer.
a13bd47f22085c82960265c150f10f2195369630vboxsync */
a13bd47f22085c82960265c150f10f2195369630vboxsyncSUPR3DECL(int) SUPR3MsrProberModifyEx(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, bool fFaster,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync PSUPMSRPROBERMODIFYRESULT pResult);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Resume built-in keyboard on MacBook Air and Pro hosts.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3ResumeSuspendedKeyboards(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Measure the TSC-delta for the specified CPU.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param idCpu The CPU to measure the TSC-delta for.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param fAsync Whether the measurement is asynchronous, returns
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * immediately after signalling a measurement
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * request.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param fForce Whether to perform a measurement even if the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * specified CPU has a (possibly) valid TSC delta.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param cRetries Number of times to retry failed delta
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * measurements.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3TscDeltaMeasure(RTCPUID idCpu, bool fAsync, bool fForce, uint8_t cRetries);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Reads the delta-adjust TSC value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param puTsc Where to store the read TSC value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pidApic Where to store the APIC ID of the CPU where the TSC
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * was read (optional, can be NULL).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR3DECL(int) SUPR3ReadTsc(uint64_t *puTsc, uint16_t *pidApic);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @} */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* IN_RING3 */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Gets the descriptive GIP mode name.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns The name.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pGip Pointer to the GIP.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncDECLINLINE(const char *) SUPGetGIPModeName(PSUPGLOBALINFOPAGE pGip)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync AssertReturn(pGip, NULL);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync switch (pGip->u32Mode)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync case SUPGIPMODE_INVARIANT_TSC: return "Invariant";
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync case SUPGIPMODE_SYNC_TSC: return "Synchronous";
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync case SUPGIPMODE_ASYNC_TSC: return "Asynchronous";
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync case SUPGIPMODE_INVALID: return "Invalid";
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync default: return "???";
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync }
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync}
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Checks if the provided TSC frequency is close enough to the computed TSC
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * frequency of the host.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns true if it's compatible, false otherwise.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncDECLINLINE(bool) SUPIsTscFreqCompatible(uint64_t u64CpuHz)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if ( pGip
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync && pGip->u32Mode == SUPGIPMODE_INVARIANT_TSC)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if (pGip->u64CpuHz != u64CpuHz)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* Arbitrary tolerance threshold, tweak later if required, perhaps
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync more tolerance on lower frequencies and less tolerance on higher. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t uLo = (pGip->u64CpuHz << 10) / 1025;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t uHi = pGip->u64CpuHz + (pGip->u64CpuHz - uLo);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if ( u64CpuHz < uLo
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync || u64CpuHz > uHi)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return false;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync }
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return true;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync }
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return false;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync}
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Applies the TSC delta to the supplied raw TSC value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pGip Pointer to the GIP.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param puTsc Pointer to a valid TSC value before the TSC delta has been applied.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param idApic The APIC ID of the CPU @c puTsc corresponds to.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param fDeltaApplied Where to store whether the TSC delta was succesfully
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * applied or not (optional, can be NULL).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks Maybe called with interrupts disabled in ring-0!
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @note If you change the delta calculation made here, make sure to update
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * the assembly version in sup.mac! Also update supdrvGipMpEvent()
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * while re-adjusting deltas while choosing a new GIP master.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncDECLINLINE(int) SUPTscDeltaApply(PSUPGLOBALINFOPAGE pGip, uint64_t *puTsc, uint16_t idApic, bool *pfDeltaApplied)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync PSUPGIPCPU pGipCpu;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t iCpu;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* Validate. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync Assert(puTsc);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync Assert(pGip);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync Assert(GIP_ARE_TSC_DELTAS_APPLICABLE(pGip));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync /** @todo convert these to AssertMsg() after sufficient testing before public
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * release. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync AssertMsgReturn(idApic < RT_ELEMENTS(pGip->aiCpuFromApicId), ("idApic=%u\n", idApic), VERR_INVALID_CPU_ID);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync iCpu = pGip->aiCpuFromApicId[idApic];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync AssertMsgReturn(iCpu < pGip->cCpus, ("iCpu=%u cCpus=%u\n", iCpu, pGip->cCpus), VERR_INVALID_CPU_INDEX);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync pGipCpu = &pGip->aCPUs[iCpu];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync Assert(pGipCpu);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if (RT_LIKELY(pGipCpu->i64TSCDelta != INT64_MAX))
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *puTsc -= pGipCpu->i64TSCDelta;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if (pfDeltaApplied)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *pfDeltaApplied = true;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync }
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync else if (pfDeltaApplied)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *pfDeltaApplied = false;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return VINF_SUCCESS;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync}
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * Gets the delta-adjusted TSC.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Must only be called when GIP mode is invariant (i.e. when TSC deltas are
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * likely to be computed and available). In other GIP modes, like async, we
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * don't bother with computing TSC deltas and therefore it is meaningless to
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * call this function, use SUPReadTSC() instead.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param puTsc Where to store the normalized TSC value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pidApic Where to store the APIC ID of the CPU where the TSC
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * was read (optional, can be NULL). This is updated
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * even if the function fails with
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * VERR_SUPDRV_TSC_READ_FAILED. Not guaranteed to be
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * updated for other failures.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks May be called with interrupts disabled in ring-0!
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncDECLINLINE(int) SUPGetTsc(uint64_t *puTsc, uint16_t *pidApic)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# ifdef IN_RING3
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync Assert(GIP_ARE_TSC_DELTAS_APPLICABLE(g_pSUPGlobalInfoPage));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** @todo Use rdtscp after figuring out what the host OS has stuffed into the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * TSC_AUX msr, otherwise use the fallback below. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync int cTries = 10;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync do
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t idApicBefore;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t idApicAfter;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* The chance of getting preempted twice here is rather low, hence we
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync take this approach. Performance matters, see @bugref{6710} comment #24. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync idApicBefore = ASMGetApicId();
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *puTsc = ASMReadTSC();
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync idApicAfter = ASMGetApicId();
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync if (RT_LIKELY(idApicBefore == idApicAfter))
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPTscDeltaApply(g_pSUPGlobalInfoPage, puTsc, idApicBefore, NULL);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if (pidApic)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *pidApic = idApicBefore;
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync return VINF_SUCCESS;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync }
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync } while (cTries-- > 0);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *puTsc = 0;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return VERR_SUPDRV_TSC_READ_FAILED;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** @todo get rid of SUPR3ReadTsc(). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync //return SUPR3ReadTsc(puTsc, pidApic);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync# else
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync RTCCUINTREG uFlags;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint16_t idApic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fDeltaApplied;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync int rc;
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** @todo Use rdtscp after figuring out what the host OS has stuffed into the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * TSC_AUX msr, otherwise use the fallback below. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /* Validate. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync Assert(puTsc);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uFlags = ASMIntDisableFlags();
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync idApic = ASMGetApicId(); /* Doubles as serialization. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *puTsc = ASMReadTSC();
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync ASMSetFlags(uFlags);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if (pidApic)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *pidApic = idApic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync rc = SUPTscDeltaApply(g_pSUPGlobalInfoPage, puTsc, idApic, &fDeltaApplied);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync AssertRC(rc);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync return fDeltaApplied ? VINF_SUCCESS : VERR_SUPDRV_TSC_READ_FAILED;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync# endif
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync}
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Reads the host TSC value.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * If applicable, normalizes the host TSC value with intercpu TSC deltas.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns the TSC value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks Requires GIP to be initialized.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncDECLINLINE(uint64_t) SUPReadTsc(void)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync if ( GIP_ARE_TSC_DELTAS_APPLICABLE(g_pSUPGlobalInfoPage)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync && !GIP_TSC_DELTAS_ROUGHLY_IN_SYNC(g_pSUPGlobalInfoPage))
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t u64Tsc = UINT64_MAX;
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync int rc = SUPGetTsc(&u64Tsc, NULL /* pidApic */);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync NOREF(rc);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#ifdef DEBUG_ramshankar
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync AssertRC(rc);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return u64Tsc;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync }
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync return ASMReadTSC();
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync}
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#endif /* X86 || AMD64 */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @name User mode module flags (SUPR3TracerRegisterModule & SUP_IOCTL_TRACER_UMOD_REG).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{ */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync/** Executable image. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUP_TRACER_UMOD_FLAGS_EXE UINT32_C(1)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Shared library (DLL, DYLIB, SO, etc). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUP_TRACER_UMOD_FLAGS_SHARED UINT32_C(2)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Image type mask. */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync#define SUP_TRACER_UMOD_FLAGS_TYPE_MASK UINT32_C(3)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @} */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#ifdef IN_RING0
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @defgroup grp_sup_r0 SUP Host Context Ring-0 API
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Security objectype.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef enum SUPDRVOBJTYPE
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The usual invalid object. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_INVALID = 0,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** A Virtual Machine instance. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_VM,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Internal network. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_INTERNAL_NETWORK,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Internal network interface. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_INTERNAL_NETWORK_INTERFACE,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Single release event semaphore. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_SEM_EVENT,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Multiple release event semaphore. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_SEM_EVENT_MULTI,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Raw PCI device. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_RAW_PCI_DEVICE,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The first invalid object type in this end. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_END,
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync /** The usual 32-bit type size hack. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVOBJTYPE_32_BIT_HACK = 0x7ffffff
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVOBJTYPE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Object destructor callback.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is called for reference counted objectes when the count reaches 0.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pvObj The object pointer.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pvUser1 The first user argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pvUser2 The second user argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef DECLCALLBACK(void) FNSUPDRVDESTRUCTOR(void *pvObj, void *pvUser1, void *pvUser2);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync/** Pointer to a FNSUPDRVDESTRUCTOR(). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef FNSUPDRVDESTRUCTOR *PFNSUPDRVDESTRUCTOR;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsyncSUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cPages, PRTHCPHYS paPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0UnlockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ContFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS paPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0LowFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0MemAlloc(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0MemGetPhys(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, PSUPPAGE paPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0MemFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0PageAllocEx(PSUPDRVSESSION pSession, uint32_t cPages, uint32_t fFlags, PRTR3PTR ppvR3, PRTR0PTR ppvR0, PRTHCPHYS paPages);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0PageMapKernel(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t offSub, uint32_t cbSub, uint32_t fFlags, PRTR0PTR ppvR0);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0PageProtect(PSUPDRVSESSION pSession, RTR3PTR pvR3, RTR0PTR pvR0, uint32_t offSub, uint32_t cbSub, uint32_t fProt);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0PageFree(PSUPDRVSESSION pSession, RTR3PTR pvR3);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsyncSUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PRTR3PTR ppGipR3, PRTHCPHYS pHCPhysGip);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0GetSvmUsability(bool fInitSvm);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0GetVmxUsability(bool *pfIsSmxModeAmbiguous);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0GipUnmap(PSUPDRVSESSION pSession);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsyncSUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(SUPPAGINGMODE) SUPR0GetPagingMode(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0EnableVTx(bool fEnable);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(bool) SUPR0SuspendVTxOnCpu(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0ResumeVTxOnCpu(bool fSuspended);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @name Absolute symbols
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * Take the address of these, don't try call them.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{ */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0AbsIs64bit(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0Abs64bitKernelCS(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0Abs64bitKernelSS(void);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsyncSUPR0DECL(void) SUPR0Abs64bitKernelDS(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0AbsKernelCS(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0AbsKernelSS(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0AbsKernelDS(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0AbsKernelES(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0AbsKernelFS(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0AbsKernelGS(void);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @} */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Support driver component factory.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Component factories are registered by drivers that provides services
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * such as the host network interface filtering and access to the host
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * TCP/IP stack.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remark Module dependencies and making sure that a component doesn't
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * get unloaded while in use, is the sole responsibility of the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * driver/kext/whatever implementing the component.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVFACTORY
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The (unique) name of the component factory. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync char szName[56];
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Queries a factory interface.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * The factory interface is specific to each component and will be be
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * found in the header(s) for the component alongside its UUID.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * @returns Pointer to the factory interfaces on success, NULL on failure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSupDrvFactory Pointer to this structure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The SUPDRV session making the query.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pszInterfaceUuid The UUID of the factory interface.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(void *, pfnQueryFactoryInterface,(struct SUPDRVFACTORY const *pSupDrvFactory, PSUPDRVSESSION pSession, const char *pszInterfaceUuid));
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync} SUPDRVFACTORY;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a support driver factory. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPDRVFACTORY *PSUPDRVFACTORY;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a const support driver factory. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPDRVFACTORY const *PCSUPDRVFACTORY;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ComponentRegisterFactory(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ComponentDeregisterFactory(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0ComponentQueryFactory(PSUPDRVSESSION pSession, const char *pszName, const char *pszInterfaceUuid, void **ppvFactoryIf);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @name Tracing
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{ */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * Tracer data associated with a provider.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef union SUPDRVTRACERDATA
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Generic */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync uint64_t au64[2];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** DTrace data. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync struct
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync {
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Provider ID. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uintptr_t idProvider;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The number of trace points provided. */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync uint32_t volatile cProvidedProbes;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Whether we've invalidated this bugger. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fZombie;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync } DTrace;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVTRACERDATA;
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync/** Pointer to the tracer data associated with a provider. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPDRVTRACERDATA *PSUPDRVTRACERDATA;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Probe location info for ring-0.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Since we cannot trust user tracepoint modules, we need to duplicate the probe
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * ID and enabled flag in ring-0.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVPROBELOC
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The probe ID. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t idProbe;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Whether it's enabled or not. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fEnabled;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVPROBELOC;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a ring-0 probe location record. */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsynctypedef SUPDRVPROBELOC *PSUPDRVPROBELOC;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Probe info for ring-0.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Since we cannot trust user tracepoint modules, we need to duplicate the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * probe enable count.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVPROBEINFO
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The number of times this probe has been enabled. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t volatile cEnabled;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVPROBEINFO;
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync/** Pointer to a ring-0 probe info record. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPDRVPROBEINFO *PSUPDRVPROBEINFO;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Support driver tracepoint provider core.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVVDTPROVIDERCORE
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The tracer data member. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync SUPDRVTRACERDATA TracerData;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the provider name (a copy that's always available). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync const char *pszName;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the module name (a copy that's always available). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync const char *pszModName;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The provider descriptor. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync struct VTGDESCPROVIDER *pDesc;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The VTG header. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync struct VTGOBJHDR *pHdr;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The size of the entries in the pvProbeLocsEn table. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint8_t cbProbeLocsEn;
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync /** The actual module bit count (corresponds to cbProbeLocsEn). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint8_t cBits;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Set if this is a Umod, otherwise clear.. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync bool fUmod;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Explicit alignment padding (paranoia). */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync uint8_t abAlignment[ARCH_BITS == 32 ? 1 : 5];
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The probe locations used for descriptive purposes. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync struct VTGPROBELOC const *paProbeLocsRO;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the probe location array where the enable flag needs
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * flipping. For kernel providers, this will always be SUPDRVPROBELOC,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * while user providers can either be 32-bit or 64-bit. Use
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * cbProbeLocsEn to calculate the address of an entry. */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync void *pvProbeLocsEn;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Pointer to the probe array containing the enabled counts. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t *pacProbeEnabled;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The ring-0 probe location info for user tracepoint modules.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * This is NULL if fUmod is false. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync PSUPDRVPROBELOC paR0ProbeLocs;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The ring-0 probe info for user tracepoint modules.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This is NULL if fUmod is false. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync PSUPDRVPROBEINFO paR0Probes;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVVDTPROVIDERCORE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a tracepoint provider core structure. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef SUPDRVVDTPROVIDERCORE *PSUPDRVVDTPROVIDERCORE;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a tracer registration record. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVTRACERREG const *PCSUPDRVTRACERREG;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Support driver tracer registration record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVTRACERREG
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync /** Magic value (SUPDRVTRACERREG_MAGIC). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t u32Magic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** Version (SUPDRVTRACERREG_VERSION). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint32_t u32Version;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Fire off a kernel probe.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVtgProbeLoc The probe location record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg0 The first raw probe argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg1 The second raw probe argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg2 The third raw probe argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg3 The fourth raw probe argument.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * @param uArg4 The fifth raw probe argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks SUPR0TracerFireProbe will do a tail jump thru this member, so
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * no extra stack frames will be added.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @remarks This does not take a 'this' pointer argument because it doesn't map
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * well onto VTG or DTrace.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(void, pfnProbeFireKernel, (struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uintptr_t uArg3, uintptr_t uArg4));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Fire off a user-mode probe.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pThis Pointer to the registration record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVtgProbeLoc The probe location record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The user session.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pCtx The usermode context info.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pVtgHdr The VTG header (read-only).
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pProbeLocRO The read-only probe location record .
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync DECLR0CALLBACKMEMBER(void, pfnProbeFireUser, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync struct VTGOBJHDR const *pVtgHdr, struct VTGPROBELOC const *pProbeLocRO));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Opens up the tracer.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pThis Pointer to the registration record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session doing the opening.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uCookie A cookie (magic) unique to the tracer, so it can
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * fend off incompatible clients.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg Tracer specific argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param puSessionData Pointer to the session data variable. This must be
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * set to a non-zero value on success.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(int, pfnTracerOpen, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie, uintptr_t uArg,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uintptr_t *puSessionData));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * I/O control style tracer communication method.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pThis Pointer to the registration record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uSessionData The session data value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uCmd The tracer specific command.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uArg The tracer command specific argument.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param piRetVal The tracer specific return value.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(int, pfnTracerIoCtl, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Cleans up data the tracer has associated with a session.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pThis Pointer to the registration record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The session handle.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param uSessionData The data assoicated with the session.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(void, pfnTracerClose, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Registers a provider.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pThis Pointer to the registration record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pCore The provider core data.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @todo Kernel vs. Userland providers.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(int, pfnProviderRegister, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Attempts to deregisters a provider.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VINF_SUCCESS or VERR_TRY_AGAIN. If the latter, the provider
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * should be made as harmless as possible before returning as the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * VTG object and associated code will be unloaded upon return.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pThis Pointer to the registration record.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pCore The provider core data.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(int, pfnProviderDeregister, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Make another attempt at unregister a busy provider.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VINF_SUCCESS or VERR_TRY_AGAIN.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pThis Pointer to the registration record.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * @param pCore The provider core data.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync DECLR0CALLBACKMEMBER(int, pfnProviderDeregisterZombie, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** End marker (SUPDRVTRACERREG_MAGIC). */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync uintptr_t uEndMagic;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVTRACERREG;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Tracer magic (Kenny Garrett). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPDRVTRACERREG_MAGIC UINT32_C(0x19601009)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Tracer registration structure version. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPDRVTRACERREG_VERSION RT_MAKE_U32(0, 1)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync/** Pointer to a trace helper structure. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef struct SUPDRVTRACERHLP const *PCSUPDRVTRACERHLP;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Helper structure.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsynctypedef struct SUPDRVTRACERHLP
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** The structure version (SUPDRVTRACERHLP_VERSION). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uintptr_t uVersion;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** @todo ... */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync /** End marker (SUPDRVTRACERHLP_VERSION) */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uintptr_t uEndVersion;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync} SUPDRVTRACERHLP;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Tracer helper structure version. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPDRVTRACERHLP_VERSION RT_MAKE_U32(0, 1)
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0TracerRegisterImpl(void *hMod, PSUPDRVSESSION pSession, PCSUPDRVTRACERREG pReg, PCSUPDRVTRACERHLP *ppHlp);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0TracerDeregisterImpl(void *hMod, PSUPDRVSESSION pSession);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(int) SUPR0TracerRegisterDrv(PSUPDRVSESSION pSession, struct VTGOBJHDR *pVtgHdr, const char *pszName);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0TracerDeregisterDrv(PSUPDRVSESSION pSession);
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsyncSUPR0DECL(int) SUPR0TracerRegisterModule(void *hMod, struct VTGOBJHDR *pVtgHdr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0TracerFireProbe(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uintptr_t uArg3, uintptr_t uArg4);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsyncSUPR0DECL(void) SUPR0TracerUmodProbeFire(PSUPDRVSESSION pSession, PSUPDRVTRACERUSRCTX pCtx);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @} */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync/**
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * Service request callback function.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync *
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @returns VBox status code.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param pSession The caller's session.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @param u64Arg 64-bit integer argument.
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync * @param pReqHdr The request header. Input / Output. Optional.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef DECLCALLBACK(int) FNSUPR0SERVICEREQHANDLER(PSUPDRVSESSION pSession, uint32_t uOperation,
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** Pointer to a FNR0SERVICEREQHANDLER(). */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsynctypedef R0PTRTYPE(FNSUPR0SERVICEREQHANDLER *) PFNSUPR0SERVICEREQHANDLER;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
8f28e374e0b8ea801e7b5364bccd8a7e0a6211d3vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** @defgroup grp_sup_r0_idc The IDC Interface
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * @{
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync/** The current SUPDRV IDC version.
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * This follows the usual high word / low word rules, i.e. high word is the
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync * major number and it signifies incompatible interface changes. */
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync#define SUPDRV_IDC_VERSION UINT32_C(0x00010000)
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/**
b1e4667c5a9588bd509d569ce252127891b44923vboxsync * Inter-Driver Communication Handle.
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync */
b1e4667c5a9588bd509d569ce252127891b44923vboxsynctypedef union SUPDRVIDCHANDLE
b1e4667c5a9588bd509d569ce252127891b44923vboxsync{
b1e4667c5a9588bd509d569ce252127891b44923vboxsync /** Padding for opaque usage.
b1e4667c5a9588bd509d569ce252127891b44923vboxsync * Must be greater or equal in size than the private struct. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync void *apvPadding[4];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync#ifdef SUPDRVIDCHANDLEPRIVATE_DECLARED
b1e4667c5a9588bd509d569ce252127891b44923vboxsync /** The private view. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync struct SUPDRVIDCHANDLEPRIVATE s;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync#endif
b1e4667c5a9588bd509d569ce252127891b44923vboxsync} SUPDRVIDCHANDLE;
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync/** Pointer to a handle. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsynctypedef SUPDRVIDCHANDLE *PSUPDRVIDCHANDLE;
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncSUPR0DECL(int) SUPR0IdcOpen(PSUPDRVIDCHANDLE pHandle, uint32_t uReqVersion, uint32_t uMinVersion,
b1e4667c5a9588bd509d569ce252127891b44923vboxsync uint32_t *puSessionVersion, uint32_t *puDriverVersion, uint32_t *puDriverRevision);
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncSUPR0DECL(int) SUPR0IdcCall(PSUPDRVIDCHANDLE pHandle, uint32_t iReq, void *pvReq, uint32_t cbReq);
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncSUPR0DECL(int) SUPR0IdcClose(PSUPDRVIDCHANDLE pHandle);
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncSUPR0DECL(PSUPDRVSESSION) SUPR0IdcGetSession(PSUPDRVIDCHANDLE pHandle);
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncSUPR0DECL(int) SUPR0IdcComponentRegisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory);
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncSUPR0DECL(int) SUPR0IdcComponentDeregisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory);
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** @} */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** @name Ring-0 module entry points.
c2f73fbf271131906a68f2583f744fe791dd0f11vboxsync *
b1e4667c5a9588bd509d569ce252127891b44923vboxsync * These can be exported by ring-0 modules SUP are told to load.
c2f73fbf271131906a68f2583f744fe791dd0f11vboxsync *
b1e4667c5a9588bd509d569ce252127891b44923vboxsync * @{ */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncDECLEXPORT(int) ModuleInit(void *hMod);
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncDECLEXPORT(void) ModuleTerm(void *hMod);
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** @} */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** @} */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync#endif
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** @name Trust Anchors and Certificates
b1e4667c5a9588bd509d569ce252127891b44923vboxsync * @{ */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/**
b1e4667c5a9588bd509d569ce252127891b44923vboxsync * Trust anchor table entry (in generated Certificates.cpp).
b1e4667c5a9588bd509d569ce252127891b44923vboxsync */
b1e4667c5a9588bd509d569ce252127891b44923vboxsynctypedef struct SUPTAENTRY
b1e4667c5a9588bd509d569ce252127891b44923vboxsync{
b1e4667c5a9588bd509d569ce252127891b44923vboxsync /** Pointer to the raw bytes. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync const unsigned char *pch;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync /** Number of bytes. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync unsigned cb;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync} SUPTAENTRY;
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync/** Pointer to a trust anchor table entry. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsynctypedef SUPTAENTRY const *PCSUPTAENTRY;
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Macro for simplifying generating the trust anchor tables. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync#define SUPTAENTRY_GEN(a_abTA) { &a_abTA[0], sizeof(a_abTA) }
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** All certificates we know. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern SUPTAENTRY const g_aSUPAllTAs[];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Number of entries in g_aSUPAllTAs. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern unsigned const g_cSUPAllTAs;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Software publisher certificate roots (Authenticode). */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern SUPTAENTRY const g_aSUPSpcRootTAs[];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Number of entries in g_aSUPSpcRootTAs. */
c2f73fbf271131906a68f2583f744fe791dd0f11vboxsyncextern unsigned const g_cSUPSpcRootTAs;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
c2f73fbf271131906a68f2583f744fe791dd0f11vboxsync/** Kernel root certificates used by Windows. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern SUPTAENTRY const g_aSUPNtKernelRootTAs[];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Number of entries in g_aSUPNtKernelRootTAs. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern unsigned const g_cSUPNtKernelRootTAs;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Timestamp root certificates trusted by Windows. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern SUPTAENTRY const g_aSUPTimestampTAs[];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Number of entries in g_aSUPTimestampTAs. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern unsigned const g_cSUPTimestampTAs;
65c72795ab90d3daefa759b716fbb5c6352c7a56vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** TAs we trust (the build certificate, Oracle VirtualBox). */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern SUPTAENTRY const g_aSUPTrustedTAs[];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Number of entries in g_aSUPTrustedTAs. */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsyncextern unsigned const g_cSUPTrustedTAs;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Supplemental certificates, like cross signing certificates. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern SUPTAENTRY const g_aSUPSupplementalTAs[];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** Number of entries in g_aSUPTrustedTAs. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern unsigned const g_cSUPSupplementalTAs;
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** The build certificate. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern const unsigned char g_abSUPBuildCert[];
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** The size of the build certificate. */
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncextern const unsigned g_cbSUPBuildCert;
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** @} */
ea4433aedd4105e6599e57e0c5f6cb32a68e963cvboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync/** @} */
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsyncRT_C_DECLS_END
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync#endif
b1e4667c5a9588bd509d569ce252127891b44923vboxsync
b1e4667c5a9588bd509d569ce252127891b44923vboxsync