Skip to contentSkip to conversation

libxc/cpuid: minor fixes

PATCH In review Roger Pau Monne 3 participants 13 messages Jun 27, 2018 – Jun 28, 2018

lore
Share & tools
lore
#0 lore raw

cover libxc/cpuid: minor fixes

Hello,

This series contain some minor fixes for cpuid header file generation and a couple of fixes for libxc related cpuid functions.

Thanks, Roger.

Roger Pau Monne (3):
x86/cpuid: fix generation of auto cpuid header
libxc: fix stale PVH comment
libxc: do not return a value from xc_cpuid_policy

 tools/libxc/xc_cpuid_x86.c | 14 ++++++--------
 xen/include/Makefile       |  2 +-
 2 files changed, 7 insertions(+), 9 deletions(-)
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH 1/3 x86/cpuid: fix generation of auto cpuid header

The makefile rule to generate the cpuid-autogen.h header passes the whole list of dependencies to gen-cpuid.py but only the first dependency is actually needed.

So far this seems to be harmless.

---
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Stefano Stabellini <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>

---
 xen/include/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/Makefile +1 -1
index 8762ab3334..7c5034e6e0 100644
@@ -143,7 +143,7 @@ endif
 ifeq ($(XEN_TARGET_ARCH),x86_64)
 
 $(BASEDIR)/include/asm-x86/cpuid-autogen.h: $(BASEDIR)/include/public/arch-x86/cpufeatureset.h $(BASEDIR)/tools/gen-cpuid.py FORCE
-	$(PYTHON) $(BASEDIR)/tools/gen-cpuid.py -i $^ -o [email protected]
+	$(PYTHON) $(BASEDIR)/tools/gen-cpuid.py -i $< -o [email protected]
 	$(call move-if-changed,[email protected],$@)
 
 all: $(BASEDIR)/include/asm-x86/cpuid-autogen.h
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] x86/cpuid: fix generation of auto cpuid header

Quoted 7 lines · Roger Pau Monne

The makefile rule to generate the cpuid-autogen.h header passes the whole list of dependencies to gen-cpuid.py but only the first dependency is actually needed.

So far this seems to be harmless.

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

#3 lore raw

PATCH 2/3 libxc: fix stale PVH comment

In reply to Roger Pau Monne

PVHv2 uses the HVM path, not the PV one.

---
 tools/libxc/xc_cpuid_x86.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxc/xc_cpuid_x86.c +2 -2
index 21537f06f1..364f802c0f 100644
@@ -666,7 +666,7 @@ static void sanitise_featureset(struct cpuid_domain_info *info)
 
     if ( info->hvm )
     {
-        /* HVM Guest */
+        /* HVM or PVH Guest */
 
         if ( !info->pae )
             clear_bit(X86_FEATURE_PAE, info->featureset);
@@ -679,7 +679,7 @@ static void sanitise_featureset(struct cpuid_domain_info *info)
     }
     else
     {
-        /* PV or PVH Guest */
+        /* PV Guest */
 
         if ( !info->pv64 )
         {
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#5 lore raw

PATCH 3/3 libxc: do not return a value from xc_cpuid_policy

In reply to Roger Pau Monne

None of the called functions return any errors, so there's no point in returning an int from xc_cpuid_policy.

---
 tools/libxc/xc_cpuid_x86.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
tools/libxc/xc_cpuid_x86.c +4 -6
index 364f802c0f..3d1421aa50 100644
@@ -592,9 +592,9 @@ static void xc_cpuid_pv_policy(xc_interface *xch,
     }
 }
 
-static int xc_cpuid_policy(xc_interface *xch,
-                           const struct cpuid_domain_info *info,
-                           const unsigned int *input, unsigned int *regs)
+static void xc_cpuid_policy(xc_interface *xch,
+                            const struct cpuid_domain_info *info,
+                            const unsigned int *input, unsigned int *regs)
 {
     /*
      * For hypervisor leaves (0x4000XXXX) only 0x4000xx00.EAX[7:0] bits (max
@@ -604,15 +604,13 @@ static int xc_cpuid_policy(xc_interface *xch,
     if ( (input[0] & 0xffff0000) == 0x40000000 )
     {
         regs[0] = regs[1] = regs[2] = regs[3] = 0;
-        return 0;
+        return;
     }
 
     if ( info->hvm )
         xc_cpuid_hvm_policy(xch, info, input, regs);
     else
         xc_cpuid_pv_policy(xch, info, input, regs);
-
-    return 0;
 }
 
 static int xc_cpuid_do_domctl(
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw

Re: [PATCH 3/3] libxc: do not return a value from xc_cpuid_policy

Quoted 4 lines · Roger Pau Monne

None of the called functions return any errors, so there's no point in returning an int from xc_cpuid_policy.

What is the plan for this function? I expect it (and its children) to go away soon?

You can also delete xch, I think. It is not used.

Wei.

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

#7 lore raw

Re: [PATCH 3/3] libxc: do not return a value from xc_cpuid_policy

Quoted 8 lines · Wei Liu
Quoted 4 lines · Roger Pau Monne

None of the called functions return any errors, so there's no point in returning an int from xc_cpuid_policy.

What is the plan for this function? I expect it (and its children) to go away soon?

This is likely to go away with further cpuid work.

Quoted 1 line

You can also delete xch, I think. It is not used.

Right, I left it because all the xc_cpuid_* take xch as the first parameter. If I remove it here I will have to remove it from the _intel, _amd, _hvm and _pv helpers.

Roger.

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

Acked-by
#8 lore raw

Re: [PATCH 3/3] libxc: do not return a value from xc_cpuid_policy

Quoted 10 lines · Roger Pau Monné
Quoted 8 lines · Wei Liu
Quoted 4 lines · Roger Pau Monne

None of the called functions return any errors, so there's no point in returning an int from xc_cpuid_policy.

What is the plan for this function? I expect it (and its children) to go away soon?

Quoted 7 lines

This is likely to go away with further cpuid work.

Quoted 1 line

You can also delete xch, I think. It is not used.

Right, I left it because all the xc_cpuid_* take xch as the first parameter. If I remove it here I will have to remove it from the _intel, _amd, _hvm and _pv helpers.

If this and its leaf functions are going away soon-ish I'm fine with less code churn.

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

#9 lore raw

Re: [PATCH 3/3] libxc: do not return a value from xc_cpuid_policy

Quoted 13 lines · Wei Liu
Quoted 12 lines · Roger Pau Monné
Quoted 8 lines · Wei Liu
Quoted 4 lines · Roger Pau Monne

None of the called functions return any errors, so there's no point in returning an int from xc_cpuid_policy.

What is the plan for this function? I expect it (and its children) to go away soon?

This is likely to go away with further cpuid work.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

You can also delete xch, I think. It is not used.

Right, I left it because all the xc_cpuid_* take xch as the first parameter. If I remove it here I will have to remove it from the _intel, _amd, _hvm and _pv helpers.

If this and its leaf functions are going away soon-ish I'm fine with less code churn.

Hm, I'm not removing all of them, so let me add another patch on top of this one to remove the xch parameter.

Thanks, Roger.

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

#10 lore raw

Re: [PATCH 3/3] libxc: do not return a value from xc_cpuid_policy

Quoted 20 lines · Roger Pau Monné
Quoted 19 lines · Wei Liu
Quoted 17 lines · Roger Pau Monné
Quoted 8 lines · Wei Liu
Quoted 4 lines · Roger Pau Monne

None of the called functions return any errors, so there's no point in returning an int from xc_cpuid_policy.

What is the plan for this function? I expect it (and its children) to go away soon?

This is likely to go away with further cpuid work.

Quoted 1 line

You can also delete xch, I think. It is not used.

Right, I left it because all the xc_cpuid_* take xch as the first parameter. If I remove it here I will have to remove it from the _intel, _amd, _hvm and _pv helpers.

Quoted 5 lines
Quoted 2 lines

If this and its leaf functions are going away soon-ish I'm fine with less code churn.

Hm, I'm not removing all of them, so let me add another patch on top of this one to remove the xch parameter.

Here it is, since the rest of the patches are already Acked I'm just appending it here. Let me know if you prefer me to send it to the list together with the rest of the series.

---8<---
From c15f795af8311d12222c85454c9d82a12621057a Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <[email protected]>
Date: Thu, 28 Jun 2018 09:54:48 +0200
Subject: [PATCH 4/3] libxc: remove xch parameter from xc_cpuid_policy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

It's not used by the function or any of the helpers called by it.

---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>

---
 tools/libxc/xc_cpuid_x86.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)
tools/libxc/xc_cpuid_x86.c +11 -16
index 3d1421aa50..eb2e2db569 100644
@@ -308,8 +308,7 @@ static void free_cpuid_domain_info(struct cpuid_domain_info *info)
     free(info->featureset);
 }
 
-static void amd_xc_cpuid_policy(xc_interface *xch,
-                                const struct cpuid_domain_info *info,
+static void amd_xc_cpuid_policy(const struct cpuid_domain_info *info,
                                 const unsigned int *input, unsigned int *regs)
 {
     switch ( input[0] )
@@ -365,8 +364,7 @@ static void amd_xc_cpuid_policy(xc_interface *xch,
     }
 }
 
-static void intel_xc_cpuid_policy(xc_interface *xch,
-                                  const struct cpuid_domain_info *info,
+static void intel_xc_cpuid_policy(const struct cpuid_domain_info *info,
                                   const unsigned int *input, unsigned int *regs)
 {
     switch ( input[0] )
@@ -397,8 +395,7 @@ static void intel_xc_cpuid_policy(xc_interface *xch,
     }
 }
 
-static void xc_cpuid_hvm_policy(xc_interface *xch,
-                                const struct cpuid_domain_info *info,
+static void xc_cpuid_hvm_policy(const struct cpuid_domain_info *info,
                                 const unsigned int *input, unsigned int *regs)
 {
     switch ( input[0] )
@@ -490,13 +487,12 @@ static void xc_cpuid_hvm_policy(xc_interface *xch,
     }
 
     if ( info->vendor == VENDOR_AMD )
-        amd_xc_cpuid_policy(xch, info, input, regs);
+        amd_xc_cpuid_policy(info, input, regs);
     else
-        intel_xc_cpuid_policy(xch, info, input, regs);
+        intel_xc_cpuid_policy(info, input, regs);
 }
 
-static void xc_cpuid_pv_policy(xc_interface *xch,
-                               const struct cpuid_domain_info *info,
+static void xc_cpuid_pv_policy(const struct cpuid_domain_info *info,
                                const unsigned int *input, unsigned int *regs)
 {
     switch ( input[0] )
@@ -592,8 +588,7 @@ static void xc_cpuid_pv_policy(xc_interface *xch,
     }
 }
 
-static void xc_cpuid_policy(xc_interface *xch,
-                            const struct cpuid_domain_info *info,
+static void xc_cpuid_policy(const struct cpuid_domain_info *info,
                             const unsigned int *input, unsigned int *regs)
 {
     /*
@@ -608,9 +603,9 @@ static void xc_cpuid_policy(xc_interface *xch,
     }
 
     if ( info->hvm )
-        xc_cpuid_hvm_policy(xch, info, input, regs);
+        xc_cpuid_hvm_policy(info, input, regs);
     else
-        xc_cpuid_pv_policy(xch, info, input, regs);
+        xc_cpuid_pv_policy(info, input, regs);
 }
 
 static int xc_cpuid_do_domctl(
@@ -745,7 +740,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid,
     for ( ; ; )
     {
         cpuid(input, regs);
-        xc_cpuid_policy(xch, &info, input, regs);
+        xc_cpuid_policy(&info, input, regs);
 
         if ( regs[0] || regs[1] || regs[2] || regs[3] )
         {
@@ -818,7 +813,7 @@ int xc_cpuid_set(
     cpuid(input, regs);
 
     memcpy(polregs, regs, sizeof(regs));
-    xc_cpuid_policy(xch, &info, input, polregs);
+    xc_cpuid_policy(&info, input, polregs);
 
     for ( i = 0; i < 4; i++ )
     {
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by
#11 lore raw

Re: [PATCH 3/3] libxc: do not return a value from xc_cpuid_policy

Quoted 40 lines · Roger Pau Monné
Quoted 20 lines · Roger Pau Monné
Quoted 19 lines · Wei Liu
Quoted 17 lines · Roger Pau Monné
Quoted 8 lines · Wei Liu
Quoted 4 lines · Roger Pau Monne

None of the called functions return any errors, so there's no point in returning an int from xc_cpuid_policy.

What is the plan for this function? I expect it (and its children) to go away soon?

This is likely to go away with further cpuid work.

Quoted 1 line

You can also delete xch, I think. It is not used.

Right, I left it because all the xc_cpuid_* take xch as the first parameter. If I remove it here I will have to remove it from the _intel, _amd, _hvm and _pv helpers.

Quoted 5 lines
Quoted 2 lines

If this and its leaf functions are going away soon-ish I'm fine with less code churn.

Hm, I'm not removing all of them, so let me add another patch on top of this one to remove the xch parameter.

Here it is, since the rest of the patches are already Acked I'm just appending it here. Let me know if you prefer me to send it to the list together with the rest of the series.

---8<---
From c15f795af8311d12222c85454c9d82a12621057a Mon Sep 17 00:00:00 2001
From: Roger Pau Monne <[email protected]>
Date: Thu, 28 Jun 2018 09:54:48 +0200
Subject: [PATCH 4/3] libxc: remove xch parameter from xc_cpuid_policy
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Quoted 4 lines

It's not used by the function or any of the helpers called by it.

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

#12 lore raw
In reply to Roger Pau Monne
Quoted 11 lines · Roger Pau Monne

Hello,

This series contain some minor fixes for cpuid header file generation and a couple of fixes for libxc related cpuid functions.

Thanks, Roger.

Roger Pau Monne (3):
x86/cpuid: fix generation of auto cpuid header
libxc: fix stale PVH comment
libxc: do not return a value from xc_cpuid_policy

All 3 Reviewed-by: Andrew Cooper <[email protected]>

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