Skip to content

Commit e3de3a1

Browse files
committed
Merge tag 'powerpc-5.18-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Fix the DWARF CFI in our VDSO time functions, allowing gdb to backtrace through them correctly. - Fix a buffer overflow in the papr_scm driver, only triggerable by hypervisor input. - A fix in the recently added QoS handling for VAS (used for communicating with coprocessors). Thanks to Alan Modra, Haren Myneni, Kajol Jain, and Segher Boessenkool. * tag 'powerpc-5.18-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/papr_scm: Fix buffer overflow issue with CONFIG_FORTIFY_SOURCE powerpc/vdso: Fix incorrect CFI in gettimeofday.S powerpc/pseries/vas: Use QoS credits from the userspace
2 parents 27b5d61 + 348c713 commit e3de3a1

File tree

5 files changed

+36
-24
lines changed

5 files changed

+36
-24
lines changed

arch/powerpc/kernel/vdso/gettimeofday.S

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222
.macro cvdso_call funct call_time=0
2323
.cfi_startproc
2424
PPC_STLU r1, -PPC_MIN_STKFRM(r1)
25+
.cfi_adjust_cfa_offset PPC_MIN_STKFRM
2526
mflr r0
26-
.cfi_register lr, r0
2727
PPC_STLU r1, -PPC_MIN_STKFRM(r1)
28+
.cfi_adjust_cfa_offset PPC_MIN_STKFRM
2829
PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
30+
.cfi_rel_offset lr, PPC_MIN_STKFRM + PPC_LR_STKOFF
2931
#ifdef __powerpc64__
3032
PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
33+
.cfi_rel_offset r2, PPC_MIN_STKFRM + STK_GOT
3134
#endif
3235
get_datapage r5
3336
.ifeq \call_time
@@ -39,13 +42,15 @@
3942
PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
4043
#ifdef __powerpc64__
4144
PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
45+
.cfi_restore r2
4246
#endif
4347
.ifeq \call_time
4448
cmpwi r3, 0
4549
.endif
4650
mtlr r0
47-
.cfi_restore lr
4851
addi r1, r1, 2 * PPC_MIN_STKFRM
52+
.cfi_restore lr
53+
.cfi_def_cfa_offset 0
4954
crclr so
5055
.ifeq \call_time
5156
beqlr+

arch/powerpc/platforms/pseries/papr_scm.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct nvdimm_pmu
462462
{
463463
struct papr_scm_perf_stat *stat;
464464
struct papr_scm_perf_stats *stats;
465-
char *statid;
466465
int index, rc, count;
467466
u32 available_events;
468467

@@ -493,14 +492,12 @@ static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct nvdimm_pmu
493492

494493
for (index = 0, stat = stats->scm_statistic, count = 0;
495494
index < available_events; index++, ++stat) {
496-
statid = kzalloc(strlen(stat->stat_id) + 1, GFP_KERNEL);
497-
if (!statid) {
495+
p->nvdimm_events_map[count] = kmemdup_nul(stat->stat_id, 8, GFP_KERNEL);
496+
if (!p->nvdimm_events_map[count]) {
498497
rc = -ENOMEM;
499498
goto out_nvdimm_events_map;
500499
}
501500

502-
strcpy(statid, stat->stat_id);
503-
p->nvdimm_events_map[count] = statid;
504501
count++;
505502
}
506503
p->nvdimm_events_map[count] = NULL;

arch/powerpc/platforms/pseries/vas-sysfs.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,31 @@ struct vas_caps_entry {
2727

2828
/*
2929
* This function is used to get the notification from the drmgr when
30-
* QoS credits are changed. Though receiving the target total QoS
31-
* credits here, get the official QoS capabilities from the hypervisor.
30+
* QoS credits are changed.
3231
*/
33-
static ssize_t update_total_credits_trigger(struct vas_cop_feat_caps *caps,
32+
static ssize_t update_total_credits_store(struct vas_cop_feat_caps *caps,
3433
const char *buf, size_t count)
3534
{
3635
int err;
3736
u16 creds;
3837

3938
err = kstrtou16(buf, 0, &creds);
39+
/*
40+
* The user space interface from the management console
41+
* notifies OS with the new QoS credits and then the
42+
* hypervisor. So OS has to use this new credits value
43+
* and reconfigure VAS windows (close or reopen depends
44+
* on the credits available) instead of depending on VAS
45+
* QoS capabilities from the hypervisor.
46+
*/
4047
if (!err)
41-
err = vas_reconfig_capabilties(caps->win_type);
48+
err = vas_reconfig_capabilties(caps->win_type, creds);
4249

4350
if (err)
4451
return -EINVAL;
4552

53+
pr_info("Set QoS total credits %u\n", creds);
54+
4655
return count;
4756
}
4857

@@ -92,7 +101,7 @@ VAS_ATTR_RO(nr_total_credits);
92101
VAS_ATTR_RO(nr_used_credits);
93102

94103
static struct vas_sysfs_entry update_total_credits_attribute =
95-
__ATTR(update_total_credits, 0200, NULL, update_total_credits_trigger);
104+
__ATTR(update_total_credits, 0200, NULL, update_total_credits_store);
96105

97106
static struct attribute *vas_def_capab_attrs[] = {
98107
&nr_total_credits_attribute.attr,

arch/powerpc/platforms/pseries/vas.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -779,10 +779,10 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds,
779779
* changes. Reconfig window configurations based on the credits
780780
* availability from this new capabilities.
781781
*/
782-
int vas_reconfig_capabilties(u8 type)
782+
int vas_reconfig_capabilties(u8 type, int new_nr_creds)
783783
{
784784
struct vas_cop_feat_caps *caps;
785-
int old_nr_creds, new_nr_creds;
785+
int old_nr_creds;
786786
struct vas_caps *vcaps;
787787
int rc = 0, nr_active_wins;
788788

@@ -795,12 +795,6 @@ int vas_reconfig_capabilties(u8 type)
795795
caps = &vcaps->caps;
796796

797797
mutex_lock(&vas_pseries_mutex);
798-
rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES, vcaps->feat,
799-
(u64)virt_to_phys(&hv_cop_caps));
800-
if (rc)
801-
goto out;
802-
803-
new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds);
804798

805799
old_nr_creds = atomic_read(&caps->nr_total_credits);
806800

@@ -832,7 +826,6 @@ int vas_reconfig_capabilties(u8 type)
832826
false);
833827
}
834828

835-
out:
836829
mutex_unlock(&vas_pseries_mutex);
837830
return rc;
838831
}
@@ -850,7 +843,7 @@ static int pseries_vas_notifier(struct notifier_block *nb,
850843
struct of_reconfig_data *rd = data;
851844
struct device_node *dn = rd->dn;
852845
const __be32 *intserv = NULL;
853-
int len, rc = 0;
846+
int new_nr_creds, len, rc = 0;
854847

855848
if ((action == OF_RECONFIG_ATTACH_NODE) ||
856849
(action == OF_RECONFIG_DETACH_NODE))
@@ -862,7 +855,15 @@ static int pseries_vas_notifier(struct notifier_block *nb,
862855
if (!intserv)
863856
return NOTIFY_OK;
864857

865-
rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE);
858+
rc = h_query_vas_capabilities(H_QUERY_VAS_CAPABILITIES,
859+
vascaps[VAS_GZIP_DEF_FEAT_TYPE].feat,
860+
(u64)virt_to_phys(&hv_cop_caps));
861+
if (!rc) {
862+
new_nr_creds = be16_to_cpu(hv_cop_caps.target_lpar_creds);
863+
rc = vas_reconfig_capabilties(VAS_GZIP_DEF_FEAT_TYPE,
864+
new_nr_creds);
865+
}
866+
866867
if (rc)
867868
pr_err("Failed reconfig VAS capabilities with DLPAR\n");
868869

arch/powerpc/platforms/pseries/vas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ struct pseries_vas_window {
135135
};
136136

137137
int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps);
138-
int vas_reconfig_capabilties(u8 type);
138+
int vas_reconfig_capabilties(u8 type, int new_nr_creds);
139139
int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps);
140140

141141
#ifdef CONFIG_PPC_VAS

0 commit comments

Comments
 (0)