From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB6DAC433EF for ; Thu, 7 Oct 2021 16:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B756261130 for ; Thu, 7 Oct 2021 16:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242557AbhJGQUW (ORCPT ); Thu, 7 Oct 2021 12:20:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47911 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242564AbhJGQUQ (ORCPT ); Thu, 7 Oct 2021 12:20:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633623502; 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=89V0d1PNFsuCxWRiRzeXMO8a63XAoQ+evMckrwIv15E=; b=doJKWHxlsHoFHCvTZBelpzN/1HLGAbDslcafQOa9xZWDsmne52dWUXf+xO9dCCe1Kvy9lr hSW9MtvP7/PIkBOg7ke3wsRgzbLqOT9PaAJGyVI2+pegUMWsmO4pjHU1Pz5EnxHXq/Zb2e Y//z79eYypM8LVOyt6k0g2+WvRI46uE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-586-T6KpgNB2OduG_RRlMMJ9lA-1; Thu, 07 Oct 2021 12:18:19 -0400 X-MC-Unique: T6KpgNB2OduG_RRlMMJ9lA-1 Received: by mail-wr1-f69.google.com with SMTP id d13-20020adf9b8d000000b00160a94c235aso5130684wrc.2 for ; Thu, 07 Oct 2021 09:18: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=89V0d1PNFsuCxWRiRzeXMO8a63XAoQ+evMckrwIv15E=; b=dKCCEtyPHD7dynKlA1floyW/FC6qdAJAzbCmOP3mtsjWj6fc3RnO1SZ2Z/A1Gk9TrH 4ONlwU1mATl6oR7YKtUtJEXqWC4ELiz9lgDqZwjxt0lyynOfDAexLx1rL3ITLFsWp2IZ hRX77fMJ8DCQ+HG5C5ibbBsT9MmyyUB+LTdUO/+W08pkZQcRXslXewLEjALViUwezXzK 9GXlbZkLmcOvG7vKFbUko/Es0JlqzQIKySKNzl0YSThfM3v3MwXgeizSAc5fogYxNxoj SCK0NDaMe9rQc6uVuouJjRFfsgw5XBlTVU3YlNeM5e6ZKnToav7FJETnMjFfHGImGBdg Jt6A== X-Gm-Message-State: AOAM531uCvDR2zemImvrQhFI3Skz+JuTwoVSedDycQZzvf06BzUZd/Sz VyVNXriDb0dvw+fi+DDwqsOiKVb4yAQgTrCBNd411x7bxBYePoJD00zpSx0fyH+GmqvWIGH9J4u 1rCHDJ60gn+wO X-Received: by 2002:a1c:2:: with SMTP id 2mr17491478wma.87.1633623498401; Thu, 07 Oct 2021 09:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybbjnGgx9aPwaHiTsiUUeAUcDEXJV3VetZXPeXIxDRjX+nW5gqW/S5HCcW3+GX4C5xkS0GDg== X-Received: by 2002:a1c:2:: with SMTP id 2mr17491444wma.87.1633623498131; Thu, 07 Oct 2021 09:18:18 -0700 (PDT) Received: from x1w.redhat.com (118.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.118]) by smtp.gmail.com with ESMTPSA id c5sm9181006wml.9.2021.10.07.09.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 09:18:17 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Eduardo Habkost , kvm@vger.kernel.org, "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , James Bottomley , Brijesh Singh , Sergio Lopez , Dov Murik , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 13/23] target/i386/sev: Restrict SEV to system emulation Date: Thu, 7 Oct 2021 18:17:06 +0200 Message-Id: <20211007161716.453984-14-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211007161716.453984-1-philmd@redhat.com> References: <20211007161716.453984-1-philmd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé --- 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 55f1ec74196..170e9f50fee 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,49 +30,11 @@ 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; -} - bool sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Error **errp) { g_assert_not_reached(); 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') -- 2.31.1