Re: [v6 PATCH 21/21] selftests/x86: Add tests for User-Mode Instruction Prevention
Andy Lutomirski <[email protected]> Wed, 8 Mar 2017 07:56:20 -0800
| Newsgroups | org.kernel.vger.linux-msdos,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CALCETrX8EAkDMYxx0QB-k1eZH51sMXDpXKHfZTo0hS-FE7weBg@mail.gmail.com> |
On Tue, Mar 7, 2017 at 4:32 PM, Ricardo Neri <[email protected]> wrote: > Certain user space programs that run on virtual-8086 mode may utilize > instructions protected by the User-Mode Instruction Prevention (UMIP) > security feature present in new Intel processors: SGDT, SIDT and SMSW. In > such a case, a general protection fault is issued if UMIP is enabled. When > such a fault happens, the kernel catches it and emulates the results of > these instructions with dummy values. The purpose of this new > test is to verify whether the impacted instructions can be executed without > causing such #GP. If no #GP exceptions occur, we expect to exit virtual- > 8086 mode from INT 0x80. > > The instructions protected by UMIP are executed in representative use > cases: > a) the memory address of the result is given in the form of a displacement > from the base of the data segment > b) the memory address of the result is given in a general purpose register > c) the result is stored directly in a general purpose register. > > Unfortunately, it is not possible to check the results against a set of > expected values because no emulation will occur in systems that do not have > the UMIP feature. Instead, results are printed for verification. You could pre-initialize the result buffer to a bunch of non-matching values (1, 2, 3, ...) and then check that all the invocations of the same instruction gave the same value. If you do this, maybe make it a follow-up patch -- see other email.