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

Re: [PATCH] x86: implement cpuid() in terms of cpuid_count()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 9 Aug 2023 15:35:51 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RpMMCxfj7BVSG4J1D4V3WsA/uJ7w6fw04YD4dnrrU2w=; b=jesuw7ruz2mAzS/8J0+vN6QcSaIC3laWEpO1/UHAW/gOe5HjoeyuYW9xz9/ppstUvjctN+807ikNNC55B085+U3R0rk4o4St7oDWtJPapMWZ1nSS5FFohqSBoeS1pG1XRnD2PMlHM/4IiGuo8rZ5oBSPQ/2mZiJDPfm4Bvyl72T6NmjMsv517uYPJjq0gNWWDAFB1Cpjdlr0Xft0FBVrdh2KTdn0MUv3O7nph0lRH9fwrWpDZVZh+EhNIDUot1NMeV/Lzil5SeqTvXGZqmyo9ZIlHvuDIG/G8n1uDJaP3gdPb8SnUjdrZpA8kzurX7ExPHb5HFSRrsavW/SXY6r+pQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PiIqgldnA3UAn7dl31PDlEZkiHB6LhGp2ZXQTPRpTmlxRTphqyUDe/hjHDz4341E4sdldfOgkvLwWSz6kH+k9QE5uXINzlH/h21soWBvGbDmcrj3kshHniao7W8zV0T5FMO6KtjrMlluwQyw6MTK3K+PtIYklC2PFX1hNsd6p7hV16wm1Rvfu82RMyT9lDO+EiWFNFMeZcYMm+K0wgLl78ChrqUSld00py/E7t6C90xD0recnQMYs8jEIYK0dJmVPJUL1UlgH6g9NZ7OcmsP0/JZ3+rl7CSPVkXafow/m47nx2Pz+MetcY7GR4hp0vjlPa5D65E9QZDFtYe97F9GvQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 09 Aug 2023 14:36:17 +0000
  • Ironport-data: A9a23:J3xyuqK0sWXkXfW/FE+R/JQlxSXFcZb7ZxGr2PjKsXjdYENShTMDm zQdXm6BOqyNNGL2LttyPN/i8U4B6J/UmN9lHgBlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrawP9TlK6q4mhA7gRvPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c4pBGt+p dgkAwshdy2FqO2H2eriW+dF05FLwMnDZOvzu1lG5BSAV7MKZM6GRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/dmpTGMlGSd05C0WDbRUvWMSd9YgQCzo WXe8n6iKhobKMae2XyO9XfEaurnxHqqANtNS+XnnhJsqFif7WMXUT8caXa2pMbhmmOYfNBuD 3VBr0LCqoB3riRHVOLVXRe1vXqFtR40QMdLHqsx7wTl4rrZ5UOVC3YJShZFacc6r4kmSDoyz FiLktj1Qzt1v9W9Vna15rqS6zSoNkAowXQqYCYFSU4J5oflqYRq1BbXFI88SOiyk8H/Hiz2z 3aSti8iir4PjMkNkaKm4VTAhDHqrZ/MJuIo2jjqsquexlsRTOaYi0aAsDA3Md4owF6lc2S8
  • Ironport-hdrordr: A9a23:pHR41av1Oe3beomZUBf1iuq/7skDSNV00zEX/kB9WHVpm62j5r mTdZEgvyMc5wx+ZJhRo7u90Ze7IU80iqQFhrX5UY3OYOCkghrKEGlahbGSoQEIYheOk9K1jJ 0QF5SWa+eAa2SS8/ya3ODQKb9J/DDtys+VbInlo0tQcQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 09/08/2023 1:29 pm, Jan Beulich wrote:
> Since as a bug workaround (likely inapplicable to any 64-bit CPUs, but
> it probably doesn't hurt to keep this) we clear %ecx on input anyway,
> we can as well fall back to cpuid_count(). This allows getting rid of
> four risky casts and makes things type-safe. The latter aspect requires
> two type adjustments elsewhere. While adjusting init_intel_cacheinfo(),
> convert three other local variables there as well. For the struct
> cpuinfo_x86 change it is relevant to note that no 64-bit CPU comes
> without CPUID support, and hence cpuid_level is never set to -1; the
> comment there was simply stale.
>
> No functional change intended, yet of course generated code isn't
> identical.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Hmm, far less invasive than when I last tried this, but that was years ago.

> --- a/xen/arch/x86/include/asm/processor.h
> +++ b/xen/arch/x86/include/asm/processor.h
> @@ -131,13 +131,8 @@ static inline int cpu_nr_siblings(unsign
>   * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
>   * resulting in stale register contents being returned.
>   */
> -#define cpuid(_op,_eax,_ebx,_ecx,_edx)          \
> -    asm volatile ( "cpuid"                      \
> -          : "=a" (*(int *)(_eax)),              \
> -            "=b" (*(int *)(_ebx)),              \
> -            "=c" (*(int *)(_ecx)),              \
> -            "=d" (*(int *)(_edx))               \
> -          : "0" (_op), "2" (0) )
> +#define cpuid(op, eax, ebx, ecx, edx)          \
> +        cpuid_count(op, 0, eax, ebx, ecx, edx)

Can we swap op for leaf seeing as both are changing?

Preferably with that changed, Acked-by: Andrew Cooper
<andrew.cooper3@xxxxxxxxxx>



 


Rackspace

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