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?