From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>
Cc: Tom Rix <trix@redhat.com>,
kvm@vger.kernel.org, llvm@lists.linux.dev,
linux-kernel@vger.kernel.org,
Andrew Jones <andrew.jones@linux.dev>,
Anup Patel <anup@brainfault.org>,
Atish Patra <atishp@atishpatra.org>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Sean Christopherson <seanjc@google.com>,
Oliver Upton <oliver.upton@linux.dev>,
Jim Mattson <jmattson@google.com>
Subject: [PATCH v2 0/7] KVM: selftests: Fix "fix hypercall test" build errors
Date: Wed, 28 Sep 2022 23:36:45 +0000 [thread overview]
Message-ID: <20220928233652.783504-1-seanjc@google.com> (raw)
After a toolchain upgrade, the x86 fix_hypercall_test started throwing
warnings due to -Werror=array-bounds rightly complaining that the test is
generating an out-of-bounds array access.
The "obvious" fix is to replace the memcpy() with a memcmp() and compare
only the exact size of the hypercall instruction. That worked, until I
fiddled with the code a bit more and suddenly the test started jumping into
the weeds due to gcc generating a call to the external memcmp() through the
PLT, which isn't supported in the selftests.
To fix that mess, which has been a pitfall for quite some time, provide
implementations of memcmp(), memcpy(), and memset() to effectively override
the compiler built-ins. My thought is to start with the helpers that are
most likely to be used in guest code, and then add more as needed.
v2:
- Revert a patch that avoided memset(). [Jim]
- Collect reviews. [Oliver]
- Rename kvm_string.c => string_overrides.c. [David]
- Tweak the "fix hypercall" test to verify that the original opcode
is preserved exactly. [Oliver]
- Further dedup code in the "fix hypercall" test.
v1: https://lore.kernel.org/all/20220908233134.3523339-1-seanjc@google.com
Sean Christopherson (7):
KVM: selftests: Implement memcmp(), memcpy(), and memset() for guest
use
KVM: selftests: Compare insn opcodes directly in fix_hypercall_test
KVM: selftests: Remove unnecessary register shuffling in
fix_hypercall_test
KVM: selftests: Hardcode VMCALL/VMMCALL opcodes in "fix hypercall"
test
KVM: selftests: Explicitly verify KVM doesn't patch hypercall if
quirk==off
KVM: selftests: Dedup subtests of fix_hypercall_test
Revert "KVM: selftests: Fix nested SVM tests when built with clang"
tools/testing/selftests/kvm/Makefile | 11 +-
.../selftests/kvm/lib/string_override.c | 39 +++++
tools/testing/selftests/kvm/lib/x86_64/svm.c | 14 +-
.../selftests/kvm/x86_64/fix_hypercall_test.c | 134 +++++++-----------
4 files changed, 103 insertions(+), 95 deletions(-)
create mode 100644 tools/testing/selftests/kvm/lib/string_override.c
base-commit: c59fb127583869350256656b7ed848c398bef879
--
2.37.3.998.g577e59143f-goog
next reply other threads:[~2022-09-28 23:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 23:36 Sean Christopherson [this message]
2022-09-28 23:36 ` [PATCH v2 1/7] KVM: selftests: Implement memcmp(), memcpy(), and memset() for guest use Sean Christopherson
2022-09-29 8:48 ` Andrew Jones
2022-09-29 15:21 ` Sean Christopherson
2022-09-28 23:36 ` [PATCH v2 2/7] KVM: selftests: Compare insn opcodes directly in fix_hypercall_test Sean Christopherson
2022-09-28 23:36 ` [PATCH v2 3/7] KVM: selftests: Remove unnecessary register shuffling " Sean Christopherson
2022-09-28 23:36 ` [PATCH v2 4/7] KVM: selftests: Hardcode VMCALL/VMMCALL opcodes in "fix hypercall" test Sean Christopherson
2022-09-28 23:36 ` [PATCH v2 5/7] KVM: selftests: Explicitly verify KVM doesn't patch hypercall if quirk==off Sean Christopherson
2022-09-28 23:36 ` [PATCH v2 6/7] KVM: selftests: Dedup subtests of fix_hypercall_test Sean Christopherson
2022-09-28 23:36 ` [PATCH v2 7/7] Revert "KVM: selftests: Fix nested SVM tests when built with clang" Sean Christopherson
2022-09-28 23:44 ` Jim Mattson
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=20220928233652.783504-1-seanjc@google.com \
--to=seanjc@google.com \
--cc=andrew.jones@linux.dev \
--cc=anup@brainfault.org \
--cc=atishp@atishpatra.org \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=oliver.upton@linux.dev \
--cc=pbonzini@redhat.com \
--cc=trix@redhat.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