* [kvm-unit-tests PATCH v2 0/1] x86: test clflushopt of MMIO address
@ 2020-11-18 12:11 David Edmondson
2020-11-18 12:11 ` [kvm-unit-tests PATCH v2 1/1] x86: check that clflushopt of an MMIO address succeeds David Edmondson
0 siblings, 1 reply; 3+ messages in thread
From: David Edmondson @ 2020-11-18 12:11 UTC (permalink / raw)
To: kvm; +Cc: David Edmondson
Kernel fix was merged in 51b958e5aeb1e18c00332e0b37c5d4e95a3eff84.
v2:
- Use HPET rather than the PCI test device (Nadav Amit).
David Edmondson (1):
x86: check that clflushopt of an MMIO address succeeds
x86/Makefile.common | 3 ++-
x86/clflushopt_mmio.c | 45 +++++++++++++++++++++++++++++++++++++++++++
x86/unittests.cfg | 5 +++++
3 files changed, 52 insertions(+), 1 deletion(-)
create mode 100644 x86/clflushopt_mmio.c
--
2.29.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [kvm-unit-tests PATCH v2 1/1] x86: check that clflushopt of an MMIO address succeeds
2020-11-18 12:11 [kvm-unit-tests PATCH v2 0/1] x86: test clflushopt of MMIO address David Edmondson
@ 2020-11-18 12:11 ` David Edmondson
2020-12-16 14:10 ` David Edmondson
0 siblings, 1 reply; 3+ messages in thread
From: David Edmondson @ 2020-11-18 12:11 UTC (permalink / raw)
To: kvm; +Cc: David Edmondson, Joao Martins
Verify that the clflushopt instruction succeeds when applied to an
MMIO address at both cpl0 and cpl3.
Suggested-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
x86/Makefile.common | 3 ++-
x86/clflushopt_mmio.c | 45 +++++++++++++++++++++++++++++++++++++++++++
x86/unittests.cfg | 5 +++++
3 files changed, 52 insertions(+), 1 deletion(-)
create mode 100644 x86/clflushopt_mmio.c
diff --git a/x86/Makefile.common b/x86/Makefile.common
index b942086..e11666a 100644
--- a/x86/Makefile.common
+++ b/x86/Makefile.common
@@ -62,7 +62,8 @@ tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \
$(TEST_DIR)/init.flat $(TEST_DIR)/smap.flat \
$(TEST_DIR)/hyperv_synic.flat $(TEST_DIR)/hyperv_stimer.flat \
$(TEST_DIR)/hyperv_connections.flat \
- $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat
+ $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat \
+ $(TEST_DIR)/clflushopt_mmio.flat
test_cases: $(tests-common) $(tests)
diff --git a/x86/clflushopt_mmio.c b/x86/clflushopt_mmio.c
new file mode 100644
index 0000000..f048f58
--- /dev/null
+++ b/x86/clflushopt_mmio.c
@@ -0,0 +1,45 @@
+#include "libcflat.h"
+#include "usermode.h"
+#include "pci.h"
+#include "x86/asm/pci.h"
+
+static volatile int ud;
+static void *memaddr = (void *)0xfed00000; /* HPET */
+
+static void handle_ud(struct ex_regs *regs)
+{
+ ud = 1;
+ regs->rip += 4;
+}
+
+static void try_clflushopt(const char *comment)
+{
+ int expected = !this_cpu_has(X86_FEATURE_CLFLUSHOPT);
+
+ ud = 0;
+ /* clflushopt (%rbx): */
+ asm volatile(".byte 0x66, 0x0f, 0xae, 0x3b" : : "b" (memaddr));
+
+ report(ud == expected, comment, expected ? "ABSENT" : "present");
+}
+
+static uint64_t user_clflushopt(void)
+{
+ try_clflushopt("clflushopt-mmio@cpl3 (%s)");
+
+ return 0;
+}
+
+int main(int ac, char **av)
+{
+ bool raised;
+
+ setup_vm();
+
+ handle_exception(UD_VECTOR, handle_ud);
+
+ (void) run_in_user(user_clflushopt, false, 0, 0, 0, 0, &raised);
+ try_clflushopt("clflushopt-mmio@cpl0 (%s)");
+
+ return report_summary();
+}
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 872d679..35bedf8 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -359,3 +359,8 @@ extra_params = -M q35,kernel-irqchip=split -device intel-iommu,intremap=on,eim=o
file = tsx-ctrl.flat
extra_params = -cpu host
groups = tsx-ctrl
+
+[clflushopt_mmio]
+file = clflushopt_mmio.flat
+extra_params = -cpu host
+arch = x86_64
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [kvm-unit-tests PATCH v2 1/1] x86: check that clflushopt of an MMIO address succeeds
2020-11-18 12:11 ` [kvm-unit-tests PATCH v2 1/1] x86: check that clflushopt of an MMIO address succeeds David Edmondson
@ 2020-12-16 14:10 ` David Edmondson
0 siblings, 0 replies; 3+ messages in thread
From: David Edmondson @ 2020-12-16 14:10 UTC (permalink / raw)
To: kvm
Ping, any chance of a review?
I'm happy to rework this or merge it with existing tests if required.
On Wednesday, 2020-11-18 at 12:11:29 GMT, David Edmondson wrote:
> Verify that the clflushopt instruction succeeds when applied to an
> MMIO address at both cpl0 and cpl3.
>
> Suggested-by: Joao Martins <joao.m.martins@oracle.com>
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
> x86/Makefile.common | 3 ++-
> x86/clflushopt_mmio.c | 45 +++++++++++++++++++++++++++++++++++++++++++
> x86/unittests.cfg | 5 +++++
> 3 files changed, 52 insertions(+), 1 deletion(-)
> create mode 100644 x86/clflushopt_mmio.c
>
> diff --git a/x86/Makefile.common b/x86/Makefile.common
> index b942086..e11666a 100644
> --- a/x86/Makefile.common
> +++ b/x86/Makefile.common
> @@ -62,7 +62,8 @@ tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \
> $(TEST_DIR)/init.flat $(TEST_DIR)/smap.flat \
> $(TEST_DIR)/hyperv_synic.flat $(TEST_DIR)/hyperv_stimer.flat \
> $(TEST_DIR)/hyperv_connections.flat \
> - $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat
> + $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat \
> + $(TEST_DIR)/clflushopt_mmio.flat
>
> test_cases: $(tests-common) $(tests)
>
> diff --git a/x86/clflushopt_mmio.c b/x86/clflushopt_mmio.c
> new file mode 100644
> index 0000000..f048f58
> --- /dev/null
> +++ b/x86/clflushopt_mmio.c
> @@ -0,0 +1,45 @@
> +#include "libcflat.h"
> +#include "usermode.h"
> +#include "pci.h"
> +#include "x86/asm/pci.h"
> +
> +static volatile int ud;
> +static void *memaddr = (void *)0xfed00000; /* HPET */
> +
> +static void handle_ud(struct ex_regs *regs)
> +{
> + ud = 1;
> + regs->rip += 4;
> +}
> +
> +static void try_clflushopt(const char *comment)
> +{
> + int expected = !this_cpu_has(X86_FEATURE_CLFLUSHOPT);
> +
> + ud = 0;
> + /* clflushopt (%rbx): */
> + asm volatile(".byte 0x66, 0x0f, 0xae, 0x3b" : : "b" (memaddr));
> +
> + report(ud == expected, comment, expected ? "ABSENT" : "present");
> +}
> +
> +static uint64_t user_clflushopt(void)
> +{
> + try_clflushopt("clflushopt-mmio@cpl3 (%s)");
> +
> + return 0;
> +}
> +
> +int main(int ac, char **av)
> +{
> + bool raised;
> +
> + setup_vm();
> +
> + handle_exception(UD_VECTOR, handle_ud);
> +
> + (void) run_in_user(user_clflushopt, false, 0, 0, 0, 0, &raised);
> + try_clflushopt("clflushopt-mmio@cpl0 (%s)");
> +
> + return report_summary();
> +}
> diff --git a/x86/unittests.cfg b/x86/unittests.cfg
> index 872d679..35bedf8 100644
> --- a/x86/unittests.cfg
> +++ b/x86/unittests.cfg
> @@ -359,3 +359,8 @@ extra_params = -M q35,kernel-irqchip=split -device intel-iommu,intremap=on,eim=o
> file = tsx-ctrl.flat
> extra_params = -cpu host
> groups = tsx-ctrl
> +
> +[clflushopt_mmio]
> +file = clflushopt_mmio.flat
> +extra_params = -cpu host
> +arch = x86_64
> --
> 2.29.2
dme.
--
It's alright, we told you what to dream.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-16 14:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18 12:11 [kvm-unit-tests PATCH v2 0/1] x86: test clflushopt of MMIO address David Edmondson
2020-11-18 12:11 ` [kvm-unit-tests PATCH v2 1/1] x86: check that clflushopt of an MMIO address succeeds David Edmondson
2020-12-16 14:10 ` David Edmondson
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).