Skip to contentSkip to conversation

x86: check that clflushopt of an MMIO address succeeds

PATCH Superseded David Edmondson 2 participants 3 messages Nov 3, 2020 – Nov 5, 2020 KVM

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: check that clflushopt of an MMIO address succeeds

Verify that the clflushopt instruction succeeds when applied to an MMIO address at both cpl0 and cpl3.

---
This is a test for the fix included in:
https://lore.kernel.org/r/[email protected]

 x86/Makefile.common   |  3 ++-
 x86/clflushopt_mmio.c | 58 +++++++++++++++++++++++++++++++++++++++++++
 x86/unittests.cfg     |  5 ++++
 3 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 x86/clflushopt_mmio.c
x86/Makefile.common +2 -1
index b942086..e11666a 100644
@@ -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)
 
x86/clflushopt_mmio.c new file +58 -0

58 lines not on this page · raw message

x86/unittests.cfg +5 -0
index 872d679..35bedf8 100644
@@ -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
Signature · 1 line
2.28.0
#1 lore raw
Quoted 8 lines · David Edmondson

Verify that the clflushopt instruction succeeds when applied to an MMIO address at both cpl0 and cpl3.

[snip]

x86/clflushopt_mmio.c line 44

Quoted 3 lines
x86/clflushopt_mmio.c new file +3 -0
+	ret = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);
+	if (ret != PCIDEVADDR_INVALID) {
+		pci_dev_init(&pcidev, ret);

Just wondering, and perhaps this question is more general: does this test really need the Red-Hat test device?

I know it is an emulated device, but can’t we use some other MMIO address (e.g., PIT) that is also available on bare-metal?

#2 lore raw
Quoted 18 lines · Nadav Amit
Quoted 8 lines · David Edmondson

Verify that the clflushopt instruction succeeds when applied to an MMIO address at both cpl0 and cpl3.

[snip]

x86/clflushopt_mmio.c line 44

Quoted 3 lines
x86/clflushopt_mmio.c new file +3 -0
+	ret = pci_find_dev(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_TEST);
+	if (ret != PCIDEVADDR_INVALID) {
+		pci_dev_init(&pcidev, ret);

Just wondering, and perhaps this question is more general: does this test really need the Red-Hat test device?

Quoted 2 lines

I know it is an emulated device, but can’t we use some other MMIO address (e.g., PIT) that is also available on bare-metal?

If it's acceptable to assume that HPET is present and at 0xfed00000, then it could be used.

dme.

Signature · 1 line
Does everyone stare the way I do?