All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests
@ 2021-08-13 11:12 Paolo Bonzini
  2021-08-13 11:12 ` [PATCH kvm-unit-tests 1/2] access: optimize check for multiple reserved bits Paolo Bonzini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-08-13 11:12 UTC (permalink / raw)
  To: kvm; +Cc: babu.moger

Cut execution time by another 25%, from ~4 minutes to 2:40.

Paolo Bonzini (2):
  access: optimize check for multiple reserved bits
  access: treat NX as reserved if EFER.NXE=0

 x86/access.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH kvm-unit-tests 1/2] access: optimize check for multiple reserved bits
  2021-08-13 11:12 [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests Paolo Bonzini
@ 2021-08-13 11:12 ` Paolo Bonzini
  2021-08-13 11:12 ` [PATCH kvm-unit-tests 2/2] access: treat NX as reserved if EFER.NXE=0 Paolo Bonzini
  2021-08-13 15:32 ` [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests Babu Moger
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-08-13 11:12 UTC (permalink / raw)
  To: kvm; +Cc: babu.moger

Instead of using multiple ANDs statements, build a mask and check
it for more than one set bit.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 x86/access.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/x86/access.c b/x86/access.c
index c71f39d..6285c8c 100644
--- a/x86/access.c
+++ b/x86/access.c
@@ -288,6 +288,7 @@ static int ac_test_bump_one(ac_test_t *at)
 static _Bool ac_test_legal(ac_test_t *at)
 {
     int flags = at->flags;
+    unsigned reserved;
 
     if (F(AC_ACCESS_FETCH) && F(AC_ACCESS_WRITE))
 	return false;
@@ -321,8 +322,12 @@ static _Bool ac_test_legal(ac_test_t *at)
      * error code; the odds of a KVM bug are super low, and the odds of actually
      * being able to detect a bug are even lower.
      */
-    if ((F(AC_PDE_BIT51) + F(AC_PDE_BIT36) + F(AC_PDE_BIT13) +
-        F(AC_PTE_BIT51) + F(AC_PTE_BIT36)) > 1)
+    reserved = (AC_PDE_BIT51_MASK | AC_PDE_BIT36_MASK | AC_PDE_BIT13_MASK |
+	        AC_PTE_BIT51_MASK | AC_PTE_BIT36_MASK);
+
+    /* Only test one reserved bit at a time.  */
+    reserved &= flags;
+    if (reserved & (reserved - 1))
         return false;
 
     return true;
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH kvm-unit-tests 2/2] access: treat NX as reserved if EFER.NXE=0
  2021-08-13 11:12 [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests Paolo Bonzini
  2021-08-13 11:12 ` [PATCH kvm-unit-tests 1/2] access: optimize check for multiple reserved bits Paolo Bonzini
@ 2021-08-13 11:12 ` Paolo Bonzini
  2021-08-13 15:32 ` [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests Babu Moger
  2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2021-08-13 11:12 UTC (permalink / raw)
  To: kvm; +Cc: babu.moger

Cull more tests if EFER.NXE=0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 x86/access.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/x86/access.c b/x86/access.c
index 6285c8c..4725bbd 100644
--- a/x86/access.c
+++ b/x86/access.c
@@ -324,6 +324,8 @@ static _Bool ac_test_legal(ac_test_t *at)
      */
     reserved = (AC_PDE_BIT51_MASK | AC_PDE_BIT36_MASK | AC_PDE_BIT13_MASK |
 	        AC_PTE_BIT51_MASK | AC_PTE_BIT36_MASK);
+    if (!F(AC_CPU_EFER_NX))
+        reserved |= AC_PDE_NX_MASK | AC_PTE_NX_MASK;
 
     /* Only test one reserved bit at a time.  */
     reserved &= flags;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests
  2021-08-13 11:12 [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests Paolo Bonzini
  2021-08-13 11:12 ` [PATCH kvm-unit-tests 1/2] access: optimize check for multiple reserved bits Paolo Bonzini
  2021-08-13 11:12 ` [PATCH kvm-unit-tests 2/2] access: treat NX as reserved if EFER.NXE=0 Paolo Bonzini
@ 2021-08-13 15:32 ` Babu Moger
  2 siblings, 0 replies; 4+ messages in thread
From: Babu Moger @ 2021-08-13 15:32 UTC (permalink / raw)
  To: Paolo Bonzini, kvm



On 8/13/21 6:12 AM, Paolo Bonzini wrote:
> Cut execution time by another 25%, from ~4 minutes to 2:40.
> 
> Paolo Bonzini (2):
>   access: optimize check for multiple reserved bits
>   access: treat NX as reserved if EFER.NXE=0
> 
>  x86/access.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 

Tested-by: Babu Moger <babu.moger@amd.com>

Looks good. Number of tests reduced by half.

Before the patch.

#./tests/access
enabling apic
starting test

run
41287685 tests, 0 failures
PASS access
===========================================
After the patch.

# time ./tests/access

run
28753925 tests, 0 failures
PASS access

Thanks
Babu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-13 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13 11:12 [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests Paolo Bonzini
2021-08-13 11:12 ` [PATCH kvm-unit-tests 1/2] access: optimize check for multiple reserved bits Paolo Bonzini
2021-08-13 11:12 ` [PATCH kvm-unit-tests 2/2] access: treat NX as reserved if EFER.NXE=0 Paolo Bonzini
2021-08-13 15:32 ` [PATCH kvm-unit-tests 0/2] access: cut more execution time on reserved bit tests Babu Moger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.