Skip to content

Commit

Permalink
Automatic merge of 'next' into merge (2024-08-27 14:25)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpe committed Aug 27, 2024
2 parents 25b2f04 + b7d4733 commit 15d63cb
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 34 deletions.
6 changes: 6 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ S: 1549 Hiironen Rd.
S: Brimson, MN 55602
S: USA

N: Arnd Bergmann
D: Maintainer of Cell Broadband Engine Architecture

N: Hennus Bergman
P: 1024/77D50909 76 99 FD 31 91 E1 96 1C 90 BB 22 80 62 F6 BD 63
D: Author and maintainer of the QIC-02 tape driver
Expand Down Expand Up @@ -1869,6 +1872,9 @@ S: K osmidomkum 723
S: 160 00 Praha 6
S: Czech Republic

N: Jeremy Kerr
D: Maintainer of SPU File System

N: Michael Kerrisk
E: [email protected]
W: https://man7.org/
Expand Down
8 changes: 2 additions & 6 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -5098,10 +5098,8 @@ F: Documentation/devicetree/bindings/media/cec/cec-gpio.yaml
F: drivers/media/cec/platform/cec-gpio/

CELL BROADBAND ENGINE ARCHITECTURE
M: Arnd Bergmann <[email protected]>
L: [email protected]
S: Supported
W: http://www.ibm.com/developerworks/power/cell/
S: Orphan
F: arch/powerpc/include/asm/cell*.h
F: arch/powerpc/include/asm/spu*.h
F: arch/powerpc/include/uapi/asm/spu*.h
Expand Down Expand Up @@ -21519,10 +21517,8 @@ F: include/linux/spmi.h
F: include/trace/events/spmi.h

SPU FILE SYSTEM
M: Jeremy Kerr <[email protected]>
L: [email protected]
S: Supported
W: http://www.ibm.com/developerworks/power/cell/
S: Orphan
F: Documentation/filesystems/spufs/spufs.rst
F: arch/powerpc/platforms/cell/spufs/

Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/include/asm/asm-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
#define PPC_MIN_STKFRM 112

#ifdef __BIG_ENDIAN__
#define LHZX_BE stringify_in_c(lhzx)
#define LWZX_BE stringify_in_c(lwzx)
#define LDX_BE stringify_in_c(ldx)
#define STWX_BE stringify_in_c(stwx)
#define STDX_BE stringify_in_c(stdx)
#else
#define LHZX_BE stringify_in_c(lhbrx)
#define LWZX_BE stringify_in_c(lwbrx)
#define LDX_BE stringify_in_c(ldbrx)
#define STWX_BE stringify_in_c(stwbrx)
Expand Down
37 changes: 37 additions & 0 deletions arch/powerpc/include/asm/code-patching.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,43 @@ int patch_instruction(u32 *addr, ppc_inst_t instr);
int raw_patch_instruction(u32 *addr, ppc_inst_t instr);
int patch_instructions(u32 *addr, u32 *code, size_t len, bool repeat_instr);

/*
* The data patching functions patch_uint() and patch_ulong(), etc., must be
* called on aligned addresses.
*
* The instruction patching functions patch_instruction() and similar must be
* called on addresses satisfying instruction alignment requirements.
*/

#ifdef CONFIG_PPC64

int patch_uint(void *addr, unsigned int val);
int patch_ulong(void *addr, unsigned long val);

#define patch_u64 patch_ulong

#else

static inline int patch_uint(void *addr, unsigned int val)
{
if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned int)))
return -EINVAL;

return patch_instruction(addr, ppc_inst(val));
}

static inline int patch_ulong(void *addr, unsigned long val)
{
if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned long)))
return -EINVAL;

return patch_instruction(addr, ppc_inst(val));
}

#endif

#define patch_u32 patch_uint

static inline unsigned long patch_site_addr(s32 *site)
{
return (unsigned long)site + *site;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/include/asm/percpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DECLARE_STATIC_KEY_FALSE(__percpu_first_chunk_is_paged);
(static_key_enabled(&__percpu_first_chunk_is_paged.key))
#else
#define percpu_first_chunk_is_paged false
#endif /* CONFIG_PPC64 && CONFIG_SMP */
#endif

#include <asm-generic/percpu.h>

Expand Down
5 changes: 2 additions & 3 deletions arch/powerpc/kernel/module_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,11 @@ static inline int create_stub(const Elf64_Shdr *sechdrs,
// func_desc_t is 8 bytes if ABIv2, else 16 bytes
desc = func_desc(addr);
for (i = 0; i < sizeof(func_desc_t) / sizeof(u32); i++) {
if (patch_instruction(((u32 *)&entry->funcdata) + i,
ppc_inst(((u32 *)(&desc))[i])))
if (patch_u32(((u32 *)&entry->funcdata) + i, ((u32 *)&desc)[i]))
return 0;
}

if (patch_instruction(&entry->magic, ppc_inst(STUB_MAGIC)))
if (patch_u32(&entry->magic, STUB_MAGIC))
return 0;

return 1;
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/static_call.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void arch_static_call_transform(void *site, void *tramp, void *func, bool tail)
mutex_lock(&text_mutex);

if (func && !is_short) {
err = patch_instruction(tramp + PPC_SCT_DATA, ppc_inst(target));
err = patch_ulong(tramp + PPC_SCT_DATA, target);
if (err)
goto out;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static void pmac_backlight_unblank(void)

props = &pmac_backlight->props;
props->brightness = props->max_brightness;
props->power = FB_BLANK_UNBLANK;
props->power = BACKLIGHT_POWER_ON;
backlight_update_status(pmac_backlight);
}
mutex_unlock(&pmac_backlight_mutex);
Expand Down
70 changes: 55 additions & 15 deletions arch/powerpc/lib/code-patching.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
#include <asm/code-patching.h>
#include <asm/inst.h>

static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr)
static int __patch_mem(void *exec_addr, unsigned long val, void *patch_addr, bool is_dword)
{
if (!ppc_inst_prefixed(instr)) {
u32 val = ppc_inst_val(instr);
if (!IS_ENABLED(CONFIG_PPC64) || likely(!is_dword)) {
/* For big endian correctness: plain address would use the wrong half */
u32 val32 = val;

__put_kernel_nofault(patch_addr, &val, u32, failed);
__put_kernel_nofault(patch_addr, &val32, u32, failed);
} else {
u64 val = ppc_inst_as_ulong(instr);

__put_kernel_nofault(patch_addr, &val, u64, failed);
}

Expand All @@ -44,7 +43,10 @@ static int __patch_instruction(u32 *exec_addr, ppc_inst_t instr, u32 *patch_addr

int raw_patch_instruction(u32 *addr, ppc_inst_t instr)
{
return __patch_instruction(addr, instr, addr);
if (ppc_inst_prefixed(instr))
return __patch_mem(addr, ppc_inst_as_ulong(instr), addr, true);
else
return __patch_mem(addr, ppc_inst_val(instr), addr, false);
}

struct patch_context {
Expand Down Expand Up @@ -276,7 +278,7 @@ static void unmap_patch_area(unsigned long addr)
flush_tlb_kernel_range(addr, addr + PAGE_SIZE);
}

static int __do_patch_instruction_mm(u32 *addr, ppc_inst_t instr)
static int __do_patch_mem_mm(void *addr, unsigned long val, bool is_dword)
{
int err;
u32 *patch_addr;
Expand Down Expand Up @@ -305,7 +307,7 @@ static int __do_patch_instruction_mm(u32 *addr, ppc_inst_t instr)

orig_mm = start_using_temp_mm(patching_mm);

err = __patch_instruction(addr, instr, patch_addr);
err = __patch_mem(addr, val, patch_addr, is_dword);

/* context synchronisation performed by __patch_instruction (isync or exception) */
stop_using_temp_mm(patching_mm, orig_mm);
Expand All @@ -322,7 +324,7 @@ static int __do_patch_instruction_mm(u32 *addr, ppc_inst_t instr)
return err;
}

static int __do_patch_instruction(u32 *addr, ppc_inst_t instr)
static int __do_patch_mem(void *addr, unsigned long val, bool is_dword)
{
int err;
u32 *patch_addr;
Expand All @@ -339,15 +341,15 @@ static int __do_patch_instruction(u32 *addr, ppc_inst_t instr)
if (radix_enabled())
asm volatile("ptesync": : :"memory");

err = __patch_instruction(addr, instr, patch_addr);
err = __patch_mem(addr, val, patch_addr, is_dword);

pte_clear(&init_mm, text_poke_addr, pte);
flush_tlb_kernel_range(text_poke_addr, text_poke_addr + PAGE_SIZE);

return err;
}

int patch_instruction(u32 *addr, ppc_inst_t instr)
static int patch_mem(void *addr, unsigned long val, bool is_dword)
{
int err;
unsigned long flags;
Expand All @@ -359,19 +361,57 @@ int patch_instruction(u32 *addr, ppc_inst_t instr)
*/
if (!IS_ENABLED(CONFIG_STRICT_KERNEL_RWX) ||
!static_branch_likely(&poking_init_done))
return raw_patch_instruction(addr, instr);
return __patch_mem(addr, val, addr, is_dword);

local_irq_save(flags);
if (mm_patch_enabled())
err = __do_patch_instruction_mm(addr, instr);
err = __do_patch_mem_mm(addr, val, is_dword);
else
err = __do_patch_instruction(addr, instr);
err = __do_patch_mem(addr, val, is_dword);
local_irq_restore(flags);

return err;
}

#ifdef CONFIG_PPC64

int patch_instruction(u32 *addr, ppc_inst_t instr)
{
if (ppc_inst_prefixed(instr))
return patch_mem(addr, ppc_inst_as_ulong(instr), true);
else
return patch_mem(addr, ppc_inst_val(instr), false);
}
NOKPROBE_SYMBOL(patch_instruction);

int patch_uint(void *addr, unsigned int val)
{
if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned int)))
return -EINVAL;

return patch_mem(addr, val, false);
}
NOKPROBE_SYMBOL(patch_uint);

int patch_ulong(void *addr, unsigned long val)
{
if (!IS_ALIGNED((unsigned long)addr, sizeof(unsigned long)))
return -EINVAL;

return patch_mem(addr, val, true);
}
NOKPROBE_SYMBOL(patch_ulong);

#else

int patch_instruction(u32 *addr, ppc_inst_t instr)
{
return patch_mem(addr, ppc_inst_val(instr), false);
}
NOKPROBE_SYMBOL(patch_instruction)

#endif

static int patch_memset64(u64 *addr, u64 val, size_t count)
{
for (u64 *end = addr + count; addr < end; addr++)
Expand Down
41 changes: 41 additions & 0 deletions arch/powerpc/lib/test-code-patching.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,46 @@ static void __init test_multi_instruction_patching(void)
vfree(buf);
}

static void __init test_data_patching(void)
{
void *buf;
u32 *addr32;

buf = vzalloc(PAGE_SIZE);
check(buf);
if (!buf)
return;

addr32 = buf + 128;

addr32[1] = 0xA0A1A2A3;
addr32[2] = 0xB0B1B2B3;

check(!patch_uint(&addr32[1], 0xC0C1C2C3));

check(addr32[0] == 0);
check(addr32[1] == 0xC0C1C2C3);
check(addr32[2] == 0xB0B1B2B3);
check(addr32[3] == 0);

/* Unaligned patch_ulong() should fail */
if (IS_ENABLED(CONFIG_PPC64))
check(patch_ulong(&addr32[1], 0xD0D1D2D3) == -EINVAL);

check(!patch_ulong(&addr32[2], 0xD0D1D2D3));

check(addr32[0] == 0);
check(addr32[1] == 0xC0C1C2C3);
check(*(unsigned long *)(&addr32[2]) == 0xD0D1D2D3);

if (!IS_ENABLED(CONFIG_PPC64))
check(addr32[3] == 0);

check(addr32[4] == 0);

vfree(buf);
}

static int __init test_code_patching(void)
{
pr_info("Running code patching self-tests ...\n");
Expand All @@ -448,6 +488,7 @@ static int __init test_code_patching(void)
test_translate_branch();
test_prefixed_patching();
test_multi_instruction_patching();
test_data_patching();

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/44x/ppc476.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int avr_probe(struct i2c_client *client)
}

static const struct i2c_device_id avr_id[] = {
{ "akebono-avr", 0 },
{ "akebono-avr" },
{ }
};

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powermac/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ static int smp_core99_kick_cpu(int nr)
mdelay(1);

/* Restore our exception vector */
patch_instruction(vector, ppc_inst(save_vector));
patch_uint(vector, save_vector);

local_irq_restore(flags);
if (ppc_md.progress) ppc_md.progress("smp_core99_kick_cpu done", 0x347);
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powernv/eeh-powernv.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ static int pnv_eeh_bridge_reset(struct pci_dev *pdev, int option)
int64_t rc;

/* Hot reset to the bus if firmware cannot handle */
if (!dn || !of_get_property(dn, "ibm,reset-by-firmware", NULL))
if (!dn || !of_property_present(dn, "ibm,reset-by-firmware"))
return __pnv_eeh_bridge_reset(pdev, option);

pr_debug("%s: FW reset PCI bus %04x:%02x with option %d\n",
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/powernv/opal-lpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void __init opal_lpc_init(void)
for_each_compatible_node(np, NULL, "ibm,power8-lpc") {
if (!of_device_is_available(np))
continue;
if (!of_get_property(np, "primary", NULL))
if (!of_property_present(np, "primary"))
continue;
opal_lpc_chip_id = of_get_ibm_chip_id(np);
of_node_put(np);
Expand Down
2 changes: 1 addition & 1 deletion drivers/macintosh/via-pmu-backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void __init pmu_backlight_init(void)
}

bd->props.brightness = level;
bd->props.power = FB_BLANK_UNBLANK;
bd->props.power = BACKLIGHT_POWER_ON;
backlight_update_status(bd);

printk(KERN_INFO "PMU Backlight initialized (%s)\n", name);
Expand Down

0 comments on commit 15d63cb

Please sign in to comment.