[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 02/24] xen/x86: library-fy cpuid-releated functions


  • To: Penny Zheng <Penny.Zheng@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 15 Dec 2025 13:14:26 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: ray.huang@xxxxxxx, grygorii_strashko@xxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 15 Dec 2025 12:14:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 12.12.2025 05:01, Penny Zheng wrote:
> There are some cpuid library functions only referenced in
> XEN_DOMCTL-case, and shall be wrapped with CONFIG_MGMT_HYPERCALLS later,
> otherwise they will become unreachable when MGMT_HYPERCALLS=n, and hence
> violate Misra 2.1

At this point of the series there's no MGMT_HYPERCALLS yet (see also my reply
to the cover letter).

> For file cpupolicy-clr.c to contain cpupolicy clearing library function:
> - x86_cpu_policy_clear_out_of_range_leaves
>   - zero_leaves
> For file cpuid-cp2buf.c to contain cpuid copy-to-buffer library function:
> - x86_cpuid_copy_to_buffer
>   - copy_leaf_to_buffer
> For file cpuid-cpfrbuf.c to contain cpuid copy-from-buffer library function:
> - x86_cpuid_copy_from_buffer
> Sunmmerize all needed cpuid-library object file under a new variable
> CPUID_OBJS in Makefile.
> 
> Suggested-by: Jan Beulich <jbeulich@xxxxxxxx>
> Signed-off-by: Penny Zheng <Penny.Zheng@xxxxxxx>
> ---
> v4 -> v5:
> - library-fy cpuid-releated functions
> ---
>  tools/fuzz/cpu-policy/Makefile               |   4 +-
>  tools/fuzz/x86_instruction_emulator/Makefile |  11 +-
>  tools/libs/guest/Makefile.common             |   4 +-
>  tools/tests/cpu-policy/Makefile              |   3 +-
>  tools/tests/x86_emulator/Makefile            |   3 +-
>  xen/lib/Makefile                             |   5 +
>  xen/lib/x86/cpuid-cp2buf.c                   | 123 ++++++++
>  xen/lib/x86/cpuid-cpfrbuf.c                  | 129 +++++++++
>  xen/lib/x86/cpuid.c                          | 286 -------------------
>  xen/lib/x86/cpupolicy-clr.c                  |  73 +++++
>  10 files changed, 346 insertions(+), 295 deletions(-)
>  create mode 100644 xen/lib/x86/cpuid-cp2buf.c
>  create mode 100644 xen/lib/x86/cpuid-cpfrbuf.c
>  create mode 100644 xen/lib/x86/cpupolicy-clr.c

This looks to be doing at least three things in one go. If all of them would be
simple (including them being a reasonably small diff), that may be fine. But
the diffstat above says otherwise, so I may I ask that this be split in three,
maybe even four pieces (one per function moving to a new file, and maybe one
doing prep work in the Makefile-s touched)?

The filenames also aren't very descriptive. cp-from-buffer.c, cp-to-buffer.c,
and cp-clear.c maybe? Albeit the last one is where I'm the least convinced
that splitting out and making a library function is actually a good idea. Note
how I also didn't mention that function as a possible candidate for library-
fying. I'll try to not forget to bring this up with the x86 maintainers later
in the day.

> --- a/tools/libs/guest/Makefile.common
> +++ b/tools/libs/guest/Makefile.common
> @@ -35,7 +35,9 @@ OBJS-y += $(LIBELF_OBJS)
>  ifeq ($(CONFIG_X86),y) # Add libx86 to the build
>  vpath %.c ../../../xen/lib/x86
>  
> -OBJS-y                 += cpuid.o msr.o policy.o
> +CPUID_OBJS := cpuid.o cpuid-cp2buf.o cpuid-cpfrbuf.o cpupolicy-clr.o
> +OBJS-y                 += $(CPUID_OBJS)
> +OBJS-y                 += msr.o policy.o
>  endif

Why the mismatched padding on the := line?

> --- a/xen/lib/Makefile
> +++ b/xen/lib/Makefile
> @@ -45,3 +45,8 @@ lib-$(CONFIG_X86) += xxhash64.o
>  lib32-y := divmod.o
>  lib32-$(CONFIG_64BIT) :=
>  lib-y += $(lib32-y)
> +
> +libx86-y := x86/cpuid-cp2buf.o
> +libx86-y += x86/cpuid-cpfrbuf.o
> +libx86-y += x86/cpupolicy-clr.o
> +lib-$(CONFIG_X86) += $(libx86-y)

Why the intermediate libx86-y? And why is this not being done in 
xen/lib/x86/Makefile
anyway?

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.