[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP045AoHaa_ogg_d_yv85R6t+Yt77b=X=mzxm-433B1fFTeF3g@mail.gmail.com>
Date: Thu, 15 Sep 2016 22:30:08 -0700
From: Kyle Huey <me@...ehuey.com>
To: Andy Lutomirski <luto@...capital.net>
Cc: "Robert O'Callahan" <robert@...llahan.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Dmitry Safonov <0x7f454c46@...il.com>,
Borislav Petkov <bp@...e.de>,
Linux API <linux-api@...r.kernel.org>,
"xen-devel@...ts.xenproject.org" <xen-devel@...ts.xenproject.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
Shuah Khan <shuah@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Len Brown <len.brown@...el.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Aravind Gopalakrishnan <Aravind.Gopalakrishnan@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Huang Rui <ray.huang@....com>,
Vladimir Zapolskiy <vladimir_zapolskiy@...tor.com>,
Andy Lutomirski <luto@...nel.org>,
Dmitry Safonov <dsafonov@...tuozzo.com>,
Kees Cook <keescook@...omium.org>, Jiri Slaby <jslaby@...e.cz>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Denys Vlasenko <dvlasenk@...hat.com>,
"open list:FILESYSTEMS (VFS and infrastructure)"
<linux-fsdevel@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH v3 3/3] x86,arch_prctl Add ARCH_[GET|SET]_CPUID for
controlling the CPUID instruction
On Thu, Sep 15, 2016 at 5:07 PM, Andy Lutomirski <luto@...capital.net> wrote:
> On Thu, Sep 15, 2016 at 4:33 PM, Kyle Huey <me@...ehuey.com> wrote:
>> +int get_cpuid_mode(unsigned long adr)
>> +{
>> + unsigned int val;
>> +
>> + if (test_thread_flag(TIF_NOCPUID))
>> + val = ARCH_CPUID_SIGSEGV;
>> + else
>> + val = ARCH_CPUID_ENABLE;
>> +
>> + return put_user(val, (unsigned int __user *)adr);
>> +}
>
> Can we just do:
>
> if (arg2 != 0)
> return -EINVAL;
> else
> return test_thread_flag(TIF_NOCPUID) ? ARCH_CPUID_SIGSEGBV : ARCH_CPUID_ENABLE;
We could. I copied the pattern of PR_GET_TSC here, but I don't feel
strongly about it.
>> diff --git a/tools/testing/selftests/x86/cpuid-fault.c b/tools/testing/selftests/x86/cpuid-fault.c
>> new file mode 100644
>> index 0000000..a9f3f68
>> --- /dev/null
>> +++ b/tools/testing/selftests/x86/cpuid-fault.c
>> @@ -0,0 +1,234 @@
>> +
>> +/*
>> + * Tests for arch_prctl(ARCH_GET_CPUID, ...) / prctl(ARCH_SET_CPUID, ...)
>> + *
>> + * Basic test to test behaviour of ARCH_GET_CPUID and ARCH_SET_CPUID
>> + */
>> +
>> +#include <stdio.h>
>> +#include <stdlib.h>
>> +#include <unistd.h>
>> +#include <signal.h>
>> +#include <inttypes.h>
>> +#include <cpuid.h>
>> +#include <errno.h>
>> +#include <sys/wait.h>
>> +
>> +#include <sys/prctl.h>
>> +#include <linux/prctl.h>
>> +
>> +const char *cpuid_names[] = {
>> + [0] = "[not set]",
>
> Is 0 even possible?
Only if the call fails.
- Kyle
Powered by blists - more mailing lists