On 30/09/2025 9:54 am, Alejandro Vallejo wrote: > If Xen isn't detected on CPUID, then: > > * Skip setting up Xenbus/PV-console/shared_info/hypercalls/qemu-debug. > * Register COM1 as an output callback. > > This patch enables running XTF on QEMU-TCG/KVM out of the box.
When I did a KVM branch for amluto, https://xenbits.xen.org/gitweb/?p=people/andrewcoop/xen-test-framework.git;a=shortlog;h=refs/heads/kvm was what was necessary to get tests to pass. I can see the need for MB1 going away now that KVM uses the PVH entrypoint, but is the rest really unnecessary? > diff --git a/arch/x86/setup.c b/arch/x86/setup.c > index 2ac212e..6172c7e 100644 > --- a/arch/x86/setup.c > +++ b/arch/x86/setup.c > @@ -243,11 +245,19 @@ static void map_shared_info(void) > panic("Failed to map shared_info: %d\n", rc); > } > > +static void pio_write(uint16_t port, const char *buf, size_t len) > +{ > + asm volatile("rep; outsb" : "+S" (buf), "+c" (len) : "d" (port)); > +} I've factored out rep_movsb() in the proper place for library functions, and without the rebasing issue reinserting the erroneous ;. > @@ -255,12 +265,41 @@ static void xen_console_write(const char *buf, size_t > len) > hypercall_console_write(buf, len); > } > > +static bool detect_xen_runtime(void) > +{ > + uint32_t eax, ebx, ecx, edx; > + > + /* PV tests always run under Xen */ > + if ( IS_DEFINED(CONFIG_PV) ) > + return true; > + > + /* HVM tests may additionally run on non-Xen hypervisors or baremetal */ > + cpuid_count(0x40000000, 0, &eax, &ebx, &ecx, &edx); > + if ( ebx == XEN_CPUID_SIGNATURE_EBX && > + ecx == XEN_CPUID_SIGNATURE_ECX && > + edx == XEN_CPUID_SIGNATURE_EDX ) > + return true; > + > + /* Viridian guests have the Xen leaves higher up, so check there too */ > + cpuid_count(0x40000100, 0, &eax, &ebx, &ecx, &edx); > + return ebx == XEN_CPUID_SIGNATURE_EBX && > + ecx == XEN_CPUID_SIGNATURE_ECX && > + edx == XEN_CPUID_SIGNATURE_EDX; > +} This isn't quite correct. There's a find_xen_leaves() helper which should do what you want. ~Andrew
