Re: your patch "crypto: sha1 - SSSE3 based SHA1 implementation forx86-64" vs xsave

From: Mathias Krause
Date: Thu Nov 17 2011 - 09:13:08 EST


On Thu, Nov 17, 2011 at 2:09 PM, Jan Beulich <JBeulich@xxxxxxxx> wrote:
>> I don't see where X86_CR4_OSXSAVE would get reset after xsave init.
>> Can you give me a pointer to that code?
>
> I didn't say it would get cleared. I said it should be used in favor of
> cpu_has_osxsave.
>
>>> Additionally, under a hypervisor, CPUID.OSXSAVE may be set (due to
>>> the hypervisor having enabled xsave), while the kernel may be running
>>> with xsave disabled (e.g. due to a command line option saying so).
>>
>> When noxsave is given on the kernel command line, X86_FEATURE_XSAVE
>> will be cleared and xsave_init() won't call xstate_enable(), so not
>> setting X86_CR4_OSXSAVE. All fine.
>
> But you're not looking at this bit, you're looking at cpu_has_osxsave,
> which is a CPUID bit (not a CR4 one).

You're right. But that's no problem at all, as the cpu_has_* tests are
only to error out early. They also ensure it is save to execute the
next instruction -- xsetbv(). This instruction actually does the xsave
runtime support check by looking at the extended control register XCR0
and the enabled features in there.
So you're right that the cpu_has_osxsave might be superfluous here but
it doesn't hurt either.

Mathias
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/