[PATCH kvm-unit-tests] x86: access: check for PKU even for non-writable pages

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

 



Xiao Guangrong ran kvm-unit-tests on an actual machine with PKU and
found that it fails:

test pte.p pte.user pde.p pde.user pde.a pde.pse pkru.wd pkey=1 user write efer.nx cr4.pke: FAIL: error code 27 expected 7
Dump mapping: address: 0x123400000000
------L4: 2ebe007
------L3: 2ebf007
------L2: 8000000020000a5

So PFEC.PKEY is set even if the ordinary check failed (which it did
because pde.w is zero).  Adjust ac_test_permissions to match behavior
of silicon.

Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
 x86/access.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/x86/access.c b/x86/access.c
index 7caada8..8df2da8 100644
--- a/x86/access.c
+++ b/x86/access.c
@@ -353,9 +353,7 @@ pt_element_t ac_test_permissions(ac_test_t *at, unsigned flags, bool writable,
     if (F(AC_ACCESS_FETCH) && user && F(AC_CPU_CR4_SMEP))
         at->expected_fault = 1;
 
-    if (user && !F(AC_ACCESS_FETCH) &&
-        F(AC_PKU_PKEY) && F(AC_CPU_CR4_PKE) &&
-        !at->expected_fault) {
+    if (user && !F(AC_ACCESS_FETCH) && F(AC_PKU_PKEY) && F(AC_CPU_CR4_PKE)) {
         if (F(AC_PKU_AD)) {
             at->expected_fault = 1;
             at->expected_error |= PFERR_PK_MASK;
-- 
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux