From patchwork Sat Oct 2 12:52:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532069 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB83FC433EF for ; Sat, 2 Oct 2021 12:53:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C00A661AF8 for ; Sat, 2 Oct 2021 12:53:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233215AbhJBMzN (ORCPT ); Sat, 2 Oct 2021 08:55:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43893 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232823AbhJBMzM (ORCPT ); Sat, 2 Oct 2021 08:55:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179206; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=77XCyInhhDjafl0gvl8ONZ83GvKuNYK6mpZCL7SUumw=; b=ep+GH9K8FmZt02QS3Ybf3xdgx+qrha3NQCy9m5GOhjEL/QPgBewm71xRK9unD+H0fb3rkN vXq36OZIUau0HH26zkJaFkCjrkVpIkEdLhGJEDMjReiknCeyHbnuLZk7/ZhU0AobvFAO40 L9KwQTeLGFT/mNmmtQNnhYHkpzf6vsg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-2v0tDAelPDOa0Vb_MDAh-g-1; Sat, 02 Oct 2021 08:53:25 -0400 X-MC-Unique: 2v0tDAelPDOa0Vb_MDAh-g-1 Received: by mail-wm1-f71.google.com with SMTP id o28-20020a05600c511c00b0030cdce826f9so3791338wms.5 for ; Sat, 02 Oct 2021 05:53:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=77XCyInhhDjafl0gvl8ONZ83GvKuNYK6mpZCL7SUumw=; b=KVhamf/ePLXn0sMptacyZlR47sct2YAARZkj7WRVLicFrUKWYeNihAuRXB6f2P2VO7 0tmrphU6rqlJl+urc1e3Pax7qHOqA8JegqklJ4bbzkLXfIojMKTkgLruA7nqkBZt4j9A vXjklQJi3oL9uJe2ZcY+PFquvpXN6yYJMVgiuDnQdfZIEF2g59CSG3l4KtVOCKpcwcVe fdLKO2apwptVR5/E3Sr0dhca2OnRYBnPizPQEU70NPQLZ2k9U8r7G26+ETN1dESCM0hC 1zsc/T2lKQd939LxPNT9ktDzMBm7yZaD00pPkm9VHWA15HLwmzmGu9Rx1h8ZQtfp7clV JWHQ== X-Gm-Message-State: AOAM532AbOl2bdU3kvnQR9CVIMwadHqdbteC4cbK6RaYubm2Sec5xuxQ mwrqdgzauzXXcfPKwGezP956UyitQXwiXxf2uQfpkwWus8jz8DcqlK/Ijg3/CEOWh89aiTbB4p7 xFL5x1zLoN7ht X-Received: by 2002:a1c:35c7:: with SMTP id c190mr9340536wma.57.1633179204061; Sat, 02 Oct 2021 05:53:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1GirbsivBGcc75qonhC/tP/yFG+dbrQslj/ieJQDwUJOIb3YR9xlNe3qi6SdxOBKkUr/2Og== X-Received: by 2002:a1c:35c7:: with SMTP id c190mr9340526wma.57.1633179203922; Sat, 02 Oct 2021 05:53:23 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id c7sm10953748wmq.13.2021.10.02.05.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" , Markus Armbruster Subject: [PATCH v3 01/22] qapi/misc-target: Wrap long 'SEV Attestation Report' long lines Date: Sat, 2 Oct 2021 14:52:56 +0200 Message-Id: <20211002125317.3418648-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Wrap long lines before 70 characters for legibility. Suggested-by: Markus Armbruster Reviewed-by: Markus Armbruster Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- qapi/misc-target.json | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 594fbd1577f..ae5577e0390 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -300,8 +300,8 @@ ## # @SevAttestationReport: # -# The struct describes attestation report for a Secure Encrypted Virtualization -# feature. +# The struct describes attestation report for a Secure Encrypted +# Virtualization feature. # # @data: guest attestation report (base64 encoded) # @@ -315,10 +315,11 @@ ## # @query-sev-attestation-report: # -# This command is used to get the SEV attestation report, and is supported on AMD -# X86 platforms only. +# This command is used to get the SEV attestation report, and is +# supported on AMD X86 platforms only. # -# @mnonce: a random 16 bytes value encoded in base64 (it will be included in report) +# @mnonce: a random 16 bytes value encoded in base64 (it will be +# included in report) # # Returns: SevAttestationReport objects. # @@ -326,11 +327,13 @@ # # Example: # -# -> { "execute" : "query-sev-attestation-report", "arguments": { "mnonce": "aaaaaaa" } } +# -> { "execute" : "query-sev-attestation-report", +# "arguments": { "mnonce": "aaaaaaa" } } # <- { "return" : { "data": "aaaaaaaabbbddddd"} } # ## -{ 'command': 'query-sev-attestation-report', 'data': { 'mnonce': 'str' }, +{ 'command': 'query-sev-attestation-report', + 'data': { 'mnonce': 'str' }, 'returns': 'SevAttestationReport', 'if': 'TARGET_I386' } From patchwork Sat Oct 2 12:52:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532071 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E326C433EF for ; Sat, 2 Oct 2021 12:53:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75D0961A51 for ; Sat, 2 Oct 2021 12:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233212AbhJBMz3 (ORCPT ); Sat, 2 Oct 2021 08:55:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56436 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233221AbhJBMzS (ORCPT ); Sat, 2 Oct 2021 08:55:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179212; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uxFjxneImH8t+TNgA6RwI5GC/nMw3TKiWJEHDqKeLyw=; b=GIsxXQila3coD21BAwndch1qqhN/M0u+nhmt0O57/tu1WDWo5q1FLnWcoHiW124u5X/3ip EJvJgowgtrTnDNArxVBMetVuZzXodbE6TVqqcXFbuRxuzxtnWEOJfO26BujravVvVuGSij yYDx3KveYxw4LqSjdmi1i8NsgYCgSsw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-117-DjzxvCjpPzGrjBYVOTsCFA-1; Sat, 02 Oct 2021 08:53:29 -0400 X-MC-Unique: DjzxvCjpPzGrjBYVOTsCFA-1 Received: by mail-wm1-f71.google.com with SMTP id r66-20020a1c4445000000b0030cf0c97157so6084604wma.1 for ; Sat, 02 Oct 2021 05:53:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uxFjxneImH8t+TNgA6RwI5GC/nMw3TKiWJEHDqKeLyw=; b=h2DcSgLh0Y0AgOKzjJqGB17Yfi5pgsg9DRniqqFRAGgjx/QQSvQ+ReC04XqHSvl/Io 2+1OtrQlYJUlW0xglztG8YUhyDzXOSLDi963l8iOWlbZZBRa4fHUZvSTJV9zXH9MlGDq tqVAezxv2lf2yn+mLtE8ATd8ts4X/pkho5Wx6ILeA/bU9XJsk/V2CZXFymiqilihEI4t G9ayFl6VJhItXasDOtf+MUR6zNH9hTaY8FX9jQ9RZvT3HbbbJ5lqyOwrbY20tTaDy4eA xRgAc39Rs/nGVV4vxGgoNgne5JHKhYRaEnFlkT0iTCSDR7pMM1msmCozqeSkPGu0woRd ofpw== X-Gm-Message-State: AOAM530CcdNKrCgxccCs19A5KlxDrtzzB+ym+IFxynR3S3flf2o/44Oq s1JuEZBTOg+6o+W6jeykbwqoZXHm//wDPQBgo/4DB4NN6kukGK/fM9hlc2mPTWfU7gsvSazLwm1 t7+tKXqyZplOY X-Received: by 2002:a5d:6da9:: with SMTP id u9mr3290600wrs.58.1633179208583; Sat, 02 Oct 2021 05:53:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDVSNYXZrFwgHN4o6mFCnb6T1FU6BIRdNia2pWh+N6e4sjnaGfMzRIY8qxl27Xi1WFkhgpNw== X-Received: by 2002:a5d:6da9:: with SMTP id u9mr3290585wrs.58.1633179208431; Sat, 02 Oct 2021 05:53:28 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id 61sm8574908wrl.94.2021.10.02.05.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:28 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 02/22] qapi/misc-target: Group SEV QAPI definitions Date: Sat, 2 Oct 2021 14:52:57 +0200 Message-Id: <20211002125317.3418648-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org There is already a section with various SEV commands / types, so move the SEV guest attestation together. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- qapi/misc-target.json | 80 +++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/qapi/misc-target.json b/qapi/misc-target.json index ae5577e0390..5aa2b95b7d4 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -229,6 +229,46 @@ 'data': { 'packet-header': 'str', 'secret': 'str', '*gpa': 'uint64' }, 'if': 'TARGET_I386' } +## +# @SevAttestationReport: +# +# The struct describes attestation report for a Secure Encrypted +# Virtualization feature. +# +# @data: guest attestation report (base64 encoded) +# +# +# Since: 6.1 +## +{ 'struct': 'SevAttestationReport', + 'data': { 'data': 'str'}, + 'if': 'TARGET_I386' } + +## +# @query-sev-attestation-report: +# +# This command is used to get the SEV attestation report, and is +# supported on AMD X86 platforms only. +# +# @mnonce: a random 16 bytes value encoded in base64 (it will be +# included in report) +# +# Returns: SevAttestationReport objects. +# +# Since: 6.1 +# +# Example: +# +# -> { "execute" : "query-sev-attestation-report", +# "arguments": { "mnonce": "aaaaaaa" } } +# <- { "return" : { "data": "aaaaaaaabbbddddd"} } +# +## +{ 'command': 'query-sev-attestation-report', + 'data': { 'mnonce': 'str' }, + 'returns': 'SevAttestationReport', + 'if': 'TARGET_I386' } + ## # @dump-skeys: # @@ -297,46 +337,6 @@ 'if': 'TARGET_ARM' } -## -# @SevAttestationReport: -# -# The struct describes attestation report for a Secure Encrypted -# Virtualization feature. -# -# @data: guest attestation report (base64 encoded) -# -# -# Since: 6.1 -## -{ 'struct': 'SevAttestationReport', - 'data': { 'data': 'str'}, - 'if': 'TARGET_I386' } - -## -# @query-sev-attestation-report: -# -# This command is used to get the SEV attestation report, and is -# supported on AMD X86 platforms only. -# -# @mnonce: a random 16 bytes value encoded in base64 (it will be -# included in report) -# -# Returns: SevAttestationReport objects. -# -# Since: 6.1 -# -# Example: -# -# -> { "execute" : "query-sev-attestation-report", -# "arguments": { "mnonce": "aaaaaaa" } } -# <- { "return" : { "data": "aaaaaaaabbbddddd"} } -# -## -{ 'command': 'query-sev-attestation-report', - 'data': { 'mnonce': 'str' }, - 'returns': 'SevAttestationReport', - 'if': 'TARGET_I386' } - ## # @SGXInfo: # From patchwork Sat Oct 2 12:52:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532119 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 063C9C433F5 for ; Sat, 2 Oct 2021 12:55:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE31961AF8 for ; Sat, 2 Oct 2021 12:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233194AbhJBM5I (ORCPT ); Sat, 2 Oct 2021 08:57:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58540 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233238AbhJBMzV (ORCPT ); Sat, 2 Oct 2021 08:55:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179215; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g4CQJdzlwnG2lhh6cD8LFOTW/FEZbmRSxqmO9AK0wf0=; b=I/8Xp4e2E+WL79W0XSEGvCPifPK2bhUerJaAixHYDFZv4YtEtGwgifBZfuqgqJArFiN9uv 5gGYpeRpnDETEKJ+MTpICjYpUmp96vczUjcQTJjIldTeuBS8fsqQRyvn/I138ozLwAa/qg GZ0H3LpZNUz3uE+bPo0Ayf3AbKAJxNM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-S81j0aWgNoWf8SfTwSr2nQ-1; Sat, 02 Oct 2021 08:53:34 -0400 X-MC-Unique: S81j0aWgNoWf8SfTwSr2nQ-1 Received: by mail-wm1-f72.google.com with SMTP id m9-20020a05600c4f4900b003057c761567so7366943wmq.1 for ; Sat, 02 Oct 2021 05:53:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g4CQJdzlwnG2lhh6cD8LFOTW/FEZbmRSxqmO9AK0wf0=; b=YrP53aId7d7wrzF3CIawQ/JT1flPmm0mBLQvyJrDiYMmY8+nWYfIN0e2nxzTGuaplo bGqRo6iqSI+KPDHJX4GUxn/tgvxhOE7vreD6qixTzZjp/eiURSoFtNHQsMF3QsYTGT7S QPa2VHCMIVUiLZwOyJKqwgZn6koCIHrvd3NsHMhgy6Q3TryLR/1sBIeYrWdOtUb/CwdH uM9xkQpI2UFLepQkMFRsCskk4WiGarMiqu6zSl7UBJxV8CkfkeZSusBGZjctVCKoaak0 cUZpjoH/UoC7MQUaH4xmp2xNkV/8G/a0MqgwFL547bWQi3lMdNpqnM0meEUWBeVf/v7P ECaQ== X-Gm-Message-State: AOAM533P47MJKLrnVSLAJtX0u6AhZEsR6oxeaU8iVGvGlAWV18NyLuna YI+TorL/hLXa/UQhu3Sa7Om6Irh3JjjWuajAez39qIBRO4TGens5q9+j2ZgzzZpAemOb9aIOxFD KeUhT6soen4d2 X-Received: by 2002:a05:600c:240a:: with SMTP id 10mr9368878wmp.170.1633179213048; Sat, 02 Oct 2021 05:53:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVukirZxFLCnS0tPkLQb551+kxcHjcGyPtCd0pzUdBEUoIeuKLgKAGClPI+IvXqQdALVy20Q== X-Received: by 2002:a05:600c:240a:: with SMTP id 10mr9368862wmp.170.1633179212853; Sat, 02 Oct 2021 05:53:32 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id n17sm8399735wrp.17.2021.10.02.05.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 03/22] target/i386/kvm: Introduce i386_softmmu_kvm Meson source set Date: Sat, 2 Oct 2021 14:52:58 +0200 Message-Id: <20211002125317.3418648-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Introduce the i386_softmmu_kvm Meson source set to be able to add features dependent on CONFIG_KVM. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/kvm/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/meson.build b/target/i386/kvm/meson.build index 0a533411cab..b1c76957c76 100644 --- a/target/i386/kvm/meson.build +++ b/target/i386/kvm/meson.build @@ -1,8 +1,12 @@ i386_ss.add(when: 'CONFIG_KVM', if_false: files('kvm-stub.c')) -i386_softmmu_ss.add(when: 'CONFIG_KVM', if_true: files( +i386_softmmu_kvm_ss = ss.source_set() + +i386_softmmu_kvm_ss.add(files( 'kvm.c', 'kvm-cpu.c', )) i386_softmmu_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_false: files('hyperv-stub.c')) + +i386_softmmu_ss.add_all(when: 'CONFIG_KVM', if_true: i386_softmmu_kvm_ss) From patchwork Sat Oct 2 12:52:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532121 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E9F2C433EF for ; Sat, 2 Oct 2021 12:55:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0775161AF8 for ; Sat, 2 Oct 2021 12:55:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233227AbhJBM5J (ORCPT ); Sat, 2 Oct 2021 08:57:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59462 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233256AbhJBMzZ (ORCPT ); Sat, 2 Oct 2021 08:55:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179219; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZlL6otvRUOhsGg4LexEjqPgBur9Sbw4O6pWOtqIiK2E=; b=GZdx9slGGrzOtU9ZPOPmAIm7BlEZi22L3Kj/0gw2xDL3iTkk2WbAEqFk+qTX5o4zko35ta hmjW4b5KIUkpQlqXMdfqaPphlL7bnURMg9GH43Cdpb7oOLXEEOVtHB2vQphzPK6Zb4l6R+ dwFw8DSMzMjSK7Wnz8J+rIsT7jAkYQM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-9oitxajvNr-th8DHvlh6jQ-1; Sat, 02 Oct 2021 08:53:38 -0400 X-MC-Unique: 9oitxajvNr-th8DHvlh6jQ-1 Received: by mail-wm1-f71.google.com with SMTP id 129-20020a1c1987000000b0030cd1616fbfso7349257wmz.3 for ; Sat, 02 Oct 2021 05:53:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZlL6otvRUOhsGg4LexEjqPgBur9Sbw4O6pWOtqIiK2E=; b=QHX7mJP6qpNcqqy4KnTug0T88/9n7ppXj+1ujMk3qv6g+s4xwaKmezaa+ssTEdWGIK 8E/liqV7F3FNq2T7QiVfh4Kmj0Yp9BAnvPxt7JdSKwiUxsEusGFpP7yyhkmenSEP3Gjf 2QVl6qJ68OJphbKwKTPdOZ4ROcceKGR0JmkaMU8B876bYndRBucaCYCaMn3kRWPKs6pW VNSxyNxtUayLZy4fnpf/uAEU+L8mGT1n14yQDicF5PBBBLizIzkcvDpJyYr+sHNG2HoM leUL8H9n3haLbdec36G1BG+bcXq9fa2NYnkGRvtdWUkFfO3Pp+p69ivfc+kcQq9/CFvz S6YA== X-Gm-Message-State: AOAM5301xMX8issh+HzioEnQYyQrh2O1oB0tt+rdSfro0agato4pfLNk FfP8AD34VumJhmSi5r0Yjl3SuGB+xk5m7fEMsppdmcQH5JwWmo99aCt+7AWDBC6Wg6CJE4JqBKS iL0N5dSvDAH1e X-Received: by 2002:adf:ea45:: with SMTP id j5mr3279486wrn.291.1633179217541; Sat, 02 Oct 2021 05:53:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvngRg6mSfZAPhLoI1z88TfL+DRAdtPTmC0GBIdj7S99yXfNxRBj9wMpPO15fh3FpbNOAwJw== X-Received: by 2002:adf:ea45:: with SMTP id j5mr3279481wrn.291.1633179217363; Sat, 02 Oct 2021 05:53:37 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id b15sm10237676wru.9.2021.10.02.05.53.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:37 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 04/22] target/i386/kvm: Restrict SEV stubs to x86 architecture Date: Sat, 2 Oct 2021 14:52:59 +0200 Message-Id: <20211002125317.3418648-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org SEV is x86-specific, no need to add its stub to other architectures. Move the stub file to target/i386/kvm/. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- {accel => target/i386}/kvm/sev-stub.c | 0 accel/kvm/meson.build | 1 - target/i386/kvm/meson.build | 2 ++ 3 files changed, 2 insertions(+), 1 deletion(-) rename {accel => target/i386}/kvm/sev-stub.c (100%) diff --git a/accel/kvm/sev-stub.c b/target/i386/kvm/sev-stub.c similarity index 100% rename from accel/kvm/sev-stub.c rename to target/i386/kvm/sev-stub.c diff --git a/accel/kvm/meson.build b/accel/kvm/meson.build index 8d219bea507..397a1fe1fd1 100644 --- a/accel/kvm/meson.build +++ b/accel/kvm/meson.build @@ -3,6 +3,5 @@ 'kvm-all.c', 'kvm-accel-ops.c', )) -kvm_ss.add(when: 'CONFIG_SEV', if_false: files('sev-stub.c')) specific_ss.add_all(when: 'CONFIG_KVM', if_true: kvm_ss) diff --git a/target/i386/kvm/meson.build b/target/i386/kvm/meson.build index b1c76957c76..736df8b72e3 100644 --- a/target/i386/kvm/meson.build +++ b/target/i386/kvm/meson.build @@ -7,6 +7,8 @@ 'kvm-cpu.c', )) +i386_softmmu_kvm_ss.add(when: 'CONFIG_SEV', if_false: files('sev-stub.c')) + i386_softmmu_ss.add(when: 'CONFIG_HYPERV', if_true: files('hyperv.c'), if_false: files('hyperv-stub.c')) i386_softmmu_ss.add_all(when: 'CONFIG_KVM', if_true: i386_softmmu_kvm_ss) From patchwork Sat Oct 2 12:53:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532073 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E969C433FE for ; Sat, 2 Oct 2021 12:53:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3897C61A51 for ; Sat, 2 Oct 2021 12:53:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233223AbhJBMzd (ORCPT ); Sat, 2 Oct 2021 08:55:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40314 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233217AbhJBMzc (ORCPT ); Sat, 2 Oct 2021 08:55:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179226; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l2pfbYxP1f86zn1O+UmnIVR/OdXuADklhW48W/+4agE=; b=aqg6YioDSz9T8fdJVEajRj/Bg407r39Yxyhf+f/6WrWD7SeXvgc56YjSY55iCUbbsZUT2d +7AXGu+/k3acMPBf+Aeke2BmKbC4XA/mOGksTviPb2TkxLlUEYxBcVo8b04EVg3p1WfTkI T4WyEOqDFS5OA+qwAHA6eTkwWPYxniM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-gF2vrlU6PzOodj88UH2LAg-1; Sat, 02 Oct 2021 08:53:43 -0400 X-MC-Unique: gF2vrlU6PzOodj88UH2LAg-1 Received: by mail-wm1-f70.google.com with SMTP id z137-20020a1c7e8f000000b0030cd1800d86so6075368wmc.2 for ; Sat, 02 Oct 2021 05:53:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l2pfbYxP1f86zn1O+UmnIVR/OdXuADklhW48W/+4agE=; b=3kYS/eOPE9IdkKtKXDBG5menKxXPbsWSHnrbT+aAP6A8h5OI1MCBxzmMB3mmin13hv DmSjUbwR6c+9zWZJT36iKtVJ4bY2Z1XG1ggn07+YgcvkTgdb/EE7Ex8YCk6zmXokCZ+b 6IPYDx+Ji3P+fxiH9CoeOLJIgEmWCrowEqRqxJ1qAg4tHZIHKZ3JZUDnbpifJQI2dCHT xaqi025WhpIQGUR51cNGY9+2h55ZifYtsHkAv3K3xj96TKZeZIkYKlQqnCsgKGyulVNk M+rjo5ah1XdIBOuo7fI2z8n8zDA2xqZyjjiRcbRLuW7Cp3uq+AfwUjjhV59GXBlC9HYr /KIg== X-Gm-Message-State: AOAM532o6HSjU9i5Sz36cI5P8+p1gbtVKYMujSZuw6a3+G2WIi3sAjGk D+HP+A8vZ9Kgt0oOBSHyLvP1vmDyVy9oBXDw8wq++7CowB0Cs4imHclTnrjV1CUvNC6Hxk7E9RH dqNqA+6djqAgN X-Received: by 2002:adf:b19b:: with SMTP id q27mr3023131wra.125.1633179222031; Sat, 02 Oct 2021 05:53:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0wFJ6jOD1dsu7MobrHxWDwOimiCMUGE3Wc9F0Vh2YBeD1QDrYkdFU3s2oEYQ/eTvQ2tlbQw== X-Received: by 2002:adf:b19b:: with SMTP id q27mr3023109wra.125.1633179221880; Sat, 02 Oct 2021 05:53:41 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id l21sm1643231wmg.18.2021.10.02.05.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" , Connor Kuehl Subject: [PATCH v3 05/22] target/i386/monitor: Return QMP error when SEV is disabled in build Date: Sat, 2 Oct 2021 14:53:00 +0200 Message-Id: <20211002125317.3418648-6-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If the management layer tries to inject a secret, it gets an empty response in case the binary built without SEV: { "execute": "sev-inject-launch-secret", "arguments": { "packet-header": "mypkt", "secret": "mypass", "gpa": 4294959104 } } { "return": { } } Make it clearer by returning an error, mentioning the feature is disabled: { "execute": "sev-inject-launch-secret", "arguments": { "packet-header": "mypkt", "secret": "mypass", "gpa": 4294959104 } } { "error": { "class": "GenericError", "desc": "this feature or command is not currently supported" } } Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Philippe Mathieu-Daudé --- target/i386/monitor.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 196c1c9e77f..a9f85acd473 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -28,6 +28,7 @@ #include "monitor/hmp-target.h" #include "monitor/hmp.h" #include "qapi/qmp/qdict.h" +#include "qapi/qmp/qerror.h" #include "sysemu/kvm.h" #include "sysemu/sev.h" #include "qapi/error.h" @@ -743,6 +744,10 @@ void qmp_sev_inject_launch_secret(const char *packet_hdr, bool has_gpa, uint64_t gpa, Error **errp) { + if (!sev_enabled()) { + error_setg(errp, QERR_UNSUPPORTED); + return; + } if (!has_gpa) { uint8_t *data; struct sev_secret_area *area; From patchwork Sat Oct 2 12:53:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532075 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F09B8C433EF for ; Sat, 2 Oct 2021 12:53:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7B6B61A51 for ; Sat, 2 Oct 2021 12:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233282AbhJBMzf (ORCPT ); Sat, 2 Oct 2021 08:55:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47715 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233216AbhJBMzf (ORCPT ); Sat, 2 Oct 2021 08:55:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179229; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=T1NIBoSE4LuxR67pjfbeheswmOYBoIBhIFI0FnH33UA=; b=hom5VAod04hjnOJJP+FoudbVaFc0wkak+VXQIRrTBLUQP8GfK/wu6Da8mS20UtAfAzbkVR sll4HZuqC1rVbE3vRSHUfGEM3eRet5x2KrZhHthQJ99ZQPUXQ6hnj6d49hulJCZaBF7ua+ TNZ6vzs3koKHlGaGwQU/hth0yX4qIr4= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-568-c6p7q1fFOYGIicM1kithSg-1; Sat, 02 Oct 2021 08:53:48 -0400 X-MC-Unique: c6p7q1fFOYGIicM1kithSg-1 Received: by mail-wm1-f71.google.com with SMTP id j21-20020a05600c1c1500b0030ccce95837so3788990wms.3 for ; Sat, 02 Oct 2021 05:53:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T1NIBoSE4LuxR67pjfbeheswmOYBoIBhIFI0FnH33UA=; b=0c8mQ7Ho47mh+lXRnLhSR1MpIwSgLCztXByrc6PsOfgYxcW/JHWDTUC8rdUjFtwJlG MXv3lu2T4b1ISq2KyDfKYoXNlZvKD96wlikpgwamcCNby7znqgfx/7cGXnImo506HZ0e ppgm9w7hSD7GogSOyIelYCJiH2VOIUzLE59DiIicbM26ZdBsYWVUNYktC/R/IGFFfP0S OnCiiyaOXs/o2pd3qo3A75m4/QUa1Z1n8ndOeUHg7vq4QjcdnYsnMsxqPA0QUoKRNKa7 GVDuHMJ9+9IZIElnO9+VymH9M3XqyAz/vqnxRN8F+qHxq+jQsHFPuppPYlwtpmjrb4bR T09A== X-Gm-Message-State: AOAM530zNLKgnkdhvH3drTk4fZpEex0hXLmQ0lJNjjR/13J3syjJcFkq LhRIEf+gwjSCyUFZJcOf8S3cjyDFpKcw05b0508MZzyn7+HY9q/04TVcQG5JT1SYu03RW0LGhXz cIhfmopd2X2Xn X-Received: by 2002:a05:6000:c3:: with SMTP id q3mr3272625wrx.361.1633179226451; Sat, 02 Oct 2021 05:53:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSb9fTK6/UuOYq5MO4Gn39GE9tLudrOZsgwLInKNkYdtRvDdV88QT0skDGxAwXecnl0DrCeA== X-Received: by 2002:a05:6000:c3:: with SMTP id q3mr3272609wrx.361.1633179226312; Sat, 02 Oct 2021 05:53:46 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id l26sm10571166wmi.25.2021.10.02.05.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" , Connor Kuehl Subject: [PATCH v3 06/22] target/i386/cpu: Add missing 'qapi/error.h' header Date: Sat, 2 Oct 2021 14:53:01 +0200 Message-Id: <20211002125317.3418648-7-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Commit 00b81053244 ("target-i386: Remove assert_no_error usage") forgot to add the "qapi/error.h" for &error_abort, add it now. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index cacec605bf1..e169a01713d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -27,6 +27,7 @@ #include "sysemu/hvf.h" #include "kvm/kvm_i386.h" #include "sev_i386.h" +#include "qapi/error.h" #include "qapi/qapi-visit-machine.h" #include "qapi/qmp/qerror.h" #include "qapi/qapi-commands-machine-target.h" From patchwork Sat Oct 2 12:53:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532077 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48E91C433F5 for ; Sat, 2 Oct 2021 12:53:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 345A961A51 for ; Sat, 2 Oct 2021 12:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233286AbhJBMzk (ORCPT ); Sat, 2 Oct 2021 08:55:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27051 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233217AbhJBMzj (ORCPT ); Sat, 2 Oct 2021 08:55:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179233; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J6Nu9xcD/1mLwA45H6T/mwE1HK3rKCkbuT6P4bJEEQ4=; b=WOzXIdZrMDUAtoo9o7MEfWUtNCtab60BP9qO4YEiZuIuEK82TskcazDOibkAZ0KkFnByaV J/idG34SH18tBH807TrZnHE/0ILZGiJwtFU9EcKQ+is8xja3/lLCKFzcBkP+4jPDxvuBR5 gbduzBxjASGFsz+DHjdyPHKn/Op9ZMc= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-330-3TkHJxFyOB-7euTa2KKLFw-1; Sat, 02 Oct 2021 08:53:52 -0400 X-MC-Unique: 3TkHJxFyOB-7euTa2KKLFw-1 Received: by mail-wm1-f71.google.com with SMTP id 5-20020a1c00050000b02902e67111d9f0so6079013wma.4 for ; Sat, 02 Oct 2021 05:53:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J6Nu9xcD/1mLwA45H6T/mwE1HK3rKCkbuT6P4bJEEQ4=; b=Jg+2G+92UG44hU8XZIgXbP1qIowQiwwyKJoIh0kZUNn0nSiXDCNd4wxNkpkrpYxxbm QF9WUl3VQcit/GDn5evX+Xf4rgWsZPbGBHFnyYVPJzBWzqTmgLLnVuSv5SNgwi2qbpbN dQMTShyf4e2zunUsb2ttSJRW4tRVODwQ9hNYdHmWOY/S+lvMSO55tiNRTspMONtbdGWH Hho5hjGpxmgZ62uVNXOqVcrkgM+r8NUJ1bpPABKPdVJey1Cu5Wop2IaEaa2eYvTxY+Iu RD2fDBh0YhveGvsQCMISBqOmIbXVKweSILPJeScCNm4bOqPLWEdYkq6F+00CMPZb59I7 daZw== X-Gm-Message-State: AOAM533/VZI5neCjVPqISwOoNoh0u0uBEV1h0yUUHdpxI2M/CR30Lr55 lZ8iGOCh/YuYy00OQaOsm2hVN9J0r97ooJbT7qWDwOLZapMxD2xo1rJunM6bUiv9bb+W8Rgyba3 hK/oufXpK4tmf X-Received: by 2002:adf:97cc:: with SMTP id t12mr1334720wrb.189.1633179230888; Sat, 02 Oct 2021 05:53:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEX2HQVvG0eH4EoV9kXNFJrMMQBJdc9DWwXnuA0OfpprIlXkRMpruuO+nx+/QeCu4EKQakjA== X-Received: by 2002:adf:97cc:: with SMTP id t12mr1334706wrb.189.1633179230756; Sat, 02 Oct 2021 05:53:50 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id f18sm4106229wrj.30.2021.10.02.05.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" , Connor Kuehl Subject: [PATCH v3 07/22] target/i386/sev_i386.h: Remove unused headers Date: Sat, 2 Oct 2021 14:53:02 +0200 Message-Id: <20211002125317.3418648-8-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Declarations don't require these headers, remove them. Reviewed-by: Connor Kuehl Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev_i386.h | 4 ---- target/i386/sev-stub.c | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index ae6d8404787..f4223f1febf 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -14,11 +14,7 @@ #ifndef QEMU_SEV_I386_H #define QEMU_SEV_I386_H -#include "qom/object.h" -#include "qapi/error.h" -#include "sysemu/kvm.h" #include "sysemu/sev.h" -#include "qemu/error-report.h" #include "qapi/qapi-types-misc-target.h" #define SEV_POLICY_NODBG 0x1 diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c index 0227cb51778..d91c2ece784 100644 --- a/target/i386/sev-stub.c +++ b/target/i386/sev-stub.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "sev_i386.h" SevInfo *sev_get_info(void) From patchwork Sat Oct 2 12:53:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532081 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 273F1C433EF for ; Sat, 2 Oct 2021 12:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1005D61A51 for ; Sat, 2 Oct 2021 12:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233293AbhJBMzv (ORCPT ); Sat, 2 Oct 2021 08:55:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37735 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233291AbhJBMzt (ORCPT ); Sat, 2 Oct 2021 08:55:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179243; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2JOuakDg9TjNTLsEL31Gb5qf2swMU1YyZ5LrMCCfA9Y=; b=atJkaSqSD0IQc1ORNLP5tLwT/yz72MUEJk1o/1f3m7LkYhGdaea15qXRT+PCNYxQ7VltCA u4BFLgXUr0XiB3P9H+3jVpKlf2qElOOwyfE9sIt9m/fr6jy+iDaldePzbIajNtkza7pzBV jgXReu0EDNFvFAf+/l3vrZskGM7mkOw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-ba8Xnr6uOnKbZZWNhnm6ug-1; Sat, 02 Oct 2021 08:53:56 -0400 X-MC-Unique: ba8Xnr6uOnKbZZWNhnm6ug-1 Received: by mail-wm1-f69.google.com with SMTP id 5-20020a1c00050000b02902e67111d9f0so6079098wma.4 for ; Sat, 02 Oct 2021 05:53: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:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2JOuakDg9TjNTLsEL31Gb5qf2swMU1YyZ5LrMCCfA9Y=; b=YWpWc4ZuMTyWF+IKUvxIt0LcWdrIk4ku0ot7aLNhirZ2SNWEHxBhpIWp9/2SllOU8j 2gLsSdjbaWSyxBQu2FpJ5DHMYIYUcwQqtYVNJwg4hQ4Ofutlf3DHenK2ppDAoRLjBLSZ 8ExDi9yH4DLdVx2vvsmxe3pvZMoVVRm3XA61CNL+28M5ViMRbwYaeK1G6VKL6rtWTt93 Sc/OlGsqYf/ITy3Gr4U7XDMXW9dvAxrcdhm57F538LyU3piRTjv/jsUdXnrW6tl3NXDl 5mnzDv6yU5q5YVUdKhqYACLl0KX6kSH1lZ/D4khZzkZ2sur1FIwymS6XKx3aMZljNsAT RrDA== X-Gm-Message-State: AOAM533qPOJSABJJpM6I0xXLsyjIL7gk3MVkv0A9xxCUyJWci8iYKqt5 a5/9YEyisvqJFGNKtYltknZQhQkfJVJOtirGuNQbhc4BYQnoZ7gVGTCjPn/hhvEMcRYXWa5e1+A tmRBeXqk9HCnc X-Received: by 2002:adf:a18d:: with SMTP id u13mr3366726wru.275.1633179235453; Sat, 02 Oct 2021 05:53:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3pw9/64lGQcYsWkhaqchQbJCRGpJ8vrpRflv453uN3gfkMzMibGa3diRsytvz2Ljjr0eAUQ== X-Received: by 2002:adf:a18d:: with SMTP id u13mr3366709wru.275.1633179235309; Sat, 02 Oct 2021 05:53:55 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id o12sm8849678wms.15.2021.10.02.05.53.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" , Connor Kuehl Subject: [PATCH v3 08/22] target/i386/sev: Remove sev_get_me_mask() Date: Sat, 2 Oct 2021 14:53:03 +0200 Message-Id: <20211002125317.3418648-9-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Unused dead code makes review harder, so remove it. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev_i386.h | 1 - target/i386/sev-stub.c | 5 ----- target/i386/sev.c | 9 --------- 3 files changed, 15 deletions(-) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index f4223f1febf..afa19a0a161 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -25,7 +25,6 @@ #define SEV_POLICY_SEV 0x20 extern bool sev_es_enabled(void); -extern uint64_t sev_get_me_mask(void); extern SevInfo *sev_get_info(void); extern uint32_t sev_get_cbit_position(void); extern uint32_t sev_get_reduced_phys_bits(void); diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c index d91c2ece784..eb0c89bf2be 100644 --- a/target/i386/sev-stub.c +++ b/target/i386/sev-stub.c @@ -25,11 +25,6 @@ bool sev_enabled(void) return false; } -uint64_t sev_get_me_mask(void) -{ - return ~0; -} - uint32_t sev_get_cbit_position(void) { return 0; diff --git a/target/i386/sev.c b/target/i386/sev.c index fa7210473a6..c88cd808410 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -64,7 +64,6 @@ struct SevGuestState { uint8_t api_major; uint8_t api_minor; uint8_t build_id; - uint64_t me_mask; int sev_fd; SevState state; gchar *measurement; @@ -362,12 +361,6 @@ sev_es_enabled(void) return sev_enabled() && (sev_guest->policy & SEV_POLICY_ES); } -uint64_t -sev_get_me_mask(void) -{ - return sev_guest ? sev_guest->me_mask : ~0; -} - uint32_t sev_get_cbit_position(void) { @@ -804,8 +797,6 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp) goto err; } - sev->me_mask = ~(1UL << sev->cbitpos); - devname = object_property_get_str(OBJECT(sev), "sev-device", NULL); sev->sev_fd = open(devname, O_RDWR); if (sev->sev_fd < 0) { From patchwork Sat Oct 2 12:53:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532079 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D09EC433F5 for ; Sat, 2 Oct 2021 12:54:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D73261AF8 for ; Sat, 2 Oct 2021 12:54:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233226AbhJBMzt (ORCPT ); Sat, 2 Oct 2021 08:55:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51138 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233291AbhJBMzs (ORCPT ); Sat, 2 Oct 2021 08:55:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179242; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KJdW6m0Ma56hwzjCy1teOEHrEH20tchf6AQogJnEfxU=; b=IMROb0Jmtcifq0WE06BVpFvlcPZbhXPT0OmZYgYlj4whBtlz4N5yag++utQ0FO4vr1FBYy PeCMczK9CbCzOSnXMni4eO4wQ7+b35x87Ov4pnPsDb4oG6069DUETVZq3rtSm6Kod0vg30 xezFufs0RlYqf6TDnkCgPG0m/lv6caE= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-390-tgpzsy_GPdKu6Cjdht0I9g-1; Sat, 02 Oct 2021 08:54:01 -0400 X-MC-Unique: tgpzsy_GPdKu6Cjdht0I9g-1 Received: by mail-wm1-f70.google.com with SMTP id y23-20020a05600c365700b003015b277f98so3788580wmq.2 for ; Sat, 02 Oct 2021 05:54:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KJdW6m0Ma56hwzjCy1teOEHrEH20tchf6AQogJnEfxU=; b=ZZlFtu5Xtz0aVyU95JHLnNb/oUJnkVj32hidIFM+w8m1VVkNUroIMLXgrO3QiETL0L 5sF9tm/QCC3A3iLXSmkydSJcBTYLZM1alj9L5PaZ1HRsj0IUid9t0Fnb5xoUQxAShmVL xy64WSYSwxEv9QrFCQ+7myfMYUlfQ4cPNDnWmBYWvyk6EvGsSXejdQQHWUHF6XV2VEsX mGWBM/AuTnH9BhjGcw60+exH6JW89pOv5nPnxXq03NObcCd+C7/4ptF3MYlkDenFKTNB rLZBkPP+IpuEbdF/faQqxaCM+k4QPTtIzeN3PToZ5o06r6WvagTB3QTSW2lHOpS29BMD 7rCw== X-Gm-Message-State: AOAM530OuuWefdIzqYbp1Ykxv2XgGYfcefL/2vrwV8HG7LDX0XXlS0m6 u2Sco6wV1Xc8V+CvDQdbuuzw6m9WaMCn4iKI6A7cFwwIB6Os9Q9fjzHQ2HCIuPSnoDhqDn4Ijf8 2VZx/rJl74Efh X-Received: by 2002:a05:6000:2c6:: with SMTP id o6mr3374977wry.292.1633179240039; Sat, 02 Oct 2021 05:54:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1kpUWp8JDca6ogxcYyGFA/Lr3YXbhWtYHXiUio3plQycEwa1/nNlCgTVPD8fjk35/bjBa4A== X-Received: by 2002:a05:6000:2c6:: with SMTP id o6mr3374964wry.292.1633179239910; Sat, 02 Oct 2021 05:53:59 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id f1sm9356839wri.43.2021.10.02.05.53.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:53:59 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" , Connor Kuehl Subject: [PATCH v3 09/22] target/i386/sev: Mark unreachable code with g_assert_not_reached() Date: Sat, 2 Oct 2021 14:53:04 +0200 Message-Id: <20211002125317.3418648-10-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The unique sev_encrypt_flash() invocation (in pc_system_flash_map) is protected by the "if (sev_enabled())" check, so is not reacheable. Replace the abort() call in sev_es_save_reset_vector() by g_assert_not_reached() which meaning is clearer. Reviewed-by: Connor Kuehl Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev-stub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c index eb0c89bf2be..4668365fd3e 100644 --- a/target/i386/sev-stub.c +++ b/target/i386/sev-stub.c @@ -54,7 +54,7 @@ int sev_inject_launch_secret(const char *hdr, const char *secret, int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp) { - return 0; + g_assert_not_reached(); } bool sev_es_enabled(void) @@ -68,7 +68,7 @@ void sev_es_set_reset_vector(CPUState *cpu) int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size) { - abort(); + g_assert_not_reached(); } SevAttestationReport * From patchwork Sat Oct 2 12:53:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532083 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5701CC433F5 for ; Sat, 2 Oct 2021 12:54:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3976361AF8 for ; Sat, 2 Oct 2021 12:54:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233295AbhJBMzz (ORCPT ); Sat, 2 Oct 2021 08:55:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22397 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233288AbhJBMzy (ORCPT ); Sat, 2 Oct 2021 08:55:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179248; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tAj3BwaM+hRNB5Zlp17fWtjr58QjWY/+pHTXgMu/M3k=; b=Xc5pHhUzkq40srIW+Dh50j/7Eah9eYKTgMxn+lcngBQH/yn/qf0X6tK0fZ10QkGbjc5PEg +ajB5iRNq3zSB/zVy6RovzxICEHs/GJsnnJCdP+MnSLjmYgYFGLF9950wB1zo1412AcU/B j8aR0e4pbD9N1jkhow4lJsfatglj1Yk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-555-SpmNsjGxNs6F3DXUGlalwA-1; Sat, 02 Oct 2021 08:54:05 -0400 X-MC-Unique: SpmNsjGxNs6F3DXUGlalwA-1 Received: by mail-wm1-f72.google.com with SMTP id v5-20020a1cac05000000b0030b85d2d479so6060661wme.9 for ; Sat, 02 Oct 2021 05:54:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tAj3BwaM+hRNB5Zlp17fWtjr58QjWY/+pHTXgMu/M3k=; b=NBWoYnvF3a4QfE2VQLZ1qLQUN7XpIIUlvGbbU8zdYJtYW94PY319qc5OzL0qa7KL40 VPsj+BZVkbe9cKG4V3GwW/sqBtfhAr/2bzThMqoHIOCK3tmUnZruaNwmNUdCGzlFKYI0 AqY2nMIbnFKE7fnYYQ5782G8hDgYu9Ykd0oNn8txOF9kealDbWmTYc+na6J+NTbs38ti pZHSymxukdogRGUFVlql5UL86BjEjcWDl8Y1JbRBm9YZEdW83MIXO8IGE6fin3hyt8A8 Sonv10aLpl1ajH4mVxQDlN1byE93B9giTfoq0rOM0xicweZXQxVTiwOktCkDD1u4LuFt 02ag== X-Gm-Message-State: AOAM531t7uRRpZ5tNF1n+kcauKyymVXojC3WPiA6x9Gx4z3q/wL9DnvI S2lAJ8FYljF43d/RYhONnJoqyXwNuHp0ibTH3QxdrWk05m+ABDNmaVfRBkC/Ks5A/lwr7CtL7nf uQCd/RULfQbYS X-Received: by 2002:a5d:64cf:: with SMTP id f15mr3236677wri.284.1633179244573; Sat, 02 Oct 2021 05:54:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgDxwlX5HGT9dZoGs+v2dDhfLDMjbUmMV+tcfi8guLt6V72knTXRGXTjkGozRRcnhuV3Vi0Q== X-Received: by 2002:a5d:64cf:: with SMTP id f15mr3236665wri.284.1633179244437; Sat, 02 Oct 2021 05:54:04 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id i7sm8530172wrp.5.2021.10.02.05.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:04 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" , Connor Kuehl Subject: [PATCH v3 10/22] target/i386/sev: sev_get_attestation_report use g_autofree Date: Sat, 2 Oct 2021 14:53:05 +0200 Message-Id: <20211002125317.3418648-11-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: "Dr. David Alan Gilbert" Removes a whole bunch of g_free's and a goto. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Connor Kuehl Reviewed-by: Brijesh Singh Message-Id: <20210603113017.34922-1-dgilbert@redhat.com> Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index c88cd808410..aefbef4bb63 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -493,8 +493,8 @@ sev_get_attestation_report(const char *mnonce, Error **errp) struct kvm_sev_attestation_report input = {}; SevAttestationReport *report = NULL; SevGuestState *sev = sev_guest; - guchar *data; - guchar *buf; + g_autofree guchar *data = NULL; + g_autofree guchar *buf = NULL; gsize len; int err = 0, ret; @@ -514,7 +514,6 @@ sev_get_attestation_report(const char *mnonce, Error **errp) if (len != sizeof(input.mnonce)) { error_setg(errp, "SEV: mnonce must be %zu bytes (got %" G_GSIZE_FORMAT ")", sizeof(input.mnonce), len); - g_free(buf); return NULL; } @@ -525,7 +524,6 @@ sev_get_attestation_report(const char *mnonce, Error **errp) if (err != SEV_RET_INVALID_LEN) { error_setg(errp, "failed to query the attestation report length " "ret=%d fw_err=%d (%s)", ret, err, fw_error_to_str(err)); - g_free(buf); return NULL; } } @@ -540,7 +538,7 @@ sev_get_attestation_report(const char *mnonce, Error **errp) if (ret) { error_setg_errno(errp, errno, "Failed to get attestation report" " ret=%d fw_err=%d (%s)", ret, err, fw_error_to_str(err)); - goto e_free_data; + return NULL; } report = g_new0(SevAttestationReport, 1); @@ -548,9 +546,6 @@ sev_get_attestation_report(const char *mnonce, Error **errp) trace_kvm_sev_attestation_report(mnonce, report->data); -e_free_data: - g_free(data); - g_free(buf); return report; } From patchwork Sat Oct 2 12:53:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532095 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E9B5C433EF for ; Sat, 2 Oct 2021 12:54:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44A2261AF8 for ; Sat, 2 Oct 2021 12:54:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233288AbhJBMz5 (ORCPT ); Sat, 2 Oct 2021 08:55:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21764 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233277AbhJBMz5 (ORCPT ); Sat, 2 Oct 2021 08:55:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179251; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AZLS+m7xAvvk2uRB++FAfryJbzXnCIDe39YBz1qMJyo=; b=cAJsT9hPxKeAPOiS3lTpLkXmCWqN/L7g21neJdhTZYR3flL8ZYkm7Ao01JTNuM0pU6506T DSgw6vsSOGzMXhH+NXUd5jRFjYwpKU+EGZIRvrtKeRwl6jbhGf7TCY+zDev5KWPTzgzZTk zNTmPTfjSgj2aIJziMEdTDWyWzV3maw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-579-WcEH7UnDPWWKETcxOi4BDw-1; Sat, 02 Oct 2021 08:54:10 -0400 X-MC-Unique: WcEH7UnDPWWKETcxOi4BDw-1 Received: by mail-wm1-f69.google.com with SMTP id o11-20020a05600c378b00b0030d4f47013aso2285875wmr.7 for ; Sat, 02 Oct 2021 05:54:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AZLS+m7xAvvk2uRB++FAfryJbzXnCIDe39YBz1qMJyo=; b=3SsdQtmeXQZgPMXub4QhVRSCgrNYTYURokVIuV+HATQxRSztL4nVjw6k5Cog4b7JQc +iCzdDG9hXjmtcChkwShUGtDSi+66SJU0zdII80rKfgjGMn+L8/7HV+9UYQGlYyKWyCG QLRDoH/lDTs0I0IaI2NxVxaADZi61e3zT1EP1XH10x5FYbk9UpBZ+QUN7UYy3KW+cW7B rUbl4ph5B9STEoDj5FrDgy+5sO+o63/fMkphO4YG57WZmw5R8P+gcUNdYrIcF9EHNR3B a4hzNI+P7JMyMhIlaKBnyh8kYUYKXgZlcwvSeQoSMYr9qmI7z9XK739ayhEoYWwA+tml plcw== X-Gm-Message-State: AOAM532YTI8WBTs/JxrIMosifOfFbqlpMABGt4UuADQ43ZEAcn/Q4wpS b565vytUQ8Mqhv/Q+Vni+2p0ckYAnBkf6ZAEk1DkyFUY5Zbb3bFwbB6TqmQIU5HG7LioQ2KXdZV kVwyRFmMlQxLk X-Received: by 2002:adf:b185:: with SMTP id q5mr1100016wra.213.1633179248985; Sat, 02 Oct 2021 05:54:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhvlat8mS6Fsi/9Q+MqqxK+CL6/DlRnFXF7c3AjMW/EsZmLOxs5oU2baglAlxjjo/FnbXepw== X-Received: by 2002:adf:b185:: with SMTP id q5mr1100005wra.213.1633179248822; Sat, 02 Oct 2021 05:54:08 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id z8sm9814721wrm.63.2021.10.02.05.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:08 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 11/22] target/i386/sev: Restrict SEV to system emulation Date: Sat, 2 Oct 2021 14:53:06 +0200 Message-Id: <20211002125317.3418648-12-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org SEV is irrelevant on user emulation, so restrict it to sysemu. Some stubs are still required because used in cpu.c by x86_register_cpudef_types(), so move the sysemu specific stubs to sev-sysemu-stub.c instead. This will allow us to simplify monitor.c (which is not available in user emulation) in the next commit. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev-stub.c | 43 ------------------------- target/i386/sev-sysemu-stub.c | 60 +++++++++++++++++++++++++++++++++++ target/i386/meson.build | 4 ++- 3 files changed, 63 insertions(+), 44 deletions(-) create mode 100644 target/i386/sev-sysemu-stub.c diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c index 4668365fd3e..8eae5d2fa8d 100644 --- a/target/i386/sev-stub.c +++ b/target/i386/sev-stub.c @@ -15,11 +15,6 @@ #include "qapi/error.h" #include "sev_i386.h" -SevInfo *sev_get_info(void) -{ - return NULL; -} - bool sev_enabled(void) { return false; @@ -35,45 +30,7 @@ uint32_t sev_get_reduced_phys_bits(void) return 0; } -char *sev_get_launch_measurement(void) -{ - return NULL; -} - -SevCapability *sev_get_capabilities(Error **errp) -{ - error_setg(errp, "SEV is not available in this QEMU"); - return NULL; -} - -int sev_inject_launch_secret(const char *hdr, const char *secret, - uint64_t gpa, Error **errp) -{ - return 1; -} - -int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp) -{ - g_assert_not_reached(); -} - bool sev_es_enabled(void) { return false; } - -void sev_es_set_reset_vector(CPUState *cpu) -{ -} - -int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size) -{ - g_assert_not_reached(); -} - -SevAttestationReport * -sev_get_attestation_report(const char *mnonce, Error **errp) -{ - error_setg(errp, "SEV is not available in this QEMU"); - return NULL; -} diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c new file mode 100644 index 00000000000..d556b4f091f --- /dev/null +++ b/target/i386/sev-sysemu-stub.c @@ -0,0 +1,60 @@ +/* + * QEMU SEV system stub + * + * Copyright Advanced Micro Devices 2018 + * + * Authors: + * Brijesh Singh + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qapi/qapi-commands-misc-target.h" +#include "qapi/error.h" +#include "sev_i386.h" + +SevInfo *sev_get_info(void) +{ + return NULL; +} + +char *sev_get_launch_measurement(void) +{ + return NULL; +} + +SevCapability *sev_get_capabilities(Error **errp) +{ + error_setg(errp, "SEV is not available in this QEMU"); + return NULL; +} + +int sev_inject_launch_secret(const char *hdr, const char *secret, + uint64_t gpa, Error **errp) +{ + return 1; +} + +int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp) +{ + g_assert_not_reached(); +} + +void sev_es_set_reset_vector(CPUState *cpu) +{ +} + +int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size) +{ + g_assert_not_reached(); +} + +SevAttestationReport *sev_get_attestation_report(const char *mnonce, + Error **errp) +{ + error_setg(errp, "SEV is not available in this QEMU"); + return NULL; +} diff --git a/target/i386/meson.build b/target/i386/meson.build index dac19ec00d4..a4f45c3ec1d 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -6,7 +6,7 @@ 'xsave_helper.c', 'cpu-dump.c', )) -i386_ss.add(when: 'CONFIG_SEV', if_true: files('host-cpu.c', 'sev.c'), if_false: files('sev-stub.c')) +i386_ss.add(when: 'CONFIG_SEV', if_true: files('host-cpu.c'), if_false: files('sev-stub.c')) # x86 cpu type i386_ss.add(when: 'CONFIG_KVM', if_true: files('host-cpu.c')) @@ -20,6 +20,8 @@ 'monitor.c', 'cpu-sysemu.c', )) +i386_softmmu_ss.add(when: 'CONFIG_SEV', if_true: files('sev.c'), if_false: files('sev-sysemu-stub.c')) + i386_user_ss = ss.source_set() subdir('kvm') From patchwork Sat Oct 2 12:53:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532097 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 563A3C433EF for ; Sat, 2 Oct 2021 12:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 383B361ACE for ; Sat, 2 Oct 2021 12:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233305AbhJBM4D (ORCPT ); Sat, 2 Oct 2021 08:56:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54955 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233277AbhJBM4C (ORCPT ); Sat, 2 Oct 2021 08:56:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179256; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PLN18Kg90p6yE/kKbVk7ZeNbapKw0JC8XYHCCSL7Hxc=; b=YqOIYt51o9O0/haJF1hiBqvCXQudbr3IhwIeRxxkJ/itSPYDd7kbeTKP6XPtvPDrRd0yeH DUJW671V52xh8x7gN4VpMFpvKbRydKb8OotOBa7I0csqWO5l+utEJ9BlslsSQBlteIpZ7S /3U5+8kuE3pbYp6aGdlHG0Y0NMg85bo= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-3-OEm_g37eNJqB4S-Nf965yA-1; Sat, 02 Oct 2021 08:54:14 -0400 X-MC-Unique: OEm_g37eNJqB4S-Nf965yA-1 Received: by mail-wm1-f71.google.com with SMTP id m2-20020a05600c3b0200b0030cd1310631so3791381wms.7 for ; Sat, 02 Oct 2021 05:54:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PLN18Kg90p6yE/kKbVk7ZeNbapKw0JC8XYHCCSL7Hxc=; b=w9P7CmKtNYBWxNBauEiOehSdwWzbcp1k6g7EqF0bFpJ/vTJsfktwwSAi3gUZnxxelm rRIZIuTug8aPWTa9iHGIKw54WSBCy7CzoncgOY5fi5FNENTZa4vzokRRsvDE7JLdmbv/ ulwQosqqEoPvMFj5Eab042znxM/SKGcZ3NXI5c9okjk5Sd5mkcQPvNsA5ijIzTMTgp8i Bd3aEYTYQhBsUSeyTtecd97pwof8BxHb46DJ2a8QYBI11mRwcf8zcnOLpgdkZ5G0tcBD urY7UfGKqB3c42nDaH9v8wBbRWkaJtsfL5gAx9IdcZS/fRPmNwYN0xmqNqLe+RgMp64X RtFA== X-Gm-Message-State: AOAM533062MDzx11a23mhrleO8JcyPRdnqOiTyYxoPDuEMCQ30ViW326 tgvigYhQ95JDVy+EvOy1DxH468C9Te9bSsn0NdzwD2otNARW4THwfX3CMByD+q1xNTdGRIKiFiz INZoB4yOJ+JS/ X-Received: by 2002:a1c:451:: with SMTP id 78mr9420870wme.158.1633179253571; Sat, 02 Oct 2021 05:54:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvcuP74ApKFXkJudhkd8SG4XnSX9kLVw5i9VtVFVZpVk56S2QPWclGVjksHGgaC8beyVsBGA== X-Received: by 2002:a1c:451:: with SMTP id 78mr9420859wme.158.1633179253445; Sat, 02 Oct 2021 05:54:13 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id f3sm4714202wmb.12.2021.10.02.05.54.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 12/22] target/i386/sev: Declare system-specific functions in 'sev_i386.h' Date: Sat, 2 Oct 2021 14:53:07 +0200 Message-Id: <20211002125317.3418648-13-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org While prefixed with sysemu, 'sysemu/sev.h' contains the architecture specific declarations. The system specific parts are declared in 'sev_i386.h'. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- include/sysemu/sev.h | 6 ------ target/i386/sev_i386.h | 7 +++++++ hw/i386/pc_sysfw.c | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h index 94d821d737c..a329ed75c1c 100644 --- a/include/sysemu/sev.h +++ b/include/sysemu/sev.h @@ -18,11 +18,5 @@ bool sev_enabled(void); int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp); -int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); -int sev_inject_launch_secret(const char *hdr, const char *secret, - uint64_t gpa, Error **errp); - -int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size); -void sev_es_set_reset_vector(CPUState *cpu); #endif diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index afa19a0a161..0798ab3519a 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -33,4 +33,11 @@ extern SevCapability *sev_get_capabilities(Error **errp); extern SevAttestationReport * sev_get_attestation_report(const char *mnonce, Error **errp); +int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); +int sev_inject_launch_secret(const char *hdr, const char *secret, + uint64_t gpa, Error **errp); + +int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size); +void sev_es_set_reset_vector(CPUState *cpu); + #endif diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 68d6b1f783e..0b202138b66 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -37,7 +37,7 @@ #include "hw/qdev-properties.h" #include "hw/block/flash.h" #include "sysemu/kvm.h" -#include "sysemu/sev.h" +#include "sev_i386.h" #define FLASH_SECTOR_SIZE 4096 From patchwork Sat Oct 2 12:53:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532099 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6315DC433EF for ; Sat, 2 Oct 2021 12:54:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4ACD961AF8 for ; Sat, 2 Oct 2021 12:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233300AbhJBM4J (ORCPT ); Sat, 2 Oct 2021 08:56:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38186 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233277AbhJBM4I (ORCPT ); Sat, 2 Oct 2021 08:56:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179262; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ORMXV0Tst1vudHF4i8O0+oN0mxRTrnSBxDsiV4I1LIw=; b=NlshnXKVitQtim8qSGiGgdDN/uE/knkcCci3ShAkF8RzV8+HRJhXPkgspWm9ZjLG4Z81Wa Qldl+PqfWSC+PgvHDj83bkx4ZMeXCa0XYW6g/cH1luqBCcVv/O4OAh4GicF5d2ZZOPzfOD I0Y0R59VkcNeovBR8rYmXOaKEGANyjg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-gzmGQhyCPy6JWZ8S7JOG4w-1; Sat, 02 Oct 2021 08:54:19 -0400 X-MC-Unique: gzmGQhyCPy6JWZ8S7JOG4w-1 Received: by mail-wm1-f70.google.com with SMTP id j21-20020a05600c1c1500b0030ccce95837so3789305wms.3 for ; Sat, 02 Oct 2021 05:54:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ORMXV0Tst1vudHF4i8O0+oN0mxRTrnSBxDsiV4I1LIw=; b=DtAydpPoYqHW6WbIWDm3sszAy/Wh41FY5mE7TpaggoecOnHNmECWglB+QTxaVS8KQY ezTZ5ECcx258rW7SYH0e4raYtMyBDd6G9HD8FShweDIhLx9AqlftW0kFAKZgPpE9QkSr rMCiWJA3vHh2WQMEeF00if7iD4/QZOlxcFOo2oCZOZjzh5zv3eQukQZs6PXwYV57MAqf xnHPk51XrmX5Yr90L3Bgq0N0LmFA8F2mRznjbRmW7Ye0qJ7hiiGbssq+Zi6ptpmXSJZv cEHX0fqKpL9xFBs4FnxHOMOLWiIodtyCQ3a/y+O6P84uFn1Ata44faFduiGlVqpigMHL +Zmg== X-Gm-Message-State: AOAM533TrQvjsrcDf1ozz/s0yKVGm6RkmoxL9SA+nGdnFQjBHvr6gyaM iyWvflY5hsDuGAa0Ovl9bon/Zw0n0skOKe7lVKu8aQSfWcPeB79wilE+Q/WNhogRlkoATtb2qvU yu1nZEmS6BZoI X-Received: by 2002:adf:a18d:: with SMTP id u13mr3368088wru.275.1633179258172; Sat, 02 Oct 2021 05:54:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuWjXvREy5i/oGIVOiC0tBm2gnRbqZb/64Psa7EoqmzOxcl6FWYaAG1lUh/i/7mWLZCmUUqw== X-Received: by 2002:adf:a18d:: with SMTP id u13mr3368069wru.275.1633179258011; Sat, 02 Oct 2021 05:54:18 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id i2sm8381097wrq.78.2021.10.02.05.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:17 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 13/22] target/i386/sev: Remove stubs by using code elision Date: Sat, 2 Oct 2021 14:53:08 +0200 Message-Id: <20211002125317.3418648-14-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Only declare sev_enabled() and sev_es_enabled() when CONFIG_SEV is set, to allow the compiler to elide unused code. Remove unnecessary stubs. Signed-off-by: Philippe Mathieu-Daudé --- include/sysemu/sev.h | 14 +++++++++++++- target/i386/sev_i386.h | 3 --- target/i386/cpu.c | 16 +++++++++------- target/i386/sev-stub.c | 36 ------------------------------------ target/i386/meson.build | 2 +- 5 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 target/i386/sev-stub.c diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h index a329ed75c1c..f5c625bb3b3 100644 --- a/include/sysemu/sev.h +++ b/include/sysemu/sev.h @@ -14,9 +14,21 @@ #ifndef QEMU_SEV_H #define QEMU_SEV_H -#include "sysemu/kvm.h" +#ifndef CONFIG_USER_ONLY +#include CONFIG_DEVICES /* CONFIG_SEV */ +#endif +#ifdef CONFIG_SEV bool sev_enabled(void); +bool sev_es_enabled(void); +#else +#define sev_enabled() 0 +#define sev_es_enabled() 0 +#endif + +uint32_t sev_get_cbit_position(void); +uint32_t sev_get_reduced_phys_bits(void); + int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **errp); #endif diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 0798ab3519a..2d9a1a0112e 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -24,10 +24,7 @@ #define SEV_POLICY_DOMAIN 0x10 #define SEV_POLICY_SEV 0x20 -extern bool sev_es_enabled(void); extern SevInfo *sev_get_info(void); -extern uint32_t sev_get_cbit_position(void); -extern uint32_t sev_get_reduced_phys_bits(void); extern char *sev_get_launch_measurement(void); extern SevCapability *sev_get_capabilities(Error **errp); extern SevAttestationReport * diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e169a01713d..27992bdc9f8 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -25,8 +25,8 @@ #include "tcg/helper-tcg.h" #include "sysemu/reset.h" #include "sysemu/hvf.h" +#include "sysemu/sev.h" #include "kvm/kvm_i386.h" -#include "sev_i386.h" #include "qapi/error.h" #include "qapi/qapi-visit-machine.h" #include "qapi/qmp/qerror.h" @@ -38,6 +38,7 @@ #include "exec/address-spaces.h" #include "hw/boards.h" #include "hw/i386/sgx-epc.h" +#include "sev_i386.h" #endif #include "disas/capstone.h" @@ -5764,12 +5765,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, *edx = 0; break; case 0x8000001F: - *eax = sev_enabled() ? 0x2 : 0; - *eax |= sev_es_enabled() ? 0x8 : 0; - *ebx = sev_get_cbit_position(); - *ebx |= sev_get_reduced_phys_bits() << 6; - *ecx = 0; - *edx = 0; + *eax = *ebx = *ecx = *edx = 0; + if (sev_enabled()) { + *eax = 0x2; + *eax |= sev_es_enabled() ? 0x8 : 0; + *ebx = sev_get_cbit_position(); + *ebx |= sev_get_reduced_phys_bits() << 6; + } break; default: /* reserved values: zero */ diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c deleted file mode 100644 index 8eae5d2fa8d..00000000000 --- a/target/i386/sev-stub.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * QEMU SEV stub - * - * Copyright Advanced Micro Devices 2018 - * - * Authors: - * Brijesh Singh - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * See the COPYING file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include "qapi/error.h" -#include "sev_i386.h" - -bool sev_enabled(void) -{ - return false; -} - -uint32_t sev_get_cbit_position(void) -{ - return 0; -} - -uint32_t sev_get_reduced_phys_bits(void) -{ - return 0; -} - -bool sev_es_enabled(void) -{ - return false; -} diff --git a/target/i386/meson.build b/target/i386/meson.build index a4f45c3ec1d..ae38dc95635 100644 --- a/target/i386/meson.build +++ b/target/i386/meson.build @@ -6,7 +6,7 @@ 'xsave_helper.c', 'cpu-dump.c', )) -i386_ss.add(when: 'CONFIG_SEV', if_true: files('host-cpu.c'), if_false: files('sev-stub.c')) +i386_ss.add(when: 'CONFIG_SEV', if_true: files('host-cpu.c')) # x86 cpu type i386_ss.add(when: 'CONFIG_KVM', if_true: files('host-cpu.c')) From patchwork Sat Oct 2 12:53:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532101 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B83EFC433EF for ; Sat, 2 Oct 2021 12:54:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A52961ACE for ; Sat, 2 Oct 2021 12:54:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233309AbhJBM4L (ORCPT ); Sat, 2 Oct 2021 08:56:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44643 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233277AbhJBM4K (ORCPT ); Sat, 2 Oct 2021 08:56:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179264; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+4z6jUCebNJqEmNFJ/VStW7BTMEQNitBNtR46XouroI=; b=Fgg2WK/FoaEoFd1NraXoeMRhu0Ejvk+ZO18gpE195cVEbiWHmARp3Uq8HKHE8OdlUlC57w 6f3R+TFJOgDiaojdEuLwOWj8r/n4wsZyI3erDBOB4f4EyFTp4zHiIpvMJnjDqsnlxok1kp iLtWb7iQ8gdu/2kxEm+AHe5cXpEK0IU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-0-2DjKR7NgiXWb99ksdMcw-1; Sat, 02 Oct 2021 08:54:23 -0400 X-MC-Unique: 0-2DjKR7NgiXWb99ksdMcw-1 Received: by mail-wm1-f72.google.com with SMTP id z137-20020a1c7e8f000000b0030cd1800d86so6075917wmc.2 for ; Sat, 02 Oct 2021 05:54:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+4z6jUCebNJqEmNFJ/VStW7BTMEQNitBNtR46XouroI=; b=8B5UIoxbBcUtRMQgXDHxIOYPMo+5Vzmsme4c3+HhnYOmYUoS8CtHUSmtItPNkkEBv6 KSsRnG7dT1MMPr3FdgKtyZyo2ms7ZxpQQ8Cuk1RwuUz1CVaMuyJMliiGIa4ezyXiE9E2 KfrpveNu/pxF0FG8OWZiYas8c18diEXHgR7MKLi8irr2WcvpJqFrm/gEdCow2ULbKDCm 1GYQwSGQFI8gRTVdloxavwohZs58sZ5ng2v5jQc+Yw6XhIYfPuJbY1MUbSxq7JxttB/M qk+A+UktROFx3IO5h6IyzTg/fe4PYKiMnjXrapXWSlc8yKmW96nQ1YjikLWmyHEibs7o oR4Q== X-Gm-Message-State: AOAM53177WIfTkTNye3Fd5jjtT9BzohJbvZER38zdzVliiyCPjpn+g4I 0NBNjPaNtwwMr359CXId/vZIEKzvaBJouKYfEI8b20Vxzsgb4a13WLDP5CsR2lYiuOalgDboGAg Ak0CObZN68WVe X-Received: by 2002:a05:6000:2c6:: with SMTP id o6mr3376260wry.292.1633179262576; Sat, 02 Oct 2021 05:54:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPg2SUP1KRqKQDM976J1UW+bK/dVfMUDIEqkBzFMQ49KQqAlYHTXe/I8QRvH6n2Zfw+A1FBw== X-Received: by 2002:a05:6000:2c6:: with SMTP id o6mr3376245wry.292.1633179262453; Sat, 02 Oct 2021 05:54:22 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id o19sm9025753wrg.60.2021.10.02.05.54.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:22 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 14/22] target/i386/sev: Move qmp_query_sev_attestation_report() to sev.c Date: Sat, 2 Oct 2021 14:53:09 +0200 Message-Id: <20211002125317.3418648-15-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move qmp_query_sev_attestation_report() from monitor.c to sev.c and make sev_get_attestation_report() static. We don't need the stub anymore, remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev_i386.h | 2 -- target/i386/monitor.c | 6 ------ target/i386/sev-sysemu-stub.c | 7 ++++--- target/i386/sev.c | 12 ++++++++++-- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 2d9a1a0112e..5f367f78eb7 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -27,8 +27,6 @@ extern SevInfo *sev_get_info(void); extern char *sev_get_launch_measurement(void); extern SevCapability *sev_get_capabilities(Error **errp); -extern SevAttestationReport * -sev_get_attestation_report(const char *mnonce, Error **errp); int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); int sev_inject_launch_secret(const char *hdr, const char *secret, diff --git a/target/i386/monitor.c b/target/i386/monitor.c index a9f85acd473..c05d70252a2 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -764,12 +764,6 @@ void qmp_sev_inject_launch_secret(const char *packet_hdr, sev_inject_launch_secret(packet_hdr, secret, gpa, errp); } -SevAttestationReport * -qmp_query_sev_attestation_report(const char *mnonce, Error **errp) -{ - return sev_get_attestation_report(mnonce, errp); -} - SGXInfo *qmp_query_sgx(Error **errp) { return sgx_get_info(errp); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index d556b4f091f..813b9a6a03b 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "qapi/qapi-commands-misc-target.h" +#include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "sev_i386.h" @@ -52,9 +53,9 @@ int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size) g_assert_not_reached(); } -SevAttestationReport *sev_get_attestation_report(const char *mnonce, - Error **errp) +SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce, + Error **errp) { - error_setg(errp, "SEV is not available in this QEMU"); + error_setg(errp, QERR_UNSUPPORTED); return NULL; } diff --git a/target/i386/sev.c b/target/i386/sev.c index aefbef4bb63..91a217bbb85 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -31,6 +31,8 @@ #include "migration/blocker.h" #include "qom/object.h" #include "monitor/monitor.h" +#include "qapi/qapi-commands-misc-target.h" +#include "qapi/qmp/qerror.h" #include "exec/confidential-guest-support.h" #include "hw/i386/pc.h" @@ -487,8 +489,8 @@ out: return cap; } -SevAttestationReport * -sev_get_attestation_report(const char *mnonce, Error **errp) +static SevAttestationReport *sev_get_attestation_report(const char *mnonce, + Error **errp) { struct kvm_sev_attestation_report input = {}; SevAttestationReport *report = NULL; @@ -549,6 +551,12 @@ sev_get_attestation_report(const char *mnonce, Error **errp) return report; } +SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce, + Error **errp) +{ + return sev_get_attestation_report(mnonce, errp); +} + static int sev_read_file_base64(const char *filename, guchar **data, gsize *len) { From patchwork Sat Oct 2 12:53:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532103 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D2B1C433F5 for ; Sat, 2 Oct 2021 12:54:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E63E61A51 for ; Sat, 2 Oct 2021 12:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233306AbhJBM4Q (ORCPT ); Sat, 2 Oct 2021 08:56:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25847 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233303AbhJBM4P (ORCPT ); Sat, 2 Oct 2021 08:56:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179269; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MFPED/lWL7McgnfaLMNLaFFcTGfU944hsrHyvaxNr8c=; b=Np2brtWWkoftLajluTJEbcJ9Td+yudIRnJOCacgoCA7kvZ+Nnu8EkgcCqlGtBUZ01XFEZp QvDpOvhIB4mIKGkQqzrHHLEWDu69JrDBww4kkYKXUqOfWeBEj5fL33a6cL5XrQhqIgtUQA O3/n91SjMtIZZF4/bF4xLG+x1vPPthg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-zLpZr1HxOmmyXkCZsUuqJQ-1; Sat, 02 Oct 2021 08:54:28 -0400 X-MC-Unique: zLpZr1HxOmmyXkCZsUuqJQ-1 Received: by mail-wm1-f71.google.com with SMTP id o28-20020a05600c511c00b0030cdce826f9so3791974wms.5 for ; Sat, 02 Oct 2021 05:54:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MFPED/lWL7McgnfaLMNLaFFcTGfU944hsrHyvaxNr8c=; b=X39bCPP0900gin3VLy7LEfyyN2OtCH6n4hHYzxSn0I32Bn4GYBxbnfIOszh5Mf/7Hc tMUb/530smVYUDRKYhNGMyZBY/EXkl1OE+OaIrLHzEFAc05J5r04dxYci085hv5DnTPW IA/Cl+x6GNNbKJJVSK9u99K5NKooIUC+oJV3YVacVjcE/45ZQeXbvDniTBUsbswKEAU5 ASzucvYyrt3jPi6uKtBzGoaPBseEFKk2WK2aBzkCMoOKy71WMEvl8a3C/pMmt+m7pWVt zteevpIIHMlRomVZL5w0Haolp0JeNUc5pgSeJEjOj4ox2Ndu9nGLQGkLYJaIrVUsQQ8N d3pg== X-Gm-Message-State: AOAM532i3ekk2v5/I2dFGe7X2qQivz8Bne2QGRBxs3FLOx8bCch5rju/ kINuN3NGCxlCIkQSbF9tSys9A4KhPIvEugtQKahWUxlPQ2BBsNj5e61AeTpJRArtf6XHNL5cm+5 NPfFRv7dmwkTO X-Received: by 2002:a5d:608e:: with SMTP id w14mr3315467wrt.119.1633179267185; Sat, 02 Oct 2021 05:54:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1NL6M/YsdfSGb125vbKkdnK0ovBHXMOfTrj0Zv4qPiwD4uvPRl8NF6jMFLf6uS8Tsr9ze6A== X-Received: by 2002:a5d:608e:: with SMTP id w14mr3315454wrt.119.1633179266991; Sat, 02 Oct 2021 05:54:26 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id j7sm9971641wrr.27.2021.10.02.05.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 15/22] target/i386/sev: Move qmp_sev_inject_launch_secret() to sev.c Date: Sat, 2 Oct 2021 14:53:10 +0200 Message-Id: <20211002125317.3418648-16-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move qmp_sev_inject_launch_secret() from monitor.c to sev.c and make sev_inject_launch_secret() static. We don't need the stub anymore, remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/monitor.c | 31 ------------------------------- target/i386/sev-sysemu-stub.c | 6 +++--- target/i386/sev.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/target/i386/monitor.c b/target/i386/monitor.c index c05d70252a2..188203da6f2 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -733,37 +733,6 @@ SevCapability *qmp_query_sev_capabilities(Error **errp) return sev_get_capabilities(errp); } -#define SEV_SECRET_GUID "4c2eb361-7d9b-4cc3-8081-127c90d3d294" -struct sev_secret_area { - uint32_t base; - uint32_t size; -}; - -void qmp_sev_inject_launch_secret(const char *packet_hdr, - const char *secret, - bool has_gpa, uint64_t gpa, - Error **errp) -{ - if (!sev_enabled()) { - error_setg(errp, QERR_UNSUPPORTED); - return; - } - if (!has_gpa) { - uint8_t *data; - struct sev_secret_area *area; - - if (!pc_system_ovmf_table_find(SEV_SECRET_GUID, &data, NULL)) { - error_setg(errp, "SEV: no secret area found in OVMF," - " gpa must be specified."); - return; - } - area = (struct sev_secret_area *)data; - gpa = area->base; - } - - sev_inject_launch_secret(packet_hdr, secret, gpa, errp); -} - SGXInfo *qmp_query_sgx(Error **errp) { return sgx_get_info(errp); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index 813b9a6a03b..66b69540aa5 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -33,10 +33,10 @@ SevCapability *sev_get_capabilities(Error **errp) return NULL; } -int sev_inject_launch_secret(const char *hdr, const char *secret, - uint64_t gpa, Error **errp) +void qmp_sev_inject_launch_secret(const char *packet_header, const char *secret, + bool has_gpa, uint64_t gpa, Error **errp) { - return 1; + error_setg(errp, QERR_UNSUPPORTED); } int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp) diff --git a/target/i386/sev.c b/target/i386/sev.c index 91a217bbb85..2198d550be2 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -949,6 +949,37 @@ int sev_inject_launch_secret(const char *packet_hdr, const char *secret, return 0; } +#define SEV_SECRET_GUID "4c2eb361-7d9b-4cc3-8081-127c90d3d294" +struct sev_secret_area { + uint32_t base; + uint32_t size; +}; + +void qmp_sev_inject_launch_secret(const char *packet_hdr, + const char *secret, + bool has_gpa, uint64_t gpa, + Error **errp) +{ + if (!sev_enabled()) { + error_setg(errp, QERR_UNSUPPORTED); + return; + } + if (!has_gpa) { + uint8_t *data; + struct sev_secret_area *area; + + if (!pc_system_ovmf_table_find(SEV_SECRET_GUID, &data, NULL)) { + error_setg(errp, "SEV: no secret area found in OVMF," + " gpa must be specified."); + return; + } + area = (struct sev_secret_area *)data; + gpa = area->base; + } + + sev_inject_launch_secret(packet_hdr, secret, gpa, errp); +} + static int sev_es_parse_reset_block(SevInfoBlock *info, uint32_t *addr) { From patchwork Sat Oct 2 12:53:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532105 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9A4EC433EF for ; Sat, 2 Oct 2021 12:54:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D073161ACE for ; Sat, 2 Oct 2021 12:54:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233312AbhJBM4U (ORCPT ); Sat, 2 Oct 2021 08:56:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36528 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbhJBM4U (ORCPT ); Sat, 2 Oct 2021 08:56:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179274; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h6tz1pzz/4VduuxUJcTVLKl1Lh7BOZFtJinbrllV/PI=; b=IlPgud7CN/KA9MvgNbY6QcMz5e2pN72c5L/kh8qcbWC453AzpXyMQz/YYpPKZ6WfGOb/sb jjwfXozqaZDqz7CJgL3IZwgxiJmjSBdnAf4nufTNFxrpRWCqo8gFYT+Wn3cjQ4UvIvagtt McFag+hot0WtQg8TJY1VKt8MefAgQLM= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-gedc6EmJNqyeMe5lJ9HCQg-1; Sat, 02 Oct 2021 08:54:33 -0400 X-MC-Unique: gedc6EmJNqyeMe5lJ9HCQg-1 Received: by mail-wm1-f72.google.com with SMTP id u3-20020a7bcb03000000b0030d5228cbbdso2089056wmj.3 for ; Sat, 02 Oct 2021 05:54:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h6tz1pzz/4VduuxUJcTVLKl1Lh7BOZFtJinbrllV/PI=; b=UNXWJ9DFizVbso1s6bsGdePalXHpJ3NzQD5nEIPa2SA0vK6U4EUlILpk1y89Mi+dFQ kzK2r4SRjZ7RtWd7e+6OxXz5ZQRVo/CHh0ilZC2WyQ2Cgh0Je4wCfH/FMi4Fgz+1Zgj/ dirT2M8k4hXZpORkGAqkZtcB/uegUmOfK+qT++1Zl0mEKPSpDHUfmDW1+/6L6XfeFbPS 5PIsUMVawpcBE56BKg166/dXxkVajz4qIX26cQ7cIyBmHBcNx7VCHV4qHU2p9pJFiRy+ vb8xyue18pc1jDMVAup56tYZe2ios9MylAr++JWFl96VRLlf5fQ7qSDEnYCcB5sX0Obo h6UA== X-Gm-Message-State: AOAM533S+V2ogDzT8aZx8k4FPvPsPclrVW1ITTcZCcxwBEtT6rAG2Js7 XAuaCBi+z2QQ71pWtoUFK/ldEZdIbgVr5HYKIdtsjg9GAE7SAvyY5s5P4R+zRBcyEFHo9J3lsTQ EXlqGWZHQG9SJ X-Received: by 2002:adf:b311:: with SMTP id j17mr3202013wrd.340.1633179271656; Sat, 02 Oct 2021 05:54:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu9v9AoE33m8O4FuueDOzXS5cpHqzVSB1CjLXdyosJZ9VfYPRTPpP3kB+NiZ18zNjZf4Yvsw== X-Received: by 2002:adf:b311:: with SMTP id j17mr3201997wrd.340.1633179271459; Sat, 02 Oct 2021 05:54:31 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id l25sm8457300wmi.29.2021.10.02.05.54.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:31 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 16/22] target/i386/sev: Move qmp_query_sev_capabilities() to sev.c Date: Sat, 2 Oct 2021 14:53:11 +0200 Message-Id: <20211002125317.3418648-17-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move qmp_query_sev_capabilities() from monitor.c to sev.c and make sev_get_capabilities() static. We don't need the stub anymore, remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev_i386.h | 1 - target/i386/monitor.c | 5 ----- target/i386/sev-sysemu-stub.c | 4 ++-- target/i386/sev.c | 8 ++++++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 5f367f78eb7..8d9388d8c5c 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -26,7 +26,6 @@ extern SevInfo *sev_get_info(void); extern char *sev_get_launch_measurement(void); -extern SevCapability *sev_get_capabilities(Error **errp); int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); int sev_inject_launch_secret(const char *hdr, const char *secret, diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 188203da6f2..da36522fa15 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -728,11 +728,6 @@ SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) return info; } -SevCapability *qmp_query_sev_capabilities(Error **errp) -{ - return sev_get_capabilities(errp); -} - SGXInfo *qmp_query_sgx(Error **errp) { return sgx_get_info(errp); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index 66b69540aa5..cc486a1afbe 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -27,9 +27,9 @@ char *sev_get_launch_measurement(void) return NULL; } -SevCapability *sev_get_capabilities(Error **errp) +SevCapability *qmp_query_sev_capabilities(Error **errp) { - error_setg(errp, "SEV is not available in this QEMU"); + error_setg(errp, QERR_UNSUPPORTED); return NULL; } diff --git a/target/i386/sev.c b/target/i386/sev.c index 2198d550be2..fce007d6749 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -438,8 +438,7 @@ e_free: return 1; } -SevCapability * -sev_get_capabilities(Error **errp) +static SevCapability *sev_get_capabilities(Error **errp) { SevCapability *cap = NULL; guchar *pdh_data = NULL; @@ -489,6 +488,11 @@ out: return cap; } +SevCapability *qmp_query_sev_capabilities(Error **errp) +{ + return sev_get_capabilities(errp); +} + static SevAttestationReport *sev_get_attestation_report(const char *mnonce, Error **errp) { From patchwork Sat Oct 2 12:53:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532107 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4146C433EF for ; Sat, 2 Oct 2021 12:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1A4061ACE for ; Sat, 2 Oct 2021 12:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233320AbhJBM42 (ORCPT ); Sat, 2 Oct 2021 08:56:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38945 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbhJBM4Y (ORCPT ); Sat, 2 Oct 2021 08:56:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179278; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0nKTjzIKPyPIMBpHVM/tD1diKI5Lwbe51EbfE5s5an0=; b=D8Qn+KgffYy5o7SjXAfU6hwJce5qS9uGRGHo/Y09Gl20tbCOW32GfGVu9Pp4Ath0RJYGBK SF8SoHev4t28BRtLG7MMajx3oeZFPZHeRV/IM03+F9qAu8x7LxkXhKBW/eVH+SjNpzxDtM DsFRQU5wbZAlxoS5XKgfLDXi7KqCoqs= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-I-8dPZgGMiulp_dzpvWiQA-1; Sat, 02 Oct 2021 08:54:37 -0400 X-MC-Unique: I-8dPZgGMiulp_dzpvWiQA-1 Received: by mail-wm1-f71.google.com with SMTP id 129-20020a1c1987000000b0030cd1616fbfso7350179wmz.3 for ; Sat, 02 Oct 2021 05:54:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0nKTjzIKPyPIMBpHVM/tD1diKI5Lwbe51EbfE5s5an0=; b=po6qOw6CxtLGprKRl1zLF7+6FHhTTOtXT/2c6hKjD+7sRPapNwLYrKNBEC2fBcHAmw angRBDdBi1H8bV33yCmsrAfOoExPVco2GJX4erJrgyNz7iHpurCD5mqPnYjXrJZb87ZC OZa+v0ZENDx7PcTl8RiwSD8VtsrJBMNlRO+Rg1ozpvMN8FxKiOSpjkGh5SkFhvLw5a4A rN9QqlJzkx6IrdnUpv4HE1bxUx+/A9OW6icn04+kFCz5zJl/Zk0E+DY917sT8gEneDFt wuYg+P6UPzU6lspdaJqsrNMtbx8mFP2G6RbaPsj6/S+S+RbPWC+sWuoJ0w2AyHVaEeDf vvzg== X-Gm-Message-State: AOAM531b0XW8lgwbSoAR5EIdfpFOe8l9aqJ4LYjVA53mSw2949Oxhs/+ QnX4BUgj8FXF00HJ8cmOdlXfbsA0wxxA3azcmEXAYcvsFy9nq4h/3OVEV2CFMInmjB7C/qLamhI J8O7ni0ETEydD X-Received: by 2002:adf:a4cf:: with SMTP id h15mr3355712wrb.56.1633179276024; Sat, 02 Oct 2021 05:54:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE7Ld4d7xRxNwNhximLYRSqvfEbRdkNWVwkt+fYHrToiPZNRg70XquUCHdmcVJ53wdpAfvzQ== X-Received: by 2002:adf:a4cf:: with SMTP id h15mr3355700wrb.56.1633179275866; Sat, 02 Oct 2021 05:54:35 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id y15sm1796812wrp.44.2021.10.02.05.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:35 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 17/22] target/i386/sev: Move qmp_query_sev_launch_measure() to sev.c Date: Sat, 2 Oct 2021 14:53:12 +0200 Message-Id: <20211002125317.3418648-18-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move qmp_query_sev_launch_measure() from monitor.c to sev.c and make sev_get_launch_measurement() static. We don't need the stub anymore, remove it. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev_i386.h | 1 - target/i386/monitor.c | 17 ----------------- target/i386/sev-sysemu-stub.c | 3 ++- target/i386/sev.c | 20 ++++++++++++++++++-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 8d9388d8c5c..1699376ad87 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -25,7 +25,6 @@ #define SEV_POLICY_SEV 0x20 extern SevInfo *sev_get_info(void); -extern char *sev_get_launch_measurement(void); int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); int sev_inject_launch_secret(const char *hdr, const char *secret, diff --git a/target/i386/monitor.c b/target/i386/monitor.c index da36522fa15..0b38e970c73 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -711,23 +711,6 @@ void hmp_info_sev(Monitor *mon, const QDict *qdict) qapi_free_SevInfo(info); } -SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) -{ - char *data; - SevLaunchMeasureInfo *info; - - data = sev_get_launch_measurement(); - if (!data) { - error_setg(errp, "Measurement is not available"); - return NULL; - } - - info = g_malloc0(sizeof(*info)); - info->data = data; - - return info; -} - SGXInfo *qmp_query_sgx(Error **errp) { return sgx_get_info(errp); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index cc486a1afbe..355391c16c4 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -22,8 +22,9 @@ SevInfo *sev_get_info(void) return NULL; } -char *sev_get_launch_measurement(void) +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) { + error_setg(errp, QERR_UNSUPPORTED); return NULL; } diff --git a/target/i386/sev.c b/target/i386/sev.c index fce007d6749..8e9cce62196 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -718,8 +718,7 @@ free_measurement: g_free(measurement); } -char * -sev_get_launch_measurement(void) +static char *sev_get_launch_measurement(void) { if (sev_guest && sev_guest->state >= SEV_STATE_LAUNCH_SECRET) { @@ -729,6 +728,23 @@ sev_get_launch_measurement(void) return NULL; } +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) +{ + char *data; + SevLaunchMeasureInfo *info; + + data = sev_get_launch_measurement(); + if (!data) { + error_setg(errp, "Measurement is not available"); + return NULL; + } + + info = g_malloc0(sizeof(*info)); + info->data = data; + + return info; +} + static Notifier sev_machine_done_notify = { .notify = sev_launch_get_measure, }; From patchwork Sat Oct 2 12:53:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532109 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27E3CC433F5 for ; Sat, 2 Oct 2021 12:54:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 113B761AF8 for ; Sat, 2 Oct 2021 12:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233319AbhJBM43 (ORCPT ); Sat, 2 Oct 2021 08:56:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38855 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbhJBM42 (ORCPT ); Sat, 2 Oct 2021 08:56:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179283; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zmeHSaAJmvIQWkoqQvBbbph1YlHUwqkxNB0lhULs12o=; b=f9d9n+474myHbdMtMa4nwz4md0QpUXCxUGHaOVPuetXc6otKxKt/bYHNlTXRJ8qqsTXPLk frvg51/TBkyn1j7BSEIOo882wBAZXObDAY8BpmUOyDdKp3k5QjpsNTKh633KyY5MYy7uRa My/uC0YdLsU0DYosPX1CvSrXPu44QG4= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-438-mTXAltLDMpaqgtnS-n5fYA-1; Sat, 02 Oct 2021 08:54:41 -0400 X-MC-Unique: mTXAltLDMpaqgtnS-n5fYA-1 Received: by mail-wm1-f70.google.com with SMTP id m9-20020a05600c4f4900b003057c761567so7367977wmq.1 for ; Sat, 02 Oct 2021 05:54:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zmeHSaAJmvIQWkoqQvBbbph1YlHUwqkxNB0lhULs12o=; b=0tLHR1rB1i2kMvaiHkZMqcjpI/1T7TWCGrdMp7Vw93Sq6hFuzeT9gNeElYDOVSzo5V CmN/oT6/Zv8JFVEYXUnD52ODTOA18KvVk8NLg9lv2+wla0b2WKcyvP7BavJhR0inrzkW 25qo0RVDdhTOy+aXYQxD+FZ4dyEVzgF85sPA4Dd45HKprLcoaXE/TWcOQUvFxGNZ+M1q wvETMxhKLve1rsHLfnkRCL2L0O6v1+S8rPlqa5HnDPLBiaC9NQ+/zjgn+0UWcVP/GIpR UPY+q2CdT1dqQhMyhnjwMF3LcuhJAJjL9gKMpgzE34/tS2XZabX9V8XeFmSEY85pIsk7 xitg== X-Gm-Message-State: AOAM533479qBDk0HC/969HgbFiSXze2uzx1KdxdVrsX74LScDBaLKlyt 7I3ACnU5OL+27IWo8fJ2GtOjn4ZOssKpjokVBIT0wsvN8jryzxP9lNv881xHM3A+8Aixj9iQ4sz laZJ625TukqMA X-Received: by 2002:a1c:7302:: with SMTP id d2mr9391302wmb.92.1633179280617; Sat, 02 Oct 2021 05:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgPMBEpdCmd98sav+qHs899wgnlAFISSby1vK2IYSyDBW7M/2t9a3jNO0u1D6NgduWenHWdg== X-Received: by 2002:a1c:7302:: with SMTP id d2mr9391291wmb.92.1633179280396; Sat, 02 Oct 2021 05:54:40 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id m29sm8762685wrb.89.2021.10.02.05.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:40 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 18/22] target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c Date: Sat, 2 Oct 2021 14:53:13 +0200 Message-Id: <20211002125317.3418648-19-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Move qmp_query_sev() & hmp_info_sev()() from monitor.c to sev.c and make sev_get_info() static. We don't need the stub anymore, remove it. Add a stub for hmp_info_sev(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- target/i386/sev_i386.h | 3 --- target/i386/monitor.c | 38 +--------------------------------- target/i386/sev-sysemu-stub.c | 10 ++++++++- target/i386/sev.c | 39 +++++++++++++++++++++++++++++++++-- 4 files changed, 47 insertions(+), 43 deletions(-) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 1699376ad87..15a959d6174 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -15,7 +15,6 @@ #define QEMU_SEV_I386_H #include "sysemu/sev.h" -#include "qapi/qapi-types-misc-target.h" #define SEV_POLICY_NODBG 0x1 #define SEV_POLICY_NOKS 0x2 @@ -24,8 +23,6 @@ #define SEV_POLICY_DOMAIN 0x10 #define SEV_POLICY_SEV 0x20 -extern SevInfo *sev_get_info(void); - int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); int sev_inject_launch_secret(const char *hdr, const char *secret, uint64_t gpa, Error **errp); diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 0b38e970c73..890870b252d 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -28,11 +28,9 @@ #include "monitor/hmp-target.h" #include "monitor/hmp.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qerror.h" +//#include "qapi/qmp/qerror.h" #include "sysemu/kvm.h" -#include "sysemu/sev.h" #include "qapi/error.h" -#include "sev_i386.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-commands-misc.h" #include "hw/i386/pc.h" @@ -677,40 +675,6 @@ void hmp_info_io_apic(Monitor *mon, const QDict *qdict) "removed soon. Please use 'info pic' instead.\n"); } -SevInfo *qmp_query_sev(Error **errp) -{ - SevInfo *info; - - info = sev_get_info(); - if (!info) { - error_setg(errp, "SEV feature is not available"); - return NULL; - } - - return info; -} - -void hmp_info_sev(Monitor *mon, const QDict *qdict) -{ - SevInfo *info = sev_get_info(); - - if (info && info->enabled) { - monitor_printf(mon, "handle: %d\n", info->handle); - monitor_printf(mon, "state: %s\n", SevState_str(info->state)); - monitor_printf(mon, "build: %d\n", info->build_id); - monitor_printf(mon, "api version: %d.%d\n", - info->api_major, info->api_minor); - monitor_printf(mon, "debug: %s\n", - info->policy & SEV_POLICY_NODBG ? "off" : "on"); - monitor_printf(mon, "key-sharing: %s\n", - info->policy & SEV_POLICY_NOKS ? "off" : "on"); - } else { - monitor_printf(mon, "SEV is not enabled\n"); - } - - qapi_free_SevInfo(info); -} - SGXInfo *qmp_query_sgx(Error **errp) { return sgx_get_info(errp); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index 355391c16c4..1836b32e4fc 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -12,13 +12,16 @@ */ #include "qemu/osdep.h" +#include "monitor/monitor.h" +#include "monitor/hmp.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qmp/qerror.h" #include "qapi/error.h" #include "sev_i386.h" -SevInfo *sev_get_info(void) +SevInfo *qmp_query_sev(Error **errp) { + error_setg(errp, QERR_UNSUPPORTED); return NULL; } @@ -60,3 +63,8 @@ SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce, error_setg(errp, QERR_UNSUPPORTED); return NULL; } + +void hmp_info_sev(Monitor *mon, const QDict *qdict) +{ + monitor_printf(mon, "SEV is not available in this QEMU\n"); +} diff --git a/target/i386/sev.c b/target/i386/sev.c index 8e9cce62196..7caaa117ff7 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -27,10 +27,12 @@ #include "sev_i386.h" #include "sysemu/sysemu.h" #include "sysemu/runstate.h" +#include "sysemu/sev.h" #include "trace.h" #include "migration/blocker.h" #include "qom/object.h" #include "monitor/monitor.h" +#include "monitor/hmp.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qmp/qerror.h" #include "exec/confidential-guest-support.h" @@ -375,8 +377,7 @@ sev_get_reduced_phys_bits(void) return sev_guest ? sev_guest->reduced_phys_bits : 0; } -SevInfo * -sev_get_info(void) +static SevInfo *sev_get_info(void) { SevInfo *info; @@ -395,6 +396,40 @@ sev_get_info(void) return info; } +SevInfo *qmp_query_sev(Error **errp) +{ + SevInfo *info; + + info = sev_get_info(); + if (!info) { + error_setg(errp, "SEV feature is not available"); + return NULL; + } + + return info; +} + +void hmp_info_sev(Monitor *mon, const QDict *qdict) +{ + SevInfo *info = sev_get_info(); + + if (info && info->enabled) { + monitor_printf(mon, "handle: %d\n", info->handle); + monitor_printf(mon, "state: %s\n", SevState_str(info->state)); + monitor_printf(mon, "build: %d\n", info->build_id); + monitor_printf(mon, "api version: %d.%d\n", + info->api_major, info->api_minor); + monitor_printf(mon, "debug: %s\n", + info->policy & SEV_POLICY_NODBG ? "off" : "on"); + monitor_printf(mon, "key-sharing: %s\n", + info->policy & SEV_POLICY_NOKS ? "off" : "on"); + } else { + monitor_printf(mon, "SEV is not enabled\n"); + } + + qapi_free_SevInfo(info); +} + static int sev_get_pdh_info(int fd, guchar **pdh, size_t *pdh_len, guchar **cert_chain, size_t *cert_chain_len, Error **errp) From patchwork Sat Oct 2 12:53:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532111 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97BC4C433F5 for ; Sat, 2 Oct 2021 12:54:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7BCFA61A51 for ; Sat, 2 Oct 2021 12:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233325AbhJBM4e (ORCPT ); Sat, 2 Oct 2021 08:56:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40233 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbhJBM4d (ORCPT ); Sat, 2 Oct 2021 08:56:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179287; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WyR/eNCtMhabJTiJL4KYPQfagO3ysZNetDQfcxieNmI=; b=fVsltZ6HffjC1hd7tmQU6T9GQyrwvL4MAOyBjfoUhvwkNh5jg49dTbrlb6cneTMLejizPX 6QakBJQu4NqoT+E6lCPMRXN2sSngDGsZYTiZQ/vnvhPKXe6dYfHJcYsDLhEzf9vQsqiDj3 zLfYKk8B/CZqo2Mqs1Um/m+B+x/6upg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-RANXtHbgOYe-XiBNZmroQw-1; Sat, 02 Oct 2021 08:54:46 -0400 X-MC-Unique: RANXtHbgOYe-XiBNZmroQw-1 Received: by mail-wm1-f70.google.com with SMTP id n3-20020a7bcbc3000000b0030b68c4de38so3791372wmi.8 for ; Sat, 02 Oct 2021 05:54:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WyR/eNCtMhabJTiJL4KYPQfagO3ysZNetDQfcxieNmI=; b=vvVMV8FRlbkdNboESwMrcvWsy7NZbI3XLBfqhnMIlH08W2ZR51l+snQTUxQbrKCAOj PU/RY+WgrVLf0kWrwtHQzyXL1WREcFZgnsUm+HY3+x98wbwiOjMxWWkm0D5ayDS9nHru /7tmt3k6OLfC9SShKaCOqPPS9TBRI6N1MY3rLQx75LKKBzlzwrsQa/QdOXqnJgD5NCxH uKhBT6VtmQFjKZKCjH5pWYwUVu77f3Wh/3ZtGx1bGBSUgS2MVulmqRZhD0hrLYa12OJC /j+AzA4XpM+1+R5XLo90jt8jrS6pztJK34ip6I83gYoG3kePLcY5nFq+Q+wmfolNVJWA q1dA== X-Gm-Message-State: AOAM530B/zSxVzyZ4IsaWNnSnvCjcG31d0XGowwAWNggUZxKkyAbjzS/ F1djOhJ/GgVv4wpf2wcklmIk7OmMhdNaX1MPkyvzG5cvBk9SoIkY9Ur0KK523aHquUnrtnXrYyd x0fkNnawOgkR+ X-Received: by 2002:a5d:44d1:: with SMTP id z17mr3370226wrr.187.1633179285065; Sat, 02 Oct 2021 05:54:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy67yh1G/4H9iMDyZQOpRZdq+m1Nl/19ODGozR8E+nhB1/ZKWnqdXBw6WrBb4+UnlkFrV3bSA== X-Received: by 2002:a5d:44d1:: with SMTP id z17mr3370205wrr.187.1633179284860; Sat, 02 Oct 2021 05:54:44 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id o12sm8851885wms.15.2021.10.02.05.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 19/22] monitor: Restrict 'info sev' to x86 targets Date: Sat, 2 Oct 2021 14:53:14 +0200 Message-Id: <20211002125317.3418648-20-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Paolo Bonzini --- include/monitor/hmp-target.h | 1 + include/monitor/hmp.h | 1 - target/i386/sev-sysemu-stub.c | 2 +- target/i386/sev.c | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h index dc53add7eef..96956d0fc41 100644 --- a/include/monitor/hmp-target.h +++ b/include/monitor/hmp-target.h @@ -49,6 +49,7 @@ void hmp_info_tlb(Monitor *mon, const QDict *qdict); void hmp_mce(Monitor *mon, const QDict *qdict); void hmp_info_local_apic(Monitor *mon, const QDict *qdict); void hmp_info_io_apic(Monitor *mon, const QDict *qdict); +void hmp_info_sev(Monitor *mon, const QDict *qdict); void hmp_info_sgx(Monitor *mon, const QDict *qdict); #endif /* MONITOR_HMP_TARGET_H */ diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 3baa1058e2c..6bc27639e01 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -124,7 +124,6 @@ void hmp_info_ramblock(Monitor *mon, const QDict *qdict); void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict); -void hmp_info_sev(Monitor *mon, const QDict *qdict); void hmp_info_replay(Monitor *mon, const QDict *qdict); void hmp_replay_break(Monitor *mon, const QDict *qdict); void hmp_replay_delete_break(Monitor *mon, const QDict *qdict); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index 1836b32e4fc..b2a4033a030 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -13,7 +13,7 @@ #include "qemu/osdep.h" #include "monitor/monitor.h" -#include "monitor/hmp.h" +#include "monitor/hmp-target.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qmp/qerror.h" #include "qapi/error.h" diff --git a/target/i386/sev.c b/target/i386/sev.c index 7caaa117ff7..c6d8fc52eb2 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -32,7 +32,7 @@ #include "migration/blocker.h" #include "qom/object.h" #include "monitor/monitor.h" -#include "monitor/hmp.h" +#include "monitor/hmp-target.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qmp/qerror.h" #include "exec/confidential-guest-support.h" From patchwork Sat Oct 2 12:53:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532113 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCCA3C433EF for ; Sat, 2 Oct 2021 12:54:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3AFF61ACE for ; Sat, 2 Oct 2021 12:54:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233327AbhJBM4j (ORCPT ); Sat, 2 Oct 2021 08:56:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38594 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbhJBM4i (ORCPT ); Sat, 2 Oct 2021 08:56:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179292; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wGfA2j80SC2+4aGulWQ/r67RC6gVnbvOoez6cQaSfN0=; b=EYZw2M6pSpQlO6vDt26ddACx3wglajza6MFLXOZly15WHFjojwxjiRNUu/sRDtdtafKe3+ phGv1jjjYLmCtVAsAKPrGpEUs56r8tBjeZvJI8oKfjQ3ScEmCMTCIr5YhuxKiSXtMfDLS3 /sJ9lAFGa1oABrDVcJ76NdQp8WrmkT4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-km_vmdIbPfyP7V38Gmr-jA-1; Sat, 02 Oct 2021 08:54:50 -0400 X-MC-Unique: km_vmdIbPfyP7V38Gmr-jA-1 Received: by mail-wm1-f72.google.com with SMTP id h24-20020a7bc938000000b0030d400be5b5so3358945wml.0 for ; Sat, 02 Oct 2021 05:54:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wGfA2j80SC2+4aGulWQ/r67RC6gVnbvOoez6cQaSfN0=; b=qWJaZpDbTh7aPR7aEScczdSdduBviONMQR1bqjh//nRUM8bp0Ym8KmScmfXdVmHI2d 7Kd78O44gcooz+3nqjDbYz1KfWBScdlTzJ68hI2IOk1d3cyISI0ojN7lkcScafvFI+nH UEhwjuiLdzqH1liRrVfJEY9by0Xw+u5RRdkMTAHy9B0nN0xeKItO+422U1ol12LW+lIQ p9YSJ7NSr815ycu7rcb6vYQT8Jfwylh1PkSbdukWlHtyHSHUZXeInFDkaCFgnEwSeUBF 6QQh/+idIBxgStG49oYuJUmnJNkLNK61RhjfqJSvnEygb8bwOdLrtoCuBfVG0I3GFZwc LMmg== X-Gm-Message-State: AOAM533i/0GHYWz4XoRtpPdSvvrtiIeyTe67tDHpyqrxoeLiwhqnfokS bmLp2OMCloKwa4gfZdtwuplTCaJErMmEkWMzuav1sQUSHfDPr07ICPd/KUPfffUxgkq03/pXlOK 3bzA6LRyWd9Pa X-Received: by 2002:adf:cf10:: with SMTP id o16mr3263915wrj.12.1633179289664; Sat, 02 Oct 2021 05:54:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIlAGUzy37xRAc3wO3Jx5AvnPpGg0GVEAXuua31avnpgtYrsVxayrEFINAr8sZqcOzoicXYw== X-Received: by 2002:adf:cf10:: with SMTP id o16mr3263894wrj.12.1633179289485; Sat, 02 Oct 2021 05:54:49 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id z5sm13146962wmp.26.2021.10.02.05.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 20/22] sev/i386: Introduce sev_add_kernel_loader_hashes for measured linux boot Date: Sat, 2 Oct 2021 14:53:15 +0200 Message-Id: <20211002125317.3418648-21-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Dov Murik Add the sev_add_kernel_loader_hashes function to calculate the hashes of the kernel/initrd/cmdline and fill a designated OVMF encrypted hash table area. For this to work, OVMF must support an encrypted area to place the data which is advertised via a special GUID in the OVMF reset table. The hashes of each of the files is calculated (or the string in the case of the cmdline with trailing '\0' included). Each entry in the hashes table is GUID identified and since they're passed through the sev_encrypt_flash interface, the hashes will be accumulated by the AMD PSP measurement (SEV_LAUNCH_MEASURE). Co-developed-by: James Bottomley Signed-off-by: James Bottomley Signed-off-by: Dov Murik Reviewed-by: Daniel P. Berrangé Message-Id: <20210930054915.13252-2-dovmurik@linux.ibm.com> [PMD: Rebased on top of 0021c4765a6] Signed-off-by: Philippe Mathieu-Daudé --- target/i386/sev_i386.h | 12 ++++ target/i386/sev.c | 138 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 15a959d6174..17031cddd37 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -23,9 +23,21 @@ #define SEV_POLICY_DOMAIN 0x10 #define SEV_POLICY_SEV 0x20 +typedef struct SevKernelLoaderContext { + char *setup_data; + size_t setup_size; + char *kernel_data; + size_t kernel_size; + char *initrd_data; + size_t initrd_size; + char *cmdline_data; + size_t cmdline_size; +} SevKernelLoaderContext; + int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); int sev_inject_launch_secret(const char *hdr, const char *secret, uint64_t gpa, Error **errp); +bool sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Error **errp); int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size); void sev_es_set_reset_vector(CPUState *cpu); diff --git a/target/i386/sev.c b/target/i386/sev.c index c6d8fc52eb2..91fdf0d4503 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -23,6 +23,7 @@ #include "qemu/base64.h" #include "qemu/module.h" #include "qemu/uuid.h" +#include "crypto/hash.h" #include "sysemu/kvm.h" #include "sev_i386.h" #include "sysemu/sysemu.h" @@ -86,6 +87,32 @@ typedef struct __attribute__((__packed__)) SevInfoBlock { uint32_t reset_addr; } SevInfoBlock; +#define SEV_HASH_TABLE_RV_GUID "7255371f-3a3b-4b04-927b-1da6efa8d454" +typedef struct QEMU_PACKED SevHashTableDescriptor { + /* SEV hash table area guest address */ + uint32_t base; + /* SEV hash table area size (in bytes) */ + uint32_t size; +} SevHashTableDescriptor; + +/* hard code sha256 digest size */ +#define HASH_SIZE 32 + +typedef struct QEMU_PACKED SevHashTableEntry { + QemuUUID guid; + uint16_t len; + uint8_t hash[HASH_SIZE]; +} SevHashTableEntry; + +typedef struct QEMU_PACKED SevHashTable { + QemuUUID guid; + uint16_t len; + SevHashTableEntry cmdline; + SevHashTableEntry initrd; + SevHashTableEntry kernel; + uint8_t padding[]; +} SevHashTable; + static SevGuestState *sev_guest; static Error *sev_mig_blocker; @@ -1151,6 +1178,117 @@ int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size) return 0; } +static const QemuUUID sev_hash_table_header_guid = { + .data = UUID_LE(0x9438d606, 0x4f22, 0x4cc9, 0xb4, 0x79, 0xa7, 0x93, + 0xd4, 0x11, 0xfd, 0x21) +}; + +static const QemuUUID sev_kernel_entry_guid = { + .data = UUID_LE(0x4de79437, 0xabd2, 0x427f, 0xb8, 0x35, 0xd5, 0xb1, + 0x72, 0xd2, 0x04, 0x5b) +}; +static const QemuUUID sev_initrd_entry_guid = { + .data = UUID_LE(0x44baf731, 0x3a2f, 0x4bd7, 0x9a, 0xf1, 0x41, 0xe2, + 0x91, 0x69, 0x78, 0x1d) +}; +static const QemuUUID sev_cmdline_entry_guid = { + .data = UUID_LE(0x97d02dd8, 0xbd20, 0x4c94, 0xaa, 0x78, 0xe7, 0x71, + 0x4d, 0x36, 0xab, 0x2a) +}; + +/* + * Add the hashes of the linux kernel/initrd/cmdline to an encrypted guest page + * which is included in SEV's initial memory measurement. + */ +bool sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Error **errp) +{ + uint8_t *data; + SevHashTableDescriptor *area; + SevHashTable *ht; + uint8_t cmdline_hash[HASH_SIZE]; + uint8_t initrd_hash[HASH_SIZE]; + uint8_t kernel_hash[HASH_SIZE]; + uint8_t *hashp; + size_t hash_len = HASH_SIZE; + int aligned_len; + + if (!pc_system_ovmf_table_find(SEV_HASH_TABLE_RV_GUID, &data, NULL)) { + error_setg(errp, + "SEV: kernel specified but OVMF has no hash table guid"); + return false; + } + area = (SevHashTableDescriptor *)data; + + /* + * Calculate hash of kernel command-line with the terminating null byte. If + * the user doesn't supply a command-line via -append, the 1-byte "\0" will + * be used. + */ + hashp = cmdline_hash; + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->cmdline_data, + ctx->cmdline_size, &hashp, &hash_len, errp) < 0) { + return false; + } + assert(hash_len == HASH_SIZE); + + /* + * Calculate hash of initrd. If the user doesn't supply an initrd via + * -initrd, an empty buffer will be used (ctx->initrd_size == 0). + */ + hashp = initrd_hash; + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALG_SHA256, ctx->initrd_data, + ctx->initrd_size, &hashp, &hash_len, errp) < 0) { + return false; + } + assert(hash_len == HASH_SIZE); + + /* Calculate hash of the kernel */ + hashp = kernel_hash; + struct iovec iov[2] = { + { .iov_base = ctx->setup_data, .iov_len = ctx->setup_size }, + { .iov_base = ctx->kernel_data, .iov_len = ctx->kernel_size } + }; + if (qcrypto_hash_bytesv(QCRYPTO_HASH_ALG_SHA256, iov, ARRAY_SIZE(iov), + &hashp, &hash_len, errp) < 0) { + return false; + } + assert(hash_len == HASH_SIZE); + + /* + * Populate the hashes table in the guest's memory at the OVMF-designated + * area for the SEV hashes table + */ + ht = qemu_map_ram_ptr(NULL, area->base); + + ht->guid = sev_hash_table_header_guid; + ht->len = sizeof(*ht); + + ht->cmdline.guid = sev_cmdline_entry_guid; + ht->cmdline.len = sizeof(ht->cmdline); + memcpy(ht->cmdline.hash, cmdline_hash, sizeof(ht->cmdline.hash)); + + ht->initrd.guid = sev_initrd_entry_guid; + ht->initrd.len = sizeof(ht->initrd); + memcpy(ht->initrd.hash, initrd_hash, sizeof(ht->initrd.hash)); + + ht->kernel.guid = sev_kernel_entry_guid; + ht->kernel.len = sizeof(ht->kernel); + memcpy(ht->kernel.hash, kernel_hash, sizeof(ht->kernel.hash)); + + /* When calling sev_encrypt_flash, the length has to be 16 byte aligned */ + aligned_len = ROUND_UP(ht->len, 16); + if (aligned_len != ht->len) { + /* zero the excess data so the measurement can be reliably calculated */ + memset(ht->padding, 0, aligned_len - ht->len); + } + + if (sev_encrypt_flash((uint8_t *)ht, aligned_len, errp) < 0) { + return false; + } + + return true; +} + static void sev_register_types(void) { From patchwork Sat Oct 2 12:53:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532115 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74E70C433EF for ; Sat, 2 Oct 2021 12:54:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B6BD61ACE for ; Sat, 2 Oct 2021 12:54:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233330AbhJBM4n (ORCPT ); Sat, 2 Oct 2021 08:56:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47016 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbhJBM4m (ORCPT ); Sat, 2 Oct 2021 08:56:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179296; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HQMlJLpBHn2fUxB+2/XhMlNl1C9ZrEw/LRArmGOAdEM=; b=JqroPGK+b3ioFC5fJzYNbHwIwD0gjhLgTD8WchAMjScyouB1rBAxelXXe2icXsJ09DtPgZ BdQdo32fUJs1LNKmklypCQULdR7sN3arFJrpM/BI7ahqwG8fZcuIrxhXLNykGBTiLEI91U MHS85HtztsRAE6FEw2sw6iRupV5acg8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-DkjUsU-9NFew_HIjEaWp5A-1; Sat, 02 Oct 2021 08:54:55 -0400 X-MC-Unique: DkjUsU-9NFew_HIjEaWp5A-1 Received: by mail-wm1-f71.google.com with SMTP id 129-20020a1c1987000000b0030cd1616fbfso7350476wmz.3 for ; Sat, 02 Oct 2021 05:54:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HQMlJLpBHn2fUxB+2/XhMlNl1C9ZrEw/LRArmGOAdEM=; b=GY6Ue79q2wuh5+V6dMOtnvpqOlsqYZ5w8SzJDGn/jLSB8Vkav2cWiLKsgp0AoUgk9a vIYhBGEnybGpx0zyilzXi4VtLfejuiwDHTh9IyM+H5F5zHLxV5dntnv1tkcseJmaKSHg kY0OJ1ZwHFczLnV1eJmROyvEKOE/L5/Bk/YKx9Dt+vQga6MR0jie+8SxSaM0OvS0+u06 y8shq41MU08ICeiRZuycRVhBv6ld7zHJN86YKH8wo+U6PUMj0bIORLK1NCeYh2kG6vU2 zJKSZGTMNx+tAioFOrKlbjWNCrEIrRRANmdh+59Z3bX1efm362F2yuHqAxHSs+ZiDyq/ TKiQ== X-Gm-Message-State: AOAM531FeeNpsVSleTtpoOVfJyhncpaJLTzR0xeq5qaTZWGiuWjc2+x6 HIaRfXeAGVZXSSWH9M8gX98kD/qBsENRmJkRmC5s5MtdAbadDQAYZiPJEpUKWvUTCab2RIbT2r+ fI2P8gZitG5Bp X-Received: by 2002:a05:600c:a05:: with SMTP id z5mr9289027wmp.73.1633179294187; Sat, 02 Oct 2021 05:54:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZjFxaIEu9svYHDueJWKUmqvnq/eSj6AVK+xBQ/cs0mjHbQ9g0Mh2BXrylFwcs1VzcJPeV+Q== X-Received: by 2002:a05:600c:a05:: with SMTP id z5mr9289016wmp.73.1633179294045; Sat, 02 Oct 2021 05:54:54 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id m4sm10915060wml.28.2021.10.02.05.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:53 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 21/22] x86/sev: generate SEV kernel loader hashes in x86_load_linux Date: Sat, 2 Oct 2021 14:53:16 +0200 Message-Id: <20211002125317.3418648-22-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Dov Murik If SEV is enabled and a kernel is passed via -kernel, pass the hashes of kernel/initrd/cmdline in an encrypted guest page to OVMF for SEV measured boot. Co-developed-by: James Bottomley Signed-off-by: James Bottomley Signed-off-by: Dov Murik Reviewed-by: Daniel P. Berrangé Message-Id: <20210930054915.13252-3-dovmurik@linux.ibm.com> [PMD: Rebased on top of 0021c4765a6] Signed-off-by: Philippe Mathieu-Daudé --- hw/i386/x86.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 41ef9a84a9f..0c7c054e3a0 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -47,6 +47,7 @@ #include "hw/i386/fw_cfg.h" #include "hw/intc/i8259.h" #include "hw/rtc/mc146818rtc.h" +#include "target/i386/sev_i386.h" #include "hw/acpi/cpu_hotplug.h" #include "hw/irq.h" @@ -780,6 +781,7 @@ void x86_load_linux(X86MachineState *x86ms, const char *initrd_filename = machine->initrd_filename; const char *dtb_filename = machine->dtb; const char *kernel_cmdline = machine->kernel_cmdline; + SevKernelLoaderContext sev_load_ctx = {}; /* Align to 16 bytes as a paranoia measure */ cmdline_size = (strlen(kernel_cmdline) + 16) & ~15; @@ -926,6 +928,8 @@ void x86_load_linux(X86MachineState *x86ms, fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline) + 1); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); + sev_load_ctx.cmdline_data = (char *)kernel_cmdline; + sev_load_ctx.cmdline_size = strlen(kernel_cmdline) + 1; if (protocol >= 0x202) { stl_p(header + 0x228, cmdline_addr); @@ -1007,6 +1011,8 @@ void x86_load_linux(X86MachineState *x86ms, fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size); + sev_load_ctx.initrd_data = initrd_data; + sev_load_ctx.initrd_size = initrd_size; stl_p(header + 0x218, initrd_addr); stl_p(header + 0x21c, initrd_size); @@ -1065,15 +1071,32 @@ void x86_load_linux(X86MachineState *x86ms, load_image_size(dtb_filename, setup_data->data, dtb_size); } - memcpy(setup, header, MIN(sizeof(header), setup_size)); + /* + * If we're starting an encrypted VM, it will be OVMF based, which uses the + * efi stub for booting and doesn't require any values to be placed in the + * kernel header. We therefore don't update the header so the hash of the + * kernel on the other side of the fw_cfg interface matches the hash of the + * file the user passed in. + */ + if (!sev_enabled()) { + memcpy(setup, header, MIN(sizeof(header), setup_size)); + } fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size); + sev_load_ctx.kernel_data = (char *)kernel; + sev_load_ctx.kernel_size = kernel_size; fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size); + sev_load_ctx.setup_data = (char *)setup; + sev_load_ctx.setup_size = setup_size; + + if (sev_enabled()) { + sev_add_kernel_loader_hashes(&sev_load_ctx, &error_fatal); + } option_rom[nb_option_roms].bootindex = 0; option_rom[nb_option_roms].name = "linuxboot.bin"; From patchwork Sat Oct 2 12:53:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 12532117 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CEAEC433F5 for ; Sat, 2 Oct 2021 12:55:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D82261AF8 for ; Sat, 2 Oct 2021 12:55:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233335AbhJBM4r (ORCPT ); Sat, 2 Oct 2021 08:56:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32621 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbhJBM4q (ORCPT ); Sat, 2 Oct 2021 08:56:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633179300; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9cOF84rCmS7WTO0HbW0oz9DUXo06vj+3GXepVVOD4Pg=; b=M/6JDvqkoQdDVXW2OzxyCwaqNJbJ0jTIoq7OBp0iwRMeeAzAfQCpqCJnDt74Oau12LVahh IFk3IO/bBSx3lpBdyNTqwVFq0/vZCLGk2IYLm8Fn38AnLrFZvUer1n3INtXNSI+kisoiQC +0gUKP0UtcZpU8Rau1h7rzNOpsSG+VY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-tg0nZv1iNj6ie2oN8WQ_DQ-1; Sat, 02 Oct 2021 08:54:59 -0400 X-MC-Unique: tg0nZv1iNj6ie2oN8WQ_DQ-1 Received: by mail-wr1-f70.google.com with SMTP id j16-20020adfa550000000b0016012acc443so3511448wrb.14 for ; Sat, 02 Oct 2021 05:54:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9cOF84rCmS7WTO0HbW0oz9DUXo06vj+3GXepVVOD4Pg=; b=U+b2k1acxTRj5Scd2mmz/g5SL8gsgPKycdRtX8OCmLDbLSycjOH+b2rMgsQZjHP3Xk vqe05Lu/0N1AWpwJfBRO6lq/0GbolPY/wG7jonVxI/RNoRsc3MglSu7RoER7ru+IHt89 QhHCXUkjCayOlmNXk7jBI2Rg5ZPtMzRRzaCylnYRoOyUJVu3Nx2KuBqkuyu4vN0u9zmZ Ii8VSCnDF3daBAMUTC+B2FcxHPqhkmFjSaywmZAeUwDRhQWO6C/RbDTt9X5dCLPW/bu2 leqmQNav6YLPZ2+vNxop5K//8fspe/85NnvwuLmdQyv9DNIB8rxozpExvaCwVOoiI/wU eqDw== X-Gm-Message-State: AOAM533NP+Cj4uIcwckQ+AyiNTPtJfKCwnsIPXvmF9t5HpohDjzlfkkQ O98AGptRpt7EpKTBYlWzwlbt0yZwyFXtI5BmKt6xmJfjmZfHkCayz17JPunL4WkUT6UohQZq8rs UwyHl5+HCS2W/ X-Received: by 2002:a05:600c:a4b:: with SMTP id c11mr9217335wmq.97.1633179298644; Sat, 02 Oct 2021 05:54:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEYfPco7QeJt1MbnGV0YAVEkNIsPSX2xggQ+cxCOIhC5Ja//3oCylj2OTXEwQB2mCra2x0Dg== X-Received: by 2002:a05:600c:a4b:: with SMTP id c11mr9217325wmq.97.1633179298521; Sat, 02 Oct 2021 05:54:58 -0700 (PDT) Received: from x1w.. (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id o3sm8574713wra.52.2021.10.02.05.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 05:54:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Dr . David Alan Gilbert" , Dov Murik , Sergio Lopez , kvm@vger.kernel.org, James Bottomley , Eduardo Habkost , Paolo Bonzini , Brijesh Singh , "Daniel P . Berrange" Subject: [PATCH v3 22/22] MAINTAINERS: Cover AMD SEV files Date: Sat, 2 Oct 2021 14:53:17 +0200 Message-Id: <20211002125317.3418648-23-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211002125317.3418648-1-philmd@redhat.com> References: <20211002125317.3418648-1-philmd@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add an entry to list SEV-related files. Signed-off-by: Philippe Mathieu-Daudé --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 50435b8d2f5..733a5201e76 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3038,6 +3038,13 @@ F: hw/core/clock-vmstate.c F: hw/core/qdev-clock.c F: docs/devel/clocks.rst +AMD Secure Encrypted Virtualization (SEV) +S: Orphan +F: docs/amd-memory-encryption.txt +F: target/i386/sev* +F: target/i386/kvm/sev-stub.c +F: include/sysemu/sev.h + Usermode Emulation ------------------ Overall usermode emulation