Skip to content

Commit

Permalink
x86/sev: Drop redundant and potentially misleading 'sev_enabled'
Browse files Browse the repository at this point in the history
Drop the sev_enabled flag and switch its one user over to sev_active().
sev_enabled was made redundant with the introduction of sev_status in
commit b57de6c ("x86/sev-es: Add SEV-ES Feature Detection").
sev_enabled and sev_active() are guaranteed to be equivalent, as each is
true iff 'sev_status & MSR_AMD64_SEV_ENABLED' is true, and are only ever
written in tandem (ignoring compressed boot's version of sev_status).

Removing sev_enabled avoids confusion over whether it refers to the guest
or the host, and will also allow KVM to usurp "sev_enabled" for its own
purposes.

No functional change intended.

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210422021125.3417167-7-seanjc@google.com>
Acked-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Sean Christopherson authored and Paolo Bonzini committed Apr 26, 2021
1 parent 0133807 commit 4daf2a1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
1 change: 0 additions & 1 deletion arch/x86/include/asm/mem_encrypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

extern u64 sme_me_mask;
extern u64 sev_status;
extern bool sev_enabled;

void sme_encrypt_execute(unsigned long encrypted_kernel_vaddr,
unsigned long decrypted_kernel_vaddr,
Expand Down
10 changes: 4 additions & 6 deletions arch/x86/mm/mem_encrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ EXPORT_SYMBOL(sme_me_mask);
DEFINE_STATIC_KEY_FALSE(sev_enable_key);
EXPORT_SYMBOL_GPL(sev_enable_key);

bool sev_enabled __section(".data");

/* Buffer used for early in-place encryption by BSP, no locking needed */
static char sme_early_buffer[PAGE_SIZE] __initdata __aligned(PAGE_SIZE);

Expand Down Expand Up @@ -373,14 +371,14 @@ int __init early_set_memory_encrypted(unsigned long vaddr, unsigned long size)
* up under SME the trampoline area cannot be encrypted, whereas under SEV
* the trampoline area must be encrypted.
*/
bool sme_active(void)
bool sev_active(void)
{
return sme_me_mask && !sev_enabled;
return sev_status & MSR_AMD64_SEV_ENABLED;
}

bool sev_active(void)
bool sme_active(void)
{
return sev_status & MSR_AMD64_SEV_ENABLED;
return sme_me_mask && !sev_active();
}
EXPORT_SYMBOL_GPL(sev_active);

Expand Down
1 change: 0 additions & 1 deletion arch/x86/mm/mem_encrypt_identity.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ void __init sme_enable(struct boot_params *bp)

/* SEV state cannot be controlled by a command line option */
sme_me_mask = me_mask;
sev_enabled = true;
physical_mask &= ~sme_me_mask;
return;
}
Expand Down

0 comments on commit 4daf2a1

Please sign in to comment.