From: Brijesh Singh Subject: Re: SEV guest regression in 4.18 Date: Fri, 24 Aug 2018 13:48:52 -0500 Message-ID: References: <3d46f44c-dd78-8fa9-02ac-8206676ffde9@amd.com> <20180821151938.GA31212@nazgul.tnic> <92e2b80c-0dcc-94be-8d3a-5e11e5cf2370@amd.com> <20180822081417.GB4069@nazgul.tnic> <20180822150033.GA14200@linux.intel.com> <4d6ee892-a34f-28b3-18b7-1c663eb281c6@amd.com> <9635ebf0-7c99-6edf-1240-8dec28036a70@redhat.com> <20180823152907.GA1488@linux.intel.com> <60acb594-abe3-912f-9702-2f34961e575d@redhat.com> <20180824162408.GA5491@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: brijesh.singh@amd.com, Paolo Bonzini , Borislav Petkov , "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "Lendacky, Thomas" , Thomas Gleixner To: Sean Christopherson Return-path: In-Reply-To: <20180824162408.GA5491@linux.intel.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 08/24/2018 11:24 AM, Sean Christopherson wrote: > On Fri, Aug 24, 2018 at 10:41:27AM -0500, Brijesh Singh wrote: >> >> >> On 08/23/2018 11:16 AM, Paolo Bonzini wrote: >>> On 23/08/2018 17:29, Sean Christopherson wrote: >>>> On Thu, Aug 23, 2018 at 01:26:55PM +0200, Paolo Bonzini wrote: >>>>> On 22/08/2018 22:11, Brijesh Singh wrote: >>>>>> >>>>>> Yes, this is one of approach I have in mind. It will avoid splitting >>>>>> the larger pages; I am thinking that early in boot code we can lookup >>>>>> for this special section and decrypt it in-place and probably maps with >>>>>> C=0. Only downside, it will increase data section footprint a bit >>>>>> because we need to align this section to PM_SIZE. >>>>> >>>>> If you can ensure it doesn't span a PMD, maybe it does not need to be >>>>> aligned; you could establish a C=0 mapping of the whole 2M around it. >>>> >>>> Wouldn't that result in exposing/leaking whatever code/data happened >>>> to reside on the same 2M page (or corrupting it if the entire page >>>> isn't decrypted)? Or are you suggesting that we'd also leave the >>>> encrypted mapping intact? >>> >>> Yes, exactly the latter, because... >> >> >> Hardware does not enforce coherency between the encrypted and >> unencrypted mapping for the same physical page. So, creating a >> two mapping of same physical address will lead a possible data >> corruption. > > But couldn't we avoid corruption by ensuring data accessed via the > unencrypted mapping is cache line aligned and sized? The CPU could > speculatively bring the encrypted version into the cache but it > should never get into a modified state (barring a software bug, but > that would be a problem regardless of encryption). > Yes, if we can ensure that accessed are cache line aligned and sized then we should be fine.