[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <570ead2a-ff41-e730-d61d-0f59c67b1903@intel.com>
Date: Thu, 17 Dec 2020 12:55:39 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: ira.weiny@...el.com, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Fenghua Yu <fenghua.yu@...el.com>, x86@...nel.org,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
linux-doc@...r.kernel.org, linux-nvdimm@...ts.01.org,
linux-mm@...ck.org, linux-kselftest@...r.kernel.org,
Dan Williams <dan.j.williams@...el.com>,
Greg KH <gregkh@...uxfoundation.org>
Subject: Re: [PATCH V3 10/10] x86/pks: Add PKS test code
On 11/6/20 3:29 PM, ira.weiny@...el.com wrote:
> + /* Arm for context switch test */
> + write(fd, "1", 1);
> +
> + /* Context switch out... */
> + sleep(4);
> +
> + /* Check msr restored */
> + write(fd, "2", 1);
These are always tricky. What you ideally want here is:
1. Switch away from this task to a non-PKS task, or
2. Switch from this task to a PKS-using task, but one which has a
different PKS value
then, switch back to this task and make sure PKS maintained its value.
*But*, there's no absolute guarantee that another task will run. It
would not be totally unreasonable to have the kernel just sit in a loop
without context switching here if no other tasks can run.
The only way you *know* there is a context switch is by having two tasks
bound to the same logical CPU and make sure they run one after another.
This just gets itself into a state where it *CAN* context switch and
prays that one will happen.
You can also run a bunch of these in parallel bound to a single CPU.
That would also give you higher levels of assurance that *some* context
switch happens at sleep().
One critical thing with these tests is to sabotage the kernel and then
run them and make *sure* they fail. Basically, if you screw up, do they
actually work to catch it?
Powered by blists - more mailing lists