0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/* $Id$ */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @file
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * GIM - KVM, Internal header file.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/*
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * Copyright (C) 2015 Oracle Corporation
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync *
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * available from http://www.virtualbox.org. This file is free software;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * you can redistribute it and/or modify it under the terms of the GNU
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * General Public License (GPL) as published by the Free Software
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#ifndef ___GIMKvmInternal_h
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define ___GIMKvmInternal_h
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#include <VBox/vmm/gim.h>
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#include <VBox/vmm/cpum.h>
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @name KVM base features.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * @{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Old, deprecated clock source available. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_CLOCK_OLD RT_BIT(0)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** No need for artifical delays on IO operations. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_NOP_IO_DELAY RT_BIT(1)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** MMU op supported (deprecated, unused). */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_MMU_OP RT_BIT(2)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Clock source available. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_CLOCK RT_BIT(3)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Asynchronous page faults supported. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_ASYNC_PF RT_BIT(4)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Steal time (VCPU not executing guest code time in ns) available. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_STEAL_TIME RT_BIT(5)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Paravirtualized EOI (end-of-interrupt) supported. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_PV_EOI RT_BIT(6)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Paravirtualized spinlock (unhalting VCPU) supported. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_PV_UNHALT RT_BIT(7)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** The TSC is stable (fixed rate, monotonic). */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_BASE_FEAT_TSC_STABLE RT_BIT(24)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @} */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @name KVM MSRs.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * @{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Start of range 0. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_RANGE0_START UINT32_C(0x11)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Old, deprecated wall clock. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_WALL_CLOCK_OLD UINT32_C(0x11)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Old, deprecated System time. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_SYSTEM_TIME_OLD UINT32_C(0x12)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** End of range 0. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_RANGE0_END MSR_GIM_KVM_SYSTEM_TIME_OLD
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Start of range 1. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_RANGE1_START UINT32_C(0x4b564d00)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Wall clock. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_WALL_CLOCK UINT32_C(0x4b564d00)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** System time. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_SYSTEM_TIME UINT32_C(0x4b564d01)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Asynchronous page fault. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_ASYNC_PF UINT32_C(0x4b564d02)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Steal time. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_STEAL_TIME UINT32_C(0x4b564d03)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Paravirtualized EOI (end-of-interrupt). */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_EOI UINT32_C(0x4b564d04)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** End of range 1. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_RANGE1_END MSR_GIM_KVM_EOI
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncAssertCompile(MSR_GIM_KVM_RANGE0_START <= MSR_GIM_KVM_RANGE0_END);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncAssertCompile(MSR_GIM_KVM_RANGE1_START <= MSR_GIM_KVM_RANGE1_END);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** KVM page size. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_PAGE_SIZE 0x1000
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/**
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * MMIO2 region indices.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** The system time page(s) region. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_SYSTEM_TIME_PAGE_REGION_IDX UINT8_C(0)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** The steal time page(s) region. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_STEAL_TIME_PAGE_REGION_IDX UINT8_C(1)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** The maximum region index (must be <= UINT8_MAX). */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_REGION_IDX_MAX GIM_KVM_STEAL_TIME_PAGE_REGION_IDX
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/**
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * KVM system-time structure (GIM_KVM_SYSTEM_TIME_FLAGS_XXX) flags.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * See "Documentation/virtual/kvm/api.txt".
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** The TSC is stable (monotonic). */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_SYSTEM_TIME_FLAGS_TSC_STABLE RT_BIT(0)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** The guest VCPU has been paused by the hypervisor. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define GIM_KVM_SYSTEM_TIME_FLAGS_GUEST_PAUSED RT_BIT(1)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @name KVM MSR - System time (MSR_GIM_KVM_SYSTEM_TIME and
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * MSR_GIM_KVM_SYSTEM_TIME_OLD).
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * @{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** The system-time enable bit. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_SYSTEM_TIME_ENABLE_BIT RT_BIT_64(0)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Whether the system-time struct. is enabled or not. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_SYSTEM_TIME_IS_ENABLED(a) RT_BOOL((a) & MSR_GIM_KVM_SYSTEM_TIME_ENABLE_BIT)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Guest-physical address of the system-time struct. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#define MSR_GIM_KVM_SYSTEM_TIME_GUEST_GPA(a) ((a) & ~MSR_GIM_KVM_SYSTEM_TIME_ENABLE_BIT)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @} */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @name KVM MSR - Wall clock (MSR_GIM_KVM_WALL_CLOCK and
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * MSR_GIM_KVM_WALL_CLOCK_OLD).
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * @{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Guest-physical address of the wall-clock struct. */
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define MSR_GIM_KVM_WALL_CLOCK_GUEST_GPA(a) (a)
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** @} */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync/** @name KVM Hypercall operations.
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync * @{ */
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_OP_VAPIC_POLL_IRQ 1
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_OP_MMU 2
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_OP_FEATURES 3
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_OP_KICK_CPU 5
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync/** @} */
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync/** @name KVM Hypercall return values.
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync * @{ */
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync/* Return values for hypercalls */
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_RET_SUCCESS 0
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_RET_ENOSYS (uint64_t)(-1000)
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_RET_EFAULT (uint64_t)(-14)
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_RET_E2BIG (uint64_t)(-7)
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync#define KVM_HYPERCALL_RET_EPERM (uint64_t)(-1)
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync/** @} */
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/**
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * KVM per-VCPU system-time structure.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef struct GIMKVMSYSTEMTIME
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Version (sequence number). */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t u32Version;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Alignment padding. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t u32Padding0;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** TSC time stamp. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint64_t u64Tsc;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** System time in nanoseconds. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint64_t u64NanoTS;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** TSC to system time scale factor. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t u32TscScale;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** TSC frequency shift. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync int8_t i8TscShift;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Clock source (GIM_KVM_SYSTEM_TIME_FLAGS_XXX) flags. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint8_t fFlags;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Alignment padding. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint8_t abPadding0[2];
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync} GIMKVMSYSTEMTIME;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to KVM system-time struct. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVMSYSTEMTIME *PGIMKVMSYSTEMTIME;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to a const KVM system-time struct. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVMSYSTEMTIME const *PCGIMKVMSYSTEMTIME;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncAssertCompileSize(GIMKVMSYSTEMTIME, 32);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/**
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * KVM per-VM wall-clock structure.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef struct GIMKVMWALLCLOCK
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Version (sequence number). */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t u32Version;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Number of seconds since boot. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t u32Sec;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Number of nanoseconds since boot. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t u32Nano;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync} GIMKVMWALLCLOCK;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to KVM wall-clock struct. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVMWALLCLOCK *PGIMKVMWALLCLOCK;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to a const KVM wall-clock struct. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVMWALLCLOCK const *PCGIMKVMWALLCLOCK;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncAssertCompileSize(GIMKVMWALLCLOCK, 12);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/**
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * GIM KVMV VM instance data.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * Changes to this must checked against the padding of the gim union in VM!
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef struct GIMKVM
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** Wall-clock MSR. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint64_t u64WallClockMsr;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
fa35e2dfd910e18dbb7f136bfe56030e5116d51cvboxsync /** CPUID features: Basic. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t uBaseFeat;
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync
fa35e2dfd910e18dbb7f136bfe56030e5116d51cvboxsync /** Whether GIM needs to trap #UD exceptions. */
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync bool fTrapXcptUD;
fa35e2dfd910e18dbb7f136bfe56030e5116d51cvboxsync /** Disassembler opcode of hypercall instruction native for this host CPU. */
fa35e2dfd910e18dbb7f136bfe56030e5116d51cvboxsync uint16_t uOpCodeNative;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync} GIMKVM;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to per-VM GIM KVM instance data. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVM *PGIMKVM;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to const per-VM GIM KVM instance data. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVM const *PCGIMKVM;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/**
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * GIM KVMV VCPU instance data.
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync * Changes to this must checked against the padding of the gim union in VMCPU!
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef struct GIMKVMCPU
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync{
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** System-time MSR. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint64_t u64SystemTimeMsr;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** The guest-physical address of the system-time struct. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync RTGCPHYS GCPhysSystemTime;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync /** The version (sequence number) of the system-time struct. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync uint32_t u32SystemTimeVersion;
6fd7ca38c2e6dbc9871b33b11cf70ed6bf4e7d03vboxsync /** The guest TSC value while enabling the system-time MSR. */
6fd7ca38c2e6dbc9871b33b11cf70ed6bf4e7d03vboxsync uint64_t uTsc;
6fd7ca38c2e6dbc9871b33b11cf70ed6bf4e7d03vboxsync /** The guest virtual time while enabling the system-time MSR. */
6fd7ca38c2e6dbc9871b33b11cf70ed6bf4e7d03vboxsync uint64_t uVirtNanoTS;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync} GIMKVMCPU;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to per-VCPU GIM KVM instance data. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVMCPU *PGIMKVMCPU;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync/** Pointer to const per-VCPU GIM KVM instance data. */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsynctypedef GIMKVMCPU const *PCGIMKVMCPU;
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncRT_C_DECLS_BEGIN
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#ifdef IN_RING0
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#if 0
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR0_INT_DECL(int) gimR0KvmInitVM(PVM pVM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR0_INT_DECL(int) gimR0KvmTermVM(PVM pVM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR0_INT_DECL(int) gimR0KvmUpdateParavirtTsc(PVM pVM, uint64_t u64Offset);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#endif
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#endif /* IN_RING0 */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#ifdef IN_RING3
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(int) gimR3KvmInit(PVM pVM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(int) gimR3KvmInitCompleted(PVM pVM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(int) gimR3KvmTerm(PVM pVM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(void) gimR3KvmRelocate(PVM pVM, RTGCINTPTR offDelta);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(void) gimR3KvmReset(PVM pVM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(int) gimR3KvmSave(PVM pVM, PSSMHANDLE pSSM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(int) gimR3KvmLoad(PVM pVM, PSSMHANDLE pSSM, uint32_t uSSMVersion);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(int) gimR3KvmDisableSystemTime(PVM pVM);
6fd7ca38c2e6dbc9871b33b11cf70ed6bf4e7d03vboxsyncVMMR3_INT_DECL(int) gimR3KvmEnableSystemTime(PVM pVM, PVMCPU pVCpu, PGIMKVMCPU pKvmCpu, uint8_t fFlags);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMMR3_INT_DECL(int) gimR3KvmEnableWallClock(PVM pVM, RTGCPHYS GCPhysSysTime, uint32_t uVersion);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#endif /* IN_RING3 */
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMM_INT_DECL(bool) gimKvmIsParavirtTscEnabled(PVM pVM);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMM_INT_DECL(bool) gimKvmAreHypercallsEnabled(PVMCPU pVCpu);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMM_INT_DECL(int) gimKvmHypercall(PVMCPU pVCpu, PCPUMCTX pCtx);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMM_INT_DECL(VBOXSTRICTRC) gimKvmReadMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue);
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncVMM_INT_DECL(VBOXSTRICTRC) gimKvmWriteMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uRawValue);
66d96ba0c4c722996a3a1e6d92403a14a27db1b4vboxsyncVMM_INT_DECL(bool) gimKvmShouldTrapXcptUD(PVMCPU pVCpu);
fa35e2dfd910e18dbb7f136bfe56030e5116d51cvboxsyncVMM_INT_DECL(int) gimKvmXcptUD(PVMCPU pVCpu, PCPUMCTX pCtx, PDISCPUSTATE pDis);
9c178a84047ec38c02debb747cbdc7de4531d940vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsyncRT_C_DECLS_END
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync#endif
0bc35f54322c5f9b2d43b064f839a8cf8c99a234vboxsync