Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177962725
D61367.1795660727.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D61367.1795660727.diff
View Options
diff --git a/sys/dev/hwpmc/hwpmc_ibs.c b/sys/dev/hwpmc/hwpmc_ibs.c
--- a/sys/dev/hwpmc/hwpmc_ibs.c
+++ b/sys/dev/hwpmc/hwpmc_ibs.c
@@ -143,7 +143,7 @@
static int
ibs_validate_fetch_config(uint64_t config)
{
- uint64_t allowed_mask;
+ uint64_t allowed_mask, period;
allowed_mask = ibs_fetch_allowed_mask | ibs_fetch_extra_mask;
if ((config & ~allowed_mask) != 0) {
@@ -152,13 +152,19 @@
" 0x%jx", (uintmax_t)config, (uintmax_t)allowed_mask));
}
+ period = IBS_FETCH_CTL_TO_INTERVAL(config);
+ if (period < IBS_FETCH_MIN_RATE)
+ return (EXTERROR(EINVAL,
+ "IBS fetch period %ju is below the minimum %d",
+ (uintmax_t)period, IBS_FETCH_MIN_RATE));
+
return (0);
}
static int
ibs_validate_op_config(uint64_t config)
{
- uint64_t allowed_mask;
+ uint64_t allowed_mask, period;
allowed_mask = ibs_op_allowed_mask;
@@ -186,6 +192,12 @@
" 0x%jx", (uintmax_t)config, (uintmax_t)allowed_mask));
}
+ period = IBS_OP_CTL_TO_INTERVAL(config);
+ if (period < IBS_OP_MIN_RATE)
+ return (EXTERROR(EINVAL,
+ "IBS op period %ju is below the minimum %d",
+ (uintmax_t)period, IBS_OP_MIN_RATE));
+
return (0);
}
diff --git a/tests/sys/pmc/pmc_exterr_test.c b/tests/sys/pmc/pmc_exterr_test.c
--- a/tests/sys/pmc/pmc_exterr_test.c
+++ b/tests/sys/pmc/pmc_exterr_test.c
@@ -407,6 +407,50 @@
require_exterr("IBS op ctl config");
}
+ATF_TC_WITHOUT_HEAD(ibs_op_period_below_minimum);
+ATF_TC_BODY(ibs_op_period_below_minimum, tc)
+{
+ struct pmc_op_pmcallocate pa;
+
+ ATF_REQUIRE_FEATURE("exterr_strings");
+ require_hwpmc();
+ require_class(PMC_CLASS_IBS, "IBS");
+ clear_exterr();
+
+ memset(&pa, 0, sizeof(pa));
+ pa.pm_caps = PMC_CAP_SYSTEM;
+ pa.pm_class = PMC_CLASS_IBS;
+ pa.pm_mode = PMC_MODE_SS;
+ pa.pm_cpu = 0;
+ pa.pm_md.pm_ibs.ibs_type = IBS_PMC_OP;
+ pa.pm_md.pm_ibs.ibs_ctl = IBS_OP_INTERVAL_TO_CTL(65520);
+
+ ATF_REQUIRE_ERRNO(EINVAL, hwpmc_call(PMC_OP_PMCALLOCATE, &pa) == -1);
+ require_exterr("IBS op period 65520 is below the minimum 65536");
+}
+
+ATF_TC_WITHOUT_HEAD(ibs_fetch_period_below_minimum);
+ATF_TC_BODY(ibs_fetch_period_below_minimum, tc)
+{
+ struct pmc_op_pmcallocate pa;
+
+ ATF_REQUIRE_FEATURE("exterr_strings");
+ require_hwpmc();
+ require_class(PMC_CLASS_IBS, "IBS");
+ clear_exterr();
+
+ memset(&pa, 0, sizeof(pa));
+ pa.pm_caps = PMC_CAP_SYSTEM;
+ pa.pm_class = PMC_CLASS_IBS;
+ pa.pm_mode = PMC_MODE_SS;
+ pa.pm_cpu = 0;
+ pa.pm_md.pm_ibs.ibs_type = IBS_PMC_FETCH;
+ pa.pm_md.pm_ibs.ibs_ctl = IBS_FETCH_INTERVAL_TO_CTL(65520);
+
+ ATF_REQUIRE_ERRNO(EINVAL, hwpmc_call(PMC_OP_PMCALLOCATE, &pa) == -1);
+ require_exterr("IBS fetch period 65520 is below the minimum 65536");
+}
+
ATF_TC_WITHOUT_HEAD(ibs_nonsampling_mode);
ATF_TC_BODY(ibs_nonsampling_mode, tc)
{
@@ -438,6 +482,8 @@
ATF_TP_ADD_TC(tp, pmcrw_no_flags);
ATF_TP_ADD_TC(tp, pmcrw_write_running);
ATF_TP_ADD_TC(tp, amd_invalid_subclass);
+ ATF_TP_ADD_TC(tp, ibs_op_period_below_minimum);
+ ATF_TP_ADD_TC(tp, ibs_fetch_period_below_minimum);
ATF_TP_ADD_TC(tp, amd_invalid_config_bits);
ATF_TP_ADD_TC(tp, amd_invalid_df_config_bits);
ATF_TP_ADD_TC(tp, ibs_missing_system_capability);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 26, 2:38 AM (11 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41978675
Default Alt Text
D61367.1795660727.diff (3 KB)
Attached To
Mode
D61367: hwpmc_ibs: enforce minimum sample periods
Attached
Detach File
Event Timeline