Skip to content

Commit 390e508

Browse files
author
Herton R. Krzesinski
committed
Merge: Fix for CSB.V bit never becomes valid for NX Gzip job during LPAR migration
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/1632 Bugzilla: https://bugzilla.redhat.com/2130348 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=50152615 Tested: Tested with LPM Signed-off-by: Mukesh Chaurasiya <mchauras@redhat.com> Approved-by: Waiman Long <longman@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
2 parents 4149442 + 1e9fda9 commit 390e508

File tree

7 files changed

+103
-31
lines changed

7 files changed

+103
-31
lines changed

arch/powerpc/include/asm/mmu.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@
129129
*/
130130
#define MMU_FTR_1T_SEGMENT ASM_CONST(0x40000000)
131131

132+
// NX paste RMA reject in DSI
133+
#define MMU_FTR_NX_DSI ASM_CONST(0x80000000)
134+
132135
/* MMU feature bit sets for various CPUs */
133136
#define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 (MMU_FTR_HPTE_TABLE | MMU_FTR_TLBIEL | MMU_FTR_16M_PAGE)
134137
#define MMU_FTRS_POWER MMU_FTRS_DEFAULT_HPTE_ARCH_V2
@@ -193,7 +196,7 @@ enum {
193196
#endif
194197
#ifdef CONFIG_PPC_RADIX_MMU
195198
MMU_FTR_TYPE_RADIX |
196-
MMU_FTR_GTSE |
199+
MMU_FTR_GTSE | MMU_FTR_NX_DSI |
197200
#endif /* CONFIG_PPC_RADIX_MMU */
198201
#endif
199202
#ifdef CONFIG_PPC_KUAP

arch/powerpc/kernel/prom.c

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void __init move_device_tree(void)
138138
}
139139

140140
/*
141-
* ibm,pa-features is a per-cpu property that contains a string of
141+
* ibm,pa/pi-features is a per-cpu property that contains a string of
142142
* attribute descriptors, each of which has a 2 byte header plus up
143143
* to 254 bytes worth of processor attribute bits. First header
144144
* byte specifies the number of bytes following the header.
@@ -150,15 +150,17 @@ static void __init move_device_tree(void)
150150
* is supported/not supported. Note that the bit numbers are
151151
* big-endian to match the definition in PAPR.
152152
*/
153-
static struct ibm_pa_feature {
153+
struct ibm_feature {
154154
unsigned long cpu_features; /* CPU_FTR_xxx bit */
155155
unsigned long mmu_features; /* MMU_FTR_xxx bit */
156156
unsigned int cpu_user_ftrs; /* PPC_FEATURE_xxx bit */
157157
unsigned int cpu_user_ftrs2; /* PPC_FEATURE2_xxx bit */
158-
unsigned char pabyte; /* byte number in ibm,pa-features */
158+
unsigned char pabyte; /* byte number in ibm,pa/pi-features */
159159
unsigned char pabit; /* bit number (big-endian) */
160160
unsigned char invert; /* if 1, pa bit set => clear feature */
161-
} ibm_pa_features[] __initdata = {
161+
};
162+
163+
static struct ibm_feature ibm_pa_features[] __initdata = {
162164
{ .pabyte = 0, .pabit = 0, .cpu_user_ftrs = PPC_FEATURE_HAS_MMU },
163165
{ .pabyte = 0, .pabit = 1, .cpu_user_ftrs = PPC_FEATURE_HAS_FPU },
164166
{ .pabyte = 0, .pabit = 3, .cpu_features = CPU_FTR_CTRL },
@@ -180,9 +182,19 @@ static struct ibm_pa_feature {
180182
{ .pabyte = 64, .pabit = 0, .cpu_features = CPU_FTR_DAWR1 },
181183
};
182184

185+
/*
186+
* ibm,pi-features property provides the support of processor specific
187+
* options not described in ibm,pa-features. Right now use byte 0, bit 3
188+
* which indicates the occurrence of DSI interrupt when the paste operation
189+
* on the suspended NX window.
190+
*/
191+
static struct ibm_feature ibm_pi_features[] __initdata = {
192+
{ .pabyte = 0, .pabit = 3, .mmu_features = MMU_FTR_NX_DSI },
193+
};
194+
183195
static void __init scan_features(unsigned long node, const unsigned char *ftrs,
184196
unsigned long tablelen,
185-
struct ibm_pa_feature *fp,
197+
struct ibm_feature *fp,
186198
unsigned long ft_size)
187199
{
188200
unsigned long i, len, bit;
@@ -219,17 +231,18 @@ static void __init scan_features(unsigned long node, const unsigned char *ftrs,
219231
}
220232
}
221233

222-
static void __init check_cpu_pa_features(unsigned long node)
234+
static void __init check_cpu_features(unsigned long node, char *name,
235+
struct ibm_feature *fp,
236+
unsigned long size)
223237
{
224238
const unsigned char *pa_ftrs;
225239
int tablelen;
226240

227-
pa_ftrs = of_get_flat_dt_prop(node, "ibm,pa-features", &tablelen);
241+
pa_ftrs = of_get_flat_dt_prop(node, name, &tablelen);
228242
if (pa_ftrs == NULL)
229243
return;
230244

231-
scan_features(node, pa_ftrs, tablelen,
232-
ibm_pa_features, ARRAY_SIZE(ibm_pa_features));
245+
scan_features(node, pa_ftrs, tablelen, fp, size);
233246
}
234247

235248
#ifdef CONFIG_PPC_64S_HASH_MMU
@@ -383,7 +396,10 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
383396
identify_cpu(0, be32_to_cpup(prop));
384397

385398
check_cpu_feature_properties(node);
386-
check_cpu_pa_features(node);
399+
check_cpu_features(node, "ibm,pa-features", ibm_pa_features,
400+
ARRAY_SIZE(ibm_pa_features));
401+
check_cpu_features(node, "ibm,pi-features", ibm_pi_features,
402+
ARRAY_SIZE(ibm_pi_features));
387403
}
388404

389405
identical_pvr_fixup(node);

arch/powerpc/mm/fault.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,22 @@ static void sanity_check_fault(bool is_write, bool is_user,
368368
#elif defined(CONFIG_PPC_8xx)
369369
#define page_fault_is_bad(__err) ((__err) & DSISR_NOEXEC_OR_G)
370370
#elif defined(CONFIG_PPC64)
371-
#define page_fault_is_bad(__err) ((__err) & DSISR_BAD_FAULT_64S)
371+
static int page_fault_is_bad(unsigned long err)
372+
{
373+
unsigned long flag = DSISR_BAD_FAULT_64S;
374+
375+
/*
376+
* PAPR+ v2.11 § 14.15.3.4.1 (unreleased)
377+
* If byte 0, bit 3 of pi-attribute-specifier-type in
378+
* ibm,pi-features property is defined, ignore the DSI error
379+
* which is caused by the paste instruction on the
380+
* suspended NX window.
381+
*/
382+
if (mmu_has_feature(MMU_FTR_NX_DSI))
383+
flag &= ~DSISR_BAD_COPYPASTE;
384+
385+
return err & flag;
386+
}
372387
#else
373388
#define page_fault_is_bad(__err) ((__err) & DSISR_BAD_FAULT_32S)
374389
#endif

arch/powerpc/platforms/pseries/mobility.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,11 +740,19 @@ static int pseries_migrate_partition(u64 handle)
740740
#ifdef CONFIG_PPC_WATCHDOG
741741
factor = nmi_wd_lpm_factor;
742742
#endif
743+
/*
744+
* When the migration is initiated, the hypervisor changes VAS
745+
* mappings to prepare before OS gets the notification and
746+
* closes all VAS windows. NX generates continuous faults during
747+
* this time and the user space can not differentiate these
748+
* faults from the migration event. So reduce this time window
749+
* by closing VAS windows at the beginning of this function.
750+
*/
751+
vas_migration_handler(VAS_SUSPEND);
752+
743753
ret = wait_for_vasi_session_suspending(handle);
744754
if (ret)
745-
return ret;
746-
747-
vas_migration_handler(VAS_SUSPEND);
755+
goto out;
748756

749757
if (factor)
750758
watchdog_nmi_set_timeout_pct(factor);
@@ -765,6 +773,7 @@ static int pseries_migrate_partition(u64 handle)
765773
if (factor)
766774
watchdog_nmi_set_timeout_pct(0);
767775

776+
out:
768777
vas_migration_handler(VAS_RESUME);
769778

770779
return ret;

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,26 @@ struct vas_sysfs_entry {
7474

7575
/*
7676
* Create sysfs interface:
77-
* /sys/devices/vas/vas0/gzip/default_capabilities
77+
* /sys/devices/virtual/misc/vas/vas0/gzip/default_capabilities
7878
* This directory contains the following VAS GZIP capabilities
7979
* for the defaule credit type.
80-
* /sys/devices/vas/vas0/gzip/default_capabilities/nr_total_credits
80+
* /sys/devices/virtual/misc/vas/vas0/gzip/default_capabilities/nr_total_credits
8181
* Total number of default credits assigned to the LPAR which
8282
* can be changed with DLPAR operation.
83-
* /sys/devices/vas/vas0/gzip/default_capabilities/nr_used_credits
83+
* /sys/devices/virtual/misc/vas/vas0/gzip/default_capabilities/nr_used_credits
8484
* Number of credits used by the user space. One credit will
8585
* be assigned for each window open.
8686
*
87-
* /sys/devices/vas/vas0/gzip/qos_capabilities
87+
* /sys/devices/virtual/misc/vas/vas0/gzip/qos_capabilities
8888
* This directory contains the following VAS GZIP capabilities
8989
* for the Quality of Service (QoS) credit type.
90-
* /sys/devices/vas/vas0/gzip/qos_capabilities/nr_total_credits
90+
* /sys/devices/virtual/misc/vas/vas0/gzip/qos_capabilities/nr_total_credits
9191
* Total number of QoS credits assigned to the LPAR. The user
9292
* has to define this value using HMC interface. It can be
9393
* changed dynamically by the user.
94-
* /sys/devices/vas/vas0/gzip/qos_capabilities/nr_used_credits
94+
* /sys/devices/virtual/misc/vas/vas0/gzip/qos_capabilities/nr_used_credits
9595
* Number of credits used by the user space.
96-
* /sys/devices/vas/vas0/gzip/qos_capabilities/update_total_credits
96+
* /sys/devices/virtual/misc/vas/vas0/gzip/qos_capabilities/update_total_credits
9797
* Update total QoS credits dynamically
9898
*/
9999

@@ -108,13 +108,15 @@ static struct attribute *vas_def_capab_attrs[] = {
108108
&nr_used_credits_attribute.attr,
109109
NULL,
110110
};
111+
ATTRIBUTE_GROUPS(vas_def_capab);
111112

112113
static struct attribute *vas_qos_capab_attrs[] = {
113114
&nr_total_credits_attribute.attr,
114115
&nr_used_credits_attribute.attr,
115116
&update_total_credits_attribute.attr,
116117
NULL,
117118
};
119+
ATTRIBUTE_GROUPS(vas_qos_capab);
118120

119121
static ssize_t vas_type_show(struct kobject *kobj, struct attribute *attr,
120122
char *buf)
@@ -163,13 +165,13 @@ static const struct sysfs_ops vas_sysfs_ops = {
163165
static struct kobj_type vas_def_attr_type = {
164166
.release = vas_type_release,
165167
.sysfs_ops = &vas_sysfs_ops,
166-
.default_attrs = vas_def_capab_attrs,
168+
.default_groups = vas_def_capab_groups,
167169
};
168170

169171
static struct kobj_type vas_qos_attr_type = {
170172
.release = vas_type_release,
171173
.sysfs_ops = &vas_sysfs_ops,
172-
.default_attrs = vas_qos_capab_attrs,
174+
.default_groups = vas_qos_capab_groups,
173175
};
174176

175177
static char *vas_caps_kobj_name(struct vas_caps_entry *centry,

arch/powerpc/platforms/pseries/vas.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,41 @@ irqreturn_t pseries_vas_fault_thread_fn(int irq, void *data)
192192
struct vas_user_win_ref *tsk_ref;
193193
int rc;
194194

195-
rc = h_get_nx_fault(txwin->vas_win.winid, (u64)virt_to_phys(&crb));
196-
if (!rc) {
197-
tsk_ref = &txwin->vas_win.task_ref;
198-
vas_dump_crb(&crb);
199-
vas_update_csb(&crb, tsk_ref);
195+
while (atomic_read(&txwin->pending_faults)) {
196+
rc = h_get_nx_fault(txwin->vas_win.winid, (u64)virt_to_phys(&crb));
197+
if (!rc) {
198+
tsk_ref = &txwin->vas_win.task_ref;
199+
vas_dump_crb(&crb);
200+
vas_update_csb(&crb, tsk_ref);
201+
}
202+
atomic_dec(&txwin->pending_faults);
200203
}
201204

202205
return IRQ_HANDLED;
203206
}
204207

208+
/*
209+
* irq_default_primary_handler() can be used only with IRQF_ONESHOT
210+
* which disables IRQ before executing the thread handler and enables
211+
* it after. But this disabling interrupt sets the VAS IRQ OFF
212+
* state in the hypervisor. If the NX generates fault interrupt
213+
* during this window, the hypervisor will not deliver this
214+
* interrupt to the LPAR. So use VAS specific IRQ handler instead
215+
* of calling the default primary handler.
216+
*/
217+
static irqreturn_t pseries_vas_irq_handler(int irq, void *data)
218+
{
219+
struct pseries_vas_window *txwin = data;
220+
221+
/*
222+
* The thread hanlder will process this interrupt if it is
223+
* already running.
224+
*/
225+
atomic_inc(&txwin->pending_faults);
226+
227+
return IRQ_WAKE_THREAD;
228+
}
229+
205230
/*
206231
* Allocate window and setup IRQ mapping.
207232
*/
@@ -232,8 +257,9 @@ static int allocate_setup_window(struct pseries_vas_window *txwin,
232257
goto out_irq;
233258
}
234259

235-
rc = request_threaded_irq(txwin->fault_virq, NULL,
236-
pseries_vas_fault_thread_fn, IRQF_ONESHOT,
260+
rc = request_threaded_irq(txwin->fault_virq,
261+
pseries_vas_irq_handler,
262+
pseries_vas_fault_thread_fn, 0,
237263
txwin->name, txwin);
238264
if (rc) {
239265
pr_err("VAS-Window[%d]: Request IRQ(%u) failed with %d\n",

arch/powerpc/platforms/pseries/vas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ struct pseries_vas_window {
132132
u64 flags;
133133
char *name;
134134
int fault_virq;
135+
atomic_t pending_faults; /* Number of pending faults */
135136
};
136137

137138
int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps);

0 commit comments

Comments
 (0)