qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Kevin Wolf" <kwolf@redhat.com>,
	qemu-block@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Ben Warren" <ben@skyportsystems.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"David Hildenbrand" <david@redhat.com>,
	"Peter Lieven" <pl@kamp.de>,
	qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Ronnie Sahlberg" <ronniesahlberg@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Igor Mammedov" <imammedo@redhat.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [PATCH v3 1/9] target/i386: Restrict X86CPUFeatureWord to X86 targets
Date: Tue, 26 May 2020 09:36:11 +0200	[thread overview]
Message-ID: <1f75c8d8-1e4d-a64d-9911-bdc747fd6475@redhat.com> (raw)
In-Reply-To: <8590aa71-d8a5-4aa8-3672-e1ccfa96bcbd@redhat.com>

On 5/26/20 9:23 AM, Philippe Mathieu-Daudé wrote:
> On 5/26/20 8:45 AM, Markus Armbruster wrote:
>> Philippe Mathieu-Daudé <philmd@redhat.com> writes:
>>
>>> Move out x86-specific structures from generic machine code.
>>>
>>> Acked-by: Richard Henderson <richard.henderson@linaro.org>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>>> ---
>>>  qapi/machine-target.json   | 45 ++++++++++++++++++++++++++++++++++++++
>>>  qapi/machine.json          | 42 -----------------------------------
>>>  target/i386/cpu.c          |  2 +-
>>>  target/i386/machine-stub.c | 22 +++++++++++++++++++
>>>  target/i386/Makefile.objs  |  3 ++-
>>>  5 files changed, 70 insertions(+), 44 deletions(-)
>>>  create mode 100644 target/i386/machine-stub.c
>>>
>>> diff --git a/qapi/machine-target.json b/qapi/machine-target.json
>>> index f2c82949d8..fb7a4b7850 100644
>>> --- a/qapi/machine-target.json
>>> +++ b/qapi/machine-target.json
>>> @@ -3,6 +3,51 @@
>>>  # This work is licensed under the terms of the GNU GPL, version 2 or later.
>>>  # See the COPYING file in the top-level directory.
>>>  
>>> +##
>>> +# @X86CPURegister32:
>>> +#
>>> +# A X86 32-bit register
>>> +#
>>> +# Since: 1.5
>>> +##
>>> +{ 'enum': 'X86CPURegister32',
>>> +  'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ],
>>> +  'if': 'defined(TARGET_I386)' }
>>> +
>>> +##
>>> +# @X86CPUFeatureWordInfo:
>>> +#
>>> +# Information about a X86 CPU feature word
>>> +#
>>> +# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
>>> +#
>>> +# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
>>> +#                   feature word
>>> +#
>>> +# @cpuid-register: Output register containing the feature bits
>>> +#
>>> +# @features: value of output register, containing the feature bits
>>> +#
>>> +# Since: 1.5
>>> +##
>>> +{ 'struct': 'X86CPUFeatureWordInfo',
>>> +  'data': { 'cpuid-input-eax': 'int',
>>> +            '*cpuid-input-ecx': 'int',
>>> +            'cpuid-register': 'X86CPURegister32',
>>> +            'features': 'int' },
>>> +  'if': 'defined(TARGET_I386)' }
>>> +
>>> +##
>>> +# @DummyForceArrays:
>>> +#
>>> +# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
>>> +#
>>> +# Since: 2.5
>>> +##
>>> +{ 'struct': 'DummyForceArrays',
>>> +  'data': { 'unused': ['X86CPUFeatureWordInfo'] },
>>> +  'if': 'defined(TARGET_I386)' }
>>> +
>>>  ##
>>>  # @CpuModelInfo:
>>>  #
>>> diff --git a/qapi/machine.json b/qapi/machine.json
>>> index ff7b5032e3..1fe31d374c 100644
>>> --- a/qapi/machine.json
>>> +++ b/qapi/machine.json
>>> @@ -511,48 +511,6 @@
>>>     'dst': 'uint16',
>>>     'val': 'uint8' }}
>>>  
>>> -##
>>> -# @X86CPURegister32:
>>> -#
>>> -# A X86 32-bit register
>>> -#
>>> -# Since: 1.5
>>> -##
>>> -{ 'enum': 'X86CPURegister32',
>>> -  'data': [ 'EAX', 'EBX', 'ECX', 'EDX', 'ESP', 'EBP', 'ESI', 'EDI' ] }
>>> -
>>> -##
>>> -# @X86CPUFeatureWordInfo:
>>> -#
>>> -# Information about a X86 CPU feature word
>>> -#
>>> -# @cpuid-input-eax: Input EAX value for CPUID instruction for that feature word
>>> -#
>>> -# @cpuid-input-ecx: Input ECX value for CPUID instruction for that
>>> -#                   feature word
>>> -#
>>> -# @cpuid-register: Output register containing the feature bits
>>> -#
>>> -# @features: value of output register, containing the feature bits
>>> -#
>>> -# Since: 1.5
>>> -##
>>> -{ 'struct': 'X86CPUFeatureWordInfo',
>>> -  'data': { 'cpuid-input-eax': 'int',
>>> -            '*cpuid-input-ecx': 'int',
>>> -            'cpuid-register': 'X86CPURegister32',
>>> -            'features': 'int' } }
>>> -
>>> -##
>>> -# @DummyForceArrays:
>>> -#
>>> -# Not used by QMP; hack to let us use X86CPUFeatureWordInfoList internally
>>> -#
>>> -# Since: 2.5
>>> -##
>>> -{ 'struct': 'DummyForceArrays',
>>> -  'data': { 'unused': ['X86CPUFeatureWordInfo'] } }
>>> -
>>>  ##
>>>  # @NumaCpuOptions:
>>>  #
>>> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
>>> index 7a4a8e3847..832498c723 100644
>>> --- a/target/i386/cpu.c
>>> +++ b/target/i386/cpu.c
>>> @@ -37,7 +37,7 @@
>>>  #include "qemu/option.h"
>>>  #include "qemu/config-file.h"
>>>  #include "qapi/error.h"
>>> -#include "qapi/qapi-visit-machine.h"
>>> +#include "qapi/qapi-visit-machine-target.h"
>>>  #include "qapi/qapi-visit-run-state.h"
>>>  #include "qapi/qmp/qdict.h"
>>>  #include "qapi/qmp/qerror.h"
>>> diff --git a/target/i386/machine-stub.c b/target/i386/machine-stub.c
>>> new file mode 100644
>>> index 0000000000..cb301af057
>>> --- /dev/null
>>> +++ b/target/i386/machine-stub.c
>>> @@ -0,0 +1,22 @@
>>> +/*
>>> + * QAPI x86 CPU features stub
>>> + *
>>> + * Copyright (c) 2020 Red Hat, Inc.
>>> + *
>>> + * Author:
>>> + *   Philippe Mathieu-Daudé <philmd@redhat.com>
>>> + *
>>> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
>>> + * See the COPYING file in the top-level directory.
>>> + * SPDX-License-Identifier: GPL-2.0-or-later
>>> + */
>>> +
>>> +#include "qemu/osdep.h"
>>> +#include "qapi/error.h"
>>> +#include "qapi/qapi-visit-machine-target.h"
>>> +
>>> +void visit_type_X86CPUFeatureWordInfoList(Visitor *v, const char *name,
>>> +                                      X86CPUFeatureWordInfoList **obj,
>>> +                                      Error **errp)
>>
>> Unusual indentation.
>>
>>> +{
>>> +}
>>
>> Two kinds of stubs: stubs that can get called, and stubs that exist only
>> to satisfy the linker.  Which kind is this one?
> 
> I suppose "stubs that exist only to satisfy the linker" must abort if
> ever called...

Link problem when building linux-user:

  LINK    i386-linux-user/qemu-i386
/usr/bin/ld: target/i386/cpu.o: in function `x86_cpu_get_feature_words':
target/i386/cpu.c:4627: undefined reference to
`visit_type_X86CPUFeatureWordInfoList'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:208: qemu-i386] Error 1
make: *** [Makefile:527: i386-linux-user/all] Error 2

Various properties from x86_cpu_initfn() should be removed from
user-mode (tsc/stepping/kvm/...) but I'll let that to some x86 specialist.

> 
>>
>>> diff --git a/target/i386/Makefile.objs b/target/i386/Makefile.objs
>>> index 48e0c28434..1cdfc9f50c 100644
>>> --- a/target/i386/Makefile.objs
>>> +++ b/target/i386/Makefile.objs
>>> @@ -17,6 +17,7 @@ obj-$(CONFIG_HAX) += hax-all.o hax-mem.o hax-posix.o
>>>  endif
>>>  obj-$(CONFIG_HVF) += hvf/
>>>  obj-$(CONFIG_WHPX) += whpx-all.o
>>> -endif
>>> +endif # CONFIG_SOFTMMU
>>>  obj-$(CONFIG_SEV) += sev.o
>>>  obj-$(call lnot,$(CONFIG_SEV)) += sev-stub.o
>>> +obj-$(call lnot,$(CONFIG_SOFTMMU)) += machine-stub.o
>>
>> Suggest
>>
>>    ifeq ($(CONFIG_SOFTMMU),y)
>>    ...
>>    else
>>    obj-y += machine-stub.o
>>    endif
>>
>> Matter of taste.
>>
> 
> OK
> 



  reply	other threads:[~2020-05-26  7:37 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25 15:06 [PATCH v3 0/9] user-mode: Prune build dependencies (part 2) Philippe Mathieu-Daudé
2020-05-25 15:06 ` [PATCH v3 1/9] target/i386: Restrict X86CPUFeatureWord to X86 targets Philippe Mathieu-Daudé
2020-05-26  6:45   ` Markus Armbruster
2020-05-26  7:23     ` Philippe Mathieu-Daudé
2020-05-26  7:36       ` Philippe Mathieu-Daudé [this message]
2020-05-26  9:02         ` Markus Armbruster
2020-05-25 15:06 ` [PATCH v3 2/9] qapi/misc: Restrict LostTickPolicy enum to machine code Philippe Mathieu-Daudé
2020-05-26  7:34   ` Markus Armbruster
2020-05-25 15:06 ` [PATCH v3 3/9] qapi/misc.json: Correct balloon documentation Philippe Mathieu-Daudé
2020-05-26  7:43   ` David Hildenbrand
2020-05-25 15:06 ` [PATCH v3 4/9] qapi/misc: Restrict balloon-related commands to machine code Philippe Mathieu-Daudé
2020-05-26  7:35   ` David Hildenbrand
2020-05-26  7:36     ` David Hildenbrand
2020-05-26  7:38   ` Markus Armbruster
2020-05-26  8:04     ` Philippe Mathieu-Daudé
2020-05-26  9:04       ` Markus Armbruster
2020-05-26  9:31         ` Philippe Mathieu-Daudé
2020-05-26 15:36           ` Philippe Mathieu-Daudé
2020-05-27  4:49             ` Markus Armbruster
2020-05-27  7:31               ` Philippe Mathieu-Daudé
2020-05-25 15:06 ` [PATCH v3 5/9] qapi/misc: Restrict query-vm-generation-id command " Philippe Mathieu-Daudé
2020-05-26  7:41   ` Markus Armbruster
2020-05-25 15:06 ` [PATCH v3 6/9] qapi/misc: Move query-uuid " Philippe Mathieu-Daudé
2020-05-26  7:42   ` Markus Armbruster
2020-05-25 15:06 ` [PATCH v3 7/9] qapi/misc: Restrict ACPI commands " Philippe Mathieu-Daudé
2020-05-26  7:44   ` Markus Armbruster
2020-05-25 15:06 ` [PATCH v3 8/9] qapi/misc: Restrict PCI " Philippe Mathieu-Daudé
2020-05-26  7:44   ` Markus Armbruster
2020-05-25 15:06 ` [PATCH v3 9/9] qapi/misc: Restrict device memory " Philippe Mathieu-Daudé
2020-05-26  8:18   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f75c8d8-1e4d-a64d-9911-bdc747fd6475@redhat.com \
    --to=philmd@redhat.com \
    --cc=armbru@redhat.com \
    --cc=ben@skyportsystems.com \
    --cc=berrange@redhat.com \
    --cc=david@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).