From: Mark Cave-Ayland <mark.caveayland@nutanix.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Xiaoyao Li" <xiaoyao.li@intel.com>,
pbonzini@redhat.com, mst@redhat.com, marcel.apfelbaum@gmail.com,
eduardo@habkost.net, qemu-devel@nongnu.org,
"Jiri Denemark" <jdenemar@redhat.com>
Subject: Re: [PATCH v6 01/19] hw/i386/pc_piix.c: restrict isapc machine to 32-bit CPUs
Date: Wed, 24 Sep 2025 13:50:39 +0100 [thread overview]
Message-ID: <ddfb99cf-efc7-4883-8e36-6dbc1f4ece82@nutanix.com> (raw)
In-Reply-To: <20250923113029.78c03a5c@fedora>
On 23/09/2025 10:30, Igor Mammedov wrote:
> On Mon, 22 Sep 2025 14:56:57 +0100
> Mark Cave-Ayland <mark.caveayland@nutanix.com> wrote:
>
>> On 22/09/2025 13:35, Igor Mammedov wrote:
>>
>>> On Mon, 22 Sep 2025 14:05:13 +0200
>>> Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>
>>>> On 27/8/25 13:46, Daniel P. Berrangé wrote:
>>>>> On Wed, Aug 27, 2025 at 12:10:00PM +0100, Mark Cave-Ayland wrote:
>>>>>> On 26/08/2025 08:25, Xiaoyao Li wrote:
>>>>>>
>>>>>>> On 8/22/2025 8:11 PM, Mark Cave-Ayland wrote:
>>>>>>>> The isapc machine represents a legacy ISA PC with a 486 CPU. Whilst it is
>>>>>>>> possible to specify any CPU via -cpu on the command line, it makes no
>>>>>>>> sense to allow modern 64-bit CPUs to be used.
>>>>>>>>
>>>>>>>> Restrict the isapc machine to the available 32-bit CPUs, taking care to
>>>>>>>> handle the case where if a user inadvertently uses -cpu max then the
>>>>>>>> "best"
>>>>>>>> 32-bit CPU is used (in this case the pentium3).
>>>>>>>>
>>>>>>>> Signed-off-by: Mark Cave-Ayland <mark.caveayland@nutanix.com>
>>>>>>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>>>>>>> ---
>>>>>>>> hw/i386/pc_piix.c | 26 ++++++++++++++++++++++++++
>>>>>>>> 1 file changed, 26 insertions(+)
>>>>>>>>
>>>>>>>> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
>>>>>>>> index c03324281b..5720b6b556 100644
>>>>>>>> --- a/hw/i386/pc_piix.c
>>>>>>>> +++ b/hw/i386/pc_piix.c
>>>>>>>> @@ -436,6 +436,19 @@ static void pc_set_south_bridge(Object *obj,
>>>>>>>> int value, Error **errp)
>>>>>>>> #ifdef CONFIG_ISAPC
>>>>>>>> static void pc_init_isa(MachineState *machine)
>>>>>>>> {
>>>>>>>> + /*
>>>>>>>> + * There is a small chance that someone unintentionally passes
>>>>>>>> "- cpu max"
>>>>>>>> + * for the isapc machine, which will provide a much more modern
>>>>>>>> 32-bit
>>>>>>>> + * CPU than would be expected for an ISA-era PC. If the "max"
>>>>>>>> cpu type has
>>>>>>>> + * been specified, choose the "best" 32-bit cpu possible which
>>>>>>>> we consider
>>>>>>>> + * be the pentium3 (deliberately choosing an Intel CPU given
>>>>>>>> that the
>>>>>>>> + * default 486 CPU for the isapc machine is also an Intel CPU).
>>>>>>>> + */
>>>>>>>> + if (!strcmp(machine->cpu_type, X86_CPU_TYPE_NAME("max"))) {
>>>>>>>> + machine->cpu_type = X86_CPU_TYPE_NAME("pentium3");
>>>>>>>> + warn_report("-cpu max is invalid for isapc machine, using
>>>>>>>> pentium3");
>>>>>>>> + }
>>>>>>>
>>>>>>> Do we need to handle the case of "-cpu host"?
>>>>>>
>>>>>> I don't believe so. I wasn't originally planning to support "-cpu max" for
>>>>>> isapc, however Daniel mentioned that it could possibly be generated from
>>>>>> libvirt so it makes sense to add the above check to warn in this case and
>>>>>> then continue.
>>>>>
>>>>> Libvirt will support sending any valid -cpu flag, including both
>>>>> 'max' (any config) and 'host' (if KVM).
>>>>>
>>>>> If 'isapc' still expects to support KVM, then it would be odd to
>>>>> reject 'host', but KVM presumably has no built-in way to limit to
>>>>> 32-bit without QEMU manually masking many features ?
>>>>>
>>>>> I'm a little worried about implications of libvirt sending '-cpu max'
>>>>> and QEMU secretly turning that into '-cpu pentium3', as opposed to
>>>>> having '-cpu max' expand to equiv to 'pentium3', which might cauase
>>>>> confusion when libvirt queries the expanded CPU ? Copying Jiri for
>>>>> an opinion from libvirt side, as I might be worrying about nothing.
>>>>
>>>> OK, on 2nd thought, even while warning the user, changing the type
>>>> under the hood isn't great.
>>>
>>> I second that,
>>> Please don't do magical mutations of CPUs, just error out.
>>>
>>> we used to 'fix|tweak' CPUs using machine compat hack,
>>> however with introduction of versioned cpu models we shouldn't do that anymore.
>>> (aka: existing CPU devices should stay immutable if possible, and any visible
>>> changes should go into new version)
>>
>> The original suggestion for allowing "max"/"host" was so that it
>> wouldn't cause any regressions with command lines erroneously including
>> -cpu max or -cpu host (which I believe may be possible with libvirt).
>
> looking back and at Daniels reply,
> max/host are indeed are 'special' aka mutable as opposed to named cpu models.
>
> if we go by the books, 'host' and by extension 'max' should work with KVM accelerator.
> But that (aka reducing it to isapc levels) should be done at 'host' cpu model code
> and that part of code is not really aware (nor should be) of machine types.
> I'm not sure, whether it's worth the effort and complexity.
>
> I'd be fine with valid_cpu_types[] approach here, i.e. user will get
> clear error that her is doing wrong thing trying 'host/max',
> and printing suggestion how to remedy error should guide user
> to the right config.
Okay I've just sent through a patch that removes the -cpu host and -cpu
max mapping logic for the isapc machine.
As an aside, I think it was originally your proposal a while back to
deprecate isapc? Now the main series has been merged, is the current
split sufficient for the tidy-up/improvements that you were planning to
do for the pc/q35 machines, or is there a way we can improve it?
ATB,
Mark.
next prev parent reply other threads:[~2025-09-24 12:52 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 12:11 [PATCH v6 00/19] hw/i386: separate isapc out from pc_piix Mark Cave-Ayland
2025-08-22 12:11 ` [PATCH v6 01/19] hw/i386/pc_piix.c: restrict isapc machine to 32-bit CPUs Mark Cave-Ayland
2025-08-26 7:25 ` Xiaoyao Li
2025-08-27 11:10 ` Mark Cave-Ayland
2025-08-27 11:46 ` Daniel P. Berrangé
2025-09-22 10:44 ` Jiří Denemark
2025-09-22 12:05 ` Philippe Mathieu-Daudé
2025-09-22 12:35 ` Igor Mammedov
2025-09-22 13:56 ` Mark Cave-Ayland
2025-09-23 9:30 ` Igor Mammedov
2025-09-24 12:50 ` Mark Cave-Ayland [this message]
2025-10-02 13:31 ` Igor Mammedov
2025-09-22 12:55 ` Daniel P. Berrangé
2025-08-27 11:50 ` Xiaoyao Li
2025-08-28 10:42 ` Mark Cave-Ayland
2025-09-22 12:01 ` Philippe Mathieu-Daudé
2025-09-22 13:40 ` Mark Cave-Ayland
2025-08-22 12:11 ` [PATCH v6 02/19] hw/i386/pc_piix.c: remove include for loader.h Mark Cave-Ayland
2025-08-26 7:30 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 03/19] hw/i386/pc_piix.c: inline pc_xen_hvm_init_pci() into pc_xen_hvm_init() Mark Cave-Ayland
2025-08-26 7:34 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 04/19] hw/i386/pc_piix.c: duplicate pc_init1() into pc_isa_init() Mark Cave-Ayland
2025-08-26 9:21 ` Xiaoyao Li
2025-08-27 10:47 ` Mark Cave-Ayland
2025-08-22 12:11 ` [PATCH v6 05/19] hw/i386/pc_piix.c: remove pcmc->pci_enabled dependent initialisation from pc_init_isa() Mark Cave-Ayland
2025-08-26 9:48 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 06/19] hw/i386/pc_piix.c: remove SMI and piix4_pm " Mark Cave-Ayland
2025-08-26 9:52 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 07/19] hw/i386/pc_piix.c: remove SGX " Mark Cave-Ayland
2025-08-26 11:55 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 08/19] hw/i386/pc_piix.c: remove nvdimm " Mark Cave-Ayland
2025-08-26 11:56 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 09/19] hw/i386/pc_piix.c: simplify RAM size logic in pc_init_isa() Mark Cave-Ayland
2025-08-22 14:58 ` Philippe Mathieu-Daudé
2025-08-26 10:01 ` Xiaoyao Li
2025-08-27 11:00 ` Mark Cave-Ayland
2025-08-28 8:41 ` Mark Cave-Ayland
2025-09-22 12:08 ` Philippe Mathieu-Daudé
2025-09-22 13:44 ` Mark Cave-Ayland
2025-08-22 12:11 ` [PATCH v6 10/19] hw/i386/pc_piix.c: hardcode hole64_size to 0 " Mark Cave-Ayland
2025-08-26 11:57 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 11/19] hw/i386/pc_piix.c: remove pc_system_flash_cleanup_unused() from pc_init_isa() Mark Cave-Ayland
2025-08-22 12:11 ` [PATCH v6 12/19] hw/i386/pc_piix.c: always initialise ISA IDE drives in pc_init_isa() Mark Cave-Ayland
2025-08-26 12:01 ` Xiaoyao Li
2025-08-22 12:11 ` [PATCH v6 13/19] hw/i386/pc_piix.c: assume pcmc->pci_enabled is always false " Mark Cave-Ayland
2025-08-26 9:50 ` Xiaoyao Li
2025-08-27 11:32 ` Mark Cave-Ayland
2025-08-22 12:12 ` [PATCH v6 14/19] hw/i386/pc_piix.c: hardcode pcms->pci_bus to NULL " Mark Cave-Ayland
2025-08-26 12:03 ` Xiaoyao Li
2025-08-22 12:12 ` [PATCH v6 15/19] hw/i386/pc_piix.c: assume pcmc->pci_enabled is always true in pc_init1() Mark Cave-Ayland
2025-08-26 12:09 ` Xiaoyao Li
2025-08-27 11:54 ` Mark Cave-Ayland
2025-08-22 12:12 ` [PATCH v6 16/19] hw/i386: move isapc machine to separate isapc.c file Mark Cave-Ayland
2025-08-26 12:10 ` Xiaoyao Li
2025-08-22 12:12 ` [PATCH v6 17/19] hw/i386/pc_piix.c: remove unused headers after isapc machine split Mark Cave-Ayland
2025-08-26 12:10 ` Xiaoyao Li
2025-08-22 12:12 ` [PATCH v6 18/19] hw/i386/pc_piix.c: replace rom_memory with pci_memory Mark Cave-Ayland
2025-08-26 12:11 ` Xiaoyao Li
2025-08-22 12:12 ` [PATCH v6 19/19] hw/i386/isapc.c: replace rom_memory with system_memory Mark Cave-Ayland
2025-08-26 12:12 ` Xiaoyao Li
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=ddfb99cf-efc7-4883-8e36-6dbc1f4ece82@nutanix.com \
--to=mark.caveayland@nutanix.com \
--cc=berrange@redhat.com \
--cc=eduardo@habkost.net \
--cc=imammedo@redhat.com \
--cc=jdenemar@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=xiaoyao.li@intel.com \
/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).