From: Jan Kiszka <jan.kiszka@siemens.com>
To: "Mihai Donțu" <mdontu@bitdefender.com>, kvm@vger.kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, gleb@kernel.org, pbonzini@redhat.com,
wanpeng.li@linux.intel.com, guangrong.xiao@linux.intel.com,
kai.huang@linux.intel.com, rkrcmar@redhat.com,
mtosatti@redhat.com, pmatouse@redhat.com, fanwenyi0529@gmail.com,
linux-kernel@vger.kernel.org,
"Mihai Donțu" <mihai.dontu@gmail.com>
Subject: Re: [PATCH] kvm/x86: add support for MONITOR_TRAP_FLAG
Date: Thu, 09 Jul 2015 21:49:46 +0200 [thread overview]
Message-ID: <559ED05A.3040107@siemens.com> (raw)
In-Reply-To: <1436116137-20262-1-git-send-email-mdontu@bitdefender.com>
On 2015-07-05 19:08, Mihai Donțu wrote:
> Allow a nested hypervisor to single step its guests.
>
> Signed-off-by: Mihai Donțu <mihai.dontu@gmail.com>
>
> ---
>
> This patch applies on top of current linux-next.
> ---
> arch/x86/include/asm/vmx.h | 1 +
> arch/x86/include/uapi/asm/vmx.h | 2 ++
> arch/x86/kvm/vmx.c | 10 +++++++++-
> 3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
> index da772ed..9299ae5 100644
> --- a/arch/x86/include/asm/vmx.h
> +++ b/arch/x86/include/asm/vmx.h
> @@ -47,6 +47,7 @@
> #define CPU_BASED_MOV_DR_EXITING 0x00800000
> #define CPU_BASED_UNCOND_IO_EXITING 0x01000000
> #define CPU_BASED_USE_IO_BITMAPS 0x02000000
> +#define CPU_BASED_MONITOR_TRAP_FLAG 0x08000000
> #define CPU_BASED_USE_MSR_BITMAPS 0x10000000
> #define CPU_BASED_MONITOR_EXITING 0x20000000
> #define CPU_BASED_PAUSE_EXITING 0x40000000
> diff --git a/arch/x86/include/uapi/asm/vmx.h b/arch/x86/include/uapi/asm/vmx.h
> index 1fe9218..37fee27 100644
> --- a/arch/x86/include/uapi/asm/vmx.h
> +++ b/arch/x86/include/uapi/asm/vmx.h
> @@ -58,6 +58,7 @@
> #define EXIT_REASON_INVALID_STATE 33
> #define EXIT_REASON_MSR_LOAD_FAIL 34
> #define EXIT_REASON_MWAIT_INSTRUCTION 36
> +#define EXIT_REASON_MONITOR_TRAP_FLAG 37
> #define EXIT_REASON_MONITOR_INSTRUCTION 39
> #define EXIT_REASON_PAUSE_INSTRUCTION 40
> #define EXIT_REASON_MCE_DURING_VMENTRY 41
> @@ -106,6 +107,7 @@
> { EXIT_REASON_MSR_READ, "MSR_READ" }, \
> { EXIT_REASON_MSR_WRITE, "MSR_WRITE" }, \
> { EXIT_REASON_MWAIT_INSTRUCTION, "MWAIT_INSTRUCTION" }, \
> + { EXIT_REASON_MONITOR_TRAP_FLAG, "MONITOR_TRAP_FLAG" }, \
> { EXIT_REASON_MONITOR_INSTRUCTION, "MONITOR_INSTRUCTION" }, \
> { EXIT_REASON_PAUSE_INSTRUCTION, "PAUSE_INSTRUCTION" }, \
> { EXIT_REASON_MCE_DURING_VMENTRY, "MCE_DURING_VMENTRY" }, \
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index e856dd5..6d7c650 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -2443,7 +2443,7 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
> CPU_BASED_CR8_LOAD_EXITING | CPU_BASED_CR8_STORE_EXITING |
> #endif
> CPU_BASED_MOV_DR_EXITING | CPU_BASED_UNCOND_IO_EXITING |
> - CPU_BASED_USE_IO_BITMAPS | CPU_BASED_MONITOR_EXITING |
> + CPU_BASED_USE_IO_BITMAPS | CPU_BASED_MONITOR_TRAP_FLAG | CPU_BASED_MONITOR_EXITING |
Overlong line.
> CPU_BASED_RDPMC_EXITING | CPU_BASED_RDTSC_EXITING |
> CPU_BASED_PAUSE_EXITING | CPU_BASED_TPR_SHADOW |
> CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
> @@ -6246,6 +6246,11 @@ static int handle_mwait(struct kvm_vcpu *vcpu)
> return handle_nop(vcpu);
> }
>
> +static int handle_monitor_trap(struct kvm_vcpu *vcpu)
> +{
> + return 1;
> +}
> +
> static int handle_monitor(struct kvm_vcpu *vcpu)
> {
> printk_once(KERN_WARNING "kvm: MONITOR instruction emulated as NOP!\n");
> @@ -7282,6 +7287,7 @@ static int (*const kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
> [EXIT_REASON_EPT_MISCONFIG] = handle_ept_misconfig,
> [EXIT_REASON_PAUSE_INSTRUCTION] = handle_pause,
> [EXIT_REASON_MWAIT_INSTRUCTION] = handle_mwait,
> + [EXIT_REASON_MONITOR_TRAP_FLAG] = handle_monitor_trap,
> [EXIT_REASON_MONITOR_INSTRUCTION] = handle_monitor,
> [EXIT_REASON_INVEPT] = handle_invept,
> [EXIT_REASON_INVVPID] = handle_invvpid,
> @@ -7542,6 +7548,8 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu *vcpu)
> return true;
> case EXIT_REASON_MWAIT_INSTRUCTION:
> return nested_cpu_has(vmcs12, CPU_BASED_MWAIT_EXITING);
> + case EXIT_REASON_MONITOR_TRAP_FLAG:
> + return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_TRAP_FLAG);
> case EXIT_REASON_MONITOR_INSTRUCTION:
> return nested_cpu_has(vmcs12, CPU_BASED_MONITOR_EXITING);
> case EXIT_REASON_PAUSE_INSTRUCTION:
>
Looks OK otherwise. If you fix up the style thing, you may add my
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Jan
--
Siemens AG, Corporate Technology, CT RTC ITP SES-DE
Corporate Competence Center Embedded Linux
next prev parent reply other threads:[~2015-07-09 19:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-05 17:08 [PATCH] kvm/x86: add support for MONITOR_TRAP_FLAG Mihai Donțu
2015-07-09 19:49 ` Jan Kiszka [this message]
2015-07-10 11:28 ` Paolo Bonzini
2015-07-10 16:05 ` Mihai Donțu
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=559ED05A.3040107@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=fanwenyi0529@gmail.com \
--cc=gleb@kernel.org \
--cc=guangrong.xiao@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kai.huang@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdontu@bitdefender.com \
--cc=mihai.dontu@gmail.com \
--cc=mingo@redhat.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pmatouse@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=wanpeng.li@linux.intel.com \
--cc=x86@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.