From: Alexandru Elisei <alexandru.elisei@arm.com>
To: kvm@vger.kernel.org
Cc: pbonzini@redhat.com, drjones@redhat.com, maz@kernel.org,
andre.przywara@arm.com
Subject: [kvm-unit-tests RFC PATCH v3 7/7] arm64: timer: Run tests with VHE disabled
Date: Thu, 2 Jan 2020 13:46:46 +0000 [thread overview]
Message-ID: <1577972806-16184-8-git-send-email-alexandru.elisei@arm.com> (raw)
In-Reply-To: <1577972806-16184-1-git-send-email-alexandru.elisei@arm.com>
Disable VHE if first command line parameter is "nvhe" and then test the
timers. Just like with VHE enabled, if no other parameter is given, all
four timers are tested; otherwise, only the timers specified by the user.
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
---
lib/arm64/asm/processor.h | 2 ++
arm/timer.c | 33 +++++++++++++++++++++++++++++----
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/lib/arm64/asm/processor.h b/lib/arm64/asm/processor.h
index 70a5261dfe97..45a3176629e7 100644
--- a/lib/arm64/asm/processor.h
+++ b/lib/arm64/asm/processor.h
@@ -21,6 +21,8 @@
#define HCR_EL2_TGE (1 << 27)
#define HCR_EL2_E2H_SHIFT 34
#define HCR_EL2_E2H (_UL(1) << 34)
+#define HCR_EL2_IMO (1 << 4)
+#define HCR_EL2_FMO (1 << 3)
#define SCTLR_EL2_RES1 (3 << 28 | 3 << 22 | 1 << 18 | \
1 << 16 | 1 << 11 | 3 << 4)
diff --git a/arm/timer.c b/arm/timer.c
index 88de84bc1bcf..b35af189f857 100644
--- a/arm/timer.c
+++ b/arm/timer.c
@@ -465,19 +465,34 @@ static void test_hptimer(void)
report_prefix_pop();
}
-static void test_init(void)
+static void test_init(bool nvhe)
{
const struct fdt_property *prop;
const void *fdt = dt_fdt();
+ u64 hcr;
int node, len;
u32 *data;
+ if (nvhe) {
+ disable_vhe();
+ hcr = read_sysreg(hcr_el2);
+ /* KVM doesn't support different IMO/FMO settings */
+ hcr |= HCR_EL2_IMO | HCR_EL2_FMO;
+ write_sysreg(hcr, hcr_el2);
+ isb();
+ }
+
if (current_el == CurrentEL_EL1) {
vtimer = &vtimer_info;
ptimer = &ptimer_info;
} else {
- vtimer = &vtimer_info_vhe;
- ptimer = &ptimer_info_vhe;
+ if (nvhe) {
+ vtimer = &vtimer_info;
+ ptimer = &ptimer_info;
+ } else {
+ vtimer = &vtimer_info_vhe;
+ ptimer = &ptimer_info_vhe;
+ }
hvtimer = &hvtimer_info;
hptimer = &hptimer_info;
}
@@ -564,10 +579,20 @@ static void print_timer_info(void)
int main(int argc, char **argv)
{
int i;
+ bool nvhe = false;
current_el = current_level();
- test_init();
+ if (argc > 1 && strcmp(argv[1], "nvhe") == 0) {
+ if (current_el == CurrentEL_EL1)
+ report_info("Skipping EL2 tests. Boot at EL2 to enable.");
+ else
+ nvhe = true;
+ argv = &argv[1];
+ argc--;
+ }
+
+ test_init(nvhe);
print_timer_info();
--
2.7.4
prev parent reply other threads:[~2020-01-02 13:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-02 13:46 [kvm-unit-tests RFC PATCH v3 0/7] arm64: Run at EL2 Alexandru Elisei
2020-01-02 13:46 ` [kvm-unit-tests RFC PATCH v3 1/7] lib: Add _UL and _ULL definitions to linux/const.h Alexandru Elisei
2020-01-02 13:46 ` [kvm-unit-tests RFC PATCH v3 2/7] lib: arm64: Run existing tests at EL2 Alexandru Elisei
2020-01-02 13:46 ` [kvm-unit-tests RFC PATCH v3 3/7] arm64: timer: Add test for EL2 timers Alexandru Elisei
2020-01-02 13:46 ` [kvm-unit-tests RFC PATCH v3 4/7] arm64: selftest: Add basic test for EL2 Alexandru Elisei
2020-01-02 13:46 ` [kvm-unit-tests RFC PATCH v3 5/7] lib: arm64: Add support for disabling and re-enabling VHE Alexandru Elisei
2020-01-30 17:40 ` Marc Zyngier
2020-01-31 9:52 ` Alexandru Elisei
2020-01-31 11:26 ` Marc Zyngier
2020-01-31 11:43 ` Alexandru Elisei
2020-01-02 13:46 ` [kvm-unit-tests RFC PATCH v3 6/7] arm64: selftest: Expand EL2 test to disable and re-enable VHE Alexandru Elisei
2020-01-02 13:46 ` Alexandru Elisei [this message]
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=1577972806-16184-8-git-send-email-alexandru.elisei@arm.com \
--to=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=maz@kernel.org \
--cc=pbonzini@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;
as well as URLs for NNTP newsgroup(s).