summaryrefslogtreecommitdiff
path: root/kvm_x86impl.h
blob: 6fdcfd3cb06ae750c6c069a330dd763bb50bbbe2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * GPL HEADER START
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * GPL HEADER END
 *
 * Copyright 2011 various Linux Kernel contributors.
 * Copyright (c) 2012 Joyent, Inc. All Rights Reserved.
 */

#ifndef __KVM_X86_IMPL_H
#define	__KVM_X86_IMPL_H

#include <sys/types.h>
#include <vm/page.h>

#include "kvm_host.h"
#include "kvm_x86.h"
#include "kvm_cache_regs.h"

extern void kvm_clear_exception_queue(struct kvm_vcpu *);
extern void kvm_queue_interrupt(struct kvm_vcpu *, uint8_t, int);
extern void kvm_clear_interrupt_queue(struct kvm_vcpu *);
extern int kvm_event_needs_reinjection(struct kvm_vcpu *);
extern int kvm_exception_is_soft(unsigned int nr);
extern kvm_cpuid_entry2_t *kvm_find_cpuid_entry(struct kvm_vcpu *,
    uint32_t, uint32_t);
extern int is_protmode(struct kvm_vcpu *);
extern int is_long_mode(struct kvm_vcpu *);
extern int is_pae(struct kvm_vcpu *);
extern int is_pse(struct kvm_vcpu *);
extern int is_paging(struct kvm_vcpu *);

extern caddr_t page_address(page_t *);
extern page_t *alloc_page(int, void **);
extern uint64_t kvm_va2pa(caddr_t);
extern page_t *pfn_to_page(pfn_t);
extern int zero_constructor(void *, void *, int);

#define	KVM_CPUALL -1

typedef void (*kvm_xcall_t)(void *);
extern void kvm_xcall(processorid_t, kvm_xcall_t, void *);
extern int kvm_xcall_func(kvm_xcall_t, void *);

extern unsigned long native_read_cr0(void);
#define	read_cr0()	(native_read_cr0())
extern unsigned long native_read_cr4(void);
#define	read_cr4()	(native_read_cr4())
extern unsigned long native_read_cr3(void);
#define	read_cr3()	(native_read_cr3())

extern page_t *compound_head(page_t *);
extern void get_page(page_t *);
extern unsigned long get_desc_limit(const struct desc_struct *);

extern unsigned long get_desc_base(const struct desc_struct *);
extern uint32_t bit(int);

#endif