From: Borislav Petkov <bp@alien8.de>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org,
iommu@lists.linux-foundation.org, kvm@vger.kernel.org,
linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org,
linux-graphics-maintainer@vmware.com,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org,
Brijesh Singh <brijesh.singh@amd.com>,
Joerg Roedel <joro@8bytes.org>, Andi Kleen <ak@linux.intel.com>,
Sathyanarayanan Kuppuswamy
<sathyanarayanan.kuppuswamy@linux.intel.com>,
Tianyu Lan <Tianyu.Lan@microsoft.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ard Biesheuvel <ardb@kernel.org>, Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH v2 06/12] x86/sev: Replace occurrences of sev_active() with prot_guest_has()
Date: Tue, 17 Aug 2021 12:02:38 +0200 [thread overview]
Message-ID: <YRuJPqxFZ6ItZd++@zn.tnic> (raw)
In-Reply-To: <2b3a8fc4659f2e7617399cecdcca549e0fa1dcb7.1628873970.git.thomas.lendacky@amd.com>
On Fri, Aug 13, 2021 at 11:59:25AM -0500, Tom Lendacky wrote:
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index 8e7b517ad738..66ff788b79c9 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -167,7 +167,7 @@ static int init_transition_pgtable(struct kimage *image, pgd_t *pgd)
> }
> pte = pte_offset_kernel(pmd, vaddr);
>
> - if (sev_active())
> + if (prot_guest_has(PATTR_GUEST_MEM_ENCRYPT))
> prot = PAGE_KERNEL_EXEC;
>
> set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, prot));
> @@ -207,7 +207,7 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
> level4p = (pgd_t *)__va(start_pgtable);
> clear_page(level4p);
>
> - if (sev_active()) {
> + if (prot_guest_has(PATTR_GUEST_MEM_ENCRYPT)) {
> info.page_flag |= _PAGE_ENC;
> info.kernpg_flag |= _PAGE_ENC;
> }
> @@ -570,12 +570,12 @@ void arch_kexec_unprotect_crashkres(void)
> */
> int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, gfp_t gfp)
> {
> - if (sev_active())
> + if (!prot_guest_has(PATTR_HOST_MEM_ENCRYPT))
> return 0;
>
> /*
> - * If SME is active we need to be sure that kexec pages are
> - * not encrypted because when we boot to the new kernel the
> + * If host memory encryption is active we need to be sure that kexec
> + * pages are not encrypted because when we boot to the new kernel the
> * pages won't be accessed encrypted (initially).
> */
That hunk belongs logically into the previous patch which removes
sme_active().
> return set_memory_decrypted((unsigned long)vaddr, pages);
> @@ -583,12 +583,12 @@ int arch_kexec_post_alloc_pages(void *vaddr, unsigned int pages, gfp_t gfp)
>
> void arch_kexec_pre_free_pages(void *vaddr, unsigned int pages)
> {
> - if (sev_active())
> + if (!prot_guest_has(PATTR_HOST_MEM_ENCRYPT))
> return;
>
> /*
> - * If SME is active we need to reset the pages back to being
> - * an encrypted mapping before freeing them.
> + * If host memory encryption is active we need to reset the pages back
> + * to being an encrypted mapping before freeing them.
> */
> set_memory_encrypted((unsigned long)vaddr, pages);
> }
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index e8ccab50ebf6..b69f5ac622d5 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -25,6 +25,7 @@
> #include <linux/pagemap.h>
> #include <linux/swap.h>
> #include <linux/rwsem.h>
> +#include <linux/protected_guest.h>
>
> #include <asm/apic.h>
> #include <asm/perf_event.h>
> @@ -457,7 +458,7 @@ static int has_svm(void)
> return 0;
> }
>
> - if (sev_active()) {
> + if (prot_guest_has(PATTR_SEV)) {
> pr_info("KVM is unsupported when running as an SEV guest\n");
> return 0;
Same question as for PATTR_SME. PATTR_GUEST_MEM_ENCRYPT should be enough.
> @@ -373,7 +373,7 @@ 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 sev_active(void)
> +static bool sev_active(void)
> {
> return sev_status & MSR_AMD64_SEV_ENABLED;
> }
> @@ -382,7 +382,6 @@ static bool sme_active(void)
> {
> return sme_me_mask && !sev_active();
> }
> -EXPORT_SYMBOL_GPL(sev_active);
Just get rid of it altogether.
Thx.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
next prev parent reply other threads:[~2021-08-17 10:02 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-13 16:59 [PATCH v2 00/12] Implement generic prot_guest_has() helper function Tom Lendacky
2021-08-13 16:59 ` [PATCH v2 01/12] x86/ioremap: Selectively build arch override encryption functions Tom Lendacky
2021-08-14 15:25 ` Borislav Petkov
2021-08-13 16:59 ` [PATCH v2 02/12] mm: Introduce a function to check for virtualization protection features Tom Lendacky
2021-08-13 17:19 ` Kuppuswamy, Sathyanarayanan
2021-08-14 18:32 ` Borislav Petkov
2021-08-14 18:49 ` Tom Lendacky
2021-08-19 9:46 ` Christoph Hellwig
2021-08-19 16:39 ` Tom Lendacky
2021-08-13 16:59 ` [PATCH v2 03/12] x86/sev: Add an x86 version of prot_guest_has() Tom Lendacky
2021-08-14 19:08 ` Borislav Petkov
2021-08-15 13:53 ` Tom Lendacky
2021-08-15 14:39 ` Borislav Petkov
2021-08-17 15:22 ` Tom Lendacky
2021-08-17 18:39 ` Borislav Petkov
2021-08-19 9:52 ` Christoph Hellwig
2021-08-19 17:26 ` Borislav Petkov
2021-08-19 18:33 ` Tom Lendacky
2021-08-19 19:57 ` Kuppuswamy, Sathyanarayanan
2021-08-24 7:14 ` Christoph Hellwig
2021-08-13 16:59 ` [PATCH v2 04/12] powerpc/pseries/svm: Add a powerpc " Tom Lendacky
2021-08-17 8:35 ` Borislav Petkov
2021-08-17 14:11 ` Tom Lendacky
2021-08-17 12:38 ` Michael Ellerman
2021-08-19 9:55 ` Christoph Hellwig
2021-08-19 18:34 ` Tom Lendacky
2021-08-13 16:59 ` [PATCH v2 05/12] x86/sme: Replace occurrences of sme_active() with prot_guest_has() Tom Lendacky
2021-08-17 9:00 ` Borislav Petkov
2021-08-17 14:46 ` Tom Lendacky
2021-08-17 18:41 ` Borislav Petkov
2021-08-13 16:59 ` [PATCH v2 06/12] x86/sev: Replace occurrences of sev_active() " Tom Lendacky
2021-08-17 10:02 ` Borislav Petkov [this message]
2021-08-17 15:26 ` Tom Lendacky
2021-08-17 18:43 ` Borislav Petkov
2021-08-13 16:59 ` [PATCH v2 07/12] x86/sev: Replace occurrences of sev_es_active() " Tom Lendacky
2021-08-17 10:06 ` Borislav Petkov
2021-08-13 16:59 ` [PATCH v2 08/12] treewide: Replace the use of mem_encrypt_active() " Tom Lendacky
2021-08-13 16:59 ` [PATCH v2 09/12] mm: Remove the now unused mem_encrypt_active() function Tom Lendacky
2021-08-17 10:22 ` Borislav Petkov
2021-08-17 10:24 ` Borislav Petkov
2021-08-17 15:30 ` Tom Lendacky
2021-08-13 16:59 ` [PATCH v2 10/12] x86/sev: " Tom Lendacky
2021-08-13 16:59 ` [PATCH v2 11/12] powerpc/pseries/svm: " Tom Lendacky
2021-08-13 16:59 ` [PATCH v2 12/12] s390/mm: " Tom Lendacky
2021-08-13 17:22 ` [PATCH v2 00/12] Implement generic prot_guest_has() helper function Tom Lendacky
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=YRuJPqxFZ6ItZd++@zn.tnic \
--to=bp@alien8.de \
--cc=Tianyu.Lan@microsoft.com \
--cc=ak@linux.intel.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=ardb@kernel.org \
--cc=brijesh.singh@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--cc=kexec@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-graphics-maintainer@vmware.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--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;
as well as URLs for NNTP newsgroup(s).