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

Re: [Xen-devel] [PATCH XTF] Functional: Add a UMIP test



On 21/07/17 02:42, Boqun Feng wrote:
On Thu, Jul 20, 2017 at 10:38:59AM +0100, Andrew Cooper wrote:
On 20/07/17 06:29, Boqun Feng (Intel) wrote:
Add a "umip" test for the User-Model Instruction Prevention. The test
simply tries to run sgdt/sidt/sldt/str/smsw in guest user-mode with
CR4_UMIP = 1.

Signed-off-by: Boqun Feng (Intel) <boqun.feng@xxxxxxxxx>
Thankyou very much for providing a test.

As a general remark, how have you found XTF to use?

Great tool! Especially when you need to run Xen in a simulated
environment like simics and want to test something, bringing up even a
simple Linux domainU would be a lot of pain. ;-) While XTF just works
like a charm and it's easy to write a test case, though according to
your comments I'm now very good at it now ;-)

I'm glad to hear this.


+void test_main(void)
+{
+    unsigned long exp;
+    unsigned long cr4 = read_cr4();
This is all good.  However, it is insufficient to properly test the UMIP
behaviour.  Please look at the cpuid-faulting to see how I structured
things.

In particular, you should:

1) Test the regular behaviour of the instructions.
2) Search for UMIP, skipping if it isn't available.
3) Enable UMIP.
Maybe I also need to provide a write_cr4_safe() similar as wrmsr_safe(),
in case that cpuid indicates UMIP supported while UMIP CR4 bit is not
allowed to set, which means a bug?

Yes. You are entirely correct. Feel free to put write_cr4_safe() in lib.h along with the other *_safe() variants.


4) Test the instructions again, this time checking for #GP in userspace.
5) Disable UMIP.
6) Check again for regular behaviour.

This way, you also check that turning it off works as well as turning it on.

In addition, each test needs to check more than just the block of tests
below.

1) The tests should run the instructions natively, and forced through the
instruction emulator.  See the FPU Exception Emulation test which is along
the same lines.  One thing to be aware of though is that in older versions
of Xen, the s??? instructions weren't implemented in the instruction
emulator, so the test should tolerate and skip if it gets #UD back.

Rogar that.

:)

Roger.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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