diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2010-11-29 11:51:47 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-01-12 04:30:04 -0500 |
commit | ec9e60b21977007e3dfacc2b8fe3a8fbb9276b51 (patch) | |
tree | 419f1a51980fb3cd93ab857d0c47457795fa90ef | |
parent | 6389ee946303cb4313dba0a49865e495a53351ff (diff) |
KVM: X86: Introduce generic guest-mode representation
This patch introduces a generic representation of guest-mode
fpr a vcpu. This currently only exists in the SVM code.
Having this representation generic will help making the
non-svm code aware of nesting when this is necessary.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/kvm_cache_regs.h | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 0c0941db31c4..56e45a2ed2de 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -779,6 +779,7 @@ enum { | |||
779 | #define HF_VINTR_MASK (1 << 2) | 779 | #define HF_VINTR_MASK (1 << 2) |
780 | #define HF_NMI_MASK (1 << 3) | 780 | #define HF_NMI_MASK (1 << 3) |
781 | #define HF_IRET_MASK (1 << 4) | 781 | #define HF_IRET_MASK (1 << 4) |
782 | #define HF_GUEST_MASK (1 << 5) /* VCPU is in guest-mode */ | ||
782 | 783 | ||
783 | /* | 784 | /* |
784 | * Hardware virtualization extension instructions may fault if a | 785 | * Hardware virtualization extension instructions may fault if a |
diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_regs.h index 975bb45329a1..95ac3afa6e6f 100644 --- a/arch/x86/kvm/kvm_cache_regs.h +++ b/arch/x86/kvm/kvm_cache_regs.h | |||
@@ -84,4 +84,19 @@ static inline u64 kvm_read_edx_eax(struct kvm_vcpu *vcpu) | |||
84 | | ((u64)(kvm_register_read(vcpu, VCPU_REGS_RDX) & -1u) << 32); | 84 | | ((u64)(kvm_register_read(vcpu, VCPU_REGS_RDX) & -1u) << 32); |
85 | } | 85 | } |
86 | 86 | ||
87 | static inline void enter_guest_mode(struct kvm_vcpu *vcpu) | ||
88 | { | ||
89 | vcpu->arch.hflags |= HF_GUEST_MASK; | ||
90 | } | ||
91 | |||
92 | static inline void leave_guest_mode(struct kvm_vcpu *vcpu) | ||
93 | { | ||
94 | vcpu->arch.hflags &= ~HF_GUEST_MASK; | ||
95 | } | ||
96 | |||
97 | static inline bool is_guest_mode(struct kvm_vcpu *vcpu) | ||
98 | { | ||
99 | return vcpu->arch.hflags & HF_GUEST_MASK; | ||
100 | } | ||
101 | |||
87 | #endif | 102 | #endif |