Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Al Stone <ahs3@redhat.com>
Pablo Greco ceb317
Date: Tue, 27 Feb 2018 00:21:23 -0500
Pablo Greco 0f1c57
Subject: [PATCH 01/34] ACPI: APEI: arm64: Ignore broken HPE moonshot APEI
Pablo Greco ceb317
 support
Pablo Greco ceb317
Pablo Greco ceb317
Message-id: <20180227002123.21608-1-ahs3@redhat.com>
Pablo Greco ceb317
Patchwork-id: 206052
Pablo Greco ceb317
O-Subject: [RHEL8 BZ1518076 PATCH] ACPI: APEI: arm64: Ignore broken HPE moonshot APEI support
Pablo Greco ceb317
Bugzilla: 1518076
Pablo Greco ceb317
RH-Acked-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Jeremy McNicoll <jmcnicol@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1518076
Pablo Greco ceb317
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=15417197
Pablo Greco ceb317
Tested: compile-only; several other patches are required for full booting
Pablo Greco ceb317
        QE has tested limited boot (see comment#12 of BZ)
Pablo Greco ceb317
Pablo Greco ceb317
This is a re-post of a RHEL-ALT-7.5 patch specific to aarch64 moonshots
Pablo Greco ceb317
that we use in beaker.  It is required for these machines to boot.
Pablo Greco ceb317
Pablo Greco ceb317
    commit 8a663a264863efedf8bb4a9d76ac603920fdd739
Pablo Greco ceb317
    Author: Robert Richter <rrichter@redhat.com>
Pablo Greco ceb317
    Date:   Wed Aug 16 19:49:30 2017 -0400
Pablo Greco ceb317
Pablo Greco ceb317
    [acpi] APEI: arm64: Ignore broken HPE moonshot APEI support
Pablo Greco ceb317
Pablo Greco ceb317
    From: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1344237
Pablo Greco ceb317
    Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=13768971
Pablo Greco ceb317
    Tested: Booted on moonshot with patched 4.11.0-20 kernel
Pablo Greco ceb317
    Upstream: RHEL-only
Pablo Greco ceb317
Pablo Greco ceb317
    The aarch64 HP moonshot platforms we have in beaker and elsewhere have
Pablo Greco ceb317
    a firmware bug which causes a spurious fatal memory error via APEI at
Pablo Greco ceb317
    boot time. This platform is no longer supported and no further firmware
Pablo Greco ceb317
    updates are expected. This is a downstream-only hack to avoid the problem
Pablo Greco ceb317
    by bailing out of HEST table probing if we detect a moonshot HEST table.
Pablo Greco ceb317
Pablo Greco ceb317
    Signed-off-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
    Signed-off-by: Robert Richter <rrichter@redhat.com>
Pablo Greco ceb317
    Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Al Stone <ahs3@redhat.com>
Pablo Greco ceb317
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/acpi/apei/hest.c | 8 ++++++++
Pablo Greco ceb317
 1 file changed, 8 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
Pablo Greco 0f1c57
index 6aef1ee5e1bd..8f146b1b4972 100644
Pablo Greco ceb317
--- a/drivers/acpi/apei/hest.c
Pablo Greco ceb317
+++ b/drivers/acpi/apei/hest.c
Pablo Greco 0f1c57
@@ -96,6 +96,14 @@ static int apei_hest_parse(apei_hest_func_t func, void *data)
Pablo Greco ceb317
 	if (hest_disable || !hest_tab)
Pablo Greco ceb317
 		return -EINVAL;
Pablo Greco ceb317
 
Pablo Greco ceb317
+#ifdef CONFIG_ARM64
Pablo Greco ceb317
+	/* Ignore broken firmware */
Pablo Greco ceb317
+	if (!strncmp(hest_tab->header.oem_id, "HPE   ", 6) &&
Pablo Greco ceb317
+	    !strncmp(hest_tab->header.oem_table_id, "ProLiant", 8) &&
Pablo Greco ceb317
+	    MIDR_IMPLEMENTOR(read_cpuid_id()) == ARM_CPU_IMP_APM)
Pablo Greco ceb317
+		return -EINVAL;
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+
Pablo Greco ceb317
 	hest_hdr = (struct acpi_hest_header *)(hest_tab + 1);
Pablo Greco ceb317
 	for (i = 0; i < hest_tab->error_source_count; i++) {
Pablo Greco ceb317
 		len = hest_esrc_len(hest_hdr);
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Date: Thu, 10 May 2018 17:38:43 -0400
Pablo Greco 0f1c57
Subject: [PATCH 02/34] ACPI / irq: Workaround firmware issue on X-Gene based
Pablo Greco ceb317
 m400
Pablo Greco ceb317
Pablo Greco ceb317
Message-id: <20180510173844.29580-3-msalter@redhat.com>
Pablo Greco ceb317
Patchwork-id: 214383
Pablo Greco ceb317
O-Subject: [RHEL-8 BZ1519554 2/3] ACPI / irq: Workaround firmware issue on X-Gene based m400
Pablo Greco ceb317
Bugzilla: 1519554
Pablo Greco ceb317
RH-Acked-by: Al Stone <astone@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1519554
Pablo Greco ceb317
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=16144520
Pablo Greco ceb317
Pablo Greco ceb317
The ACPI firmware on the xgene-based m400 platorms erroneously
Pablo Greco ceb317
describes its UART interrupt as ACPI_PRODUCER rather than
Pablo Greco ceb317
ACPI_CONSUMER. This leads to the UART driver being unable to
Pablo Greco ceb317
find its interrupt and the kernel unable find a console.
Pablo Greco ceb317
Work around this by avoiding the producer/consumer check
Pablo Greco ceb317
for X-Gene UARTs.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/acpi/irq.c | 17 +++++++++++++++--
Pablo Greco ceb317
 1 file changed, 15 insertions(+), 2 deletions(-)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c
Pablo Greco 0f1c57
index c2c786eb95ab..377cddba06dc 100644
Pablo Greco ceb317
--- a/drivers/acpi/irq.c
Pablo Greco ceb317
+++ b/drivers/acpi/irq.c
Pablo Greco 0f1c57
@@ -138,6 +138,7 @@ struct acpi_irq_parse_one_ctx {
Pablo Greco ceb317
 	unsigned int index;
Pablo Greco ceb317
 	unsigned long *res_flags;
Pablo Greco ceb317
 	struct irq_fwspec *fwspec;
Pablo Greco ceb317
+	bool skip_producer_check;
Pablo Greco ceb317
 };
Pablo Greco ceb317
 
Pablo Greco ceb317
 /**
Pablo Greco 0f1c57
@@ -211,7 +212,8 @@ static acpi_status acpi_irq_parse_one_cb(struct acpi_resource *ares,
Pablo Greco ceb317
 		return AE_CTRL_TERMINATE;
Pablo Greco ceb317
 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
Pablo Greco ceb317
 		eirq = &ares->data.extended_irq;
Pablo Greco ceb317
-		if (eirq->producer_consumer == ACPI_PRODUCER)
Pablo Greco ceb317
+		if (!ctx->skip_producer_check &&
Pablo Greco ceb317
+		    eirq->producer_consumer == ACPI_PRODUCER)
Pablo Greco ceb317
 			return AE_OK;
Pablo Greco ceb317
 		if (ctx->index >= eirq->interrupt_count) {
Pablo Greco ceb317
 			ctx->index -= eirq->interrupt_count;
Pablo Greco 0f1c57
@@ -247,8 +249,19 @@ static acpi_status acpi_irq_parse_one_cb(struct acpi_resource *ares,
Pablo Greco ceb317
 static int acpi_irq_parse_one(acpi_handle handle, unsigned int index,
Pablo Greco ceb317
 			      struct irq_fwspec *fwspec, unsigned long *flags)
Pablo Greco ceb317
 {
Pablo Greco ceb317
-	struct acpi_irq_parse_one_ctx ctx = { -EINVAL, index, flags, fwspec };
Pablo Greco ceb317
+	struct acpi_irq_parse_one_ctx ctx = { -EINVAL, index, flags, fwspec, false };
Pablo Greco ceb317
 
Pablo Greco ceb317
+	/*
Pablo Greco ceb317
+	 * Firmware on arm64-based HPE m400 platform incorrectly marks
Pablo Greco ceb317
+	 * its UART interrupt as ACPI_PRODUCER rather than ACPI_CONSUMER.
Pablo Greco ceb317
+	 * Don't do the producer/consumer check for that device.
Pablo Greco ceb317
+	 */
Pablo Greco ceb317
+	if (IS_ENABLED(CONFIG_ARM64)) {
Pablo Greco ceb317
+		struct acpi_device *adev = acpi_bus_get_acpi_device(handle);
Pablo Greco ceb317
+
Pablo Greco ceb317
+		if (adev && !strcmp(acpi_device_hid(adev), "APMC0D08"))
Pablo Greco ceb317
+			ctx.skip_producer_check = true;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
 	acpi_walk_resources(handle, METHOD_NAME__CRS, acpi_irq_parse_one_cb, &ctx;;
Pablo Greco ceb317
 	return ctx.rc;
Pablo Greco ceb317
 }
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Date: Thu, 10 May 2018 17:38:44 -0400
Pablo Greco 0f1c57
Subject: [PATCH 03/34] aarch64: acpi scan: Fix regression related to X-Gene
Pablo Greco ceb317
 UARTs
Pablo Greco ceb317
Pablo Greco ceb317
Message-id: <20180510173844.29580-4-msalter@redhat.com>
Pablo Greco ceb317
Patchwork-id: 214381
Pablo Greco ceb317
O-Subject: [RHEL-8 BZ1519554 3/3] aarch64: acpi scan: Fix regression related to X-Gene UARTs
Pablo Greco ceb317
Bugzilla: 1519554
Pablo Greco ceb317
RH-Acked-by: Al Stone <astone@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Tony Camuso <tcamuso@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1519554
Pablo Greco ceb317
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=16144520
Pablo Greco ceb317
Pablo Greco ceb317
Commit e361d1f85855 ("ACPI / scan: Fix enumeration for special UART
Pablo Greco ceb317
devices") caused a regression with some X-Gene based platforms (Mustang
Pablo Greco ceb317
and M400) with invalid DSDT. The DSDT makes it appear that the UART
Pablo Greco ceb317
device is also a slave device attached to itself. With the above commit
Pablo Greco ceb317
the UART won't be enumerated by ACPI scan (slave serial devices shouldn't
Pablo Greco ceb317
be). So check for X-Gene UART device and skip slace device check on it.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/acpi/scan.c | 9 +++++++++
Pablo Greco ceb317
 1 file changed, 9 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
Pablo Greco 0f1c57
index dbfa58e799e2..69654a728e07 100644
Pablo Greco ceb317
--- a/drivers/acpi/scan.c
Pablo Greco ceb317
+++ b/drivers/acpi/scan.c
Pablo Greco 0f1c57
@@ -1746,6 +1746,15 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
Pablo Greco 08fca0
 	if (!acpi_match_device_ids(device, ignore_serial_bus_ids))
Pablo Greco ceb317
 		return false;
Pablo Greco ceb317
 
Pablo Greco ceb317
+	/*
Pablo Greco ceb317
+	 * Firmware on some arm64 X-Gene platforms will make the UART
Pablo Greco ceb317
+	 * device appear as both a UART and a slave of that UART. Just
Pablo Greco ceb317
+	 * bail out here for X-Gene UARTs.
Pablo Greco ceb317
+	 */
Pablo Greco ceb317
+	if (IS_ENABLED(CONFIG_ARM64) &&
Pablo Greco ceb317
+	    !strcmp(acpi_device_hid(device), "APMC0D08"))
Pablo Greco ceb317
+		return false;
Pablo Greco ceb317
+
Pablo Greco ceb317
 	INIT_LIST_HEAD(&resource_list);
Pablo Greco ceb317
 	acpi_dev_get_resources(device, &resource_list,
Pablo Greco ceb317
 			       acpi_check_serial_bus_slave,
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Robert Richter <rrichter@redhat.com>
Pablo Greco ceb317
Date: Thu, 7 Jun 2018 22:59:32 -0400
Pablo Greco 0f1c57
Subject: [PATCH 04/34] Vulcan: AHCI PCI bar fix for Broadcom Vulcan early
Pablo Greco ceb317
 silicon
Pablo Greco ceb317
Pablo Greco ceb317
Message-id: <1528412373-19128-2-git-send-email-rrichter@redhat.com>
Pablo Greco ceb317
Patchwork-id: 220950
Pablo Greco ceb317
O-Subject: [RHEL-8.0 BZ 1563590 v2 1/2] PCI: Vulcan: AHCI PCI bar fix for Broadcom Vulcan early silicon
Pablo Greco ceb317
Bugzilla: 1563590
Pablo Greco ceb317
RH-Acked-by: Dean Nelson <dnelson@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Mark Langsdorf <mlangsdo@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
From: Ashok Kumar Sekar <asekar@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
PCI BAR 5 is not setup correctly for the on-board AHCI
Pablo Greco ceb317
controller on Broadcom's Vulcan processor. Added a quirk to fix BAR 5
Pablo Greco ceb317
by using BAR 4's resources which are populated correctly but NOT used
Pablo Greco ceb317
by the AHCI controller actually.
Pablo Greco ceb317
Pablo Greco ceb317
RHEL-only:
Pablo Greco ceb317
Pablo Greco ceb317
Both patches are in RHEL-7.6 also. Inclusion of the patches into RHEL-8
Pablo Greco ceb317
was discussed. Since there are partners with Ax system configurations it
Pablo Greco ceb317
was decided to carry them in RHEL8 too. See:
Pablo Greco ceb317
Pablo Greco ceb317
 https://bugzilla.redhat.com/show_bug.cgi?id=1563590#c1
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Ashok Kumar Sekar <asekar@redhat.com>
Pablo Greco ceb317
Signed-off-by: Jayachandran C <jchandra@broadcom.com>
Pablo Greco ceb317
Signed-off-by: Robert Richter <rrichter@redhat.com>
Pablo Greco ceb317
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/pci/quirks.c | 24 ++++++++++++++++++++++++
Pablo Greco ceb317
 1 file changed, 24 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
Pablo Greco 0f1c57
index 494fa46f5767..27bc8dd45ad8 100644
Pablo Greco ceb317
--- a/drivers/pci/quirks.c
Pablo Greco ceb317
+++ b/drivers/pci/quirks.c
Pablo Greco 0f1c57
@@ -4296,6 +4296,30 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, 0x9000,
Pablo Greco ceb317
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, 0x9084,
Pablo Greco ceb317
 				quirk_bridge_cavm_thrx2_pcie_root);
Pablo Greco ceb317
 
Pablo Greco ceb317
+/*
Pablo Greco ceb317
+ * PCI BAR 5 is not setup correctly for the on-board AHCI controller
Pablo Greco ceb317
+ * on Broadcom's Vulcan processor. Added a quirk to fix BAR 5 by
Pablo Greco ceb317
+ * using BAR 4's resources which are populated correctly and NOT
Pablo Greco ceb317
+ * actually used by the AHCI controller.
Pablo Greco ceb317
+ */
Pablo Greco ceb317
+static void quirk_fix_vulcan_ahci_bars(struct pci_dev *dev)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	struct resource *r =  &dev->resource[4];
Pablo Greco ceb317
+
Pablo Greco ceb317
+	if (!(r->flags & IORESOURCE_MEM) || (r->start == 0))
Pablo Greco ceb317
+		return;
Pablo Greco ceb317
+
Pablo Greco ceb317
+	/* Set BAR5 resource to BAR4 */
Pablo Greco ceb317
+	dev->resource[5] = *r;
Pablo Greco ceb317
+
Pablo Greco ceb317
+	/* Update BAR5 in pci config space */
Pablo Greco ceb317
+	pci_write_config_dword(dev, PCI_BASE_ADDRESS_5, r->start);
Pablo Greco ceb317
+
Pablo Greco ceb317
+	/* Clear BAR4's resource */
Pablo Greco ceb317
+	memset(r, 0, sizeof(*r));
Pablo Greco ceb317
+}
Pablo Greco ceb317
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, 0x9027, quirk_fix_vulcan_ahci_bars);
Pablo Greco ceb317
+
Pablo Greco ceb317
 /*
Pablo Greco ceb317
  * Intersil/Techwell TW686[4589]-based video capture cards have an empty (zero)
Pablo Greco ceb317
  * class code.  Fix it.
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Robert Richter <rrichter@redhat.com>
Pablo Greco ceb317
Date: Thu, 7 Jun 2018 22:59:33 -0400
Pablo Greco 0f1c57
Subject: [PATCH 05/34] ahci: thunderx2: Fix for errata that affects stop
Pablo Greco ceb317
 engine
Pablo Greco ceb317
Pablo Greco ceb317
Message-id: <1528412373-19128-3-git-send-email-rrichter@redhat.com>
Pablo Greco ceb317
Patchwork-id: 220952
Pablo Greco ceb317
O-Subject: [RHEL-8.0 BZ 1563590 v2 2/2] ahci: thunderx2: Fix for errata that affects stop engine
Pablo Greco ceb317
Bugzilla: 1563590
Pablo Greco ceb317
RH-Acked-by: Dean Nelson <dnelson@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Mark Langsdorf <mlangsdo@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
From: Jayachandran C <jnair@caviumnetworks.com>
Pablo Greco ceb317
Pablo Greco ceb317
Apply workaround for this errata:
Pablo Greco ceb317
  Synopsis: Resetting PxCMD.ST may hang the SATA device
Pablo Greco ceb317
Pablo Greco ceb317
  Description: An internal ping-pong buffer state is not reset
Pablo Greco ceb317
  correctly for an PxCMD.ST=0 command for a SATA channel. This
Pablo Greco ceb317
  may cause the SATA interface to hang when a PxCMD.ST=0 command
Pablo Greco ceb317
  is received.
Pablo Greco ceb317
Pablo Greco ceb317
  Workaround: A SATA_BIU_CORE_ENABLE.sw_init_bsi must be asserted
Pablo Greco ceb317
  by the driver whenever the PxCMD.ST needs to be de-asserted. This
Pablo Greco ceb317
  will reset both the ports. So, it may not always work in a 2
Pablo Greco ceb317
  channel SATA system.
Pablo Greco ceb317
Pablo Greco ceb317
  Resolution: Fix in B0.
Pablo Greco ceb317
Pablo Greco ceb317
Add the code to ahci_stop_engine() to do this. It is not easy to
Pablo Greco ceb317
stop the other "port" since it is associated with a different AHCI
Pablo Greco ceb317
interface. Please note that with this fix, SATA reset does not
Pablo Greco ceb317
hang any more, but it can cause failures on the other interface
Pablo Greco ceb317
if that is in active use.
Pablo Greco ceb317
Pablo Greco ceb317
Unfortunately, we have nothing other the the CPU ID to check if the
Pablo Greco ceb317
SATA block has this issue.
Pablo Greco ceb317
Pablo Greco ceb317
RHEL-only:
Pablo Greco ceb317
Pablo Greco ceb317
Both patches are in RHEL-7.6 also. Inclusion of the patches into RHEL-8
Pablo Greco ceb317
was discussed. Since there are partners with Ax system configurations it
Pablo Greco ceb317
was decided to carry them in RHEL8 too. See:
Pablo Greco ceb317
Pablo Greco ceb317
 https://bugzilla.redhat.com/show_bug.cgi?id=1563590#c1
Pablo Greco ceb317
Pablo Greco ceb317
[v3 with new delays]
Pablo Greco ceb317
Signed-off-by: Jayachandran C <jnair@caviumnetworks.com>
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Robert Richter <rrichter@redhat.com>
Pablo Greco ceb317
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/ata/libahci.c | 18 ++++++++++++++++++
Pablo Greco ceb317
 1 file changed, 18 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
Pablo Greco 0f1c57
index 954386a2b500..8f49d54e838e 100644
Pablo Greco ceb317
--- a/drivers/ata/libahci.c
Pablo Greco ceb317
+++ b/drivers/ata/libahci.c
Pablo Greco 0f1c57
@@ -727,6 +727,24 @@ int ahci_stop_engine(struct ata_port *ap)
Pablo Greco ceb317
 	tmp &= ~PORT_CMD_START;
Pablo Greco ceb317
 	writel(tmp, port_mmio + PORT_CMD);
Pablo Greco ceb317
 
Pablo Greco ceb317
+#ifdef CONFIG_ARM64
Pablo Greco ceb317
+	/* Rev Ax of Cavium CN99XX needs a hack for port stop */
Pablo Greco ceb317
+	if (dev_is_pci(ap->host->dev) &&
Pablo Greco ceb317
+	    to_pci_dev(ap->host->dev)->vendor == 0x14e4 &&
Pablo Greco ceb317
+	    to_pci_dev(ap->host->dev)->device == 0x9027 &&
Pablo Greco ceb317
+	    midr_is_cpu_model_range(read_cpuid_id(),
Pablo Greco ceb317
+			MIDR_CPU_MODEL(ARM_CPU_IMP_BRCM, BRCM_CPU_PART_VULCAN),
Pablo Greco ceb317
+			MIDR_CPU_VAR_REV(0, 0),
Pablo Greco ceb317
+			MIDR_CPU_VAR_REV(0, MIDR_REVISION_MASK))) {
Pablo Greco ceb317
+		tmp = readl(hpriv->mmio + 0x8000);
Pablo Greco ceb317
+		udelay(100);
Pablo Greco ceb317
+		writel(tmp | (1 << 26), hpriv->mmio + 0x8000);
Pablo Greco ceb317
+		udelay(100);
Pablo Greco ceb317
+		writel(tmp & ~(1 << 26), hpriv->mmio + 0x8000);
Pablo Greco ceb317
+		dev_warn(ap->host->dev, "CN99XX SATA reset workaround applied\n");
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+
Pablo Greco ceb317
 	/* wait for engine to stop. This could be as long as 500 msec */
Pablo Greco ceb317
 	tmp = ata_wait_register(ap, port_mmio + PORT_CMD,
Pablo Greco ceb317
 				PORT_CMD_LIST_ON, PORT_CMD_LIST_ON, 1, 500);
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Laura Abbott <labbott@redhat.com>
Pablo Greco ceb317
Date: Sun, 10 Feb 2019 01:27:54 +0000
Pablo Greco 0f1c57
Subject: [PATCH 06/34] ipmi: do not configure ipmi for HPE m400
Pablo Greco ceb317
Pablo Greco ceb317
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1670017
Pablo Greco ceb317
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=20147017
Pablo Greco ceb317
Pablo Greco ceb317
Commit 913a89f009d9 ("ipmi: Don't initialize anything in the core until
Pablo Greco ceb317
something uses it") added new locking which broke context.
Pablo Greco ceb317
Pablo Greco ceb317
    Message-id: <20180713142210.15700-1-tcamuso@redhat.com>
Pablo Greco ceb317
    Patchwork-id: 224899
Pablo Greco ceb317
    O-Subject: [RHEL8 BZ 1583537 1/1] ipmi: do not configure ipmi for HPE m400
Pablo Greco ceb317
    Bugzilla: 1583537
Pablo Greco ceb317
    RH-Acked-by: Dean Nelson <dnelson@redhat.com>
Pablo Greco ceb317
    RH-Acked-by: Al Stone <ahs3@redhat.com>
Pablo Greco ceb317
    RH-Acked-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
    bugzilla:https://bugzilla.redhat.com/show_bug.cgi?id=1583537
Pablo Greco ceb317
    brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=17150528
Pablo Greco ceb317
Pablo Greco ceb317
    RHEL-only
Pablo Greco ceb317
Pablo Greco ceb317
    The ARM-based HPE m400 reports host-side ipmi as residing in intel
Pablo Greco ceb317
    port-io space, which does not exist in ARM processors. Therefore, when
Pablo Greco ceb317
    running on an m400, host-side ipmi configuration code must simply return
Pablo Greco ceb317
    zero without trying to configure the host-side ipmi.
Pablo Greco ceb317
Pablo Greco ceb317
    This patch prevents panic on boot by averting attempts to configure
Pablo Greco ceb317
    host-side ipmi on this platform.
Pablo Greco ceb317
Pablo Greco ceb317
    Though HPE m400 is not certified with RHEL, and HPE has relegated it to
Pablo Greco ceb317
    EOL status, the platform is still used extensively in ARM development
Pablo Greco ceb317
    and test for RHEL.
Pablo Greco ceb317
Pablo Greco ceb317
    Testing:
Pablo Greco ceb317
    Boot without blacklisting ipmi and check to see that no ipmi modules
Pablo Greco ceb317
    are loaded.
Pablo Greco ceb317
Pablo Greco ceb317
    Signed-off-by: Tony Camuso <tcamuso@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
    cc: Prarit Bhargava <prarit@redhat.com>
Pablo Greco ceb317
    cc: Brendan Conoboy <blc@redhat.com>
Pablo Greco ceb317
    cc: Jeff Bastian <jbastian@redhat.com>
Pablo Greco ceb317
    cc: Scott Herold <sherold@redhat.com>
Pablo Greco ceb317
    Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Laura Abbott <labbott@redhat.com>
Pablo Greco ceb317
Acked-by: Tony Camuso <tcamuso@redhat.com>
Pablo Greco ceb317
Acked-by: Dean Nelson <dnelson@redhat.com>
Pablo Greco ceb317
Acked-by: Jarod Wilson <jarod@redhat.com>
Pablo Greco ceb317
Acked-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/char/ipmi/ipmi_dmi.c        | 15 +++++++++++++++
Pablo Greco ceb317
 drivers/char/ipmi/ipmi_msghandler.c | 16 +++++++++++++++-
Pablo Greco ceb317
 2 files changed, 30 insertions(+), 1 deletion(-)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/char/ipmi/ipmi_dmi.c b/drivers/char/ipmi/ipmi_dmi.c
Pablo Greco ceb317
index bbf7029e224b..cf7faa970dd6 100644
Pablo Greco ceb317
--- a/drivers/char/ipmi/ipmi_dmi.c
Pablo Greco ceb317
+++ b/drivers/char/ipmi/ipmi_dmi.c
Pablo Greco ceb317
@@ -215,6 +215,21 @@ static int __init scan_for_dmi_ipmi(void)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	const struct dmi_device *dev = NULL;
Pablo Greco ceb317
 
Pablo Greco ceb317
+#ifdef CONFIG_ARM64
Pablo Greco ceb317
+	/* RHEL-only
Pablo Greco ceb317
+	 * If this is ARM-based HPE m400, return now, because that platform
Pablo Greco ceb317
+	 * reports the host-side ipmi address as intel port-io space, which
Pablo Greco ceb317
+	 * does not exist in the ARM architecture.
Pablo Greco ceb317
+	 */
Pablo Greco ceb317
+	const char *dmistr = dmi_get_system_info(DMI_PRODUCT_NAME);
Pablo Greco ceb317
+
Pablo Greco ceb317
+	if (dmistr && (strcmp("ProLiant m400 Server", dmistr) == 0)) {
Pablo Greco ceb317
+		pr_debug("%s does not support host ipmi\n", dmistr);
Pablo Greco ceb317
+		return 0;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+	/* END RHEL-only */
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+
Pablo Greco ceb317
 	while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev)))
Pablo Greco ceb317
 		dmi_decode_ipmi((const struct dmi_header *) dev->device_data);
Pablo Greco ceb317
 
Pablo Greco ceb317
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
Pablo Greco 0f1c57
index 5d403fb5bd92..385747b5361f 100644
Pablo Greco ceb317
--- a/drivers/char/ipmi/ipmi_msghandler.c
Pablo Greco ceb317
+++ b/drivers/char/ipmi/ipmi_msghandler.c
Pablo Greco ceb317
@@ -35,6 +35,7 @@
Pablo Greco ceb317
 #include <linux/uuid.h>
Pablo Greco ceb317
 #include <linux/nospec.h>
Pablo Greco ceb317
 #include <linux/vmalloc.h>
Pablo Greco ceb317
+#include <linux/dmi.h>
Pablo Greco ceb317
 #include <linux/delay.h>
Pablo Greco ceb317
 
Pablo Greco ceb317
 #define IPMI_DRIVER_VERSION "39.2"
Pablo Greco 0f1c57
@@ -5516,8 +5517,21 @@ static int __init ipmi_init_msghandler_mod(void)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	int rv;
Pablo Greco ceb317
 
Pablo Greco ceb317
-	pr_info("version " IPMI_DRIVER_VERSION "\n");
Pablo Greco ceb317
+#ifdef CONFIG_ARM64
Pablo Greco ceb317
+	/* RHEL-only
Pablo Greco ceb317
+	 * If this is ARM-based HPE m400, return now, because that platform
Pablo Greco ceb317
+	 * reports the host-side ipmi address as intel port-io space, which
Pablo Greco ceb317
+	 * does not exist in the ARM architecture.
Pablo Greco ceb317
+	 */
Pablo Greco ceb317
+	const char *dmistr = dmi_get_system_info(DMI_PRODUCT_NAME);
Pablo Greco ceb317
 
Pablo Greco ceb317
+	if (dmistr && (strcmp("ProLiant m400 Server", dmistr) == 0)) {
Pablo Greco ceb317
+		pr_debug("%s does not support host ipmi\n", dmistr);
Pablo Greco ceb317
+		return -ENOSYS;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+	/* END RHEL-only */
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+	pr_info("version " IPMI_DRIVER_VERSION "\n");
Pablo Greco ceb317
 	mutex_lock(&ipmi_interfaces_mutex);
Pablo Greco ceb317
 	rv = ipmi_register_driver();
Pablo Greco ceb317
 	mutex_unlock(&ipmi_interfaces_mutex);
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Laura Abbott <labbott@redhat.com>
Pablo Greco ceb317
Date: Mon, 20 May 2019 22:21:02 -0400
Pablo Greco 0f1c57
Subject: [PATCH 07/34] iommu/arm-smmu: workaround DMA mode issues
Pablo Greco ceb317
Pablo Greco ceb317
Message-id: <20190520222102.19488-1-labbott@redhat.com>
Pablo Greco ceb317
Patchwork-id: 259215
Pablo Greco ceb317
O-Subject: [ARK INTERNAL PATCH] iommu/arm-smmu: workaround DMA mode issues
Pablo Greco ceb317
Bugzilla:
Pablo Greco ceb317
RH-Acked-by: Mark Langsdorf <mlangsdo@redhat.com>
Pablo Greco ceb317
RH-Acked-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
From: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
Rebased for v5.2-rc1
Pablo Greco ceb317
Pablo Greco ceb317
	Bugzilla: 1652259
Pablo Greco ceb317
	Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=19244562
Pablo Greco ceb317
	Upstream status: RHEL only.
Pablo Greco ceb317
Pablo Greco ceb317
	rhel8 commit 65feb1ed0ec9a088a63a90d46c0f7563ac96ad0f
Pablo Greco ceb317
	Author: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
	Date:   Wed Nov 21 17:15:59 2018 +0100
Pablo Greco ceb317
Pablo Greco ceb317
	    [iommu] iommu/arm-smmu: workaround DMA mode issues
Pablo Greco ceb317
Pablo Greco ceb317
	    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1624077
Pablo Greco ceb317
	    Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=18112820
Pablo Greco ceb317
	    Testing: Verified iommu.passthrough=1 no longer needed on gigabyte platforms.
Pablo Greco ceb317
	    Upstream Status: RHEL-only
Pablo Greco ceb317
Pablo Greco ceb317
	    In RHEL_ALT 7.5 we carried a RHEL-only patch which forced the arm smmuv2
Pablo Greco ceb317
	    into bypass mode due to performance issues on CN88xx. This was intended
Pablo Greco ceb317
	    to be a temporary hack until the issues were resolved. Another vendor
Pablo Greco ceb317
	    had issues with the iommu in bypass mode so we reverted the RHEL-only
Pablo Greco ceb317
	    patch so that iommu is in DMA mode by default (upstream default).
Pablo Greco ceb317
Pablo Greco ceb317
	    It turns on that there are remaining SMMU DMA mode issues on Gigabyte
Pablo Greco ceb317
	    platformws with CN88xx cpus. The problem manifests itself by pcie
Pablo Greco ceb317
	    card drivers failing to initialize the cards when SMMU is in DMA mode.
Pablo Greco ceb317
	    The root cause has not been determined yet, but looks likely to be
Pablo Greco ceb317
	    a hw or firmware issue. This patch forces bypass mode for Gigabyte
Pablo Greco ceb317
	    platforms. CN88xx isn't officially supported in RHEL but we have a
Pablo Greco ceb317
	    lot of them being used internally for testing, so I think we want
Pablo Greco ceb317
	    this to support that use case in RHEL8.
Pablo Greco ceb317
Pablo Greco ceb317
	    Signed-off-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
	    Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
	Acked-by: Mark Salter <msalter@redhat.com>
Pablo Greco ceb317
	Acked-by: Donald Dutile <ddutile@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Laura Abbott <labbott@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/iommu/iommu.c | 22 ++++++++++++++++++++++
Pablo Greco ceb317
 1 file changed, 22 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
Pablo Greco 0f1c57
index bfb2f163c691..3e02f19e8975 100644
Pablo Greco ceb317
--- a/drivers/iommu/iommu.c
Pablo Greco ceb317
+++ b/drivers/iommu/iommu.c
Pablo Greco 0f1c57
@@ -8,6 +8,7 @@
Pablo Greco ceb317
 
Pablo Greco 0f1c57
 #include <linux/amba/bus.h>
Pablo Greco ceb317
 #include <linux/device.h>
Pablo Greco ceb317
+#include <linux/dmi.h>
Pablo Greco ceb317
 #include <linux/kernel.h>
Pablo Greco ceb317
 #include <linux/bits.h>
Pablo Greco 0f1c57
 #include <linux/bug.h>
Pablo Greco 0f1c57
@@ -2852,6 +2853,27 @@ u32 iommu_sva_get_pasid(struct iommu_sva *handle)
Pablo Greco ceb317
 }
Pablo Greco ceb317
 EXPORT_SYMBOL_GPL(iommu_sva_get_pasid);
Pablo Greco ceb317
 
Pablo Greco ceb317
+#ifdef CONFIG_ARM64
Pablo Greco ceb317
+static int __init iommu_quirks(void)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	const char *vendor, *name;
Pablo Greco ceb317
+
Pablo Greco ceb317
+	vendor = dmi_get_system_info(DMI_SYS_VENDOR);
Pablo Greco ceb317
+	name = dmi_get_system_info(DMI_PRODUCT_NAME);
Pablo Greco ceb317
+
Pablo Greco ceb317
+	if (vendor &&
Pablo Greco ceb317
+	    (strncmp(vendor, "GIGABYTE", 8) == 0 && name &&
Pablo Greco ceb317
+	     (strncmp(name, "R120", 4) == 0 ||
Pablo Greco ceb317
+	      strncmp(name, "R270", 4) == 0))) {
Pablo Greco ceb317
+		pr_warn("Gigabyte %s detected, force iommu passthrough mode", name);
Pablo Greco ceb317
+		iommu_def_domain_type = IOMMU_DOMAIN_IDENTITY;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+
Pablo Greco ceb317
+	return 0;
Pablo Greco ceb317
+}
Pablo Greco ceb317
+arch_initcall(iommu_quirks);
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+
Pablo Greco ceb317
 /*
Pablo Greco ceb317
  * Changes the default domain of an iommu group that has *only* one device
Pablo Greco ceb317
  *
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
Date: Tue, 1 Oct 2019 15:51:23 +0000
Pablo Greco 0f1c57
Subject: [PATCH 08/34] arm: aarch64: Drop the EXPERT setting from
Pablo Greco ceb317
 ARM64_FORCE_52BIT
Pablo Greco ceb317
Pablo Greco ceb317
Message-id: <20191001181256.22935-1-jcline@redhat.com>
Pablo Greco ceb317
Patchwork-id: 275498
Pablo Greco ceb317
O-Subject: [ARK INTERNAL PATCH] [ARK INTERNAL PATCH] [redhat] Add patch
Pablo Greco ceb317
    to drop the EXPERT setting from ARM64_FORCE_52BIT
Pablo Greco ceb317
Bugzilla:
Pablo Greco ceb317
RH-Acked-by: Laura Abbott <labbott@redhat.com>
Pablo Greco ceb317
Pablo Greco ceb317
We don't turn on EXPERT as there are few settings we actually want to
Pablo Greco ceb317
mess with. Remove the dependency for ARM64_FORCE_52BIT as we do want
Pablo Greco ceb317
that on in debug builds to help find 52-bit bugs.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 arch/arm64/Kconfig | 2 +-
Pablo Greco ceb317
 1 file changed, 1 insertion(+), 1 deletion(-)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
Pablo Greco 0f1c57
index 43ff7c7a3ac9..efb74e176dec 100644
Pablo Greco ceb317
--- a/arch/arm64/Kconfig
Pablo Greco ceb317
+++ b/arch/arm64/Kconfig
Pablo Greco 0f1c57
@@ -1211,7 +1211,7 @@ endchoice
Pablo Greco ceb317
 
Pablo Greco ceb317
 config ARM64_FORCE_52BIT
Pablo Greco ceb317
 	bool "Force 52-bit virtual addresses for userspace"
Pablo Greco ceb317
-	depends on ARM64_VA_BITS_52 && EXPERT
Pablo Greco ceb317
+	depends on ARM64_VA_BITS_52
Pablo Greco ceb317
 	help
Pablo Greco ceb317
 	  For systems with 52-bit userspace VAs enabled, the kernel will attempt
Pablo Greco ceb317
 	  to maintain compatibility with older software by providing 48-bit VAs
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Peter Jones <pjones@redhat.com>
Pablo Greco ceb317
Date: Mon, 2 Oct 2017 18:22:13 -0400
Pablo Greco 0f1c57
Subject: [PATCH 09/34] Add efi_status_to_str() and rework efi_status_to_err().
Pablo Greco ceb317
Pablo Greco ceb317
This adds efi_status_to_str() for use when printing efi_status_t
Pablo Greco ceb317
messages, and reworks efi_status_to_err() so that the two use a common
Pablo Greco ceb317
list of errors.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Peter Jones <pjones@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/firmware/efi/efi.c | 124 +++++++++++++++++++++++++++----------
Pablo Greco ceb317
 include/linux/efi.h        |   3 +
Pablo Greco ceb317
 2 files changed, 96 insertions(+), 31 deletions(-)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
Pablo Greco 0f1c57
index b43e5e6ddaf6..3179641e9855 100644
Pablo Greco ceb317
--- a/drivers/firmware/efi/efi.c
Pablo Greco ceb317
+++ b/drivers/firmware/efi/efi.c
Pablo Greco 0f1c57
@@ -32,6 +32,7 @@
Pablo Greco ceb317
 #include <linux/ucs2_string.h>
Pablo Greco ceb317
 #include <linux/memblock.h>
Pablo Greco ceb317
 #include <linux/security.h>
Pablo Greco ceb317
+#include <linux/bsearch.h>
Pablo Greco ceb317
 
Pablo Greco ceb317
 #include <asm/early_ioremap.h>
Pablo Greco ceb317
 
Pablo Greco 0f1c57
@@ -884,40 +885,101 @@ int efi_mem_type(unsigned long phys_addr)
Pablo Greco ceb317
 }
Pablo Greco ceb317
 #endif
Pablo Greco ceb317
 
Pablo Greco ceb317
+struct efi_error_code {
Pablo Greco ceb317
+	efi_status_t status;
Pablo Greco ceb317
+	int errno;
Pablo Greco ceb317
+	const char *description;
Pablo Greco ceb317
+};
Pablo Greco ceb317
+
Pablo Greco ceb317
+static const struct efi_error_code efi_error_codes[] = {
Pablo Greco ceb317
+	{ EFI_SUCCESS, 0, "Success"},
Pablo Greco ceb317
+#if 0
Pablo Greco ceb317
+	{ EFI_LOAD_ERROR, -EPICK_AN_ERRNO, "Load Error"},
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+	{ EFI_INVALID_PARAMETER, -EINVAL, "Invalid Parameter"},
Pablo Greco ceb317
+	{ EFI_UNSUPPORTED, -ENOSYS, "Unsupported"},
Pablo Greco ceb317
+	{ EFI_BAD_BUFFER_SIZE, -ENOSPC, "Bad Buffer Size"},
Pablo Greco ceb317
+	{ EFI_BUFFER_TOO_SMALL, -ENOSPC, "Buffer Too Small"},
Pablo Greco ceb317
+	{ EFI_NOT_READY, -EAGAIN, "Not Ready"},
Pablo Greco ceb317
+	{ EFI_DEVICE_ERROR, -EIO, "Device Error"},
Pablo Greco ceb317
+	{ EFI_WRITE_PROTECTED, -EROFS, "Write Protected"},
Pablo Greco ceb317
+	{ EFI_OUT_OF_RESOURCES, -ENOMEM, "Out of Resources"},
Pablo Greco ceb317
+#if 0
Pablo Greco ceb317
+	{ EFI_VOLUME_CORRUPTED, -EPICK_AN_ERRNO, "Volume Corrupt"},
Pablo Greco ceb317
+	{ EFI_VOLUME_FULL, -EPICK_AN_ERRNO, "Volume Full"},
Pablo Greco ceb317
+	{ EFI_NO_MEDIA, -EPICK_AN_ERRNO, "No Media"},
Pablo Greco ceb317
+	{ EFI_MEDIA_CHANGED, -EPICK_AN_ERRNO, "Media changed"},
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+	{ EFI_NOT_FOUND, -ENOENT, "Not Found"},
Pablo Greco ceb317
+#if 0
Pablo Greco ceb317
+	{ EFI_ACCESS_DENIED, -EPICK_AN_ERRNO, "Access Denied"},
Pablo Greco ceb317
+	{ EFI_NO_RESPONSE, -EPICK_AN_ERRNO, "No Response"},
Pablo Greco ceb317
+	{ EFI_NO_MAPPING, -EPICK_AN_ERRNO, "No mapping"},
Pablo Greco ceb317
+	{ EFI_TIMEOUT, -EPICK_AN_ERRNO, "Time out"},
Pablo Greco ceb317
+	{ EFI_NOT_STARTED, -EPICK_AN_ERRNO, "Not started"},
Pablo Greco ceb317
+	{ EFI_ALREADY_STARTED, -EPICK_AN_ERRNO, "Already started"},
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+	{ EFI_ABORTED, -EINTR, "Aborted"},
Pablo Greco ceb317
+#if 0
Pablo Greco ceb317
+	{ EFI_ICMP_ERROR, -EPICK_AN_ERRNO, "ICMP Error"},
Pablo Greco ceb317
+	{ EFI_TFTP_ERROR, -EPICK_AN_ERRNO, "TFTP Error"},
Pablo Greco ceb317
+	{ EFI_PROTOCOL_ERROR, -EPICK_AN_ERRNO, "Protocol Error"},
Pablo Greco ceb317
+	{ EFI_INCOMPATIBLE_VERSION, -EPICK_AN_ERRNO, "Incompatible Version"},
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+	{ EFI_SECURITY_VIOLATION, -EACCES, "Security Policy Violation"},
Pablo Greco ceb317
+#if 0
Pablo Greco ceb317
+	{ EFI_CRC_ERROR, -EPICK_AN_ERRNO, "CRC Error"},
Pablo Greco ceb317
+	{ EFI_END_OF_MEDIA, -EPICK_AN_ERRNO, "End of Media"},
Pablo Greco ceb317
+	{ EFI_END_OF_FILE, -EPICK_AN_ERRNO, "End of File"},
Pablo Greco ceb317
+	{ EFI_INVALID_LANGUAGE, -EPICK_AN_ERRNO, "Invalid Languages"},
Pablo Greco ceb317
+	{ EFI_COMPROMISED_DATA, -EPICK_AN_ERRNO, "Compromised Data"},
Pablo Greco ceb317
+
Pablo Greco ceb317
+	// warnings
Pablo Greco ceb317
+	{ EFI_WARN_UNKOWN_GLYPH, -EPICK_AN_ERRNO, "Warning Unknown Glyph"},
Pablo Greco ceb317
+	{ EFI_WARN_DELETE_FAILURE, -EPICK_AN_ERRNO, "Warning Delete Failure"},
Pablo Greco ceb317
+	{ EFI_WARN_WRITE_FAILURE, -EPICK_AN_ERRNO, "Warning Write Failure"},
Pablo Greco ceb317
+	{ EFI_WARN_BUFFER_TOO_SMALL, -EPICK_AN_ERRNO, "Warning Buffer Too Small"},
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+};
Pablo Greco ceb317
+
Pablo Greco ceb317
+static int
Pablo Greco ceb317
+efi_status_cmp_bsearch(const void *key, const void *item)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	u64 status = (u64)(uintptr_t)key;
Pablo Greco ceb317
+	struct efi_error_code *code = (struct efi_error_code *)item;
Pablo Greco ceb317
+
Pablo Greco ceb317
+	if (status < code->status)
Pablo Greco ceb317
+		return -1;
Pablo Greco ceb317
+	if (status > code->status)
Pablo Greco ceb317
+		return 1;
Pablo Greco ceb317
+	return 0;
Pablo Greco ceb317
+}
Pablo Greco ceb317
+
Pablo Greco ceb317
 int efi_status_to_err(efi_status_t status)
Pablo Greco ceb317
 {
Pablo Greco ceb317
-	int err;
Pablo Greco ceb317
-
Pablo Greco ceb317
-	switch (status) {
Pablo Greco ceb317
-	case EFI_SUCCESS:
Pablo Greco ceb317
-		err = 0;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	case EFI_INVALID_PARAMETER:
Pablo Greco ceb317
-		err = -EINVAL;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	case EFI_OUT_OF_RESOURCES:
Pablo Greco ceb317
-		err = -ENOSPC;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	case EFI_DEVICE_ERROR:
Pablo Greco ceb317
-		err = -EIO;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	case EFI_WRITE_PROTECTED:
Pablo Greco ceb317
-		err = -EROFS;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	case EFI_SECURITY_VIOLATION:
Pablo Greco ceb317
-		err = -EACCES;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	case EFI_NOT_FOUND:
Pablo Greco ceb317
-		err = -ENOENT;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	case EFI_ABORTED:
Pablo Greco ceb317
-		err = -EINTR;
Pablo Greco ceb317
-		break;
Pablo Greco ceb317
-	default:
Pablo Greco ceb317
-		err = -EINVAL;
Pablo Greco ceb317
-	}
Pablo Greco ceb317
+	struct efi_error_code *found;
Pablo Greco ceb317
+	size_t num = sizeof(efi_error_codes) / sizeof(struct efi_error_code);
Pablo Greco ceb317
 
Pablo Greco ceb317
-	return err;
Pablo Greco ceb317
+	found = bsearch((void *)(uintptr_t)status, efi_error_codes,
Pablo Greco ceb317
+			sizeof(struct efi_error_code), num,
Pablo Greco ceb317
+			efi_status_cmp_bsearch);
Pablo Greco ceb317
+	if (!found)
Pablo Greco ceb317
+		return -EINVAL;
Pablo Greco ceb317
+	return found->errno;
Pablo Greco ceb317
+}
Pablo Greco ceb317
+
Pablo Greco ceb317
+const char *
Pablo Greco ceb317
+efi_status_to_str(efi_status_t status)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	struct efi_error_code *found;
Pablo Greco ceb317
+	size_t num = sizeof(efi_error_codes) / sizeof(struct efi_error_code);
Pablo Greco ceb317
+
Pablo Greco ceb317
+	found = bsearch((void *)(uintptr_t)status, efi_error_codes,
Pablo Greco ceb317
+			sizeof(struct efi_error_code), num,
Pablo Greco ceb317
+			efi_status_cmp_bsearch);
Pablo Greco ceb317
+	if (!found)
Pablo Greco ceb317
+		return "Unknown error code";
Pablo Greco ceb317
+	return found->description;
Pablo Greco ceb317
 }
Pablo Greco 0f1c57
 EXPORT_SYMBOL_GPL(efi_status_to_err);
Pablo Greco ceb317
 
Pablo Greco ceb317
diff --git a/include/linux/efi.h b/include/linux/efi.h
Pablo Greco 0f1c57
index 4e1bfee9675d..69a3074a9fbc 100644
Pablo Greco ceb317
--- a/include/linux/efi.h
Pablo Greco ceb317
+++ b/include/linux/efi.h
Pablo Greco ceb317
@@ -43,6 +43,8 @@
Pablo Greco ceb317
 #define EFI_ABORTED		(21 | (1UL << (BITS_PER_LONG-1)))
Pablo Greco ceb317
 #define EFI_SECURITY_VIOLATION	(26 | (1UL << (BITS_PER_LONG-1)))
Pablo Greco ceb317
 
Pablo Greco ceb317
+#define EFI_IS_ERROR(x)		((x) & (1UL << (BITS_PER_LONG-1)))
Pablo Greco ceb317
+
Pablo Greco ceb317
 typedef unsigned long efi_status_t;
Pablo Greco ceb317
 typedef u8 efi_bool_t;
Pablo Greco ceb317
 typedef u16 efi_char16_t;		/* UNICODE character */
Pablo Greco 0f1c57
@@ -911,6 +913,7 @@ static inline void efi_find_mirror(void) {}
Pablo Greco ceb317
 #endif
Pablo Greco ceb317
 
Pablo Greco ceb317
 extern int efi_status_to_err(efi_status_t status);
Pablo Greco ceb317
+extern const char *efi_status_to_str(efi_status_t status);
Pablo Greco ceb317
 
Pablo Greco ceb317
 /*
Pablo Greco ceb317
  * Variable Attributes
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Peter Jones <pjones@redhat.com>
Pablo Greco ceb317
Date: Mon, 2 Oct 2017 18:18:30 -0400
Pablo Greco 0f1c57
Subject: [PATCH 10/34] Make get_cert_list() use efi_status_to_str() to print
Pablo Greco ceb317
 error messages.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Peter Jones <pjones@redhat.com>
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 security/integrity/platform_certs/load_uefi.c | 6 ++++--
Pablo Greco ceb317
 1 file changed, 4 insertions(+), 2 deletions(-)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/security/integrity/platform_certs/load_uefi.c b/security/integrity/platform_certs/load_uefi.c
Pablo Greco 0f1c57
index d1fdd113450a..182e8090cfe8 100644
Pablo Greco ceb317
--- a/security/integrity/platform_certs/load_uefi.c
Pablo Greco ceb317
+++ b/security/integrity/platform_certs/load_uefi.c
Pablo Greco 0f1c57
@@ -74,7 +74,8 @@ static __init void *get_cert_list(efi_char16_t *name, efi_guid_t *guid,
Pablo Greco ceb317
 		return NULL;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	if (*status != EFI_BUFFER_TOO_SMALL) {
Pablo Greco ceb317
-		pr_err("Couldn't get size: 0x%lx\n", *status);
Pablo Greco ceb317
+		pr_err("Couldn't get size: %s (0x%lx)\n",
Pablo Greco ceb317
+		       efi_status_to_str(*status), *status);
Pablo Greco ceb317
 		return NULL;
Pablo Greco ceb317
 	}
Pablo Greco ceb317
 
Pablo Greco 0f1c57
@@ -85,7 +86,8 @@ static __init void *get_cert_list(efi_char16_t *name, efi_guid_t *guid,
Pablo Greco ceb317
 	*status = efi.get_variable(name, guid, NULL, &lsize, db);
Pablo Greco ceb317
 	if (*status != EFI_SUCCESS) {
Pablo Greco ceb317
 		kfree(db);
Pablo Greco ceb317
-		pr_err("Error reading db var: 0x%lx\n", *status);
Pablo Greco ceb317
+		pr_err("Error reading db var: %s (0x%lx)\n",
Pablo Greco ceb317
+		       efi_status_to_str(*status), *status);
Pablo Greco ceb317
 		return NULL;
Pablo Greco ceb317
 	}
Pablo Greco ceb317
 
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
Date: Mon, 30 Sep 2019 21:22:47 +0000
Pablo Greco 0f1c57
Subject: [PATCH 11/34] security: lockdown: expose a hook to lock the kernel
Pablo Greco ceb317
 down
Pablo Greco ceb317
Pablo Greco ceb317
In order to automatically lock down kernels running on UEFI machines
Pablo Greco ceb317
booted in Secure Boot mode, expose the lock_kernel_down() hook.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 include/linux/lsm_hook_defs.h | 2 ++
Pablo Greco ceb317
 include/linux/lsm_hooks.h     | 6 ++++++
Pablo Greco ceb317
 include/linux/security.h      | 5 +++++
Pablo Greco ceb317
 security/lockdown/lockdown.c  | 1 +
Pablo Greco ceb317
 security/security.c           | 6 ++++++
Pablo Greco ceb317
 5 files changed, 20 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
Pablo Greco 0f1c57
index ec119da1d89b..3c27eb4fd460 100644
Pablo Greco ceb317
--- a/include/linux/lsm_hook_defs.h
Pablo Greco ceb317
+++ b/include/linux/lsm_hook_defs.h
Pablo Greco 0f1c57
@@ -396,6 +396,8 @@ LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free_security, struct bpf_prog_aux *aux)
Pablo Greco ceb317
 #endif /* CONFIG_BPF_SYSCALL */
Pablo Greco ceb317
 
Pablo Greco ceb317
 LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
Pablo Greco ceb317
+LSM_HOOK(int, 0, lock_kernel_down, const char *where, enum lockdown_reason level)
Pablo Greco ceb317
+
Pablo Greco ceb317
 
Pablo Greco ceb317
 #ifdef CONFIG_PERF_EVENTS
Pablo Greco ceb317
 LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
Pablo Greco ceb317
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
Pablo Greco 0f1c57
index 4ec80b96c22e..93495ac301f2 100644
Pablo Greco ceb317
--- a/include/linux/lsm_hooks.h
Pablo Greco ceb317
+++ b/include/linux/lsm_hooks.h
Pablo Greco 0f1c57
@@ -1561,6 +1561,12 @@
Pablo Greco ceb317
  *
Pablo Greco ceb317
  *     @what: kernel feature being accessed
Pablo Greco ceb317
  *
Pablo Greco ceb317
+ * @lock_kernel_down
Pablo Greco ceb317
+ * 	Put the kernel into lock-down mode.
Pablo Greco ceb317
+ *
Pablo Greco ceb317
+ * 	@where: Where the lock-down is originating from (e.g. command line option)
Pablo Greco ceb317
+ * 	@level: The lock-down level (can only increase)
Pablo Greco ceb317
+ *
Pablo Greco ceb317
  * Security hooks for perf events
Pablo Greco ceb317
  *
Pablo Greco ceb317
  * @perf_event_open:
Pablo Greco ceb317
diff --git a/include/linux/security.h b/include/linux/security.h
Pablo Greco 0f1c57
index ca1b7109c0db..b947cfbf04c2 100644
Pablo Greco ceb317
--- a/include/linux/security.h
Pablo Greco ceb317
+++ b/include/linux/security.h
Pablo Greco 0f1c57
@@ -478,6 +478,7 @@ int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
Pablo Greco ceb317
 int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
Pablo Greco ceb317
 int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
Pablo Greco ceb317
 int security_locked_down(enum lockdown_reason what);
Pablo Greco ceb317
+int security_lock_kernel_down(const char *where, enum lockdown_reason level);
Pablo Greco ceb317
 #else /* CONFIG_SECURITY */
Pablo Greco ceb317
 
Pablo Greco ceb317
 static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
Pablo Greco 0f1c57
@@ -1366,6 +1367,10 @@ static inline int security_locked_down(enum lockdown_reason what)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	return 0;
Pablo Greco ceb317
 }
Pablo Greco ceb317
+static inline int security_lock_kernel_down(const char *where, enum lockdown_reason level)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	return 0;
Pablo Greco ceb317
+}
Pablo Greco ceb317
 #endif	/* CONFIG_SECURITY */
Pablo Greco ceb317
 
Pablo Greco ceb317
 #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
Pablo Greco ceb317
diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c
Pablo Greco 0f1c57
index a79b985e917e..772a69bf43ec 100644
Pablo Greco ceb317
--- a/security/lockdown/lockdown.c
Pablo Greco ceb317
+++ b/security/lockdown/lockdown.c
Pablo Greco ceb317
@@ -73,6 +73,7 @@ static int lockdown_is_locked_down(enum lockdown_reason what)
Pablo Greco ceb317
 
Pablo Greco ceb317
 static struct security_hook_list lockdown_hooks[] __lsm_ro_after_init = {
Pablo Greco ceb317
 	LSM_HOOK_INIT(locked_down, lockdown_is_locked_down),
Pablo Greco ceb317
+	LSM_HOOK_INIT(lock_kernel_down, lock_kernel_down),
Pablo Greco ceb317
 };
Pablo Greco ceb317
 
Pablo Greco ceb317
 static int __init lockdown_lsm_init(void)
Pablo Greco ceb317
diff --git a/security/security.c b/security/security.c
Pablo Greco 0f1c57
index 75dc0947ee0c..e5be2f687c15 100644
Pablo Greco ceb317
--- a/security/security.c
Pablo Greco ceb317
+++ b/security/security.c
Pablo Greco 0f1c57
@@ -2631,6 +2631,12 @@ int security_locked_down(enum lockdown_reason what)
Pablo Greco ceb317
 }
Pablo Greco ceb317
 EXPORT_SYMBOL(security_locked_down);
Pablo Greco ceb317
 
Pablo Greco ceb317
+int security_lock_kernel_down(const char *where, enum lockdown_reason level)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	return call_int_hook(lock_kernel_down, 0, where, level);
Pablo Greco ceb317
+}
Pablo Greco ceb317
+EXPORT_SYMBOL(security_lock_kernel_down);
Pablo Greco ceb317
+
Pablo Greco ceb317
 #ifdef CONFIG_PERF_EVENTS
Pablo Greco ceb317
 int security_perf_event_open(struct perf_event_attr *attr, int type)
Pablo Greco ceb317
 {
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: David Howells <dhowells@redhat.com>
Pablo Greco ceb317
Date: Tue, 27 Feb 2018 10:04:55 +0000
Pablo Greco 0f1c57
Subject: [PATCH 12/34] efi: Add an EFI_SECURE_BOOT flag to indicate secure
Pablo Greco ceb317
 boot mode
Pablo Greco ceb317
Pablo Greco ceb317
UEFI machines can be booted in Secure Boot mode.  Add an EFI_SECURE_BOOT
Pablo Greco ceb317
flag that can be passed to efi_enabled() to find out whether secure boot is
Pablo Greco ceb317
enabled.
Pablo Greco ceb317
Pablo Greco ceb317
Move the switch-statement in x86's setup_arch() that inteprets the
Pablo Greco ceb317
secure_boot boot parameter to generic code and set the bit there.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Pablo Greco ceb317
Signed-off-by: David Howells <dhowells@redhat.com>
Pablo Greco ceb317
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Pablo Greco ceb317
cc: linux-efi@vger.kernel.org
Pablo Greco ceb317
[Rebased for context; efi_is_table_address was moved to arch/x86]
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 arch/x86/kernel/setup.c           | 14 +-----------
Pablo Greco ceb317
 drivers/firmware/efi/Makefile     |  1 +
Pablo Greco ceb317
 drivers/firmware/efi/secureboot.c | 38 +++++++++++++++++++++++++++++++
Pablo Greco ceb317
 include/linux/efi.h               | 19 ++++++++++------
Pablo Greco ceb317
 4 files changed, 52 insertions(+), 20 deletions(-)
Pablo Greco ceb317
 create mode 100644 drivers/firmware/efi/secureboot.c
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
Pablo Greco 0f1c57
index 892609cde4a2..50c2ab2156c7 100644
Pablo Greco ceb317
--- a/arch/x86/kernel/setup.c
Pablo Greco ceb317
+++ b/arch/x86/kernel/setup.c
Pablo Greco 0f1c57
@@ -1205,19 +1205,7 @@ void __init setup_arch(char **cmdline_p)
Pablo Greco ceb317
 	/* Allocate bigger log buffer */
Pablo Greco ceb317
 	setup_log_buf(1);
Pablo Greco ceb317
 
Pablo Greco ceb317
-	if (efi_enabled(EFI_BOOT)) {
Pablo Greco ceb317
-		switch (boot_params.secure_boot) {
Pablo Greco ceb317
-		case efi_secureboot_mode_disabled:
Pablo Greco ceb317
-			pr_info("Secure boot disabled\n");
Pablo Greco ceb317
-			break;
Pablo Greco ceb317
-		case efi_secureboot_mode_enabled:
Pablo Greco ceb317
-			pr_info("Secure boot enabled\n");
Pablo Greco ceb317
-			break;
Pablo Greco ceb317
-		default:
Pablo Greco ceb317
-			pr_info("Secure boot could not be determined\n");
Pablo Greco ceb317
-			break;
Pablo Greco ceb317
-		}
Pablo Greco ceb317
-	}
Pablo Greco ceb317
+	efi_set_secure_boot(boot_params.secure_boot);
Pablo Greco ceb317
 
Pablo Greco ceb317
 	reserve_initrd();
Pablo Greco ceb317
 
Pablo Greco ceb317
diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile
Pablo Greco 0f1c57
index 8d151e332584..bd29fe4ddbf3 100644
Pablo Greco ceb317
--- a/drivers/firmware/efi/Makefile
Pablo Greco ceb317
+++ b/drivers/firmware/efi/Makefile
Pablo Greco 0f1c57
@@ -27,6 +27,7 @@ obj-$(CONFIG_EFI_FAKE_MEMMAP)		+= fake_map.o
Pablo Greco ceb317
 obj-$(CONFIG_EFI_BOOTLOADER_CONTROL)	+= efibc.o
Pablo Greco ceb317
 obj-$(CONFIG_EFI_TEST)			+= test/
Pablo Greco ceb317
 obj-$(CONFIG_EFI_DEV_PATH_PARSER)	+= dev-path-parser.o
Pablo Greco ceb317
+obj-$(CONFIG_EFI)			+= secureboot.o
Pablo Greco ceb317
 obj-$(CONFIG_APPLE_PROPERTIES)		+= apple-properties.o
Pablo Greco ceb317
 obj-$(CONFIG_EFI_RCI2_TABLE)		+= rci2-table.o
Pablo Greco ceb317
 obj-$(CONFIG_EFI_EMBEDDED_FIRMWARE)	+= embedded-firmware.o
Pablo Greco ceb317
diff --git a/drivers/firmware/efi/secureboot.c b/drivers/firmware/efi/secureboot.c
Pablo Greco ceb317
new file mode 100644
Pablo Greco ceb317
index 000000000000..de0a3714a5d4
Pablo Greco ceb317
--- /dev/null
Pablo Greco ceb317
+++ b/drivers/firmware/efi/secureboot.c
Pablo Greco ceb317
@@ -0,0 +1,38 @@
Pablo Greco ceb317
+/* Core kernel secure boot support.
Pablo Greco ceb317
+ *
Pablo Greco ceb317
+ * Copyright (C) 2017 Red Hat, Inc. All Rights Reserved.
Pablo Greco ceb317
+ * Written by David Howells (dhowells@redhat.com)
Pablo Greco ceb317
+ *
Pablo Greco ceb317
+ * This program is free software; you can redistribute it and/or
Pablo Greco ceb317
+ * modify it under the terms of the GNU General Public Licence
Pablo Greco ceb317
+ * as published by the Free Software Foundation; either version
Pablo Greco ceb317
+ * 2 of the Licence, or (at your option) any later version.
Pablo Greco ceb317
+ */
Pablo Greco ceb317
+
Pablo Greco ceb317
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Pablo Greco ceb317
+
Pablo Greco ceb317
+#include <linux/efi.h>
Pablo Greco ceb317
+#include <linux/kernel.h>
Pablo Greco ceb317
+#include <linux/printk.h>
Pablo Greco ceb317
+
Pablo Greco ceb317
+/*
Pablo Greco ceb317
+ * Decide what to do when UEFI secure boot mode is enabled.
Pablo Greco ceb317
+ */
Pablo Greco ceb317
+void __init efi_set_secure_boot(enum efi_secureboot_mode mode)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	if (efi_enabled(EFI_BOOT)) {
Pablo Greco ceb317
+		switch (mode) {
Pablo Greco ceb317
+		case efi_secureboot_mode_disabled:
Pablo Greco ceb317
+			pr_info("Secure boot disabled\n");
Pablo Greco ceb317
+			break;
Pablo Greco ceb317
+		case efi_secureboot_mode_enabled:
Pablo Greco ceb317
+			set_bit(EFI_SECURE_BOOT, &efi.flags);
Pablo Greco ceb317
+			pr_info("Secure boot enabled\n");
Pablo Greco ceb317
+			break;
Pablo Greco ceb317
+		default:
Pablo Greco ceb317
+			pr_warn("Secure boot could not be determined (mode %u)\n",
Pablo Greco ceb317
+				   mode);
Pablo Greco ceb317
+			break;
Pablo Greco ceb317
+		}
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+}
Pablo Greco ceb317
diff --git a/include/linux/efi.h b/include/linux/efi.h
Pablo Greco 0f1c57
index 69a3074a9fbc..c9d330ff3614 100644
Pablo Greco ceb317
--- a/include/linux/efi.h
Pablo Greco ceb317
+++ b/include/linux/efi.h
Pablo Greco 0f1c57
@@ -867,6 +867,14 @@ extern int __init efi_setup_pcdp_console(char *);
Pablo Greco ceb317
 #define EFI_MEM_ATTR		10	/* Did firmware publish an EFI_MEMORY_ATTRIBUTES table? */
Pablo Greco ceb317
 #define EFI_MEM_NO_SOFT_RESERVE	11	/* Is the kernel configured to ignore soft reservations? */
Pablo Greco ceb317
 #define EFI_PRESERVE_BS_REGIONS	12	/* Are EFI boot-services memory segments available? */
Pablo Greco ceb317
+#define EFI_SECURE_BOOT		13	/* Are we in Secure Boot mode? */
Pablo Greco ceb317
+
Pablo Greco ceb317
+enum efi_secureboot_mode {
Pablo Greco ceb317
+	efi_secureboot_mode_unset,
Pablo Greco ceb317
+	efi_secureboot_mode_unknown,
Pablo Greco ceb317
+	efi_secureboot_mode_disabled,
Pablo Greco ceb317
+	efi_secureboot_mode_enabled,
Pablo Greco ceb317
+};
Pablo Greco ceb317
 
Pablo Greco ceb317
 #ifdef CONFIG_EFI
Pablo Greco ceb317
 /*
Pablo Greco 0f1c57
@@ -878,6 +886,8 @@ static inline bool efi_enabled(int feature)
Pablo Greco ceb317
 }
Pablo Greco ceb317
 extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
Pablo Greco ceb317
 
Pablo Greco ceb317
+extern void __init efi_set_secure_boot(enum efi_secureboot_mode mode);
Pablo Greco ceb317
+
Pablo Greco ceb317
 bool __pure __efi_soft_reserve_enabled(void);
Pablo Greco ceb317
 
Pablo Greco ceb317
 static inline bool __pure efi_soft_reserve_enabled(void)
Pablo Greco 0f1c57
@@ -899,6 +909,8 @@ static inline bool efi_enabled(int feature)
Pablo Greco ceb317
 static inline void
Pablo Greco ceb317
 efi_reboot(enum reboot_mode reboot_mode, const char *__unused) {}
Pablo Greco ceb317
 
Pablo Greco ceb317
+static inline void efi_set_secure_boot(enum efi_secureboot_mode mode) {}
Pablo Greco ceb317
+
Pablo Greco ceb317
 static inline bool efi_soft_reserve_enabled(void)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	return false;
Pablo Greco 0f1c57
@@ -1139,13 +1151,6 @@ static inline bool efi_runtime_disabled(void) { return true; }
Pablo Greco ceb317
 extern void efi_call_virt_check_flags(unsigned long flags, const char *call);
Pablo Greco ceb317
 extern unsigned long efi_call_virt_save_flags(void);
Pablo Greco ceb317
 
Pablo Greco ceb317
-enum efi_secureboot_mode {
Pablo Greco ceb317
-	efi_secureboot_mode_unset,
Pablo Greco ceb317
-	efi_secureboot_mode_unknown,
Pablo Greco ceb317
-	efi_secureboot_mode_disabled,
Pablo Greco ceb317
-	efi_secureboot_mode_enabled,
Pablo Greco ceb317
-};
Pablo Greco ceb317
-
Pablo Greco ceb317
 static inline
Pablo Greco ceb317
 enum efi_secureboot_mode efi_get_secureboot_mode(efi_get_variable_t *get_var)
Pablo Greco ceb317
 {
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: David Howells <dhowells@redhat.com>
Pablo Greco ceb317
Date: Mon, 30 Sep 2019 21:28:16 +0000
Pablo Greco 0f1c57
Subject: [PATCH 13/34] efi: Lock down the kernel if booted in secure boot mode
Pablo Greco ceb317
Pablo Greco ceb317
UEFI Secure Boot provides a mechanism for ensuring that the firmware
Pablo Greco ceb317
will only load signed bootloaders and kernels.  Certain use cases may
Pablo Greco ceb317
also require that all kernel modules also be signed.  Add a
Pablo Greco ceb317
configuration option that to lock down the kernel - which includes
Pablo Greco ceb317
requiring validly signed modules - if the kernel is secure-booted.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: David Howells <dhowells@redhat.com>
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 arch/x86/kernel/setup.c   |  8 ++++++++
Pablo Greco ceb317
 security/lockdown/Kconfig | 13 +++++++++++++
Pablo Greco ceb317
 2 files changed, 21 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
Pablo Greco 0f1c57
index 50c2ab2156c7..ad9aa11ba3a0 100644
Pablo Greco ceb317
--- a/arch/x86/kernel/setup.c
Pablo Greco ceb317
+++ b/arch/x86/kernel/setup.c
Pablo Greco 0f1c57
@@ -21,6 +21,7 @@
Pablo Greco ceb317
 #include <linux/root_dev.h>
Pablo Greco ceb317
 #include <linux/hugetlb.h>
Pablo Greco ceb317
 #include <linux/tboot.h>
Pablo Greco ceb317
+#include <linux/security.h>
Pablo Greco ceb317
 #include <linux/usb/xhci-dbgp.h>
Pablo Greco ceb317
 #include <linux/static_call.h>
Pablo Greco ceb317
 #include <linux/swiotlb.h>
Pablo Greco 0f1c57
@@ -1036,6 +1037,13 @@ void __init setup_arch(char **cmdline_p)
Pablo Greco ceb317
 	if (efi_enabled(EFI_BOOT))
Pablo Greco ceb317
 		efi_init();
Pablo Greco ceb317
 
Pablo Greco ceb317
+	efi_set_secure_boot(boot_params.secure_boot);
Pablo Greco ceb317
+
Pablo Greco ceb317
+#ifdef CONFIG_LOCK_DOWN_IN_EFI_SECURE_BOOT
Pablo Greco ceb317
+	if (efi_enabled(EFI_SECURE_BOOT))
Pablo Greco ceb317
+		security_lock_kernel_down("EFI Secure Boot mode", LOCKDOWN_INTEGRITY_MAX);
Pablo Greco ceb317
+#endif
Pablo Greco ceb317
+
Pablo Greco ceb317
 	dmi_setup();
Pablo Greco ceb317
 
Pablo Greco ceb317
 	/*
Pablo Greco ceb317
diff --git a/security/lockdown/Kconfig b/security/lockdown/Kconfig
Pablo Greco ceb317
index e84ddf484010..d0501353a4b9 100644
Pablo Greco ceb317
--- a/security/lockdown/Kconfig
Pablo Greco ceb317
+++ b/security/lockdown/Kconfig
Pablo Greco ceb317
@@ -16,6 +16,19 @@ config SECURITY_LOCKDOWN_LSM_EARLY
Pablo Greco ceb317
 	  subsystem is fully initialised. If enabled, lockdown will
Pablo Greco ceb317
 	  unconditionally be called before any other LSMs.
Pablo Greco ceb317
 
Pablo Greco ceb317
+config LOCK_DOWN_IN_EFI_SECURE_BOOT
Pablo Greco ceb317
+	bool "Lock down the kernel in EFI Secure Boot mode"
Pablo Greco ceb317
+	default n
Pablo Greco ceb317
+	depends on EFI && SECURITY_LOCKDOWN_LSM_EARLY
Pablo Greco ceb317
+	help
Pablo Greco ceb317
+	  UEFI Secure Boot provides a mechanism for ensuring that the firmware
Pablo Greco ceb317
+	  will only load signed bootloaders and kernels.  Secure boot mode may
Pablo Greco ceb317
+	  be determined from EFI variables provided by the system firmware if
Pablo Greco ceb317
+	  not indicated by the boot parameters.
Pablo Greco ceb317
+
Pablo Greco ceb317
+	  Enabling this option results in kernel lockdown being triggered if
Pablo Greco ceb317
+	  EFI Secure Boot is set.
Pablo Greco ceb317
+
Pablo Greco ceb317
 choice
Pablo Greco ceb317
 	prompt "Kernel default lockdown mode"
Pablo Greco ceb317
 	default LOCK_DOWN_KERNEL_FORCE_NONE
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
Date: Wed, 30 Oct 2019 14:37:49 +0000
Pablo Greco 0f1c57
Subject: [PATCH 14/34] s390: Lock down the kernel when the IPL secure flag is
Pablo Greco ceb317
 set
Pablo Greco ceb317
Pablo Greco ceb317
Automatically lock down the kernel to LOCKDOWN_CONFIDENTIALITY_MAX if
Pablo Greco ceb317
the IPL secure flag is set.
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Suggested-by: Philipp Rudo <prudo@redhat.com>
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 arch/s390/include/asm/ipl.h | 1 +
Pablo Greco ceb317
 arch/s390/kernel/ipl.c      | 5 +++++
Pablo Greco ceb317
 arch/s390/kernel/setup.c    | 4 ++++
Pablo Greco ceb317
 3 files changed, 10 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/arch/s390/include/asm/ipl.h b/arch/s390/include/asm/ipl.h
Pablo Greco 0f1c57
index a405b6bb89fb..50827b341fd7 100644
Pablo Greco ceb317
--- a/arch/s390/include/asm/ipl.h
Pablo Greco ceb317
+++ b/arch/s390/include/asm/ipl.h
Pablo Greco ceb317
@@ -128,6 +128,7 @@ int ipl_report_add_component(struct ipl_report *report, struct kexec_buf *kbuf,
Pablo Greco ceb317
 			     unsigned char flags, unsigned short cert);
Pablo Greco ceb317
 int ipl_report_add_certificate(struct ipl_report *report, void *key,
Pablo Greco ceb317
 			       unsigned long addr, unsigned long len);
Pablo Greco ceb317
+bool ipl_get_secureboot(void);
Pablo Greco ceb317
 
Pablo Greco ceb317
 /*
Pablo Greco ceb317
  * DIAG 308 support
Pablo Greco ceb317
diff --git a/arch/s390/kernel/ipl.c b/arch/s390/kernel/ipl.c
Pablo Greco 0f1c57
index 325cbf69ebbd..1801af7a6ec4 100644
Pablo Greco ceb317
--- a/arch/s390/kernel/ipl.c
Pablo Greco ceb317
+++ b/arch/s390/kernel/ipl.c
Pablo Greco 0f1c57
@@ -2221,3 +2221,8 @@ int ipl_report_free(struct ipl_report *report)
Pablo Greco ceb317
 }
Pablo Greco ceb317
 
Pablo Greco ceb317
 #endif
Pablo Greco ceb317
+
Pablo Greco ceb317
+bool ipl_get_secureboot(void)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	return !!ipl_secure_flag;
Pablo Greco ceb317
+}
Pablo Greco ceb317
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
Pablo Greco 0f1c57
index 2ec5f1e0312f..e67ca614e4a4 100644
Pablo Greco ceb317
--- a/arch/s390/kernel/setup.c
Pablo Greco ceb317
+++ b/arch/s390/kernel/setup.c
Pablo Greco ceb317
@@ -49,6 +49,7 @@
Pablo Greco ceb317
 #include <linux/memory.h>
Pablo Greco ceb317
 #include <linux/compat.h>
Pablo Greco ceb317
 #include <linux/start_kernel.h>
Pablo Greco ceb317
+#include <linux/security.h>
Pablo Greco ceb317
 #include <linux/hugetlb.h>
Pablo Greco ceb317
 #include <linux/kmemleak.h>
Pablo Greco ceb317
 
Pablo Greco 0f1c57
@@ -979,6 +980,9 @@ void __init setup_arch(char **cmdline_p)
Pablo Greco ceb317
 
Pablo Greco ceb317
 	log_component_list();
Pablo Greco ceb317
 
Pablo Greco ceb317
+	if (ipl_get_secureboot())
Pablo Greco ceb317
+		security_lock_kernel_down("Secure IPL mode", LOCKDOWN_INTEGRITY_MAX);
Pablo Greco ceb317
+
Pablo Greco ceb317
 	/* Have one command line that is parsed and saved in /proc/cmdline */
Pablo Greco ceb317
 	/* boot_command_line has been already set up in early.c */
Pablo Greco ceb317
 	*cmdline_p = boot_command_line;
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Peter Robinson <pbrobinson@gmail.com>
Pablo Greco ceb317
Date: Wed, 26 Feb 2020 13:38:40 -0500
Pablo Greco 0f1c57
Subject: [PATCH 15/34] Add option of 13 for FORCE_MAX_ZONEORDER
Pablo Greco ceb317
Pablo Greco ceb317
This is a hack, but it's what the other distros currently use
Pablo Greco ceb317
for aarch64 with 4K pages so we'll do the same while upstream
Pablo Greco ceb317
decides what the best outcome is (which isn't this).
Pablo Greco ceb317
Pablo Greco ceb317
Upstream Status: RHEL only
Pablo Greco ceb317
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Pablo Greco ceb317
[Add a dependency on RHEL_DIFFERENCES]
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 arch/arm64/Kconfig | 1 +
Pablo Greco ceb317
 1 file changed, 1 insertion(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
Pablo Greco 0f1c57
index efb74e176dec..1412a53688e9 100644
Pablo Greco ceb317
--- a/arch/arm64/Kconfig
Pablo Greco ceb317
+++ b/arch/arm64/Kconfig
Pablo Greco 0f1c57
@@ -1450,6 +1450,7 @@ config XEN
Pablo Greco 0f1c57
 config ARCH_FORCE_MAX_ORDER
Pablo Greco ceb317
 	int
Pablo Greco ceb317
 	default "14" if ARM64_64K_PAGES
Pablo Greco ceb317
+	default "13" if (ARCH_THUNDER && !ARM64_64K_PAGES && !RHEL_DIFFERENCES)
Pablo Greco ceb317
 	default "12" if ARM64_16K_PAGES
Pablo Greco ceb317
 	default "11"
Pablo Greco ceb317
 	help
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco 89a396
Pablo Greco 89a396
Pablo Greco 89a396
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Jon Masters <jcm@redhat.com>
Pablo Greco ceb317
Date: Thu, 18 Jul 2019 15:47:26 -0400
Pablo Greco 0f1c57
Subject: [PATCH 16/34] arm: make CONFIG_HIGHPTE optional without CONFIG_EXPERT
Pablo Greco ceb317
Pablo Greco ceb317
We will use this to force CONFIG_HIGHPTE off on LPAE for now
Pablo Greco ceb317
Pablo Greco ceb317
Signed-off-by: Jon Masters <jcm@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 arch/arm/Kconfig | 4 ++--
Pablo Greco ceb317
 1 file changed, 2 insertions(+), 2 deletions(-)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
Pablo Greco 0f1c57
index a08c9d092a33..1d82f6e9ecbd 100644
Pablo Greco ceb317
--- a/arch/arm/Kconfig
Pablo Greco ceb317
+++ b/arch/arm/Kconfig
Pablo Greco 0f1c57
@@ -1315,9 +1315,9 @@ config HIGHMEM
Pablo Greco ceb317
 	  If unsure, say n.
Pablo Greco ceb317
 
Pablo Greco ceb317
 config HIGHPTE
Pablo Greco ceb317
-	bool "Allocate 2nd-level pagetables from highmem" if EXPERT
Pablo Greco ceb317
+	bool "Allocate 2nd-level pagetables from highmem"
Pablo Greco ceb317
 	depends on HIGHMEM
Pablo Greco ceb317
-	default y
Pablo Greco ceb317
+	default n
Pablo Greco ceb317
 	help
Pablo Greco ceb317
 	  The VM uses one page of physical memory for each page table.
Pablo Greco ceb317
 	  For systems with a lot of processes, this can use a lot of
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Peter Robinson <pbrobinson@gmail.com>
Pablo Greco ceb317
Date: Thu, 3 May 2012 20:27:11 +0100
Pablo Greco 0f1c57
Subject: [PATCH 17/34] ARM: tegra: usb no reset
Pablo Greco ceb317
Pablo Greco ceb317
Patch for disconnect issues with storage attached to a
Pablo Greco ceb317
 tegra-ehci controller
Pablo Greco ceb317
---
Pablo Greco ceb317
 drivers/usb/core/hub.c | 7 +++++++
Pablo Greco ceb317
 1 file changed, 7 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
Pablo Greco 0f1c57
index 1abe43ddb75f..041f8bc643d8 100644
Pablo Greco ceb317
--- a/drivers/usb/core/hub.c
Pablo Greco ceb317
+++ b/drivers/usb/core/hub.c
Pablo Greco 0f1c57
@@ -5678,6 +5678,13 @@ static void hub_event(struct work_struct *work)
Pablo Greco ceb317
 			(u16) hub->change_bits[0],
Pablo Greco ceb317
 			(u16) hub->event_bits[0]);
Pablo Greco ceb317
 
Pablo Greco ceb317
+	/* Don't disconnect USB-SATA on TrimSlice */
Pablo Greco ceb317
+	if (strcmp(dev_name(hdev->bus->controller), "tegra-ehci.0") == 0) {
Pablo Greco ceb317
+		if ((hdev->state == 7) && (hub->change_bits[0] == 0) &&
Pablo Greco ceb317
+				(hub->event_bits[0] == 0x2))
Pablo Greco ceb317
+			hub->event_bits[0] = 0;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+
Pablo Greco ceb317
 	/* Lock the device, then check to see if we were
Pablo Greco ceb317
 	 * disconnected while waiting for the lock to succeed. */
Pablo Greco ceb317
 	usb_lock_device(hdev);
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Pablo Greco ceb317
Date: Mon, 3 Apr 2017 18:18:21 +0200
Pablo Greco 0f1c57
Subject: [PATCH 18/34] Input: rmi4 - remove the need for artificial IRQ in
Pablo Greco ceb317
 case of HID
Pablo Greco ceb317
Pablo Greco ceb317
The IRQ from rmi4 may interfere with the one we currently use on i2c-hid.
Pablo Greco ceb317
Given that there is already a need for an external API from rmi4 to
Pablo Greco ceb317
forward the attention data, we can, in this particular case rely on a
Pablo Greco ceb317
separate workqueue to prevent cursor jumps.
Pablo Greco ceb317
Pablo Greco ceb317
Reported-by: Cameron Gutman <aicommander@gmail.com>
Pablo Greco ceb317
Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
Pablo Greco ceb317
Reported-by: Jason Ekstrand <jason@jlekstrand.net>
Pablo Greco ceb317
Tested-by: Andrew Duggan <aduggan@synaptics.com>
Pablo Greco ceb317
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Pablo Greco ceb317
Signed-off-by: Lyude <lyude@redhat.com>
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 drivers/hid/hid-rmi.c           |  66 -----------------
Pablo Greco ceb317
 drivers/input/rmi4/rmi_driver.c | 124 +++++++++++++++++++-------------
Pablo Greco ceb317
 include/linux/rmi.h             |   1 +
Pablo Greco 0f1c57
 3 files changed, 75 insertions(+), 116 deletions(-)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
Pablo Greco 0f1c57
index 84e7ba5314d3..efc96776f761 100644
Pablo Greco ceb317
--- a/drivers/hid/hid-rmi.c
Pablo Greco ceb317
+++ b/drivers/hid/hid-rmi.c
Pablo Greco 0f1c57
@@ -321,21 +321,12 @@ static int rmi_input_event(struct hid_device *hdev, u8 *data, int size)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	struct rmi_data *hdata = hid_get_drvdata(hdev);
Pablo Greco ceb317
 	struct rmi_device *rmi_dev = hdata->xport.rmi_dev;
Pablo Greco ceb317
-	unsigned long flags;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	if (!(test_bit(RMI_STARTED, &hdata->flags)))
Pablo Greco ceb317
 		return 0;
Pablo Greco ceb317
 
Pablo Greco 0f1c57
-	pm_wakeup_event(hdev->dev.parent, 0);
Pablo Greco 0f1c57
-
Pablo Greco ceb317
-	local_irq_save(flags);
Pablo Greco ceb317
-
Pablo Greco ceb317
 	rmi_set_attn_data(rmi_dev, data[1], &data[2], size - 2);
Pablo Greco ceb317
 
Pablo Greco ceb317
-	generic_handle_irq(hdata->rmi_irq);
Pablo Greco ceb317
-
Pablo Greco ceb317
-	local_irq_restore(flags);
Pablo Greco ceb317
-
Pablo Greco ceb317
 	return 1;
Pablo Greco ceb317
 }
Pablo Greco ceb317
 
Pablo Greco 0f1c57
@@ -591,56 +582,6 @@ static const struct rmi_transport_ops hid_rmi_ops = {
Pablo Greco ceb317
 	.reset		= rmi_hid_reset,
Pablo Greco ceb317
 };
Pablo Greco ceb317
 
Pablo Greco ceb317
-static void rmi_irq_teardown(void *data)
Pablo Greco ceb317
-{
Pablo Greco ceb317
-	struct rmi_data *hdata = data;
Pablo Greco ceb317
-	struct irq_domain *domain = hdata->domain;
Pablo Greco ceb317
-
Pablo Greco ceb317
-	if (!domain)
Pablo Greco ceb317
-		return;
Pablo Greco ceb317
-
Pablo Greco ceb317
-	irq_dispose_mapping(irq_find_mapping(domain, 0));
Pablo Greco ceb317
-
Pablo Greco ceb317
-	irq_domain_remove(domain);
Pablo Greco ceb317
-	hdata->domain = NULL;
Pablo Greco ceb317
-	hdata->rmi_irq = 0;
Pablo Greco ceb317
-}
Pablo Greco ceb317
-
Pablo Greco ceb317
-static int rmi_irq_map(struct irq_domain *h, unsigned int virq,
Pablo Greco ceb317
-		       irq_hw_number_t hw_irq_num)
Pablo Greco ceb317
-{
Pablo Greco ceb317
-	irq_set_chip_and_handler(virq, &dummy_irq_chip, handle_simple_irq);
Pablo Greco ceb317
-
Pablo Greco ceb317
-	return 0;
Pablo Greco ceb317
-}
Pablo Greco ceb317
-
Pablo Greco ceb317
-static const struct irq_domain_ops rmi_irq_ops = {
Pablo Greco ceb317
-	.map = rmi_irq_map,
Pablo Greco ceb317
-};
Pablo Greco ceb317
-
Pablo Greco ceb317
-static int rmi_setup_irq_domain(struct hid_device *hdev)
Pablo Greco ceb317
-{
Pablo Greco ceb317
-	struct rmi_data *hdata = hid_get_drvdata(hdev);
Pablo Greco ceb317
-	int ret;
Pablo Greco ceb317
-
Pablo Greco ceb317
-	hdata->domain = irq_domain_create_linear(hdev->dev.fwnode, 1,
Pablo Greco ceb317
-						 &rmi_irq_ops, hdata);
Pablo Greco ceb317
-	if (!hdata->domain)
Pablo Greco ceb317
-		return -ENOMEM;
Pablo Greco ceb317
-
Pablo Greco ceb317
-	ret = devm_add_action_or_reset(&hdev->dev, &rmi_irq_teardown, hdata);
Pablo Greco ceb317
-	if (ret)
Pablo Greco ceb317
-		return ret;
Pablo Greco ceb317
-
Pablo Greco ceb317
-	hdata->rmi_irq = irq_create_mapping(hdata->domain, 0);
Pablo Greco ceb317
-	if (hdata->rmi_irq <= 0) {
Pablo Greco ceb317
-		hid_err(hdev, "Can't allocate an IRQ\n");
Pablo Greco ceb317
-		return hdata->rmi_irq < 0 ? hdata->rmi_irq : -ENXIO;
Pablo Greco ceb317
-	}
Pablo Greco ceb317
-
Pablo Greco ceb317
-	return 0;
Pablo Greco ceb317
-}
Pablo Greco ceb317
-
Pablo Greco ceb317
 static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	struct rmi_data *data = NULL;
Pablo Greco 0f1c57
@@ -713,18 +654,11 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
Pablo Greco ceb317
 
Pablo Greco ceb317
 	mutex_init(&data->page_mutex);
Pablo Greco ceb317
 
Pablo Greco ceb317
-	ret = rmi_setup_irq_domain(hdev);
Pablo Greco ceb317
-	if (ret) {
Pablo Greco ceb317
-		hid_err(hdev, "failed to allocate IRQ domain\n");
Pablo Greco ceb317
-		return ret;
Pablo Greco ceb317
-	}
Pablo Greco ceb317
-
Pablo Greco ceb317
 	if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS)
Pablo Greco ceb317
 		rmi_hid_pdata.gpio_data.disable = true;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	data->xport.dev = hdev->dev.parent;
Pablo Greco ceb317
 	data->xport.pdata = rmi_hid_pdata;
Pablo Greco ceb317
-	data->xport.pdata.irq = data->rmi_irq;
Pablo Greco ceb317
 	data->xport.proto_name = "hid";
Pablo Greco ceb317
 	data->xport.ops = &hid_rmi_ops;
Pablo Greco ceb317
 
Pablo Greco ceb317
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
Pablo Greco ceb317
index 258d5fe3d395..f7298e3dc8f3 100644
Pablo Greco ceb317
--- a/drivers/input/rmi4/rmi_driver.c
Pablo Greco ceb317
+++ b/drivers/input/rmi4/rmi_driver.c
Pablo Greco ceb317
@@ -182,34 +182,47 @@ void rmi_set_attn_data(struct rmi_device *rmi_dev, unsigned long irq_status,
Pablo Greco ceb317
 	attn_data.data = fifo_data;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	kfifo_put(&drvdata->attn_fifo, attn_data);
Pablo Greco ceb317
+
Pablo Greco ceb317
+	schedule_work(&drvdata->attn_work);
Pablo Greco ceb317
 }
Pablo Greco ceb317
 EXPORT_SYMBOL_GPL(rmi_set_attn_data);
Pablo Greco ceb317
 
Pablo Greco ceb317
-static irqreturn_t rmi_irq_fn(int irq, void *dev_id)
Pablo Greco ceb317
+static void attn_callback(struct work_struct *work)
Pablo Greco ceb317
 {
Pablo Greco ceb317
-	struct rmi_device *rmi_dev = dev_id;
Pablo Greco ceb317
-	struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev);
Pablo Greco ceb317
+	struct rmi_driver_data *drvdata = container_of(work,
Pablo Greco ceb317
+							struct rmi_driver_data,
Pablo Greco ceb317
+							attn_work);
Pablo Greco ceb317
 	struct rmi4_attn_data attn_data = {0};
Pablo Greco ceb317
 	int ret, count;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	count = kfifo_get(&drvdata->attn_fifo, &attn_data);
Pablo Greco ceb317
-	if (count) {
Pablo Greco ceb317
-		*(drvdata->irq_status) = attn_data.irq_status;
Pablo Greco ceb317
-		drvdata->attn_data = attn_data;
Pablo Greco ceb317
-	}
Pablo Greco ceb317
+	if (!count)
Pablo Greco ceb317
+		return;
Pablo Greco ceb317
 
Pablo Greco ceb317
-	ret = rmi_process_interrupt_requests(rmi_dev);
Pablo Greco ceb317
+	*(drvdata->irq_status) = attn_data.irq_status;
Pablo Greco ceb317
+	drvdata->attn_data = attn_data;
Pablo Greco ceb317
+
Pablo Greco ceb317
+	ret = rmi_process_interrupt_requests(drvdata->rmi_dev);
Pablo Greco ceb317
 	if (ret)
Pablo Greco ceb317
-		rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev,
Pablo Greco ceb317
+		rmi_dbg(RMI_DEBUG_CORE, &drvdata->rmi_dev->dev,
Pablo Greco ceb317
 			"Failed to process interrupt request: %d\n", ret);
Pablo Greco ceb317
 
Pablo Greco ceb317
-	if (count) {
Pablo Greco ceb317
-		kfree(attn_data.data);
Pablo Greco ceb317
-		drvdata->attn_data.data = NULL;
Pablo Greco ceb317
-	}
Pablo Greco ceb317
+	kfree(attn_data.data);
Pablo Greco ceb317
+	drvdata->attn_data.data = NULL;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	if (!kfifo_is_empty(&drvdata->attn_fifo))
Pablo Greco ceb317
-		return rmi_irq_fn(irq, dev_id);
Pablo Greco ceb317
+		schedule_work(&drvdata->attn_work);
Pablo Greco ceb317
+}
Pablo Greco ceb317
+
Pablo Greco ceb317
+static irqreturn_t rmi_irq_fn(int irq, void *dev_id)
Pablo Greco ceb317
+{
Pablo Greco ceb317
+	struct rmi_device *rmi_dev = dev_id;
Pablo Greco ceb317
+	int ret;
Pablo Greco ceb317
+
Pablo Greco ceb317
+	ret = rmi_process_interrupt_requests(rmi_dev);
Pablo Greco ceb317
+	if (ret)
Pablo Greco ceb317
+		rmi_dbg(RMI_DEBUG_CORE, &rmi_dev->dev,
Pablo Greco ceb317
+			"Failed to process interrupt request: %d\n", ret);
Pablo Greco ceb317
 
Pablo Greco ceb317
 	return IRQ_HANDLED;
Pablo Greco ceb317
 }
Pablo Greco ceb317
@@ -217,7 +230,6 @@ static irqreturn_t rmi_irq_fn(int irq, void *dev_id)
Pablo Greco ceb317
 static int rmi_irq_init(struct rmi_device *rmi_dev)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	struct rmi_device_platform_data *pdata = rmi_get_platform_data(rmi_dev);
Pablo Greco ceb317
-	struct rmi_driver_data *data = dev_get_drvdata(&rmi_dev->dev);
Pablo Greco ceb317
 	int irq_flags = irq_get_trigger_type(pdata->irq);
Pablo Greco ceb317
 	int ret;
Pablo Greco ceb317
 
Pablo Greco ceb317
@@ -235,8 +247,6 @@ static int rmi_irq_init(struct rmi_device *rmi_dev)
Pablo Greco ceb317
 		return ret;
Pablo Greco ceb317
 	}
Pablo Greco ceb317
 
Pablo Greco ceb317
-	data->enabled = true;
Pablo Greco ceb317
-
Pablo Greco ceb317
 	return 0;
Pablo Greco ceb317
 }
Pablo Greco ceb317
 
Pablo Greco ceb317
@@ -886,23 +896,27 @@ void rmi_enable_irq(struct rmi_device *rmi_dev, bool clear_wake)
Pablo Greco ceb317
 	if (data->enabled)
Pablo Greco ceb317
 		goto out;
Pablo Greco ceb317
 
Pablo Greco ceb317
-	enable_irq(irq);
Pablo Greco ceb317
-	data->enabled = true;
Pablo Greco ceb317
-	if (clear_wake && device_may_wakeup(rmi_dev->xport->dev)) {
Pablo Greco ceb317
-		retval = disable_irq_wake(irq);
Pablo Greco ceb317
-		if (retval)
Pablo Greco ceb317
-			dev_warn(&rmi_dev->dev,
Pablo Greco ceb317
-				 "Failed to disable irq for wake: %d\n",
Pablo Greco ceb317
-				 retval);
Pablo Greco ceb317
-	}
Pablo Greco ceb317
+	if (irq) {
Pablo Greco ceb317
+		enable_irq(irq);
Pablo Greco ceb317
+		data->enabled = true;
Pablo Greco ceb317
+		if (clear_wake && device_may_wakeup(rmi_dev->xport->dev)) {
Pablo Greco ceb317
+			retval = disable_irq_wake(irq);
Pablo Greco ceb317
+			if (retval)
Pablo Greco ceb317
+				dev_warn(&rmi_dev->dev,
Pablo Greco ceb317
+					 "Failed to disable irq for wake: %d\n",
Pablo Greco ceb317
+					 retval);
Pablo Greco ceb317
+		}
Pablo Greco ceb317
 
Pablo Greco ceb317
-	/*
Pablo Greco ceb317
-	 * Call rmi_process_interrupt_requests() after enabling irq,
Pablo Greco ceb317
-	 * otherwise we may lose interrupt on edge-triggered systems.
Pablo Greco ceb317
-	 */
Pablo Greco ceb317
-	irq_flags = irq_get_trigger_type(pdata->irq);
Pablo Greco ceb317
-	if (irq_flags & IRQ_TYPE_EDGE_BOTH)
Pablo Greco ceb317
-		rmi_process_interrupt_requests(rmi_dev);
Pablo Greco ceb317
+		/*
Pablo Greco ceb317
+		 * Call rmi_process_interrupt_requests() after enabling irq,
Pablo Greco ceb317
+		 * otherwise we may lose interrupt on edge-triggered systems.
Pablo Greco ceb317
+		 */
Pablo Greco ceb317
+		irq_flags = irq_get_trigger_type(pdata->irq);
Pablo Greco ceb317
+		if (irq_flags & IRQ_TYPE_EDGE_BOTH)
Pablo Greco ceb317
+			rmi_process_interrupt_requests(rmi_dev);
Pablo Greco ceb317
+	} else {
Pablo Greco ceb317
+		data->enabled = true;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
 
Pablo Greco ceb317
 out:
Pablo Greco ceb317
 	mutex_unlock(&data->enabled_mutex);
Pablo Greco ceb317
@@ -922,20 +936,22 @@ void rmi_disable_irq(struct rmi_device *rmi_dev, bool enable_wake)
Pablo Greco ceb317
 		goto out;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	data->enabled = false;
Pablo Greco ceb317
-	disable_irq(irq);
Pablo Greco ceb317
-	if (enable_wake && device_may_wakeup(rmi_dev->xport->dev)) {
Pablo Greco ceb317
-		retval = enable_irq_wake(irq);
Pablo Greco ceb317
-		if (retval)
Pablo Greco ceb317
-			dev_warn(&rmi_dev->dev,
Pablo Greco ceb317
-				 "Failed to enable irq for wake: %d\n",
Pablo Greco ceb317
-				 retval);
Pablo Greco ceb317
-	}
Pablo Greco ceb317
-
Pablo Greco ceb317
-	/* make sure the fifo is clean */
Pablo Greco ceb317
-	while (!kfifo_is_empty(&data->attn_fifo)) {
Pablo Greco ceb317
-		count = kfifo_get(&data->attn_fifo, &attn_data);
Pablo Greco ceb317
-		if (count)
Pablo Greco ceb317
-			kfree(attn_data.data);
Pablo Greco ceb317
+	if (irq) {
Pablo Greco ceb317
+		disable_irq(irq);
Pablo Greco ceb317
+		if (enable_wake && device_may_wakeup(rmi_dev->xport->dev)) {
Pablo Greco ceb317
+			retval = enable_irq_wake(irq);
Pablo Greco ceb317
+			if (retval)
Pablo Greco ceb317
+				dev_warn(&rmi_dev->dev,
Pablo Greco ceb317
+					 "Failed to enable irq for wake: %d\n",
Pablo Greco ceb317
+					 retval);
Pablo Greco ceb317
+		}
Pablo Greco ceb317
+	} else {
Pablo Greco ceb317
+		/* make sure the fifo is clean */
Pablo Greco ceb317
+		while (!kfifo_is_empty(&data->attn_fifo)) {
Pablo Greco ceb317
+			count = kfifo_get(&data->attn_fifo, &attn_data);
Pablo Greco ceb317
+			if (count)
Pablo Greco ceb317
+				kfree(attn_data.data);
Pablo Greco ceb317
+		}
Pablo Greco ceb317
 	}
Pablo Greco ceb317
 
Pablo Greco ceb317
 out:
Pablo Greco ceb317
@@ -981,6 +997,8 @@ static int rmi_driver_remove(struct device *dev)
Pablo Greco ceb317
 	irq_domain_remove(data->irqdomain);
Pablo Greco ceb317
 	data->irqdomain = NULL;
Pablo Greco ceb317
 
Pablo Greco ceb317
+	cancel_work_sync(&data->attn_work);
Pablo Greco ceb317
+
Pablo Greco ceb317
 	rmi_f34_remove_sysfs(rmi_dev);
Pablo Greco ceb317
 	rmi_free_function_list(rmi_dev);
Pablo Greco ceb317
 
Pablo Greco ceb317
@@ -1219,9 +1237,15 @@ static int rmi_driver_probe(struct device *dev)
Pablo Greco ceb317
 		}
Pablo Greco ceb317
 	}
Pablo Greco ceb317
 
Pablo Greco ceb317
-	retval = rmi_irq_init(rmi_dev);
Pablo Greco ceb317
-	if (retval < 0)
Pablo Greco ceb317
-		goto err_destroy_functions;
Pablo Greco ceb317
+	if (pdata->irq) {
Pablo Greco ceb317
+		retval = rmi_irq_init(rmi_dev);
Pablo Greco ceb317
+		if (retval < 0)
Pablo Greco ceb317
+			goto err_destroy_functions;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+
Pablo Greco ceb317
+	data->enabled = true;
Pablo Greco ceb317
+
Pablo Greco ceb317
+	INIT_WORK(&data->attn_work, attn_callback);
Pablo Greco ceb317
 
Pablo Greco ceb317
 	if (data->f01_container->dev.driver) {
Pablo Greco ceb317
 		/* Driver already bound, so enable ATTN now. */
Pablo Greco ceb317
diff --git a/include/linux/rmi.h b/include/linux/rmi.h
Pablo Greco ceb317
index ab7eea01ab42..fff7c5f737fc 100644
Pablo Greco ceb317
--- a/include/linux/rmi.h
Pablo Greco ceb317
+++ b/include/linux/rmi.h
Pablo Greco ceb317
@@ -364,6 +364,7 @@ struct rmi_driver_data {
Pablo Greco ceb317
 
Pablo Greco ceb317
 	struct rmi4_attn_data attn_data;
Pablo Greco ceb317
 	DECLARE_KFIFO(attn_fifo, struct rmi4_attn_data, 16);
Pablo Greco ceb317
+	struct work_struct attn_work;
Pablo Greco ceb317
 };
Pablo Greco ceb317
 
Pablo Greco ceb317
 int rmi_register_transport_device(struct rmi_transport_dev *xport);
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Robert Holmes <robeholmes@gmail.com>
Pablo Greco ceb317
Date: Tue, 23 Apr 2019 07:39:29 +0000
Pablo Greco 0f1c57
Subject: [PATCH 19/34] KEYS: Make use of platform keyring for module signature
Pablo Greco ceb317
 verify
Pablo Greco ceb317
Pablo Greco ceb317
This patch completes commit 278311e417be ("kexec, KEYS: Make use of
Pablo Greco ceb317
platform keyring for signature verify") which, while adding the
Pablo Greco ceb317
platform keyring for bzImage verification, neglected to also add
Pablo Greco ceb317
this keyring for module verification.
Pablo Greco ceb317
Pablo Greco ceb317
As such, kernel modules signed with keys from the MokList variable
Pablo Greco ceb317
were not successfully verified.
Pablo Greco ceb317
Pablo Greco ceb317
Signed-off-by: Robert Holmes <robeholmes@gmail.com>
Pablo Greco ceb317
Signed-off-by: Jeremy Cline <jcline@redhat.com>
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 kernel/module/signing.c | 9 ++++++++-
Pablo Greco ceb317
 1 file changed, 8 insertions(+), 1 deletion(-)
Pablo Greco ceb317
Pablo Greco 0f1c57
diff --git a/kernel/module/signing.c b/kernel/module/signing.c
Pablo Greco 0f1c57
index a2ff4242e623..f0d2be1ee4f1 100644
Pablo Greco 0f1c57
--- a/kernel/module/signing.c
Pablo Greco 0f1c57
+++ b/kernel/module/signing.c
Pablo Greco 0f1c57
@@ -61,10 +61,17 @@ int mod_verify_sig(const void *mod, struct load_info *info)
Pablo Greco ceb317
 	modlen -= sig_len + sizeof(ms);
Pablo Greco ceb317
 	info->len = modlen;
Pablo Greco ceb317
 
Pablo Greco ceb317
-	return verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
Pablo Greco ceb317
+	ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
Pablo Greco ceb317
 				      VERIFY_USE_SECONDARY_KEYRING,
Pablo Greco ceb317
 				      VERIFYING_MODULE_SIGNATURE,
Pablo Greco ceb317
 				      NULL, NULL);
Pablo Greco ceb317
+	if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) {
Pablo Greco ceb317
+		ret = verify_pkcs7_signature(mod, modlen, mod + modlen, sig_len,
Pablo Greco ceb317
+				VERIFY_USE_PLATFORM_KEYRING,
Pablo Greco ceb317
+				VERIFYING_MODULE_SIGNATURE,
Pablo Greco ceb317
+				NULL, NULL);
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+	return ret;
Pablo Greco ceb317
 }
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 int module_sig_check(struct load_info *info, int flags)
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco ceb317
From: Jeremy Linton <jeremy.linton@arm.com>
Pablo Greco ceb317
Date: Thu, 11 Mar 2021 22:15:13 -0600
Pablo Greco 0f1c57
Subject: [PATCH 20/34] REDHAT: coresight: etm4x: Disable coresight on HPE
Pablo Greco ceb317
 Apollo 70
Pablo Greco ceb317
Pablo Greco ceb317
bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1918888
Pablo Greco ceb317
Pablo Greco ceb317
The coresight tables on the latest Apollo 70, appear to be
Pablo Greco ceb317
damaged sufficiently to throw a few hundred lines of back-traces
Pablo Greco ceb317
during boot, lets disable it until we can get a firmware fix.
Pablo Greco ceb317
Pablo Greco ceb317
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Pablo Greco ceb317
cc: Peter Robinson <pbrobinson@redhat.com>
Pablo Greco ceb317
cc: Justin M. Forbes <jforbes@fedoraproject.org>
Pablo Greco ceb317
cc: Al Stone <ahs3@redhat.com>
Pablo Greco ceb317
---
Pablo Greco ceb317
 .../coresight/coresight-etm4x-core.c          | 19 +++++++++++++++++++
Pablo Greco ceb317
 1 file changed, 19 insertions(+)
Pablo Greco ceb317
Pablo Greco ceb317
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c
Pablo Greco 0f1c57
index c7a65d1524fc..f4851d6996e9 100644
Pablo Greco ceb317
--- a/drivers/hwtracing/coresight/coresight-etm4x-core.c
Pablo Greco ceb317
+++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c
Pablo Greco ceb317
@@ -9,6 +9,7 @@
Pablo Greco ceb317
 #include <linux/init.h>
Pablo Greco ceb317
 #include <linux/types.h>
Pablo Greco ceb317
 #include <linux/device.h>
Pablo Greco ceb317
+#include <linux/dmi.h>
Pablo Greco ceb317
 #include <linux/io.h>
Pablo Greco ceb317
 #include <linux/err.h>
Pablo Greco ceb317
 #include <linux/fs.h>
Pablo Greco 0f1c57
@@ -2143,6 +2144,16 @@ static const struct amba_id etm4_ids[] = {
Pablo Greco ceb317
 	{},
Pablo Greco ceb317
 };
Pablo Greco ceb317
 
Pablo Greco ceb317
+static const struct dmi_system_id broken_coresight[] = {
Pablo Greco ceb317
+	{
Pablo Greco ceb317
+		.matches = {
Pablo Greco ceb317
+			DMI_MATCH(DMI_SYS_VENDOR, "HPE"),
Pablo Greco ceb317
+			DMI_MATCH(DMI_PRODUCT_NAME, "Apollo 70"),
Pablo Greco ceb317
+		},
Pablo Greco ceb317
+	},
Pablo Greco ceb317
+	{ }	/* terminating entry */
Pablo Greco ceb317
+};
Pablo Greco ceb317
+
Pablo Greco ceb317
 MODULE_DEVICE_TABLE(amba, etm4_ids);
Pablo Greco ceb317
 
Pablo Greco ceb317
 static struct amba_driver etm4x_amba_driver = {
Pablo Greco 0f1c57
@@ -2176,6 +2187,11 @@ static int __init etm4x_init(void)
Pablo Greco ceb317
 {
Pablo Greco ceb317
 	int ret;
Pablo Greco ceb317
 
Pablo Greco ceb317
+	if (dmi_check_system(broken_coresight)) {
Pablo Greco ceb317
+		pr_info("ETM4 disabled due to firmware bug\n");
Pablo Greco ceb317
+		return 0;
Pablo Greco ceb317
+	}
Pablo Greco ceb317
+
Pablo Greco ceb317
 	ret = etm4_pm_setup();
Pablo Greco ceb317
 
Pablo Greco ceb317
 	/* etm4_pm_setup() does its own cleanup - exit on error */
Pablo Greco 0f1c57
@@ -2202,6 +2218,9 @@ static int __init etm4x_init(void)
Pablo Greco ceb317
 
Pablo Greco ceb317
 static void __exit etm4x_exit(void)
Pablo Greco ceb317
 {
Pablo Greco ceb317
+	if (dmi_check_system(broken_coresight))
Pablo Greco ceb317
+		return;
Pablo Greco ceb317
+
Pablo Greco ceb317
 	amba_driver_unregister(&etm4x_amba_driver);
Pablo Greco ceb317
 	platform_driver_unregister(&etm4_platform_driver);
Pablo Greco ceb317
 	etm4_pm_clear();
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: "Justin M. Forbes" <jforbes@fedoraproject.org>
Pablo Greco 0f1c57
Date: Thu, 6 Oct 2022 15:34:27 -0500
Pablo Greco 0f1c57
Subject: [PATCH 21/34] Change acpi_bus_get_acpi_device to acpi_get_acpi_dev
Pablo Greco ceb317
Pablo Greco 0f1c57
Upstream commit 45e9aa1fdbb2e renamed acpi_bus_get_acpi_device to
Pablo Greco 0f1c57
acpi_get_acpi_dev. As we are carrying an out of tree patch [1] which calls
Pablo Greco 0f1c57
acpi_bus_get_acpi_device, we need to make the corresponding change
Pablo Greco 0f1c57
ourselves for things to continue to work.
Pablo Greco ceb317
Pablo Greco 0f1c57
[1]: c92805df87ae9 ACPI / irq: Workaround firmware issue on X-Gene based m400
Pablo Greco ceb317
Pablo Greco 0f1c57
Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>
Pablo Greco 0f1c57
---
Pablo Greco 0f1c57
 drivers/acpi/irq.c | 2 +-
Pablo Greco 0f1c57
 1 file changed, 1 insertion(+), 1 deletion(-)
Pablo Greco ceb317
Pablo Greco 0f1c57
diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c
Pablo Greco 0f1c57
index 377cddba06dc..4e3aa80cd5cf 100644
Pablo Greco 0f1c57
--- a/drivers/acpi/irq.c
Pablo Greco 0f1c57
+++ b/drivers/acpi/irq.c
Pablo Greco 0f1c57
@@ -257,7 +257,7 @@ static int acpi_irq_parse_one(acpi_handle handle, unsigned int index,
Pablo Greco 0f1c57
 	 * Don't do the producer/consumer check for that device.
Pablo Greco 0f1c57
 	 */
Pablo Greco 0f1c57
 	if (IS_ENABLED(CONFIG_ARM64)) {
Pablo Greco 0f1c57
-		struct acpi_device *adev = acpi_bus_get_acpi_device(handle);
Pablo Greco 0f1c57
+		struct acpi_device *adev = acpi_get_acpi_dev(handle);
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 		if (adev && !strcmp(acpi_device_hid(adev), "APMC0D08"))
Pablo Greco 0f1c57
 			ctx.skip_producer_check = true;
Pablo Greco 0f1c57
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco 0f1c57
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Jiri Olsa <olsajiri@gmail.com>
Pablo Greco 0f1c57
Date: Sun, 30 Oct 2022 15:29:54 +0100
Pablo Greco 0f1c57
Subject: [PATCH 22/34] disable enum64 BTF in fedora rawhide
Pablo Greco ceb317
Pablo Greco 0f1c57
hi,
Pablo Greco 0f1c57
I'm trying to update libbpf to 1.0, but it will take some time,
Pablo Greco 0f1c57
because there are many dependencies, meanwhile the new kernel
Pablo Greco 0f1c57
BTF seems to break other apps:
Pablo Greco 0f1c57
  https://bugzilla.redhat.com/show_bug.cgi?id=2138510
Pablo Greco ceb317
Pablo Greco 0f1c57
would it be possible to merge in workaround for that below?
Pablo Greco ceb317
Pablo Greco 0f1c57
I wanted to make MR in gitlab, but it won't let me push any
Pablo Greco 0f1c57
change for some reason..
Pablo Greco ceb317
Pablo Greco 0f1c57
thanks,
Pablo Greco 0f1c57
jirka
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 scripts/pahole-flags.sh | 3 +++
Pablo Greco ceb317
 1 file changed, 3 insertions(+)
Pablo Greco ceb317
Pablo Greco 0f1c57
diff --git a/scripts/pahole-flags.sh b/scripts/pahole-flags.sh
Pablo Greco 0f1c57
index 0d99ef17e4a5..81c8e082ec57 100755
Pablo Greco 0f1c57
--- a/scripts/pahole-flags.sh
Pablo Greco 0f1c57
+++ b/scripts/pahole-flags.sh
Pablo Greco 0f1c57
@@ -20,4 +20,7 @@ if [ "${pahole_ver}" -ge "122" ]; then
Pablo Greco 0f1c57
 	extra_paholeopt="${extra_paholeopt} -j"
Pablo Greco 0f1c57
 fi
Pablo Greco ceb317
 
Pablo Greco 0f1c57
+# temporary workaround to disable enum64
Pablo Greco 0f1c57
+extra_paholeopt="${extra_paholeopt} --skip_encoding_btf_enum64"
Pablo Greco ceb317
+
Pablo Greco 0f1c57
 echo ${extra_paholeopt}
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Javier Martinez Canillas <javierm@redhat.com>
Pablo Greco 0f1c57
Date: Thu, 19 May 2022 14:40:07 +0200
Pablo Greco 0f1c57
Subject: [PATCH 23/34] drivers/firmware: skip simpledrm if
Pablo Greco 0f1c57
 nvidia-drm.modeset=1 is set
Pablo Greco 0f1c57
Pablo Greco 0f1c57
The Nvidia proprietary driver has some bugs that leads to issues if used
Pablo Greco 0f1c57
with the simpledrm driver. The most noticeable is that does not register
Pablo Greco 0f1c57
an emulated fbdev device.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
It just relies on a fbdev to be registered by another driver, that could
Pablo Greco 0f1c57
be that could be attached to the framebuffer console. On UEFI machines,
Pablo Greco 0f1c57
this is the efifb driver.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
This means that disabling the efifb driver will cause virtual consoles to
Pablo Greco 0f1c57
not be present in the system when using the Nvidia driver. Legacy BIOS is
Pablo Greco 0f1c57
not affected just because fbcon is not used there, but instead vgacon.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Unless a VGA mode is specified using the vga= kernel command line option,
Pablo Greco 0f1c57
in that case the vesafb driver is used instead and its fbdev attached to
Pablo Greco 0f1c57
the fbcon.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
This is a problem because with CONFIG_SYSFB_SIMPLEFB=y, the sysfb platform
Pablo Greco 0f1c57
code attempts to register a "simple-framebuffer" platform device (that is
Pablo Greco 0f1c57
matched against simpledrm) and only registers either an "efi-framebuffer"
Pablo Greco 0f1c57
or "vesa-framebuffer" if this fails to be registered due the video modes
Pablo Greco 0f1c57
not being compatible.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
The Nvidia driver relying on another driver to register the fbdev is quite
Pablo Greco 0f1c57
fragile, since it can't really assume those will stick around. For example
Pablo Greco 0f1c57
there are patches posted to remove the EFI and VESA platform devices once
Pablo Greco 0f1c57
a real DRM or fbdev driver probes.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
But in any case, moving to a simpledrm + emulated fbdev only breaks this
Pablo Greco 0f1c57
assumption and causes users to not have VT if the Nvidia driver is used.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
So to prevent this, let's add a workaround and make the sysfb to skip the
Pablo Greco 0f1c57
"simple-framebuffer" registration when nvidia-drm.modeset=1 option is set.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
This is quite horrible, but honestly I can't think of any other approach.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
For this to work, the CONFIG_FB_EFI and CONFIG_FB_VESA config options must
Pablo Greco 0f1c57
be enabled besides CONFIG_DRM_SIMPLEDRM.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 drivers/firmware/sysfb.c | 18 +++++++++++++++++-
Pablo Greco 0f1c57
 1 file changed, 17 insertions(+), 1 deletion(-)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c
Pablo Greco 0f1c57
index 3fd3563d962b..75d67e6dde2a 100644
Pablo Greco 0f1c57
--- a/drivers/firmware/sysfb.c
Pablo Greco 0f1c57
+++ b/drivers/firmware/sysfb.c
Pablo Greco 0f1c57
@@ -34,6 +34,22 @@
Pablo Greco 0f1c57
 #include <linux/screen_info.h>
Pablo Greco 0f1c57
 #include <linux/sysfb.h>
Pablo Greco ceb317
 
Pablo Greco 0f1c57
+static int skip_simpledrm;
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+static int __init simpledrm_disable(char *opt)
Pablo Greco ceb317
+{
Pablo Greco 0f1c57
+	if (!opt)
Pablo Greco 0f1c57
+                return -EINVAL;
Pablo Greco ceb317
+
Pablo Greco 0f1c57
+	get_option(&opt, &skip_simpledrm);
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+	if (skip_simpledrm)
Pablo Greco 0f1c57
+		pr_info("The simpledrm driver will not be probed\n");
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+	return 0;
Pablo Greco 0f1c57
+}
Pablo Greco 0f1c57
+early_param("nvidia-drm.modeset", simpledrm_disable);
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
 static struct platform_device *pd;
Pablo Greco 0f1c57
 static DEFINE_MUTEX(disable_lock);
Pablo Greco 0f1c57
 static bool disabled;
Pablo Greco 0f1c57
@@ -83,7 +99,7 @@ static __init int sysfb_init(void)
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	/* try to create a simple-framebuffer device */
Pablo Greco 0f1c57
 	compatible = sysfb_parse_mode(si, &mode);
Pablo Greco 0f1c57
-	if (compatible) {
Pablo Greco 0f1c57
+	if (compatible && !skip_simpledrm) {
Pablo Greco 0f1c57
 		pd = sysfb_create_simplefb(si, &mode);
Pablo Greco 0f1c57
 		if (!IS_ERR(pd))
Pablo Greco 0f1c57
 			goto unlock_mutex;
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Peter Zijlstra <peterz@infradead.org>
Pablo Greco 0f1c57
Date: Thu, 27 Oct 2022 14:54:41 -0700
Pablo Greco 0f1c57
Subject: [PATCH 24/34] x86/mm: Randomize per-cpu entry area
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Seth found that the CPU-entry-area; the piece of per-cpu data that is
Pablo Greco 0f1c57
mapped into the userspace page-tables for kPTI is not subject to any
Pablo Greco 0f1c57
randomization -- irrespective of kASLR settings.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
On x86_64 a whole P4D (512 GB) of virtual address space is reserved for
Pablo Greco 0f1c57
this structure, which is plenty large enough to randomize things a
Pablo Greco 0f1c57
little.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
As such, use a straight forward randomization scheme that avoids
Pablo Greco 0f1c57
duplicates to spread the existing CPUs over the available space.
Pablo Greco 0f1c57
Pablo Greco 0f1c57
  [ bp: Fix le build. ]
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Reported-by: Seth Jenkins <sethjenkins@google.com>
Pablo Greco 0f1c57
Reviewed-by: Kees Cook <keescook@chromium.org>
Pablo Greco 0f1c57
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Pablo Greco 0f1c57
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Pablo Greco 0f1c57
Signed-off-by: Borislav Petkov <bp@suse.de>
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 arch/x86/include/asm/cpu_entry_area.h |  4 ---
Pablo Greco 0f1c57
 arch/x86/include/asm/pgtable_areas.h  |  8 ++++-
Pablo Greco 0f1c57
 arch/x86/kernel/hw_breakpoint.c       |  2 +-
Pablo Greco 0f1c57
 arch/x86/mm/cpu_entry_area.c          | 46 ++++++++++++++++++++++++---
Pablo Greco 0f1c57
 4 files changed, 50 insertions(+), 10 deletions(-)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/arch/x86/include/asm/cpu_entry_area.h b/arch/x86/include/asm/cpu_entry_area.h
Pablo Greco 0f1c57
index 75efc4c6f076..462fc34f1317 100644
Pablo Greco 0f1c57
--- a/arch/x86/include/asm/cpu_entry_area.h
Pablo Greco 0f1c57
+++ b/arch/x86/include/asm/cpu_entry_area.h
Pablo Greco 0f1c57
@@ -130,10 +130,6 @@ struct cpu_entry_area {
Pablo Greco 0f1c57
 };
Pablo Greco ceb317
 
Pablo Greco 0f1c57
 #define CPU_ENTRY_AREA_SIZE		(sizeof(struct cpu_entry_area))
Pablo Greco 0f1c57
-#define CPU_ENTRY_AREA_ARRAY_SIZE	(CPU_ENTRY_AREA_SIZE * NR_CPUS)
Pablo Greco ceb317
-
Pablo Greco 0f1c57
-/* Total size includes the readonly IDT mapping page as well: */
Pablo Greco 0f1c57
-#define CPU_ENTRY_AREA_TOTAL_SIZE	(CPU_ENTRY_AREA_ARRAY_SIZE + PAGE_SIZE)
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 DECLARE_PER_CPU(struct cpu_entry_area *, cpu_entry_area);
Pablo Greco 0f1c57
 DECLARE_PER_CPU(struct cea_exception_stacks *, cea_exception_stacks);
Pablo Greco 0f1c57
diff --git a/arch/x86/include/asm/pgtable_areas.h b/arch/x86/include/asm/pgtable_areas.h
Pablo Greco 0f1c57
index d34cce1b995c..4f056fb88174 100644
Pablo Greco 0f1c57
--- a/arch/x86/include/asm/pgtable_areas.h
Pablo Greco 0f1c57
+++ b/arch/x86/include/asm/pgtable_areas.h
Pablo Greco 0f1c57
@@ -11,6 +11,12 @@
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 #define CPU_ENTRY_AREA_RO_IDT_VADDR	((void *)CPU_ENTRY_AREA_RO_IDT)
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
-#define CPU_ENTRY_AREA_MAP_SIZE		(CPU_ENTRY_AREA_PER_CPU + CPU_ENTRY_AREA_ARRAY_SIZE - CPU_ENTRY_AREA_BASE)
Pablo Greco 0f1c57
+#ifdef CONFIG_X86_32
Pablo Greco 0f1c57
+#define CPU_ENTRY_AREA_MAP_SIZE		(CPU_ENTRY_AREA_PER_CPU +		\
Pablo Greco 0f1c57
+					 (CPU_ENTRY_AREA_SIZE * NR_CPUS) -	\
Pablo Greco 0f1c57
+					 CPU_ENTRY_AREA_BASE)
Pablo Greco 0f1c57
+#else
Pablo Greco 0f1c57
+#define CPU_ENTRY_AREA_MAP_SIZE		P4D_SIZE
Pablo Greco 0f1c57
+#endif
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 #endif /* _ASM_X86_PGTABLE_AREAS_H */
Pablo Greco 0f1c57
diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
Pablo Greco 0f1c57
index 668a4a6533d9..bbb0f737aab1 100644
Pablo Greco 0f1c57
--- a/arch/x86/kernel/hw_breakpoint.c
Pablo Greco 0f1c57
+++ b/arch/x86/kernel/hw_breakpoint.c
Pablo Greco 0f1c57
@@ -266,7 +266,7 @@ static inline bool within_cpu_entry(unsigned long addr, unsigned long end)
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	/* CPU entry erea is always used for CPU entry */
Pablo Greco 0f1c57
 	if (within_area(addr, end, CPU_ENTRY_AREA_BASE,
Pablo Greco 0f1c57
-			CPU_ENTRY_AREA_TOTAL_SIZE))
Pablo Greco 0f1c57
+			CPU_ENTRY_AREA_MAP_SIZE))
Pablo Greco 0f1c57
 		return true;
Pablo Greco ceb317
 
Pablo Greco ceb317
 	/*
Pablo Greco 0f1c57
diff --git a/arch/x86/mm/cpu_entry_area.c b/arch/x86/mm/cpu_entry_area.c
Pablo Greco 0f1c57
index 6c2f1b76a0b6..20844cf141fb 100644
Pablo Greco 0f1c57
--- a/arch/x86/mm/cpu_entry_area.c
Pablo Greco 0f1c57
+++ b/arch/x86/mm/cpu_entry_area.c
Pablo Greco 0f1c57
@@ -15,16 +15,53 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(struct entry_stack_page, entry_stack_storage)
Pablo Greco 0f1c57
 #ifdef CONFIG_X86_64
Pablo Greco 0f1c57
 static DEFINE_PER_CPU_PAGE_ALIGNED(struct exception_stacks, exception_stacks);
Pablo Greco 0f1c57
 DEFINE_PER_CPU(struct cea_exception_stacks*, cea_exception_stacks);
Pablo Greco 0f1c57
-#endif
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
-#ifdef CONFIG_X86_32
Pablo Greco 0f1c57
+static DEFINE_PER_CPU_READ_MOSTLY(unsigned long, _cea_offset);
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+static __always_inline unsigned int cea_offset(unsigned int cpu)
Pablo Greco 0f1c57
+{
Pablo Greco 0f1c57
+	return per_cpu(_cea_offset, cpu);
Pablo Greco ceb317
+}
Pablo Greco ceb317
+
Pablo Greco 0f1c57
+static __init void init_cea_offsets(void)
Pablo Greco ceb317
+{
Pablo Greco 0f1c57
+	unsigned int max_cea;
Pablo Greco 0f1c57
+	unsigned int i, j;
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+	max_cea = (CPU_ENTRY_AREA_MAP_SIZE - PAGE_SIZE) / CPU_ENTRY_AREA_SIZE;
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+	/* O(sodding terrible) */
Pablo Greco 0f1c57
+	for_each_possible_cpu(i) {
Pablo Greco 0f1c57
+		unsigned int cea;
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+again:
Pablo Greco 0f1c57
+		cea = prandom_u32_max(max_cea);
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+		for_each_possible_cpu(j) {
Pablo Greco 0f1c57
+			if (cea_offset(j) == cea)
Pablo Greco 0f1c57
+				goto again;
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+			if (i == j)
Pablo Greco 0f1c57
+				break;
Pablo Greco 0f1c57
+		}
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+		per_cpu(_cea_offset, i) = cea;
Pablo Greco 0f1c57
+	}
Pablo Greco 0f1c57
+}
Pablo Greco 0f1c57
+#else /* !X86_64 */
Pablo Greco 0f1c57
 DECLARE_PER_CPU_PAGE_ALIGNED(struct doublefault_stack, doublefault_stack);
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+static __always_inline unsigned int cea_offset(unsigned int cpu)
Pablo Greco ceb317
+{
Pablo Greco 0f1c57
+	return cpu;
Pablo Greco ceb317
+}
Pablo Greco 0f1c57
+static inline void init_cea_offsets(void) { }
Pablo Greco 0f1c57
 #endif
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 /* Is called from entry code, so must be noinstr */
Pablo Greco 0f1c57
 noinstr struct cpu_entry_area *get_cpu_entry_area(int cpu)
Pablo Greco ceb317
 {
Pablo Greco 0f1c57
-	unsigned long va = CPU_ENTRY_AREA_PER_CPU + cpu * CPU_ENTRY_AREA_SIZE;
Pablo Greco 0f1c57
+	unsigned long va = CPU_ENTRY_AREA_PER_CPU + cea_offset(cpu) * CPU_ENTRY_AREA_SIZE;
Pablo Greco 0f1c57
 	BUILD_BUG_ON(sizeof(struct cpu_entry_area) % PAGE_SIZE != 0);
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	return (struct cpu_entry_area *) va;
Pablo Greco 0f1c57
@@ -205,7 +242,6 @@ static __init void setup_cpu_entry_area_ptes(void)
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	/* The +1 is for the readonly IDT: */
Pablo Greco 0f1c57
 	BUILD_BUG_ON((CPU_ENTRY_AREA_PAGES+1)*PAGE_SIZE != CPU_ENTRY_AREA_MAP_SIZE);
Pablo Greco 0f1c57
-	BUILD_BUG_ON(CPU_ENTRY_AREA_TOTAL_SIZE != CPU_ENTRY_AREA_MAP_SIZE);
Pablo Greco 0f1c57
 	BUG_ON(CPU_ENTRY_AREA_BASE & ~PMD_MASK);
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	start = CPU_ENTRY_AREA_BASE;
Pablo Greco 0f1c57
@@ -221,6 +257,8 @@ void __init setup_cpu_entry_areas(void)
Pablo Greco 0f1c57
 {
Pablo Greco 0f1c57
 	unsigned int cpu;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
+	init_cea_offsets();
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
 	setup_cpu_entry_area_ptes();
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	for_each_possible_cpu(cpu)
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: "Justin M. Forbes" <jforbes@fedoraproject.org>
Pablo Greco 0f1c57
Date: Sat, 11 Mar 2023 08:53:53 -0600
Pablo Greco 0f1c57
Subject: [PATCH 25/34] Revert "wifi: cfg80211: Fix use after free for wext"
Pablo Greco 0f1c57
Pablo Greco 0f1c57
This reverts commit 015b8cc5e7c4d7bb671f1984d7b7338c310b185b.
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 net/wireless/sme.c | 31 +++++--------------------------
Pablo Greco 0f1c57
 1 file changed, 5 insertions(+), 26 deletions(-)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
Pablo Greco 0f1c57
index 89fc5683ed26..11a05fa2261a 100644
Pablo Greco 0f1c57
--- a/net/wireless/sme.c
Pablo Greco 0f1c57
+++ b/net/wireless/sme.c
Pablo Greco 0f1c57
@@ -285,15 +285,6 @@ void cfg80211_conn_work(struct work_struct *work)
Pablo Greco 0f1c57
 	wiphy_unlock(&rdev->wiphy);
Pablo Greco 0f1c57
 }
Pablo Greco ceb317
 
Pablo Greco 0f1c57
-static void cfg80211_step_auth_next(struct cfg80211_conn *conn,
Pablo Greco 0f1c57
-				    struct cfg80211_bss *bss)
Pablo Greco 0f1c57
-{
Pablo Greco 0f1c57
-	memcpy(conn->bssid, bss->bssid, ETH_ALEN);
Pablo Greco 0f1c57
-	conn->params.bssid = conn->bssid;
Pablo Greco 0f1c57
-	conn->params.channel = bss->channel;
Pablo Greco 0f1c57
-	conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
Pablo Greco 0f1c57
-}
Pablo Greco 0f1c57
-
Pablo Greco 0f1c57
 /* Returned bss is reference counted and must be cleaned up appropriately. */
Pablo Greco 0f1c57
 static struct cfg80211_bss *cfg80211_get_conn_bss(struct wireless_dev *wdev)
Pablo Greco 0f1c57
 {
Pablo Greco 0f1c57
@@ -311,7 +302,10 @@ static struct cfg80211_bss *cfg80211_get_conn_bss(struct wireless_dev *wdev)
Pablo Greco 0f1c57
 	if (!bss)
Pablo Greco 0f1c57
 		return NULL;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
-	cfg80211_step_auth_next(wdev->conn, bss);
Pablo Greco 0f1c57
+	memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN);
Pablo Greco 0f1c57
+	wdev->conn->params.bssid = wdev->conn->bssid;
Pablo Greco 0f1c57
+	wdev->conn->params.channel = bss->channel;
Pablo Greco 0f1c57
+	wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT;
Pablo Greco 0f1c57
 	schedule_work(&rdev->conn_work);
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	return bss;
Pablo Greco 0f1c57
@@ -603,12 +597,7 @@ static int cfg80211_sme_connect(struct wireless_dev *wdev,
Pablo Greco 0f1c57
 	wdev->conn->params.ssid_len = wdev->u.client.ssid_len;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	/* see if we have the bss already */
Pablo Greco 0f1c57
-	bss = cfg80211_get_bss(wdev->wiphy, wdev->conn->params.channel,
Pablo Greco 0f1c57
-			       wdev->conn->params.bssid,
Pablo Greco 0f1c57
-			       wdev->conn->params.ssid,
Pablo Greco 0f1c57
-			       wdev->conn->params.ssid_len,
Pablo Greco 0f1c57
-			       wdev->conn_bss_type,
Pablo Greco 0f1c57
-			       IEEE80211_PRIVACY(wdev->conn->params.privacy));
Pablo Greco 0f1c57
+	bss = cfg80211_get_conn_bss(wdev);
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	if (prev_bssid) {
Pablo Greco 0f1c57
 		memcpy(wdev->conn->prev_bssid, prev_bssid, ETH_ALEN);
Pablo Greco 0f1c57
@@ -619,7 +608,6 @@ static int cfg80211_sme_connect(struct wireless_dev *wdev,
Pablo Greco 0f1c57
 	if (bss) {
Pablo Greco 0f1c57
 		enum nl80211_timeout_reason treason;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
-		cfg80211_step_auth_next(wdev->conn, bss);
Pablo Greco 0f1c57
 		err = cfg80211_conn_do_work(wdev, &treason);
Pablo Greco 0f1c57
 		cfg80211_put_bss(wdev->wiphy, bss);
Pablo Greco 0f1c57
 	} else {
Pablo Greco 0f1c57
@@ -1479,15 +1467,6 @@ int cfg80211_connect(struct cfg80211_registered_device *rdev,
Pablo Greco 0f1c57
 	} else {
Pablo Greco 0f1c57
 		if (WARN_ON(connkeys))
Pablo Greco 0f1c57
 			return -EINVAL;
Pablo Greco 0f1c57
-
Pablo Greco 0f1c57
-		/* connect can point to wdev->wext.connect which
Pablo Greco 0f1c57
-		 * can hold key data from a previous connection
Pablo Greco 0f1c57
-		 */
Pablo Greco 0f1c57
-		connect->key = NULL;
Pablo Greco 0f1c57
-		connect->key_len = 0;
Pablo Greco 0f1c57
-		connect->key_idx = 0;
Pablo Greco 0f1c57
-		connect->crypto.cipher_group = 0;
Pablo Greco 0f1c57
-		connect->crypto.n_ciphers_pairwise = 0;
Pablo Greco 0f1c57
 	}
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 	wdev->connect_keys = connkeys;
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Laura Abbott <labbott@redhat.com>
Pablo Greco 0f1c57
Date: Wed, 23 Jan 2019 14:36:37 +0100
Pablo Greco 0f1c57
Subject: [PATCH 26/34] Drop that for now
Pablo Greco ceb317
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 Makefile | 1 +
Pablo Greco 0f1c57
 1 file changed, 1 insertion(+)
Pablo Greco ceb317
Pablo Greco 0f1c57
diff --git a/Makefile b/Makefile
Pablo Greco 0f1c57
index a825361f7162..b83f1adf1574 100644
Pablo Greco 0f1c57
--- a/Makefile
Pablo Greco 0f1c57
+++ b/Makefile
Pablo Greco 0f1c57
@@ -570,6 +570,7 @@ KBUILD_CFLAGS   := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
Pablo Greco 0f1c57
 		   -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
Pablo Greco 0f1c57
 		   -Werror=implicit-function-declaration -Werror=implicit-int \
Pablo Greco 0f1c57
 		   -Werror=return-type -Wno-format-security \
Pablo Greco 0f1c57
+		   -Wno-address-of-packed-member \
Pablo Greco 0f1c57
 		   -std=gnu11
Pablo Greco 0f1c57
 KBUILD_CPPFLAGS := -D__KERNEL__
Pablo Greco 0f1c57
 KBUILD_RUSTFLAGS := $(rust_common_flags) \
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Don Brace <dbrace@redhat.com>
Pablo Greco 0f1c57
Date: Mon, 16 Jul 2018 19:20:41 -0400
Pablo Greco 0f1c57
Subject: [PATCH 27/34] scsi: smartpqi: add inspur advantech ids
Pablo Greco ceb317
Pablo Greco 0f1c57
Message-id: <1531768843-2544-4-git-send-email-dbrace@redhat.com>
Pablo Greco 0f1c57
Patchwork-id: 224988
Pablo Greco 0f1c57
O-Subject: [RHEL 8.0 e-stor V2 PATCH 3/5] scsi: smartpqi: add inspur advantech ids
Pablo Greco 0f1c57
Bugzilla: 1503736
Pablo Greco 0f1c57
RH-Acked-by: Ewan Milne <emilne@redhat.com>
Pablo Greco 0f1c57
RH-Acked-by: Tomas Henzl <thenzl@redhat.com>
Pablo Greco ceb317
Pablo Greco 0f1c57
From: Kevin Barnett <kevin.barnett@microsemi.com>
Pablo Greco ceb317
Pablo Greco 0f1c57
Add support for these new device IDs:
Pablo Greco ceb317
Pablo Greco 0f1c57
  Advantech MIC-8312BridgeB
Pablo Greco 0f1c57
  INSPUR PM8204-2GB
Pablo Greco 0f1c57
  INSPUR PM8204-4GB
Pablo Greco 0f1c57
  INSPUR PM8222-SHBA
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Upstream Status: RHEL only
Pablo Greco 0f1c57
Reviewed-by: Scott Benesh <scott.benesh@microsemi.com>
Pablo Greco 0f1c57
Signed-off-by: Kevin Barnett <kevin.barnett@microsemi.com>
Pablo Greco 0f1c57
Signed-off-by: Don Brace <don.brace@microsemi.com>
Pablo Greco 0f1c57
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Pablo Greco 0f1c57
(cherry picked from commit 9f8d05fa98442de78d1ab30235b0cc656ed7aff0)
Pablo Greco 0f1c57
Signed-off-by: Don Brace <dbrace@redhat.com>
Pablo Greco 0f1c57
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Pablo Greco ceb317
---
Pablo Greco 0f1c57
 drivers/scsi/smartpqi/smartpqi_init.c | 16 ++++++++++++++++
Pablo Greco 0f1c57
 1 file changed, 16 insertions(+)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
Pablo Greco 0f1c57
index 9f0f69c1ed66..96909da91e03 100644
Pablo Greco 0f1c57
--- a/drivers/scsi/smartpqi/smartpqi_init.c
Pablo Greco 0f1c57
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
Pablo Greco 0f1c57
@@ -9461,6 +9461,18 @@ static const struct pci_device_id pqi_pci_id_table[] = {
Pablo Greco 0f1c57
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
 			       0x19e5, 0xd22c)
Pablo Greco 0f1c57
 	},
Pablo Greco 0f1c57
+	{
Pablo Greco 0f1c57
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
+			       0x1bd4, 0x004a)
Pablo Greco 0f1c57
+	},
Pablo Greco 0f1c57
+	{
Pablo Greco 0f1c57
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
+			       0x1bd4, 0x004b)
Pablo Greco 0f1c57
+	},
Pablo Greco 0f1c57
+	{
Pablo Greco 0f1c57
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
+			       0x1bd4, 0x004c)
Pablo Greco 0f1c57
+	},
Pablo Greco 0f1c57
 	{
Pablo Greco 0f1c57
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
 			       PCI_VENDOR_ID_ADAPTEC2, 0x0110)
Pablo Greco 0f1c57
@@ -9769,6 +9781,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {
Pablo Greco 0f1c57
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
 			       PCI_VENDOR_ID_ADVANTECH, 0x8312)
Pablo Greco 0f1c57
 	},
Pablo Greco 0f1c57
+	{
Pablo Greco 0f1c57
+		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
+			       PCI_VENDOR_ID_ADVANTECH, 0x8312)
Pablo Greco 0f1c57
+	},
Pablo Greco 0f1c57
 	{
Pablo Greco 0f1c57
 		PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x028f,
Pablo Greco 0f1c57
 			       PCI_VENDOR_ID_DELL, 0x1fe0)
Pablo Greco 0f1c57
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco 0f1c57
Pablo Greco 0f1c57
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Murphy Zhou <jencce.kernel@gmail.com>
Pablo Greco 0f1c57
Date: Sun, 29 Sep 2019 17:56:59 +0800
Pablo Greco 0f1c57
Subject: [PATCH 28/34] mm/kmemleak: skip late_init if not skip disable
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Now if DEFAULT_OFF set to y, kmemleak_init will start the cleanup_work
Pablo Greco 0f1c57
workqueue. Then late_init call will set kmemleak_initialized to 1, the
Pablo Greco 0f1c57
cleaup workqueue will try to do cleanup, triggering:
Pablo Greco 0f1c57
Pablo Greco 0f1c57
[24.738773] ==================================================================
Pablo Greco 0f1c57
[24.742784] BUG: KASAN: global-out-of-bounds in __kmemleak_do_cleanup+0x166/0x180
Pablo Greco 0f1c57
[24.744144] Key type ._fscrypt registered
Pablo Greco 0f1c57
[24.745680] Read of size 8 at addr ffffffff88746c90 by task kworker/3:1/171
Pablo Greco 0f1c57
[24.745687]
Pablo Greco 0f1c57
[24.745697] CPU: 3 PID: 171 Comm: kworker/3:1 Not tainted 5.3.0-v5.3-12475-gcbafe18 #1
Pablo Greco 0f1c57
[24.745701] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
Pablo Greco 0f1c57
[24.745710] Workqueue: events kmemleak_do_cleanup
Pablo Greco 0f1c57
[24.745717] Call Trace:
Pablo Greco 0f1c57
[24.745736]  dump_stack+0x7c/0xc0
Pablo Greco 0f1c57
[24.745755]  print_address_description.constprop.4+0x1f/0x300
Pablo Greco 0f1c57
[24.751562] Key type .fscrypt registered
Pablo Greco 0f1c57
[24.754370]  __kasan_report.cold.8+0x76/0xb2
Pablo Greco 0f1c57
[24.754388]  ? __kmemleak_do_cleanup+0x166/0x180
Pablo Greco 0f1c57
[24.754407]  kasan_report+0xe/0x20
Pablo Greco 0f1c57
[24.778543]  __kmemleak_do_cleanup+0x166/0x180
Pablo Greco 0f1c57
[24.780795]  process_one_work+0x919/0x17d0
Pablo Greco 0f1c57
[24.782929]  ? pwq_dec_nr_in_flight+0x320/0x320
Pablo Greco 0f1c57
[24.785092]  worker_thread+0x87/0xb40
Pablo Greco 0f1c57
[24.786948]  ? __kthread_parkme+0xc3/0x190
Pablo Greco 0f1c57
[24.789217]  ? process_one_work+0x17d0/0x17d0
Pablo Greco 0f1c57
[24.791414]  kthread+0x333/0x3f0
Pablo Greco 0f1c57
[24.793031]  ? kthread_create_worker_on_cpu+0xc0/0xc0
Pablo Greco 0f1c57
[24.795473]  ret_from_fork+0x3a/0x50
Pablo Greco 0f1c57
[24.797303]
Pablo Greco 0f1c57
[24.798091] The buggy address belongs to the variable:
Pablo Greco 0f1c57
[24.800634]  mem_pool_free_count+0x10/0x40
Pablo Greco 0f1c57
[24.802656]
Pablo Greco 0f1c57
[24.803434] Memory state around the buggy address:
Pablo Greco 0f1c57
[24.805793]  ffffffff88746b80: 04 fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
Pablo Greco 0f1c57
[24.809177]  ffffffff88746c00: 00 fa fa fa fa fa fa fa 00 00 fa fa fa fa fa fa
Pablo Greco 0f1c57
[24.812407] >ffffffff88746c80: 04 fa fa fa fa fa fa fa 00 00 fa fa fa fa fa fa
Pablo Greco 0f1c57
[24.815638]                          ^
Pablo Greco 0f1c57
[24.817372]  ffffffff88746d00: 00 00 fa fa fa fa fa fa 00 00 00 00 00 00 00 00
Pablo Greco 0f1c57
[24.820740]  ffffffff88746d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Pablo Greco 0f1c57
[24.824021] ==================================================================
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Fixes: c5665868183f ("mm: kmemleak: use the memory pool for early allocations")
Pablo Greco 0f1c57
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Pablo Greco 0f1c57
---
Pablo Greco 0f1c57
 mm/kmemleak.c | 5 +++++
Pablo Greco 0f1c57
 1 file changed, 5 insertions(+)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/mm/kmemleak.c b/mm/kmemleak.c
Pablo Greco 0f1c57
index 646e2979641f..6143e5a0d4ae 100644
Pablo Greco 0f1c57
--- a/mm/kmemleak.c
Pablo Greco 0f1c57
+++ b/mm/kmemleak.c
Pablo Greco 0f1c57
@@ -2107,6 +2107,11 @@ void __init kmemleak_init(void)
Pablo Greco 0f1c57
  */
Pablo Greco 0f1c57
 static int __init kmemleak_late_init(void)
Pablo Greco ceb317
 {
Pablo Greco 0f1c57
+	if (!kmemleak_skip_disable) {
Pablo Greco 0f1c57
+		kmemleak_disable();
Pablo Greco 0f1c57
+		return 0;
Pablo Greco 0f1c57
+	}
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
 	kmemleak_initialized = 1;
Pablo Greco ceb317
 
Pablo Greco 0f1c57
 	debugfs_create_file("kmemleak", 0644, NULL, NULL, &kmemleak_fops);
Pablo Greco ceb317
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco ceb317
Pablo Greco ceb317
Pablo Greco ceb317
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Icenowy Zheng <icenowy@aosc.io>
Pablo Greco 0f1c57
Date: Mon, 16 Mar 2020 21:35:00 +0800
Pablo Greco 0f1c57
Subject: [PATCH 29/34] dt-bindings: panel: add binding for Xingbangda XBD599
Pablo Greco 0f1c57
 panel
Pablo Greco 89a396
Pablo Greco 0f1c57
Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI LCD panel.
Pablo Greco 89a396
Pablo Greco 0f1c57
Add its device tree binding.
Pablo Greco 89a396
Pablo Greco 0f1c57
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Pablo Greco 89a396
---
Pablo Greco 0f1c57
 .../display/panel/xingbangda,xbd599.yaml      | 50 +++++++++++++++++++
Pablo Greco 0f1c57
 1 file changed, 50 insertions(+)
Pablo Greco 0f1c57
 create mode 100644 Documentation/devicetree/bindings/display/panel/xingbangda,xbd599.yaml
Pablo Greco 89a396
Pablo Greco 0f1c57
diff --git a/Documentation/devicetree/bindings/display/panel/xingbangda,xbd599.yaml b/Documentation/devicetree/bindings/display/panel/xingbangda,xbd599.yaml
Pablo Greco 0f1c57
new file mode 100644
Pablo Greco 0f1c57
index 000000000000..b27bcf11198f
Pablo Greco 0f1c57
--- /dev/null
Pablo Greco 0f1c57
+++ b/Documentation/devicetree/bindings/display/panel/xingbangda,xbd599.yaml
Pablo Greco 0f1c57
@@ -0,0 +1,50 @@
Pablo Greco 0f1c57
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
Pablo Greco 0f1c57
+%YAML 1.2
Pablo Greco 0f1c57
+---
Pablo Greco 0f1c57
+$id: http://devicetree.org/schemas/display/panel/xingbangda,xbd599.yaml#
Pablo Greco 0f1c57
+$schema: http://devicetree.org/meta-schemas/core.yaml#
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+title: Xingbangda XBD599 5.99in MIPI-DSI LCD panel
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+maintainers:
Pablo Greco 0f1c57
+  - Icenowy Zheng <icenowy@aosc.io>
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+allOf:
Pablo Greco 0f1c57
+  - $ref: panel-common.yaml#
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+properties:
Pablo Greco 0f1c57
+  compatible:
Pablo Greco 0f1c57
+    const: xingbangda,xbd599
Pablo Greco 0f1c57
+  reg: true
Pablo Greco 0f1c57
+  backlight: true
Pablo Greco 0f1c57
+  reset-gpios: true
Pablo Greco 0f1c57
+  vcc-supply:
Pablo Greco 0f1c57
+    description: regulator that supplies the VCC voltage
Pablo Greco 0f1c57
+  iovcc-supply:
Pablo Greco 0f1c57
+    description: regulator that supplies the IOVCC voltage
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+required:
Pablo Greco 0f1c57
+  - compatible
Pablo Greco 0f1c57
+  - reg
Pablo Greco 0f1c57
+  - backlight
Pablo Greco 0f1c57
+  - vcc-supply
Pablo Greco 0f1c57
+  - iovcc-supply
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+additionalProperties: false
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+examples:
Pablo Greco 0f1c57
+  - |
Pablo Greco 0f1c57
+    dsi {
Pablo Greco 0f1c57
+        #address-cells = <1>;
Pablo Greco 0f1c57
+        #size-cells = <0>;
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+        panel@0 {
Pablo Greco 0f1c57
+            compatible = "xingbangda,xbd599";
Pablo Greco 0f1c57
+            reg = <0>;
Pablo Greco 0f1c57
+            backlight = <&backlight>;
Pablo Greco 0f1c57
+            iovcc-supply = <&reg_dldo2>;
Pablo Greco 0f1c57
+            vcc-supply = <&reg_ldo_io0>;
Pablo Greco 0f1c57
+        };
Pablo Greco 0f1c57
+    };
Pablo Greco 0f1c57
+
Pablo Greco 0f1c57
+...
Pablo Greco 89a396
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco 89a396
Pablo Greco 08fca0
Pablo Greco 08fca0
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Icenowy Zheng <icenowy@aosc.io>
Pablo Greco 0f1c57
Date: Mon, 16 Mar 2020 21:35:02 +0800
Pablo Greco 0f1c57
Subject: [PATCH 30/34] drm/sun4i: sun6i_mipi_dsi: fix horizontal timing
Pablo Greco 0f1c57
 calculation
Pablo Greco 08fca0
Pablo Greco 0f1c57
The max() function call in horizontal timing calculation shouldn't pad a
Pablo Greco 0f1c57
length already subtracted with overhead to overhead, instead it should
Pablo Greco 0f1c57
only prevent the set timing to underflow.
Pablo Greco 08fca0
Pablo Greco 0f1c57
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Pablo Greco 0f1c57
---
Pablo Greco 0f1c57
 drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 10 +++++-----
Pablo Greco 0f1c57
 1 file changed, 5 insertions(+), 5 deletions(-)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
Pablo Greco 0f1c57
index 34234a144e87..408e48d87757 100644
Pablo Greco 0f1c57
--- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
Pablo Greco 0f1c57
+++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c
Pablo Greco 0f1c57
@@ -556,7 +556,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Pablo Greco 0f1c57
 		 */
Pablo Greco 0f1c57
 #define HSA_PACKET_OVERHEAD	10
Pablo Greco 0f1c57
 		hsa = max(HSA_PACKET_OVERHEAD,
Pablo Greco 0f1c57
-			  (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD);
Pablo Greco 0f1c57
+			  (mode->hsync_end - mode->hsync_start) * Bpp) - HSA_PACKET_OVERHEAD;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 		/*
Pablo Greco 0f1c57
 		 * The backporch is set using a blanking packet (4
Pablo Greco 0f1c57
@@ -565,7 +565,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Pablo Greco 0f1c57
 		 */
Pablo Greco 0f1c57
 #define HBP_PACKET_OVERHEAD	6
Pablo Greco 0f1c57
 		hbp = max(HBP_PACKET_OVERHEAD,
Pablo Greco 0f1c57
-			  (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD);
Pablo Greco 0f1c57
+			  (mode->htotal - mode->hsync_end) * Bpp) - HBP_PACKET_OVERHEAD;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 		/*
Pablo Greco 0f1c57
 		 * The frontporch is set using a sync event (4 bytes)
Pablo Greco 0f1c57
@@ -575,7 +575,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Pablo Greco 0f1c57
 		 */
Pablo Greco 0f1c57
 #define HFP_PACKET_OVERHEAD	16
Pablo Greco 0f1c57
 		hfp = max(HFP_PACKET_OVERHEAD,
Pablo Greco 0f1c57
-			  (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD);
Pablo Greco 0f1c57
+			  (mode->hsync_start - mode->hdisplay) * Bpp) - HFP_PACKET_OVERHEAD;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 		/*
Pablo Greco 0f1c57
 		 * The blanking is set using a sync event (4 bytes)
Pablo Greco 0f1c57
@@ -584,8 +584,8 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi,
Pablo Greco 0f1c57
 		 */
Pablo Greco 0f1c57
 #define HBLK_PACKET_OVERHEAD	10
Pablo Greco 0f1c57
 		hblk = max(HBLK_PACKET_OVERHEAD,
Pablo Greco 0f1c57
-			   (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp -
Pablo Greco 0f1c57
-			   HBLK_PACKET_OVERHEAD);
Pablo Greco 0f1c57
+			   (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp) -
Pablo Greco 0f1c57
+			   HBLK_PACKET_OVERHEAD;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
 		/*
Pablo Greco 0f1c57
 		 * And I'm not entirely sure what vblk is about. The driver in
Pablo Greco 0f1c57
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco 08fca0
Pablo Greco 08fca0
Pablo Greco 0f1c57
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: "Justin M. Forbes" <jforbes@fedoraproject.org>
Pablo Greco 0f1c57
Date: Thu, 30 Jul 2020 10:26:11 -0500
Pablo Greco 0f1c57
Subject: [PATCH 31/34] Work around for gcc bug
Pablo Greco 0f1c57
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96377
Pablo Greco 0f1c57
Pablo Greco 0f1c57
Signed-off-by: Justin M. Forbes <jforbes@fedoraproject.org>
Pablo Greco 08fca0
---
Pablo Greco 0f1c57
 crypto/aegis128-neon-inner.c | 4 ++--
Pablo Greco 0f1c57
 1 file changed, 2 insertions(+), 2 deletions(-)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/crypto/aegis128-neon-inner.c b/crypto/aegis128-neon-inner.c
Pablo Greco 0f1c57
index 7de485907d81..2ccaf0a81c4c 100644
Pablo Greco 0f1c57
--- a/crypto/aegis128-neon-inner.c
Pablo Greco 0f1c57
+++ b/crypto/aegis128-neon-inner.c
Pablo Greco 0f1c57
@@ -147,8 +147,8 @@ void crypto_aegis128_init_neon(void *state, const void *key, const void *iv)
Pablo Greco 0f1c57
 		kiv,
Pablo Greco 0f1c57
 		vld1q_u8(const1),
Pablo Greco 0f1c57
 		vld1q_u8(const0),
Pablo Greco 0f1c57
-		k ^ vld1q_u8(const0),
Pablo Greco 0f1c57
-		k ^ vld1q_u8(const1),
Pablo Greco 0f1c57
+		(uint8x16_t) (k ^ vld1q_u8(const0)),
Pablo Greco 0f1c57
+		(uint8x16_t) (k ^ vld1q_u8(const1)),
Pablo Greco 0f1c57
 	}};
Pablo Greco 0f1c57
 	int i;
Pablo Greco 08fca0
 
Pablo Greco 08fca0
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco 08fca0
Pablo Greco 08fca0
Pablo Greco 08fca0
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Peter Robinson <pbrobinson@gmail.com>
Pablo Greco 0f1c57
Date: Mon, 26 Oct 2020 17:01:57 +0000
Pablo Greco 0f1c57
Subject: [PATCH 32/34] update phy on pine64 a64 devices
Pablo Greco 08fca0
Pablo Greco 0f1c57
---
Pablo Greco 0f1c57
 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts | 2 +-
Pablo Greco 0f1c57
 1 file changed, 1 insertion(+), 1 deletion(-)
Pablo Greco 08fca0
Pablo Greco 0f1c57
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
Pablo Greco 0f1c57
index 2accb5ddf783..aa0d0959b906 100644
Pablo Greco 0f1c57
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
Pablo Greco 0f1c57
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts
Pablo Greco 0f1c57
@@ -81,7 +81,7 @@ &ehci1 {
Pablo Greco 0f1c57
 &emac {
Pablo Greco 0f1c57
 	pinctrl-names = "default";
Pablo Greco 0f1c57
 	pinctrl-0 = <&rmii_pins>;
Pablo Greco 0f1c57
-	phy-mode = "rmii";
Pablo Greco 0f1c57
+	phy-mode = "rmii-txid";
Pablo Greco 0f1c57
 	phy-handle = <&ext_rmii_phy1>;
Pablo Greco 0f1c57
 	phy-supply = <&reg_dc1sw>;
Pablo Greco 0f1c57
 	status = "okay";
Pablo Greco 0f1c57
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco 08fca0
Pablo Greco 08fca0
Pablo Greco 0f1c57
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Peter Robinson <pbrobinson@gmail.com>
Pablo Greco 0f1c57
Date: Tue, 12 Jan 2021 23:14:09 +0000
Pablo Greco 0f1c57
Subject: [PATCH 33/34] brcm: rpi4: fix usb numeration
Pablo Greco 08fca0
Pablo Greco 0f1c57
Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Pablo Greco 08fca0
---
Pablo Greco 0f1c57
 drivers/pci/controller/pcie-brcmstb.c | 1 +
Pablo Greco 0f1c57
 1 file changed, 1 insertion(+)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c
Pablo Greco 0f1c57
index 521acd632f1a..02cf1b637c1c 100644
Pablo Greco 0f1c57
--- a/drivers/pci/controller/pcie-brcmstb.c
Pablo Greco 0f1c57
+++ b/drivers/pci/controller/pcie-brcmstb.c
Pablo Greco 0f1c57
@@ -875,6 +875,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
Pablo Greco 08fca0
 
Pablo Greco 0f1c57
 	/* Reset the bridge */
Pablo Greco 0f1c57
 	pcie->bridge_sw_init_set(pcie, 1);
Pablo Greco 0f1c57
+	pcie->perst_set(pcie, 1);
Pablo Greco 0f1c57
 	usleep_range(100, 200);
Pablo Greco 08fca0
 
Pablo Greco 0f1c57
 	/* Take the bridge out of reset */
Pablo Greco 08fca0
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco 08fca0
Pablo Greco 08fca0
Pablo Greco 08fca0
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Pablo Greco 0f1c57
From: Pablo Greco <pgreco@centosproject.org>
Pablo Greco 0f1c57
Date: Tue, 22 Feb 2022 23:12:06 +0000
Pablo Greco 0f1c57
Subject: [PATCH 34/34] Fix build on i686
Pablo Greco 08fca0
Pablo Greco 08fca0
---
Pablo Greco 0f1c57
 arch/x86/kernel/resource.c | 4 ++++
Pablo Greco 0f1c57
 1 file changed, 4 insertions(+)
Pablo Greco 0f1c57
Pablo Greco 0f1c57
diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
Pablo Greco 0f1c57
index bba1abd05bfe..6e79835d1430 100644
Pablo Greco 0f1c57
--- a/arch/x86/kernel/resource.c
Pablo Greco 0f1c57
+++ b/arch/x86/kernel/resource.c
Pablo Greco 0f1c57
@@ -2,7 +2,9 @@
Pablo Greco 0f1c57
 #include <linux/ioport.h>
Pablo Greco 0f1c57
 #include <linux/printk.h>
Pablo Greco 0f1c57
 #include <asm/e820/api.h>
Pablo Greco 0f1c57
+#ifdef CONFIG_X86_64
Pablo Greco 0f1c57
 #include <asm/pci_x86.h>
Pablo Greco 0f1c57
+#endif
Pablo Greco 08fca0
 
Pablo Greco 0f1c57
 static void resource_clip(struct resource *res, resource_size_t start,
Pablo Greco 0f1c57
 			  resource_size_t end)
Pablo Greco 0f1c57
@@ -32,8 +34,10 @@ static void remove_e820_regions(struct resource *avail)
Pablo Greco 0f1c57
 	u64 e820_start, e820_end;
Pablo Greco 0f1c57
 	struct resource orig = *avail;
Pablo Greco 0f1c57
 
Pablo Greco 0f1c57
+#ifdef CONFIG_X86_64
Pablo Greco 0f1c57
 	if (!pci_use_e820)
Pablo Greco 0f1c57
 		return;
Pablo Greco 0f1c57
+#endif
Pablo Greco 08fca0
 
Pablo Greco 0f1c57
 	for (i = 0; i < e820_table->nr_entries; i++) {
Pablo Greco 0f1c57
 		entry = &e820_table->entries[i];
Pablo Greco 08fca0
-- 
Pablo Greco 0f1c57
2.39.1
Pablo Greco 08fca0