aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasha Levin <sashal@kernel.org>2024-05-07 07:49:18 -0400
committerSasha Levin <sashal@kernel.org>2024-05-07 07:49:18 -0400
commit1e50eb919329e4c60db62c44060d3d39667a1ebc (patch)
treeb8e704490ba38c337c53cf50bdb0a28efe1bf73a
parent4d47141da05dec3552121848db4520146fe25de0 (diff)
downloadstable-queue-1e50eb919329e4c60db62c44060d3d39667a1ebc.tar.gz
Fixes for 6.1
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--queue-6.1/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch72
-rw-r--r--queue-6.1/powerpc-pseries-implement-signed-update-for-plpks-ob.patch178
-rw-r--r--queue-6.1/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch83
-rw-r--r--queue-6.1/powerpc-pseries-make-max-polling-consistent-for-long.patch76
-rw-r--r--queue-6.1/powerpc-pseries-move-plpks-constants-to-header-file.patch251
-rw-r--r--queue-6.1/powerpc-pseries-replace-kmalloc-with-kzalloc-in-plpk.patch50
-rw-r--r--queue-6.1/series6
7 files changed, 716 insertions, 0 deletions
diff --git a/queue-6.1/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch b/queue-6.1/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch
new file mode 100644
index 0000000000..2fb5b74f1e
--- /dev/null
+++ b/queue-6.1/clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch
@@ -0,0 +1,72 @@
+From 695d356cf3cb811fb45a7813540ab692428c27fd Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 13 Oct 2023 20:17:12 +0200
+Subject: clk: sunxi-ng: h6: Reparent CPUX during PLL CPUX rate change
+
+From: Jernej Skrabec <jernej.skrabec@gmail.com>
+
+[ Upstream commit 7e91ed763dc07437777bd012af7a2bd4493731ff ]
+
+While PLL CPUX clock rate change when CPU is running from it works in
+vast majority of cases, now and then it causes instability. This leads
+to system crashes and other undefined behaviour. After a lot of testing
+(30+ hours) while also doing a lot of frequency switches, we can't
+observe any instability issues anymore when doing reparenting to stable
+clock like 24 MHz oscillator.
+
+Fixes: 524353ea480b ("clk: sunxi-ng: add support for the Allwinner H6 CCU")
+Reported-by: Chad Wagner <wagnerch42@gmail.com>
+Link: https://forum.libreelec.tv/thread/27295-orange-pi-3-lts-freezes/
+Tested-by: Chad Wagner <wagnerch42@gmail.com>
+Reviewed-by: Chen-Yu Tsai <wens@csie.org>
+Link: https://lore.kernel.org/r/20231013181712.2128037-1-jernej.skrabec@gmail.com
+Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ drivers/clk/sunxi-ng/ccu-sun50i-h6.c | 19 +++++++++++++++++--
+ 1 file changed, 17 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
+index 42568c6161814..892df807275c8 100644
+--- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
++++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c
+@@ -1181,11 +1181,18 @@ static const u32 usb2_clk_regs[] = {
+ SUN50I_H6_USB3_CLK_REG,
+ };
+
++static struct ccu_mux_nb sun50i_h6_cpu_nb = {
++ .common = &cpux_clk.common,
++ .cm = &cpux_clk.mux,
++ .delay_us = 1,
++ .bypass_index = 0, /* index of 24 MHz oscillator */
++};
++
+ static int sun50i_h6_ccu_probe(struct platform_device *pdev)
+ {
+ void __iomem *reg;
++ int i, ret;
+ u32 val;
+- int i;
+
+ reg = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(reg))
+@@ -1252,7 +1259,15 @@ static int sun50i_h6_ccu_probe(struct platform_device *pdev)
+ val |= BIT(24);
+ writel(val, reg + SUN50I_H6_HDMI_CEC_CLK_REG);
+
+- return devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc);
++ ret = devm_sunxi_ccu_probe(&pdev->dev, reg, &sun50i_h6_ccu_desc);
++ if (ret)
++ return ret;
++
++ /* Reparent CPU during PLL CPUX rate changes */
++ ccu_mux_notifier_register(pll_cpux_clk.common.hw.clk,
++ &sun50i_h6_cpu_nb);
++
++ return 0;
+ }
+
+ static const struct of_device_id sun50i_h6_ccu_ids[] = {
+--
+2.43.0
+
diff --git a/queue-6.1/powerpc-pseries-implement-signed-update-for-plpks-ob.patch b/queue-6.1/powerpc-pseries-implement-signed-update-for-plpks-ob.patch
new file mode 100644
index 0000000000..7daed12882
--- /dev/null
+++ b/queue-6.1/powerpc-pseries-implement-signed-update-for-plpks-ob.patch
@@ -0,0 +1,178 @@
+From a4e3cd2c82d58d88a15524a8b3191b2f31038695 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 19:03:52 +1100
+Subject: powerpc/pseries: Implement signed update for PLPKS objects
+
+From: Nayna Jain <nayna@linux.ibm.com>
+
+[ Upstream commit 899d9b8fee66da820eadc60b2a70090eb83db761 ]
+
+The Platform Keystore provides a signed update interface which can be used
+to create, replace or append to certain variables in the PKS in a secure
+fashion, with the hypervisor requiring that the update be signed using the
+Platform Key.
+
+Implement an interface to the H_PKS_SIGNED_UPDATE hcall in the plpks
+driver to allow signed updates to PKS objects.
+
+(The plpks driver doesn't need to do any cryptography or otherwise handle
+the actual signed variable contents - that will be handled by userspace
+tooling.)
+
+Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
+[ajd: split patch, add timeout handling and misc cleanups]
+Co-developed-by: Andrew Donnellan <ajd@linux.ibm.com>
+Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
+Signed-off-by: Russell Currey <ruscur@russell.cc>
+Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230210080401.345462-18-ajd@linux.ibm.com
+Stable-dep-of: 784354349d2c ("powerpc/pseries: make max polling consistent for longer H_CALLs")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/include/asm/hvcall.h | 1 +
+ arch/powerpc/platforms/pseries/plpks.c | 74 ++++++++++++++++++++++++--
+ arch/powerpc/platforms/pseries/plpks.h | 5 ++
+ 3 files changed, 75 insertions(+), 5 deletions(-)
+
+diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h
+index 95fd7f9485d55..c099780385dd3 100644
+--- a/arch/powerpc/include/asm/hvcall.h
++++ b/arch/powerpc/include/asm/hvcall.h
+@@ -335,6 +335,7 @@
+ #define H_RPT_INVALIDATE 0x448
+ #define H_SCM_FLUSH 0x44C
+ #define H_GET_ENERGY_SCALE_INFO 0x450
++#define H_PKS_SIGNED_UPDATE 0x454
+ #define H_WATCHDOG 0x45C
+ #define MAX_HCALL_OPCODE H_WATCHDOG
+
+diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c
+index 06b52fe12c88b..3efbfd25d35d0 100644
+--- a/arch/powerpc/platforms/pseries/plpks.c
++++ b/arch/powerpc/platforms/pseries/plpks.c
+@@ -74,6 +74,12 @@ static int pseries_status_to_err(int rc)
+ err = -ENOENT;
+ break;
+ case H_BUSY:
++ case H_LONG_BUSY_ORDER_1_MSEC:
++ case H_LONG_BUSY_ORDER_10_MSEC:
++ case H_LONG_BUSY_ORDER_100_MSEC:
++ case H_LONG_BUSY_ORDER_1_SEC:
++ case H_LONG_BUSY_ORDER_10_SEC:
++ case H_LONG_BUSY_ORDER_100_SEC:
+ err = -EBUSY;
+ break;
+ case H_AUTHORITY:
+@@ -174,14 +180,17 @@ static struct label *construct_label(char *component, u8 varos, u8 *name,
+ u16 namelen)
+ {
+ struct label *label;
+- size_t slen;
++ size_t slen = 0;
+
+ if (!name || namelen > PLPKS_MAX_NAME_SIZE)
+ return ERR_PTR(-EINVAL);
+
+- slen = strlen(component);
+- if (component && slen > sizeof(label->attr.prefix))
+- return ERR_PTR(-EINVAL);
++ // Support NULL component for signed updates
++ if (component) {
++ slen = strlen(component);
++ if (slen > sizeof(label->attr.prefix))
++ return ERR_PTR(-EINVAL);
++ }
+
+ label = kzalloc(sizeof(*label), GFP_KERNEL);
+ if (!label)
+@@ -264,6 +273,61 @@ static int plpks_confirm_object_flushed(struct label *label,
+ return rc;
+ }
+
++int plpks_signed_update_var(struct plpks_var *var, u64 flags)
++{
++ unsigned long retbuf[PLPAR_HCALL9_BUFSIZE] = {0};
++ int rc;
++ struct label *label;
++ struct plpks_auth *auth;
++ u64 continuetoken = 0;
++ u64 timeout = 0;
++
++ if (!var->data || var->datalen <= 0 || var->namelen > PLPKS_MAX_NAME_SIZE)
++ return -EINVAL;
++
++ if (!(var->policy & PLPKS_SIGNEDUPDATE))
++ return -EINVAL;
++
++ // Signed updates need the component to be NULL.
++ if (var->component)
++ return -EINVAL;
++
++ auth = construct_auth(PLPKS_OS_OWNER);
++ if (IS_ERR(auth))
++ return PTR_ERR(auth);
++
++ label = construct_label(var->component, var->os, var->name, var->namelen);
++ if (IS_ERR(label)) {
++ rc = PTR_ERR(label);
++ goto out;
++ }
++
++ do {
++ rc = plpar_hcall9(H_PKS_SIGNED_UPDATE, retbuf,
++ virt_to_phys(auth), virt_to_phys(label),
++ label->size, var->policy, flags,
++ virt_to_phys(var->data), var->datalen,
++ continuetoken);
++
++ continuetoken = retbuf[0];
++ if (pseries_status_to_err(rc) == -EBUSY) {
++ int delay_ms = get_longbusy_msecs(rc);
++ mdelay(delay_ms);
++ timeout += delay_ms;
++ }
++ rc = pseries_status_to_err(rc);
++ } while (rc == -EBUSY && timeout < PLPKS_MAX_TIMEOUT);
++
++ if (!rc)
++ rc = plpks_confirm_object_flushed(label, auth);
++
++ kfree(label);
++out:
++ kfree(auth);
++
++ return rc;
++}
++
+ int plpks_write_var(struct plpks_var var)
+ {
+ unsigned long retbuf[PLPAR_HCALL_BUFSIZE] = { 0 };
+@@ -314,7 +378,7 @@ int plpks_remove_var(char *component, u8 varos, struct plpks_var_name vname)
+ struct label *label;
+ int rc;
+
+- if (!component || vname.namelen > PLPKS_MAX_NAME_SIZE)
++ if (vname.namelen > PLPKS_MAX_NAME_SIZE)
+ return -EINVAL;
+
+ auth = construct_auth(PLPKS_OS_OWNER);
+diff --git a/arch/powerpc/platforms/pseries/plpks.h b/arch/powerpc/platforms/pseries/plpks.h
+index 6afb44ee74a16..ccbec26fcbd8b 100644
+--- a/arch/powerpc/platforms/pseries/plpks.h
++++ b/arch/powerpc/platforms/pseries/plpks.h
+@@ -66,6 +66,11 @@ struct plpks_var_name_list {
+ struct plpks_var_name varlist[];
+ };
+
++/**
++ * Updates the authenticated variable. It expects NULL as the component.
++ */
++int plpks_signed_update_var(struct plpks_var *var, u64 flags);
++
+ /**
+ * Writes the specified var and its data to PKS.
+ * Any caller of PKS driver should present a valid component type for
+--
+2.43.0
+
diff --git a/queue-6.1/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch b/queue-6.1/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch
new file mode 100644
index 0000000000..05cf20d8b2
--- /dev/null
+++ b/queue-6.1/powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch
@@ -0,0 +1,83 @@
+From c3ce5bdd5d1ab7cef643edc4a34a18086f66f9a4 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Mon, 22 Apr 2024 15:51:41 -0500
+Subject: powerpc/pseries/iommu: LPAR panics during boot up with a frozen PE
+
+From: Gaurav Batra <gbatra@linux.ibm.com>
+
+[ Upstream commit 49a940dbdc3107fecd5e6d3063dc07128177e058 ]
+
+At the time of LPAR boot up, partition firmware provides Open Firmware
+property ibm,dma-window for the PE. This property is provided on the PCI
+bus the PE is attached to.
+
+There are execptions where the partition firmware might not provide this
+property for the PE at the time of LPAR boot up. One of the scenario is
+where the firmware has frozen the PE due to some error condition. This
+PE is frozen for 24 hours or unless the whole system is reinitialized.
+
+Within this time frame, if the LPAR is booted, the frozen PE will be
+presented to the LPAR but ibm,dma-window property could be missing.
+
+Today, under these circumstances, the LPAR oopses with NULL pointer
+dereference, when configuring the PCI bus the PE is attached to.
+
+ BUG: Kernel NULL pointer dereference on read at 0x000000c8
+ Faulting instruction address: 0xc0000000001024c0
+ Oops: Kernel access of bad area, sig: 7 [#1]
+ LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
+ Modules linked in:
+ Supported: Yes
+ CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.4.0-150600.9-default #1
+ Hardware name: IBM,9043-MRX POWER10 (raw) 0x800200 0xf000006 of:IBM,FW1060.00 (NM1060_023) hv:phyp pSeries
+ NIP: c0000000001024c0 LR: c0000000001024b0 CTR: c000000000102450
+ REGS: c0000000037db5c0 TRAP: 0300 Not tainted (6.4.0-150600.9-default)
+ MSR: 8000000002009033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 28000822 XER: 00000000
+ CFAR: c00000000010254c DAR: 00000000000000c8 DSISR: 00080000 IRQMASK: 0
+ ...
+ NIP [c0000000001024c0] pci_dma_bus_setup_pSeriesLP+0x70/0x2a0
+ LR [c0000000001024b0] pci_dma_bus_setup_pSeriesLP+0x60/0x2a0
+ Call Trace:
+ pci_dma_bus_setup_pSeriesLP+0x60/0x2a0 (unreliable)
+ pcibios_setup_bus_self+0x1c0/0x370
+ __of_scan_bus+0x2f8/0x330
+ pcibios_scan_phb+0x280/0x3d0
+ pcibios_init+0x88/0x12c
+ do_one_initcall+0x60/0x320
+ kernel_init_freeable+0x344/0x3e4
+ kernel_init+0x34/0x1d0
+ ret_from_kernel_user_thread+0x14/0x1c
+
+Fixes: b1fc44eaa9ba ("pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window")
+Signed-off-by: Gaurav Batra <gbatra@linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://msgid.link/20240422205141.10662-1-gbatra@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/pseries/iommu.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
+index 1e5f083cdb720..5e00a3cde93b9 100644
+--- a/arch/powerpc/platforms/pseries/iommu.c
++++ b/arch/powerpc/platforms/pseries/iommu.c
+@@ -781,8 +781,16 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
+ * parent bus. During reboot, there will be ibm,dma-window property to
+ * define DMA window. For kdump, there will at least be default window or DDW
+ * or both.
++ * There is an exception to the above. In case the PE goes into frozen
++ * state, firmware may not provide ibm,dma-window property at the time
++ * of LPAR boot up.
+ */
+
++ if (!pdn) {
++ pr_debug(" no ibm,dma-window property !\n");
++ return;
++ }
++
+ ppci = PCI_DN(pdn);
+
+ pr_debug(" parent is %pOF, iommu_table: 0x%p\n",
+--
+2.43.0
+
diff --git a/queue-6.1/powerpc-pseries-make-max-polling-consistent-for-long.patch b/queue-6.1/powerpc-pseries-make-max-polling-consistent-for-long.patch
new file mode 100644
index 0000000000..18f680f99f
--- /dev/null
+++ b/queue-6.1/powerpc-pseries-make-max-polling-consistent-for-long.patch
@@ -0,0 +1,76 @@
+From ec845aca1ab07fbfc5ed8aee89a0dca6357352df Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 17 Apr 2024 23:12:30 -0400
+Subject: powerpc/pseries: make max polling consistent for longer H_CALLs
+
+From: Nayna Jain <nayna@linux.ibm.com>
+
+[ Upstream commit 784354349d2c988590c63a5a001ca37b2a6d4da1 ]
+
+Currently, plpks_confirm_object_flushed() function polls for 5msec in
+total instead of 5sec.
+
+Keep max polling time consistent for all the H_CALLs, which take longer
+than expected, to be 5sec. Also, make use of fsleep() everywhere to
+insert delay.
+
+Reported-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
+Fixes: 2454a7af0f2a ("powerpc/pseries: define driver for Platform KeyStore")
+Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
+Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
+Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://msgid.link/20240418031230.170954-1-nayna@linux.ibm.com
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/pseries/plpks.c | 10 +++++-----
+ arch/powerpc/platforms/pseries/plpks.h | 5 ++---
+ 2 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c
+index 3efbfd25d35d0..453c3cdd81fb8 100644
+--- a/arch/powerpc/platforms/pseries/plpks.c
++++ b/arch/powerpc/platforms/pseries/plpks.c
+@@ -263,8 +263,7 @@ static int plpks_confirm_object_flushed(struct label *label,
+ if (!rc && status == 1)
+ break;
+
+- usleep_range(PLPKS_FLUSH_SLEEP,
+- PLPKS_FLUSH_SLEEP + PLPKS_FLUSH_SLEEP_RANGE);
++ fsleep(PLPKS_FLUSH_SLEEP);
+ timeout = timeout + PLPKS_FLUSH_SLEEP;
+ } while (timeout < PLPKS_MAX_TIMEOUT);
+
+@@ -311,9 +310,10 @@ int plpks_signed_update_var(struct plpks_var *var, u64 flags)
+
+ continuetoken = retbuf[0];
+ if (pseries_status_to_err(rc) == -EBUSY) {
+- int delay_ms = get_longbusy_msecs(rc);
+- mdelay(delay_ms);
+- timeout += delay_ms;
++ int delay_us = get_longbusy_msecs(rc) * 1000;
++
++ fsleep(delay_us);
++ timeout += delay_us;
+ }
+ rc = pseries_status_to_err(rc);
+ } while (rc == -EBUSY && timeout < PLPKS_MAX_TIMEOUT);
+diff --git a/arch/powerpc/platforms/pseries/plpks.h b/arch/powerpc/platforms/pseries/plpks.h
+index ccbec26fcbd8b..b3c3538b229c6 100644
+--- a/arch/powerpc/platforms/pseries/plpks.h
++++ b/arch/powerpc/platforms/pseries/plpks.h
+@@ -42,9 +42,8 @@
+ #define PLPKS_MAX_DATA_SIZE 4000
+
+ // Timeouts for PLPKS operations
+-#define PLPKS_MAX_TIMEOUT 5000 // msec
+-#define PLPKS_FLUSH_SLEEP 10 // msec
+-#define PLPKS_FLUSH_SLEEP_RANGE 400
++#define PLPKS_MAX_TIMEOUT (5 * USEC_PER_SEC)
++#define PLPKS_FLUSH_SLEEP 10000 // usec
+
+ struct plpks_var {
+ char *component;
+--
+2.43.0
+
diff --git a/queue-6.1/powerpc-pseries-move-plpks-constants-to-header-file.patch b/queue-6.1/powerpc-pseries-move-plpks-constants-to-header-file.patch
new file mode 100644
index 0000000000..03c31eacec
--- /dev/null
+++ b/queue-6.1/powerpc-pseries-move-plpks-constants-to-header-file.patch
@@ -0,0 +1,251 @@
+From c8eb9676789679e1900b5089d78bc4a7b66c7e35 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Fri, 10 Feb 2023 19:03:50 +1100
+Subject: powerpc/pseries: Move PLPKS constants to header file
+
+From: Russell Currey <ruscur@russell.cc>
+
+[ Upstream commit 3def7a3e7c2ce2ab5e5c54561da7125206851be4 ]
+
+Move the constants defined in plpks.c to plpks.h, and standardise their
+naming, so that PLPKS consumers can make use of them later on.
+
+Signed-off-by: Russell Currey <ruscur@russell.cc>
+Co-developed-by: Andrew Donnellan <ajd@linux.ibm.com>
+Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
+Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20230210080401.345462-16-ajd@linux.ibm.com
+Stable-dep-of: 784354349d2c ("powerpc/pseries: make max polling consistent for longer H_CALLs")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/pseries/plpks.c | 57 ++++++++++----------------
+ arch/powerpc/platforms/pseries/plpks.h | 36 +++++++++++++---
+ 2 files changed, 53 insertions(+), 40 deletions(-)
+
+diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c
+index bb6f5437d83ab..06b52fe12c88b 100644
+--- a/arch/powerpc/platforms/pseries/plpks.c
++++ b/arch/powerpc/platforms/pseries/plpks.c
+@@ -21,19 +21,6 @@
+
+ #include "plpks.h"
+
+-#define PKS_FW_OWNER 0x1
+-#define PKS_BOOTLOADER_OWNER 0x2
+-#define PKS_OS_OWNER 0x3
+-
+-#define LABEL_VERSION 0
+-#define MAX_LABEL_ATTR_SIZE 16
+-#define MAX_NAME_SIZE 239
+-#define MAX_DATA_SIZE 4000
+-
+-#define PKS_FLUSH_MAX_TIMEOUT 5000 //msec
+-#define PKS_FLUSH_SLEEP 10 //msec
+-#define PKS_FLUSH_SLEEP_RANGE 400
+-
+ static u8 *ospassword;
+ static u16 ospasswordlength;
+
+@@ -60,7 +47,7 @@ struct label_attr {
+
+ struct label {
+ struct label_attr attr;
+- u8 name[MAX_NAME_SIZE];
++ u8 name[PLPKS_MAX_NAME_SIZE];
+ size_t size;
+ };
+
+@@ -123,7 +110,7 @@ static int pseries_status_to_err(int rc)
+ static int plpks_gen_password(void)
+ {
+ unsigned long retbuf[PLPAR_HCALL_BUFSIZE] = { 0 };
+- u8 *password, consumer = PKS_OS_OWNER;
++ u8 *password, consumer = PLPKS_OS_OWNER;
+ int rc;
+
+ password = kzalloc(maxpwsize, GFP_KERNEL);
+@@ -159,7 +146,7 @@ static struct plpks_auth *construct_auth(u8 consumer)
+ {
+ struct plpks_auth *auth;
+
+- if (consumer > PKS_OS_OWNER)
++ if (consumer > PLPKS_OS_OWNER)
+ return ERR_PTR(-EINVAL);
+
+ auth = kzalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
+@@ -169,7 +156,7 @@ static struct plpks_auth *construct_auth(u8 consumer)
+ auth->version = 1;
+ auth->consumer = consumer;
+
+- if (consumer == PKS_FW_OWNER || consumer == PKS_BOOTLOADER_OWNER)
++ if (consumer == PLPKS_FW_OWNER || consumer == PLPKS_BOOTLOADER_OWNER)
+ return auth;
+
+ memcpy(auth->password, ospassword, ospasswordlength);
+@@ -189,7 +176,7 @@ static struct label *construct_label(char *component, u8 varos, u8 *name,
+ struct label *label;
+ size_t slen;
+
+- if (!name || namelen > MAX_NAME_SIZE)
++ if (!name || namelen > PLPKS_MAX_NAME_SIZE)
+ return ERR_PTR(-EINVAL);
+
+ slen = strlen(component);
+@@ -203,9 +190,9 @@ static struct label *construct_label(char *component, u8 varos, u8 *name,
+ if (component)
+ memcpy(&label->attr.prefix, component, slen);
+
+- label->attr.version = LABEL_VERSION;
++ label->attr.version = PLPKS_LABEL_VERSION;
+ label->attr.os = varos;
+- label->attr.length = MAX_LABEL_ATTR_SIZE;
++ label->attr.length = PLPKS_MAX_LABEL_ATTR_SIZE;
+ memcpy(&label->name, name, namelen);
+
+ label->size = sizeof(struct label_attr) + namelen;
+@@ -267,10 +254,10 @@ static int plpks_confirm_object_flushed(struct label *label,
+ if (!rc && status == 1)
+ break;
+
+- usleep_range(PKS_FLUSH_SLEEP,
+- PKS_FLUSH_SLEEP + PKS_FLUSH_SLEEP_RANGE);
+- timeout = timeout + PKS_FLUSH_SLEEP;
+- } while (timeout < PKS_FLUSH_MAX_TIMEOUT);
++ usleep_range(PLPKS_FLUSH_SLEEP,
++ PLPKS_FLUSH_SLEEP + PLPKS_FLUSH_SLEEP_RANGE);
++ timeout = timeout + PLPKS_FLUSH_SLEEP;
++ } while (timeout < PLPKS_MAX_TIMEOUT);
+
+ rc = pseries_status_to_err(rc);
+
+@@ -285,13 +272,13 @@ int plpks_write_var(struct plpks_var var)
+ int rc;
+
+ if (!var.component || !var.data || var.datalen <= 0 ||
+- var.namelen > MAX_NAME_SIZE || var.datalen > MAX_DATA_SIZE)
++ var.namelen > PLPKS_MAX_NAME_SIZE || var.datalen > PLPKS_MAX_DATA_SIZE)
+ return -EINVAL;
+
+- if (var.policy & SIGNEDUPDATE)
++ if (var.policy & PLPKS_SIGNEDUPDATE)
+ return -EINVAL;
+
+- auth = construct_auth(PKS_OS_OWNER);
++ auth = construct_auth(PLPKS_OS_OWNER);
+ if (IS_ERR(auth))
+ return PTR_ERR(auth);
+
+@@ -327,10 +314,10 @@ int plpks_remove_var(char *component, u8 varos, struct plpks_var_name vname)
+ struct label *label;
+ int rc;
+
+- if (!component || vname.namelen > MAX_NAME_SIZE)
++ if (!component || vname.namelen > PLPKS_MAX_NAME_SIZE)
+ return -EINVAL;
+
+- auth = construct_auth(PKS_OS_OWNER);
++ auth = construct_auth(PLPKS_OS_OWNER);
+ if (IS_ERR(auth))
+ return PTR_ERR(auth);
+
+@@ -366,14 +353,14 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)
+ u8 *output;
+ int rc;
+
+- if (var->namelen > MAX_NAME_SIZE)
++ if (var->namelen > PLPKS_MAX_NAME_SIZE)
+ return -EINVAL;
+
+ auth = construct_auth(consumer);
+ if (IS_ERR(auth))
+ return PTR_ERR(auth);
+
+- if (consumer == PKS_OS_OWNER) {
++ if (consumer == PLPKS_OS_OWNER) {
+ label = construct_label(var->component, var->os, var->name,
+ var->namelen);
+ if (IS_ERR(label)) {
+@@ -388,7 +375,7 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)
+ goto out_free_label;
+ }
+
+- if (consumer == PKS_OS_OWNER)
++ if (consumer == PLPKS_OS_OWNER)
+ rc = plpar_hcall(H_PKS_READ_OBJECT, retbuf, virt_to_phys(auth),
+ virt_to_phys(label), label->size, virt_to_phys(output),
+ maxobjsize);
+@@ -430,17 +417,17 @@ static int plpks_read_var(u8 consumer, struct plpks_var *var)
+
+ int plpks_read_os_var(struct plpks_var *var)
+ {
+- return plpks_read_var(PKS_OS_OWNER, var);
++ return plpks_read_var(PLPKS_OS_OWNER, var);
+ }
+
+ int plpks_read_fw_var(struct plpks_var *var)
+ {
+- return plpks_read_var(PKS_FW_OWNER, var);
++ return plpks_read_var(PLPKS_FW_OWNER, var);
+ }
+
+ int plpks_read_bootloader_var(struct plpks_var *var)
+ {
+- return plpks_read_var(PKS_BOOTLOADER_OWNER, var);
++ return plpks_read_var(PLPKS_BOOTLOADER_OWNER, var);
+ }
+
+ static __init int pseries_plpks_init(void)
+diff --git a/arch/powerpc/platforms/pseries/plpks.h b/arch/powerpc/platforms/pseries/plpks.h
+index 275ccd86bfb5e..6afb44ee74a16 100644
+--- a/arch/powerpc/platforms/pseries/plpks.h
++++ b/arch/powerpc/platforms/pseries/plpks.h
+@@ -12,14 +12,40 @@
+ #include <linux/types.h>
+ #include <linux/list.h>
+
+-#define OSSECBOOTAUDIT 0x40000000
+-#define OSSECBOOTENFORCE 0x20000000
+-#define WORLDREADABLE 0x08000000
+-#define SIGNEDUPDATE 0x01000000
++// Object policy flags from supported_policies
++#define PLPKS_OSSECBOOTAUDIT PPC_BIT32(1) // OS secure boot must be audit/enforce
++#define PLPKS_OSSECBOOTENFORCE PPC_BIT32(2) // OS secure boot must be enforce
++#define PLPKS_PWSET PPC_BIT32(3) // No access without password set
++#define PLPKS_WORLDREADABLE PPC_BIT32(4) // Readable without authentication
++#define PLPKS_IMMUTABLE PPC_BIT32(5) // Once written, object cannot be removed
++#define PLPKS_TRANSIENT PPC_BIT32(6) // Object does not persist through reboot
++#define PLPKS_SIGNEDUPDATE PPC_BIT32(7) // Object can only be modified by signed updates
++#define PLPKS_HVPROVISIONED PPC_BIT32(28) // Hypervisor has provisioned this object
+
+-#define PLPKS_VAR_LINUX 0x02
++// Signature algorithm flags from signed_update_algorithms
++#define PLPKS_ALG_RSA2048 PPC_BIT(0)
++#define PLPKS_ALG_RSA4096 PPC_BIT(1)
++
++// Object label OS metadata flags
++#define PLPKS_VAR_LINUX 0x02
+ #define PLPKS_VAR_COMMON 0x04
+
++// Flags for which consumer owns an object is owned by
++#define PLPKS_FW_OWNER 0x1
++#define PLPKS_BOOTLOADER_OWNER 0x2
++#define PLPKS_OS_OWNER 0x3
++
++// Flags for label metadata fields
++#define PLPKS_LABEL_VERSION 0
++#define PLPKS_MAX_LABEL_ATTR_SIZE 16
++#define PLPKS_MAX_NAME_SIZE 239
++#define PLPKS_MAX_DATA_SIZE 4000
++
++// Timeouts for PLPKS operations
++#define PLPKS_MAX_TIMEOUT 5000 // msec
++#define PLPKS_FLUSH_SLEEP 10 // msec
++#define PLPKS_FLUSH_SLEEP_RANGE 400
++
+ struct plpks_var {
+ char *component;
+ u8 *name;
+--
+2.43.0
+
diff --git a/queue-6.1/powerpc-pseries-replace-kmalloc-with-kzalloc-in-plpk.patch b/queue-6.1/powerpc-pseries-replace-kmalloc-with-kzalloc-in-plpk.patch
new file mode 100644
index 0000000000..f9d36d633d
--- /dev/null
+++ b/queue-6.1/powerpc-pseries-replace-kmalloc-with-kzalloc-in-plpk.patch
@@ -0,0 +1,50 @@
+From 3f6f8afa1801d5d2541d40b9ead140d4001fa678 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Sun, 6 Nov 2022 15:58:38 -0500
+Subject: powerpc/pseries: replace kmalloc with kzalloc in PLPKS driver
+
+From: Nayna Jain <nayna@linux.ibm.com>
+
+[ Upstream commit 212dd5cfbee7815f3c665a51c501701edb881599 ]
+
+Replace kmalloc with kzalloc in construct_auth() function to default
+initialize structure with zeroes.
+
+Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20221106205839.600442-6-nayna@linux.ibm.com
+Stable-dep-of: 784354349d2c ("powerpc/pseries: make max polling consistent for longer H_CALLs")
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ arch/powerpc/platforms/pseries/plpks.c | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c
+index 63a1e1fe01851..bb6f5437d83ab 100644
+--- a/arch/powerpc/platforms/pseries/plpks.c
++++ b/arch/powerpc/platforms/pseries/plpks.c
+@@ -162,19 +162,15 @@ static struct plpks_auth *construct_auth(u8 consumer)
+ if (consumer > PKS_OS_OWNER)
+ return ERR_PTR(-EINVAL);
+
+- auth = kmalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
++ auth = kzalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
+ if (!auth)
+ return ERR_PTR(-ENOMEM);
+
+ auth->version = 1;
+ auth->consumer = consumer;
+- auth->rsvd0 = 0;
+- auth->rsvd1 = 0;
+
+- if (consumer == PKS_FW_OWNER || consumer == PKS_BOOTLOADER_OWNER) {
+- auth->passwordlength = 0;
++ if (consumer == PKS_FW_OWNER || consumer == PKS_BOOTLOADER_OWNER)
+ return auth;
+- }
+
+ memcpy(auth->password, ospassword, ospasswordlength);
+
+--
+2.43.0
+
diff --git a/queue-6.1/series b/queue-6.1/series
index 0c513fd9ca..73d0598ee1 100644
--- a/queue-6.1/series
+++ b/queue-6.1/series
@@ -84,3 +84,9 @@ s390-qeth-fix-kernel-panic-after-setting-hsuid.patch
drm-panel-ili9341-respect-deferred-probe.patch
drm-panel-ili9341-use-predefined-error-codes.patch
net-gro-add-flush-check-in-udp_gro_receive_segment.patch
+clk-sunxi-ng-h6-reparent-cpux-during-pll-cpux-rate-c.patch
+powerpc-pseries-replace-kmalloc-with-kzalloc-in-plpk.patch
+powerpc-pseries-move-plpks-constants-to-header-file.patch
+powerpc-pseries-implement-signed-update-for-plpks-ob.patch
+powerpc-pseries-make-max-polling-consistent-for-long.patch
+powerpc-pseries-iommu-lpar-panics-during-boot-up-wit.patch