From: Richard Henderson <richard.henderson@linaro.org>
To: Doug Gale <doug16k@gmail.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2] Add AVX, AVX-512, MPX support to x86_cpu_dump_state
Date: Thu, 7 Dec 2017 14:37:27 -0800 [thread overview]
Message-ID: <3f70d49d-30ff-384f-c942-8f1dbc2cd53c@linaro.org> (raw)
In-Reply-To: <20171203063548.10297-1-doug16k@gmail.com>
On 12/02/2017 10:35 PM, Doug Gale wrote:
> Signed-off-by: Doug Gale <doug16k@gmail.com>
> ---
> Fix MSB LSB showing when SSE is disabled
> target/i386/helper.c | 95 +++++++++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 83 insertions(+), 12 deletions(-)
>
> diff --git a/target/i386/helper.c b/target/i386/helper.c
> index f63eb3d3f4..03812b6e87 100644
> --- a/target/i386/helper.c
> +++ b/target/i386/helper.c
> @@ -543,6 +543,7 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
> }
> }
> cpu_fprintf(f, "EFER=%016" PRIx64 "\n", env->efer);
> + cpu_fprintf(f, "XCR0=%016" PRIx64 "\n", env->xcr0);
> if (flags & CPU_DUMP_FPU) {
> int fptag;
> fptag = 0;
> @@ -565,21 +566,91 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
> else
> cpu_fprintf(f, " ");
> }
> - if (env->hflags & HF_CS64_MASK)
> - nb = 16;
> - else
> +
> + if (env->hflags & HF_CS64_MASK) {
> + if (env->xcr0 & XSTATE_Hi16_ZMM_MASK) {
> + /* AVX-512 32 registers enabled */
> + nb = 32;
> + } else {
> + /* 64-bit mode, 16 registers */
> + nb = 16;
> + }
> + } else {
> + /* 32 bit mode, 8 registers */
> nb = 8;
> - for(i=0;i<nb;i++) {
> - cpu_fprintf(f, "XMM%02d=%08x%08x%08x%08x",
> - i,
> - env->xmm_regs[i].ZMM_L(3),
> - env->xmm_regs[i].ZMM_L(2),
> - env->xmm_regs[i].ZMM_L(1),
> - env->xmm_regs[i].ZMM_L(0));
> - if ((i & 1) == 1)
> + }
> +
> + /* sse register width in units of 64 bits */
> + int zmm_width;
> + char zmm_name;
> + if (env->xcr0 & XSTATE_ZMM_Hi256_MASK) {
> + /* 512-bit "ZMM" - AVX-512 registers enabled */
> + zmm_width = 8;
> + zmm_name = 'Z';
> + } else if (env->xcr0 & XSTATE_YMM_MASK) {
> + /* 256-bit "YMM" - AVX enabled */
> + zmm_width = 4;
> + zmm_name = 'Y';
> + } else if (env->cr[4] & CR4_OSFXSR_MASK) {
> + /* 128-bit "XMM" - SSE enabled */
> + zmm_width = 2;
> + zmm_name = 'X';
> + } else {
> + /* SSE not enabled */
> + zmm_width = 0;
> + zmm_name = 0;
You should exit the function here ...
> + }
> +
> + if (zmm_width > 0) {
> + cpu_fprintf(f, " MSB%*sLSB\n",
> + -(zmm_width * 16 + zmm_width - 7), "");
> + }
> +
> + for (i = 0; i < nb; i++) {
> + if (zmm_width == 0) {
> + cpu_fprintf(f, "SSE not enabled\n");
> + break;
> + }
... rather than performing this test in a loop.
Or indeed, printing anything at all.
I assume this is in order to examine registers in the monitor under kvm?
r~
next prev parent reply other threads:[~2017-12-07 22:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-03 6:35 [Qemu-devel] [PATCH v2] Add AVX, AVX-512, MPX support to x86_cpu_dump_state Doug Gale
2017-12-07 22:37 ` Richard Henderson [this message]
2017-12-07 23:01 ` Doug Gale
2018-01-17 18:51 ` Dr. David Alan Gilbert
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=3f70d49d-30ff-384f-c942-8f1dbc2cd53c@linaro.org \
--to=richard.henderson@linaro.org \
--cc=doug16k@gmail.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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;
as well as URLs for NNTP newsgroup(s).