From: Dave Hansen <dave@sr71.net>
To: Ingo Molnar <mingo@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Anvin <hpa@zytor.com>, Denys Vlasenko <dvlasenk@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
bp@alien8.de, Peter Zijlstra <a.p.zijlstra@chello.nl>,
fenghua.yu@intel.com, x86@kernel.org,
dave.hansen@linux.intel.com
Subject: Re: [PATCH] x86, fpu: correct XSAVE xstate size calculation
Date: Thu, 06 Aug 2015 07:56:10 -0700 [thread overview]
Message-ID: <55C3758A.50005@sr71.net> (raw)
In-Reply-To: <20150806082746.GA10974@gmail.com>
I think we have three options. Here's some rough pseudo-ish-code to
sketch them out.
/* Option 1, what we have today */
/*
* This breaks if offset[i]+size[i] != offset[i+1]
* or if alignment is in play. Silly hardware breaks
* this today.
*/
for (i = 0; i < nr_xstates; i++) {
if (!enabled_xstate(i))
continue;
total_blob_size += xstate_sizes[i];
}
/* Option 2: search for the end of the last state, probably works, Ingo likes? */
for (i = 0; i < nr_xstates; i++) {
if (cpu_has_xsaves && !enabled_xstate(i))
continue;
end_of_state = xstate_offsets[i] + xstate_sizes[i];
if (xstate_is_aligned[i]) /* currently not implemented */
end_of_state = ALIGN(end_of_state, 64);
if (end_of_state > total_blob_size)
total_blob_size = end_of_state;
}
/* align unconditionally, maybe??? */
total_blob_size = ALIGN(total_blob_size, 64);
/* Double check our obviously bug-free math with what the CPU says */
if (!cpu_has_xsaves)
cpuid(0xD0, 0, &check_total_blob_size, ...);
else
cpuid(0xD0, 1, &check_total_blob_size, ...);
WARN_ON(check_total_blob_size != total_blob_size);
/* Option 3, trust the CPU (what Dave's patch does) */
if (!cpu_has_xsaves)
cpuid(0xD0, 0, &total_blob_size, ...);
else
cpuid(0xD0, 1, &total_blob_size, ...);
next prev parent reply other threads:[~2015-08-06 14:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 17:21 Dave Hansen
2015-08-05 10:32 ` Ingo Molnar
2015-08-05 14:34 ` Dave Hansen
2015-08-06 7:15 ` Ingo Molnar
[not found] ` <CA+55aFxzOj-Ee=DN-_3CMeDeYVsmvmmgoxd3hp4MpRSp+og7AQ@mail.gmail.com>
2015-08-06 8:27 ` Ingo Molnar
2015-08-06 8:29 ` Ingo Molnar
2015-08-06 14:56 ` Dave Hansen [this message]
2015-08-06 16:03 ` Dave Hansen
2015-08-08 9:15 ` Ingo Molnar
2015-08-06 17:19 ` Dave Hansen
2015-08-08 9:06 ` Ingo Molnar
2015-08-10 21:14 ` Dave Hansen
2015-08-22 13:21 ` Ingo Molnar
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=55C3758A.50005@sr71.net \
--to=dave@sr71.net \
--cc=a.p.zijlstra@chello.nl \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=dvlasenk@redhat.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome