linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Vasily Gorbik <gor@linux.vnet.ibm.com>
Subject: [PATCH 4.4 76/92] s390: add assembler macros for CPU alternatives
Date: Thu, 24 May 2018 11:38:53 +0200	[thread overview]
Message-ID: <20180524093206.575196384@linuxfoundation.org> (raw)
In-Reply-To: <20180524093159.286472249@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Martin Schwidefsky <schwidefsky@de.ibm.com>

[ Upstream commit fba9eb7946251d6e420df3bdf7bc45195be7be9a ]

Add a header with macros usable in assembler files to emit alternative
code sequences. It works analog to the alternatives for inline assmeblies
in C files, with the same restrictions and capabilities.
The syntax is

     ALTERNATIVE "<default instructions sequence>", \
		 "<alternative instructions sequence>", \
		 "<features-bit>"
and

     ALTERNATIVE_2 "<default instructions sequence>", \
		   "<alternative instructions sqeuence #1>", \
		   "<feature-bit #1>",
		   "<alternative instructions sqeuence #2>", \
		   "<feature-bit #2>"

Reviewed-by: Vasily Gorbik <gor@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/s390/include/asm/alternative-asm.h |  108 ++++++++++++++++++++++++++++++++
 1 file changed, 108 insertions(+)
 create mode 100644 arch/s390/include/asm/alternative-asm.h

--- /dev/null
+++ b/arch/s390/include/asm/alternative-asm.h
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_S390_ALTERNATIVE_ASM_H
+#define _ASM_S390_ALTERNATIVE_ASM_H
+
+#ifdef __ASSEMBLY__
+
+/*
+ * Check the length of an instruction sequence. The length may not be larger
+ * than 254 bytes and it has to be divisible by 2.
+ */
+.macro alt_len_check start,end
+	.if ( \end - \start ) > 254
+	.error "cpu alternatives does not support instructions blocks > 254 bytes\n"
+	.endif
+	.if ( \end - \start ) % 2
+	.error "cpu alternatives instructions length is odd\n"
+	.endif
+.endm
+
+/*
+ * Issue one struct alt_instr descriptor entry (need to put it into
+ * the section .altinstructions, see below). This entry contains
+ * enough information for the alternatives patching code to patch an
+ * instruction. See apply_alternatives().
+ */
+.macro alt_entry orig_start, orig_end, alt_start, alt_end, feature
+	.long	\orig_start - .
+	.long	\alt_start - .
+	.word	\feature
+	.byte	\orig_end - \orig_start
+	.byte	\alt_end - \alt_start
+.endm
+
+/*
+ * Fill up @bytes with nops. The macro emits 6-byte nop instructions
+ * for the bulk of the area, possibly followed by a 4-byte and/or
+ * a 2-byte nop if the size of the area is not divisible by 6.
+ */
+.macro alt_pad_fill bytes
+	.fill	( \bytes ) / 6, 6, 0xc0040000
+	.fill	( \bytes ) % 6 / 4, 4, 0x47000000
+	.fill	( \bytes ) % 6 % 4 / 2, 2, 0x0700
+.endm
+
+/*
+ * Fill up @bytes with nops. If the number of bytes is larger
+ * than 6, emit a jg instruction to branch over all nops, then
+ * fill an area of size (@bytes - 6) with nop instructions.
+ */
+.macro alt_pad bytes
+	.if ( \bytes > 0 )
+	.if ( \bytes > 6 )
+	jg	. + \bytes
+	alt_pad_fill \bytes - 6
+	.else
+	alt_pad_fill \bytes
+	.endif
+	.endif
+.endm
+
+/*
+ * Define an alternative between two instructions. If @feature is
+ * present, early code in apply_alternatives() replaces @oldinstr with
+ * @newinstr. ".skip" directive takes care of proper instruction padding
+ * in case @newinstr is longer than @oldinstr.
+ */
+.macro ALTERNATIVE oldinstr, newinstr, feature
+	.pushsection .altinstr_replacement,"ax"
+770:	\newinstr
+771:	.popsection
+772:	\oldinstr
+773:	alt_len_check 770b, 771b
+	alt_len_check 772b, 773b
+	alt_pad ( ( 771b - 770b ) - ( 773b - 772b ) )
+774:	.pushsection .altinstructions,"a"
+	alt_entry 772b, 774b, 770b, 771b, \feature
+	.popsection
+.endm
+
+/*
+ * Define an alternative between two instructions. If @feature is
+ * present, early code in apply_alternatives() replaces @oldinstr with
+ * @newinstr. ".skip" directive takes care of proper instruction padding
+ * in case @newinstr is longer than @oldinstr.
+ */
+.macro ALTERNATIVE_2 oldinstr, newinstr1, feature1, newinstr2, feature2
+	.pushsection .altinstr_replacement,"ax"
+770:	\newinstr1
+771:	\newinstr2
+772:	.popsection
+773:	\oldinstr
+774:	alt_len_check 770b, 771b
+	alt_len_check 771b, 772b
+	alt_len_check 773b, 774b
+	.if ( 771b - 770b > 772b - 771b )
+	alt_pad ( ( 771b - 770b ) - ( 774b - 773b ) )
+	.else
+	alt_pad ( ( 772b - 771b ) - ( 774b - 773b ) )
+	.endif
+775:	.pushsection .altinstructions,"a"
+	alt_entry 773b, 775b, 770b, 771b,\feature1
+	alt_entry 773b, 775b, 771b, 772b,\feature2
+	.popsection
+.endm
+
+#endif	/*  __ASSEMBLY__  */
+
+#endif /* _ASM_S390_ALTERNATIVE_ASM_H */

  parent reply	other threads:[~2018-05-24  9:46 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24  9:37 [PATCH 4.4 00/92] 4.4.133-stable review Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 01/92] 8139too: Use disable_irq_nosync() in rtl8139_poll_controller() Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 02/92] bridge: check iface upper dev when setting master via ioctl Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 03/92] dccp: fix tasklet usage Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 04/92] ipv4: fix memory leaks in udp_sendmsg, ping_v4_sendmsg Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 05/92] llc: better deal with too small mtu Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 06/92] net: ethernet: sun: niu set correct packet size in skb Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 07/92] net/mlx4_en: Verify coalescing parameters are in range Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 08/92] net_sched: fq: take care of throttled flows before reuse Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 09/92] net: support compat 64-bit time in {s,g}etsockopt Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 10/92] openvswitch: Dont swap table in nlattr_set() after OVS_ATTR_NESTED is found Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 11/92] qmi_wwan: do not steal interfaces from class drivers Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 12/92] r8169: fix powering up RTL8168h Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 13/92] sctp: handle two v4 addrs comparison in sctp_inet6_cmp_addr Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 14/92] sctp: use the old asoc when making the cookie-ack chunk in dupcook_d Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 15/92] tg3: Fix vunmap() BUG_ON() triggered from tg3_free_consistent() Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 16/92] bonding: do not allow rlb updates to invalid mac Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 17/92] tcp: ignore Fast Open on repair mode Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 18/92] sctp: fix the issue that the cookie-ack with auth cant get processed Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 19/92] sctp: delay the authentication for the duplicated cookie-echo chunk Greg Kroah-Hartman
2018-06-06 22:31   ` Ben Hutchings
2018-06-07 18:21     ` Marcelo Ricardo Leitner
2018-05-24  9:37 ` [PATCH 4.4 20/92] ALSA: timer: Call notifier in the same spinlock Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 21/92] audit: move calcs after alloc and check when logging set loginuid Greg Kroah-Hartman
2018-05-24  9:37 ` [PATCH 4.4 22/92] arm64: introduce mov_q macro to move a constant into a 64-bit register Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 23/92] arm64: Add work around for Arm Cortex-A55 Erratum 1024718 Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 24/92] futex: Remove unnecessary warning from get_futex_key Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 25/92] futex: Remove duplicated code and fix undefined behaviour Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 26/92] xfrm: fix xfrm_do_migrate() with AEAD e.g(AES-GCM) Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 27/92] lockd: lost rollback of set_grace_period() in lockd_down_net() Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 28/92] Revert "ARM: dts: imx6qdl-wandboard: Fix audio channel swap" Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 29/92] l2tp: revert "l2tp: fix missing print session offset info" Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 30/92] pipe: cap initial pipe capacity according to pipe-max-size limit Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 31/92] futex: futex_wake_op, fix sign_extend32 sign bits Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 32/92] kernel/exit.c: avoid undefined behaviour when calling wait4() Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 33/92] usbip: usbip_host: refine probe and disconnect debug msgs to be useful Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 34/92] usbip: usbip_host: delete device from busid_table after rebind Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 35/92] usbip: usbip_host: run rebind from exit when module is removed Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 36/92] usbip: usbip_host: fix NULL-ptr deref and use-after-free errors Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 37/92] usbip: usbip_host: fix bad unlock balance during stub_probe() Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 38/92] ALSA: usb: mixer: volume quirk for CM102-A+/102S+ Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 39/92] ALSA: hda: Add Lenovo C50 All in one to the power_save blacklist Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 40/92] ALSA: control: fix a redundant-copy issue Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 41/92] spi: pxa2xx: Allow 64-bit DMA Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 42/92] powerpc/powernv: panic() on OPAL < V3 Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 43/92] powerpc/powernv: Remove OPALv2 firmware define and references Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 44/92] powerpc/powernv: remove FW_FEATURE_OPALv3 and just use FW_FEATURE_OPAL Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 45/92] cpuidle: coupled: remove unused define cpuidle_coupled_lock Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 46/92] powerpc: Dont preempt_disable() in show_cpuinfo() Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 47/92] vmscan: do not force-scan file lru if its absolute size is small Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 48/92] proc: meminfo: estimate available memory more conservatively Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 49/92] mm: filemap: remove redundant code in do_read_cache_page Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 50/92] mm: filemap: avoid unnecessary calls to lock_page when waiting for IO to complete during a read Greg Kroah-Hartman
2018-05-24 10:50   ` Jan Kara
2018-05-24 11:05     ` Greg Kroah-Hartman
2018-05-24 11:17       ` Hugh Dickins
2018-05-24 11:28         ` Greg KH
2018-05-24 12:02           ` Jan Kara
2018-05-24 13:12             ` Mel Gorman
2018-05-24 17:27           ` Hugh Dickins
2018-05-24 19:06             ` Greg KH
2018-05-24 20:01               ` Hugh Dickins
2018-11-01 21:45               ` Pavel Machek
2018-05-24  9:38 ` [PATCH 4.4 51/92] signals: avoid unnecessary taking of sighand->siglock Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 52/92] cpufreq: intel_pstate: Enable HWP by default Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 53/92] tracing/x86/xen: Remove zero data size trace events trace_xen_mmu_flush_tlb{_all} Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 54/92] proc read mms {arg,env}_{start,end} with mmap semaphore taken Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 55/92] procfs: fix pthread cross-thread naming if !PR_DUMPABLE Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 56/92] powerpc/powernv: Fix NVRAM sleep in invalid context when crashing Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 57/92] mm: dont allow deferred pages with NEED_PER_CPU_KM Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 58/92] s390/qdio: fix access to uninitialized qdio_q fields Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 59/92] s390/cpum_sf: ensure sample frequency of perf event attributes is non-zero Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 60/92] s390/qdio: dont release memory in qdio_setup_irq() Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 61/92] s390: remove indirect branch from do_softirq_own_stack Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 62/92] efi: Avoid potential crashes, fix the struct efi_pci_io_protocol_32 definition for mixed mode Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 63/92] ARM: 8771/1: kprobes: Prohibit kprobes on do_undefinstr Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 64/92] tick/broadcast: Use for_each_cpu() specially on UP kernels Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 65/92] ARM: 8769/1: kprobes: Fix to use get_kprobe_ctlblk after irq-disabed Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 66/92] ARM: 8770/1: kprobes: Prohibit probing on optimized_callback Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 67/92] ARM: 8772/1: kprobes: Prohibit kprobes on get_user functions Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 68/92] Btrfs: fix xattr loss after power failure Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 69/92] btrfs: fix crash when trying to resume balance without the resume flag Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 70/92] btrfs: fix reading stale metadata blocks after degraded raid1 mounts Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 71/92] net: test tailroom before appending to linear skb Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 72/92] packet: in packet_snd start writing at link layer allocation Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 73/92] sock_diag: fix use-after-free read in __sk_free Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 74/92] tcp: purge write queue in tcp_connect_init() Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 75/92] ext2: fix a block leak Greg Kroah-Hartman
2018-05-24  9:38 ` Greg Kroah-Hartman [this message]
2018-05-24  9:38 ` [PATCH 4.4 77/92] s390: move expoline assembler macros to a header Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 78/92] s390/lib: use expoline for indirect branches Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 79/92] s390/ftrace: " Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 80/92] s390/kernel: " Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 81/92] s390: move spectre sysfs attribute code Greg Kroah-Hartman
2018-05-24  9:38 ` [PATCH 4.4 82/92] s390: extend expoline to BC instructions Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 83/92] s390: use expoline thunks in the BPF JIT Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 84/92] scsi: libsas: defer ata device eh commands to libata Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 85/92] scsi: sg: allocate with __GFP_ZERO in sg_build_indirect() Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 86/92] scsi: zfcp: fix infinite iteration on ERP ready list Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 87/92] dmaengine: ensure dmaengine helpers check valid callback Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 88/92] time: Fix CLOCK_MONOTONIC_RAW sub-nanosecond accounting Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 89/92] gpio: rcar: Add Runtime PM handling for interrupts Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 90/92] cfg80211: limit wiphy names to 128 bytes Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 91/92] hfsplus: stop workqueue when fill_super() failed Greg Kroah-Hartman
2018-05-24  9:39 ` [PATCH 4.4 92/92] x86/kexec: Avoid double free_page() upon do_kexec_load() failure Greg Kroah-Hartman
2018-05-24 13:22 ` [PATCH 4.4 00/92] 4.4.133-stable review Guenter Roeck
2018-05-24 14:45 ` Nathan Chancellor
2018-05-24 16:46 ` kernelci.org bot
2018-05-24 17:32 ` Guenter Roeck
2018-05-24 19:47   ` Greg Kroah-Hartman
2018-05-25 14:11     ` Greg Kroah-Hartman
2018-05-25 16:39       ` Guenter Roeck
2018-05-25 16:50         ` Greg Kroah-Hartman
2018-05-24 18:06 ` Dan Rue
2018-05-24 18:17   ` Guenter Roeck
2018-05-24 21:34     ` Naresh Kamboju
2018-05-24 21:52       ` Shuah Khan
2018-05-25  0:11         ` Dan Rue
2018-05-24 19:08   ` Greg Kroah-Hartman
2018-05-24 20:31     ` Rafael Tinoco
2018-05-25  1:34       ` Daniel Sangorrin
2018-05-25  2:51         ` Rafael Tinoco
2018-05-25  6:11           ` Daniel Sangorrin
2018-05-25  7:58         ` Naresh Kamboju
2018-05-25  0:46     ` Dan Rue
2018-05-24 19:28 ` Shuah Khan

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=20180524093206.575196384@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=gor@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.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).