From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571167; cv=none; d=zohomail.com; s=zohoarc; b=MOqnIi4huTL+ANK2fBQiJZAznEH3RgX0tCRdprGRE4dCGRobvL5Z6NIwL8/YUvcaRPw8PkfZGvQ16KJp2Rj0W4IhV/VwDc0jCaUVK2tFEDqCIyz5lLBYzX5pQQdOFPYy3iLWOUmKBXJUOvO+3pEmfe/shjeZDXTDOOGiI4vfoJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571167; 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=kbBngyXu7MaV0eNzrz81Hu02B5JHNY79nLgXCQoz3a4=; b=B5fPlkO/D9mWbzaXy5ToR8UVql1EugPEzWLf5iseJWshDf+Ulml/nnLCeJDhuvIO+DT/5QizouhqQEgguHgnXKre4z5EC7g0M5ZQ8MavaGz1qG8m+WH+eHz7Rfsgl4s9kueS2NtGjFTIpK2o5Z4Ax9Y/Qyq1hZEfU4+Gxz8lANs= 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+importer2=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 1622571167372856.8499998133958; Tue, 1 Jun 2021 11:12:47 -0700 (PDT) Received: from localhost ([::1]:38962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8sg-0004iP-8W for importer2@patchew.org; Tue, 01 Jun 2021 14:12:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qM-0001rT-Ba for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qJ-0005Va-L6 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-WXVWTuVEMSOWCsB3mzH30g-1; Tue, 01 Jun 2021 14:10:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 388558015C6; Tue, 1 Jun 2021 18:10:16 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE3145C1BB; Tue, 1 Jun 2021 18:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571019; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kbBngyXu7MaV0eNzrz81Hu02B5JHNY79nLgXCQoz3a4=; b=R3lZKoS1kX0r+VnMpJ4anEB27Pa1uUiKb8iLAa3fivXEUzi1DPUDQCmAX43LSRh5Ew3KgE EuEpwYRi9dFiU74Yka2sZ7s/jURzEi/poMpXphjpcqMO2JdE0a9KvjM9p4zSVfUPKpzL8y MYRG/x01L2vPT+rWKU8/x2zuwfVI7/o= X-MC-Unique: WXVWTuVEMSOWCsB3mzH30g-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 01/24] target/i386: Add CPU model versions supporting 'xsaves' Date: Tue, 1 Jun 2021 14:09:51 -0400 Message-Id: <20210601181014.2568861-2-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Hyper-V 2016 refuses to boot on Skylake+ CPU models because they lack 'xsaves'/'vmx-xsaves' features and this diverges from real hardware. The same issue emerges with AMD "EPYC" CPU model prior to version 3 which got 'xsaves' added. EPYC-Rome/EPYC-Milan CPU models have 'xsaves' enabled from the very beginning so the comment blaming KVM to explain why other CPUs lack 'xsaves' is likely outdated. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210412073952.860944-1-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 150 +++++++++++++++++++++++++++++----------------- 1 file changed, 94 insertions(+), 56 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b4349119f8b..72c521559f0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2802,12 +2802,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_ERMS | CPUID_7_0_EBX_INVPCI= D | CPUID_7_0_EBX_RTM | CPUID_7_0_EBX_RDSEED | CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is added in version 4 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -2883,6 +2878,15 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, + { + .version =3D 4, + .note =3D "IBRS, XSAVES, no TSX", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ } + } + }, { /* end of list */ } } }, @@ -2922,12 +2926,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_EBX_AVX512VL | CPUID_7_0_EBX_CLFLUSHOPT, .features[FEAT_7_0_ECX] =3D CPUID_7_0_ECX_PKU, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is added in version 5 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -3015,6 +3014,15 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } } }, + { + .version =3D 5, + .note =3D "IBRS, XSAVES, EPT switching, no TSX", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ } + } + }, { /* end of list */ } } }, @@ -3057,12 +3065,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_ECX_AVX512VNNI, .features[FEAT_7_0_EDX] =3D CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_SPEC_CTRL_SSBD, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is added in version 5 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -3146,6 +3149,14 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } }, }, + { .version =3D 5, + .note =3D "ARCH_CAPABILITIES, EPT switching, XSAVES, no TSX", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ } + }, + }, { /* end of list */ } } }, @@ -3195,13 +3206,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { MSR_ARCH_CAP_PSCHANGE_MC_NO | MSR_ARCH_CAP_TAA_NO, .features[FEAT_7_1_EAX] =3D CPUID_7_1_EAX_AVX_VNNI | CPUID_7_1_EAX_AVX512_BF16, - /* - * Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is added in version 2 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -3257,6 +3262,18 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .features[FEAT_VMX_VMFUNC] =3D MSR_VMX_VMFUNC_EPT_SWITCHING, .xlevel =3D 0x80000008, .model_id =3D "Intel Xeon Processor (Cooperlake)", + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { .version =3D 2, + .note =3D "XSAVES", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ } + }, + }, + { /* end of list */ } + } }, { .name =3D "Icelake-Client", @@ -3299,12 +3316,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_ECX_AVX512_VPOPCNTDQ, .features[FEAT_7_0_EDX] =3D CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_SPEC_CTRL_SSBD, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is added in version 3 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -3372,6 +3384,15 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } }, }, + { + .version =3D 3, + .note =3D "no TSX, XSAVES, deprecated", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ } + }, + }, { /* end of list */ } }, .deprecation_note =3D "use Icelake-Server instead" @@ -3420,12 +3441,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_ECX_AVX512_VPOPCNTDQ | CPUID_7_0_ECX_LA57, .features[FEAT_7_0_EDX] =3D CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_SPEC_CTRL_SSBD, - /* Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is added in version 5 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -3518,6 +3534,15 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ } }, }, + { + .version =3D 5, + .note =3D "XSAVES", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ } + }, + }, { /* end of list */ } } }, @@ -3552,13 +3577,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .features[FEAT_7_0_EDX] =3D CPUID_7_0_EDX_SPEC_CTRL | CPUID_7_0_EDX_ARCH_CAPABILITIES | CPUID_7_0_EDX_SPEC_CTRL_SSBD, - /* - * Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is added in version 3 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV= 1, .features[FEAT_6_EAX] =3D @@ -3625,6 +3644,15 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ }, }, }, + { + .version =3D 3, + .note =3D "XSAVES, no MPX, no MONITOR", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ }, + }, + }, { /* end of list */ }, }, }, @@ -3683,13 +3711,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_EDX_CORE_CAPABILITY, .features[FEAT_CORE_CAPABILITY] =3D MSR_CORE_CAP_SPLIT_LOCK_DETECT, - /* - * Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component, - * and the only one defined in Skylake (processor tracing) - * probably will block migration anyway. - */ + /* XSAVES is is added in version 3 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -3754,6 +3776,15 @@ static X86CPUDefinition builtin_x86_defs[] =3D { { /* end of list */ }, }, }, + { + .version =3D 3, + .note =3D "XSAVES, no MPX", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { "vmx-xsaves", "on" }, + { /* end of list */ }, + }, + }, { /* end of list */ }, }, }, @@ -4035,11 +4066,7 @@ static X86CPUDefinition builtin_x86_defs[] =3D { CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AV= X2 | CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED= | CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSH= OPT, - /* - * Missing: XSAVES (not supported by some Linux versions, - * including v4.1 to v4.12). - * KVM doesn't yet expose any XSAVES state save component. - */ + /* XSAVES is added in version 2 */ .features[FEAT_XSAVE] =3D CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC | CPUID_XSAVE_XGETBV1, @@ -4050,6 +4077,17 @@ static X86CPUDefinition builtin_x86_defs[] =3D { .xlevel =3D 0x8000001E, .model_id =3D "Hygon Dhyana Processor", .cache_info =3D &epyc_cache_info, + .versions =3D (X86CPUVersionDefinition[]) { + { .version =3D 1 }, + { .version =3D 2, + .note =3D "XSAVES", + .props =3D (PropValue[]) { + { "xsaves", "on" }, + { /* end of list */ } + }, + }, + { /* end of list */ } + } }, { .name =3D "EPYC-Rome", --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571287; cv=none; d=zohomail.com; s=zohoarc; b=j9j0CGMBo3WTG8p8SRybu/EoUAg9dEcjrG7IWVuGpK3B1XrE53Lvbl5g/LvHoX3+ehV/VFDa994/qa4dcDLWfl+WkFg14Df4z7hMicVU9rfYuDqnV3o1w3QHR60x2B6Zo+Tkj5xxZ/Y/5zIdkOixfY4FM6kBIp9TSWY04FCTb5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571287; 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=2rgm1qMnZMkbI6kzv/3Vt8T+51l3W1TaUSwge/o9xlQ=; b=MjAQxE08+SudhYIsP1POcPD4fPRYmgBeOYzxZsH+4tvJIW50alkQbMIZQW7h23jW4bcRroexJudGJcPeEMFIGFMzoOEtWGpPRCzxWq4PBiyNt8o9aDrgnh7rzCBs9SOuKHyUrK2fktftBOuwL9XVVcHRDnO3jweyS5EPM75dXXk= 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+importer2=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 1622571287486328.9586507956968; Tue, 1 Jun 2021 11:14:47 -0700 (PDT) Received: from localhost ([::1]:47838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8uc-0002Cl-G0 for importer2@patchew.org; Tue, 01 Jun 2021 14:14:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qM-0001sx-OC for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qK-0005X4-Tx for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-8J8ZK1RCPoS3NWJvAA2a_g-1; Tue, 01 Jun 2021 14:10:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E689A107ACE3; Tue, 1 Jun 2021 18:10:16 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id B84B01346F; Tue, 1 Jun 2021 18:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2rgm1qMnZMkbI6kzv/3Vt8T+51l3W1TaUSwge/o9xlQ=; b=dEWUXwYjVBb8dBOxEyX0sdDOYExoV2KBrCbc/hwD5bYimxlxL2c4MmZR8iw88OeB7jL6hh yI6GajmIDVoDBTuTn1Rs1xI5srMrJYgoi65P64580Vyu/KmeqNMtVQegSUstsBjFVzetHV nkvT6DSNuI3usTG6I2G97zjMB7cqrnQ= X-MC-Unique: 8J8ZK1RCPoS3NWJvAA2a_g-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 02/24] i386: Document when features can be added to kvm_default_props Date: Tue, 1 Jun 2021 14:09:52 -0400 Message-Id: <20210601181014.2568861-3-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" It's very easy to mistakenly extend kvm_default_props to include features that require a kernel version that's too recent. Add a comment warning about that, pointing to the documentation file where the minimum kernel version for KVM is documented. Signed-off-by: Eduardo Habkost Acked-by: Paolo Bonzini Message-Id: <20200925211021.4158567-1-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm-cpu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/i386/kvm/kvm-cpu.c b/target/i386/kvm/kvm-cpu.c index c660ad42931..5235bce8dc0 100644 --- a/target/i386/kvm/kvm-cpu.c +++ b/target/i386/kvm/kvm-cpu.c @@ -47,6 +47,11 @@ static bool kvm_cpu_realizefn(CPUState *cs, Error **errp) /* * KVM-specific features that are automatically added/removed * from all CPU models when KVM is enabled. + * + * NOTE: features can be enabled by default only if they were + * already available in the oldest kernel version supported + * by the KVM accelerator (see "OS requirements" section at + * docs/system/target-i386.rst) */ static PropValue kvm_default_props[] =3D { { "kvmclock", "on" }, --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571167; cv=none; d=zohomail.com; s=zohoarc; b=ldIw2U/mPtjNTz1SeYQEaPI0YINT1JEiW8q6ezRKSFwbA7PCVnPTspzRpbZ3RHnTNG8+rHM4ZpJyo1s610hMM48B22vwnrmZ+5w2dI6RWkhq4ibaTBnfYUiVcuGFyP+8bcBh/PfHw9zPUHVT8ab/0k3mQjjoOkcE7397WQSppnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571167; 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=oozYPSulGnW/E31KmX1jqZ2y8WquFl+zrsXkk67JQ8w=; b=fMaqQZbmRGyHD8GIT9s4SdoYv5uHoqnADIqFOLvYuxtO/d55gkZ4cgSJ+miHWSN3JOVtyP/HacOg6YK1aQuM6HTG774RXm/Fv+Lm0EXhcaOnajClAS/INMG7RxLM3ls0k9SKJsFDB8WcNNKde4oHitozr4MS9PSgmSjWQ+Jqc98= 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+importer2=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 1622571167209938.0862802217935; Tue, 1 Jun 2021 11:12:47 -0700 (PDT) Received: from localhost ([::1]:38944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8sg-0004ho-3M for importer2@patchew.org; Tue, 01 Jun 2021 14:12:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qM-0001tR-VZ for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qL-0005Xy-DO for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-537-2XfMSN0VPd-1vN7knpvtBg-1; Tue, 01 Jun 2021 14:10:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B8DE779EC3; Tue, 1 Jun 2021 18:10:17 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88E915D9D0; Tue, 1 Jun 2021 18:10:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571020; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oozYPSulGnW/E31KmX1jqZ2y8WquFl+zrsXkk67JQ8w=; b=T8DvRuWap0mFTDGBbxtRTPN9zim0PDmP0UcvY0Rij2S16DZD/JOHfefOzhWtRNhoRF1OPY QV0ZXNQ7MyZbZm6nFY5yPP3S9ovTL+hZlKrq6buPN2zlIU7qnqW5LSF2KDqdcxJNvGDg1E aMoQG2ZRCo2uwtrZfX3W8wOrpNmUPGA= X-MC-Unique: 2XfMSN0VPd-1vN7knpvtBg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 03/24] target/i386/cpu: Constify CPUCaches Date: Tue, 1 Jun 2021 14:09:53 -0400 Message-Id: <20210601181014.2568861-4-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210503173524.833052-2-philmd@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 72c521559f0..065d40fd3e0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1576,7 +1576,7 @@ typedef struct X86CPUDefinition { int stepping; FeatureWordArray features; const char *model_id; - CPUCaches *cache_info; + const CPUCaches *const cache_info; /* * Definitions for alternative versions of CPU model. * List is terminated by item with version =3D=3D 0. @@ -1619,7 +1619,7 @@ static const X86CPUVersionDefinition *x86_cpu_def_get= _versions(X86CPUDefinition return def->versions ?: default_version_list; } =20 -static CPUCaches epyc_cache_info =3D { +static const CPUCaches epyc_cache_info =3D { .l1d_cache =3D &(CPUCacheInfo) { .type =3D DATA_CACHE, .level =3D 1, @@ -1669,7 +1669,7 @@ static CPUCaches epyc_cache_info =3D { }, }; =20 -static CPUCaches epyc_rome_cache_info =3D { +static const CPUCaches epyc_rome_cache_info =3D { .l1d_cache =3D &(CPUCacheInfo) { .type =3D DATA_CACHE, .level =3D 1, @@ -1719,7 +1719,7 @@ static CPUCaches epyc_rome_cache_info =3D { }, }; =20 -static CPUCaches epyc_milan_cache_info =3D { +static const CPUCaches epyc_milan_cache_info =3D { .l1d_cache =3D &(CPUCacheInfo) { .type =3D DATA_CACHE, .level =3D 1, --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571395; cv=none; d=zohomail.com; s=zohoarc; b=e6rXSNRcBr6Y4FQxIHvnYH94KAhYgHSC+4meaP9GxpuRIcYMkcffcWtkSeYS8wsdh9dsGoVwySCdI1+cYevEQdEyGciuwGD22l6x5Z+TYGocVMCgjmAar+qvbQ3Qy8qt1Vejll6zeGtKOqUtCvoqOCVhpgW2o5dSq9asAWeDNCg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571395; 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=qgKA1qVKIUY9RsaKnKk+R88Xea2tiVqPTmJYKjufpGg=; b=V/msiXYwhJBFg+T0s1UYoZiRqqrAO1PyutOxtp7aVxYHK5b/8epcr5A91DRphKI6pnEP97JASKDr0sByWk5264a0SPYtG36QU37EOMx/6i05rBKcWT7jOQjk1Vw2CdQo9l8w/7H2OZZQxKweN9cjGCiu+LhTlZ20zv5lXgy/yfo= 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+importer2=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 1622571395294532.9239578250883; Tue, 1 Jun 2021 11:16:35 -0700 (PDT) Received: from localhost ([::1]:56294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8wM-0007pH-Az for importer2@patchew.org; Tue, 01 Jun 2021 14:16:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qN-0001ui-GH for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qL-0005Z7-QG for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-hlY8KXMSN2KWSOnRz_QI1Q-1; Tue, 01 Jun 2021 14:10:19 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 817D91009460; Tue, 1 Jun 2021 18:10:18 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C21B60CC5; Tue, 1 Jun 2021 18:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571021; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qgKA1qVKIUY9RsaKnKk+R88Xea2tiVqPTmJYKjufpGg=; b=CEEVaa4mhFt7HEU6lZFb1EYA/okdhjvRUXURg3TcKRzqV9ov9ikQd1nUx2Y3MgBRjuRFTX 32fChA/YMubWLSfkNSr8hZy+WoCqUVl6Dq84CP7yocHWzlS+FcrcVGfh3Af4Pkvgiq/a3s sDwZASsXBBSPZb+wSIBrCkHJ3NDqY/w= X-MC-Unique: hlY8KXMSN2KWSOnRz_QI1Q-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 04/24] target/i386/cpu: Constify X86CPUDefinition Date: Tue, 1 Jun 2021 14:09:54 -0400 Message-Id: <20210601181014.2568861-5-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210503173524.833052-3-philmd@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 065d40fd3e0..ff92d924ad9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1589,7 +1589,7 @@ typedef struct X86CPUDefinition { /* Reference to a specific CPU model version */ struct X86CPUModel { /* Base CPU definition */ - X86CPUDefinition *cpudef; + const X86CPUDefinition *cpudef; /* CPU model version */ X86CPUVersion version; const char *note; @@ -1601,14 +1601,15 @@ struct X86CPUModel { }; =20 /* Get full model name for CPU version */ -static char *x86_cpu_versioned_model_name(X86CPUDefinition *cpudef, +static char *x86_cpu_versioned_model_name(const X86CPUDefinition *cpudef, X86CPUVersion version) { assert(version > 0); return g_strdup_printf("%s-v%d", cpudef->name, (int)version); } =20 -static const X86CPUVersionDefinition *x86_cpu_def_get_versions(X86CPUDefin= ition *def) +static const X86CPUVersionDefinition * +x86_cpu_def_get_versions(const X86CPUDefinition *def) { /* When X86CPUDefinition::versions is NULL, we register only v1 */ static const X86CPUVersionDefinition default_version_list[] =3D { @@ -1797,7 +1798,7 @@ static const CPUCaches epyc_milan_cache_info =3D { * PT in VMX operation */ =20 -static X86CPUDefinition builtin_x86_defs[] =3D { +static const X86CPUDefinition builtin_x86_defs[] =3D { { .name =3D "qemu64", .level =3D 0xd, @@ -5061,7 +5062,7 @@ static void x86_cpu_apply_version_props(X86CPU *cpu, = X86CPUModel *model) */ static void x86_cpu_load_model(X86CPU *cpu, X86CPUModel *model) { - X86CPUDefinition *def =3D model->cpudef; + const X86CPUDefinition *def =3D model->cpudef; CPUX86State *env =3D &cpu->env; FeatureWord w; =20 @@ -5148,7 +5149,7 @@ static void x86_register_cpu_model_type(const char *n= ame, X86CPUModel *model) type_register(&ti); } =20 -static void x86_register_cpudef_types(X86CPUDefinition *def) +static void x86_register_cpudef_types(const X86CPUDefinition *def) { X86CPUModel *m; const X86CPUVersionDefinition *vdef; --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571285; cv=none; d=zohomail.com; s=zohoarc; b=HECOqOFj24FJQhgdemVxW0+cjqh6F0/MJfq+ipa7vmHqQVmIqRAFK/3WjsGkP5cUEiEMH00FslcTzWKmG6HVzAB2A7W5jGLCo6kMleDjbgbs9CeUkpMIoz/kYQXlnVxElD9XUeC+Mk9T2sW0NzD0LUvFEzEE8L21HPON2HLTdIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571285; 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=R57ND6+vzYJ+A27EAuFK8s6uaKLDP/UdLrP951bUWvg=; b=L5YBF6mlbdnrcmHjz6X0aa98qR4QuIpIMhYcUKDirhB6H2q8HT/cEoYKo6Hr+0/RWN9k/ChUhguDQvPkBCw6Nlyh7nDVU+FPUmivRQDyuw6KYgW9ThzlEn+wkNniN/lmdVxfVywPPo8cFvkwfsVhEbpCmXFiCTobHx3kSqXxBGg= 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+importer2=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 1622571285626443.9419112464317; Tue, 1 Jun 2021 11:14:45 -0700 (PDT) Received: from localhost ([::1]:47634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8ua-00023H-Fo for importer2@patchew.org; Tue, 01 Jun 2021 14:14:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qO-0001yc-VZ for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23836) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qN-0005az-7R for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-328-Bx-2YlnGMWG4-61_QXJLAA-1; Tue, 01 Jun 2021 14:10:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 457A28015F5; Tue, 1 Jun 2021 18:10:19 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 108ED2BFED; Tue, 1 Jun 2021 18:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571022; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R57ND6+vzYJ+A27EAuFK8s6uaKLDP/UdLrP951bUWvg=; b=alMD6zVaSXs4jy4IeuT1qgJBtgxe+PKBy5h/KUZ7j3xXl+yUSSXXA4TogKsjTOwRuNI6R8 KLGtHeXbtnaDSX2EwJnUgrHwqE9yePelgpwuHfVeO9X8ElA6JRwiXX6hJZHMrtBA1se5wY CACcVwu3vkLwLGJ2yLcUOUW9ggkMvaA= X-MC-Unique: Bx-2YlnGMWG4-61_QXJLAA-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 05/24] i386/cpu_dump: support AVX512 ZMM regs dump Date: Tue, 1 Jun 2021 14:09:55 -0400 Message-Id: <20210601181014.2568861-6-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Richard Henderson , Eduardo Habkost , Robert Hoo Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Robert Hoo Since commit fa4518741e (target-i386: Rename struct XMMReg to ZMMReg), CPUX86State.xmm_regs[] has already been extended to 512bit to support AVX512. Also, other qemu level supports for AVX512 registers are there for years. But in x86_cpu_dump_state(), still only dump XMM registers no matter YMM/ZMM is enabled. This patch is to complement this, let it dump XMM/YMM/ZMM accordingly. Signed-off-by: Robert Hoo Reviewed-by: Richard Henderson Message-Id: <1618986232-73826-1-git-send-email-robert.hu@linux.intel.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu-dump.c | 63 ++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/target/i386/cpu-dump.c b/target/i386/cpu-dump.c index aac21f1f60b..02b635a52cf 100644 --- a/target/i386/cpu-dump.c +++ b/target/i386/cpu-dump.c @@ -478,6 +478,11 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fla= gs) qemu_fprintf(f, "EFER=3D%016" PRIx64 "\n", env->efer); if (flags & CPU_DUMP_FPU) { int fptag; + const uint64_t avx512_mask =3D XSTATE_OPMASK_MASK | \ + XSTATE_ZMM_Hi256_MASK | \ + XSTATE_Hi16_ZMM_MASK | \ + XSTATE_YMM_MASK | XSTATE_SSE_MASK, + avx_mask =3D XSTATE_YMM_MASK | XSTATE_SSE_MASK; fptag =3D 0; for(i =3D 0; i < 8; i++) { fptag |=3D ((!env->fptags[i]) << i); @@ -499,21 +504,49 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags) else qemu_fprintf(f, " "); } - if (env->hflags & HF_CS64_MASK) - nb =3D 16; - else - nb =3D 8; - for(i=3D0;ixmm_regs[i].ZMM_L(3), - env->xmm_regs[i].ZMM_L(2), - env->xmm_regs[i].ZMM_L(1), - env->xmm_regs[i].ZMM_L(0)); - if ((i & 1) =3D=3D 1) - qemu_fprintf(f, "\n"); - else - qemu_fprintf(f, " "); + + if ((env->xcr0 & avx512_mask) =3D=3D avx512_mask) { + /* XSAVE enabled AVX512 */ + for (i =3D 0; i < NB_OPMASK_REGS; i++) { + qemu_fprintf(f, "Opmask%02d=3D%016"PRIx64"%s", i, + env->opmask_regs[i], ((i & 3) =3D=3D 3) ? "\n= " : " "); + } + + nb =3D (env->hflags & HF_CS64_MASK) ? 32 : 8; + for (i =3D 0; i < nb; i++) { + qemu_fprintf(f, "ZMM%02d=3D%016"PRIx64" %016"PRIx64" %016"= PRIx64 + " %016"PRIx64" %016"PRIx64" %016"PRIx64 + " %016"PRIx64" %016"PRIx64"\n", + i, + env->xmm_regs[i].ZMM_Q(7), + env->xmm_regs[i].ZMM_Q(6), + env->xmm_regs[i].ZMM_Q(5), + env->xmm_regs[i].ZMM_Q(4), + env->xmm_regs[i].ZMM_Q(3), + env->xmm_regs[i].ZMM_Q(2), + env->xmm_regs[i].ZMM_Q(1), + env->xmm_regs[i].ZMM_Q(0)); + } + } else if ((env->xcr0 & avx_mask) =3D=3D avx_mask) { + /* XSAVE enabled AVX */ + nb =3D env->hflags & HF_CS64_MASK ? 16 : 8; + for (i =3D 0; i < nb; i++) { + qemu_fprintf(f, "YMM%02d=3D%016"PRIx64" %016"PRIx64" %016"= PRIx64 + " %016"PRIx64"\n", i, + env->xmm_regs[i].ZMM_Q(3), + env->xmm_regs[i].ZMM_Q(2), + env->xmm_regs[i].ZMM_Q(1), + env->xmm_regs[i].ZMM_Q(0)); + } + } else { /* SSE and below cases */ + nb =3D env->hflags & HF_CS64_MASK ? 16 : 8; + for (i =3D 0; i < nb; i++) { + qemu_fprintf(f, "XMM%02d=3D%016"PRIx64" %016"PRIx64"%s", + i, + env->xmm_regs[i].ZMM_Q(1), + env->xmm_regs[i].ZMM_Q(0), + (i & 1) ? "\n" : " "); + } } } if (flags & CPU_DUMP_CODE) { --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571382; cv=none; d=zohomail.com; s=zohoarc; b=c6pfz10GpETJ2rmGVsEwWR90jLTLeN8Vg2IRCefnPLxxarHF55iJ3qNr25/QxMCAamDTAALc/QNRNpD2sDjKtpB9f8+te8Xl1NKOi0+5t9vqwbKFclmioiI4vBtS3NmI5U482aNXzKg7i27ONiYwHg9/D7yZhs/FJOGFIrn7h9o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571382; 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=/8o5REEym/FIQDvXvPd7+wwuWGDEnF4d7W42t5/ybzw=; b=BbkZcIQGKATm5Nxp7HO57fPGdMd7+HEnFyT5886y6dNufzphEAK23hFV967XHW5PM54O9Tj8/yHl1lbKAl1SE2z+pyg8ZHAtuafncmKBG1G+AF5x6TpFNwQHOiX7BTjc2xhWrqNYDbQYOXlB7/isufMxjMtQXxUnfItxJ2OsB9Q= 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+importer2=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 1622571382983850.8625006278603; Tue, 1 Jun 2021 11:16:22 -0700 (PDT) Received: from localhost ([::1]:55046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8w9-00070q-Q0 for importer2@patchew.org; Tue, 01 Jun 2021 14:16:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qU-00026V-20 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qP-0005cb-6b for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-394-vetHwHL2MFK6ZqbcKEfNhA-1; Tue, 01 Jun 2021 14:10:21 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 287CE79EC5; Tue, 1 Jun 2021 18:10:20 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id E179510074FC; Tue, 1 Jun 2021 18:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/8o5REEym/FIQDvXvPd7+wwuWGDEnF4d7W42t5/ybzw=; b=AlhL+BRO9fD+IaY22qQwdGKasXaVLHlDSJ+DPAiTJlKKssSDcaG91BCZHCXAjRwIAuSAQM OWviYZRZmCDUsr/een05kXKjARVVBm3WXLOK0zY7/oXMrnuK/DNKAO4J3wLnBv1eJbQ35J n9JbCCWnfMFf0ZmQB1/mH/nl7dyrwjI= X-MC-Unique: vetHwHL2MFK6ZqbcKEfNhA-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 06/24] i386: use better matching family/model/stepping for 'qemu64' CPU Date: Tue, 1 Jun 2021 14:09:56 -0400 Message-Id: <20210601181014.2568861-7-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Daniel P. Berrang=C3=A9 The 'qemu64' CPUID currently reports a family/model/stepping that approximately corresponds to an AMD K7 vintage architecture. The K7 series predates the introduction of 64-bit support by AMD in the K8 series. This has been reported to lead to LLVM complaints about generating 64-bit code for a 32-bit CPU target LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it! It appears LLVM looks at the family/model/stepping, despite qemu64 reporting it is 64-bit capable. This patch changes 'qemu64' to report a CPUID with the family, model and stepping taken from a AMD Athlon(tm) 64 X2 Dual Core Processor 4000+ which is one of the first 64-bit AMD CPUs. Closes https://gitlab.com/qemu-project/qemu/-/issues/191 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Eduardo Habkost Message-Id: <20210507133650.645526-2-berrange@redhat.com> Signed-off-by: Eduardo Habkost --- hw/i386/pc.c | 6 +++++- target/i386/cpu.c | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 8cfaf216e7b..c6d8d0d84d9 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -94,7 +94,11 @@ #include "trace.h" #include CONFIG_DEVICES =20 -GlobalProperty pc_compat_6_0[] =3D {}; +GlobalProperty pc_compat_6_0[] =3D { + { "qemu64" "-" TYPE_X86_CPU, "family", "6" }, + { "qemu64" "-" TYPE_X86_CPU, "model", "6" }, + { "qemu64" "-" TYPE_X86_CPU, "stepping", "3" }, +}; const size_t pc_compat_6_0_len =3D G_N_ELEMENTS(pc_compat_6_0); =20 GlobalProperty pc_compat_5_2[] =3D { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ff92d924ad9..078ec905522 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1803,9 +1803,9 @@ static const X86CPUDefinition builtin_x86_defs[] =3D { .name =3D "qemu64", .level =3D 0xd, .vendor =3D CPUID_VENDOR_AMD, - .family =3D 6, - .model =3D 6, - .stepping =3D 3, + .family =3D 15, + .model =3D 107, + .stepping =3D 1, .features[FEAT_1_EDX] =3D PPRO_FEATURES | CPUID_MTRR | CPUID_CLFLUSH | CPUID_MCA | --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571495; cv=none; d=zohomail.com; s=zohoarc; b=fSEpwEYvyESo2k6HKtfHPCeShbgdKX1knNttBHEjARoOcNo//BFhyimpvbJIWoYIjsqxEdNlrmePrfB3XacSCXvXwi8cTGeXVbog16Yj3+De/I7O9rr+cjnE65Ar2GeevoimXPvRmcerjLIa1/LoQm2JDFc6ZAlcjyb1H5+J2J0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571495; 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=GSDGbMJlnIeZClqyLIE18K/JOLIC2BNq7T+N2XkvkYI=; b=Amr2aAELu9mjXSXCgDqwDPQmmYKv7BJpdqVr5UfS48fsK27FpZRpzIIHEilOpelblWV+FmYKGPIMYrWfZw2NCfxulRvXIznvJoeL6xN3NbrAYAoxg13feh1ALtDH9Po89SnnWYV5ene+92cTZxtq1/QQjAKgj0YVe8Ez9KY5+Wg= 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+importer2=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 1622571495374626.7717980323634; Tue, 1 Jun 2021 11:18:15 -0700 (PDT) Received: from localhost ([::1]:34552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8xy-0003md-E6 for importer2@patchew.org; Tue, 01 Jun 2021 14:18:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qT-00025r-R0 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qO-0005bj-D1 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:29 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-462-h1pngC27Miee3vt7eBg28w-1; Tue, 01 Jun 2021 14:10:21 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EACED195D566; Tue, 1 Jun 2021 18:10:20 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id B95775C1BB; Tue, 1 Jun 2021 18:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GSDGbMJlnIeZClqyLIE18K/JOLIC2BNq7T+N2XkvkYI=; b=dYvcC8croGNmIXeVQYIHuthdUAdTZy7rM/xGQHSF+jJSVYONBfcoSijWXjhEwdCx6g0Af2 K/QGVekZkr0iDibAIMs57FtZPuV0RVFmQ4WZnoVe/UJfQyQfhfo28FFgqGSCJOXChBRRSi wSti/X6HSAxEd+N4Ql6KP7SblRfXfc8= X-MC-Unique: h1pngC27Miee3vt7eBg28w-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 07/24] i386: use better matching family/model/stepping for 'max' CPU Date: Tue, 1 Jun 2021 14:09:57 -0400 Message-Id: <20210601181014.2568861-8-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Daniel P. Berrang=C3=A9 The 'max' CPU under TCG currently reports a family/model/stepping that approximately corresponds to an AMD K7 vintage architecture. The K7 series predates the introduction of 64-bit support by AMD in the K8 series. This has been reported to lead to LLVM complaints about generating 64-bit code for a 32-bit CPU target LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it! It appears LLVM looks at the family/model/stepping, despite qemu64 reporting it is 64-bit capable. This patch changes 'max' to report a CPUID with the family, model and stepping taken from a AMD Athlon(tm) 64 X2 Dual Core Processor 4000+ which is one of the first 64-bit AMD CPUs. Closes https://gitlab.com/qemu-project/qemu/-/issues/191 Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20210507133650.645526-3-berrange@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 078ec905522..d150378c400 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4285,9 +4285,15 @@ static void max_x86_cpu_initfn(Object *obj) */ object_property_set_str(OBJECT(cpu), "vendor", CPUID_VENDOR_AMD, &error_abort); +#ifdef TARGET_X86_64 + object_property_set_int(OBJECT(cpu), "family", 15, &error_abort); + object_property_set_int(OBJECT(cpu), "model", 107, &error_abort); + object_property_set_int(OBJECT(cpu), "stepping", 1, &error_abort); +#else object_property_set_int(OBJECT(cpu), "family", 6, &error_abort); object_property_set_int(OBJECT(cpu), "model", 6, &error_abort); object_property_set_int(OBJECT(cpu), "stepping", 3, &error_abort); +#endif object_property_set_str(OBJECT(cpu), "model-id", "QEMU TCG CPU version " QEMU_HW_VERSION, &error_abort); --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571396; cv=none; d=zohomail.com; s=zohoarc; b=LabJkNj5goISs9vMDJThX8PY8RbhyjzwVg2OJA8XL6tEApDXzGXMHYuPmt/qCdkMRfpcLuimfaLxnOYX/3ivuR8otMJVQe5w6MXZFTRN/6/StSQNZvE39d6ZZLNLGrlvDtSWfFUJ4j3pkJWwiGTPNzR+Dmvfg4xr7LrRsI4bamo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571396; 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=FjNwH2SyiBMMgvOrNXP7N0FHQIvLn2EKYHbUu3O+4YQ=; b=ho9DeZUq9HwbqDhnkT6UmkhChpndjXyDCogIYHhGsEKqCrveKR9xJsOqATxo7cz8tolrquqD2K1yFoIyDQO3ViGExGdPaKaea7n7c7YvRbDGvPLnNXY2iV7BM29Z8GLydmscGoqH1Xr4quzUHg//TWULaYkKMc1eO6UiIYAYcyo= 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+importer2=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 1622571396326137.86223730365236; Tue, 1 Jun 2021 11:16:36 -0700 (PDT) Received: from localhost ([::1]:56298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8wN-0007pM-32 for importer2@patchew.org; Tue, 01 Jun 2021 14:16:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qX-0002EQ-1a for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qP-0005cT-37 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-84-daHfunV2M4C7IBqcjUyPQg-1; Tue, 01 Jun 2021 14:10:22 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A73068015C6; Tue, 1 Jun 2021 18:10:21 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 787B260C4A; Tue, 1 Jun 2021 18:10:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FjNwH2SyiBMMgvOrNXP7N0FHQIvLn2EKYHbUu3O+4YQ=; b=OH4R7hHK89nrjLfvh++mrftKjRjpcVGwfxsTTK/+dlBHw3iLiXnJ3o7GcKBYZybQQH8YFW NiDET9ls7687loexchU4AaKlcXT9HIHAK7tk27mVGIbISXSwd+X7bhlg4/kiLRgIGyEmp+ tOi6HONwjUdsKQjO1tV12zLlf1FK2io= X-MC-Unique: daHfunV2M4C7IBqcjUyPQg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 08/24] i386: keep hyperv_vendor string up-to-date Date: Tue, 1 Jun 2021 14:09:58 -0400 Message-Id: <20210601181014.2568861-9-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov When cpu->hyperv_vendor is not set manually we default to "Microsoft Hv" and in 'hv_passthrough' mode we get the information from the host. This information is stored in cpu->hyperv_vendor_id[] array but we don't update cpu->hyperv_vendor string so e.g. QMP's query-cpu-model-expansion output is incorrect. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-2-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.c | 19 +++++++++---------- target/i386/kvm/kvm.c | 5 +++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d150378c400..48dabc5238a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6141,17 +6141,16 @@ static void x86_cpu_hyperv_realize(X86CPU *cpu) =20 /* Hyper-V vendor id */ if (!cpu->hyperv_vendor) { - memcpy(cpu->hyperv_vendor_id, "Microsoft Hv", 12); - } else { - len =3D strlen(cpu->hyperv_vendor); - - if (len > 12) { - warn_report("hv-vendor-id truncated to 12 characters"); - len =3D 12; - } - memset(cpu->hyperv_vendor_id, 0, 12); - memcpy(cpu->hyperv_vendor_id, cpu->hyperv_vendor, len); + object_property_set_str(OBJECT(cpu), "hv-vendor-id", "Microsoft Hv= ", + &error_abort); + } + len =3D strlen(cpu->hyperv_vendor); + if (len > 12) { + warn_report("hv-vendor-id truncated to 12 characters"); + len =3D 12; } + memset(cpu->hyperv_vendor_id, 0, 12); + memcpy(cpu->hyperv_vendor_id, cpu->hyperv_vendor, len); =20 /* 'Hv#1' interface identification*/ cpu->hyperv_interface_id[0] =3D 0x31237648; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index d972eb4705b..ce02cb6713c 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1216,6 +1216,11 @@ static int hyperv_handle_properties(CPUState *cs, cpu->hyperv_vendor_id[0] =3D c->ebx; cpu->hyperv_vendor_id[1] =3D c->ecx; cpu->hyperv_vendor_id[2] =3D c->edx; + cpu->hyperv_vendor =3D g_realloc(cpu->hyperv_vendor, + sizeof(cpu->hyperv_vendor_id) += 1); + memcpy(cpu->hyperv_vendor, cpu->hyperv_vendor_id, + sizeof(cpu->hyperv_vendor_id)); + cpu->hyperv_vendor[sizeof(cpu->hyperv_vendor_id)] =3D 0; } =20 c =3D cpuid_find_entry(cpuid, HV_CPUID_INTERFACE, 0); --=20 2.30.2 From nobody Mon May 6 12:05:25 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571566; cv=none; d=zohomail.com; s=zohoarc; b=VA4hnhiQP1UNmgmmlnejOoJG20jrA1OxoA9Eywxrr6Q4VQitWdzZuJpCJ4TjHe1wdiRzM4i3H8iaX5DqHtTL/yd1lRt6Rlzi3LaXr8MgEuIAvM98RLUUTQwJVUvxxVXbNg4xaPutcdADKWoWqIIXP6qjdBsQhvv7WLdQHsEkeAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571566; 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=UwZ76EXiVsD52cBQ/JKosxIyzJwORhxe8vPOye6RqAE=; b=Wul5eLJmHfsJwwvwvO3SmXh/W/vLiKwDpCdH7Ij7JzndneQOXI64D9o6iLEHYF5QB6nbKKgTkYi+EYw7/fRIsyNdnpfMtDmCx1FL2KQPsNqt1vEfB6a2DdLdISOs5QF0c7EbZCVElwTESXMs0SWgAmvtq7U0WsqArBNWEK70yAA= 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+importer2=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 1622571566069174.5364873492124; Tue, 1 Jun 2021 11:19:26 -0700 (PDT) Received: from localhost ([::1]:39988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8z6-0007Md-Uo for importer2@patchew.org; Tue, 01 Jun 2021 14:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qW-0002E7-O7 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qT-0005gd-Ht for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:32 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-VOm6iP3cNu2ZxJtjz7dSfw-1; Tue, 01 Jun 2021 14:10:23 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CD57802690; Tue, 1 Jun 2021 18:10:22 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47BE75C1BB; Tue, 1 Jun 2021 18:10:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571027; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UwZ76EXiVsD52cBQ/JKosxIyzJwORhxe8vPOye6RqAE=; b=bFuuv8yXlnQwVHiqo8inh3PTxbcbjD8JHgY6kfeg9NRiAgKwDfqOuGqjBbr4biYoPtRTly 2f8C1726uPVNy3egHHdll53w7viQE3Yaee4AqKoKSQ9baWhNkhgiKUKXNTYlgk5Wu5W6oe H6WJy0STcQgrmiJe/GeivPSmRoi8iHI= X-MC-Unique: VOm6iP3cNu2ZxJtjz7dSfw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 09/24] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough Date: Tue, 1 Jun 2021 14:09:59 -0400 Message-Id: <20210601181014.2568861-10-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov There is no need to have this special case: like all other Hyper-V enlightenments we can just use kernel's supplied value in hv_passthrough mode. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-3-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index ce02cb6713c..7849e84e9a0 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1257,11 +1257,7 @@ static int hyperv_handle_properties(CPUState *cs, c =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); if (c) { env->features[FEAT_HV_RECOMM_EAX] =3D c->eax; - - /* hv-spinlocks may have been overriden */ - if (cpu->hyperv_spinlock_attempts !=3D HYPERV_SPINLOCK_NEVER_N= OTIFY) { - c->ebx =3D cpu->hyperv_spinlock_attempts; - } + cpu->hyperv_spinlock_attempts =3D c->ebx; } c =3D cpuid_find_entry(cpuid, HV_CPUID_NESTED_FEATURES, 0); if (c) { --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571482; cv=none; d=zohomail.com; s=zohoarc; b=es2LUg2fc6oWurroMNI0VOLesedzj7q29qpextp3ZOdtKNXrt1a44OflGHFWd/5wBFEx1x1puJUehKhfQBvyQCFE00wVJa3CgLRGZoMWIYqIray1NbnXA7Ftxjv4SAr+V61WcA9744o7YCbiXBjQIQ7Ovuu9NP5L5kmHwtnBh5A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571482; 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=FFg9dMi/XHaUmyCE1zJWb6DH07QDM9l3Lb8+5CUtIpQ=; b=Ugo+Hp5wYBNUoERkFiaROUJSo9rArSmJE71V43IlNh8E/nsSgSV4TCFLa1HA0fas8UCgsVfrtC595htA9ZXMlP0NZpTxKHRKGfGKJzCilrhGCkKiCb86DLS7Xp7XBHSBeEvBacm1fpuIDxHbUYsvu9Jo++xNmo0oOMShk5UqfM4= 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+importer2=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 1622571482336461.8483680465732; Tue, 1 Jun 2021 11:18:02 -0700 (PDT) Received: from localhost ([::1]:33464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8xl-00033O-Bc for importer2@patchew.org; Tue, 01 Jun 2021 14:18:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43264) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qV-0002Ay-Ao for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qT-0005fT-Go for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-559-itljg9YxMZaMbmheJnAXCg-1; Tue, 01 Jun 2021 14:10:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3E60979EC3; Tue, 1 Jun 2021 18:10:23 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1059960CCC; Tue, 1 Jun 2021 18:10:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571025; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FFg9dMi/XHaUmyCE1zJWb6DH07QDM9l3Lb8+5CUtIpQ=; b=Ek57D3fEbNRprjWMRKpF+6z/6g1sdF73feCrlThSwAzK15HTNMS90eW9V+E6sCNdZzbTsh izLwltNVC92qBp/NvhUQOiJA9oXIqnbxtjways25sZ2KpGWdf6TKbICtIGEaBYV/OBJlBf jW35w/5H44vGFzEhe/08JeL0SIm3Keg= X-MC-Unique: itljg9YxMZaMbmheJnAXCg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 10/24] i386: always fill Hyper-V CPUID feature leaves from X86CPU data Date: Tue, 1 Jun 2021 14:10:00 -0400 Message-Id: <20210601181014.2568861-11-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov We have all the required data in X86CPU already and as we are about to split hyperv_handle_properties() into hyperv_expand_features()/ hyperv_fill_cpuids() we can remove the blind copy. The functional change is that QEMU won't pass CPUID leaves it doesn't currently know about to the guest but arguably this is a good change. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-4-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 7849e84e9a0..4cd4df223fc 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1208,9 +1208,6 @@ static int hyperv_handle_properties(CPUState *cs, } =20 if (cpu->hyperv_passthrough) { - memcpy(cpuid_ent, &cpuid->entries[0], - cpuid->nent * sizeof(cpuid->entries[0])); - c =3D cpuid_find_entry(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, 0= ); if (c) { cpu->hyperv_vendor_id[0] =3D c->ebx; @@ -1310,12 +1307,6 @@ static int hyperv_handle_properties(CPUState *cs, goto free; } =20 - if (cpu->hyperv_passthrough) { - /* We already copied all feature words from KVM as is */ - r =3D cpuid->nent; - goto free; - } - c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VENDOR_AND_MAX_FUNCTIONS; c->eax =3D hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) ? --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571237; cv=none; d=zohomail.com; s=zohoarc; b=NdmciSVuA1mM0jS/1FPCx3orgXK7MgY7a8zPdGQSkx3JkeNmsz1/fQsvjaBpuv31GJONjdZPcU1kTDYPgJ84zjRyrIDUZWAx/Gxfi3YGhOLl83KQb8E6nTy6PNRKnhxVsS3jd5SQI1T58VAPX007dZNQ9UAbtz49R/MgBG7swoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571237; 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=WWxxuc+yNU6M5AgsLtoKdH+zz1WdNZ2CPoRpA5Kh3LA=; b=D2XsiGUQXBczURYDJKD4mWpOnBZthkT7WEOvYfOPImE9n/dwc2anNMf4tKsLt3i0XdF/j/Fv6uKItu0nJlEbcLZiGQDdgMvDPa+bM+F66Ba/2mDD78EtR/ngfCa3EdhgDyT5AefSYaSDc1WviQJ6StXAR3F0j9+aQjxbShnlHR4= 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+importer2=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 1622571237933743.7793100329915; Tue, 1 Jun 2021 11:13:57 -0700 (PDT) Received: from localhost ([::1]:42584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8to-00078u-CO for importer2@patchew.org; Tue, 01 Jun 2021 14:13:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qV-0002Ce-QR for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qT-0005gP-HJ for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-577-op77rHRrOfOISzVY-o0DYg-1; Tue, 01 Jun 2021 14:10:25 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EA28107ACED; Tue, 1 Jun 2021 18:10:24 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF8D661008; Tue, 1 Jun 2021 18:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WWxxuc+yNU6M5AgsLtoKdH+zz1WdNZ2CPoRpA5Kh3LA=; b=fSXorZEKzbpvCAYqCM5bIYp8KJ7RoOdYu+P0MndRVGMryBGyeTjiSDf9qSFyC6cLI5QJ1R KdrvHTPayY/wpC4KUvP5q9q0+MxrO2d+gH8107zvtNc28r/ylpKi1YWmmDq7p+hE9kTJEc FGznZfH3BXOxorJkgfgdOA5jJCtZUpM= X-MC-Unique: op77rHRrOfOISzVY-o0DYg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 11/24] i386: stop using env->features[] for filling Hyper-V CPUIDs Date: Tue, 1 Jun 2021 14:10:01 -0400 Message-Id: <20210601181014.2568861-12-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov As a preparatory patch to dropping Hyper-V CPUID leaves from feature_word_info[] stop using env->features[] as a temporary storage of Hyper-V CPUIDs, just build Hyper-V CPUID leaves directly from kvm_hyperv_properties[] data. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-5-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 80 +++++++++++++++++++++++-------------------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index da72aa52286..681f11607ff 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1699,6 +1699,7 @@ struct X86CPU { uint32_t hyperv_interface_id[4]; uint32_t hyperv_version_id[4]; uint32_t hyperv_limits[3]; + uint32_t hyperv_nested[4]; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 4cd4df223fc..346528c6496 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1112,7 +1112,6 @@ static int hv_cpuid_check_and_set(CPUState *cs, struc= t kvm_cpuid2 *cpuid, int feature) { X86CPU *cpu =3D X86_CPU(cs); - CPUX86State *env =3D &cpu->env; uint32_t r, fw, bits; uint64_t deps; int i, dep_feat; @@ -1152,8 +1151,6 @@ static int hv_cpuid_check_and_set(CPUState *cs, struc= t kvm_cpuid2 *cpuid, return 0; } } - - env->features[fw] |=3D bits; } =20 if (cpu->hyperv_passthrough) { @@ -1163,6 +1160,29 @@ static int hv_cpuid_check_and_set(CPUState *cs, stru= ct kvm_cpuid2 *cpuid, return 0; } =20 +static uint32_t hv_build_cpuid_leaf(CPUState *cs, uint32_t fw) +{ + X86CPU *cpu =3D X86_CPU(cs); + uint32_t r =3D 0; + int i, j; + + for (i =3D 0; i < ARRAY_SIZE(kvm_hyperv_properties); i++) { + if (!hyperv_feat_enabled(cpu, i)) { + continue; + } + + for (j =3D 0; j < ARRAY_SIZE(kvm_hyperv_properties[i].flags); j++)= { + if (kvm_hyperv_properties[i].flags[j].fw !=3D fw) { + continue; + } + + r |=3D kvm_hyperv_properties[i].flags[j].bits; + } + } + + return r; +} + /* * Fill in Hyper-V CPUIDs. Returns the number of entries filled in cpuid_e= nt in * case of success, errno < 0 in case of failure and 0 when no Hyper-V @@ -1172,9 +1192,8 @@ static int hyperv_handle_properties(CPUState *cs, struct kvm_cpuid_entry2 *cpuid_ent) { X86CPU *cpu =3D X86_CPU(cs); - CPUX86State *env =3D &cpu->env; struct kvm_cpuid2 *cpuid; - struct kvm_cpuid_entry2 *c; + struct kvm_cpuid_entry2 *c, *c2; uint32_t cpuid_i =3D 0; int r; =20 @@ -1195,9 +1214,7 @@ static int hyperv_handle_properties(CPUState *cs, } =20 if (!r) { - env->features[FEAT_HV_RECOMM_EAX] |=3D - HV_ENLIGHTENED_VMCS_RECOMMENDED; - env->features[FEAT_HV_NESTED_EAX] =3D evmcs_version; + cpu->hyperv_nested[0] =3D evmcs_version; } } =20 @@ -1236,13 +1253,6 @@ static int hyperv_handle_properties(CPUState *cs, cpu->hyperv_version_id[3] =3D c->edx; } =20 - c =3D cpuid_find_entry(cpuid, HV_CPUID_FEATURES, 0); - if (c) { - env->features[FEAT_HYPERV_EAX] =3D c->eax; - env->features[FEAT_HYPERV_EBX] =3D c->ebx; - env->features[FEAT_HYPERV_EDX] =3D c->edx; - } - c =3D cpuid_find_entry(cpuid, HV_CPUID_IMPLEMENT_LIMITS, 0); if (c) { cpu->hv_max_vps =3D c->eax; @@ -1253,23 +1263,8 @@ static int hyperv_handle_properties(CPUState *cs, =20 c =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); if (c) { - env->features[FEAT_HV_RECOMM_EAX] =3D c->eax; cpu->hyperv_spinlock_attempts =3D c->ebx; } - c =3D cpuid_find_entry(cpuid, HV_CPUID_NESTED_FEATURES, 0); - if (c) { - env->features[FEAT_HV_NESTED_EAX] =3D c->eax; - } - } - - if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { - env->features[FEAT_HV_RECOMM_EAX] |=3D HV_NO_NONARCH_CORESHARING; - } else if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO) { - c =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); - if (c) { - env->features[FEAT_HV_RECOMM_EAX] |=3D - c->eax & HV_NO_NONARCH_CORESHARING; - } } =20 /* Features */ @@ -1299,9 +1294,6 @@ static int hyperv_handle_properties(CPUState *cs, r |=3D 1; } =20 - /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ - env->features[FEAT_HYPERV_EDX] |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILA= BLE; - if (r) { r =3D -ENOSYS; goto free; @@ -1331,15 +1323,27 @@ static int hyperv_handle_properties(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_FEATURES; - c->eax =3D env->features[FEAT_HYPERV_EAX]; - c->ebx =3D env->features[FEAT_HYPERV_EBX]; - c->edx =3D env->features[FEAT_HYPERV_EDX]; + c->eax =3D hv_build_cpuid_leaf(cs, FEAT_HYPERV_EAX); + c->ebx =3D hv_build_cpuid_leaf(cs, FEAT_HYPERV_EBX); + c->edx =3D hv_build_cpuid_leaf(cs, FEAT_HYPERV_EDX); + + /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ + c->edx |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE; =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_ENLIGHTMENT_INFO; - c->eax =3D env->features[FEAT_HV_RECOMM_EAX]; + c->eax =3D hv_build_cpuid_leaf(cs, FEAT_HV_RECOMM_EAX); c->ebx =3D cpu->hyperv_spinlock_attempts; =20 + if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { + c->eax |=3D HV_NO_NONARCH_CORESHARING; + } else if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO) { + c2 =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); + if (c2) { + c->eax |=3D c2->eax & HV_NO_NONARCH_CORESHARING; + } + } + c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_IMPLEMENT_LIMITS; c->eax =3D cpu->hv_max_vps; @@ -1359,7 +1363,7 @@ static int hyperv_handle_properties(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_NESTED_FEATURES; - c->eax =3D env->features[FEAT_HV_NESTED_EAX]; + c->eax =3D cpu->hyperv_nested[0]; } r =3D cpuid_i; =20 --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571576; cv=none; d=zohomail.com; s=zohoarc; b=V9RKNpOhYKj321bFwCGIUuI+OB90c4q2BQQtk3/n8X1HDFFxKCAVWKMV/ZbLpQbrR7rWhucvqLQ1tBs3GlWEDrXTOS73xp1AaYS4mN2Q8zbvh7MAptOBIx4E39kGmMHhfds/MD9oQkGjPxv37IKUItt0uux2izX/nztlxeeYooo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571576; 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=sDnpW+ipaKdln62AKVZyyR78WKBVDrXgag+C1IyACJM=; b=aQGe4kfbK3PrqajYoeHFiRZtKcJy+qCgbBW8Mg3NRNZZsqC087Y1EDeG/YPldnAQhfBDwsQDoHJnKDGycLqFhYOrbMMPetL9+zZcieHVlO5AUAfAYW2Ndk8d+mib/zRmH51jAB4jIX4sz0Vi4VH2CbbKMRRjt/elreZb8eiskfg= 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+importer2=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 162257157663840.82056716019497; Tue, 1 Jun 2021 11:19:36 -0700 (PDT) Received: from localhost ([::1]:40984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8zH-00081I-K2 for importer2@patchew.org; Tue, 01 Jun 2021 14:19:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qY-0002Iy-Ck for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qW-0005k4-Kg for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:34 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-377-i2XPLbkhMCqL_lsGUy91Jw-1; Tue, 01 Jun 2021 14:10:29 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7631F107ACCA; Tue, 1 Jun 2021 18:10:28 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id A054A60E3A; Tue, 1 Jun 2021 18:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sDnpW+ipaKdln62AKVZyyR78WKBVDrXgag+C1IyACJM=; b=W/MCcz2inUohXPbwoF/mSePLk0ikKYlTWCw4eFr7snHZGYzAys4Cx7gHkTzX2xIJPDz7gm GDFQoRHv2egspy8VwNhlF0X7fMrcf//zptvZczDzANhAt5ALcnLCdVsNoC0PbwOpbqH8wf 8G7hMhCtSDpRoYeHNYRRnZtZkwF1wns= X-MC-Unique: i2XPLbkhMCqL_lsGUy91Jw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 12/24] i386: introduce hyperv_feature_supported() Date: Tue, 1 Jun 2021 14:10:02 -0400 Message-Id: <20210601181014.2568861-13-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Clean up hv_cpuid_check_and_set() by separating hyperv_feature_supported() off it. No functional change intended. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-6-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 49 ++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 346528c6496..712285df40e 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1108,13 +1108,33 @@ static int hv_cpuid_get_fw(struct kvm_cpuid2 *cpuid= , int fw, uint32_t *r) return 0; } =20 +static bool hyperv_feature_supported(struct kvm_cpuid2 *cpuid, int feature) +{ + uint32_t r, fw, bits; + int i; + + for (i =3D 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i+= +) { + fw =3D kvm_hyperv_properties[feature].flags[i].fw; + bits =3D kvm_hyperv_properties[feature].flags[i].bits; + + if (!fw) { + continue; + } + + if (hv_cpuid_get_fw(cpuid, fw, &r) || (r & bits) !=3D bits) { + return false; + } + } + + return true; +} + static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid, int feature) { X86CPU *cpu =3D X86_CPU(cs); - uint32_t r, fw, bits; uint64_t deps; - int i, dep_feat; + int dep_feat; =20 if (!hyperv_feat_enabled(cpu, feature) && !cpu->hyperv_passthrough) { return 0; @@ -1133,23 +1153,14 @@ static int hv_cpuid_check_and_set(CPUState *cs, str= uct kvm_cpuid2 *cpuid, deps &=3D ~(1ull << dep_feat); } =20 - for (i =3D 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i+= +) { - fw =3D kvm_hyperv_properties[feature].flags[i].fw; - bits =3D kvm_hyperv_properties[feature].flags[i].bits; - - if (!fw) { - continue; - } - - if (hv_cpuid_get_fw(cpuid, fw, &r) || (r & bits) !=3D bits) { - if (hyperv_feat_enabled(cpu, feature)) { - fprintf(stderr, - "Hyper-V %s is not supported by kernel\n", - kvm_hyperv_properties[feature].desc); - return 1; - } else { - return 0; - } + if (!hyperv_feature_supported(cpuid, feature)) { + if (hyperv_feat_enabled(cpu, feature)) { + fprintf(stderr, + "Hyper-V %s is not supported by kernel\n", + kvm_hyperv_properties[feature].desc); + return 1; + } else { + return 0; } } =20 --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571667; cv=none; d=zohomail.com; s=zohoarc; b=f/HtRYeKIvij84gHgSHpwmyE3Px7ZnOmrigu6Ncq2W31D5wf9/zX8Nn8E6AScex5CkOQx5fkxd6LkNhbGc3rD2ynSTO3y6roHYEzBHNqo8pNPeTJjDxui4a9RFj8SFBM6oFZR5lMJEXF+pe15nG7PNtmjM6mffX3rI4vCU4IaFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571667; 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=Uf5MYu8bluJr+2VyrtullUVV71h7FWKmKQ9dNXtqXiY=; b=KsKeoTjnDmiRxdzt8ricxLSbUgGNE12VckOaAv0xBHRSuYuNqculjtmcN7xSAGANeHp7RnLEuPGnbXNwfm+eOc0qHBd21a3qFntc/2n3BS0NBBd3Ftq+bPO1Nen4E3vXxDTcHTTr6Q3VrsX72Btsgqoau5W8OUBfYsq1w3ddWEs= 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+importer2=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 1622571667203842.4947223836454; Tue, 1 Jun 2021 11:21:07 -0700 (PDT) Received: from localhost ([::1]:47476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo90k-0003td-7s for importer2@patchew.org; Tue, 01 Jun 2021 14:21:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qZ-0002O1-Ky for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47552) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qX-0005kx-Lp for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-PSxjoiAuNYuTWMUqDSqOSQ-1; Tue, 01 Jun 2021 14:10:30 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B96A100945E; Tue, 1 Jun 2021 18:10:29 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DD9B60C5B; Tue, 1 Jun 2021 18:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571033; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Uf5MYu8bluJr+2VyrtullUVV71h7FWKmKQ9dNXtqXiY=; b=XXEIE3Fysgu726fc15onl9v4i+Issox2FdJqLWHJsg4BFEGTWhH/tsG1QC3UI7CETB+Y0O I/2uFG8EqRcTATzRc7K6sVUmWSK3x2pFwc74RAimjsF6VgkRTwRadRWThizn4/YlvR8IHN K5+f2F5QIWm/KK8JtJr2qZqVa/15HOY= X-MC-Unique: PSxjoiAuNYuTWMUqDSqOSQ-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 13/24] i386: introduce hv_cpuid_get_host() Date: Tue, 1 Jun 2021 14:10:03 -0400 Message-Id: <20210601181014.2568861-14-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov As a preparation to implementing hv_cpuid_cache intro introduce hv_cpuid_get_host(). No functional change intended. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-7-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 102 +++++++++++++++++++++++------------------- 1 file changed, 57 insertions(+), 45 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 712285df40e..018f19c3a3a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1108,6 +1108,19 @@ static int hv_cpuid_get_fw(struct kvm_cpuid2 *cpuid,= int fw, uint32_t *r) return 0; } =20 +static uint32_t hv_cpuid_get_host(struct kvm_cpuid2 *cpuid, uint32_t func, + int reg) +{ + struct kvm_cpuid_entry2 *entry; + + entry =3D cpuid_find_entry(cpuid, func, 0); + if (!entry) { + return 0; + } + + return cpuid_entry_get_reg(entry, reg); +} + static bool hyperv_feature_supported(struct kvm_cpuid2 *cpuid, int feature) { uint32_t r, fw, bits; @@ -1204,7 +1217,7 @@ static int hyperv_handle_properties(CPUState *cs, { X86CPU *cpu =3D X86_CPU(cs); struct kvm_cpuid2 *cpuid; - struct kvm_cpuid_entry2 *c, *c2; + struct kvm_cpuid_entry2 *c; uint32_t cpuid_i =3D 0; int r; =20 @@ -1236,46 +1249,47 @@ static int hyperv_handle_properties(CPUState *cs, } =20 if (cpu->hyperv_passthrough) { - c =3D cpuid_find_entry(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, 0= ); - if (c) { - cpu->hyperv_vendor_id[0] =3D c->ebx; - cpu->hyperv_vendor_id[1] =3D c->ecx; - cpu->hyperv_vendor_id[2] =3D c->edx; - cpu->hyperv_vendor =3D g_realloc(cpu->hyperv_vendor, - sizeof(cpu->hyperv_vendor_id) += 1); - memcpy(cpu->hyperv_vendor, cpu->hyperv_vendor_id, - sizeof(cpu->hyperv_vendor_id)); - cpu->hyperv_vendor[sizeof(cpu->hyperv_vendor_id)] =3D 0; - } - - c =3D cpuid_find_entry(cpuid, HV_CPUID_INTERFACE, 0); - if (c) { - cpu->hyperv_interface_id[0] =3D c->eax; - cpu->hyperv_interface_id[1] =3D c->ebx; - cpu->hyperv_interface_id[2] =3D c->ecx; - cpu->hyperv_interface_id[3] =3D c->edx; - } - - c =3D cpuid_find_entry(cpuid, HV_CPUID_VERSION, 0); - if (c) { - cpu->hyperv_version_id[0] =3D c->eax; - cpu->hyperv_version_id[1] =3D c->ebx; - cpu->hyperv_version_id[2] =3D c->ecx; - cpu->hyperv_version_id[3] =3D c->edx; - } - - c =3D cpuid_find_entry(cpuid, HV_CPUID_IMPLEMENT_LIMITS, 0); - if (c) { - cpu->hv_max_vps =3D c->eax; - cpu->hyperv_limits[0] =3D c->ebx; - cpu->hyperv_limits[1] =3D c->ecx; - cpu->hyperv_limits[2] =3D c->edx; - } - - c =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); - if (c) { - cpu->hyperv_spinlock_attempts =3D c->ebx; - } + cpu->hyperv_vendor_id[0] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_= EBX); + cpu->hyperv_vendor_id[1] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_= ECX); + cpu->hyperv_vendor_id[2] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_= EDX); + cpu->hyperv_vendor =3D g_realloc(cpu->hyperv_vendor, + sizeof(cpu->hyperv_vendor_id) + 1); + memcpy(cpu->hyperv_vendor, cpu->hyperv_vendor_id, + sizeof(cpu->hyperv_vendor_id)); + cpu->hyperv_vendor[sizeof(cpu->hyperv_vendor_id)] =3D 0; + + cpu->hyperv_interface_id[0] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_EAX); + cpu->hyperv_interface_id[1] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_EBX); + cpu->hyperv_interface_id[2] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_ECX); + cpu->hyperv_interface_id[3] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_EDX); + + cpu->hyperv_version_id[0] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_EAX); + cpu->hyperv_version_id[1] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_EBX); + cpu->hyperv_version_id[2] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_ECX); + cpu->hyperv_version_id[3] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_EDX); + + cpu->hv_max_vps =3D hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LI= MITS, + R_EAX); + cpu->hyperv_limits[0] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LIMITS, R_EBX); + cpu->hyperv_limits[1] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LIMITS, R_ECX); + cpu->hyperv_limits[2] =3D + hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LIMITS, R_EDX); + + cpu->hyperv_spinlock_attempts =3D + hv_cpuid_get_host(cpuid, HV_CPUID_ENLIGHTMENT_INFO, R_EBX); } =20 /* Features */ @@ -1349,10 +1363,8 @@ static int hyperv_handle_properties(CPUState *cs, if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { c->eax |=3D HV_NO_NONARCH_CORESHARING; } else if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO) { - c2 =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); - if (c2) { - c->eax |=3D c2->eax & HV_NO_NONARCH_CORESHARING; - } + c->eax |=3D hv_cpuid_get_host(cpuid, HV_CPUID_ENLIGHTMENT_INFO, R_= EAX) & + HV_NO_NONARCH_CORESHARING; } =20 c =3D &cpuid_ent[cpuid_i++]; --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571768; cv=none; d=zohomail.com; s=zohoarc; b=FymFUJqNrc3/YpJNv3/u9BnzJrtw0kkT2xkfBBOBSUfnBS6JgNx1dMys9PHLhckyRYZTgzemWSqNTgG+UJ6GtAbb+tivvzc3ZiZJDuUN5IKuEnJKdygtaOBswCfMvpi6Q8MH/6CEfhel6olslYSQDhv1zwr4JJqgLPclapDL6lI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571768; 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=tWbTh5azKkSHnk5dSQVUKwc4EmlCKm5APBOp69VVApw=; b=XZn+kqYWZbdXFmApw2ev3nEELBH3nvUbTymkBFm7d8+Cka18Eit4iQHPQxzgjdoE4DzqawbiWg7O8fmA047hrYiCNeV4dcfl4vb5W283TdEu3I+ukT728o3VbfLGqiyIqO7fwnFNyP5K/JnfPL5H1A0bmXxY+DWX3+9qU6/2rPA= 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+importer2=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 1622571768631426.7806302548736; Tue, 1 Jun 2021 11:22:48 -0700 (PDT) Received: from localhost ([::1]:54076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo92N-0008Kj-Jl for importer2@patchew.org; Tue, 01 Jun 2021 14:22:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43336) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qa-0002RW-Pe for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qX-0005l7-Vr for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-DTPiFTAeOTKTcy4-PZKfuA-1; Tue, 01 Jun 2021 14:10:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2F7AB195D560; Tue, 1 Jun 2021 18:10:30 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id D39475C1BB; Tue, 1 Jun 2021 18:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571033; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tWbTh5azKkSHnk5dSQVUKwc4EmlCKm5APBOp69VVApw=; b=ZgdN+BNhqikvr1+HGYEjzQsbh8WOj9jWFOuYOcilDpvmvicN2DO6mvAXWlEkdPR/Vq1b6B i7uHFy9t3up9M1ceOve7dC3Dq6CKE4qJ3yJ6PsdXctjpFwqJOApoBVd/cRlUpXUD6I5As+ IqfAgkNOSLW/y18pd6AxoIbo3qQ5rrA= X-MC-Unique: DTPiFTAeOTKTcy4-PZKfuA-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 14/24] i386: drop FEAT_HYPERV feature leaves Date: Tue, 1 Jun 2021 14:10:04 -0400 Message-Id: <20210601181014.2568861-15-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Hyper-V feature leaves are weird. We have some of them in feature_word_info[] array but we don't use feature_word_info magic to enable them. Neither do we use feature_dependencies[] mechanism to validate the configuration as it doesn't allign well with Hyper-V's many-to-many dependency chains. Some of the feature leaves hold not only feature bits, but also values. E.g. FEAT_HV_NESTED_EAX contains both features and the supported Enlightened VMCS range. Hyper-V features are already represented in 'struct X86CPU' with uint64_t hyperv_features so duplicating them in env->features adds little (or zero) benefits. THe other half of Hyper-V emulation features is also stored with values in hyperv_vendor_id[], hyperv_limits[],... so env->features[] is already incomplete. Remove Hyper-V feature leaves from env->features[] completely. kvm_hyperv_properties[] is converted to using raw CPUID func/reg pairs for features, this allows us to get rid of hv_cpuid_get_fw() conversion. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-8-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/cpu.h | 5 -- target/i386/cpu-sysemu.c | 2 +- target/i386/cpu.c | 88 ------------------------------- target/i386/kvm/kvm.c | 108 +++++++++++++-------------------------- 4 files changed, 37 insertions(+), 166 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 681f11607ff..ac3abea97c1 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -531,11 +531,6 @@ typedef enum FeatureWord { FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */ FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */ FEAT_KVM_HINTS, /* CPUID[4000_0001].EDX */ - FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */ - FEAT_HYPERV_EBX, /* CPUID[4000_0003].EBX */ - FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */ - FEAT_HV_RECOMM_EAX, /* CPUID[4000_0004].EAX */ - FEAT_HV_NESTED_EAX, /* CPUID[4000_000A].EAX */ FEAT_SVM, /* CPUID[8000_000A].EDX */ FEAT_XSAVE, /* CPUID[EAX=3D0xd,ECX=3D1].EAX */ FEAT_6_EAX, /* CPUID[6].EAX */ diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c index 6477584313a..1078e3d157f 100644 --- a/target/i386/cpu-sysemu.c +++ b/target/i386/cpu-sysemu.c @@ -312,7 +312,7 @@ GuestPanicInformation *x86_cpu_get_crash_info(CPUState = *cs) CPUX86State *env =3D &cpu->env; GuestPanicInformation *panic_info =3D NULL; =20 - if (env->features[FEAT_HYPERV_EDX] & HV_GUEST_CRASH_MSR_AVAILABLE) { + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_CRASH)) { panic_info =3D g_malloc0(sizeof(GuestPanicInformation)); =20 panic_info->type =3D GUEST_PANIC_INFORMATION_TYPE_HYPER_V; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 48dabc5238a..e0ba36cc233 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -776,94 +776,6 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D { */ .no_autoenable_flags =3D ~0U, }, - /* - * .feat_names are commented out for Hyper-V enlightenments because we - * don't want to have two different ways for enabling them on QEMU com= mand - * line. Some features (e.g. "hyperv_time", "hyperv_vapic", ...) requi= re - * enabling several feature bits simultaneously, exposing these bits - * individually may just confuse guests. - */ - [FEAT_HYPERV_EAX] =3D { - .type =3D CPUID_FEATURE_WORD, - .feat_names =3D { - NULL /* hv_msr_vp_runtime_access */, NULL /* hv_msr_time_refco= unt_access */, - NULL /* hv_msr_synic_access */, NULL /* hv_msr_stimer_access *= /, - NULL /* hv_msr_apic_access */, NULL /* hv_msr_hypercall_access= */, - NULL /* hv_vpindex_access */, NULL /* hv_msr_reset_access */, - NULL /* hv_msr_stats_access */, NULL /* hv_reftsc_access */, - NULL /* hv_msr_idle_access */, NULL /* hv_msr_frequency_access= */, - NULL /* hv_msr_debug_access */, NULL /* hv_msr_reenlightenment= _access */, - NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - }, - .cpuid =3D { .eax =3D 0x40000003, .reg =3D R_EAX, }, - }, - [FEAT_HYPERV_EBX] =3D { - .type =3D CPUID_FEATURE_WORD, - .feat_names =3D { - NULL /* hv_create_partitions */, NULL /* hv_access_partition_i= d */, - NULL /* hv_access_memory_pool */, NULL /* hv_adjust_message_bu= ffers */, - NULL /* hv_post_messages */, NULL /* hv_signal_events */, - NULL /* hv_create_port */, NULL /* hv_connect_port */, - NULL /* hv_access_stats */, NULL, NULL, NULL /* hv_debugging *= /, - NULL /* hv_cpu_power_management */, NULL /* hv_configure_profi= ler */, - NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - }, - .cpuid =3D { .eax =3D 0x40000003, .reg =3D R_EBX, }, - }, - [FEAT_HYPERV_EDX] =3D { - .type =3D CPUID_FEATURE_WORD, - .feat_names =3D { - NULL /* hv_mwait */, NULL /* hv_guest_debugging */, - NULL /* hv_perf_monitor */, NULL /* hv_cpu_dynamic_part */, - NULL /* hv_hypercall_params_xmm */, NULL /* hv_guest_idle_stat= e */, - NULL, NULL, - NULL, NULL, NULL /* hv_guest_crash_msr */, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - }, - .cpuid =3D { .eax =3D 0x40000003, .reg =3D R_EDX, }, - }, - [FEAT_HV_RECOMM_EAX] =3D { - .type =3D CPUID_FEATURE_WORD, - .feat_names =3D { - NULL /* hv_recommend_pv_as_switch */, - NULL /* hv_recommend_pv_tlbflush_local */, - NULL /* hv_recommend_pv_tlbflush_remote */, - NULL /* hv_recommend_msr_apic_access */, - NULL /* hv_recommend_msr_reset */, - NULL /* hv_recommend_relaxed_timing */, - NULL /* hv_recommend_dma_remapping */, - NULL /* hv_recommend_int_remapping */, - NULL /* hv_recommend_x2apic_msrs */, - NULL /* hv_recommend_autoeoi_deprecation */, - NULL /* hv_recommend_pv_ipi */, - NULL /* hv_recommend_ex_hypercalls */, - NULL /* hv_hypervisor_is_nested */, - NULL /* hv_recommend_int_mbec */, - NULL /* hv_recommend_evmcs */, - NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, - }, - .cpuid =3D { .eax =3D 0x40000004, .reg =3D R_EAX, }, - }, - [FEAT_HV_NESTED_EAX] =3D { - .type =3D CPUID_FEATURE_WORD, - .cpuid =3D { .eax =3D 0x4000000A, .reg =3D R_EAX, }, - }, [FEAT_SVM] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 018f19c3a3a..6d6afd83e3a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -801,7 +801,8 @@ static bool tsc_is_stable_and_known(CPUX86State *env) static struct { const char *desc; struct { - uint32_t fw; + uint32_t func; + int reg; uint32_t bits; } flags[2]; uint64_t dependencies; @@ -809,25 +810,25 @@ static struct { [HYPERV_FEAT_RELAXED] =3D { .desc =3D "relaxed timing (hv-relaxed)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_HYPERCALL_AVAILABLE}, - {.fw =3D FEAT_HV_RECOMM_EAX, + {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, .bits =3D HV_RELAXED_TIMING_RECOMMENDED} } }, [HYPERV_FEAT_VAPIC] =3D { .desc =3D "virtual APIC (hv-vapic)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_HYPERCALL_AVAILABLE | HV_APIC_ACCESS_AVAILABLE}, - {.fw =3D FEAT_HV_RECOMM_EAX, + {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, .bits =3D HV_APIC_ACCESS_RECOMMENDED} } }, [HYPERV_FEAT_TIME] =3D { .desc =3D "clocksources (hv-time)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_HYPERCALL_AVAILABLE | HV_TIME_REF_COUNT_AVAILABL= E | HV_REFERENCE_TSC_AVAILABLE} } @@ -835,42 +836,42 @@ static struct { [HYPERV_FEAT_CRASH] =3D { .desc =3D "crash MSRs (hv-crash)", .flags =3D { - {.fw =3D FEAT_HYPERV_EDX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EDX, .bits =3D HV_GUEST_CRASH_MSR_AVAILABLE} } }, [HYPERV_FEAT_RESET] =3D { .desc =3D "reset MSR (hv-reset)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_RESET_AVAILABLE} } }, [HYPERV_FEAT_VPINDEX] =3D { .desc =3D "VP_INDEX MSR (hv-vpindex)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_VP_INDEX_AVAILABLE} } }, [HYPERV_FEAT_RUNTIME] =3D { .desc =3D "VP_RUNTIME MSR (hv-runtime)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_VP_RUNTIME_AVAILABLE} } }, [HYPERV_FEAT_SYNIC] =3D { .desc =3D "synthetic interrupt controller (hv-synic)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_SYNIC_AVAILABLE} } }, [HYPERV_FEAT_STIMER] =3D { .desc =3D "synthetic timers (hv-stimer)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_SYNTIMERS_AVAILABLE} }, .dependencies =3D BIT(HYPERV_FEAT_SYNIC) | BIT(HYPERV_FEAT_TIME) @@ -878,23 +879,23 @@ static struct { [HYPERV_FEAT_FREQUENCIES] =3D { .desc =3D "frequency MSRs (hv-frequencies)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_ACCESS_FREQUENCY_MSRS}, - {.fw =3D FEAT_HYPERV_EDX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EDX, .bits =3D HV_FREQUENCY_MSRS_AVAILABLE} } }, [HYPERV_FEAT_REENLIGHTENMENT] =3D { .desc =3D "reenlightenment MSRs (hv-reenlightenment)", .flags =3D { - {.fw =3D FEAT_HYPERV_EAX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, .bits =3D HV_ACCESS_REENLIGHTENMENTS_CONTROL} } }, [HYPERV_FEAT_TLBFLUSH] =3D { .desc =3D "paravirtualized TLB flush (hv-tlbflush)", .flags =3D { - {.fw =3D FEAT_HV_RECOMM_EAX, + {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, .bits =3D HV_REMOTE_TLB_FLUSH_RECOMMENDED | HV_EX_PROCESSOR_MASKS_RECOMMENDED} }, @@ -903,7 +904,7 @@ static struct { [HYPERV_FEAT_EVMCS] =3D { .desc =3D "enlightened VMCS (hv-evmcs)", .flags =3D { - {.fw =3D FEAT_HV_RECOMM_EAX, + {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, .bits =3D HV_ENLIGHTENED_VMCS_RECOMMENDED} }, .dependencies =3D BIT(HYPERV_FEAT_VAPIC) @@ -911,7 +912,7 @@ static struct { [HYPERV_FEAT_IPI] =3D { .desc =3D "paravirtualized IPI (hv-ipi)", .flags =3D { - {.fw =3D FEAT_HV_RECOMM_EAX, + {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, .bits =3D HV_CLUSTER_IPI_RECOMMENDED | HV_EX_PROCESSOR_MASKS_RECOMMENDED} }, @@ -920,7 +921,7 @@ static struct { [HYPERV_FEAT_STIMER_DIRECT] =3D { .desc =3D "direct mode synthetic timers (hv-stimer-direct)", .flags =3D { - {.fw =3D FEAT_HYPERV_EDX, + {.func =3D HV_CPUID_FEATURES, .reg =3D R_EDX, .bits =3D HV_STIMER_DIRECT_MODE_AVAILABLE} }, .dependencies =3D BIT(HYPERV_FEAT_STIMER) @@ -1066,48 +1067,6 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid_leg= acy(CPUState *cs) return cpuid; } =20 -static int hv_cpuid_get_fw(struct kvm_cpuid2 *cpuid, int fw, uint32_t *r) -{ - struct kvm_cpuid_entry2 *entry; - uint32_t func; - int reg; - - switch (fw) { - case FEAT_HYPERV_EAX: - reg =3D R_EAX; - func =3D HV_CPUID_FEATURES; - break; - case FEAT_HYPERV_EDX: - reg =3D R_EDX; - func =3D HV_CPUID_FEATURES; - break; - case FEAT_HV_RECOMM_EAX: - reg =3D R_EAX; - func =3D HV_CPUID_ENLIGHTMENT_INFO; - break; - default: - return -EINVAL; - } - - entry =3D cpuid_find_entry(cpuid, func, 0); - if (!entry) { - return -ENOENT; - } - - switch (reg) { - case R_EAX: - *r =3D entry->eax; - break; - case R_EDX: - *r =3D entry->edx; - break; - default: - return -EINVAL; - } - - return 0; -} - static uint32_t hv_cpuid_get_host(struct kvm_cpuid2 *cpuid, uint32_t func, int reg) { @@ -1123,18 +1082,20 @@ static uint32_t hv_cpuid_get_host(struct kvm_cpuid2= *cpuid, uint32_t func, =20 static bool hyperv_feature_supported(struct kvm_cpuid2 *cpuid, int feature) { - uint32_t r, fw, bits; - int i; + uint32_t func, bits; + int i, reg; =20 for (i =3D 0; i < ARRAY_SIZE(kvm_hyperv_properties[feature].flags); i+= +) { - fw =3D kvm_hyperv_properties[feature].flags[i].fw; + + func =3D kvm_hyperv_properties[feature].flags[i].func; + reg =3D kvm_hyperv_properties[feature].flags[i].reg; bits =3D kvm_hyperv_properties[feature].flags[i].bits; =20 - if (!fw) { + if (!func) { continue; } =20 - if (hv_cpuid_get_fw(cpuid, fw, &r) || (r & bits) !=3D bits) { + if ((hv_cpuid_get_host(cpuid, func, reg) & bits) !=3D bits) { return false; } } @@ -1184,7 +1145,7 @@ static int hv_cpuid_check_and_set(CPUState *cs, struc= t kvm_cpuid2 *cpuid, return 0; } =20 -static uint32_t hv_build_cpuid_leaf(CPUState *cs, uint32_t fw) +static uint32_t hv_build_cpuid_leaf(CPUState *cs, uint32_t func, int reg) { X86CPU *cpu =3D X86_CPU(cs); uint32_t r =3D 0; @@ -1196,7 +1157,10 @@ static uint32_t hv_build_cpuid_leaf(CPUState *cs, ui= nt32_t fw) } =20 for (j =3D 0; j < ARRAY_SIZE(kvm_hyperv_properties[i].flags); j++)= { - if (kvm_hyperv_properties[i].flags[j].fw !=3D fw) { + if (kvm_hyperv_properties[i].flags[j].func !=3D func) { + continue; + } + if (kvm_hyperv_properties[i].flags[j].reg !=3D reg) { continue; } =20 @@ -1348,16 +1312,16 @@ static int hyperv_handle_properties(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_FEATURES; - c->eax =3D hv_build_cpuid_leaf(cs, FEAT_HYPERV_EAX); - c->ebx =3D hv_build_cpuid_leaf(cs, FEAT_HYPERV_EBX); - c->edx =3D hv_build_cpuid_leaf(cs, FEAT_HYPERV_EDX); + c->eax =3D hv_build_cpuid_leaf(cs, HV_CPUID_FEATURES, R_EAX); + c->ebx =3D hv_build_cpuid_leaf(cs, HV_CPUID_FEATURES, R_EBX); + c->edx =3D hv_build_cpuid_leaf(cs, HV_CPUID_FEATURES, R_EDX); =20 /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ c->edx |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE; =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_ENLIGHTMENT_INFO; - c->eax =3D hv_build_cpuid_leaf(cs, FEAT_HV_RECOMM_EAX); + c->eax =3D hv_build_cpuid_leaf(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EAX); c->ebx =3D cpu->hyperv_spinlock_attempts; =20 if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571756; cv=none; d=zohomail.com; s=zohoarc; b=EcB6QtevCqQ5LZ4ReNiNW1Dphq17tN8Wcb7B/qLrFT/edeiaibKGt/ZwryIAy2YkjQKefMb1vkH/0ORPgViLRjcCt1k5a52D+yiaO4NTKuWe/GFo6QuwOQ7fIIYjjvg3E7wt4xhhUKnjTKGjnA8/ZEfh9CIdgdOp6OL90JEZFeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571756; 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=wPnj6KgAdjDpm2bFOzx8pD3GN3IHJ5shv++eHkyj2m8=; b=nDTBg2KuKkXk+KRsIZZjHoPFTfa2Gk7hp8PloCe0tpLNiFJ2SKnWmv1i0wnm3jTXmOoNi3018thSxeKTWWGBE7NS4of1dpxERowPjNv1lVPZvorksgcUw24ymrced03oEeFuWpfsDJgI+GpL5K98As0UiEGP7d+jijxZOXUHV5g= 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+importer2=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 162257175642374.03285276006568; Tue, 1 Jun 2021 11:22:36 -0700 (PDT) Received: from localhost ([::1]:52964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo92B-0007aI-7T for importer2@patchew.org; Tue, 01 Jun 2021 14:22:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qk-0002eF-8n for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qa-0005nM-DU for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-333-geny2meVM2y_LUses_MLyg-1; Tue, 01 Jun 2021 14:10:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13B82107ACCA; Tue, 1 Jun 2021 18:10:31 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE4BC5D6D5; Tue, 1 Jun 2021 18:10:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wPnj6KgAdjDpm2bFOzx8pD3GN3IHJ5shv++eHkyj2m8=; b=bb9PxIZwv5D4udLOAiJHMeEGiBNCkgF9wOpeaqRcQNIwE9LB41Rv1JZema7GeBG7qroflz ZGJ7QOHXZI0+nJEERudqzVo00ZFISBfn1C3Tf6yyQVqmPfSc9NriXu0uI/7Efs0SzFCorO LDiIpxIDwgC0cJuzpiMrTXJ4jmX04Rs= X-MC-Unique: geny2meVM2y_LUses_MLyg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 15/24] i386: introduce hv_cpuid_cache Date: Tue, 1 Jun 2021 14:10:05 -0400 Message-Id: <20210601181014.2568861-16-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Just like with cpuid_cache, it makes no sense to call KVM_GET_SUPPORTED_HV_CPUID more than once and instead of (ab)using env->features[] and/or trying to keep all the code in one place, it is better to introduce persistent hv_cpuid_cache and hv_cpuid_get_host() accessor to it. Note, hv_cpuid_get_fw() is converted to using hv_cpuid_get_host() just to be removed later with Hyper-V specific feature words. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-9-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 109 ++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 6d6afd83e3a..2dd60fcaacf 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -129,6 +129,7 @@ static int has_exception_payload; static bool has_msr_mcg_ext_ctl; =20 static struct kvm_cpuid2 *cpuid_cache; +static struct kvm_cpuid2 *hv_cpuid_cache; static struct kvm_msr_list *kvm_feature_msrs; =20 int kvm_has_pit_state2(void) @@ -1067,10 +1068,25 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid_le= gacy(CPUState *cs) return cpuid; } =20 -static uint32_t hv_cpuid_get_host(struct kvm_cpuid2 *cpuid, uint32_t func, - int reg) +static uint32_t hv_cpuid_get_host(CPUState *cs, uint32_t func, int reg) { struct kvm_cpuid_entry2 *entry; + struct kvm_cpuid2 *cpuid; + + if (hv_cpuid_cache) { + cpuid =3D hv_cpuid_cache; + } else { + if (kvm_check_extension(kvm_state, KVM_CAP_HYPERV_CPUID) > 0) { + cpuid =3D get_supported_hv_cpuid(cs); + } else { + cpuid =3D get_supported_hv_cpuid_legacy(cs); + } + hv_cpuid_cache =3D cpuid; + } + + if (!cpuid) { + return 0; + } =20 entry =3D cpuid_find_entry(cpuid, func, 0); if (!entry) { @@ -1080,7 +1096,7 @@ static uint32_t hv_cpuid_get_host(struct kvm_cpuid2 *= cpuid, uint32_t func, return cpuid_entry_get_reg(entry, reg); } =20 -static bool hyperv_feature_supported(struct kvm_cpuid2 *cpuid, int feature) +static bool hyperv_feature_supported(CPUState *cs, int feature) { uint32_t func, bits; int i, reg; @@ -1095,7 +1111,7 @@ static bool hyperv_feature_supported(struct kvm_cpuid= 2 *cpuid, int feature) continue; } =20 - if ((hv_cpuid_get_host(cpuid, func, reg) & bits) !=3D bits) { + if ((hv_cpuid_get_host(cs, func, reg) & bits) !=3D bits) { return false; } } @@ -1103,8 +1119,7 @@ static bool hyperv_feature_supported(struct kvm_cpuid= 2 *cpuid, int feature) return true; } =20 -static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid, - int feature) +static int hv_cpuid_check_and_set(CPUState *cs, int feature) { X86CPU *cpu =3D X86_CPU(cs); uint64_t deps; @@ -1127,7 +1142,7 @@ static int hv_cpuid_check_and_set(CPUState *cs, struc= t kvm_cpuid2 *cpuid, deps &=3D ~(1ull << dep_feat); } =20 - if (!hyperv_feature_supported(cpuid, feature)) { + if (!hyperv_feature_supported(cs, feature)) { if (hyperv_feat_enabled(cpu, feature)) { fprintf(stderr, "Hyper-V %s is not supported by kernel\n", @@ -1180,7 +1195,6 @@ static int hyperv_handle_properties(CPUState *cs, struct kvm_cpuid_entry2 *cpuid_ent) { X86CPU *cpu =3D X86_CPU(cs); - struct kvm_cpuid2 *cpuid; struct kvm_cpuid_entry2 *c; uint32_t cpuid_i =3D 0; int r; @@ -1206,19 +1220,13 @@ static int hyperv_handle_properties(CPUState *cs, } } =20 - if (kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_CPUID) > 0) { - cpuid =3D get_supported_hv_cpuid(cs); - } else { - cpuid =3D get_supported_hv_cpuid_legacy(cs); - } - if (cpu->hyperv_passthrough) { cpu->hyperv_vendor_id[0] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_= EBX); + hv_cpuid_get_host(cs, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_EBX= ); cpu->hyperv_vendor_id[1] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_= ECX); + hv_cpuid_get_host(cs, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_ECX= ); cpu->hyperv_vendor_id[2] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_= EDX); + hv_cpuid_get_host(cs, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_EDX= ); cpu->hyperv_vendor =3D g_realloc(cpu->hyperv_vendor, sizeof(cpu->hyperv_vendor_id) + 1); memcpy(cpu->hyperv_vendor, cpu->hyperv_vendor_id, @@ -1226,52 +1234,52 @@ static int hyperv_handle_properties(CPUState *cs, cpu->hyperv_vendor[sizeof(cpu->hyperv_vendor_id)] =3D 0; =20 cpu->hyperv_interface_id[0] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_EAX); + hv_cpuid_get_host(cs, HV_CPUID_INTERFACE, R_EAX); cpu->hyperv_interface_id[1] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_EBX); + hv_cpuid_get_host(cs, HV_CPUID_INTERFACE, R_EBX); cpu->hyperv_interface_id[2] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_ECX); + hv_cpuid_get_host(cs, HV_CPUID_INTERFACE, R_ECX); cpu->hyperv_interface_id[3] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_INTERFACE, R_EDX); + hv_cpuid_get_host(cs, HV_CPUID_INTERFACE, R_EDX); =20 cpu->hyperv_version_id[0] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_EAX); + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EAX); cpu->hyperv_version_id[1] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_EBX); + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EBX); cpu->hyperv_version_id[2] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_ECX); + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_ECX); cpu->hyperv_version_id[3] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_VERSION, R_EDX); + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EDX); =20 - cpu->hv_max_vps =3D hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LI= MITS, + cpu->hv_max_vps =3D hv_cpuid_get_host(cs, HV_CPUID_IMPLEMENT_LIMIT= S, R_EAX); cpu->hyperv_limits[0] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LIMITS, R_EBX); + hv_cpuid_get_host(cs, HV_CPUID_IMPLEMENT_LIMITS, R_EBX); cpu->hyperv_limits[1] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LIMITS, R_ECX); + hv_cpuid_get_host(cs, HV_CPUID_IMPLEMENT_LIMITS, R_ECX); cpu->hyperv_limits[2] =3D - hv_cpuid_get_host(cpuid, HV_CPUID_IMPLEMENT_LIMITS, R_EDX); + hv_cpuid_get_host(cs, HV_CPUID_IMPLEMENT_LIMITS, R_EDX); =20 cpu->hyperv_spinlock_attempts =3D - hv_cpuid_get_host(cpuid, HV_CPUID_ENLIGHTMENT_INFO, R_EBX); + hv_cpuid_get_host(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EBX); } =20 /* Features */ - r =3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RELAXED); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_VAPIC); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_TIME); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_CRASH); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RESET); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_VPINDEX); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RUNTIME); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_SYNIC); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_STIMER); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_FREQUENCIES); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_REENLIGHTENMENT); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_TLBFLUSH); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_EVMCS); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_IPI); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_STIMER_DIRECT); + r =3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_RELAXED); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_VAPIC); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_TIME); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_CRASH); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_RESET); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_VPINDEX); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_RUNTIME); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_SYNIC); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_STIMER); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_FREQUENCIES); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_REENLIGHTENMENT); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_TLBFLUSH); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_EVMCS); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_IPI); + r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_STIMER_DIRECT); =20 /* Additional dependencies not covered by kvm_hyperv_properties[] */ if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC) && @@ -1284,8 +1292,7 @@ static int hyperv_handle_properties(CPUState *cs, } =20 if (r) { - r =3D -ENOSYS; - goto free; + return -ENOSYS; } =20 c =3D &cpuid_ent[cpuid_i++]; @@ -1327,7 +1334,7 @@ static int hyperv_handle_properties(CPUState *cs, if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { c->eax |=3D HV_NO_NONARCH_CORESHARING; } else if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO) { - c->eax |=3D hv_cpuid_get_host(cpuid, HV_CPUID_ENLIGHTMENT_INFO, R_= EAX) & + c->eax |=3D hv_cpuid_get_host(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EAX= ) & HV_NO_NONARCH_CORESHARING; } =20 @@ -1352,12 +1359,8 @@ static int hyperv_handle_properties(CPUState *cs, c->function =3D HV_CPUID_NESTED_FEATURES; c->eax =3D cpu->hyperv_nested[0]; } - r =3D cpuid_i; =20 -free: - g_free(cpuid); - - return r; + return cpuid_i; } =20 static Error *hv_passthrough_mig_blocker; --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571972; cv=none; d=zohomail.com; s=zohoarc; b=mHxPzHlILHSS+zWBCippPRTW2haZMcxLFDsM1w6CguJYcSGmYb9xdG3yVtoOHoDqW/R9QrtTuygtY/u1Tey0lbyLtqjnOqDg6my5P2nSG8Hl9/PTq2JViNdlZ3HJhnON4jUZOU9/G+OcMr/wvAk8w07U2bo6LJXrGOa8MJBjxUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571972; 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=PVppsRVr9TNNGmsrGCjZHrnCVid3ZaBVsRLFFY6R+Jo=; b=MFfyZgYEyhy3a0Sb6KwYBuyr04VCokyj5mz1PmaSXLqSiX01igpm5w1mDoXSaJvgh7Kit59H5sVlT8thqQQkzeT4TVyv6rV4ycaqbXvm015FUeEBKbZyfat61oMD9F3swm+/g1RxWzy+piHofsRba0AhUWl08JGsA8j/aSqMzeg= 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+importer2=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 1622571972071559.488260307022; Tue, 1 Jun 2021 11:26:12 -0700 (PDT) Received: from localhost ([::1]:38506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo95f-0008Q3-2v for importer2@patchew.org; Tue, 01 Jun 2021 14:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qi-0002am-KI for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qb-0005na-FU for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-kJevgCvONOa3KLwy81rKKg-1; Tue, 01 Jun 2021 14:10:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D34A3801817; Tue, 1 Jun 2021 18:10:31 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DEE65C1BB; Tue, 1 Jun 2021 18:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PVppsRVr9TNNGmsrGCjZHrnCVid3ZaBVsRLFFY6R+Jo=; b=Z5Z17Lca97zDkqWyRGhzfmwh9zXYgjeUg+BJZG85T2DUPlzVngbODZ3qXp9lapC5ZjofQA IbfXi58UVx2UL3QCxaxdyl6g6UbyVP8PGmQhdGtyOkhetSMlQMb2tHVwNJJbsOqLpjX+mt XrUpApe+vrrv1zrLQv2FFwJYgXFEKVs= X-MC-Unique: kJevgCvONOa3KLwy81rKKg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 16/24] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids() Date: Tue, 1 Jun 2021 14:10:06 -0400 Message-Id: <20210601181014.2568861-17-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov The intention is to call hyperv_expand_features() early, before vCPUs are created and use the acquired data later when we set guest visible CPUID data. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-10-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 2dd60fcaacf..10c836a2bf1 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1187,16 +1187,15 @@ static uint32_t hv_build_cpuid_leaf(CPUState *cs, u= int32_t func, int reg) } =20 /* - * Fill in Hyper-V CPUIDs. Returns the number of entries filled in cpuid_e= nt in - * case of success, errno < 0 in case of failure and 0 when no Hyper-V - * extentions are enabled. + * Expand Hyper-V CPU features. In partucular, check that all the requested + * features are supported by the host and the sanity of the configuration + * (that all the required dependencies are included). Also, this takes care + * of 'hv_passthrough' mode and fills the environment with all supported + * Hyper-V features. */ -static int hyperv_handle_properties(CPUState *cs, - struct kvm_cpuid_entry2 *cpuid_ent) +static int hyperv_expand_features(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); - struct kvm_cpuid_entry2 *c; - uint32_t cpuid_i =3D 0; int r; =20 if (!hyperv_enabled(cpu)) @@ -1295,6 +1294,19 @@ static int hyperv_handle_properties(CPUState *cs, return -ENOSYS; } =20 + return 0; +} + +/* + * Fill in Hyper-V CPUIDs. Returns the number of entries filled in cpuid_e= nt. + */ +static int hyperv_fill_cpuids(CPUState *cs, + struct kvm_cpuid_entry2 *cpuid_ent) +{ + X86CPU *cpu =3D X86_CPU(cs); + struct kvm_cpuid_entry2 *c; + uint32_t cpuid_i =3D 0; + c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VENDOR_AND_MAX_FUNCTIONS; c->eax =3D hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) ? @@ -1502,11 +1514,13 @@ int kvm_arch_init_vcpu(CPUState *cs) env->apic_bus_freq =3D KVM_APIC_BUS_FREQUENCY; =20 /* Paravirtualization CPUIDs */ - r =3D hyperv_handle_properties(cs, cpuid_data.entries); + r =3D hyperv_expand_features(cs); if (r < 0) { return r; - } else if (r > 0) { - cpuid_i =3D r; + } + + if (hyperv_enabled(cpu)) { + cpuid_i =3D hyperv_fill_cpuids(cs, cpuid_data.entries); kvm_base =3D KVM_CPUID_SIGNATURE_NEXT; has_msr_hv_hypercall =3D true; } --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571657; cv=none; d=zohomail.com; s=zohoarc; b=EnOENWFJMTJTj3Dj1peoKbBF0XrNCg8FSmrdCSBFDuQLgx1b/zZM2agR8s8aRG3aVuQAqST6ZZ6L9bm6pX3uddaUQ4R/2t7zte6xU5ykXI5CA/NeM0a8rwNJVfUMAuNyniAehT5fOd8IbsWhV6Tl1ItoEYoakDlqbUbAVUXPy/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571657; 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=d6y7y7Jd51cGHIFvnpnnWlxyhoDHCuSXT9SHrYrO9Hs=; b=LGoWGRCDK3LaZAonDDs5a6eehaZ2XayzwZlMReYTFrA/KLWDlA8Tr3/IXIkGcJvblI9SuMhDKVd8E3l+Qros+aXlS4R8rnV7rhY80T1wukeRjZFRhzpFey5yJ0vZoQaEsy12shnHbl0Mz6mDFNYWeFDyB5Y++8ztwcm1Uq6bW/0= 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+importer2=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 1622571657027605.4761062827583; Tue, 1 Jun 2021 11:20:57 -0700 (PDT) Received: from localhost ([::1]:46466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo90X-0003DO-PV for importer2@patchew.org; Tue, 01 Jun 2021 14:20:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qf-0002WH-Uy for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23319) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qa-0005nE-1G for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-OJyu_0WgPViZKeWcmetULA-1; Tue, 01 Jun 2021 14:10:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98A6E802690; Tue, 1 Jun 2021 18:10:32 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B08360C4A; Tue, 1 Jun 2021 18:10:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d6y7y7Jd51cGHIFvnpnnWlxyhoDHCuSXT9SHrYrO9Hs=; b=WwK+Gco6XIHZHSzg4Xi9JzNVJVqr1oqfNLaay0nQgzQZYBJ+/m9dRRq0JM21D7R2TkWc/v Qxzp+r45YSihQ+G2T+WG4bYBvclsUF073vFQlsl1o3pt09LJEY3aMdG9LItKOCAy5BEoTo ioOGtX9Z1wKpgwWKrPoAzIM5OEpHmj4= X-MC-Unique: OJyu_0WgPViZKeWcmetULA-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 17/24] i386: move eVMCS enablement to hyperv_init_vcpu() Date: Tue, 1 Jun 2021 14:10:07 -0400 Message-Id: <20210601181014.2568861-18-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov hyperv_expand_features() will be called before we create vCPU so evmcs enablement should go away. hyperv_init_vcpu() looks like the right place. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-11-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 60 ++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 10c836a2bf1..57282246c64 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -963,6 +963,7 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUSta= te *cs) { struct kvm_cpuid2 *cpuid; int max =3D 7; /* 0x40000000..0x40000005, 0x4000000A */ + int i; =20 /* * When the buffer is too small, KVM_GET_SUPPORTED_HV_CPUID fails with @@ -972,6 +973,22 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUSt= ate *cs) while ((cpuid =3D try_get_hv_cpuid(cs, max)) =3D=3D NULL) { max++; } + + /* + * KVM_GET_SUPPORTED_HV_CPUID does not set EVMCS CPUID bit before + * KVM_CAP_HYPERV_ENLIGHTENED_VMCS is enabled but we want to get the + * information early, just check for the capability and set the bit + * manually. + */ + if (kvm_check_extension(cs->kvm_state, + KVM_CAP_HYPERV_ENLIGHTENED_VMCS) > 0) { + for (i =3D 0; i < cpuid->nent; i++) { + if (cpuid->entries[i].function =3D=3D HV_CPUID_ENLIGHTMENT_INF= O) { + cpuid->entries[i].eax |=3D HV_ENLIGHTENED_VMCS_RECOMMENDED; + } + } + } + return cpuid; } =20 @@ -1201,24 +1218,6 @@ static int hyperv_expand_features(CPUState *cs) if (!hyperv_enabled(cpu)) return 0; =20 - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) || - cpu->hyperv_passthrough) { - uint16_t evmcs_version; - - r =3D kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENLIGHTENED_VMCS, 0, - (uintptr_t)&evmcs_version); - - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) && r) { - fprintf(stderr, "Hyper-V %s is not supported by kernel\n", - kvm_hyperv_properties[HYPERV_FEAT_EVMCS].desc); - return -ENOSYS; - } - - if (!r) { - cpu->hyperv_nested[0] =3D evmcs_version; - } - } - if (cpu->hyperv_passthrough) { cpu->hyperv_vendor_id[0] =3D hv_cpuid_get_host(cs, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, R_EBX= ); @@ -1456,6 +1455,21 @@ static int hyperv_init_vcpu(X86CPU *cpu) } } =20 + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { + uint16_t evmcs_version; + + ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENLIGHTENED_VMCS, 0, + (uintptr_t)&evmcs_version); + + if (ret < 0) { + fprintf(stderr, "Hyper-V %s is not supported by kernel\n", + kvm_hyperv_properties[HYPERV_FEAT_EVMCS].desc); + return ret; + } + + cpu->hyperv_nested[0] =3D evmcs_version; + } + return 0; } =20 @@ -1520,6 +1534,11 @@ int kvm_arch_init_vcpu(CPUState *cs) } =20 if (hyperv_enabled(cpu)) { + r =3D hyperv_init_vcpu(cpu); + if (r) { + return r; + } + cpuid_i =3D hyperv_fill_cpuids(cs, cpuid_data.entries); kvm_base =3D KVM_CPUID_SIGNATURE_NEXT; has_msr_hv_hypercall =3D true; @@ -1869,11 +1888,6 @@ int kvm_arch_init_vcpu(CPUState *cs) =20 kvm_init_msrs(cpu); =20 - r =3D hyperv_init_vcpu(cpu); - if (r) { - goto fail; - } - return 0; =20 fail: --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571865; cv=none; d=zohomail.com; s=zohoarc; b=n6/WoRvWnz93NyZsmDMFWcTbqinZTz1npgnCv7hvae9ySalwKe5bN1zGbqVSDvJUdJRjA1jpS+CniN1m629hh7qNnTxGlW7pQlFNDQOgulRroq1i796N+NFVLAg3Ppf9sTRCGAZoI//qRPZSCjOEmURAL29uLTqeLdaTF/534Ho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571865; 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=bOC379+PLnI7B1r55Low6cagczWWE2KNlM3WLJg+sM8=; b=JSCrIi1m/Dx+qXM5tXn6SkTpy+Kr/0yMWrHKrGlUdFHJr1jNDr679WPZhzZ0hspnwfT5Fly63N4mO0PbGaMy+9SrcVZPn2bh37UJbL8uPNDcbvGNc5/YcWRFYh7WutacAqkArH3f/r0hOscoLz48TFpRNqywxoewXWmerZn4niI= 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+importer2=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 1622571865006926.1946139982771; Tue, 1 Jun 2021 11:24:25 -0700 (PDT) Received: from localhost ([::1]:60704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo93v-0004J4-Uk for importer2@patchew.org; Tue, 01 Jun 2021 14:24:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qh-0002aQ-9f for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qa-0005nR-UG for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-539-ZFNyjIMeMkaNK17KCrIuVA-1; Tue, 01 Jun 2021 14:10:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63C3879EC5; Tue, 1 Jun 2021 18:10:33 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33E585D9D5; Tue, 1 Jun 2021 18:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bOC379+PLnI7B1r55Low6cagczWWE2KNlM3WLJg+sM8=; b=KP75kDzgoY94og7t2xF1tWqklWPETieqoURJHWZIso9DEO53qoVzkBm7k0aOg3sEPZ2r+x FS2RJmlZ9Y4Y07WJmKNME6nF4UZMTya3OpVBDolEaLKVvSCELx8rH6sfcsoWWh4fWNpEhw vT0rRzT97mEUJ6knKQrwNohlxafsXM4= X-MC-Unique: ZFNyjIMeMkaNK17KCrIuVA-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 18/24] i386: switch hyperv_expand_features() to using error_setg() Date: Tue, 1 Jun 2021 14:10:08 -0400 Message-Id: <20210601181014.2568861-19-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Use standard error_setg() mechanism in hyperv_expand_features(). Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-12-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 101 +++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 57282246c64..413f57df367 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1136,7 +1136,7 @@ static bool hyperv_feature_supported(CPUState *cs, in= t feature) return true; } =20 -static int hv_cpuid_check_and_set(CPUState *cs, int feature) +static int hv_cpuid_check_and_set(CPUState *cs, int feature, Error **errp) { X86CPU *cpu =3D X86_CPU(cs); uint64_t deps; @@ -1150,20 +1150,18 @@ static int hv_cpuid_check_and_set(CPUState *cs, int= feature) while (deps) { dep_feat =3D ctz64(deps); if (!(hyperv_feat_enabled(cpu, dep_feat))) { - fprintf(stderr, - "Hyper-V %s requires Hyper-V %s\n", - kvm_hyperv_properties[feature].desc, - kvm_hyperv_properties[dep_feat].desc); - return 1; + error_setg(errp, "Hyper-V %s requires Hyper-V %s", + kvm_hyperv_properties[feature].desc, + kvm_hyperv_properties[dep_feat].desc); + return 1; } deps &=3D ~(1ull << dep_feat); } =20 if (!hyperv_feature_supported(cs, feature)) { if (hyperv_feat_enabled(cpu, feature)) { - fprintf(stderr, - "Hyper-V %s is not supported by kernel\n", - kvm_hyperv_properties[feature].desc); + error_setg(errp, "Hyper-V %s is not supported by kernel", + kvm_hyperv_properties[feature].desc); return 1; } else { return 0; @@ -1210,13 +1208,12 @@ static uint32_t hv_build_cpuid_leaf(CPUState *cs, u= int32_t func, int reg) * of 'hv_passthrough' mode and fills the environment with all supported * Hyper-V features. */ -static int hyperv_expand_features(CPUState *cs) +static void hyperv_expand_features(CPUState *cs, Error **errp) { X86CPU *cpu =3D X86_CPU(cs); - int r; =20 if (!hyperv_enabled(cpu)) - return 0; + return; =20 if (cpu->hyperv_passthrough) { cpu->hyperv_vendor_id[0] =3D @@ -1263,37 +1260,60 @@ static int hyperv_expand_features(CPUState *cs) } =20 /* Features */ - r =3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_RELAXED); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_VAPIC); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_TIME); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_CRASH); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_RESET); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_VPINDEX); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_RUNTIME); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_SYNIC); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_STIMER); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_FREQUENCIES); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_REENLIGHTENMENT); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_TLBFLUSH); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_EVMCS); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_IPI); - r |=3D hv_cpuid_check_and_set(cs, HYPERV_FEAT_STIMER_DIRECT); + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_RELAXED, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_VAPIC, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_TIME, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_CRASH, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_RESET, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_VPINDEX, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_RUNTIME, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_SYNIC, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_STIMER, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_FREQUENCIES, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_REENLIGHTENMENT, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_TLBFLUSH, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_EVMCS, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_IPI, errp)) { + return; + } + if (hv_cpuid_check_and_set(cs, HYPERV_FEAT_STIMER_DIRECT, errp)) { + return; + } =20 /* Additional dependencies not covered by kvm_hyperv_properties[] */ if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC) && !cpu->hyperv_synic_kvm_only && !hyperv_feat_enabled(cpu, HYPERV_FEAT_VPINDEX)) { - fprintf(stderr, "Hyper-V %s requires Hyper-V %s\n", - kvm_hyperv_properties[HYPERV_FEAT_SYNIC].desc, - kvm_hyperv_properties[HYPERV_FEAT_VPINDEX].desc); - r |=3D 1; - } - - if (r) { - return -ENOSYS; + error_setg(errp, "Hyper-V %s requires Hyper-V %s", + kvm_hyperv_properties[HYPERV_FEAT_SYNIC].desc, + kvm_hyperv_properties[HYPERV_FEAT_VPINDEX].desc); } - - return 0; } =20 /* @@ -1528,9 +1548,10 @@ int kvm_arch_init_vcpu(CPUState *cs) env->apic_bus_freq =3D KVM_APIC_BUS_FREQUENCY; =20 /* Paravirtualization CPUIDs */ - r =3D hyperv_expand_features(cs); - if (r < 0) { - return r; + hyperv_expand_features(cs, &local_err); + if (local_err) { + error_report_err(local_err); + return -ENOSYS; } =20 if (hyperv_enabled(cpu)) { --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571852; cv=none; d=zohomail.com; s=zohoarc; b=UtUUWTve0v/qqtcZPk3BBmflbMNsCRhGP7fuZrvXx7WH6W/aNIZHlCKJIgSsQxwcy9K+rqcVOMQs0ZWiXKFuUlDkB1A8WgceSizOT8WCLT+QWriZa6gt7i7M+PdOaf//76W/3wYx7CLZE0O3r5SWnIwqVfgIQB9Qzs1AVZL2EVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571852; 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=j1noZ2pC0pkRSBNQpcubRWQXcQ7ahJ5fRgU2Xrptb8o=; b=meL8BIK7PBUk19EOh+Y3Nu217zxbZRHPJNTdzI8T2e6kynEzy7tClka4NzpPQmWbo/Gey7e6BWhHtidShnHakgFT8vVRz0OvWtsUqhc3RqmkPpu5/VrRGgUkN/nq3OfMTElSKd+A93QtOpa+S/mbaO+iHnc4p4j7mXiknWb0OIM= 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+importer2=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 1622571852689558.4613881278125; Tue, 1 Jun 2021 11:24:12 -0700 (PDT) Received: from localhost ([::1]:59570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo93j-0003YH-Jf for importer2@patchew.org; Tue, 01 Jun 2021 14:24:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qt-0002pl-Mr for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8ql-0005sX-H6 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-P6Uanhb0MK6gZfk4SyowEw-1; Tue, 01 Jun 2021 14:10:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4EF51107ACC7; Tue, 1 Jun 2021 18:10:34 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1524F1042A46; Tue, 1 Jun 2021 18:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j1noZ2pC0pkRSBNQpcubRWQXcQ7ahJ5fRgU2Xrptb8o=; b=HBaEmK24zi1PwgsS3/pfEjCQarCIvImSRvYtk5/mfRyk+9xP85AultDzNklvRBMt4hf0pV N/nSd5QrD8SnKLTWFfvMhtb/wIZcLXrF3BUvYm+4AcAN3/xykVIvHsqpVPnz1/0WcEjxWm Z5AdEtmHJZ2vc/E/T+a4AO5wyL1SsQU= X-MC-Unique: P6Uanhb0MK6gZfk4SyowEw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 19/24] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size Date: Tue, 1 Jun 2021 14:10:09 -0400 Message-Id: <20210601181014.2568861-20-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov SYNDBG leaves were recently (Linux-5.8) added to KVM but we haven't updated the expected size of KVM_GET_SUPPORTED_HV_CPUID output in KVM so we now make serveral tries before succeeding. Update the default. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-13-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 413f57df367..9005a4233f0 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -962,7 +962,8 @@ static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs= , int max) static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUState *cs) { struct kvm_cpuid2 *cpuid; - int max =3D 7; /* 0x40000000..0x40000005, 0x4000000A */ + /* 0x40000000..0x40000005, 0x4000000A, 0x40000080..0x40000080 leaves */ + int max =3D 10; int i; =20 /* --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571495; cv=none; d=zohomail.com; s=zohoarc; b=VFt+LRIHNxKxRSVZXXup1qfXgXujj5I0of0jH9+fzsMCe1gLAilrPQJXRCnJ4NiRl/y4ZV67kY9QTrIzlG19KDPZBOZVJH7+dDJa07e7nmULX6Hm8dWLSTas08eLdAfR7QVyCViAEXJIWDkWavb6tk/pP3Xwgbt8wB+lmpBg2Dc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571495; 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=zD0Azp2Y+MAblZ6/9zuthqoOt8TJkZ5IA7dwFy6K7Gk=; b=LAuLOxaClavzM1mEaxdSxM1tDEbhU75irwXNsOVrM3rGaH2Kdf+ScWtdnFNIHX83pmERSYYHD4uCEfkRXFmW7ewTljesWOhbbqCC+ABTomf5u56Qar9g8aKiLRJoIAqDADoVwe3K/zhou6sgRhYukp2JRlTsj+Kg2ZgWhNGJ7rk= 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+importer2=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 1622571495766653.3893601939479; Tue, 1 Jun 2021 11:18:15 -0700 (PDT) Received: from localhost ([::1]:34586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8xy-0003nu-Ot for importer2@patchew.org; Tue, 01 Jun 2021 14:18:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qj-0002cZ-3P for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qf-0005oG-LF for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-kyafcdGgMO2No5yiOIHOKw-1; Tue, 01 Jun 2021 14:10:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E3A8107ACCD; Tue, 1 Jun 2021 18:10:35 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED93AE2D4; Tue, 1 Jun 2021 18:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zD0Azp2Y+MAblZ6/9zuthqoOt8TJkZ5IA7dwFy6K7Gk=; b=U4tjTCxlMlrwFhP3WYyMy5sMs6yImyj2aexkacszEKyqwAhbudyH4ZRcX8FBMr2052tnsG xZDYhMoCeUuexzx59MVR1gRMFZt7o5y0/OP/uYvDWXfMq5LKZUICl7Y/Clnli3VK4nz95v uUUZFpTP2w+0aWp4MQwYjSKJz0U4I0s= X-MC-Unique: kyafcdGgMO2No5yiOIHOKw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 20/24] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one Date: Tue, 1 Jun 2021 14:10:10 -0400 Message-Id: <20210601181014.2568861-21-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov KVM_GET_SUPPORTED_HV_CPUID was made a system wide ioctl which can be called prior to creating vCPUs and we are going to use that to expand Hyper-V cpu features early. Use it when it is supported by KVM. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-14-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 9005a4233f0..6bcb74b1d84 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -929,7 +929,8 @@ static struct { }, }; =20 -static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max) +static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, + bool do_sys_ioctl) { struct kvm_cpuid2 *cpuid; int r, size; @@ -938,7 +939,11 @@ static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *c= s, int max) cpuid =3D g_malloc0(size); cpuid->nent =3D max; =20 - r =3D kvm_vcpu_ioctl(cs, KVM_GET_SUPPORTED_HV_CPUID, cpuid); + if (do_sys_ioctl) { + r =3D kvm_ioctl(kvm_state, KVM_GET_SUPPORTED_HV_CPUID, cpuid); + } else { + r =3D kvm_vcpu_ioctl(cs, KVM_GET_SUPPORTED_HV_CPUID, cpuid); + } if (r =3D=3D 0 && cpuid->nent >=3D max) { r =3D -E2BIG; } @@ -965,13 +970,17 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUS= tate *cs) /* 0x40000000..0x40000005, 0x4000000A, 0x40000080..0x40000080 leaves */ int max =3D 10; int i; + bool do_sys_ioctl; + + do_sys_ioctl =3D + kvm_check_extension(kvm_state, KVM_CAP_SYS_HYPERV_CPUID) > 0; =20 /* * When the buffer is too small, KVM_GET_SUPPORTED_HV_CPUID fails with * -E2BIG, however, it doesn't report back the right size. Keep increa= sing * it and re-trying until we succeed. */ - while ((cpuid =3D try_get_hv_cpuid(cs, max)) =3D=3D NULL) { + while ((cpuid =3D try_get_hv_cpuid(cs, max, do_sys_ioctl)) =3D=3D NULL= ) { max++; } =20 @@ -981,7 +990,7 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUSta= te *cs) * information early, just check for the capability and set the bit * manually. */ - if (kvm_check_extension(cs->kvm_state, + if (!do_sys_ioctl && kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_ENLIGHTENED_VMCS) > 0) { for (i =3D 0; i < cpuid->nent; i++) { if (cpuid->entries[i].function =3D=3D HV_CPUID_ENLIGHTMENT_INF= O) { --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622572041; cv=none; d=zohomail.com; s=zohoarc; b=WYbZlQOHsfQKnq9wzQP4eTxqCiXYFBdgsOtMRpDCFCX70NW/XgA6ldr6O3SXHpt/DrnKv59aIRAXULJcF6pzo17EdSQcaqBsn28KxILakdmGdTWou4U4DDaAiVjz3Th2gRrwHYO1d0Ko9nxaOvN9BrO9kS0DjvzReP6EgBela3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622572041; 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=EmMFDD+VN1S5ts7Z5Pg8YdMr5ZYM3/+hUmq1l51iup8=; b=Uc6eiBNF08cK3jMQ/Y4/2V3N2vtouTtuPLXo2txhI7W1bOrvt3nlS7/wHB2J/IakHl9TwEdr9rJI+xc6ll5LurW/7F92Lbiit8w6KcslKpyc0nN1XYV3raqriGGdhDleDVw3yhqPwS4zUj9fjUjYROxb7amqHHfBYLzUtba5gm4= 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+importer2=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 1622572041725645.0326663899582; Tue, 1 Jun 2021 11:27:21 -0700 (PDT) Received: from localhost ([::1]:43090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo96m-00032z-KW for importer2@patchew.org; Tue, 01 Jun 2021 14:27:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qk-0002dX-11 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59985) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qf-0005ob-Lr for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-sy4GbEpEM2-4LyI-9_wgHw-1; Tue, 01 Jun 2021 14:10:36 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E12711009446; Tue, 1 Jun 2021 18:10:35 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2CD360C5B; Tue, 1 Jun 2021 18:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EmMFDD+VN1S5ts7Z5Pg8YdMr5ZYM3/+hUmq1l51iup8=; b=FSNdRmCpxy0ZHz8YhlrXZw0hhzD3aLFeq8+XQXgu3thXqK9lvo11dCRaoFxNaBkztL0t8r EOBC3bBz7Xet/OfL+T4t/q9BUVx4KtyRIj2cIpvjK4dJGpQPpVCEQ7y6/X/Pu/KH924Blg OTNb5aKmbFu4syKUC5GAyjqbM52LG3U= X-MC-Unique: sy4GbEpEM2-4LyI-9_wgHw-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 21/24] i386: use global kvm_state in hyperv_enabled() check Date: Tue, 1 Jun 2021 14:10:11 -0400 Message-Id: <20210601181014.2568861-22-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , Eduardo Habkost Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov There is no need to use vCPU-specific kvm state in hyperv_enabled() check and we need to do that when feature expansion happens early, before vCPU specific KVM state is created. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Eduardo Habkost Message-Id: <20210422161130.652779-15-vkuznets@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/kvm/kvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 6bcb74b1d84..c676ee8b38a 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -716,8 +716,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs) =20 static bool hyperv_enabled(X86CPU *cpu) { - CPUState *cs =3D CPU(cpu); - return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 && + return kvm_check_extension(kvm_state, KVM_CAP_HYPERV) > 0 && ((cpu->hyperv_spinlock_attempts !=3D HYPERV_SPINLOCK_NEVER_NOTIFY)= || cpu->hyperv_features || cpu->hyperv_passthrough); } --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571577; cv=none; d=zohomail.com; s=zohoarc; b=dMRk20MP/amXf9V7zsw8873Ui25sF2XJHz++Jt9YsTnkLykQdvh2YHsrwomfElhfwDrL24TmEJ6XHzpjEC7w4GABjmU/GQKIsyk/6xEhr8dyJVAsDQ/KetWn9U/IXBo+MfPKBLUZHK4r7AdoKYYdqDxtmCYLOyMGsBmKzswCq8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571577; 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=OiznvOiw988Q6wohYwG7BaAaFXlSoFR15pAhGpAEt6w=; b=NR1CcFGSIHSZCj4VsDFePefutaj9Mn7NjUJhGru1boKx8d0KiTxSYtdD9vMCj1dDhLVEDJ+a/1GjzjK5HEKRAOCZWM4q+AO5HlYeC1Tfp168n13m0gbaFC8Xd/FHIozfX0koioXCvQSxvJxmF05X3DbhkQnyN5N63qxZ43CyhEk= 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+importer2=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 1622571577242471.3049275838539; Tue, 1 Jun 2021 11:19:37 -0700 (PDT) Received: from localhost ([::1]:41018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8zI-00082a-9I for importer2@patchew.org; Tue, 01 Jun 2021 14:19:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qk-0002fI-HS for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42381) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qf-0005oR-Mb for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-406-qCi5fKTeP6K0j0O814c44Q-1; Tue, 01 Jun 2021 14:10:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C512E801107; Tue, 1 Jun 2021 18:10:36 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 883DA60D52; Tue, 1 Jun 2021 18:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OiznvOiw988Q6wohYwG7BaAaFXlSoFR15pAhGpAEt6w=; b=akUfc5k7BQtobmQkrQ+6g0Xu1yotkNefDcxJMv23WUz4sE4GCJZ9LVf9n0jrWCiaZkxUbl u+L/bq/sl5+TNIVKV4w28jwe4K3h5eAz1PRLDWsJzf3ecBrmUTR5bWz7Horc5vXPdp/Z1u mxHETKSOkx7YDCS0hNgZA7cVVyyfnrw= X-MC-Unique: qCi5fKTeP6K0j0O814c44Q-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 22/24] target/i386/sev: add support to query the attestation report Date: Tue, 1 Jun 2021 14:10:12 -0400 Message-Id: <20210601181014.2568861-23-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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 , Brijesh Singh , Eduardo Habkost , kvm@vger.kernel.org, Connor Kuehl , James Bottomley , Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Brijesh Singh The SEV FW >=3D 0.23 added a new command that can be used to query the attestation report containing the SHA-256 digest of the guest memory and VMSA encrypted with the LAUNCH_UPDATE and sign it with the PEK. Note, we already have a command (LAUNCH_MEASURE) that can be used to query the SHA-256 digest of the guest memory encrypted through the LAUNCH_UPDATE. The main difference between previous and this command is that the report is signed with the PEK and unlike the LAUNCH_MEASURE command the ATTESATION_REPORT command can be called while the guest is running. Add a QMP interface "query-sev-attestation-report" that can be used to get the report encoded in base64. Cc: James Bottomley Cc: Tom Lendacky Cc: Eric Blake Cc: Paolo Bonzini Cc: kvm@vger.kernel.org Reviewed-by: James Bottomley Tested-by: James Bottomley Signed-off-by: Brijesh Singh Reviewed-by: Connor Kuehl Message-Id: <20210429170728.24322-1-brijesh.singh@amd.com> Signed-off-by: Eduardo Habkost --- linux-headers/linux/kvm.h | 8 +++++ target/i386/sev_i386.h | 2 ++ qapi/misc-target.json | 38 ++++++++++++++++++++++ target/i386/monitor.c | 6 ++++ target/i386/sev-stub.c | 7 ++++ target/i386/sev.c | 67 +++++++++++++++++++++++++++++++++++++++ target/i386/trace-events | 1 + 7 files changed, 129 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 020b62a619a..897f8313749 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1591,6 +1591,8 @@ enum sev_cmd_id { KVM_SEV_DBG_ENCRYPT, /* Guest certificates commands */ KVM_SEV_CERT_EXPORT, + /* Attestation report */ + KVM_SEV_GET_ATTESTATION_REPORT, =20 KVM_SEV_NR_MAX, }; @@ -1643,6 +1645,12 @@ struct kvm_sev_dbg { __u32 len; }; =20 +struct kvm_sev_attestation_report { + __u8 mnonce[16]; + __u64 uaddr; + __u32 len; +}; + #define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0) #define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1) #define KVM_DEV_ASSIGN_MASK_INTX (1 << 2) diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index ae221d4c724..ae6d8404787 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -35,5 +35,7 @@ extern uint32_t sev_get_cbit_position(void); extern uint32_t sev_get_reduced_phys_bits(void); extern char *sev_get_launch_measurement(void); extern SevCapability *sev_get_capabilities(Error **errp); +extern SevAttestationReport * +sev_get_attestation_report(const char *mnonce, Error **errp); =20 #endif diff --git a/qapi/misc-target.json b/qapi/misc-target.json index 6200c671bef..5573dcf8f08 100644 --- a/qapi/misc-target.json +++ b/qapi/misc-target.json @@ -285,3 +285,41 @@ ## { 'command': 'query-gic-capabilities', 'returns': ['GICCapability'], 'if': 'defined(TARGET_ARM)' } + + +## +# @SevAttestationReport: +# +# The struct describes attestation report for a Secure Encrypted Virtualiz= ation +# feature. +# +# @data: guest attestation report (base64 encoded) +# +# +# Since: 6.1 +## +{ 'struct': 'SevAttestationReport', + 'data': { 'data': 'str'}, + 'if': 'defined(TARGET_I386)' } + +## +# @query-sev-attestation-report: +# +# This command is used to get the SEV attestation report, and is supported= on AMD +# X86 platforms only. +# +# @mnonce: a random 16 bytes value encoded in base64 (it will be included = in report) +# +# Returns: SevAttestationReport objects. +# +# Since: 6.1 +# +# Example: +# +# -> { "execute" : "query-sev-attestation-report", "arguments": { "mnonce"= : "aaaaaaa" } } +# <- { "return" : { "data": "aaaaaaaabbbddddd"} } +# +## +{ 'command': 'query-sev-attestation-report', 'data': { 'mnonce': 'str' }, + 'returns': 'SevAttestationReport', + 'if': 'defined(TARGET_I386)' } diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 5994408bee1..119211f0b06 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -757,3 +757,9 @@ void qmp_sev_inject_launch_secret(const char *packet_hd= r, =20 sev_inject_launch_secret(packet_hdr, secret, gpa, errp); } + +SevAttestationReport * +qmp_query_sev_attestation_report(const char *mnonce, Error **errp) +{ + return sev_get_attestation_report(mnonce, errp); +} diff --git a/target/i386/sev-stub.c b/target/i386/sev-stub.c index 0207f1c5aae..0227cb51778 100644 --- a/target/i386/sev-stub.c +++ b/target/i386/sev-stub.c @@ -74,3 +74,10 @@ int sev_es_save_reset_vector(void *flash_ptr, uint64_t f= lash_size) { abort(); } + +SevAttestationReport * +sev_get_attestation_report(const char *mnonce, Error **errp) +{ + error_setg(errp, "SEV is not available in this QEMU"); + return NULL; +} diff --git a/target/i386/sev.c b/target/i386/sev.c index 41f7800b5f7..1a88f127035 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -492,6 +492,73 @@ out: return cap; } =20 +SevAttestationReport * +sev_get_attestation_report(const char *mnonce, Error **errp) +{ + struct kvm_sev_attestation_report input =3D {}; + SevAttestationReport *report =3D NULL; + SevGuestState *sev =3D sev_guest; + guchar *data; + guchar *buf; + gsize len; + int err =3D 0, ret; + + if (!sev_enabled()) { + error_setg(errp, "SEV is not enabled"); + return NULL; + } + + /* lets decode the mnonce string */ + buf =3D g_base64_decode(mnonce, &len); + if (!buf) { + error_setg(errp, "SEV: failed to decode mnonce input"); + return NULL; + } + + /* verify the input mnonce length */ + if (len !=3D sizeof(input.mnonce)) { + error_setg(errp, "SEV: mnonce must be %zu bytes (got %" G_GSIZE_FO= RMAT ")", + sizeof(input.mnonce), len); + g_free(buf); + return NULL; + } + + /* Query the report length */ + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_GET_ATTESTATION_REPORT, + &input, &err); + if (ret < 0) { + if (err !=3D SEV_RET_INVALID_LEN) { + error_setg(errp, "failed to query the attestation report lengt= h " + "ret=3D%d fw_err=3D%d (%s)", ret, err, fw_error_to_str= (err)); + g_free(buf); + return NULL; + } + } + + data =3D g_malloc(input.len); + input.uaddr =3D (unsigned long)data; + memcpy(input.mnonce, buf, sizeof(input.mnonce)); + + /* Query the report */ + ret =3D sev_ioctl(sev->sev_fd, KVM_SEV_GET_ATTESTATION_REPORT, + &input, &err); + if (ret) { + error_setg_errno(errp, errno, "Failed to get attestation report" + " ret=3D%d fw_err=3D%d (%s)", ret, err, fw_error_to_str(er= r)); + goto e_free_data; + } + + report =3D g_new0(SevAttestationReport, 1); + report->data =3D g_base64_encode(data, input.len); + + trace_kvm_sev_attestation_report(mnonce, report->data); + +e_free_data: + g_free(data); + g_free(buf); + return report; +} + static int sev_read_file_base64(const char *filename, guchar **data, gsize *len) { diff --git a/target/i386/trace-events b/target/i386/trace-events index a22ab24e214..8d6437404d5 100644 --- a/target/i386/trace-events +++ b/target/i386/trace-events @@ -10,3 +10,4 @@ kvm_sev_launch_update_data(void *addr, uint64_t len) "add= r %p len 0x%" PRIx64 kvm_sev_launch_measurement(const char *value) "data %s" kvm_sev_launch_finish(void) "" kvm_sev_launch_secret(uint64_t hpa, uint64_t hva, uint64_t secret, int len= ) "hpa 0x%" PRIx64 " hva 0x%" PRIx64 " data 0x%" PRIx64 " len %d" +kvm_sev_attestation_report(const char *mnonce, const char *data) "mnonce %= s data %s" --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622571321; cv=none; d=zohomail.com; s=zohoarc; b=lPqQdSymiMzXElINwWGOuf0neGg6jeHi2hR9lB3KNv/kji9nxtskU482FdC6SBg3Jnz4t4LHbcPdt9DKwYloK9whAkTqvl9EnboqbA0bbt9Fk73/Z39Dfu0RyeJWOTRvOQ2CixJDYMew3SS2qZce8bPWO0nvgncE17n6frk5mqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622571321; 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=MnOIYbIKjYiDgtpVN4+Wmj9A+5oig7jow+vPBOpyLE8=; b=n/nY/ucBJ5Rghyrzwpe+zfvzMDnU7zZEbZ2W9PX6pEJxJGcN2dZNleUgSMzh7E6pC/1O/U4SYZiINUS4ihbiwVQcKJroWKcs01BRPVLFvZv4hFnUxt8bDuI0EO31jPXDODIiVPrEbD1RjCiicQd48Xtqv2VLuzW1fONhu6kbV1k= 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+importer2=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 1622571321942830.9904351288952; Tue, 1 Jun 2021 11:15:21 -0700 (PDT) Received: from localhost ([::1]:51146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo8vA-0004Nr-Rq for importer2@patchew.org; Tue, 01 Jun 2021 14:15:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qj-0002cc-QP for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55353) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qf-0005od-Ld for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-500-a-HoW8H8N2yVrXu6fH55pg-1; Tue, 01 Jun 2021 14:10:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9ABDF801B20; Tue, 1 Jun 2021 18:10:37 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 642105C1BB; Tue, 1 Jun 2021 18:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MnOIYbIKjYiDgtpVN4+Wmj9A+5oig7jow+vPBOpyLE8=; b=KwxP5KUsB7fZo1IRU5XXf/ATwhIilanoayc3Sejz3a6hGQZ0G6lLqP+EWXRgauNyhABFSU pZlx29eIV4V2N5k2yYolxqQR7avNOyvVLG2oNshcjvbG5/d5Fjlw2tdaiSjEZuVoNy+iJ3 TM1YYNVxSTJFVSNyGgCD0Ip8KS1YnRU= X-MC-Unique: a-HoW8H8N2yVrXu6fH55pg-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 23/24] sev: use explicit indices for mapping firmware error codes to strings Date: Tue, 1 Jun 2021 14:10:13 -0400 Message-Id: <20210601181014.2568861-24-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Connor Kuehl , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Connor Kuehl This can help lower any margin for error when making future additions to the list, especially if they're made out of order. While doing so, make capitalization of ASID consistent with its usage in the SEV firmware spec (Asid -> ASID). Signed-off-by: Connor Kuehl Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210430134830.254741-2-ckuehl@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/sev.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/target/i386/sev.c b/target/i386/sev.c index 1a88f127035..5467407ee1d 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -87,29 +87,29 @@ static SevGuestState *sev_guest; static Error *sev_mig_blocker; =20 static const char *const sev_fw_errlist[] =3D { - "", - "Platform state is invalid", - "Guest state is invalid", - "Platform configuration is invalid", - "Buffer too small", - "Platform is already owned", - "Certificate is invalid", - "Policy is not allowed", - "Guest is not active", - "Invalid address", - "Bad signature", - "Bad measurement", - "Asid is already owned", - "Invalid ASID", - "WBINVD is required", - "DF_FLUSH is required", - "Guest handle is invalid", - "Invalid command", - "Guest is active", - "Hardware error", - "Hardware unsafe", - "Feature not supported", - "Invalid parameter" + [SEV_RET_SUCCESS] =3D "", + [SEV_RET_INVALID_PLATFORM_STATE] =3D "Platform state is invalid", + [SEV_RET_INVALID_GUEST_STATE] =3D "Guest state is invalid", + [SEV_RET_INAVLID_CONFIG] =3D "Platform configuration is invali= d", + [SEV_RET_INVALID_LEN] =3D "Buffer too small", + [SEV_RET_ALREADY_OWNED] =3D "Platform is already owned", + [SEV_RET_INVALID_CERTIFICATE] =3D "Certificate is invalid", + [SEV_RET_POLICY_FAILURE] =3D "Policy is not allowed", + [SEV_RET_INACTIVE] =3D "Guest is not active", + [SEV_RET_INVALID_ADDRESS] =3D "Invalid address", + [SEV_RET_BAD_SIGNATURE] =3D "Bad signature", + [SEV_RET_BAD_MEASUREMENT] =3D "Bad measurement", + [SEV_RET_ASID_OWNED] =3D "ASID is already owned", + [SEV_RET_INVALID_ASID] =3D "Invalid ASID", + [SEV_RET_WBINVD_REQUIRED] =3D "WBINVD is required", + [SEV_RET_DFFLUSH_REQUIRED] =3D "DF_FLUSH is required", + [SEV_RET_INVALID_GUEST] =3D "Guest handle is invalid", + [SEV_RET_INVALID_COMMAND] =3D "Invalid command", + [SEV_RET_ACTIVE] =3D "Guest is active", + [SEV_RET_HWSEV_RET_PLATFORM] =3D "Hardware error", + [SEV_RET_HWSEV_RET_UNSAFE] =3D "Hardware unsafe", + [SEV_RET_UNSUPPORTED] =3D "Feature not supported", + [SEV_RET_INVALID_PARAM] =3D "Invalid parameter", }; =20 #define SEV_FW_MAX_ERROR ARRAY_SIZE(sev_fw_errlist) --=20 2.30.2 From nobody Mon May 6 12:05:26 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622572116; cv=none; d=zohomail.com; s=zohoarc; b=bSjoB5IueWA16DtW2my7pYRhXnynKKw/ht8EH3qDFiaxMzUoV0lppt++UEcRtjZCnkKQelgRBsvzv3NmYVo58MYs1V2PLMnwof6pAvt76bRWZ4AQWx+5i/o1B7t9Okn2/CuaWNNrmL7yqGvFsBsK1MltO1kFygDr3nrOrA21Qh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622572116; 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=e+CN1V9BVnInryiuSkiDBV3eMijkf3HB7B66SuXqlEI=; b=YKET7jn55Hu9iGbPMxhBGGKj5h54kZ6fhsij6wwzTDLkaq4+7MfCH09exZ47vdhu3SSOYA7sIhhHk0JPrkb+5C7K5Ko6k3glzpp0nYvcxHuz41bWLEr2JXAFPOmrWutrx3I4GRv4nwMA+eOndD7Rm1flVSj/ntOg6vMWYi+Z1Eg= 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+importer2=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 1622572116682473.7935267800666; Tue, 1 Jun 2021 11:28:36 -0700 (PDT) Received: from localhost ([::1]:45272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo97z-0004Wh-NG for importer2@patchew.org; Tue, 01 Jun 2021 14:28:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qn-0002lU-Cz for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo8qf-0005oj-T8 for qemu-devel@nongnu.org; Tue, 01 Jun 2021 14:10:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-336-Hmpc5r0INTisgW-MVIlwvA-1; Tue, 01 Jun 2021 14:10:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E2C679EC0; Tue, 1 Jun 2021 18:10:38 +0000 (UTC) Received: from localhost (ovpn-112-239.rdu2.redhat.com [10.10.112.239]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D1FE5D9D5; Tue, 1 Jun 2021 18:10:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622571041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e+CN1V9BVnInryiuSkiDBV3eMijkf3HB7B66SuXqlEI=; b=gTftjpWlM8EHhh2ENfLEJDWPLTlTpy3mIBOd9ETDlXkjE6iR73Sh7P6ib0VjLc9c/dz6va amXwmKcc5OxWNGJcFV9KPJ30a1JzFPNX8113Zwk75EoV2GxmN19QZ1QhpAqRcnTM0lEznq nPkj2hKFheOFipdjiDPPMQoQ5AlO2do= X-MC-Unique: Hmpc5r0INTisgW-MVIlwvA-1 From: Eduardo Habkost To: qemu-devel@nongnu.org, Peter Maydell Subject: [PULL 24/24] sev: add missing firmware error conditions Date: Tue, 1 Jun 2021 14:10:14 -0400 Message-Id: <20210601181014.2568861-25-ehabkost@redhat.com> In-Reply-To: <20210601181014.2568861-1-ehabkost@redhat.com> References: <20210601181014.2568861-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ehabkost@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=ehabkost@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Connor Kuehl , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Connor Kuehl The SEV userspace header[1] exports a couple of other error conditions that aren't listed in QEMU's SEV implementation, so let's just round out the list. [1] linux-headers/linux/psp-sev.h Signed-off-by: Connor Kuehl Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210430134830.254741-3-ckuehl@redhat.com> Signed-off-by: Eduardo Habkost --- target/i386/sev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/i386/sev.c b/target/i386/sev.c index 5467407ee1d..83df8c09f6a 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -110,6 +110,8 @@ static const char *const sev_fw_errlist[] =3D { [SEV_RET_HWSEV_RET_UNSAFE] =3D "Hardware unsafe", [SEV_RET_UNSUPPORTED] =3D "Feature not supported", [SEV_RET_INVALID_PARAM] =3D "Invalid parameter", + [SEV_RET_RESOURCE_LIMIT] =3D "Required firmware resource deple= ted", + [SEV_RET_SECURE_DATA_INVALID] =3D "Part-specific integrity check fa= ilure", }; =20 #define SEV_FW_MAX_ERROR ARRAY_SIZE(sev_fw_errlist) --=20 2.30.2