* [PATCH v2] KVM: x86/cpuid: add type suffix to decimal const 48 fix building warning
@ 2025-01-27 1:38 Ethan Zhao
2025-02-15 0:50 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Ethan Zhao @ 2025-01-27 1:38 UTC (permalink / raw)
To: hpa, bp, tglx, mingo
Cc: linux-kernel, kvm, x86, joro, jmattson, wanpengli, pbonzini,
seanjc, etzhao
The default type of a decimal constant is determined by the magnitude of
its value. If the value falls within the range of int, its type is int;
otherwise, if it falls within the range of unsigned int, its type is
unsigned int. This results in the constant 48 being of type int. In the
following min call,
g_phys_as = min(g_phys_as, 48);
This leads to a building warning/error (CONFIG_KVM_WERROR=y) caused by
the mismatch between the types of the two arguments to macro min. By
adding the suffix U to explicitly declare the type of the constant, this
issue is fixed.
Signed-off-by: Ethan Zhao <haifeng.zhao@linux.intel.com>
---
v2: fix typo in subject.
---
arch/x86/kvm/cpuid.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 2cbb3874ad39..aa2c319118bc 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1704,7 +1704,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
phys_as = entry->eax & 0xff;
g_phys_as = phys_as;
if (kvm_mmu_get_max_tdp_level() < 5)
- g_phys_as = min(g_phys_as, 48);
+ g_phys_as = min(g_phys_as, 48U);
}
entry->eax = phys_as | (virt_as << 8) | (g_phys_as << 16);
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] KVM: x86/cpuid: add type suffix to decimal const 48 fix building warning
2025-01-27 1:38 [PATCH v2] KVM: x86/cpuid: add type suffix to decimal const 48 fix building warning Ethan Zhao
@ 2025-02-15 0:50 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2025-02-15 0:50 UTC (permalink / raw)
To: Sean Christopherson, hpa, bp, tglx, mingo, Ethan Zhao
Cc: linux-kernel, kvm, x86, joro, jmattson, wanpengli, pbonzini, etzhao
On Mon, 27 Jan 2025 09:38:37 +0800, Ethan Zhao wrote:
> The default type of a decimal constant is determined by the magnitude of
> its value. If the value falls within the range of int, its type is int;
> otherwise, if it falls within the range of unsigned int, its type is
> unsigned int. This results in the constant 48 being of type int. In the
> following min call,
>
> g_phys_as = min(g_phys_as, 48);
>
> [...]
Applied to kvm-x86 misc, thanks!
[1/1] KVM: x86/cpuid: add type suffix to decimal const 48 fix building warning
https://github.com/kvm-x86/linux/commit/a11128ce1636
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-15 0:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-27 1:38 [PATCH v2] KVM: x86/cpuid: add type suffix to decimal const 48 fix building warning Ethan Zhao
2025-02-15 0:50 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®