From: Paolo Bonzini <pbonzini@redhat.com>
To: Bandan Das <bsd@redhat.com>
Cc: kvm@vger.kernel.org, Gleb Natapov <gleb@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Subject: Re: [PATCH v2 1/2] kvm: make vendor_intel a generic function
Date: Wed, 05 Jun 2013 01:33:26 +0200 [thread overview]
Message-ID: <51AE7946.9060908@redhat.com> (raw)
In-Reply-To: <1370361738-4277-2-git-send-email-bsd@redhat.com>
Il 04/06/2013 18:02, Bandan Das ha scritto:
> Make vendor_intel generic so that functions in x86.c
> can use it.
>
> v2:
> Change vendor_intel function signature because the emulator
> shouldn't be dealing with struct vcpu
>
> Signed-off-by: Bandan Das <bsd@redhat.com>
> ---
> arch/x86/include/asm/kvm_emulate.h | 13 -------------
> arch/x86/include/asm/kvm_host.h | 20 ++++++++++++++++++++
> arch/x86/kvm/emulate.c | 16 ++++------------
> 3 files changed, 24 insertions(+), 25 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
> index 15f960c..611a55f 100644
> --- a/arch/x86/include/asm/kvm_emulate.h
> +++ b/arch/x86/include/asm/kvm_emulate.h
> @@ -319,19 +319,6 @@ struct x86_emulate_ctxt {
> #define REPE_PREFIX 0xf3
> #define REPNE_PREFIX 0xf2
>
> -/* CPUID vendors */
> -#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541
> -#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163
> -#define X86EMUL_CPUID_VENDOR_AuthenticAMD_edx 0x69746e65
> -
> -#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx 0x69444d41
> -#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx 0x21726574
> -#define X86EMUL_CPUID_VENDOR_AMDisbetterI_edx 0x74656273
> -
> -#define X86EMUL_CPUID_VENDOR_GenuineIntel_ebx 0x756e6547
> -#define X86EMUL_CPUID_VENDOR_GenuineIntel_ecx 0x6c65746e
> -#define X86EMUL_CPUID_VENDOR_GenuineIntel_edx 0x49656e69
> -
> enum x86_intercept_stage {
> X86_ICTP_NONE = 0, /* Allow zero-init to not match anything */
> X86_ICPT_PRE_EXCEPT,
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 3741c65..ce9a44f 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -144,6 +144,19 @@ enum {
>
> #include <asm/kvm_emulate.h>
>
> +/* CPUID vendors */
> +#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx 0x68747541
> +#define X86EMUL_CPUID_VENDOR_AuthenticAMD_ecx 0x444d4163
> +#define X86EMUL_CPUID_VENDOR_AuthenticAMD_edx 0x69746e65
> +
> +#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ebx 0x69444d41
> +#define X86EMUL_CPUID_VENDOR_AMDisbetterI_ecx 0x21726574
> +#define X86EMUL_CPUID_VENDOR_AMDisbetterI_edx 0x74656273
> +
> +#define X86EMUL_CPUID_VENDOR_GenuineIntel_ebx 0x756e6547
> +#define X86EMUL_CPUID_VENDOR_GenuineIntel_ecx 0x6c65746e
> +#define X86EMUL_CPUID_VENDOR_GenuineIntel_edx 0x49656e69
> +
> #define KVM_NR_MEM_OBJS 40
>
> #define KVM_NR_DB_REGS 4
> @@ -942,6 +955,13 @@ static inline unsigned long read_msr(unsigned long msr)
> }
> #endif
>
> +static inline bool vendor_intel(u32 ebx, u32 ecx, u32 edx)
> +{
> + return ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx
> + && ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx
> + && edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx;
> +}
> +
> static inline u32 get_rdx_init_val(void)
> {
> return 0x600; /* P6 family */
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index 8db0010..87f12fc 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -2280,17 +2280,6 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
> ss->avl = 0;
> }
>
> -static bool vendor_intel(struct x86_emulate_ctxt *ctxt)
> -{
> - u32 eax, ebx, ecx, edx;
> -
> - eax = ecx = 0;
> - ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx);
> - return ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx
> - && ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx
> - && edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx;
> -}
> -
> static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt)
> {
> const struct x86_emulate_ops *ops = ctxt->ops;
> @@ -2400,6 +2389,7 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
> u64 msr_data;
> u16 cs_sel, ss_sel;
> u64 efer = 0;
> + u32 eax, ebx, ecx, edx;
>
> ops->get_msr(ctxt, MSR_EFER, &efer);
> /* inject #GP if in real mode */
> @@ -2410,8 +2400,10 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
> * Not recognized on AMD in compat mode (but is recognized in legacy
> * mode).
> */
> + eax = ecx = 0;
> + ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx);
> if ((ctxt->mode == X86EMUL_MODE_PROT32) && (efer & EFER_LMA)
> - && !vendor_intel(ctxt))
> + && !vendor_intel(ebx, ecx, edx))
> return emulate_ud(ctxt);
>
> /* XXX sysenter/sysexit have not been tested in 64bit mode.
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2013-06-04 23:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-04 16:02 [PATCH v2 0/2] kvm: x86: Emulate MSR_PLATFORM_INFO Bandan Das
2013-06-04 16:02 ` [PATCH v2 1/2] kvm: make vendor_intel a generic function Bandan Das
2013-06-04 23:33 ` Paolo Bonzini [this message]
2013-06-04 16:02 ` [PATCH v2 2/2] kvm: x86: emulate MSR_PLATFORM_INFO Bandan Das
2013-06-18 14:07 ` Paolo Bonzini
2013-06-18 15:11 ` Bandan Das
2013-06-05 8:42 ` [PATCH v2 0/2] kvm: x86: Emulate MSR_PLATFORM_INFO Gleb Natapov
2013-06-18 14:05 ` Paolo Bonzini
2013-06-18 15:16 ` Gleb Natapov
2013-06-18 15:29 ` Bandan Das
2013-06-18 15:40 ` Gleb Natapov
2013-06-19 17:50 ` Bandan Das
2013-06-20 7:31 ` Gleb Natapov
2013-06-20 8:34 ` Paolo Bonzini
2013-06-20 8:57 ` Gleb Natapov
2013-06-18 17:59 ` Nakajima, Jun
2013-06-19 10:57 ` Gleb Natapov
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=51AE7946.9060908@redhat.com \
--to=pbonzini@redhat.com \
--cc=bsd@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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.