From nobody Tue Feb 10 06:25:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623876273; cv=none; d=zohomail.com; s=zohoarc; b=Ia1GrwtmAUc8/jxhQTFBODTtU1S5awcsk9pTiN5C7zgfkyOFzUkKe5umsq1PhodJt+OighQ316ftLzxaEMuCmRloEnbZExq563mBPhcd73fC2d7rod1l9ntpgs+PkJzRQbG6UlrkDqw5zr7yvCVs7qAUtWg08HtffJcasaLZxas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623876273; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=AZLS+m7xAvvk2uRB++FAfryJbzXnCIDe39YBz1qMJyo=; b=JltH4zJ7s8SX0UlPb1TxdLqh7MOMJv226QeicPaCQHQzL8duoeEeDNioL2Lr4pa2WS9FirjNkjbSnY/U5Gdpis7pgFPxD3sEVDuAsa02vxyJEGtQxSIgqcQrOe8RJavqrX2LIPbbO9DWg6fMMbb6WKkpSHeS580RMt+Gx0LfQM0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623876273734301.2715992518001; Wed, 16 Jun 2021 13:44:33 -0700 (PDT) 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-546-ZWZUFGmFOrar3B8gn9ziPw-1; Wed, 16 Jun 2021 16:44:31 -0400 Received: by mail-wr1-f70.google.com with SMTP id e9-20020a5d6d090000b0290119e91be97dso1874898wrq.1 for ; Wed, 16 Jun 2021 13:44:31 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id f12sm3804968wru.81.2021.06.16.13.44.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Jun 2021 13:44:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623876272; 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=gPA5mrl9Zmcxny2cvnuIHzkcN9D6Ps61IHukGMf+TVYQkbfPW9us/4uGyLFnJh2vM6soeD NgbZ9z74a0aQxLuiGVj0M78HKmxPNRJ8iTNh5AKYuZ9Jym+cqwCojs3ThCqcnP2uP+qgRr ODY8eLLO4EJoObB7C2huWIJ3r6ywzIk= X-MC-Unique: ZWZUFGmFOrar3B8gn9ziPw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=TeME3bemhSjuPtPC7ghxtEAfqYS61UTqJW2ztDoIlhrVPcLCy1yxPog0ZN3Hnz0M4s FBIr/ZvulIHveozSO+zpfb/8g0ZZduzd8j3LrlaudQcez0bNAWJCC9RtX8nb62fFK0lk yCbGQmCZuU0oxBr1Ha1c2tEGnHIvMK+vR+TFhNwXGPbYvdsZSkMSsFQ2XQgi4UVEwg78 4pNzFWDKobTJaATzLEkhEC0HtLo3+ntYbYi5Xz51YcGpNeXMw6VKG8+bEiHN/xnG0UBq tOqeA0EcZWmA2EtnSQ9zJkS4hOUxgxvy6rakurLNY41wbRHUK8Sq7QwG4tC/XR3MmgGf DMHw== X-Gm-Message-State: AOAM532EjkP2anJEbXYngJooLt5Kda5H9jRYLZLfyhXABqdpqQkVmVD3 DaqWIgorVbnnwiJZ5v/6uPMZG8kRFQAYBrN4MeGxugVw56L95H8SS/e5krbGvTum5neSmxc7JhA P3d8Un6hHJyUenA== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr1122345wrn.127.1623876270409; Wed, 16 Jun 2021 13:44:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzv1QtrHVuIiKQIVbYKn8PlR0K7pmHNt/rPvhHLLZNkTjXErbA7lySXCe0JCJniz1FHFkjHAg== X-Received: by 2002:adf:e8cb:: with SMTP id k11mr1122314wrn.127.1623876270220; Wed, 16 Jun 2021 13:44:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Paolo Bonzini , Connor Kuehl , Gerd Hoffmann , Brijesh Singh , "Dr . David Alan Gilbert" , Eric Blake , Eduardo Habkost , Markus Armbruster , Igor Mammedov , James Bottomley , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Sergio Lopez , Marcel Apfelbaum , "Michael S. Tsirkin" , Laszlo Ersek , Dov Murik Subject: [PATCH v2 10/23] target/i386/sev: Restrict SEV to system emulation Date: Wed, 16 Jun 2021 22:43:15 +0200 Message-Id: <20210616204328.2611406-11-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210616204328.2611406-1-philmd@redhat.com> References: <20210616204328.2611406-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 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=C3=A9 --- 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" =20 -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; } =20 -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 late= r. + * 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: fi= les('sev-stub.c')) =20 # 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 =3D ss.source_set() =20 subdir('kvm') --=20 2.31.1