All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] i386: Don't print warning if phys-bits was set automatically
@ 2019-06-11 20:54 Eduardo Habkost
  2019-06-12  8:58 ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 2+ messages in thread
From: Eduardo Habkost @ 2019-06-11 20:54 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, xuelian.guo, Eduardo Habkost,
	Dr. David Alan Gilbert, Robert Hoo

If cpu->host_phys_bits_limit is set, QEMU will make
cpu->phys_bits be lower than host_phys_bits on some cases.  This
triggers a warning that was supposed to be printed only if
phys-bits was explicitly set in the command-line.

Reorder the code so the value of cpu->phys_bits is validated
before the cpu->host_phys_bits handling.  This will avoid
unexpected warnings when cpu->host_phys_bits_limit is set.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 target/i386/cpu.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 7e5b545005..1327e4901a 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -5269,15 +5269,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
             uint32_t host_phys_bits = x86_host_phys_bits();
             static bool warned;
 
-            if (cpu->host_phys_bits) {
-                /* The user asked for us to use the host physical bits */
-                cpu->phys_bits = host_phys_bits;
-                if (cpu->host_phys_bits_limit &&
-                    cpu->phys_bits > cpu->host_phys_bits_limit) {
-                    cpu->phys_bits = cpu->host_phys_bits_limit;
-                }
-            }
-
             /* Print a warning if the user set it to a value that's not the
              * host value.
              */
@@ -5289,6 +5280,15 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
                 warned = true;
             }
 
+            if (cpu->host_phys_bits) {
+                /* The user asked for us to use the host physical bits */
+                cpu->phys_bits = host_phys_bits;
+                if (cpu->host_phys_bits_limit &&
+                    cpu->phys_bits > cpu->host_phys_bits_limit) {
+                    cpu->phys_bits = cpu->host_phys_bits_limit;
+                }
+            }
+
             if (cpu->phys_bits &&
                 (cpu->phys_bits > TARGET_PHYS_ADDR_SPACE_BITS ||
                 cpu->phys_bits < 32)) {
-- 
2.18.0.rc1.1.g3f1ff2140



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] i386: Don't print warning if phys-bits was set automatically
  2019-06-11 20:54 [Qemu-devel] [PATCH] i386: Don't print warning if phys-bits was set automatically Eduardo Habkost
@ 2019-06-12  8:58 ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: Dr. David Alan Gilbert @ 2019-06-12  8:58 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: Paolo Bonzini, xuelian.guo, qemu-devel, Robert Hoo

* Eduardo Habkost (ehabkost@redhat.com) wrote:
> If cpu->host_phys_bits_limit is set, QEMU will make
> cpu->phys_bits be lower than host_phys_bits on some cases.  This
> triggers a warning that was supposed to be printed only if
> phys-bits was explicitly set in the command-line.
> 
> Reorder the code so the value of cpu->phys_bits is validated
> before the cpu->host_phys_bits handling.  This will avoid
> unexpected warnings when cpu->host_phys_bits_limit is set.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

I think that's OK; note I think that means you can trigger an erroneous
warning in the case where the user does something odd like:

 phys_bits=50,host_phys_bits=true

so you print the warning and *then* set phys_bits = host_phys_bits.


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>


> ---
>  target/i386/cpu.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 7e5b545005..1327e4901a 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -5269,15 +5269,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>              uint32_t host_phys_bits = x86_host_phys_bits();
>              static bool warned;
>  
> -            if (cpu->host_phys_bits) {
> -                /* The user asked for us to use the host physical bits */
> -                cpu->phys_bits = host_phys_bits;
> -                if (cpu->host_phys_bits_limit &&
> -                    cpu->phys_bits > cpu->host_phys_bits_limit) {
> -                    cpu->phys_bits = cpu->host_phys_bits_limit;
> -                }
> -            }
> -
>              /* Print a warning if the user set it to a value that's not the
>               * host value.
>               */
> @@ -5289,6 +5280,15 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
>                  warned = true;
>              }
>  
> +            if (cpu->host_phys_bits) {
> +                /* The user asked for us to use the host physical bits */
> +                cpu->phys_bits = host_phys_bits;
> +                if (cpu->host_phys_bits_limit &&
> +                    cpu->phys_bits > cpu->host_phys_bits_limit) {
> +                    cpu->phys_bits = cpu->host_phys_bits_limit;
> +                }
> +            }
> +
>              if (cpu->phys_bits &&
>                  (cpu->phys_bits > TARGET_PHYS_ADDR_SPACE_BITS ||
>                  cpu->phys_bits < 32)) {
> -- 
> 2.18.0.rc1.1.g3f1ff2140
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-12  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-11 20:54 [Qemu-devel] [PATCH] i386: Don't print warning if phys-bits was set automatically Eduardo Habkost
2019-06-12  8:58 ` Dr. David Alan Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.