From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 14/41] KVM: Fold kvm_run::exit_type into kvm_run::exit_reason
Date: Sun, 1 Apr 2007 17:35:11 +0300 [thread overview]
Message-ID: <11754381391514-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <11754381393496-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Currently, userspace is told about the nature of the last exit from the
guest using two fields, exit_type and exit_reason, where exit_type has
just two enumerations (and no need for more). So fold exit_type into
exit_reason, reducing the complexity of determining what really happened.
Signed-off-by: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
drivers/kvm/kvm_main.c | 3 +--
drivers/kvm/svm.c | 7 +++----
drivers/kvm/vmx.c | 7 +++----
include/linux/kvm.h | 15 ++++++++-------
4 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index de93117..ac44df5 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1608,8 +1608,7 @@ static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
vcpu->mmio_needed = 0;
- if (kvm_run->exit_type == KVM_EXIT_TYPE_VM_EXIT
- && kvm_run->exit_reason == KVM_EXIT_HYPERCALL) {
+ if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL) {
kvm_arch_ops->cache_regs(vcpu);
vcpu->regs[VCPU_REGS_RAX] = kvm_run->hypercall.ret;
kvm_arch_ops->decache_regs(vcpu);
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index d4b2936..b09928f 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1298,8 +1298,6 @@ static int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
{
u32 exit_code = vcpu->svm->vmcb->control.exit_code;
- kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT;
-
if (is_external_interrupt(vcpu->svm->vmcb->control.exit_int_info) &&
exit_code != SVM_EXIT_EXCP_BASE + PF_VECTOR)
printk(KERN_ERR "%s: unexpected exit_ini_info 0x%x "
@@ -1609,8 +1607,9 @@ again:
vcpu->svm->next_rip = 0;
if (vcpu->svm->vmcb->control.exit_code == SVM_EXIT_ERR) {
- kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY;
- kvm_run->exit_reason = vcpu->svm->vmcb->control.exit_code;
+ kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;
+ kvm_run->fail_entry.hardware_entry_failure_reason
+ = vcpu->svm->vmcb->control.exit_code;
post_kvm_run_save(vcpu, kvm_run);
return 0;
}
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 71410a6..cf9568f 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1922,10 +1922,10 @@ again:
asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
- kvm_run->exit_type = 0;
if (fail) {
- kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY;
- kvm_run->exit_reason = vmcs_read32(VM_INSTRUCTION_ERROR);
+ kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;
+ kvm_run->fail_entry.hardware_entry_failure_reason
+ = vmcs_read32(VM_INSTRUCTION_ERROR);
r = 0;
} else {
/*
@@ -1935,7 +1935,6 @@ again:
profile_hit(KVM_PROFILING, (void *)vmcs_readl(GUEST_RIP));
vcpu->launched = 1;
- kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT;
r = kvm_handle_exit(kvm_run, vcpu);
if (r > 0) {
/* Give scheduler a change to reschedule. */
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 9151ebf..57f47ef 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -11,7 +11,7 @@
#include <asm/types.h>
#include <linux/ioctl.h>
-#define KVM_API_VERSION 7
+#define KVM_API_VERSION 8
/*
* Architectural interrupt line count, and the size of the bitmap needed
@@ -34,9 +34,6 @@ struct kvm_memory_region {
#define KVM_MEM_LOG_DIRTY_PAGES 1UL
-#define KVM_EXIT_TYPE_FAIL_ENTRY 1
-#define KVM_EXIT_TYPE_VM_EXIT 2
-
enum kvm_exit_reason {
KVM_EXIT_UNKNOWN = 0,
KVM_EXIT_EXCEPTION = 1,
@@ -47,6 +44,7 @@ enum kvm_exit_reason {
KVM_EXIT_MMIO = 6,
KVM_EXIT_IRQ_WINDOW_OPEN = 7,
KVM_EXIT_SHUTDOWN = 8,
+ KVM_EXIT_FAIL_ENTRY = 9,
};
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
@@ -57,12 +55,11 @@ struct kvm_run {
__u8 padding1[3];
/* out */
- __u32 exit_type;
__u32 exit_reason;
__u32 instruction_length;
__u8 ready_for_interrupt_injection;
__u8 if_flag;
- __u16 padding2;
+ __u8 padding2[6];
/* in (pre_kvm_run), out (post_kvm_run) */
__u64 cr8;
@@ -71,8 +68,12 @@ struct kvm_run {
union {
/* KVM_EXIT_UNKNOWN */
struct {
- __u32 hardware_exit_reason;
+ __u64 hardware_exit_reason;
} hw;
+ /* KVM_EXIT_FAIL_ENTRY */
+ struct {
+ __u64 hardware_entry_failure_reason;
+ } fail_entry;
/* KVM_EXIT_EXCEPTION */
struct {
__u32 exception;
--
1.5.0.5
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
next prev parent reply other threads:[~2007-04-01 14:35 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-01 14:34 [PATCH 00/41] kvm updates for 2.6.22 Avi Kivity
[not found] ` <1175438138288-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:34 ` [PATCH 01/41] KVM: Fix guest register corruption on paravirt hypercall Avi Kivity
[not found] ` <11754381381990-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:34 ` [PATCH 02/41] KVM: Use the generic skip_emulated_instruction() in hypercall code Avi Kivity
[not found] ` <11754381384009-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 03/41] KVM: Use own minor number Avi Kivity
[not found] ` <1175438138805-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 04/41] KVM: Export <linux/kvm.h> Avi Kivity
[not found] ` <11754381382515-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 05/41] KVM: Fix bogus sign extension in mmu mapping audit Avi Kivity
[not found] ` <11754381383730-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 06/41] KVM: Use a shared page for kernel/user communication when runing a vcpu Avi Kivity
[not found] ` <11754381383144-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 07/41] KVM: Do not communicate to userspace through cpu registers during PIO Avi Kivity
[not found] ` <11754381381597-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 08/41] KVM: Handle cpuid in the kernel instead of punting to userspace Avi Kivity
[not found] ` <1175438139242-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 09/41] KVM: Remove the 'emulated' field from the userspace interface Avi Kivity
[not found] ` <1175438139494-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 10/41] KVM: Remove minor wart from KVM_CREATE_VCPU ioctl Avi Kivity
[not found] ` <11754381392046-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 11/41] KVM: Renumber ioctls Avi Kivity
[not found] ` <1175438139795-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 12/41] KVM: Add method to check for backwards-compatible API extensions Avi Kivity
[not found] ` <1175438139430-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 13/41] KVM: Allow userspace to process hypercalls which have no kernel handler Avi Kivity
[not found] ` <11754381393496-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` Avi Kivity [this message]
[not found] ` <11754381391514-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 15/41] KVM: Add a special exit reason when exiting due to an interrupt Avi Kivity
[not found] ` <11754381392382-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 16/41] KVM: Initialize the apic_base msr on svm too Avi Kivity
[not found] ` <11754381392358-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 17/41] KVM: Add guest mode signal mask Avi Kivity
[not found] ` <1175438139872-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 18/41] KVM: Allow kernel to select size of mmap() buffer Avi Kivity
[not found] ` <11754381392921-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 19/41] KVM: Future-proof argument-less ioctls Avi Kivity
[not found] ` <117543813978-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 20/41] KVM: Avoid guest virtual addresses in string pio userspace interface Avi Kivity
[not found] ` <117543 81393061-git-send-email-avi@qumranet.com>
[not found] ` <11754381393061-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 21/41] KVM: MMU: Remove unnecessary check for pdptr access Avi Kivity
[not found] ` <11754381392186-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 22/41] KVM: MMU: Remove global pte tracking Avi Kivity
[not found] ` <117543813916-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 23/41] KVM: Workaround vmx inability to virtualize the reset state Avi Kivity
[not found] ` <1175438139530-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 24/41] KVM: Remove set_cr0_no_modeswitch() arch op Avi Kivity
[not found] ` <1175438139960-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 25/41] KVM: Modify guest segments after potentially switching modes Avi Kivity
[not found] ` <1175438139816-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 26/41] KVM: Hack real-mode segments on vmx from KVM_SET_SREGS Avi Kivity
[not found] ` <1175438139141-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 27/41] KVM: Don't allow the guest to turn off the cpu cache Avi Kivity
[not found] ` <11754381391993-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 28/41] KVM: Remove unused and write-only variables Avi Kivity
[not found] ` <1175438139877-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 29/41] KVM: Handle writes to MCG_STATUS msr Avi Kivity
[not found] ` <11754381391119-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 30/41] KVM: SVM: forbid guest to execute monitor/mwait Avi Kivity
[not found] ` <1175438139312-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 31/41] KVM: MMU: Fix hugepage pdes mapping same physical address with different access Avi Kivity
[not found] ` <11754381392527-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 32/41] KVM: SVM: Ensure timestamp counter monotonicity Avi Kivity
[not found] ` <11754381393184-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 33/41] KVM: Remove unused function Avi Kivity
[not found] ` <1175438139249-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 34/41] KVM: Use list_move() Avi Kivity
[not found] ` <11754381391161-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 35/41] KVM: Remove debug message Avi Kivity
[not found] ` <11754381393714-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 36/41] KVM: x86 emulator: fix bit string operations operand size Avi Kivity
[not found] ` <11754381392948-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 37/41] KVM: Add mmu cache clear function Avi Kivity
[not found] ` <1175438139458-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 38/41] KVM: Simply gfn_to_page() Avi Kivity
[not found] ` <117543813933-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 39/41] KVM: Add physical memory aliasing feature Avi Kivity
[not found] ` <11754381393962-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 40/41] KVM: Add fpu get/set operations Avi Kivity
[not found] ` <11754381393751-git-send-ema il-avi@qumranet.com>
[not found] ` <11754381393751-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-04-01 14:35 ` [PATCH 41/41] KVM: SVM: enable LBRV virtualization if available Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=11754381391514-git-send-email-avi@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox