Skip to content

Commit 99bfdd4

Browse files
author
Mukesh Chaurasiya
committed
powerpc: Ignore DSI error caused by the copy/paste instruction
Bugzilla: https://bugzilla.redhat.com/2130348 commit 335e1a9 Author: Haren Myneni <haren@linux.ibm.com> Date: Tue Sep 27 18:29:27 2022 -0700 powerpc: Ignore DSI error caused by the copy/paste instruction The data storage interrupt (DSI) error will be generated when the paste operation is issued on the suspended Nest Accelerator (NX) window due to NX state changes. The hypervisor expects the partition to ignore this error during page fault handling. To differentiate DSI caused by an actual HW configuration or by the NX window, a new “ibm,pi-features” type value is defined. Byte 0, bit 3 of pi-attribute-specifier-type is now defined to indicate this DSI error. If this error is not ignored, the user space can get SIGBUS when the NX request is issued. This patch adds changes to read ibm,pi-features property and ignore DSI error during page fault handling if MMU_FTR_NX_DSI is defined. Signed-off-by: Haren Myneni <haren@linux.ibm.com> [mpe: Mention PAPR version in comment] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/b9cd844b85eb8f70459109ce1b14e44c4cc85fa7.camel@linux.ibm.com Signed-off-by: Mukesh Chaurasiya <mchauras@redhat.com>
1 parent 05641af commit 99bfdd4

File tree

3 files changed

+46
-12
lines changed

3 files changed

+46
-12
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

0 commit comments

Comments
 (0)