From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38A82C43217 for ; Thu, 14 Apr 2022 08:26:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240892AbiDNI22 (ORCPT ); Thu, 14 Apr 2022 04:28:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240837AbiDNI2Y (ORCPT ); Thu, 14 Apr 2022 04:28:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4BD963193C for ; Thu, 14 Apr 2022 01:25:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649924758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g0u6ONe9j1j6k19mj6sFChlmsxQ/kXNGxnIkwP2DTq8=; b=VxHRlFXaM4PpcEw/JDPcSezSJxHVU3i2sbdi9MuZa5xTkqrWzkgPZNigBl0R9tvzvWsCiC 1qMCc/Uj8dNDi6aDgvudXE49f6WqczdLRSfKlUEBUQtu+wuTYDnPqyK25i1CvJVbv5tUQV mBGcQ45BrR8bfj9aPihIAp0bBVmNwhc= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-611-n5SOGAeYOPuKtEzbx6aOuw-1; Thu, 14 Apr 2022 04:25:57 -0400 X-MC-Unique: n5SOGAeYOPuKtEzbx6aOuw-1 Received: by mail-wm1-f72.google.com with SMTP id p31-20020a05600c1d9f00b0038ed0964a90so1896439wms.4 for ; Thu, 14 Apr 2022 01:25:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g0u6ONe9j1j6k19mj6sFChlmsxQ/kXNGxnIkwP2DTq8=; b=mn2zAjJjH6VtI+VdJTqNS0iUgS9RCH2iX7h6h8rb1locani2hsOoHXNu9MKxsZqPB1 pJSkQb/ivoEC+yTxTZ1jvRVFaqnhb+LpwQbDbLjVcpim9NjK/kbhqJ7aXCyCoLLihI8U fRSDoKZDYWkg48Gz3INVuSnatYolIPnrsT7AmuYvQN5XblCUnFTEAN7pG0zlr7QFodHj UF+qnUX6b8J/38P0QY/Gogtm5NXXhV5rXeM9NhYbMZWEr/IX/85aBbZHFXCiY6qBGr7C KZxpmMileXZKJwYBiXuMK9nuyQKMiUdjGUQAwZLapeU7L0i33mFNgiV0hJ4iI2JSDKwv 8L5g== X-Gm-Message-State: AOAM533pETisoQL84BPSPBlha2R03FKDVC29g3PFHAjyJeXyXk9RicBd Zlrpygrw1M6nqd5Uo2OJrXEMMpweQdSqNkJn9/ZuN1xApzeQkqY5nfMySvkhed4Mq5o0fQDwisj dChZDLhRlay2c X-Received: by 2002:a05:6000:1541:b0:207:8ee6:1417 with SMTP id 1-20020a056000154100b002078ee61417mr1217583wry.504.1649924756045; Thu, 14 Apr 2022 01:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJJiDAargXbObsVDj9G3u5k/2S0Fw8jMKh3LM9lqbK1deff4nEQkiYIkjtAou08aM/zPgZzw== X-Received: by 2002:a05:6000:1541:b0:207:8ee6:1417 with SMTP id 1-20020a056000154100b002078ee61417mr1217567wry.504.1649924755808; Thu, 14 Apr 2022 01:25:55 -0700 (PDT) Received: from work-vm (cpc109025-salf6-2-0-cust480.10-2.cable.virginm.net. [82.30.61.225]) by smtp.gmail.com with ESMTPSA id n15-20020a05600c500f00b0038cfb1a43d6sm1349951wmr.24.2022.04.14.01.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 01:25:55 -0700 (PDT) Date: Thu, 14 Apr 2022 09:25:53 +0100 From: "Dr. David Alan Gilbert" To: Dov Murik Cc: Cole Robinson , "kvm@vger.kernel.org" , qemu-devel , "Singh, Brijesh" , Tom Lendacky , "Daniel P. Berrange" , Paolo Bonzini Subject: Re: adding 'official' way to dump SEV VMSA Message-ID: References: <462cbf77-432a-c09c-6ec9-91556dc0f887@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <462cbf77-432a-c09c-6ec9-91556dc0f887@linux.ibm.com> User-Agent: Mutt/2.2.1 (2022-02-19) Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org * Dov Murik (dovmurik@linux.ibm.com) wrote: > Hi Cole, > > On 13/04/2022 16:36, Cole Robinson wrote: > > Hi all, > > > > SEV-ES and SEV-SNP attestation require a copy of the initial VMSA to > > validate the launch measurement. For developers dipping their toe into > > SEV-* work, the easiest way to get sample VMSA data for their machine is > > to grab it from a running VM. > > > > There's two techniques I've seen for that: patch some printing into > > kernel __sev_launch_update_vmsa, or use systemtap like danpb's script > > here: https://gitlab.com/berrange/libvirt/-/blob/lgtm/scripts/sev-vmsa.stp > > > > Seems like this could be friendlier though. I'd like to work on this if > > others agree. > > > > Some ideas I've seen mentioned in passing: > > > > - debugfs entry in /sys/kernel/debug/kvm/.../vcpuX/ > > - new KVM ioctl > > - something with tracepoints > > - some kind of dump in dmesg that doesn't require a patch > > > > Thoughts? > > > Brijesh suggested to me to construct the VMSA without getting any info from > the host (except number of vcpus), because the initial state of the vcpus > is standard and known if you use QEMU and OVMF (but that's open for discussion). > > I took his approach (thanks Brijesh!) and now it's how we calculate expected > SNP measurements in sev-snp-measure [1]. The relevant part for VMSA construction > is in [2]. > > I plan to add SEV-ES and SEV measurements calculation to this > library/program as well. Everyone seems to be writing one; you, Dan etc! I think I agree the right way is to build it programmatically rather than taking a copy from the kernel; it's fairly simple, although the scripts get increasingly hairy as you deal with more and more VMM's and firmwares. I think I'd like to see a new ioctl to read the initial VMSA, primarily as a way of debugging so you can see what VMSA you have when something goes wrong. Dave > > [1] https://github.com/IBM/sev-snp-measure > [2] https://github.com/IBM/sev-snp-measure/blob/main/sevsnpmeasure/vmsa.py > > -Dov > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15F39C433EF for ; Thu, 14 Apr 2022 08:26:52 +0000 (UTC) Received: from localhost ([::1]:33644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1neuoV-00012E-5J for qemu-devel@archiver.kernel.org; Thu, 14 Apr 2022 04:26:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neunl-0000HY-SW for qemu-devel@nongnu.org; Thu, 14 Apr 2022 04:26:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1neung-0006wP-Tq for qemu-devel@nongnu.org; Thu, 14 Apr 2022 04:26:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649924758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g0u6ONe9j1j6k19mj6sFChlmsxQ/kXNGxnIkwP2DTq8=; b=VxHRlFXaM4PpcEw/JDPcSezSJxHVU3i2sbdi9MuZa5xTkqrWzkgPZNigBl0R9tvzvWsCiC 1qMCc/Uj8dNDi6aDgvudXE49f6WqczdLRSfKlUEBUQtu+wuTYDnPqyK25i1CvJVbv5tUQV mBGcQ45BrR8bfj9aPihIAp0bBVmNwhc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-cwN2IyT9Ple_Y-9gOymNaA-1; Thu, 14 Apr 2022 04:25:57 -0400 X-MC-Unique: cwN2IyT9Ple_Y-9gOymNaA-1 Received: by mail-wm1-f70.google.com with SMTP id k16-20020a7bc310000000b0038e6cf00439so1914651wmj.0 for ; Thu, 14 Apr 2022 01:25:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g0u6ONe9j1j6k19mj6sFChlmsxQ/kXNGxnIkwP2DTq8=; b=1qqSw5q9kZFifuGd3Vf/y7ZrYTavd38uiut8E/vNiMyprTlsVr0NO5FF+YXJYHLzr2 ZN/ZoUqaiWgP9N6HcTyRvxikZ6cNcyxeo/DmS7SbMlmDiMhTtRMG5gmFSs5x0NwUtV9Z skjsZZq5ngTvq9IQZfCKAnVYbykDOKMIkKVrgN/MbQ22yzaFWhoZmWqn798xkH9R+TTE WtmMvLogjYB9ebDcmGY+/3XzrrN7jVqmRZLrvVN6zn7PQApi5DuL6Jq2D53bewP31OZJ EdM8UAmziSoi3yxwjXB4bErrpSp8J8U6Wnsv053EzFIOCWW76QZ5iV9gjPFx09nO3D5m xzQg== X-Gm-Message-State: AOAM5318o5cVyAWZfxab5hfHKTMEPbMaXhPS0g7CfgcRqFilZaqizmjN Hldb/+J32y2ZKmwt2Wbmlwsf3AeujBxCQf4+M/Gp5mZ8A2jso2A1N5aGwU/KqO+2e4CvSieRzNU XoF5PbM4v0YW5Cp8= X-Received: by 2002:a05:6000:1541:b0:207:8ee6:1417 with SMTP id 1-20020a056000154100b002078ee61417mr1217588wry.504.1649924756056; Thu, 14 Apr 2022 01:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJJiDAargXbObsVDj9G3u5k/2S0Fw8jMKh3LM9lqbK1deff4nEQkiYIkjtAou08aM/zPgZzw== X-Received: by 2002:a05:6000:1541:b0:207:8ee6:1417 with SMTP id 1-20020a056000154100b002078ee61417mr1217567wry.504.1649924755808; Thu, 14 Apr 2022 01:25:55 -0700 (PDT) Received: from work-vm (cpc109025-salf6-2-0-cust480.10-2.cable.virginm.net. [82.30.61.225]) by smtp.gmail.com with ESMTPSA id n15-20020a05600c500f00b0038cfb1a43d6sm1349951wmr.24.2022.04.14.01.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Apr 2022 01:25:55 -0700 (PDT) Date: Thu, 14 Apr 2022 09:25:53 +0100 From: "Dr. David Alan Gilbert" To: Dov Murik Subject: Re: adding 'official' way to dump SEV VMSA Message-ID: References: <462cbf77-432a-c09c-6ec9-91556dc0f887@linux.ibm.com> MIME-Version: 1.0 In-Reply-To: <462cbf77-432a-c09c-6ec9-91556dc0f887@linux.ibm.com> User-Agent: Mutt/2.2.1 (2022-02-19) Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=170.10.129.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , "Daniel P. Berrange" , "kvm@vger.kernel.org" , qemu-devel , Paolo Bonzini , Cole Robinson , "Singh, Brijesh" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" * Dov Murik (dovmurik@linux.ibm.com) wrote: > Hi Cole, > > On 13/04/2022 16:36, Cole Robinson wrote: > > Hi all, > > > > SEV-ES and SEV-SNP attestation require a copy of the initial VMSA to > > validate the launch measurement. For developers dipping their toe into > > SEV-* work, the easiest way to get sample VMSA data for their machine is > > to grab it from a running VM. > > > > There's two techniques I've seen for that: patch some printing into > > kernel __sev_launch_update_vmsa, or use systemtap like danpb's script > > here: https://gitlab.com/berrange/libvirt/-/blob/lgtm/scripts/sev-vmsa.stp > > > > Seems like this could be friendlier though. I'd like to work on this if > > others agree. > > > > Some ideas I've seen mentioned in passing: > > > > - debugfs entry in /sys/kernel/debug/kvm/.../vcpuX/ > > - new KVM ioctl > > - something with tracepoints > > - some kind of dump in dmesg that doesn't require a patch > > > > Thoughts? > > > Brijesh suggested to me to construct the VMSA without getting any info from > the host (except number of vcpus), because the initial state of the vcpus > is standard and known if you use QEMU and OVMF (but that's open for discussion). > > I took his approach (thanks Brijesh!) and now it's how we calculate expected > SNP measurements in sev-snp-measure [1]. The relevant part for VMSA construction > is in [2]. > > I plan to add SEV-ES and SEV measurements calculation to this > library/program as well. Everyone seems to be writing one; you, Dan etc! I think I agree the right way is to build it programmatically rather than taking a copy from the kernel; it's fairly simple, although the scripts get increasingly hairy as you deal with more and more VMM's and firmwares. I think I'd like to see a new ioctl to read the initial VMSA, primarily as a way of debugging so you can see what VMSA you have when something goes wrong. Dave > > [1] https://github.com/IBM/sev-snp-measure > [2] https://github.com/IBM/sev-snp-measure/blob/main/sevsnpmeasure/vmsa.py > > -Dov > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK