qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
	Zhao Liu <zhao1.liu@intel.com>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH v2] i386/cpu: Drop the check of phys_bits in host_cpu_realizefn()
Date: Fri, 25 Oct 2024 09:20:21 +0800	[thread overview]
Message-ID: <f8370907-cc8d-41d0-bf9b-b9581d8a08fe@intel.com> (raw)
In-Reply-To: <20240929085747.2023198-1-xiaoyao.li@intel.com>

Ping.

Paolo, this is a simple clean up.

On 9/29/2024 4:57 PM, Xiaoyao Li wrote:
> The check of cpu->phys_bits to be in range between
> [32, TARGET_PHYS_ADDR_SPACE_BITS] in host_cpu_realizefn()
> is duplicated with check in x86_cpu_realizefn().
> 
> Since the ckeck in x86_cpu_realizefn() is called later and can cover all
> the x86 cases. Remove the one in host_cpu_realizefn().
> 
> Opportunistically adjust cpu->phys_bits directly in
> host_cpu_adjust_phys_bits(), which matches more with the function name.
> 
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
> ---
> Changes in v2:
>   - make host_cpu_adjust_phys_bits() return void and adjust
>     cpu->phys_bits inside it.
> ---
>   target/i386/host-cpu.c | 16 +++-------------
>   1 file changed, 3 insertions(+), 13 deletions(-)
> 
> diff --git a/target/i386/host-cpu.c b/target/i386/host-cpu.c
> index 8b8bf5afeccf..03b9d1b169a5 100644
> --- a/target/i386/host-cpu.c
> +++ b/target/i386/host-cpu.c
> @@ -42,7 +42,7 @@ static uint32_t host_cpu_phys_bits(void)
>       return host_phys_bits;
>   }
>   
> -static uint32_t host_cpu_adjust_phys_bits(X86CPU *cpu)
> +static void host_cpu_adjust_phys_bits(X86CPU *cpu)
>   {
>       uint32_t host_phys_bits = host_cpu_phys_bits();
>       uint32_t phys_bits = cpu->phys_bits;
> @@ -66,7 +66,7 @@ static uint32_t host_cpu_adjust_phys_bits(X86CPU *cpu)
>           }
>       }
>   
> -    return phys_bits;
> +    cpu->phys_bits = phys_bits;
>   }
>   
>   bool host_cpu_realizefn(CPUState *cs, Error **errp)
> @@ -75,17 +75,7 @@ bool host_cpu_realizefn(CPUState *cs, Error **errp)
>       CPUX86State *env = &cpu->env;
>   
>       if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) {
> -        uint32_t phys_bits = host_cpu_adjust_phys_bits(cpu);
> -
> -        if (phys_bits &&
> -            (phys_bits > TARGET_PHYS_ADDR_SPACE_BITS ||
> -             phys_bits < 32)) {
> -            error_setg(errp, "phys-bits should be between 32 and %u "
> -                       " (but is %u)",
> -                       TARGET_PHYS_ADDR_SPACE_BITS, phys_bits);
> -            return false;
> -        }
> -        cpu->phys_bits = phys_bits;
> +        host_cpu_adjust_phys_bits(cpu);
>       }
>       return true;
>   }


  reply	other threads:[~2024-10-25  1:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-29  8:57 [PATCH v2] i386/cpu: Drop the check of phys_bits in host_cpu_realizefn() Xiaoyao Li
2024-10-25  1:20 ` Xiaoyao Li [this message]
2024-10-28 18:42 ` Paolo Bonzini

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=f8370907-cc8d-41d0-bf9b-b9581d8a08fe@intel.com \
    --to=xiaoyao.li@intel.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhao1.liu@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).