i386: Fix signedness of hyperv_spinlock_attempts
PATCH 1/1 i386: Fix signedness of hyperv_spinlock_attempts
The current default value for hv-spinlocks is 0xFFFFFFFF (meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of 0xFFFFFFFF.
Fix this by changing the type of X86CPU::hyperv_spinlock_attempts to uint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.
--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/i386/cpu.h +1 -1
@@ -1372,7 +1372,7 @@ struct X86CPU {bool hyperv_vapic;bool hyperv_relaxed_timing; -int hyperv_spinlock_attempts; +uint32_t hyperv_spinlock_attempts;char *hyperv_vendor_id;bool hyperv_time;bool hyperv_crash;
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Quoted 19 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Fix this by changing the type of
X86CPU::hyperv_spinlock_attemptstouint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/i386/cpu.h +0
-0
target/i386/cpu.h struct X86CPU { · line 1378
Quoted 8 lines
target/i386/cpu.h +1
-1@@ -1372,7 +1372,7 @@ struct X86CPU {bool hyperv_vapic;bool hyperv_relaxed_timing; -int hyperv_spinlock_attempts; +uint32_t hyperv_spinlock_attempts;char *hyperv_vendor_id;bool hyperv_time;bool hyperv_crash;
Signature · 1 line
Vitaly
Quoted 5 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.
Quoted 8 lines
Fix this by changing the type of
X86CPU::hyperv_spinlock_attemptstouint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
That said, it's tempting to just nuke qdev_prop_spinlocks and make hv-spinlocks a regular DEFINE_PROP_UINT32...
Quoted 17 lines
target/i386/cpu.h +1
-1@@ -1372,7 +1372,7 @@ struct X86CPU {bool hyperv_vapic;bool hyperv_relaxed_timing; -int hyperv_spinlock_attempts; +uint32_t hyperv_spinlock_attempts;char *hyperv_vendor_id;bool hyperv_time;bool hyperv_crash;Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Quoted 15 lines · Roman Kagan
Quoted 5 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Quoted 8 lines
Fix this by changing the type of
X86CPU::hyperv_spinlock_attemptstouint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 4 lines
Reviewed-by Roman Kagan <[email protected]>That said, it's tempting to just nuke
qdev_prop_spinlocksand make hv-spinlocks a regularDEFINE_PROP_UINT32...
Agreed. The only difference is that we would validate the property at realize time instead of object_property_set().
Signature · 1 line
Eduardo
Quoted 16 lines · Eduardo Habkost
Quoted 15 lines · Roman Kagan
Quoted 13 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Fix this by changing the type of
X86CPU::hyperv_spinlock_attemptstouint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 7 lines
Quoted 4 lines
Reviewed-by Roman Kagan <[email protected]>That said, it's tempting to just nuke
qdev_prop_spinlocksand make hv-spinlocks a regularDEFINE_PROP_UINT32...Agreed. The only difference is that we would validate the property at realize time instead of
object_property_set().
Right. But currently it's validated to be no less than 0xfff and no bigger than 0xffffffff. The latter check would become unnecessary, and I'm unable to find any reason to do the former (neither spec references nor the log messages of the commits that introduced it).
Roman.
Quoted 22 lines · Roman Kagan
Quoted 21 lines · Eduardo Habkost
Quoted 19 lines · Roman Kagan
Quoted 5 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Quoted 8 lines
Fix this by changing the type of
X86CPU::hyperv_spinlock_attemptstouint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Reviewed-by Roman Kagan <[email protected]>That said, it's tempting to just nuke
qdev_prop_spinlocksand make hv-spinlocks a regularDEFINE_PROP_UINT32...
Quoted 7 lines
Quoted 2 lines
Agreed. The only difference is that we would validate the property at realize time instead of
object_property_set().Right. But currently it's validated to be no less than
0xfffand no bigger than0xffffffff. The latter check would become unnecessary, and I'm unable to find any reason to do the former (neither spec references nor the log messages of the commits that introduced it).
The 0xFFF lower limit was originally introduced by commit 28f52cc04d34 ("hyper-v: introduce Hyper-V support infrastructure").
Vadim, do you know where the 0xFFF limit comes from?
Signature · 1 line
Eduardo
Quoted 38 lines · Eduardo Habkost
Quoted 29 lines · Roman Kagan
Quoted 19 lines · Eduardo Habkost
Quoted 18 lines · Roman Kagan
Quoted 15 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning
"never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Fix this by changing the type of
X86CPU::hyperv_spinlock_attempts
touint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 8 lines
Quoted 5 lines
Reviewed-by Roman Kagan <[email protected]>That said, it's tempting to just nuke
qdev_prop_spinlocksand make
hv-spinlocks a regularDEFINE_PROP_UINT32...Agreed. The only difference is that we would validate the property at realize time instead of
object_property_set().Quoted 7 lines
Right. But currently it's validated to be no less than
0xfffand no
bigger than0xffffffff. The latter check would become unnecessary, and
I'm unable to find any reason to do the former (neither spec references
nor the log messages of the commits that introduced it).
Quoted 4 lines
The
0xFFFlower limit was originally introduced by commit28f52cc04d34("hyper-v: introduce Hyper-V support infrastructure").Vadim, do you know where the
0xFFFlimit comes from?
I simply took this value from Windows Server 2008 R2 that I used as a reference while working on Hyper-V support for KVM. I also remember some paper (probably published by AMD ???) mentioned that 0x2fff seemed to have the best balance for PLE logic.
Best,
Vadim.
Quoted 42 lines · Vadim Rozenfeld
Quoted 41 lines · Eduardo Habkost
Quoted 29 lines · Roman Kagan
Quoted 19 lines · Eduardo Habkost
Quoted 18 lines · Roman Kagan
Quoted 15 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning
"never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Fix this by changing the type of
X86CPU::hyperv_spinlock_attempts
touint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 8 lines
Quoted 5 lines
Reviewed-by Roman Kagan <[email protected]>That said, it's tempting to just nuke
qdev_prop_spinlocksand make
hv-spinlocks a regularDEFINE_PROP_UINT32...Agreed. The only difference is that we would validate the property at realize time instead of
object_property_set().Quoted 7 lines
Right. But currently it's validated to be no less than
0xfffand no
bigger than0xffffffff. The latter check would become unnecessary, and
I'm unable to find any reason to do the former (neither spec references
nor the log messages of the commits that introduced it).The
0xFFFlower limit was originally introduced by commit28f52cc04d34("hyper-v: introduce Hyper-V support infrastructure").
Quoted 6 lines
Quoted 1 line
Vadim, do you know where the
0xFFFlimit comes from?I simply took this value from Windows Server 2008 R2 that I used as a reference while working on Hyper-V support for KVM. I also remember some paper (probably published by AMD ???) mentioned that
0x2fffseemed to have the best balance for PLE logic.
The question is whether the user should be disallowed to set it below 0xfff?
I don't see this mandated by the spec, so I'd rather remove the lower limit and convert the property to a regular DEFINE_PROP_UINT32.
Roman.
Quoted 50 lines · Roman Kagan
Quoted 42 lines · Vadim Rozenfeld
Quoted 41 lines · Eduardo Habkost
Quoted 29 lines · Roman Kagan
Quoted 19 lines · Eduardo Habkost
Quoted 18 lines · Roman Kagan
Quoted 15 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning
"never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Fix this by changing the type of
X86CPU::hyperv_spinlock_attempts
touint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 8 lines
Quoted 5 lines
Reviewed-by Roman Kagan <[email protected]>That said, it's tempting to just nuke
qdev_prop_spinlocksand make
hv-spinlocks a regularDEFINE_PROP_UINT32...Agreed. The only difference is that we would validate the property at realize time instead of
object_property_set().Quoted 7 lines
Right. But currently it's validated to be no less than
0xfffand no
bigger than0xffffffff. The latter check would become unnecessary, and
I'm unable to find any reason to do the former (neither spec references
nor the log messages of the commits that introduced it).The
0xFFFlower limit was originally introduced by commit28f52cc04d34("hyper-v: introduce Hyper-V support infrastructure").Quoted 6 lines
Quoted 1 line
Vadim, do you know where the
0xFFFlimit comes from?I simply took this value from Windows Server 2008 R2 that I used as a reference while working on Hyper-V support for KVM. I also remember some paper (probably published by AMD ???) mentioned that
0x2fffseemed to have the best balance for PLE logic.
Quoted 4 lines
The question is whether the user should be disallowed to set it below
0xfff?
I don't see this mandated by the spec, so I'd rather remove the lower limit and convert the property to a regularDEFINE_PROP_UINT32.
I've just posted a patch to that end, feel free to (dis)approve.
Roman.
Quoted 58 lines · Roman Kagan
Quoted 49 lines · Vadim Rozenfeld
Quoted 48 lines · Eduardo Habkost
Quoted 33 lines · Roman Kagan
Quoted 23 lines · Eduardo Habkost
Quoted 22 lines · Roman Kagan
Quoted 13 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning
"never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property
return -1 instead of0xFFFFFFFF.Fix this by changing the type of
X86CPU::hyperv_spinlock_attempts
touint32_t. This has no visible effect to guest operating
systems, affecting just the behavior of the QOM getter.Quoted 4 lines
Signed-off-by Eduardo Habkost <[email protected]>--- target/i386/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Reviewed-by Roman Kagan <[email protected]>Quoted 7 lines
Quoted 4 lines
That said, it's tempting to just nuke
qdev_prop_spinlocksand
make
hv-spinlocks a regularDEFINE_PROP_UINT32...Agreed. The only difference is that we would validate the property at realize time instead of
object_property_set().Quoted 9 lines
Right. But currently it's validated to be no less than
0xfffand
no
bigger than0xffffffff. The latter check would become unnecessary,
and
I'm unable to find any reason to do the former (neither spec references
nor the log messages of the commits that introduced it).The
0xFFFlower limit was originally introduced by commit28f52cc04d34("hyper-v: introduce Hyper-V support infrastructure").Quoted 7 lines
Quoted 1 line
Vadim, do you know where the
0xFFFlimit comes from?I simply took this value from Windows Server 2008 R2 that I used as a reference while working on Hyper-V support for KVM. I also remember some paper (probably published by AMD ???) mentioned
that0x2fffseemed to have the best balance for PLE logic.
Quoted 5 lines
The question is whether the user should be disallowed to set it below
0xfff?
I don't see this mandated by the spec, so I'd rather remove the lower limit and convert the property to a regularDEFINE_PROP_UINT32.
Honestly, I don't have any strong opinions on this matter. Having some lower boundary limit seemed quite logical to me. However, if a user wants to experiment and see how the smaller number of spinlock acquire attempts before calling HvNotifyLongSpinWait will affect the overall system performance, then why not?
Vadim.
Quoted 1 line
Roman.
Eduardo Habkost
AppliedQuoted 10 lines · Eduardo Habkost
The current default value for hv-spinlocks is
0xFFFFFFFF(meaning "never retry"). However, the value is stored as a signed integer, making the getter of the hv-spinlocks QOM property return -1 instead of0xFFFFFFFF.Fix this by changing the type of
X86CPU::hyperv_spinlock_attemptstouint32_t. This has no visible effect to guest operating systems, affecting just the behavior of the QOM getter.Signed-off-by Eduardo Habkost <[email protected]>
Queued on x86-next.
Signature · 1 line
Eduardo