Module Name: src Committed By: pho Date: Thu May 9 12:41:08 UTC 2024
Modified Files: src/share/man/man4: vmt.4 src/sys/arch/aarch64/aarch64: cpu.c src/sys/arch/arm/acpi: cpu_acpi.c src/sys/arch/arm/arm32: cpu.c src/sys/arch/arm/fdt: cpu_fdt.c src/sys/arch/arm/include: cpuvar.h src/sys/arch/arm/mainbus: cpu_mainbus.c Log Message: kern/58195: arm: Support drvctl -d and -r for cpufeaturebus This is required for detaching and re-attaching the vmt(4) driver on aarch64. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/vmt.4 cvs rdiff -u -r1.75 -r1.76 src/sys/arch/aarch64/aarch64/cpu.c cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/acpi/cpu_acpi.c cvs rdiff -u -r1.153 -r1.154 src/sys/arch/arm/arm32/cpu.c cvs rdiff -u -r1.42 -r1.43 src/sys/arch/arm/fdt/cpu_fdt.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/include/cpuvar.h cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/mainbus/cpu_mainbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man4/vmt.4 diff -u src/share/man/man4/vmt.4:1.4 src/share/man/man4/vmt.4:1.5 --- src/share/man/man4/vmt.4:1.4 Thu May 9 12:09:58 2024 +++ src/share/man/man4/vmt.4 Thu May 9 12:41:08 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: vmt.4,v 1.4 2024/05/09 12:09:58 pho Exp $ +.\" $NetBSD: vmt.4,v 1.5 2024/05/09 12:41:08 pho Exp $ .\" $OpenBSD: vmt.4,v 1.4 2010/10/26 05:07:31 jmc Exp $ .\" .\" Copyright (c) 2008 Marco Peereboom <ma...@openbsd.org> @@ -78,3 +78,41 @@ The .Nm driver was written by .An David Gwynne Aq Mt d...@openbsd.org . +.Sh BUGS +.Nm +is known to cause a conflict with +.Xr vmtoolsd 8 +from +.Li open-vm-tools . +.Nm +works by establishing an RPC channel called TCLO between VMware guest and +host to receive controlling messages from the host. The problem is that +.Nm +is essentially a subset of +.Xr vmtoolsd 8 , +and they both use the same RPC channel, but TCLO is never meant to be +simultaneously used by two distinct services in the same VM guest. So when +.Xr vmtoolsd 8 +is running while also +.Nm +is active, they continually fight for the channel, both get rejected by the +confused VM host, and neither one can establish a stable communication +line. +.Pp +So before launching +.Xr vmtoolsd 8 +the +.Nm +driver should be detached by running: +.Bd -literal -offset indent +# drvctl -d vmt0 +.Ed +.Pp +And after terminating +.Xr vmtoolsd 8 +the +.Nm +driver should be re-attached by running: +.Bd -literal -offset indent +# drvctl -r -a cpufeaturebus cpu0 +.Ed Index: src/sys/arch/aarch64/aarch64/cpu.c diff -u src/sys/arch/aarch64/aarch64/cpu.c:1.75 src/sys/arch/aarch64/aarch64/cpu.c:1.76 --- src/sys/arch/aarch64/aarch64/cpu.c:1.75 Thu May 9 12:09:58 2024 +++ src/sys/arch/aarch64/aarch64/cpu.c Thu May 9 12:41:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.75 2024/05/09 12:09:58 pho Exp $ */ +/* $NetBSD: cpu.c,v 1.76 2024/05/09 12:41:08 pho Exp $ */ /* * Copyright (c) 2017 Ryo Shimizu @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.75 2024/05/09 12:09:58 pho Exp $"); +__KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.76 2024/05/09 12:41:08 pho Exp $"); #include "locators.h" #include "opt_arm_debug.h" @@ -60,6 +60,7 @@ __KERNEL_RCSID(1, "$NetBSD: cpu.c,v 1.75 #include <aarch64/machdep.h> #include <arm/cpufunc.h> +#include <arm/cpuvar.h> #include <arm/cpu_topology.h> #ifdef FDT #include <arm/fdt/arm_fdtvar.h> @@ -181,10 +182,28 @@ cpu_attach(device_t dv, cpuid_t id) cpu_setup_aes(dv, ci); cpu_setup_chacha(dv, ci); - struct cpufeature_attach_args cfaa; - memset(&cfaa, 0, sizeof(cfaa)); - cfaa.ci = ci; - config_found(dv, &cfaa, NULL, CFARGS(.iattr = "cpufeaturebus")); + cpu_rescan(dv, NULL, NULL); +} + +int +cpu_rescan(device_t dv, const char *ifattr, const int *locators) +{ + struct cpu_info *ci = device_private(dv); + + if (ifattr_match(ifattr, "cpufeaturebus")) { + struct cpufeature_attach_args cfaa = { + .ci = ci, + }; + config_found(dv, &cfaa, NULL, CFARGS(.iattr = "cpufeaturebus")); + } + + return 0; +} + +void +cpu_childdetached(device_t dv, device_t child) +{ + /* Nada */ } struct cpuidtab { Index: src/sys/arch/arm/acpi/cpu_acpi.c diff -u src/sys/arch/arm/acpi/cpu_acpi.c:1.14 src/sys/arch/arm/acpi/cpu_acpi.c:1.15 --- src/sys/arch/arm/acpi/cpu_acpi.c:1.14 Mon May 16 09:42:32 2022 +++ src/sys/arch/arm/acpi/cpu_acpi.c Thu May 9 12:41:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_acpi.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $ */ +/* $NetBSD: cpu_acpi.c,v 1.15 2024/05/09 12:41:08 pho Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -33,7 +33,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.14 2022/05/16 09:42:32 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.15 2024/05/09 12:41:08 pho Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -65,7 +65,9 @@ static void cpu_acpi_attach(device_t, de static void cpu_acpi_tprof_init(device_t); #endif -CFATTACH_DECL_NEW(cpu_acpi, 0, cpu_acpi_match, cpu_acpi_attach, NULL, NULL); +CFATTACH_DECL2_NEW(cpu_acpi, 0, + cpu_acpi_match, cpu_acpi_attach, NULL, NULL, + cpu_rescan, cpu_childdetached); #ifdef MULTIPROCESSOR static register_t Index: src/sys/arch/arm/arm32/cpu.c diff -u src/sys/arch/arm/arm32/cpu.c:1.153 src/sys/arch/arm/arm32/cpu.c:1.154 --- src/sys/arch/arm/arm32/cpu.c:1.153 Thu Mar 3 06:26:05 2022 +++ src/sys/arch/arm/arm32/cpu.c Thu May 9 12:41:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.153 2022/03/03 06:26:05 riastradh Exp $ */ +/* $NetBSD: cpu.c,v 1.154 2024/05/09 12:41:08 pho Exp $ */ /* * Copyright (c) 1995 Mark Brinicombe. @@ -46,7 +46,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.153 2022/03/03 06:26:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.154 2024/05/09 12:41:08 pho Exp $"); #include <sys/param.h> @@ -62,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.15 #include <arm/locore.h> #include <arm/undefined.h> +#include <arm/cpuvar.h> #include <arm/cpu_topology.h> extern const char *cpu_arch; @@ -233,6 +234,18 @@ cpu_attach(device_t dv, cpuid_t id) vfp_attach(ci); } +int +cpu_rescan(device_t dv, const char *ifattr, const int *locators) +{ + return 0; +} + +void +cpu_childdetached(device_t dv, device_t child) +{ + /* Nada */ +} + enum cpu_class { CPU_CLASS_NONE, CPU_CLASS_ARM2, Index: src/sys/arch/arm/fdt/cpu_fdt.c diff -u src/sys/arch/arm/fdt/cpu_fdt.c:1.42 src/sys/arch/arm/fdt/cpu_fdt.c:1.43 --- src/sys/arch/arm/fdt/cpu_fdt.c:1.42 Thu Mar 3 06:26:05 2022 +++ src/sys/arch/arm/fdt/cpu_fdt.c Thu May 9 12:41:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_fdt.c,v 1.42 2022/03/03 06:26:05 riastradh Exp $ */ +/* $NetBSD: cpu_fdt.c,v 1.43 2024/05/09 12:41:08 pho Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcne...@invisible.ca> @@ -30,7 +30,7 @@ #include "psci_fdt.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.42 2022/03/03 06:26:05 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v 1.43 2024/05/09 12:41:08 pho Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -57,8 +57,9 @@ __KERNEL_RCSID(0, "$NetBSD: cpu_fdt.c,v static int cpu_fdt_match(device_t, cfdata_t, void *); static void cpu_fdt_attach(device_t, device_t, void *); -CFATTACH_DECL_NEW(cpu_fdt, 0, - cpu_fdt_match, cpu_fdt_attach, NULL, NULL); +CFATTACH_DECL2_NEW(cpu_fdt, 0, + cpu_fdt_match, cpu_fdt_attach, NULL, NULL, + cpu_rescan, cpu_childdetached); static int cpu_fdt_match(device_t parent, cfdata_t cf, void *aux) Index: src/sys/arch/arm/include/cpuvar.h diff -u src/sys/arch/arm/include/cpuvar.h:1.1 src/sys/arch/arm/include/cpuvar.h:1.2 --- src/sys/arch/arm/include/cpuvar.h:1.1 Sat Feb 15 08:16:11 2020 +++ src/sys/arch/arm/include/cpuvar.h Thu May 9 12:41:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuvar.h,v 1.1 2020/02/15 08:16:11 skrll Exp $ */ +/* $NetBSD: cpuvar.h,v 1.2 2024/05/09 12:41:08 pho Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -37,6 +37,8 @@ #include <sys/device_if.h> void cpu_attach(device_t, cpuid_t); +int cpu_rescan(device_t, const char *, const int *); +void cpu_childdetached(device_t, device_t); #endif Index: src/sys/arch/arm/mainbus/cpu_mainbus.c diff -u src/sys/arch/arm/mainbus/cpu_mainbus.c:1.18 src/sys/arch/arm/mainbus/cpu_mainbus.c:1.19 --- src/sys/arch/arm/mainbus/cpu_mainbus.c:1.18 Sat Feb 15 08:16:11 2020 +++ src/sys/arch/arm/mainbus/cpu_mainbus.c Thu May 9 12:41:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu_mainbus.c,v 1.18 2020/02/15 08:16:11 skrll Exp $ */ +/* $NetBSD: cpu_mainbus.c,v 1.19 2024/05/09 12:41:08 pho Exp $ */ /* * Copyright (c) 1995 Mark Brinicombe. @@ -45,7 +45,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu_mainbus.c,v 1.18 2020/02/15 08:16:11 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu_mainbus.c,v 1.19 2024/05/09 12:41:08 pho Exp $"); #include <sys/param.h> #include <sys/types.h> @@ -122,5 +122,6 @@ cpu_mainbus_attach(device_t parent, devi cpu_attach(self, mb->mb_core); } -CFATTACH_DECL_NEW(cpu_mainbus, 0, - cpu_mainbus_match, cpu_mainbus_attach, NULL, NULL); +CFATTACH_DECL2_NEW(cpu_mainbus, 0, + cpu_mainbus_match, cpu_mainbus_attach, NULL, NULL, + cpu_rescan, cpu_childdetached);