Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e5b48fd0 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Merge 4.9.322 into android-4.9-q



Changes in 4.9.322
	dm raid: fix KASAN warning in raid5_add_disks
	SUNRPC: Fix READ_PLUS crasher
	net: rose: fix UAF bugs caused by timer handler
	net: usb: ax88179_178a: Fix packet receiving
	usbnet: make sure no NULL pointer is passed through
	usbnet: fix memory allocation in helpers
	powerpc/powernv: wire up rng during setup_arch
	caif_virtio: fix race between virtio_device_ready() and ndo_open()
	netfilter: nft_dynset: restore set element counter when failing to update
	net: bonding: fix possible NULL deref in rlb code
	net: bonding: fix use-after-free after 802.3ad slave unbind
	nfc: nfcmrvl: Fix irq_of_parse_and_map() return value
	NFC: nxp-nci: Don't issue a zero length i2c_master_read()
	xen/gntdev: Avoid blocking in unmap_grant_pages()
	hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails
	sit: use min
	ipv6/sit: fix ipip6_tunnel_get_prl return value
	net: Rename and export copy_skb_header
	xen/blkfront: fix leaking data in shared pages
	xen/netfront: fix leaking data in shared pages
	xen/netfront: force data bouncing when backend is untrusted
	xen/blkfront: force data bouncing when backend is untrusted
	xen/arm: Fix race in RB-tree based P2M accounting
	qmi_wwan: Added support for Telit LN940 series
	net: usb: qmi_wwan: add Telit 0x1260 and 0x1261 compositions
	net: usb: qmi_wwan: add Telit LE910Cx 0x1230 composition
	net: usb: qmi_wwan: add Telit 0x1060 composition
	net: usb: qmi_wwan: add Telit 0x1070 composition
	Linux 4.9.322

Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
Change-Id: I38531cdafc0a16ea008a8b3f97129d01faaeea24
parents 47df8523 44551420
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
VERSION = 4
PATCHLEVEL = 9
SUBLEVEL = 321
SUBLEVEL = 322
EXTRAVERSION =
NAME = Roaring Lionus

+4 −2
Original line number Diff line number Diff line
@@ -61,11 +61,12 @@ static int xen_add_phys_to_mach_entry(struct xen_p2m_entry *new)

unsigned long __pfn_to_mfn(unsigned long pfn)
{
	struct rb_node *n = phys_to_mach.rb_node;
	struct rb_node *n;
	struct xen_p2m_entry *entry;
	unsigned long irqflags;

	read_lock_irqsave(&p2m_lock, irqflags);
	n = phys_to_mach.rb_node;
	while (n) {
		entry = rb_entry(n, struct xen_p2m_entry, rbnode_phys);
		if (entry->pfn <= pfn &&
@@ -151,10 +152,11 @@ bool __set_phys_to_machine_multi(unsigned long pfn,
	int rc;
	unsigned long irqflags;
	struct xen_p2m_entry *p2m_entry;
	struct rb_node *n = phys_to_mach.rb_node;
	struct rb_node *n;

	if (mfn == INVALID_P2M_ENTRY) {
		write_lock_irqsave(&p2m_lock, irqflags);
		n = phys_to_mach.rb_node;
		while (n) {
			p2m_entry = rb_entry(n, struct xen_p2m_entry, rbnode_phys);
			if (p2m_entry->pfn <= pfn &&
+4 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@
#define PPC_INST_COPY			0x7c00060c
#define PPC_INST_COPY_FIRST		0x7c20060c
#define PPC_INST_CP_ABORT		0x7c00068c
#define PPC_INST_DARN			0x7c0005e6
#define PPC_INST_DCBA			0x7c0005ec
#define PPC_INST_DCBA_MASK		0xfc0007fe
#define PPC_INST_DCBAL			0x7c2005ec
@@ -328,6 +329,9 @@

/* Deal with instructions that older assemblers aren't aware of */
#define	PPC_CP_ABORT		stringify_in_c(.long PPC_INST_CP_ABORT)
#define PPC_DARN(t, l)		stringify_in_c(.long PPC_INST_DARN |  \
						___PPC_RT(t)	   |  \
						(((l) & 0x3) << 16))
#define	PPC_DCBAL(a, b)		stringify_in_c(.long PPC_INST_DCBAL | \
					__PPC_RA(a) | __PPC_RB(b))
#define	PPC_DCBZL(a, b)		stringify_in_c(.long PPC_INST_DCBZL | \
+2 −0
Original line number Diff line number Diff line
@@ -27,4 +27,6 @@ extern void opal_event_shutdown(void);

bool cpu_core_split_required(void);

void pnv_rng_init(void);

#endif /* _POWERNV_H */
+77 −14
Original line number Diff line number Diff line
@@ -16,11 +16,14 @@
#include <linux/slab.h>
#include <linux/smp.h>
#include <asm/archrandom.h>
#include <asm/cputable.h>
#include <asm/io.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/smp.h>
#include "powernv.h"

#define DARN_ERR 0xFFFFFFFFFFFFFFFFul

struct powernv_rng {
	void __iomem *regs;
@@ -30,7 +33,6 @@ struct powernv_rng {

static DEFINE_PER_CPU(struct powernv_rng *, powernv_rng);


int powernv_hwrng_present(void)
{
	struct powernv_rng *rng;
@@ -45,7 +47,11 @@ static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val)
	unsigned long parity;

	/* Calculate the parity of the value */
	asm ("popcntd %0,%1" : "=r" (parity) : "r" (val));
	asm (".machine push;   \
	      .machine power7; \
	      popcntd %0,%1;   \
	      .machine pop;"
	     : "=r" (parity) : "r" (val));

	/* xor our value with the previous mask */
	val ^= rng->mask;
@@ -67,6 +73,38 @@ int powernv_get_random_real_mode(unsigned long *v)
	return 1;
}

static int powernv_get_random_darn(unsigned long *v)
{
	unsigned long val;

	/* Using DARN with L=1 - 64-bit conditioned random number */
	asm volatile(PPC_DARN(%0, 1) : "=r"(val));

	if (val == DARN_ERR)
		return 0;

	*v = val;

	return 1;
}

static int __init initialise_darn(void)
{
	unsigned long val;
	int i;

	if (!cpu_has_feature(CPU_FTR_ARCH_300))
		return -ENODEV;

	for (i = 0; i < 10; i++) {
		if (powernv_get_random_darn(&val)) {
			ppc_md.get_random_seed = powernv_get_random_darn;
			return 0;
		}
	}
	return -EIO;
}

int powernv_get_random_long(unsigned long *v)
{
	struct powernv_rng *rng;
@@ -88,7 +126,7 @@ static __init void rng_init_per_cpu(struct powernv_rng *rng,

	chip_id = of_get_ibm_chip_id(dn);
	if (chip_id == -1)
		pr_warn("No ibm,chip-id found for %s.\n", dn->full_name);
		pr_warn("No ibm,chip-id found for %pOF.\n", dn);

	for_each_possible_cpu(cpu) {
		if (per_cpu(powernv_rng, cpu) == NULL ||
@@ -126,30 +164,55 @@ static __init int rng_create(struct device_node *dn)

	rng_init_per_cpu(rng, dn);

	pr_info_once("Registering arch random hook.\n");

	ppc_md.get_random_seed = powernv_get_random_long;

	return 0;
}

static __init int rng_init(void)
static int __init pnv_get_random_long_early(unsigned long *v)
{
	struct device_node *dn;
	int rc;

	if (!slab_is_available())
		return 0;

	if (cmpxchg(&ppc_md.get_random_seed, pnv_get_random_long_early,
		    NULL) != pnv_get_random_long_early)
		return 0;

	for_each_compatible_node(dn, NULL, "ibm,power-rng") {
		rc = rng_create(dn);
		if (rc) {
			pr_err("Failed creating rng for %s (%d).\n",
				dn->full_name, rc);
		if (rng_create(dn))
			continue;
		}

		/* Create devices for hwrng driver */
		of_platform_device_create(dn, NULL, NULL);
	}

	if (!ppc_md.get_random_seed)
		return 0;
	return ppc_md.get_random_seed(v);
}

void __init pnv_rng_init(void)
{
	struct device_node *dn;

	/* Prefer darn over the rest. */
	if (!initialise_darn())
		return;

	dn = of_find_compatible_node(NULL, NULL, "ibm,power-rng");
	if (dn)
		ppc_md.get_random_seed = pnv_get_random_long_early;

	of_node_put(dn);
}

static int __init pnv_rng_late_init(void)
{
	unsigned long v;
	/* In case it wasn't called during init for some other reason. */
	if (ppc_md.get_random_seed == pnv_get_random_long_early)
		pnv_get_random_long_early(&v);
	return 0;
}
machine_subsys_initcall(powernv, rng_init);
machine_subsys_initcall(powernv, pnv_rng_late_init);
Loading