Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1522631 > unrolled thread
| Started by | Joerg Roedel <joro@8bytes.org> |
|---|---|
| First post | 2016-11-15 13:20 +0100 |
| Last post | 2016-11-15 22:40 +0100 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME Joerg Roedel <joro@8bytes.org> - 2016-11-15 13:20 +0100
Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME Borislav Petkov <bp@alien8.de> - 2016-11-15 13:20 +0100
Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME Borislav Petkov <bp@alien8.de> - 2016-11-15 16:40 +0100
Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME Borislav Petkov <bp@alien8.de> - 2016-11-15 17:40 +0100
Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME Borislav Petkov <bp@alien8.de> - 2016-11-15 22:40 +0100
| From | Joerg Roedel <joro@8bytes.org> |
|---|---|
| Date | 2016-11-15 13:20 +0100 |
| Subject | Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME |
| Message-ID | <sDKSt-4PB-17@gated-at.bofh.it> |
On Wed, Nov 09, 2016 at 06:35:13PM -0600, Tom Lendacky wrote:
> +/*
> + * AMD Secure Memory Encryption (SME) can reduce the size of the physical
> + * address space if it is enabled, even if memory encryption is not active.
> + * Adjust x86_phys_bits if SME is enabled.
> + */
> +static void phys_bits_adjust(struct cpuinfo_x86 *c)
> +{
Better call this function amd_sme_phys_bits_adjust(). This name makes it
clear at the call-site why it is there and what it does.
> + u32 eax, ebx, ecx, edx;
> + u64 msr;
> +
> + if (c->x86_vendor != X86_VENDOR_AMD)
> + return;
> +
> + if (c->extended_cpuid_level < 0x8000001f)
> + return;
> +
> + /* Check for SME feature */
> + cpuid(0x8000001f, &eax, &ebx, &ecx, &edx);
> + if (!(eax & 0x01))
> + return;
Maybe add a comment here why you can't use cpu_has (yet).
[toc] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-11-15 13:20 +0100 |
| Message-ID | <sDKSt-4PB-13@gated-at.bofh.it> |
| In reply to | #1522631 |
On Tue, Nov 15, 2016 at 01:10:35PM +0100, Joerg Roedel wrote:
> Maybe add a comment here why you can't use cpu_has (yet).
So that could be alleviated by moving this function *after*
init_scattered_cpuid_features(). Then you can simply do *cpu_has().
Also, I'm not sure why we're checking CPUID for the SME feature when we
have sme_get_me_mask() et al which have been setup much earlier...
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-11-15 16:40 +0100 |
| Message-ID | <sDO02-6JS-37@gated-at.bofh.it> |
| In reply to | #1522634 |
On Tue, Nov 15, 2016 at 08:40:05AM -0600, Tom Lendacky wrote:
> The feature may be present and enabled even if it is not currently
> active. In other words, the SYS_CFG MSR bit could be set but we aren't
> actually using encryption (sme_me_mask is 0). As long as the SYS_CFG
> MSR bit is set we need to take into account the physical reduction in
> address space.
But later in the series I see sme_early_mem_enc() which tests exactly
that mask.
And in patch 12 you have:
+ /*
+ * If memory encryption is active, the trampoline area will need to
+ * be in un-encrypted memory in order to bring up other processors
+ * successfully.
+ */
+ sme_early_mem_dec(__pa(base), size);
+ sme_set_mem_unenc(base, size);
What's up?
IOW, it all sounds to me like you want to have an sme_active() helper
and use it everywhere.
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-11-15 17:40 +0100 |
| Message-ID | <sDOW5-7mP-21@gated-at.bofh.it> |
| In reply to | #1522837 |
On Tue, Nov 15, 2016 at 10:06:16AM -0600, Tom Lendacky wrote:
> Yes, but that doesn't relate to the physical address space reduction.
>
> Once the SYS_CFG MSR bit for SME is set, even if the encryption bit is
> never used, there is a physical reduction of the address space. So when
> checking whether to adjust the physical address bits I can't rely on the
> sme_me_mask, I have to look at the MSR.
>
> But when I'm looking to decide whether to encrypt or decrypt something,
> I use the sme_me_mask to decide if that is needed. If the sme_me_mask
> is not set then the encrypt/decrypt op shouldn't be performed.
>
> I might not be grasping the point you're trying to make...
Ok, let me try to summarize how I see it. There are a couple of states:
* CPUID bit in 0x8000001f - that's SME supported
* Reduction of address space - MSR bit. That could be called "SME
BIOS-eenabled".
* SME active. That's both of the above and is sme_me_mask != 0.
Right?
So you said previously "The feature may be present and enabled even if
it is not currently active."
But then you say "active" below
> > And in patch 12 you have:
> >
> > + /*
> > + * If memory encryption is active, the trampoline area will need to
> > + * be in un-encrypted memory in order to bring up other processors
> > + * successfully.
> > + */
> > + sme_early_mem_dec(__pa(base), size);
> > + sme_set_mem_unenc(base, size);
and test sme_me_mask. Which makes sense now after having explained which
hw setting controls what.
So can we agree on the nomenclature for all the different SME states
first and use those throughout the code? And hold those states down in
Documentation/x86/amd-memory-encryption.txt so that it is perfectly
clear to people looking at the code.
Also, if we need to check those states more than once, we should add
inline helpers:
sme_supported()
sme_bios_enabled()
sme_active()
How does that sound?
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2016-11-15 22:40 +0100 |
| Message-ID | <sDTCp-1UC-1@gated-at.bofh.it> |
| In reply to | #1522634 |
On Tue, Nov 15, 2016 at 03:22:45PM -0600, Tom Lendacky wrote:
> Hmmm... I still need the ebx value from the CPUID instruction to
> calculate the proper reduction in physical bits, so I'll still need
> to make the CPUID call.
if (c->extended_cpuid_level >= 0x8000001f) {
cpuid(0x8000001f, &eax, &ebx, &ecx, &edx);
...
just like the rest of get_cpu_cap() :)
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web