[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c
From: |
Paolo Bonzini |
Subject: |
Re: [RFC 09/13] i386/fw_cfg: move hpet_cfg definition to hpet.c |
Date: |
Fri, 17 Jan 2025 11:15:27 +0100 |
On Fri, Jan 17, 2025 at 11:13 AM Zhao Liu <zhao1.liu@intel.com> wrote:>
> Unfortunately, this way doesn't work either, if we disable both
> CONFIG_HPET and CONFIG_X_HPET_RUST.
>
> This is because I integrate hpet_fw_cfg into hpet lib which is compiled
> under CONFIG_X_HPET_RUST along with other HPET parts.
>
> The place broken is when hpet_fw_cfg is written into machine's fw_cfg (in
> hw/i386/fw_cfg.c).
>
> diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
> index 162785019b7a..3635b83620da 100644
> --- a/hw/i386/fw_cfg.c
> +++ b/hw/i386/fw_cfg.c
> @@ -147,7 +147,14 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms,
> #endif
> fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1);
>
> - fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_fw_cfg, sizeof(hpet_fw_cfg));
> +#if defined(CONFIG_HPET) || defined(CONFIG_X_HPET_RUST)
> + PCMachineState *pcms = (PCMachineState *)object_dynamic_cast(OBJECT(ms),
> +
> TYPE_PC_MACHINE);
> + if (pcms && pcms->hpet_enabled) {
> + fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_fw_cfg,
> sizeof(hpet_fw_cfg));
> + }
> +#endif
> +
> /* allocate memory for the NUMA channel: one (64bit) word for the number
> * of nodes, one word for each VCPU->node and one word for each node to
> * hold the amount of memory.
>
> I think this is a thorough enough solution and I can post a separate
> patch.
Yes, go ahead so that we can evaluate it separately from Rust concerns.
Paolo