Re: [PATCH v6 09/13] KVM: selftests: aarch64: Add aarch64/page_fault_test

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

 



On Tue, Sep 06, 2022 at 06:09:26PM +0000, Ricardo Koller wrote:
> Add a new test for stage 2 faults when using different combinations of
> guest accesses (e.g., write, S1PTW), backing source type (e.g., anon)
> and types of faults (e.g., read on hugetlbfs with a hole). The next
> commits will add different handling methods and more faults (e.g., uffd
> and dirty logging). This first commit starts by adding two sanity checks
> for all types of accesses: AF setting by the hw, and accessing memslots
> with holes.
> 
> Signed-off-by: Ricardo Koller <ricarkol@xxxxxxxxxx>

Hey Ricardo,

You'll need to update .gitignore for this patch. Additionally, building
this test throws the following compiler warning:

In function ‘load_exec_code_for_test’,
    inlined from ‘run_test’ at aarch64/page_fault_test.c:745:2:
aarch64/page_fault_test.c:545:9: warning: array subscript ‘long unsigned int[0]’ is partly outside array bounds of ‘unsigned char[1]’ [-Warray-bounds]
  545 |         memcpy(code, c, 8);
      |         ^~~~~~~~~~~~~~~~~~

I've fixed both of these in the appended diff, feel free to squash.

--
Thanks,
Oliver

>From 0a5d3710b9043ae8fe5a9d7cc48eb854d1b7b746 Mon Sep 17 00:00:00 2001
From: Oliver Upton <oliver.upton@xxxxxxxxx>
Date: Sat, 17 Sep 2022 21:38:11 +0000
Subject: [PATCH] fixup! KVM: selftests: aarch64: Add aarch64/page_fault_test

---
 tools/testing/selftests/kvm/.gitignore               |  1 +
 .../testing/selftests/kvm/aarch64/page_fault_test.c  | 12 +++---------
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/tools/testing/selftests/kvm/.gitignore b/tools/testing/selftests/kvm/.gitignore
index d625a3f83780..7a9022cfa033 100644
--- a/tools/testing/selftests/kvm/.gitignore
+++ b/tools/testing/selftests/kvm/.gitignore
@@ -3,6 +3,7 @@
 /aarch64/debug-exceptions
 /aarch64/get-reg-list
 /aarch64/hypercalls
+/aarch64/page_fault_test
 /aarch64/psci_test
 /aarch64/vcpu_width_config
 /aarch64/vgic_init
diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm/aarch64/page_fault_test.c
index 60a6a8a45fa4..5ef2a7b941ec 100644
--- a/tools/testing/selftests/kvm/aarch64/page_fault_test.c
+++ b/tools/testing/selftests/kvm/aarch64/page_fault_test.c
@@ -512,7 +512,7 @@ void fail_vcpu_run_mmio_no_syndrome_handler(int ret)
 	events.fail_vcpu_runs += 1;
 }
 
-extern unsigned char __exec_test;
+extern uint64_t __exec_test;
 
 void noinline __return_0x77(void)
 {
@@ -526,7 +526,7 @@ void noinline __return_0x77(void)
  */
 static void load_exec_code_for_test(struct kvm_vm *vm)
 {
-	uint64_t *code, *c;
+	uint64_t *code;
 	struct userspace_mem_region *region;
 	void *hva;
 
@@ -536,13 +536,7 @@ static void load_exec_code_for_test(struct kvm_vm *vm)
 	assert(TEST_EXEC_GVA - TEST_GVA);
 	code = hva + 8;
 
-	/*
-	 * We need the cast to be separate in order for the compiler to not
-	 * complain with: "‘memcpy’ forming offset [1, 7] is out of the bounds
-	 * [0, 1] of object ‘__exec_test’ with type ‘unsigned char’"
-	 */
-	c = (uint64_t *)&__exec_test;
-	memcpy(code, c, 8);
+	*code = __exec_test;
 }
 
 static void setup_abort_handlers(struct kvm_vm *vm, struct kvm_vcpu *vcpu,
-- 
2.37.3.968.ga6b4b080e4-goog




[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