linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Singh, Brijesh" <brijesh.singh@amd.com>
To: Borislav Petkov <bp@alien8.de>,
	"Lendacky, Thomas" <Thomas.Lendacky@amd.com>
Cc: "Singh, Brijesh" <brijesh.singh@amd.com>,
	lijiang <lijiang@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kexec@lists.infradead.org" <kexec@lists.infradead.org>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"dyoung@redhat.com" <dyoung@redhat.com>,
	"bhe@redhat.com" <bhe@redhat.com>
Subject: Re: [PATCH 1/3] kexec: Do not map the kexec area as decrypted when SEV is active
Date: Mon, 25 Mar 2019 18:17:26 +0000	[thread overview]
Message-ID: <11013ad2-2eab-5a7a-d4e2-a9da4920cfab@amd.com> (raw)
In-Reply-To: <20190325173239.GO12016@zn.tnic>



On 3/25/19 12:32 PM, Borislav Petkov wrote:
> On Mon, Mar 25, 2019 at 05:17:55PM +0000, Singh, Brijesh wrote:
>> By default all the memory regions are mapped encrypted. The
>> set_memory_{encrypt,decrypt}() is a generic function which can be
>> called explicitly to clear/set the encryption mask from the existing
>> memory mapping. The mem_encrypt_active() returns true if either SEV or
>> SME is active. So the __set_memory_enc_dec() uses the
>> memory_encrypt_active() check to ensure that the function is no-op when
>> SME/SEV are not active.
>>
>> Currently, the arch_kexec_post_alloc_pages() unconditionally clear the
>> encryption mask from the kexec area. In case of SEV, we should not clear
>> the encryption mask.
> 
> Brijesh, I know all that.
> 
> Please read what I said here at the end:
> 
> https://lkml.kernel.org/r/20190324150034.GH23289@zn.tnic
> 
> With this change, the code looks like this:
> 
> +       if (sme_active())
> +               return set_memory_decrypted((unsigned long)vaddr, pages);
> 
> now in __set_memory_enc_dec via set_memory_decrypted():
> 
>          /* Nothing to do if memory encryption is not active */
>          if (!mem_encrypt_active())
>                  return 0;
> 
> 
> so you have:
> 
> 	if (sme_active())
> 
> 		...
> 
> 		if (!mem_encrypt_active())
> 
> 
> now maybe this is all clear to you and Tom but I betcha others will get
> confused. Probably something like "well, what should be active now, SME,
> SEV or memory encryption in general"?
> 
> I hope you're catching my drift.
> 
> So if you want to *not* decrypt memory in the SEV case, then doing something
> like this should make it a bit more clear:
> 
> 
> 	if (sev_active())
> 		return;
> 
> 	return set_memory_decrypted((unsigned long)vaddr, pages);
> 


I see your point. I agree it can get confusing.


> along with a comment *why* we're checking here.
> 
> But actually, I'd prefer if you had separate wrappers which are called
> for SME and for SEV.


Just a thought, maybe we can move the above if(sev_active()) check up in
kernel/kexec_core.c because we don't need to set/clear the encryption
masks when SEV is active so there is no need to call the wrapper.


> 
> I'll let Tom chime in too.
> 


  reply	other threads:[~2019-03-25 18:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-15 10:32 [PATCH 0/3] Add kdump support for the SEV enabled guest Lianbo Jiang
2019-03-15 10:32 ` [PATCH 1/3] kexec: Do not map the kexec area as decrypted when SEV is active Lianbo Jiang
2019-03-24 15:00   ` Borislav Petkov
2019-03-25  1:58     ` lijiang
2019-03-25  6:37       ` Borislav Petkov
2019-03-25 17:17         ` Singh, Brijesh
2019-03-25 17:32           ` Borislav Petkov
2019-03-25 18:17             ` Singh, Brijesh [this message]
2019-03-25 19:59               ` Lendacky, Thomas
2019-03-26 10:06                 ` Boris Petkov
2019-03-26  1:27             ` lijiang
2019-03-15 10:32 ` [PATCH 2/3] kexec: Set the C-bit in the identity map page table " Lianbo Jiang
2019-03-15 10:32 ` [PATCH 3/3] kdump,proc/vmcore: Enable kdumping encrypted memory when SEV was active Lianbo Jiang
2019-03-15 10:42 ` [PATCH 0/3] Add kdump support for the SEV enabled guest lijiang

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=11013ad2-2eab-5a7a-d4e2-a9da4920cfab@amd.com \
    --to=brijesh.singh@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=dyoung@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kexec@lists.infradead.org \
    --cc=lijiang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --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).