Skip to contentSkip to conversation

tools/libxc: Properly increment ApicIdCoreSize field on AMD

PATCH Applied Boris Ostrovsky 3 participants 7 messages Jul 22, 2016 – Jul 26, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/libxc: Properly increment ApicIdCoreSize field on AMD

Current code incorrectly adds 1 to full register instead of incrementing the field in bits 15:12.

---
 tools/libxc/xc_cpuid_x86.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_cpuid_x86.c +2 -1
index 84f4e08..fbbac9e 100644
@@ -331,7 +331,8 @@ static void amd_xc_cpuid_policy(xc_interface *xch,
          * ECX[15:12] is ApicIdCoreSize: ECX[7:0] is NumberOfCores (minus one).
          * Update to reflect vLAPIC_ID = vCPU_ID * 2.
          */
-        regs[2] = ((regs[2] & 0xf000u) + 1) | ((regs[2] & 0xffu) << 1) | 1u;
+        regs[2] = ((regs[2] + (1u << 12)) & 0xf000u) |
+                  ((regs[2] & 0xffu) << 1) | 1u;
         break;
 
     case 0x8000000a: {
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Boris Ostrovsky

Current code incorrectly adds 1 to full register instead of incrementing the field in bits 15:12.

I trust your expertise in this field. :-)

Quoted 21 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_cpuid_x86.c +2 -1
index 84f4e08..fbbac9e 100644
@@ -331,7 +331,8 @@ static void amd_xc_cpuid_policy(xc_interface *xch,
          * ECX[15:12] is ApicIdCoreSize: ECX[7:0] is NumberOfCores (minus one).
          * Update to reflect vLAPIC_ID = vCPU_ID * 2.
          */
-        regs[2] = ((regs[2] & 0xf000u) + 1) | ((regs[2] & 0xffu) << 1) | 1u;
+        regs[2] = ((regs[2] + (1u << 12)) & 0xf000u) |
+                  ((regs[2] & 0xffu) << 1) | 1u;
         break;
 
     case 0x8000000a: {
Signature · 1 line
1.8.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#2 lore raw
Quoted 8 lines · Wei Liu
Quoted 4 lines · Boris Ostrovsky

Current code incorrectly adds 1 to full register instead of incrementing the field in bits 15:12.

I trust your expertise in this field. :-)

Just in this field? The field is only 4 bits! ;-)

But this actually fixes a regression that was triggered by recent hvmloader change on one particular processor that we have in the test farm.

-boris

Quoted 18 lines
Quoted 18 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_cpuid_x86.c +2 -1
index 84f4e08..fbbac9e 100644
@@ -331,7 +331,8 @@ static void amd_xc_cpuid_policy(xc_interface *xch,
          * ECX[15:12] is ApicIdCoreSize: ECX[7:0] is NumberOfCores (minus one).
          * Update to reflect vLAPIC_ID = vCPU_ID * 2.
          */
-        regs[2] = ((regs[2] & 0xf000u) + 1) | ((regs[2] & 0xffu) << 1) | 1u;
+        regs[2] = ((regs[2] + (1u << 12)) & 0xf000u) |
+                  ((regs[2] & 0xffu) << 1) | 1u;
         break;
 
Quoted 4 lines
Quoted 4 lines
tools/libxc/xc_cpuid_x86.c +0 -0
     case 0x8000000a: {
Signature · 1 line
1.8.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
Quoted 5 lines · Boris Ostrovsky
Quoted 4 lines · Wei Liu
Quoted 3 lines · Boris Ostrovsky

Current code incorrectly adds 1 to full register instead of incrementing the field in bits 15:12.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

I trust your expertise in this field. :-)

Just in this field? The field is only 4 bits! ;-)

No, it's only one bit! :-P

Quoted 2 lines

But this actually fixes a regression that was triggered by recent hvmloader change on one particular processor that we have in the test farm.

Ian, this is a backport candidate and needs to go back as far as possible. The bogus calculation was introduced in 2008 (!).

Wei.

Quoted 21 lines

-boris

Quoted 18 lines
Quoted 18 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/libxc/xc_cpuid_x86.c +2 -1
index 84f4e08..fbbac9e 100644
@@ -331,7 +331,8 @@ static void amd_xc_cpuid_policy(xc_interface *xch,
          * ECX[15:12] is ApicIdCoreSize: ECX[7:0] is NumberOfCores (minus one).
          * Update to reflect vLAPIC_ID = vCPU_ID * 2.
          */
-        regs[2] = ((regs[2] & 0xf000u) + 1) | ((regs[2] & 0xffu) << 1) | 1u;
+        regs[2] = ((regs[2] + (1u << 12)) & 0xf000u) |
+                  ((regs[2] & 0xffu) << 1) | 1u;
         break;
 
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
tools/libxc/xc_cpuid_x86.c +0 -0
     case 0x8000000a: {
Signature · 1 line
1.8.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw

Wei Liu writes ("Re: [PATCH] tools/libxc: Properly increment ApicIdCoreSize field on AMD"):

Quoted 7 lines · Boris Ostrovsky
Quoted 3 lines · Wei Liu

But this actually fixes a regression that was triggered by recent hvmloader change on one particular processor that we have in the test farm.

Ian, this is a backport candidate and needs to go back as far as possible. The bogus calculation was introduced in 2008 (!).

Thanks, but:

Not queued for backport because the patch is not in staging.

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Applied
#5 lore raw
Quoted 6 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH] tools/libxc: Properly increment ApicIdCoreSize field on AMD"):

Quoted 5 lines · Boris Ostrovsky
Quoted 3 lines · Wei Liu

But this actually fixes a regression that was triggered by recent hvmloader change on one particular processor that we have in the test farm.

Quoted 7 lines
Quoted 2 lines

Ian, this is a backport candidate and needs to go back as far as possible. The bogus calculation was introduced in 2008 (!).

Thanks, but:

Not queued for backport because the patch is not in staging.

Pushed to staging.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#6 lore raw

Wei Liu writes ("Re: [PATCH] tools/libxc: Properly increment ApicIdCoreSize field on AMD"):

Quoted 6 lines · Ian Jackson
Quoted 3 lines

Wei Liu writes ("Re: [PATCH] tools/libxc: Properly increment ApicIdCoreSize field on AMD"):

Quoted 2 lines

Ian, this is a backport candidate and needs to go back as far as possible. The bogus calculation was introduced in 2008 (!).

Pushed to staging.

Thanks, queued.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel