* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: vcpu.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
#pragma ident "@(#)vcpu.h 1.10 07/07/09 SMI"
#include <sun4v/traps.h> /* for MAXPTL */
* Size of svc code's per-cpu scratch area in 64-bit words
#define NSVCSCRATCHREGS 6
* Number of per-cpu scratch locations
* hvctl register save size
#define REG_STORE_SZ (28 * 8)
typedef struct vcpu vcpu_t
;
typedef struct mau mau_t
;
typedef struct cwq cwq_t
;
typedef struct rng rng_t
;
typedef struct vcpustate vcpustate_t
;
* we preserve htstate for vcpu in case at some point
* we add new "hyperprivileged" features relevent
* to that vcpu - e.g. "trap on level zero" etc.
typedef struct vcpu_trapstate vcpu_trapstate_t
;
uint64_t g
[7]; /* ignore g0 */
typedef struct vcpu_globals vcpu_globals_t
;
vcpu_trapstate_t trapstack
[MAXTL
];
vcpu_globals_t globals
[MAXGL
];
struct rwindow wins
[NWINDOWS
];
uint16_t error_resumable_head
;
uint16_t error_resumable_tail
;
uint16_t error_nonresumable_head
;
uint16_t error_nonresumable_tail
;
* Temp staging for info gleaned from MD node.
* VCPU utilisation statistics
typedef struct vcpu_util
{
uint64_t stick_last
; /* last time stats were read */
volatile uint64_t yield_count
; /* total yielded cycles */
uint64_t yield_start
; /* start of yield in progress */
uint64_t last_yield_count_guest
; /* previous guest yield count */
uint64_t last_yield_count_vcpu
; /* previous vcpu yield count */
error IDs
for cpus in
this HV use
8 bit values
if you want more than
error
256 cpus you need to find all these
and change to wider types
* This is the virtual cpu struct. There's one per virtual cpu.
struct guest
*guest
; /* pointer to owning guest */
uint8_t vid
; /* virtual cpu number */
uint8_t parttag
; /* id to use for partition tag reg */
uint64_t scr
[NCPUSCRATCH
]; /* scratch space */
* Configuration and running status
volatile uint64_t status
;
uint64_t ttrace_buf_size
;
uint8_t tsbds_ctx0
[MAX_NTSB
* TSBD_BYTES
];
uint8_t tsbds_ctxn
[MAX_NTSB
* TSBD_BYTES
];
uint64_t mmustat_area_ra
;
uint64_t svcregs
[NSVCSCRATCHREGS
];
* LDC interrupt handling/delivery
uint32_t ldc_intr_pend
; /* pending flag for synchronization */
uint64_t ldc_endpoint
; /* target endpt structure */
uint64_t ldc_sp_endpt
; /* for save/restore around callbacks */
uint64_t ldc_sp_arg
; /* for save/restore around callbacks */
uint64_t ldc_sp_arg_pc
; /* for save/restore around callbacks */
uint64_t ldc_cb_scr1
; /* scratch reg used in callback */
uint64_t ldc_cb_scr2
; /* scratch reg used in callback */
* Virtual CPU state save area
struct vcpustate state_save_area
;
uint8_t launch_with_retry
;
* Utilisation statistics area
extern void init_vcpu(int id
);
extern void reset_vcpu_state(vcpu_t
*vp
);
extern void c_desched_n_stop_vcpu(vcpu_t
*vp
);
* Per-vcpu low-level mailbox commands, see vcpu.command.
* Over time, the list of commands that use the vcpu mailbox
* has dwindled. Everything other than the cpu_mondo_send hcall
* has been converted to use the hvxcall mechanism. Once that
* has been modified to use hvxcalls as well, the vcpu mailbox
* can be removed in its entirety.
#define CPU_CMD_READY 0x0
#define CPU_CMD_GUESTMONDO_READY 0x3