From: Ricardo Koller <ricarkol@google.com>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu,
andrew.jones@linux.dev, pbonzini@redhat.com, maz@kernel.org,
seanjc@google.com, alexandru.elisei@arm.com,
eric.auger@redhat.com, reijiw@google.com, rananta@google.com,
bgardon@google.com, dmatlack@google.com,
axelrasmussen@google.com
Subject: Re: [PATCH v6 09/13] KVM: selftests: aarch64: Add aarch64/page_fault_test
Date: Mon, 19 Sep 2022 12:29:13 -0700 [thread overview]
Message-ID: <YyjDCWCJ5j8c6T2h@google.com> (raw)
In-Reply-To: <YyZDBIQsux1g97zl@google.com>
On Sat, Sep 17, 2022 at 09:58:28PM +0000, Oliver Upton wrote:
> 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@google.com>
>
> 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, will do that.
>
> --
> Thanks,
> Oliver
>
> From 0a5d3710b9043ae8fe5a9d7cc48eb854d1b7b746 Mon Sep 17 00:00:00 2001
> From: Oliver Upton <oliver.upton@linux.dev>
> 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;
I remember trying many ways of getting the compiler to not complain, I
must have tried this (wonder what happened). Anyway, gcc and clang are
happy with it.
> }
>
> static void setup_abort_handlers(struct kvm_vm *vm, struct kvm_vcpu *vcpu,
> --
> 2.37.3.968.ga6b4b080e4-goog
>
next prev parent reply other threads:[~2022-09-19 19:29 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 18:09 [PATCH v6 00/13] KVM: selftests: Add aarch64/page_fault_test Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 01/13] KVM: selftests: Add a userfaultfd library Ricardo Koller
2022-09-17 22:14 ` Oliver Upton
2022-09-06 18:09 ` [PATCH v6 02/13] KVM: selftests: aarch64: Add virt_get_pte_hva() library function Ricardo Koller
2022-09-17 22:15 ` Oliver Upton
2022-09-06 18:09 ` [PATCH v6 03/13] KVM: selftests: Add missing close and munmap in __vm_mem_region_delete() Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 04/13] KVM: selftests: aarch64: Construct DEFAULT_MAIR_EL1 using sysreg.h macros Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 05/13] tools: Copy bitfield.h from the kernel sources Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 06/13] KVM: selftests: Stash backing_src_type in struct userspace_mem_region Ricardo Koller
2022-09-17 22:17 ` Oliver Upton
2022-09-06 18:09 ` [PATCH v6 07/13] KVM: selftests: Change ____vm_create() to take struct kvm_vm_mem_params Ricardo Koller
2022-09-19 6:42 ` Andrew Jones
2022-09-19 16:28 ` Sean Christopherson
2022-09-19 19:21 ` Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 08/13] KVM: selftests: Use the right memslot for code, page-tables, and data allocations Ricardo Koller
2022-09-19 6:42 ` Andrew Jones
2022-09-06 18:09 ` [PATCH v6 09/13] KVM: selftests: aarch64: Add aarch64/page_fault_test Ricardo Koller
2022-09-17 21:58 ` Oliver Upton
2022-09-19 19:29 ` Ricardo Koller [this message]
2022-09-19 20:01 ` Sean Christopherson
2022-09-06 18:09 ` [PATCH v6 10/13] KVM: selftests: aarch64: Add userfaultfd tests into page_fault_test Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 11/13] KVM: selftests: aarch64: Add dirty logging " Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 12/13] KVM: selftests: aarch64: Add readonly memslot " Ricardo Koller
2022-09-06 18:09 ` [PATCH v6 13/13] KVM: selftests: aarch64: Add mix of " Ricardo Koller
2022-09-19 10:38 ` [PATCH v6 00/13] KVM: selftests: Add aarch64/page_fault_test Marc Zyngier
2022-09-19 16:38 ` Sean Christopherson
2022-09-19 16:57 ` Marc Zyngier
2022-09-19 18:28 ` Ricardo Koller
2022-09-20 4:14 Ricardo Koller
2022-09-20 4:15 ` [PATCH v6 09/13] KVM: selftests: aarch64: " Ricardo Koller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YyjDCWCJ5j8c6T2h@google.com \
--to=ricarkol@google.com \
--cc=alexandru.elisei@arm.com \
--cc=andrew.jones@linux.dev \
--cc=axelrasmussen@google.com \
--cc=bgardon@google.com \
--cc=dmatlack@google.com \
--cc=eric.auger@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=rananta@google.com \
--cc=reijiw@google.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).