linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brijesh Singh <brijesh.singh@amd.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: brijesh.singh@amd.com, x86@kernel.org,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	"Tom Lendacky" <thomas.lendacky@amd.com>,
	"Borislav Petkov" <bp@suse.de>, "H. Peter Anvin" <hpa@zytor.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Sean Christopherson" <sean.j.christopherson@intel.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH v8 1/2] x86/mm: add .bss..decrypted section to hold shared variables
Date: Thu, 13 Sep 2018 21:14:47 -0500	[thread overview]
Message-ID: <a9391cea-bdd5-fdfe-442b-0c9f9699ee49@amd.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1809140122590.1473@nanos.tec.linutronix.de>



On 9/13/18 6:24 PM, Thomas Gleixner wrote:
> On Thu, 13 Sep 2018, Brijesh Singh wrote:
>>  
>> +void __weak mem_encrypt_free_decrypted_mem(void) { }
>> +
>>  void __ref free_initmem(void)
>>  {
>>  	e820__reallocate_tables();
>>  
>> +	mem_encrypt_free_decrypted_mem();
>> +
>>  	free_kernel_image_pages(&__init_begin, &__init_end);
>>  }
>>  
>> diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c
>> index b2de398..718acdf 100644
>> --- a/arch/x86/mm/mem_encrypt.c
>> +++ b/arch/x86/mm/mem_encrypt.c
>> @@ -348,6 +348,16 @@ bool sev_active(void)
>>  EXPORT_SYMBOL(sev_active);
>>  
>>  /* Architecture __weak replacement functions */
>> +void __init mem_encrypt_free_decrypted_mem(void)
>> +{
>> +	if (mem_encrypt_active())
>> +		return;
> Why?

Hmm, I think we should be able to free the unused memory when memory
encryption is active.
In that case, since memory range was mapped C=0 so we should do
set_memory_encryptyed()
to change from C=0 -> C=1 before freeing it.

>> +
>> +	free_init_pages("unused decrypted",
>> +			(unsigned long)__start_bss_decrypted_unused,
>> +			(unsigned long)__end_bss_decrypted);
> Everything _AFTER_ __start_bss_decrypted_unused _IS_ unused and can be
> freed. No conditional nothing. It's unused in any case.
>
> Thanks,
>
> 	tglx
>
>


  reply	other threads:[~2018-09-14  2:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13 21:51 [PATCH v8 0/2] x86: Fix SEV guest regression Brijesh Singh
2018-09-13 21:51 ` [PATCH v8 1/2] x86/mm: add .bss..decrypted section to hold shared variables Brijesh Singh
2018-09-13 23:24   ` Thomas Gleixner
2018-09-14  2:14     ` Brijesh Singh [this message]
2018-09-14  7:10   ` Borislav Petkov
2018-09-14 11:58     ` Brijesh Singh
2018-09-14 12:17       ` Thomas Gleixner
2018-09-14 14:12         ` Borislav Petkov
2018-09-14 14:27           ` Brijesh Singh
2018-09-14 14:45             ` Borislav Petkov
2018-09-14 14:50           ` Tom Lendacky
2018-09-14 14:55             ` Thomas Gleixner
2018-09-13 21:51 ` [PATCH v8 2/2] x86/kvm: use __bss_decrypted attribute in " Brijesh Singh
2018-09-13 23:31   ` Thomas Gleixner
2018-09-14  0:25   ` kbuild test robot

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=a9391cea-bdd5-fdfe-442b-0c9f9699ee49@amd.com \
    --to=brijesh.singh@amd.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=sean.j.christopherson@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).