aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Silva <andasilv@amd.com>2026-04-06 20:55:43 +0000
committerMitchell Horne <mhorne@FreeBSD.org>2026-04-28 18:49:21 +0000
commita9a562a08e77ac024066a6ca7ab77e7e25e007dc (patch)
treedce18e0cc461df2c19761394e304cfdcd50d8524
parentd5db883af2cc46bf884ba3fd067cec68f44fc66d (diff)
hwpmc_ibs: Add external error handling
Add EXTERR_CAT_HWPMC_IBS to the external error categories and replace generic EINVAL returns in ibs_allocate_pmc() with EXTERROR() calls that provide detailed error messages. This will be augmented with additional cases in the near future. Reviewed by: mhorne Sponsored by: AMD Signed-off-by: Andre Silva <andasilv@amd.com> Pull Request: https://github.com/freebsd/freebsd-src/pull/2134
-rw-r--r--lib/libc/gen/exterr_cat_filenames.h1
-rw-r--r--sys/dev/hwpmc/hwpmc_ibs.c11
-rw-r--r--sys/sys/exterr_cat.h1
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/libc/gen/exterr_cat_filenames.h b/lib/libc/gen/exterr_cat_filenames.h
index e45d05e384bd..be65c1990af5 100644
--- a/lib/libc/gen/exterr_cat_filenames.h
+++ b/lib/libc/gen/exterr_cat_filenames.h
@@ -2,6 +2,7 @@
* Automatically @generated, use
* tools/build/make_libc_exterr_cat_filenames.sh
*/
+ [EXTERR_CAT_HWPMC_IBS] = "dev/hwpmc/hwpmc_ibs.c",
[EXTERR_CAT_VMM] = "dev/vmm/vmm_dev.c",
[EXTERR_CAT_FUSE_DEVICE] = "fs/fuse/fuse_device.c",
[EXTERR_CAT_FUSE_VFS] = "fs/fuse/fuse_vfsops.c",
diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c
index 56903699ac51..280a84208847 100644
--- a/sys/dev/hwpmc/hwpmc_ibs.c
+++ b/sys/dev/hwpmc/hwpmc_ibs.c
@@ -38,6 +38,9 @@
#include <sys/smp.h>
#include <sys/systm.h>
+#define EXTERR_CATEGORY EXTERR_CAT_HWPMC_IBS
+#include <sys/exterrvar.h>
+
#include <machine/cpu.h>
#include <machine/cpufunc.h>
#include <machine/md_var.h>
@@ -185,16 +188,18 @@ ibs_allocate_pmc(int cpu __unused, int ri, struct pmc *pm,
/* check class match */
if (a->pm_class != PMC_CLASS_IBS)
- return (EINVAL);
+ return (EXTERROR(EINVAL, "PMC class is not IBS"));
if (a->pm_md.pm_ibs.ibs_type != ri)
- return (EINVAL);
+ return (EXTERROR(EINVAL,
+ "IBS type %ju does not match PMC index %ju",
+ (uint64_t)a->pm_md.pm_ibs.ibs_type, (uint64_t)ri));
caps = pm->pm_caps;
PMCDBG2(MDP, ALL, 1, "ibs-allocate ri=%d caps=0x%x", ri, caps);
if ((caps & PMC_CAP_SYSTEM) == 0)
- return (EINVAL);
+ return (EXTERROR(EINVAL, "IBS requires SYSTEM capability"));
if (!PMC_IS_SAMPLING_MODE(a->pm_mode))
return (EINVAL);
diff --git a/sys/sys/exterr_cat.h b/sys/sys/exterr_cat.h
index 4f3ff6925242..edc23d7dfbe6 100644
--- a/sys/sys/exterr_cat.h
+++ b/sys/sys/exterr_cat.h
@@ -40,6 +40,7 @@
#define EXTERR_CAT_FORK 15
#define EXTERR_CAT_PROCEXIT 16
#define EXTERR_CAT_VMM 17
+#define EXTERR_CAT_HWPMC_IBS 18
#endif