Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp97199imm; Thu, 13 Sep 2018 16:28:12 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZjCzcdZDL3UtwJbDu98sJh0djfCO96i3TW5vjQ3D9tjoPK+qgj3pqypyTc7mmte319tPU/ X-Received: by 2002:a17:902:9696:: with SMTP id n22-v6mr9413068plp.212.1536881292639; Thu, 13 Sep 2018 16:28:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536881292; cv=none; d=google.com; s=arc-20160816; b=RMonkIHRVWrds6i19qpr2EFvEMP1gQSphYCERHmz/a7QdA/lYK7D4BJ+YhEk0GCTtZ YcLaLrPFANiKNa58x03ArPXGYQ5ChbBqgt19Y/gKyM5igOdNR7DLztpmTetfevR8W+/+ svXhKOPJ5Qfn8+Uz9OigFImnVjpID6JRDg4RNMH6eoECpkfCgFmlvjUtHpbo6Xs8FtoU l/bwp3jt/+ibqgY/ydTUnlMePyRcGYEj7ptiuEYGQN86FLjw8bzR4enJfi7y/0YqnyR/ 2ZtRLedpkawM4bFd6KHmTz1Fc1L4NxEWGMgSFe1zCVaekUwvkzMDv18Ukj6NjNQFdPBA PNTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=V46vbQ07InAouNYqzy60QzUmeigo92GiOKfSwq7VGp8=; b=aMlZlWEO+B8colwCvkkIldPKYtSrunXgjqiBH1PRclJNv+yD8doFD7rzq+98g8TuuA zPqAK0uoKz7Alm6Bz2HQS7wE23wDlPS4kP4AQfSM5AwSof33V4msbz7ndNWft5m931C5 uebfHT0Bmw6VQ77psvsBOZktd2GXJ83W2nW5XzCiU8XOjc3yGoue8A+8N+W9jc9h+WSm H6XNlHQlbvErAeShZfCl3NV6cR8BE0qe/HCuK8IkZsofUfmI02izy/N77gJnj+a3tQN+ iIqMlA+FD9FjRoKT2HkjlErTxmtfav5zb3wVHMF005Ns8MigEpRDY73Y42U0Ua4hs+oL xinQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o137-v6si5557939pfg.362.2018.09.13.16.27.57; Thu, 13 Sep 2018 16:28:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727056AbeINEgj (ORCPT + 99 others); Fri, 14 Sep 2018 00:36:39 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:46622 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725757AbeINEgi (ORCPT ); Fri, 14 Sep 2018 00:36:38 -0400 Received: from p4fea45ac.dip0.t-ipconnect.de ([79.234.69.172] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1g0ayk-0003GU-BU; Fri, 14 Sep 2018 01:24:54 +0200 Date: Fri, 14 Sep 2018 01:24:53 +0200 (CEST) From: Thomas Gleixner To: Brijesh Singh cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Tom Lendacky , Borislav Petkov , "H. Peter Anvin" , Paolo Bonzini , Sean Christopherson , =?ISO-8859-2?Q?Radim_Kr=E8m=E1=F8?= Subject: Re: [PATCH v8 1/2] x86/mm: add .bss..decrypted section to hold shared variables In-Reply-To: <1536875471-17391-2-git-send-email-brijesh.singh@amd.com> Message-ID: References: <1536875471-17391-1-git-send-email-brijesh.singh@amd.com> <1536875471-17391-2-git-send-email-brijesh.singh@amd.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > + > + 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