Linux-man Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] arch_prctl.2: Add ARCH_SET_CPUID subcommand
@ 2020-03-16  3:21 Keno Fischer
  2020-04-07 20:23 ` Michael Kerrisk (man-pages)
  0 siblings, 1 reply; 2+ messages in thread
From: Keno Fischer @ 2020-03-16  3:21 UTC (permalink / raw)
  To: mtk.manpages; +Cc: linux-man

This subcommand was added a few years ago to support cpuid emulation
on x86 targets, but no changes to the man page appear to have been
made at the time. This commit adds a description for it and the
corresponding getter.

Signed-off-by: Keno Fischer <keno@juliacomputing.com>
---
 man2/arch_prctl.2 | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/man2/arch_prctl.2 b/man2/arch_prctl.2
index c49f4e0..e40d6bb 100644
--- a/man2/arch_prctl.2
+++ b/man2/arch_prctl.2
@@ -48,7 +48,44 @@ for the "set" operations, or as an
 .IR "unsigned long\ *" ,
 for the "get" operations.
 .PP
-Subfunctions for x86-64 are:
+Subfunctions for both x86 and x86-64 are:
+.TP
+.BR ARCH_SET_CPUID " (since Linux 4.12)"
+Enable (
+.I addr != 0
+) or disable (
+.I addr == 0
+) the
+.I cpuid
+instruction for the current thread. The instruction
+is enabled by default. If disabled,
+any execution of a
+.I cpuid
+instruction will instead generate a
+.B SIGSEGV
+signal. This feature can be used to emulate
+.I cpuid
+results that differ from what the underlying
+hardware would have produced (e.g. in a paravirtualization setting).
+This setting is preserved across
+.BR fork (2)
+and
+.BR clone (2)
+but reset to default (i.e.
+.I cpuid
+enabled) on
+.BR execve (2)
+.
+.TP
+.BR ARCH_GET_CPUID " (since Linux 4.12)"
+Return the setting of the flag manipulated by
+.B ARCH_SET_CPUID
+as the result of the system call (1 for enabled, 0 for disabled).
+.I addr
+is ignored.
+
+.TP
+Subfunctions for x86-64 only are:
 .TP
 .B ARCH_SET_FS
 Set the 64-bit base for the
@@ -96,6 +133,10 @@ is not a valid subcommand.
 .B EPERM
 .I addr
 is outside the process address space.
+.TP
+.B ENODEV
+.B ARCH_SET_CPUID
+was requested, but the underlying hardware does not support CPUID faulting.
 .\" .SH AUTHOR
 .\" Man page written by Andi Kleen.
 .SH CONFORMING TO
-- 
2.8.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] arch_prctl.2: Add ARCH_SET_CPUID subcommand
  2020-03-16  3:21 [PATCH] arch_prctl.2: Add ARCH_SET_CPUID subcommand Keno Fischer
@ 2020-04-07 20:23 ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-04-07 20:23 UTC (permalink / raw)
  To: Keno Fischer; +Cc: mtk.manpages, linux-man

Hello Keno,

On 3/16/20 4:21 AM, Keno Fischer wrote:
> This subcommand was added a few years ago to support cpuid emulation
> on x86 targets, but no changes to the man page appear to have been
> made at the time. This commit adds a description for it and the
> corresponding getter.
> 
> Signed-off-by: Keno Fischer <keno@juliacomputing.com>

Thanks. Patch applied.

Cheers,

Michael


> ---
>  man2/arch_prctl.2 | 43 ++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/man2/arch_prctl.2 b/man2/arch_prctl.2
> index c49f4e0..e40d6bb 100644
> --- a/man2/arch_prctl.2
> +++ b/man2/arch_prctl.2
> @@ -48,7 +48,44 @@ for the "set" operations, or as an
>  .IR "unsigned long\ *" ,
>  for the "get" operations.
>  .PP
> -Subfunctions for x86-64 are:
> +Subfunctions for both x86 and x86-64 are:
> +.TP
> +.BR ARCH_SET_CPUID " (since Linux 4.12)"
> +Enable (
> +.I addr != 0
> +) or disable (
> +.I addr == 0
> +) the
> +.I cpuid
> +instruction for the current thread. The instruction
> +is enabled by default. If disabled,
> +any execution of a
> +.I cpuid
> +instruction will instead generate a
> +.B SIGSEGV
> +signal. This feature can be used to emulate
> +.I cpuid
> +results that differ from what the underlying
> +hardware would have produced (e.g. in a paravirtualization setting).
> +This setting is preserved across
> +.BR fork (2)
> +and
> +.BR clone (2)
> +but reset to default (i.e.
> +.I cpuid
> +enabled) on
> +.BR execve (2)
> +.
> +.TP
> +.BR ARCH_GET_CPUID " (since Linux 4.12)"
> +Return the setting of the flag manipulated by
> +.B ARCH_SET_CPUID
> +as the result of the system call (1 for enabled, 0 for disabled).
> +.I addr
> +is ignored.
> +
> +.TP
> +Subfunctions for x86-64 only are:
>  .TP
>  .B ARCH_SET_FS
>  Set the 64-bit base for the
> @@ -96,6 +133,10 @@ is not a valid subcommand.
>  .B EPERM
>  .I addr
>  is outside the process address space.
> +.TP
> +.B ENODEV
> +.B ARCH_SET_CPUID
> +was requested, but the underlying hardware does not support CPUID faulting.
>  .\" .SH AUTHOR
>  .\" Man page written by Andi Kleen.
>  .SH CONFORMING TO
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-16  3:21 [PATCH] arch_prctl.2: Add ARCH_SET_CPUID subcommand Keno Fischer
2020-04-07 20:23 ` Michael Kerrisk (man-pages)

Linux-man Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-man/0 linux-man/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-man linux-man/ https://lore.kernel.org/linux-man \
		linux-man@vger.kernel.org
	public-inbox-index linux-man

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-man


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git