stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	"Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>,
	Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH 4.14 42/51] powerpc/bpf: use unsigned division instruction for 64-bit operations
Date: Mon, 24 Jun 2019 17:57:00 +0800	[thread overview]
Message-ID: <20190624092310.844040207@linuxfoundation.org> (raw)
In-Reply-To: <20190624092305.919204959@linuxfoundation.org>

From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

commit 758f2046ea040773ae8ea7f72dd3bbd8fa984501 upstream.

BPF_ALU64 div/mod operations are currently using signed division, unlike
BPF_ALU32 operations. Fix the same. DIV64 and MOD64 overflow tests pass
with this fix.

Fixes: 156d0e290e969c ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
Cc: stable@vger.kernel.org # v4.8+
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/powerpc/include/asm/ppc-opcode.h |    1 +
 arch/powerpc/net/bpf_jit.h            |    2 +-
 arch/powerpc/net/bpf_jit_comp64.c     |    8 ++++----
 3 files changed, 6 insertions(+), 5 deletions(-)

--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -324,6 +324,7 @@
 #define PPC_INST_MULLI			0x1c000000
 #define PPC_INST_DIVWU			0x7c000396
 #define PPC_INST_DIVD			0x7c0003d2
+#define PPC_INST_DIVDU			0x7c000392
 #define PPC_INST_RLWINM			0x54000000
 #define PPC_INST_RLWIMI			0x50000000
 #define PPC_INST_RLDICL			0x78000000
--- a/arch/powerpc/net/bpf_jit.h
+++ b/arch/powerpc/net/bpf_jit.h
@@ -116,7 +116,7 @@
 				     ___PPC_RA(a) | IMM_L(i))
 #define PPC_DIVWU(d, a, b)	EMIT(PPC_INST_DIVWU | ___PPC_RT(d) |	      \
 				     ___PPC_RA(a) | ___PPC_RB(b))
-#define PPC_DIVD(d, a, b)	EMIT(PPC_INST_DIVD | ___PPC_RT(d) |	      \
+#define PPC_DIVDU(d, a, b)	EMIT(PPC_INST_DIVDU | ___PPC_RT(d) |	      \
 				     ___PPC_RA(a) | ___PPC_RB(b))
 #define PPC_AND(d, a, b)	EMIT(PPC_INST_AND | ___PPC_RA(d) |	      \
 				     ___PPC_RS(a) | ___PPC_RB(b))
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -415,12 +415,12 @@ static int bpf_jit_build_body(struct bpf
 			PPC_LI(b2p[BPF_REG_0], 0);
 			PPC_JMP(exit_addr);
 			if (BPF_OP(code) == BPF_MOD) {
-				PPC_DIVD(b2p[TMP_REG_1], dst_reg, src_reg);
+				PPC_DIVDU(b2p[TMP_REG_1], dst_reg, src_reg);
 				PPC_MULD(b2p[TMP_REG_1], src_reg,
 						b2p[TMP_REG_1]);
 				PPC_SUB(dst_reg, dst_reg, b2p[TMP_REG_1]);
 			} else
-				PPC_DIVD(dst_reg, dst_reg, src_reg);
+				PPC_DIVDU(dst_reg, dst_reg, src_reg);
 			break;
 		case BPF_ALU | BPF_MOD | BPF_K: /* (u32) dst %= (u32) imm */
 		case BPF_ALU | BPF_DIV | BPF_K: /* (u32) dst /= (u32) imm */
@@ -448,7 +448,7 @@ static int bpf_jit_build_body(struct bpf
 				break;
 			case BPF_ALU64:
 				if (BPF_OP(code) == BPF_MOD) {
-					PPC_DIVD(b2p[TMP_REG_2], dst_reg,
+					PPC_DIVDU(b2p[TMP_REG_2], dst_reg,
 							b2p[TMP_REG_1]);
 					PPC_MULD(b2p[TMP_REG_1],
 							b2p[TMP_REG_1],
@@ -456,7 +456,7 @@ static int bpf_jit_build_body(struct bpf
 					PPC_SUB(dst_reg, dst_reg,
 							b2p[TMP_REG_1]);
 				} else
-					PPC_DIVD(dst_reg, dst_reg,
+					PPC_DIVDU(dst_reg, dst_reg,
 							b2p[TMP_REG_1]);
 				break;
 			}



  parent reply	other threads:[~2019-06-24  9:59 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  9:56 [PATCH 4.14 00/51] 4.14.130-stable review Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 01/51] tracing: Silence GCC 9 array bounds warning Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 02/51] objtool: Support per-function rodata sections Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 03/51] gcc-9: silence address-of-packed-member warning Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 04/51] net: phy: broadcom: Use strlcpy() for ethtool::get_strings Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 05/51] mmc: core: Prevent processing SDIO IRQs when the card is suspended Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 06/51] scsi: ufs: Avoid runtime suspend possibly being blocked forever Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 07/51] usb: chipidea: udc: workaround for endpoint conflict issue Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 08/51] IB/hfi1: Silence txreq allocation warnings Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 09/51] Input: synaptics - enable SMBus on ThinkPad E480 and E580 Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 10/51] Input: uinput - add compat ioctl number translation for UI_*_FF_UPLOAD Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 11/51] apparmor: enforce nullbyte at end of tag string Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 12/51] ARC: fix build warnings Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 13/51] ARC: [plat-hsdk]: Add missing multicast filter bins number to GMAC node Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 14/51] ARC: [plat-hsdk]: Add missing FIFO size entry in " Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 15/51] parport: Fix mem leak in parport_register_dev_model Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 16/51] parisc: Fix compiler warnings in float emulation code Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 17/51] IB/rdmavt: Fix alloc_qpn() WARN_ON() Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 18/51] IB/hfi1: Insure freeze_work work_struct is canceled on shutdown Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 19/51] IB/{qib, hfi1, rdmavt}: Correct ibv_devinfo max_mr value Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 20/51] IB/hfi1: Validate page aligned for a given virtual address Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 21/51] MIPS: uprobes: remove set but not used variable epc Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 22/51] xtensa: Fix section mismatch between memblock_reserve and mem_reserve Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 23/51] net: dsa: mv88e6xxx: avoid error message on remove from VLAN 0 Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 24/51] net: hns: Fix loopback test failed at copper ports Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 25/51] mdesc: fix a missing-check bug in get_vdev_port_node_info() Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 26/51] sparc: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 27/51] net: ethernet: mediatek: Use hw_feature to judge if HWLRO is supported Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 28/51] net: ethernet: mediatek: Use NET_IP_ALIGN to judge if HW RX_2BYTE_OFFSET is enabled Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 29/51] drm/arm/hdlcd: Actually validate CRTC modes Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 30/51] drm/arm/hdlcd: Allow a bit of clock tolerance Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 31/51] scripts/checkstack.pl: Fix arm64 wrong or unknown architecture Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 32/51] scsi: ufs: Check that space was properly alloced in copy_query_response Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 33/51] scsi: smartpqi: unlock on error in pqi_submit_raid_request_synchronous() Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 34/51] net: ipvlan: Fix ipvlan device tso disabled while NETIF_F_IP_CSUM is set Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 35/51] s390/qeth: fix VLAN attribute in bridge_hostnotify udev event Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 36/51] hwmon: (core) add thermal sensors only if dev->of_node is present Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 37/51] hwmon: (pmbus/core) Treat parameters as paged if on multiple pages Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 38/51] nvme: Fix u32 overflow in the number of namespace list calculation Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 39/51] btrfs: start readahead also in seed devices Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 40/51] can: flexcan: fix timeout when set small bitrate Greg Kroah-Hartman
2019-06-24  9:56 ` [PATCH 4.14 41/51] can: purge socket error queue on sock destruct Greg Kroah-Hartman
2019-06-24  9:57 ` Greg Kroah-Hartman [this message]
2019-06-24  9:57 ` [PATCH 4.14 43/51] ARM: imx: cpuidle-imx6sx: Restrict the SW2ISO increase to i.MX6SX Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 44/51] ARM: dts: am57xx-idk: Remove support for voltage switching for SD card Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 45/51] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 46/51] Bluetooth: Fix regression with minimum encryption key size alignment Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 47/51] SMB3: retry on STATUS_INSUFFICIENT_RESOURCES instead of failing write Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 48/51] cfg80211: fix memory leak of wiphy device name Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 49/51] mac80211: drop robust management frames from unknown TA Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 50/51] mac80211: handle deauthentication/disassociation from TDLS peer Greg Kroah-Hartman
2019-06-24  9:57 ` [PATCH 4.14 51/51] mac80211: Do not use stack memory with scatterlist for GMAC Greg Kroah-Hartman
2019-06-24 15:31 ` [PATCH 4.14 00/51] 4.14.130-stable review kernelci.org bot
2019-06-24 15:47 ` Naresh Kamboju
2019-06-24 18:03 ` Guenter Roeck
2019-06-25  9:59 ` Jon Hunter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190624092310.844040207@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).