From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FADBC4338F for ; Sat, 7 Aug 2021 14:22:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E70BE6113B for ; Sat, 7 Aug 2021 14:22:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232397AbhHGOXG (ORCPT ); Sat, 7 Aug 2021 10:23:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48289 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232313AbhHGOXF (ORCPT ); Sat, 7 Aug 2021 10:23:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628346167; 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: in-reply-to:in-reply-to:references:references; bh=Mn88nB2Mn33WML8Ivc2xsRfSzqG9DRPUmQ//XqF85LY=; b=Yj1vx2uoaBm3g1ex3Xcwu9jj1DYp63yHhAP1aIWCZHrqvl1WYQLXdp2NMrL7BY1JQrK1E2 +5WvQn5VJ3VQ22L/+vflaHugrtQZ4CrJsQs5oTgQqbB8mYK95vHYtJr8kjDM8wPMQVh2gg N5UV/bs7PZGX4PkkNMiAxvxv01cZ0Ic= 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-153-UIfdWls6O5-ASsNY-O66YQ-1; Sat, 07 Aug 2021 10:22:46 -0400 X-MC-Unique: UIfdWls6O5-ASsNY-O66YQ-1 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 B36B9180FCBC; Sat, 7 Aug 2021 14:22:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-12.ams2.redhat.com [10.36.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C51C5D6AD; Sat, 7 Aug 2021 14:22:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 23B8711380A0; Sat, 7 Aug 2021 16:22:42 +0200 (CEST) From: Markus Armbruster To: Valeriy Vdovin Cc: qemu-devel@nongnu.org, Eduardo Habkost , Marcel Apfelbaum , Eric Blake , Paolo Bonzini , Marcelo Tosatti , Richard Henderson , Thomas Huth , Laurent Vivier , kvm@vger.kernel.org, Denis Lunev , Vladimir Sementsov-Ogievskiy Subject: Re: [PATCH v12] qapi: introduce 'query-x86-cpuid' QMP command. References: <20210728125402.2496-1-valeriy.vdovin@virtuozzo.com> Date: Sat, 07 Aug 2021 16:22:42 +0200 In-Reply-To: <20210728125402.2496-1-valeriy.vdovin@virtuozzo.com> (Valeriy Vdovin's message of "Wed, 28 Jul 2021 15:54:02 +0300") Message-ID: <87eeb59vwt.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org I'm afraid this needs a rebase now. Reviewing anyway. Valeriy Vdovin writes: > Introducing new QMP command 'query-x86-cpuid'. This command can be used to > get virtualized cpu model info generated by QEMU during VM initialization in > the form of cpuid representation. > > Diving into more details about virtual CPU generation: QEMU first parses '-cpu' > command line option. From there it takes the name of the model as the basis for > feature set of the new virtual CPU. After that it uses trailing '-cpu' options, > that state if additional cpu features should be present on the virtual CPU or > excluded from it (tokens '+'/'-' or '=on'/'=off'). > After that QEMU checks if the host's cpu can actually support the derived > feature set and applies host limitations to it. > After this initialization procedure, virtual CPU has it's model and > vendor names, and a working feature set and is ready for identification > instructions such as CPUID. > > To learn exactly how virtual CPU is presented to the guest machine via CPUID > instruction, new QMP command can be used. By calling 'query-x86-cpuid' > command, one can get a full listing of all CPUID leaves with subleaves which are > supported by the initialized virtual CPU. > > Other than debug, the command is useful in cases when we would like to > utilize QEMU's virtual CPU initialization routines and put the retrieved > values into kernel CPUID overriding mechanics for more precise control > over how various processes perceive its underlying hardware with > container processes as a good example. > > The command is specific to x86. It is currenly only implemented for KVM acceleator. > > Output format: > The output is a plain list of leaf/subleaf argument combinations, that > return 4 words in registers EAX, EBX, ECX, EDX. > > Use example: > qmp_request: { > "execute": "query-x86-cpuid" > } > > qmp_response: { > "return": [ > { > "eax": 1073741825, > "edx": 77, > "in-eax": 1073741824, > "ecx": 1447775574, > "ebx": 1263359563 > }, > { > "eax": 16777339, > "edx": 0, > "in-eax": 1073741825, > "ecx": 0, > "ebx": 0 > }, > { > "eax": 13, > "edx": 1231384169, > "in-eax": 0, > "ecx": 1818588270, > "ebx": 1970169159 > }, > { > "eax": 198354, > "edx": 126614527, > "in-eax": 1, > "ecx": 2176328193, > "ebx": 2048 > }, > .... > { > "eax": 12328, > "edx": 0, > "in-eax": 2147483656, > "ecx": 0, > "ebx": 0 > } > ] > } > > Signed-off-by: Valeriy Vdovin > --- [...] > diff --git a/qapi/machine-target.json b/qapi/machine-target.json > index e7811654b7..db906c9240 100644 > --- a/qapi/machine-target.json > +++ b/qapi/machine-target.json > @@ -329,3 +329,47 @@ > ## > { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], > 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } > + > +## > +# @CpuidEntry: > +# > +# A single entry of a CPUID response. > +# > +# One entry holds full set of information (leaf) returned to the guest > +# in response to it calling a CPUID instruction with eax, ecx used as > +# the agruments to that instruction. ecx is an optional argument as Typo: arguments > +# not all of the leaves support it. > +# > +# @in-eax: CPUID argument in eax > +# @in-ecx: CPUID argument in ecx > +# @eax: CPUID result in eax > +# @ebx: CPUID result in ebx > +# @ecx: CPUID result in ecx > +# @edx: CPUID result in edx > +# > +# Since: 6.1 > +## > +{ 'struct': 'CpuidEntry', > + 'data': { 'in-eax' : 'uint32', > + '*in-ecx' : 'uint32', > + 'eax' : 'uint32', > + 'ebx' : 'uint32', > + 'ecx' : 'uint32', > + 'edx' : 'uint32' > + }, > + 'if': 'defined(TARGET_I386)' } > + > +## > +# @query-x86-cpuid: > +# > +# Returns raw data from the emulated CPUID table for the first VCPU. > +# The emulated CPUID table defines the response to the CPUID > +# instruction when executed by the guest operating system. > +# > +# Returns: a list of CpuidEntry > +# > +# Since: 6.1 > +## > +{ 'command': 'query-x86-cpuid', > + 'returns': ['CpuidEntry'], > + 'if': 'defined(TARGET_I386)' } I understand this fails when the acceleator isn't KVM. I think that's worth documenting. Is this intended to be a stable interface? Interfaces intended just for debugging usually aren't. Eduardo, what's your take on this version? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2341DC432BE for ; Sat, 7 Aug 2021 14:23:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 688D761104 for ; Sat, 7 Aug 2021 14:23:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 688D761104 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:38738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mCNEo-0002l7-3q for qemu-devel@archiver.kernel.org; Sat, 07 Aug 2021 10:23:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCNDx-00025T-J3 for qemu-devel@nongnu.org; Sat, 07 Aug 2021 10:22:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mCNDu-0003LI-Q0 for qemu-devel@nongnu.org; Sat, 07 Aug 2021 10:22:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628346169; 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: in-reply-to:in-reply-to:references:references; bh=Mn88nB2Mn33WML8Ivc2xsRfSzqG9DRPUmQ//XqF85LY=; b=B5uu1H0OH+VoclxArWAovHFKXqdKpqFI0DkTXXQZQDo2456mveSNa03GTJQEqg/VirdQDp 1AxmafzZBvyei7DhjEBW6p09n4tiHILEDKSh1s+YBvICJwNGhdpp2CZODfKP28AcTiLU1N afNj+Njah8KQVWR1aeON1GeMPF+ztTg= 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-153-UIfdWls6O5-ASsNY-O66YQ-1; Sat, 07 Aug 2021 10:22:46 -0400 X-MC-Unique: UIfdWls6O5-ASsNY-O66YQ-1 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 B36B9180FCBC; Sat, 7 Aug 2021 14:22:44 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-12.ams2.redhat.com [10.36.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C51C5D6AD; Sat, 7 Aug 2021 14:22:43 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 23B8711380A0; Sat, 7 Aug 2021 16:22:42 +0200 (CEST) From: Markus Armbruster To: Valeriy Vdovin Subject: Re: [PATCH v12] qapi: introduce 'query-x86-cpuid' QMP command. References: <20210728125402.2496-1-valeriy.vdovin@virtuozzo.com> Date: Sat, 07 Aug 2021 16:22:42 +0200 In-Reply-To: <20210728125402.2496-1-valeriy.vdovin@virtuozzo.com> (Valeriy Vdovin's message of "Wed, 28 Jul 2021 15:54:02 +0300") Message-ID: <87eeb59vwt.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Received-SPF: pass client-ip=216.205.24.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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_H2=-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: Laurent Vivier , Thomas Huth , Vladimir Sementsov-Ogievskiy , Eduardo Habkost , kvm@vger.kernel.org, Marcelo Tosatti , Richard Henderson , qemu-devel@nongnu.org, Denis Lunev , Paolo Bonzini , Eric Blake Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" I'm afraid this needs a rebase now. Reviewing anyway. Valeriy Vdovin writes: > Introducing new QMP command 'query-x86-cpuid'. This command can be used to > get virtualized cpu model info generated by QEMU during VM initialization in > the form of cpuid representation. > > Diving into more details about virtual CPU generation: QEMU first parses '-cpu' > command line option. From there it takes the name of the model as the basis for > feature set of the new virtual CPU. After that it uses trailing '-cpu' options, > that state if additional cpu features should be present on the virtual CPU or > excluded from it (tokens '+'/'-' or '=on'/'=off'). > After that QEMU checks if the host's cpu can actually support the derived > feature set and applies host limitations to it. > After this initialization procedure, virtual CPU has it's model and > vendor names, and a working feature set and is ready for identification > instructions such as CPUID. > > To learn exactly how virtual CPU is presented to the guest machine via CPUID > instruction, new QMP command can be used. By calling 'query-x86-cpuid' > command, one can get a full listing of all CPUID leaves with subleaves which are > supported by the initialized virtual CPU. > > Other than debug, the command is useful in cases when we would like to > utilize QEMU's virtual CPU initialization routines and put the retrieved > values into kernel CPUID overriding mechanics for more precise control > over how various processes perceive its underlying hardware with > container processes as a good example. > > The command is specific to x86. It is currenly only implemented for KVM acceleator. > > Output format: > The output is a plain list of leaf/subleaf argument combinations, that > return 4 words in registers EAX, EBX, ECX, EDX. > > Use example: > qmp_request: { > "execute": "query-x86-cpuid" > } > > qmp_response: { > "return": [ > { > "eax": 1073741825, > "edx": 77, > "in-eax": 1073741824, > "ecx": 1447775574, > "ebx": 1263359563 > }, > { > "eax": 16777339, > "edx": 0, > "in-eax": 1073741825, > "ecx": 0, > "ebx": 0 > }, > { > "eax": 13, > "edx": 1231384169, > "in-eax": 0, > "ecx": 1818588270, > "ebx": 1970169159 > }, > { > "eax": 198354, > "edx": 126614527, > "in-eax": 1, > "ecx": 2176328193, > "ebx": 2048 > }, > .... > { > "eax": 12328, > "edx": 0, > "in-eax": 2147483656, > "ecx": 0, > "ebx": 0 > } > ] > } > > Signed-off-by: Valeriy Vdovin > --- [...] > diff --git a/qapi/machine-target.json b/qapi/machine-target.json > index e7811654b7..db906c9240 100644 > --- a/qapi/machine-target.json > +++ b/qapi/machine-target.json > @@ -329,3 +329,47 @@ > ## > { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'], > 'if': 'defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || defined(TARGET_S390X) || defined(TARGET_MIPS)' } > + > +## > +# @CpuidEntry: > +# > +# A single entry of a CPUID response. > +# > +# One entry holds full set of information (leaf) returned to the guest > +# in response to it calling a CPUID instruction with eax, ecx used as > +# the agruments to that instruction. ecx is an optional argument as Typo: arguments > +# not all of the leaves support it. > +# > +# @in-eax: CPUID argument in eax > +# @in-ecx: CPUID argument in ecx > +# @eax: CPUID result in eax > +# @ebx: CPUID result in ebx > +# @ecx: CPUID result in ecx > +# @edx: CPUID result in edx > +# > +# Since: 6.1 > +## > +{ 'struct': 'CpuidEntry', > + 'data': { 'in-eax' : 'uint32', > + '*in-ecx' : 'uint32', > + 'eax' : 'uint32', > + 'ebx' : 'uint32', > + 'ecx' : 'uint32', > + 'edx' : 'uint32' > + }, > + 'if': 'defined(TARGET_I386)' } > + > +## > +# @query-x86-cpuid: > +# > +# Returns raw data from the emulated CPUID table for the first VCPU. > +# The emulated CPUID table defines the response to the CPUID > +# instruction when executed by the guest operating system. > +# > +# Returns: a list of CpuidEntry > +# > +# Since: 6.1 > +## > +{ 'command': 'query-x86-cpuid', > + 'returns': ['CpuidEntry'], > + 'if': 'defined(TARGET_I386)' } I understand this fails when the acceleator isn't KVM. I think that's worth documenting. Is this intended to be a stable interface? Interfaces intended just for debugging usually aren't. Eduardo, what's your take on this version?