From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395171251508.3792898990698; Mon, 15 Feb 2021 05:19:31 -0800 (PST) Received: from localhost ([::1]:52930 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdmj-00072b-SC for importer@patchew.org; Mon, 15 Feb 2021 08:19:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjr-0005PY-Ca for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:31 -0500 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:39840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjp-0005Sn-OU for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:31 -0500 Received: by mail-ed1-x535.google.com with SMTP id h10so3264163edl.6 for ; Mon, 15 Feb 2021 05:16:29 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OMCSlzKUEJNJSmXUjPhcprlREyEBG+IPJnwyqLAL74E=; b=GTu5ktkxTw0u8aZ7wLRk/FRqMcMz/2V2r/MJGhLxB0dLJthNOzSHmJXsFGl3kfYVkT oO26gtLOTuME+hkBd6oLQWSHWLhWlb6oDk4aF4WSZUoZ3lMgfaRTveHWW64cakDepAgG YdqD0BzeM+eXx5NoUF8OyFV7YH4uLm5MSzAUMnkw1Kr2SY+5zbr+BoS9qjTgJrPC1WtA V0WeGW3+9R8LpyY2MlTbWTw0AU9vedndhjp8qE+8jS2gSKjC8ZzZ6KoQdqZ41iu4keUJ uo15AmGeYLTgDrFO6OrZVwLzm6Iy3ohkFf0rGrPS9+Lxwi4j/sqnV8FTJr56fxXs7MS1 vOKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=OMCSlzKUEJNJSmXUjPhcprlREyEBG+IPJnwyqLAL74E=; b=OIIVxcgHFoVk35MAR5eyEaTt9MH8IfiJTPXk6KalXXbv2RBWklWrAoiixu3iEQVJLk NmTRkBfVBw036aOXHJ89iZ7qwTnO02yWQRCmGMql/YBeap33NFNXcXdM5Bm/VtfPMpDZ ihmkvLOnoTlBUUnuoAu+9dPdZZR2gBZttpL/G4Ar0CuYx6f8MLStnPnQoY4vJza0Mieb xn3hth5vizkALljA7PyyTb8aTceXhn3eth/Y4Wmwq02LgcsK1WKT0Vbha3m6ejyv99aH NRFl5g61OxaoHN2gUhhpMntPlc3fV8irnx+EOiif0EvXeT5cZlr6JttAVGGbuMyuuFJR otVg== X-Gm-Message-State: AOAM531iEgjWRjlbsS5eUn43yrM+P5CaXah0PCjYZmgpubmKlgI5evCB PUJ+hnQlz8HymdGRnHQZF+BMMeSzM8k= X-Google-Smtp-Source: ABdhPJyRjKpp6qFuwZmG5RY+iYQXyTgnyc+YZbPgmTmPAnea3OyidelDYk5c6ozqsqSuwld/pzuEXg== X-Received: by 2002:a05:6402:17aa:: with SMTP id j10mr15804165edy.184.1613394988616; Mon, 15 Feb 2021 05:16:28 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/19] pc: add parser for OVMF reset block Date: Mon, 15 Feb 2021 14:16:08 +0100 Message-Id: <20210215131626.65640-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Bottomley , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: James Bottomley OVMF is developing a mechanism for depositing a GUIDed table just below the known location of the reset vector. The table goes backwards in memory so all entries are of the form |len| Where is arbtrary size and type, is a uint16_t and describes the entire length of the entry from the beginning of the data to the end of the guid. The foot of the table is of this form and for this case describes the entire size of the table. The table foot GUID is defined by OVMF as 96b582de-1fb2-45f7-baea-a366c55a082d and if the table is present this GUID is just below the reset vector, 48 bytes before the end of the firmware file. Add a parser for the ovmf reset block which takes a copy of the block, if the table foot guid is found, minus the footer and a function for later traversal to return the data area of any specified GUIDs. Signed-off-by: James Bottomley Reviewed-by: Dr. David Alan Gilbert Message-Id: <20210204193939.16617-2-jejb@linux.ibm.com> Signed-off-by: Paolo Bonzini --- hw/i386/pc_sysfw.c | 122 +++++++++++++++++++++++++++++++++++++++-- include/hw/i386/pc.h | 4 ++ include/sysemu/sev.h | 1 + target/i386/sev_i386.h | 1 - 4 files changed, 123 insertions(+), 5 deletions(-) diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 11172214f1..6404b5a86f 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -125,6 +125,113 @@ void pc_system_flash_cleanup_unused(PCMachineState *p= cms) } } =20 +#define OVMF_TABLE_FOOTER_GUID "96b582de-1fb2-45f7-baea-a366c55a082d" + +static uint8_t *ovmf_table; +static int ovmf_table_len; + +static void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_si= ze) +{ + uint8_t *ptr; + QemuUUID guid; + int tot_len; + + /* should only be called once */ + if (ovmf_table) { + return; + } + + if (flash_size < TARGET_PAGE_SIZE) { + return; + } + + /* + * if this is OVMF there will be a table footer + * guid 48 bytes before the end of the flash file. If it's + * not found, silently abort the flash parsing. + */ + qemu_uuid_parse(OVMF_TABLE_FOOTER_GUID, &guid); + guid =3D qemu_uuid_bswap(guid); /* guids are LE */ + ptr =3D flash_ptr + flash_size - 48; + if (!qemu_uuid_is_equal((QemuUUID *)ptr, &guid)) { + return; + } + + /* if found, just before is two byte table length */ + ptr -=3D sizeof(uint16_t); + tot_len =3D le16_to_cpu(*(uint16_t *)ptr) - sizeof(guid) - sizeof(uint= 16_t); + + if (tot_len <=3D 0) { + return; + } + + ovmf_table =3D g_malloc(tot_len); + ovmf_table_len =3D tot_len; + + /* + * ptr is the foot of the table, so copy it all to the newly + * allocated ovmf_table and then set the ovmf_table pointer + * to the table foot + */ + memcpy(ovmf_table, ptr - tot_len, tot_len); + ovmf_table +=3D tot_len; +} + +bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, + int *data_len) +{ + uint8_t *ptr =3D ovmf_table; + int tot_len =3D ovmf_table_len; + QemuUUID entry_guid; + + if (qemu_uuid_parse(entry, &entry_guid) < 0) { + return false; + } + + if (!ptr) { + return false; + } + + entry_guid =3D qemu_uuid_bswap(entry_guid); /* guids are LE */ + while (tot_len >=3D sizeof(QemuUUID) + sizeof(uint16_t)) { + int len; + QemuUUID *guid; + + /* + * The data structure is + * arbitrary length data + * 2 byte length of entire entry + * 16 byte guid + */ + guid =3D (QemuUUID *)(ptr - sizeof(QemuUUID)); + len =3D le16_to_cpu(*(uint16_t *)(ptr - sizeof(QemuUUID) - + sizeof(uint16_t))); + + /* + * just in case the table is corrupt, wouldn't want to spin in + * the zero case + */ + if (len < sizeof(QemuUUID) + sizeof(uint16_t)) { + return false; + } else if (len > tot_len) { + return false; + } + + ptr -=3D len; + tot_len -=3D len; + if (qemu_uuid_is_equal(guid, &entry_guid)) { + if (data) { + *data =3D ptr; + } + if (data_len) { + *data_len =3D len - sizeof(QemuUUID) - sizeof(uint16_t); + } + return true; + } + } + return false; +} + /* * Map the pcms->flash[] from 4GiB downward, and realize. * Map them in descending order, i.e. pcms->flash[0] at the top, @@ -192,10 +299,17 @@ static void pc_system_flash_map(PCMachineState *pcms, flash_mem =3D pflash_cfi01_get_memory(system_flash); pc_isa_bios_init(rom_memory, flash_mem, size); =20 - /* Encrypt the pflash boot ROM, if necessary */ - flash_ptr =3D memory_region_get_ram_ptr(flash_mem); - flash_size =3D memory_region_size(flash_mem); - sev_encrypt_flash(flash_ptr, flash_size, &error_fatal); + /* Encrypt the pflash boot ROM */ + if (sev_enabled()) { + flash_ptr =3D memory_region_get_ram_ptr(flash_mem); + flash_size =3D memory_region_size(flash_mem); + /* + * OVMF places a GUIDed structures in the flash, so + * search for them + */ + pc_system_parse_ovmf_flash(flash_ptr, flash_size); + sev_encrypt_flash(flash_ptr, flash_size, &error_fatal); + } } } } diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 5f93540a43..c9d194a5e7 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -3,6 +3,7 @@ =20 #include "qemu/notify.h" #include "qapi/qapi-types-common.h" +#include "qemu/uuid.h" #include "hw/boards.h" #include "hw/block/fdc.h" #include "hw/block/flash.h" @@ -191,6 +192,9 @@ ISADevice *pc_find_fdc0(void); void pc_system_flash_create(PCMachineState *pcms); void pc_system_flash_cleanup_unused(PCMachineState *pcms); void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memor= y); +bool pc_system_ovmf_table_find(const char *entry, uint8_t **data, + int *data_len); + =20 /* acpi-build.c */ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h index 5c5a13c6ca..882e8a4fb1 100644 --- a/include/sysemu/sev.h +++ b/include/sysemu/sev.h @@ -16,6 +16,7 @@ =20 #include "sysemu/kvm.h" =20 +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, diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 4db6960f60..bd9f00a908 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -28,7 +28,6 @@ #define SEV_POLICY_DOMAIN 0x10 #define SEV_POLICY_SEV 0x20 =20 -extern bool sev_enabled(void); extern uint64_t sev_get_me_mask(void); extern SevInfo *sev_get_info(void); extern uint32_t sev_get_cbit_position(void); --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395181599537.8579497063353; Mon, 15 Feb 2021 05:19:41 -0800 (PST) Received: from localhost ([::1]:53210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdmu-0007An-Eu for importer@patchew.org; Mon, 15 Feb 2021 08:19:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjs-0005Pk-Qj for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:32 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:36816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjq-0005TE-Mz for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:32 -0500 Received: by mail-ed1-x52b.google.com with SMTP id l12so7986452edt.3 for ; Mon, 15 Feb 2021 05:16:30 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FR1nDuMgguk9xv0/pf+gg1LCjCOE4sCVlVest7n7PBs=; b=p0uspELXrlmv8YdI/bwQQD66KrcRZKFoHrgVSah6ZBu/XbJDZ83PDU8wjjV0BSFM9y Rwdv7OMsvsV8OhDG2cimKM5ckApJ3qzdzJPbd6XjNwgH/oHXKlgUEIIpzPrB3VH2QCq5 N5V8E1OgwWxwWXgqpd5UrJ6xedTO+GwFbyXzLcnlqFf9nbc6Vttq5ju+ajS8sCed7Ri5 Fo9Stx9irV0XjntGTjZhRYFboVlUc1jeHUGzvwohC7T8p+gQ+cidSXSfXpdghhzwnZDa oymDegBuvvNM9EC1s3MQh/5fR+wr0nrUQLFBTF9ubGCZlr0T2iv1oTTMJderXYfqI/7B tLUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FR1nDuMgguk9xv0/pf+gg1LCjCOE4sCVlVest7n7PBs=; b=R5uzdqhp3sL1CCfQsqFkmhMBXPw1+Nhy/j3b65EpjYXp0Z/9WnTeGIB2N6r9nkPIZG NbcEgsE/LZNlIzHigIKjzovH5DvGf9eb7/j5ZJVq1gRHgilnH06nXkD8TQGaVACkLYec XOKITN/7Px9XNGpBRn3TAxjFJ/e6f5z6d7gLH/Kz9iRL3uwRjJhcbxDXxYs6Sh3i/iCT rgeF3YkGcLPXkHrQa/JftOQ6SjbP5Wi+0XEeBk2JbTCRBIbrjpGgVzlvGaAN08xAEkbe t+atIhMSAvxpvw5vBKo6wDAtcw6Wa/NoI7fg/4kLtQ+o8mcX20QOcF2Xd6DAT87zz+gj 4jXg== X-Gm-Message-State: AOAM533fMC1udFFXphQ7zbk/QQEckF9RIw4RUifFTsCmWU8S4j5X/68I B4MErDpMlbEYhDRmSu+rTM3NtahedDk= X-Google-Smtp-Source: ABdhPJxweENtI/b8T4Z9RPwK12VyNaY6DBrdQK48BuoW+LVqG6eD6YKa1T86tVbjDC7y/7l0Hridwg== X-Received: by 2002:a05:6402:270d:: with SMTP id y13mr15499138edd.149.1613394989240; Mon, 15 Feb 2021 05:16:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 02/19] sev: update sev-inject-launch-secret to make gpa optional Date: Mon, 15 Feb 2021 14:16:09 +0100 Message-Id: <20210215131626.65640-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Bottomley , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: James Bottomley If the gpa isn't specified, it's value is extracted from the OVMF properties table located below the reset vector (and if this doesn't exist, an error is returned). OVMF has defined the GUID for the SEV secret area as 4c2eb361-7d9b-4cc3-8081-127c90d3d294 and the format of the is: | where both are uint32_t. We extract and use it as the gpa for the injection. Note: it is expected that the injected secret will also be GUID described but since qemu can't interpret it, the format is left undefined here. Signed-off-by: James Bottomley Reviewed-by: Dr. David Alan Gilbert Message-Id: <20210204193939.16617-3-jejb@linux.ibm.com> Signed-off-by: Paolo Bonzini --- qapi/misc-target.json | 2 +- target/i386/monitor.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 06ef8757f0..0c7491cd82 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -216,7 +216,7 @@ # ## { 'command': 'sev-inject-launch-secret', - 'data': { 'packet-header': 'str', 'secret': 'str', 'gpa': 'uint64' }, + 'data': { 'packet-header': 'str', 'secret': 'str', '*gpa': 'uint64' }, 'if': 'defined(TARGET_I386)' } =20 ## diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 1bc91442b1..5994408bee 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -34,6 +34,7 @@ #include "sev_i386.h" #include "qapi/qapi-commands-misc-target.h" #include "qapi/qapi-commands-misc.h" +#include "hw/i386/pc.h" =20 /* Perform linear address sign extension */ static hwaddr addr_canonical(CPUArchState *env, hwaddr addr) @@ -730,9 +731,29 @@ SevCapability *qmp_query_sev_capabilities(Error **errp) return sev_get_capabilities(errp); } =20 +#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, uint64_t gpa, + const char *secret, + bool has_gpa, uint64_t gpa, Error **errp) { + 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 =3D (struct sev_secret_area *)data; + gpa =3D area->base; + } + sev_inject_launch_secret(packet_hdr, secret, gpa, errp); } --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395435; cv=none; d=zohomail.com; s=zohoarc; b=Ky0KWvxDsgLnF3sPpSifsqGdNPqB0mtgm+R1jBEYFaa4qJWgE8tPz7elqvLMN+CbyN8/e0dEvQPYa4DkZZTRCdaZwVBwUk38nHArppXqh+iVmDTRYtJrhTqknmp3375zXrb6rBZt394jZLeh0bRo6H4UT7Nbbu2QUdF3Nu7JM1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395435; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xYbjOUSvajLSkt/9wJk0yaturey15raJMMrMJiL6dNY=; b=OwojKSPlu7cld0uX/SQDEBBsPIJD059haumKMeBri7kAwsOHoHvOVCZgvNdE1Sx1Z6jSo4g/zVZr5p70DcHwnzA/3zfj0OTiy2pldMxFgaTBxVohDtaKCyvIjofm7bvuWTYuZdFAc/1eOBEBMNBv9YPpqStD6LBZ9763yLKjqD4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395435583872.4475214426659; Mon, 15 Feb 2021 05:23:55 -0800 (PST) Received: from localhost ([::1]:33074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdr0-0002D6-HB for importer@patchew.org; Mon, 15 Feb 2021 08:23:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjs-0005Pl-RN for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:32 -0500 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:39831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjr-0005U6-4g for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:32 -0500 Received: by mail-ed1-x52b.google.com with SMTP id h10so3264269edl.6 for ; Mon, 15 Feb 2021 05:16:30 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xYbjOUSvajLSkt/9wJk0yaturey15raJMMrMJiL6dNY=; b=OtckRL79ygHk4CiVmQECM/uf215rQmICoKqPBgGEXmSxc2tBcZEgEMEZ/deDQiD2PN Cx3Wea4Cd+AsJIcC3jI4wSkDFmRC1oMAEIri9zaFP+8MVPmOztaFybPRIk4mSZjEy0Au ARvSjjtzIFQqvfnrDQQbiv6qRTcfXUdFT8MnpUaVUy5EKZPRpMD8xVRmwv5yIKb6xX3m +DIkizZCCX+Mf0EPk/zXFF9c6eVFJq+EoUDuL9vvGASAxoWGAvn0XqJAwsrc38WTftgp MWv5SEQ3enCMcZZyjYeG97ZyHb4lwhRjiNARMSSjTK0aUMu9RS7qjB5hF4jIQIow9bqO s6PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xYbjOUSvajLSkt/9wJk0yaturey15raJMMrMJiL6dNY=; b=iisCpNZBVhlYMk7tk05RO3vjjeCPAyuBySSH61xNpoBbQstQvsd3Zb0cXXF401fHPY NpFthypJHMkbvS/xtlK2Q89IXNqf64ynWfotzhEyIfdIKU0jLwaiTgC/aDtcElmeLXFU h2hxLcXwigxdSXRbgNeBwFrjxoEwqdIaQloSvG+DaMUuHTzu4HDhoKafQvqvS0ydcURt lqT1fcwQD7WqgeRFKvAS1w30djFw3cua0983J9vXdLSiAHchpDzKAdWlJY8G/GPtcfE4 VyT7Y7WFcfogDQQnktmct35g6TwzTOhM+ieBPHHmimmRnYs9eawAPAXXZ07JUBeT9kT1 RjJg== X-Gm-Message-State: AOAM532JgOG1OQxLsG1YlHf2FoOLtlCJSHcnNDegZBs58i+lGFYyGddJ t4+wIsXMeaERFtwLr+TK/QfN49ggqDc= X-Google-Smtp-Source: ABdhPJyjy0hZhOdDP9ecUZmCRRbZSLyq6MnM4Ll0tOY4pFSJuFldh/hJJCJHlWdrupTxH9kwBqcsOQ== X-Received: by 2002:a05:6402:278a:: with SMTP id b10mr15750415ede.347.1613394989989; Mon, 15 Feb 2021 05:16:29 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/19] sev/i386: Add initial support for SEV-ES Date: Mon, 15 Feb 2021 14:16:10 +0100 Message-Id: <20210215131626.65640-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Eduardo Habkost , Richard Henderson , "Dr . David Alan Gilbert" , Venu Busireddy , Jiri Slaby Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky Provide initial support for SEV-ES. This includes creating a function to indicate the guest is an SEV-ES guest (which will return false until all support is in place), performing the proper SEV initialization and ensuring that the guest CPU state is measured as part of the launch. Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Reviewed-by: Dr. David Alan Gilbert Co-developed-by: Jiri Slaby Signed-off-by: Jiri Slaby Signed-off-by: Tom Lendacky Reviewed-by: Venu Busireddy Message-Id: <2e6386cbc1ddeaf701547dd5677adf5ddab2b6bd.1611682609.git.thomas= .lendacky@amd.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 1 + target/i386/sev-stub.c | 6 ++++++ target/i386/sev.c | 44 ++++++++++++++++++++++++++++++++++++++++-- target/i386/sev_i386.h | 1 + 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9c3d2d60b7..20c3a5af3f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5984,6 +5984,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, break; case 0x8000001F: *eax =3D sev_enabled() ? 0x2 : 0; + *eax |=3D sev_es_enabled() ? 0x8 : 0; *ebx =3D sev_get_cbit_position(); *ebx |=3D sev_get_reduced_phys_bits() << 6; *ecx =3D 0; diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c index 1ac1fd5b94..edf6c519d7 100644 --- a/target/i386/sev-stub.c +++ b/target/i386/sev-stub.c @@ -49,6 +49,7 @@ 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) { @@ -59,3 +60,8 @@ int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error *= *errp) { return 0; } + +bool sev_es_enabled(void) +{ + return false; +} diff --git a/target/i386/sev.c b/target/i386/sev.c index 11c9a3cc21..dc0e53019b 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -341,6 +341,12 @@ sev_enabled(void) return !!sev_guest; } =20 +bool +sev_es_enabled(void) +{ + return false; +} + uint64_t sev_get_me_mask(void) { @@ -561,6 +567,20 @@ sev_launch_update_data(SevGuestState *sev, uint8_t *ad= dr, uint64_t len) return ret; } =20 +static int +sev_launch_update_vmsa(SevGuestState *sev) +{ + int ret, fw_error; + + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_LAUNCH_UPDATE_VMSA, NULL, &fw_e= rror); + if (ret) { + error_report("%s: LAUNCH_UPDATE_VMSA ret=3D%d fw_error=3D%d '%s'", + __func__, ret, fw_error, fw_error_to_str(fw_error)); + } + + return ret; +} + static void sev_launch_get_measure(Notifier *notifier, void *unused) { @@ -573,6 +593,14 @@ sev_launch_get_measure(Notifier *notifier, void *unuse= d) return; } =20 + if (sev_es_enabled()) { + /* measure all the VM save areas before getting launch_measure */ + ret =3D sev_launch_update_vmsa(sev); + if (ret) { + exit(1); + } + } + measurement =3D g_new0(struct kvm_sev_launch_measure, 1); =20 /* query the measurement blob length */ @@ -667,7 +695,7 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error *= *errp) SevGuestState *sev =3D (SevGuestState *)object_dynamic_cast(OBJECT(cgs), TYPE_SEV_GUE= ST); char *devname; - int ret, fw_error; + int ret, fw_error, cmd; uint32_t ebx; uint32_t host_cbitpos; struct sev_user_data_status status =3D {}; @@ -724,8 +752,20 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error = **errp) sev->api_major =3D status.api_major; sev->api_minor =3D status.api_minor; =20 + if (sev_es_enabled()) { + if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) { + error_report("%s: guest policy requires SEV-ES, but " + "host SEV-ES support unavailable", + __func__); + goto err; + } + cmd =3D KVM_SEV_ES_INIT; + } else { + cmd =3D KVM_SEV_INIT; + } + trace_kvm_sev_init(); - ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_INIT, NULL, &fw_error); + ret =3D sev_ioctl(sev->sev_fd, cmd, NULL, &fw_error); if (ret) { error_setg(errp, "%s: failed to initialize ret=3D%d fw_error=3D%d = '%s'", __func__, ret, fw_error, fw_error_to_str(fw_error)); diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index bd9f00a908..ae221d4c72 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -28,6 +28,7 @@ #define SEV_POLICY_DOMAIN 0x10 #define SEV_POLICY_SEV 0x20 =20 +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); --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395671; cv=none; d=zohomail.com; s=zohoarc; b=LonjZYGklLGMRtYB7AA0qyYjvaAOhq9P4+njxdWi+gYYFaUDuTQiE4iLFimNHabmlIlHKD5IFmRjnRi+8T9Xft+g9PG/QRkyvMNwebYFEWrxY65KCJP68hzoawVVMKIKN8wMuG+s1GaHZDLE5NMvPslllR5ARYCfAJ/m15ToRbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395671; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7kVoRfQIcHYNLGdfwdkxHQvayLS/DSZelR8+WiwgdAI=; b=QlbXZYGUyt9Vr2lMmhzq6EUJO4QyTPW1G3QEIC1lZvO6OHKZXxRHRzao9CFAnS45opOxcO18l6hKYsJ8QTTvZZ1ohbYLlQD7eQh/hSSy1J4S9Bwc0eL6MOzjhLoduSjzAEqJVmpcJb02r0tYhJl/gLMS7MxIWsmMf6UmswME1CY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395671550220.56586521049803; Mon, 15 Feb 2021 05:27:51 -0800 (PST) Received: from localhost ([::1]:41644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBduo-0005mB-Ap for importer@patchew.org; Mon, 15 Feb 2021 08:27:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjt-0005Qy-LE for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:33 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:44360) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjs-0005UE-0m for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:33 -0500 Received: by mail-ed1-x530.google.com with SMTP id g3so5480742edb.11 for ; Mon, 15 Feb 2021 05:16:31 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7kVoRfQIcHYNLGdfwdkxHQvayLS/DSZelR8+WiwgdAI=; b=uaAFJz1vG5dtvxt83Rngvtd5nqUNqpfUIxxPnCVPJQM4Kinvy5ayE+xBVcJVpFjvFO eQAN2n4DV1bfxd8N5aHBGTipLsVAI3BI9fgf1AR6mxq52dreipVbg5lwS7C+Mt9Y0yBB ykSTnqHK/HrZTERm0lOoU7AE1ULd0QFlGpvrfo5W58RcqranW+qsWvpkOR9eLcRAXJtE TRu+wwyBMza8qNoAo1dyBnl3HdRqilk+yVcFLhMhIdcovvPuTCwCyoc5sGZeP5CGlLlI ct5nfvPEOpXslUwhgl1OPYv1OJe25OmgU+hhI45YLlFVXOVBdjW1ZlXjqTDBP+JF2Jco 9oAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7kVoRfQIcHYNLGdfwdkxHQvayLS/DSZelR8+WiwgdAI=; b=E1ZINK0W7XYnvXHJC+8QNOAtmfW4X/UcvA+vvrXyjjbiRwB41gETmJYKyKjSTcq0Gw OxTfNfAMAPlNApltHwl40W7hjrFWJZa36eOCkogJyQshMHJp/HPqxyQmYQs+nblUXfPO 0GwoxsQU3BKML7vvEwS5hbDXsdGGS5cdoeV7DdOoimGKMrmpuldJA29tHO0/VucL+nyY GwYwwsyG7BZSxy2eZKBToJjQOlnTH5GORLUAPho+sSF5QP5z8/oWgRKQ2CWcHzQGatxM 4ln7dlW6JjFgZnWECZf4eZiNIMn3chWCS4s6OdlyU+k73Rv6/T2qiqq2YB4pwwIOoell jV8g== X-Gm-Message-State: AOAM533jexxYSItWUOif8CdAqVhKu3fuLmcdUh8DVNWk2JaNTMwtuZAT swsmueQ9tAuvN2ZKn0TRN8onUx+DdOA= X-Google-Smtp-Source: ABdhPJzDDyyKKjwL6dkajP3rlnZBW6gPPrMFpGtXE5BZ1jqagXkUuKpZpXhsu2ZHFMAps7N+FIVg0Q== X-Received: by 2002:a50:d7c7:: with SMTP id m7mr15036718edj.260.1613394990709; Mon, 15 Feb 2021 05:16:30 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/19] sev/i386: Require in-kernel irqchip support for SEV-ES guests Date: Mon, 15 Feb 2021 14:16:11 +0100 Message-Id: <20210215131626.65640-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Venu Busireddy , Richard Henderson , Eduardo Habkost , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky In prep for AP booting, require the use of in-kernel irqchip support. This lessens the Qemu support burden required to boot APs. Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Tom Lendacky Reviewed-by: Venu Busireddy Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index dc0e53019b..35b9259bfc 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -753,6 +753,12 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error = **errp) sev->api_minor =3D status.api_minor; =20 if (sev_es_enabled()) { + if (!kvm_kernel_irqchip_allowed()) { + error_report("%s: SEV-ES guests require in-kernel irqchip supp= ort", + __func__); + goto err; + } + if (!(status.flags & SEV_STATUS_FLAGS_CONFIG_ES)) { error_report("%s: guest policy requires SEV-ES, but " "host SEV-ES support unavailable", --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395438; cv=none; d=zohomail.com; s=zohoarc; b=kpw0e9Ig3SXeeo0e1RibSxuA7D92wOym3LacGQWhIbXRSORxF10PFr5A/ivFBzT0hJOJ60PpzkLbg3RmyZHct4zRhCTEFeCApAWjNJeUvkN2B7tRI0VaZ+6T56Mz/zRLl5h5/p3BocNs/5K2TbfPln8P3W6vhVM3LdGhsTaz9lI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395438; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=76dw5Z0xlzDF5DA6fvM+I0AFUB+e7NqGmYzkTWS3sPw=; b=BZwpaQtjdGmrLJrlVySeKWX4+miRGhonhTU6XyE9X8NVBxclyU41MDP/6AysFaBzfjh0aQNr+2hz2qiIAxGe5k8OZXURn/upsL+vL/BBXvNjxCqKOg7quGyGVfV8y2SO9MDE0fAnG+0QgRrK7NMaTk7Evdh56hJiGUZihYkggqE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395438244197.78905162445324; Mon, 15 Feb 2021 05:23:58 -0800 (PST) Received: from localhost ([::1]:33416 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdr3-0002LW-5F for importer@patchew.org; Mon, 15 Feb 2021 08:23:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdju-0005SN-Gc for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:34 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:37488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjs-0005UQ-OT for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:34 -0500 Received: by mail-ed1-x536.google.com with SMTP id o3so5823384edv.4 for ; Mon, 15 Feb 2021 05:16:32 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=76dw5Z0xlzDF5DA6fvM+I0AFUB+e7NqGmYzkTWS3sPw=; b=Yl4pO/A9LjcojS9TmgJ7b5V1bS+tCnPCsMcU1UHfjX4/7pM3XTptsmcwkzu+8T04mQ ng2vAAvCbH/pTlDzvubDtSRFfb9vwkTy7E6BjzNQXvSpw2CdQ42CLx7iRKPRg9rSg4In /XDgQvcZdTFbCwD1/eVcLkbkDXKK8YMo6d80HDLN8Ra7wQFnfqE1TYRJKUX1adHXkpi6 DvwO/m698nDiEQbyt6dHFAx5mXfz1YOZ8XT0vAVkQgHvyGanj8tbtSmW7m5l509iJuan bwWv0B4I3jvQZECjr3L0Z9mWQLB1AtV/BGhUNvcBWiTyTJ0lWbRI2f0HbY7S5amWQsHb Zuew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=76dw5Z0xlzDF5DA6fvM+I0AFUB+e7NqGmYzkTWS3sPw=; b=CTnRkoOzLVJ1dpGOW5Pj7ZqUtn4DOnZSI+ln933Ax4FzIsjvgKymSg+Xd8YKw+wz3z QokfczVj2QVWTF8hFvkxneoDsGpUw+K0FD2ddTGNQxZuX/qLPrIYoKGluXlTz5ICo43X ITeMZqnuxgJ7/UJIBDNsxA1A1VG/fnHn/2X0bavCokJxhoo662n6R1b9HjBVBm0Y7+25 lw0atM0oA/ngJB+kr3jY787X1jCNIhJSJHaSUjDTfzQZD+EBqYBpW+02SvzPhn28hkw8 JRx+pk9uaUmlwFg6GwPMgAn8prd5YXL0TTJotmrYpSsbIhs3uucReKf7ZwJRe9G8uqd8 E6cg== X-Gm-Message-State: AOAM530F0naIg7ywal3H6RjmY6V7Lgcxmt5DZ1OR5z2sh6O9y2SQCFyv MGLAEowPq9O7yK7VIfk+rE5c5ZTTUQo= X-Google-Smtp-Source: ABdhPJzaY+LZWIQhZjqUJtcHv8YnJB+QNvH+kC8/ffOqTT0qg1v7Qm71uFJk93sj0Ywx0AzVpoR0Lw== X-Received: by 2002:a05:6402:1152:: with SMTP id g18mr15736771edw.18.1613394991461; Mon, 15 Feb 2021 05:16:31 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 05/19] sev/i386: Allow AP booting under SEV-ES Date: Mon, 15 Feb 2021 14:16:12 +0100 Message-Id: <20210215131626.65640-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Eduardo Habkost , "Michael S. Tsirkin" , Marcelo Tosatti , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" When SEV-ES is enabled, it is not possible modify the guests register state after it has been initially created, encrypted and measured. Normally, an INIT-SIPI-SIPI request is used to boot the AP. However, the hypervisor cannot emulate this because it cannot update the AP register state. For the very first boot by an AP, the reset vector CS segment value and the EIP value must be programmed before the register has been encrypted and measured. Search the guest firmware for the guest for a specific GUID that tells Qemu the value of the reset vector to use. Cc: Paolo Bonzini Cc: "Michael S. Tsirkin" Cc: Marcel Apfelbaum Cc: Richard Henderson Cc: Eduardo Habkost Cc: Marcelo Tosatti Signed-off-by: Tom Lendacky Message-Id: <22db2bfb4d6551aed661a9ae95b4fdbef613ca21.1611682609.git.thomas= .lendacky@amd.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 1 - hw/i386/pc_sysfw.c | 8 +++ include/sysemu/sev.h | 4 ++ target/i386/kvm/kvm.c | 2 + target/i386/sev-stub.c | 9 +++ target/i386/sev.c | 128 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 151 insertions(+), 1 deletion(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 47516913b7..bf61ef4b54 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -39,7 +39,6 @@ #include "qemu/main-loop.h" #include "trace.h" #include "hw/irq.h" -#include "sysemu/sev.h" #include "qapi/visitor.h" #include "qapi/qapi-types-common.h" #include "qapi/qapi-visit-common.h" diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 6404b5a86f..9fe72b370e 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -256,6 +256,7 @@ static void pc_system_flash_map(PCMachineState *pcms, MemoryRegion *flash_mem; void *flash_ptr; int flash_size; + int ret; =20 assert(PC_MACHINE_GET_CLASS(pcms)->pci_enabled); =20 @@ -308,6 +309,13 @@ static void pc_system_flash_map(PCMachineState *pcms, * search for them */ pc_system_parse_ovmf_flash(flash_ptr, flash_size); + + ret =3D sev_es_save_reset_vector(flash_ptr, flash_size); + if (ret) { + error_report("failed to locate and/or save reset vecto= r"); + exit(1); + } + sev_encrypt_flash(flash_ptr, flash_size, &error_fatal); } } diff --git a/include/sysemu/sev.h b/include/sysemu/sev.h index 882e8a4fb1..94d821d737 100644 --- a/include/sysemu/sev.h +++ b/include/sysemu/sev.h @@ -21,4 +21,8 @@ int sev_kvm_init(ConfidentialGuestSupport *cgs, Error **e= rrp); 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/kvm/kvm.c b/target/i386/kvm/kvm.c index e97f841757..f56a8536d0 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1922,6 +1922,8 @@ void kvm_arch_reset_vcpu(X86CPU *cpu) } /* enabled by default */ env->poll_control_msr =3D 1; + + sev_es_set_reset_vector(CPU(cpu)); } =20 void kvm_arch_do_init_vcpu(X86CPU *cpu) diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c index edf6c519d7..0207f1c5aa 100644 --- a/target/i386/sev-stub.c +++ b/target/i386/sev-stub.c @@ -65,3 +65,12 @@ 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) +{ + abort(); +} diff --git a/target/i386/sev.c b/target/i386/sev.c index 35b9259bfc..4b70d4284f 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -22,6 +22,7 @@ #include "qom/object_interfaces.h" #include "qemu/base64.h" #include "qemu/module.h" +#include "qemu/uuid.h" #include "sysemu/kvm.h" #include "sev_i386.h" #include "sysemu/sysemu.h" @@ -32,6 +33,7 @@ #include "exec/address-spaces.h" #include "monitor/monitor.h" #include "exec/confidential-guest-support.h" +#include "hw/i386/pc.h" =20 #define TYPE_SEV_GUEST "sev-guest" OBJECT_DECLARE_SIMPLE_TYPE(SevGuestState, SEV_GUEST) @@ -67,11 +69,21 @@ struct SevGuestState { int sev_fd; SevState state; gchar *measurement; + + uint32_t reset_cs; + uint32_t reset_ip; + bool reset_data_valid; }; =20 #define DEFAULT_GUEST_POLICY 0x1 /* disable debug */ #define DEFAULT_SEV_DEVICE "/dev/sev" =20 +#define SEV_INFO_BLOCK_GUID "00f771de-1a7e-4fcb-890e-68c77e2fb44e" +typedef struct __attribute__((__packed__)) SevInfoBlock { + /* SEV-ES Reset Vector Address */ + uint32_t reset_addr; +} SevInfoBlock; + static SevGuestState *sev_guest; static Error *sev_mig_blocker; =20 @@ -879,6 +891,122 @@ int sev_inject_launch_secret(const char *packet_hdr, = const char *secret, return 0; } =20 +static int +sev_es_parse_reset_block(SevInfoBlock *info, uint32_t *addr) +{ + if (!info->reset_addr) { + error_report("SEV-ES reset address is zero"); + return 1; + } + + *addr =3D info->reset_addr; + + return 0; +} + +static int +sev_es_find_reset_vector(void *flash_ptr, uint64_t flash_size, + uint32_t *addr) +{ + QemuUUID info_guid, *guid; + SevInfoBlock *info; + uint8_t *data; + uint16_t *len; + + /* + * Initialize the address to zero. An address of zero with a successful + * return code indicates that SEV-ES is not active. + */ + *addr =3D 0; + + /* + * Extract the AP reset vector for SEV-ES guests by locating the SEV G= UID. + * The SEV GUID is located on its own (original implementation) or wit= hin + * the Firmware GUID Table (new implementation), either of which are + * located 32 bytes from the end of the flash. + * + * Check the Firmware GUID Table first. + */ + if (pc_system_ovmf_table_find(SEV_INFO_BLOCK_GUID, &data, NULL)) { + return sev_es_parse_reset_block((SevInfoBlock *)data, addr); + } + + /* + * SEV info block not found in the Firmware GUID Table (or there isn't + * a Firmware GUID Table), fall back to the original implementation. + */ + data =3D flash_ptr + flash_size - 0x20; + + qemu_uuid_parse(SEV_INFO_BLOCK_GUID, &info_guid); + info_guid =3D qemu_uuid_bswap(info_guid); /* GUIDs are LE */ + + guid =3D (QemuUUID *)(data - sizeof(info_guid)); + if (!qemu_uuid_is_equal(guid, &info_guid)) { + error_report("SEV information block/Firmware GUID Table block not = found in pflash rom"); + return 1; + } + + len =3D (uint16_t *)((uint8_t *)guid - sizeof(*len)); + info =3D (SevInfoBlock *)(data - le16_to_cpu(*len)); + + return sev_es_parse_reset_block(info, addr); +} + +void sev_es_set_reset_vector(CPUState *cpu) +{ + X86CPU *x86; + CPUX86State *env; + + /* Only update if we have valid reset information */ + if (!sev_guest || !sev_guest->reset_data_valid) { + return; + } + + /* Do not update the BSP reset state */ + if (cpu->cpu_index =3D=3D 0) { + return; + } + + x86 =3D X86_CPU(cpu); + env =3D &x86->env; + + cpu_x86_load_seg_cache(env, R_CS, 0xf000, sev_guest->reset_cs, 0xffff, + DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK | + DESC_R_MASK | DESC_A_MASK); + + env->eip =3D sev_guest->reset_ip; +} + +int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size) +{ + CPUState *cpu; + uint32_t addr; + int ret; + + if (!sev_es_enabled()) { + return 0; + } + + addr =3D 0; + ret =3D sev_es_find_reset_vector(flash_ptr, flash_size, + &addr); + if (ret) { + return ret; + } + + if (addr) { + sev_guest->reset_cs =3D addr & 0xffff0000; + sev_guest->reset_ip =3D addr & 0x0000ffff; + sev_guest->reset_data_valid =3D true; + + CPU_FOREACH(cpu) { + sev_es_set_reset_vector(cpu); + } + } + + return 0; +} + static void sev_register_types(void) { --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395892; cv=none; d=zohomail.com; s=zohoarc; b=LyZnsk3ncO4jtHQEN4bnxu2NoS/MECFVKSBGEKX1eeFVmBpGf1PAg4grM71uWP6KH+Dvvaz9nZ+0sQLyZLPnpL6b71ZRS2nA5t0GbXTNqWCY3X2wRCncokW8fx0LcuzAbpnhpjbZ5KZUHHU3WzE62vg5iFd5XgaSlDCZ5gcrwYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395892; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OJI3qM7gIOXePDLd73m8wlmDXyNbPRnqK0YSUpDiyi0=; b=JZoUgHh2ALDpYKYYZX2jxe74r2iTP1Hr0Zbyr8vVXg5K/aSGGrum1WvpJlLfSFhu3vE+GXfJtCCXvBSrn78HhfkEaYVMuzMrs30wMXJ4zDvnsm+cUajZJS7BGD6o4ISs6qhv5Z1cImEwXomNuziUBdZ4YIwUhKisEExp7o7EMAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161339589190246.10277598178834; Mon, 15 Feb 2021 05:31:31 -0800 (PST) Received: from localhost ([::1]:49590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdyM-0000Z5-SU for importer@patchew.org; Mon, 15 Feb 2021 08:31:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjv-0005UU-Ct for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:35 -0500 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:41555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjt-0005VK-Jm for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:35 -0500 Received: by mail-ed1-x534.google.com with SMTP id v9so3592210edw.8 for ; Mon, 15 Feb 2021 05:16:33 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OJI3qM7gIOXePDLd73m8wlmDXyNbPRnqK0YSUpDiyi0=; b=AtQD/u70Fv/u26K0rE5+n/ktk5mmCF6vE+D2To/Icxqd0wuU6emNLgNRISZ5PDC5Ff XLstY+5xAKugacxRW3itkd8lSOV1wfrHuTlY5RaBBx19TzhV8t+PlQoumaiJij6Cr5l0 KiBUOdruKqslTy5TD0mYV3VF9la4CmAwB+3rwSDKTDDiGld0R98Vl2SVfsza9I6xN2yc GG0g2jbj1jEEznplzAvCU8LHSdBweNKXYRs2SiZVOheyw0bhcZuwUZJwWmYVukIzoif3 wlrfI1riCxWQ4yMovGyyfiydPZufdhgDi603Dqbf6Q6UnR+2150Ui2J1XQrJPASnOHc3 2Epg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=OJI3qM7gIOXePDLd73m8wlmDXyNbPRnqK0YSUpDiyi0=; b=Gw6+p7RKo2glpZSn/dx2ReP1TuLmsKwK+MUmrq9M8tSeo+nqInh+iYOlK6LBDPNcfm qwKqkRMIRE3hK6NJ9eFVkiz2jzHMBDCDG1/KvnN1gGSFXWUukrGD/kbmG6jB3kCq4MGD w4jFGL05J5Nt8mmduTygguhK3u4TuOEQ1OcnIGCkAP99x95ShI2gSfyNq3iBrUHCBkXV QkCBF+uFTAda4SYFVZ2Kyd2taxR8KZOmzVOS251fU2kS8dLyHlTpR8KnZZLoFVAbqY74 RLTb4SKJ2sRZDe1/88n2/T5Q7aKioDNTl34sfxYHx6sRTUZ5xSe3o3K3/68RAWm2SNCg mZbw== X-Gm-Message-State: AOAM530dAg0u/Q5w5OVWHu2utXIPW4NEHz9bU2vY+Nl5HiUR6YWTJk1Q y7RShaZilFjcqKS+cJ85yy0tZPzhsuY= X-Google-Smtp-Source: ABdhPJz7j+X6NtzdNy1/SsJNsiwTjpmVzXcVZKbafGONuZfY2okZiU1ZGELrndDVGtIoE+KyREwWsQ== X-Received: by 2002:a05:6402:1806:: with SMTP id g6mr4588088edy.120.1613394992312; Mon, 15 Feb 2021 05:16:32 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 06/19] sev/i386: Don't allow a system reset under an SEV-ES guest Date: Mon, 15 Feb 2021 14:16:13 +0100 Message-Id: <20210215131626.65640-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Aleksandar Rikalo , Peter Maydell , David Hildenbrand , "Dr . David Alan Gilbert" , Venu Busireddy , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky An SEV-ES guest does not allow register state to be altered once it has been measured. When an SEV-ES guest issues a reboot command, Qemu will reset the vCPU state and resume the guest. This will cause failures under SEV-ES. Prevent that from occuring by introducing an arch-specific callback that returns a boolean indicating whether vCPUs are resettable. Cc: Peter Maydell Cc: Aurelien Jarno Cc: Jiaxun Yang Cc: Aleksandar Rikalo Cc: David Gibson Cc: David Hildenbrand Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Tom Lendacky Reviewed-by: Venu Busireddy Message-Id: <1ac39c441b9a3e970e9556e1cc29d0a0814de6fd.1611682609.git.thomas= .lendacky@amd.com> Signed-off-by: Paolo Bonzini --- accel/kvm/kvm-all.c | 5 +++++ include/sysemu/cpus.h | 2 ++ include/sysemu/hw_accel.h | 5 +++++ include/sysemu/kvm.h | 10 ++++++++++ softmmu/cpus.c | 5 +++++ softmmu/runstate.c | 3 +++ target/arm/kvm.c | 5 +++++ target/i386/kvm/kvm.c | 6 ++++++ target/mips/kvm.c | 5 +++++ target/ppc/kvm.c | 5 +++++ target/s390x/kvm.c | 5 +++++ 11 files changed, 56 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index bf61ef4b54..84c943fcdb 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2312,6 +2312,11 @@ void kvm_flush_coalesced_mmio_buffer(void) s->coalesced_flush_in_progress =3D false; } =20 +bool kvm_cpu_check_are_resettable(void) +{ + return kvm_arch_cpu_check_are_resettable(); +} + static void do_kvm_cpu_synchronize_state(CPUState *cpu, run_on_cpu_data ar= g) { if (!cpu->vcpu_dirty) { diff --git a/include/sysemu/cpus.h b/include/sysemu/cpus.h index 2cd74392e0..868f1192de 100644 --- a/include/sysemu/cpus.h +++ b/include/sysemu/cpus.h @@ -41,6 +41,8 @@ extern int icount_align_option; /* Unblock cpu */ void qemu_cpu_kick_self(void); =20 +bool cpus_are_resettable(void); + void cpu_synchronize_all_states(void); void cpu_synchronize_all_post_reset(void); void cpu_synchronize_all_post_init(void); diff --git a/include/sysemu/hw_accel.h b/include/sysemu/hw_accel.h index ffed6192a3..61672f9b32 100644 --- a/include/sysemu/hw_accel.h +++ b/include/sysemu/hw_accel.h @@ -22,4 +22,9 @@ void cpu_synchronize_post_reset(CPUState *cpu); void cpu_synchronize_post_init(CPUState *cpu); void cpu_synchronize_pre_loadvm(CPUState *cpu); =20 +static inline bool cpu_check_are_resettable(void) +{ + return kvm_enabled() ? kvm_cpu_check_are_resettable() : true; +} + #endif /* QEMU_HW_ACCEL_H */ diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index c5546bdecc..687c598be9 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -541,4 +541,14 @@ int kvm_get_max_memslots(void); /* Notify resamplefd for EOI of specific interrupts. */ void kvm_resample_fd_notify(int gsi); =20 +/** + * kvm_cpu_check_are_resettable - return whether CPUs can be reset + * + * Returns: true: CPUs are resettable + * false: CPUs are not resettable + */ +bool kvm_cpu_check_are_resettable(void); + +bool kvm_arch_cpu_check_are_resettable(void); + #endif diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 112eba9d54..a7ee431187 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -194,6 +194,11 @@ void cpu_synchronize_pre_loadvm(CPUState *cpu) } } =20 +bool cpus_are_resettable(void) +{ + return cpu_check_are_resettable(); +} + int64_t cpus_get_virtual_clock(void) { /* diff --git a/softmmu/runstate.c b/softmmu/runstate.c index a7fcb603f7..2874417b61 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -528,6 +528,9 @@ void qemu_system_reset_request(ShutdownCause reason) if (reboot_action =3D=3D REBOOT_ACTION_SHUTDOWN && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { shutdown_requested =3D reason; + } else if (!cpus_are_resettable()) { + error_report("cpus are not resettable, terminating"); + shutdown_requested =3D reason; } else { reset_requested =3D reason; } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ffe186de8d..00e124c812 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -1045,3 +1045,8 @@ int kvm_arch_msi_data_to_gsi(uint32_t data) { return (data - 32) & 0xffff; } + +bool kvm_arch_cpu_check_are_resettable(void) +{ + return true; +} diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index f56a8536d0..d10667b21b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -27,6 +27,7 @@ #include "sysemu/kvm_int.h" #include "sysemu/runstate.h" #include "kvm_i386.h" +#include "sev_i386.h" #include "hyperv.h" #include "hyperv-proto.h" =20 @@ -4821,3 +4822,8 @@ bool kvm_has_waitpkg(void) { return has_msr_umwait; } + +bool kvm_arch_cpu_check_are_resettable(void) +{ + return !sev_es_enabled(); +} diff --git a/target/mips/kvm.c b/target/mips/kvm.c index 84fb10ea35..123ec1be7e 100644 --- a/target/mips/kvm.c +++ b/target/mips/kvm.c @@ -1290,3 +1290,8 @@ int mips_kvm_type(MachineState *machine, const char *= vm_type) =20 return -1; } + +bool kvm_arch_cpu_check_are_resettable(void) +{ + return true; +} diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 0c5056dd5b..298c1f882c 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2929,3 +2929,8 @@ void kvmppc_set_reg_tb_offset(PowerPCCPU *cpu, int64_= t tb_offset) kvm_set_one_reg(cs, KVM_REG_PPC_TB_OFFSET, &tb_offset); } } + +bool kvm_arch_cpu_check_are_resettable(void) +{ + return true; +} diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index dc27fa36c9..7a892d663d 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2599,3 +2599,8 @@ void kvm_s390_stop_interrupt(S390CPU *cpu) =20 kvm_s390_vcpu_interrupt(cpu, &irq); } + +bool kvm_arch_cpu_check_are_resettable(void) +{ + return true; +} --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395437; cv=none; d=zohomail.com; s=zohoarc; b=gaDBFClUi/7sGnjowODbRwZBhZO1AbDDYF14i2pKTz8FaPKSIoNX3zd1J96vJ29T0s6U+u0/hT+zKx00jzRxkMyZ7LUNOPSmYg8Or5gQ+YThK1xZyZvcnhZi0hNE026haIJ7eNlxlUm8lH3J/w7wUNAP3kfB/KICnryVWcaUZrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395437; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3L8J4G/OuQfDu+BLdvk75fMpqFgpjr5W7kEtzKbxSzQ=; b=bF0EA2bmMI0lcoyJ5QAp4QzOlNyzunoyFzwyLoKUY3+CcPJgpepW0aMc+BXFQVDaI8jccX8BW+2v7QXCMJyBKavqiPpkDct6DjnAtdHwGuLqVilfbolJiKESFCmEV5quNURyWK97jjPjdXQsTN9ArDmws2Hdsiy72o78s3nskqk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395437115122.72425271523309; Mon, 15 Feb 2021 05:23:57 -0800 (PST) Received: from localhost ([::1]:33054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdqz-0002CZ-Pg for importer@patchew.org; Mon, 15 Feb 2021 08:23:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjv-0005Vk-Ux for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:36 -0500 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]:34187) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdju-0005Vt-FA for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:35 -0500 Received: by mail-ej1-x632.google.com with SMTP id hs11so11110168ejc.1 for ; Mon, 15 Feb 2021 05:16:34 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3L8J4G/OuQfDu+BLdvk75fMpqFgpjr5W7kEtzKbxSzQ=; b=kydCY7RdE3c3cqChe5iGDWoLhwkBdHf/CpIM/3FAVtcfEE2M9PA1scsTEVx/RQDsY+ bHoVrn7+QJuJMl8xzatWL1S1MtYqETb8UyluTD3bd+MbDlBQylEijJPfpiJmgDWWoLER HvIHp7NqDvMkJ1Hq4/i1+91xREffx2wsRZezmREIdDJgip3s9eC+mAprcui/diiyJZLR 227TE26rh5chdjmNuBo/z/h9ci8WYr2Cj3JqMMEyy+Y3/2V9A65A9ehikmEJfBrYZS8s SbqdTIwuQ2pxW+Df4CeQGk01hFrXtZckRP1bKc9HS9lS3QpWrnNVlSb6uQE1A/w98Mdw X0DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3L8J4G/OuQfDu+BLdvk75fMpqFgpjr5W7kEtzKbxSzQ=; b=LQN8uZ3pAj3qCgS9l0k3cSw1m2pe+6eqy1f3/baktLF5TXxOAtvxoU8kehyGjn+K5o pGqa/G+Wsmvrq3eFHqi88GYlENL5afU5wvL0mW3bNPIoDUUtgGLgz34d5KnjVDXguH+C I8Bm0tZzDOmI+jW8AkvZY0j3qZLtsARlH0tqRM6oDxUEyoM/d3Y+ReiP4wi/hjVemZqe cS1Pz9TN6SUEZ3afUlxj7p6HtFqCH9uH2xOavrwuDRxwE0/An2jfeJc2nl6EAes3QL5Z WZQkG3Q14iX8qT0U44LYdRhZvXVcsWPjY3ZJRWrP/tUVCBSdYKGCAn5EaxZj8LuoLwGo 8/Yw== X-Gm-Message-State: AOAM533Wzq545iB79hoPGIxe8Bp3jx2x5fMbkyulkz8Wp+Pm9zAobYMO rGBmuywsYBn7Xxby0GWwa5mkc3SuklE= X-Google-Smtp-Source: ABdhPJz8e1UDz69R4ts+F1QZNtKF2WacvL+CbB1oBW9XyPaV1Cw48w5dqT7d2DfLHszd/Khs8Vt6NA== X-Received: by 2002:a17:907:9614:: with SMTP id gb20mr15140132ejc.157.1613394993131; Mon, 15 Feb 2021 05:16:33 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 07/19] kvm/i386: Use a per-VM check for SMM capability Date: Mon, 15 Feb 2021 14:16:14 +0100 Message-Id: <20210215131626.65640-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x632.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Venu Busireddy , Richard Henderson , Eduardo Habkost , Sean Christopherson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky SMM is not currently supported for an SEV-ES guest by KVM. Change the SMM capability check from a KVM-wide check to a per-VM check in order to have a finer-grained SMM capability check. Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Suggested-by: Sean Christopherson Signed-off-by: Tom Lendacky Reviewed-by: Venu Busireddy Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index d10667b21b..0b5755e42b 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -137,7 +137,7 @@ int kvm_has_pit_state2(void) =20 bool kvm_has_smm(void) { - return kvm_check_extension(kvm_state, KVM_CAP_X86_SMM); + return kvm_vm_check_extension(kvm_state, KVM_CAP_X86_SMM); } =20 bool kvm_has_adjust_clock_stable(void) --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395186; cv=none; d=zohomail.com; s=zohoarc; b=JsMYxs0q5PsB0GViTakFO0i2pFdVXe7Vl6as/4ZzH28baqHeDGqdRzh4+rfgQurJ+JViPDEKnIwQSoYEGARb7L1EI7plq1jPjcO9k/xIFUqGPeZBzzOgAuKAGOShD684x0IwdCqfl7WV29oghnSieJE3ScQ8bIBjyVZ8gCShMcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395186; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pJZ2UzBf4qDMvnMPIQu0goRmI82r4LnUGUSIEIbHu28=; b=BYhlTzrVXWvyPGD+MkSlEb5lPDMxLi+8kKDKsgMnd6P3bRuZglzQKBUE/K8UAr2qoe2SoR2LSTnwC5kwCmoQbK2R7AMwu7kN96/9PVe8Fc9Xtp5J1cPlHSj5QuDSY4u1GGgiJteJw3K4dR/W7wSeKAgvbPbOtfwy1+IQajsBanE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395185863991.4369591795177; Mon, 15 Feb 2021 05:19:45 -0800 (PST) Received: from localhost ([::1]:53622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdmy-0007LC-Ip for importer@patchew.org; Mon, 15 Feb 2021 08:19:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjw-0005X4-It for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:36 -0500 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]:34188) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjv-0005W2-4q for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:36 -0500 Received: by mail-ej1-x633.google.com with SMTP id hs11so11110220ejc.1 for ; Mon, 15 Feb 2021 05:16:34 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pJZ2UzBf4qDMvnMPIQu0goRmI82r4LnUGUSIEIbHu28=; b=prGqWKlb+KXC+JiAqDfHZWjVxNpZagjIosLfj6WE6d/+MgT09/8VVb91ZnovWVX1dB 9tFYGd86ygFMOAAuCnLWhKFzzUk2+taxHyBWrV5Rz0g/JrFaTqbzWKO0QAepWQ205+tH HqNr0HHDQhhoRwM2O7+R8uua6IQe5lSvTRpEruDC6zgfyH8odAsxjb4MFascOzsRW+nt Dlcg5eVuN/0IdMC4dEcH0P7+TEgiXaySfcbha55iGvVKfdK++CeMGLHQZXik45plukzl kTqb2ZcEfStQbGi0pc2MOHnndZ5HG67Tek1GWOHpP7YQa7ZJt85dD5ub05m8lEfSliND 6LCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pJZ2UzBf4qDMvnMPIQu0goRmI82r4LnUGUSIEIbHu28=; b=dnNUx/TJbDMPSebMIMlf63H/LufA1MD82Vu+8M4wZ/dr6WqhoDWMp3PjbecyenPsR6 13R62ma4EDp0rKoAaJna3Ts6nug5h00LrBCf9RbGtgf8JtY9H7WI7GpeNAUnAqHsrv1d m4SwwA9W6AHApLpliHwgJssEQBV0/QugtSYRHUzujP36iH8Nm7bzuw5IRFrH2m9B0A4n i8rlatSRvYo4PGhHUXZhW2P3TUFLeNTGwFp7aezFIjpR0Ueby7R8PscvgF3yFFuo97LI x6vMbgcC9qV6kpMyLvUfsw2je9O/yaXWa+VqyW02wzzWsWRutjf9x2ZkTVhIzXiPvv8R 6Mqg== X-Gm-Message-State: AOAM532rGQf1SVI60lVrORIEv4AOPjoBkY5M/eBnXiwY+ynk7iaKKytq D46n1jo/z3bIym2GFHts+wKoFR8JDN0= X-Google-Smtp-Source: ABdhPJzoM9+bja1FDbf4YAg9+EriQnQ8JRPknyas5GQmF6zQm8olF/slNmlnSy8jfHUUUCIkjlkMHA== X-Received: by 2002:a17:907:35cb:: with SMTP id ap11mr15709405ejc.459.1613394993877; Mon, 15 Feb 2021 05:16:33 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 08/19] sev/i386: Enable an SEV-ES guest based on SEV policy Date: Mon, 15 Feb 2021 14:16:15 +0100 Message-Id: <20210215131626.65640-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Lendacky , Venu Busireddy , Richard Henderson , Eduardo Habkost , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky Update the sev_es_enabled() function return value to be based on the SEV policy that has been specified. SEV-ES is enabled if SEV is enabled and the SEV-ES policy bit is set in the policy object. Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Tom Lendacky Reviewed-by: Venu Busireddy Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/sev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 4b70d4284f..0f414df02f 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -356,7 +356,7 @@ sev_enabled(void) bool sev_es_enabled(void) { - return false; + return sev_enabled() && (sev_guest->policy & SEV_POLICY_ES); } =20 uint64_t --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395472692607.6068048134758; Mon, 15 Feb 2021 05:24:32 -0800 (PST) Received: from localhost ([::1]:33672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdrb-0002S1-7M for importer@patchew.org; Mon, 15 Feb 2021 08:24:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjx-0005Yh-MU for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:37 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]:33394) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjv-0005WB-UX for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:37 -0500 Received: by mail-ej1-x62f.google.com with SMTP id jt13so11124004ejb.0 for ; Mon, 15 Feb 2021 05:16:35 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xJQYENmqLP+bilTlpTv825EhHuvFtwMDrASktBaWBro=; b=GWo8Yzly+XQ80lKHdWM9qoqf5+4o5ZP/HOsr0fTM+dVjsFRRnJeOz5VrohZi3yNmcB KQDC1PyZkuhboIRIqlCgeQy6Mhfwmr4Hf2T2QAhGuEXyI8d4nkQD8K2jU/1+tj0hEX/B 0dXD9HO/weoU7vnZ+L/BqOXYdLa3mMnPLHqu9zceouiEUDOxqwu6b5ysyURHT3pI/NuA rXhqYFOl5ygGx5eDXcERr9BxI8IzDdAFVtl1v/4st34y4n4Rc0CZG75OlecgNCE9emH4 KenW5DJSlXc60GTKhGMVdwp7eu/Q8yLLFKNWqxTd9n9E7r2mJZf5Uopn8qrCI71ALLx1 FcDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=xJQYENmqLP+bilTlpTv825EhHuvFtwMDrASktBaWBro=; b=Dd6q1XLkay4kp6rCn0tlmbVe8RLJziORpPjtm3b2rysg6LNxMMzqE2cHk+dZndAs1G jExADrD6CUUDYF3vx+tEgbGlucR0d6F+F1XRjOi8zicea+O9JCeMKbiwv/E6qP1QqO3k SwftIMHa4T9ZFB+OTl3NzwKJNWlVZFiulKQ9HKmAkZQ5KdCVuU2zpBVH5xDUZZKZV4ZS 4dxB0UYWrWrXEQIrq3YmjWqHV6i5QWYXScFvjOF2SizOfDMXmh8VQwIDS/XaZhhPPkp7 yCSi8mKpcfvPwPc4wzAyye4BpjwJSeP6ke93H9IoNuWD2rOZaVcy16kBWAHW+BZzOaNS eZJQ== X-Gm-Message-State: AOAM530Kwz5EJ+HnLwFambI1Wx/c+Og7K5ojCuSGQLyLnucfmdxqo0Wq etsOCO2YVIn2tUjgF2lCD36pKMtwRqE= X-Google-Smtp-Source: ABdhPJy0o0OAk5/gOmXllxyPTNIPybBv8mu1DdPxf8IoCes9HuXoeq74RVvgs93UUhpT+WnmNN3UaQ== X-Received: by 2002:a17:906:268a:: with SMTP id t10mr13562818ejc.2.1613394994506; Mon, 15 Feb 2021 05:16:34 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/19] libqos/qgraph: add qos_node_create_driver_named() Date: Mon, 15 Feb 2021 14:16:16 +0100 Message-Id: <20210215131626.65640-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Schoenebeck Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: qemu_oss--- via So far the qos subsystem of the qtest framework had the limitation that only one instance of the same official QEMU (QMP) driver name could be created for qtests. That's because a) the created qos node names must always be unique, b) the node name must match the official QEMU driver name being instantiated and c) all nodes are in a global space shared by all tests. This patch removes this limitation by introducing a new function qos_node_create_driver_named() which allows test case authors to specify a node name being different from the actual associated QEMU driver name. It fills the new 'qemu_name' field of QOSGraphNode for that purpose. Adjust build_driver_cmd_line() and qos_graph_node_set_availability() to correctly deal with either accessing node name vs. node's qemu_name correctly. Signed-off-by: Christian Schoenebeck Message-Id: <3be962ff38f3396f8040deaa5ffdab525c4e0b16.1611704181.git.qemu_o= ss@crudebyte.com> Signed-off-by: Paolo Bonzini --- tests/qtest/libqos/qgraph.c | 54 ++++++++++++++++++++++++++-- tests/qtest/libqos/qgraph.h | 16 +++++++++ tests/qtest/libqos/qgraph_internal.h | 1 + 3 files changed, 68 insertions(+), 3 deletions(-) diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c index fc49cfa879..61faf6b27d 100644 --- a/tests/qtest/libqos/qgraph.c +++ b/tests/qtest/libqos/qgraph.c @@ -153,6 +153,7 @@ static QOSGraphNode *create_node(const char *name, QOSN= odeType type) static void destroy_node(void *val) { QOSGraphNode *node =3D val; + g_free(node->qemu_name); g_free(node->command_line); g_free(node); } @@ -286,7 +287,8 @@ static void build_machine_cmd_line(QOSGraphNode *node, = const char *args) */ static void build_driver_cmd_line(QOSGraphNode *node) { - node->command_line =3D g_strconcat(" -device ", node->name, NULL); + const char *name =3D node->qemu_name ?: node->name; + node->command_line =3D g_strconcat(" -device ", name, NULL); } =20 /* qos_print_cb(): callback prints all path found by the DFS algorithm. */ @@ -631,6 +633,15 @@ void qos_node_create_driver(const char *name, QOSCreat= eDriverFunc function) node->u.driver.constructor =3D function; } =20 +void qos_node_create_driver_named(const char *name, const char *qemu_name, + QOSCreateDriverFunc function) +{ + QOSGraphNode *node =3D create_node(name, QNODE_DRIVER); + node->qemu_name =3D g_strdup(qemu_name); + build_driver_cmd_line(node); + node->u.driver.constructor =3D function; +} + void qos_node_contains(const char *container, const char *contained, QOSGraphEdgeOptions *opts, ...) { @@ -663,7 +674,7 @@ void qos_node_consumes(const char *consumer, const char= *interface, add_edge(interface, consumer, QEDGE_CONSUMED_BY, opts); } =20 -void qos_graph_node_set_availability(const char *node, bool av) +static void qos_graph_node_set_availability_explicit(const char *node, boo= l av) { QOSGraphEdgeList *elist; QOSGraphNode *n =3D search_node(node); @@ -678,9 +689,46 @@ void qos_graph_node_set_availability(const char *node,= bool av) } QSLIST_FOREACH_SAFE(e, elist, edge_list, next) { if (e->type =3D=3D QEDGE_CONTAINS || e->type =3D=3D QEDGE_PRODUCES= ) { - qos_graph_node_set_availability(e->dest, av); + qos_graph_node_set_availability_explicit(e->dest, av); + } + } +} + +/* + * Behaves as qos_graph_node_set_availability_explicit(), except that the + * former always matches by node name only, whereas this function matches = both + * by node name and node's optional 'qemu_name' field. + */ +void qos_graph_node_set_availability(const char *node, bool av) +{ + GList *l; + QOSGraphEdgeList *elist; + QOSGraphEdge *e, *next; + QOSGraphNode *n; + GList *keys =3D g_hash_table_get_keys(node_table); + + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + n =3D g_hash_table_lookup(node_table, key); + /* + * node's 'qemu_name' is set if there is more than one device with + * the same QEMU (QMP) device name + */ + const char *node_name =3D n->qemu_name ?: n->name; + if (g_strcmp0(node_name, node) =3D=3D 0) { + n->available =3D av; + elist =3D get_edgelist(n->name); + if (elist) { + QSLIST_FOREACH_SAFE(e, elist, edge_list, next) { + if (e->type =3D=3D QEDGE_CONTAINS || e->type =3D=3D QE= DGE_PRODUCES) + { + qos_graph_node_set_availability_explicit(e->dest, = av); + } + } + } } } + g_list_free(keys); } =20 void qos_graph_foreach_test_path(QOSTestCallback fn) diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index 5f63d352ca..f472949f68 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -452,6 +452,22 @@ void qos_node_create_machine_args(const char *name, */ void qos_node_create_driver(const char *name, QOSCreateDriverFunc function= ); =20 +/** + * Behaves as qos_node_create_driver() with the extension of allowing to + * specify a different node name vs. associated QEMU device name. + * + * Use this function instead of qos_node_create_driver() if you need to cr= eate + * several instances of the same QEMU device. You are free to choose a cus= tom + * node name, however the chosen node name must always be unique. + * + * @param name: custom, unique name of the node to be created + * @param qemu_name: actual (official) QEMU driver name the node shall be + * associated with + * @param function: driver constructor + */ +void qos_node_create_driver_named(const char *name, const char *qemu_name, + QOSCreateDriverFunc function); + /** * qos_node_contains(): creates one or more edges of type QEDGE_CONTAINS * and adds them to the edge list mapped to @container in the diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgra= ph_internal.h index 968fa69450..974985dce9 100644 --- a/tests/qtest/libqos/qgraph_internal.h +++ b/tests/qtest/libqos/qgraph_internal.h @@ -56,6 +56,7 @@ struct QOSGraphNode { bool available; /* set by QEMU via QMP, used during graph walk */ bool visited; /* used during graph walk */ char *name; /* used to identify the node */ + char *qemu_name; /* optional: see qos_node_create_driver_named() */ char *command_line; /* used to start QEMU at test execution */ union { struct { --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395674; cv=none; d=zohomail.com; s=zohoarc; b=UzPEBOvi7yzmZnh61v6dcLMcw1Nxo4+xdMJ2DVMSDCgEV2psWF0EJt1VP24dgRkz2unLojd56haI8GIWlD8banA9pVWKDay7Tu0l8Z6JLlefGX8wzW8MNd5kpjIbE66bDRy6iOFczci/8H4LjCo2PcGA2UXJzObF2ez5WuRaNEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395674; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UnObrrOSAPDzUf3sGkOTM2n/CMfEuxCbzh/iVrZ08VM=; b=RFRka925CNq8hfSsOGHF0boAPtWgW4Wj1iFEtR4u7voDbbRfygFrY8cdcbRdjNJLG97oi5H/QuUwXClVjHGQE6HDRByQ/MzbCfooedKgAjksYQPe0ITSFYwI0J1aItKaxXVU+Ckj/Gv0ATr5Yi4a5w651U/lajcr2s4RnoBj3Es= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161339567399741.39370616157339; Mon, 15 Feb 2021 05:27:53 -0800 (PST) Received: from localhost ([::1]:41970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBduq-0005tx-OP for importer@patchew.org; Mon, 15 Feb 2021 08:27:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjx-0005Z7-SJ for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:37 -0500 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]:41044) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjw-0005WO-Ed for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:37 -0500 Received: by mail-ej1-x630.google.com with SMTP id f14so11024820ejc.8 for ; Mon, 15 Feb 2021 05:16:36 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UnObrrOSAPDzUf3sGkOTM2n/CMfEuxCbzh/iVrZ08VM=; b=TMqp6ViqrITuc+EnrlSTKvrbRdSqXYghaFxczUGUc6yOQk6YAeYQrjNgLl5z+TUasz SeOQ/odWHuuRhtZSelMOshpi3xiP1oXi2biGeVDTsG+baNrQL86ukDDAUnZgaSE7jU8D FlqHUbsxy9dWKXpCnrx7pkmMrOkGl2RD4MAiWrl54xGv1WbibsnlVJlh7lJ7Yw5Rf+lG oet+QLEnhrTW983MPEJTKo1/QBBPkPQ3+Yzi8rxFfWOO7GkJM9MoNMmstLpI2Nolx07S l59TpJ57Jql0TeRqMjMa/LdtSiG3Y8rGsWnmxG/x6sO/+HSaU/kzPBdhwWWkkwoZLND7 R5Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=UnObrrOSAPDzUf3sGkOTM2n/CMfEuxCbzh/iVrZ08VM=; b=KNGDLHxnru6Jw9KO97rFnyfy8hbhxDQKoRLZ6wzI/Cp9LJKH6xlzu7Vfk+eTqBBoEW e97u816dtMkyb52ii0y1TwbDMt8mecFViI4QffngZLScfy5mJtZrL94VxUNndsUFiMap va0vNyAXv41qVGagJGSrGhmSuIE2xm2dDle72VHdn79/magVnRWY48aYEHI800kXmL9z 603DegRTf2Zbt8hCazUT0a+QAIzNCTRpvlIS0BoupVC08kZBaPExr/klmNYolwo7+iM+ ktp9uHS+iTkngeTwjdrxQ3E0DOUpn79EGrFtaMdn+y9VP1e94Ywj5Nz+ligS5y6GIWOT 056g== X-Gm-Message-State: AOAM530+ArExCVFOmiHsdEb4WOp8Gz7vthcMGHpYcJ0MhQDRieIii2ic kpbawwiiVntm+z7Wk+IFtmtN3ldKlh4= X-Google-Smtp-Source: ABdhPJyFlJVbB02ryBNBpM03T9t5ESq9H0mWlfKPDFKTcbb8I1xzNzOsCAnqdt5aVI7JxsYjI9TMSQ== X-Received: by 2002:a17:906:5e05:: with SMTP id n5mr8213359eju.349.1613394995190; Mon, 15 Feb 2021 05:16:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/19] libqos/qgraph_internal: add qos_printf() and qos_printf_literal() Date: Mon, 15 Feb 2021 14:16:17 +0100 Message-Id: <20210215131626.65640-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Christian Schoenebeck Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: qemu_oss--- via These two are macros wrapping regular printf() call. They are intended to be used instead of calling printf() directly in order to avoid breaking TAP output format. TAP output format is enabled by using --tap command line argument. Starting with glib 2.62 it is enabled by default. Unfortunately there is currently no public glib API available to check whether TAP output format is enabled. For that reason qos_printf() simply always prepends a '#' character for now. Signed-off-by: Christian Schoenebeck Reviewed-by: Thomas Huth Message-Id: <653a5ef61c5e7d160e4d6294e542c57ea324cee4.1611704181.git.qemu_o= ss@crudebyte.com> Signed-off-by: Paolo Bonzini --- tests/qtest/libqos/qgraph_internal.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgra= ph_internal.h index 974985dce9..c0025f5ab9 100644 --- a/tests/qtest/libqos/qgraph_internal.h +++ b/tests/qtest/libqos/qgraph_internal.h @@ -255,4 +255,15 @@ void qos_delete_cmd_line(const char *name); */ void qos_graph_node_set_availability(const char *node, bool av); =20 +/* + * Prepends a '#' character in front for not breaking TAP output format. + */ +#define qos_printf(...) printf("# " __VA_ARGS__) + +/* + * Intended for printing something literally, i.e. for appending text as is + * to a line already been started by qos_printf() before. + */ +#define qos_printf_literal printf + #endif --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395670831564.5030189406018; Mon, 15 Feb 2021 05:27:50 -0800 (PST) Received: from localhost ([::1]:41574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdun-0005kQ-PW for importer@patchew.org; Mon, 15 Feb 2021 08:27:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjy-0005az-Ux for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:38 -0500 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:41551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjx-0005XZ-6H for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:38 -0500 Received: by mail-ed1-x52f.google.com with SMTP id v9so3592545edw.8 for ; Mon, 15 Feb 2021 05:16:36 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jQUH6VObd8u7+fDQH28VbFEYWbLdj3MMsViIPnVyQ0g=; b=k3EWQ7ExgRoYspRezvtdEqSrOLE74sE+HtAWZJXemv0PfwLg8LfEcMbOD7k2L8XWN+ 6mMOVZQJ2EhzwPBNiah5cabOKmkshWF8ZSn22YC1B2OmNVdqHRFaRAtcXHGWhz5hhY3+ M7EEBlrETQg6N/OMjz7C7A0wLo2j0ce/jU/3alZXKaFRv87yj8XQaagEh+VYPIKx/lnQ 3YMrHnVUeWrIIzkdQjtlKkiCmEuBJOFZr9EwC8Rc9qPpVhcovalqF1jd5aCCdjBgpwvv HlZwcs1RNqjoj5wIRQR7+hv9Sp6kzTpVBbcY60TUBId5o8ZHoYnOD1/7bmKUi5K+bkJT F0tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jQUH6VObd8u7+fDQH28VbFEYWbLdj3MMsViIPnVyQ0g=; b=m0RrqTu4yj0y+kax04tp+r6QgWEnkoY8Jx/eR3fwLM7f8c/VCW2Aaja5DsYVvOsp+m LmEGnSQ8k9xgGc2ZdfB8CuEKJT3K/9nF0++dityA3fF/1itW6WrkuvuX/k3lzztD6A0E EfSGgrppgPwhgN9uYkqJ+EPghrO5WoX4eUi4l8A0A/idL7NfPM78717/I0yjJzMEXP86 Rf5Y7G63/PadFO1ZOcdLmgdNcrXKpwoKoBnv96A74w53aOABdAg3e/GAZk8DNPkvHJQN +x6waPq60247eW6JDmIGW9mAeVZVnJxjCfgxxEGPCyyr+ax/RHyRecjml6XZpzfu+iVP 3Mkg== X-Gm-Message-State: AOAM532dLJdGSd3cK1RcazoSDQyxvUlRqYUtHarCB5I6EeaRn0AOWdkM r1mJ5Jd/gWIuP/yVeT/AymJj0bXkWXU= X-Google-Smtp-Source: ABdhPJzah0VkayTg2LB3L+9WmeamxU8aZFBxOwg1wI9gZShiK5nUOKmWOJCH8Rx93gyqVTkQHwYWZg== X-Received: by 2002:aa7:c555:: with SMTP id s21mr332652edr.43.1613394995859; Mon, 15 Feb 2021 05:16:35 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 11/19] tests/qtest/qos-test: dump qos graph if verbose Date: Mon, 15 Feb 2021 14:16:18 +0100 Message-Id: <20210215131626.65640-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Schoenebeck Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: qemu_oss--- via If qtests were run in verbose mode (i.e. if --verbose CL argument was provided) then dump the generated qos graph (all nodes and edges, along with their current individual availability status) to stdout, which allows to identify problems in the created qos graph e.g. when writing new qos tests. See API doc comment on function qos_dump_graph() for details. Signed-off-by: Christian Schoenebeck Message-Id: <6bffb6e38589fb2c06a2c1b5deed33f3e710fed1.1611704181.git.qemu_o= ss@crudebyte.com> Signed-off-by: Paolo Bonzini --- tests/qtest/libqos/qgraph.c | 45 +++++++++++++++++++++++++++++++++++++ tests/qtest/libqos/qgraph.h | 20 +++++++++++++++++ tests/qtest/qos-test.c | 3 +++ 3 files changed, 68 insertions(+) diff --git a/tests/qtest/libqos/qgraph.c b/tests/qtest/libqos/qgraph.c index 61faf6b27d..b3b1a31f81 100644 --- a/tests/qtest/libqos/qgraph.c +++ b/tests/qtest/libqos/qgraph.c @@ -805,3 +805,48 @@ void qos_delete_cmd_line(const char *name) node->command_line =3D NULL; } } + +void qos_dump_graph(void) +{ + GList *keys; + GList *l; + QOSGraphEdgeList *list; + QOSGraphEdge *e, *next; + QOSGraphNode *dest_node, *node; + + qos_printf("ALL QGRAPH EDGES: {\n"); + keys =3D g_hash_table_get_keys(edge_table); + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + qos_printf("\t src=3D'%s'\n", key); + list =3D get_edgelist(key); + QSLIST_FOREACH_SAFE(e, list, edge_list, next) { + dest_node =3D g_hash_table_lookup(node_table, e->dest); + qos_printf("\t\t|-> dest=3D'%s' type=3D%d (node=3D%p)", + e->dest, e->type, dest_node); + if (!dest_node) { + qos_printf_literal(" <------- ERROR !"); + } + qos_printf_literal("\n"); + } + } + g_list_free(keys); + qos_printf("}\n"); + + qos_printf("ALL QGRAPH NODES: {\n"); + keys =3D g_hash_table_get_keys(node_table); + for (l =3D keys; l !=3D NULL; l =3D l->next) { + const gchar *key =3D l->data; + node =3D g_hash_table_lookup(node_table, key); + qos_printf("\t name=3D'%s' ", key); + if (node->qemu_name) { + qos_printf_literal("qemu_name=3D'%s' ", node->qemu_name); + } + qos_printf_literal("type=3D%d cmd_line=3D'%s' [%s]\n", + node->type, node->command_line, + node->available ? "available" : "UNAVAILBLE" + ); + } + g_list_free(keys); + qos_printf("}\n"); +} diff --git a/tests/qtest/libqos/qgraph.h b/tests/qtest/libqos/qgraph.h index f472949f68..07a32535f1 100644 --- a/tests/qtest/libqos/qgraph.h +++ b/tests/qtest/libqos/qgraph.h @@ -586,5 +586,25 @@ QOSGraphObject *qos_machine_new(QOSGraphNode *node, QT= estState *qts); QOSGraphObject *qos_driver_new(QOSGraphNode *node, QOSGraphObject *parent, QGuestAllocator *alloc, void *arg); =20 +/** + * Just for debugging purpose: prints all currently existing nodes and + * edges to stdout. + * + * All qtests add themselves to the overall qos graph by calling qgraph + * functions that add device nodes and edges between the individual graph + * nodes for tests. As the actual graph is assmbled at runtime by the qos + * subsystem, it is sometimes not obvious how the overall graph looks like. + * E.g. when writing new tests it may happen that those new tests are simp= ly + * ignored by the qtest framework. + * + * This function allows to identify problems in the created qgraph. Keep in + * mind: only tests with a path down from the actual test case node (leaf)= up + * to the graph's root node are actually executed by the qtest framework. = And + * the qtest framework uses QMP to automatically check which QEMU drivers = are + * actually currently available, and accordingly qos marks certain pathes = as + * 'unavailable' in such cases (e.g. when QEMU was compiled without suppor= t for + * a certain feature). + */ +void qos_dump_graph(void); =20 #endif diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index 8fdf87b183..d98ef78613 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -322,6 +322,9 @@ int main(int argc, char **argv) qos_set_machines_devices_available(); =20 qos_graph_foreach_test_path(walk_path); + if (g_test_verbose()) { + qos_dump_graph(); + } g_test_run(); qtest_end(); qos_graph_destroy(); --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613396099; cv=none; d=zohomail.com; s=zohoarc; b=X8aDFdlz/7PrmekhylJ6HWZNT3q33P2uQoSgnwK7zn4z9WNgjXO+n1NCaa+waekevI8Cx1xm1y+xdqc/o1tLBghOMm6PWdfVyNcUB9/9CRTu9VMkLOtp5pXMbU77by8UKRCC53dfT0YcF4G9X4akdyjmJuUIZaHKuHe6IPHmieU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613396099; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v8B7dQMP2+1i46OpqrqPq2fC3acQ71+O471l3ttFlJY=; b=Hcx918UIntC62uGPLt9cQMo9KjPNHwcwptn5daWx4YBtzcF0nktxK2YZw1TGO/WmRx+6X5z/X64IjfLkVvqPTXekpabj/z1wjWH1eBHacpuoxPZ/IryQvgZHjnnhBDUPsmqMh21KmN1BKaeaX6s4yrfrZgACwcXOKH92QaWOyqQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613396099671568.5542029672037; Mon, 15 Feb 2021 05:34:59 -0800 (PST) Received: from localhost ([::1]:59286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBe1i-0004b6-MT for importer@patchew.org; Mon, 15 Feb 2021 08:34:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjz-0005bS-7n for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:39 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:41553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjx-0005Xf-NN for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:38 -0500 Received: by mail-ed1-x531.google.com with SMTP id v9so3592594edw.8 for ; Mon, 15 Feb 2021 05:16:37 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v8B7dQMP2+1i46OpqrqPq2fC3acQ71+O471l3ttFlJY=; b=hiTUKrZrGkPhopODUfpsPxZwxzIIeEMvBIEXLUyM79v64KFVbsNnJ1orwwH8RticO4 qZrgC8f/Pl8+YGSDCNI6wF0DdFbSVNSCyEIP6POPsB7gYFFc3CmWIZYV96F/ydXjC8A9 2sQuZpj6W/6wlkJov86tzH3h5MBE2EK39NKd9wBTQaT+MP8dQi0AFgoTCt5IlWekPitj ng+tVLnC1yybhnibUB/zDW4w71CNCALa1GvhqLbdbb3A/Tr6XPw1PZkeSOWm9ADZLA3e 7QHCrboy2g5vShKam0c9WAoBlRZt+VKRH49XdUdqraSoCS072+hwxpvHrSG5AvRZxV8z rzrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=v8B7dQMP2+1i46OpqrqPq2fC3acQ71+O471l3ttFlJY=; b=ewcVN4zrSZdpaIjaj/MwckWy9qg3vAeHabD8TS4oH7qnw7EbYnyfLI8AAYl0AoyeRZ GjX03UHraloyMFPNLuQ+Ci4XghmLwBfAW5gv34yOqiXfhyHv7CrPnp22OVfTdk3bwrK2 t0C6Sp3JezNm6uWNXOfq9kPgPOmQpaClQWeTB55jDJfcOJO+nV32vjFauilyLFYxEyUF saow/P81Akkxw2kAwWw0upYoyv4vXv7uCnwvGWVp6G5cwkrPdS/9JiGbOtOPP5oMS3ER jaM4qQDdDIbXXXDI8VFgBzIWjpoOAfcpcjoQBITfIF/frWu3hsnm9E6+825AZWUSQS1b 80CQ== X-Gm-Message-State: AOAM53129HZf8biK9N1kR6u5gJK76+N4j7rYDCsjzAHjJ9zb/YtCBuzg dqnL8t1FsuuSRn9NzEXVO6eHEMfSqZ4= X-Google-Smtp-Source: ABdhPJzozOxVWZXlcERSiL/085JHb5KtJ2mcv8l0R3+wH0sFuN4c9PeHKe3C882e/FpqShMRKB3xrw== X-Received: by 2002:a05:6402:216:: with SMTP id t22mr13687550edv.168.1613394996463; Mon, 15 Feb 2021 05:16:36 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/19] tests/qtest/qos-test: dump environment variables if verbose Date: Mon, 15 Feb 2021 14:16:19 +0100 Message-Id: <20210215131626.65640-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Schoenebeck Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: qemu_oss--- via If qtests are run in verbose mode (i.e. if --verbose CL argument was provided) then print all environment variables to stdout before running the individual tests. It is common nowadays, at least being able to output all config vectors in a build chain, especially if it is required to investigate build- and test-issues on foreign/remote machines, which includes environment variables. In the context of writing new test cases this is also useful for finding out whether there are already some existing options for common questions like is there a preferred location for writing test files to? Is there a maximum size for test data? Is there a deadline for running tests? Use qos_printf() instead of g_test_message() to avoid the latter cluttering the output. Signed-off-by: Christian Schoenebeck Message-Id: <21d77b33c578d80b5bba1068e61fd3562958b3c2.1611704181.git.qemu_o= ss@crudebyte.com> Signed-off-by: Paolo Bonzini --- tests/qtest/qos-test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index d98ef78613..b279b6f816 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -313,9 +313,16 @@ static void walk_path(QOSGraphNode *orig_path, int len) * machine/drivers/test objects * - Cleans up everything */ -int main(int argc, char **argv) +int main(int argc, char **argv, char** envp) { g_test_init(&argc, &argv, NULL); + if (g_test_verbose()) { + qos_printf("ENVIRONMENT VARIABLES: {\n"); + for (char **env =3D envp; *env !=3D 0; env++) { + qos_printf("\t%s\n", *env); + } + qos_printf("}\n"); + } qos_graph_init(); module_call_init(MODULE_INIT_QOM); module_call_init(MODULE_INIT_LIBQOS); --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613396255668215.01531749154606; Mon, 15 Feb 2021 05:37:35 -0800 (PST) Received: from localhost ([::1]:38154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBe4E-0007Wz-JN for importer@patchew.org; Mon, 15 Feb 2021 08:37:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdjz-0005cV-QO for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:39 -0500 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]:44149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjy-0005Xl-Ag for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:39 -0500 Received: by mail-ej1-x635.google.com with SMTP id w1so10981594ejf.11 for ; Mon, 15 Feb 2021 05:16:37 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pp/kQNjyS4VICCzImjwdyqsn8FUT6fpPnB3O9eihh7I=; b=MevVA3EF9tJ4XvPY2GyRcgb2Ypp/e5ukZl80QQlKpGsJ4YfHmbEhI1Z+hJlTPnDBNU lqDSKVygr9kdDQ02Y6aKQpoXj1bjd3p3aQJ1Ds5DX4lT+lvA1qwC8Fba4JuFUBOX2GCE tRtT/IXJSrQgfCf/I1EmBci9GaUSpGPSFvmZKfKcK/X4u+k/rjwK/eA8KZVWXmbBJInQ IpOUiojmOzCcMnTkedbtnf7aNgZS+CN279T+7A246Tk9E2WI54GZivpNl225x2LIi1aP ExHVDKJ5VNbVSm14rgV9ScmBbUHScyuTKFTmxh2Ry3rJ/JqKOtw21PV5if3fdbwtqfz0 Mx6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pp/kQNjyS4VICCzImjwdyqsn8FUT6fpPnB3O9eihh7I=; b=IcegKH/GeG2lTxpcRRN535PIRY22+rGEYZWAz+guV5NP9RJTSUffmp0N/rxNBnIpGt /lpN/vIej2DFSE7M+lRFz9ltGPv/nd9f7NVAzuM/R9HNqae5o5oGTI8tmK1a3hQCJfah 4t+VVVr1Z/OepUrTxdhbD5PqoF92ZYyB/P9lHSGVq/irtg2GnjgGrVDva2woMBTn3Im/ kpp+trG487IYrlUA/2v+/VztS8dCSranvb3PLwqSRBDe0JbbSsf34cmUckdBmI1m02T1 pZ0pfk4QkTdeBlyEPjNV/rlYbWZhCwJdDCYgPFEOZFCvp8A9YashejQqRZz1B7aYblqY YeBg== X-Gm-Message-State: AOAM5311AkbDnKlTJtS57v6K/tY05DM1AOKT22jaqR15/yq+6svv7MWe ZLoFArLeVHxS2dG+MAYpuY4x4yfCdbQ= X-Google-Smtp-Source: ABdhPJyjGmdw3VPA9fGF0KiEZ/qJRGe0/T7JQIQTb6+CuTrlBtZe2bmPw/weJfK3id8cqSYv8qu+Gw== X-Received: by 2002:a17:907:20d6:: with SMTP id qq22mr15526867ejb.517.1613394997061; Mon, 15 Feb 2021 05:16:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 13/19] tests/qtest/qos-test: dump QEMU command if verbose Date: Mon, 15 Feb 2021 14:16:20 +0100 Message-Id: <20210215131626.65640-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Schoenebeck Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: qemu_oss--- via If qtests are run in verbose mode (i.e. if --verbose CL argument was provided) then print the assembled qemu command line for each test. Use qos_printf() instead of g_test_message() to avoid the latter cluttering the output. Signed-off-by: Christian Schoenebeck Message-Id: <110bef3595cb841dfa1b86733c174ac9774eb37e.1611704181.git.qemu_o= ss@crudebyte.com> Signed-off-by: Paolo Bonzini --- tests/qtest/qos-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qtest/qos-test.c b/tests/qtest/qos-test.c index b279b6f816..f97d0a08fd 100644 --- a/tests/qtest/qos-test.c +++ b/tests/qtest/qos-test.c @@ -89,6 +89,9 @@ static void qos_set_machines_devices_available(void) =20 static void restart_qemu_or_continue(char *path) { + if (g_test_verbose()) { + qos_printf("Run QEMU with: '%s'\n", path); + } /* compares the current command line with the * one previously executed: if they are the same, * don't restart QEMU, if they differ, stop previous --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395685; cv=none; d=zohomail.com; s=zohoarc; b=NYhPXfrXdJxXJ466/v6nhU22YDON2Djev3+OTcuZn1DUa6yVG46hBMZg+S91ECLEDkcL5oWM+CEEyfXrqUT3BS4zwYyiKfAFXRUg+6pnRzq1MeWw83RnlPi4lTuxCsXGwhbBPpFj6+YkNP8+bU8Do7cWDh7vIjBk1hwUhdRHwWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395685; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FDZgxt19cep10sPenqmyiZgIQfpc+2ftCbZKz0i31KU=; b=hD9Ifmt0M/7uchJNbjQsKgSggPCuGgO1hgcpKsTOCl149EcgTny63NJlt2eGlCIbUhC7X4RtrpolHqm0GTz9hLveFSsa6m9MQhyHJa8levdCWt7m0s5Z/5dFZx9IDTOeWwscunZ9CHdo/DvJLZYGNJmkuHt0n1Xkc0LHenW4cUE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395684631609.2206381505329; Mon, 15 Feb 2021 05:28:04 -0800 (PST) Received: from localhost ([::1]:42384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdv1-00064L-JF for importer@patchew.org; Mon, 15 Feb 2021 08:28:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdk0-0005ec-Qs; Mon, 15 Feb 2021 08:16:40 -0500 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:41546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjz-0005Xw-F8; Mon, 15 Feb 2021 08:16:40 -0500 Received: by mail-ed1-x529.google.com with SMTP id v9so3592696edw.8; Mon, 15 Feb 2021 05:16:38 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FDZgxt19cep10sPenqmyiZgIQfpc+2ftCbZKz0i31KU=; b=OTG7zej3/E7m9SvlCi4yuWLr338QxHuAsMKXLcT2bfcUKlamoo8wE0Ki3u0JoFUVY1 Vxvb1leoRzJ+xcJC7FvvAPRCg0fbrkraruookznB8oYhTBCJ/G+85RyF0pMnh4GSWR68 A3DJweM+EYCQew2mJKkV8TJKsHxh05XyoXCKQ4+ypTKCEyVsMMnumWUbaBokDV6aOQn9 RwwUZcNK/H+j3fQ69+EApBUYd13cQS7SRWR50bsLLZRsIPPmrOblG6X9eS1DxvnI3Hui HXcZYqTADa5nXB/L1XfYIQ1z/sJMTJYWRW2N/YK5XbgAqZaZIWxgqLJVsEjCoh6eYbLu ZeUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FDZgxt19cep10sPenqmyiZgIQfpc+2ftCbZKz0i31KU=; b=Z4E+l/WdCgRA0/N5NrEeuZ/aoeMmaAhpTjYYdEK1HjF0WM2qzERFpOcfay1vZ2M+I0 LZTAX+ZmPjJFy6A/AcWVGli+jBU/VZIMb8t1z4kAHb4JmjpEdkmCJ8RQb3gEoO0cuva6 lPGn9UBz4NxEZwtDNh1c7ywXMh46EQVYlC1Rvg+2ByaCzVEwU+qoMxAtHMujyKt2rczZ qTIJEbnax7ljnwhZ48U4INwEojTT5caZF935YJoMOuybOIO5jKklQ7WvDejXlFNwXAk1 ySkQv+9hoJFmI+FHoTzeJZ6YbfMNZP+/sDUkYtef1Hn08AIlzkeBOhPtT1fC/ZXBe+u4 Pe1Q== X-Gm-Message-State: AOAM5317BVngQPoCZpTVG+rwOXb8XgMfnkIG7Cc/xL71fBnHHWkUBJ6E eF0WT2PXa1uZVSyJqapIK1LA6zOCeWs= X-Google-Smtp-Source: ABdhPJyPDj0sJJB4qDHZ42WxY1E1qiLmaFp7TgyAo6e30NJxszJjwWb/FRMsISiJ2wgPRYXnHMjOwg== X-Received: by 2002:a05:6402:3514:: with SMTP id b20mr15205642edd.100.1613394997734; Mon, 15 Feb 2021 05:16:37 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 14/19] util/cutils: Skip "." when looking for next directory component Date: Mon, 15 Feb 2021 14:16:21 +0100 Message-Id: <20210215131626.65640-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Weil , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Stefan Weil When looking for the next directory component, a "." component is now skipp= ed. This fixes the path(s) used for firmware lookup for the prefix =3D=3D bindi= r case which is standard for QEMU on Windows and where the internally used bindir value ends with "/.". Signed-off-by: Stefan Weil Message-Id: <20210208205752.2488774-1-sw@weilnetz.de> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- util/cutils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/cutils.c b/util/cutils.c index 0b5073b330..70c7d6efbd 100644 --- a/util/cutils.c +++ b/util/cutils.c @@ -916,7 +916,8 @@ static inline bool starts_with_prefix(const char *dir) static inline const char *next_component(const char *dir, int *p_len) { int len; - while (*dir && G_IS_DIR_SEPARATOR(*dir)) { + while ((*dir && G_IS_DIR_SEPARATOR(*dir)) || + (*dir =3D=3D '.' && (G_IS_DIR_SEPARATOR(dir[1]) || dir[1] =3D= =3D '\0'))) { dir++; } len =3D 0; --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613395914; cv=none; d=zohomail.com; s=zohoarc; b=mT9Dswo+9D/undEX6SU87m1C5l5vWOjHk/EHpQqfM7/RPOigo2mWpr8PhEu8efj4U25COtYuIRlj44UgrZtq1dA1Qx9eM7EELWsunKdABGKO8AL99RwPUl63N1zR3TzX6jnSRqP6vurOWECS6Wq276AlmDeSvVCX6TH6jeHi9LA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613395914; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UXgcd0FI6AOswc8vxaoBN+OEtL7F7rxrjG3WEvBYSR0=; b=BJSNgCSoKyzu3xPtC0paoScl1CFaxBW37CGv0IMFI3rjS8F4N49kM5XsnulHSPdveds7Oxx3kxnvOZjgvFppi/XMUKiPRusLC1iP/NJUZuimOxW+SkAt/UoXoH6SnFWCcy1XCXp1RLgWoRQmCgUqbES7OAFinBxV0az0f/5Fjp4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395913620921.4566204060139; Mon, 15 Feb 2021 05:31:53 -0800 (PST) Received: from localhost ([::1]:51116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdyi-0001IO-Ic for importer@patchew.org; Mon, 15 Feb 2021 08:31:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdk1-0005gI-Cu for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:41 -0500 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]:36934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdjz-0005YO-R3 for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:41 -0500 Received: by mail-ej1-x62a.google.com with SMTP id jj19so11089310ejc.4 for ; Mon, 15 Feb 2021 05:16:39 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UXgcd0FI6AOswc8vxaoBN+OEtL7F7rxrjG3WEvBYSR0=; b=U8kU37l6HTUwHsuDqb6REtQ4sjM26+JA6VgWqZjLfvpzLCT0ybcBY2HIxSWgb37wqC 6jS2mAJb3QXUzMvYJ6oXy0EsrA5T8dxbUguriLtUD4uUyorK1IrU2pfR5FM8PxCm/xNz 88KUuxKZ6DFIGoJxK5dIyv4LHeZYTzvJicGwEHPtBxwOZbL5wybcrWdax8UagbBw51bV v3tQcNOXHK8kGVkhN6cWmaOeKP7FX5xOw4wP+Iouruq8c7+pcr0m6Cjr6P8OW/jW6FXa AUnMczQHrYV1tu3c59NMfZoRuYu94dakfhFBySVgC5ooYi/UJMa7WcdQuaXcekcKt7W8 EIxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=UXgcd0FI6AOswc8vxaoBN+OEtL7F7rxrjG3WEvBYSR0=; b=M8yF9neT1QjGObftqBtQcrjnPjkW0jKggKUiDeDcvPttCmJKO6jcAJlCB6trFQZ49d +t2dXFmFpjIJ0ro1RK8hUo4P3SGEfD5/Ey0aAru2uwz0cE8OIrEyIxj/YSi5e8pJF7rv SAfn/ae4DHywjJjcVCCZ/TWoq9PBQLsSjja2pE42yPYVVezdUXYIIZj6gtk39jhgH+IN 5Pq64mGjQaISRwYac9YcVT/nHmFfwM055JmgL+M8edz6YqLCKVkNlqHWa3Yx3XEqFbAh Ysxk+7V/96IgGnc7ytmx0iAZ4TZtj1AFj2zBmunCGWc7+WVSaHHN20hSTEop5gzE6tpQ 0b3g== X-Gm-Message-State: AOAM5302Ke7DoBdbCxjOuREvjJ67dJ5TMPKAFceCyA082wbAXVDuySRl KZhFg6QxKQSSWfc6FC4gzKdSXVyroLw= X-Google-Smtp-Source: ABdhPJy0GtZd+diJKpkF7bpd67n5EgzWd5f3+MEwR6qpIFxyembbJczoXRg+qwJSeGBCJadi/285EA== X-Received: by 2002:a17:907:da9:: with SMTP id go41mr15668611ejc.326.1613394998529; Mon, 15 Feb 2021 05:16:38 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 15/19] hvf: Guard xgetbv call Date: Mon, 15 Feb 2021 14:16:22 +0100 Message-Id: <20210215131626.65640-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , Hill Ma , Cameron Esfahani Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Hill Ma This prevents illegal instruction on cpus that do not support xgetbv. Buglink: https://bugs.launchpad.net/qemu/+bug/1758819 Reviewed-by: Cameron Esfahani Signed-off-by: Hill Ma Message-Id: Signed-off-by: Roman Bolshakov Signed-off-by: Paolo Bonzini --- target/i386/hvf/x86_cpuid.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/target/i386/hvf/x86_cpuid.c b/target/i386/hvf/x86_cpuid.c index a6842912f5..32b0d131df 100644 --- a/target/i386/hvf/x86_cpuid.c +++ b/target/i386/hvf/x86_cpuid.c @@ -27,15 +27,22 @@ #include "vmx.h" #include "sysemu/hvf.h" =20 -static uint64_t xgetbv(uint32_t xcr) +static bool xgetbv(uint32_t cpuid_ecx, uint32_t idx, uint64_t *xcr) { - uint32_t eax, edx; + uint32_t xcrl, xcrh; =20 - __asm__ volatile ("xgetbv" - : "=3Da" (eax), "=3Dd" (edx) - : "c" (xcr)); + if (cpuid_ecx & CPUID_EXT_OSXSAVE) { + /* + * The xgetbv instruction is not available to older versions of + * the assembler, so we encode the instruction manually. + */ + asm(".byte 0x0f, 0x01, 0xd0" : "=3Da" (xcrl), "=3Dd" (xcrh) : "c" = (idx)); =20 - return (((uint64_t)edx) << 32) | eax; + *xcr =3D (((uint64_t)xcrh) << 32) | xcrl; + return true; + } + + return false; } =20 uint32_t hvf_get_supported_cpuid(uint32_t func, uint32_t idx, @@ -100,12 +107,15 @@ uint32_t hvf_get_supported_cpuid(uint32_t func, uint3= 2_t idx, break; case 0xD: if (idx =3D=3D 0) { - uint64_t host_xcr0 =3D xgetbv(0); - uint64_t supp_xcr0 =3D host_xcr0 & (XSTATE_FP_MASK | XSTATE_SS= E_MASK | - XSTATE_YMM_MASK | XSTATE_BNDREGS_MASK | - XSTATE_BNDCSR_MASK | XSTATE_OPMASK_MASK | - XSTATE_ZMM_Hi256_MASK | XSTATE_Hi16_ZMM_= MASK); - eax &=3D supp_xcr0; + uint64_t host_xcr0; + if (xgetbv(ecx, 0, &host_xcr0)) { + uint64_t supp_xcr0 =3D host_xcr0 & (XSTATE_FP_MASK | + XSTATE_SSE_MASK | XSTATE_YMM_MASK | + XSTATE_BNDREGS_MASK | XSTATE_BNDCSR_MASK= | + XSTATE_OPMASK_MASK | XSTATE_ZMM_Hi256_MA= SK | + XSTATE_Hi16_ZMM_MASK); + eax &=3D supp_xcr0; + } } else if (idx =3D=3D 1) { hv_vmx_read_capability(HV_VMX_CAP_PROCBASED2, &cap); eax &=3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XGETBV1; --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613396410577732.4023309063019; Mon, 15 Feb 2021 05:40:10 -0800 (PST) Received: from localhost ([::1]:46108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBe6j-0002Q2-Hg for importer@patchew.org; Mon, 15 Feb 2021 08:40:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdk2-0005hL-4n for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:42 -0500 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:33609) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdk0-0005ZP-FO for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:41 -0500 Received: by mail-ed1-x52d.google.com with SMTP id c6so8021234ede.0 for ; Mon, 15 Feb 2021 05:16:40 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kax+fTmbEkmsBktA3FVc+VoFFDt7mh+TEtj+R0qVDHE=; b=Nz6k3F99nHkK1qCdHVuMMN97WZfVX7hrOx3ZYY9egGeereTGTBBS/Umzy0hYi6dPqS rU4JpGpX6W4UGObKzcSnkPOI4tv26d1iUMSLnJLMXId0aqiDPIyWksiFqFbt5KWr4gWa h7RnV0S/YXwSNT5eGH3HyKml+aSQe/xo065mtMSXHsD0S4EgT9SVCGqAJvQyKbqe4HvB ZYLGtLSPWHtp1h1wNnsbUK4EutMWolxr07hiWUKL7ZutswR191S0Y4odnXlzgUTYpEJX 7dleSwbmLKc5r/EuMKaqKYwNNmyRGYm6bLnKtRly6tsYgRrhtffqoHT0+LijxmLSFPj5 i14Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Kax+fTmbEkmsBktA3FVc+VoFFDt7mh+TEtj+R0qVDHE=; b=UaOLGsqqg6J76M7bwQClAsLnuWLnhFgZet+rR3wppeZq5JfHzTShf16KhAXe6pLkPi 5jwJlnCHfxoHt4Xl5QKGdd/LOmmt1FxL5QN0WCoZFz/dqGBzVOagYARQUTpvSeZkI6SY ZLjZqckxVi1vvPyi2D+UTmdHcBN7NxyJzkDyqUjxQ/02/DQLUps+kuel9NM2+uklEDDj qwI0GmSFgm3/wRisVEnUWcRhNhOnEcdjPqVCNcadqijjm2RnD2GZGAlgLgL+diKeL882 xXnkwMfAPPe3DXAF9tA1HTk+2ctSVax1KkRAdFL60wdpvC2AGf18GaXc7cdY2EHjVX/f XABg== X-Gm-Message-State: AOAM532En/MUw44w+pzqX4MU46dYIoyVGlwntmAeqgma8fUXb5ca4Dwl Ua8ceercQPnd+8KZaSsTpIgRVPxldTk= X-Google-Smtp-Source: ABdhPJzSellroVhCP7ElTyG3U7nUHLjhkkvRv2CAJ17oo+b0kocLlJVJVAGCpfRBc9wTiOhSVidqtw== X-Received: by 2002:a05:6402:2053:: with SMTP id bc19mr15127370edb.230.1613394999181; Mon, 15 Feb 2021 05:16:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 16/19] target/i386/hvf: add vmware-cpuid-freq cpu feature Date: Mon, 15 Feb 2021 14:16:23 +0100 Message-Id: <20210215131626.65640-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk For `-accel hvf` cpu_x86_cpuid() is wrapped with hvf_cpu_x86_cpuid() to add paravirtualization cpuid leaf 0x40000010 https://lkml.org/lkml/2008/10/1/246 Leaf 0x40000010, Timing Information: EAX: (Virtual) TSC frequency in kHz. EBX: (Virtual) Bus (local apic timer) frequency in kHz. ECX, EDX: RESERVED (Per above, reserved fields are set to zero). On macOS TSC and APIC Bus frequencies can be readed by sysctl call with names `machdep.tsc.frequency` and `hw.busfrequency` This options is required for Darwin-XNU guest to be synchronized with host Leaf 0x40000000 not exposes HVF leaving hypervisor signature empty Signed-off-by: Vladislav Yaroshchuk Message-Id: <20210122150518.3551-1-yaroshchuk2000@gmail.com> Signed-off-by: Roman Bolshakov Signed-off-by: Paolo Bonzini --- target/i386/hvf/hvf.c | 96 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 5b90dcdf88..10a06c3c79 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -65,6 +65,7 @@ =20 #include #include +#include =20 #include "exec/address-spaces.h" #include "hw/i386/apic_internal.h" @@ -456,6 +457,48 @@ static void dummy_signal(int sig) { } =20 +static void init_tsc_freq(CPUX86State *env) +{ + size_t length; + uint64_t tsc_freq; + + if (env->tsc_khz !=3D 0) { + return; + } + + length =3D sizeof(uint64_t); + if (sysctlbyname("machdep.tsc.frequency", &tsc_freq, &length, NULL, 0)= ) { + return; + } + env->tsc_khz =3D tsc_freq / 1000; /* Hz to KHz */ +} + +static void init_apic_bus_freq(CPUX86State *env) +{ + size_t length; + uint64_t bus_freq; + + if (env->apic_bus_freq !=3D 0) { + return; + } + + length =3D sizeof(uint64_t); + if (sysctlbyname("hw.busfrequency", &bus_freq, &length, NULL, 0)) { + return; + } + env->apic_bus_freq =3D bus_freq; +} + +static inline bool tsc_is_known(CPUX86State *env) +{ + return env->tsc_khz !=3D 0; +} + +static inline bool apic_bus_freq_is_known(CPUX86State *env) +{ + return env->apic_bus_freq !=3D 0; +} + int hvf_init_vcpu(CPUState *cpu) { =20 @@ -480,6 +523,15 @@ int hvf_init_vcpu(CPUState *cpu) hvf_state->hvf_caps =3D g_new0(struct hvf_vcpu_caps, 1); env->hvf_mmio_buf =3D g_new(char, 4096); =20 + if (x86cpu->vmware_cpuid_freq) { + init_tsc_freq(env); + init_apic_bus_freq(env); + + if (!tsc_is_known(env) || !apic_bus_freq_is_known(env)) { + error_report("vmware-cpuid-freq: feature couldn't be enabled"); + } + } + r =3D hv_vcpu_create((hv_vcpuid_t *)&cpu->hvf_fd, HV_VCPU_DEFAULT); cpu->vcpu_dirty =3D 1; assert_hvf_ok(r); @@ -597,6 +649,48 @@ static void hvf_store_events(CPUState *cpu, uint32_t i= ns_len, uint64_t idtvec_in } } =20 +static void hvf_cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t c= ount, + uint32_t *eax, uint32_t *ebx, + uint32_t *ecx, uint32_t *edx) +{ + /* + * A wrapper extends cpu_x86_cpuid with 0x40000000 and 0x40000010 leaf= s, + * leafs 0x40000001-0x4000000F are filled with zeros + * Provides vmware-cpuid-freq support to hvf + * + * Note: leaf 0x40000000 not exposes HVF, + * leaving hypervisor signature empty + */ + + if (index < 0x40000000 || index > 0x40000010 || + !tsc_is_known(env) || !apic_bus_freq_is_known(env)) { + + cpu_x86_cpuid(env, index, count, eax, ebx, ecx, edx); + return; + } + + switch (index) { + case 0x40000000: + *eax =3D 0x40000010; /* Max available cpuid leaf */ + *ebx =3D 0; /* Leave signature empty */ + *ecx =3D 0; + *edx =3D 0; + break; + case 0x40000010: + *eax =3D env->tsc_khz; + *ebx =3D env->apic_bus_freq / 1000; /* Hz to KHz */ + *ecx =3D 0; + *edx =3D 0; + break; + default: + *eax =3D 0; + *ebx =3D 0; + *ecx =3D 0; + *edx =3D 0; + break; + } +} + int hvf_vcpu_exec(CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); @@ -734,7 +828,7 @@ int hvf_vcpu_exec(CPUState *cpu) uint32_t rcx =3D (uint32_t)rreg(cpu->hvf_fd, HV_X86_RCX); uint32_t rdx =3D (uint32_t)rreg(cpu->hvf_fd, HV_X86_RDX); =20 - cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx); + hvf_cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx); =20 wreg(cpu->hvf_fd, HV_X86_RAX, rax); wreg(cpu->hvf_fd, HV_X86_RBX, rbx); --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613396079; cv=none; d=zohomail.com; s=zohoarc; b=TQQknE7yGzXvuVt3W+6IojQancZIIxRTEr4dECdvfwGJlyiSbBCuQW/v41nO72FRne7wYFx9ws8oM+yJ0FDaObW5U3FYa7zbxo+EdImF9FShY+k7I1MQeXfLAcSJH2i4de0u7LOIwKr5wTdxV60oIWnEebuUDay70d+vd9GHq3I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613396079; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EbeBCGKw5ea/26l+m+1IcrhSCzVy72F8eml9RSOy7Wk=; b=hzfQxmoZwLL3UqvNVNj/huwq+gLem2cR9jZaKJZ8Ph9EOgazfGR87E0YiUZCr7nYdC58W9sMn1B6bLjMNUomAG7WAJOesjvD5/drohktDEFw/WLdybmxcfu60PICBXQzeRZ8yZPK4ObSqHlU6X3YunQTpuUwYcxE5cJc4UV/PN4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613396078854945.9133894387234; Mon, 15 Feb 2021 05:34:38 -0800 (PST) Received: from localhost ([::1]:58204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBe1N-0004Ah-KC for importer@patchew.org; Mon, 15 Feb 2021 08:34:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdk2-0005he-Gf for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:42 -0500 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:42440) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdk1-0005ZZ-41 for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:42 -0500 Received: by mail-ed1-x52c.google.com with SMTP id z22so7923562edb.9 for ; Mon, 15 Feb 2021 05:16:40 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EbeBCGKw5ea/26l+m+1IcrhSCzVy72F8eml9RSOy7Wk=; b=TN+riZx61G3lJzbmHwKJ4pDEod4kH42KkBRxgZKSigzS76nUGJq+whyaW+eTteWcxT 9ouuC69FmBdWiPFArH8wZEddsq2GRWfDg+wbukSIGmqcmIxHH0o4id0G2So6tO4Bdi+x 0s0sf/kx+siyynr9K99ax5DFExsU/G4nUbxf+nYE8CHLtIc3HHzErOJwVIMihcnCQ3GP FVfkWE9Hiu3T7dAYqbvAtIIA5XYGlwAeS9UA+r3qRugJlPb/6c6KZeJ5PimNGGcqd1lL /VlsG7i2h5oNthDamJd2cY77A+tIf9lff3u8gkcwWIbx4mg8qpTKLLBGY7RVmDxxm+nD WnxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=EbeBCGKw5ea/26l+m+1IcrhSCzVy72F8eml9RSOy7Wk=; b=eeCtBFVOhdpfw+cEbvlwvdqQyPdT9M0Y58smz9tfWdtHB4Jxv40OnQbaWXxDBHNAQX Jw8nO46E5K4H1ef0eq+V+tmt2Q6f6oNKoRlIKor8yJv14wizan+0wuBJshKNLLkKRDML BdbkFTYZosXJ+5ON7wPewFLeHIbknqKb+f0hiPj3S8F6qW2YHpafBDeMqsZ38EqvRtxi DJKvBNWj/WHs9IaiQJ3qE9Np1U0qQrK5+XRYc/d6rh5yO/OCQmhOxnBAajofS5gPXFWO FQUrYB1t+ZmmleUcAbZjrrN028N253JpIxHm7HmO5hNH5hb9C4ktc2NES52BQLFl2jVP pmBw== X-Gm-Message-State: AOAM531Gbd4uUs2IIddPQUBRJaHDwYmqP/8RTU1bBEoZhvazD/vI6txy UjdNAF+fvdFZ+xSs31moN90iqXqsPJs= X-Google-Smtp-Source: ABdhPJw8I5tgQUh3puVR3495SyzbJGUDl6jC0A/l2B0w+a9THV/AwFqHOIIge2hIelMc+P0rGuU7Gg== X-Received: by 2002:aa7:d6c9:: with SMTP id x9mr1403639edr.150.1613394999844; Mon, 15 Feb 2021 05:16:39 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 17/19] hvf: x86: Remove unused definitions Date: Mon, 15 Feb 2021 14:16:24 +0100 Message-Id: <20210215131626.65640-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , Alexander Graf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alexander Graf The hvf i386 has a few struct and cpp definitions that are never used. Remove them. Suggested-by: Roman Bolshakov Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alexander Graf Message-Id: <20210120224444.71840-3-agraf@csgraf.de> Signed-off-by: Roman Bolshakov Signed-off-by: Paolo Bonzini --- target/i386/hvf/hvf-i386.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/target/i386/hvf/hvf-i386.h b/target/i386/hvf/hvf-i386.h index 50b914fd67..59cfca8875 100644 --- a/target/i386/hvf/hvf-i386.h +++ b/target/i386/hvf/hvf-i386.h @@ -21,21 +21,6 @@ #include "cpu.h" #include "x86.h" =20 -#define HVF_MAX_VCPU 0x10 - -extern struct hvf_state hvf_global; - -struct hvf_vm { - int id; - struct hvf_vcpu_state *vcpus[HVF_MAX_VCPU]; -}; - -struct hvf_state { - uint32_t version; - struct hvf_vm *vm; - uint64_t mem_quota; -}; - /* hvf_slot flags */ #define HVF_SLOT_LOG (1 << 0) =20 @@ -75,7 +60,6 @@ hvf_slot *hvf_find_overlap_slot(uint64_t, uint64_t); =20 /* Host specific functions */ int hvf_inject_interrupt(CPUArchState *env, int vector); -int hvf_vcpu_run(struct hvf_vcpu_state *vcpu); #endif =20 #endif --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613395891899379.01348563230613; Mon, 15 Feb 2021 05:31:31 -0800 (PST) Received: from localhost ([::1]:49566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBdyM-0000YY-Q8 for importer@patchew.org; Mon, 15 Feb 2021 08:31:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdk6-0005la-0o for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:47 -0500 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:36934) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdk4-0005bJ-JA for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:45 -0500 Received: by mail-ej1-x629.google.com with SMTP id jj19so11089683ejc.4 for ; Mon, 15 Feb 2021 05:16:44 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wOb5WqK1h7H5VvgqNLb/EnTdOMmXVIKU1eAqcJBfqNs=; b=kWFa6blpdDKXkQqlM/1dJELCLMt4tDow3aocqNQ4kJyuvYvN9SmIyEpHAGsmUiC+T8 QXeHTKh9b3BNtvLONzU0IvL5e11UAUrwlhPsYvoBNkYMrWmAShO0ZSomPXt85PWkJo3j 0bDSKSOtJivlvUjmQWhol/PB/VcsdQp3N3hEBErpTZB6Odh4k9GEBiopFV+7P63IBGq4 EgcqTRbpbasHWmlWncPBdM6TyqnDhgZW1Yt3bkXxLLLDQV0Km8A6HfBh+tp+FraLqIXV WNGR00F7dQfv6P6eIW8hQNG8diHma/6Ityxh4uRxRJf6n0y0R44y/c2PuMg0rYhQhS4V A0IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=wOb5WqK1h7H5VvgqNLb/EnTdOMmXVIKU1eAqcJBfqNs=; b=bz5ySZOXb9IYGFYHfnfhUPeQzvbxb0RVLNfnMxBPovBNZ7BLroC5am3BiSwkVNSAxl z3LPvONlOz7yY0VIJeN8Nl6bV/V09L4rShDaUKeR/A/bYHAyreeD+oSD3mgGxz2Blp50 2vkv12fD+beKmH7YfJalWVCid3s7OrsTMzwmTHDrYVvMYOfGteLyLJXNuIKVVQSRv5dJ n8ErcXEsGOyX801EkOwNACcu0JKJLPV/Hqmtpv5UeAqwn8L3TgKX5G+3sjRDyeEiat1J b2qf+SEIV88gS89BTX2p4csplYRCQF2SXy6ZzNUDfo2NnERjtl8JIOEz6ld/uI4S2B+7 k07Q== X-Gm-Message-State: AOAM531aE6vfu1l62mT9YK0xkRCheMBYnGMdUNcNm7J+ryt23RQ+XS1F BGBufYzErlRhxJPXWi+m8dSMp6HLe5M= X-Google-Smtp-Source: ABdhPJy0GcvzQOH+ShVIbwnGNXlRF/2zmOo2zT3LUi7tBTOvBuHlzflQLDNtg3vwQNN5BWXjwNuBZw== X-Received: by 2002:a17:907:3e06:: with SMTP id hp6mr15523255ejc.254.1613395000562; Mon, 15 Feb 2021 05:16:40 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 18/19] target/i386/hvf: add rdmsr 35H MSR_CORE_THREAD_COUNT Date: Mon, 15 Feb 2021 14:16:25 +0100 Message-Id: <20210215131626.65640-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x629.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , Vladislav Yaroshchuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vladislav Yaroshchuk Some guests (ex. Darwin-XNU) can attemp to read this MSR to retrieve and validate CPU topology comparing it to ACPI MADT content MSR description from Intel Manual: 35H: MSR_CORE_THREAD_COUNT: Configured State of Enabled Processor Core Count and Logical Processor Count Bits 15:0 THREAD_COUNT The number of logical processors that are currently enabled in the physical package Bits 31:16 Core_COUNT The number of processor cores that are currently enabled in the physical package Bits 63:32 Reserved Signed-off-by: Vladislav Yaroshchuk Message-Id: <20210113205323.33310-1-yaroshchuk2000@gmail.com> [RB: reordered MSR definition and dropped u suffix from shift offset] Signed-off-by: Roman Bolshakov Signed-off-by: Paolo Bonzini --- target/i386/cpu.h | 1 + target/i386/hvf/x86_emu.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 8d599bb5b8..82c1ac00ef 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -368,6 +368,7 @@ typedef enum X86Seg { =20 #define MSR_IA32_SMBASE 0x9e #define MSR_SMI_COUNT 0x34 +#define MSR_CORE_THREAD_COUNT 0x35 #define MSR_MTRRcap 0xfe #define MSR_MTRRcap_VCNT 8 #define MSR_MTRRcap_FIXRANGE_SUPPORT (1 << 8) diff --git a/target/i386/hvf/x86_emu.c b/target/i386/hvf/x86_emu.c index da570e352b..e52c39ddb1 100644 --- a/target/i386/hvf/x86_emu.c +++ b/target/i386/hvf/x86_emu.c @@ -668,6 +668,7 @@ void simulate_rdmsr(struct CPUState *cpu) { X86CPU *x86_cpu =3D X86_CPU(cpu); CPUX86State *env =3D &x86_cpu->env; + CPUState *cs =3D env_cpu(env); uint32_t msr =3D ECX(env); uint64_t val =3D 0; =20 @@ -745,6 +746,10 @@ void simulate_rdmsr(struct CPUState *cpu) case MSR_MTRRdefType: val =3D env->mtrr_deftype; break; + case MSR_CORE_THREAD_COUNT: + val =3D cs->nr_threads * cs->nr_cores; /* thread count, bits 15..0= */ + val |=3D ((uint32_t)cs->nr_cores << 16); /* core count, bits 31..1= 6 */ + break; default: /* fprintf(stderr, "%s: unknown msr 0x%x\n", __func__, msr); */ val =3D 0; --=20 2.29.2 From nobody Thu Mar 28 19:47:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613396223; cv=none; d=zohomail.com; s=zohoarc; b=JrvLOOcXaSmFGQy/rbMDpI7Tg9ZRUk92IHTe7MRyc0juyxYRoX+RZbdrjoRPCYGNVkgZt8YgGWYpMapJGBMQcGYFTdEhGiXRKfh/AZL6UHYJx8Yqt8g9mm/S4NKEkwCI6UfOvSFbtiUWWJrS5frl50Ar1NW9U4qz98JB+fmPWiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613396223; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mMLsMq3LdsiwYZYkAKBGxeQQfZ5vW9qSwDuSz8zkItM=; b=XhLZ3PxsJhgUqBvQPFidxUbBagCpV4a11Os4FnBCburrERx8oa9HBozbI8GsJbkY2+L0CLzbmELT9N7YE1WQ2wrPBI3BGNB4EQWfLBENp3+T9uoGi6PYv3W/eXkdclmifaLYVi9aLQ/z0S5IjRzDrzT5O/ZVmm+ifFMNfxEvvQ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1613396222749989.4937891649342; Mon, 15 Feb 2021 05:37:02 -0800 (PST) Received: from localhost ([::1]:37100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBe3h-00076y-Ls for importer@patchew.org; Mon, 15 Feb 2021 08:37:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBdk6-0005lb-MG for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:47 -0500 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:45706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBdk5-0005bQ-C3 for qemu-devel@nongnu.org; Mon, 15 Feb 2021 08:16:46 -0500 Received: by mail-ed1-x531.google.com with SMTP id y10so3131341edt.12 for ; Mon, 15 Feb 2021 05:16:44 -0800 (PST) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id o4sm9950184edw.78.2021.02.15.05.16.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 05:16:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mMLsMq3LdsiwYZYkAKBGxeQQfZ5vW9qSwDuSz8zkItM=; b=SR30BVsDLdqYXhHEc1OK45mIcM5fH3W7aj/7Ql3+ROySTmAMcqxudflR5XBqrEjgQu g1oCvDlCAvC1NBvWaX1Dwk8kAkD/h8Jco9GKW/HNqoRF+dizqvfGnDiVEaaHRrfr/Wwu UHwuLvewXMKPLZvtKaygEbn517c6SMH+Bb2pq9b1epbvR0NXKmbj/9yFvlmOHZ5+/Pq5 xQdqVdRBc6iJp11qzuwogP+6uD+Cobw/hHdlMSThZ9Q2edkXXFYgk+rlllk9PJucfFrV ppC9G0E1G2kjL+znkJIwkIt0CIQKH9NH9PHVb7M4pI1d4sQjV4BiVIDHPemxXWu6RzST oiGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=mMLsMq3LdsiwYZYkAKBGxeQQfZ5vW9qSwDuSz8zkItM=; b=GnhvNe4vQNdxiaZsbzQ1B7v0oyT7krAPQDq4y6cskQ5aP77+UdFgfcalX/WTDKUw2s jL7Tq4o50ctddnLau6TPOQC7E4L0uFGnfvS/Y77L6wK2MZn38fEUbNeFRu7Tvfgu7Cb9 W5U1zpof2ARjZoMGFkIcOSINhcj4wBDmIlQF1WgAwDGDxXyyNi2D3gCLoh7N5oZ8YQd+ aWWJ+RiVP51RammZGuiBhH8kCquSZzkQyK11cZrho7wJCB4AyA8e75k9YIAPQZuMFYI8 ij7io+fJHeto+rvhv2kgJX6Difcc3z9yAIN3QbLyjZjg9bwRYFvx4DzJ3rSSRFTT7z5c 1s+w== X-Gm-Message-State: AOAM532kFJbYHLXR5MC9+Igo0cr6WjwSuPZAMsw57ajgRALqAf3080Wz XR6iHYMv/y1FTMq2nl1flntYUh6qnKw= X-Google-Smtp-Source: ABdhPJy8bMncpTLO0DZluRdd+3iAAqvmDHd5LVTpYh6ZyrYwmiEtX1Ov+wRc3n7ohiGlUJUIW0dOsA== X-Received: by 2002:a05:6402:17aa:: with SMTP id j10mr15805587edy.184.1613395003931; Mon, 15 Feb 2021 05:16:43 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 19/19] hvf: Fetch cr4 before evaluating CPUID(1) Date: Mon, 15 Feb 2021 14:16:26 +0100 Message-Id: <20210215131626.65640-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210215131626.65640-1-pbonzini@redhat.com> References: <20210215131626.65640-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Asad Ali , Alexander Graf , Roman Bolshakov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Alexander Graf The CPUID function 1 has a bit called OSXSAVE which tells user space the status of the CR4.OSXSAVE bit. Our generic CPUID function injects that bit based on the status of CR4. With Hypervisor.framework, we do not synchronize full CPU state often enough for this function to see the CR4 update before guest user space asks for it. To be on the save side, let's just always synchronize it when we receive a CPUID(1) request. That way we can set the bit with real confidence. Reported-by: Asad Ali Signed-off-by: Alexander Graf Message-Id: <20210123004129.6364-1-agraf@csgraf.de> [RB: resolved conflict with another CPUID change] Signed-off-by: Roman Bolshakov Signed-off-by: Paolo Bonzini --- target/i386/hvf/hvf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 10a06c3c79..15f14ac69e 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -828,6 +828,10 @@ int hvf_vcpu_exec(CPUState *cpu) uint32_t rcx =3D (uint32_t)rreg(cpu->hvf_fd, HV_X86_RCX); uint32_t rdx =3D (uint32_t)rreg(cpu->hvf_fd, HV_X86_RDX); =20 + if (rax =3D=3D 1) { + /* CPUID1.ecx.OSXSAVE needs to know CR4 */ + env->cr[4] =3D rvmcs(cpu->hvf_fd, VMCS_GUEST_CR4); + } hvf_cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx); =20 wreg(cpu->hvf_fd, HV_X86_RAX, rax); --=20 2.29.2