i386/cpu: Drop the check of phys_bits in host_cpu_realizefn()
PATCH 1/1 i386/cpu: Drop the check of phys_bits in host_cpu_realizefn()
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 teh x86 case. Remove the one in host_cpu_realizefn().
--- target/i386/host-cpu.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
target/i386/host-cpu.c +1 -11
@@ -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; + cpu->phys_bits =host_cpu_adjust_phys_bits (cpu); }return true; }
Signature · 1 line
2.34.1
Quoted 8 lines · On Thu, 4 Jul 2024 07:12:31 -0400 Xiaoyao Li <[email protected]> wrote:
The check of
cpu->phys_bitsto be in range between [32,TARGET_PHYS_ADDR_SPACE_BITS] inhost_cpu_realizefn()is duplicated with check inx86_cpu_realizefn().Since the ckeck in
x86_cpu_realizefn()is called later and can cover all teh x86 case. Remove the one inhost_cpu_realizefn().Signed-off-by Xiaoyao Li <[email protected]>
Quoted 27 lines
--- target/i386/host-cpu.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)target/i386/host-cpu.c +1
-11@@ -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; + cpu->phys_bits =host_cpu_adjust_phys_bits (cpu); }return true; }
Hi Xiaoyao,
Quoted 28 lines · Xiaoyao Li
Date: Thu, 4 Jul 2024 07:12:31 -0400
From: Xiaoyao Li <[email protected]>
Subject: [PATCH] i386/cpu: Drop the check ofphys_bitsin
host_cpu_realizefn()
X-Mailer: git-send-email 2.34.1The check of
cpu->phys_bitsto be in range between [32,TARGET_PHYS_ADDR_SPACE_BITS] inhost_cpu_realizefn()is duplicated with check inx86_cpu_realizefn().Since the ckeck in
x86_cpu_realizefn()is called later and can cover all teh x86 case. Remove the one inhost_cpu_realizefn().Signed-off-by Xiaoyao Li <[email protected]>--- target/i386/host-cpu.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)target/i386/host-cpu.c +0
-2@@ -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); -
target/i386/host-cpu.c bool host_cpu_realizefn(CPUState *cs, Error **errp) · line 78
Quoted 10 lines
target/i386/host-cpu.c +1
-9-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; + cpu->phys_bits =host_cpu_adjust_phys_bits (cpu);
Just nit:
cpu->phys_bits can be adjusted directly in host_cpu_adjust_phys_bits(), and no need to return it out again.
Otherwise,