public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Stefan Bader <stefan.bader@canonical.com>
Cc: stable@vger.kernel.org, kvm@vger.kernel.org,
	Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>,
	Avi Kivity <avi@redhat.com>
Subject: Re: [v3.0.y 1/2] KVM: x86: extend "struct x86_emulate_ops" with "get_cpuid"
Date: Fri, 23 Mar 2012 11:00:52 -0300	[thread overview]
Message-ID: <20120323140052.GA8174@amt.cnet> (raw)
In-Reply-To: <1332406246-3978-4-git-send-email-stefan.bader@canonical.com>

On Thu, Mar 22, 2012 at 09:50:43AM +0100, Stefan Bader wrote:
> >From eaee58e1433e1b16e686cfcdcbc207d4310a239f Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Stephan=20B=C3=A4rwolf?= <stephan.baerwolf@tu-ilmenau.de>
> Date: Thu, 12 Jan 2012 16:43:03 +0100
> Subject: [PATCH 7/8] KVM: x86: extend "struct x86_emulate_ops" with
>  "get_cpuid"
> 
> In order to be able to proceed checks on CPU-specific properties
> within the emulator, function "get_cpuid" is introduced.
> With "get_cpuid" it is possible to virtually call the guests
> "cpuid"-opcode without changing the VM's context.
> 
> [mtosatti: cleanup/beautify code]
> 
> Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
> 
> (cherry-picked from commit bdb42f5afebe208eae90406959383856ae2caf2b upstream)
> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  arch/x86/include/asm/kvm_emulate.h |    3 +++
>  arch/x86/kvm/x86.c                 |   23 +++++++++++++++++++++++
>  2 files changed, 26 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
> index 0049211..18e54f1 100644
> --- a/arch/x86/include/asm/kvm_emulate.h
> +++ b/arch/x86/include/asm/kvm_emulate.h
> @@ -189,6 +189,9 @@ struct x86_emulate_ops {
>  	int (*intercept)(struct x86_emulate_ctxt *ctxt,
>  			 struct x86_instruction_info *info,
>  			 enum x86_intercept_stage stage);
> +
> +	bool (*get_cpuid)(struct x86_emulate_ctxt *ctxt,
> +			 u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
>  };
>  
>  typedef u32 __attribute__((vector_size(16))) sse128_t;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index bc58ede..8e15578 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4436,6 +4436,28 @@ static int emulator_intercept(struct x86_emulate_ctxt *ctxt,
>  	return kvm_x86_ops->check_intercept(emul_to_vcpu(ctxt), info, stage);
>  }
>  
> +static bool emulator_get_cpuid(struct x86_emulate_ctxt *ctxt,
> +			       u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
> +{
> +	struct kvm_cpuid_entry2 *cpuid = NULL;
> +
> +	if (eax && ecx)
> +		cpuid = kvm_find_cpuid_entry(emul_to_vcpu(ctxt),
> +					    *eax, *ecx);
> +
> +	if (cpuid) {
> +		*eax = cpuid->eax;
> +		*ecx = cpuid->ecx;
> +		if (ebx)
> +			*ebx = cpuid->ebx;
> +		if (edx)
> +			*edx = cpuid->edx;
> +		return true;
> +	}
> +
> +	return false;
> +}
> +
>  static struct x86_emulate_ops emulate_ops = {
>  	.read_std            = kvm_read_guest_virt_system,
>  	.write_std           = kvm_write_guest_virt_system,
> @@ -4466,6 +4488,7 @@ static struct x86_emulate_ops emulate_ops = {
>  	.get_fpu             = emulator_get_fpu,
>  	.put_fpu             = emulator_put_fpu,
>  	.intercept           = emulator_intercept,
> +	.get_cpuid           = emulator_get_cpuid,
>  };
>  
>  static void cache_all_regs(struct kvm_vcpu *vcpu)

ACK

  reply	other threads:[~2012-03-23 14:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22  8:50 CVE-2012-0045 for 3.2.y, 3.0.y and 2.6.32.y (again) Stefan Bader
2012-03-22  8:50 ` [v2.6.32.y 1/2] KVM: x86: extend "struct x86_emulate_ops" with "get_cpuid" Stefan Bader
2012-03-22  8:50 ` [v2.6.32.y 2/2] KVM: x86: fix missing checks in syscall emulation Stefan Bader
2012-03-23  0:07   ` Marcelo Tosatti
2012-03-23  7:01     ` Stefan Bader
2012-03-22  8:50 ` [v3.0.y 1/2] KVM: x86: extend "struct x86_emulate_ops" with "get_cpuid" Stefan Bader
2012-03-23 14:00   ` Marcelo Tosatti [this message]
2012-03-23 17:22   ` Greg KH
2012-03-23 17:47     ` Stefan Bader
2012-03-23 17:57       ` Greg KH
2012-03-22  8:50 ` [v3.0.y 2/2] KVM: x86: fix missing checks in syscall emulation Stefan Bader
2012-03-23 14:01   ` Marcelo Tosatti
2012-03-22  8:50 ` [v3.2.y 1/2] KVM: x86: extend "struct x86_emulate_ops" with "get_cpuid" Stefan Bader
2012-03-22  8:50 ` [v3.2.y 2/2] KVM: x86: fix missing checks in syscall emulation Stefan Bader
2012-03-22 14:37 ` CVE-2012-0045 for 3.2.y, 3.0.y and 2.6.32.y (again) Greg KH
2012-03-23  1:47 ` Marcelo Tosatti

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=20120323140052.GA8174@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stefan.bader@canonical.com \
    --cc=stephan.baerwolf@tu-ilmenau.de \
    /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