From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=66.187.233.73; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1D3B62245119A for ; Mon, 5 Mar 2018 01:49:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 876B8402314E; Mon, 5 Mar 2018 09:55:46 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-64.rdu2.redhat.com [10.10.120.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78462219AD4A; Mon, 5 Mar 2018 09:55:45 +0000 (UTC) To: Brijesh Singh , edk2-devel-01 Cc: Ard Biesheuvel , Jordan Justen References: <20180302000408.14201-1-lersek@redhat.com> <2d6e37a5-fdfa-330d-d7ef-51e0350afdad@amd.com> <6be3c2e4-0269-7743-d14d-4cf1f2935342@redhat.com> <45c6adcc-57a1-c7c4-3474-b33b7323ea17@amd.com> From: Laszlo Ersek Message-ID: <70789562-f92e-aa68-3b52-fac52f83c036@redhat.com> Date: Mon, 5 Mar 2018 10:55:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <45c6adcc-57a1-c7c4-3474-b33b7323ea17@amd.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 05 Mar 2018 09:55:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 05 Mar 2018 09:55:46 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' Subject: Re: [PATCH 00/20] OvmfPkg: SEV: decrypt the initial SMRAM save state map for SMBASE relocation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Mar 2018 09:49:35 -0000 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 03/02/18 14:17, Brijesh Singh wrote: > > > On 3/2/18 5:53 AM, Laszlo Ersek wrote: >> On 03/02/18 02:16, Brijesh Singh wrote: >>> >>> On 3/1/18 6:03 PM, Laszlo Ersek wrote: >>>> I also tried to test the series with SEV guests (again with Brijesh's v2 >>>> 2/2 patch applied on top). Unfortunately, I didn't get good results with >>>> or without SMM. Without SMM, the guest OS boots to a point, but then it >>>> gets stuck with the CPU spinning. With SMM, OVMF gets stuck in SMBASE >>>> relocation. >>> To boot the SEV guest with SMM support we need this KVM patch, without >>> this we will get either #UD or some undefined behavior. >>> >>> https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?id=7607b7174405aec7441ff6c970833c463114040a >> Looks like a very recent commit. What tree (and at what commit) do you >> recommend that I build a new host kernel? > > Yes this is very recent commit and it was developed during SMM work. For > host kernel we need at least 4.16.0-rc1 but since you are going to boot > the SMM enabled BIOS hence I recommend using latest kvm/master > > https://git.kernel.org/pub/scm/virt/kvm/kvm.git/ > >> >>> It's strange that you are having trouble booting SEV guest without SMM >>> support. It's possible that we might have some mismatch kernel kvm + >>> qemu + ovmf patches. >> Wait, the details matter: I wrote "the guest OS boots to a point". There >> are no problems with the firmware, or the initial OS boot progress. The >> issue happens fairly later (but certainly before I reach a login prompt >> or similar). Maybe this is nothing new relative to last November; I >> don't remember. > > Ah, my best guess is that userspace program is getting wrong time using > clock_gettime() and hence the bootscripts are waiting on some events > forever .. IIRC, I was getting boot hang sometime back in Oct or Nov and > debugging took me to the kvmclock support for SEV guest. I was doing > everything right in my patches for kvmclock except the first hunk of the > below patch. When kvmclock is available the clock_getttime() uses vdso > and since kvmclock page is shared between HV and Guest hence we needed > to ensure that userspace pgtable have proper C-bit when accessing this > memory range. > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.16-rc3&id=819aeee065e5d1b417ecd633897427c89f3253ec > > All the SEV guest got accepted in 4.15, hence for guest kernel you can > use Linux kernel >=4.15 > >>>> Until then, Brijesh, can you please test this series? Thank you! >>> >>> Sure, I will try the series tomorrow morning. thank you so much for the >>> cleanup and remaining SMM work. >> Thanks! >> >> Do you have (maybe updated) instructions for setting up the SEV host? >> What are the latest bits that are expected to work together? > > AMDSEV page https://github.com/AMDESE/AMDSEV contains some instruction > and scripts to boot the SEV guest but its still using the older version > of kernel and qemu. Here is what you need to do: > > For host kernel: > - use recent kvm/master > - make sure following kernel config is enabled >   CONFIG_KVM_AMD_SEV >   CONFIG_CRYPTO_DEV_SP_PSP >   CONFIG_AMD_MEM_ENCRYPT >   CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT > > For guest kernel: >  - you can use host kernel or anything >=4.15 >     make sure you have following config enabled in kernel: >       CONFIG_AMD_MEM_ENCRYPT > > For qemu: > - v10 patches from this branch > https://github.com/codomania/qemu/tree/v10 Great, I'll work on updating all the bits and I'll report back. Thanks! Laszlo