kernel: Move to Linux v5.4.48-openpower1

This adds secure boot support backported from upstream and enables it
in the configuration.

Appearing in the backports is a patch to disable STRICT_KERNEL_RWX so
it drops out of the configuration.

Backported patches to support secureboot:

 powerpc/ima: Fix secure boot rules in ima arch policy
 powerpc/ima: Indicate kernel modules appended signatures are enforced
 powerpc/xmon: Allow listing and clearing breakpoints in read-only mode
 powerpc: Load firmware trusted keys/hashes into kernel keyring
 x86/efi: move common keyring handler functions to new file
 powerpc: expose secure variables to userspace via sysfs
 powerpc/powernv: Add OPAL API interface to access secure variable
 powerpc/ima: Update ima arch policy to check for blacklist
 ima: Check against blacklisted hashes for files with modsig
 certs: Add wrapper function to check blacklisted binary hash
 ima: Make process_buffer_measurement() generic
 powerpc/ima: Define trusted boot policy
 powerpc: Detect the trusted boot state of the system
 powerpc/ima: Add support to initialize ima policy rules
 powerpc: Detect the secure boot mode of the system

PowerPC related fixes:

 powerpc/64s: Save FSCR to init_task.thread.fscr after feature init
 powerpc/64s: Don't let DT CPU features set FSCR_DSCR
 powerpc/kasan: Fix shadow pages allocation failure
 powerpc/kasan: Fix issues by lowering KASAN_SHADOW_END
 powerpc/fadump: Account for memory_limit while reserving memory
 powerpc/fadump: consider reserved ranges while reserving memory
 powerpc/fadump: use static allocation for reserved memory ranges
 powerpc/mm: Fix conditions to perform MMU specific management by blocks on PPC32.
 powerpc/spufs: fix copy_to_user while atomic
 sched/core: Fix illegal RCU from offline CPUs
 powerpc/ptdump: Properly handle non standard page size
 powerpc/xive: Clear the page tables for the ESB IO mapping
 bpf: Support llvm-objcopy for vmlinux BTF
 powerpc/xmon: Restrict when kernel is locked down
 powerpc/powernv: Avoid re-registration of imc debugfs directory
 powerpc/64s: Disable STRICT_KERNEL_RWX
 powerpc: Remove STRICT_KERNEL_RWX incompatibility with RELOCATABLE
 powerpc/mm: Fix CONFIG_PPC_KUAP_DEBUG on PPC32
 powerpc/kuap: PPC_KUAP_DEBUG should depend on PPC_KUAP
 powerpc/setup_64: Set cache-line-size based on cache-block-size
 Revert "powerpc/64: irq_work avoid interrupt when called with hardware irqs enabled"

Signed-off-by: Joel Stanley <joel@jms.id.au>
diff --git a/openpower/linux/0013-powerpc-Load-firmware-trusted-keys-hashes-into-kerne.patch b/openpower/linux/0013-powerpc-Load-firmware-trusted-keys-hashes-into-kerne.patch
new file mode 100644
index 0000000..9b6b06e
--- /dev/null
+++ b/openpower/linux/0013-powerpc-Load-firmware-trusted-keys-hashes-into-kerne.patch
@@ -0,0 +1,163 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Nayna Jain <nayna@linux.ibm.com>
+Date: Sun, 10 Nov 2019 21:10:36 -0600
+Subject: [PATCH 13/18] powerpc: Load firmware trusted keys/hashes into kernel
+ keyring
+
+The keys used to verify the Host OS kernel are managed by firmware as
+secure variables. This patch loads the verification keys into the
+.platform keyring and revocation hashes into .blacklist keyring. This
+enables verification and loading of the kernels signed by the boot
+time keys which are trusted by firmware.
+
+Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
+Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
+Signed-off-by: Eric Richter <erichte@linux.ibm.com>
+[mpe: Search by compatible in load_powerpc_certs(), not using format]
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/1573441836-3632-5-git-send-email-nayna@linux.ibm.com
+(cherry picked from commit 8220e22d11a05049aab9693839ab82e5e177ccde)
+Signed-off-by: Joel Stanley <joel@jms.id.au>
+---
+ security/integrity/Kconfig                    |  9 ++
+ security/integrity/Makefile                   |  4 +-
+ .../integrity/platform_certs/load_powerpc.c   | 96 +++++++++++++++++++
+ 3 files changed, 108 insertions(+), 1 deletion(-)
+ create mode 100644 security/integrity/platform_certs/load_powerpc.c
+
+diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig
+index 0bae6adb63a9..71f0177e8716 100644
+--- a/security/integrity/Kconfig
++++ b/security/integrity/Kconfig
+@@ -72,6 +72,15 @@ config LOAD_IPL_KEYS
+        depends on S390
+        def_bool y
+ 
++config LOAD_PPC_KEYS
++	bool "Enable loading of platform and blacklisted keys for POWER"
++	depends on INTEGRITY_PLATFORM_KEYRING
++	depends on PPC_SECURE_BOOT
++	default y
++	help
++	  Enable loading of keys to the .platform keyring and blacklisted
++	  hashes to the .blacklist keyring for powerpc based platforms.
++
+ config INTEGRITY_AUDIT
+ 	bool "Enables integrity auditing support "
+ 	depends on AUDIT
+diff --git a/security/integrity/Makefile b/security/integrity/Makefile
+index 351c9662994b..7ee39d66cf16 100644
+--- a/security/integrity/Makefile
++++ b/security/integrity/Makefile
+@@ -14,6 +14,8 @@ integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \
+ 				      platform_certs/load_uefi.o \
+ 				      platform_certs/keyring_handler.o
+ integrity-$(CONFIG_LOAD_IPL_KEYS) += platform_certs/load_ipl_s390.o
+-
++integrity-$(CONFIG_LOAD_PPC_KEYS) += platform_certs/efi_parser.o \
++                                     platform_certs/load_powerpc.o \
++                                     platform_certs/keyring_handler.o
+ obj-$(CONFIG_IMA)			+= ima/
+ obj-$(CONFIG_EVM)			+= evm/
+diff --git a/security/integrity/platform_certs/load_powerpc.c b/security/integrity/platform_certs/load_powerpc.c
+new file mode 100644
+index 000000000000..a2900cb85357
+--- /dev/null
++++ b/security/integrity/platform_certs/load_powerpc.c
+@@ -0,0 +1,96 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * Copyright (C) 2019 IBM Corporation
++ * Author: Nayna Jain
++ *
++ *      - loads keys and hashes stored and controlled by the firmware.
++ */
++#include <linux/kernel.h>
++#include <linux/sched.h>
++#include <linux/cred.h>
++#include <linux/err.h>
++#include <linux/slab.h>
++#include <linux/of.h>
++#include <asm/secure_boot.h>
++#include <asm/secvar.h>
++#include "keyring_handler.h"
++
++/*
++ * Get a certificate list blob from the named secure variable.
++ */
++static __init void *get_cert_list(u8 *key, unsigned long keylen, uint64_t *size)
++{
++	int rc;
++	void *db;
++
++	rc = secvar_ops->get(key, keylen, NULL, size);
++	if (rc) {
++		pr_err("Couldn't get size: %d\n", rc);
++		return NULL;
++	}
++
++	db = kmalloc(*size, GFP_KERNEL);
++	if (!db)
++		return NULL;
++
++	rc = secvar_ops->get(key, keylen, db, size);
++	if (rc) {
++		kfree(db);
++		pr_err("Error reading %s var: %d\n", key, rc);
++		return NULL;
++	}
++
++	return db;
++}
++
++/*
++ * Load the certs contained in the keys databases into the platform trusted
++ * keyring and the blacklisted X.509 cert SHA256 hashes into the blacklist
++ * keyring.
++ */
++static int __init load_powerpc_certs(void)
++{
++	void *db = NULL, *dbx = NULL;
++	uint64_t dbsize = 0, dbxsize = 0;
++	int rc = 0;
++	struct device_node *node;
++
++	if (!secvar_ops)
++		return -ENODEV;
++
++	/* The following only applies for the edk2-compat backend. */
++	node = of_find_compatible_node(NULL, NULL, "ibm,edk2-compat-v1");
++	if (!node)
++		return -ENODEV;
++
++	/*
++	 * Get db, and dbx. They might not exist, so it isn't an error if we
++	 * can't get them.
++	 */
++	db = get_cert_list("db", 3, &dbsize);
++	if (!db) {
++		pr_err("Couldn't get db list from firmware\n");
++	} else {
++		rc = parse_efi_signature_list("powerpc:db", db, dbsize,
++					      get_handler_for_db);
++		if (rc)
++			pr_err("Couldn't parse db signatures: %d\n", rc);
++		kfree(db);
++	}
++
++	dbx = get_cert_list("dbx", 4,  &dbxsize);
++	if (!dbx) {
++		pr_info("Couldn't get dbx list from firmware\n");
++	} else {
++		rc = parse_efi_signature_list("powerpc:dbx", dbx, dbxsize,
++					      get_handler_for_dbx);
++		if (rc)
++			pr_err("Couldn't parse dbx signatures: %d\n", rc);
++		kfree(dbx);
++	}
++
++	of_node_put(node);
++
++	return rc;
++}
++late_initcall(load_powerpc_certs);