From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: Re: [Part1 PATCH v4 15/17] percpu: introduce DEFINE_PER_CPU_UNENCRYPTED Date: Tue, 19 Sep 2017 08:50:20 -0500 Message-ID: References: <20170916123418.37807-1-brijesh.singh@amd.com> <20170916123418.37807-16-brijesh.singh@amd.com> <20170919103906.GM4733@nazgul.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170919103906.GM4733@nazgul.tnic> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org To: Borislav Petkov Cc: brijesh.singh@amd.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Tom Lendacky , Arnd Bergmann , Tejun Heo , Christoph Lameter , linux-arch@vger.kernel.org List-Id: linux-arch.vger.kernel.org Hi Boris, On 09/19/2017 05:39 AM, Borislav Petkov wrote: ... >> @@ -815,6 +825,7 @@ >> . = ALIGN(cacheline); \ >> *(.data..percpu) \ >> *(.data..percpu..shared_aligned) \ >> + PERCPU_UNENCRYPTED_SECTION \ >> VMLINUX_SYMBOL(__per_cpu_end) = .; > > So looking at this more: I'm wondering if we can simply reuse the > PER_CPU_SHARED_ALIGNED_SECTION definition which is for shared per-CPU > sections. Instead of introducing a special section which is going to be > used only by SEV, practically. > > Because "shared" also kinda implies that it is shared by multiple agents > and those agents can just as well be guest and hypervisor. And then that > patch is gone too. > > Hmmm...? > "..shared_aligned" section does not start and end with page-size alignment. Since the C-bit works on PAGE_SIZE alignment hence the "..unencrypted" section starts and ends with page-size alignment. The closest I can find is "..page_aligned" but again it does not end with page-size alignment. Additionally, since we clear the C-bit from unencrypted section hence we should avoid overloading the existing section -- we don't want to expose more than we wish. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-co1nam03on0062.outbound.protection.outlook.com ([104.47.40.62]:40384 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751237AbdISNua (ORCPT ); Tue, 19 Sep 2017 09:50:30 -0400 Subject: Re: [Part1 PATCH v4 15/17] percpu: introduce DEFINE_PER_CPU_UNENCRYPTED References: <20170916123418.37807-1-brijesh.singh@amd.com> <20170916123418.37807-16-brijesh.singh@amd.com> <20170919103906.GM4733@nazgul.tnic> From: Brijesh Singh Message-ID: Date: Tue, 19 Sep 2017 08:50:20 -0500 MIME-Version: 1.0 In-Reply-To: <20170919103906.GM4733@nazgul.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Borislav Petkov Cc: brijesh.singh@amd.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Tom Lendacky , Arnd Bergmann , Tejun Heo , Christoph Lameter , linux-arch@vger.kernel.org Message-ID: <20170919135020.USUf5MH7TYAuAtWuRtjJENkd9Uv4NYdAN-2BrfculkE@z> Hi Boris, On 09/19/2017 05:39 AM, Borislav Petkov wrote: ... >> @@ -815,6 +825,7 @@ >> . = ALIGN(cacheline); \ >> *(.data..percpu) \ >> *(.data..percpu..shared_aligned) \ >> + PERCPU_UNENCRYPTED_SECTION \ >> VMLINUX_SYMBOL(__per_cpu_end) = .; > > So looking at this more: I'm wondering if we can simply reuse the > PER_CPU_SHARED_ALIGNED_SECTION definition which is for shared per-CPU > sections. Instead of introducing a special section which is going to be > used only by SEV, practically. > > Because "shared" also kinda implies that it is shared by multiple agents > and those agents can just as well be guest and hypervisor. And then that > patch is gone too. > > Hmmm...? > "..shared_aligned" section does not start and end with page-size alignment. Since the C-bit works on PAGE_SIZE alignment hence the "..unencrypted" section starts and ends with page-size alignment. The closest I can find is "..page_aligned" but again it does not end with page-size alignment. Additionally, since we clear the C-bit from unencrypted section hence we should avoid overloading the existing section -- we don't want to expose more than we wish.