aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2017-03-02 02:05:45 -0500
committerIngo Molnar <mingo@kernel.org>2017-03-02 02:05:45 -0500
commit9d020d33fc1b2faa0eb35859df1381ca5dc94ffe (patch)
treeadcd4356b93b17b42c9e4ef95c3fea3afa52f3ee
parent6b0b7551428e4caae1e2c023a529465a9a9ae2d4 (diff)
parent4977ab6e92e267afe9d8f78438c3db330ca8434c (diff)
Merge branch 'linus' into perf/urgent, to resolve conflict
Conflicts: arch/powerpc/configs/85xx/kmp204x_defconfig Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/pwm/imx-pwm.txt6
-rw-r--r--Documentation/devicetree/bindings/thermal/qoriq-thermal.txt7
-rw-r--r--Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt56
-rw-r--r--Documentation/devicetree/bindings/thermal/zx2967-thermal.txt116
-rw-r--r--Documentation/filesystems/f2fs.txt7
-rw-r--r--MAINTAINERS8
-rw-r--r--arch/arm64/include/asm/cpufeature.h14
-rw-r--r--arch/arm64/mm/mmu.c34
-rw-r--r--arch/arm64/mm/proc.S2
-rw-r--r--arch/powerpc/Kconfig2
-rw-r--r--arch/powerpc/boot/dts/fsl/kmcent2.dts303
-rw-r--r--arch/powerpc/boot/dts/fsl/kmcoge4.dts4
-rw-r--r--arch/powerpc/boot/dts/fsl/t1023si-post.dtsi4
-rw-r--r--arch/powerpc/boot/dts/fsl/t1040si-post.dtsi4
-rw-r--r--arch/powerpc/configs/85xx/kmp204x_defconfig220
-rw-r--r--arch/powerpc/configs/pseries_defconfig1
-rw-r--r--arch/powerpc/include/asm/bitops.h28
-rw-r--r--arch/powerpc/include/asm/pnv-pci.h2
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h1
-rw-r--r--arch/powerpc/include/asm/processor.h2
-rw-r--r--arch/powerpc/include/asm/prom.h1
-rw-r--r--arch/powerpc/include/asm/reg.h2
-rw-r--r--arch/powerpc/include/asm/reg_8xx.h11
-rw-r--r--arch/powerpc/include/asm/rtas.h2
-rw-r--r--arch/powerpc/kernel/asm-offsets.c772
-rw-r--r--arch/powerpc/kernel/cpu_setup_power.S4
-rw-r--r--arch/powerpc/kernel/cputable.c17
-rw-r--r--arch/powerpc/kernel/entry_32.S19
-rw-r--r--arch/powerpc/kernel/head_32.S3
-rw-r--r--arch/powerpc/kernel/head_8xx.S72
-rw-r--r--arch/powerpc/kernel/hw_breakpoint.c6
-rw-r--r--arch/powerpc/kernel/optprobes_head.S7
-rw-r--r--arch/powerpc/kernel/pci-common.c10
-rw-r--r--arch/powerpc/kernel/process.c22
-rw-r--r--arch/powerpc/kernel/prom_init.c2
-rw-r--r--arch/powerpc/kernel/setup_64.c12
-rw-r--r--arch/powerpc/kernel/time.c2
-rw-r--r--arch/powerpc/mm/pgtable.c4
-rw-r--r--arch/powerpc/mm/slb_low.S24
-rw-r--r--arch/powerpc/perf/8xx-pmu.c173
-rw-r--r--arch/powerpc/perf/Makefile2
-rw-r--r--arch/powerpc/perf/core-book3s.c38
-rw-r--r--arch/powerpc/perf/isa207-common.c94
-rw-r--r--arch/powerpc/perf/isa207-common.h7
-rw-r--r--arch/powerpc/perf/power8-pmu.c35
-rw-r--r--arch/powerpc/perf/power9-events-list.h3
-rw-r--r--arch/powerpc/perf/power9-pmu.c47
-rw-r--r--arch/powerpc/platforms/85xx/Makefile1
-rw-r--r--arch/powerpc/platforms/85xx/corenet_generic.c1
-rw-r--r--arch/powerpc/platforms/85xx/t1042rdb_diu.c152
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype7
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c65
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h3
-rw-r--r--arch/powerpc/platforms/powernv/Kconfig3
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c2
-rw-r--r--arch/powerpc/platforms/pseries/dlpar.c38
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-memory.c272
-rw-r--r--arch/powerpc/xmon/ppc-dis.c260
-rw-r--r--arch/powerpc/xmon/ppc-opc.c8999
-rw-r--r--arch/powerpc/xmon/ppc.h268
-rw-r--r--arch/powerpc/xmon/xmon.c58
-rw-r--r--arch/x86/kernel/vmlinux.lds.S2
-rw-r--r--drivers/acpi/acpi_lpss.c14
-rw-r--r--drivers/dma-buf/dma-buf.c3
-rw-r--r--drivers/gpu/drm/ast/ast_dram_tables.h62
-rw-r--r--drivers/gpu/drm/ast/ast_drv.h12
-rw-r--r--drivers/gpu/drm/ast/ast_main.c304
-rw-r--r--drivers/gpu/drm/ast/ast_mode.c38
-rw-r--r--drivers/gpu/drm/ast/ast_post.c562
-rw-r--r--drivers/gpu/drm/ast/ast_tables.h164
-rw-r--r--drivers/gpu/drm/rockchip/Kconfig1
-rw-r--r--drivers/gpu/drm/rockchip/cdn-dp-core.c4
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c11
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h4
-rw-r--r--drivers/gpu/drm/zte/zx_plane.c4
-rw-r--r--drivers/input/rmi4/rmi_f30.c5
-rw-r--r--drivers/leds/leds-pwm.c16
-rw-r--r--drivers/misc/cxl/cxl.h5
-rw-r--r--drivers/misc/cxl/main.c3
-rw-r--r--drivers/misc/cxl/pci.c11
-rw-r--r--drivers/misc/cxl/vphb.c18
-rw-r--r--drivers/pci/hotplug/pnv_php.c81
-rw-r--r--drivers/pwm/Kconfig4
-rw-r--r--drivers/pwm/core.c70
-rw-r--r--drivers/pwm/pwm-atmel-hlcdc.c1
-rw-r--r--drivers/pwm/pwm-atmel.c1
-rw-r--r--drivers/pwm/pwm-bcm-kona.c1
-rw-r--r--drivers/pwm/pwm-berlin.c1
-rw-r--r--drivers/pwm/pwm-bfin.c2
-rw-r--r--drivers/pwm/pwm-brcmstb.c1
-rw-r--r--drivers/pwm/pwm-fsl-ftm.c1
-rw-r--r--drivers/pwm/pwm-imx.c272
-rw-r--r--drivers/pwm/pwm-lp3943.c1
-rw-r--r--drivers/pwm/pwm-lpss-pci.c22
-rw-r--r--drivers/pwm/pwm-lpss-platform.c21
-rw-r--r--drivers/pwm/pwm-lpss.c132
-rw-r--r--drivers/pwm/pwm-lpss.h4
-rw-r--r--drivers/pwm/pwm-mxs.c2
-rw-r--r--drivers/pwm/pwm-pca9685.c176
-rw-r--r--drivers/pwm/pwm-pxa.c2
-rw-r--r--drivers/pwm/pwm-sti.c1
-rw-r--r--drivers/pwm/pwm-sun4i.c1
-rw-r--r--drivers/pwm/pwm-twl-led.c1
-rw-r--r--drivers/pwm/pwm-twl.c1
-rw-r--r--drivers/pwm/pwm-vt8500.c2
-rw-r--r--drivers/staging/greybus/pwm.c1
-rw-r--r--drivers/thermal/Kconfig17
-rw-r--r--drivers/thermal/Makefile2
-rw-r--r--drivers/thermal/clock_cooling.c50
-rw-r--r--drivers/thermal/cpu_cooling.c102
-rw-r--r--drivers/thermal/devfreq_cooling.c53
-rw-r--r--drivers/thermal/imx_thermal.c4
-rw-r--r--drivers/thermal/intel_powerclamp.c4
-rw-r--r--drivers/thermal/mtk_thermal.c16
-rw-r--r--drivers/thermal/rcar_gen3_thermal.c335
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c1
-rw-r--r--drivers/thermal/samsung/exynos_tmu.h1
-rw-r--r--drivers/thermal/thermal_core.c75
-rw-r--r--drivers/thermal/ti-soc-thermal/Kconfig1
-rw-r--r--drivers/thermal/ti-soc-thermal/dra752-bandgap.h19
-rw-r--r--drivers/thermal/ti-soc-thermal/dra752-thermal-data.c28
-rw-r--r--drivers/thermal/zx2967_thermal.c258
-rw-r--r--fs/f2fs/checkpoint.c70
-rw-r--r--fs/f2fs/data.c191
-rw-r--r--fs/f2fs/debug.c31
-rw-r--r--fs/f2fs/dir.c38
-rw-r--r--fs/f2fs/extent_cache.c52
-rw-r--r--fs/f2fs/f2fs.h644
-rw-r--r--fs/f2fs/file.c36
-rw-r--r--fs/f2fs/gc.c79
-rw-r--r--fs/f2fs/inode.c4
-rw-r--r--fs/f2fs/namei.c18
-rw-r--r--fs/f2fs/node.c560
-rw-r--r--fs/f2fs/node.h33
-rw-r--r--fs/f2fs/recovery.c17
-rw-r--r--fs/f2fs/segment.c501
-rw-r--r--fs/f2fs/segment.h40
-rw-r--r--fs/f2fs/super.c138
-rw-r--r--fs/f2fs/xattr.c151
-rw-r--r--fs/f2fs/xattr.h7
-rw-r--r--fs/nfs/cache_lib.c3
-rw-r--r--fs/nfs/callback_xdr.c38
-rw-r--r--fs/nfs/dir.c36
-rw-r--r--fs/nfs/filelayout/filelayout.c6
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c60
-rw-r--r--fs/nfs/nfs42proc.c69
-rw-r--r--fs/nfs/nfs4_fs.h15
-rw-r--r--fs/nfs/nfs4proc.c390
-rw-r--r--fs/nfs/nfs4renewd.c2
-rw-r--r--fs/nfs/nfs4session.h7
-rw-r--r--fs/nfs/nfs4state.c2
-rw-r--r--fs/nfs/nfs4trace.h64
-rw-r--r--fs/nfs/nfs4xdr.c187
-rw-r--r--fs/nfs/super.c21
-rw-r--r--fs/nfs/write.c6
-rw-r--r--include/linux/compiler-gcc.h4
-rw-r--r--include/linux/f2fs_fs.h8
-rw-r--r--include/linux/frame.h2
-rw-r--r--include/linux/lockd/lockd.h3
-rw-r--r--include/linux/pwm.h33
-rw-r--r--include/linux/sunrpc/auth.h6
-rw-r--r--include/linux/sunrpc/cache.h15
-rw-r--r--include/linux/sunrpc/clnt.h6
-rw-r--r--include/linux/sunrpc/debug.h58
-rw-r--r--include/linux/sunrpc/xdr.h179
-rw-r--r--include/linux/sunrpc/xprt.h4
-rw-r--r--include/linux/sunrpc/xprtsock.h3
-rw-r--r--include/linux/thermal.h4
-rw-r--r--include/trace/events/f2fs.h151
-rw-r--r--net/sunrpc/auth.c15
-rw-r--r--net/sunrpc/auth_null.c3
-rw-r--r--net/sunrpc/auth_unix.c18
-rw-r--r--net/sunrpc/cache.c68
-rw-r--r--net/sunrpc/clnt.c51
-rw-r--r--net/sunrpc/debugfs.c35
-rw-r--r--net/sunrpc/svcauth_unix.c4
-rw-r--r--net/sunrpc/xdr.c34
-rw-r--r--net/sunrpc/xprt.c2
-rw-r--r--net/sunrpc/xprtrdma/fmr_ops.c5
-rw-r--r--net/sunrpc/xprtrdma/frwr_ops.c11
-rw-r--r--net/sunrpc/xprtrdma/rpc_rdma.c82
-rw-r--r--net/sunrpc/xprtrdma/transport.c6
-rw-r--r--net/sunrpc/xprtrdma/verbs.c96
-rw-r--r--net/sunrpc/xprtrdma/xprt_rdma.h30
-rw-r--r--net/sunrpc/xprtsock.c94
-rw-r--r--scripts/mod/modpost.c1
-rw-r--r--scripts/module-common.lds5
-rw-r--r--sound/core/seq/seq_fifo.c3
-rw-r--r--sound/core/timer.c18
-rw-r--r--sound/pci/ctxfi/cthw20k1.c19
-rw-r--r--sound/pci/ctxfi/cthw20k2.c19
-rw-r--r--sound/pci/hda/hda_intel.c3
-rw-r--r--sound/pci/hda/patch_hdmi.c1
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--tools/objtool/builtin-check.c6
195 files changed, 13074 insertions, 6901 deletions
diff --git a/Documentation/devicetree/bindings/pwm/imx-pwm.txt b/Documentation/devicetree/bindings/pwm/imx-pwm.txt
index e00c2e9f484d..c61bdf8cd41b 100644
--- a/Documentation/devicetree/bindings/pwm/imx-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/imx-pwm.txt
@@ -6,8 +6,8 @@ Required properties:
6 - "fsl,imx1-pwm" for PWM compatible with the one integrated on i.MX1 6 - "fsl,imx1-pwm" for PWM compatible with the one integrated on i.MX1
7 - "fsl,imx27-pwm" for PWM compatible with the one integrated on i.MX27 7 - "fsl,imx27-pwm" for PWM compatible with the one integrated on i.MX27
8- reg: physical base address and length of the controller's registers 8- reg: physical base address and length of the controller's registers
9- #pwm-cells: should be 2. See pwm.txt in this directory for a description of 9- #pwm-cells: 2 for i.MX1 and 3 for i.MX27 and newer SoCs. See pwm.txt
10 the cells format. 10 in this directory for a description of the cells format.
11- clocks : Clock specifiers for both ipg and per clocks. 11- clocks : Clock specifiers for both ipg and per clocks.
12- clock-names : Clock names should include both "ipg" and "per" 12- clock-names : Clock names should include both "ipg" and "per"
13See the clock consumer binding, 13See the clock consumer binding,
@@ -17,7 +17,7 @@ See the clock consumer binding,
17Example: 17Example:
18 18
19pwm1: pwm@53fb4000 { 19pwm1: pwm@53fb4000 {
20 #pwm-cells = <2>; 20 #pwm-cells = <3>;
21 compatible = "fsl,imx53-pwm", "fsl,imx27-pwm"; 21 compatible = "fsl,imx53-pwm", "fsl,imx27-pwm";
22 reg = <0x53fb4000 0x4000>; 22 reg = <0x53fb4000 0x4000>;
23 clocks = <&clks IMX5_CLK_PWM1_IPG_GATE>, 23 clocks = <&clks IMX5_CLK_PWM1_IPG_GATE>,
diff --git a/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt b/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
index 66223d561972..20ca4ef9d776 100644
--- a/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
+++ b/Documentation/devicetree/bindings/thermal/qoriq-thermal.txt
@@ -17,6 +17,12 @@ Required properties:
17 calibration data, as specified by the SoC reference manual. 17 calibration data, as specified by the SoC reference manual.
18 The first cell of each pair is the value to be written to TTCFGR, 18 The first cell of each pair is the value to be written to TTCFGR,
19 and the second is the value to be written to TSCFGR. 19 and the second is the value to be written to TSCFGR.
20- #thermal-sensor-cells : Must be 1. The sensor specifier is the monitoring
21 site ID, and represents the "n" in TRITSRn and TRATSRn.
22
23Optional property:
24- little-endian : If present, the TMU registers are little endian. If absent,
25 the default is big endian.
20 26
21Example: 27Example:
22 28
@@ -60,4 +66,5 @@ tmu@f0000 {
60 66
61 0x00030000 0x00000012 67 0x00030000 0x00000012
62 0x00030001 0x0000001d>; 68 0x00030001 0x0000001d>;
69 #thermal-sensor-cells = <1>;
63}; 70};
diff --git a/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt b/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
new file mode 100644
index 000000000000..07a9713ae6a7
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
@@ -0,0 +1,56 @@
1* DT bindings for Renesas R-Car Gen3 Thermal Sensor driver
2
3On R-Car Gen3 SoCs, the thermal sensor controllers (TSC) control the thermal
4sensors (THS) which are the analog circuits for measuring temperature (Tj)
5inside the LSI.
6
7Required properties:
8- compatible : "renesas,<soctype>-thermal",
9 Examples with soctypes are:
10 - "renesas,r8a7795-thermal" (R-Car H3)
11 - "renesas,r8a7796-thermal" (R-Car M3-W)
12- reg : Address ranges of the thermal registers. Each sensor
13 needs one address range. Sorting must be done in
14 increasing order according to datasheet, i.e.
15 TSC1, TSC2, ...
16- clocks : Must contain a reference to the functional clock.
17- #thermal-sensor-cells : must be <1>.
18
19Optional properties:
20
21- interrupts : interrupts routed to the TSC (3 for H3 and M3-W)
22- power-domain : Must contain a reference to the power domain. This
23 property is mandatory if the thermal sensor instance
24 is part of a controllable power domain.
25
26Example:
27
28 tsc: thermal@e6198000 {
29 compatible = "renesas,r8a7795-thermal";
30 reg = <0 0xe6198000 0 0x68>,
31 <0 0xe61a0000 0 0x5c>,
32 <0 0xe61a8000 0 0x5c>;
33 interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
34 <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
35 <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
36 clocks = <&cpg CPG_MOD 522>;
37 power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
38 #thermal-sensor-cells = <1>;
39 status = "okay";
40 };
41
42 thermal-zones {
43 sensor_thermal1: sensor-thermal1 {
44 polling-delay-passive = <250>;
45 polling-delay = <1000>;
46 thermal-sensors = <&tsc 0>;
47
48 trips {
49 sensor1_crit: sensor1-crit {
50 temperature = <90000>;
51 hysteresis = <2000>;
52 type = "critical";
53 };
54 };
55 };
56 };
diff --git a/Documentation/devicetree/bindings/thermal/zx2967-thermal.txt b/Documentation/devicetree/bindings/thermal/zx2967-thermal.txt
new file mode 100644
index 000000000000..3dc1c6bf0478
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/zx2967-thermal.txt
@@ -0,0 +1,116 @@
1* ZTE zx2967 family Thermal
2
3Required Properties:
4- compatible: should be one of the following.
5 * zte,zx296718-thermal
6- reg: physical base address of the controller and length of memory mapped
7 region.
8- clocks : Pairs of phandle and specifier referencing the controller's clocks.
9- clock-names: "topcrm" for the topcrm clock.
10 "apb" for the apb clock.
11- #thermal-sensor-cells: must be 0.
12
13Please note: slope coefficient defined in thermal-zones section need to be
14multiplied by 1000.
15
16Example for tempsensor:
17
18 tempsensor: tempsensor@148a000 {
19 compatible = "zte,zx296718-thermal";
20 reg = <0x0148a000 0x20>;
21 clocks = <&topcrm TEMPSENSOR_GATE>, <&audiocrm AUDIO_TS_PCLK>;
22 clock-names = "topcrm", "apb";
23 #thermal-sensor-cells = <0>;
24 };
25
26Example for cooling device:
27
28 cooling_dev: cooling_dev {
29 cluster0_cooling_dev: cluster0-cooling-dev {
30 #cooling-cells = <2>;
31 cpumask = <0xf>;
32 capacitance = <1500>;
33 };
34
35 cluster1_cooling_dev: cluster1-cooling-dev {
36 #cooling-cells = <2>;
37 cpumask = <0x30>;
38 capacitance = <2000>;
39 };
40 };
41
42Example for thermal zones:
43
44 thermal-zones {
45 zx296718_thermal: zx296718_thermal {
46 polling-delay-passive = <500>;
47 polling-delay = <1000>;
48 sustainable-power = <6500>;
49
50 thermal-sensors = <&tempsensor 0>;
51 /*
52 * slope need to be multiplied by 1000.
53 */
54 coefficients = <1951 (-922)>;
55
56 trips {
57 trip0: switch_on_temperature {
58 temperature = <90000>;
59 hysteresis = <2000>;
60 type = "passive";
61 };
62
63 trip1: desired_temperature {
64 temperature = <100000>;
65 hysteresis = <2000>;
66 type = "passive";
67 };
68
69 crit: critical_temperature {
70 temperature = <110000>;
71 hysteresis = <2000>;
72 type = "critical";
73 };
74 };
75
76 cooling-maps {
77 map0 {
78 trip = <&trip0>;
79 cooling-device = <&gpu 2 5>;
80 };
81
82 map1 {
83 trip = <&trip0>;
84 cooling-device = <&cluster0_cooling_dev 1 2>;
85 };
86
87 map2 {
88 trip = <&trip1>;
89 cooling-device = <&cluster0_cooling_dev 1 2>;
90 };
91
92 map3 {
93 trip = <&crit>;
94 cooling-device = <&cluster0_cooling_dev 1 2>;
95 };
96
97 map4 {
98 trip = <&trip0>;
99 cooling-device = <&cluster1_cooling_dev 1 2>;
100 contribution = <9000>;
101 };
102
103 map5 {
104 trip = <&trip1>;
105 cooling-device = <&cluster1_cooling_dev 1 2>;
106 contribution = <4096>;
107 };
108
109 map6 {
110 trip = <&crit>;
111 cooling-device = <&cluster1_cooling_dev 1 2>;
112 contribution = <4096>;
113 };
114 };
115 };
116 };
diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
index 753dd4f96afe..4f6531a4701b 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -125,13 +125,14 @@ active_logs=%u Support configuring the number of active logs. In the
125disable_ext_identify Disable the extension list configured by mkfs, so f2fs 125disable_ext_identify Disable the extension list configured by mkfs, so f2fs
126 does not aware of cold files such as media files. 126 does not aware of cold files such as media files.
127inline_xattr Enable the inline xattrs feature. 127inline_xattr Enable the inline xattrs feature.
128noinline_xattr Disable the inline xattrs feature.
128inline_data Enable the inline data feature: New created small(<~3.4k) 129inline_data Enable the inline data feature: New created small(<~3.4k)
129 files can be written into inode block. 130 files can be written into inode block.
130inline_dentry Enable the inline dir feature: data in new created 131inline_dentry Enable the inline dir feature: data in new created
131 directory entries can be written into inode block. The 132 directory entries can be written into inode block. The
132 space of inode block which is used to store inline 133 space of inode block which is used to store inline
133 dentries is limited to ~3.4k. 134 dentries is limited to ~3.4k.
134noinline_dentry Diable the inline dentry feature. 135noinline_dentry Disable the inline dentry feature.
135flush_merge Merge concurrent cache_flush commands as much as possible 136flush_merge Merge concurrent cache_flush commands as much as possible
136 to eliminate redundant command issues. If the underlying 137 to eliminate redundant command issues. If the underlying
137 device handles the cache_flush command relatively slowly, 138 device handles the cache_flush command relatively slowly,
@@ -157,6 +158,8 @@ data_flush Enable data flushing before checkpoint in order to
157mode=%s Control block allocation mode which supports "adaptive" 158mode=%s Control block allocation mode which supports "adaptive"
158 and "lfs". In "lfs" mode, there should be no random 159 and "lfs". In "lfs" mode, there should be no random
159 writes towards main area. 160 writes towards main area.
161io_bits=%u Set the bit size of write IO requests. It should be set
162 with "mode=lfs".
160 163
161================================================================================ 164================================================================================
162DEBUGFS ENTRIES 165DEBUGFS ENTRIES
@@ -174,7 +177,7 @@ f2fs. Each file shows the whole f2fs information.
174SYSFS ENTRIES 177SYSFS ENTRIES
175================================================================================ 178================================================================================
176 179
177Information about mounted f2f2 file systems can be found in 180Information about mounted f2fs file systems can be found in
178/sys/fs/f2fs. Each mounted filesystem will have a directory in 181/sys/fs/f2fs. Each mounted filesystem will have a directory in
179/sys/fs/f2fs based on its device name (i.e., /sys/fs/f2fs/sda). 182/sys/fs/f2fs based on its device name (i.e., /sys/fs/f2fs/sda).
180The files in each per-device directory are shown in table below. 183The files in each per-device directory are shown in table below.
diff --git a/MAINTAINERS b/MAINTAINERS
index 846f97aa3508..00018356f4a5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7483,18 +7483,24 @@ L: linuxppc-dev@lists.ozlabs.org
7483Q: http://patchwork.ozlabs.org/project/linuxppc-dev/list/ 7483Q: http://patchwork.ozlabs.org/project/linuxppc-dev/list/
7484T: git git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git 7484T: git git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git
7485S: Supported 7485S: Supported
7486F: Documentation/ABI/stable/sysfs-firmware-opal-*
7487F: Documentation/devicetree/bindings/powerpc/opal/
7488F: Documentation/devicetree/bindings/rtc/rtc-opal.txt
7489F: Documentation/devicetree/bindings/i2c/i2c-opal.txt
7486F: Documentation/powerpc/ 7490F: Documentation/powerpc/
7487F: arch/powerpc/ 7491F: arch/powerpc/
7488F: drivers/char/tpm/tpm_ibmvtpm* 7492F: drivers/char/tpm/tpm_ibmvtpm*
7489F: drivers/crypto/nx/ 7493F: drivers/crypto/nx/
7490F: drivers/crypto/vmx/ 7494F: drivers/crypto/vmx/
7495F: drivers/i2c/busses/i2c-opal.c
7491F: drivers/net/ethernet/ibm/ibmveth.* 7496F: drivers/net/ethernet/ibm/ibmveth.*
7492F: drivers/net/ethernet/ibm/ibmvnic.* 7497F: drivers/net/ethernet/ibm/ibmvnic.*
7493F: drivers/pci/hotplug/pnv_php.c 7498F: drivers/pci/hotplug/pnv_php.c
7494F: drivers/pci/hotplug/rpa* 7499F: drivers/pci/hotplug/rpa*
7500F: drivers/rtc/rtc-opal.c
7495F: drivers/scsi/ibmvscsi/ 7501F: drivers/scsi/ibmvscsi/
7502F: drivers/tty/hvc/hvc_opal.c
7496F: tools/testing/selftests/powerpc 7503F: tools/testing/selftests/powerpc
7497N: opal
7498N: /pmac 7504N: /pmac
7499N: powermac 7505N: powermac
7500N: powernv 7506N: powernv
diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 4ce82ed3e7c3..05310ad8c5ab 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -184,16 +184,22 @@ static inline u64 arm64_ftr_reg_user_value(const struct arm64_ftr_reg *reg)
184} 184}
185 185
186static inline int __attribute_const__ 186static inline int __attribute_const__
187cpuid_feature_extract_field(u64 features, int field, bool sign) 187cpuid_feature_extract_field_width(u64 features, int field, int width, bool sign)
188{ 188{
189 return (sign) ? 189 return (sign) ?
190 cpuid_feature_extract_signed_field(features, field) : 190 cpuid_feature_extract_signed_field_width(features, field, width) :
191 cpuid_feature_extract_unsigned_field(features, field); 191 cpuid_feature_extract_unsigned_field_width(features, field, width);
192}
193
194static inline int __attribute_const__
195cpuid_feature_extract_field(u64 features, int field, bool sign)
196{
197 return cpuid_feature_extract_field_width(features, field, 4, sign);
192} 198}
193 199
194static inline s64 arm64_ftr_value(const struct arm64_ftr_bits *ftrp, u64 val) 200static inline s64 arm64_ftr_value(const struct arm64_ftr_bits *ftrp, u64 val)
195{ 201{
196 return (s64)cpuid_feature_extract_field(val, ftrp->shift, ftrp->sign); 202 return (s64)cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width, ftrp->sign);
197} 203}
198 204
199static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0) 205static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0)
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index b805c017f789..d28dbcf596b6 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -109,10 +109,8 @@ static bool pgattr_change_is_safe(u64 old, u64 new)
109static void alloc_init_pte(pmd_t *pmd, unsigned long addr, 109static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
110 unsigned long end, unsigned long pfn, 110 unsigned long end, unsigned long pfn,
111 pgprot_t prot, 111 pgprot_t prot,
112 phys_addr_t (*pgtable_alloc)(void), 112 phys_addr_t (*pgtable_alloc)(void))
113 bool page_mappings_only)
114{ 113{
115 pgprot_t __prot = prot;
116 pte_t *pte; 114 pte_t *pte;
117 115
118 BUG_ON(pmd_sect(*pmd)); 116 BUG_ON(pmd_sect(*pmd));
@@ -130,18 +128,7 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
130 do { 128 do {
131 pte_t old_pte = *pte; 129 pte_t old_pte = *pte;
132 130
133 /* 131 set_pte(pte, pfn_pte(pfn, prot));
134 * Set the contiguous bit for the subsequent group of PTEs if
135 * its size and alignment are appropriate.
136 */
137 if (((addr | PFN_PHYS(pfn)) & ~CONT_PTE_MASK) == 0) {
138 if (end - addr >= CONT_PTE_SIZE && !page_mappings_only)
139 __prot = __pgprot(pgprot_val(prot) | PTE_CONT);
140 else
141 __prot = prot;
142 }
143
144 set_pte(pte, pfn_pte(pfn, __prot));
145 pfn++; 132 pfn++;
146 133
147 /* 134 /*
@@ -160,7 +147,6 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
160 phys_addr_t (*pgtable_alloc)(void), 147 phys_addr_t (*pgtable_alloc)(void),
161 bool page_mappings_only) 148 bool page_mappings_only)
162{ 149{
163 pgprot_t __prot = prot;
164 pmd_t *pmd; 150 pmd_t *pmd;
165 unsigned long next; 151 unsigned long next;
166 152
@@ -187,18 +173,7 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
187 /* try section mapping first */ 173 /* try section mapping first */
188 if (((addr | next | phys) & ~SECTION_MASK) == 0 && 174 if (((addr | next | phys) & ~SECTION_MASK) == 0 &&
189 !page_mappings_only) { 175 !page_mappings_only) {
190 /* 176 pmd_set_huge(pmd, phys, prot);
191 * Set the contiguous bit for the subsequent group of
192 * PMDs if its size and alignment are appropriate.
193 */
194 if (((addr | phys) & ~CONT_PMD_MASK) == 0) {
195 if (end - addr >= CONT_PMD_SIZE)
196 __prot = __pgprot(pgprot_val(prot) |
197 PTE_CONT);
198 else
199 __prot = prot;
200 }
201 pmd_set_huge(pmd, phys, __prot);
202 177
203 /* 178 /*
204 * After the PMD entry has been populated once, we 179 * After the PMD entry has been populated once, we
@@ -208,8 +183,7 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
208 pmd_val(*pmd))); 183 pmd_val(*pmd)));
209 } else { 184 } else {
210 alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys), 185 alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys),
211 prot, pgtable_alloc, 186 prot, pgtable_alloc);
212 page_mappings_only);
213 187
214 BUG_ON(pmd_val(old_pmd) != 0 && 188 BUG_ON(pmd_val(old_pmd) != 0 &&
215 pmd_val(old_pmd) != pmd_val(*pmd)); 189 pmd_val(old_pmd) != pmd_val(*pmd));
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index cd4d53d7e458..877d42fb0df6 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -138,7 +138,7 @@ ENDPROC(cpu_do_resume)
138 * - pgd_phys - physical address of new TTB 138 * - pgd_phys - physical address of new TTB
139 */ 139 */
140ENTRY(cpu_do_switch_mm) 140ENTRY(cpu_do_switch_mm)
141 pre_ttbr0_update_workaround x0, x1, x2 141 pre_ttbr0_update_workaround x0, x2, x3
142 mmid x1, x1 // get mm->context.id 142 mmid x1, x1 // get mm->context.id
143 bfi x0, x1, #48, #16 // set the ASID 143 bfi x0, x1, #48, #16 // set the ASID
144 msr ttbr0_el1, x0 // set TTBR0 144 msr ttbr0_el1, x0 // set TTBR0
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 8582121d7a45..494091762bd7 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -115,7 +115,7 @@ config PPC
115 select HAVE_PERF_REGS 115 select HAVE_PERF_REGS
116 select HAVE_PERF_USER_STACK_DUMP 116 select HAVE_PERF_USER_STACK_DUMP
117 select HAVE_REGS_AND_STACK_ACCESS_API 117 select HAVE_REGS_AND_STACK_ACCESS_API
118 select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64 118 select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx)
119 select ARCH_WANT_IPC_PARSE_VERSION 119 select ARCH_WANT_IPC_PARSE_VERSION
120 select SPARSE_IRQ 120 select SPARSE_IRQ
121 select IRQ_DOMAIN 121 select IRQ_DOMAIN
diff --git a/arch/powerpc/boot/dts/fsl/kmcent2.dts b/arch/powerpc/boot/dts/fsl/kmcent2.dts
new file mode 100644
index 000000000000..47afa438602e
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/kmcent2.dts
@@ -0,0 +1,303 @@
1/*
2 * Keymile kmcent2 Device Tree Source, based on T1040RDB DTS
3 *
4 * (C) Copyright 2016
5 * Valentin Longchamp, Keymile AG, valentin.longchamp@keymile.com
6 *
7 * Copyright 2014 - 2015 Freescale Semiconductor Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14
15/include/ "t104xsi-pre.dtsi"
16
17/ {
18 model = "keymile,kmcent2";
19 compatible = "keymile,kmcent2";
20
21 aliases {
22 front_phy = &front_phy;
23 };
24
25 reserved-memory {
26 #address-cells = <2>;
27 #size-cells = <2>;
28 ranges;
29
30 bman_fbpr: bman-fbpr {
31 size = <0 0x1000000>;
32 alignment = <0 0x1000000>;
33 };
34 qman_fqd: qman-fqd {
35 size = <0 0x400000>;
36 alignment = <0 0x400000>;
37 };
38 qman_pfdr: qman-pfdr {
39 size = <0 0x2000000>;
40 alignment = <0 0x2000000>;
41 };
42 };
43
44 ifc: localbus@ffe124000 {
45 reg = <0xf 0xfe124000 0 0x2000>;
46 ranges = <0 0 0xf 0xe8000000 0x04000000
47 1 0 0xf 0xfa000000 0x00010000
48 2 0 0xf 0xfb000000 0x00010000
49 4 0 0xf 0xc0000000 0x08000000
50 6 0 0xf 0xd0000000 0x08000000
51 7 0 0xf 0xd8000000 0x08000000>;
52
53 nor@0,0 {
54 #address-cells = <1>;
55 #size-cells = <1>;
56 compatible = "cfi-flash";
57 reg = <0x0 0x0 0x04000000>;
58 bank-width = <2>;
59 device-width = <2>;
60 };
61
62 nand@1,0 {
63 #address-cells = <1>;
64 #size-cells = <1>;
65 compatible = "fsl,ifc-nand";
66 reg = <0x1 0x0 0x10000>;
67 };
68
69 board-control@2,0 {
70 compatible = "keymile,qriox";
71 reg = <0x2 0x0 0x80>;
72 };
73
74 chassis-mgmt@6,0 {
75 compatible = "keymile,bfticu";
76 reg = <6 0 0x100>;
77 interrupt-controller;
78 interrupt-parent = <&mpic>;
79 interrupts = <11 1 0 0>;
80 #interrupt-cells = <1>;
81 };
82
83 };
84
85 memory {
86 device_type = "memory";
87 };
88
89 dcsr: dcsr@f00000000 {
90 ranges = <0x00000000 0xf 0x00000000 0x01072000>;
91 };
92
93 bportals: bman-portals@ff4000000 {
94 ranges = <0x0 0xf 0xf4000000 0x2000000>;
95 };
96
97 qportals: qman-portals@ff6000000 {
98 ranges = <0x0 0xf 0xf6000000 0x2000000>;
99 };
100
101 soc: soc@ffe000000 {
102 ranges = <0x00000000 0xf 0xfe000000 0x1000000>;
103 reg = <0xf 0xfe000000 0 0x00001000>;
104
105 spi@110000 {
106 network-clock@1 {
107 compatible = "zarlink,zl30364";
108 reg = <1>;
109 spi-max-frequency = <1000000>;
110 };
111 };
112
113 sdhc@114000 {
114 status = "disabled";
115 };
116
117 i2c@118000 {
118 clock-frequency = <100000>;
119
120 mux@70 {
121 compatible = "nxp,pca9547";
122 reg = <0x70>;
123 #address-cells = <1>;
124 #size-cells = <0>;
125 i2c-mux-idle-disconnect;
126
127 i2c@0 {
128 reg = <0>;
129 #address-cells = <1>;
130 #size-cells = <0>;
131
132 eeprom@54 {
133 compatible = "24c02";
134 reg = <0x54>;
135 pagesize = <2>;
136 read-only;
137 label = "ddr3-spd";
138 };
139 };
140
141 i2c@7 {
142 reg = <7>;
143 #address-cells = <1>;
144 #size-cells = <0>;
145
146 temp-sensor@48 {
147 compatible = "national,lm75";
148 reg = <0x48>;
149 label = "SENSOR_0";
150 };
151 temp-sensor@4a {
152 compatible = "national,lm75";
153 reg = <0x4a>;
154 label = "SENSOR_2";
155 };
156 temp-sensor@4b {
157 compatible = "national,lm75";
158 reg = <0x4b>;
159 label = "SENSOR_3";
160 };
161 };
162 };
163 };
164
165 i2c@118100 {
166 clock-frequency = <100000>;
167
168 eeprom@50 {
169 compatible = "atmel,24c08";
170 reg = <0x50>;
171 pagesize = <16>;
172 };
173
174 eeprom@54 {
175 compatible = "atmel,24c08";
176 reg = <0x54>;
177 pagesize = <16>;
178 };
179 };
180
181 i2c@119000 {
182 status = "disabled";
183 };
184
185 i2c@119100 {
186 status = "disabled";
187 };
188
189 serial2: serial@11d500 {
190 status = "disabled";
191 };
192
193 serial3: serial@11d600 {
194 status = "disabled";
195 };
196
197 usb0: usb@210000 {
198 status = "disabled";
199 };
200 usb1: usb@211000 {
201 status = "disabled";
202 };
203
204 display@180000 {
205 status = "disabled";
206 };
207
208 sata@220000 {
209 status = "disabled";
210 };
211 sata@221000 {
212 status = "disabled";
213 };
214
215 fman@400000 {
216 ethernet@e0000 {
217 fixed-link = <0 1 1000 0 0>;
218 phy-connection-type = "sgmii";
219 };
220
221 ethernet@e2000 {
222 fixed-link = <1 1 1000 0 0>;
223 phy-connection-type = "sgmii";
224 };
225
226 ethernet@e4000 {
227 status = "disabled";
228 };
229
230 ethernet@e6000 {
231 status = "disabled";
232 };
233
234 ethernet@e8000 {
235 phy-handle = <&front_phy>;
236 phy-connection-type = "rgmii";
237 };
238
239 mdio0: mdio@fc000 {
240 front_phy: ethernet-phy@11 {
241 reg = <0x11>;
242 };
243 };
244 };
245 };
246
247
248 pci0: pcie@ffe240000 {
249 reg = <0xf 0xfe240000 0 0x10000>;
250 ranges = <0x02000000 0 0xe0000000 0xc 0x00000000 0x0 0x20000000
251 0x01000000 0 0x00000000 0xf 0xf8000000 0x0 0x00010000>;
252 pcie@0 {
253 ranges = <0x02000000 0 0xe0000000
254 0x02000000 0 0xe0000000
255 0 0x20000000
256
257 0x01000000 0 0x00000000
258 0x01000000 0 0x00000000
259 0 0x00010000>;
260 };
261 };
262
263 pci1: pcie@ffe250000 {
264 status = "disabled";
265 };
266
267 pci2: pcie@ffe260000 {
268 status = "disabled";
269 };
270
271 pci3: pcie@ffe270000 {
272 status = "disabled";
273 };
274
275 qe: qe@ffe140000 {
276 ranges = <0x0 0xf 0xfe140000 0x40000>;
277 reg = <0xf 0xfe140000 0 0x480>;
278 brg-frequency = <0>;
279 bus-frequency = <0>;
280
281 si1: si@700 {
282 compatible = "fsl,t1040-qe-si";
283 reg = <0x700 0x80>;
284 };
285
286 siram1: siram@1000 {
287 compatible = "fsl,t1040-qe-siram";
288 reg = <0x1000 0x800>;
289 };
290
291 ucc_hdlc: ucc@2000 {
292 device_type = "hdlc";
293 compatible = "fsl,ucc-hdlc";
294 rx-clock-name = "clk9";
295 tx-clock-name = "clk9";
296 fsl,tx-timeslot-mask = <0xfffffffe>;
297 fsl,rx-timeslot-mask = <0xfffffffe>;
298 fsl,siram-entry-id = <0>;
299 };
300 };
301};
302
303#include "t1040si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/fsl/kmcoge4.dts b/arch/powerpc/boot/dts/fsl/kmcoge4.dts
index ae70a24094b0..e103c0f3f650 100644
--- a/arch/powerpc/boot/dts/fsl/kmcoge4.dts
+++ b/arch/powerpc/boot/dts/fsl/kmcoge4.dts
@@ -83,6 +83,10 @@
83 }; 83 };
84 }; 84 };
85 85
86 sdhc@114000 {
87 status = "disabled";
88 };
89
86 i2c@119000 { 90 i2c@119000 {
87 status = "disabled"; 91 status = "disabled";
88 }; 92 };
diff --git a/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi b/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
index da2894c59479..4908af501098 100644
--- a/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/t1023si-post.dtsi
@@ -422,7 +422,7 @@
422 0x00030001 0x0000000d 422 0x00030001 0x0000000d
423 0x00030002 0x00000019 423 0x00030002 0x00000019
424 0x00030003 0x00000024>; 424 0x00030003 0x00000024>;
425 #thermal-sensor-cells = <0>; 425 #thermal-sensor-cells = <1>;
426 }; 426 };
427 427
428 thermal-zones { 428 thermal-zones {
@@ -430,7 +430,7 @@
430 polling-delay-passive = <1000>; 430 polling-delay-passive = <1000>;
431 polling-delay = <5000>; 431 polling-delay = <5000>;
432 432
433 thermal-sensors = <&tmu>; 433 thermal-sensors = <&tmu 0>;
434 434
435 trips { 435 trips {
436 cpu_alert: cpu-alert { 436 cpu_alert: cpu-alert {
diff --git a/arch/powerpc/boot/dts/fsl/t1040si-post.dtsi b/arch/powerpc/boot/dts/fsl/t1040si-post.dtsi
index 44e399b17f6f..145c7f43b5b6 100644
--- a/arch/powerpc/boot/dts/fsl/t1040si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/t1040si-post.dtsi
@@ -526,7 +526,7 @@
526 526
527 0x00030000 0x00000012 527 0x00030000 0x00000012
528 0x00030001 0x0000001d>; 528 0x00030001 0x0000001d>;
529 #thermal-sensor-cells = <0>; 529 #thermal-sensor-cells = <1>;
530 }; 530 };
531 531
532 thermal-zones { 532 thermal-zones {
@@ -534,7 +534,7 @@
534 polling-delay-passive = <1000>; 534 polling-delay-passive = <1000>;
535 polling-delay = <5000>; 535 polling-delay = <5000>;
536 536
537 thermal-sensors = <&tmu>; 537 thermal-sensors = <&tmu 2>;
538 538
539 trips { 539 trips {
540 cpu_alert: cpu-alert { 540 cpu_alert: cpu-alert {
diff --git a/arch/powerpc/configs/85xx/kmp204x_defconfig b/arch/powerpc/configs/85xx/kmp204x_defconfig
deleted file mode 100644
index 34a4da23f000..000000000000
--- a/arch/powerpc/configs/85xx/kmp204x_defconfig
+++ /dev/null
@@ -1,220 +0,0 @@
1CONFIG_PPC_85xx=y
2CONFIG_SMP=y
3CONFIG_NR_CPUS=8
4CONFIG_SYSVIPC=y
5CONFIG_POSIX_MQUEUE=y
6CONFIG_AUDIT=y
7CONFIG_NO_HZ=y
8CONFIG_HIGH_RES_TIMERS=y
9CONFIG_BSD_PROCESS_ACCT=y
10CONFIG_IKCONFIG=y
11CONFIG_IKCONFIG_PROC=y
12CONFIG_LOG_BUF_SHIFT=14
13CONFIG_CGROUPS=y
14CONFIG_CGROUP_SCHED=y
15CONFIG_RELAY=y
16CONFIG_BLK_DEV_INITRD=y
17CONFIG_KALLSYMS_ALL=y
18CONFIG_EMBEDDED=y
19CONFIG_PERF_EVENTS=y
20CONFIG_SLAB=y
21CONFIG_MODULES=y
22CONFIG_MODULE_UNLOAD=y
23CONFIG_MODULE_FORCE_UNLOAD=y
24CONFIG_MODVERSIONS=y
25# CONFIG_BLK_DEV_BSG is not set
26CONFIG_PARTITION_ADVANCED=y
27CONFIG_MAC_PARTITION=y
28CONFIG_CORENET_GENERIC=y
29CONFIG_MPIC_MSGR=y
30CONFIG_HIGHMEM=y
31# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
32CONFIG_BINFMT_MISC=m
33CONFIG_KEXEC=y
34CONFIG_FORCE_MAX_ZONEORDER=13
35CONFIG_PCI=y
36CONFIG_PCIEPORTBUS=y
37# CONFIG_PCIEASPM is not set
38CONFIG_PCI_MSI=y
39CONFIG_ADVANCED_OPTIONS=y
40CONFIG_LOWMEM_SIZE_BOOL=y
41CONFIG_LOWMEM_SIZE=0x20000000
42CONFIG_NET=y
43CONFIG_PACKET=y
44CONFIG_UNIX=y
45CONFIG_XFRM_USER=y
46CONFIG_XFRM_SUB_POLICY=y
47CONFIG_XFRM_STATISTICS=y
48CONFIG_NET_KEY=y
49CONFIG_NET_KEY_MIGRATE=y
50CONFIG_INET=y
51CONFIG_IP_MULTICAST=y
52CONFIG_IP_ADVANCED_ROUTER=y
53CONFIG_IP_MULTIPLE_TABLES=y
54CONFIG_IP_ROUTE_MULTIPATH=y
55CONFIG_IP_ROUTE_VERBOSE=y
56CONFIG_IP_PNP=y
57CONFIG_IP_PNP_DHCP=y
58CONFIG_IP_PNP_BOOTP=y
59CONFIG_IP_PNP_RARP=y
60CONFIG_NET_IPIP=y
61CONFIG_IP_MROUTE=y
62CONFIG_IP_PIMSM_V1=y
63CONFIG_IP_PIMSM_V2=y
64CONFIG_INET_AH=y
65CONFIG_INET_ESP=y
66CONFIG_INET_IPCOMP=y
67CONFIG_IPV6=y
68CONFIG_IP_SCTP=m
69CONFIG_TIPC=y
70CONFIG_NET_SCHED=y
71CONFIG_NET_SCH_CBQ=y
72CONFIG_NET_SCH_HTB=y
73CONFIG_NET_SCH_HFSC=y
74CONFIG_NET_SCH_PRIO=y
75CONFIG_NET_SCH_MULTIQ=y
76CONFIG_NET_SCH_RED=y
77CONFIG_NET_SCH_SFQ=y
78CONFIG_NET_SCH_TEQL=y
79CONFIG_NET_SCH_TBF=y
80CONFIG_NET_SCH_GRED=y
81CONFIG_NET_CLS_BASIC=y
82CONFIG_NET_CLS_TCINDEX=y
83CONFIG_NET_CLS_U32=y
84CONFIG_CLS_U32_PERF=y
85CONFIG_CLS_U32_MARK=y
86CONFIG_NET_CLS_FLOW=y
87CONFIG_NET_CLS_CGROUP=y
88CONFIG_UEVENT_HELPER_PATH="/sbin/mdev"
89CONFIG_DEVTMPFS=y
90CONFIG_MTD=y
91CONFIG_MTD_CMDLINE_PARTS=y
92CONFIG_MTD_BLOCK=y
93CONFIG_MTD_CFI=y
94CONFIG_MTD_CFI_AMDSTD=y
95CONFIG_MTD_PHYSMAP_OF=y
96CONFIG_MTD_PHRAM=y
97CONFIG_MTD_NAND=y
98CONFIG_MTD_NAND_ECC_BCH=y
99CONFIG_MTD_NAND_FSL_ELBC=y
100CONFIG_MTD_UBI=y
101CONFIG_MTD_UBI_GLUEBI=y
102CONFIG_BLK_DEV_LOOP=y
103CONFIG_BLK_DEV_RAM=y
104CONFIG_BLK_DEV_RAM_COUNT=2
105CONFIG_BLK_DEV_RAM_SIZE=2048
106CONFIG_EEPROM_AT24=y
107CONFIG_SCSI=y
108CONFIG_BLK_DEV_SD=y
109CONFIG_CHR_DEV_ST=y
110CONFIG_BLK_DEV_SR=y
111CONFIG_CHR_DEV_SG=y
112CONFIG_SCSI_LOGGING=y
113CONFIG_SCSI_SYM53C8XX_2=y
114CONFIG_NETDEVICES=y
115# CONFIG_NET_VENDOR_3COM is not set
116# CONFIG_NET_VENDOR_ADAPTEC is not set
117# CONFIG_NET_VENDOR_ALTEON is not set
118# CONFIG_NET_VENDOR_AMD is not set
119# CONFIG_NET_VENDOR_ATHEROS is not set
120# CONFIG_NET_VENDOR_BROADCOM is not set
121# CONFIG_NET_VENDOR_BROCADE is not set
122# CONFIG_NET_VENDOR_CHELSIO is not set
123# CONFIG_NET_VENDOR_CISCO is not set
124# CONFIG_NET_VENDOR_DEC is not set
125# CONFIG_NET_VENDOR_DLINK is not set
126# CONFIG_NET_VENDOR_EMULEX is not set
127# CONFIG_NET_VENDOR_EXAR is not set
128CONFIG_FSL_PQ_MDIO=y
129CONFIG_FSL_XGMAC_MDIO=y
130# CONFIG_NET_VENDOR_HP is not set
131# CONFIG_NET_VENDOR_INTEL is not set
132# CONFIG_NET_VENDOR_MARVELL is not set
133# CONFIG_NET_VENDOR_MELLANOX is not set
134# CONFIG_NET_VENDOR_MICREL is not set
135# CONFIG_NET_VENDOR_MICROCHIP is not set
136# CONFIG_NET_VENDOR_MYRI is not set
137# CONFIG_NET_VENDOR_NATSEMI is not set
138# CONFIG_NET_VENDOR_NVIDIA is not set
139# CONFIG_NET_VENDOR_OKI is not set
140# CONFIG_NET_PACKET_ENGINE is not set
141# CONFIG_NET_VENDOR_QLOGIC is not set
142# CONFIG_NET_VENDOR_REALTEK is not set
143# CONFIG_NET_VENDOR_RDC is not set
144# CONFIG_NET_VENDOR_SEEQ is not set
145# CONFIG_NET_VENDOR_SILAN is not set
146# CONFIG_NET_VENDOR_SIS is not set
147# CONFIG_NET_VENDOR_SMSC is not set
148# CONFIG_NET_VENDOR_STMICRO is not set
149# CONFIG_NET_VENDOR_SUN is not set
150# CONFIG_NET_VENDOR_TEHUTI is not set
151# CONFIG_NET_VENDOR_TI is not set
152# CONFIG_NET_VENDOR_VIA is not set
153# CONFIG_NET_VENDOR_WIZNET is not set
154# CONFIG_NET_VENDOR_XILINX is not set
155CONFIG_MARVELL_PHY=y
156CONFIG_VITESSE_PHY=y
157CONFIG_FIXED_PHY=y
158# CONFIG_WLAN is not set
159# CONFIG_INPUT_MOUSEDEV is not set
160# CONFIG_INPUT_KEYBOARD is not set
161# CONFIG_INPUT_MOUSE is not set
162CONFIG_SERIO_LIBPS2=y
163# CONFIG_LEGACY_PTYS is not set
164CONFIG_PPC_EPAPR_HV_BYTECHAN=y
165CONFIG_SERIAL_8250=y
166CONFIG_SERIAL_8250_CONSOLE=y
167CONFIG_SERIAL_8250_MANY_PORTS=y
168CONFIG_SERIAL_8250_DETECT_IRQ=y
169CONFIG_SERIAL_8250_RSA=y
170CONFIG_NVRAM=y
171CONFIG_I2C=y
172CONFIG_I2C_CHARDEV=y
173CONFIG_I2C_MUX=y
174CONFIG_I2C_MUX_PCA954x=y
175CONFIG_I2C_MPC=y
176CONFIG_SPI=y
177CONFIG_SPI_FSL_SPI=y
178CONFIG_SPI_FSL_ESPI=y
179CONFIG_SPI_SPIDEV=m
180CONFIG_PTP_1588_CLOCK=y
181# CONFIG_HWMON is not set
182# CONFIG_USB_SUPPORT is not set
183CONFIG_EDAC=y
184CONFIG_EDAC_MM_EDAC=y
185CONFIG_EDAC_MPC85XX=y
186CONFIG_RTC_CLASS=y
187CONFIG_RTC_DRV_DS3232=y
188CONFIG_RTC_DRV_CMOS=y
189CONFIG_UIO=y
190CONFIG_STAGING=y
191CONFIG_CLK_QORIQ=y
192CONFIG_EXT2_FS=y
193CONFIG_NTFS_FS=y
194CONFIG_PROC_KCORE=y
195CONFIG_TMPFS=y
196CONFIG_JFFS2_FS=y
197CONFIG_UBIFS_FS=y
198CONFIG_CRAMFS=y
199CONFIG_SQUASHFS=y
200CONFIG_SQUASHFS_XZ=y
201CONFIG_NFS_FS=y
202CONFIG_NFS_V4=y
203CONFIG_ROOT_NFS=y
204CONFIG_NLS_ISO8859_1=y
205CONFIG_NLS_UTF8=m
206CONFIG_CRC_ITU_T=m
207CONFIG_DEBUG_INFO=y
208CONFIG_MAGIC_SYSRQ=y
209CONFIG_DEBUG_SHIRQ=y
210CONFIG_DETECT_HUNG_TASK=y
211CONFIG_SCHEDSTATS=y
212CONFIG_RCU_TRACE=y
213CONFIG_UPROBE_EVENTS=y
214CONFIG_CRYPTO_NULL=y
215CONFIG_CRYPTO_PCBC=m
216CONFIG_CRYPTO_MD4=y
217CONFIG_CRYPTO_SHA256=y
218CONFIG_CRYPTO_SHA512=y
219# CONFIG_CRYPTO_ANSI_CPRNG is not set
220CONFIG_CRYPTO_DEV_FSL_CAAM=y
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index 6d0eb02fefa4..4ff68b752618 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -58,7 +58,6 @@ CONFIG_KEXEC_FILE=y
58CONFIG_IRQ_ALL_CPUS=y 58CONFIG_IRQ_ALL_CPUS=y
59CONFIG_MEMORY_HOTPLUG=y 59CONFIG_MEMORY_HOTPLUG=y
60CONFIG_MEMORY_HOTREMOVE=y 60CONFIG_MEMORY_HOTREMOVE=y
61CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y
62CONFIG_KSM=y 61CONFIG_KSM=y
63CONFIG_TRANSPARENT_HUGEPAGE=y 62CONFIG_TRANSPARENT_HUGEPAGE=y
64CONFIG_PPC_64K_PAGES=y 63CONFIG_PPC_64K_PAGES=y
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 59abc620f8e8..73eb794d6163 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -154,6 +154,34 @@ static __inline__ int test_and_change_bit(unsigned long nr,
154 return test_and_change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0; 154 return test_and_change_bits(BIT_MASK(nr), addr + BIT_WORD(nr)) != 0;
155} 155}
156 156
157#ifdef CONFIG_PPC64
158static __inline__ unsigned long clear_bit_unlock_return_word(int nr,
159 volatile unsigned long *addr)
160{
161 unsigned long old, t;
162 unsigned long *p = (unsigned long *)addr + BIT_WORD(nr);
163 unsigned long mask = BIT_MASK(nr);
164
165 __asm__ __volatile__ (
166 PPC_RELEASE_BARRIER
167"1:" PPC_LLARX(%0,0,%3,0) "\n"
168 "andc %1,%0,%2\n"
169 PPC405_ERR77(0,%3)
170 PPC_STLCX "%1,0,%3\n"
171 "bne- 1b\n"
172 : "=&r" (old), "=&r" (t)
173 : "r" (mask), "r" (p)
174 : "cc", "memory");
175
176 return old;
177}
178
179/* This is a special function for mm/filemap.c */
180#define clear_bit_unlock_is_negative_byte(nr, addr) \
181 (clear_bit_unlock_return_word(nr, addr) & BIT_MASK(PG_waiters))
182
183#endif /* CONFIG_PPC64 */
184
157#include <asm-generic/bitops/non-atomic.h> 185#include <asm-generic/bitops/non-atomic.h>
158 186
159static __inline__ void __clear_bit_unlock(int nr, volatile unsigned long *addr) 187static __inline__ void __clear_bit_unlock(int nr, volatile unsigned long *addr)
diff --git a/arch/powerpc/include/asm/pnv-pci.h b/arch/powerpc/include/asm/pnv-pci.h
index 696438f09aea..de9681034353 100644
--- a/arch/powerpc/include/asm/pnv-pci.h
+++ b/arch/powerpc/include/asm/pnv-pci.h
@@ -57,6 +57,8 @@ struct pnv_php_slot {
57 uint64_t id; 57 uint64_t id;
58 char *name; 58 char *name;
59 int slot_no; 59 int slot_no;
60 unsigned int flags;
61#define PNV_PHP_FLAG_BROKEN_PDC 0x1
60 struct kref kref; 62 struct kref kref;
61#define PNV_PHP_STATE_INITIALIZED 0 63#define PNV_PHP_STATE_INITIALIZED 0
62#define PNV_PHP_STATE_REGISTERED 1 64#define PNV_PHP_STATE_REGISTERED 1
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 025833b8df9f..359c44341761 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -505,7 +505,6 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
505#define MTMSRD(r) mtmsrd r 505#define MTMSRD(r) mtmsrd r
506#define MTMSR_EERI(reg) mtmsrd reg,1 506#define MTMSR_EERI(reg) mtmsrd reg,1
507#else 507#else
508#define FIX_SRR1(ra, rb)
509#ifndef CONFIG_40x 508#ifndef CONFIG_40x
510#define RFI rfi 509#define RFI rfi
511#else 510#else
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 21e0b52685b5..e0fecbcea2a2 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -225,6 +225,7 @@ struct thread_struct {
225#ifdef CONFIG_PPC64 225#ifdef CONFIG_PPC64
226 unsigned long start_tb; /* Start purr when proc switched in */ 226 unsigned long start_tb; /* Start purr when proc switched in */
227 unsigned long accum_tb; /* Total accumulated purr for process */ 227 unsigned long accum_tb; /* Total accumulated purr for process */
228#endif
228#ifdef CONFIG_HAVE_HW_BREAKPOINT 229#ifdef CONFIG_HAVE_HW_BREAKPOINT
229 struct perf_event *ptrace_bps[HBP_NUM]; 230 struct perf_event *ptrace_bps[HBP_NUM];
230 /* 231 /*
@@ -233,7 +234,6 @@ struct thread_struct {
233 */ 234 */
234 struct perf_event *last_hit_ubp; 235 struct perf_event *last_hit_ubp;
235#endif /* CONFIG_HAVE_HW_BREAKPOINT */ 236#endif /* CONFIG_HAVE_HW_BREAKPOINT */
236#endif
237 struct arch_hw_breakpoint hw_brk; /* info on the hardware breakpoint */ 237 struct arch_hw_breakpoint hw_brk; /* info on the hardware breakpoint */
238 unsigned long trap_nr; /* last trap # on this thread */ 238 unsigned long trap_nr; /* last trap # on this thread */
239 u8 load_fp; 239 u8 load_fp;
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 2c8001cc93b6..4a90634e8322 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -153,6 +153,7 @@ struct of_drconf_cell {
153#define OV5_XCMO 0x0440 /* Page Coalescing */ 153#define OV5_XCMO 0x0440 /* Page Coalescing */
154#define OV5_TYPE1_AFFINITY 0x0580 /* Type 1 NUMA affinity */ 154#define OV5_TYPE1_AFFINITY 0x0580 /* Type 1 NUMA affinity */
155#define OV5_PRRN 0x0540 /* Platform Resource Reassignment */ 155#define OV5_PRRN 0x0540 /* Platform Resource Reassignment */
156#define OV5_HP_EVT 0x0604 /* Hot Plug Event support */
156#define OV5_RESIZE_HPT 0x0601 /* Hash Page Table resizing */ 157#define OV5_RESIZE_HPT 0x0601 /* Hash Page Table resizing */
157#define OV5_PFO_HW_RNG 0x1180 /* PFO Random Number Generator */ 158#define OV5_PFO_HW_RNG 0x1180 /* PFO Random Number Generator */
158#define OV5_PFO_HW_842 0x1140 /* PFO Compression Accelerator */ 159#define OV5_PFO_HW_842 0x1140 /* PFO Compression Accelerator */
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index cb02d32db147..fc879fd6bdae 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -552,7 +552,9 @@
552#define SPRN_IBAT7U 0x236 /* Instruction BAT 7 Upper Register */ 552#define SPRN_IBAT7U 0x236 /* Instruction BAT 7 Upper Register */
553#define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */ 553#define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */
554#define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */ 554#define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */
555#ifndef SPRN_ICTRL
555#define SPRN_ICTRL 0x3F3 /* 1011 7450 icache and interrupt ctrl */ 556#define SPRN_ICTRL 0x3F3 /* 1011 7450 icache and interrupt ctrl */
557#endif
556#define ICTRL_EICE 0x08000000 /* enable icache parity errs */ 558#define ICTRL_EICE 0x08000000 /* enable icache parity errs */
557#define ICTRL_EDC 0x04000000 /* enable dcache parity errs */ 559#define ICTRL_EDC 0x04000000 /* enable dcache parity errs */
558#define ICTRL_EICP 0x00000100 /* enable icache par. check */ 560#define ICTRL_EICP 0x00000100 /* enable icache par. check */
diff --git a/arch/powerpc/include/asm/reg_8xx.h b/arch/powerpc/include/asm/reg_8xx.h
index 1f1636124a04..ae16fef7a4d6 100644
--- a/arch/powerpc/include/asm/reg_8xx.h
+++ b/arch/powerpc/include/asm/reg_8xx.h
@@ -28,6 +28,17 @@
28/* Special MSR manipulation registers */ 28/* Special MSR manipulation registers */
29#define SPRN_EIE 80 /* External interrupt enable (EE=1, RI=1) */ 29#define SPRN_EIE 80 /* External interrupt enable (EE=1, RI=1) */
30#define SPRN_EID 81 /* External interrupt disable (EE=0, RI=1) */ 30#define SPRN_EID 81 /* External interrupt disable (EE=0, RI=1) */
31#define SPRN_NRI 82 /* Non recoverable interrupt (EE=0, RI=0) */
32
33/* Debug registers */
34#define SPRN_CMPA 144
35#define SPRN_COUNTA 150
36#define SPRN_CMPE 152
37#define SPRN_CMPF 153
38#define SPRN_LCTRL1 156
39#define SPRN_LCTRL2 157
40#define SPRN_ICTRL 158
41#define SPRN_BAR 159
31 42
32/* Commands. Only the first few are available to the instruction cache. 43/* Commands. Only the first few are available to the instruction cache.
33*/ 44*/
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 076b89247ab5..ec9dd79398ee 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -307,6 +307,7 @@ struct pseries_hp_errorlog {
307 union { 307 union {
308 __be32 drc_index; 308 __be32 drc_index;
309 __be32 drc_count; 309 __be32 drc_count;
310 struct { __be32 count, index; } ic;
310 char drc_name[1]; 311 char drc_name[1];
311 } _drc_u; 312 } _drc_u;
312}; 313};
@@ -323,6 +324,7 @@ struct pseries_hp_errorlog {
323#define PSERIES_HP_ELOG_ID_DRC_NAME 1 324#define PSERIES_HP_ELOG_ID_DRC_NAME 1
324#define PSERIES_HP_ELOG_ID_DRC_INDEX 2 325#define PSERIES_HP_ELOG_ID_DRC_INDEX 2
325#define PSERIES_HP_ELOG_ID_DRC_COUNT 3 326#define PSERIES_HP_ELOG_ID_DRC_COUNT 3
327#define PSERIES_HP_ELOG_ID_DRC_IC 4
326 328
327struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, 329struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
328 uint16_t section_id); 330 uint16_t section_id);
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index f25239b3a06f..4367e7df51a1 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -72,205 +72,190 @@
72#include <asm/fixmap.h> 72#include <asm/fixmap.h>
73#endif 73#endif
74 74
75#define STACK_PT_REGS_OFFSET(sym, val) \
76 DEFINE(sym, STACK_FRAME_OVERHEAD + offsetof(struct pt_regs, val))
77
75int main(void) 78int main(void)
76{ 79{
77 DEFINE(THREAD, offsetof(struct task_struct, thread)); 80 OFFSET(THREAD, task_struct, thread);
78 DEFINE(MM, offsetof(struct task_struct, mm)); 81 OFFSET(MM, task_struct, mm);
79 DEFINE(MMCONTEXTID, offsetof(struct mm_struct, context.id)); 82 OFFSET(MMCONTEXTID, mm_struct, context.id);
80#ifdef CONFIG_PPC64 83#ifdef CONFIG_PPC64
81 DEFINE(SIGSEGV, SIGSEGV); 84 DEFINE(SIGSEGV, SIGSEGV);
82 DEFINE(NMI_MASK, NMI_MASK); 85 DEFINE(NMI_MASK, NMI_MASK);
83 DEFINE(TASKTHREADPPR, offsetof(struct task_struct, thread.ppr)); 86 OFFSET(TASKTHREADPPR, task_struct, thread.ppr);
84#else 87#else
85 DEFINE(THREAD_INFO, offsetof(struct task_struct, stack)); 88 OFFSET(THREAD_INFO, task_struct, stack);
86 DEFINE(THREAD_INFO_GAP, _ALIGN_UP(sizeof(struct thread_info), 16)); 89 DEFINE(THREAD_INFO_GAP, _ALIGN_UP(sizeof(struct thread_info), 16));
87 DEFINE(KSP_LIMIT, offsetof(struct thread_struct, ksp_limit)); 90 OFFSET(KSP_LIMIT, thread_struct, ksp_limit);
88#endif /* CONFIG_PPC64 */ 91#endif /* CONFIG_PPC64 */
89 92
90#ifdef CONFIG_LIVEPATCH 93#ifdef CONFIG_LIVEPATCH
91 DEFINE(TI_livepatch_sp, offsetof(struct thread_info, livepatch_sp)); 94 OFFSET(TI_livepatch_sp, thread_info, livepatch_sp);
92#endif 95#endif
93 96
94 DEFINE(KSP, offsetof(struct thread_struct, ksp)); 97 OFFSET(KSP, thread_struct, ksp);
95 DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); 98 OFFSET(PT_REGS, thread_struct, regs);
96#ifdef CONFIG_BOOKE 99#ifdef CONFIG_BOOKE
97 DEFINE(THREAD_NORMSAVES, offsetof(struct thread_struct, normsave[0])); 100 OFFSET(THREAD_NORMSAVES, thread_struct, normsave[0]);
98#endif 101#endif
99 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); 102 OFFSET(THREAD_FPEXC_MODE, thread_struct, fpexc_mode);
100 DEFINE(THREAD_FPSTATE, offsetof(struct thread_struct, fp_state)); 103 OFFSET(THREAD_FPSTATE, thread_struct, fp_state);
101 DEFINE(THREAD_FPSAVEAREA, offsetof(struct thread_struct, fp_save_area)); 104 OFFSET(THREAD_FPSAVEAREA, thread_struct, fp_save_area);
102 DEFINE(FPSTATE_FPSCR, offsetof(struct thread_fp_state, fpscr)); 105 OFFSET(FPSTATE_FPSCR, thread_fp_state, fpscr);
103 DEFINE(THREAD_LOAD_FP, offsetof(struct thread_struct, load_fp)); 106 OFFSET(THREAD_LOAD_FP, thread_struct, load_fp);
104#ifdef CONFIG_ALTIVEC 107#ifdef CONFIG_ALTIVEC
105 DEFINE(THREAD_VRSTATE, offsetof(struct thread_struct, vr_state)); 108 OFFSET(THREAD_VRSTATE, thread_struct, vr_state);
106 DEFINE(THREAD_VRSAVEAREA, offsetof(struct thread_struct, vr_save_area)); 109 OFFSET(THREAD_VRSAVEAREA, thread_struct, vr_save_area);
107 DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave)); 110 OFFSET(THREAD_VRSAVE, thread_struct, vrsave);
108 DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr)); 111 OFFSET(THREAD_USED_VR, thread_struct, used_vr);
109 DEFINE(VRSTATE_VSCR, offsetof(struct thread_vr_state, vscr)); 112 OFFSET(VRSTATE_VSCR, thread_vr_state, vscr);
110 DEFINE(THREAD_LOAD_VEC, offsetof(struct thread_struct, load_vec)); 113 OFFSET(THREAD_LOAD_VEC, thread_struct, load_vec);
111#endif /* CONFIG_ALTIVEC */ 114#endif /* CONFIG_ALTIVEC */
112#ifdef CONFIG_VSX 115#ifdef CONFIG_VSX
113 DEFINE(THREAD_USED_VSR, offsetof(struct thread_struct, used_vsr)); 116 OFFSET(THREAD_USED_VSR, thread_struct, used_vsr);
114#endif /* CONFIG_VSX */ 117#endif /* CONFIG_VSX */
115#ifdef CONFIG_PPC64 118#ifdef CONFIG_PPC64
116 DEFINE(KSP_VSID, offsetof(struct thread_struct, ksp_vsid)); 119 OFFSET(KSP_VSID, thread_struct, ksp_vsid);
117#else /* CONFIG_PPC64 */ 120#else /* CONFIG_PPC64 */
118 DEFINE(PGDIR, offsetof(struct thread_struct, pgdir)); 121 OFFSET(PGDIR, thread_struct, pgdir);
119#ifdef CONFIG_SPE 122#ifdef CONFIG_SPE
120 DEFINE(THREAD_EVR0, offsetof(struct thread_struct, evr[0])); 123 OFFSET(THREAD_EVR0, thread_struct, evr[0]);
121 DEFINE(THREAD_ACC, offsetof(struct thread_struct, acc)); 124 OFFSET(THREAD_ACC, thread_struct, acc);
122 DEFINE(THREAD_SPEFSCR, offsetof(struct thread_struct, spefscr)); 125 OFFSET(THREAD_SPEFSCR, thread_struct, spefscr);
123 DEFINE(THREAD_USED_SPE, offsetof(struct thread_struct, used_spe)); 126 OFFSET(THREAD_USED_SPE, thread_struct, used_spe);
124#endif /* CONFIG_SPE */ 127#endif /* CONFIG_SPE */
125#endif /* CONFIG_PPC64 */ 128#endif /* CONFIG_PPC64 */
126#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) 129#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
127 DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, debug.dbcr0)); 130 OFFSET(THREAD_DBCR0, thread_struct, debug.dbcr0);
128#endif 131#endif
129#ifdef CONFIG_KVM_BOOK3S_32_HANDLER 132#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
130 DEFINE(THREAD_KVM_SVCPU, offsetof(struct thread_struct, kvm_shadow_vcpu)); 133 OFFSET(THREAD_KVM_SVCPU, thread_struct, kvm_shadow_vcpu);
131#endif 134#endif
132#if defined(CONFIG_KVM) && defined(CONFIG_BOOKE) 135#if defined(CONFIG_KVM) && defined(CONFIG_BOOKE)
133 DEFINE(THREAD_KVM_VCPU, offsetof(struct thread_struct, kvm_vcpu)); 136 OFFSET(THREAD_KVM_VCPU, thread_struct, kvm_vcpu);
134#endif 137#endif
135 138
136#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 139#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
137 DEFINE(PACATMSCRATCH, offsetof(struct paca_struct, tm_scratch)); 140 OFFSET(PACATMSCRATCH, paca_struct, tm_scratch);
138 DEFINE(THREAD_TM_TFHAR, offsetof(struct thread_struct, tm_tfhar)); 141 OFFSET(THREAD_TM_TFHAR, thread_struct, tm_tfhar);
139 DEFINE(THREAD_TM_TEXASR, offsetof(struct thread_struct, tm_texasr)); 142 OFFSET(THREAD_TM_TEXASR, thread_struct, tm_texasr);
140 DEFINE(THREAD_TM_TFIAR, offsetof(struct thread_struct, tm_tfiar)); 143 OFFSET(THREAD_TM_TFIAR, thread_struct, tm_tfiar);
141 DEFINE(THREAD_TM_TAR, offsetof(struct thread_struct, tm_tar)); 144 OFFSET(THREAD_TM_TAR, thread_struct, tm_tar);
142 DEFINE(THREAD_TM_PPR, offsetof(struct thread_struct, tm_ppr)); 145 OFFSET(THREAD_TM_PPR, thread_struct, tm_ppr);
143 DEFINE(THREAD_TM_DSCR, offsetof(struct thread_struct, tm_dscr)); 146 OFFSET(THREAD_TM_DSCR, thread_struct, tm_dscr);
144 DEFINE(PT_CKPT_REGS, offsetof(struct thread_struct, ckpt_regs)); 147 OFFSET(PT_CKPT_REGS, thread_struct, ckpt_regs);
145 DEFINE(THREAD_CKVRSTATE, offsetof(struct thread_struct, 148 OFFSET(THREAD_CKVRSTATE, thread_struct, ckvr_state);
146 ckvr_state)); 149 OFFSET(THREAD_CKVRSAVE, thread_struct, ckvrsave);
147 DEFINE(THREAD_CKVRSAVE, offsetof(struct thread_struct, 150 OFFSET(THREAD_CKFPSTATE, thread_struct, ckfp_state);
148 ckvrsave));
149 DEFINE(THREAD_CKFPSTATE, offsetof(struct thread_struct,
150 ckfp_state));
151 /* Local pt_regs on stack for Transactional Memory funcs. */ 151 /* Local pt_regs on stack for Transactional Memory funcs. */
152 DEFINE(TM_FRAME_SIZE, STACK_FRAME_OVERHEAD + 152 DEFINE(TM_FRAME_SIZE, STACK_FRAME_OVERHEAD +
153 sizeof(struct pt_regs) + 16); 153 sizeof(struct pt_regs) + 16);
154#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ 154#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
155 155
156 DEFINE(TI_FLAGS, offsetof(struct thread_info, flags)); 156 OFFSET(TI_FLAGS, thread_info, flags);
157 DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, local_flags)); 157 OFFSET(TI_LOCAL_FLAGS, thread_info, local_flags);
158 DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count)); 158 OFFSET(TI_PREEMPT, thread_info, preempt_count);
159 DEFINE(TI_TASK, offsetof(struct thread_info, task)); 159 OFFSET(TI_TASK, thread_info, task);
160 DEFINE(TI_CPU, offsetof(struct thread_info, cpu)); 160 OFFSET(TI_CPU, thread_info, cpu);
161 161
162#ifdef CONFIG_PPC64 162#ifdef CONFIG_PPC64
163 DEFINE(DCACHEL1BLOCKSIZE, offsetof(struct ppc64_caches, l1d.block_size)); 163 OFFSET(DCACHEL1BLOCKSIZE, ppc64_caches, l1d.block_size);
164 DEFINE(DCACHEL1LOGBLOCKSIZE, offsetof(struct ppc64_caches, l1d.log_block_size)); 164 OFFSET(DCACHEL1LOGBLOCKSIZE, ppc64_caches, l1d.log_block_size);
165 DEFINE(DCACHEL1BLOCKSPERPAGE, offsetof(struct ppc64_caches, l1d.blocks_per_page)); 165 OFFSET(DCACHEL1BLOCKSPERPAGE, ppc64_caches, l1d.blocks_per_page);
166 DEFINE(ICACHEL1BLOCKSIZE, offsetof(struct ppc64_caches, l1i.block_size)); 166 OFFSET(ICACHEL1BLOCKSIZE, ppc64_caches, l1i.block_size);
167 DEFINE(ICACHEL1LOGBLOCKSIZE, offsetof(struct ppc64_caches, l1i.log_block_size)); 167 OFFSET(ICACHEL1LOGBLOCKSIZE, ppc64_caches, l1i.log_block_size);
168 DEFINE(ICACHEL1BLOCKSPERPAGE, offsetof(struct ppc64_caches, l1i.blocks_per_page)); 168 OFFSET(ICACHEL1BLOCKSPERPAGE, ppc64_caches, l1i.blocks_per_page);
169 /* paca */ 169 /* paca */
170 DEFINE(PACA_SIZE, sizeof(struct paca_struct)); 170 DEFINE(PACA_SIZE, sizeof(struct paca_struct));
171 DEFINE(PACAPACAINDEX, offsetof(struct paca_struct, paca_index)); 171 OFFSET(PACAPACAINDEX, paca_struct, paca_index);
172 DEFINE(PACAPROCSTART, offsetof(struct paca_struct, cpu_start)); 172 OFFSET(PACAPROCSTART, paca_struct, cpu_start);
173 DEFINE(PACAKSAVE, offsetof(struct paca_struct, kstack)); 173 OFFSET(PACAKSAVE, paca_struct, kstack);
174 DEFINE(PACACURRENT, offsetof(struct paca_struct, __current)); 174 OFFSET(PACACURRENT, paca_struct, __current);
175 DEFINE(PACASAVEDMSR, offsetof(struct paca_struct, saved_msr)); 175 OFFSET(PACASAVEDMSR, paca_struct, saved_msr);
176 DEFINE(PACASTABRR, offsetof(struct paca_struct, stab_rr)); 176 OFFSET(PACASTABRR, paca_struct, stab_rr);
177 DEFINE(PACAR1, offsetof(struct paca_struct, saved_r1)); 177 OFFSET(PACAR1, paca_struct, saved_r1);
178 DEFINE(PACATOC, offsetof(struct paca_struct, kernel_toc)); 178 OFFSET(PACATOC, paca_struct, kernel_toc);
179 DEFINE(PACAKBASE, offsetof(struct paca_struct, kernelbase)); 179 OFFSET(PACAKBASE, paca_struct, kernelbase);
180 DEFINE(PACAKMSR, offsetof(struct paca_struct, kernel_msr)); 180 OFFSET(PACAKMSR, paca_struct, kernel_msr);
181 DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct, soft_enabled)); 181 OFFSET(PACASOFTIRQEN, paca_struct, soft_enabled);
182 DEFINE(PACAIRQHAPPENED, offsetof(struct paca_struct, irq_happened)); 182 OFFSET(PACAIRQHAPPENED, paca_struct, irq_happened);
183#ifdef CONFIG_PPC_BOOK3S 183#ifdef CONFIG_PPC_BOOK3S
184 DEFINE(PACACONTEXTID, offsetof(struct paca_struct, mm_ctx_id)); 184 OFFSET(PACACONTEXTID, paca_struct, mm_ctx_id);
185#ifdef CONFIG_PPC_MM_SLICES 185#ifdef CONFIG_PPC_MM_SLICES
186 DEFINE(PACALOWSLICESPSIZE, offsetof(struct paca_struct, 186 OFFSET(PACALOWSLICESPSIZE, paca_struct, mm_ctx_low_slices_psize);
187 mm_ctx_low_slices_psize)); 187 OFFSET(PACAHIGHSLICEPSIZE, paca_struct, mm_ctx_high_slices_psize);
188 DEFINE(PACAHIGHSLICEPSIZE, offsetof(struct paca_struct,
189 mm_ctx_high_slices_psize));
190 DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def)); 188 DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def));
191#endif /* CONFIG_PPC_MM_SLICES */ 189#endif /* CONFIG_PPC_MM_SLICES */
192#endif 190#endif
193 191
194#ifdef CONFIG_PPC_BOOK3E 192#ifdef CONFIG_PPC_BOOK3E
195 DEFINE(PACAPGD, offsetof(struct paca_struct, pgd)); 193 OFFSET(PACAPGD, paca_struct, pgd);
196 DEFINE(PACA_KERNELPGD, offsetof(struct paca_struct, kernel_pgd)); 194 OFFSET(PACA_KERNELPGD, paca_struct, kernel_pgd);
197 DEFINE(PACA_EXGEN, offsetof(struct paca_struct, exgen)); 195 OFFSET(PACA_EXGEN, paca_struct, exgen);
198 DEFINE(PACA_EXTLB, offsetof(struct paca_struct, extlb)); 196 OFFSET(PACA_EXTLB, paca_struct, extlb);
199 DEFINE(PACA_EXMC, offsetof(struct paca_struct, exmc)); 197 OFFSET(PACA_EXMC, paca_struct, exmc);
200 DEFINE(PACA_EXCRIT, offsetof(struct paca_struct, excrit)); 198 OFFSET(PACA_EXCRIT, paca_struct, excrit);
201 DEFINE(PACA_EXDBG, offsetof(struct paca_struct, exdbg)); 199 OFFSET(PACA_EXDBG, paca_struct, exdbg);
202 DEFINE(PACA_MC_STACK, offsetof(struct paca_struct, mc_kstack)); 200 OFFSET(PACA_MC_STACK, paca_struct, mc_kstack);
203 DEFINE(PACA_CRIT_STACK, offsetof(struct paca_struct, crit_kstack)); 201 OFFSET(PACA_CRIT_STACK, paca_struct, crit_kstack);
204 DEFINE(PACA_DBG_STACK, offsetof(struct paca_struct, dbg_kstack)); 202 OFFSET(PACA_DBG_STACK, paca_struct, dbg_kstack);
205 DEFINE(PACA_TCD_PTR, offsetof(struct paca_struct, tcd_ptr)); 203 OFFSET(PACA_TCD_PTR, paca_struct, tcd_ptr);
206 204
207 DEFINE(TCD_ESEL_NEXT, 205 OFFSET(TCD_ESEL_NEXT, tlb_core_data, esel_next);
208 offsetof(struct tlb_core_data, esel_next)); 206 OFFSET(TCD_ESEL_MAX, tlb_core_data, esel_max);
209 DEFINE(TCD_ESEL_MAX, 207 OFFSET(TCD_ESEL_FIRST, tlb_core_data, esel_first);
210 offsetof(struct tlb_core_data, esel_max));
211 DEFINE(TCD_ESEL_FIRST,
212 offsetof(struct tlb_core_data, esel_first));
213#endif /* CONFIG_PPC_BOOK3E */ 208#endif /* CONFIG_PPC_BOOK3E */
214 209
215#ifdef CONFIG_PPC_STD_MMU_64 210#ifdef CONFIG_PPC_STD_MMU_64
216 DEFINE(PACASLBCACHE, offsetof(struct paca_struct, slb_cache)); 211 OFFSET(PACASLBCACHE, paca_struct, slb_cache);
217 DEFINE(PACASLBCACHEPTR, offsetof(struct paca_struct, slb_cache_ptr)); 212 OFFSET(PACASLBCACHEPTR, paca_struct, slb_cache_ptr);
218 DEFINE(PACAVMALLOCSLLP, offsetof(struct paca_struct, vmalloc_sllp)); 213 OFFSET(PACAVMALLOCSLLP, paca_struct, vmalloc_sllp);
219#ifdef CONFIG_PPC_MM_SLICES 214#ifdef CONFIG_PPC_MM_SLICES
220 DEFINE(MMUPSIZESLLP, offsetof(struct mmu_psize_def, sllp)); 215 OFFSET(MMUPSIZESLLP, mmu_psize_def, sllp);
221#else 216#else
222 DEFINE(PACACONTEXTSLLP, offsetof(struct paca_struct, mm_ctx_sllp)); 217 OFFSET(PACACONTEXTSLLP, paca_struct, mm_ctx_sllp);
223#endif /* CONFIG_PPC_MM_SLICES */ 218#endif /* CONFIG_PPC_MM_SLICES */
224 DEFINE(PACA_EXGEN, offsetof(struct paca_struct, exgen)); 219 OFFSET(PACA_EXGEN, paca_struct, exgen);
225 DEFINE(PACA_EXMC, offsetof(struct paca_struct, exmc)); 220 OFFSET(PACA_EXMC, paca_struct, exmc);
226 DEFINE(PACA_EXSLB, offsetof(struct paca_struct, exslb)); 221 OFFSET(PACA_EXSLB, paca_struct, exslb);
227 DEFINE(PACALPPACAPTR, offsetof(struct paca_struct, lppaca_ptr)); 222 OFFSET(PACALPPACAPTR, paca_struct, lppaca_ptr);
228 DEFINE(PACA_SLBSHADOWPTR, offsetof(struct paca_struct, slb_shadow_ptr)); 223 OFFSET(PACA_SLBSHADOWPTR, paca_struct, slb_shadow_ptr);
229 DEFINE(SLBSHADOW_STACKVSID, 224 OFFSET(SLBSHADOW_STACKVSID, slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid);
230 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid)); 225 OFFSET(SLBSHADOW_STACKESID, slb_shadow, save_area[SLB_NUM_BOLTED - 1].esid);
231 DEFINE(SLBSHADOW_STACKESID, 226 OFFSET(SLBSHADOW_SAVEAREA, slb_shadow, save_area);
232 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].esid)); 227 OFFSET(LPPACA_PMCINUSE, lppaca, pmcregs_in_use);
233 DEFINE(SLBSHADOW_SAVEAREA, offsetof(struct slb_shadow, save_area)); 228 OFFSET(LPPACA_DTLIDX, lppaca, dtl_idx);
234 DEFINE(LPPACA_PMCINUSE, offsetof(struct lppaca, pmcregs_in_use)); 229 OFFSET(LPPACA_YIELDCOUNT, lppaca, yield_count);
235 DEFINE(LPPACA_DTLIDX, offsetof(struct lppaca, dtl_idx)); 230 OFFSET(PACA_DTL_RIDX, paca_struct, dtl_ridx);
236 DEFINE(LPPACA_YIELDCOUNT, offsetof(struct lppaca, yield_count));
237 DEFINE(PACA_DTL_RIDX, offsetof(struct paca_struct, dtl_ridx));
238#endif /* CONFIG_PPC_STD_MMU_64 */ 231#endif /* CONFIG_PPC_STD_MMU_64 */
239 DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp)); 232 OFFSET(PACAEMERGSP, paca_struct, emergency_sp);
240#ifdef CONFIG_PPC_BOOK3S_64 233#ifdef CONFIG_PPC_BOOK3S_64
241 DEFINE(PACAMCEMERGSP, offsetof(struct paca_struct, mc_emergency_sp)); 234 OFFSET(PACAMCEMERGSP, paca_struct, mc_emergency_sp);
242 DEFINE(PACA_IN_MCE, offsetof(struct paca_struct, in_mce)); 235 OFFSET(PACA_IN_MCE, paca_struct, in_mce);
243#endif 236#endif
244 DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id)); 237 OFFSET(PACAHWCPUID, paca_struct, hw_cpu_id);
245 DEFINE(PACAKEXECSTATE, offsetof(struct paca_struct, kexec_state)); 238 OFFSET(PACAKEXECSTATE, paca_struct, kexec_state);
246 DEFINE(PACA_DSCR_DEFAULT, offsetof(struct paca_struct, dscr_default)); 239 OFFSET(PACA_DSCR_DEFAULT, paca_struct, dscr_default);
247 DEFINE(ACCOUNT_STARTTIME, 240 OFFSET(ACCOUNT_STARTTIME, paca_struct, accounting.starttime);
248 offsetof(struct paca_struct, accounting.starttime)); 241 OFFSET(ACCOUNT_STARTTIME_USER, paca_struct, accounting.starttime_user);
249 DEFINE(ACCOUNT_STARTTIME_USER, 242 OFFSET(ACCOUNT_USER_TIME, paca_struct, accounting.utime);
250 offsetof(struct paca_struct, accounting.starttime_user)); 243 OFFSET(ACCOUNT_SYSTEM_TIME, paca_struct, accounting.stime);
251 DEFINE(ACCOUNT_USER_TIME, 244 OFFSET(PACA_TRAP_SAVE, paca_struct, trap_save);
252 offsetof(struct paca_struct, accounting.utime)); 245 OFFSET(PACA_NAPSTATELOST, paca_struct, nap_state_lost);
253 DEFINE(ACCOUNT_SYSTEM_TIME, 246 OFFSET(PACA_SPRG_VDSO, paca_struct, sprg_vdso);
254 offsetof(struct paca_struct, accounting.stime));
255 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save));
256 DEFINE(PACA_NAPSTATELOST, offsetof(struct paca_struct, nap_state_lost));
257 DEFINE(PACA_SPRG_VDSO, offsetof(struct paca_struct, sprg_vdso));
258#else /* CONFIG_PPC64 */ 247#else /* CONFIG_PPC64 */
259#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE 248#ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE
260 DEFINE(ACCOUNT_STARTTIME, 249 OFFSET(ACCOUNT_STARTTIME, thread_info, accounting.starttime);
261 offsetof(struct thread_info, accounting.starttime)); 250 OFFSET(ACCOUNT_STARTTIME_USER, thread_info, accounting.starttime_user);
262 DEFINE(ACCOUNT_STARTTIME_USER, 251 OFFSET(ACCOUNT_USER_TIME, thread_info, accounting.utime);
263 offsetof(struct thread_info, accounting.starttime_user)); 252 OFFSET(ACCOUNT_SYSTEM_TIME, thread_info, accounting.stime);
264 DEFINE(ACCOUNT_USER_TIME,
265 offsetof(struct thread_info, accounting.utime));
266 DEFINE(ACCOUNT_SYSTEM_TIME,
267 offsetof(struct thread_info, accounting.stime));
268#endif 253#endif
269#endif /* CONFIG_PPC64 */ 254#endif /* CONFIG_PPC64 */
270 255
271 /* RTAS */ 256 /* RTAS */
272 DEFINE(RTASBASE, offsetof(struct rtas_t, base)); 257 OFFSET(RTASBASE, rtas_t, base);
273 DEFINE(RTASENTRY, offsetof(struct rtas_t, entry)); 258 OFFSET(RTASENTRY, rtas_t, entry);
274 259
275 /* Interrupt register frame */ 260 /* Interrupt register frame */
276 DEFINE(INT_FRAME_SIZE, STACK_INT_FRAME_SIZE); 261 DEFINE(INT_FRAME_SIZE, STACK_INT_FRAME_SIZE);
@@ -280,38 +265,38 @@ int main(void)
280 DEFINE(PROM_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16); 265 DEFINE(PROM_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16);
281 DEFINE(RTAS_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16); 266 DEFINE(RTAS_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16);
282#endif /* CONFIG_PPC64 */ 267#endif /* CONFIG_PPC64 */
283 DEFINE(GPR0, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[0])); 268 STACK_PT_REGS_OFFSET(GPR0, gpr[0]);
284 DEFINE(GPR1, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[1])); 269 STACK_PT_REGS_OFFSET(GPR1, gpr[1]);
285 DEFINE(GPR2, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[2])); 270 STACK_PT_REGS_OFFSET(GPR2, gpr[2]);
286 DEFINE(GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[3])); 271 STACK_PT_REGS_OFFSET(GPR3, gpr[3]);
287 DEFINE(GPR4, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[4])); 272 STACK_PT_REGS_OFFSET(GPR4, gpr[4]);
288 DEFINE(GPR5, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[5])); 273 STACK_PT_REGS_OFFSET(GPR5, gpr[5]);
289 DEFINE(GPR6, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[6])); 274 STACK_PT_REGS_OFFSET(GPR6, gpr[6]);
290 DEFINE(GPR7, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[7])); 275 STACK_PT_REGS_OFFSET(GPR7, gpr[7]);
291 DEFINE(GPR8, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[8])); 276 STACK_PT_REGS_OFFSET(GPR8, gpr[8]);
292 DEFINE(GPR9, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[9])); 277 STACK_PT_REGS_OFFSET(GPR9, gpr[9]);
293 DEFINE(GPR10, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[10])); 278 STACK_PT_REGS_OFFSET(GPR10, gpr[10]);
294 DEFINE(GPR11, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[11])); 279 STACK_PT_REGS_OFFSET(GPR11, gpr[11]);
295 DEFINE(GPR12, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[12])); 280 STACK_PT_REGS_OFFSET(GPR12, gpr[12]);
296 DEFINE(GPR13, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[13])); 281 STACK_PT_REGS_OFFSET(GPR13, gpr[13]);
297#ifndef CONFIG_PPC64 282#ifndef CONFIG_PPC64
298 DEFINE(GPR14, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[14])); 283 STACK_PT_REGS_OFFSET(GPR14, gpr[14]);
299#endif /* CONFIG_PPC64 */ 284#endif /* CONFIG_PPC64 */
300 /* 285 /*
301 * Note: these symbols include _ because they overlap with special 286 * Note: these symbols include _ because they overlap with special
302 * register names 287 * register names
303 */ 288 */
304 DEFINE(_NIP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, nip)); 289 STACK_PT_REGS_OFFSET(_NIP, nip);
305 DEFINE(_MSR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, msr)); 290 STACK_PT_REGS_OFFSET(_MSR, msr);
306 DEFINE(_CTR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ctr)); 291 STACK_PT_REGS_OFFSET(_CTR, ctr);
307 DEFINE(_LINK, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, link)); 292 STACK_PT_REGS_OFFSET(_LINK, link);
308 DEFINE(_CCR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, ccr)); 293 STACK_PT_REGS_OFFSET(_CCR, ccr);
309 DEFINE(_XER, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, xer)); 294 STACK_PT_REGS_OFFSET(_XER, xer);
310 DEFINE(_DAR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dar)); 295 STACK_PT_REGS_OFFSET(_DAR, dar);
311 DEFINE(_DSISR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dsisr)); 296 STACK_PT_REGS_OFFSET(_DSISR, dsisr);
312 DEFINE(ORIG_GPR3, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, orig_gpr3)); 297 STACK_PT_REGS_OFFSET(ORIG_GPR3, orig_gpr3);
313 DEFINE(RESULT, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, result)); 298 STACK_PT_REGS_OFFSET(RESULT, result);
314 DEFINE(_TRAP, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, trap)); 299 STACK_PT_REGS_OFFSET(_TRAP, trap);
315#ifndef CONFIG_PPC64 300#ifndef CONFIG_PPC64
316 /* 301 /*
317 * The PowerPC 400-class & Book-E processors have neither the DAR 302 * The PowerPC 400-class & Book-E processors have neither the DAR
@@ -319,10 +304,10 @@ int main(void)
319 * DEAR and ESR SPRs for such processors. For critical interrupts 304 * DEAR and ESR SPRs for such processors. For critical interrupts
320 * we use them to hold SRR0 and SRR1. 305 * we use them to hold SRR0 and SRR1.
321 */ 306 */
322 DEFINE(_DEAR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dar)); 307 STACK_PT_REGS_OFFSET(_DEAR, dar);
323 DEFINE(_ESR, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, dsisr)); 308 STACK_PT_REGS_OFFSET(_ESR, dsisr);
324#else /* CONFIG_PPC64 */ 309#else /* CONFIG_PPC64 */
325 DEFINE(SOFTE, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, softe)); 310 STACK_PT_REGS_OFFSET(SOFTE, softe);
326 311
327 /* These _only_ to be used with {PROM,RTAS}_FRAME_SIZE!!! */ 312 /* These _only_ to be used with {PROM,RTAS}_FRAME_SIZE!!! */
328 DEFINE(_SRR0, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs)); 313 DEFINE(_SRR0, STACK_FRAME_OVERHEAD+sizeof(struct pt_regs));
@@ -351,17 +336,17 @@ int main(void)
351#endif 336#endif
352 337
353#ifndef CONFIG_PPC64 338#ifndef CONFIG_PPC64
354 DEFINE(MM_PGD, offsetof(struct mm_struct, pgd)); 339 OFFSET(MM_PGD, mm_struct, pgd);
355#endif /* ! CONFIG_PPC64 */ 340#endif /* ! CONFIG_PPC64 */
356 341
357 /* About the CPU features table */ 342 /* About the CPU features table */
358 DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features)); 343 OFFSET(CPU_SPEC_FEATURES, cpu_spec, cpu_features);
359 DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup)); 344 OFFSET(CPU_SPEC_SETUP, cpu_spec, cpu_setup);
360 DEFINE(CPU_SPEC_RESTORE, offsetof(struct cpu_spec, cpu_restore)); 345 OFFSET(CPU_SPEC_RESTORE, cpu_spec, cpu_restore);
361 346
362 DEFINE(pbe_address, offsetof(struct pbe, address)); 347 OFFSET(pbe_address, pbe, address);
363 DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address)); 348 OFFSET(pbe_orig_address, pbe, orig_address);
364 DEFINE(pbe_next, offsetof(struct pbe, next)); 349 OFFSET(pbe_next, pbe, next);
365 350
366#ifndef CONFIG_PPC64 351#ifndef CONFIG_PPC64
367 DEFINE(TASK_SIZE, TASK_SIZE); 352 DEFINE(TASK_SIZE, TASK_SIZE);
@@ -369,40 +354,40 @@ int main(void)
369#endif /* ! CONFIG_PPC64 */ 354#endif /* ! CONFIG_PPC64 */
370 355
371 /* datapage offsets for use by vdso */ 356 /* datapage offsets for use by vdso */
372 DEFINE(CFG_TB_ORIG_STAMP, offsetof(struct vdso_data, tb_orig_stamp)); 357 OFFSET(CFG_TB_ORIG_STAMP, vdso_data, tb_orig_stamp);
373 DEFINE(CFG_TB_TICKS_PER_SEC, offsetof(struct vdso_data, tb_ticks_per_sec)); 358 OFFSET(CFG_TB_TICKS_PER_SEC, vdso_data, tb_ticks_per_sec);
374 DEFINE(CFG_TB_TO_XS, offsetof(struct vdso_data, tb_to_xs)); 359 OFFSET(CFG_TB_TO_XS, vdso_data, tb_to_xs);
375 DEFINE(CFG_TB_UPDATE_COUNT, offsetof(struct vdso_data, tb_update_count)); 360 OFFSET(CFG_TB_UPDATE_COUNT, vdso_data, tb_update_count);
376 DEFINE(CFG_TZ_MINUTEWEST, offsetof(struct vdso_data, tz_minuteswest)); 361 OFFSET(CFG_TZ_MINUTEWEST, vdso_data, tz_minuteswest);
377 DEFINE(CFG_TZ_DSTTIME, offsetof(struct vdso_data, tz_dsttime)); 362 OFFSET(CFG_TZ_DSTTIME, vdso_data, tz_dsttime);
378 DEFINE(CFG_SYSCALL_MAP32, offsetof(struct vdso_data, syscall_map_32)); 363 OFFSET(CFG_SYSCALL_MAP32, vdso_data, syscall_map_32);
379 DEFINE(WTOM_CLOCK_SEC, offsetof(struct vdso_data, wtom_clock_sec)); 364 OFFSET(WTOM_CLOCK_SEC, vdso_data, wtom_clock_sec);
380 DEFINE(WTOM_CLOCK_NSEC, offsetof(struct vdso_data, wtom_clock_nsec)); 365 OFFSET(WTOM_CLOCK_NSEC, vdso_data, wtom_clock_nsec);
381 DEFINE(STAMP_XTIME, offsetof(struct vdso_data, stamp_xtime)); 366 OFFSET(STAMP_XTIME, vdso_data, stamp_xtime);
382 DEFINE(STAMP_SEC_FRAC, offsetof(struct vdso_data, stamp_sec_fraction)); 367 OFFSET(STAMP_SEC_FRAC, vdso_data, stamp_sec_fraction);
383 DEFINE(CFG_ICACHE_BLOCKSZ, offsetof(struct vdso_data, icache_block_size)); 368 OFFSET(CFG_ICACHE_BLOCKSZ, vdso_data, icache_block_size);
384 DEFINE(CFG_DCACHE_BLOCKSZ, offsetof(struct vdso_data, dcache_block_size)); 369 OFFSET(CFG_DCACHE_BLOCKSZ, vdso_data, dcache_block_size);
385 DEFINE(CFG_ICACHE_LOGBLOCKSZ, offsetof(struct vdso_data, icache_log_block_size)); 370 OFFSET(CFG_ICACHE_LOGBLOCKSZ, vdso_data, icache_log_block_size);
386 DEFINE(CFG_DCACHE_LOGBLOCKSZ, offsetof(struct vdso_data, dcache_log_block_size)); 371 OFFSET(CFG_DCACHE_LOGBLOCKSZ, vdso_data, dcache_log_block_size);
387#ifdef CONFIG_PPC64 372#ifdef CONFIG_PPC64
388 DEFINE(CFG_SYSCALL_MAP64, offsetof(struct vdso_data, syscall_map_64)); 373 OFFSET(CFG_SYSCALL_MAP64, vdso_data, syscall_map_64);
389 DEFINE(TVAL64_TV_SEC, offsetof(struct timeval, tv_sec)); 374 OFFSET(TVAL64_TV_SEC, timeval, tv_sec);
390 DEFINE(TVAL64_TV_USEC, offsetof(struct timeval, tv_usec)); 375 OFFSET(TVAL64_TV_USEC, timeval, tv_usec);
391 DEFINE(TVAL32_TV_SEC, offsetof(struct compat_timeval, tv_sec)); 376 OFFSET(TVAL32_TV_SEC, compat_timeval, tv_sec);
392 DEFINE(TVAL32_TV_USEC, offsetof(struct compat_timeval, tv_usec)); 377 OFFSET(TVAL32_TV_USEC, compat_timeval, tv_usec);
393 DEFINE(TSPC64_TV_SEC, offsetof(struct timespec, tv_sec)); 378 OFFSET(TSPC64_TV_SEC, timespec, tv_sec);
394 DEFINE(TSPC64_TV_NSEC, offsetof(struct timespec, tv_nsec)); 379 OFFSET(TSPC64_TV_NSEC, timespec, tv_nsec);
395 DEFINE(TSPC32_TV_SEC, offsetof(struct compat_timespec, tv_sec)); 380 OFFSET(TSPC32_TV_SEC, compat_timespec, tv_sec);
396 DEFINE(TSPC32_TV_NSEC, offsetof(struct compat_timespec, tv_nsec)); 381 OFFSET(TSPC32_TV_NSEC, compat_timespec, tv_nsec);
397#else 382#else
398 DEFINE(TVAL32_TV_SEC, offsetof(struct timeval, tv_sec)); 383 OFFSET(TVAL32_TV_SEC, timeval, tv_sec);
399 DEFINE(TVAL32_TV_USEC, offsetof(struct timeval, tv_usec)); 384 OFFSET(TVAL32_TV_USEC, timeval, tv_usec);
400 DEFINE(TSPC32_TV_SEC, offsetof(struct timespec, tv_sec)); 385 OFFSET(TSPC32_TV_SEC, timespec, tv_sec);
401 DEFINE(TSPC32_TV_NSEC, offsetof(struct timespec, tv_nsec)); 386 OFFSET(TSPC32_TV_NSEC, timespec, tv_nsec);
402#endif 387#endif
403 /* timeval/timezone offsets for use by vdso */ 388 /* timeval/timezone offsets for use by vdso */
404 DEFINE(TZONE_TZ_MINWEST, offsetof(struct timezone, tz_minuteswest)); 389 OFFSET(TZONE_TZ_MINWEST, timezone, tz_minuteswest);
405 DEFINE(TZONE_TZ_DSTTIME, offsetof(struct timezone, tz_dsttime)); 390 OFFSET(TZONE_TZ_DSTTIME, timezone, tz_dsttime);
406 391
407 /* Other bits used by the vdso */ 392 /* Other bits used by the vdso */
408 DEFINE(CLOCK_REALTIME, CLOCK_REALTIME); 393 DEFINE(CLOCK_REALTIME, CLOCK_REALTIME);
@@ -422,170 +407,170 @@ int main(void)
422 DEFINE(PTE_SIZE, sizeof(pte_t)); 407 DEFINE(PTE_SIZE, sizeof(pte_t));
423 408
424#ifdef CONFIG_KVM 409#ifdef CONFIG_KVM
425 DEFINE(VCPU_HOST_STACK, offsetof(struct kvm_vcpu, arch.host_stack)); 410 OFFSET(VCPU_HOST_STACK, kvm_vcpu, arch.host_stack);
426 DEFINE(VCPU_HOST_PID, offsetof(struct kvm_vcpu, arch.host_pid)); 411 OFFSET(VCPU_HOST_PID, kvm_vcpu, arch.host_pid);
427 DEFINE(VCPU_GUEST_PID, offsetof(struct kvm_vcpu, arch.pid)); 412 OFFSET(VCPU_GUEST_PID, kvm_vcpu, arch.pid);
428 DEFINE(VCPU_GPRS, offsetof(struct kvm_vcpu, arch.gpr)); 413 OFFSET(VCPU_GPRS, kvm_vcpu, arch.gpr);
429 DEFINE(VCPU_VRSAVE, offsetof(struct kvm_vcpu, arch.vrsave)); 414 OFFSET(VCPU_VRSAVE, kvm_vcpu, arch.vrsave);
430 DEFINE(VCPU_FPRS, offsetof(struct kvm_vcpu, arch.fp.fpr)); 415 OFFSET(VCPU_FPRS, kvm_vcpu, arch.fp.fpr);
431#ifdef CONFIG_ALTIVEC 416#ifdef CONFIG_ALTIVEC
432 DEFINE(VCPU_VRS, offsetof(struct kvm_vcpu, arch.vr.vr)); 417 OFFSET(VCPU_VRS, kvm_vcpu, arch.vr.vr);
433#endif 418#endif
434 DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer)); 419 OFFSET(VCPU_XER, kvm_vcpu, arch.xer);
435 DEFINE(VCPU_CTR, offsetof(struct kvm_vcpu, arch.ctr)); 420 OFFSET(VCPU_CTR, kvm_vcpu, arch.ctr);
436 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); 421 OFFSET(VCPU_LR, kvm_vcpu, arch.lr);
437#ifdef CONFIG_PPC_BOOK3S 422#ifdef CONFIG_PPC_BOOK3S
438 DEFINE(VCPU_TAR, offsetof(struct kvm_vcpu, arch.tar)); 423 OFFSET(VCPU_TAR, kvm_vcpu, arch.tar);
439#endif 424#endif
440 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); 425 OFFSET(VCPU_CR, kvm_vcpu, arch.cr);
441 DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, arch.pc)); 426 OFFSET(VCPU_PC, kvm_vcpu, arch.pc);
442#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 427#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
443 DEFINE(VCPU_MSR, offsetof(struct kvm_vcpu, arch.shregs.msr)); 428 OFFSET(VCPU_MSR, kvm_vcpu, arch.shregs.msr);
444 DEFINE(VCPU_SRR0, offsetof(struct kvm_vcpu, arch.shregs.srr0)); 429 OFFSET(VCPU_SRR0, kvm_vcpu, arch.shregs.srr0);
445 DEFINE(VCPU_SRR1, offsetof(struct kvm_vcpu, arch.shregs.srr1)); 430 OFFSET(VCPU_SRR1, kvm_vcpu, arch.shregs.srr1);
446 DEFINE(VCPU_SPRG0, offsetof(struct kvm_vcpu, arch.shregs.sprg0)); 431 OFFSET(VCPU_SPRG0, kvm_vcpu, arch.shregs.sprg0);
447 DEFINE(VCPU_SPRG1, offsetof(struct kvm_vcpu, arch.shregs.sprg1)); 432 OFFSET(VCPU_SPRG1, kvm_vcpu, arch.shregs.sprg1);
448 DEFINE(VCPU_SPRG2, offsetof(struct kvm_vcpu, arch.shregs.sprg2)); 433 OFFSET(VCPU_SPRG2, kvm_vcpu, arch.shregs.sprg2);
449 DEFINE(VCPU_SPRG3, offsetof(struct kvm_vcpu, arch.shregs.sprg3)); 434 OFFSET(VCPU_SPRG3, kvm_vcpu, arch.shregs.sprg3);
450#endif 435#endif
451#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING 436#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING
452 DEFINE(VCPU_TB_RMENTRY, offsetof(struct kvm_vcpu, arch.rm_entry)); 437 OFFSET(VCPU_TB_RMENTRY, kvm_vcpu, arch.rm_entry);
453 DEFINE(VCPU_TB_RMINTR, offsetof(struct kvm_vcpu, arch.rm_intr)); 438 OFFSET(VCPU_TB_RMINTR, kvm_vcpu, arch.rm_intr);
454 DEFINE(VCPU_TB_RMEXIT, offsetof(struct kvm_vcpu, arch.rm_exit)); 439 OFFSET(VCPU_TB_RMEXIT, kvm_vcpu, arch.rm_exit);
455 DEFINE(VCPU_TB_GUEST, offsetof(struct kvm_vcpu, arch.guest_time)); 440 OFFSET(VCPU_TB_GUEST, kvm_vcpu, arch.guest_time);
456 DEFINE(VCPU_TB_CEDE, offsetof(struct kvm_vcpu, arch.cede_time)); 441 OFFSET(VCPU_TB_CEDE, kvm_vcpu, arch.cede_time);
457 DEFINE(VCPU_CUR_ACTIVITY, offsetof(struct kvm_vcpu, arch.cur_activity)); 442 OFFSET(VCPU_CUR_ACTIVITY, kvm_vcpu, arch.cur_activity);
458 DEFINE(VCPU_ACTIVITY_START, offsetof(struct kvm_vcpu, arch.cur_tb_start)); 443 OFFSET(VCPU_ACTIVITY_START, kvm_vcpu, arch.cur_tb_start);
459 DEFINE(TAS_SEQCOUNT, offsetof(struct kvmhv_tb_accumulator, seqcount)); 444 OFFSET(TAS_SEQCOUNT, kvmhv_tb_accumulator, seqcount);
460 DEFINE(TAS_TOTAL, offsetof(struct kvmhv_tb_accumulator, tb_total)); 445 OFFSET(TAS_TOTAL, kvmhv_tb_accumulator, tb_total);
461 DEFINE(TAS_MIN, offsetof(struct kvmhv_tb_accumulator, tb_min)); 446 OFFSET(TAS_MIN, kvmhv_tb_accumulator, tb_min);
462 DEFINE(TAS_MAX, offsetof(struct kvmhv_tb_accumulator, tb_max)); 447 OFFSET(TAS_MAX, kvmhv_tb_accumulator, tb_max);
463#endif 448#endif
464 DEFINE(VCPU_SHARED_SPRG3, offsetof(struct kvm_vcpu_arch_shared, sprg3)); 449 OFFSET(VCPU_SHARED_SPRG3, kvm_vcpu_arch_shared, sprg3);
465 DEFINE(VCPU_SHARED_SPRG4, offsetof(struct kvm_vcpu_arch_shared, sprg4)); 450 OFFSET(VCPU_SHARED_SPRG4, kvm_vcpu_arch_shared, sprg4);
466 DEFINE(VCPU_SHARED_SPRG5, offsetof(struct kvm_vcpu_arch_shared, sprg5)); 451 OFFSET(VCPU_SHARED_SPRG5, kvm_vcpu_arch_shared, sprg5);
467 DEFINE(VCPU_SHARED_SPRG6, offsetof(struct kvm_vcpu_arch_shared, sprg6)); 452 OFFSET(VCPU_SHARED_SPRG6, kvm_vcpu_arch_shared, sprg6);
468 DEFINE(VCPU_SHARED_SPRG7, offsetof(struct kvm_vcpu_arch_shared, sprg7)); 453 OFFSET(VCPU_SHARED_SPRG7, kvm_vcpu_arch_shared, sprg7);
469 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid)); 454 OFFSET(VCPU_SHADOW_PID, kvm_vcpu, arch.shadow_pid);
470 DEFINE(VCPU_SHADOW_PID1, offsetof(struct kvm_vcpu, arch.shadow_pid1)); 455 OFFSET(VCPU_SHADOW_PID1, kvm_vcpu, arch.shadow_pid1);
471 DEFINE(VCPU_SHARED, offsetof(struct kvm_vcpu, arch.shared)); 456 OFFSET(VCPU_SHARED, kvm_vcpu, arch.shared);
472 DEFINE(VCPU_SHARED_MSR, offsetof(struct kvm_vcpu_arch_shared, msr)); 457 OFFSET(VCPU_SHARED_MSR, kvm_vcpu_arch_shared, msr);
473 DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, arch.shadow_msr)); 458 OFFSET(VCPU_SHADOW_MSR, kvm_vcpu, arch.shadow_msr);
474#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE) 459#if defined(CONFIG_PPC_BOOK3S_64) && defined(CONFIG_KVM_BOOK3S_PR_POSSIBLE)
475 DEFINE(VCPU_SHAREDBE, offsetof(struct kvm_vcpu, arch.shared_big_endian)); 460 OFFSET(VCPU_SHAREDBE, kvm_vcpu, arch.shared_big_endian);
476#endif 461#endif
477 462
478 DEFINE(VCPU_SHARED_MAS0, offsetof(struct kvm_vcpu_arch_shared, mas0)); 463 OFFSET(VCPU_SHARED_MAS0, kvm_vcpu_arch_shared, mas0);
479 DEFINE(VCPU_SHARED_MAS1, offsetof(struct kvm_vcpu_arch_shared, mas1)); 464 OFFSET(VCPU_SHARED_MAS1, kvm_vcpu_arch_shared, mas1);
480 DEFINE(VCPU_SHARED_MAS2, offsetof(struct kvm_vcpu_arch_shared, mas2)); 465 OFFSET(VCPU_SHARED_MAS2, kvm_vcpu_arch_shared, mas2);
481 DEFINE(VCPU_SHARED_MAS7_3, offsetof(struct kvm_vcpu_arch_shared, mas7_3)); 466 OFFSET(VCPU_SHARED_MAS7_3, kvm_vcpu_arch_shared, mas7_3);
482 DEFINE(VCPU_SHARED_MAS4, offsetof(struct kvm_vcpu_arch_shared, mas4)); 467 OFFSET(VCPU_SHARED_MAS4, kvm_vcpu_arch_shared, mas4);
483 DEFINE(VCPU_SHARED_MAS6, offsetof(struct kvm_vcpu_arch_shared, mas6)); 468 OFFSET(VCPU_SHARED_MAS6, kvm_vcpu_arch_shared, mas6);
484 469
485 DEFINE(VCPU_KVM, offsetof(struct kvm_vcpu, kvm)); 470 OFFSET(VCPU_KVM, kvm_vcpu, kvm);
486 DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid)); 471 OFFSET(KVM_LPID, kvm, arch.lpid);
487 472
488 /* book3s */ 473 /* book3s */
489#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 474#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
490 DEFINE(KVM_TLB_SETS, offsetof(struct kvm, arch.tlb_sets)); 475 OFFSET(KVM_TLB_SETS, kvm, arch.tlb_sets);
491 DEFINE(KVM_SDR1, offsetof(struct kvm, arch.sdr1)); 476 OFFSET(KVM_SDR1, kvm, arch.sdr1);
492 DEFINE(KVM_HOST_LPID, offsetof(struct kvm, arch.host_lpid)); 477 OFFSET(KVM_HOST_LPID, kvm, arch.host_lpid);
493 DEFINE(KVM_HOST_LPCR, offsetof(struct kvm, arch.host_lpcr)); 478 OFFSET(KVM_HOST_LPCR, kvm, arch.host_lpcr);
494 DEFINE(KVM_HOST_SDR1, offsetof(struct kvm, arch.host_sdr1)); 479 OFFSET(KVM_HOST_SDR1, kvm, arch.host_sdr1);
495 DEFINE(KVM_NEED_FLUSH, offsetof(struct kvm, arch.need_tlb_flush.bits)); 480 OFFSET(KVM_NEED_FLUSH, kvm, arch.need_tlb_flush.bits);
496 DEFINE(KVM_ENABLED_HCALLS, offsetof(struct kvm, arch.enabled_hcalls)); 481 OFFSET(KVM_ENABLED_HCALLS, kvm, arch.enabled_hcalls);
497 DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v)); 482 OFFSET(KVM_VRMA_SLB_V, kvm, arch.vrma_slb_v);
498 DEFINE(KVM_RADIX, offsetof(struct kvm, arch.radix)); 483 OFFSET(KVM_RADIX, kvm, arch.radix);
499 DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr)); 484 OFFSET(VCPU_DSISR, kvm_vcpu, arch.shregs.dsisr);
500 DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); 485 OFFSET(VCPU_DAR, kvm_vcpu, arch.shregs.dar);
501 DEFINE(VCPU_VPA, offsetof(struct kvm_vcpu, arch.vpa.pinned_addr)); 486 OFFSET(VCPU_VPA, kvm_vcpu, arch.vpa.pinned_addr);
502 DEFINE(VCPU_VPA_DIRTY, offsetof(struct kvm_vcpu, arch.vpa.dirty)); 487 OFFSET(VCPU_VPA_DIRTY, kvm_vcpu, arch.vpa.dirty);
503 DEFINE(VCPU_HEIR, offsetof(struct kvm_vcpu, arch.emul_inst)); 488 OFFSET(VCPU_HEIR, kvm_vcpu, arch.emul_inst);
504 DEFINE(VCPU_CPU, offsetof(struct kvm_vcpu, cpu)); 489 OFFSET(VCPU_CPU, kvm_vcpu, cpu);
505 DEFINE(VCPU_THREAD_CPU, offsetof(struct kvm_vcpu, arch.thread_cpu)); 490 OFFSET(VCPU_THREAD_CPU, kvm_vcpu, arch.thread_cpu);
506#endif 491#endif
507#ifdef CONFIG_PPC_BOOK3S 492#ifdef CONFIG_PPC_BOOK3S
508 DEFINE(VCPU_PURR, offsetof(struct kvm_vcpu, arch.purr)); 493 OFFSET(VCPU_PURR, kvm_vcpu, arch.purr);
509 DEFINE(VCPU_SPURR, offsetof(struct kvm_vcpu, arch.spurr)); 494 OFFSET(VCPU_SPURR, kvm_vcpu, arch.spurr);
510 DEFINE(VCPU_IC, offsetof(struct kvm_vcpu, arch.ic)); 495 OFFSET(VCPU_IC, kvm_vcpu, arch.ic);
511 DEFINE(VCPU_DSCR, offsetof(struct kvm_vcpu, arch.dscr)); 496 OFFSET(VCPU_DSCR, kvm_vcpu, arch.dscr);
512 DEFINE(VCPU_AMR, offsetof(struct kvm_vcpu, arch.amr)); 497 OFFSET(VCPU_AMR, kvm_vcpu, arch.amr);
513 DEFINE(VCPU_UAMOR, offsetof(struct kvm_vcpu, arch.uamor)); 498 OFFSET(VCPU_UAMOR, kvm_vcpu, arch.uamor);
514 DEFINE(VCPU_IAMR, offsetof(struct kvm_vcpu, arch.iamr)); 499 OFFSET(VCPU_IAMR, kvm_vcpu, arch.iamr);
515 DEFINE(VCPU_CTRL, offsetof(struct kvm_vcpu, arch.ctrl)); 500 OFFSET(VCPU_CTRL, kvm_vcpu, arch.ctrl);
516 DEFINE(VCPU_DABR, offsetof(struct kvm_vcpu, arch.dabr)); 501 OFFSET(VCPU_DABR, kvm_vcpu, arch.dabr);
517 DEFINE(VCPU_DABRX, offsetof(struct kvm_vcpu, arch.dabrx)); 502 OFFSET(VCPU_DABRX, kvm_vcpu, arch.dabrx);
518 DEFINE(VCPU_DAWR, offsetof(struct kvm_vcpu, arch.dawr)); 503 OFFSET(VCPU_DAWR, kvm_vcpu, arch.dawr);
519 DEFINE(VCPU_DAWRX, offsetof(struct kvm_vcpu, arch.dawrx)); 504 OFFSET(VCPU_DAWRX, kvm_vcpu, arch.dawrx);
520 DEFINE(VCPU_CIABR, offsetof(struct kvm_vcpu, arch.ciabr)); 505 OFFSET(VCPU_CIABR, kvm_vcpu, arch.ciabr);
521 DEFINE(VCPU_HFLAGS, offsetof(struct kvm_vcpu, arch.hflags)); 506 OFFSET(VCPU_HFLAGS, kvm_vcpu, arch.hflags);
522 DEFINE(VCPU_DEC, offsetof(struct kvm_vcpu, arch.dec)); 507 OFFSET(VCPU_DEC, kvm_vcpu, arch.dec);
523 DEFINE(VCPU_DEC_EXPIRES, offsetof(struct kvm_vcpu, arch.dec_expires)); 508 OFFSET(VCPU_DEC_EXPIRES, kvm_vcpu, arch.dec_expires);
524 DEFINE(VCPU_PENDING_EXC, offsetof(struct kvm_vcpu, arch.pending_exceptions)); 509 OFFSET(VCPU_PENDING_EXC, kvm_vcpu, arch.pending_exceptions);
525 DEFINE(VCPU_CEDED, offsetof(struct kvm_vcpu, arch.ceded)); 510 OFFSET(VCPU_CEDED, kvm_vcpu, arch.ceded);
526 DEFINE(VCPU_PRODDED, offsetof(struct kvm_vcpu, arch.prodded)); 511 OFFSET(VCPU_PRODDED, kvm_vcpu, arch.prodded);
527 DEFINE(VCPU_MMCR, offsetof(struct kvm_vcpu, arch.mmcr)); 512 OFFSET(VCPU_MMCR, kvm_vcpu, arch.mmcr);
528 DEFINE(VCPU_PMC, offsetof(struct kvm_vcpu, arch.pmc)); 513 OFFSET(VCPU_PMC, kvm_vcpu, arch.pmc);
529 DEFINE(VCPU_SPMC, offsetof(struct kvm_vcpu, arch.spmc)); 514 OFFSET(VCPU_SPMC, kvm_vcpu, arch.spmc);
530 DEFINE(VCPU_SIAR, offsetof(struct kvm_vcpu, arch.siar)); 515 OFFSET(VCPU_SIAR, kvm_vcpu, arch.siar);
531 DEFINE(VCPU_SDAR, offsetof(struct kvm_vcpu, arch.sdar)); 516 OFFSET(VCPU_SDAR, kvm_vcpu, arch.sdar);
532 DEFINE(VCPU_SIER, offsetof(struct kvm_vcpu, arch.sier)); 517 OFFSET(VCPU_SIER, kvm_vcpu, arch.sier);
533 DEFINE(VCPU_SLB, offsetof(struct kvm_vcpu, arch.slb)); 518 OFFSET(VCPU_SLB, kvm_vcpu, arch.slb);
534 DEFINE(VCPU_SLB_MAX, offsetof(struct kvm_vcpu, arch.slb_max)); 519 OFFSET(VCPU_SLB_MAX, kvm_vcpu, arch.slb_max);
535 DEFINE(VCPU_SLB_NR, offsetof(struct kvm_vcpu, arch.slb_nr)); 520 OFFSET(VCPU_SLB_NR, kvm_vcpu, arch.slb_nr);
536 DEFINE(VCPU_FAULT_DSISR, offsetof(struct kvm_vcpu, arch.fault_dsisr)); 521 OFFSET(VCPU_FAULT_DSISR, kvm_vcpu, arch.fault_dsisr);
537 DEFINE(VCPU_FAULT_DAR, offsetof(struct kvm_vcpu, arch.fault_dar)); 522 OFFSET(VCPU_FAULT_DAR, kvm_vcpu, arch.fault_dar);
538 DEFINE(VCPU_FAULT_GPA, offsetof(struct kvm_vcpu, arch.fault_gpa)); 523 OFFSET(VCPU_FAULT_GPA, kvm_vcpu, arch.fault_gpa);
539 DEFINE(VCPU_INTR_MSR, offsetof(struct kvm_vcpu, arch.intr_msr)); 524 OFFSET(VCPU_INTR_MSR, kvm_vcpu, arch.intr_msr);
540 DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst)); 525 OFFSET(VCPU_LAST_INST, kvm_vcpu, arch.last_inst);
541 DEFINE(VCPU_TRAP, offsetof(struct kvm_vcpu, arch.trap)); 526 OFFSET(VCPU_TRAP, kvm_vcpu, arch.trap);
542 DEFINE(VCPU_CFAR, offsetof(struct kvm_vcpu, arch.cfar)); 527 OFFSET(VCPU_CFAR, kvm_vcpu, arch.cfar);
543 DEFINE(VCPU_PPR, offsetof(struct kvm_vcpu, arch.ppr)); 528 OFFSET(VCPU_PPR, kvm_vcpu, arch.ppr);
544 DEFINE(VCPU_FSCR, offsetof(struct kvm_vcpu, arch.fscr)); 529 OFFSET(VCPU_FSCR, kvm_vcpu, arch.fscr);
545 DEFINE(VCPU_PSPB, offsetof(struct kvm_vcpu, arch.pspb)); 530 OFFSET(VCPU_PSPB, kvm_vcpu, arch.pspb);
546 DEFINE(VCPU_EBBHR, offsetof(struct kvm_vcpu, arch.ebbhr)); 531 OFFSET(VCPU_EBBHR, kvm_vcpu, arch.ebbhr);
547 DEFINE(VCPU_EBBRR, offsetof(struct kvm_vcpu, arch.ebbrr)); 532 OFFSET(VCPU_EBBRR, kvm_vcpu, arch.ebbrr);
548 DEFINE(VCPU_BESCR, offsetof(struct kvm_vcpu, arch.bescr)); 533 OFFSET(VCPU_BESCR, kvm_vcpu, arch.bescr);
549 DEFINE(VCPU_CSIGR, offsetof(struct kvm_vcpu, arch.csigr)); 534 OFFSET(VCPU_CSIGR, kvm_vcpu, arch.csigr);
550 DEFINE(VCPU_TACR, offsetof(struct kvm_vcpu, arch.tacr)); 535 OFFSET(VCPU_TACR, kvm_vcpu, arch.tacr);
551 DEFINE(VCPU_TCSCR, offsetof(struct kvm_vcpu, arch.tcscr)); 536 OFFSET(VCPU_TCSCR, kvm_vcpu, arch.tcscr);
552 DEFINE(VCPU_ACOP, offsetof(struct kvm_vcpu, arch.acop)); 537 OFFSET(VCPU_ACOP, kvm_vcpu, arch.acop);
553 DEFINE(VCPU_WORT, offsetof(struct kvm_vcpu, arch.wort)); 538 OFFSET(VCPU_WORT, kvm_vcpu, arch.wort);
554 DEFINE(VCPU_TID, offsetof(struct kvm_vcpu, arch.tid)); 539 OFFSET(VCPU_TID, kvm_vcpu, arch.tid);
555 DEFINE(VCPU_PSSCR, offsetof(struct kvm_vcpu, arch.psscr)); 540 OFFSET(VCPU_PSSCR, kvm_vcpu, arch.psscr);
556 DEFINE(VCORE_ENTRY_EXIT, offsetof(struct kvmppc_vcore, entry_exit_map)); 541 OFFSET(VCORE_ENTRY_EXIT, kvmppc_vcore, entry_exit_map);
557 DEFINE(VCORE_IN_GUEST, offsetof(struct kvmppc_vcore, in_guest)); 542 OFFSET(VCORE_IN_GUEST, kvmppc_vcore, in_guest);
558 DEFINE(VCORE_NAPPING_THREADS, offsetof(struct kvmppc_vcore, napping_threads)); 543 OFFSET(VCORE_NAPPING_THREADS, kvmppc_vcore, napping_threads);
559 DEFINE(VCORE_KVM, offsetof(struct kvmppc_vcore, kvm)); 544 OFFSET(VCORE_KVM, kvmppc_vcore, kvm);
560 DEFINE(VCORE_TB_OFFSET, offsetof(struct kvmppc_vcore, tb_offset)); 545 OFFSET(VCORE_TB_OFFSET, kvmppc_vcore, tb_offset);
561 DEFINE(VCORE_LPCR, offsetof(struct kvmppc_vcore, lpcr)); 546 OFFSET(VCORE_LPCR, kvmppc_vcore, lpcr);
562 DEFINE(VCORE_PCR, offsetof(struct kvmppc_vcore, pcr)); 547 OFFSET(VCORE_PCR, kvmppc_vcore, pcr);
563 DEFINE(VCORE_DPDES, offsetof(struct kvmppc_vcore, dpdes)); 548 OFFSET(VCORE_DPDES, kvmppc_vcore, dpdes);
564 DEFINE(VCORE_VTB, offsetof(struct kvmppc_vcore, vtb)); 549 OFFSET(VCORE_VTB, kvmppc_vcore, vtb);
565 DEFINE(VCPU_SLB_E, offsetof(struct kvmppc_slb, orige)); 550 OFFSET(VCPU_SLB_E, kvmppc_slb, orige);
566 DEFINE(VCPU_SLB_V, offsetof(struct kvmppc_slb, origv)); 551 OFFSET(VCPU_SLB_V, kvmppc_slb, origv);
567 DEFINE(VCPU_SLB_SIZE, sizeof(struct kvmppc_slb)); 552 DEFINE(VCPU_SLB_SIZE, sizeof(struct kvmppc_slb));
568#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 553#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
569 DEFINE(VCPU_TFHAR, offsetof(struct kvm_vcpu, arch.tfhar)); 554 OFFSET(VCPU_TFHAR, kvm_vcpu, arch.tfhar);
570 DEFINE(VCPU_TFIAR, offsetof(struct kvm_vcpu, arch.tfiar)); 555 OFFSET(VCPU_TFIAR, kvm_vcpu, arch.tfiar);
571 DEFINE(VCPU_TEXASR, offsetof(struct kvm_vcpu, arch.texasr)); 556 OFFSET(VCPU_TEXASR, kvm_vcpu, arch.texasr);
572 DEFINE(VCPU_GPR_TM, offsetof(struct kvm_vcpu, arch.gpr_tm)); 557 OFFSET(VCPU_GPR_TM, kvm_vcpu, arch.gpr_tm);
573 DEFINE(VCPU_FPRS_TM, offsetof(struct kvm_vcpu, arch.fp_tm.fpr)); 558 OFFSET(VCPU_FPRS_TM, kvm_vcpu, arch.fp_tm.fpr);
574 DEFINE(VCPU_VRS_TM, offsetof(struct kvm_vcpu, arch.vr_tm.vr)); 559 OFFSET(VCPU_VRS_TM, kvm_vcpu, arch.vr_tm.vr);
575 DEFINE(VCPU_VRSAVE_TM, offsetof(struct kvm_vcpu, arch.vrsave_tm)); 560 OFFSET(VCPU_VRSAVE_TM, kvm_vcpu, arch.vrsave_tm);
576 DEFINE(VCPU_CR_TM, offsetof(struct kvm_vcpu, arch.cr_tm)); 561 OFFSET(VCPU_CR_TM, kvm_vcpu, arch.cr_tm);
577 DEFINE(VCPU_XER_TM, offsetof(struct kvm_vcpu, arch.xer_tm)); 562 OFFSET(VCPU_XER_TM, kvm_vcpu, arch.xer_tm);
578 DEFINE(VCPU_LR_TM, offsetof(struct kvm_vcpu, arch.lr_tm)); 563 OFFSET(VCPU_LR_TM, kvm_vcpu, arch.lr_tm);
579 DEFINE(VCPU_CTR_TM, offsetof(struct kvm_vcpu, arch.ctr_tm)); 564 OFFSET(VCPU_CTR_TM, kvm_vcpu, arch.ctr_tm);
580 DEFINE(VCPU_AMR_TM, offsetof(struct kvm_vcpu, arch.amr_tm)); 565 OFFSET(VCPU_AMR_TM, kvm_vcpu, arch.amr_tm);
581 DEFINE(VCPU_PPR_TM, offsetof(struct kvm_vcpu, arch.ppr_tm)); 566 OFFSET(VCPU_PPR_TM, kvm_vcpu, arch.ppr_tm);
582 DEFINE(VCPU_DSCR_TM, offsetof(struct kvm_vcpu, arch.dscr_tm)); 567 OFFSET(VCPU_DSCR_TM, kvm_vcpu, arch.dscr_tm);
583 DEFINE(VCPU_TAR_TM, offsetof(struct kvm_vcpu, arch.tar_tm)); 568 OFFSET(VCPU_TAR_TM, kvm_vcpu, arch.tar_tm);
584#endif 569#endif
585 570
586#ifdef CONFIG_PPC_BOOK3S_64 571#ifdef CONFIG_PPC_BOOK3S_64
587#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE 572#ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
588 DEFINE(PACA_SVCPU, offsetof(struct paca_struct, shadow_vcpu)); 573 OFFSET(PACA_SVCPU, paca_struct, shadow_vcpu);
589# define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, shadow_vcpu.f)) 574# define SVCPU_FIELD(x, f) DEFINE(x, offsetof(struct paca_struct, shadow_vcpu.f))
590#else 575#else
591# define SVCPU_FIELD(x, f) 576# define SVCPU_FIELD(x, f)
@@ -668,11 +653,11 @@ int main(void)
668 HSTATE_FIELD(HSTATE_DECEXP, dec_expires); 653 HSTATE_FIELD(HSTATE_DECEXP, dec_expires);
669 HSTATE_FIELD(HSTATE_SPLIT_MODE, kvm_split_mode); 654 HSTATE_FIELD(HSTATE_SPLIT_MODE, kvm_split_mode);
670 DEFINE(IPI_PRIORITY, IPI_PRIORITY); 655 DEFINE(IPI_PRIORITY, IPI_PRIORITY);
671 DEFINE(KVM_SPLIT_RPR, offsetof(struct kvm_split_mode, rpr)); 656 OFFSET(KVM_SPLIT_RPR, kvm_split_mode, rpr);
672 DEFINE(KVM_SPLIT_PMMAR, offsetof(struct kvm_split_mode, pmmar)); 657 OFFSET(KVM_SPLIT_PMMAR, kvm_split_mode, pmmar);
673 DEFINE(KVM_SPLIT_LDBAR, offsetof(struct kvm_split_mode, ldbar)); 658 OFFSET(KVM_SPLIT_LDBAR, kvm_split_mode, ldbar);
674 DEFINE(KVM_SPLIT_DO_NAP, offsetof(struct kvm_split_mode, do_nap)); 659 OFFSET(KVM_SPLIT_DO_NAP, kvm_split_mode, do_nap);
675 DEFINE(KVM_SPLIT_NAPPED, offsetof(struct kvm_split_mode, napped)); 660 OFFSET(KVM_SPLIT_NAPPED, kvm_split_mode, napped);
676#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ 661#endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
677 662
678#ifdef CONFIG_PPC_BOOK3S_64 663#ifdef CONFIG_PPC_BOOK3S_64
@@ -682,32 +667,27 @@ int main(void)
682#endif /* CONFIG_PPC_BOOK3S_64 */ 667#endif /* CONFIG_PPC_BOOK3S_64 */
683 668
684#else /* CONFIG_PPC_BOOK3S */ 669#else /* CONFIG_PPC_BOOK3S */
685 DEFINE(VCPU_CR, offsetof(struct kvm_vcpu, arch.cr)); 670 OFFSET(VCPU_CR, kvm_vcpu, arch.cr);
686 DEFINE(VCPU_XER, offsetof(struct kvm_vcpu, arch.xer)); 671 OFFSET(VCPU_XER, kvm_vcpu, arch.xer);
687 DEFINE(VCPU_LR, offsetof(struct kvm_vcpu, arch.lr)); 672 OFFSET(VCPU_LR, kvm_vcpu, arch.lr);
688 DEFINE(VCPU_CTR, offsetof(struct kvm_vcpu, arch.ctr)); 673 OFFSET(VCPU_CTR, kvm_vcpu, arch.ctr);
689 DEFINE(VCPU_PC, offsetof(struct kvm_vcpu, arch.pc)); 674 OFFSET(VCPU_PC, kvm_vcpu, arch.pc);
690 DEFINE(VCPU_SPRG9, offsetof(struct kvm_vcpu, arch.sprg9)); 675 OFFSET(VCPU_SPRG9, kvm_vcpu, arch.sprg9);
691 DEFINE(VCPU_LAST_INST, offsetof(struct kvm_vcpu, arch.last_inst)); 676 OFFSET(VCPU_LAST_INST, kvm_vcpu, arch.last_inst);
692 DEFINE(VCPU_FAULT_DEAR, offsetof(struct kvm_vcpu, arch.fault_dear)); 677 OFFSET(VCPU_FAULT_DEAR, kvm_vcpu, arch.fault_dear);
693 DEFINE(VCPU_FAULT_ESR, offsetof(struct kvm_vcpu, arch.fault_esr)); 678 OFFSET(VCPU_FAULT_ESR, kvm_vcpu, arch.fault_esr);
694 DEFINE(VCPU_CRIT_SAVE, offsetof(struct kvm_vcpu, arch.crit_save)); 679 OFFSET(VCPU_CRIT_SAVE, kvm_vcpu, arch.crit_save);
695#endif /* CONFIG_PPC_BOOK3S */ 680#endif /* CONFIG_PPC_BOOK3S */
696#endif /* CONFIG_KVM */ 681#endif /* CONFIG_KVM */
697 682
698#ifdef CONFIG_KVM_GUEST 683#ifdef CONFIG_KVM_GUEST
699 DEFINE(KVM_MAGIC_SCRATCH1, offsetof(struct kvm_vcpu_arch_shared, 684 OFFSET(KVM_MAGIC_SCRATCH1, kvm_vcpu_arch_shared, scratch1);
700 scratch1)); 685 OFFSET(KVM_MAGIC_SCRATCH2, kvm_vcpu_arch_shared, scratch2);
701 DEFINE(KVM_MAGIC_SCRATCH2, offsetof(struct kvm_vcpu_arch_shared, 686 OFFSET(KVM_MAGIC_SCRATCH3, kvm_vcpu_arch_shared, scratch3);
702 scratch2)); 687 OFFSET(KVM_MAGIC_INT, kvm_vcpu_arch_shared, int_pending);
703 DEFINE(KVM_MAGIC_SCRATCH3, offsetof(struct kvm_vcpu_arch_shared, 688 OFFSET(KVM_MAGIC_MSR, kvm_vcpu_arch_shared, msr);
704 scratch3)); 689 OFFSET(KVM_MAGIC_CRITICAL, kvm_vcpu_arch_shared, critical);
705 DEFINE(KVM_MAGIC_INT, offsetof(struct kvm_vcpu_arch_shared, 690 OFFSET(KVM_MAGIC_SR, kvm_vcpu_arch_shared, sr);
706 int_pending));
707 DEFINE(KVM_MAGIC_MSR, offsetof(struct kvm_vcpu_arch_shared, msr));
708 DEFINE(KVM_MAGIC_CRITICAL, offsetof(struct kvm_vcpu_arch_shared,
709 critical));
710 DEFINE(KVM_MAGIC_SR, offsetof(struct kvm_vcpu_arch_shared, sr));
711#endif 691#endif
712 692
713#ifdef CONFIG_44x 693#ifdef CONFIG_44x
@@ -716,45 +696,37 @@ int main(void)
716#endif 696#endif
717#ifdef CONFIG_PPC_FSL_BOOK3E 697#ifdef CONFIG_PPC_FSL_BOOK3E
718 DEFINE(TLBCAM_SIZE, sizeof(struct tlbcam)); 698 DEFINE(TLBCAM_SIZE, sizeof(struct tlbcam));
719 DEFINE(TLBCAM_MAS0, offsetof(struct tlbcam, MAS0)); 699 OFFSET(TLBCAM_MAS0, tlbcam, MAS0);
720 DEFINE(TLBCAM_MAS1, offsetof(struct tlbcam, MAS1)); 700 OFFSET(TLBCAM_MAS1, tlbcam, MAS1);
721 DEFINE(TLBCAM_MAS2, offsetof(struct tlbcam, MAS2)); 701 OFFSET(TLBCAM_MAS2, tlbcam, MAS2);
722 DEFINE(TLBCAM_MAS3, offsetof(struct tlbcam, MAS3)); 702 OFFSET(TLBCAM_MAS3, tlbcam, MAS3);
723 DEFINE(TLBCAM_MAS7, offsetof(struct tlbcam, MAS7)); 703 OFFSET(TLBCAM_MAS7, tlbcam, MAS7);
724#endif 704#endif
725 705
726#if defined(CONFIG_KVM) && defined(CONFIG_SPE) 706#if defined(CONFIG_KVM) && defined(CONFIG_SPE)
727 DEFINE(VCPU_EVR, offsetof(struct kvm_vcpu, arch.evr[0])); 707 OFFSET(VCPU_EVR, kvm_vcpu, arch.evr[0]);
728 DEFINE(VCPU_ACC, offsetof(struct kvm_vcpu, arch.acc)); 708 OFFSET(VCPU_ACC, kvm_vcpu, arch.acc);
729 DEFINE(VCPU_SPEFSCR, offsetof(struct kvm_vcpu, arch.spefscr)); 709 OFFSET(VCPU_SPEFSCR, kvm_vcpu, arch.spefscr);
730 DEFINE(VCPU_HOST_SPEFSCR, offsetof(struct kvm_vcpu, arch.host_spefscr)); 710 OFFSET(VCPU_HOST_SPEFSCR, kvm_vcpu, arch.host_spefscr);
731#endif 711#endif
732 712
733#ifdef CONFIG_KVM_BOOKE_HV 713#ifdef CONFIG_KVM_BOOKE_HV
734 DEFINE(VCPU_HOST_MAS4, offsetof(struct kvm_vcpu, arch.host_mas4)); 714 OFFSET(VCPU_HOST_MAS4, kvm_vcpu, arch.host_mas4);
735 DEFINE(VCPU_HOST_MAS6, offsetof(struct kvm_vcpu, arch.host_mas6)); 715 OFFSET(VCPU_HOST_MAS6, kvm_vcpu, arch.host_mas6);
736#endif 716#endif
737 717
738#ifdef CONFIG_KVM_EXIT_TIMING 718#ifdef CONFIG_KVM_EXIT_TIMING
739 DEFINE(VCPU_TIMING_EXIT_TBU, offsetof(struct kvm_vcpu, 719 OFFSET(VCPU_TIMING_EXIT_TBU, kvm_vcpu, arch.timing_exit.tv32.tbu);
740 arch.timing_exit.tv32.tbu)); 720 OFFSET(VCPU_TIMING_EXIT_TBL, kvm_vcpu, arch.timing_exit.tv32.tbl);
741 DEFINE(VCPU_TIMING_EXIT_TBL, offsetof(struct kvm_vcpu, 721 OFFSET(VCPU_TIMING_LAST_ENTER_TBU, kvm_vcpu, arch.timing_last_enter.tv32.tbu);
742 arch.timing_exit.tv32.tbl)); 722 OFFSET(VCPU_TIMING_LAST_ENTER_TBL, kvm_vcpu, arch.timing_last_enter.tv32.tbl);
743 DEFINE(VCPU_TIMING_LAST_ENTER_TBU, offsetof(struct kvm_vcpu,
744 arch.timing_last_enter.tv32.tbu));
745 DEFINE(VCPU_TIMING_LAST_ENTER_TBL, offsetof(struct kvm_vcpu,
746 arch.timing_last_enter.tv32.tbl));
747#endif 723#endif
748 724
749#ifdef CONFIG_PPC_POWERNV 725#ifdef CONFIG_PPC_POWERNV
750 DEFINE(PACA_CORE_IDLE_STATE_PTR, 726 OFFSET(PACA_CORE_IDLE_STATE_PTR, paca_struct, core_idle_state_ptr);
751 offsetof(struct paca_struct, core_idle_state_ptr)); 727 OFFSET(PACA_THREAD_IDLE_STATE, paca_struct, thread_idle_state);
752 DEFINE(PACA_THREAD_IDLE_STATE, 728 OFFSET(PACA_THREAD_MASK, paca_struct, thread_mask);
753 offsetof(struct paca_struct, thread_idle_state)); 729 OFFSET(PACA_SUBCORE_SIBLING_MASK, paca_struct, subcore_sibling_mask);
754 DEFINE(PACA_THREAD_MASK,
755 offsetof(struct paca_struct, thread_mask));
756 DEFINE(PACA_SUBCORE_SIBLING_MASK,
757 offsetof(struct paca_struct, subcore_sibling_mask));
758#endif 730#endif
759 731
760 DEFINE(PPC_DBELL_SERVER, PPC_DBELL_SERVER); 732 DEFINE(PPC_DBELL_SERVER, PPC_DBELL_SERVER);
diff --git a/arch/powerpc/kernel/cpu_setup_power.S b/arch/powerpc/kernel/cpu_setup_power.S
index 917188615bf5..7fe8c79e6937 100644
--- a/arch/powerpc/kernel/cpu_setup_power.S
+++ b/arch/powerpc/kernel/cpu_setup_power.S
@@ -101,6 +101,8 @@ _GLOBAL(__setup_cpu_power9)
101 mfspr r3,SPRN_LPCR 101 mfspr r3,SPRN_LPCR
102 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) 102 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE)
103 or r3, r3, r4 103 or r3, r3, r4
104 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
105 andc r3, r3, r4
104 bl __init_LPCR 106 bl __init_LPCR
105 bl __init_HFSCR 107 bl __init_HFSCR
106 bl __init_tlb_power9 108 bl __init_tlb_power9
@@ -122,6 +124,8 @@ _GLOBAL(__restore_cpu_power9)
122 mfspr r3,SPRN_LPCR 124 mfspr r3,SPRN_LPCR
123 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) 125 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE)
124 or r3, r3, r4 126 or r3, r3, r4
127 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
128 andc r3, r3, r4
125 bl __init_LPCR 129 bl __init_LPCR
126 bl __init_HFSCR 130 bl __init_HFSCR
127 bl __init_tlb_power9 131 bl __init_tlb_power9
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 6a82ef039c50..bb7a1890aeb7 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -386,6 +386,23 @@ static struct cpu_spec __initdata cpu_specs[] = {
386 .machine_check_early = __machine_check_early_realmode_p8, 386 .machine_check_early = __machine_check_early_realmode_p8,
387 .platform = "power8", 387 .platform = "power8",
388 }, 388 },
389 { /* 3.00-compliant processor, i.e. Power9 "architected" mode */
390 .pvr_mask = 0xffffffff,
391 .pvr_value = 0x0f000005,
392 .cpu_name = "POWER9 (architected)",
393 .cpu_features = CPU_FTRS_POWER9,
394 .cpu_user_features = COMMON_USER_POWER9,
395 .cpu_user_features2 = COMMON_USER2_POWER9,
396 .mmu_features = MMU_FTRS_POWER9,
397 .icache_bsize = 128,
398 .dcache_bsize = 128,
399 .oprofile_type = PPC_OPROFILE_INVALID,
400 .oprofile_cpu_type = "ppc64/ibm-compat-v1",
401 .cpu_setup = __setup_cpu_power9,
402 .cpu_restore = __restore_cpu_power9,
403 .flush_tlb = __flush_tlb_power9,
404 .platform = "power9",
405 },
389 { /* Power7 */ 406 { /* Power7 */
390 .pvr_mask = 0xffff0000, 407 .pvr_mask = 0xffff0000,
391 .pvr_value = 0x003f0000, 408 .pvr_value = 0x003f0000,
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 3841d749a430..a38600949f3a 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -205,6 +205,9 @@ transfer_to_handler_cont:
205 mflr r9 205 mflr r9
206 lwz r11,0(r9) /* virtual address of handler */ 206 lwz r11,0(r9) /* virtual address of handler */
207 lwz r9,4(r9) /* where to go when done */ 207 lwz r9,4(r9) /* where to go when done */
208#ifdef CONFIG_PPC_8xx_PERF_EVENT
209 mtspr SPRN_NRI, r0
210#endif
208#ifdef CONFIG_TRACE_IRQFLAGS 211#ifdef CONFIG_TRACE_IRQFLAGS
209 lis r12,reenable_mmu@h 212 lis r12,reenable_mmu@h
210 ori r12,r12,reenable_mmu@l 213 ori r12,r12,reenable_mmu@l
@@ -292,7 +295,9 @@ stack_ovf:
292 lis r9,StackOverflow@ha 295 lis r9,StackOverflow@ha
293 addi r9,r9,StackOverflow@l 296 addi r9,r9,StackOverflow@l
294 LOAD_MSR_KERNEL(r10,MSR_KERNEL) 297 LOAD_MSR_KERNEL(r10,MSR_KERNEL)
295 FIX_SRR1(r10,r12) 298#ifdef CONFIG_PPC_8xx_PERF_EVENT
299 mtspr SPRN_NRI, r0
300#endif
296 mtspr SPRN_SRR0,r9 301 mtspr SPRN_SRR0,r9
297 mtspr SPRN_SRR1,r10 302 mtspr SPRN_SRR1,r10
298 SYNC 303 SYNC
@@ -417,9 +422,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
417 mtlr r4 422 mtlr r4
418 mtcr r5 423 mtcr r5
419 lwz r7,_NIP(r1) 424 lwz r7,_NIP(r1)
420 FIX_SRR1(r8, r0)
421 lwz r2,GPR2(r1) 425 lwz r2,GPR2(r1)
422 lwz r1,GPR1(r1) 426 lwz r1,GPR1(r1)
427#ifdef CONFIG_PPC_8xx_PERF_EVENT
428 mtspr SPRN_NRI, r0
429#endif
423 mtspr SPRN_SRR0,r7 430 mtspr SPRN_SRR0,r7
424 mtspr SPRN_SRR1,r8 431 mtspr SPRN_SRR1,r8
425 SYNC 432 SYNC
@@ -699,6 +706,9 @@ fast_exception_return:
699 lwz r10,_LINK(r11) 706 lwz r10,_LINK(r11)
700 mtlr r10 707 mtlr r10
701 REST_GPR(10, r11) 708 REST_GPR(10, r11)
709#ifdef CONFIG_PPC_8xx_PERF_EVENT
710 mtspr SPRN_NRI, r0
711#endif
702 mtspr SPRN_SRR1,r9 712 mtspr SPRN_SRR1,r9
703 mtspr SPRN_SRR0,r12 713 mtspr SPRN_SRR0,r12
704 REST_GPR(9, r11) 714 REST_GPR(9, r11)
@@ -947,7 +957,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_NEED_PAIRED_STWCX)
947 .globl exc_exit_restart 957 .globl exc_exit_restart
948exc_exit_restart: 958exc_exit_restart:
949 lwz r12,_NIP(r1) 959 lwz r12,_NIP(r1)
950 FIX_SRR1(r9,r10) 960#ifdef CONFIG_PPC_8xx_PERF_EVENT
961 mtspr SPRN_NRI, r0
962#endif
951 mtspr SPRN_SRR0,r12 963 mtspr SPRN_SRR0,r12
952 mtspr SPRN_SRR1,r9 964 mtspr SPRN_SRR1,r9
953 REST_4GPRS(9, r1) 965 REST_4GPRS(9, r1)
@@ -1290,7 +1302,6 @@ _GLOBAL(enter_rtas)
12901: tophys(r9,r1) 13021: tophys(r9,r1)
1291 lwz r8,INT_FRAME_SIZE+4(r9) /* get return address */ 1303 lwz r8,INT_FRAME_SIZE+4(r9) /* get return address */
1292 lwz r9,8(r9) /* original msr value */ 1304 lwz r9,8(r9) /* original msr value */
1293 FIX_SRR1(r9,r0)
1294 addi r1,r1,INT_FRAME_SIZE 1305 addi r1,r1,INT_FRAME_SIZE
1295 li r0,0 1306 li r0,0
1296 mtspr SPRN_SPRG_RTAS,r0 1307 mtspr SPRN_SPRG_RTAS,r0
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 9d963547d243..1607be7c0ef2 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -869,7 +869,6 @@ __secondary_start:
869 869
870 /* enable MMU and jump to start_secondary */ 870 /* enable MMU and jump to start_secondary */
871 li r4,MSR_KERNEL 871 li r4,MSR_KERNEL
872 FIX_SRR1(r4,r5)
873 lis r3,start_secondary@h 872 lis r3,start_secondary@h
874 ori r3,r3,start_secondary@l 873 ori r3,r3,start_secondary@l
875 mtspr SPRN_SRR0,r3 874 mtspr SPRN_SRR0,r3
@@ -977,7 +976,6 @@ start_here:
977 ori r4,r4,2f@l 976 ori r4,r4,2f@l
978 tophys(r4,r4) 977 tophys(r4,r4)
979 li r3,MSR_KERNEL & ~(MSR_IR|MSR_DR) 978 li r3,MSR_KERNEL & ~(MSR_IR|MSR_DR)
980 FIX_SRR1(r3,r5)
981 mtspr SPRN_SRR0,r4 979 mtspr SPRN_SRR0,r4
982 mtspr SPRN_SRR1,r3 980 mtspr SPRN_SRR1,r3
983 SYNC 981 SYNC
@@ -1001,7 +999,6 @@ start_here:
1001 999
1002/* Now turn on the MMU for real! */ 1000/* Now turn on the MMU for real! */
1003 li r4,MSR_KERNEL 1001 li r4,MSR_KERNEL
1004 FIX_SRR1(r4,r5)
1005 lis r3,start_kernel@h 1002 lis r3,start_kernel@h
1006 ori r3,r3,start_kernel@l 1003 ori r3,r3,start_kernel@l
1007 mtspr SPRN_SRR0,r3 1004 mtspr SPRN_SRR0,r3
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 1a9c99d3e5d8..c032fe8c2d26 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -329,6 +329,12 @@ InstructionTLBMiss:
329 mtspr SPRN_SPRG_SCRATCH2, r3 329 mtspr SPRN_SPRG_SCRATCH2, r3
330#endif 330#endif
331 EXCEPTION_PROLOG_0 331 EXCEPTION_PROLOG_0
332#ifdef CONFIG_PPC_8xx_PERF_EVENT
333 lis r10, (itlb_miss_counter - PAGE_OFFSET)@ha
334 lwz r11, (itlb_miss_counter - PAGE_OFFSET)@l(r10)
335 addi r11, r11, 1
336 stw r11, (itlb_miss_counter - PAGE_OFFSET)@l(r10)
337#endif
332 338
333 /* If we are faulting a kernel address, we have to use the 339 /* If we are faulting a kernel address, we have to use the
334 * kernel page tables. 340 * kernel page tables.
@@ -429,6 +435,12 @@ InstructionTLBMiss:
429DataStoreTLBMiss: 435DataStoreTLBMiss:
430 mtspr SPRN_SPRG_SCRATCH2, r3 436 mtspr SPRN_SPRG_SCRATCH2, r3
431 EXCEPTION_PROLOG_0 437 EXCEPTION_PROLOG_0
438#ifdef CONFIG_PPC_8xx_PERF_EVENT
439 lis r10, (dtlb_miss_counter - PAGE_OFFSET)@ha
440 lwz r11, (dtlb_miss_counter - PAGE_OFFSET)@l(r10)
441 addi r11, r11, 1
442 stw r11, (dtlb_miss_counter - PAGE_OFFSET)@l(r10)
443#endif
432 mfcr r3 444 mfcr r3
433 445
434 /* If we are faulting a kernel address, we have to use the 446 /* If we are faulting a kernel address, we have to use the
@@ -561,6 +573,7 @@ InstructionTLBError:
561 andis. r10,r5,0x4000 573 andis. r10,r5,0x4000
562 beq+ 1f 574 beq+ 1f
563 tlbie r4 575 tlbie r4
576itlbie:
564 /* 0x400 is InstructionAccess exception, needed by bad_page_fault() */ 577 /* 0x400 is InstructionAccess exception, needed by bad_page_fault() */
5651: EXC_XFER_LITE(0x400, handle_page_fault) 5781: EXC_XFER_LITE(0x400, handle_page_fault)
566 579
@@ -585,6 +598,7 @@ DARFixed:/* Return from dcbx instruction bug workaround */
585 andis. r10,r5,0x4000 598 andis. r10,r5,0x4000
586 beq+ 1f 599 beq+ 1f
587 tlbie r4 600 tlbie r4
601dtlbie:
5881: li r10,RPN_PATTERN 6021: li r10,RPN_PATTERN
589 mtspr SPRN_DAR,r10 /* Tag DAR, to be used in DTLB Error */ 603 mtspr SPRN_DAR,r10 /* Tag DAR, to be used in DTLB Error */
590 /* 0x300 is DataAccess exception, needed by bad_page_fault() */ 604 /* 0x300 is DataAccess exception, needed by bad_page_fault() */
@@ -602,8 +616,43 @@ DARFixed:/* Return from dcbx instruction bug workaround */
602 * support of breakpoints and such. Someday I will get around to 616 * support of breakpoints and such. Someday I will get around to
603 * using them. 617 * using them.
604 */ 618 */
605 EXCEPTION(0x1c00, Trap_1c, unknown_exception, EXC_XFER_EE) 619 . = 0x1c00
620DataBreakpoint:
621 EXCEPTION_PROLOG_0
622 mfcr r10
623 mfspr r11, SPRN_SRR0
624 cmplwi cr0, r11, (dtlbie - PAGE_OFFSET)@l
625 cmplwi cr7, r11, (itlbie - PAGE_OFFSET)@l
626 beq- cr0, 11f
627 beq- cr7, 11f
628 EXCEPTION_PROLOG_1
629 EXCEPTION_PROLOG_2
630 addi r3,r1,STACK_FRAME_OVERHEAD
631 mfspr r4,SPRN_BAR
632 stw r4,_DAR(r11)
633 mfspr r5,SPRN_DSISR
634 EXC_XFER_EE(0x1c00, do_break)
63511:
636 mtcr r10
637 EXCEPTION_EPILOG_0
638 rfi
639
640#ifdef CONFIG_PPC_8xx_PERF_EVENT
641 . = 0x1d00
642InstructionBreakpoint:
643 EXCEPTION_PROLOG_0
644 lis r10, (instruction_counter - PAGE_OFFSET)@ha
645 lwz r11, (instruction_counter - PAGE_OFFSET)@l(r10)
646 addi r11, r11, -1
647 stw r11, (instruction_counter - PAGE_OFFSET)@l(r10)
648 lis r10, 0xffff
649 ori r10, r10, 0x01
650 mtspr SPRN_COUNTA, r10
651 EXCEPTION_EPILOG_0
652 rfi
653#else
606 EXCEPTION(0x1d00, Trap_1d, unknown_exception, EXC_XFER_EE) 654 EXCEPTION(0x1d00, Trap_1d, unknown_exception, EXC_XFER_EE)
655#endif
607 EXCEPTION(0x1e00, Trap_1e, unknown_exception, EXC_XFER_EE) 656 EXCEPTION(0x1e00, Trap_1e, unknown_exception, EXC_XFER_EE)
608 EXCEPTION(0x1f00, Trap_1f, unknown_exception, EXC_XFER_EE) 657 EXCEPTION(0x1f00, Trap_1f, unknown_exception, EXC_XFER_EE)
609 658
@@ -977,6 +1026,14 @@ initial_mmu:
977 lis r8, IDC_ENABLE@h 1026 lis r8, IDC_ENABLE@h
978 mtspr SPRN_DC_CST, r8 1027 mtspr SPRN_DC_CST, r8
979#endif 1028#endif
1029 /* Disable debug mode entry on breakpoints */
1030 mfspr r8, SPRN_DER
1031#ifdef CONFIG_PPC_8xx_PERF_EVENT
1032 rlwinm r8, r8, 0, ~0xc
1033#else
1034 rlwinm r8, r8, 0, ~0x8
1035#endif
1036 mtspr SPRN_DER, r8
980 blr 1037 blr
981 1038
982 1039
@@ -1010,3 +1067,16 @@ cpu6_errata_word:
1010 .space 16 1067 .space 16
1011#endif 1068#endif
1012 1069
1070#ifdef CONFIG_PPC_8xx_PERF_EVENT
1071 .globl itlb_miss_counter
1072itlb_miss_counter:
1073 .space 4
1074
1075 .globl dtlb_miss_counter
1076dtlb_miss_counter:
1077 .space 4
1078
1079 .globl instruction_counter
1080instruction_counter:
1081 .space 4
1082#endif
diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 53cc9270aac8..53b9c1dfd7d9 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -211,9 +211,11 @@ int hw_breakpoint_handler(struct die_args *args)
211 int rc = NOTIFY_STOP; 211 int rc = NOTIFY_STOP;
212 struct perf_event *bp; 212 struct perf_event *bp;
213 struct pt_regs *regs = args->regs; 213 struct pt_regs *regs = args->regs;
214#ifndef CONFIG_PPC_8xx
214 int stepped = 1; 215 int stepped = 1;
215 struct arch_hw_breakpoint *info;
216 unsigned int instr; 216 unsigned int instr;
217#endif
218 struct arch_hw_breakpoint *info;
217 unsigned long dar = regs->dar; 219 unsigned long dar = regs->dar;
218 220
219 /* Disable breakpoints during exception handling */ 221 /* Disable breakpoints during exception handling */
@@ -257,6 +259,7 @@ int hw_breakpoint_handler(struct die_args *args)
257 (dar - bp->attr.bp_addr < bp->attr.bp_len))) 259 (dar - bp->attr.bp_addr < bp->attr.bp_len)))
258 info->type |= HW_BRK_TYPE_EXTRANEOUS_IRQ; 260 info->type |= HW_BRK_TYPE_EXTRANEOUS_IRQ;
259 261
262#ifndef CONFIG_PPC_8xx
260 /* Do not emulate user-space instructions, instead single-step them */ 263 /* Do not emulate user-space instructions, instead single-step them */
261 if (user_mode(regs)) { 264 if (user_mode(regs)) {
262 current->thread.last_hit_ubp = bp; 265 current->thread.last_hit_ubp = bp;
@@ -280,6 +283,7 @@ int hw_breakpoint_handler(struct die_args *args)
280 perf_event_disable_inatomic(bp); 283 perf_event_disable_inatomic(bp);
281 goto out; 284 goto out;
282 } 285 }
286#endif
283 /* 287 /*
284 * As a policy, the callback is invoked in a 'trigger-after-execute' 288 * As a policy, the callback is invoked in a 'trigger-after-execute'
285 * fashion 289 * fashion
diff --git a/arch/powerpc/kernel/optprobes_head.S b/arch/powerpc/kernel/optprobes_head.S
index 53e429b5a29d..4937bef7652f 100644
--- a/arch/powerpc/kernel/optprobes_head.S
+++ b/arch/powerpc/kernel/optprobes_head.S
@@ -65,6 +65,13 @@ optprobe_template_entry:
65 mfdsisr r5 65 mfdsisr r5
66 std r5,_DSISR(r1) 66 std r5,_DSISR(r1)
67 67
68 /*
69 * We may get here from a module, so load the kernel TOC in r2.
70 * The original TOC gets restored when pt_regs is restored
71 * further below.
72 */
73 ld r2,PACATOC(r13)
74
68 .global optprobe_template_op_address 75 .global optprobe_template_op_address
69optprobe_template_op_address: 76optprobe_template_op_address:
70 /* 77 /*
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 8e6fde8d28f3..ffda24a38dda 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1560,16 +1560,10 @@ static void pcibios_setup_phb_resources(struct pci_controller *hose,
1560 /* Hookup PHB Memory resources */ 1560 /* Hookup PHB Memory resources */
1561 for (i = 0; i < 3; ++i) { 1561 for (i = 0; i < 3; ++i) {
1562 res = &hose->mem_resources[i]; 1562 res = &hose->mem_resources[i];
1563 if (!res->flags) { 1563 if (!res->flags)
1564 if (i == 0)
1565 printk(KERN_ERR "PCI: Memory resource 0 not set for "
1566 "host bridge %s (domain %d)\n",
1567 hose->dn->full_name, hose->global_number);
1568 continue; 1564 continue;
1569 }
1570 offset = hose->mem_offset[i];
1571
1572 1565
1566 offset = hose->mem_offset[i];
1573 pr_debug("PCI: PHB MEM resource %d = %pR off 0x%08llx\n", i, 1567 pr_debug("PCI: PHB MEM resource %d = %pR off 0x%08llx\n", i,
1574 res, (unsigned long long)offset); 1568 res, (unsigned long long)offset);
1575 1569
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 5dd056df0baa..4379a079b3c2 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -730,6 +730,28 @@ static inline int __set_dabr(unsigned long dabr, unsigned long dabrx)
730 mtspr(SPRN_DABRX, dabrx); 730 mtspr(SPRN_DABRX, dabrx);
731 return 0; 731 return 0;
732} 732}
733#elif defined(CONFIG_PPC_8xx)
734static inline int __set_dabr(unsigned long dabr, unsigned long dabrx)
735{
736 unsigned long addr = dabr & ~HW_BRK_TYPE_DABR;
737 unsigned long lctrl1 = 0x90000000; /* compare type: equal on E & F */
738 unsigned long lctrl2 = 0x8e000002; /* watchpoint 1 on cmp E | F */
739
740 if ((dabr & HW_BRK_TYPE_RDWR) == HW_BRK_TYPE_READ)
741 lctrl1 |= 0xa0000;
742 else if ((dabr & HW_BRK_TYPE_RDWR) == HW_BRK_TYPE_WRITE)
743 lctrl1 |= 0xf0000;
744 else if ((dabr & HW_BRK_TYPE_RDWR) == 0)
745 lctrl2 = 0;
746
747 mtspr(SPRN_LCTRL2, 0);
748 mtspr(SPRN_CMPE, addr);
749 mtspr(SPRN_CMPF, addr + 4);
750 mtspr(SPRN_LCTRL1, lctrl1);
751 mtspr(SPRN_LCTRL2, lctrl2);
752
753 return 0;
754}
733#else 755#else
734static inline int __set_dabr(unsigned long dabr, unsigned long dabrx) 756static inline int __set_dabr(unsigned long dabr, unsigned long dabrx)
735{ 757{
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 616de028f7f8..a3944540fe0d 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -839,7 +839,7 @@ struct ibm_arch_vec __cacheline_aligned ibm_architecture_vec = {
839 0, 839 0,
840#endif 840#endif
841 .associativity = OV5_FEAT(OV5_TYPE1_AFFINITY) | OV5_FEAT(OV5_PRRN), 841 .associativity = OV5_FEAT(OV5_TYPE1_AFFINITY) | OV5_FEAT(OV5_PRRN),
842 .bin_opts = OV5_FEAT(OV5_RESIZE_HPT), 842 .bin_opts = OV5_FEAT(OV5_RESIZE_HPT) | OV5_FEAT(OV5_HP_EVT),
843 .micro_checkpoint = 0, 843 .micro_checkpoint = 0,
844 .reserved0 = 0, 844 .reserved0 = 0,
845 .max_cpus = cpu_to_be32(NR_CPUS), /* number of cores supported */ 845 .max_cpus = cpu_to_be32(NR_CPUS), /* number of cores supported */
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index b9855f1b290a..adf2084f214b 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -113,14 +113,12 @@ void __init setup_tlb_core_data(void)
113 * If we have threads, we need either tlbsrx. 113 * If we have threads, we need either tlbsrx.
114 * or e6500 tablewalk mode, or else TLB handlers 114 * or e6500 tablewalk mode, or else TLB handlers
115 * will be racy and could produce duplicate entries. 115 * will be racy and could produce duplicate entries.
116 * Should we panic instead?
116 */ 117 */
117 if (smt_enabled_at_boot >= 2 && 118 WARN_ONCE(smt_enabled_at_boot >= 2 &&
118 !mmu_has_feature(MMU_FTR_USE_TLBRSRV) && 119 !mmu_has_feature(MMU_FTR_USE_TLBRSRV) &&
119 book3e_htw_mode != PPC_HTW_E6500) { 120 book3e_htw_mode != PPC_HTW_E6500,
120 /* Should we panic instead? */ 121 "%s: unsupported MMU configuration\n", __func__);
121 WARN_ONCE("%s: unsupported MMU configuration -- expect problems\n",
122 __func__);
123 }
124 } 122 }
125} 123}
126#endif 124#endif
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 14e485525e31..bc84a8d47b9e 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -709,7 +709,7 @@ unsigned long long running_clock(void)
709 * time and on a host which doesn't do any virtualisation TB *should* equal 709 * time and on a host which doesn't do any virtualisation TB *should* equal
710 * VTB so it makes no difference anyway. 710 * VTB so it makes no difference anyway.
711 */ 711 */
712 return local_clock() - cputime_to_nsecs(kcpustat_this_cpu->cpustat[CPUTIME_STEAL]); 712 return local_clock() - kcpustat_this_cpu->cpustat[CPUTIME_STEAL];
713} 713}
714#endif 714#endif
715 715
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index cb39c8bd2436..a03ff3d99e0c 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -193,9 +193,7 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
193 */ 193 */
194 VM_WARN_ON(pte_present(*ptep) && !pte_protnone(*ptep)); 194 VM_WARN_ON(pte_present(*ptep) && !pte_protnone(*ptep));
195 195
196 /* 196 /* Add the pte bit when trying to set a pte */
197 * Add the pte bit when tryint set a pte
198 */
199 pte = __pte(pte_val(pte) | _PAGE_PTE); 197 pte = __pte(pte_val(pte) | _PAGE_PTE);
200 198
201 /* Note: mm->context.id might not yet have been assigned as 199 /* Note: mm->context.id might not yet have been assigned as
diff --git a/arch/powerpc/mm/slb_low.S b/arch/powerpc/mm/slb_low.S
index e2974fcd20f1..a85e06ea6c20 100644
--- a/arch/powerpc/mm/slb_low.S
+++ b/arch/powerpc/mm/slb_low.S
@@ -71,9 +71,9 @@ slb_miss_kernel_load_linear:
71 71
72 72
73BEGIN_FTR_SECTION 73BEGIN_FTR_SECTION
74 b slb_finish_load 74 b .Lslb_finish_load
75END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) 75END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
76 b slb_finish_load_1T 76 b .Lslb_finish_load_1T
77 77
781: 781:
79#ifdef CONFIG_SPARSEMEM_VMEMMAP 79#ifdef CONFIG_SPARSEMEM_VMEMMAP
@@ -109,9 +109,9 @@ slb_miss_kernel_load_io:
109 addi r9,r9,(MAX_USER_CONTEXT - 0xc + 1)@l 109 addi r9,r9,(MAX_USER_CONTEXT - 0xc + 1)@l
110 110
111BEGIN_FTR_SECTION 111BEGIN_FTR_SECTION
112 b slb_finish_load 112 b .Lslb_finish_load
113END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT) 113END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
114 b slb_finish_load_1T 114 b .Lslb_finish_load_1T
115 115
1160: /* 1160: /*
117 * For userspace addresses, make sure this is region 0. 117 * For userspace addresses, make sure this is region 0.
@@ -174,9 +174,9 @@ END_MMU_FTR_SECTION_IFCLR(MMU_FTR_1T_SEGMENT)
174 ld r9,PACACONTEXTID(r13) 174 ld r9,PACACONTEXTID(r13)
175BEGIN_FTR_SECTION 175BEGIN_FTR_SECTION
176 cmpldi r10,0x1000 176 cmpldi r10,0x1000
177 bge slb_finish_load_1T 177 bge .Lslb_finish_load_1T
178END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT) 178END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
179 b slb_finish_load 179 b .Lslb_finish_load
180 180
1818: /* invalid EA - return an error indication */ 1818: /* invalid EA - return an error indication */
182 crset 4*cr0+eq /* indicate failure */ 182 crset 4*cr0+eq /* indicate failure */
@@ -187,7 +187,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
187 * 187 *
188 * r3 = EA, r9 = context, r10 = ESID, r11 = flags, clobbers r9, cr7 = <> PAGE_OFFSET 188 * r3 = EA, r9 = context, r10 = ESID, r11 = flags, clobbers r9, cr7 = <> PAGE_OFFSET
189 */ 189 */
190slb_finish_load: 190.Lslb_finish_load:
191 rldimi r10,r9,ESID_BITS,0 191 rldimi r10,r9,ESID_BITS,0
192 ASM_VSID_SCRAMBLE(r10,r9,256M) 192 ASM_VSID_SCRAMBLE(r10,r9,256M)
193 /* 193 /*
@@ -256,7 +256,7 @@ slb_compare_rr_to_size:
256 * 256 *
257 * r3 = EA, r9 = context, r10 = ESID(256MB), r11 = flags, clobbers r9 257 * r3 = EA, r9 = context, r10 = ESID(256MB), r11 = flags, clobbers r9
258 */ 258 */
259slb_finish_load_1T: 259.Lslb_finish_load_1T:
260 srdi r10,r10,(SID_SHIFT_1T - SID_SHIFT) /* get 1T ESID */ 260 srdi r10,r10,(SID_SHIFT_1T - SID_SHIFT) /* get 1T ESID */
261 rldimi r10,r9,ESID_BITS_1T,0 261 rldimi r10,r9,ESID_BITS_1T,0
262 ASM_VSID_SCRAMBLE(r10,r9,1T) 262 ASM_VSID_SCRAMBLE(r10,r9,1T)
@@ -272,3 +272,11 @@ slb_finish_load_1T:
272 clrrdi r3,r3,SID_SHIFT_1T /* clear out non-ESID bits */ 272 clrrdi r3,r3,SID_SHIFT_1T /* clear out non-ESID bits */
273 b 7b 273 b 7b
274 274
275
276_ASM_NOKPROBE_SYMBOL(slb_allocate_realmode)
277_ASM_NOKPROBE_SYMBOL(slb_miss_kernel_load_linear)
278_ASM_NOKPROBE_SYMBOL(slb_miss_kernel_load_io)
279_ASM_NOKPROBE_SYMBOL(slb_compare_rr_to_size)
280#ifdef CONFIG_SPARSEMEM_VMEMMAP
281_ASM_NOKPROBE_SYMBOL(slb_miss_kernel_load_vmemmap)
282#endif
diff --git a/arch/powerpc/perf/8xx-pmu.c b/arch/powerpc/perf/8xx-pmu.c
new file mode 100644
index 000000000000..3c39f05f0af3
--- /dev/null
+++ b/arch/powerpc/perf/8xx-pmu.c
@@ -0,0 +1,173 @@
1/*
2 * Performance event support - PPC 8xx
3 *
4 * Copyright 2016 Christophe Leroy, CS Systemes d'Information
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/sched.h>
14#include <linux/perf_event.h>
15#include <linux/percpu.h>
16#include <linux/hardirq.h>
17#include <asm/pmc.h>
18#include <asm/machdep.h>
19#include <asm/firmware.h>
20#include <asm/ptrace.h>
21
22#define PERF_8xx_ID_CPU_CYCLES 1
23#define PERF_8xx_ID_HW_INSTRUCTIONS 2
24#define PERF_8xx_ID_ITLB_LOAD_MISS 3
25#define PERF_8xx_ID_DTLB_LOAD_MISS 4
26
27#define C(x) PERF_COUNT_HW_CACHE_##x
28#define DTLB_LOAD_MISS (C(DTLB) | (C(OP_READ) << 8) | (C(RESULT_MISS) << 16))
29#define ITLB_LOAD_MISS (C(ITLB) | (C(OP_READ) << 8) | (C(RESULT_MISS) << 16))
30
31extern unsigned long itlb_miss_counter, dtlb_miss_counter;
32extern atomic_t instruction_counter;
33
34static atomic_t insn_ctr_ref;
35
36static s64 get_insn_ctr(void)
37{
38 int ctr;
39 unsigned long counta;
40
41 do {
42 ctr = atomic_read(&instruction_counter);
43 counta = mfspr(SPRN_COUNTA);
44 } while (ctr != atomic_read(&instruction_counter));
45
46 return ((s64)ctr << 16) | (counta >> 16);
47}
48
49static int event_type(struct perf_event *event)
50{
51 switch (event->attr.type) {
52 case PERF_TYPE_HARDWARE:
53 if (event->attr.config == PERF_COUNT_HW_CPU_CYCLES)
54 return PERF_8xx_ID_CPU_CYCLES;
55 if (event->attr.config == PERF_COUNT_HW_INSTRUCTIONS)
56 return PERF_8xx_ID_HW_INSTRUCTIONS;
57 break;
58 case PERF_TYPE_HW_CACHE:
59 if (event->attr.config == ITLB_LOAD_MISS)
60 return PERF_8xx_ID_ITLB_LOAD_MISS;
61 if (event->attr.config == DTLB_LOAD_MISS)
62 return PERF_8xx_ID_DTLB_LOAD_MISS;
63 break;
64 case PERF_TYPE_RAW:
65 break;
66 default:
67 return -ENOENT;
68 }
69 return -EOPNOTSUPP;
70}
71
72static int mpc8xx_pmu_event_init(struct perf_event *event)
73{
74 int type = event_type(event);
75
76 if (type < 0)
77 return type;
78 return 0;
79}
80
81static int mpc8xx_pmu_add(struct perf_event *event, int flags)
82{
83 int type = event_type(event);
84 s64 val = 0;
85
86 if (type < 0)
87 return type;
88
89 switch (type) {
90 case PERF_8xx_ID_CPU_CYCLES:
91 val = get_tb();
92 break;
93 case PERF_8xx_ID_HW_INSTRUCTIONS:
94 if (atomic_inc_return(&insn_ctr_ref) == 1)
95 mtspr(SPRN_ICTRL, 0xc0080007);
96 val = get_insn_ctr();
97 break;
98 case PERF_8xx_ID_ITLB_LOAD_MISS:
99 val = itlb_miss_counter;
100 break;
101 case PERF_8xx_ID_DTLB_LOAD_MISS:
102 val = dtlb_miss_counter;
103 break;
104 }
105 local64_set(&event->hw.prev_count, val);
106 return 0;
107}
108
109static void mpc8xx_pmu_read(struct perf_event *event)
110{
111 int type = event_type(event);
112 s64 prev, val = 0, delta = 0;
113
114 if (type < 0)
115 return;
116
117 do {
118 prev = local64_read(&event->hw.prev_count);
119 switch (type) {
120 case PERF_8xx_ID_CPU_CYCLES:
121 val = get_tb();
122 delta = 16 * (val - prev);
123 break;
124 case PERF_8xx_ID_HW_INSTRUCTIONS:
125 val = get_insn_ctr();
126 delta = prev - val;
127 if (delta < 0)
128 delta += 0x1000000000000LL;
129 break;
130 case PERF_8xx_ID_ITLB_LOAD_MISS:
131 val = itlb_miss_counter;
132 delta = (s64)((s32)val - (s32)prev);
133 break;
134 case PERF_8xx_ID_DTLB_LOAD_MISS:
135 val = dtlb_miss_counter;
136 delta = (s64)((s32)val - (s32)prev);
137 break;
138 }
139 } while (local64_cmpxchg(&event->hw.prev_count, prev, val) != prev);
140
141 local64_add(delta, &event->count);
142}
143
144static void mpc8xx_pmu_del(struct perf_event *event, int flags)
145{
146 mpc8xx_pmu_read(event);
147 if (event_type(event) != PERF_8xx_ID_HW_INSTRUCTIONS)
148 return;
149
150 /* If it was the last user, stop counting to avoid useles overhead */
151 if (atomic_dec_return(&insn_ctr_ref) == 0)
152 mtspr(SPRN_ICTRL, 7);
153}
154
155static struct pmu mpc8xx_pmu = {
156 .event_init = mpc8xx_pmu_event_init,
157 .add = mpc8xx_pmu_add,
158 .del = mpc8xx_pmu_del,
159 .read = mpc8xx_pmu_read,
160 .capabilities = PERF_PMU_CAP_NO_INTERRUPT |
161 PERF_PMU_CAP_NO_NMI,
162};
163
164static int init_mpc8xx_pmu(void)
165{
166 mtspr(SPRN_ICTRL, 7);
167 mtspr(SPRN_CMPA, 0);
168 mtspr(SPRN_COUNTA, 0xffff);
169
170 return perf_pmu_register(&mpc8xx_pmu, "cpu", PERF_TYPE_RAW);
171}
172
173early_initcall(init_mpc8xx_pmu);
diff --git a/arch/powerpc/perf/Makefile b/arch/powerpc/perf/Makefile
index f102d5370101..4d606b99a5cb 100644
--- a/arch/powerpc/perf/Makefile
+++ b/arch/powerpc/perf/Makefile
@@ -13,5 +13,7 @@ obj-$(CONFIG_FSL_EMB_PERF_EVENT_E500) += e500-pmu.o e6500-pmu.o
13 13
14obj-$(CONFIG_HV_PERF_CTRS) += hv-24x7.o hv-gpci.o hv-common.o 14obj-$(CONFIG_HV_PERF_CTRS) += hv-24x7.o hv-gpci.o hv-common.o
15 15
16obj-$(CONFIG_PPC_8xx_PERF_EVENT) += 8xx-pmu.o
17
16obj-$(CONFIG_PPC64) += $(obj64-y) 18obj-$(CONFIG_PPC64) += $(obj64-y)
17obj-$(CONFIG_PPC32) += $(obj32-y) 19obj-$(CONFIG_PPC32) += $(obj32-y)
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 270eb9b74e2e..595dd718ea87 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -57,6 +57,7 @@ struct cpu_hw_events {
57 void *bhrb_context; 57 void *bhrb_context;
58 struct perf_branch_stack bhrb_stack; 58 struct perf_branch_stack bhrb_stack;
59 struct perf_branch_entry bhrb_entries[BHRB_MAX_ENTRIES]; 59 struct perf_branch_entry bhrb_entries[BHRB_MAX_ENTRIES];
60 u64 ic_init;
60}; 61};
61 62
62static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events); 63static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
@@ -127,6 +128,10 @@ static inline void power_pmu_bhrb_disable(struct perf_event *event) {}
127static void power_pmu_sched_task(struct perf_event_context *ctx, bool sched_in) {} 128static void power_pmu_sched_task(struct perf_event_context *ctx, bool sched_in) {}
128static inline void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw) {} 129static inline void power_pmu_bhrb_read(struct cpu_hw_events *cpuhw) {}
129static void pmao_restore_workaround(bool ebb) { } 130static void pmao_restore_workaround(bool ebb) { }
131static bool use_ic(u64 event)
132{
133 return false;
134}
130#endif /* CONFIG_PPC32 */ 135#endif /* CONFIG_PPC32 */
131 136
132static bool regs_use_siar(struct pt_regs *regs) 137static bool regs_use_siar(struct pt_regs *regs)
@@ -243,7 +248,7 @@ static inline u32 perf_get_misc_flags(struct pt_regs *regs)
243 */ 248 */
244 if (ppmu->flags & PPMU_NO_SIPR) { 249 if (ppmu->flags & PPMU_NO_SIPR) {
245 unsigned long siar = mfspr(SPRN_SIAR); 250 unsigned long siar = mfspr(SPRN_SIAR);
246 if (siar >= PAGE_OFFSET) 251 if (is_kernel_addr(siar))
247 return PERF_RECORD_MISC_KERNEL; 252 return PERF_RECORD_MISC_KERNEL;
248 return PERF_RECORD_MISC_USER; 253 return PERF_RECORD_MISC_USER;
249 } 254 }
@@ -688,6 +693,15 @@ static void pmao_restore_workaround(bool ebb)
688 mtspr(SPRN_PMC5, pmcs[4]); 693 mtspr(SPRN_PMC5, pmcs[4]);
689 mtspr(SPRN_PMC6, pmcs[5]); 694 mtspr(SPRN_PMC6, pmcs[5]);
690} 695}
696
697static bool use_ic(u64 event)
698{
699 if (cpu_has_feature(CPU_FTR_POWER9_DD1) &&
700 (event == 0x200f2 || event == 0x300f2))
701 return true;
702
703 return false;
704}
691#endif /* CONFIG_PPC64 */ 705#endif /* CONFIG_PPC64 */
692 706
693static void perf_event_interrupt(struct pt_regs *regs); 707static void perf_event_interrupt(struct pt_regs *regs);
@@ -1007,6 +1021,7 @@ static u64 check_and_compute_delta(u64 prev, u64 val)
1007static void power_pmu_read(struct perf_event *event) 1021static void power_pmu_read(struct perf_event *event)
1008{ 1022{
1009 s64 val, delta, prev; 1023 s64 val, delta, prev;
1024 struct cpu_hw_events *cpuhw = this_cpu_ptr(&cpu_hw_events);
1010 1025
1011 if (event->hw.state & PERF_HES_STOPPED) 1026 if (event->hw.state & PERF_HES_STOPPED)
1012 return; 1027 return;
@@ -1016,6 +1031,13 @@ static void power_pmu_read(struct perf_event *event)
1016 1031
1017 if (is_ebb_event(event)) { 1032 if (is_ebb_event(event)) {
1018 val = read_pmc(event->hw.idx); 1033 val = read_pmc(event->hw.idx);
1034 if (use_ic(event->attr.config)) {
1035 val = mfspr(SPRN_IC);
1036 if (val > cpuhw->ic_init)
1037 val = val - cpuhw->ic_init;
1038 else
1039 val = val + (0 - cpuhw->ic_init);
1040 }
1019 local64_set(&event->hw.prev_count, val); 1041 local64_set(&event->hw.prev_count, val);
1020 return; 1042 return;
1021 } 1043 }
@@ -1029,6 +1051,13 @@ static void power_pmu_read(struct perf_event *event)
1029 prev = local64_read(&event->hw.prev_count); 1051 prev = local64_read(&event->hw.prev_count);
1030 barrier(); 1052 barrier();
1031 val = read_pmc(event->hw.idx); 1053 val = read_pmc(event->hw.idx);
1054 if (use_ic(event->attr.config)) {
1055 val = mfspr(SPRN_IC);
1056 if (val > cpuhw->ic_init)
1057 val = val - cpuhw->ic_init;
1058 else
1059 val = val + (0 - cpuhw->ic_init);
1060 }
1032 delta = check_and_compute_delta(prev, val); 1061 delta = check_and_compute_delta(prev, val);
1033 if (!delta) 1062 if (!delta)
1034 return; 1063 return;
@@ -1466,6 +1495,13 @@ nocheck:
1466 event->attr.branch_sample_type); 1495 event->attr.branch_sample_type);
1467 } 1496 }
1468 1497
1498 /*
1499 * Workaround for POWER9 DD1 to use the Instruction Counter
1500 * register value for instruction counting
1501 */
1502 if (use_ic(event->attr.config))
1503 cpuhw->ic_init = mfspr(SPRN_IC);
1504
1469 perf_pmu_enable(event->pmu); 1505 perf_pmu_enable(event->pmu);
1470 local_irq_restore(flags); 1506 local_irq_restore(flags);
1471 return ret; 1507 return ret;
diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c
index 50e598cf644b..e79fb5fb817d 100644
--- a/arch/powerpc/perf/isa207-common.c
+++ b/arch/powerpc/perf/isa207-common.c
@@ -97,6 +97,28 @@ static unsigned long combine_shift(unsigned long pmc)
97 return MMCR1_COMBINE_SHIFT(pmc); 97 return MMCR1_COMBINE_SHIFT(pmc);
98} 98}
99 99
100static inline bool event_is_threshold(u64 event)
101{
102 return (event >> EVENT_THR_SEL_SHIFT) & EVENT_THR_SEL_MASK;
103}
104
105static bool is_thresh_cmp_valid(u64 event)
106{
107 unsigned int cmp, exp;
108
109 /*
110 * Check the mantissa upper two bits are not zero, unless the
111 * exponent is also zero. See the THRESH_CMP_MANTISSA doc.
112 */
113 cmp = (event >> EVENT_THR_CMP_SHIFT) & EVENT_THR_CMP_MASK;
114 exp = cmp >> 7;
115
116 if (exp && (cmp & 0x60) == 0)
117 return false;
118
119 return true;
120}
121
100int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp) 122int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
101{ 123{
102 unsigned int unit, pmc, cache, ebb; 124 unsigned int unit, pmc, cache, ebb;
@@ -163,28 +185,26 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp)
163 value |= CNST_SAMPLE_VAL(event >> EVENT_SAMPLE_SHIFT); 185 value |= CNST_SAMPLE_VAL(event >> EVENT_SAMPLE_SHIFT);
164 } 186 }
165 187
166 /* 188 if (cpu_has_feature(CPU_FTR_ARCH_300)) {
167 * Special case for PM_MRK_FAB_RSP_MATCH and PM_MRK_FAB_RSP_MATCH_CYC, 189 if (event_is_threshold(event) && is_thresh_cmp_valid(event)) {
168 * the threshold control bits are used for the match value. 190 mask |= CNST_THRESH_MASK;
169 */ 191 value |= CNST_THRESH_VAL(event >> EVENT_THRESH_SHIFT);
170 if (event_is_fab_match(event)) { 192 }
171 mask |= CNST_FAB_MATCH_MASK;
172 value |= CNST_FAB_MATCH_VAL(event >> EVENT_THR_CTL_SHIFT);
173 } else { 193 } else {
174 /* 194 /*
175 * Check the mantissa upper two bits are not zero, unless the 195 * Special case for PM_MRK_FAB_RSP_MATCH and PM_MRK_FAB_RSP_MATCH_CYC,
176 * exponent is also zero. See the THRESH_CMP_MANTISSA doc. 196 * the threshold control bits are used for the match value.
177 */ 197 */
178 unsigned int cmp, exp; 198 if (event_is_fab_match(event)) {
179 199 mask |= CNST_FAB_MATCH_MASK;
180 cmp = (event >> EVENT_THR_CMP_SHIFT) & EVENT_THR_CMP_MASK; 200 value |= CNST_FAB_MATCH_VAL(event >> EVENT_THR_CTL_SHIFT);
181 exp = cmp >> 7; 201 } else {
182 202 if (!is_thresh_cmp_valid(event))
183 if (exp && (cmp & 0x60) == 0) 203 return -1;
184 return -1;
185 204
186 mask |= CNST_THRESH_MASK; 205 mask |= CNST_THRESH_MASK;
187 value |= CNST_THRESH_VAL(event >> EVENT_THRESH_SHIFT); 206 value |= CNST_THRESH_VAL(event >> EVENT_THRESH_SHIFT);
207 }
188 } 208 }
189 209
190 if (!pmc && ebb) 210 if (!pmc && ebb)
@@ -279,7 +299,7 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
279 * PM_MRK_FAB_RSP_MATCH and PM_MRK_FAB_RSP_MATCH_CYC, 299 * PM_MRK_FAB_RSP_MATCH and PM_MRK_FAB_RSP_MATCH_CYC,
280 * the threshold bits are used for the match value. 300 * the threshold bits are used for the match value.
281 */ 301 */
282 if (event_is_fab_match(event[i])) { 302 if (!cpu_has_feature(CPU_FTR_ARCH_300) && event_is_fab_match(event[i])) {
283 mmcr1 |= ((event[i] >> EVENT_THR_CTL_SHIFT) & 303 mmcr1 |= ((event[i] >> EVENT_THR_CTL_SHIFT) &
284 EVENT_THR_CTL_MASK) << MMCR1_FAB_SHIFT; 304 EVENT_THR_CTL_MASK) << MMCR1_FAB_SHIFT;
285 } else { 305 } else {
@@ -338,3 +358,39 @@ void isa207_disable_pmc(unsigned int pmc, unsigned long mmcr[])
338 if (pmc <= 3) 358 if (pmc <= 3)
339 mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SHIFT(pmc + 1)); 359 mmcr[1] &= ~(0xffUL << MMCR1_PMCSEL_SHIFT(pmc + 1));
340} 360}
361
362static int find_alternative(u64 event, const unsigned int ev_alt[][MAX_ALT], int size)
363{
364 int i, j;
365
366 for (i = 0; i < size; ++i) {
367 if (event < ev_alt[i][0])
368 break;
369
370 for (j = 0; j < MAX_ALT && ev_alt[i][j]; ++j)
371 if (event == ev_alt[i][j])
372 return i;
373 }
374
375 return -1;
376}
377
378int isa207_get_alternatives(u64 event, u64 alt[],
379 const unsigned int ev_alt[][MAX_ALT], int size)
380{
381 int i, j, num_alt = 0;
382 u64 alt_event;
383
384 alt[num_alt++] = event;
385 i = find_alternative(event, ev_alt, size);
386 if (i >= 0) {
387 /* Filter out the original event, it's already in alt[0] */
388 for (j = 0; j < MAX_ALT; ++j) {
389 alt_event = ev_alt[i][j];
390 if (alt_event && alt_event != event)
391 alt[num_alt++] = alt_event;
392 }
393 }
394
395 return num_alt;
396}
diff --git a/arch/powerpc/perf/isa207-common.h b/arch/powerpc/perf/isa207-common.h
index 90495f1580c7..cf9bd8990159 100644
--- a/arch/powerpc/perf/isa207-common.h
+++ b/arch/powerpc/perf/isa207-common.h
@@ -222,6 +222,10 @@
222 CNST_PMC_VAL(1) | CNST_PMC_VAL(2) | CNST_PMC_VAL(3) | \ 222 CNST_PMC_VAL(1) | CNST_PMC_VAL(2) | CNST_PMC_VAL(3) | \
223 CNST_PMC_VAL(4) | CNST_PMC_VAL(5) | CNST_PMC_VAL(6) | CNST_NC_VAL 223 CNST_PMC_VAL(4) | CNST_PMC_VAL(5) | CNST_PMC_VAL(6) | CNST_NC_VAL
224 224
225/*
226 * Lets restrict use of PMC5 for instruction counting.
227 */
228#define P9_DD1_TEST_ADDER (ISA207_TEST_ADDER | CNST_PMC_VAL(5))
225 229
226/* Bits in MMCR1 for PowerISA v2.07 */ 230/* Bits in MMCR1 for PowerISA v2.07 */
227#define MMCR1_UNIT_SHIFT(pmc) (60 - (4 * ((pmc) - 1))) 231#define MMCR1_UNIT_SHIFT(pmc) (60 - (4 * ((pmc) - 1)))
@@ -260,5 +264,8 @@ int isa207_compute_mmcr(u64 event[], int n_ev,
260 unsigned int hwc[], unsigned long mmcr[], 264 unsigned int hwc[], unsigned long mmcr[],
261 struct perf_event *pevents[]); 265 struct perf_event *pevents[]);
262void isa207_disable_pmc(unsigned int pmc, unsigned long mmcr[]); 266void isa207_disable_pmc(unsigned int pmc, unsigned long mmcr[]);
267int isa207_get_alternatives(u64 event, u64 alt[],
268 const unsigned int ev_alt[][MAX_ALT], int size);
269
263 270
264#endif 271#endif
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c
index d07186382f3a..ce15b19a7962 100644
--- a/arch/powerpc/perf/power8-pmu.c
+++ b/arch/powerpc/perf/power8-pmu.c
@@ -48,43 +48,12 @@ static const unsigned int event_alternatives[][MAX_ALT] = {
48 { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL }, 48 { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL },
49}; 49};
50 50
51/*
52 * Scan the alternatives table for a match and return the
53 * index into the alternatives table if found, else -1.
54 */
55static int find_alternative(u64 event)
56{
57 int i, j;
58
59 for (i = 0; i < ARRAY_SIZE(event_alternatives); ++i) {
60 if (event < event_alternatives[i][0])
61 break;
62
63 for (j = 0; j < MAX_ALT && event_alternatives[i][j]; ++j)
64 if (event == event_alternatives[i][j])
65 return i;
66 }
67
68 return -1;
69}
70
71static int power8_get_alternatives(u64 event, unsigned int flags, u64 alt[]) 51static int power8_get_alternatives(u64 event, unsigned int flags, u64 alt[])
72{ 52{
73 int i, j, num_alt = 0; 53 int i, j, num_alt = 0;
74 u64 alt_event;
75
76 alt[num_alt++] = event;
77
78 i = find_alternative(event);
79 if (i >= 0) {
80 /* Filter out the original event, it's already in alt[0] */
81 for (j = 0; j < MAX_ALT; ++j) {
82 alt_event = event_alternatives[i][j];
83 if (alt_event && alt_event != event)
84 alt[num_alt++] = alt_event;
85 }
86 }
87 54
55 num_alt = isa207_get_alternatives(event, alt, event_alternatives,
56 (int)ARRAY_SIZE(event_alternatives));
88 if (flags & PPMU_ONLY_COUNT_RUN) { 57 if (flags & PPMU_ONLY_COUNT_RUN) {
89 /* 58 /*
90 * We're only counting in RUN state, so PM_CYC is equivalent to 59 * We're only counting in RUN state, so PM_CYC is equivalent to
diff --git a/arch/powerpc/perf/power9-events-list.h b/arch/powerpc/perf/power9-events-list.h
index 929b56d47ad9..71a6bfee5c02 100644
--- a/arch/powerpc/perf/power9-events-list.h
+++ b/arch/powerpc/perf/power9-events-list.h
@@ -53,3 +53,6 @@ EVENT(PM_ITLB_MISS, 0x400fc)
53EVENT(PM_RUN_INST_CMPL, 0x500fa) 53EVENT(PM_RUN_INST_CMPL, 0x500fa)
54/* Run_cycles */ 54/* Run_cycles */
55EVENT(PM_RUN_CYC, 0x600f4) 55EVENT(PM_RUN_CYC, 0x600f4)
56/* Instruction Dispatched */
57EVENT(PM_INST_DISP, 0x200f2)
58EVENT(PM_INST_DISP_ALT, 0x300f2)
diff --git a/arch/powerpc/perf/power9-pmu.c b/arch/powerpc/perf/power9-pmu.c
index 7332634e18c9..7f6582708e06 100644
--- a/arch/powerpc/perf/power9-pmu.c
+++ b/arch/powerpc/perf/power9-pmu.c
@@ -22,7 +22,7 @@
22 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | 22 * | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - | - - - - |
23 * | | [ ] [ ] [ thresh_cmp ] [ thresh_ctl ] 23 * | | [ ] [ ] [ thresh_cmp ] [ thresh_ctl ]
24 * | | | | | 24 * | | | | |
25 * | | *- IFM (Linux) | thresh start/stop OR FAB match -* 25 * | | *- IFM (Linux) | thresh start/stop -*
26 * | *- BHRB (Linux) *sm 26 * | *- BHRB (Linux) *sm
27 * *- EBB (Linux) 27 * *- EBB (Linux)
28 * 28 *
@@ -50,11 +50,9 @@
50 * MMCR1[31] = pmc4combine[1] 50 * MMCR1[31] = pmc4combine[1]
51 * 51 *
52 * if pmc == 3 and unit == 0 and pmcxsel[0:6] == 0b0101011 52 * if pmc == 3 and unit == 0 and pmcxsel[0:6] == 0b0101011
53 * # PM_MRK_FAB_RSP_MATCH 53 * MMCR1[20:27] = thresh_ctl
54 * MMCR1[20:27] = thresh_ctl (FAB_CRESP_MATCH / FAB_TYPE_MATCH)
55 * else if pmc == 4 and unit == 0xf and pmcxsel[0:6] == 0b0101001 54 * else if pmc == 4 and unit == 0xf and pmcxsel[0:6] == 0b0101001
56 * # PM_MRK_FAB_RSP_MATCH_CYC 55 * MMCR1[20:27] = thresh_ctl
57 * MMCR1[20:27] = thresh_ctl (FAB_CRESP_MATCH / FAB_TYPE_MATCH)
58 * else 56 * else
59 * MMCRA[48:55] = thresh_ctl (THRESH START/END) 57 * MMCRA[48:55] = thresh_ctl (THRESH START/END)
60 * 58 *
@@ -106,6 +104,21 @@ enum {
106/* PowerISA v2.07 format attribute structure*/ 104/* PowerISA v2.07 format attribute structure*/
107extern struct attribute_group isa207_pmu_format_group; 105extern struct attribute_group isa207_pmu_format_group;
108 106
107/* Table of alternatives, sorted by column 0 */
108static const unsigned int power9_event_alternatives[][MAX_ALT] = {
109 { PM_INST_DISP, PM_INST_DISP_ALT },
110};
111
112static int power9_get_alternatives(u64 event, unsigned int flags, u64 alt[])
113{
114 int num_alt = 0;
115
116 num_alt = isa207_get_alternatives(event, alt, power9_event_alternatives,
117 (int)ARRAY_SIZE(power9_event_alternatives));
118
119 return num_alt;
120}
121
109GENERIC_EVENT_ATTR(cpu-cycles, PM_CYC); 122GENERIC_EVENT_ATTR(cpu-cycles, PM_CYC);
110GENERIC_EVENT_ATTR(stalled-cycles-frontend, PM_ICT_NOSLOT_CYC); 123GENERIC_EVENT_ATTR(stalled-cycles-frontend, PM_ICT_NOSLOT_CYC);
111GENERIC_EVENT_ATTR(stalled-cycles-backend, PM_CMPLU_STALL); 124GENERIC_EVENT_ATTR(stalled-cycles-backend, PM_CMPLU_STALL);
@@ -213,6 +226,17 @@ static const struct attribute_group *power9_pmu_attr_groups[] = {
213 NULL, 226 NULL,
214}; 227};
215 228
229static int power9_generic_events_dd1[] = {
230 [PERF_COUNT_HW_CPU_CYCLES] = PM_CYC,
231 [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = PM_ICT_NOSLOT_CYC,
232 [PERF_COUNT_HW_STALLED_CYCLES_BACKEND] = PM_CMPLU_STALL,
233 [PERF_COUNT_HW_INSTRUCTIONS] = PM_INST_DISP,
234 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = PM_BRU_CMPL,
235 [PERF_COUNT_HW_BRANCH_MISSES] = PM_BR_MPRED_CMPL,
236 [PERF_COUNT_HW_CACHE_REFERENCES] = PM_LD_REF_L1,
237 [PERF_COUNT_HW_CACHE_MISSES] = PM_LD_MISS_L1_FIN,
238};
239
216static int power9_generic_events[] = { 240static int power9_generic_events[] = {
217 [PERF_COUNT_HW_CPU_CYCLES] = PM_CYC, 241 [PERF_COUNT_HW_CPU_CYCLES] = PM_CYC,
218 [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = PM_ICT_NOSLOT_CYC, 242 [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = PM_ICT_NOSLOT_CYC,
@@ -383,10 +407,11 @@ static struct power_pmu power9_isa207_pmu = {
383 .config_bhrb = power9_config_bhrb, 407 .config_bhrb = power9_config_bhrb,
384 .bhrb_filter_map = power9_bhrb_filter_map, 408 .bhrb_filter_map = power9_bhrb_filter_map,
385 .get_constraint = isa207_get_constraint, 409 .get_constraint = isa207_get_constraint,
410 .get_alternatives = power9_get_alternatives,
386 .disable_pmc = isa207_disable_pmc, 411 .disable_pmc = isa207_disable_pmc,
387 .flags = PPMU_NO_SIAR | PPMU_ARCH_207S, 412 .flags = PPMU_NO_SIAR | PPMU_ARCH_207S,
388 .n_generic = ARRAY_SIZE(power9_generic_events), 413 .n_generic = ARRAY_SIZE(power9_generic_events_dd1),
389 .generic_events = power9_generic_events, 414 .generic_events = power9_generic_events_dd1,
390 .cache_events = &power9_cache_events, 415 .cache_events = &power9_cache_events,
391 .attr_groups = power9_isa207_pmu_attr_groups, 416 .attr_groups = power9_isa207_pmu_attr_groups,
392 .bhrb_nr = 32, 417 .bhrb_nr = 32,
@@ -396,11 +421,12 @@ static struct power_pmu power9_pmu = {
396 .name = "POWER9", 421 .name = "POWER9",
397 .n_counter = MAX_PMU_COUNTERS, 422 .n_counter = MAX_PMU_COUNTERS,
398 .add_fields = ISA207_ADD_FIELDS, 423 .add_fields = ISA207_ADD_FIELDS,
399 .test_adder = ISA207_TEST_ADDER, 424 .test_adder = P9_DD1_TEST_ADDER,
400 .compute_mmcr = isa207_compute_mmcr, 425 .compute_mmcr = isa207_compute_mmcr,
401 .config_bhrb = power9_config_bhrb, 426 .config_bhrb = power9_config_bhrb,
402 .bhrb_filter_map = power9_bhrb_filter_map, 427 .bhrb_filter_map = power9_bhrb_filter_map,
403 .get_constraint = isa207_get_constraint, 428 .get_constraint = isa207_get_constraint,
429 .get_alternatives = power9_get_alternatives,
404 .disable_pmc = isa207_disable_pmc, 430 .disable_pmc = isa207_disable_pmc,
405 .flags = PPMU_HAS_SIER | PPMU_ARCH_207S, 431 .flags = PPMU_HAS_SIER | PPMU_ARCH_207S,
406 .n_generic = ARRAY_SIZE(power9_generic_events), 432 .n_generic = ARRAY_SIZE(power9_generic_events),
@@ -420,6 +446,11 @@ static int __init init_power9_pmu(void)
420 return -ENODEV; 446 return -ENODEV;
421 447
422 if (cpu_has_feature(CPU_FTR_POWER9_DD1)) { 448 if (cpu_has_feature(CPU_FTR_POWER9_DD1)) {
449 /*
450 * Since PM_INST_CMPL may not provide right counts in all
451 * sampling scenarios in power9 DD1, instead use PM_INST_DISP.
452 */
453 EVENT_VAR(PM_INST_CMPL, _g).id = PM_INST_DISP;
423 rc = register_power_pmu(&power9_isa207_pmu); 454 rc = register_power_pmu(&power9_isa207_pmu);
424 } else { 455 } else {
425 rc = register_power_pmu(&power9_pmu); 456 rc = register_power_pmu(&power9_pmu);
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 7bc86dae9517..fe19dad568e2 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_P1022_RDK) += p1022_rdk.o
22obj-$(CONFIG_P1023_RDB) += p1023_rdb.o 22obj-$(CONFIG_P1023_RDB) += p1023_rdb.o
23obj-$(CONFIG_TWR_P102x) += twr_p102x.o 23obj-$(CONFIG_TWR_P102x) += twr_p102x.o
24obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o 24obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o
25obj-$(CONFIG_FB_FSL_DIU) += t1042rdb_diu.o
25obj-$(CONFIG_STX_GP3) += stx_gp3.o 26obj-$(CONFIG_STX_GP3) += stx_gp3.o
26obj-$(CONFIG_TQM85xx) += tqm85xx.o 27obj-$(CONFIG_TQM85xx) += tqm85xx.o
27obj-$(CONFIG_SBC8548) += sbc8548.o 28obj-$(CONFIG_SBC8548) += sbc8548.o
diff --git a/arch/powerpc/platforms/85xx/corenet_generic.c b/arch/powerpc/platforms/85xx/corenet_generic.c
index 6c0ba75fb256..ac191a7a1337 100644
--- a/arch/powerpc/platforms/85xx/corenet_generic.c
+++ b/arch/powerpc/platforms/85xx/corenet_generic.c
@@ -157,6 +157,7 @@ static const char * const boards[] __initconst = {
157 "fsl,T1040RDB", 157 "fsl,T1040RDB",
158 "fsl,T1042RDB", 158 "fsl,T1042RDB",
159 "fsl,T1042RDB_PI", 159 "fsl,T1042RDB_PI",
160 "keymile,kmcent2",
160 "keymile,kmcoge4", 161 "keymile,kmcoge4",
161 "varisys,CYRUS", 162 "varisys,CYRUS",
162 NULL 163 NULL
diff --git a/arch/powerpc/platforms/85xx/t1042rdb_diu.c b/arch/powerpc/platforms/85xx/t1042rdb_diu.c
new file mode 100644
index 000000000000..58fa3d319f1c
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/t1042rdb_diu.c
@@ -0,0 +1,152 @@
1/*
2 * T1042 platform DIU operation
3 *
4 * Copyright 2014 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/io.h>
13#include <linux/kernel.h>
14#include <linux/of.h>
15#include <linux/of_address.h>
16
17#include <sysdev/fsl_soc.h>
18
19/*DIU Pixel ClockCR offset in scfg*/
20#define CCSR_SCFG_PIXCLKCR 0x28
21
22/* DIU Pixel Clock bits of the PIXCLKCR */
23#define PIXCLKCR_PXCKEN 0x80000000
24#define PIXCLKCR_PXCKINV 0x40000000
25#define PIXCLKCR_PXCKDLY 0x0000FF00
26#define PIXCLKCR_PXCLK_MASK 0x00FF0000
27
28/* Some CPLD register definitions */
29#define CPLD_DIUCSR 0x16
30#define CPLD_DIUCSR_DVIEN 0x80
31#define CPLD_DIUCSR_BACKLIGHT 0x0f
32
33struct device_node *cpld_node;
34
35/**
36 * t1042rdb_set_monitor_port: switch the output to a different monitor port
37 */
38static void t1042rdb_set_monitor_port(enum fsl_diu_monitor_port port)
39{
40 static void __iomem *cpld_base;
41
42 cpld_base = of_iomap(cpld_node, 0);
43 if (!cpld_base) {
44 pr_err("%s: Could not map cpld registers\n", __func__);
45 goto exit;
46 }
47
48 switch (port) {
49 case FSL_DIU_PORT_DVI:
50 /* Enable the DVI(HDMI) port, disable the DFP and
51 * the backlight
52 */
53 clrbits8(cpld_base + CPLD_DIUCSR, CPLD_DIUCSR_DVIEN);
54 break;
55 case FSL_DIU_PORT_LVDS:
56 /*
57 * LVDS also needs backlight enabled, otherwise the display
58 * will be blank.
59 */
60 /* Enable the DFP port, disable the DVI*/
61 setbits8(cpld_base + CPLD_DIUCSR, 0x01 << 8);
62 setbits8(cpld_base + CPLD_DIUCSR, 0x01 << 4);
63 setbits8(cpld_base + CPLD_DIUCSR, CPLD_DIUCSR_BACKLIGHT);
64 break;
65 default:
66 pr_err("%s: Unsupported monitor port %i\n", __func__, port);
67 }
68
69 iounmap(cpld_base);
70exit:
71 of_node_put(cpld_node);
72}
73
74/**
75 * t1042rdb_set_pixel_clock: program the DIU's clock
76 * @pixclock: pixel clock in ps (pico seconds)
77 */
78static void t1042rdb_set_pixel_clock(unsigned int pixclock)
79{
80 struct device_node *scfg_np;
81 void __iomem *scfg;
82 unsigned long freq;
83 u64 temp;
84 u32 pxclk;
85
86 scfg_np = of_find_compatible_node(NULL, NULL, "fsl,t1040-scfg");
87 if (!scfg_np) {
88 pr_err("%s: Missing scfg node. Can not display video.\n",
89 __func__);
90 return;
91 }
92
93 scfg = of_iomap(scfg_np, 0);
94 of_node_put(scfg_np);
95 if (!scfg) {
96 pr_err("%s: Could not map device. Can not display video.\n",
97 __func__);
98 return;
99 }
100
101 /* Convert pixclock into frequency */
102 temp = 1000000000000ULL;
103 do_div(temp, pixclock);
104 freq = temp;
105
106 /*
107 * 'pxclk' is the ratio of the platform clock to the pixel clock.
108 * This number is programmed into the PIXCLKCR register, and the valid
109 * range of values is 2-255.
110 */
111 pxclk = DIV_ROUND_CLOSEST(fsl_get_sys_freq(), freq);
112 pxclk = clamp_t(u32, pxclk, 2, 255);
113
114 /* Disable the pixel clock, and set it to non-inverted and no delay */
115 clrbits32(scfg + CCSR_SCFG_PIXCLKCR,
116 PIXCLKCR_PXCKEN | PIXCLKCR_PXCKDLY | PIXCLKCR_PXCLK_MASK);
117
118 /* Enable the clock and set the pxclk */
119 setbits32(scfg + CCSR_SCFG_PIXCLKCR, PIXCLKCR_PXCKEN | (pxclk << 16));
120
121 iounmap(scfg);
122}
123
124/**
125 * t1042rdb_valid_monitor_port: set the monitor port for sysfs
126 */
127static enum fsl_diu_monitor_port
128t1042rdb_valid_monitor_port(enum fsl_diu_monitor_port port)
129{
130 switch (port) {
131 case FSL_DIU_PORT_DVI:
132 case FSL_DIU_PORT_LVDS:
133 return port;
134 default:
135 return FSL_DIU_PORT_DVI; /* Dual-link LVDS is not supported */
136 }
137}
138
139static int __init t1042rdb_diu_init(void)
140{
141 cpld_node = of_find_compatible_node(NULL, NULL, "fsl,t1042rdb-cpld");
142 if (!cpld_node)
143 return 0;
144
145 diu_ops.set_monitor_port = t1042rdb_set_monitor_port;
146 diu_ops.set_pixel_clock = t1042rdb_set_pixel_clock;
147 diu_ops.valid_monitor_port = t1042rdb_valid_monitor_port;
148
149 return 0;
150}
151
152early_initcall(t1042rdb_diu_init);
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 6e89e5a8d4fb..99b0ae8acb78 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -172,6 +172,13 @@ config PPC_FPU
172 bool 172 bool
173 default y if PPC64 173 default y if PPC64
174 174
175config PPC_8xx_PERF_EVENT
176 bool "PPC 8xx perf events"
177 depends on PPC_8xx && PERF_EVENTS
178 help
179 This is Performance Events support for PPC 8xx. The 8xx doesn't
180 have a PMU but some events are emulated using 8xx features.
181
175config FSL_EMB_PERFMON 182config FSL_EMB_PERFMON
176 bool "Freescale Embedded Perfmon" 183 bool "Freescale Embedded Perfmon"
177 depends on E500 || PPC_83xx 184 depends on E500 || PPC_83xx
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index e5ec1368f0cd..ae2f740a82f1 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -683,23 +683,13 @@ size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
683 return ctx->ops->ibox_read(ctx, data); 683 return ctx->ops->ibox_read(ctx, data);
684} 684}
685 685
686static int spufs_ibox_fasync(int fd, struct file *file, int on)
687{
688 struct spu_context *ctx = file->private_data;
689
690 return fasync_helper(fd, file, on, &ctx->ibox_fasync);
691}
692
693/* interrupt-level ibox callback function. */ 686/* interrupt-level ibox callback function. */
694void spufs_ibox_callback(struct spu *spu) 687void spufs_ibox_callback(struct spu *spu)
695{ 688{
696 struct spu_context *ctx = spu->ctx; 689 struct spu_context *ctx = spu->ctx;
697 690
698 if (!ctx) 691 if (ctx)
699 return; 692 wake_up_all(&ctx->ibox_wq);
700
701 wake_up_all(&ctx->ibox_wq);
702 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
703} 693}
704 694
705/* 695/*
@@ -794,7 +784,6 @@ static const struct file_operations spufs_ibox_fops = {
794 .open = spufs_pipe_open, 784 .open = spufs_pipe_open,
795 .read = spufs_ibox_read, 785 .read = spufs_ibox_read,
796 .poll = spufs_ibox_poll, 786 .poll = spufs_ibox_poll,
797 .fasync = spufs_ibox_fasync,
798 .llseek = no_llseek, 787 .llseek = no_llseek,
799}; 788};
800 789
@@ -832,26 +821,13 @@ size_t spu_wbox_write(struct spu_context *ctx, u32 data)
832 return ctx->ops->wbox_write(ctx, data); 821 return ctx->ops->wbox_write(ctx, data);
833} 822}
834 823
835static int spufs_wbox_fasync(int fd, struct file *file, int on)
836{
837 struct spu_context *ctx = file->private_data;
838 int ret;
839
840 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
841
842 return ret;
843}
844
845/* interrupt-level wbox callback function. */ 824/* interrupt-level wbox callback function. */
846void spufs_wbox_callback(struct spu *spu) 825void spufs_wbox_callback(struct spu *spu)
847{ 826{
848 struct spu_context *ctx = spu->ctx; 827 struct spu_context *ctx = spu->ctx;
849 828
850 if (!ctx) 829 if (ctx)
851 return; 830 wake_up_all(&ctx->wbox_wq);
852
853 wake_up_all(&ctx->wbox_wq);
854 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
855} 831}
856 832
857/* 833/*
@@ -944,7 +920,6 @@ static const struct file_operations spufs_wbox_fops = {
944 .open = spufs_pipe_open, 920 .open = spufs_pipe_open,
945 .write = spufs_wbox_write, 921 .write = spufs_wbox_write,
946 .poll = spufs_wbox_poll, 922 .poll = spufs_wbox_poll,
947 .fasync = spufs_wbox_fasync,
948 .llseek = no_llseek, 923 .llseek = no_llseek,
949}; 924};
950 925
@@ -1520,28 +1495,8 @@ void spufs_mfc_callback(struct spu *spu)
1520{ 1495{
1521 struct spu_context *ctx = spu->ctx; 1496 struct spu_context *ctx = spu->ctx;
1522 1497
1523 if (!ctx) 1498 if (ctx)
1524 return; 1499 wake_up_all(&ctx->mfc_wq);
1525
1526 wake_up_all(&ctx->mfc_wq);
1527
1528 pr_debug("%s %s\n", __func__, spu->name);
1529 if (ctx->mfc_fasync) {
1530 u32 free_elements, tagstatus;
1531 unsigned int mask;
1532
1533 /* no need for spu_acquire in interrupt context */
1534 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1535 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1536
1537 mask = 0;
1538 if (free_elements & 0xffff)
1539 mask |= POLLOUT;
1540 if (tagstatus & ctx->tagwait)
1541 mask |= POLLIN;
1542
1543 kill_fasync(&ctx->mfc_fasync, SIGIO, mask);
1544 }
1545} 1500}
1546 1501
1547static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status) 1502static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
@@ -1803,13 +1758,6 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int data
1803 return err; 1758 return err;
1804} 1759}
1805 1760
1806static int spufs_mfc_fasync(int fd, struct file *file, int on)
1807{
1808 struct spu_context *ctx = file->private_data;
1809
1810 return fasync_helper(fd, file, on, &ctx->mfc_fasync);
1811}
1812
1813static const struct file_operations spufs_mfc_fops = { 1761static const struct file_operations spufs_mfc_fops = {
1814 .open = spufs_mfc_open, 1762 .open = spufs_mfc_open,
1815 .release = spufs_mfc_release, 1763 .release = spufs_mfc_release,
@@ -1818,7 +1766,6 @@ static const struct file_operations spufs_mfc_fops = {
1818 .poll = spufs_mfc_poll, 1766 .poll = spufs_mfc_poll,
1819 .flush = spufs_mfc_flush, 1767 .flush = spufs_mfc_flush,
1820 .fsync = spufs_mfc_fsync, 1768 .fsync = spufs_mfc_fsync,
1821 .fasync = spufs_mfc_fasync,
1822 .mmap = spufs_mfc_mmap, 1769 .mmap = spufs_mfc_mmap,
1823 .llseek = no_llseek, 1770 .llseek = no_llseek,
1824}; 1771};
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index bcfd6f063efa..aac733966092 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -102,9 +102,6 @@ struct spu_context {
102 wait_queue_head_t stop_wq; 102 wait_queue_head_t stop_wq;
103 wait_queue_head_t mfc_wq; 103 wait_queue_head_t mfc_wq;
104 wait_queue_head_t run_wq; 104 wait_queue_head_t run_wq;
105 struct fasync_struct *ibox_fasync;
106 struct fasync_struct *wbox_fasync;
107 struct fasync_struct *mfc_fasync;
108 u32 tagwait; 105 u32 tagwait;
109 struct spu_context_ops *ops; 106 struct spu_context_ops *ops;
110 struct work_struct reap_work; 107 struct work_struct reap_work;
diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
index 604190cab522..3a07e4dcf97c 100644
--- a/arch/powerpc/platforms/powernv/Kconfig
+++ b/arch/powerpc/platforms/powernv/Kconfig
@@ -5,7 +5,8 @@ config PPC_POWERNV
5 select PPC_XICS 5 select PPC_XICS
6 select PPC_ICP_NATIVE 6 select PPC_ICP_NATIVE
7 select PPC_P7_NAP 7 select PPC_P7_NAP
8 select PPC_PCI_CHOICE if EMBEDDED 8 select PCI
9 select PCI_MSI
9 select EPAPR_BOOT 10 select EPAPR_BOOT
10 select PPC_INDIRECT_PIO 11 select PPC_INDIRECT_PIO
11 select PPC_UDBG_16550 12 select PPC_UDBG_16550
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index e0f83c204ccc..6901a06da2f9 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1468,14 +1468,12 @@ void pnv_pci_sriov_disable(struct pci_dev *pdev)
1468 struct pnv_phb *phb; 1468 struct pnv_phb *phb;
1469 struct pnv_ioda_pe *pe; 1469 struct pnv_ioda_pe *pe;
1470 struct pci_dn *pdn; 1470 struct pci_dn *pdn;
1471 struct pci_sriov *iov;
1472 u16 num_vfs, i; 1471 u16 num_vfs, i;
1473 1472
1474 bus = pdev->bus; 1473 bus = pdev->bus;
1475 hose = pci_bus_to_host(bus); 1474 hose = pci_bus_to_host(bus);
1476 phb = hose->private_data; 1475 phb = hose->private_data;
1477 pdn = pci_get_pdn(pdev); 1476 pdn = pci_get_pdn(pdev);
1478 iov = pdev->sriov;
1479 num_vfs = pdn->num_vfs; 1477 num_vfs = pdn->num_vfs;
1480 1478
1481 /* Release VF PEs */ 1479 /* Release VF PEs */
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index d3a81e746fc4..193e052fa0dd 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -354,11 +354,17 @@ static int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog)
354 switch (hp_elog->id_type) { 354 switch (hp_elog->id_type) {
355 case PSERIES_HP_ELOG_ID_DRC_COUNT: 355 case PSERIES_HP_ELOG_ID_DRC_COUNT:
356 hp_elog->_drc_u.drc_count = 356 hp_elog->_drc_u.drc_count =
357 be32_to_cpu(hp_elog->_drc_u.drc_count); 357 be32_to_cpu(hp_elog->_drc_u.drc_count);
358 break; 358 break;
359 case PSERIES_HP_ELOG_ID_DRC_INDEX: 359 case PSERIES_HP_ELOG_ID_DRC_INDEX:
360 hp_elog->_drc_u.drc_index = 360 hp_elog->_drc_u.drc_index =
361 be32_to_cpu(hp_elog->_drc_u.drc_index); 361 be32_to_cpu(hp_elog->_drc_u.drc_index);
362 break;
363 case PSERIES_HP_ELOG_ID_DRC_IC:
364 hp_elog->_drc_u.ic.count =
365 be32_to_cpu(hp_elog->_drc_u.ic.count);
366 hp_elog->_drc_u.ic.index =
367 be32_to_cpu(hp_elog->_drc_u.ic.index);
362 } 368 }
363 369
364 switch (hp_elog->resource) { 370 switch (hp_elog->resource) {
@@ -467,7 +473,33 @@ static int dlpar_parse_id_type(char **cmd, struct pseries_hp_errorlog *hp_elog)
467 if (!arg) 473 if (!arg)
468 return -EINVAL; 474 return -EINVAL;
469 475
470 if (sysfs_streq(arg, "index")) { 476 if (sysfs_streq(arg, "indexed-count")) {
477 hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_IC;
478 arg = strsep(cmd, " ");
479 if (!arg) {
480 pr_err("No DRC count specified.\n");
481 return -EINVAL;
482 }
483
484 if (kstrtou32(arg, 0, &count)) {
485 pr_err("Invalid DRC count specified.\n");
486 return -EINVAL;
487 }
488
489 arg = strsep(cmd, " ");
490 if (!arg) {
491 pr_err("No DRC Index specified.\n");
492 return -EINVAL;
493 }
494
495 if (kstrtou32(arg, 0, &index)) {
496 pr_err("Invalid DRC Index specified.\n");
497 return -EINVAL;
498 }
499
500 hp_elog->_drc_u.ic.count = cpu_to_be32(count);
501 hp_elog->_drc_u.ic.index = cpu_to_be32(index);
502 } else if (sysfs_streq(arg, "index")) {
471 hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_INDEX; 503 hp_elog->id_type = PSERIES_HP_ELOG_ID_DRC_INDEX;
472 arg = strsep(cmd, " "); 504 arg = strsep(cmd, " ");
473 if (!arg) { 505 if (!arg) {
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 3381c20edbc0..e104c71ea44a 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -320,6 +320,19 @@ static int dlpar_remove_device_tree_lmb(struct of_drconf_cell *lmb)
320 return dlpar_update_device_tree_lmb(lmb); 320 return dlpar_update_device_tree_lmb(lmb);
321} 321}
322 322
323static struct memory_block *lmb_to_memblock(struct of_drconf_cell *lmb)
324{
325 unsigned long section_nr;
326 struct mem_section *mem_sect;
327 struct memory_block *mem_block;
328
329 section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr));
330 mem_sect = __nr_to_section(section_nr);
331
332 mem_block = find_memory_block(mem_sect);
333 return mem_block;
334}
335
323#ifdef CONFIG_MEMORY_HOTREMOVE 336#ifdef CONFIG_MEMORY_HOTREMOVE
324static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size) 337static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size)
325{ 338{
@@ -407,19 +420,6 @@ static bool lmb_is_removable(struct of_drconf_cell *lmb)
407 420
408static int dlpar_add_lmb(struct of_drconf_cell *); 421static int dlpar_add_lmb(struct of_drconf_cell *);
409 422
410static struct memory_block *lmb_to_memblock(struct of_drconf_cell *lmb)
411{
412 unsigned long section_nr;
413 struct mem_section *mem_sect;
414 struct memory_block *mem_block;
415
416 section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr));
417 mem_sect = __nr_to_section(section_nr);
418
419 mem_block = find_memory_block(mem_sect);
420 return mem_block;
421}
422
423static int dlpar_remove_lmb(struct of_drconf_cell *lmb) 423static int dlpar_remove_lmb(struct of_drconf_cell *lmb)
424{ 424{
425 struct memory_block *mem_block; 425 struct memory_block *mem_block;
@@ -601,6 +601,94 @@ static int dlpar_memory_readd_by_index(u32 drc_index, struct property *prop)
601 601
602 return rc; 602 return rc;
603} 603}
604
605static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
606 struct property *prop)
607{
608 struct of_drconf_cell *lmbs;
609 u32 num_lmbs, *p;
610 int i, rc, start_lmb_found;
611 int lmbs_available = 0, start_index = 0, end_index;
612
613 pr_info("Attempting to hot-remove %u LMB(s) at %x\n",
614 lmbs_to_remove, drc_index);
615
616 if (lmbs_to_remove == 0)
617 return -EINVAL;
618
619 p = prop->value;
620 num_lmbs = *p++;
621 lmbs = (struct of_drconf_cell *)p;
622 start_lmb_found = 0;
623
624 /* Navigate to drc_index */
625 while (start_index < num_lmbs) {
626 if (lmbs[start_index].drc_index == drc_index) {
627 start_lmb_found = 1;
628 break;
629 }
630
631 start_index++;
632 }
633
634 if (!start_lmb_found)
635 return -EINVAL;
636
637 end_index = start_index + lmbs_to_remove;
638
639 /* Validate that there are enough LMBs to satisfy the request */
640 for (i = start_index; i < end_index; i++) {
641 if (lmbs[i].flags & DRCONF_MEM_RESERVED)
642 break;
643
644 lmbs_available++;
645 }
646
647 if (lmbs_available < lmbs_to_remove)
648 return -EINVAL;
649
650 for (i = start_index; i < end_index; i++) {
651 if (!(lmbs[i].flags & DRCONF_MEM_ASSIGNED))
652 continue;
653
654 rc = dlpar_remove_lmb(&lmbs[i]);
655 if (rc)
656 break;
657
658 lmbs[i].reserved = 1;
659 }
660
661 if (rc) {
662 pr_err("Memory indexed-count-remove failed, adding any removed LMBs\n");
663
664 for (i = start_index; i < end_index; i++) {
665 if (!lmbs[i].reserved)
666 continue;
667
668 rc = dlpar_add_lmb(&lmbs[i]);
669 if (rc)
670 pr_err("Failed to add LMB, drc index %x\n",
671 be32_to_cpu(lmbs[i].drc_index));
672
673 lmbs[i].reserved = 0;
674 }
675 rc = -EINVAL;
676 } else {
677 for (i = start_index; i < end_index; i++) {
678 if (!lmbs[i].reserved)
679 continue;
680
681 dlpar_release_drc(lmbs[i].drc_index);
682 pr_info("Memory at %llx (drc index %x) was hot-removed\n",
683 lmbs[i].base_addr, lmbs[i].drc_index);
684
685 lmbs[i].reserved = 0;
686 }
687 }
688
689 return rc;
690}
691
604#else 692#else
605static inline int pseries_remove_memblock(unsigned long base, 693static inline int pseries_remove_memblock(unsigned long base,
606 unsigned int memblock_size) 694 unsigned int memblock_size)
@@ -628,9 +716,32 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
628{ 716{
629 return -EOPNOTSUPP; 717 return -EOPNOTSUPP;
630} 718}
719static int dlpar_memory_readd_by_index(u32 drc_index, struct property *prop)
720{
721 return -EOPNOTSUPP;
722}
631 723
724static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
725 struct property *prop)
726{
727 return -EOPNOTSUPP;
728}
632#endif /* CONFIG_MEMORY_HOTREMOVE */ 729#endif /* CONFIG_MEMORY_HOTREMOVE */
633 730
731static int dlpar_online_lmb(struct of_drconf_cell *lmb)
732{
733 struct memory_block *mem_block;
734 int rc;
735
736 mem_block = lmb_to_memblock(lmb);
737 if (!mem_block)
738 return -EINVAL;
739
740 rc = device_online(&mem_block->dev);
741 put_device(&mem_block->dev);
742 return rc;
743}
744
634static int dlpar_add_lmb(struct of_drconf_cell *lmb) 745static int dlpar_add_lmb(struct of_drconf_cell *lmb)
635{ 746{
636 unsigned long block_sz; 747 unsigned long block_sz;
@@ -654,10 +765,18 @@ static int dlpar_add_lmb(struct of_drconf_cell *lmb)
654 765
655 /* Add the memory */ 766 /* Add the memory */
656 rc = add_memory(nid, lmb->base_addr, block_sz); 767 rc = add_memory(nid, lmb->base_addr, block_sz);
657 if (rc) 768 if (rc) {
658 dlpar_remove_device_tree_lmb(lmb); 769 dlpar_remove_device_tree_lmb(lmb);
659 else 770 return rc;
771 }
772
773 rc = dlpar_online_lmb(lmb);
774 if (rc) {
775 remove_memory(nid, lmb->base_addr, block_sz);
776 dlpar_remove_device_tree_lmb(lmb);
777 } else {
660 lmb->flags |= DRCONF_MEM_ASSIGNED; 778 lmb->flags |= DRCONF_MEM_ASSIGNED;
779 }
661 780
662 return rc; 781 return rc;
663} 782}
@@ -776,6 +895,97 @@ static int dlpar_memory_add_by_index(u32 drc_index, struct property *prop)
776 return rc; 895 return rc;
777} 896}
778 897
898static int dlpar_memory_add_by_ic(u32 lmbs_to_add, u32 drc_index,
899 struct property *prop)
900{
901 struct of_drconf_cell *lmbs;
902 u32 num_lmbs, *p;
903 int i, rc, start_lmb_found;
904 int lmbs_available = 0, start_index = 0, end_index;
905
906 pr_info("Attempting to hot-add %u LMB(s) at index %x\n",
907 lmbs_to_add, drc_index);
908
909 if (lmbs_to_add == 0)
910 return -EINVAL;
911
912 p = prop->value;
913 num_lmbs = *p++;
914 lmbs = (struct of_drconf_cell *)p;
915 start_lmb_found = 0;
916
917 /* Navigate to drc_index */
918 while (start_index < num_lmbs) {
919 if (lmbs[start_index].drc_index == drc_index) {
920 start_lmb_found = 1;
921 break;
922 }
923
924 start_index++;
925 }
926
927 if (!start_lmb_found)
928 return -EINVAL;
929
930 end_index = start_index + lmbs_to_add;
931
932 /* Validate that the LMBs in this range are not reserved */
933 for (i = start_index; i < end_index; i++) {
934 if (lmbs[i].flags & DRCONF_MEM_RESERVED)
935 break;
936
937 lmbs_available++;
938 }
939
940 if (lmbs_available < lmbs_to_add)
941 return -EINVAL;
942
943 for (i = start_index; i < end_index; i++) {
944 if (lmbs[i].flags & DRCONF_MEM_ASSIGNED)
945 continue;
946
947 rc = dlpar_acquire_drc(lmbs[i].drc_index);
948 if (rc)
949 break;
950
951 rc = dlpar_add_lmb(&lmbs[i]);
952 if (rc) {
953 dlpar_release_drc(lmbs[i].drc_index);
954 break;
955 }
956
957 lmbs[i].reserved = 1;
958 }
959
960 if (rc) {
961 pr_err("Memory indexed-count-add failed, removing any added LMBs\n");
962
963 for (i = start_index; i < end_index; i++) {
964 if (!lmbs[i].reserved)
965 continue;
966
967 rc = dlpar_remove_lmb(&lmbs[i]);
968 if (rc)
969 pr_err("Failed to remove LMB, drc index %x\n",
970 be32_to_cpu(lmbs[i].drc_index));
971 else
972 dlpar_release_drc(lmbs[i].drc_index);
973 }
974 rc = -EINVAL;
975 } else {
976 for (i = start_index; i < end_index; i++) {
977 if (!lmbs[i].reserved)
978 continue;
979
980 pr_info("Memory at %llx (drc index %x) was hot-added\n",
981 lmbs[i].base_addr, lmbs[i].drc_index);
982 lmbs[i].reserved = 0;
983 }
984 }
985
986 return rc;
987}
988
779int dlpar_memory(struct pseries_hp_errorlog *hp_elog) 989int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
780{ 990{
781 struct device_node *dn; 991 struct device_node *dn;
@@ -783,9 +993,6 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
783 u32 count, drc_index; 993 u32 count, drc_index;
784 int rc; 994 int rc;
785 995
786 count = hp_elog->_drc_u.drc_count;
787 drc_index = hp_elog->_drc_u.drc_index;
788
789 lock_device_hotplug(); 996 lock_device_hotplug();
790 997
791 dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); 998 dn = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
@@ -802,22 +1009,39 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
802 1009
803 switch (hp_elog->action) { 1010 switch (hp_elog->action) {
804 case PSERIES_HP_ELOG_ACTION_ADD: 1011 case PSERIES_HP_ELOG_ACTION_ADD:
805 if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) 1012 if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
1013 count = hp_elog->_drc_u.drc_count;
806 rc = dlpar_memory_add_by_count(count, prop); 1014 rc = dlpar_memory_add_by_count(count, prop);
807 else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) 1015 } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
1016 drc_index = hp_elog->_drc_u.drc_index;
808 rc = dlpar_memory_add_by_index(drc_index, prop); 1017 rc = dlpar_memory_add_by_index(drc_index, prop);
809 else 1018 } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_IC) {
1019 count = hp_elog->_drc_u.ic.count;
1020 drc_index = hp_elog->_drc_u.ic.index;
1021 rc = dlpar_memory_add_by_ic(count, drc_index, prop);
1022 } else {
810 rc = -EINVAL; 1023 rc = -EINVAL;
1024 }
1025
811 break; 1026 break;
812 case PSERIES_HP_ELOG_ACTION_REMOVE: 1027 case PSERIES_HP_ELOG_ACTION_REMOVE:
813 if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) 1028 if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_COUNT) {
1029 count = hp_elog->_drc_u.drc_count;
814 rc = dlpar_memory_remove_by_count(count, prop); 1030 rc = dlpar_memory_remove_by_count(count, prop);
815 else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) 1031 } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
1032 drc_index = hp_elog->_drc_u.drc_index;
816 rc = dlpar_memory_remove_by_index(drc_index, prop); 1033 rc = dlpar_memory_remove_by_index(drc_index, prop);
817 else 1034 } else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_IC) {
1035 count = hp_elog->_drc_u.ic.count;
1036 drc_index = hp_elog->_drc_u.ic.index;
1037 rc = dlpar_memory_remove_by_ic(count, drc_index, prop);
1038 } else {
818 rc = -EINVAL; 1039 rc = -EINVAL;
1040 }
1041
819 break; 1042 break;
820 case PSERIES_HP_ELOG_ACTION_READD: 1043 case PSERIES_HP_ELOG_ACTION_READD:
1044 drc_index = hp_elog->_drc_u.drc_index;
821 rc = dlpar_memory_readd_by_index(drc_index, prop); 1045 rc = dlpar_memory_readd_by_index(drc_index, prop);
822 break; 1046 break;
823 default: 1047 default:
diff --git a/arch/powerpc/xmon/ppc-dis.c b/arch/powerpc/xmon/ppc-dis.c
index ee9891734149..31db8c072acd 100644
--- a/arch/powerpc/xmon/ppc-dis.c
+++ b/arch/powerpc/xmon/ppc-dis.c
@@ -1,6 +1,5 @@
1/* ppc-dis.c -- Disassemble PowerPC instructions 1/* ppc-dis.c -- Disassemble PowerPC instructions
2 Copyright 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005, 2006 2 Copyright (C) 1994-2016 Free Software Foundation, Inc.
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 3 Written by Ian Lance Taylor, Cygnus Support
5 4
6This file is part of GDB, GAS, and the GNU binutils. 5This file is part of GDB, GAS, and the GNU binutils.
@@ -26,57 +25,94 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, US
26#include "ppc.h" 25#include "ppc.h"
27#include "dis-asm.h" 26#include "dis-asm.h"
28 27
29/* Print a PowerPC or POWER instruction. */ 28/* This file provides several disassembler functions, all of which use
29 the disassembler interface defined in dis-asm.h. Several functions
30 are provided because this file handles disassembly for the PowerPC
31 in both big and little endian mode and also for the POWER (RS/6000)
32 chip. */
33
34/* Extract the operand value from the PowerPC or POWER instruction. */
30 35
31int 36static long
32print_insn_powerpc (unsigned long insn, unsigned long memaddr) 37operand_value_powerpc (const struct powerpc_operand *operand,
38 unsigned long insn, ppc_cpu_t dialect)
33{ 39{
34 const struct powerpc_opcode *opcode; 40 long value;
35 const struct powerpc_opcode *opcode_end; 41 int invalid;
36 unsigned long op; 42 /* Extract the value from the instruction. */
37 int dialect; 43 if (operand->extract)
44 value = (*operand->extract) (insn, dialect, &invalid);
45 else
46 {
47 if (operand->shift >= 0)
48 value = (insn >> operand->shift) & operand->bitm;
49 else
50 value = (insn << -operand->shift) & operand->bitm;
51 if ((operand->flags & PPC_OPERAND_SIGNED) != 0)
52 {
53 /* BITM is always some number of zeros followed by some
54 number of ones, followed by some number of zeros. */
55 unsigned long top = operand->bitm;
56 /* top & -top gives the rightmost 1 bit, so this
57 fills in any trailing zeros. */
58 top |= (top & -top) - 1;
59 top &= ~(top >> 1);
60 value = (value ^ top) - top;
61 }
62 }
38 63
39 dialect = PPC_OPCODE_PPC | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON 64 return value;
40 | PPC_OPCODE_64 | PPC_OPCODE_POWER4 | PPC_OPCODE_ALTIVEC; 65}
41 66
42 if (cpu_has_feature(CPU_FTRS_POWER5)) 67/* Determine whether the optional operand(s) should be printed. */
43 dialect |= PPC_OPCODE_POWER5;
44 68
45 if (cpu_has_feature(CPU_FTRS_CELL)) 69static int
46 dialect |= PPC_OPCODE_CELL | PPC_OPCODE_ALTIVEC; 70skip_optional_operands (const unsigned char *opindex,
71 unsigned long insn, ppc_cpu_t dialect)
72{
73 const struct powerpc_operand *operand;
47 74
48 if (cpu_has_feature(CPU_FTRS_POWER6)) 75 for (; *opindex != 0; opindex++)
49 dialect |= PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_ALTIVEC; 76 {
77 operand = &powerpc_operands[*opindex];
78 if ((operand->flags & PPC_OPERAND_NEXT) != 0
79 || ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
80 && operand_value_powerpc (operand, insn, dialect) !=
81 ppc_optional_operand_value (operand)))
82 return 0;
83 }
84
85 return 1;
86}
87
88/* Find a match for INSN in the opcode table, given machine DIALECT.
89 A DIALECT of -1 is special, matching all machine opcode variations. */
90
91static const struct powerpc_opcode *
92lookup_powerpc (unsigned long insn, ppc_cpu_t dialect)
93{
94 const struct powerpc_opcode *opcode;
95 const struct powerpc_opcode *opcode_end;
96 unsigned long op;
50 97
51 /* Get the major opcode of the instruction. */ 98 /* Get the major opcode of the instruction. */
52 op = PPC_OP (insn); 99 op = PPC_OP (insn);
53 100
54 /* Find the first match in the opcode table. We could speed this up
55 a bit by doing a binary search on the major opcode. */
56 opcode_end = powerpc_opcodes + powerpc_num_opcodes; 101 opcode_end = powerpc_opcodes + powerpc_num_opcodes;
57 again: 102 /* Find the first match in the opcode table for this major opcode. */
58 for (opcode = powerpc_opcodes; opcode < opcode_end; opcode++) 103 for (opcode = powerpc_opcodes; opcode < opcode_end; ++opcode)
59 { 104 {
60 unsigned long table_op;
61 const unsigned char *opindex; 105 const unsigned char *opindex;
62 const struct powerpc_operand *operand; 106 const struct powerpc_operand *operand;
63 int invalid; 107 int invalid;
64 int need_comma;
65 int need_paren;
66
67 table_op = PPC_OP (opcode->opcode);
68 if (op < table_op)
69 break;
70 if (op > table_op)
71 continue;
72 108
73 if ((insn & opcode->mask) != opcode->opcode 109 if ((insn & opcode->mask) != opcode->opcode
74 || (opcode->flags & dialect) == 0) 110 || (dialect != (ppc_cpu_t) -1
111 && ((opcode->flags & dialect) == 0
112 || (opcode->deprecated & dialect) != 0)))
75 continue; 113 continue;
76 114
77 /* Make two passes over the operands. First see if any of them 115 /* Check validity of operands. */
78 have extraction functions, and, if they do, make sure the
79 instruction is valid. */
80 invalid = 0; 116 invalid = 0;
81 for (opindex = opcode->operands; *opindex != 0; opindex++) 117 for (opindex = opcode->operands; *opindex != 0; opindex++)
82 { 118 {
@@ -87,14 +123,77 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
87 if (invalid) 123 if (invalid)
88 continue; 124 continue;
89 125
90 /* The instruction is valid. */ 126 return opcode;
91 printf("%s", opcode->name); 127 }
128
129 return NULL;
130}
131
132/* Print a PowerPC or POWER instruction. */
133
134int print_insn_powerpc (unsigned long insn, unsigned long memaddr)
135{
136 const struct powerpc_opcode *opcode;
137 bool insn_is_short;
138 ppc_cpu_t dialect;
139
140 dialect = PPC_OPCODE_PPC | PPC_OPCODE_COMMON
141 | PPC_OPCODE_64 | PPC_OPCODE_POWER4 | PPC_OPCODE_ALTIVEC;
142
143 if (cpu_has_feature(CPU_FTRS_POWER5))
144 dialect |= PPC_OPCODE_POWER5;
145
146 if (cpu_has_feature(CPU_FTRS_CELL))
147 dialect |= (PPC_OPCODE_CELL | PPC_OPCODE_ALTIVEC);
148
149 if (cpu_has_feature(CPU_FTRS_POWER6))
150 dialect |= (PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_ALTIVEC);
151
152 if (cpu_has_feature(CPU_FTRS_POWER7))
153 dialect |= (PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_POWER7
154 | PPC_OPCODE_ALTIVEC | PPC_OPCODE_VSX);
155
156 if (cpu_has_feature(CPU_FTRS_POWER8))
157 dialect |= (PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_POWER7
158 | PPC_OPCODE_POWER8 | PPC_OPCODE_HTM
159 | PPC_OPCODE_ALTIVEC | PPC_OPCODE_ALTIVEC2 | PPC_OPCODE_VSX);
160
161 if (cpu_has_feature(CPU_FTRS_POWER9))
162 dialect |= (PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_POWER7
163 | PPC_OPCODE_POWER8 | PPC_OPCODE_POWER9 | PPC_OPCODE_HTM
164 | PPC_OPCODE_ALTIVEC | PPC_OPCODE_ALTIVEC2
165 | PPC_OPCODE_VSX | PPC_OPCODE_VSX3),
166
167 /* Get the major opcode of the insn. */
168 opcode = NULL;
169 insn_is_short = false;
170
171 if (opcode == NULL)
172 opcode = lookup_powerpc (insn, dialect);
173 if (opcode == NULL && (dialect & PPC_OPCODE_ANY) != 0)
174 opcode = lookup_powerpc (insn, (ppc_cpu_t) -1);
175
176 if (opcode != NULL)
177 {
178 const unsigned char *opindex;
179 const struct powerpc_operand *operand;
180 int need_comma;
181 int need_paren;
182 int skip_optional;
183
92 if (opcode->operands[0] != 0) 184 if (opcode->operands[0] != 0)
93 printf("\t"); 185 printf("%-7s ", opcode->name);
186 else
187 printf("%s", opcode->name);
188
189 if (insn_is_short)
190 /* The operands will be fetched out of the 16-bit instruction. */
191 insn >>= 16;
94 192
95 /* Now extract and print the operands. */ 193 /* Now extract and print the operands. */
96 need_comma = 0; 194 need_comma = 0;
97 need_paren = 0; 195 need_paren = 0;
196 skip_optional = -1;
98 for (opindex = opcode->operands; *opindex != 0; opindex++) 197 for (opindex = opcode->operands; *opindex != 0; opindex++)
99 { 198 {
100 long value; 199 long value;
@@ -107,23 +206,18 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
107 if ((operand->flags & PPC_OPERAND_FAKE) != 0) 206 if ((operand->flags & PPC_OPERAND_FAKE) != 0)
108 continue; 207 continue;
109 208
110 /* Extract the value from the instruction. */ 209 /* If all of the optional operands have the value zero,
111 if (operand->extract) 210 then don't print any of them. */
112 value = (*operand->extract) (insn, dialect, &invalid); 211 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0)
113 else
114 { 212 {
115 value = (insn >> operand->shift) & ((1 << operand->bits) - 1); 213 if (skip_optional < 0)
116 if ((operand->flags & PPC_OPERAND_SIGNED) != 0 214 skip_optional = skip_optional_operands (opindex, insn,
117 && (value & (1 << (operand->bits - 1))) != 0) 215 dialect);
118 value -= 1 << operand->bits; 216 if (skip_optional)
217 continue;
119 } 218 }
120 219
121 /* If the operand is optional, and the value is zero, don't 220 value = operand_value_powerpc (operand, insn, dialect);
122 print anything. */
123 if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0
124 && (operand->flags & PPC_OPERAND_NEXT) == 0
125 && value == 0)
126 continue;
127 221
128 if (need_comma) 222 if (need_comma)
129 { 223 {
@@ -139,30 +233,38 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
139 printf("f%ld", value); 233 printf("f%ld", value);
140 else if ((operand->flags & PPC_OPERAND_VR) != 0) 234 else if ((operand->flags & PPC_OPERAND_VR) != 0)
141 printf("v%ld", value); 235 printf("v%ld", value);
236 else if ((operand->flags & PPC_OPERAND_VSR) != 0)
237 printf("vs%ld", value);
142 else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0) 238 else if ((operand->flags & PPC_OPERAND_RELATIVE) != 0)
143 print_address (memaddr + value); 239 print_address(memaddr + value);
144 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) 240 else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0)
145 print_address (value & 0xffffffff); 241 print_address(value & 0xffffffff);
146 else if ((operand->flags & PPC_OPERAND_CR) == 0 242 else if ((operand->flags & PPC_OPERAND_FSL) != 0)
147 || (dialect & PPC_OPCODE_PPC) == 0) 243 printf("fsl%ld", value);
244 else if ((operand->flags & PPC_OPERAND_FCR) != 0)
245 printf("fcr%ld", value);
246 else if ((operand->flags & PPC_OPERAND_UDI) != 0)
148 printf("%ld", value); 247 printf("%ld", value);
149 else 248 else if ((operand->flags & PPC_OPERAND_CR_REG) != 0
249 && (((dialect & PPC_OPCODE_PPC) != 0)
250 || ((dialect & PPC_OPCODE_VLE) != 0)))
251 printf("cr%ld", value);
252 else if (((operand->flags & PPC_OPERAND_CR_BIT) != 0)
253 && (((dialect & PPC_OPCODE_PPC) != 0)
254 || ((dialect & PPC_OPCODE_VLE) != 0)))
150 { 255 {
151 if (operand->bits == 3) 256 static const char *cbnames[4] = { "lt", "gt", "eq", "so" };
152 printf("cr%ld", value); 257 int cr;
153 else 258 int cc;
154 { 259
155 static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; 260 cr = value >> 2;
156 int cr; 261 if (cr != 0)
157 int cc; 262 printf("4*cr%d+", cr);
158 263 cc = value & 3;
159 cr = value >> 2; 264 printf("%s", cbnames[cc]);
160 if (cr != 0)
161 printf("4*cr%d+", cr);
162 cc = value & 3;
163 printf("%s", cbnames[cc]);
164 }
165 } 265 }
266 else
267 printf("%d", (int) value);
166 268
167 if (need_paren) 269 if (need_paren)
168 { 270 {
@@ -179,14 +281,16 @@ print_insn_powerpc (unsigned long insn, unsigned long memaddr)
179 } 281 }
180 } 282 }
181 283
182 /* We have found and printed an instruction; return. */ 284 /* We have found and printed an instruction.
183 return 4; 285 If it was a short VLE instruction we have more to do. */
184 } 286 if (insn_is_short)
185 287 {
186 if ((dialect & PPC_OPCODE_ANY) != 0) 288 memaddr += 2;
187 { 289 return 2;
188 dialect = ~PPC_OPCODE_ANY; 290 }
189 goto again; 291 else
292 /* Otherwise, return. */
293 return 4;
190 } 294 }
191 295
192 /* We could not find a match. */ 296 /* We could not find a match. */
diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc-opc.c
index 954dbf8222d7..ac2b55b1332e 100644
--- a/arch/powerpc/xmon/ppc-opc.c
+++ b/arch/powerpc/xmon/ppc-opc.c
@@ -1,6 +1,5 @@
1/* ppc-opc.c -- PowerPC opcode list 1/* ppc-opc.c -- PowerPC opcode list
2 Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2 Copyright (C) 1994-2016 Free Software Foundation, Inc.
3 2005 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 3 Written by Ian Lance Taylor, Cygnus Support
5 4
6 This file is part of GDB, GAS, and the GNU binutils. 5 This file is part of GDB, GAS, and the GNU binutils.
@@ -42,66 +41,97 @@
42 41
43/* Local insertion and extraction functions. */ 42/* Local insertion and extraction functions. */
44 43
45static unsigned long insert_bat (unsigned long, long, int, const char **); 44static unsigned long insert_arx (unsigned long, long, ppc_cpu_t, const char **);
46static long extract_bat (unsigned long, int, int *); 45static long extract_arx (unsigned long, ppc_cpu_t, int *);
47static unsigned long insert_bba (unsigned long, long, int, const char **); 46static unsigned long insert_ary (unsigned long, long, ppc_cpu_t, const char **);
48static long extract_bba (unsigned long, int, int *); 47static long extract_ary (unsigned long, ppc_cpu_t, int *);
49static unsigned long insert_bd (unsigned long, long, int, const char **); 48static unsigned long insert_bat (unsigned long, long, ppc_cpu_t, const char **);
50static long extract_bd (unsigned long, int, int *); 49static long extract_bat (unsigned long, ppc_cpu_t, int *);
51static unsigned long insert_bdm (unsigned long, long, int, const char **); 50static unsigned long insert_bba (unsigned long, long, ppc_cpu_t, const char **);
52static long extract_bdm (unsigned long, int, int *); 51static long extract_bba (unsigned long, ppc_cpu_t, int *);
53static unsigned long insert_bdp (unsigned long, long, int, const char **); 52static unsigned long insert_bdm (unsigned long, long, ppc_cpu_t, const char **);
54static long extract_bdp (unsigned long, int, int *); 53static long extract_bdm (unsigned long, ppc_cpu_t, int *);
55static unsigned long insert_bo (unsigned long, long, int, const char **); 54static unsigned long insert_bdp (unsigned long, long, ppc_cpu_t, const char **);
56static long extract_bo (unsigned long, int, int *); 55static long extract_bdp (unsigned long, ppc_cpu_t, int *);
57static unsigned long insert_boe (unsigned long, long, int, const char **); 56static unsigned long insert_bo (unsigned long, long, ppc_cpu_t, const char **);
58static long extract_boe (unsigned long, int, int *); 57static long extract_bo (unsigned long, ppc_cpu_t, int *);
59static unsigned long insert_dq (unsigned long, long, int, const char **); 58static unsigned long insert_boe (unsigned long, long, ppc_cpu_t, const char **);
60static long extract_dq (unsigned long, int, int *); 59static long extract_boe (unsigned long, ppc_cpu_t, int *);
61static unsigned long insert_ds (unsigned long, long, int, const char **); 60static unsigned long insert_esync (unsigned long, long, ppc_cpu_t, const char **);
62static long extract_ds (unsigned long, int, int *); 61static unsigned long insert_dcmxs (unsigned long, long, ppc_cpu_t, const char **);
63static unsigned long insert_de (unsigned long, long, int, const char **); 62static long extract_dcmxs (unsigned long, ppc_cpu_t, int *);
64static long extract_de (unsigned long, int, int *); 63static unsigned long insert_dxd (unsigned long, long, ppc_cpu_t, const char **);
65static unsigned long insert_des (unsigned long, long, int, const char **); 64static long extract_dxd (unsigned long, ppc_cpu_t, int *);
66static long extract_des (unsigned long, int, int *); 65static unsigned long insert_dxdn (unsigned long, long, ppc_cpu_t, const char **);
67static unsigned long insert_fxm (unsigned long, long, int, const char **); 66static long extract_dxdn (unsigned long, ppc_cpu_t, int *);
68static long extract_fxm (unsigned long, int, int *); 67static unsigned long insert_fxm (unsigned long, long, ppc_cpu_t, const char **);
69static unsigned long insert_li (unsigned long, long, int, const char **); 68static long extract_fxm (unsigned long, ppc_cpu_t, int *);
70static long extract_li (unsigned long, int, int *); 69static unsigned long insert_li20 (unsigned long, long, ppc_cpu_t, const char **);
71static unsigned long insert_mbe (unsigned long, long, int, const char **); 70static long extract_li20 (unsigned long, ppc_cpu_t, int *);
72static long extract_mbe (unsigned long, int, int *); 71static unsigned long insert_ls (unsigned long, long, ppc_cpu_t, const char **);
73static unsigned long insert_mb6 (unsigned long, long, int, const char **); 72static unsigned long insert_mbe (unsigned long, long, ppc_cpu_t, const char **);
74static long extract_mb6 (unsigned long, int, int *); 73static long extract_mbe (unsigned long, ppc_cpu_t, int *);
75static unsigned long insert_nb (unsigned long, long, int, const char **); 74static unsigned long insert_mb6 (unsigned long, long, ppc_cpu_t, const char **);
76static long extract_nb (unsigned long, int, int *); 75static long extract_mb6 (unsigned long, ppc_cpu_t, int *);
77static unsigned long insert_nsi (unsigned long, long, int, const char **); 76static long extract_nb (unsigned long, ppc_cpu_t, int *);
78static long extract_nsi (unsigned long, int, int *); 77static unsigned long insert_nbi (unsigned long, long, ppc_cpu_t, const char **);
79static unsigned long insert_ral (unsigned long, long, int, const char **); 78static unsigned long insert_nsi (unsigned long, long, ppc_cpu_t, const char **);
80static unsigned long insert_ram (unsigned long, long, int, const char **); 79static long extract_nsi (unsigned long, ppc_cpu_t, int *);
81static unsigned long insert_raq (unsigned long, long, int, const char **); 80static unsigned long insert_oimm (unsigned long, long, ppc_cpu_t, const char **);
82static unsigned long insert_ras (unsigned long, long, int, const char **); 81static long extract_oimm (unsigned long, ppc_cpu_t, int *);
83static unsigned long insert_rbs (unsigned long, long, int, const char **); 82static unsigned long insert_ral (unsigned long, long, ppc_cpu_t, const char **);
84static long extract_rbs (unsigned long, int, int *); 83static unsigned long insert_ram (unsigned long, long, ppc_cpu_t, const char **);
85static unsigned long insert_rsq (unsigned long, long, int, const char **); 84static unsigned long insert_raq (unsigned long, long, ppc_cpu_t, const char **);
86static unsigned long insert_rtq (unsigned long, long, int, const char **); 85static unsigned long insert_ras (unsigned long, long, ppc_cpu_t, const char **);
87static unsigned long insert_sh6 (unsigned long, long, int, const char **); 86static unsigned long insert_rbs (unsigned long, long, ppc_cpu_t, const char **);
88static long extract_sh6 (unsigned long, int, int *); 87static long extract_rbs (unsigned long, ppc_cpu_t, int *);
89static unsigned long insert_spr (unsigned long, long, int, const char **); 88static unsigned long insert_rbx (unsigned long, long, ppc_cpu_t, const char **);
90static long extract_spr (unsigned long, int, int *); 89static unsigned long insert_rx (unsigned long, long, ppc_cpu_t, const char **);
91static unsigned long insert_sprg (unsigned long, long, int, const char **); 90static long extract_rx (unsigned long, ppc_cpu_t, int *);
92static long extract_sprg (unsigned long, int, int *); 91static unsigned long insert_ry (unsigned long, long, ppc_cpu_t, const char **);
93static unsigned long insert_tbr (unsigned long, long, int, const char **); 92static long extract_ry (unsigned long, ppc_cpu_t, int *);
94static long extract_tbr (unsigned long, int, int *); 93static unsigned long insert_sh6 (unsigned long, long, ppc_cpu_t, const char **);
95static unsigned long insert_ev2 (unsigned long, long, int, const char **); 94static long extract_sh6 (unsigned long, ppc_cpu_t, int *);
96static long extract_ev2 (unsigned long, int, int *); 95static unsigned long insert_sci8 (unsigned long, long, ppc_cpu_t, const char **);
97static unsigned long insert_ev4 (unsigned long, long, int, const char **); 96static long extract_sci8 (unsigned long, ppc_cpu_t, int *);
98static long extract_ev4 (unsigned long, int, int *); 97static unsigned long insert_sci8n (unsigned long, long, ppc_cpu_t, const char **);
99static unsigned long insert_ev8 (unsigned long, long, int, const char **); 98static long extract_sci8n (unsigned long, ppc_cpu_t, int *);
100static long extract_ev8 (unsigned long, int, int *); 99static unsigned long insert_sd4h (unsigned long, long, ppc_cpu_t, const char **);
100static long extract_sd4h (unsigned long, ppc_cpu_t, int *);
101static unsigned long insert_sd4w (unsigned long, long, ppc_cpu_t, const char **);
102static long extract_sd4w (unsigned long, ppc_cpu_t, int *);
103static unsigned long insert_spr (unsigned long, long, ppc_cpu_t, const char **);
104static long extract_spr (unsigned long, ppc_cpu_t, int *);
105static unsigned long insert_sprg (unsigned long, long, ppc_cpu_t, const char **);
106static long extract_sprg (unsigned long, ppc_cpu_t, int *);
107static unsigned long insert_tbr (unsigned long, long, ppc_cpu_t, const char **);
108static long extract_tbr (unsigned long, ppc_cpu_t, int *);
109static unsigned long insert_xt6 (unsigned long, long, ppc_cpu_t, const char **);
110static long extract_xt6 (unsigned long, ppc_cpu_t, int *);
111static unsigned long insert_xtq6 (unsigned long, long, ppc_cpu_t, const char **);
112static long extract_xtq6 (unsigned long, ppc_cpu_t, int *);
113static unsigned long insert_xa6 (unsigned long, long, ppc_cpu_t, const char **);
114static long extract_xa6 (unsigned long, ppc_cpu_t, int *);
115static unsigned long insert_xb6 (unsigned long, long, ppc_cpu_t, const char **);
116static long extract_xb6 (unsigned long, ppc_cpu_t, int *);
117static unsigned long insert_xb6s (unsigned long, long, ppc_cpu_t, const char **);
118static long extract_xb6s (unsigned long, ppc_cpu_t, int *);
119static unsigned long insert_xc6 (unsigned long, long, ppc_cpu_t, const char **);
120static long extract_xc6 (unsigned long, ppc_cpu_t, int *);
121static unsigned long insert_dm (unsigned long, long, ppc_cpu_t, const char **);
122static long extract_dm (unsigned long, ppc_cpu_t, int *);
123static unsigned long insert_vlesi (unsigned long, long, ppc_cpu_t, const char **);
124static long extract_vlesi (unsigned long, ppc_cpu_t, int *);
125static unsigned long insert_vlensi (unsigned long, long, ppc_cpu_t, const char **);
126static long extract_vlensi (unsigned long, ppc_cpu_t, int *);
127static unsigned long insert_vleui (unsigned long, long, ppc_cpu_t, const char **);
128static long extract_vleui (unsigned long, ppc_cpu_t, int *);
129static unsigned long insert_vleil (unsigned long, long, ppc_cpu_t, const char **);
130static long extract_vleil (unsigned long, ppc_cpu_t, int *);
101 131
102/* The operands table. 132/* The operands table.
103 133
104 The fields are bits, shift, insert, extract, flags. 134 The fields are bitm, shift, insert, extract, flags.
105 135
106 We used to put parens around the various additions, like the one 136 We used to put parens around the various additions, like the one
107 for BA just below. However, that caused trouble with feeble 137 for BA just below. However, that caused trouble with feeble
@@ -119,493 +149,934 @@ const struct powerpc_operand powerpc_operands[] =
119 149
120 /* The BA field in an XL form instruction. */ 150 /* The BA field in an XL form instruction. */
121#define BA UNUSED + 1 151#define BA UNUSED + 1
122#define BA_MASK (0x1f << 16) 152 /* The BI field in a B form or XL form instruction. */
123 { 5, 16, NULL, NULL, PPC_OPERAND_CR }, 153#define BI BA
154#define BI_MASK (0x1f << 16)
155 { 0x1f, 16, NULL, NULL, PPC_OPERAND_CR_BIT },
124 156
125 /* The BA field in an XL form instruction when it must be the same 157 /* The BA field in an XL form instruction when it must be the same
126 as the BT field in the same instruction. */ 158 as the BT field in the same instruction. */
127#define BAT BA + 1 159#define BAT BA + 1
128 { 5, 16, insert_bat, extract_bat, PPC_OPERAND_FAKE }, 160 { 0x1f, 16, insert_bat, extract_bat, PPC_OPERAND_FAKE },
129 161
130 /* The BB field in an XL form instruction. */ 162 /* The BB field in an XL form instruction. */
131#define BB BAT + 1 163#define BB BAT + 1
132#define BB_MASK (0x1f << 11) 164#define BB_MASK (0x1f << 11)
133 { 5, 11, NULL, NULL, PPC_OPERAND_CR }, 165 { 0x1f, 11, NULL, NULL, PPC_OPERAND_CR_BIT },
134 166
135 /* The BB field in an XL form instruction when it must be the same 167 /* The BB field in an XL form instruction when it must be the same
136 as the BA field in the same instruction. */ 168 as the BA field in the same instruction. */
137#define BBA BB + 1 169#define BBA BB + 1
138 { 5, 11, insert_bba, extract_bba, PPC_OPERAND_FAKE }, 170 /* The VB field in a VX form instruction when it must be the same
171 as the VA field in the same instruction. */
172#define VBA BBA
173 { 0x1f, 11, insert_bba, extract_bba, PPC_OPERAND_FAKE },
139 174
140 /* The BD field in a B form instruction. The lower two bits are 175 /* The BD field in a B form instruction. The lower two bits are
141 forced to zero. */ 176 forced to zero. */
142#define BD BBA + 1 177#define BD BBA + 1
143 { 16, 0, insert_bd, extract_bd, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 178 { 0xfffc, 0, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
144 179
145 /* The BD field in a B form instruction when absolute addressing is 180 /* The BD field in a B form instruction when absolute addressing is
146 used. */ 181 used. */
147#define BDA BD + 1 182#define BDA BD + 1
148 { 16, 0, insert_bd, extract_bd, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 183 { 0xfffc, 0, NULL, NULL, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
149 184
150 /* The BD field in a B form instruction when the - modifier is used. 185 /* The BD field in a B form instruction when the - modifier is used.
151 This sets the y bit of the BO field appropriately. */ 186 This sets the y bit of the BO field appropriately. */
152#define BDM BDA + 1 187#define BDM BDA + 1
153 { 16, 0, insert_bdm, extract_bdm, 188 { 0xfffc, 0, insert_bdm, extract_bdm,
154 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 189 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
155 190
156 /* The BD field in a B form instruction when the - modifier is used 191 /* The BD field in a B form instruction when the - modifier is used
157 and absolute address is used. */ 192 and absolute address is used. */
158#define BDMA BDM + 1 193#define BDMA BDM + 1
159 { 16, 0, insert_bdm, extract_bdm, 194 { 0xfffc, 0, insert_bdm, extract_bdm,
160 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 195 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
161 196
162 /* The BD field in a B form instruction when the + modifier is used. 197 /* The BD field in a B form instruction when the + modifier is used.
163 This sets the y bit of the BO field appropriately. */ 198 This sets the y bit of the BO field appropriately. */
164#define BDP BDMA + 1 199#define BDP BDMA + 1
165 { 16, 0, insert_bdp, extract_bdp, 200 { 0xfffc, 0, insert_bdp, extract_bdp,
166 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 201 PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
167 202
168 /* The BD field in a B form instruction when the + modifier is used 203 /* The BD field in a B form instruction when the + modifier is used
169 and absolute addressing is used. */ 204 and absolute addressing is used. */
170#define BDPA BDP + 1 205#define BDPA BDP + 1
171 { 16, 0, insert_bdp, extract_bdp, 206 { 0xfffc, 0, insert_bdp, extract_bdp,
172 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 207 PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
173 208
174 /* The BF field in an X or XL form instruction. */ 209 /* The BF field in an X or XL form instruction. */
175#define BF BDPA + 1 210#define BF BDPA + 1
176 { 3, 23, NULL, NULL, PPC_OPERAND_CR }, 211 /* The CRFD field in an X form instruction. */
212#define CRFD BF
213 /* The CRD field in an XL form instruction. */
214#define CRD BF
215 { 0x7, 23, NULL, NULL, PPC_OPERAND_CR_REG },
216
217 /* The BF field in an X or XL form instruction. */
218#define BFF BF + 1
219 { 0x7, 23, NULL, NULL, 0 },
177 220
178 /* An optional BF field. This is used for comparison instructions, 221 /* An optional BF field. This is used for comparison instructions,
179 in which an omitted BF field is taken as zero. */ 222 in which an omitted BF field is taken as zero. */
180#define OBF BF + 1 223#define OBF BFF + 1
181 { 3, 23, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, 224 { 0x7, 23, NULL, NULL, PPC_OPERAND_CR_REG | PPC_OPERAND_OPTIONAL },
182 225
183 /* The BFA field in an X or XL form instruction. */ 226 /* The BFA field in an X or XL form instruction. */
184#define BFA OBF + 1 227#define BFA OBF + 1
185 { 3, 18, NULL, NULL, PPC_OPERAND_CR }, 228 { 0x7, 18, NULL, NULL, PPC_OPERAND_CR_REG },
186
187 /* The BI field in a B form or XL form instruction. */
188#define BI BFA + 1
189#define BI_MASK (0x1f << 16)
190 { 5, 16, NULL, NULL, PPC_OPERAND_CR },
191 229
192 /* The BO field in a B form instruction. Certain values are 230 /* The BO field in a B form instruction. Certain values are
193 illegal. */ 231 illegal. */
194#define BO BI + 1 232#define BO BFA + 1
195#define BO_MASK (0x1f << 21) 233#define BO_MASK (0x1f << 21)
196 { 5, 21, insert_bo, extract_bo, 0 }, 234 { 0x1f, 21, insert_bo, extract_bo, 0 },
197 235
198 /* The BO field in a B form instruction when the + or - modifier is 236 /* The BO field in a B form instruction when the + or - modifier is
199 used. This is like the BO field, but it must be even. */ 237 used. This is like the BO field, but it must be even. */
200#define BOE BO + 1 238#define BOE BO + 1
201 { 5, 21, insert_boe, extract_boe, 0 }, 239 { 0x1e, 21, insert_boe, extract_boe, 0 },
240
241 /* The RM field in an X form instruction. */
242#define RM BOE + 1
243 { 0x3, 11, NULL, NULL, 0 },
202 244
203#define BH BOE + 1 245#define BH RM + 1
204 { 2, 11, NULL, NULL, PPC_OPERAND_OPTIONAL }, 246 { 0x3, 11, NULL, NULL, PPC_OPERAND_OPTIONAL },
205 247
206 /* The BT field in an X or XL form instruction. */ 248 /* The BT field in an X or XL form instruction. */
207#define BT BH + 1 249#define BT BH + 1
208 { 5, 21, NULL, NULL, PPC_OPERAND_CR }, 250 { 0x1f, 21, NULL, NULL, PPC_OPERAND_CR_BIT },
251
252 /* The BI16 field in a BD8 form instruction. */
253#define BI16 BT + 1
254 { 0x3, 8, NULL, NULL, PPC_OPERAND_CR_BIT },
255
256 /* The BI32 field in a BD15 form instruction. */
257#define BI32 BI16 + 1
258 { 0xf, 16, NULL, NULL, PPC_OPERAND_CR_BIT },
259
260 /* The BO32 field in a BD15 form instruction. */
261#define BO32 BI32 + 1
262 { 0x3, 20, NULL, NULL, 0 },
263
264 /* The B8 field in a BD8 form instruction. */
265#define B8 BO32 + 1
266 { 0x1fe, -1, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
267
268 /* The B15 field in a BD15 form instruction. The lowest bit is
269 forced to zero. */
270#define B15 B8 + 1
271 { 0xfffe, 0, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
272
273 /* The B24 field in a BD24 form instruction. The lowest bit is
274 forced to zero. */
275#define B24 B15 + 1
276 { 0x1fffffe, 0, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
209 277
210 /* The condition register number portion of the BI field in a B form 278 /* The condition register number portion of the BI field in a B form
211 or XL form instruction. This is used for the extended 279 or XL form instruction. This is used for the extended
212 conditional branch mnemonics, which set the lower two bits of the 280 conditional branch mnemonics, which set the lower two bits of the
213 BI field. This field is optional. */ 281 BI field. This field is optional. */
214#define CR BT + 1 282#define CR B24 + 1
215 { 3, 18, NULL, NULL, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, 283 { 0x7, 18, NULL, NULL, PPC_OPERAND_CR_REG | PPC_OPERAND_OPTIONAL },
216 284
217 /* The CRB field in an X form instruction. */ 285 /* The CRB field in an X form instruction. */
218#define CRB CR + 1 286#define CRB CR + 1
219 { 5, 6, NULL, NULL, 0 }, 287 /* The MB field in an M form instruction. */
288#define MB CRB
289#define MB_MASK (0x1f << 6)
290 { 0x1f, 6, NULL, NULL, 0 },
220 291
221 /* The CRFD field in an X form instruction. */ 292 /* The CRD32 field in an XL form instruction. */
222#define CRFD CRB + 1 293#define CRD32 CRB + 1
223 { 3, 23, NULL, NULL, PPC_OPERAND_CR }, 294 { 0x3, 21, NULL, NULL, PPC_OPERAND_CR_REG },
224 295
225 /* The CRFS field in an X form instruction. */ 296 /* The CRFS field in an X form instruction. */
226#define CRFS CRFD + 1 297#define CRFS CRD32 + 1
227 { 3, 0, NULL, NULL, PPC_OPERAND_CR }, 298 { 0x7, 0, NULL, NULL, PPC_OPERAND_CR_REG },
299
300#define CRS CRFS + 1
301 { 0x3, 18, NULL, NULL, PPC_OPERAND_CR_REG | PPC_OPERAND_OPTIONAL },
228 302
229 /* The CT field in an X form instruction. */ 303 /* The CT field in an X form instruction. */
230#define CT CRFS + 1 304#define CT CRS + 1
231 { 5, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 305 /* The MO field in an mbar instruction. */
306#define MO CT
307 { 0x1f, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
232 308
233 /* The D field in a D form instruction. This is a displacement off 309 /* The D field in a D form instruction. This is a displacement off
234 a register, and implies that the next operand is a register in 310 a register, and implies that the next operand is a register in
235 parentheses. */ 311 parentheses. */
236#define D CT + 1 312#define D CT + 1
237 { 16, 0, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED }, 313 { 0xffff, 0, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
238 314
239 /* The DE field in a DE form instruction. This is like D, but is 12 315 /* The D8 field in a D form instruction. This is a displacement off
240 bits only. */ 316 a register, and implies that the next operand is a register in
241#define DE D + 1 317 parentheses. */
242 { 14, 0, insert_de, extract_de, PPC_OPERAND_PARENS }, 318#define D8 D + 1
319 { 0xff, 0, NULL, NULL, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
320
321 /* The DCMX field in an X form instruction. */
322#define DCMX D8 + 1
323 { 0x7f, 16, NULL, NULL, 0 },
243 324
244 /* The DES field in a DES form instruction. This is like DS, but is 14 325 /* The split DCMX field in an X form instruction. */
245 bits only (12 stored.) */ 326#define DCMXS DCMX + 1
246#define DES DE + 1 327 { 0x7f, PPC_OPSHIFT_INV, insert_dcmxs, extract_dcmxs, 0 },
247 { 14, 0, insert_des, extract_des, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
248 328
249 /* The DQ field in a DQ form instruction. This is like D, but the 329 /* The DQ field in a DQ form instruction. This is like D, but the
250 lower four bits are forced to zero. */ 330 lower four bits are forced to zero. */
251#define DQ DES + 1 331#define DQ DCMXS + 1
252 { 16, 0, insert_dq, extract_dq, 332 { 0xfff0, 0, NULL, NULL,
253 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DQ }, 333 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DQ },
254 334
255 /* The DS field in a DS form instruction. This is like D, but the 335 /* The DS field in a DS form instruction. This is like D, but the
256 lower two bits are forced to zero. */ 336 lower two bits are forced to zero. */
257#define DS DQ + 1 337#define DS DQ + 1
258 { 16, 0, insert_ds, extract_ds, 338 { 0xfffc, 0, NULL, NULL,
259 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DS }, 339 PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DS },
340
341 /* The DUIS or BHRBE fields in a XFX form instruction, 10 bits
342 unsigned imediate */
343#define DUIS DS + 1
344#define BHRBE DUIS
345 { 0x3ff, 11, NULL, NULL, 0 },
346
347 /* The split D field in a DX form instruction. */
348#define DXD DUIS + 1
349 { 0xffff, PPC_OPSHIFT_INV, insert_dxd, extract_dxd,
350 PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT},
351
352 /* The split ND field in a DX form instruction.
353 This is the same as the DX field, only negated. */
354#define NDXD DXD + 1
355 { 0xffff, PPC_OPSHIFT_INV, insert_dxdn, extract_dxdn,
356 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT},
260 357
261 /* The E field in a wrteei instruction. */ 358 /* The E field in a wrteei instruction. */
262#define E DS + 1 359 /* And the W bit in the pair singles instructions. */
263 { 1, 15, NULL, NULL, 0 }, 360 /* And the ST field in a VX form instruction. */
361#define E NDXD + 1
362#define PSW E
363#define ST E
364 { 0x1, 15, NULL, NULL, 0 },
264 365
265 /* The FL1 field in a POWER SC form instruction. */ 366 /* The FL1 field in a POWER SC form instruction. */
266#define FL1 E + 1 367#define FL1 E + 1
267 { 4, 12, NULL, NULL, 0 }, 368 /* The U field in an X form instruction. */
369#define U FL1
370 { 0xf, 12, NULL, NULL, 0 },
268 371
269 /* The FL2 field in a POWER SC form instruction. */ 372 /* The FL2 field in a POWER SC form instruction. */
270#define FL2 FL1 + 1 373#define FL2 FL1 + 1
271 { 3, 2, NULL, NULL, 0 }, 374 { 0x7, 2, NULL, NULL, 0 },
272 375
273 /* The FLM field in an XFL form instruction. */ 376 /* The FLM field in an XFL form instruction. */
274#define FLM FL2 + 1 377#define FLM FL2 + 1
275 { 8, 17, NULL, NULL, 0 }, 378 { 0xff, 17, NULL, NULL, 0 },
276 379
277 /* The FRA field in an X or A form instruction. */ 380 /* The FRA field in an X or A form instruction. */
278#define FRA FLM + 1 381#define FRA FLM + 1
279#define FRA_MASK (0x1f << 16) 382#define FRA_MASK (0x1f << 16)
280 { 5, 16, NULL, NULL, PPC_OPERAND_FPR }, 383 { 0x1f, 16, NULL, NULL, PPC_OPERAND_FPR },
384
385 /* The FRAp field of DFP instructions. */
386#define FRAp FRA + 1
387 { 0x1e, 16, NULL, NULL, PPC_OPERAND_FPR },
281 388
282 /* The FRB field in an X or A form instruction. */ 389 /* The FRB field in an X or A form instruction. */
283#define FRB FRA + 1 390#define FRB FRAp + 1
284#define FRB_MASK (0x1f << 11) 391#define FRB_MASK (0x1f << 11)
285 { 5, 11, NULL, NULL, PPC_OPERAND_FPR }, 392 { 0x1f, 11, NULL, NULL, PPC_OPERAND_FPR },
393
394 /* The FRBp field of DFP instructions. */
395#define FRBp FRB + 1
396 { 0x1e, 11, NULL, NULL, PPC_OPERAND_FPR },
286 397
287 /* The FRC field in an A form instruction. */ 398 /* The FRC field in an A form instruction. */
288#define FRC FRB + 1 399#define FRC FRBp + 1
289#define FRC_MASK (0x1f << 6) 400#define FRC_MASK (0x1f << 6)
290 { 5, 6, NULL, NULL, PPC_OPERAND_FPR }, 401 { 0x1f, 6, NULL, NULL, PPC_OPERAND_FPR },
291 402
292 /* The FRS field in an X form instruction or the FRT field in a D, X 403 /* The FRS field in an X form instruction or the FRT field in a D, X
293 or A form instruction. */ 404 or A form instruction. */
294#define FRS FRC + 1 405#define FRS FRC + 1
295#define FRT FRS 406#define FRT FRS
296 { 5, 21, NULL, NULL, PPC_OPERAND_FPR }, 407 { 0x1f, 21, NULL, NULL, PPC_OPERAND_FPR },
408
409 /* The FRSp field of stfdp or the FRTp field of lfdp and DFP
410 instructions. */
411#define FRSp FRS + 1
412#define FRTp FRSp
413 { 0x1e, 21, NULL, NULL, PPC_OPERAND_FPR },
297 414
298 /* The FXM field in an XFX instruction. */ 415 /* The FXM field in an XFX instruction. */
299#define FXM FRS + 1 416#define FXM FRSp + 1
300#define FXM_MASK (0xff << 12) 417 { 0xff, 12, insert_fxm, extract_fxm, 0 },
301 { 8, 12, insert_fxm, extract_fxm, 0 },
302 418
303 /* Power4 version for mfcr. */ 419 /* Power4 version for mfcr. */
304#define FXM4 FXM + 1 420#define FXM4 FXM + 1
305 { 8, 12, insert_fxm, extract_fxm, PPC_OPERAND_OPTIONAL }, 421 { 0xff, 12, insert_fxm, extract_fxm,
422 PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
423 /* If the FXM4 operand is ommitted, use the sentinel value -1. */
424 { -1, -1, NULL, NULL, 0},
425
426 /* The IMM20 field in an LI instruction. */
427#define IMM20 FXM4 + 2
428 { 0xfffff, PPC_OPSHIFT_INV, insert_li20, extract_li20, PPC_OPERAND_SIGNED},
306 429
307 /* The L field in a D or X form instruction. */ 430 /* The L field in a D or X form instruction. */
308#define L FXM4 + 1 431#define L IMM20 + 1
309 { 1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 432 { 0x1, 21, NULL, NULL, 0 },
433
434 /* The optional L field in tlbie and tlbiel instructions. */
435#define LOPT L + 1
436 /* The R field in a HTM X form instruction. */
437#define HTM_R LOPT
438 { 0x1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
439
440 /* The optional (for 32-bit) L field in cmp[l][i] instructions. */
441#define L32OPT LOPT + 1
442 { 0x1, 21, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL32 },
443
444 /* The L field in dcbf instruction. */
445#define L2OPT L32OPT + 1
446 { 0x3, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
310 447
311 /* The LEV field in a POWER SVC form instruction. */ 448 /* The LEV field in a POWER SVC form instruction. */
312#define SVC_LEV L + 1 449#define SVC_LEV L2OPT + 1
313 { 7, 5, NULL, NULL, 0 }, 450 { 0x7f, 5, NULL, NULL, 0 },
314 451
315 /* The LEV field in an SC form instruction. */ 452 /* The LEV field in an SC form instruction. */
316#define LEV SVC_LEV + 1 453#define LEV SVC_LEV + 1
317 { 7, 5, NULL, NULL, PPC_OPERAND_OPTIONAL }, 454 { 0x7f, 5, NULL, NULL, PPC_OPERAND_OPTIONAL },
318 455
319 /* The LI field in an I form instruction. The lower two bits are 456 /* The LI field in an I form instruction. The lower two bits are
320 forced to zero. */ 457 forced to zero. */
321#define LI LEV + 1 458#define LI LEV + 1
322 { 26, 0, insert_li, extract_li, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, 459 { 0x3fffffc, 0, NULL, NULL, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED },
323 460
324 /* The LI field in an I form instruction when used as an absolute 461 /* The LI field in an I form instruction when used as an absolute
325 address. */ 462 address. */
326#define LIA LI + 1 463#define LIA LI + 1
327 { 26, 0, insert_li, extract_li, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, 464 { 0x3fffffc, 0, NULL, NULL, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED },
328 465
329 /* The LS field in an X (sync) form instruction. */ 466 /* The LS or WC field in an X (sync or wait) form instruction. */
330#define LS LIA + 1 467#define LS LIA + 1
331 { 2, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 468#define WC LS
332 469 { 0x3, 21, insert_ls, NULL, PPC_OPERAND_OPTIONAL },
333 /* The MB field in an M form instruction. */
334#define MB LS + 1
335#define MB_MASK (0x1f << 6)
336 { 5, 6, NULL, NULL, 0 },
337 470
338 /* The ME field in an M form instruction. */ 471 /* The ME field in an M form instruction. */
339#define ME MB + 1 472#define ME LS + 1
340#define ME_MASK (0x1f << 1) 473#define ME_MASK (0x1f << 1)
341 { 5, 1, NULL, NULL, 0 }, 474 { 0x1f, 1, NULL, NULL, 0 },
342 475
343 /* The MB and ME fields in an M form instruction expressed a single 476 /* The MB and ME fields in an M form instruction expressed a single
344 operand which is a bitmask indicating which bits to select. This 477 operand which is a bitmask indicating which bits to select. This
345 is a two operand form using PPC_OPERAND_NEXT. See the 478 is a two operand form using PPC_OPERAND_NEXT. See the
346 description in opcode/ppc.h for what this means. */ 479 description in opcode/ppc.h for what this means. */
347#define MBE ME + 1 480#define MBE ME + 1
348 { 5, 6, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT }, 481 { 0x1f, 6, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT },
349 { 32, 0, insert_mbe, extract_mbe, 0 }, 482 { -1, 0, insert_mbe, extract_mbe, 0 },
350 483
351 /* The MB or ME field in an MD or MDS form instruction. The high 484 /* The MB or ME field in an MD or MDS form instruction. The high
352 bit is wrapped to the low end. */ 485 bit is wrapped to the low end. */
353#define MB6 MBE + 2 486#define MB6 MBE + 2
354#define ME6 MB6 487#define ME6 MB6
355#define MB6_MASK (0x3f << 5) 488#define MB6_MASK (0x3f << 5)
356 { 6, 5, insert_mb6, extract_mb6, 0 }, 489 { 0x3f, 5, insert_mb6, extract_mb6, 0 },
357
358 /* The MO field in an mbar instruction. */
359#define MO MB6 + 1
360 { 5, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
361 490
362 /* The NB field in an X form instruction. The value 32 is stored as 491 /* The NB field in an X form instruction. The value 32 is stored as
363 0. */ 492 0. */
364#define NB MO + 1 493#define NB MB6 + 1
365 { 6, 11, insert_nb, extract_nb, 0 }, 494 { 0x1f, 11, NULL, extract_nb, PPC_OPERAND_PLUS1 },
495
496 /* The NBI field in an lswi instruction, which has special value
497 restrictions. The value 32 is stored as 0. */
498#define NBI NB + 1
499 { 0x1f, 11, insert_nbi, extract_nb, PPC_OPERAND_PLUS1 },
366 500
367 /* The NSI field in a D form instruction. This is the same as the 501 /* The NSI field in a D form instruction. This is the same as the
368 SI field, only negated. */ 502 SI field, only negated. */
369#define NSI NB + 1 503#define NSI NBI + 1
370 { 16, 0, insert_nsi, extract_nsi, 504 { 0xffff, 0, insert_nsi, extract_nsi,
371 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED }, 505 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED },
506
507 /* The NSI field in a D form instruction when we accept a wide range
508 of positive values. */
509#define NSISIGNOPT NSI + 1
510 { 0xffff, 0, insert_nsi, extract_nsi,
511 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },
372 512
373 /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction. */ 513 /* The RA field in an D, DS, DQ, X, XO, M, or MDS form instruction. */
374#define RA NSI + 1 514#define RA NSISIGNOPT + 1
375#define RA_MASK (0x1f << 16) 515#define RA_MASK (0x1f << 16)
376 { 5, 16, NULL, NULL, PPC_OPERAND_GPR }, 516 { 0x1f, 16, NULL, NULL, PPC_OPERAND_GPR },
377 517
378 /* As above, but 0 in the RA field means zero, not r0. */ 518 /* As above, but 0 in the RA field means zero, not r0. */
379#define RA0 RA + 1 519#define RA0 RA + 1
380 { 5, 16, NULL, NULL, PPC_OPERAND_GPR_0 }, 520 { 0x1f, 16, NULL, NULL, PPC_OPERAND_GPR_0 },
381 521
382 /* The RA field in the DQ form lq instruction, which has special 522 /* The RA field in the DQ form lq or an lswx instruction, which have special
383 value restrictions. */ 523 value restrictions. */
384#define RAQ RA0 + 1 524#define RAQ RA0 + 1
385 { 5, 16, insert_raq, NULL, PPC_OPERAND_GPR_0 }, 525#define RAX RAQ
526 { 0x1f, 16, insert_raq, NULL, PPC_OPERAND_GPR_0 },
386 527
387 /* The RA field in a D or X form instruction which is an updating 528 /* The RA field in a D or X form instruction which is an updating
388 load, which means that the RA field may not be zero and may not 529 load, which means that the RA field may not be zero and may not
389 equal the RT field. */ 530 equal the RT field. */
390#define RAL RAQ + 1 531#define RAL RAQ + 1
391 { 5, 16, insert_ral, NULL, PPC_OPERAND_GPR_0 }, 532 { 0x1f, 16, insert_ral, NULL, PPC_OPERAND_GPR_0 },
392 533
393 /* The RA field in an lmw instruction, which has special value 534 /* The RA field in an lmw instruction, which has special value
394 restrictions. */ 535 restrictions. */
395#define RAM RAL + 1 536#define RAM RAL + 1
396 { 5, 16, insert_ram, NULL, PPC_OPERAND_GPR_0 }, 537 { 0x1f, 16, insert_ram, NULL, PPC_OPERAND_GPR_0 },
397 538
398 /* The RA field in a D or X form instruction which is an updating 539 /* The RA field in a D or X form instruction which is an updating
399 store or an updating floating point load, which means that the RA 540 store or an updating floating point load, which means that the RA
400 field may not be zero. */ 541 field may not be zero. */
401#define RAS RAM + 1 542#define RAS RAM + 1
402 { 5, 16, insert_ras, NULL, PPC_OPERAND_GPR_0 }, 543 { 0x1f, 16, insert_ras, NULL, PPC_OPERAND_GPR_0 },
403 544
404 /* The RA field of the tlbwe instruction, which is optional. */ 545 /* The RA field of the tlbwe, dccci and iccci instructions,
546 which are optional. */
405#define RAOPT RAS + 1 547#define RAOPT RAS + 1
406 { 5, 16, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL }, 548 { 0x1f, 16, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL },
407 549
408 /* The RB field in an X, XO, M, or MDS form instruction. */ 550 /* The RB field in an X, XO, M, or MDS form instruction. */
409#define RB RAOPT + 1 551#define RB RAOPT + 1
410#define RB_MASK (0x1f << 11) 552#define RB_MASK (0x1f << 11)
411 { 5, 11, NULL, NULL, PPC_OPERAND_GPR }, 553 { 0x1f, 11, NULL, NULL, PPC_OPERAND_GPR },
412 554
413 /* The RB field in an X form instruction when it must be the same as 555 /* The RB field in an X form instruction when it must be the same as
414 the RS field in the instruction. This is used for extended 556 the RS field in the instruction. This is used for extended
415 mnemonics like mr. */ 557 mnemonics like mr. */
416#define RBS RB + 1 558#define RBS RB + 1
417 { 5, 1, insert_rbs, extract_rbs, PPC_OPERAND_FAKE }, 559 { 0x1f, 11, insert_rbs, extract_rbs, PPC_OPERAND_FAKE },
560
561 /* The RB field in an lswx instruction, which has special value
562 restrictions. */
563#define RBX RBS + 1
564 { 0x1f, 11, insert_rbx, NULL, PPC_OPERAND_GPR },
565
566 /* The RB field of the dccci and iccci instructions, which are optional. */
567#define RBOPT RBX + 1
568 { 0x1f, 11, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL },
569
570 /* The RC register field in an maddld, maddhd or maddhdu instruction. */
571#define RC RBOPT + 1
572 { 0x1f, 6, NULL, NULL, PPC_OPERAND_GPR },
418 573
419 /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form 574 /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form
420 instruction or the RT field in a D, DS, X, XFX or XO form 575 instruction or the RT field in a D, DS, X, XFX or XO form
421 instruction. */ 576 instruction. */
422#define RS RBS + 1 577#define RS RC + 1
423#define RT RS 578#define RT RS
424#define RT_MASK (0x1f << 21) 579#define RT_MASK (0x1f << 21)
425 { 5, 21, NULL, NULL, PPC_OPERAND_GPR }, 580#define RD RS
581 { 0x1f, 21, NULL, NULL, PPC_OPERAND_GPR },
426 582
427 /* The RS field of the DS form stq instruction, which has special 583 /* The RS and RT fields of the DS form stq and DQ form lq instructions,
428 value restrictions. */ 584 which have special value restrictions. */
429#define RSQ RS + 1 585#define RSQ RS + 1
430 { 5, 21, insert_rsq, NULL, PPC_OPERAND_GPR_0 }, 586#define RTQ RSQ
431 587 { 0x1e, 21, NULL, NULL, PPC_OPERAND_GPR },
432 /* The RT field of the DQ form lq instruction, which has special
433 value restrictions. */
434#define RTQ RSQ + 1
435 { 5, 21, insert_rtq, NULL, PPC_OPERAND_GPR_0 },
436 588
437 /* The RS field of the tlbwe instruction, which is optional. */ 589 /* The RS field of the tlbwe instruction, which is optional. */
438#define RSO RTQ + 1 590#define RSO RSQ + 1
439#define RTO RSO 591#define RTO RSO
440 { 5, 21, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL }, 592 { 0x1f, 21, NULL, NULL, PPC_OPERAND_GPR | PPC_OPERAND_OPTIONAL },
593
594 /* The RX field of the SE_RR form instruction. */
595#define RX RSO + 1
596 { 0x1f, PPC_OPSHIFT_INV, insert_rx, extract_rx, PPC_OPERAND_GPR },
597
598 /* The ARX field of the SE_RR form instruction. */
599#define ARX RX + 1
600 { 0x1f, PPC_OPSHIFT_INV, insert_arx, extract_arx, PPC_OPERAND_GPR },
601
602 /* The RY field of the SE_RR form instruction. */
603#define RY ARX + 1
604#define RZ RY
605 { 0x1f, PPC_OPSHIFT_INV, insert_ry, extract_ry, PPC_OPERAND_GPR },
606
607 /* The ARY field of the SE_RR form instruction. */
608#define ARY RY + 1
609 { 0x1f, PPC_OPSHIFT_INV, insert_ary, extract_ary, PPC_OPERAND_GPR },
610
611 /* The SCLSCI8 field in a D form instruction. */
612#define SCLSCI8 ARY + 1
613 { 0xffffffff, PPC_OPSHIFT_INV, insert_sci8, extract_sci8, 0 },
614
615 /* The SCLSCI8N field in a D form instruction. This is the same as the
616 SCLSCI8 field, only negated. */
617#define SCLSCI8N SCLSCI8 + 1
618 { 0xffffffff, PPC_OPSHIFT_INV, insert_sci8n, extract_sci8n,
619 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED },
620
621 /* The SD field of the SD4 form instruction. */
622#define SE_SD SCLSCI8N + 1
623 { 0xf, 8, NULL, NULL, PPC_OPERAND_PARENS },
624
625 /* The SD field of the SD4 form instruction, for halfword. */
626#define SE_SDH SE_SD + 1
627 { 0x1e, PPC_OPSHIFT_INV, insert_sd4h, extract_sd4h, PPC_OPERAND_PARENS },
628
629 /* The SD field of the SD4 form instruction, for word. */
630#define SE_SDW SE_SDH + 1
631 { 0x3c, PPC_OPSHIFT_INV, insert_sd4w, extract_sd4w, PPC_OPERAND_PARENS },
441 632
442 /* The SH field in an X or M form instruction. */ 633 /* The SH field in an X or M form instruction. */
443#define SH RSO + 1 634#define SH SE_SDW + 1
444#define SH_MASK (0x1f << 11) 635#define SH_MASK (0x1f << 11)
445 { 5, 11, NULL, NULL, 0 }, 636 /* The other UIMM field in a EVX form instruction. */
637#define EVUIMM SH
638 /* The FC field in an atomic X form instruction. */
639#define FC SH
640 { 0x1f, 11, NULL, NULL, 0 },
641
642 /* The SI field in a HTM X form instruction. */
643#define HTM_SI SH + 1
644 { 0x1f, 11, NULL, NULL, PPC_OPERAND_SIGNED },
446 645
447 /* The SH field in an MD form instruction. This is split. */ 646 /* The SH field in an MD form instruction. This is split. */
448#define SH6 SH + 1 647#define SH6 HTM_SI + 1
449#define SH6_MASK ((0x1f << 11) | (1 << 1)) 648#define SH6_MASK ((0x1f << 11) | (1 << 1))
450 { 6, 1, insert_sh6, extract_sh6, 0 }, 649 { 0x3f, PPC_OPSHIFT_INV, insert_sh6, extract_sh6, 0 },
451 650
452 /* The SH field of the tlbwe instruction, which is optional. */ 651 /* The SH field of the tlbwe instruction, which is optional. */
453#define SHO SH6 + 1 652#define SHO SH6 + 1
454 { 5, 11,NULL, NULL, PPC_OPERAND_OPTIONAL }, 653 { 0x1f, 11, NULL, NULL, PPC_OPERAND_OPTIONAL },
455 654
456 /* The SI field in a D form instruction. */ 655 /* The SI field in a D form instruction. */
457#define SI SHO + 1 656#define SI SHO + 1
458 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED }, 657 { 0xffff, 0, NULL, NULL, PPC_OPERAND_SIGNED },
459 658
460 /* The SI field in a D form instruction when we accept a wide range 659 /* The SI field in a D form instruction when we accept a wide range
461 of positive values. */ 660 of positive values. */
462#define SISIGNOPT SI + 1 661#define SISIGNOPT SI + 1
463 { 16, 0, NULL, NULL, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT }, 662 { 0xffff, 0, NULL, NULL, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },
663
664 /* The SI8 field in a D form instruction. */
665#define SI8 SISIGNOPT + 1
666 { 0xff, 0, NULL, NULL, PPC_OPERAND_SIGNED },
464 667
465 /* The SPR field in an XFX form instruction. This is flipped--the 668 /* The SPR field in an XFX form instruction. This is flipped--the
466 lower 5 bits are stored in the upper 5 and vice- versa. */ 669 lower 5 bits are stored in the upper 5 and vice- versa. */
467#define SPR SISIGNOPT + 1 670#define SPR SI8 + 1
468#define PMR SPR 671#define PMR SPR
672#define TMR SPR
469#define SPR_MASK (0x3ff << 11) 673#define SPR_MASK (0x3ff << 11)
470 { 10, 11, insert_spr, extract_spr, 0 }, 674 { 0x3ff, 11, insert_spr, extract_spr, 0 },
471 675
472 /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */ 676 /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */
473#define SPRBAT SPR + 1 677#define SPRBAT SPR + 1
474#define SPRBAT_MASK (0x3 << 17) 678#define SPRBAT_MASK (0x3 << 17)
475 { 2, 17, NULL, NULL, 0 }, 679 { 0x3, 17, NULL, NULL, 0 },
476 680
477 /* The SPRG register number in an XFX form m[ft]sprg instruction. */ 681 /* The SPRG register number in an XFX form m[ft]sprg instruction. */
478#define SPRG SPRBAT + 1 682#define SPRG SPRBAT + 1
479 { 5, 16, insert_sprg, extract_sprg, 0 }, 683 { 0x1f, 16, insert_sprg, extract_sprg, 0 },
480 684
481 /* The SR field in an X form instruction. */ 685 /* The SR field in an X form instruction. */
482#define SR SPRG + 1 686#define SR SPRG + 1
483 { 4, 16, NULL, NULL, 0 }, 687 /* The 4-bit UIMM field in a VX form instruction. */
688#define UIMM4 SR
689 { 0xf, 16, NULL, NULL, 0 },
484 690
485 /* The STRM field in an X AltiVec form instruction. */ 691 /* The STRM field in an X AltiVec form instruction. */
486#define STRM SR + 1 692#define STRM SR + 1
487#define STRM_MASK (0x3 << 21) 693 /* The T field in a tlbilx form instruction. */
488 { 2, 21, NULL, NULL, 0 }, 694#define T STRM
695 /* The L field in wclr instructions. */
696#define L2 STRM
697 { 0x3, 21, NULL, NULL, 0 },
698
699 /* The ESYNC field in an X (sync) form instruction. */
700#define ESYNC STRM + 1
701 { 0xf, 16, insert_esync, NULL, PPC_OPERAND_OPTIONAL },
489 702
490 /* The SV field in a POWER SC form instruction. */ 703 /* The SV field in a POWER SC form instruction. */
491#define SV STRM + 1 704#define SV ESYNC + 1
492 { 14, 2, NULL, NULL, 0 }, 705 { 0x3fff, 2, NULL, NULL, 0 },
493 706
494 /* The TBR field in an XFX form instruction. This is like the SPR 707 /* The TBR field in an XFX form instruction. This is like the SPR
495 field, but it is optional. */ 708 field, but it is optional. */
496#define TBR SV + 1 709#define TBR SV + 1
497 { 10, 11, insert_tbr, extract_tbr, PPC_OPERAND_OPTIONAL }, 710 { 0x3ff, 11, insert_tbr, extract_tbr,
711 PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
712 /* If the TBR operand is ommitted, use the value 268. */
713 { -1, 268, NULL, NULL, 0},
498 714
499 /* The TO field in a D or X form instruction. */ 715 /* The TO field in a D or X form instruction. */
500#define TO TBR + 1 716#define TO TBR + 2
717#define DUI TO
501#define TO_MASK (0x1f << 21) 718#define TO_MASK (0x1f << 21)
502 { 5, 21, NULL, NULL, 0 }, 719 { 0x1f, 21, NULL, NULL, 0 },
503
504 /* The U field in an X form instruction. */
505#define U TO + 1
506 { 4, 12, NULL, NULL, 0 },
507 720
508 /* The UI field in a D form instruction. */ 721 /* The UI field in a D form instruction. */
509#define UI U + 1 722#define UI TO + 1
510 { 16, 0, NULL, NULL, 0 }, 723 { 0xffff, 0, NULL, NULL, 0 },
724
725#define UISIGNOPT UI + 1
726 { 0xffff, 0, NULL, NULL, PPC_OPERAND_SIGNOPT },
727
728 /* The IMM field in an SE_IM5 instruction. */
729#define UI5 UISIGNOPT + 1
730 { 0x1f, 4, NULL, NULL, 0 },
731
732 /* The OIMM field in an SE_OIM5 instruction. */
733#define OIMM5 UI5 + 1
734 { 0x1f, PPC_OPSHIFT_INV, insert_oimm, extract_oimm, PPC_OPERAND_PLUS1 },
735
736 /* The UI7 field in an SE_LI instruction. */
737#define UI7 OIMM5 + 1
738 { 0x7f, 4, NULL, NULL, 0 },
511 739
512 /* The VA field in a VA, VX or VXR form instruction. */ 740 /* The VA field in a VA, VX or VXR form instruction. */
513#define VA UI + 1 741#define VA UI7 + 1
514#define VA_MASK (0x1f << 16) 742 { 0x1f, 16, NULL, NULL, PPC_OPERAND_VR },
515 { 5, 16, NULL, NULL, PPC_OPERAND_VR },
516 743
517 /* The VB field in a VA, VX or VXR form instruction. */ 744 /* The VB field in a VA, VX or VXR form instruction. */
518#define VB VA + 1 745#define VB VA + 1
519#define VB_MASK (0x1f << 11) 746 { 0x1f, 11, NULL, NULL, PPC_OPERAND_VR },
520 { 5, 11, NULL, NULL, PPC_OPERAND_VR },
521 747
522 /* The VC field in a VA form instruction. */ 748 /* The VC field in a VA form instruction. */
523#define VC VB + 1 749#define VC VB + 1
524#define VC_MASK (0x1f << 6) 750 { 0x1f, 6, NULL, NULL, PPC_OPERAND_VR },
525 { 5, 6, NULL, NULL, PPC_OPERAND_VR },
526 751
527 /* The VD or VS field in a VA, VX, VXR or X form instruction. */ 752 /* The VD or VS field in a VA, VX, VXR or X form instruction. */
528#define VD VC + 1 753#define VD VC + 1
529#define VS VD 754#define VS VD
530#define VD_MASK (0x1f << 21) 755 { 0x1f, 21, NULL, NULL, PPC_OPERAND_VR },
531 { 5, 21, NULL, NULL, PPC_OPERAND_VR },
532 756
533 /* The SIMM field in a VX form instruction. */ 757 /* The SIMM field in a VX form instruction, and TE in Z form. */
534#define SIMM VD + 1 758#define SIMM VD + 1
535 { 5, 16, NULL, NULL, PPC_OPERAND_SIGNED}, 759#define TE SIMM
760 { 0x1f, 16, NULL, NULL, PPC_OPERAND_SIGNED},
536 761
537 /* The UIMM field in a VX form instruction. */ 762 /* The UIMM field in a VX form instruction. */
538#define UIMM SIMM + 1 763#define UIMM SIMM + 1
539 { 5, 16, NULL, NULL, 0 }, 764#define DCTL UIMM
765 { 0x1f, 16, NULL, NULL, 0 },
540 766
541 /* The SHB field in a VA form instruction. */ 767 /* The 3-bit UIMM field in a VX form instruction. */
542#define SHB UIMM + 1 768#define UIMM3 UIMM + 1
543 { 4, 6, NULL, NULL, 0 }, 769 { 0x7, 16, NULL, NULL, 0 },
544 770
545 /* The other UIMM field in a EVX form instruction. */ 771 /* The 6-bit UIM field in a X form instruction. */
546#define EVUIMM SHB + 1 772#define UIM6 UIMM3 + 1
547 { 5, 11, NULL, NULL, 0 }, 773 { 0x3f, 16, NULL, NULL, 0 },
774
775 /* The SIX field in a VX form instruction. */
776#define SIX UIM6 + 1
777 { 0xf, 11, NULL, NULL, 0 },
778
779 /* The PS field in a VX form instruction. */
780#define PS SIX + 1
781 { 0x1, 9, NULL, NULL, 0 },
782
783 /* The SHB field in a VA form instruction. */
784#define SHB PS + 1
785 { 0xf, 6, NULL, NULL, 0 },
548 786
549 /* The other UIMM field in a half word EVX form instruction. */ 787 /* The other UIMM field in a half word EVX form instruction. */
550#define EVUIMM_2 EVUIMM + 1 788#define EVUIMM_2 SHB + 1
551 { 32, 11, insert_ev2, extract_ev2, PPC_OPERAND_PARENS }, 789 { 0x3e, 10, NULL, NULL, PPC_OPERAND_PARENS },
552 790
553 /* The other UIMM field in a word EVX form instruction. */ 791 /* The other UIMM field in a word EVX form instruction. */
554#define EVUIMM_4 EVUIMM_2 + 1 792#define EVUIMM_4 EVUIMM_2 + 1
555 { 32, 11, insert_ev4, extract_ev4, PPC_OPERAND_PARENS }, 793 { 0x7c, 9, NULL, NULL, PPC_OPERAND_PARENS },
556 794
557 /* The other UIMM field in a double EVX form instruction. */ 795 /* The other UIMM field in a double EVX form instruction. */
558#define EVUIMM_8 EVUIMM_4 + 1 796#define EVUIMM_8 EVUIMM_4 + 1
559 { 32, 11, insert_ev8, extract_ev8, PPC_OPERAND_PARENS }, 797 { 0xf8, 8, NULL, NULL, PPC_OPERAND_PARENS },
560 798
561 /* The WS field. */ 799 /* The WS or DRM field in an X form instruction. */
562#define WS EVUIMM_8 + 1 800#define WS EVUIMM_8 + 1
563#define WS_MASK (0x7 << 11) 801#define DRM WS
564 { 3, 11, NULL, NULL, 0 }, 802 { 0x7, 11, NULL, NULL, 0 },
565 803
566 /* The L field in an mtmsrd or A form instruction. */ 804 /* PowerPC paired singles extensions. */
567#define MTMSRD_L WS + 1 805 /* W bit in the pair singles instructions for x type instructions. */
568#define A_L MTMSRD_L 806#define PSWM WS + 1
569 { 1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL }, 807 /* The BO16 field in a BD8 form instruction. */
808#define BO16 PSWM
809 { 0x1, 10, 0, 0, 0 },
810
811 /* IDX bits for quantization in the pair singles instructions. */
812#define PSQ PSWM + 1
813 { 0x7, 12, 0, 0, 0 },
814
815 /* IDX bits for quantization in the pair singles x-type instructions. */
816#define PSQM PSQ + 1
817 { 0x7, 7, 0, 0, 0 },
818
819 /* Smaller D field for quantization in the pair singles instructions. */
820#define PSD PSQM + 1
821 { 0xfff, 0, 0, 0, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED },
822
823 /* The L field in an mtmsrd or A form instruction or R or W in an X form. */
824#define A_L PSD + 1
825#define W A_L
826#define X_R A_L
827 { 0x1, 16, NULL, NULL, PPC_OPERAND_OPTIONAL },
828
829 /* The RMC or CY field in a Z23 form instruction. */
830#define RMC A_L + 1
831#define CY RMC
832 { 0x3, 9, NULL, NULL, 0 },
570 833
571 /* The DCM field in a Z form instruction. */ 834#define R RMC + 1
572#define DCM MTMSRD_L + 1 835 { 0x1, 16, NULL, NULL, 0 },
573 { 6, 16, NULL, NULL, 0 },
574
575 /* Likewise, the DGM field in a Z form instruction. */
576#define DGM DCM + 1
577 { 6, 16, NULL, NULL, 0 },
578 836
579#define TE DGM + 1 837#define RIC R + 1
580 { 5, 11, NULL, NULL, 0 }, 838 { 0x3, 18, NULL, NULL, PPC_OPERAND_OPTIONAL },
581 839
582#define RMC TE + 1 840#define PRS RIC + 1
583 { 2, 21, NULL, NULL, 0 }, 841 { 0x1, 17, NULL, NULL, PPC_OPERAND_OPTIONAL },
584 842
585#define R RMC + 1 843#define SP PRS + 1
586 { 1, 15, NULL, NULL, 0 }, 844 { 0x3, 19, NULL, NULL, 0 },
587
588#define SP R + 1
589 { 2, 11, NULL, NULL, 0 },
590 845
591#define S SP + 1 846#define S SP + 1
592 { 1, 11, NULL, NULL, 0 }, 847 { 0x1, 20, NULL, NULL, 0 },
593 848
594 /* SH field starting at bit position 16. */ 849 /* The S field in a XL form instruction. */
595#define SH16 S + 1 850#define SXL S + 1
596 { 6, 10, NULL, NULL, 0 }, 851 { 0x1, 11, NULL, NULL, PPC_OPERAND_OPTIONAL | PPC_OPERAND_OPTIONAL_VALUE},
852 /* If the SXL operand is ommitted, use the value 1. */
853 { -1, 1, NULL, NULL, 0},
597 854
598 /* The L field in an X form with the RT field fixed instruction. */ 855 /* SH field starting at bit position 16. */
599#define XRT_L SH16 + 1 856#define SH16 SXL + 2
600 { 2, 21, NULL, NULL, PPC_OPERAND_OPTIONAL }, 857 /* The DCM and DGM fields in a Z form instruction. */
858#define DCM SH16
859#define DGM DCM
860 { 0x3f, 10, NULL, NULL, 0 },
601 861
602 /* The EH field in larx instruction. */ 862 /* The EH field in larx instruction. */
603#define EH XRT_L + 1 863#define EH SH16 + 1
604 { 1, 0, NULL, NULL, PPC_OPERAND_OPTIONAL }, 864 { 0x1, 0, NULL, NULL, PPC_OPERAND_OPTIONAL },
865
866 /* The L field in an mtfsf or XFL form instruction. */
867 /* The A field in a HTM X form instruction. */
868#define XFL_L EH + 1
869#define HTM_A XFL_L
870 { 0x1, 25, NULL, NULL, PPC_OPERAND_OPTIONAL},
871
872 /* Xilinx APU related masks and macros */
873#define FCRT XFL_L + 1
874#define FCRT_MASK (0x1f << 21)
875 { 0x1f, 21, 0, 0, PPC_OPERAND_FCR },
876
877 /* Xilinx FSL related masks and macros */
878#define FSL FCRT + 1
879#define FSL_MASK (0x1f << 11)
880 { 0x1f, 11, 0, 0, PPC_OPERAND_FSL },
881
882 /* Xilinx UDI related masks and macros */
883#define URT FSL + 1
884 { 0x1f, 21, 0, 0, PPC_OPERAND_UDI },
885
886#define URA URT + 1
887 { 0x1f, 16, 0, 0, PPC_OPERAND_UDI },
888
889#define URB URA + 1
890 { 0x1f, 11, 0, 0, PPC_OPERAND_UDI },
891
892#define URC URB + 1
893 { 0x1f, 6, 0, 0, PPC_OPERAND_UDI },
894
895 /* The VLESIMM field in a D form instruction. */
896#define VLESIMM URC + 1
897 { 0xffff, PPC_OPSHIFT_INV, insert_vlesi, extract_vlesi,
898 PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },
899
900 /* The VLENSIMM field in a D form instruction. */
901#define VLENSIMM VLESIMM + 1
902 { 0xffff, PPC_OPSHIFT_INV, insert_vlensi, extract_vlensi,
903 PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT },
904
905 /* The VLEUIMM field in a D form instruction. */
906#define VLEUIMM VLENSIMM + 1
907 { 0xffff, PPC_OPSHIFT_INV, insert_vleui, extract_vleui, 0 },
908
909 /* The VLEUIMML field in a D form instruction. */
910#define VLEUIMML VLEUIMM + 1
911 { 0xffff, PPC_OPSHIFT_INV, insert_vleil, extract_vleil, 0 },
912
913 /* The XT and XS fields in an XX1 or XX3 form instruction. This is split. */
914#define XS6 VLEUIMML + 1
915#define XT6 XS6
916 { 0x3f, PPC_OPSHIFT_INV, insert_xt6, extract_xt6, PPC_OPERAND_VSR },
917
918 /* The XT and XS fields in an DQ form VSX instruction. This is split. */
919#define XSQ6 XT6 + 1
920#define XTQ6 XSQ6
921 { 0x3f, PPC_OPSHIFT_INV, insert_xtq6, extract_xtq6, PPC_OPERAND_VSR },
922
923 /* The XA field in an XX3 form instruction. This is split. */
924#define XA6 XTQ6 + 1
925 { 0x3f, PPC_OPSHIFT_INV, insert_xa6, extract_xa6, PPC_OPERAND_VSR },
926
927 /* The XB field in an XX2 or XX3 form instruction. This is split. */
928#define XB6 XA6 + 1
929 { 0x3f, PPC_OPSHIFT_INV, insert_xb6, extract_xb6, PPC_OPERAND_VSR },
930
931 /* The XB field in an XX3 form instruction when it must be the same as
932 the XA field in the instruction. This is used in extended mnemonics
933 like xvmovdp. This is split. */
934#define XB6S XB6 + 1
935 { 0x3f, PPC_OPSHIFT_INV, insert_xb6s, extract_xb6s, PPC_OPERAND_FAKE },
936
937 /* The XC field in an XX4 form instruction. This is split. */
938#define XC6 XB6S + 1
939 { 0x3f, PPC_OPSHIFT_INV, insert_xc6, extract_xc6, PPC_OPERAND_VSR },
940
941 /* The DM or SHW field in an XX3 form instruction. */
942#define DM XC6 + 1
943#define SHW DM
944 { 0x3, 8, NULL, NULL, 0 },
945
946 /* The DM field in an extended mnemonic XX3 form instruction. */
947#define DMEX DM + 1
948 { 0x3, 8, insert_dm, extract_dm, 0 },
949
950 /* The UIM field in an XX2 form instruction. */
951#define UIM DMEX + 1
952 /* The 2-bit UIMM field in a VX form instruction. */
953#define UIMM2 UIM
954 /* The 2-bit L field in a darn instruction. */
955#define LRAND UIM
956 { 0x3, 16, NULL, NULL, 0 },
957
958#define ERAT_T UIM + 1
959 { 0x7, 21, NULL, NULL, 0 },
960
961#define IH ERAT_T + 1
962 { 0x7, 21, NULL, NULL, PPC_OPERAND_OPTIONAL },
963
964 /* The 8-bit IMM8 field in a XX1 form instruction. */
965#define IMM8 IH + 1
966 { 0xff, 11, NULL, NULL, PPC_OPERAND_SIGNOPT },
605}; 967};
606 968
969const unsigned int num_powerpc_operands = (sizeof (powerpc_operands)
970 / sizeof (powerpc_operands[0]));
971
607/* The functions used to insert and extract complicated operands. */ 972/* The functions used to insert and extract complicated operands. */
608 973
974/* The ARX, ARY, RX and RY operands are alternate encodings of GPRs. */
975
976static unsigned long
977insert_arx (unsigned long insn,
978 long value,
979 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
980 const char **errmsg ATTRIBUTE_UNUSED)
981{
982 if (value >= 8 && value < 24)
983 return insn | ((value - 8) & 0xf);
984 else
985 {
986 *errmsg = _("invalid register");
987 return 0;
988 }
989}
990
991static long
992extract_arx (unsigned long insn,
993 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
994 int *invalid ATTRIBUTE_UNUSED)
995{
996 return (insn & 0xf) + 8;
997}
998
999static unsigned long
1000insert_ary (unsigned long insn,
1001 long value,
1002 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1003 const char **errmsg ATTRIBUTE_UNUSED)
1004{
1005 if (value >= 8 && value < 24)
1006 return insn | (((value - 8) & 0xf) << 4);
1007 else
1008 {
1009 *errmsg = _("invalid register");
1010 return 0;
1011 }
1012}
1013
1014static long
1015extract_ary (unsigned long insn,
1016 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1017 int *invalid ATTRIBUTE_UNUSED)
1018{
1019 return ((insn >> 4) & 0xf) + 8;
1020}
1021
1022static unsigned long
1023insert_rx (unsigned long insn,
1024 long value,
1025 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1026 const char **errmsg)
1027{
1028 if (value >= 0 && value < 8)
1029 return insn | value;
1030 else if (value >= 24 && value <= 31)
1031 return insn | (value - 16);
1032 else
1033 {
1034 *errmsg = _("invalid register");
1035 return 0;
1036 }
1037}
1038
1039static long
1040extract_rx (unsigned long insn,
1041 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1042 int *invalid ATTRIBUTE_UNUSED)
1043{
1044 int value = insn & 0xf;
1045 if (value >= 0 && value < 8)
1046 return value;
1047 else
1048 return value + 16;
1049}
1050
1051static unsigned long
1052insert_ry (unsigned long insn,
1053 long value,
1054 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1055 const char **errmsg)
1056{
1057 if (value >= 0 && value < 8)
1058 return insn | (value << 4);
1059 else if (value >= 24 && value <= 31)
1060 return insn | ((value - 16) << 4);
1061 else
1062 {
1063 *errmsg = _("invalid register");
1064 return 0;
1065 }
1066}
1067
1068static long
1069extract_ry (unsigned long insn,
1070 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1071 int *invalid ATTRIBUTE_UNUSED)
1072{
1073 int value = (insn >> 4) & 0xf;
1074 if (value >= 0 && value < 8)
1075 return value;
1076 else
1077 return value + 16;
1078}
1079
609/* The BA field in an XL form instruction when it must be the same as 1080/* The BA field in an XL form instruction when it must be the same as
610 the BT field in the same instruction. This operand is marked FAKE. 1081 the BT field in the same instruction. This operand is marked FAKE.
611 The insertion function just copies the BT field into the BA field, 1082 The insertion function just copies the BT field into the BA field,
@@ -615,7 +1086,7 @@ const struct powerpc_operand powerpc_operands[] =
615static unsigned long 1086static unsigned long
616insert_bat (unsigned long insn, 1087insert_bat (unsigned long insn,
617 long value ATTRIBUTE_UNUSED, 1088 long value ATTRIBUTE_UNUSED,
618 int dialect ATTRIBUTE_UNUSED, 1089 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
619 const char **errmsg ATTRIBUTE_UNUSED) 1090 const char **errmsg ATTRIBUTE_UNUSED)
620{ 1091{
621 return insn | (((insn >> 21) & 0x1f) << 16); 1092 return insn | (((insn >> 21) & 0x1f) << 16);
@@ -623,7 +1094,7 @@ insert_bat (unsigned long insn,
623 1094
624static long 1095static long
625extract_bat (unsigned long insn, 1096extract_bat (unsigned long insn,
626 int dialect ATTRIBUTE_UNUSED, 1097 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
627 int *invalid) 1098 int *invalid)
628{ 1099{
629 if (((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f)) 1100 if (((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f))
@@ -640,7 +1111,7 @@ extract_bat (unsigned long insn,
640static unsigned long 1111static unsigned long
641insert_bba (unsigned long insn, 1112insert_bba (unsigned long insn,
642 long value ATTRIBUTE_UNUSED, 1113 long value ATTRIBUTE_UNUSED,
643 int dialect ATTRIBUTE_UNUSED, 1114 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
644 const char **errmsg ATTRIBUTE_UNUSED) 1115 const char **errmsg ATTRIBUTE_UNUSED)
645{ 1116{
646 return insn | (((insn >> 16) & 0x1f) << 11); 1117 return insn | (((insn >> 16) & 0x1f) << 11);
@@ -648,7 +1119,7 @@ insert_bba (unsigned long insn,
648 1119
649static long 1120static long
650extract_bba (unsigned long insn, 1121extract_bba (unsigned long insn,
651 int dialect ATTRIBUTE_UNUSED, 1122 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
652 int *invalid) 1123 int *invalid)
653{ 1124{
654 if (((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f)) 1125 if (((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))
@@ -656,26 +1127,6 @@ extract_bba (unsigned long insn,
656 return 0; 1127 return 0;
657} 1128}
658 1129
659/* The BD field in a B form instruction. The lower two bits are
660 forced to zero. */
661
662static unsigned long
663insert_bd (unsigned long insn,
664 long value,
665 int dialect ATTRIBUTE_UNUSED,
666 const char **errmsg ATTRIBUTE_UNUSED)
667{
668 return insn | (value & 0xfffc);
669}
670
671static long
672extract_bd (unsigned long insn,
673 int dialect ATTRIBUTE_UNUSED,
674 int *invalid ATTRIBUTE_UNUSED)
675{
676 return ((insn & 0xfffc) ^ 0x8000) - 0x8000;
677}
678
679/* The BD field in a B form instruction when the - modifier is used. 1130/* The BD field in a B form instruction when the - modifier is used.
680 This modifier means that the branch is not expected to be taken. 1131 This modifier means that the branch is not expected to be taken.
681 For chips built to versions of the architecture prior to version 2 1132 For chips built to versions of the architecture prior to version 2
@@ -687,15 +1138,21 @@ extract_bd (unsigned long insn,
687 the "y" bit. "at" == 00 => no hint, "at" == 01 => unpredictable, 1138 the "y" bit. "at" == 00 => no hint, "at" == 01 => unpredictable,
688 "at" == 10 => not taken, "at" == 11 => taken. The "t" bit is 00001 1139 "at" == 10 => not taken, "at" == 11 => taken. The "t" bit is 00001
689 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000 1140 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000
690 for branch on CTR. We only handle the taken/not-taken hint here. */ 1141 for branch on CTR. We only handle the taken/not-taken hint here.
1142 Note that we don't relax the conditions tested here when
1143 disassembling with -Many because insns using extract_bdm and
1144 extract_bdp always occur in pairs. One or the other will always
1145 be valid. */
1146
1147#define ISA_V2 (PPC_OPCODE_POWER4 | PPC_OPCODE_E500MC | PPC_OPCODE_TITAN)
691 1148
692static unsigned long 1149static unsigned long
693insert_bdm (unsigned long insn, 1150insert_bdm (unsigned long insn,
694 long value, 1151 long value,
695 int dialect, 1152 ppc_cpu_t dialect,
696 const char **errmsg ATTRIBUTE_UNUSED) 1153 const char **errmsg ATTRIBUTE_UNUSED)
697{ 1154{
698 if ((dialect & PPC_OPCODE_POWER4) == 0) 1155 if ((dialect & ISA_V2) == 0)
699 { 1156 {
700 if ((value & 0x8000) != 0) 1157 if ((value & 0x8000) != 0)
701 insn |= 1 << 21; 1158 insn |= 1 << 21;
@@ -712,10 +1169,10 @@ insert_bdm (unsigned long insn,
712 1169
713static long 1170static long
714extract_bdm (unsigned long insn, 1171extract_bdm (unsigned long insn,
715 int dialect, 1172 ppc_cpu_t dialect,
716 int *invalid) 1173 int *invalid)
717{ 1174{
718 if ((dialect & PPC_OPCODE_POWER4) == 0) 1175 if ((dialect & ISA_V2) == 0)
719 { 1176 {
720 if (((insn & (1 << 21)) == 0) != ((insn & (1 << 15)) == 0)) 1177 if (((insn & (1 << 21)) == 0) != ((insn & (1 << 15)) == 0))
721 *invalid = 1; 1178 *invalid = 1;
@@ -737,10 +1194,10 @@ extract_bdm (unsigned long insn,
737static unsigned long 1194static unsigned long
738insert_bdp (unsigned long insn, 1195insert_bdp (unsigned long insn,
739 long value, 1196 long value,
740 int dialect, 1197 ppc_cpu_t dialect,
741 const char **errmsg ATTRIBUTE_UNUSED) 1198 const char **errmsg ATTRIBUTE_UNUSED)
742{ 1199{
743 if ((dialect & PPC_OPCODE_POWER4) == 0) 1200 if ((dialect & ISA_V2) == 0)
744 { 1201 {
745 if ((value & 0x8000) == 0) 1202 if ((value & 0x8000) == 0)
746 insn |= 1 << 21; 1203 insn |= 1 << 21;
@@ -757,10 +1214,10 @@ insert_bdp (unsigned long insn,
757 1214
758static long 1215static long
759extract_bdp (unsigned long insn, 1216extract_bdp (unsigned long insn,
760 int dialect, 1217 ppc_cpu_t dialect,
761 int *invalid) 1218 int *invalid)
762{ 1219{
763 if ((dialect & PPC_OPCODE_POWER4) == 0) 1220 if ((dialect & ISA_V2) == 0)
764 { 1221 {
765 if (((insn & (1 << 21)) == 0) == ((insn & (1 << 15)) == 0)) 1222 if (((insn & (1 << 21)) == 0) == ((insn & (1 << 15)) == 0))
766 *invalid = 1; 1223 *invalid = 1;
@@ -775,55 +1232,70 @@ extract_bdp (unsigned long insn,
775 return ((insn & 0xfffc) ^ 0x8000) - 0x8000; 1232 return ((insn & 0xfffc) ^ 0x8000) - 0x8000;
776} 1233}
777 1234
1235static inline int
1236valid_bo_pre_v2 (long value)
1237{
1238 /* Certain encodings have bits that are required to be zero.
1239 These are (z must be zero, y may be anything):
1240 0000y
1241 0001y
1242 001zy
1243 0100y
1244 0101y
1245 011zy
1246 1z00y
1247 1z01y
1248 1z1zz
1249 */
1250 if ((value & 0x14) == 0)
1251 return 1;
1252 else if ((value & 0x14) == 0x4)
1253 return (value & 0x2) == 0;
1254 else if ((value & 0x14) == 0x10)
1255 return (value & 0x8) == 0;
1256 else
1257 return value == 0x14;
1258}
1259
1260static inline int
1261valid_bo_post_v2 (long value)
1262{
1263 /* Certain encodings have bits that are required to be zero.
1264 These are (z must be zero, a & t may be anything):
1265 0000z
1266 0001z
1267 001at
1268 0100z
1269 0101z
1270 011at
1271 1a00t
1272 1a01t
1273 1z1zz
1274 */
1275 if ((value & 0x14) == 0)
1276 return (value & 0x1) == 0;
1277 else if ((value & 0x14) == 0x14)
1278 return value == 0x14;
1279 else
1280 return 1;
1281}
1282
778/* Check for legal values of a BO field. */ 1283/* Check for legal values of a BO field. */
779 1284
780static int 1285static int
781valid_bo (long value, int dialect) 1286valid_bo (long value, ppc_cpu_t dialect, int extract)
782{ 1287{
783 if ((dialect & PPC_OPCODE_POWER4) == 0) 1288 int valid_y = valid_bo_pre_v2 (value);
784 { 1289 int valid_at = valid_bo_post_v2 (value);
785 /* Certain encodings have bits that are required to be zero. 1290
786 These are (z must be zero, y may be anything): 1291 /* When disassembling with -Many, accept either encoding on the
787 001zy 1292 second pass through opcodes. */
788 011zy 1293 if (extract && dialect == ~(ppc_cpu_t) PPC_OPCODE_ANY)
789 1z00y 1294 return valid_y || valid_at;
790 1z01y 1295 if ((dialect & ISA_V2) == 0)
791 1z1zz 1296 return valid_y;
792 */
793 switch (value & 0x14)
794 {
795 default:
796 case 0:
797 return 1;
798 case 0x4:
799 return (value & 0x2) == 0;
800 case 0x10:
801 return (value & 0x8) == 0;
802 case 0x14:
803 return value == 0x14;
804 }
805 }
806 else 1297 else
807 { 1298 return valid_at;
808 /* Certain encodings have bits that are required to be zero.
809 These are (z must be zero, a & t may be anything):
810 0000z
811 0001z
812 0100z
813 0101z
814 001at
815 011at
816 1a00t
817 1a01t
818 1z1zz
819 */
820 if ((value & 0x14) == 0)
821 return (value & 0x1) == 0;
822 else if ((value & 0x14) == 0x14)
823 return value == 0x14;
824 else
825 return 1;
826 }
827} 1299}
828 1300
829/* The BO field in a B form instruction. Warn about attempts to set 1301/* The BO field in a B form instruction. Warn about attempts to set
@@ -832,23 +1304,25 @@ valid_bo (long value, int dialect)
832static unsigned long 1304static unsigned long
833insert_bo (unsigned long insn, 1305insert_bo (unsigned long insn,
834 long value, 1306 long value,
835 int dialect, 1307 ppc_cpu_t dialect,
836 const char **errmsg) 1308 const char **errmsg)
837{ 1309{
838 if (!valid_bo (value, dialect)) 1310 if (!valid_bo (value, dialect, 0))
839 *errmsg = _("invalid conditional option"); 1311 *errmsg = _("invalid conditional option");
1312 else if (PPC_OP (insn) == 19 && (insn & 0x400) && ! (value & 4))
1313 *errmsg = _("invalid counter access");
840 return insn | ((value & 0x1f) << 21); 1314 return insn | ((value & 0x1f) << 21);
841} 1315}
842 1316
843static long 1317static long
844extract_bo (unsigned long insn, 1318extract_bo (unsigned long insn,
845 int dialect, 1319 ppc_cpu_t dialect,
846 int *invalid) 1320 int *invalid)
847{ 1321{
848 long value; 1322 long value;
849 1323
850 value = (insn >> 21) & 0x1f; 1324 value = (insn >> 21) & 0x1f;
851 if (!valid_bo (value, dialect)) 1325 if (!valid_bo (value, dialect, 1))
852 *invalid = 1; 1326 *invalid = 1;
853 return value; 1327 return value;
854} 1328}
@@ -860,11 +1334,13 @@ extract_bo (unsigned long insn,
860static unsigned long 1334static unsigned long
861insert_boe (unsigned long insn, 1335insert_boe (unsigned long insn,
862 long value, 1336 long value,
863 int dialect, 1337 ppc_cpu_t dialect,
864 const char **errmsg) 1338 const char **errmsg)
865{ 1339{
866 if (!valid_bo (value, dialect)) 1340 if (!valid_bo (value, dialect, 0))
867 *errmsg = _("invalid conditional option"); 1341 *errmsg = _("invalid conditional option");
1342 else if (PPC_OP (insn) == 19 && (insn & 0x400) && ! (value & 4))
1343 *errmsg = _("invalid counter access");
868 else if ((value & 1) != 0) 1344 else if ((value & 1) != 0)
869 *errmsg = _("attempt to set y bit when using + or - modifier"); 1345 *errmsg = _("attempt to set y bit when using + or - modifier");
870 1346
@@ -873,166 +1349,73 @@ insert_boe (unsigned long insn,
873 1349
874static long 1350static long
875extract_boe (unsigned long insn, 1351extract_boe (unsigned long insn,
876 int dialect, 1352 ppc_cpu_t dialect,
877 int *invalid) 1353 int *invalid)
878{ 1354{
879 long value; 1355 long value;
880 1356
881 value = (insn >> 21) & 0x1f; 1357 value = (insn >> 21) & 0x1f;
882 if (!valid_bo (value, dialect)) 1358 if (!valid_bo (value, dialect, 1))
883 *invalid = 1; 1359 *invalid = 1;
884 return value & 0x1e; 1360 return value & 0x1e;
885} 1361}
886 1362
887/* The DQ field in a DQ form instruction. This is like D, but the 1363/* The DCMX field in a X form instruction when the field is split
888 lower four bits are forced to zero. */ 1364 into separate DC, DM and DX fields. */
889
890static unsigned long
891insert_dq (unsigned long insn,
892 long value,
893 int dialect ATTRIBUTE_UNUSED,
894 const char **errmsg)
895{
896 if ((value & 0xf) != 0)
897 *errmsg = _("offset not a multiple of 16");
898 return insn | (value & 0xfff0);
899}
900
901static long
902extract_dq (unsigned long insn,
903 int dialect ATTRIBUTE_UNUSED,
904 int *invalid ATTRIBUTE_UNUSED)
905{
906 return ((insn & 0xfff0) ^ 0x8000) - 0x8000;
907}
908 1365
909static unsigned long 1366static unsigned long
910insert_ev2 (unsigned long insn, 1367insert_dcmxs (unsigned long insn,
911 long value, 1368 long value,
912 int dialect ATTRIBUTE_UNUSED, 1369 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
913 const char **errmsg) 1370 const char **errmsg ATTRIBUTE_UNUSED)
914{ 1371{
915 if ((value & 1) != 0) 1372 return insn | ((value & 0x1f) << 16) | ((value & 0x20) >> 3) | (value & 0x40);
916 *errmsg = _("offset not a multiple of 2");
917 if ((value > 62) != 0)
918 *errmsg = _("offset greater than 62");
919 return insn | ((value & 0x3e) << 10);
920} 1373}
921 1374
922static long 1375static long
923extract_ev2 (unsigned long insn, 1376extract_dcmxs (unsigned long insn,
924 int dialect ATTRIBUTE_UNUSED, 1377 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
925 int *invalid ATTRIBUTE_UNUSED) 1378 int *invalid ATTRIBUTE_UNUSED)
926{ 1379{
927 return (insn >> 10) & 0x3e; 1380 return (insn & 0x40) | ((insn << 3) & 0x20) | ((insn >> 16) & 0x1f);
928} 1381}
929 1382
930static unsigned long 1383/* The D field in a DX form instruction when the field is split
931insert_ev4 (unsigned long insn, 1384 into separate D0, D1 and D2 fields. */
932 long value,
933 int dialect ATTRIBUTE_UNUSED,
934 const char **errmsg)
935{
936 if ((value & 3) != 0)
937 *errmsg = _("offset not a multiple of 4");
938 if ((value > 124) != 0)
939 *errmsg = _("offset greater than 124");
940 return insn | ((value & 0x7c) << 9);
941}
942
943static long
944extract_ev4 (unsigned long insn,
945 int dialect ATTRIBUTE_UNUSED,
946 int *invalid ATTRIBUTE_UNUSED)
947{
948 return (insn >> 9) & 0x7c;
949}
950 1385
951static unsigned long 1386static unsigned long
952insert_ev8 (unsigned long insn, 1387insert_dxd (unsigned long insn,
953 long value, 1388 long value,
954 int dialect ATTRIBUTE_UNUSED, 1389 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
955 const char **errmsg) 1390 const char **errmsg ATTRIBUTE_UNUSED)
956{ 1391{
957 if ((value & 7) != 0) 1392 return insn | (value & 0xffc1) | ((value & 0x3e) << 15);
958 *errmsg = _("offset not a multiple of 8");
959 if ((value > 248) != 0)
960 *errmsg = _("offset greater than 248");
961 return insn | ((value & 0xf8) << 8);
962} 1393}
963 1394
964static long 1395static long
965extract_ev8 (unsigned long insn, 1396extract_dxd (unsigned long insn,
966 int dialect ATTRIBUTE_UNUSED, 1397 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
967 int *invalid ATTRIBUTE_UNUSED) 1398 int *invalid ATTRIBUTE_UNUSED)
968{ 1399{
969 return (insn >> 8) & 0xf8; 1400 unsigned long dxd = (insn & 0xffc1) | ((insn >> 15) & 0x3e);
1401 return (dxd ^ 0x8000) - 0x8000;
970} 1402}
971 1403
972/* The DS field in a DS form instruction. This is like D, but the
973 lower two bits are forced to zero. */
974
975static unsigned long 1404static unsigned long
976insert_ds (unsigned long insn, 1405insert_dxdn (unsigned long insn,
977 long value,
978 int dialect ATTRIBUTE_UNUSED,
979 const char **errmsg)
980{
981 if ((value & 3) != 0)
982 *errmsg = _("offset not a multiple of 4");
983 return insn | (value & 0xfffc);
984}
985
986static long
987extract_ds (unsigned long insn,
988 int dialect ATTRIBUTE_UNUSED,
989 int *invalid ATTRIBUTE_UNUSED)
990{
991 return ((insn & 0xfffc) ^ 0x8000) - 0x8000;
992}
993
994/* The DE field in a DE form instruction. */
995
996static unsigned long
997insert_de (unsigned long insn,
998 long value,
999 int dialect ATTRIBUTE_UNUSED,
1000 const char **errmsg)
1001{
1002 if (value > 2047 || value < -2048)
1003 *errmsg = _("offset not between -2048 and 2047");
1004 return insn | ((value << 4) & 0xfff0);
1005}
1006
1007static long
1008extract_de (unsigned long insn,
1009 int dialect ATTRIBUTE_UNUSED,
1010 int *invalid ATTRIBUTE_UNUSED)
1011{
1012 return (insn & 0xfff0) >> 4;
1013}
1014
1015/* The DES field in a DES form instruction. */
1016
1017static unsigned long
1018insert_des (unsigned long insn,
1019 long value, 1406 long value,
1020 int dialect ATTRIBUTE_UNUSED, 1407 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1021 const char **errmsg) 1408 const char **errmsg ATTRIBUTE_UNUSED)
1022{ 1409{
1023 if (value > 8191 || value < -8192) 1410 return insert_dxd (insn, -value, dialect, errmsg);
1024 *errmsg = _("offset not between -8192 and 8191");
1025 else if ((value & 3) != 0)
1026 *errmsg = _("offset not a multiple of 4");
1027 return insn | ((value << 2) & 0xfff0);
1028} 1411}
1029 1412
1030static long 1413static long
1031extract_des (unsigned long insn, 1414extract_dxdn (unsigned long insn,
1032 int dialect ATTRIBUTE_UNUSED, 1415 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1033 int *invalid ATTRIBUTE_UNUSED) 1416 int *invalid ATTRIBUTE_UNUSED)
1034{ 1417{
1035 return (((insn >> 2) & 0x3ffc) ^ 0x2000) - 0x2000; 1418 return -extract_dxd (insn, dialect, invalid);
1036} 1419}
1037 1420
1038/* FXM mask in mfcr and mtcrf instructions. */ 1421/* FXM mask in mfcr and mtcrf instructions. */
@@ -1040,7 +1423,7 @@ extract_des (unsigned long insn,
1040static unsigned long 1423static unsigned long
1041insert_fxm (unsigned long insn, 1424insert_fxm (unsigned long insn,
1042 long value, 1425 long value,
1043 int dialect, 1426 ppc_cpu_t dialect,
1044 const char **errmsg) 1427 const char **errmsg)
1045{ 1428{
1046 /* If we're handling the mfocrf and mtocrf insns ensure that exactly 1429 /* If we're handling the mfocrf and mtocrf insns ensure that exactly
@@ -1054,19 +1437,13 @@ insert_fxm (unsigned long insn,
1054 } 1437 }
1055 } 1438 }
1056 1439
1057 /* If the optional field on mfcr is missing that means we want to use
1058 the old form of the instruction that moves the whole cr. In that
1059 case we'll have VALUE zero. There doesn't seem to be a way to
1060 distinguish this from the case where someone writes mfcr %r3,0. */
1061 else if (value == 0)
1062 ;
1063
1064 /* If only one bit of the FXM field is set, we can use the new form 1440 /* If only one bit of the FXM field is set, we can use the new form
1065 of the instruction, which is faster. Unlike the Power4 branch hint 1441 of the instruction, which is faster. Unlike the Power4 branch hint
1066 encoding, this is not backward compatible. Do not generate the 1442 encoding, this is not backward compatible. Do not generate the
1067 new form unless -mpower4 has been given, or -many and the two 1443 new form unless -mpower4 has been given, or -many and the two
1068 operand form of mfcr was used. */ 1444 operand form of mfcr was used. */
1069 else if ((value & -value) == value 1445 else if (value > 0
1446 && (value & -value) == value
1070 && ((dialect & PPC_OPCODE_POWER4) != 0 1447 && ((dialect & PPC_OPCODE_POWER4) != 0
1071 || ((dialect & PPC_OPCODE_ANY) != 0 1448 || ((dialect & PPC_OPCODE_ANY) != 0
1072 && (insn & (0x3ff << 1)) == 19 << 1))) 1449 && (insn & (0x3ff << 1)) == 19 << 1)))
@@ -1075,7 +1452,10 @@ insert_fxm (unsigned long insn,
1075 /* Any other value on mfcr is an error. */ 1452 /* Any other value on mfcr is an error. */
1076 else if ((insn & (0x3ff << 1)) == 19 << 1) 1453 else if ((insn & (0x3ff << 1)) == 19 << 1)
1077 { 1454 {
1078 *errmsg = _("ignoring invalid mfcr mask"); 1455 /* A value of -1 means we used the one operand form of
1456 mfcr which is valid. */
1457 if (value != -1)
1458 *errmsg = _("invalid mfcr mask");
1079 value = 0; 1459 value = 0;
1080 } 1460 }
1081 1461
@@ -1084,7 +1464,7 @@ insert_fxm (unsigned long insn,
1084 1464
1085static long 1465static long
1086extract_fxm (unsigned long insn, 1466extract_fxm (unsigned long insn,
1087 int dialect ATTRIBUTE_UNUSED, 1467 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1088 int *invalid) 1468 int *invalid)
1089{ 1469{
1090 long mask = (insn >> 12) & 0xff; 1470 long mask = (insn >> 12) & 0xff;
@@ -1102,31 +1482,86 @@ extract_fxm (unsigned long insn,
1102 { 1482 {
1103 if (mask != 0) 1483 if (mask != 0)
1104 *invalid = 1; 1484 *invalid = 1;
1485 else
1486 mask = -1;
1105 } 1487 }
1106 1488
1107 return mask; 1489 return mask;
1108} 1490}
1109 1491
1110/* The LI field in an I form instruction. The lower two bits are 1492static unsigned long
1111 forced to zero. */ 1493insert_li20 (unsigned long insn,
1494 long value,
1495 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1496 const char **errmsg ATTRIBUTE_UNUSED)
1497{
1498 return insn | ((value & 0xf0000) >> 5) | ((value & 0x0f800) << 5) | (value & 0x7ff);
1499}
1500
1501static long
1502extract_li20 (unsigned long insn,
1503 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1504 int *invalid ATTRIBUTE_UNUSED)
1505{
1506 long ext = ((insn & 0x4000) == 0x4000) ? 0xfff00000 : 0x00000000;
1507
1508 return ext
1509 | (((insn >> 11) & 0xf) << 16)
1510 | (((insn >> 17) & 0xf) << 12)
1511 | (((insn >> 16) & 0x1) << 11)
1512 | (insn & 0x7ff);
1513}
1514
1515/* The 2-bit L field in a SYNC or WC field in a WAIT instruction.
1516 For SYNC, some L values are reserved:
1517 * Value 3 is reserved on newer server cpus.
1518 * Values 2 and 3 are reserved on all other cpus. */
1112 1519
1113static unsigned long 1520static unsigned long
1114insert_li (unsigned long insn, 1521insert_ls (unsigned long insn,
1115 long value, 1522 long value,
1116 int dialect ATTRIBUTE_UNUSED, 1523 ppc_cpu_t dialect,
1117 const char **errmsg) 1524 const char **errmsg)
1118{ 1525{
1119 if ((value & 3) != 0) 1526 /* For SYNC, some L values are illegal. */
1120 *errmsg = _("ignoring least significant bits in branch offset"); 1527 if (((insn >> 1) & 0x3ff) == 598)
1121 return insn | (value & 0x3fffffc); 1528 {
1529 long max_lvalue = (dialect & PPC_OPCODE_POWER4) ? 2 : 1;
1530 if (value > max_lvalue)
1531 {
1532 *errmsg = _("illegal L operand value");
1533 return insn;
1534 }
1535 }
1536
1537 return insn | ((value & 0x3) << 21);
1122} 1538}
1123 1539
1124static long 1540/* The 4-bit E field in a sync instruction that accepts 2 operands.
1125extract_li (unsigned long insn, 1541 If ESYNC is non-zero, then the L field must be either 0 or 1 and
1126 int dialect ATTRIBUTE_UNUSED, 1542 the complement of ESYNC-bit2. */
1127 int *invalid ATTRIBUTE_UNUSED) 1543
1544static unsigned long
1545insert_esync (unsigned long insn,
1546 long value,
1547 ppc_cpu_t dialect,
1548 const char **errmsg)
1128{ 1549{
1129 return ((insn & 0x3fffffc) ^ 0x2000000) - 0x2000000; 1550 unsigned long ls = (insn >> 21) & 0x03;
1551
1552 if (value == 0)
1553 {
1554 if (((dialect & PPC_OPCODE_E6500) != 0 && ls > 1)
1555 || ((dialect & PPC_OPCODE_POWER9) != 0 && ls > 2))
1556 *errmsg = _("illegal L operand value");
1557 return insn;
1558 }
1559
1560 if ((ls & ~0x1)
1561 || (((value >> 1) & 0x1) ^ ls) == 0)
1562 *errmsg = _("incompatible L operand value");
1563
1564 return insn | ((value & 0xf) << 16);
1130} 1565}
1131 1566
1132/* The MB and ME fields in an M form instruction expressed as a single 1567/* The MB and ME fields in an M form instruction expressed as a single
@@ -1137,7 +1572,7 @@ extract_li (unsigned long insn,
1137static unsigned long 1572static unsigned long
1138insert_mbe (unsigned long insn, 1573insert_mbe (unsigned long insn,
1139 long value, 1574 long value,
1140 int dialect ATTRIBUTE_UNUSED, 1575 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1141 const char **errmsg) 1576 const char **errmsg)
1142{ 1577{
1143 unsigned long uval, mask; 1578 unsigned long uval, mask;
@@ -1189,7 +1624,7 @@ insert_mbe (unsigned long insn,
1189 1624
1190static long 1625static long
1191extract_mbe (unsigned long insn, 1626extract_mbe (unsigned long insn,
1192 int dialect ATTRIBUTE_UNUSED, 1627 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1193 int *invalid) 1628 int *invalid)
1194{ 1629{
1195 long ret; 1630 long ret;
@@ -1223,7 +1658,7 @@ extract_mbe (unsigned long insn,
1223static unsigned long 1658static unsigned long
1224insert_mb6 (unsigned long insn, 1659insert_mb6 (unsigned long insn,
1225 long value, 1660 long value,
1226 int dialect ATTRIBUTE_UNUSED, 1661 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1227 const char **errmsg ATTRIBUTE_UNUSED) 1662 const char **errmsg ATTRIBUTE_UNUSED)
1228{ 1663{
1229 return insn | ((value & 0x1f) << 6) | (value & 0x20); 1664 return insn | ((value & 0x1f) << 6) | (value & 0x20);
@@ -1231,7 +1666,7 @@ insert_mb6 (unsigned long insn,
1231 1666
1232static long 1667static long
1233extract_mb6 (unsigned long insn, 1668extract_mb6 (unsigned long insn,
1234 int dialect ATTRIBUTE_UNUSED, 1669 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1235 int *invalid ATTRIBUTE_UNUSED) 1670 int *invalid ATTRIBUTE_UNUSED)
1236{ 1671{
1237 return ((insn >> 6) & 0x1f) | (insn & 0x20); 1672 return ((insn >> 6) & 0x1f) | (insn & 0x20);
@@ -1240,22 +1675,9 @@ extract_mb6 (unsigned long insn,
1240/* The NB field in an X form instruction. The value 32 is stored as 1675/* The NB field in an X form instruction. The value 32 is stored as
1241 0. */ 1676 0. */
1242 1677
1243static unsigned long
1244insert_nb (unsigned long insn,
1245 long value,
1246 int dialect ATTRIBUTE_UNUSED,
1247 const char **errmsg)
1248{
1249 if (value < 0 || value > 32)
1250 *errmsg = _("value out of range");
1251 if (value == 32)
1252 value = 0;
1253 return insn | ((value & 0x1f) << 11);
1254}
1255
1256static long 1678static long
1257extract_nb (unsigned long insn, 1679extract_nb (unsigned long insn,
1258 int dialect ATTRIBUTE_UNUSED, 1680 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1259 int *invalid ATTRIBUTE_UNUSED) 1681 int *invalid ATTRIBUTE_UNUSED)
1260{ 1682{
1261 long ret; 1683 long ret;
@@ -1266,6 +1688,26 @@ extract_nb (unsigned long insn,
1266 return ret; 1688 return ret;
1267} 1689}
1268 1690
1691/* The NB field in an lswi instruction, which has special value
1692 restrictions. The value 32 is stored as 0. */
1693
1694static unsigned long
1695insert_nbi (unsigned long insn,
1696 long value,
1697 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1698 const char **errmsg ATTRIBUTE_UNUSED)
1699{
1700 long rtvalue = (insn & RT_MASK) >> 21;
1701 long ravalue = (insn & RA_MASK) >> 16;
1702
1703 if (value == 0)
1704 value = 32;
1705 if (rtvalue + (value + 3) / 4 > (rtvalue > ravalue ? ravalue + 32
1706 : ravalue))
1707 *errmsg = _("address register in load range");
1708 return insn | ((value & 0x1f) << 11);
1709}
1710
1269/* The NSI field in a D form instruction. This is the same as the SI 1711/* The NSI field in a D form instruction. This is the same as the SI
1270 field, only negated. The extraction function always marks it as 1712 field, only negated. The extraction function always marks it as
1271 invalid, since we never want to recognize an instruction which uses 1713 invalid, since we never want to recognize an instruction which uses
@@ -1274,7 +1716,7 @@ extract_nb (unsigned long insn,
1274static unsigned long 1716static unsigned long
1275insert_nsi (unsigned long insn, 1717insert_nsi (unsigned long insn,
1276 long value, 1718 long value,
1277 int dialect ATTRIBUTE_UNUSED, 1719 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1278 const char **errmsg ATTRIBUTE_UNUSED) 1720 const char **errmsg ATTRIBUTE_UNUSED)
1279{ 1721{
1280 return insn | (-value & 0xffff); 1722 return insn | (-value & 0xffff);
@@ -1282,7 +1724,7 @@ insert_nsi (unsigned long insn,
1282 1724
1283static long 1725static long
1284extract_nsi (unsigned long insn, 1726extract_nsi (unsigned long insn,
1285 int dialect ATTRIBUTE_UNUSED, 1727 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1286 int *invalid) 1728 int *invalid)
1287{ 1729{
1288 *invalid = 1; 1730 *invalid = 1;
@@ -1296,7 +1738,7 @@ extract_nsi (unsigned long insn,
1296static unsigned long 1738static unsigned long
1297insert_ral (unsigned long insn, 1739insert_ral (unsigned long insn,
1298 long value, 1740 long value,
1299 int dialect ATTRIBUTE_UNUSED, 1741 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1300 const char **errmsg) 1742 const char **errmsg)
1301{ 1743{
1302 if (value == 0 1744 if (value == 0
@@ -1311,7 +1753,7 @@ insert_ral (unsigned long insn,
1311static unsigned long 1753static unsigned long
1312insert_ram (unsigned long insn, 1754insert_ram (unsigned long insn,
1313 long value, 1755 long value,
1314 int dialect ATTRIBUTE_UNUSED, 1756 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1315 const char **errmsg) 1757 const char **errmsg)
1316{ 1758{
1317 if ((unsigned long) value >= ((insn >> 21) & 0x1f)) 1759 if ((unsigned long) value >= ((insn >> 21) & 0x1f))
@@ -1319,13 +1761,13 @@ insert_ram (unsigned long insn,
1319 return insn | ((value & 0x1f) << 16); 1761 return insn | ((value & 0x1f) << 16);
1320} 1762}
1321 1763
1322/* The RA field in the DQ form lq instruction, which has special 1764/* The RA field in the DQ form lq or an lswx instruction, which have special
1323 value restrictions. */ 1765 value restrictions. */
1324 1766
1325static unsigned long 1767static unsigned long
1326insert_raq (unsigned long insn, 1768insert_raq (unsigned long insn,
1327 long value, 1769 long value,
1328 int dialect ATTRIBUTE_UNUSED, 1770 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1329 const char **errmsg) 1771 const char **errmsg)
1330{ 1772{
1331 long rtvalue = (insn & RT_MASK) >> 21; 1773 long rtvalue = (insn & RT_MASK) >> 21;
@@ -1342,7 +1784,7 @@ insert_raq (unsigned long insn,
1342static unsigned long 1784static unsigned long
1343insert_ras (unsigned long insn, 1785insert_ras (unsigned long insn,
1344 long value, 1786 long value,
1345 int dialect ATTRIBUTE_UNUSED, 1787 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1346 const char **errmsg) 1788 const char **errmsg)
1347{ 1789{
1348 if (value == 0) 1790 if (value == 0)
@@ -1359,7 +1801,7 @@ insert_ras (unsigned long insn,
1359static unsigned long 1801static unsigned long
1360insert_rbs (unsigned long insn, 1802insert_rbs (unsigned long insn,
1361 long value ATTRIBUTE_UNUSED, 1803 long value ATTRIBUTE_UNUSED,
1362 int dialect ATTRIBUTE_UNUSED, 1804 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1363 const char **errmsg ATTRIBUTE_UNUSED) 1805 const char **errmsg ATTRIBUTE_UNUSED)
1364{ 1806{
1365 return insn | (((insn >> 21) & 0x1f) << 11); 1807 return insn | (((insn >> 21) & 0x1f) << 11);
@@ -1367,7 +1809,7 @@ insert_rbs (unsigned long insn,
1367 1809
1368static long 1810static long
1369extract_rbs (unsigned long insn, 1811extract_rbs (unsigned long insn,
1370 int dialect ATTRIBUTE_UNUSED, 1812 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1371 int *invalid) 1813 int *invalid)
1372{ 1814{
1373 if (((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f)) 1815 if (((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f))
@@ -1375,32 +1817,155 @@ extract_rbs (unsigned long insn,
1375 return 0; 1817 return 0;
1376} 1818}
1377 1819
1378/* The RT field of the DQ form lq instruction, which has special 1820/* The RB field in an lswx instruction, which has special value
1379 value restrictions. */ 1821 restrictions. */
1380 1822
1381static unsigned long 1823static unsigned long
1382insert_rtq (unsigned long insn, 1824insert_rbx (unsigned long insn,
1383 long value, 1825 long value,
1384 int dialect ATTRIBUTE_UNUSED, 1826 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1385 const char **errmsg) 1827 const char **errmsg)
1386{ 1828{
1387 if ((value & 1) != 0) 1829 long rtvalue = (insn & RT_MASK) >> 21;
1388 *errmsg = _("target register operand must be even"); 1830
1389 return insn | ((value & 0x1f) << 21); 1831 if (value == rtvalue)
1832 *errmsg = _("source and target register operands must be different");
1833 return insn | ((value & 0x1f) << 11);
1390} 1834}
1391 1835
1392/* The RS field of the DS form stq instruction, which has special 1836/* The SCI8 field is made up of SCL and {U,N}I8 fields. */
1393 value restrictions. */ 1837static unsigned long
1838insert_sci8 (unsigned long insn,
1839 long value,
1840 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1841 const char **errmsg)
1842{
1843 unsigned int fill_scale = 0;
1844 unsigned long ui8 = value;
1845
1846 if ((ui8 & 0xffffff00) == 0)
1847 ;
1848 else if ((ui8 & 0xffffff00) == 0xffffff00)
1849 fill_scale = 0x400;
1850 else if ((ui8 & 0xffff00ff) == 0)
1851 {
1852 fill_scale = 1 << 8;
1853 ui8 >>= 8;
1854 }
1855 else if ((ui8 & 0xffff00ff) == 0xffff00ff)
1856 {
1857 fill_scale = 0x400 | (1 << 8);
1858 ui8 >>= 8;
1859 }
1860 else if ((ui8 & 0xff00ffff) == 0)
1861 {
1862 fill_scale = 2 << 8;
1863 ui8 >>= 16;
1864 }
1865 else if ((ui8 & 0xff00ffff) == 0xff00ffff)
1866 {
1867 fill_scale = 0x400 | (2 << 8);
1868 ui8 >>= 16;
1869 }
1870 else if ((ui8 & 0x00ffffff) == 0)
1871 {
1872 fill_scale = 3 << 8;
1873 ui8 >>= 24;
1874 }
1875 else if ((ui8 & 0x00ffffff) == 0x00ffffff)
1876 {
1877 fill_scale = 0x400 | (3 << 8);
1878 ui8 >>= 24;
1879 }
1880 else
1881 {
1882 *errmsg = _("illegal immediate value");
1883 ui8 = 0;
1884 }
1885
1886 return insn | fill_scale | (ui8 & 0xff);
1887}
1888
1889static long
1890extract_sci8 (unsigned long insn,
1891 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1892 int *invalid ATTRIBUTE_UNUSED)
1893{
1894 int fill = insn & 0x400;
1895 int scale_factor = (insn & 0x300) >> 5;
1896 long value = (insn & 0xff) << scale_factor;
1897
1898 if (fill != 0)
1899 value |= ~((long) 0xff << scale_factor);
1900 return value;
1901}
1394 1902
1395static unsigned long 1903static unsigned long
1396insert_rsq (unsigned long insn, 1904insert_sci8n (unsigned long insn,
1397 long value ATTRIBUTE_UNUSED, 1905 long value,
1398 int dialect ATTRIBUTE_UNUSED, 1906 ppc_cpu_t dialect,
1399 const char **errmsg) 1907 const char **errmsg)
1400{ 1908{
1401 if ((value & 1) != 0) 1909 return insert_sci8 (insn, -value, dialect, errmsg);
1402 *errmsg = _("source register operand must be even"); 1910}
1403 return insn | ((value & 0x1f) << 21); 1911
1912static long
1913extract_sci8n (unsigned long insn,
1914 ppc_cpu_t dialect,
1915 int *invalid)
1916{
1917 return -extract_sci8 (insn, dialect, invalid);
1918}
1919
1920static unsigned long
1921insert_sd4h (unsigned long insn,
1922 long value,
1923 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1924 const char **errmsg ATTRIBUTE_UNUSED)
1925{
1926 return insn | ((value & 0x1e) << 7);
1927}
1928
1929static long
1930extract_sd4h (unsigned long insn,
1931 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1932 int *invalid ATTRIBUTE_UNUSED)
1933{
1934 return ((insn >> 8) & 0xf) << 1;
1935}
1936
1937static unsigned long
1938insert_sd4w (unsigned long insn,
1939 long value,
1940 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1941 const char **errmsg ATTRIBUTE_UNUSED)
1942{
1943 return insn | ((value & 0x3c) << 6);
1944}
1945
1946static long
1947extract_sd4w (unsigned long insn,
1948 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1949 int *invalid ATTRIBUTE_UNUSED)
1950{
1951 return ((insn >> 8) & 0xf) << 2;
1952}
1953
1954static unsigned long
1955insert_oimm (unsigned long insn,
1956 long value,
1957 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1958 const char **errmsg ATTRIBUTE_UNUSED)
1959{
1960 return insn | (((value - 1) & 0x1f) << 4);
1961}
1962
1963static long
1964extract_oimm (unsigned long insn,
1965 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1966 int *invalid ATTRIBUTE_UNUSED)
1967{
1968 return ((insn >> 4) & 0x1f) + 1;
1404} 1969}
1405 1970
1406/* The SH field in an MD form instruction. This is split. */ 1971/* The SH field in an MD form instruction. This is split. */
@@ -1408,18 +1973,26 @@ insert_rsq (unsigned long insn,
1408static unsigned long 1973static unsigned long
1409insert_sh6 (unsigned long insn, 1974insert_sh6 (unsigned long insn,
1410 long value, 1975 long value,
1411 int dialect ATTRIBUTE_UNUSED, 1976 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1412 const char **errmsg ATTRIBUTE_UNUSED) 1977 const char **errmsg ATTRIBUTE_UNUSED)
1413{ 1978{
1414 return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4); 1979 /* SH6 operand in the rldixor instructions. */
1980 if (PPC_OP (insn) == 4)
1981 return insn | ((value & 0x1f) << 6) | ((value & 0x20) >> 5);
1982 else
1983 return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4);
1415} 1984}
1416 1985
1417static long 1986static long
1418extract_sh6 (unsigned long insn, 1987extract_sh6 (unsigned long insn,
1419 int dialect ATTRIBUTE_UNUSED, 1988 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1420 int *invalid ATTRIBUTE_UNUSED) 1989 int *invalid ATTRIBUTE_UNUSED)
1421{ 1990{
1422 return ((insn >> 11) & 0x1f) | ((insn << 4) & 0x20); 1991 /* SH6 operand in the rldixor instructions. */
1992 if (PPC_OP (insn) == 4)
1993 return ((insn >> 6) & 0x1f) | ((insn << 5) & 0x20);
1994 else
1995 return ((insn >> 11) & 0x1f) | ((insn << 4) & 0x20);
1423} 1996}
1424 1997
1425/* The SPR field in an XFX form instruction. This is flipped--the 1998/* The SPR field in an XFX form instruction. This is flipped--the
@@ -1428,7 +2001,7 @@ extract_sh6 (unsigned long insn,
1428static unsigned long 2001static unsigned long
1429insert_spr (unsigned long insn, 2002insert_spr (unsigned long insn,
1430 long value, 2003 long value,
1431 int dialect ATTRIBUTE_UNUSED, 2004 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1432 const char **errmsg ATTRIBUTE_UNUSED) 2005 const char **errmsg ATTRIBUTE_UNUSED)
1433{ 2006{
1434 return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6); 2007 return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);
@@ -1436,26 +2009,23 @@ insert_spr (unsigned long insn,
1436 2009
1437static long 2010static long
1438extract_spr (unsigned long insn, 2011extract_spr (unsigned long insn,
1439 int dialect ATTRIBUTE_UNUSED, 2012 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1440 int *invalid ATTRIBUTE_UNUSED) 2013 int *invalid ATTRIBUTE_UNUSED)
1441{ 2014{
1442 return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0); 2015 return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
1443} 2016}
1444 2017
1445/* Some dialects have 8 SPRG registers instead of the standard 4. */ 2018/* Some dialects have 8 SPRG registers instead of the standard 4. */
2019#define ALLOW8_SPRG (PPC_OPCODE_BOOKE | PPC_OPCODE_405)
1446 2020
1447static unsigned long 2021static unsigned long
1448insert_sprg (unsigned long insn, 2022insert_sprg (unsigned long insn,
1449 long value, 2023 long value,
1450 int dialect, 2024 ppc_cpu_t dialect,
1451 const char **errmsg) 2025 const char **errmsg)
1452{ 2026{
1453 /* This check uses PPC_OPCODE_403 because PPC405 is later defined
1454 as a synonym. If ever a 405 specific dialect is added this
1455 check should use that instead. */
1456 if (value > 7 2027 if (value > 7
1457 || (value > 3 2028 || (value > 3 && (dialect & ALLOW8_SPRG) == 0))
1458 && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_403)) == 0))
1459 *errmsg = _("invalid sprg number"); 2029 *errmsg = _("invalid sprg number");
1460 2030
1461 /* If this is mfsprg4..7 then use spr 260..263 which can be read in 2031 /* If this is mfsprg4..7 then use spr 260..263 which can be read in
@@ -1468,54 +2038,272 @@ insert_sprg (unsigned long insn,
1468 2038
1469static long 2039static long
1470extract_sprg (unsigned long insn, 2040extract_sprg (unsigned long insn,
1471 int dialect, 2041 ppc_cpu_t dialect,
1472 int *invalid) 2042 int *invalid)
1473{ 2043{
1474 unsigned long val = (insn >> 16) & 0x1f; 2044 unsigned long val = (insn >> 16) & 0x1f;
1475 2045
1476 /* mfsprg can use 260..263 and 272..279. mtsprg only uses spr 272..279 2046 /* mfsprg can use 260..263 and 272..279. mtsprg only uses spr 272..279
1477 If not BOOKE or 405, then both use only 272..275. */ 2047 If not BOOKE, 405 or VLE, then both use only 272..275. */
1478 if (val <= 3 2048 if ((val - 0x10 > 3 && (dialect & ALLOW8_SPRG) == 0)
1479 || (val < 0x10 && (insn & 0x100) != 0) 2049 || (val - 0x10 > 7 && (insn & 0x100) != 0)
1480 || (val - 0x10 > 3 2050 || val <= 3
1481 && (dialect & (PPC_OPCODE_BOOKE | PPC_OPCODE_403)) == 0)) 2051 || (val & 8) != 0)
1482 *invalid = 1; 2052 *invalid = 1;
1483 return val & 7; 2053 return val & 7;
1484} 2054}
1485 2055
1486/* The TBR field in an XFX instruction. This is just like SPR, but it 2056/* The TBR field in an XFX instruction. This is just like SPR, but it
1487 is optional. When TBR is omitted, it must be inserted as 268 (the 2057 is optional. */
1488 magic number of the TB register). These functions treat 0
1489 (indicating an omitted optional operand) as 268. This means that
1490 ``mftb 4,0'' is not handled correctly. This does not matter very
1491 much, since the architecture manual does not define mftb as
1492 accepting any values other than 268 or 269. */
1493
1494#define TB (268)
1495 2058
1496static unsigned long 2059static unsigned long
1497insert_tbr (unsigned long insn, 2060insert_tbr (unsigned long insn,
1498 long value, 2061 long value,
1499 int dialect ATTRIBUTE_UNUSED, 2062 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1500 const char **errmsg ATTRIBUTE_UNUSED) 2063 const char **errmsg)
1501{ 2064{
1502 if (value == 0) 2065 if (value != 268 && value != 269)
1503 value = TB; 2066 *errmsg = _("invalid tbr number");
1504 return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6); 2067 return insn | ((value & 0x1f) << 16) | ((value & 0x3e0) << 6);
1505} 2068}
1506 2069
1507static long 2070static long
1508extract_tbr (unsigned long insn, 2071extract_tbr (unsigned long insn,
1509 int dialect ATTRIBUTE_UNUSED, 2072 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
1510 int *invalid ATTRIBUTE_UNUSED) 2073 int *invalid)
1511{ 2074{
1512 long ret; 2075 long ret;
1513 2076
1514 ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0); 2077 ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0);
1515 if (ret == TB) 2078 if (ret != 268 && ret != 269)
1516 ret = 0; 2079 *invalid = 1;
1517 return ret; 2080 return ret;
1518} 2081}
2082
2083/* The XT and XS fields in an XX1 or XX3 form instruction. This is split. */
2084
2085static unsigned long
2086insert_xt6 (unsigned long insn,
2087 long value,
2088 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2089 const char **errmsg ATTRIBUTE_UNUSED)
2090{
2091 return insn | ((value & 0x1f) << 21) | ((value & 0x20) >> 5);
2092}
2093
2094static long
2095extract_xt6 (unsigned long insn,
2096 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2097 int *invalid ATTRIBUTE_UNUSED)
2098{
2099 return ((insn << 5) & 0x20) | ((insn >> 21) & 0x1f);
2100}
2101
2102/* The XT and XS fields in an DQ form VSX instruction. This is split. */
2103static unsigned long
2104insert_xtq6 (unsigned long insn,
2105 long value,
2106 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2107 const char **errmsg ATTRIBUTE_UNUSED)
2108{
2109 return insn | ((value & 0x1f) << 21) | ((value & 0x20) >> 2);
2110}
2111
2112static long
2113extract_xtq6 (unsigned long insn,
2114 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2115 int *invalid ATTRIBUTE_UNUSED)
2116{
2117 return ((insn << 2) & 0x20) | ((insn >> 21) & 0x1f);
2118}
2119
2120/* The XA field in an XX3 form instruction. This is split. */
2121
2122static unsigned long
2123insert_xa6 (unsigned long insn,
2124 long value,
2125 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2126 const char **errmsg ATTRIBUTE_UNUSED)
2127{
2128 return insn | ((value & 0x1f) << 16) | ((value & 0x20) >> 3);
2129}
2130
2131static long
2132extract_xa6 (unsigned long insn,
2133 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2134 int *invalid ATTRIBUTE_UNUSED)
2135{
2136 return ((insn << 3) & 0x20) | ((insn >> 16) & 0x1f);
2137}
2138
2139/* The XB field in an XX3 form instruction. This is split. */
2140
2141static unsigned long
2142insert_xb6 (unsigned long insn,
2143 long value,
2144 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2145 const char **errmsg ATTRIBUTE_UNUSED)
2146{
2147 return insn | ((value & 0x1f) << 11) | ((value & 0x20) >> 4);
2148}
2149
2150static long
2151extract_xb6 (unsigned long insn,
2152 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2153 int *invalid ATTRIBUTE_UNUSED)
2154{
2155 return ((insn << 4) & 0x20) | ((insn >> 11) & 0x1f);
2156}
2157
2158/* The XB field in an XX3 form instruction when it must be the same as
2159 the XA field in the instruction. This is used for extended
2160 mnemonics like xvmovdp. This operand is marked FAKE. The insertion
2161 function just copies the XA field into the XB field, and the
2162 extraction function just checks that the fields are the same. */
2163
2164static unsigned long
2165insert_xb6s (unsigned long insn,
2166 long value ATTRIBUTE_UNUSED,
2167 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2168 const char **errmsg ATTRIBUTE_UNUSED)
2169{
2170 return insn | (((insn >> 16) & 0x1f) << 11) | (((insn >> 2) & 0x1) << 1);
2171}
2172
2173static long
2174extract_xb6s (unsigned long insn,
2175 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2176 int *invalid)
2177{
2178 if ((((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f))
2179 || (((insn >> 2) & 0x1) != ((insn >> 1) & 0x1)))
2180 *invalid = 1;
2181 return 0;
2182}
2183
2184/* The XC field in an XX4 form instruction. This is split. */
2185
2186static unsigned long
2187insert_xc6 (unsigned long insn,
2188 long value,
2189 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2190 const char **errmsg ATTRIBUTE_UNUSED)
2191{
2192 return insn | ((value & 0x1f) << 6) | ((value & 0x20) >> 2);
2193}
2194
2195static long
2196extract_xc6 (unsigned long insn,
2197 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2198 int *invalid ATTRIBUTE_UNUSED)
2199{
2200 return ((insn << 2) & 0x20) | ((insn >> 6) & 0x1f);
2201}
2202
2203static unsigned long
2204insert_dm (unsigned long insn,
2205 long value,
2206 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2207 const char **errmsg)
2208{
2209 if (value != 0 && value != 1)
2210 *errmsg = _("invalid constant");
2211 return insn | (((value) ? 3 : 0) << 8);
2212}
2213
2214static long
2215extract_dm (unsigned long insn,
2216 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2217 int *invalid)
2218{
2219 long value;
2220
2221 value = (insn >> 8) & 3;
2222 if (value != 0 && value != 3)
2223 *invalid = 1;
2224 return (value) ? 1 : 0;
2225}
2226
2227/* The VLESIMM field in an I16A form instruction. This is split. */
2228
2229static unsigned long
2230insert_vlesi (unsigned long insn,
2231 long value,
2232 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2233 const char **errmsg ATTRIBUTE_UNUSED)
2234{
2235 return insn | ((value & 0xf800) << 10) | (value & 0x7ff);
2236}
2237
2238static long
2239extract_vlesi (unsigned long insn,
2240 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2241 int *invalid ATTRIBUTE_UNUSED)
2242{
2243 long value = ((insn >> 10) & 0xf800) | (insn & 0x7ff);
2244 value = (value ^ 0x8000) - 0x8000;
2245 return value;
2246}
2247
2248static unsigned long
2249insert_vlensi (unsigned long insn,
2250 long value,
2251 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2252 const char **errmsg ATTRIBUTE_UNUSED)
2253{
2254 value = -value;
2255 return insn | ((value & 0xf800) << 10) | (value & 0x7ff);
2256}
2257static long
2258extract_vlensi (unsigned long insn,
2259 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2260 int *invalid ATTRIBUTE_UNUSED)
2261{
2262 long value = ((insn >> 10) & 0xf800) | (insn & 0x7ff);
2263 value = (value ^ 0x8000) - 0x8000;
2264 /* Don't use for disassembly. */
2265 *invalid = 1;
2266 return -value;
2267}
2268
2269/* The VLEUIMM field in an I16A form instruction. This is split. */
2270
2271static unsigned long
2272insert_vleui (unsigned long insn,
2273 long value,
2274 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2275 const char **errmsg ATTRIBUTE_UNUSED)
2276{
2277 return insn | ((value & 0xf800) << 10) | (value & 0x7ff);
2278}
2279
2280static long
2281extract_vleui (unsigned long insn,
2282 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2283 int *invalid ATTRIBUTE_UNUSED)
2284{
2285 return ((insn >> 10) & 0xf800) | (insn & 0x7ff);
2286}
2287
2288/* The VLEUIMML field in an I16L form instruction. This is split. */
2289
2290static unsigned long
2291insert_vleil (unsigned long insn,
2292 long value,
2293 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2294 const char **errmsg ATTRIBUTE_UNUSED)
2295{
2296 return insn | ((value & 0xf800) << 5) | (value & 0x7ff);
2297}
2298
2299static long
2300extract_vleil (unsigned long insn,
2301 ppc_cpu_t dialect ATTRIBUTE_UNUSED,
2302 int *invalid ATTRIBUTE_UNUSED)
2303{
2304 return ((insn >> 5) & 0xf800) | (insn & 0x7ff);
2305}
2306
1519 2307
1520/* Macros used to form opcodes. */ 2308/* Macros used to form opcodes. */
1521 2309
@@ -1535,6 +2323,17 @@ extract_tbr (unsigned long insn,
1535#define OPL(x,l) (OP (x) | ((((unsigned long)(l)) & 1) << 21)) 2323#define OPL(x,l) (OP (x) | ((((unsigned long)(l)) & 1) << 21))
1536#define OPL_MASK OPL (0x3f,1) 2324#define OPL_MASK OPL (0x3f,1)
1537 2325
2326/* The main opcode combined with an update code in D form instruction.
2327 Used for extended mnemonics for VLE memory instructions. */
2328#define OPVUP(x,vup) (OP (x) | ((((unsigned long)(vup)) & 0xff) << 8))
2329#define OPVUP_MASK OPVUP (0x3f, 0xff)
2330
2331/* The main opcode combined with an update code and the RT fields specified in
2332 D form instruction. Used for VLE volatile context save/restore
2333 instructions. */
2334#define OPVUPRT(x,vup,rt) (OPVUP (x, vup) | ((((unsigned long)(rt)) & 0x1f) << 21))
2335#define OPVUPRT_MASK OPVUPRT (0x3f, 0xff, 0x1f)
2336
1538/* An A form instruction. */ 2337/* An A form instruction. */
1539#define A(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1) | (((unsigned long)(rc)) & 1)) 2338#define A(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1) | (((unsigned long)(rc)) & 1))
1540#define A_MASK A (0x3f, 0x1f, 1) 2339#define A_MASK A (0x3f, 0x1f, 1)
@@ -1555,6 +2354,43 @@ extract_tbr (unsigned long insn,
1555#define B(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 1) | ((lk) & 1)) 2354#define B(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 1) | ((lk) & 1))
1556#define B_MASK B (0x3f, 1, 1) 2355#define B_MASK B (0x3f, 1, 1)
1557 2356
2357/* A BD8 form instruction. This is a 16-bit instruction. */
2358#define BD8(op, aa, lk) (((((unsigned long)(op)) & 0x3f) << 10) | (((aa) & 1) << 9) | (((lk) & 1) << 8))
2359#define BD8_MASK BD8 (0x3f, 1, 1)
2360
2361/* Another BD8 form instruction. This is a 16-bit instruction. */
2362#define BD8IO(op) ((((unsigned long)(op)) & 0x1f) << 11)
2363#define BD8IO_MASK BD8IO (0x1f)
2364
2365/* A BD8 form instruction for simplified mnemonics. */
2366#define EBD8IO(op, bo, bi) (BD8IO ((op)) | ((bo) << 10) | ((bi) << 8))
2367/* A mask that excludes BO32 and BI32. */
2368#define EBD8IO1_MASK 0xf800
2369/* A mask that includes BO32 and excludes BI32. */
2370#define EBD8IO2_MASK 0xfc00
2371/* A mask that include BO32 AND BI32. */
2372#define EBD8IO3_MASK 0xff00
2373
2374/* A BD15 form instruction. */
2375#define BD15(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 0xf) << 22) | ((lk) & 1))
2376#define BD15_MASK BD15 (0x3f, 0xf, 1)
2377
2378/* A BD15 form instruction for extended conditional branch mnemonics. */
2379#define EBD15(op, aa, bo, lk) (((op) & 0x3f) << 26) | (((aa) & 0xf) << 22) | (((bo) & 0x3) << 20) | ((lk) & 1)
2380#define EBD15_MASK 0xfff00001
2381
2382/* A BD15 form instruction for extended conditional branch mnemonics with BI. */
2383#define EBD15BI(op, aa, bo, bi, lk) (((op) & 0x3f) << 26) \
2384 | (((aa) & 0xf) << 22) \
2385 | (((bo) & 0x3) << 20) \
2386 | (((bi) & 0x3) << 16) \
2387 | ((lk) & 1)
2388#define EBD15BI_MASK 0xfff30001
2389
2390/* A BD24 form instruction. */
2391#define BD24(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 25) | ((lk) & 1))
2392#define BD24_MASK BD24 (0x3f, 1, 1)
2393
1558/* A B form instruction setting the BO field. */ 2394/* A B form instruction setting the BO field. */
1559#define BBO(op, bo, aa, lk) (B ((op), (aa), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21)) 2395#define BBO(op, bo, aa, lk) (B ((op), (aa), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21))
1560#define BBO_MASK BBO (0x3f, 0x1f, 1, 1) 2396#define BBO_MASK BBO (0x3f, 0x1f, 1, 1)
@@ -1562,7 +2398,7 @@ extract_tbr (unsigned long insn,
1562/* A BBO_MASK with the y bit of the BO field removed. This permits 2398/* A BBO_MASK with the y bit of the BO field removed. This permits
1563 matching a conditional branch regardless of the setting of the y 2399 matching a conditional branch regardless of the setting of the y
1564 bit. Similarly for the 'at' bits used for power4 branch hints. */ 2400 bit. Similarly for the 'at' bits used for power4 branch hints. */
1565#define Y_MASK (((unsigned long) 1) << 21) 2401#define Y_MASK (((unsigned long) 1) << 21)
1566#define AT1_MASK (((unsigned long) 3) << 21) 2402#define AT1_MASK (((unsigned long) 3) << 21)
1567#define AT2_MASK (((unsigned long) 9) << 21) 2403#define AT2_MASK (((unsigned long) 9) << 21)
1568#define BBOY_MASK (BBO_MASK &~ Y_MASK) 2404#define BBOY_MASK (BBO_MASK &~ Y_MASK)
@@ -1583,6 +2419,12 @@ extract_tbr (unsigned long insn,
1583#define BBOYBI_MASK (BBOYCB_MASK | BI_MASK) 2419#define BBOYBI_MASK (BBOYCB_MASK | BI_MASK)
1584#define BBOATBI_MASK (BBOAT2CB_MASK | BI_MASK) 2420#define BBOATBI_MASK (BBOAT2CB_MASK | BI_MASK)
1585 2421
2422/* A VLE C form instruction. */
2423#define C_LK(x, lk) (((((unsigned long)(x)) & 0x7fff) << 1) | ((lk) & 1))
2424#define C_LK_MASK C_LK(0x7fff, 1)
2425#define C(x) ((((unsigned long)(x)) & 0xffff))
2426#define C_MASK C(0xffff)
2427
1586/* An Context form instruction. */ 2428/* An Context form instruction. */
1587#define CTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7)) 2429#define CTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7))
1588#define CTX_MASK CTX(0x3f, 0x7) 2430#define CTX_MASK CTX(0x3f, 0x7)
@@ -1594,22 +2436,46 @@ extract_tbr (unsigned long insn,
1594/* The main opcode mask with the RA field clear. */ 2436/* The main opcode mask with the RA field clear. */
1595#define DRA_MASK (OP_MASK | RA_MASK) 2437#define DRA_MASK (OP_MASK | RA_MASK)
1596 2438
2439/* A DQ form VSX instruction. */
2440#define DQX(op, xop) (OP (op) | ((xop) & 0x7))
2441#define DQX_MASK DQX (0x3f, 7)
2442
1597/* A DS form instruction. */ 2443/* A DS form instruction. */
1598#define DSO(op, xop) (OP (op) | ((xop) & 0x3)) 2444#define DSO(op, xop) (OP (op) | ((xop) & 0x3))
1599#define DS_MASK DSO (0x3f, 3) 2445#define DS_MASK DSO (0x3f, 3)
1600 2446
1601/* A DE form instruction. */ 2447/* An DX form instruction. */
1602#define DEO(op, xop) (OP (op) | ((xop) & 0xf)) 2448#define DX(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1))
1603#define DE_MASK DEO (0x3e, 0xf) 2449#define DX_MASK DX (0x3f, 0x1f)
1604 2450
1605/* An EVSEL form instruction. */ 2451/* An EVSEL form instruction. */
1606#define EVSEL(op, xop) (OP (op) | (((unsigned long)(xop)) & 0xff) << 3) 2452#define EVSEL(op, xop) (OP (op) | (((unsigned long)(xop)) & 0xff) << 3)
1607#define EVSEL_MASK EVSEL(0x3f, 0xff) 2453#define EVSEL_MASK EVSEL(0x3f, 0xff)
1608 2454
2455/* An IA16 form instruction. */
2456#define IA16(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f) << 11)
2457#define IA16_MASK IA16(0x3f, 0x1f)
2458
2459/* An I16A form instruction. */
2460#define I16A(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f) << 11)
2461#define I16A_MASK I16A(0x3f, 0x1f)
2462
2463/* An I16L form instruction. */
2464#define I16L(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f) << 11)
2465#define I16L_MASK I16L(0x3f, 0x1f)
2466
2467/* An IM7 form instruction. */
2468#define IM7(op) ((((unsigned long)(op)) & 0x1f) << 11)
2469#define IM7_MASK IM7(0x1f)
2470
1609/* An M form instruction. */ 2471/* An M form instruction. */
1610#define M(op, rc) (OP (op) | ((rc) & 1)) 2472#define M(op, rc) (OP (op) | ((rc) & 1))
1611#define M_MASK M (0x3f, 1) 2473#define M_MASK M (0x3f, 1)
1612 2474
2475/* An LI20 form instruction. */
2476#define LI20(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1) << 15)
2477#define LI20_MASK LI20(0x3f, 0x1)
2478
1613/* An M form instruction with the ME field specified. */ 2479/* An M form instruction with the ME field specified. */
1614#define MME(op, me, rc) (M ((op), (rc)) | ((((unsigned long)(me)) & 0x1f) << 1)) 2480#define MME(op, me, rc) (M ((op), (rc)) | ((((unsigned long)(me)) & 0x1f) << 1))
1615 2481
@@ -1640,44 +2506,189 @@ extract_tbr (unsigned long insn,
1640#define SC(op, sa, lk) (OP (op) | ((((unsigned long)(sa)) & 1) << 1) | ((lk) & 1)) 2506#define SC(op, sa, lk) (OP (op) | ((((unsigned long)(sa)) & 1) << 1) | ((lk) & 1))
1641#define SC_MASK (OP_MASK | (((unsigned long)0x3ff) << 16) | (((unsigned long)1) << 1) | 1) 2507#define SC_MASK (OP_MASK | (((unsigned long)0x3ff) << 16) | (((unsigned long)1) << 1) | 1)
1642 2508
1643/* An VX form instruction. */ 2509/* An SCI8 form instruction. */
2510#define SCI8(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 11))
2511#define SCI8_MASK SCI8(0x3f, 0x1f)
2512
2513/* An SCI8 form instruction. */
2514#define SCI8BF(op, fop, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 11) | (((fop) & 7) << 23))
2515#define SCI8BF_MASK SCI8BF(0x3f, 7, 0x1f)
2516
2517/* An SD4 form instruction. This is a 16-bit instruction. */
2518#define SD4(op) ((((unsigned long)(op)) & 0xf) << 12)
2519#define SD4_MASK SD4(0xf)
2520
2521/* An SE_IM5 form instruction. This is a 16-bit instruction. */
2522#define SE_IM5(op, xop) (((((unsigned long)(op)) & 0x3f) << 10) | (((xop) & 0x1) << 9))
2523#define SE_IM5_MASK SE_IM5(0x3f, 1)
2524
2525/* An SE_R form instruction. This is a 16-bit instruction. */
2526#define SE_R(op, xop) (((((unsigned long)(op)) & 0x3f) << 10) | (((xop) & 0x3f) << 4))
2527#define SE_R_MASK SE_R(0x3f, 0x3f)
2528
2529/* An SE_RR form instruction. This is a 16-bit instruction. */
2530#define SE_RR(op, xop) (((((unsigned long)(op)) & 0x3f) << 10) | (((xop) & 0x3) << 8))
2531#define SE_RR_MASK SE_RR(0x3f, 3)
2532
2533/* A VX form instruction. */
1644#define VX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7ff)) 2534#define VX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7ff))
1645 2535
1646/* The mask for an VX form instruction. */ 2536/* The mask for an VX form instruction. */
1647#define VX_MASK VX(0x3f, 0x7ff) 2537#define VX_MASK VX(0x3f, 0x7ff)
1648 2538
1649/* An VA form instruction. */ 2539/* A VX_MASK with the VA field fixed. */
2540#define VXVA_MASK (VX_MASK | (0x1f << 16))
2541
2542/* A VX_MASK with the VB field fixed. */
2543#define VXVB_MASK (VX_MASK | (0x1f << 11))
2544
2545/* A VX_MASK with the VA and VB fields fixed. */
2546#define VXVAVB_MASK (VX_MASK | (0x1f << 16) | (0x1f << 11))
2547
2548/* A VX_MASK with the VD and VA fields fixed. */
2549#define VXVDVA_MASK (VX_MASK | (0x1f << 21) | (0x1f << 16))
2550
2551/* A VX_MASK with a UIMM4 field. */
2552#define VXUIMM4_MASK (VX_MASK | (0x1 << 20))
2553
2554/* A VX_MASK with a UIMM3 field. */
2555#define VXUIMM3_MASK (VX_MASK | (0x3 << 19))
2556
2557/* A VX_MASK with a UIMM2 field. */
2558#define VXUIMM2_MASK (VX_MASK | (0x7 << 18))
2559
2560/* A VX_MASK with a PS field. */
2561#define VXPS_MASK (VX_MASK & ~(0x1 << 9))
2562
2563/* A VX_MASK with the VA field fixed with a PS field. */
2564#define VXVAPS_MASK ((VX_MASK | (0x1f << 16)) & ~(0x1 << 9))
2565
2566/* A VA form instruction. */
1650#define VXA(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x03f)) 2567#define VXA(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x03f))
1651 2568
1652/* The mask for an VA form instruction. */ 2569/* The mask for an VA form instruction. */
1653#define VXA_MASK VXA(0x3f, 0x3f) 2570#define VXA_MASK VXA(0x3f, 0x3f)
1654 2571
1655/* An VXR form instruction. */ 2572/* A VXA_MASK with a SHB field. */
2573#define VXASHB_MASK (VXA_MASK | (1 << 10))
2574
2575/* A VXR form instruction. */
1656#define VXR(op, xop, rc) (OP (op) | (((rc) & 1) << 10) | (((unsigned long)(xop)) & 0x3ff)) 2576#define VXR(op, xop, rc) (OP (op) | (((rc) & 1) << 10) | (((unsigned long)(xop)) & 0x3ff))
1657 2577
1658/* The mask for a VXR form instruction. */ 2578/* The mask for a VXR form instruction. */
1659#define VXR_MASK VXR(0x3f, 0x3ff, 1) 2579#define VXR_MASK VXR(0x3f, 0x3ff, 1)
1660 2580
2581/* A VX form instruction with a VA tertiary opcode. */
2582#define VXVA(op, xop, vaop) (VX(op,xop) | (((vaop) & 0x1f) << 16))
2583
2584#define VXASH(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1))
2585#define VXASH_MASK VXASH (0x3f, 0x1f)
2586
1661/* An X form instruction. */ 2587/* An X form instruction. */
1662#define X(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1)) 2588#define X(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1))
1663 2589
2590/* A X form instruction for Quad-Precision FP Instructions. */
2591#define XVA(op, xop, vaop) (X(op,xop) | (((vaop) & 0x1f) << 16))
2592
2593/* An EX form instruction. */
2594#define EX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7ff))
2595
2596/* The mask for an EX form instruction. */
2597#define EX_MASK EX (0x3f, 0x7ff)
2598
2599/* An XX2 form instruction. */
2600#define XX2(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 2))
2601
2602/* A XX2 form instruction with the VA bits specified. */
2603#define XX2VA(op, xop, vaop) (XX2(op,xop) | (((vaop) & 0x1f) << 16))
2604
2605/* An XX3 form instruction. */
2606#define XX3(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0xff) << 3))
2607
2608/* An XX3 form instruction with the RC bit specified. */
2609#define XX3RC(op, xop, rc) (OP (op) | (((rc) & 1) << 10) | ((((unsigned long)(xop)) & 0x7f) << 3))
2610
2611/* An XX4 form instruction. */
2612#define XX4(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3) << 4))
2613
1664/* A Z form instruction. */ 2614/* A Z form instruction. */
1665#define Z(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1)) 2615#define Z(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1))
1666 2616
1667/* An X form instruction with the RC bit specified. */ 2617/* An X form instruction with the RC bit specified. */
1668#define XRC(op, xop, rc) (X ((op), (xop)) | ((rc) & 1)) 2618#define XRC(op, xop, rc) (X ((op), (xop)) | ((rc) & 1))
1669 2619
2620/* A X form instruction for Quad-Precision FP Instructions with RC bit. */
2621#define XVARC(op, xop, vaop, rc) (XVA ((op), (xop), (vaop)) | ((rc) & 1))
2622
2623/* An X form instruction with the RA bits specified as two ops. */
2624#define XMMF(op, xop, mop0, mop1) (X ((op), (xop)) | ((mop0) & 3) << 19 | ((mop1) & 7) << 16)
2625
1670/* A Z form instruction with the RC bit specified. */ 2626/* A Z form instruction with the RC bit specified. */
1671#define ZRC(op, xop, rc) (Z ((op), (xop)) | ((rc) & 1)) 2627#define ZRC(op, xop, rc) (Z ((op), (xop)) | ((rc) & 1))
1672 2628
1673/* The mask for an X form instruction. */ 2629/* The mask for an X form instruction. */
1674#define X_MASK XRC (0x3f, 0x3ff, 1) 2630#define X_MASK XRC (0x3f, 0x3ff, 1)
1675 2631
2632/* The mask for an X form instruction with the BF bits specified. */
2633#define XBF_MASK (X_MASK | (3 << 21))
2634
2635/* An X form wait instruction with everything filled in except the WC field. */
2636#define XWC_MASK (XRC (0x3f, 0x3ff, 1) | (7 << 23) | RA_MASK | RB_MASK)
2637
2638/* The mask for an XX1 form instruction. */
2639#define XX1_MASK X (0x3f, 0x3ff)
2640
2641/* An XX1_MASK with the RB field fixed. */
2642#define XX1RB_MASK (XX1_MASK | RB_MASK)
2643
2644/* The mask for an XX2 form instruction. */
2645#define XX2_MASK (XX2 (0x3f, 0x1ff) | (0x1f << 16))
2646
2647/* The mask for an XX2 form instruction with the UIM bits specified. */
2648#define XX2UIM_MASK (XX2 (0x3f, 0x1ff) | (7 << 18))
2649
2650/* The mask for an XX2 form instruction with the 4 UIM bits specified. */
2651#define XX2UIM4_MASK (XX2 (0x3f, 0x1ff) | (1 << 20))
2652
2653/* The mask for an XX2 form instruction with the BF bits specified. */
2654#define XX2BF_MASK (XX2_MASK | (3 << 21) | (1))
2655
2656/* The mask for an XX2 form instruction with the BF and DCMX bits specified. */
2657#define XX2BFD_MASK (XX2 (0x3f, 0x1ff) | 1)
2658
2659/* The mask for an XX2 form instruction with a split DCMX bits specified. */
2660#define XX2DCMXS_MASK XX2 (0x3f, 0x1ee)
2661
2662/* The mask for an XX3 form instruction. */
2663#define XX3_MASK XX3 (0x3f, 0xff)
2664
2665/* The mask for an XX3 form instruction with the BF bits specified. */
2666#define XX3BF_MASK (XX3 (0x3f, 0xff) | (3 << 21) | (1))
2667
2668/* The mask for an XX3 form instruction with the DM or SHW bits specified. */
2669#define XX3DM_MASK (XX3 (0x3f, 0x1f) | (1 << 10))
2670#define XX3SHW_MASK XX3DM_MASK
2671
2672/* The mask for an XX4 form instruction. */
2673#define XX4_MASK XX4 (0x3f, 0x3)
2674
2675/* An X form wait instruction with everything filled in except the WC field. */
2676#define XWC_MASK (XRC (0x3f, 0x3ff, 1) | (7 << 23) | RA_MASK | RB_MASK)
2677
2678/* The mask for an XMMF form instruction. */
2679#define XMMF_MASK (XMMF (0x3f, 0x3ff, 3, 7) | (1))
2680
1676/* The mask for a Z form instruction. */ 2681/* The mask for a Z form instruction. */
1677#define Z_MASK ZRC (0x3f, 0x1ff, 1) 2682#define Z_MASK ZRC (0x3f, 0x1ff, 1)
2683#define Z2_MASK ZRC (0x3f, 0xff, 1)
1678 2684
1679/* An X_MASK with the RA field fixed. */ 2685/* An X_MASK with the RA/VA field fixed. */
1680#define XRA_MASK (X_MASK | RA_MASK) 2686#define XRA_MASK (X_MASK | RA_MASK)
2687#define XVA_MASK XRA_MASK
2688
2689/* An XRA_MASK with the A_L/W field clear. */
2690#define XWRA_MASK (XRA_MASK & ~((unsigned long) 1 << 16))
2691#define XRLA_MASK XWRA_MASK
1681 2692
1682/* An X_MASK with the RB field fixed. */ 2693/* An X_MASK with the RB field fixed. */
1683#define XRB_MASK (X_MASK | RB_MASK) 2694#define XRB_MASK (X_MASK | RB_MASK)
@@ -1691,18 +2702,54 @@ extract_tbr (unsigned long insn,
1691/* An X_MASK with the RA and RB fields fixed. */ 2702/* An X_MASK with the RA and RB fields fixed. */
1692#define XRARB_MASK (X_MASK | RA_MASK | RB_MASK) 2703#define XRARB_MASK (X_MASK | RA_MASK | RB_MASK)
1693 2704
2705/* An XBF_MASK with the RA and RB fields fixed. */
2706#define XBFRARB_MASK (XBF_MASK | RA_MASK | RB_MASK)
2707
1694/* An XRARB_MASK, but with the L bit clear. */ 2708/* An XRARB_MASK, but with the L bit clear. */
1695#define XRLARB_MASK (XRARB_MASK & ~((unsigned long) 1 << 16)) 2709#define XRLARB_MASK (XRARB_MASK & ~((unsigned long) 1 << 16))
1696 2710
2711/* An XRARB_MASK, but with the L bits in a darn instruction clear. */
2712#define XLRAND_MASK (XRARB_MASK & ~((unsigned long) 3 << 16))
2713
1697/* An X_MASK with the RT and RA fields fixed. */ 2714/* An X_MASK with the RT and RA fields fixed. */
1698#define XRTRA_MASK (X_MASK | RT_MASK | RA_MASK) 2715#define XRTRA_MASK (X_MASK | RT_MASK | RA_MASK)
1699 2716
2717/* An X_MASK with the RT and RB fields fixed. */
2718#define XRTRB_MASK (X_MASK | RT_MASK | RB_MASK)
2719
1700/* An XRTRA_MASK, but with L bit clear. */ 2720/* An XRTRA_MASK, but with L bit clear. */
1701#define XRTLRA_MASK (XRTRA_MASK & ~((unsigned long) 1 << 21)) 2721#define XRTLRA_MASK (XRTRA_MASK & ~((unsigned long) 1 << 21))
1702 2722
2723/* An X_MASK with the RT, RA and RB fields fixed. */
2724#define XRTRARB_MASK (X_MASK | RT_MASK | RA_MASK | RB_MASK)
2725
2726/* An XRTRARB_MASK, but with L bit clear. */
2727#define XRTLRARB_MASK (XRTRARB_MASK & ~((unsigned long) 1 << 21))
2728
2729/* An XRTRARB_MASK, but with A bit clear. */
2730#define XRTARARB_MASK (XRTRARB_MASK & ~((unsigned long) 1 << 25))
2731
2732/* An XRTRARB_MASK, but with BF bits clear. */
2733#define XRTBFRARB_MASK (XRTRARB_MASK & ~((unsigned long) 7 << 23))
2734
1703/* An X form instruction with the L bit specified. */ 2735/* An X form instruction with the L bit specified. */
1704#define XOPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21)) 2736#define XOPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21))
1705 2737
2738/* An X form instruction with the L bits specified. */
2739#define XOPL2(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 3) << 21))
2740
2741/* An X form instruction with the L bit and RC bit specified. */
2742#define XRCL(op, xop, l, rc) (XRC ((op), (xop), (rc)) | ((((unsigned long)(l)) & 1) << 21))
2743
2744/* An X form instruction with RT fields specified */
2745#define XRT(op, xop, rt) (X ((op), (xop)) \
2746 | ((((unsigned long)(rt)) & 0x1f) << 21))
2747
2748/* An X form instruction with RT and RA fields specified */
2749#define XRTRA(op, xop, rt, ra) (X ((op), (xop)) \
2750 | ((((unsigned long)(rt)) & 0x1f) << 21) \
2751 | ((((unsigned long)(ra)) & 0x1f) << 16))
2752
1706/* The mask for an X form comparison instruction. */ 2753/* The mask for an X form comparison instruction. */
1707#define XCMP_MASK (X_MASK | (((unsigned long)1) << 22)) 2754#define XCMP_MASK (X_MASK | (((unsigned long)1) << 22))
1708 2755
@@ -1724,6 +2771,9 @@ extract_tbr (unsigned long insn,
1724/* An X form sync instruction with everything filled in except the LS field. */ 2771/* An X form sync instruction with everything filled in except the LS field. */
1725#define XSYNC_MASK (0xff9fffff) 2772#define XSYNC_MASK (0xff9fffff)
1726 2773
2774/* An X form sync instruction with everything filled in except the L and E fields. */
2775#define XSYNCLE_MASK (0xff90ffff)
2776
1727/* An X_MASK, but with the EH bit clear. */ 2777/* An X_MASK, but with the EH bit clear. */
1728#define XEH_MASK (X_MASK & ~((unsigned long )1)) 2778#define XEH_MASK (X_MASK & ~((unsigned long )1))
1729 2779
@@ -1733,11 +2783,11 @@ extract_tbr (unsigned long insn,
1733 2783
1734/* An XFL form instruction. */ 2784/* An XFL form instruction. */
1735#define XFL(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1) | (((unsigned long)(rc)) & 1)) 2785#define XFL(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1) | (((unsigned long)(rc)) & 1))
1736#define XFL_MASK (XFL (0x3f, 0x3ff, 1) | (((unsigned long)1) << 25) | (((unsigned long)1) << 16)) 2786#define XFL_MASK XFL (0x3f, 0x3ff, 1)
1737 2787
1738/* An X form isel instruction. */ 2788/* An X form isel instruction. */
1739#define XISEL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1)) 2789#define XISEL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1))
1740#define XISEL_MASK XISEL(0x3f, 0x1f) 2790#define XISEL_MASK XISEL(0x3f, 0x1f)
1741 2791
1742/* An XL form instruction with the LK field set to 0. */ 2792/* An XL form instruction with the LK field set to 0. */
1743#define XL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1)) 2793#define XL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1))
@@ -1748,6 +2798,9 @@ extract_tbr (unsigned long insn,
1748/* The mask for an XL form instruction. */ 2798/* The mask for an XL form instruction. */
1749#define XL_MASK XLLK (0x3f, 0x3ff, 1) 2799#define XL_MASK XLLK (0x3f, 0x3ff, 1)
1750 2800
2801/* An XL_MASK with the RT, RA and RB fields fixed, but S bit clear. */
2802#define XLS_MASK ((XL_MASK | RT_MASK | RA_MASK | RB_MASK) & ~(1 << 11))
2803
1751/* An XL form instruction which explicitly sets the BO field. */ 2804/* An XL form instruction which explicitly sets the BO field. */
1752#define XLO(op, bo, xop, lk) \ 2805#define XLO(op, bo, xop, lk) \
1753 (XLLK ((op), (xop), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21)) 2806 (XLLK ((op), (xop), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21))
@@ -1778,6 +2831,9 @@ extract_tbr (unsigned long insn,
1778/* An XL_MASK with the BO, BI and BB fields fixed. */ 2831/* An XL_MASK with the BO, BI and BB fields fixed. */
1779#define XLBOBIBB_MASK (XL_MASK | BO_MASK | BI_MASK | BB_MASK) 2832#define XLBOBIBB_MASK (XL_MASK | BO_MASK | BI_MASK | BB_MASK)
1780 2833
2834/* An X form mbar instruction with MO field. */
2835#define XMBAR(op, xop, mo) (X ((op), (xop)) | ((((unsigned long)(mo)) & 1) << 21))
2836
1781/* An XO form instruction. */ 2837/* An XO form instruction. */
1782#define XO(op, xop, oe, rc) \ 2838#define XO(op, xop, oe, rc) \
1783 (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1) | ((((unsigned long)(oe)) & 1) << 10) | (((unsigned long)(rc)) & 1)) 2839 (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1) | ((((unsigned long)(oe)) & 1) << 10) | (((unsigned long)(rc)) & 1))
@@ -1786,6 +2842,12 @@ extract_tbr (unsigned long insn,
1786/* An XO_MASK with the RB field fixed. */ 2842/* An XO_MASK with the RB field fixed. */
1787#define XORB_MASK (XO_MASK | RB_MASK) 2843#define XORB_MASK (XO_MASK | RB_MASK)
1788 2844
2845/* An XOPS form instruction for paired singles. */
2846#define XOPS(op, xop, rc) \
2847 (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1) | (((unsigned long)(rc)) & 1))
2848#define XOPS_MASK XOPS (0x3f, 0x3ff, 1)
2849
2850
1789/* An XS form instruction. */ 2851/* An XS form instruction. */
1790#define XS(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 2) | (((unsigned long)(rc)) & 1)) 2852#define XS(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 2) | (((unsigned long)(rc)) & 1))
1791#define XS_MASK XS (0x3f, 0x1ff, 1) 2853#define XS_MASK XS (0x3f, 0x1ff, 1)
@@ -1809,7 +2871,7 @@ extract_tbr (unsigned long insn,
1809 2871
1810/* An XFX form instruction with the SPR field filled in except for the 2872/* An XFX form instruction with the SPR field filled in except for the
1811 SPRG field. */ 2873 SPRG field. */
1812#define XSPRG_MASK (XSPR_MASK & ~(0x17 << 16)) 2874#define XSPRG_MASK (XSPR_MASK & ~(0x1f << 16))
1813 2875
1814/* An X form instruction with everything filled in except the E field. */ 2876/* An X form instruction with everything filled in except the E field. */
1815#define XE_MASK (0xffff7fff) 2877#define XE_MASK (0xffff7fff)
@@ -1818,6 +2880,19 @@ extract_tbr (unsigned long insn,
1818#define XUC(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f)) 2880#define XUC(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f))
1819#define XUC_MASK XUC(0x3f, 0x1f) 2881#define XUC_MASK XUC(0x3f, 0x1f)
1820 2882
2883/* An XW form instruction. */
2884#define XW(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x3f) << 1) | ((rc) & 1))
2885/* The mask for a G form instruction. rc not supported at present. */
2886#define XW_MASK XW (0x3f, 0x3f, 0)
2887
2888/* An APU form instruction. */
2889#define APU(op, xop, rc) (OP (op) | (((unsigned long)(xop)) & 0x3ff) << 1 | ((rc) & 1))
2890
2891/* The mask for an APU form instruction. */
2892#define APU_MASK APU (0x3f, 0x3ff, 1)
2893#define APU_RT_MASK (APU_MASK | RT_MASK)
2894#define APU_RA_MASK (APU_MASK | RA_MASK)
2895
1821/* The BO encodings used in extended conditional branch mnemonics. */ 2896/* The BO encodings used in extended conditional branch mnemonics. */
1822#define BODNZF (0x0) 2897#define BODNZF (0x0)
1823#define BODNZFP (0x1) 2898#define BODNZFP (0x1)
@@ -1848,6 +2923,16 @@ extract_tbr (unsigned long insn,
1848 2923
1849#define BOU (0x14) 2924#define BOU (0x14)
1850 2925
2926/* The BO16 encodings used in extended VLE conditional branch mnemonics. */
2927#define BO16F (0x0)
2928#define BO16T (0x1)
2929
2930/* The BO32 encodings used in extended VLE conditional branch mnemonics. */
2931#define BO32F (0x0)
2932#define BO32T (0x1)
2933#define BO32DNZ (0x2)
2934#define BO32DZ (0x3)
2935
1851/* The BI condition bit encodings used in extended conditional branch 2936/* The BI condition bit encodings used in extended conditional branch
1852 mnemonics. */ 2937 mnemonics. */
1853#define CBLT (0) 2938#define CBLT (0)
@@ -1875,3066 +2960,4267 @@ extract_tbr (unsigned long insn,
1875/* Smaller names for the flags so each entry in the opcodes table will 2960/* Smaller names for the flags so each entry in the opcodes table will
1876 fit on a single line. */ 2961 fit on a single line. */
1877#undef PPC 2962#undef PPC
1878#define PPC PPC_OPCODE_PPC 2963#define PPC PPC_OPCODE_PPC
1879#define PPCCOM PPC_OPCODE_PPC | PPC_OPCODE_COMMON 2964#define PPCCOM PPC_OPCODE_PPC | PPC_OPCODE_COMMON
1880#define NOPOWER4 PPC_OPCODE_NOPOWER4 | PPCCOM
1881#define POWER4 PPC_OPCODE_POWER4 2965#define POWER4 PPC_OPCODE_POWER4
1882#define POWER5 PPC_OPCODE_POWER5 2966#define POWER5 PPC_OPCODE_POWER5
1883#define POWER6 PPC_OPCODE_POWER6 2967#define POWER6 PPC_OPCODE_POWER6
2968#define POWER7 PPC_OPCODE_POWER7
2969#define POWER8 PPC_OPCODE_POWER8
2970#define POWER9 PPC_OPCODE_POWER9
1884#define CELL PPC_OPCODE_CELL 2971#define CELL PPC_OPCODE_CELL
1885#define PPC32 PPC_OPCODE_32 | PPC_OPCODE_PPC 2972#define PPC64 PPC_OPCODE_64 | PPC_OPCODE_64_BRIDGE
1886#define PPC64 PPC_OPCODE_64 | PPC_OPCODE_PPC 2973#define NON32 (PPC_OPCODE_64 | PPC_OPCODE_POWER4 \
2974 | PPC_OPCODE_EFS | PPC_OPCODE_E500MC | PPC_OPCODE_TITAN)
1887#define PPC403 PPC_OPCODE_403 2975#define PPC403 PPC_OPCODE_403
1888#define PPC405 PPC403 2976#define PPC405 PPC_OPCODE_405
1889#define PPC440 PPC_OPCODE_440 2977#define PPC440 PPC_OPCODE_440
1890#define PPC750 PPC 2978#define PPC464 PPC440
1891#define PPC860 PPC 2979#define PPC476 PPC_OPCODE_476
2980#define PPC750 PPC_OPCODE_750
2981#define PPC7450 PPC_OPCODE_7450
2982#define PPC860 PPC_OPCODE_860
2983#define PPCPS PPC_OPCODE_PPCPS
1892#define PPCVEC PPC_OPCODE_ALTIVEC 2984#define PPCVEC PPC_OPCODE_ALTIVEC
1893#define POWER PPC_OPCODE_POWER 2985#define PPCVEC2 PPC_OPCODE_ALTIVEC2
1894#define POWER2 PPC_OPCODE_POWER | PPC_OPCODE_POWER2 2986#define PPCVEC3 PPC_OPCODE_ALTIVEC2
1895#define PPCPWR2 PPC_OPCODE_PPC | PPC_OPCODE_POWER | PPC_OPCODE_POWER2 2987#define PPCVSX PPC_OPCODE_VSX
1896#define POWER32 PPC_OPCODE_POWER | PPC_OPCODE_32 2988#define PPCVSX2 PPC_OPCODE_VSX
1897#define COM PPC_OPCODE_POWER | PPC_OPCODE_PPC | PPC_OPCODE_COMMON 2989#define PPCVSX3 PPC_OPCODE_VSX3
1898#define COM32 PPC_OPCODE_POWER | PPC_OPCODE_PPC | PPC_OPCODE_COMMON | PPC_OPCODE_32 2990#define POWER PPC_OPCODE_POWER
1899#define M601 PPC_OPCODE_POWER | PPC_OPCODE_601 2991#define POWER2 PPC_OPCODE_POWER | PPC_OPCODE_POWER2
2992#define PWR2COM PPC_OPCODE_POWER | PPC_OPCODE_POWER2 | PPC_OPCODE_COMMON
2993#define PPCPWR2 PPC_OPCODE_PPC | PPC_OPCODE_POWER | PPC_OPCODE_POWER2 | PPC_OPCODE_COMMON
2994#define COM PPC_OPCODE_POWER | PPC_OPCODE_PPC | PPC_OPCODE_COMMON
2995#define M601 PPC_OPCODE_POWER | PPC_OPCODE_601
1900#define PWRCOM PPC_OPCODE_POWER | PPC_OPCODE_601 | PPC_OPCODE_COMMON 2996#define PWRCOM PPC_OPCODE_POWER | PPC_OPCODE_601 | PPC_OPCODE_COMMON
1901#define MFDEC1 PPC_OPCODE_POWER 2997#define MFDEC1 PPC_OPCODE_POWER
1902#define MFDEC2 PPC_OPCODE_PPC | PPC_OPCODE_601 | PPC_OPCODE_BOOKE 2998#define MFDEC2 PPC_OPCODE_PPC | PPC_OPCODE_601 | PPC_OPCODE_BOOKE | PPC_OPCODE_TITAN
1903#define BOOKE PPC_OPCODE_BOOKE 2999#define BOOKE PPC_OPCODE_BOOKE
1904#define BOOKE64 PPC_OPCODE_BOOKE64 3000#define NO371 PPC_OPCODE_BOOKE | PPC_OPCODE_PPCPS | PPC_OPCODE_EFS
1905#define CLASSIC PPC_OPCODE_CLASSIC
1906#define PPCE300 PPC_OPCODE_E300 3001#define PPCE300 PPC_OPCODE_E300
1907#define PPCSPE PPC_OPCODE_SPE 3002#define PPCSPE PPC_OPCODE_SPE
1908#define PPCISEL PPC_OPCODE_ISEL 3003#define PPCISEL PPC_OPCODE_ISEL
1909#define PPCEFS PPC_OPCODE_EFS 3004#define PPCEFS PPC_OPCODE_EFS
1910#define PPCBRLK PPC_OPCODE_BRLOCK 3005#define PPCBRLK PPC_OPCODE_BRLOCK
1911#define PPCPMR PPC_OPCODE_PMR 3006#define PPCPMR PPC_OPCODE_PMR
1912#define PPCCHLK PPC_OPCODE_CACHELCK 3007#define PPCTMR PPC_OPCODE_TMR
1913#define PPCCHLK64 PPC_OPCODE_CACHELCK | PPC_OPCODE_BOOKE64 3008#define PPCCHLK PPC_OPCODE_CACHELCK
1914#define PPCRFMCI PPC_OPCODE_RFMCI 3009#define PPCRFMCI PPC_OPCODE_RFMCI
3010#define E500MC PPC_OPCODE_E500MC
3011#define PPCA2 PPC_OPCODE_A2
3012#define TITAN PPC_OPCODE_TITAN
3013#define MULHW PPC_OPCODE_405 | PPC_OPCODE_440 | TITAN
3014#define E500 PPC_OPCODE_E500
3015#define E6500 PPC_OPCODE_E6500
3016#define PPCVLE PPC_OPCODE_VLE
3017#define PPCHTM PPC_OPCODE_HTM
3018#define E200Z4 PPC_OPCODE_E200Z4
3019/* The list of embedded processors that use the embedded operand ordering
3020 for the 3 operand dcbt and dcbtst instructions. */
3021#define DCBT_EO (PPC_OPCODE_E500 | PPC_OPCODE_E500MC | PPC_OPCODE_476 \
3022 | PPC_OPCODE_A2)
3023
3024
1915 3025
1916/* The opcode table. 3026/* The opcode table.
1917 3027
1918 The format of the opcode table is: 3028 The format of the opcode table is:
1919 3029
1920 NAME OPCODE MASK FLAGS { OPERANDS } 3030 NAME OPCODE MASK FLAGS ANTI {OPERANDS}
1921 3031
1922 NAME is the name of the instruction. 3032 NAME is the name of the instruction.
1923 OPCODE is the instruction opcode. 3033 OPCODE is the instruction opcode.
1924 MASK is the opcode mask; this is used to tell the disassembler 3034 MASK is the opcode mask; this is used to tell the disassembler
1925 which bits in the actual opcode must match OPCODE. 3035 which bits in the actual opcode must match OPCODE.
1926 FLAGS are flags indicated what processors support the instruction. 3036 FLAGS are flags indicating which processors support the instruction.
3037 ANTI indicates which processors don't support the instruction.
1927 OPERANDS is the list of operands. 3038 OPERANDS is the list of operands.
1928 3039
1929 The disassembler reads the table in order and prints the first 3040 The disassembler reads the table in order and prints the first
1930 instruction which matches, so this table is sorted to put more 3041 instruction which matches, so this table is sorted to put more
1931 specific instructions before more general instructions. It is also 3042 specific instructions before more general instructions.
1932 sorted by major opcode. */ 3043
3044 This table must be sorted by major opcode. Please try to keep it
3045 vaguely sorted within major opcode too, except of course where
3046 constrained otherwise by disassembler operation. */
1933 3047
1934const struct powerpc_opcode powerpc_opcodes[] = { 3048const struct powerpc_opcode powerpc_opcodes[] = {
1935{ "attn", X(0,256), X_MASK, POWER4, { 0 } }, 3049{"attn", X(0,256), X_MASK, POWER4|PPCA2, PPC476|PPCVLE, {0}},
1936{ "tdlgti", OPTO(2,TOLGT), OPTO_MASK, PPC64, { RA, SI } }, 3050{"tdlgti", OPTO(2,TOLGT), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1937{ "tdllti", OPTO(2,TOLLT), OPTO_MASK, PPC64, { RA, SI } }, 3051{"tdllti", OPTO(2,TOLLT), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1938{ "tdeqi", OPTO(2,TOEQ), OPTO_MASK, PPC64, { RA, SI } }, 3052{"tdeqi", OPTO(2,TOEQ), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1939{ "tdlgei", OPTO(2,TOLGE), OPTO_MASK, PPC64, { RA, SI } }, 3053{"tdlgei", OPTO(2,TOLGE), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1940{ "tdlnli", OPTO(2,TOLNL), OPTO_MASK, PPC64, { RA, SI } }, 3054{"tdlnli", OPTO(2,TOLNL), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1941{ "tdllei", OPTO(2,TOLLE), OPTO_MASK, PPC64, { RA, SI } }, 3055{"tdllei", OPTO(2,TOLLE), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1942{ "tdlngi", OPTO(2,TOLNG), OPTO_MASK, PPC64, { RA, SI } }, 3056{"tdlngi", OPTO(2,TOLNG), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1943{ "tdgti", OPTO(2,TOGT), OPTO_MASK, PPC64, { RA, SI } }, 3057{"tdgti", OPTO(2,TOGT), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1944{ "tdgei", OPTO(2,TOGE), OPTO_MASK, PPC64, { RA, SI } }, 3058{"tdgei", OPTO(2,TOGE), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1945{ "tdnli", OPTO(2,TONL), OPTO_MASK, PPC64, { RA, SI } }, 3059{"tdnli", OPTO(2,TONL), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1946{ "tdlti", OPTO(2,TOLT), OPTO_MASK, PPC64, { RA, SI } }, 3060{"tdlti", OPTO(2,TOLT), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1947{ "tdlei", OPTO(2,TOLE), OPTO_MASK, PPC64, { RA, SI } }, 3061{"tdlei", OPTO(2,TOLE), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1948{ "tdngi", OPTO(2,TONG), OPTO_MASK, PPC64, { RA, SI } }, 3062{"tdngi", OPTO(2,TONG), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1949{ "tdnei", OPTO(2,TONE), OPTO_MASK, PPC64, { RA, SI } }, 3063{"tdnei", OPTO(2,TONE), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1950{ "tdi", OP(2), OP_MASK, PPC64, { TO, RA, SI } }, 3064{"tdui", OPTO(2,TOU), OPTO_MASK, PPC64, PPCVLE, {RA, SI}},
1951 3065{"tdi", OP(2), OP_MASK, PPC64, PPCVLE, {TO, RA, SI}},
1952{ "twlgti", OPTO(3,TOLGT), OPTO_MASK, PPCCOM, { RA, SI } }, 3066
1953{ "tlgti", OPTO(3,TOLGT), OPTO_MASK, PWRCOM, { RA, SI } }, 3067{"twlgti", OPTO(3,TOLGT), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1954{ "twllti", OPTO(3,TOLLT), OPTO_MASK, PPCCOM, { RA, SI } }, 3068{"tlgti", OPTO(3,TOLGT), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1955{ "tllti", OPTO(3,TOLLT), OPTO_MASK, PWRCOM, { RA, SI } }, 3069{"twllti", OPTO(3,TOLLT), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1956{ "tweqi", OPTO(3,TOEQ), OPTO_MASK, PPCCOM, { RA, SI } }, 3070{"tllti", OPTO(3,TOLLT), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1957{ "teqi", OPTO(3,TOEQ), OPTO_MASK, PWRCOM, { RA, SI } }, 3071{"tweqi", OPTO(3,TOEQ), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1958{ "twlgei", OPTO(3,TOLGE), OPTO_MASK, PPCCOM, { RA, SI } }, 3072{"teqi", OPTO(3,TOEQ), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1959{ "tlgei", OPTO(3,TOLGE), OPTO_MASK, PWRCOM, { RA, SI } }, 3073{"twlgei", OPTO(3,TOLGE), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1960{ "twlnli", OPTO(3,TOLNL), OPTO_MASK, PPCCOM, { RA, SI } }, 3074{"tlgei", OPTO(3,TOLGE), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1961{ "tlnli", OPTO(3,TOLNL), OPTO_MASK, PWRCOM, { RA, SI } }, 3075{"twlnli", OPTO(3,TOLNL), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1962{ "twllei", OPTO(3,TOLLE), OPTO_MASK, PPCCOM, { RA, SI } }, 3076{"tlnli", OPTO(3,TOLNL), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1963{ "tllei", OPTO(3,TOLLE), OPTO_MASK, PWRCOM, { RA, SI } }, 3077{"twllei", OPTO(3,TOLLE), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1964{ "twlngi", OPTO(3,TOLNG), OPTO_MASK, PPCCOM, { RA, SI } }, 3078{"tllei", OPTO(3,TOLLE), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1965{ "tlngi", OPTO(3,TOLNG), OPTO_MASK, PWRCOM, { RA, SI } }, 3079{"twlngi", OPTO(3,TOLNG), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1966{ "twgti", OPTO(3,TOGT), OPTO_MASK, PPCCOM, { RA, SI } }, 3080{"tlngi", OPTO(3,TOLNG), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1967{ "tgti", OPTO(3,TOGT), OPTO_MASK, PWRCOM, { RA, SI } }, 3081{"twgti", OPTO(3,TOGT), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1968{ "twgei", OPTO(3,TOGE), OPTO_MASK, PPCCOM, { RA, SI } }, 3082{"tgti", OPTO(3,TOGT), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1969{ "tgei", OPTO(3,TOGE), OPTO_MASK, PWRCOM, { RA, SI } }, 3083{"twgei", OPTO(3,TOGE), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1970{ "twnli", OPTO(3,TONL), OPTO_MASK, PPCCOM, { RA, SI } }, 3084{"tgei", OPTO(3,TOGE), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1971{ "tnli", OPTO(3,TONL), OPTO_MASK, PWRCOM, { RA, SI } }, 3085{"twnli", OPTO(3,TONL), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1972{ "twlti", OPTO(3,TOLT), OPTO_MASK, PPCCOM, { RA, SI } }, 3086{"tnli", OPTO(3,TONL), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1973{ "tlti", OPTO(3,TOLT), OPTO_MASK, PWRCOM, { RA, SI } }, 3087{"twlti", OPTO(3,TOLT), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1974{ "twlei", OPTO(3,TOLE), OPTO_MASK, PPCCOM, { RA, SI } }, 3088{"tlti", OPTO(3,TOLT), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1975{ "tlei", OPTO(3,TOLE), OPTO_MASK, PWRCOM, { RA, SI } }, 3089{"twlei", OPTO(3,TOLE), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1976{ "twngi", OPTO(3,TONG), OPTO_MASK, PPCCOM, { RA, SI } }, 3090{"tlei", OPTO(3,TOLE), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1977{ "tngi", OPTO(3,TONG), OPTO_MASK, PWRCOM, { RA, SI } }, 3091{"twngi", OPTO(3,TONG), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1978{ "twnei", OPTO(3,TONE), OPTO_MASK, PPCCOM, { RA, SI } }, 3092{"tngi", OPTO(3,TONG), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1979{ "tnei", OPTO(3,TONE), OPTO_MASK, PWRCOM, { RA, SI } }, 3093{"twnei", OPTO(3,TONE), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1980{ "twi", OP(3), OP_MASK, PPCCOM, { TO, RA, SI } }, 3094{"tnei", OPTO(3,TONE), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1981{ "ti", OP(3), OP_MASK, PWRCOM, { TO, RA, SI } }, 3095{"twui", OPTO(3,TOU), OPTO_MASK, PPCCOM, PPCVLE, {RA, SI}},
1982 3096{"tui", OPTO(3,TOU), OPTO_MASK, PWRCOM, PPCVLE, {RA, SI}},
1983{ "macchw", XO(4,172,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3097{"twi", OP(3), OP_MASK, PPCCOM, PPCVLE, {TO, RA, SI}},
1984{ "macchw.", XO(4,172,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3098{"ti", OP(3), OP_MASK, PWRCOM, PPCVLE, {TO, RA, SI}},
1985{ "macchwo", XO(4,172,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3099
1986{ "macchwo.", XO(4,172,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3100{"ps_cmpu0", X (4, 0), XBF_MASK, PPCPS, 0, {BF, FRA, FRB}},
1987{ "macchws", XO(4,236,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3101{"vaddubm", VX (4, 0), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
1988{ "macchws.", XO(4,236,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3102{"vmul10cuq", VX (4, 1), VXVB_MASK, PPCVEC3, 0, {VD, VA}},
1989{ "macchwso", XO(4,236,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3103{"vmaxub", VX (4, 2), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
1990{ "macchwso.", XO(4,236,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3104{"vrlb", VX (4, 4), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
1991{ "macchwsu", XO(4,204,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3105{"vcmpequb", VXR(4, 6,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
1992{ "macchwsu.", XO(4,204,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3106{"vcmpneb", VXR(4, 7,0), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
1993{ "macchwsuo", XO(4,204,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3107{"vmuloub", VX (4, 8), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
1994{ "macchwsuo.", XO(4,204,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3108{"vaddfp", VX (4, 10), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
1995{ "macchwu", XO(4,140,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3109{"psq_lx", XW (4, 6,0), XW_MASK, PPCPS, 0, {FRT,RA,RB,PSWM,PSQM}},
1996{ "macchwu.", XO(4,140,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3110{"vmrghb", VX (4, 12), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
1997{ "macchwuo", XO(4,140,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3111{"psq_stx", XW (4, 7,0), XW_MASK, PPCPS, 0, {FRS,RA,RB,PSWM,PSQM}},
1998{ "macchwuo.", XO(4,140,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3112{"vpkuhum", VX (4, 14), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
1999{ "machhw", XO(4,44,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3113{"mulhhwu", XRC(4, 8,0), X_MASK, MULHW, 0, {RT, RA, RB}},
2000{ "machhw.", XO(4,44,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3114{"mulhhwu.", XRC(4, 8,1), X_MASK, MULHW, 0, {RT, RA, RB}},
2001{ "machhwo", XO(4,44,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3115{"ps_sum0", A (4, 10,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2002{ "machhwo.", XO(4,44,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3116{"ps_sum0.", A (4, 10,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2003{ "machhws", XO(4,108,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3117{"ps_sum1", A (4, 11,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2004{ "machhws.", XO(4,108,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3118{"ps_sum1.", A (4, 11,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2005{ "machhwso", XO(4,108,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3119{"ps_muls0", A (4, 12,0), AFRB_MASK, PPCPS, 0, {FRT, FRA, FRC}},
2006{ "machhwso.", XO(4,108,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3120{"machhwu", XO (4, 12,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2007{ "machhwsu", XO(4,76,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3121{"ps_muls0.", A (4, 12,1), AFRB_MASK, PPCPS, 0, {FRT, FRA, FRC}},
2008{ "machhwsu.", XO(4,76,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3122{"machhwu.", XO (4, 12,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2009{ "machhwsuo", XO(4,76,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3123{"ps_muls1", A (4, 13,0), AFRB_MASK, PPCPS, 0, {FRT, FRA, FRC}},
2010{ "machhwsuo.", XO(4,76,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3124{"ps_muls1.", A (4, 13,1), AFRB_MASK, PPCPS, 0, {FRT, FRA, FRC}},
2011{ "machhwu", XO(4,12,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3125{"ps_madds0", A (4, 14,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2012{ "machhwu.", XO(4,12,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3126{"ps_madds0.", A (4, 14,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2013{ "machhwuo", XO(4,12,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3127{"ps_madds1", A (4, 15,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2014{ "machhwuo.", XO(4,12,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3128{"ps_madds1.", A (4, 15,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2015{ "maclhw", XO(4,428,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3129{"vmhaddshs", VXA(4, 32), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2016{ "maclhw.", XO(4,428,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3130{"vmhraddshs", VXA(4, 33), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2017{ "maclhwo", XO(4,428,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3131{"vmladduhm", VXA(4, 34), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2018{ "maclhwo.", XO(4,428,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3132{"vmsumudm", VXA(4, 35), VXA_MASK, PPCVEC3, 0, {VD, VA, VB, VC}},
2019{ "maclhws", XO(4,492,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3133{"ps_div", A (4, 18,0), AFRC_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2020{ "maclhws.", XO(4,492,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3134{"vmsumubm", VXA(4, 36), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2021{ "maclhwso", XO(4,492,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3135{"ps_div.", A (4, 18,1), AFRC_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2022{ "maclhwso.", XO(4,492,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3136{"vmsummbm", VXA(4, 37), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2023{ "maclhwsu", XO(4,460,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3137{"vmsumuhm", VXA(4, 38), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2024{ "maclhwsu.", XO(4,460,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3138{"vmsumuhs", VXA(4, 39), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2025{ "maclhwsuo", XO(4,460,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3139{"ps_sub", A (4, 20,0), AFRC_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2026{ "maclhwsuo.", XO(4,460,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3140{"vmsumshm", VXA(4, 40), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2027{ "maclhwu", XO(4,396,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3141{"ps_sub.", A (4, 20,1), AFRC_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2028{ "maclhwu.", XO(4,396,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3142{"vmsumshs", VXA(4, 41), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2029{ "maclhwuo", XO(4,396,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3143{"ps_add", A (4, 21,0), AFRC_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2030{ "maclhwuo.", XO(4,396,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3144{"vsel", VXA(4, 42), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2031{ "mulchw", XRC(4,168,0), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3145{"ps_add.", A (4, 21,1), AFRC_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2032{ "mulchw.", XRC(4,168,1), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3146{"vperm", VXA(4, 43), VXA_MASK, PPCVEC, 0, {VD, VA, VB, VC}},
2033{ "mulchwu", XRC(4,136,0), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3147{"vsldoi", VXA(4, 44), VXASHB_MASK, PPCVEC, 0, {VD, VA, VB, SHB}},
2034{ "mulchwu.", XRC(4,136,1), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3148{"vpermxor", VXA(4, 45), VXA_MASK, PPCVEC2, 0, {VD, VA, VB, VC}},
2035{ "mulhhw", XRC(4,40,0), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3149{"ps_sel", A (4, 23,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2036{ "mulhhw.", XRC(4,40,1), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3150{"vmaddfp", VXA(4, 46), VXA_MASK, PPCVEC, 0, {VD, VA, VC, VB}},
2037{ "mulhhwu", XRC(4,8,0), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3151{"ps_sel.", A (4, 23,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2038{ "mulhhwu.", XRC(4,8,1), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3152{"vnmsubfp", VXA(4, 47), VXA_MASK, PPCVEC, 0, {VD, VA, VC, VB}},
2039{ "mullhw", XRC(4,424,0), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3153{"ps_res", A (4, 24,0), AFRAFRC_MASK, PPCPS, 0, {FRT, FRB}},
2040{ "mullhw.", XRC(4,424,1), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3154{"maddhd", VXA(4, 48), VXA_MASK, POWER9, 0, {RT, RA, RB, RC}},
2041{ "mullhwu", XRC(4,392,0), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3155{"ps_res.", A (4, 24,1), AFRAFRC_MASK, PPCPS, 0, {FRT, FRB}},
2042{ "mullhwu.", XRC(4,392,1), X_MASK, PPC405|PPC440, { RT, RA, RB } }, 3156{"maddhdu", VXA(4, 49), VXA_MASK, POWER9, 0, {RT, RA, RB, RC}},
2043{ "nmacchw", XO(4,174,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3157{"ps_mul", A (4, 25,0), AFRB_MASK, PPCPS, 0, {FRT, FRA, FRC}},
2044{ "nmacchw.", XO(4,174,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3158{"ps_mul.", A (4, 25,1), AFRB_MASK, PPCPS, 0, {FRT, FRA, FRC}},
2045{ "nmacchwo", XO(4,174,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3159{"maddld", VXA(4, 51), VXA_MASK, POWER9, 0, {RT, RA, RB, RC}},
2046{ "nmacchwo.", XO(4,174,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3160{"ps_rsqrte", A (4, 26,0), AFRAFRC_MASK, PPCPS, 0, {FRT, FRB}},
2047{ "nmacchws", XO(4,238,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3161{"ps_rsqrte.", A (4, 26,1), AFRAFRC_MASK, PPCPS, 0, {FRT, FRB}},
2048{ "nmacchws.", XO(4,238,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3162{"ps_msub", A (4, 28,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2049{ "nmacchwso", XO(4,238,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3163{"ps_msub.", A (4, 28,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2050{ "nmacchwso.", XO(4,238,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3164{"ps_madd", A (4, 29,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2051{ "nmachhw", XO(4,46,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3165{"ps_madd.", A (4, 29,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2052{ "nmachhw.", XO(4,46,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3166{"vpermr", VXA(4, 59), VXA_MASK, PPCVEC3, 0, {VD, VA, VB, VC}},
2053{ "nmachhwo", XO(4,46,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3167{"ps_nmsub", A (4, 30,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2054{ "nmachhwo.", XO(4,46,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3168{"vaddeuqm", VXA(4, 60), VXA_MASK, PPCVEC2, 0, {VD, VA, VB, VC}},
2055{ "nmachhws", XO(4,110,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3169{"ps_nmsub.", A (4, 30,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2056{ "nmachhws.", XO(4,110,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3170{"vaddecuq", VXA(4, 61), VXA_MASK, PPCVEC2, 0, {VD, VA, VB, VC}},
2057{ "nmachhwso", XO(4,110,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3171{"ps_nmadd", A (4, 31,0), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2058{ "nmachhwso.", XO(4,110,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3172{"vsubeuqm", VXA(4, 62), VXA_MASK, PPCVEC2, 0, {VD, VA, VB, VC}},
2059{ "nmaclhw", XO(4,430,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3173{"ps_nmadd.", A (4, 31,1), A_MASK, PPCPS, 0, {FRT, FRA, FRC, FRB}},
2060{ "nmaclhw.", XO(4,430,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3174{"vsubecuq", VXA(4, 63), VXA_MASK, PPCVEC2, 0, {VD, VA, VB, VC}},
2061{ "nmaclhwo", XO(4,430,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3175{"ps_cmpo0", X (4, 32), XBF_MASK, PPCPS, 0, {BF, FRA, FRB}},
2062{ "nmaclhwo.", XO(4,430,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3176{"vadduhm", VX (4, 64), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2063{ "nmaclhws", XO(4,494,0,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3177{"vmul10ecuq", VX (4, 65), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2064{ "nmaclhws.", XO(4,494,0,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3178{"vmaxuh", VX (4, 66), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2065{ "nmaclhwso", XO(4,494,1,0), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3179{"vrlh", VX (4, 68), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2066{ "nmaclhwso.", XO(4,494,1,1), XO_MASK, PPC405|PPC440, { RT, RA, RB } }, 3180{"vcmpequh", VXR(4, 70,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2067{ "mfvscr", VX(4, 1540), VX_MASK, PPCVEC, { VD } }, 3181{"vcmpneh", VXR(4, 71,0), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2068{ "mtvscr", VX(4, 1604), VX_MASK, PPCVEC, { VB } }, 3182{"vmulouh", VX (4, 72), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2069 3183{"vsubfp", VX (4, 74), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2070 /* Double-precision opcodes. */ 3184{"psq_lux", XW (4, 38,0), XW_MASK, PPCPS, 0, {FRT,RA,RB,PSWM,PSQM}},
2071 /* Some of these conflict with AltiVec, so move them before, since 3185{"vmrghh", VX (4, 76), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2072 PPCVEC includes the PPC_OPCODE_PPC set. */ 3186{"psq_stux", XW (4, 39,0), XW_MASK, PPCPS, 0, {FRS,RA,RB,PSWM,PSQM}},
2073{ "efscfd", VX(4, 719), VX_MASK, PPCEFS, { RS, RB } }, 3187{"vpkuwum", VX (4, 78), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2074{ "efdabs", VX(4, 740), VX_MASK, PPCEFS, { RS, RA } }, 3188{"ps_neg", XRC(4, 40,0), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2075{ "efdnabs", VX(4, 741), VX_MASK, PPCEFS, { RS, RA } }, 3189{"mulhhw", XRC(4, 40,0), X_MASK, MULHW, 0, {RT, RA, RB}},
2076{ "efdneg", VX(4, 742), VX_MASK, PPCEFS, { RS, RA } }, 3190{"ps_neg.", XRC(4, 40,1), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2077{ "efdadd", VX(4, 736), VX_MASK, PPCEFS, { RS, RA, RB } }, 3191{"mulhhw.", XRC(4, 40,1), X_MASK, MULHW, 0, {RT, RA, RB}},
2078{ "efdsub", VX(4, 737), VX_MASK, PPCEFS, { RS, RA, RB } }, 3192{"machhw", XO (4, 44,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2079{ "efdmul", VX(4, 744), VX_MASK, PPCEFS, { RS, RA, RB } }, 3193{"machhw.", XO (4, 44,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2080{ "efddiv", VX(4, 745), VX_MASK, PPCEFS, { RS, RA, RB } }, 3194{"nmachhw", XO (4, 46,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2081{ "efdcmpgt", VX(4, 748), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3195{"nmachhw.", XO (4, 46,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2082{ "efdcmplt", VX(4, 749), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3196{"ps_cmpu1", X (4, 64), XBF_MASK, PPCPS, 0, {BF, FRA, FRB}},
2083{ "efdcmpeq", VX(4, 750), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3197{"vadduwm", VX (4, 128), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2084{ "efdtstgt", VX(4, 764), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3198{"vmaxuw", VX (4, 130), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2085{ "efdtstlt", VX(4, 765), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3199{"vrlw", VX (4, 132), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2086{ "efdtsteq", VX(4, 766), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3200{"vrlwmi", VX (4, 133), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2087{ "efdcfsi", VX(4, 753), VX_MASK, PPCEFS, { RS, RB } }, 3201{"vcmpequw", VXR(4, 134,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2088{ "efdcfsid", VX(4, 739), VX_MASK, PPCEFS, { RS, RB } }, 3202{"vcmpnew", VXR(4, 135,0), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2089{ "efdcfui", VX(4, 752), VX_MASK, PPCEFS, { RS, RB } }, 3203{"vmulouw", VX (4, 136), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2090{ "efdcfuid", VX(4, 738), VX_MASK, PPCEFS, { RS, RB } }, 3204{"vmuluwm", VX (4, 137), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2091{ "efdcfsf", VX(4, 755), VX_MASK, PPCEFS, { RS, RB } }, 3205{"vmrghw", VX (4, 140), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2092{ "efdcfuf", VX(4, 754), VX_MASK, PPCEFS, { RS, RB } }, 3206{"vpkuhus", VX (4, 142), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2093{ "efdctsi", VX(4, 757), VX_MASK, PPCEFS, { RS, RB } }, 3207{"ps_mr", XRC(4, 72,0), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2094{ "efdctsidz",VX(4, 747), VX_MASK, PPCEFS, { RS, RB } }, 3208{"ps_mr.", XRC(4, 72,1), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2095{ "efdctsiz", VX(4, 762), VX_MASK, PPCEFS, { RS, RB } }, 3209{"machhwsu", XO (4, 76,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2096{ "efdctui", VX(4, 756), VX_MASK, PPCEFS, { RS, RB } }, 3210{"machhwsu.", XO (4, 76,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2097{ "efdctuidz",VX(4, 746), VX_MASK, PPCEFS, { RS, RB } }, 3211{"ps_cmpo1", X (4, 96), XBF_MASK, PPCPS, 0, {BF, FRA, FRB}},
2098{ "efdctuiz", VX(4, 760), VX_MASK, PPCEFS, { RS, RB } }, 3212{"vaddudm", VX (4, 192), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2099{ "efdctsf", VX(4, 759), VX_MASK, PPCEFS, { RS, RB } }, 3213{"vmaxud", VX (4, 194), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2100{ "efdctuf", VX(4, 758), VX_MASK, PPCEFS, { RS, RB } }, 3214{"vrld", VX (4, 196), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2101{ "efdcfs", VX(4, 751), VX_MASK, PPCEFS, { RS, RB } }, 3215{"vrldmi", VX (4, 197), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2102 /* End of double-precision opcodes. */ 3216{"vcmpeqfp", VXR(4, 198,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2103 3217{"vcmpequd", VXR(4, 199,0), VXR_MASK, PPCVEC2, 0, {VD, VA, VB}},
2104{ "vaddcuw", VX(4, 384), VX_MASK, PPCVEC, { VD, VA, VB } }, 3218{"vpkuwus", VX (4, 206), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2105{ "vaddfp", VX(4, 10), VX_MASK, PPCVEC, { VD, VA, VB } }, 3219{"machhws", XO (4, 108,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2106{ "vaddsbs", VX(4, 768), VX_MASK, PPCVEC, { VD, VA, VB } }, 3220{"machhws.", XO (4, 108,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2107{ "vaddshs", VX(4, 832), VX_MASK, PPCVEC, { VD, VA, VB } }, 3221{"nmachhws", XO (4, 110,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2108{ "vaddsws", VX(4, 896), VX_MASK, PPCVEC, { VD, VA, VB } }, 3222{"nmachhws.", XO (4, 110,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2109{ "vaddubm", VX(4, 0), VX_MASK, PPCVEC, { VD, VA, VB } }, 3223{"vadduqm", VX (4, 256), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2110{ "vaddubs", VX(4, 512), VX_MASK, PPCVEC, { VD, VA, VB } }, 3224{"vmaxsb", VX (4, 258), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2111{ "vadduhm", VX(4, 64), VX_MASK, PPCVEC, { VD, VA, VB } }, 3225{"vslb", VX (4, 260), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2112{ "vadduhs", VX(4, 576), VX_MASK, PPCVEC, { VD, VA, VB } }, 3226{"vcmpnezb", VXR(4, 263,0), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2113{ "vadduwm", VX(4, 128), VX_MASK, PPCVEC, { VD, VA, VB } }, 3227{"vmulosb", VX (4, 264), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2114{ "vadduws", VX(4, 640), VX_MASK, PPCVEC, { VD, VA, VB } }, 3228{"vrefp", VX (4, 266), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2115{ "vand", VX(4, 1028), VX_MASK, PPCVEC, { VD, VA, VB } }, 3229{"vmrglb", VX (4, 268), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2116{ "vandc", VX(4, 1092), VX_MASK, PPCVEC, { VD, VA, VB } }, 3230{"vpkshus", VX (4, 270), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2117{ "vavgsb", VX(4, 1282), VX_MASK, PPCVEC, { VD, VA, VB } }, 3231{"ps_nabs", XRC(4, 136,0), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2118{ "vavgsh", VX(4, 1346), VX_MASK, PPCVEC, { VD, VA, VB } }, 3232{"mulchwu", XRC(4, 136,0), X_MASK, MULHW, 0, {RT, RA, RB}},
2119{ "vavgsw", VX(4, 1410), VX_MASK, PPCVEC, { VD, VA, VB } }, 3233{"ps_nabs.", XRC(4, 136,1), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2120{ "vavgub", VX(4, 1026), VX_MASK, PPCVEC, { VD, VA, VB } }, 3234{"mulchwu.", XRC(4, 136,1), X_MASK, MULHW, 0, {RT, RA, RB}},
2121{ "vavguh", VX(4, 1090), VX_MASK, PPCVEC, { VD, VA, VB } }, 3235{"macchwu", XO (4, 140,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2122{ "vavguw", VX(4, 1154), VX_MASK, PPCVEC, { VD, VA, VB } }, 3236{"macchwu.", XO (4, 140,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2123{ "vcfsx", VX(4, 842), VX_MASK, PPCVEC, { VD, VB, UIMM } }, 3237{"vaddcuq", VX (4, 320), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2124{ "vcfux", VX(4, 778), VX_MASK, PPCVEC, { VD, VB, UIMM } }, 3238{"vmaxsh", VX (4, 322), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2125{ "vcmpbfp", VXR(4, 966, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3239{"vslh", VX (4, 324), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2126{ "vcmpbfp.", VXR(4, 966, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3240{"vcmpnezh", VXR(4, 327,0), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2127{ "vcmpeqfp", VXR(4, 198, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3241{"vmulosh", VX (4, 328), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2128{ "vcmpeqfp.", VXR(4, 198, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3242{"vrsqrtefp", VX (4, 330), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2129{ "vcmpequb", VXR(4, 6, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3243{"vmrglh", VX (4, 332), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2130{ "vcmpequb.", VXR(4, 6, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3244{"vpkswus", VX (4, 334), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2131{ "vcmpequh", VXR(4, 70, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3245{"mulchw", XRC(4, 168,0), X_MASK, MULHW, 0, {RT, RA, RB}},
2132{ "vcmpequh.", VXR(4, 70, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3246{"mulchw.", XRC(4, 168,1), X_MASK, MULHW, 0, {RT, RA, RB}},
2133{ "vcmpequw", VXR(4, 134, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3247{"macchw", XO (4, 172,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2134{ "vcmpequw.", VXR(4, 134, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3248{"macchw.", XO (4, 172,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2135{ "vcmpgefp", VXR(4, 454, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3249{"nmacchw", XO (4, 174,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2136{ "vcmpgefp.", VXR(4, 454, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3250{"nmacchw.", XO (4, 174,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2137{ "vcmpgtfp", VXR(4, 710, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3251{"vaddcuw", VX (4, 384), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2138{ "vcmpgtfp.", VXR(4, 710, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3252{"vmaxsw", VX (4, 386), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2139{ "vcmpgtsb", VXR(4, 774, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3253{"vslw", VX (4, 388), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2140{ "vcmpgtsb.", VXR(4, 774, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3254{"vrlwnm", VX (4, 389), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2141{ "vcmpgtsh", VXR(4, 838, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3255{"vcmpnezw", VXR(4, 391,0), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2142{ "vcmpgtsh.", VXR(4, 838, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3256{"vmulosw", VX (4, 392), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2143{ "vcmpgtsw", VXR(4, 902, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3257{"vexptefp", VX (4, 394), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2144{ "vcmpgtsw.", VXR(4, 902, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3258{"vmrglw", VX (4, 396), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2145{ "vcmpgtub", VXR(4, 518, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3259{"vpkshss", VX (4, 398), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2146{ "vcmpgtub.", VXR(4, 518, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3260{"macchwsu", XO (4, 204,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2147{ "vcmpgtuh", VXR(4, 582, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3261{"macchwsu.", XO (4, 204,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2148{ "vcmpgtuh.", VXR(4, 582, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3262{"vmaxsd", VX (4, 450), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2149{ "vcmpgtuw", VXR(4, 646, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3263{"vsl", VX (4, 452), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2150{ "vcmpgtuw.", VXR(4, 646, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, 3264{"vrldnm", VX (4, 453), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2151{ "vctsxs", VX(4, 970), VX_MASK, PPCVEC, { VD, VB, UIMM } }, 3265{"vcmpgefp", VXR(4, 454,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2152{ "vctuxs", VX(4, 906), VX_MASK, PPCVEC, { VD, VB, UIMM } }, 3266{"vlogefp", VX (4, 458), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2153{ "vexptefp", VX(4, 394), VX_MASK, PPCVEC, { VD, VB } }, 3267{"vpkswss", VX (4, 462), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2154{ "vlogefp", VX(4, 458), VX_MASK, PPCVEC, { VD, VB } }, 3268{"macchws", XO (4, 236,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2155{ "vmaddfp", VXA(4, 46), VXA_MASK, PPCVEC, { VD, VA, VC, VB } }, 3269{"macchws.", XO (4, 236,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2156{ "vmaxfp", VX(4, 1034), VX_MASK, PPCVEC, { VD, VA, VB } }, 3270{"nmacchws", XO (4, 238,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2157{ "vmaxsb", VX(4, 258), VX_MASK, PPCVEC, { VD, VA, VB } }, 3271{"nmacchws.", XO (4, 238,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2158{ "vmaxsh", VX(4, 322), VX_MASK, PPCVEC, { VD, VA, VB } }, 3272{"evaddw", VX (4, 512), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2159{ "vmaxsw", VX(4, 386), VX_MASK, PPCVEC, { VD, VA, VB } }, 3273{"vaddubs", VX (4, 512), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2160{ "vmaxub", VX(4, 2), VX_MASK, PPCVEC, { VD, VA, VB } }, 3274{"vmul10uq", VX (4, 513), VXVB_MASK, PPCVEC3, 0, {VD, VA}},
2161{ "vmaxuh", VX(4, 66), VX_MASK, PPCVEC, { VD, VA, VB } }, 3275{"evaddiw", VX (4, 514), VX_MASK, PPCSPE, 0, {RS, RB, UIMM}},
2162{ "vmaxuw", VX(4, 130), VX_MASK, PPCVEC, { VD, VA, VB } }, 3276{"vminub", VX (4, 514), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2163{ "vmhaddshs", VXA(4, 32), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3277{"evsubfw", VX (4, 516), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2164{ "vmhraddshs", VXA(4, 33), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3278{"evsubw", VX (4, 516), VX_MASK, PPCSPE, 0, {RS, RB, RA}},
2165{ "vminfp", VX(4, 1098), VX_MASK, PPCVEC, { VD, VA, VB } }, 3279{"vsrb", VX (4, 516), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2166{ "vminsb", VX(4, 770), VX_MASK, PPCVEC, { VD, VA, VB } }, 3280{"evsubifw", VX (4, 518), VX_MASK, PPCSPE, 0, {RS, UIMM, RB}},
2167{ "vminsh", VX(4, 834), VX_MASK, PPCVEC, { VD, VA, VB } }, 3281{"evsubiw", VX (4, 518), VX_MASK, PPCSPE, 0, {RS, RB, UIMM}},
2168{ "vminsw", VX(4, 898), VX_MASK, PPCVEC, { VD, VA, VB } }, 3282{"vcmpgtub", VXR(4, 518,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2169{ "vminub", VX(4, 514), VX_MASK, PPCVEC, { VD, VA, VB } }, 3283{"evabs", VX (4, 520), VX_MASK, PPCSPE, 0, {RS, RA}},
2170{ "vminuh", VX(4, 578), VX_MASK, PPCVEC, { VD, VA, VB } }, 3284{"vmuleub", VX (4, 520), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2171{ "vminuw", VX(4, 642), VX_MASK, PPCVEC, { VD, VA, VB } }, 3285{"evneg", VX (4, 521), VX_MASK, PPCSPE, 0, {RS, RA}},
2172{ "vmladduhm", VXA(4, 34), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3286{"evextsb", VX (4, 522), VX_MASK, PPCSPE, 0, {RS, RA}},
2173{ "vmrghb", VX(4, 12), VX_MASK, PPCVEC, { VD, VA, VB } }, 3287{"vrfin", VX (4, 522), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2174{ "vmrghh", VX(4, 76), VX_MASK, PPCVEC, { VD, VA, VB } }, 3288{"evextsh", VX (4, 523), VX_MASK, PPCSPE, 0, {RS, RA}},
2175{ "vmrghw", VX(4, 140), VX_MASK, PPCVEC, { VD, VA, VB } }, 3289{"evrndw", VX (4, 524), VX_MASK, PPCSPE, 0, {RS, RA}},
2176{ "vmrglb", VX(4, 268), VX_MASK, PPCVEC, { VD, VA, VB } }, 3290{"vspltb", VX (4, 524), VXUIMM4_MASK, PPCVEC, 0, {VD, VB, UIMM4}},
2177{ "vmrglh", VX(4, 332), VX_MASK, PPCVEC, { VD, VA, VB } }, 3291{"vextractub", VX (4, 525), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2178{ "vmrglw", VX(4, 396), VX_MASK, PPCVEC, { VD, VA, VB } }, 3292{"evcntlzw", VX (4, 525), VX_MASK, PPCSPE, 0, {RS, RA}},
2179{ "vmsummbm", VXA(4, 37), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3293{"evcntlsw", VX (4, 526), VX_MASK, PPCSPE, 0, {RS, RA}},
2180{ "vmsumshm", VXA(4, 40), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3294{"vupkhsb", VX (4, 526), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2181{ "vmsumshs", VXA(4, 41), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3295{"brinc", VX (4, 527), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2182{ "vmsumubm", VXA(4, 36), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3296{"ps_abs", XRC(4, 264,0), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2183{ "vmsumuhm", VXA(4, 38), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3297{"ps_abs.", XRC(4, 264,1), XRA_MASK, PPCPS, 0, {FRT, FRB}},
2184{ "vmsumuhs", VXA(4, 39), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3298{"evand", VX (4, 529), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2185{ "vmulesb", VX(4, 776), VX_MASK, PPCVEC, { VD, VA, VB } }, 3299{"evandc", VX (4, 530), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2186{ "vmulesh", VX(4, 840), VX_MASK, PPCVEC, { VD, VA, VB } }, 3300{"evxor", VX (4, 534), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2187{ "vmuleub", VX(4, 520), VX_MASK, PPCVEC, { VD, VA, VB } }, 3301{"evmr", VX (4, 535), VX_MASK, PPCSPE, 0, {RS, RA, BBA}},
2188{ "vmuleuh", VX(4, 584), VX_MASK, PPCVEC, { VD, VA, VB } }, 3302{"evor", VX (4, 535), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2189{ "vmulosb", VX(4, 264), VX_MASK, PPCVEC, { VD, VA, VB } }, 3303{"evnor", VX (4, 536), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2190{ "vmulosh", VX(4, 328), VX_MASK, PPCVEC, { VD, VA, VB } }, 3304{"evnot", VX (4, 536), VX_MASK, PPCSPE, 0, {RS, RA, BBA}},
2191{ "vmuloub", VX(4, 8), VX_MASK, PPCVEC, { VD, VA, VB } }, 3305{"get", APU(4, 268,0), APU_RA_MASK, PPC405, 0, {RT, FSL}},
2192{ "vmulouh", VX(4, 72), VX_MASK, PPCVEC, { VD, VA, VB } }, 3306{"eveqv", VX (4, 537), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2193{ "vnmsubfp", VXA(4, 47), VXA_MASK, PPCVEC, { VD, VA, VC, VB } }, 3307{"evorc", VX (4, 539), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2194{ "vnor", VX(4, 1284), VX_MASK, PPCVEC, { VD, VA, VB } }, 3308{"evnand", VX (4, 542), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2195{ "vor", VX(4, 1156), VX_MASK, PPCVEC, { VD, VA, VB } }, 3309{"evsrwu", VX (4, 544), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2196{ "vperm", VXA(4, 43), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3310{"evsrws", VX (4, 545), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2197{ "vpkpx", VX(4, 782), VX_MASK, PPCVEC, { VD, VA, VB } }, 3311{"evsrwiu", VX (4, 546), VX_MASK, PPCSPE, 0, {RS, RA, EVUIMM}},
2198{ "vpkshss", VX(4, 398), VX_MASK, PPCVEC, { VD, VA, VB } }, 3312{"evsrwis", VX (4, 547), VX_MASK, PPCSPE, 0, {RS, RA, EVUIMM}},
2199{ "vpkshus", VX(4, 270), VX_MASK, PPCVEC, { VD, VA, VB } }, 3313{"evslw", VX (4, 548), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2200{ "vpkswss", VX(4, 462), VX_MASK, PPCVEC, { VD, VA, VB } }, 3314{"evslwi", VX (4, 550), VX_MASK, PPCSPE, 0, {RS, RA, EVUIMM}},
2201{ "vpkswus", VX(4, 334), VX_MASK, PPCVEC, { VD, VA, VB } }, 3315{"evrlw", VX (4, 552), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2202{ "vpkuhum", VX(4, 14), VX_MASK, PPCVEC, { VD, VA, VB } }, 3316{"evsplati", VX (4, 553), VX_MASK, PPCSPE, 0, {RS, SIMM}},
2203{ "vpkuhus", VX(4, 142), VX_MASK, PPCVEC, { VD, VA, VB } }, 3317{"evrlwi", VX (4, 554), VX_MASK, PPCSPE, 0, {RS, RA, EVUIMM}},
2204{ "vpkuwum", VX(4, 78), VX_MASK, PPCVEC, { VD, VA, VB } }, 3318{"evsplatfi", VX (4, 555), VX_MASK, PPCSPE, 0, {RS, SIMM}},
2205{ "vpkuwus", VX(4, 206), VX_MASK, PPCVEC, { VD, VA, VB } }, 3319{"evmergehi", VX (4, 556), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2206{ "vrefp", VX(4, 266), VX_MASK, PPCVEC, { VD, VB } }, 3320{"evmergelo", VX (4, 557), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2207{ "vrfim", VX(4, 714), VX_MASK, PPCVEC, { VD, VB } }, 3321{"evmergehilo", VX (4, 558), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2208{ "vrfin", VX(4, 522), VX_MASK, PPCVEC, { VD, VB } }, 3322{"evmergelohi", VX (4, 559), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2209{ "vrfip", VX(4, 650), VX_MASK, PPCVEC, { VD, VB } }, 3323{"evcmpgtu", VX (4, 560), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2210{ "vrfiz", VX(4, 586), VX_MASK, PPCVEC, { VD, VB } }, 3324{"evcmpgts", VX (4, 561), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2211{ "vrlb", VX(4, 4), VX_MASK, PPCVEC, { VD, VA, VB } }, 3325{"evcmpltu", VX (4, 562), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2212{ "vrlh", VX(4, 68), VX_MASK, PPCVEC, { VD, VA, VB } }, 3326{"evcmplts", VX (4, 563), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2213{ "vrlw", VX(4, 132), VX_MASK, PPCVEC, { VD, VA, VB } }, 3327{"evcmpeq", VX (4, 564), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2214{ "vrsqrtefp", VX(4, 330), VX_MASK, PPCVEC, { VD, VB } }, 3328{"cget", APU(4, 284,0), APU_RA_MASK, PPC405, 0, {RT, FSL}},
2215{ "vsel", VXA(4, 42), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, 3329{"vadduhs", VX (4, 576), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2216{ "vsl", VX(4, 452), VX_MASK, PPCVEC, { VD, VA, VB } }, 3330{"vmul10euq", VX (4, 577), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2217{ "vslb", VX(4, 260), VX_MASK, PPCVEC, { VD, VA, VB } }, 3331{"vminuh", VX (4, 578), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2218{ "vsldoi", VXA(4, 44), VXA_MASK, PPCVEC, { VD, VA, VB, SHB } }, 3332{"vsrh", VX (4, 580), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2219{ "vslh", VX(4, 324), VX_MASK, PPCVEC, { VD, VA, VB } }, 3333{"vcmpgtuh", VXR(4, 582,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2220{ "vslo", VX(4, 1036), VX_MASK, PPCVEC, { VD, VA, VB } }, 3334{"vmuleuh", VX (4, 584), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2221{ "vslw", VX(4, 388), VX_MASK, PPCVEC, { VD, VA, VB } }, 3335{"vrfiz", VX (4, 586), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2222{ "vspltb", VX(4, 524), VX_MASK, PPCVEC, { VD, VB, UIMM } }, 3336{"vsplth", VX (4, 588), VXUIMM3_MASK, PPCVEC, 0, {VD, VB, UIMM3}},
2223{ "vsplth", VX(4, 588), VX_MASK, PPCVEC, { VD, VB, UIMM } }, 3337{"vextractuh", VX (4, 589), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2224{ "vspltisb", VX(4, 780), VX_MASK, PPCVEC, { VD, SIMM } }, 3338{"vupkhsh", VX (4, 590), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2225{ "vspltish", VX(4, 844), VX_MASK, PPCVEC, { VD, SIMM } }, 3339{"nget", APU(4, 300,0), APU_RA_MASK, PPC405, 0, {RT, FSL}},
2226{ "vspltisw", VX(4, 908), VX_MASK, PPCVEC, { VD, SIMM } }, 3340{"evsel", EVSEL(4,79), EVSEL_MASK, PPCSPE, 0, {RS, RA, RB, CRFS}},
2227{ "vspltw", VX(4, 652), VX_MASK, PPCVEC, { VD, VB, UIMM } }, 3341{"ncget", APU(4, 316,0), APU_RA_MASK, PPC405, 0, {RT, FSL}},
2228{ "vsr", VX(4, 708), VX_MASK, PPCVEC, { VD, VA, VB } }, 3342{"evfsadd", VX (4, 640), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2229{ "vsrab", VX(4, 772), VX_MASK, PPCVEC, { VD, VA, VB } }, 3343{"vadduws", VX (4, 640), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2230{ "vsrah", VX(4, 836), VX_MASK, PPCVEC, { VD, VA, VB } }, 3344{"evfssub", VX (4, 641), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2231{ "vsraw", VX(4, 900), VX_MASK, PPCVEC, { VD, VA, VB } }, 3345{"vminuw", VX (4, 642), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2232{ "vsrb", VX(4, 516), VX_MASK, PPCVEC, { VD, VA, VB } }, 3346{"evfsabs", VX (4, 644), VX_MASK, PPCSPE, 0, {RS, RA}},
2233{ "vsrh", VX(4, 580), VX_MASK, PPCVEC, { VD, VA, VB } }, 3347{"vsrw", VX (4, 644), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2234{ "vsro", VX(4, 1100), VX_MASK, PPCVEC, { VD, VA, VB } }, 3348{"evfsnabs", VX (4, 645), VX_MASK, PPCSPE, 0, {RS, RA}},
2235{ "vsrw", VX(4, 644), VX_MASK, PPCVEC, { VD, VA, VB } }, 3349{"evfsneg", VX (4, 646), VX_MASK, PPCSPE, 0, {RS, RA}},
2236{ "vsubcuw", VX(4, 1408), VX_MASK, PPCVEC, { VD, VA, VB } }, 3350{"vcmpgtuw", VXR(4, 646,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2237{ "vsubfp", VX(4, 74), VX_MASK, PPCVEC, { VD, VA, VB } }, 3351{"vmuleuw", VX (4, 648), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2238{ "vsubsbs", VX(4, 1792), VX_MASK, PPCVEC, { VD, VA, VB } }, 3352{"evfsmul", VX (4, 648), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2239{ "vsubshs", VX(4, 1856), VX_MASK, PPCVEC, { VD, VA, VB } }, 3353{"evfsdiv", VX (4, 649), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2240{ "vsubsws", VX(4, 1920), VX_MASK, PPCVEC, { VD, VA, VB } }, 3354{"vrfip", VX (4, 650), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2241{ "vsububm", VX(4, 1024), VX_MASK, PPCVEC, { VD, VA, VB } }, 3355{"evfscmpgt", VX (4, 652), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2242{ "vsububs", VX(4, 1536), VX_MASK, PPCVEC, { VD, VA, VB } }, 3356{"vspltw", VX (4, 652), VXUIMM2_MASK, PPCVEC, 0, {VD, VB, UIMM2}},
2243{ "vsubuhm", VX(4, 1088), VX_MASK, PPCVEC, { VD, VA, VB } }, 3357{"vextractuw", VX (4, 653), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2244{ "vsubuhs", VX(4, 1600), VX_MASK, PPCVEC, { VD, VA, VB } }, 3358{"evfscmplt", VX (4, 653), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2245{ "vsubuwm", VX(4, 1152), VX_MASK, PPCVEC, { VD, VA, VB } }, 3359{"evfscmpeq", VX (4, 654), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2246{ "vsubuws", VX(4, 1664), VX_MASK, PPCVEC, { VD, VA, VB } }, 3360{"vupklsb", VX (4, 654), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2247{ "vsumsws", VX(4, 1928), VX_MASK, PPCVEC, { VD, VA, VB } }, 3361{"evfscfui", VX (4, 656), VX_MASK, PPCSPE, 0, {RS, RB}},
2248{ "vsum2sws", VX(4, 1672), VX_MASK, PPCVEC, { VD, VA, VB } }, 3362{"evfscfsi", VX (4, 657), VX_MASK, PPCSPE, 0, {RS, RB}},
2249{ "vsum4sbs", VX(4, 1800), VX_MASK, PPCVEC, { VD, VA, VB } }, 3363{"evfscfuf", VX (4, 658), VX_MASK, PPCSPE, 0, {RS, RB}},
2250{ "vsum4shs", VX(4, 1608), VX_MASK, PPCVEC, { VD, VA, VB } }, 3364{"evfscfsf", VX (4, 659), VX_MASK, PPCSPE, 0, {RS, RB}},
2251{ "vsum4ubs", VX(4, 1544), VX_MASK, PPCVEC, { VD, VA, VB } }, 3365{"evfsctui", VX (4, 660), VX_MASK, PPCSPE, 0, {RS, RB}},
2252{ "vupkhpx", VX(4, 846), VX_MASK, PPCVEC, { VD, VB } }, 3366{"evfsctsi", VX (4, 661), VX_MASK, PPCSPE, 0, {RS, RB}},
2253{ "vupkhsb", VX(4, 526), VX_MASK, PPCVEC, { VD, VB } }, 3367{"evfsctuf", VX (4, 662), VX_MASK, PPCSPE, 0, {RS, RB}},
2254{ "vupkhsh", VX(4, 590), VX_MASK, PPCVEC, { VD, VB } }, 3368{"evfsctsf", VX (4, 663), VX_MASK, PPCSPE, 0, {RS, RB}},
2255{ "vupklpx", VX(4, 974), VX_MASK, PPCVEC, { VD, VB } }, 3369{"evfsctuiz", VX (4, 664), VX_MASK, PPCSPE, 0, {RS, RB}},
2256{ "vupklsb", VX(4, 654), VX_MASK, PPCVEC, { VD, VB } }, 3370{"put", APU(4, 332,0), APU_RT_MASK, PPC405, 0, {RA, FSL}},
2257{ "vupklsh", VX(4, 718), VX_MASK, PPCVEC, { VD, VB } }, 3371{"evfsctsiz", VX (4, 666), VX_MASK, PPCSPE, 0, {RS, RB}},
2258{ "vxor", VX(4, 1220), VX_MASK, PPCVEC, { VD, VA, VB } }, 3372{"evfststgt", VX (4, 668), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2259 3373{"evfststlt", VX (4, 669), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2260{ "evaddw", VX(4, 512), VX_MASK, PPCSPE, { RS, RA, RB } }, 3374{"evfststeq", VX (4, 670), VX_MASK, PPCSPE, 0, {CRFD, RA, RB}},
2261{ "evaddiw", VX(4, 514), VX_MASK, PPCSPE, { RS, RB, UIMM } }, 3375{"cput", APU(4, 348,0), APU_RT_MASK, PPC405, 0, {RA, FSL}},
2262{ "evsubfw", VX(4, 516), VX_MASK, PPCSPE, { RS, RA, RB } }, 3376{"efsadd", VX (4, 704), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2263{ "evsubw", VX(4, 516), VX_MASK, PPCSPE, { RS, RB, RA } }, 3377{"efssub", VX (4, 705), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2264{ "evsubifw", VX(4, 518), VX_MASK, PPCSPE, { RS, UIMM, RB } }, 3378{"vminud", VX (4, 706), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2265{ "evsubiw", VX(4, 518), VX_MASK, PPCSPE, { RS, RB, UIMM } }, 3379{"efsabs", VX (4, 708), VX_MASK, PPCEFS, 0, {RS, RA}},
2266{ "evabs", VX(4, 520), VX_MASK, PPCSPE, { RS, RA } }, 3380{"vsr", VX (4, 708), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2267{ "evneg", VX(4, 521), VX_MASK, PPCSPE, { RS, RA } }, 3381{"efsnabs", VX (4, 709), VX_MASK, PPCEFS, 0, {RS, RA}},
2268{ "evextsb", VX(4, 522), VX_MASK, PPCSPE, { RS, RA } }, 3382{"efsneg", VX (4, 710), VX_MASK, PPCEFS, 0, {RS, RA}},
2269{ "evextsh", VX(4, 523), VX_MASK, PPCSPE, { RS, RA } }, 3383{"vcmpgtfp", VXR(4, 710,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2270{ "evrndw", VX(4, 524), VX_MASK, PPCSPE, { RS, RA } }, 3384{"vcmpgtud", VXR(4, 711,0), VXR_MASK, PPCVEC2, 0, {VD, VA, VB}},
2271{ "evcntlzw", VX(4, 525), VX_MASK, PPCSPE, { RS, RA } }, 3385{"efsmul", VX (4, 712), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2272{ "evcntlsw", VX(4, 526), VX_MASK, PPCSPE, { RS, RA } }, 3386{"efsdiv", VX (4, 713), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2273 3387{"vrfim", VX (4, 714), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2274{ "brinc", VX(4, 527), VX_MASK, PPCSPE, { RS, RA, RB } }, 3388{"efscmpgt", VX (4, 716), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2275 3389{"vextractd", VX (4, 717), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2276{ "evand", VX(4, 529), VX_MASK, PPCSPE, { RS, RA, RB } }, 3390{"efscmplt", VX (4, 717), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2277{ "evandc", VX(4, 530), VX_MASK, PPCSPE, { RS, RA, RB } }, 3391{"efscmpeq", VX (4, 718), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2278{ "evmr", VX(4, 535), VX_MASK, PPCSPE, { RS, RA, BBA } }, 3392{"vupklsh", VX (4, 718), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2279{ "evor", VX(4, 535), VX_MASK, PPCSPE, { RS, RA, RB } }, 3393{"efscfd", VX (4, 719), VX_MASK, PPCEFS, 0, {RS, RB}},
2280{ "evorc", VX(4, 539), VX_MASK, PPCSPE, { RS, RA, RB } }, 3394{"efscfui", VX (4, 720), VX_MASK, PPCEFS, 0, {RS, RB}},
2281{ "evxor", VX(4, 534), VX_MASK, PPCSPE, { RS, RA, RB } }, 3395{"efscfsi", VX (4, 721), VX_MASK, PPCEFS, 0, {RS, RB}},
2282{ "eveqv", VX(4, 537), VX_MASK, PPCSPE, { RS, RA, RB } }, 3396{"efscfuf", VX (4, 722), VX_MASK, PPCEFS, 0, {RS, RB}},
2283{ "evnand", VX(4, 542), VX_MASK, PPCSPE, { RS, RA, RB } }, 3397{"efscfsf", VX (4, 723), VX_MASK, PPCEFS, 0, {RS, RB}},
2284{ "evnot", VX(4, 536), VX_MASK, PPCSPE, { RS, RA, BBA } }, 3398{"efsctui", VX (4, 724), VX_MASK, PPCEFS, 0, {RS, RB}},
2285{ "evnor", VX(4, 536), VX_MASK, PPCSPE, { RS, RA, RB } }, 3399{"efsctsi", VX (4, 725), VX_MASK, PPCEFS, 0, {RS, RB}},
2286 3400{"efsctuf", VX (4, 726), VX_MASK, PPCEFS, 0, {RS, RB}},
2287{ "evrlw", VX(4, 552), VX_MASK, PPCSPE, { RS, RA, RB } }, 3401{"efsctsf", VX (4, 727), VX_MASK, PPCEFS, 0, {RS, RB}},
2288{ "evrlwi", VX(4, 554), VX_MASK, PPCSPE, { RS, RA, EVUIMM } }, 3402{"efsctuiz", VX (4, 728), VX_MASK, PPCEFS, 0, {RS, RB}},
2289{ "evslw", VX(4, 548), VX_MASK, PPCSPE, { RS, RA, RB } }, 3403{"nput", APU(4, 364,0), APU_RT_MASK, PPC405, 0, {RA, FSL}},
2290{ "evslwi", VX(4, 550), VX_MASK, PPCSPE, { RS, RA, EVUIMM } }, 3404{"efsctsiz", VX (4, 730), VX_MASK, PPCEFS, 0, {RS, RB}},
2291{ "evsrws", VX(4, 545), VX_MASK, PPCSPE, { RS, RA, RB } }, 3405{"efststgt", VX (4, 732), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2292{ "evsrwu", VX(4, 544), VX_MASK, PPCSPE, { RS, RA, RB } }, 3406{"efststlt", VX (4, 733), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2293{ "evsrwis", VX(4, 547), VX_MASK, PPCSPE, { RS, RA, EVUIMM } }, 3407{"efststeq", VX (4, 734), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2294{ "evsrwiu", VX(4, 546), VX_MASK, PPCSPE, { RS, RA, EVUIMM } }, 3408{"efdadd", VX (4, 736), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2295{ "evsplati", VX(4, 553), VX_MASK, PPCSPE, { RS, SIMM } }, 3409{"efdsub", VX (4, 737), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2296{ "evsplatfi", VX(4, 555), VX_MASK, PPCSPE, { RS, SIMM } }, 3410{"efdcfuid", VX (4, 738), VX_MASK, PPCEFS, 0, {RS, RB}},
2297{ "evmergehi", VX(4, 556), VX_MASK, PPCSPE, { RS, RA, RB } }, 3411{"efdcfsid", VX (4, 739), VX_MASK, PPCEFS, 0, {RS, RB}},
2298{ "evmergelo", VX(4, 557), VX_MASK, PPCSPE, { RS, RA, RB } }, 3412{"efdabs", VX (4, 740), VX_MASK, PPCEFS, 0, {RS, RA}},
2299{ "evmergehilo",VX(4,558), VX_MASK, PPCSPE, { RS, RA, RB } }, 3413{"efdnabs", VX (4, 741), VX_MASK, PPCEFS, 0, {RS, RA}},
2300{ "evmergelohi",VX(4,559), VX_MASK, PPCSPE, { RS, RA, RB } }, 3414{"efdneg", VX (4, 742), VX_MASK, PPCEFS, 0, {RS, RA}},
2301 3415{"efdmul", VX (4, 744), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2302{ "evcmpgts", VX(4, 561), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3416{"efddiv", VX (4, 745), VX_MASK, PPCEFS, 0, {RS, RA, RB}},
2303{ "evcmpgtu", VX(4, 560), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3417{"efdctuidz", VX (4, 746), VX_MASK, PPCEFS, 0, {RS, RB}},
2304{ "evcmplts", VX(4, 563), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3418{"efdctsidz", VX (4, 747), VX_MASK, PPCEFS, 0, {RS, RB}},
2305{ "evcmpltu", VX(4, 562), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3419{"efdcmpgt", VX (4, 748), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2306{ "evcmpeq", VX(4, 564), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3420{"efdcmplt", VX (4, 749), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2307{ "evsel", EVSEL(4,79),EVSEL_MASK, PPCSPE, { RS, RA, RB, CRFS } }, 3421{"efdcmpeq", VX (4, 750), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2308 3422{"efdcfs", VX (4, 751), VX_MASK, PPCEFS, 0, {RS, RB}},
2309{ "evldd", VX(4, 769), VX_MASK, PPCSPE, { RS, EVUIMM_8, RA } }, 3423{"efdcfui", VX (4, 752), VX_MASK, PPCEFS, 0, {RS, RB}},
2310{ "evlddx", VX(4, 768), VX_MASK, PPCSPE, { RS, RA, RB } }, 3424{"efdcfsi", VX (4, 753), VX_MASK, PPCEFS, 0, {RS, RB}},
2311{ "evldw", VX(4, 771), VX_MASK, PPCSPE, { RS, EVUIMM_8, RA } }, 3425{"efdcfuf", VX (4, 754), VX_MASK, PPCEFS, 0, {RS, RB}},
2312{ "evldwx", VX(4, 770), VX_MASK, PPCSPE, { RS, RA, RB } }, 3426{"efdcfsf", VX (4, 755), VX_MASK, PPCEFS, 0, {RS, RB}},
2313{ "evldh", VX(4, 773), VX_MASK, PPCSPE, { RS, EVUIMM_8, RA } }, 3427{"efdctui", VX (4, 756), VX_MASK, PPCEFS, 0, {RS, RB}},
2314{ "evldhx", VX(4, 772), VX_MASK, PPCSPE, { RS, RA, RB } }, 3428{"efdctsi", VX (4, 757), VX_MASK, PPCEFS, 0, {RS, RB}},
2315{ "evlwhe", VX(4, 785), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3429{"efdctuf", VX (4, 758), VX_MASK, PPCEFS, 0, {RS, RB}},
2316{ "evlwhex", VX(4, 784), VX_MASK, PPCSPE, { RS, RA, RB } }, 3430{"efdctsf", VX (4, 759), VX_MASK, PPCEFS, 0, {RS, RB}},
2317{ "evlwhou", VX(4, 789), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3431{"efdctuiz", VX (4, 760), VX_MASK, PPCEFS, 0, {RS, RB}},
2318{ "evlwhoux", VX(4, 788), VX_MASK, PPCSPE, { RS, RA, RB } }, 3432{"ncput", APU(4, 380,0), APU_RT_MASK, PPC405, 0, {RA, FSL}},
2319{ "evlwhos", VX(4, 791), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3433{"efdctsiz", VX (4, 762), VX_MASK, PPCEFS, 0, {RS, RB}},
2320{ "evlwhosx", VX(4, 790), VX_MASK, PPCSPE, { RS, RA, RB } }, 3434{"efdtstgt", VX (4, 764), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2321{ "evlwwsplat",VX(4, 793), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3435{"efdtstlt", VX (4, 765), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2322{ "evlwwsplatx",VX(4, 792), VX_MASK, PPCSPE, { RS, RA, RB } }, 3436{"efdtsteq", VX (4, 766), VX_MASK, PPCEFS, 0, {CRFD, RA, RB}},
2323{ "evlwhsplat",VX(4, 797), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3437{"evlddx", VX (4, 768), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2324{ "evlwhsplatx",VX(4, 796), VX_MASK, PPCSPE, { RS, RA, RB } }, 3438{"vaddsbs", VX (4, 768), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2325{ "evlhhesplat",VX(4, 777), VX_MASK, PPCSPE, { RS, EVUIMM_2, RA } }, 3439{"evldd", VX (4, 769), VX_MASK, PPCSPE, 0, {RS, EVUIMM_8, RA}},
2326{ "evlhhesplatx",VX(4, 776), VX_MASK, PPCSPE, { RS, RA, RB } }, 3440{"evldwx", VX (4, 770), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2327{ "evlhhousplat",VX(4, 781), VX_MASK, PPCSPE, { RS, EVUIMM_2, RA } }, 3441{"vminsb", VX (4, 770), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2328{ "evlhhousplatx",VX(4, 780), VX_MASK, PPCSPE, { RS, RA, RB } }, 3442{"evldw", VX (4, 771), VX_MASK, PPCSPE, 0, {RS, EVUIMM_8, RA}},
2329{ "evlhhossplat",VX(4, 783), VX_MASK, PPCSPE, { RS, EVUIMM_2, RA } }, 3443{"evldhx", VX (4, 772), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2330{ "evlhhossplatx",VX(4, 782), VX_MASK, PPCSPE, { RS, RA, RB } }, 3444{"vsrab", VX (4, 772), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2331 3445{"evldh", VX (4, 773), VX_MASK, PPCSPE, 0, {RS, EVUIMM_8, RA}},
2332{ "evstdd", VX(4, 801), VX_MASK, PPCSPE, { RS, EVUIMM_8, RA } }, 3446{"vcmpgtsb", VXR(4, 774,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2333{ "evstddx", VX(4, 800), VX_MASK, PPCSPE, { RS, RA, RB } }, 3447{"evlhhesplatx",VX (4, 776), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2334{ "evstdw", VX(4, 803), VX_MASK, PPCSPE, { RS, EVUIMM_8, RA } }, 3448{"vmulesb", VX (4, 776), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2335{ "evstdwx", VX(4, 802), VX_MASK, PPCSPE, { RS, RA, RB } }, 3449{"evlhhesplat", VX (4, 777), VX_MASK, PPCSPE, 0, {RS, EVUIMM_2, RA}},
2336{ "evstdh", VX(4, 805), VX_MASK, PPCSPE, { RS, EVUIMM_8, RA } }, 3450{"vcfux", VX (4, 778), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2337{ "evstdhx", VX(4, 804), VX_MASK, PPCSPE, { RS, RA, RB } }, 3451{"vcuxwfp", VX (4, 778), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2338{ "evstwwe", VX(4, 825), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3452{"evlhhousplatx",VX(4, 780), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2339{ "evstwwex", VX(4, 824), VX_MASK, PPCSPE, { RS, RA, RB } }, 3453{"vspltisb", VX (4, 780), VXVB_MASK, PPCVEC, 0, {VD, SIMM}},
2340{ "evstwwo", VX(4, 829), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3454{"vinsertb", VX (4, 781), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2341{ "evstwwox", VX(4, 828), VX_MASK, PPCSPE, { RS, RA, RB } }, 3455{"evlhhousplat",VX (4, 781), VX_MASK, PPCSPE, 0, {RS, EVUIMM_2, RA}},
2342{ "evstwhe", VX(4, 817), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3456{"evlhhossplatx",VX(4, 782), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2343{ "evstwhex", VX(4, 816), VX_MASK, PPCSPE, { RS, RA, RB } }, 3457{"vpkpx", VX (4, 782), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2344{ "evstwho", VX(4, 821), VX_MASK, PPCSPE, { RS, EVUIMM_4, RA } }, 3458{"evlhhossplat",VX (4, 783), VX_MASK, PPCSPE, 0, {RS, EVUIMM_2, RA}},
2345{ "evstwhox", VX(4, 820), VX_MASK, PPCSPE, { RS, RA, RB } }, 3459{"mullhwu", XRC(4, 392,0), X_MASK, MULHW, 0, {RT, RA, RB}},
2346 3460{"evlwhex", VX (4, 784), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2347{ "evfsabs", VX(4, 644), VX_MASK, PPCSPE, { RS, RA } }, 3461{"mullhwu.", XRC(4, 392,1), X_MASK, MULHW, 0, {RT, RA, RB}},
2348{ "evfsnabs", VX(4, 645), VX_MASK, PPCSPE, { RS, RA } }, 3462{"evlwhe", VX (4, 785), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2349{ "evfsneg", VX(4, 646), VX_MASK, PPCSPE, { RS, RA } }, 3463{"evlwhoux", VX (4, 788), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2350{ "evfsadd", VX(4, 640), VX_MASK, PPCSPE, { RS, RA, RB } }, 3464{"evlwhou", VX (4, 789), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2351{ "evfssub", VX(4, 641), VX_MASK, PPCSPE, { RS, RA, RB } }, 3465{"evlwhosx", VX (4, 790), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2352{ "evfsmul", VX(4, 648), VX_MASK, PPCSPE, { RS, RA, RB } }, 3466{"evlwhos", VX (4, 791), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2353{ "evfsdiv", VX(4, 649), VX_MASK, PPCSPE, { RS, RA, RB } }, 3467{"maclhwu", XO (4, 396,0,0),XO_MASK, MULHW, 0, {RT, RA, RB}},
2354{ "evfscmpgt", VX(4, 652), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3468{"evlwwsplatx", VX (4, 792), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2355{ "evfscmplt", VX(4, 653), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3469{"maclhwu.", XO (4, 396,0,1),XO_MASK, MULHW, 0, {RT, RA, RB}},
2356{ "evfscmpeq", VX(4, 654), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3470{"evlwwsplat", VX (4, 793), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2357{ "evfststgt", VX(4, 668), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3471{"evlwhsplatx", VX (4, 796), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2358{ "evfststlt", VX(4, 669), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3472{"evlwhsplat", VX (4, 797), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2359{ "evfststeq", VX(4, 670), VX_MASK, PPCSPE, { CRFD, RA, RB } }, 3473{"evstddx", VX (4, 800), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2360{ "evfscfui", VX(4, 656), VX_MASK, PPCSPE, { RS, RB } }, 3474{"evstdd", VX (4, 801), VX_MASK, PPCSPE, 0, {RS, EVUIMM_8, RA}},
2361{ "evfsctuiz", VX(4, 664), VX_MASK, PPCSPE, { RS, RB } }, 3475{"evstdwx", VX (4, 802), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2362{ "evfscfsi", VX(4, 657), VX_MASK, PPCSPE, { RS, RB } }, 3476{"evstdw", VX (4, 803), VX_MASK, PPCSPE, 0, {RS, EVUIMM_8, RA}},
2363{ "evfscfuf", VX(4, 658), VX_MASK, PPCSPE, { RS, RB } }, 3477{"evstdhx", VX (4, 804), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2364{ "evfscfsf", VX(4, 659), VX_MASK, PPCSPE, { RS, RB } }, 3478{"evstdh", VX (4, 805), VX_MASK, PPCSPE, 0, {RS, EVUIMM_8, RA}},
2365{ "evfsctui", VX(4, 660), VX_MASK, PPCSPE, { RS, RB } }, 3479{"evstwhex", VX (4, 816), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2366{ "evfsctsi", VX(4, 661), VX_MASK, PPCSPE, { RS, RB } }, 3480{"evstwhe", VX (4, 817), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2367{ "evfsctsiz", VX(4, 666), VX_MASK, PPCSPE, { RS, RB } }, 3481{"evstwhox", VX (4, 820), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2368{ "evfsctuf", VX(4, 662), VX_MASK, PPCSPE, { RS, RB } }, 3482{"evstwho", VX (4, 821), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2369{ "evfsctsf", VX(4, 663), VX_MASK, PPCSPE, { RS, RB } }, 3483{"evstwwex", VX (4, 824), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2370 3484{"evstwwe", VX (4, 825), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2371{ "efsabs", VX(4, 708), VX_MASK, PPCEFS, { RS, RA } }, 3485{"evstwwox", VX (4, 828), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2372{ "efsnabs", VX(4, 709), VX_MASK, PPCEFS, { RS, RA } }, 3486{"evstwwo", VX (4, 829), VX_MASK, PPCSPE, 0, {RS, EVUIMM_4, RA}},
2373{ "efsneg", VX(4, 710), VX_MASK, PPCEFS, { RS, RA } }, 3487{"vaddshs", VX (4, 832), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2374{ "efsadd", VX(4, 704), VX_MASK, PPCEFS, { RS, RA, RB } }, 3488{"bcdcpsgn.", VX (4, 833), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2375{ "efssub", VX(4, 705), VX_MASK, PPCEFS, { RS, RA, RB } }, 3489{"vminsh", VX (4, 834), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2376{ "efsmul", VX(4, 712), VX_MASK, PPCEFS, { RS, RA, RB } }, 3490{"vsrah", VX (4, 836), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2377{ "efsdiv", VX(4, 713), VX_MASK, PPCEFS, { RS, RA, RB } }, 3491{"vcmpgtsh", VXR(4, 838,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2378{ "efscmpgt", VX(4, 716), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3492{"vmulesh", VX (4, 840), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2379{ "efscmplt", VX(4, 717), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3493{"vcfsx", VX (4, 842), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2380{ "efscmpeq", VX(4, 718), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3494{"vcsxwfp", VX (4, 842), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2381{ "efststgt", VX(4, 732), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3495{"vspltish", VX (4, 844), VXVB_MASK, PPCVEC, 0, {VD, SIMM}},
2382{ "efststlt", VX(4, 733), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3496{"vinserth", VX (4, 845), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2383{ "efststeq", VX(4, 734), VX_MASK, PPCEFS, { CRFD, RA, RB } }, 3497{"vupkhpx", VX (4, 846), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2384{ "efscfui", VX(4, 720), VX_MASK, PPCEFS, { RS, RB } }, 3498{"mullhw", XRC(4, 424,0), X_MASK, MULHW, 0, {RT, RA, RB}},
2385{ "efsctuiz", VX(4, 728), VX_MASK, PPCEFS, { RS, RB } }, 3499{"mullhw.", XRC(4, 424,1), X_MASK, MULHW, 0, {RT, RA, RB}},
2386{ "efscfsi", VX(4, 721), VX_MASK, PPCEFS, { RS, RB } }, 3500{"maclhw", XO (4, 428,0,0),XO_MASK, MULHW, 0, {RT, RA, RB}},
2387{ "efscfuf", VX(4, 722), VX_MASK, PPCEFS, { RS, RB } }, 3501{"maclhw.", XO (4, 428,0,1),XO_MASK, MULHW, 0, {RT, RA, RB}},
2388{ "efscfsf", VX(4, 723), VX_MASK, PPCEFS, { RS, RB } }, 3502{"nmaclhw", XO (4, 430,0,0),XO_MASK, MULHW, 0, {RT, RA, RB}},
2389{ "efsctui", VX(4, 724), VX_MASK, PPCEFS, { RS, RB } }, 3503{"nmaclhw.", XO (4, 430,0,1),XO_MASK, MULHW, 0, {RT, RA, RB}},
2390{ "efsctsi", VX(4, 725), VX_MASK, PPCEFS, { RS, RB } }, 3504{"vaddsws", VX (4, 896), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2391{ "efsctsiz", VX(4, 730), VX_MASK, PPCEFS, { RS, RB } }, 3505{"vminsw", VX (4, 898), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2392{ "efsctuf", VX(4, 726), VX_MASK, PPCEFS, { RS, RB } }, 3506{"vsraw", VX (4, 900), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2393{ "efsctsf", VX(4, 727), VX_MASK, PPCEFS, { RS, RB } }, 3507{"vcmpgtsw", VXR(4, 902,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2394 3508{"vmulesw", VX (4, 904), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2395{ "evmhossf", VX(4, 1031), VX_MASK, PPCSPE, { RS, RA, RB } }, 3509{"vctuxs", VX (4, 906), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2396{ "evmhossfa", VX(4, 1063), VX_MASK, PPCSPE, { RS, RA, RB } }, 3510{"vcfpuxws", VX (4, 906), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2397{ "evmhosmf", VX(4, 1039), VX_MASK, PPCSPE, { RS, RA, RB } }, 3511{"vspltisw", VX (4, 908), VXVB_MASK, PPCVEC, 0, {VD, SIMM}},
2398{ "evmhosmfa", VX(4, 1071), VX_MASK, PPCSPE, { RS, RA, RB } }, 3512{"vinsertw", VX (4, 909), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2399{ "evmhosmi", VX(4, 1037), VX_MASK, PPCSPE, { RS, RA, RB } }, 3513{"maclhwsu", XO (4, 460,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2400{ "evmhosmia", VX(4, 1069), VX_MASK, PPCSPE, { RS, RA, RB } }, 3514{"maclhwsu.", XO (4, 460,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2401{ "evmhoumi", VX(4, 1036), VX_MASK, PPCSPE, { RS, RA, RB } }, 3515{"vminsd", VX (4, 962), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2402{ "evmhoumia", VX(4, 1068), VX_MASK, PPCSPE, { RS, RA, RB } }, 3516{"vsrad", VX (4, 964), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2403{ "evmhessf", VX(4, 1027), VX_MASK, PPCSPE, { RS, RA, RB } }, 3517{"vcmpbfp", VXR(4, 966,0), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2404{ "evmhessfa", VX(4, 1059), VX_MASK, PPCSPE, { RS, RA, RB } }, 3518{"vcmpgtsd", VXR(4, 967,0), VXR_MASK, PPCVEC2, 0, {VD, VA, VB}},
2405{ "evmhesmf", VX(4, 1035), VX_MASK, PPCSPE, { RS, RA, RB } }, 3519{"vctsxs", VX (4, 970), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2406{ "evmhesmfa", VX(4, 1067), VX_MASK, PPCSPE, { RS, RA, RB } }, 3520{"vcfpsxws", VX (4, 970), VX_MASK, PPCVEC, 0, {VD, VB, UIMM}},
2407{ "evmhesmi", VX(4, 1033), VX_MASK, PPCSPE, { RS, RA, RB } }, 3521{"vinsertd", VX (4, 973), VXUIMM4_MASK, PPCVEC3, 0, {VD, VB, UIMM4}},
2408{ "evmhesmia", VX(4, 1065), VX_MASK, PPCSPE, { RS, RA, RB } }, 3522{"vupklpx", VX (4, 974), VXVA_MASK, PPCVEC, 0, {VD, VB}},
2409{ "evmheumi", VX(4, 1032), VX_MASK, PPCSPE, { RS, RA, RB } }, 3523{"maclhws", XO (4, 492,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2410{ "evmheumia", VX(4, 1064), VX_MASK, PPCSPE, { RS, RA, RB } }, 3524{"maclhws.", XO (4, 492,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2411 3525{"nmaclhws", XO (4, 494,0,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2412{ "evmhossfaaw",VX(4, 1287), VX_MASK, PPCSPE, { RS, RA, RB } }, 3526{"nmaclhws.", XO (4, 494,0,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2413{ "evmhossiaaw",VX(4, 1285), VX_MASK, PPCSPE, { RS, RA, RB } }, 3527{"vsububm", VX (4,1024), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2414{ "evmhosmfaaw",VX(4, 1295), VX_MASK, PPCSPE, { RS, RA, RB } }, 3528{"bcdadd.", VX (4,1025), VXPS_MASK, PPCVEC2, 0, {VD, VA, VB, PS}},
2415{ "evmhosmiaaw",VX(4, 1293), VX_MASK, PPCSPE, { RS, RA, RB } }, 3529{"vavgub", VX (4,1026), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2416{ "evmhousiaaw",VX(4, 1284), VX_MASK, PPCSPE, { RS, RA, RB } }, 3530{"vabsdub", VX (4,1027), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2417{ "evmhoumiaaw",VX(4, 1292), VX_MASK, PPCSPE, { RS, RA, RB } }, 3531{"evmhessf", VX (4,1027), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2418{ "evmhessfaaw",VX(4, 1283), VX_MASK, PPCSPE, { RS, RA, RB } }, 3532{"vand", VX (4,1028), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2419{ "evmhessiaaw",VX(4, 1281), VX_MASK, PPCSPE, { RS, RA, RB } }, 3533{"vcmpequb.", VXR(4, 6,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2420{ "evmhesmfaaw",VX(4, 1291), VX_MASK, PPCSPE, { RS, RA, RB } }, 3534{"vcmpneb.", VXR(4, 7,1), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2421{ "evmhesmiaaw",VX(4, 1289), VX_MASK, PPCSPE, { RS, RA, RB } }, 3535{"udi0fcm.", APU(4, 515,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2422{ "evmheusiaaw",VX(4, 1280), VX_MASK, PPCSPE, { RS, RA, RB } }, 3536{"udi0fcm", APU(4, 515,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2423{ "evmheumiaaw",VX(4, 1288), VX_MASK, PPCSPE, { RS, RA, RB } }, 3537{"evmhossf", VX (4,1031), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2424 3538{"vpmsumb", VX (4,1032), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2425{ "evmhossfanw",VX(4, 1415), VX_MASK, PPCSPE, { RS, RA, RB } }, 3539{"evmheumi", VX (4,1032), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2426{ "evmhossianw",VX(4, 1413), VX_MASK, PPCSPE, { RS, RA, RB } }, 3540{"evmhesmi", VX (4,1033), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2427{ "evmhosmfanw",VX(4, 1423), VX_MASK, PPCSPE, { RS, RA, RB } }, 3541{"vmaxfp", VX (4,1034), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2428{ "evmhosmianw",VX(4, 1421), VX_MASK, PPCSPE, { RS, RA, RB } }, 3542{"evmhesmf", VX (4,1035), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2429{ "evmhousianw",VX(4, 1412), VX_MASK, PPCSPE, { RS, RA, RB } }, 3543{"evmhoumi", VX (4,1036), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2430{ "evmhoumianw",VX(4, 1420), VX_MASK, PPCSPE, { RS, RA, RB } }, 3544{"vslo", VX (4,1036), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2431{ "evmhessfanw",VX(4, 1411), VX_MASK, PPCSPE, { RS, RA, RB } }, 3545{"evmhosmi", VX (4,1037), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2432{ "evmhessianw",VX(4, 1409), VX_MASK, PPCSPE, { RS, RA, RB } }, 3546{"evmhosmf", VX (4,1039), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2433{ "evmhesmfanw",VX(4, 1419), VX_MASK, PPCSPE, { RS, RA, RB } }, 3547{"machhwuo", XO (4, 12,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2434{ "evmhesmianw",VX(4, 1417), VX_MASK, PPCSPE, { RS, RA, RB } }, 3548{"machhwuo.", XO (4, 12,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2435{ "evmheusianw",VX(4, 1408), VX_MASK, PPCSPE, { RS, RA, RB } }, 3549{"ps_merge00", XOPS(4,528,0), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2436{ "evmheumianw",VX(4, 1416), VX_MASK, PPCSPE, { RS, RA, RB } }, 3550{"ps_merge00.", XOPS(4,528,1), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2437 3551{"evmhessfa", VX (4,1059), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2438{ "evmhogsmfaa",VX(4, 1327), VX_MASK, PPCSPE, { RS, RA, RB } }, 3552{"evmhossfa", VX (4,1063), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2439{ "evmhogsmiaa",VX(4, 1325), VX_MASK, PPCSPE, { RS, RA, RB } }, 3553{"evmheumia", VX (4,1064), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2440{ "evmhogumiaa",VX(4, 1324), VX_MASK, PPCSPE, { RS, RA, RB } }, 3554{"evmhesmia", VX (4,1065), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2441{ "evmhegsmfaa",VX(4, 1323), VX_MASK, PPCSPE, { RS, RA, RB } }, 3555{"evmhesmfa", VX (4,1067), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2442{ "evmhegsmiaa",VX(4, 1321), VX_MASK, PPCSPE, { RS, RA, RB } }, 3556{"evmhoumia", VX (4,1068), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2443{ "evmhegumiaa",VX(4, 1320), VX_MASK, PPCSPE, { RS, RA, RB } }, 3557{"evmhosmia", VX (4,1069), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2444 3558{"evmhosmfa", VX (4,1071), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2445{ "evmhogsmfan",VX(4, 1455), VX_MASK, PPCSPE, { RS, RA, RB } }, 3559{"vsubuhm", VX (4,1088), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2446{ "evmhogsmian",VX(4, 1453), VX_MASK, PPCSPE, { RS, RA, RB } }, 3560{"bcdsub.", VX (4,1089), VXPS_MASK, PPCVEC2, 0, {VD, VA, VB, PS}},
2447{ "evmhogumian",VX(4, 1452), VX_MASK, PPCSPE, { RS, RA, RB } }, 3561{"vavguh", VX (4,1090), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2448{ "evmhegsmfan",VX(4, 1451), VX_MASK, PPCSPE, { RS, RA, RB } }, 3562{"vabsduh", VX (4,1091), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2449{ "evmhegsmian",VX(4, 1449), VX_MASK, PPCSPE, { RS, RA, RB } }, 3563{"vandc", VX (4,1092), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2450{ "evmhegumian",VX(4, 1448), VX_MASK, PPCSPE, { RS, RA, RB } }, 3564{"vcmpequh.", VXR(4, 70,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2451 3565{"udi1fcm.", APU(4, 547,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2452{ "evmwhssf", VX(4, 1095), VX_MASK, PPCSPE, { RS, RA, RB } }, 3566{"udi1fcm", APU(4, 547,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2453{ "evmwhssfa", VX(4, 1127), VX_MASK, PPCSPE, { RS, RA, RB } }, 3567{"vcmpneh.", VXR(4, 71,1), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2454{ "evmwhsmf", VX(4, 1103), VX_MASK, PPCSPE, { RS, RA, RB } }, 3568{"evmwhssf", VX (4,1095), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2455{ "evmwhsmfa", VX(4, 1135), VX_MASK, PPCSPE, { RS, RA, RB } }, 3569{"vpmsumh", VX (4,1096), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2456{ "evmwhsmi", VX(4, 1101), VX_MASK, PPCSPE, { RS, RA, RB } }, 3570{"evmwlumi", VX (4,1096), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2457{ "evmwhsmia", VX(4, 1133), VX_MASK, PPCSPE, { RS, RA, RB } }, 3571{"vminfp", VX (4,1098), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2458{ "evmwhumi", VX(4, 1100), VX_MASK, PPCSPE, { RS, RA, RB } }, 3572{"evmwhumi", VX (4,1100), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2459{ "evmwhumia", VX(4, 1132), VX_MASK, PPCSPE, { RS, RA, RB } }, 3573{"vsro", VX (4,1100), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2460 3574{"evmwhsmi", VX (4,1101), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2461{ "evmwlumi", VX(4, 1096), VX_MASK, PPCSPE, { RS, RA, RB } }, 3575{"vpkudum", VX (4,1102), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2462{ "evmwlumia", VX(4, 1128), VX_MASK, PPCSPE, { RS, RA, RB } }, 3576{"evmwhsmf", VX (4,1103), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2463 3577{"evmwssf", VX (4,1107), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2464{ "evmwlssiaaw",VX(4, 1345), VX_MASK, PPCSPE, { RS, RA, RB } }, 3578{"machhwo", XO (4, 44,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2465{ "evmwlsmiaaw",VX(4, 1353), VX_MASK, PPCSPE, { RS, RA, RB } }, 3579{"evmwumi", VX (4,1112), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2466{ "evmwlusiaaw",VX(4, 1344), VX_MASK, PPCSPE, { RS, RA, RB } }, 3580{"machhwo.", XO (4, 44,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2467{ "evmwlumiaaw",VX(4, 1352), VX_MASK, PPCSPE, { RS, RA, RB } }, 3581{"evmwsmi", VX (4,1113), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2468 3582{"evmwsmf", VX (4,1115), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2469{ "evmwlssianw",VX(4, 1473), VX_MASK, PPCSPE, { RS, RA, RB } }, 3583{"nmachhwo", XO (4, 46,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2470{ "evmwlsmianw",VX(4, 1481), VX_MASK, PPCSPE, { RS, RA, RB } }, 3584{"nmachhwo.", XO (4, 46,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2471{ "evmwlusianw",VX(4, 1472), VX_MASK, PPCSPE, { RS, RA, RB } }, 3585{"ps_merge01", XOPS(4,560,0), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2472{ "evmwlumianw",VX(4, 1480), VX_MASK, PPCSPE, { RS, RA, RB } }, 3586{"ps_merge01.", XOPS(4,560,1), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2473 3587{"evmwhssfa", VX (4,1127), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2474{ "evmwssf", VX(4, 1107), VX_MASK, PPCSPE, { RS, RA, RB } }, 3588{"evmwlumia", VX (4,1128), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2475{ "evmwssfa", VX(4, 1139), VX_MASK, PPCSPE, { RS, RA, RB } }, 3589{"evmwhumia", VX (4,1132), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2476{ "evmwsmf", VX(4, 1115), VX_MASK, PPCSPE, { RS, RA, RB } }, 3590{"evmwhsmia", VX (4,1133), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2477{ "evmwsmfa", VX(4, 1147), VX_MASK, PPCSPE, { RS, RA, RB } }, 3591{"evmwhsmfa", VX (4,1135), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2478{ "evmwsmi", VX(4, 1113), VX_MASK, PPCSPE, { RS, RA, RB } }, 3592{"evmwssfa", VX (4,1139), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2479{ "evmwsmia", VX(4, 1145), VX_MASK, PPCSPE, { RS, RA, RB } }, 3593{"evmwumia", VX (4,1144), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2480{ "evmwumi", VX(4, 1112), VX_MASK, PPCSPE, { RS, RA, RB } }, 3594{"evmwsmia", VX (4,1145), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2481{ "evmwumia", VX(4, 1144), VX_MASK, PPCSPE, { RS, RA, RB } }, 3595{"evmwsmfa", VX (4,1147), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2482 3596{"vsubuwm", VX (4,1152), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2483{ "evmwssfaa", VX(4, 1363), VX_MASK, PPCSPE, { RS, RA, RB } }, 3597{"bcdus.", VX (4,1153), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2484{ "evmwsmfaa", VX(4, 1371), VX_MASK, PPCSPE, { RS, RA, RB } }, 3598{"vavguw", VX (4,1154), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2485{ "evmwsmiaa", VX(4, 1369), VX_MASK, PPCSPE, { RS, RA, RB } }, 3599{"vabsduw", VX (4,1155), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2486{ "evmwumiaa", VX(4, 1368), VX_MASK, PPCSPE, { RS, RA, RB } }, 3600{"vmr", VX (4,1156), VX_MASK, PPCVEC, 0, {VD, VA, VBA}},
2487 3601{"vor", VX (4,1156), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2488{ "evmwssfan", VX(4, 1491), VX_MASK, PPCSPE, { RS, RA, RB } }, 3602{"vcmpnew.", VXR(4, 135,1), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2489{ "evmwsmfan", VX(4, 1499), VX_MASK, PPCSPE, { RS, RA, RB } }, 3603{"vpmsumw", VX (4,1160), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2490{ "evmwsmian", VX(4, 1497), VX_MASK, PPCSPE, { RS, RA, RB } }, 3604{"vcmpequw.", VXR(4, 134,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2491{ "evmwumian", VX(4, 1496), VX_MASK, PPCSPE, { RS, RA, RB } }, 3605{"udi2fcm.", APU(4, 579,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2492 3606{"udi2fcm", APU(4, 579,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2493{ "evaddssiaaw",VX(4, 1217), VX_MASK, PPCSPE, { RS, RA } }, 3607{"machhwsuo", XO (4, 76,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2494{ "evaddsmiaaw",VX(4, 1225), VX_MASK, PPCSPE, { RS, RA } }, 3608{"machhwsuo.", XO (4, 76,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2495{ "evaddusiaaw",VX(4, 1216), VX_MASK, PPCSPE, { RS, RA } }, 3609{"ps_merge10", XOPS(4,592,0), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2496{ "evaddumiaaw",VX(4, 1224), VX_MASK, PPCSPE, { RS, RA } }, 3610{"ps_merge10.", XOPS(4,592,1), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2497 3611{"vsubudm", VX (4,1216), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2498{ "evsubfssiaaw",VX(4, 1219), VX_MASK, PPCSPE, { RS, RA } }, 3612{"evaddusiaaw", VX (4,1216), VX_MASK, PPCSPE, 0, {RS, RA}},
2499{ "evsubfsmiaaw",VX(4, 1227), VX_MASK, PPCSPE, { RS, RA } }, 3613{"bcds.", VX (4,1217), VXPS_MASK, PPCVEC3, 0, {VD, VA, VB, PS}},
2500{ "evsubfusiaaw",VX(4, 1218), VX_MASK, PPCSPE, { RS, RA } }, 3614{"evaddssiaaw", VX (4,1217), VX_MASK, PPCSPE, 0, {RS, RA}},
2501{ "evsubfumiaaw",VX(4, 1226), VX_MASK, PPCSPE, { RS, RA } }, 3615{"evsubfusiaaw",VX (4,1218), VX_MASK, PPCSPE, 0, {RS, RA}},
2502 3616{"evsubfssiaaw",VX (4,1219), VX_MASK, PPCSPE, 0, {RS, RA}},
2503{ "evmra", VX(4, 1220), VX_MASK, PPCSPE, { RS, RA } }, 3617{"evmra", VX (4,1220), VX_MASK, PPCSPE, 0, {RS, RA}},
2504 3618{"vxor", VX (4,1220), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2505{ "evdivws", VX(4, 1222), VX_MASK, PPCSPE, { RS, RA, RB } }, 3619{"evdivws", VX (4,1222), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2506{ "evdivwu", VX(4, 1223), VX_MASK, PPCSPE, { RS, RA, RB } }, 3620{"vcmpeqfp.", VXR(4, 198,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2507 3621{"udi3fcm.", APU(4, 611,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2508{ "mulli", OP(7), OP_MASK, PPCCOM, { RT, RA, SI } }, 3622{"vcmpequd.", VXR(4, 199,1), VXR_MASK, PPCVEC2, 0, {VD, VA, VB}},
2509{ "muli", OP(7), OP_MASK, PWRCOM, { RT, RA, SI } }, 3623{"udi3fcm", APU(4, 611,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2510 3624{"evdivwu", VX (4,1223), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2511{ "subfic", OP(8), OP_MASK, PPCCOM, { RT, RA, SI } }, 3625{"vpmsumd", VX (4,1224), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2512{ "sfi", OP(8), OP_MASK, PWRCOM, { RT, RA, SI } }, 3626{"evaddumiaaw", VX (4,1224), VX_MASK, PPCSPE, 0, {RS, RA}},
2513 3627{"evaddsmiaaw", VX (4,1225), VX_MASK, PPCSPE, 0, {RS, RA}},
2514{ "dozi", OP(9), OP_MASK, M601, { RT, RA, SI } }, 3628{"evsubfumiaaw",VX (4,1226), VX_MASK, PPCSPE, 0, {RS, RA}},
2515 3629{"evsubfsmiaaw",VX (4,1227), VX_MASK, PPCSPE, 0, {RS, RA}},
2516{ "bce", B(9,0,0), B_MASK, BOOKE64, { BO, BI, BD } }, 3630{"vpkudus", VX (4,1230), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2517{ "bcel", B(9,0,1), B_MASK, BOOKE64, { BO, BI, BD } }, 3631{"machhwso", XO (4, 108,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2518{ "bcea", B(9,1,0), B_MASK, BOOKE64, { BO, BI, BDA } }, 3632{"machhwso.", XO (4, 108,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2519{ "bcela", B(9,1,1), B_MASK, BOOKE64, { BO, BI, BDA } }, 3633{"nmachhwso", XO (4, 110,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2520 3634{"nmachhwso.", XO (4, 110,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2521{ "cmplwi", OPL(10,0), OPL_MASK, PPCCOM, { OBF, RA, UI } }, 3635{"ps_merge11", XOPS(4,624,0), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2522{ "cmpldi", OPL(10,1), OPL_MASK, PPC64, { OBF, RA, UI } }, 3636{"ps_merge11.", XOPS(4,624,1), XOPS_MASK, PPCPS, 0, {FRT, FRA, FRB}},
2523{ "cmpli", OP(10), OP_MASK, PPC, { BF, L, RA, UI } }, 3637{"vsubuqm", VX (4,1280), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2524{ "cmpli", OP(10), OP_MASK, PWRCOM, { BF, RA, UI } }, 3638{"evmheusiaaw", VX (4,1280), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2525 3639{"bcdtrunc.", VX (4,1281), VXPS_MASK, PPCVEC3, 0, {VD, VA, VB, PS}},
2526{ "cmpwi", OPL(11,0), OPL_MASK, PPCCOM, { OBF, RA, SI } }, 3640{"evmhessiaaw", VX (4,1281), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2527{ "cmpdi", OPL(11,1), OPL_MASK, PPC64, { OBF, RA, SI } }, 3641{"vavgsb", VX (4,1282), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2528{ "cmpi", OP(11), OP_MASK, PPC, { BF, L, RA, SI } }, 3642{"evmhessfaaw", VX (4,1283), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2529{ "cmpi", OP(11), OP_MASK, PWRCOM, { BF, RA, SI } }, 3643{"evmhousiaaw", VX (4,1284), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2530 3644{"vnot", VX (4,1284), VX_MASK, PPCVEC, 0, {VD, VA, VBA}},
2531{ "addic", OP(12), OP_MASK, PPCCOM, { RT, RA, SI } }, 3645{"vnor", VX (4,1284), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2532{ "ai", OP(12), OP_MASK, PWRCOM, { RT, RA, SI } }, 3646{"evmhossiaaw", VX (4,1285), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2533{ "subic", OP(12), OP_MASK, PPCCOM, { RT, RA, NSI } }, 3647{"udi4fcm.", APU(4, 643,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2534 3648{"udi4fcm", APU(4, 643,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2535{ "addic.", OP(13), OP_MASK, PPCCOM, { RT, RA, SI } }, 3649{"vcmpnezb.", VXR(4, 263,1), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2536{ "ai.", OP(13), OP_MASK, PWRCOM, { RT, RA, SI } }, 3650{"evmhossfaaw", VX (4,1287), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2537{ "subic.", OP(13), OP_MASK, PPCCOM, { RT, RA, NSI } }, 3651{"evmheumiaaw", VX (4,1288), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2538 3652{"vcipher", VX (4,1288), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2539{ "li", OP(14), DRA_MASK, PPCCOM, { RT, SI } }, 3653{"vcipherlast", VX (4,1289), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2540{ "lil", OP(14), DRA_MASK, PWRCOM, { RT, SI } }, 3654{"evmhesmiaaw", VX (4,1289), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2541{ "addi", OP(14), OP_MASK, PPCCOM, { RT, RA0, SI } }, 3655{"evmhesmfaaw", VX (4,1291), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2542{ "cal", OP(14), OP_MASK, PWRCOM, { RT, D, RA0 } }, 3656{"vgbbd", VX (4,1292), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2543{ "subi", OP(14), OP_MASK, PPCCOM, { RT, RA0, NSI } }, 3657{"evmhoumiaaw", VX (4,1292), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2544{ "la", OP(14), OP_MASK, PPCCOM, { RT, D, RA0 } }, 3658{"evmhosmiaaw", VX (4,1293), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2545 3659{"evmhosmfaaw", VX (4,1295), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2546{ "lis", OP(15), DRA_MASK, PPCCOM, { RT, SISIGNOPT } }, 3660{"macchwuo", XO (4, 140,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2547{ "liu", OP(15), DRA_MASK, PWRCOM, { RT, SISIGNOPT } }, 3661{"macchwuo.", XO (4, 140,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2548{ "addis", OP(15), OP_MASK, PPCCOM, { RT,RA0,SISIGNOPT } }, 3662{"evmhegumiaa", VX (4,1320), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2549{ "cau", OP(15), OP_MASK, PWRCOM, { RT,RA0,SISIGNOPT } }, 3663{"evmhegsmiaa", VX (4,1321), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2550{ "subis", OP(15), OP_MASK, PPCCOM, { RT, RA0, NSI } }, 3664{"evmhegsmfaa", VX (4,1323), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2551 3665{"evmhogumiaa", VX (4,1324), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2552{ "bdnz-", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } }, 3666{"evmhogsmiaa", VX (4,1325), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2553{ "bdnz+", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } }, 3667{"evmhogsmfaa", VX (4,1327), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2554{ "bdnz", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BD } }, 3668{"vsubcuq", VX (4,1344), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2555{ "bdn", BBO(16,BODNZ,0,0), BBOATBI_MASK, PWRCOM, { BD } }, 3669{"evmwlusiaaw", VX (4,1344), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2556{ "bdnzl-", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } }, 3670{"bcdutrunc.", VX (4,1345), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2557{ "bdnzl+", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } }, 3671{"evmwlssiaaw", VX (4,1345), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2558{ "bdnzl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BD } }, 3672{"vavgsh", VX (4,1346), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2559{ "bdnl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PWRCOM, { BD } }, 3673{"vorc", VX (4,1348), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2560{ "bdnza-", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } }, 3674{"udi5fcm.", APU(4, 675,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2561{ "bdnza+", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } }, 3675{"udi5fcm", APU(4, 675,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2562{ "bdnza", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDA } }, 3676{"vcmpnezh.", VXR(4, 327,1), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2563{ "bdna", BBO(16,BODNZ,1,0), BBOATBI_MASK, PWRCOM, { BDA } }, 3677{"vncipher", VX (4,1352), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2564{ "bdnzla-", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } }, 3678{"evmwlumiaaw", VX (4,1352), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2565{ "bdnzla+", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } }, 3679{"vncipherlast",VX (4,1353), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2566{ "bdnzla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDA } }, 3680{"evmwlsmiaaw", VX (4,1353), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2567{ "bdnla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PWRCOM, { BDA } }, 3681{"vbpermq", VX (4,1356), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2568{ "bdz-", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } }, 3682{"vpksdus", VX (4,1358), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2569{ "bdz+", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } }, 3683{"evmwssfaa", VX (4,1363), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2570{ "bdz", BBO(16,BODZ,0,0), BBOATBI_MASK, COM, { BD } }, 3684{"macchwo", XO (4, 172,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2571{ "bdzl-", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } }, 3685{"evmwumiaa", VX (4,1368), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2572{ "bdzl+", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } }, 3686{"macchwo.", XO (4, 172,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2573{ "bdzl", BBO(16,BODZ,0,1), BBOATBI_MASK, COM, { BD } }, 3687{"evmwsmiaa", VX (4,1369), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2574{ "bdza-", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } }, 3688{"evmwsmfaa", VX (4,1371), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2575{ "bdza+", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } }, 3689{"nmacchwo", XO (4, 174,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2576{ "bdza", BBO(16,BODZ,1,0), BBOATBI_MASK, COM, { BDA } }, 3690{"nmacchwo.", XO (4, 174,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2577{ "bdzla-", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } }, 3691{"evmheusianw", VX (4,1408), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2578{ "bdzla+", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } }, 3692{"vsubcuw", VX (4,1408), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2579{ "bdzla", BBO(16,BODZ,1,1), BBOATBI_MASK, COM, { BDA } }, 3693{"evmhessianw", VX (4,1409), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2580{ "blt-", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3694{"bcdctsq.", VXVA(4,1409,0), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2581{ "blt+", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3695{"bcdcfsq.", VXVA(4,1409,2), VXVAPS_MASK, PPCVEC3, 0, {VD, VB, PS}},
2582{ "blt", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3696{"bcdctz.", VXVA(4,1409,4), VXVAPS_MASK, PPCVEC3, 0, {VD, VB, PS}},
2583{ "bltl-", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3697{"bcdctn.", VXVA(4,1409,5), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2584{ "bltl+", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3698{"bcdcfz.", VXVA(4,1409,6), VXVAPS_MASK, PPCVEC3, 0, {VD, VB, PS}},
2585{ "bltl", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3699{"bcdcfn.", VXVA(4,1409,7), VXVAPS_MASK, PPCVEC3, 0, {VD, VB, PS}},
2586{ "blta-", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3700{"bcdsetsgn.", VXVA(4,1409,31), VXVAPS_MASK, PPCVEC3, 0, {VD, VB, PS}},
2587{ "blta+", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3701{"vavgsw", VX (4,1410), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2588{ "blta", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3702{"evmhessfanw", VX (4,1411), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2589{ "bltla-", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3703{"vnand", VX (4,1412), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2590{ "bltla+", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3704{"evmhousianw", VX (4,1412), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2591{ "bltla", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3705{"evmhossianw", VX (4,1413), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2592{ "bgt-", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3706{"udi6fcm.", APU(4, 707,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2593{ "bgt+", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3707{"udi6fcm", APU(4, 707,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2594{ "bgt", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3708{"vcmpnezw.", VXR(4, 391,1), VXR_MASK, PPCVEC3, 0, {VD, VA, VB}},
2595{ "bgtl-", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3709{"evmhossfanw", VX (4,1415), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2596{ "bgtl+", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3710{"evmheumianw", VX (4,1416), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2597{ "bgtl", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3711{"evmhesmianw", VX (4,1417), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2598{ "bgta-", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3712{"evmhesmfanw", VX (4,1419), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2599{ "bgta+", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3713{"evmhoumianw", VX (4,1420), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2600{ "bgta", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3714{"evmhosmianw", VX (4,1421), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2601{ "bgtla-", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3715{"evmhosmfanw", VX (4,1423), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2602{ "bgtla+", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3716{"macchwsuo", XO (4, 204,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2603{ "bgtla", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3717{"macchwsuo.", XO (4, 204,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2604{ "beq-", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3718{"evmhegumian", VX (4,1448), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2605{ "beq+", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3719{"evmhegsmian", VX (4,1449), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2606{ "beq", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3720{"evmhegsmfan", VX (4,1451), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2607{ "beql-", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3721{"evmhogumian", VX (4,1452), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2608{ "beql+", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3722{"evmhogsmian", VX (4,1453), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2609{ "beql", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3723{"evmhogsmfan", VX (4,1455), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2610{ "beqa-", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3724{"evmwlusianw", VX (4,1472), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2611{ "beqa+", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3725{"bcdsr.", VX (4,1473), VXPS_MASK, PPCVEC3, 0, {VD, VA, VB, PS}},
2612{ "beqa", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3726{"evmwlssianw", VX (4,1473), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2613{ "beqla-", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3727{"vsld", VX (4,1476), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2614{ "beqla+", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3728{"vcmpgefp.", VXR(4, 454,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2615{ "beqla", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3729{"udi7fcm.", APU(4, 739,0), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2616{ "bso-", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3730{"udi7fcm", APU(4, 739,1), APU_MASK, PPC405|PPC440, PPC476, {URT, URA, URB}},
2617{ "bso+", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3731{"vsbox", VX (4,1480), VXVB_MASK, PPCVEC2, 0, {VD, VA}},
2618{ "bso", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3732{"evmwlumianw", VX (4,1480), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2619{ "bsol-", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3733{"evmwlsmianw", VX (4,1481), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2620{ "bsol+", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3734{"vbpermd", VX (4,1484), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2621{ "bsol", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3735{"vpksdss", VX (4,1486), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2622{ "bsoa-", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3736{"evmwssfan", VX (4,1491), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2623{ "bsoa+", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3737{"macchwso", XO (4, 236,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2624{ "bsoa", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3738{"evmwumian", VX (4,1496), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2625{ "bsola-", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3739{"macchwso.", XO (4, 236,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2626{ "bsola+", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3740{"evmwsmian", VX (4,1497), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2627{ "bsola", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3741{"evmwsmfan", VX (4,1499), VX_MASK, PPCSPE, 0, {RS, RA, RB}},
2628{ "bun-", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3742{"nmacchwso", XO (4, 238,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2629{ "bun+", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3743{"nmacchwso.", XO (4, 238,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2630{ "bun", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BD } }, 3744{"vsububs", VX (4,1536), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2631{ "bunl-", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3745{"vclzlsbb", VXVA(4,1538,0), VXVA_MASK, PPCVEC3, 0, {RT, VB}},
2632{ "bunl+", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3746{"vctzlsbb", VXVA(4,1538,1), VXVA_MASK, PPCVEC3, 0, {RT, VB}},
2633{ "bunl", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BD } }, 3747{"vnegw", VXVA(4,1538,6), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2634{ "buna-", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3748{"vnegd", VXVA(4,1538,7), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2635{ "buna+", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3749{"vprtybw", VXVA(4,1538,8), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2636{ "buna", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDA } }, 3750{"vprtybd", VXVA(4,1538,9), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2637{ "bunla-", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3751{"vprtybq", VXVA(4,1538,10), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2638{ "bunla+", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3752{"vextsb2w", VXVA(4,1538,16), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2639{ "bunla", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDA } }, 3753{"vextsh2w", VXVA(4,1538,17), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2640{ "bge-", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3754{"vextsb2d", VXVA(4,1538,24), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2641{ "bge+", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3755{"vextsh2d", VXVA(4,1538,25), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2642{ "bge", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3756{"vextsw2d", VXVA(4,1538,26), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2643{ "bgel-", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3757{"vctzb", VXVA(4,1538,28), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2644{ "bgel+", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3758{"vctzh", VXVA(4,1538,29), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2645{ "bgel", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3759{"vctzw", VXVA(4,1538,30), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2646{ "bgea-", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3760{"vctzd", VXVA(4,1538,31), VXVA_MASK, PPCVEC3, 0, {VD, VB}},
2647{ "bgea+", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3761{"mfvscr", VX (4,1540), VXVAVB_MASK, PPCVEC, 0, {VD}},
2648{ "bgea", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3762{"vcmpgtub.", VXR(4, 518,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2649{ "bgela-", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3763{"udi8fcm.", APU(4, 771,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2650{ "bgela+", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3764{"udi8fcm", APU(4, 771,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2651{ "bgela", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3765{"vsum4ubs", VX (4,1544), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2652{ "bnl-", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3766{"vextublx", VX (4,1549), VX_MASK, PPCVEC3, 0, {RT, RA, VB}},
2653{ "bnl+", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3767{"vsubuhs", VX (4,1600), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2654{ "bnl", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3768{"mtvscr", VX (4,1604), VXVDVA_MASK, PPCVEC, 0, {VB}},
2655{ "bnll-", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3769{"vcmpgtuh.", VXR(4, 582,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2656{ "bnll+", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3770{"vsum4shs", VX (4,1608), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2657{ "bnll", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3771{"udi9fcm.", APU(4, 804,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2658{ "bnla-", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3772{"udi9fcm", APU(4, 804,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2659{ "bnla+", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3773{"vextuhlx", VX (4,1613), VX_MASK, PPCVEC3, 0, {RT, RA, VB}},
2660{ "bnla", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3774{"vupkhsw", VX (4,1614), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2661{ "bnlla-", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3775{"vsubuws", VX (4,1664), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2662{ "bnlla+", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3776{"vshasigmaw", VX (4,1666), VX_MASK, PPCVEC2, 0, {VD, VA, ST, SIX}},
2663{ "bnlla", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3777{"veqv", VX (4,1668), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2664{ "ble-", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3778{"vcmpgtuw.", VXR(4, 646,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2665{ "ble+", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3779{"udi10fcm.", APU(4, 835,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2666{ "ble", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3780{"udi10fcm", APU(4, 835,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2667{ "blel-", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3781{"vsum2sws", VX (4,1672), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2668{ "blel+", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3782{"vmrgow", VX (4,1676), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2669{ "blel", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3783{"vextuwlx", VX (4,1677), VX_MASK, PPCVEC3, 0, {RT, RA, VB}},
2670{ "blea-", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3784{"vshasigmad", VX (4,1730), VX_MASK, PPCVEC2, 0, {VD, VA, ST, SIX}},
2671{ "blea+", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3785{"vsrd", VX (4,1732), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2672{ "blea", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3786{"vcmpgtfp.", VXR(4, 710,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2673{ "blela-", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3787{"udi11fcm.", APU(4, 867,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2674{ "blela+", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3788{"vcmpgtud.", VXR(4, 711,1), VXR_MASK, PPCVEC2, 0, {VD, VA, VB}},
2675{ "blela", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3789{"udi11fcm", APU(4, 867,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2676{ "bng-", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3790{"vupklsw", VX (4,1742), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2677{ "bng+", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3791{"vsubsbs", VX (4,1792), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2678{ "bng", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3792{"vclzb", VX (4,1794), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2679{ "bngl-", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3793{"vpopcntb", VX (4,1795), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2680{ "bngl+", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3794{"vsrv", VX (4,1796), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2681{ "bngl", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3795{"vcmpgtsb.", VXR(4, 774,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2682{ "bnga-", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3796{"udi12fcm.", APU(4, 899,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2683{ "bnga+", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3797{"udi12fcm", APU(4, 899,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2684{ "bnga", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3798{"vsum4sbs", VX (4,1800), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2685{ "bngla-", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3799{"vextubrx", VX (4,1805), VX_MASK, PPCVEC3, 0, {RT, RA, VB}},
2686{ "bngla+", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3800{"maclhwuo", XO (4, 396,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2687{ "bngla", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3801{"maclhwuo.", XO (4, 396,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2688{ "bne-", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3802{"vsubshs", VX (4,1856), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2689{ "bne+", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3803{"vclzh", VX (4,1858), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2690{ "bne", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3804{"vpopcnth", VX (4,1859), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2691{ "bnel-", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3805{"vslv", VX (4,1860), VX_MASK, PPCVEC3, 0, {VD, VA, VB}},
2692{ "bnel+", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3806{"vcmpgtsh.", VXR(4, 838,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2693{ "bnel", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3807{"vextuhrx", VX (4,1869), VX_MASK, PPCVEC3, 0, {RT, RA, VB}},
2694{ "bnea-", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3808{"udi13fcm.", APU(4, 931,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2695{ "bnea+", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3809{"udi13fcm", APU(4, 931,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2696{ "bnea", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3810{"maclhwo", XO (4, 428,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2697{ "bnela-", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3811{"maclhwo.", XO (4, 428,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2698{ "bnela+", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3812{"nmaclhwo", XO (4, 430,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2699{ "bnela", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3813{"nmaclhwo.", XO (4, 430,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2700{ "bns-", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3814{"vsubsws", VX (4,1920), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2701{ "bns+", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3815{"vclzw", VX (4,1922), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2702{ "bns", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, COM, { CR, BD } }, 3816{"vpopcntw", VX (4,1923), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2703{ "bnsl-", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3817{"vcmpgtsw.", VXR(4, 902,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2704{ "bnsl+", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3818{"udi14fcm.", APU(4, 963,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2705{ "bnsl", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, COM, { CR, BD } }, 3819{"udi14fcm", APU(4, 963,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2706{ "bnsa-", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3820{"vsumsws", VX (4,1928), VX_MASK, PPCVEC, 0, {VD, VA, VB}},
2707{ "bnsa+", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3821{"vmrgew", VX (4,1932), VX_MASK, PPCVEC2, 0, {VD, VA, VB}},
2708{ "bnsa", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, COM, { CR, BDA } }, 3822{"vextuwrx", VX (4,1933), VX_MASK, PPCVEC3, 0, {RT, RA, VB}},
2709{ "bnsla-", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3823{"maclhwsuo", XO (4, 460,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2710{ "bnsla+", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3824{"maclhwsuo.", XO (4, 460,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2711{ "bnsla", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, COM, { CR, BDA } }, 3825{"vclzd", VX (4,1986), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2712{ "bnu-", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3826{"vpopcntd", VX (4,1987), VXVA_MASK, PPCVEC2, 0, {VD, VB}},
2713{ "bnu+", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3827{"vcmpbfp.", VXR(4, 966,1), VXR_MASK, PPCVEC, 0, {VD, VA, VB}},
2714{ "bnu", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BD } }, 3828{"udi15fcm.", APU(4, 995,0), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2715{ "bnul-", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, 3829{"vcmpgtsd.", VXR(4, 967,1), VXR_MASK, PPCVEC2, 0, {VD, VA, VB}},
2716{ "bnul+", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, 3830{"udi15fcm", APU(4, 995,1), APU_MASK, PPC440, PPC476, {URT, URA, URB}},
2717{ "bnul", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BD } }, 3831{"maclhwso", XO (4, 492,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2718{ "bnua-", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3832{"maclhwso.", XO (4, 492,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2719{ "bnua+", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3833{"nmaclhwso", XO (4, 494,1,0), XO_MASK, MULHW, 0, {RT, RA, RB}},
2720{ "bnua", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDA } }, 3834{"nmaclhwso.", XO (4, 494,1,1), XO_MASK, MULHW, 0, {RT, RA, RB}},
2721{ "bnula-", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, 3835{"dcbz_l", X (4,1014), XRT_MASK, PPCPS, 0, {RA, RB}},
2722{ "bnula+", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, 3836
2723{ "bnula", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDA } }, 3837{"mulli", OP(7), OP_MASK, PPCCOM, PPCVLE, {RT, RA, SI}},
2724{ "bdnzt-", BBO(16,BODNZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3838{"muli", OP(7), OP_MASK, PWRCOM, PPCVLE, {RT, RA, SI}},
2725{ "bdnzt+", BBO(16,BODNZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3839
2726{ "bdnzt", BBO(16,BODNZT,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, 3840{"subfic", OP(8), OP_MASK, PPCCOM, PPCVLE, {RT, RA, SI}},
2727{ "bdnztl-", BBO(16,BODNZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3841{"sfi", OP(8), OP_MASK, PWRCOM, PPCVLE, {RT, RA, SI}},
2728{ "bdnztl+", BBO(16,BODNZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3842
2729{ "bdnztl", BBO(16,BODNZT,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, 3843{"dozi", OP(9), OP_MASK, M601, PPCVLE, {RT, RA, SI}},
2730{ "bdnzta-", BBO(16,BODNZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3844
2731{ "bdnzta+", BBO(16,BODNZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3845{"cmplwi", OPL(10,0), OPL_MASK, PPCCOM, PPCVLE, {OBF, RA, UISIGNOPT}},
2732{ "bdnzta", BBO(16,BODNZT,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, 3846{"cmpldi", OPL(10,1), OPL_MASK, PPC64, PPCVLE, {OBF, RA, UISIGNOPT}},
2733{ "bdnztla-",BBO(16,BODNZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3847{"cmpli", OP(10), OP_MASK, PPC, PPCVLE, {BF, L32OPT, RA, UISIGNOPT}},
2734{ "bdnztla+",BBO(16,BODNZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3848{"cmpli", OP(10), OP_MASK, PWRCOM, PPC|PPCVLE, {BF, RA, UISIGNOPT}},
2735{ "bdnztla", BBO(16,BODNZT,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, 3849
2736{ "bdnzf-", BBO(16,BODNZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3850{"cmpwi", OPL(11,0), OPL_MASK, PPCCOM, PPCVLE, {OBF, RA, SI}},
2737{ "bdnzf+", BBO(16,BODNZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3851{"cmpdi", OPL(11,1), OPL_MASK, PPC64, PPCVLE, {OBF, RA, SI}},
2738{ "bdnzf", BBO(16,BODNZF,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, 3852{"cmpi", OP(11), OP_MASK, PPC, PPCVLE, {BF, L32OPT, RA, SI}},
2739{ "bdnzfl-", BBO(16,BODNZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3853{"cmpi", OP(11), OP_MASK, PWRCOM, PPC|PPCVLE, {BF, RA, SI}},
2740{ "bdnzfl+", BBO(16,BODNZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3854
2741{ "bdnzfl", BBO(16,BODNZF,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, 3855{"addic", OP(12), OP_MASK, PPCCOM, PPCVLE, {RT, RA, SI}},
2742{ "bdnzfa-", BBO(16,BODNZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3856{"ai", OP(12), OP_MASK, PWRCOM, PPCVLE, {RT, RA, SI}},
2743{ "bdnzfa+", BBO(16,BODNZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3857{"subic", OP(12), OP_MASK, PPCCOM, PPCVLE, {RT, RA, NSI}},
2744{ "bdnzfa", BBO(16,BODNZF,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, 3858
2745{ "bdnzfla-",BBO(16,BODNZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3859{"addic.", OP(13), OP_MASK, PPCCOM, PPCVLE, {RT, RA, SI}},
2746{ "bdnzfla+",BBO(16,BODNZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3860{"ai.", OP(13), OP_MASK, PWRCOM, PPCVLE, {RT, RA, SI}},
2747{ "bdnzfla", BBO(16,BODNZF,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, 3861{"subic.", OP(13), OP_MASK, PPCCOM, PPCVLE, {RT, RA, NSI}},
2748{ "bt-", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, { BI, BDM } }, 3862
2749{ "bt+", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, { BI, BDP } }, 3863{"li", OP(14), DRA_MASK, PPCCOM, PPCVLE, {RT, SI}},
2750{ "bt", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, { BI, BD } }, 3864{"lil", OP(14), DRA_MASK, PWRCOM, PPCVLE, {RT, SI}},
2751{ "bbt", BBO(16,BOT,0,0), BBOAT_MASK, PWRCOM, { BI, BD } }, 3865{"addi", OP(14), OP_MASK, PPCCOM, PPCVLE, {RT, RA0, SI}},
2752{ "btl-", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, { BI, BDM } }, 3866{"cal", OP(14), OP_MASK, PWRCOM, PPCVLE, {RT, D, RA0}},
2753{ "btl+", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, { BI, BDP } }, 3867{"subi", OP(14), OP_MASK, PPCCOM, PPCVLE, {RT, RA0, NSI}},
2754{ "btl", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, { BI, BD } }, 3868{"la", OP(14), OP_MASK, PPCCOM, PPCVLE, {RT, D, RA0}},
2755{ "bbtl", BBO(16,BOT,0,1), BBOAT_MASK, PWRCOM, { BI, BD } }, 3869
2756{ "bta-", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, { BI, BDMA } }, 3870{"lis", OP(15), DRA_MASK, PPCCOM, PPCVLE, {RT, SISIGNOPT}},
2757{ "bta+", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, { BI, BDPA } }, 3871{"liu", OP(15), DRA_MASK, PWRCOM, PPCVLE, {RT, SISIGNOPT}},
2758{ "bta", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, { BI, BDA } }, 3872{"addis", OP(15), OP_MASK, PPCCOM, PPCVLE, {RT, RA0, SISIGNOPT}},
2759{ "bbta", BBO(16,BOT,1,0), BBOAT_MASK, PWRCOM, { BI, BDA } }, 3873{"cau", OP(15), OP_MASK, PWRCOM, PPCVLE, {RT, RA0, SISIGNOPT}},
2760{ "btla-", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, { BI, BDMA } }, 3874{"subis", OP(15), OP_MASK, PPCCOM, PPCVLE, {RT, RA0, NSISIGNOPT}},
2761{ "btla+", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, { BI, BDPA } }, 3875
2762{ "btla", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, { BI, BDA } }, 3876{"bdnz-", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDM}},
2763{ "bbtla", BBO(16,BOT,1,1), BBOAT_MASK, PWRCOM, { BI, BDA } }, 3877{"bdnz+", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDP}},
2764{ "bf-", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, { BI, BDM } }, 3878{"bdnz", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BD}},
2765{ "bf+", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, { BI, BDP } }, 3879{"bdn", BBO(16,BODNZ,0,0), BBOATBI_MASK, PWRCOM, PPCVLE, {BD}},
2766{ "bf", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, { BI, BD } }, 3880{"bdnzl-", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDM}},
2767{ "bbf", BBO(16,BOF,0,0), BBOAT_MASK, PWRCOM, { BI, BD } }, 3881{"bdnzl+", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDP}},
2768{ "bfl-", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, { BI, BDM } }, 3882{"bdnzl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BD}},
2769{ "bfl+", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, { BI, BDP } }, 3883{"bdnl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PWRCOM, PPCVLE, {BD}},
2770{ "bfl", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, { BI, BD } }, 3884{"bdnza-", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDMA}},
2771{ "bbfl", BBO(16,BOF,0,1), BBOAT_MASK, PWRCOM, { BI, BD } }, 3885{"bdnza+", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDPA}},
2772{ "bfa-", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, { BI, BDMA } }, 3886{"bdnza", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDA}},
2773{ "bfa+", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, { BI, BDPA } }, 3887{"bdna", BBO(16,BODNZ,1,0), BBOATBI_MASK, PWRCOM, PPCVLE, {BDA}},
2774{ "bfa", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, { BI, BDA } }, 3888{"bdnzla-", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDMA}},
2775{ "bbfa", BBO(16,BOF,1,0), BBOAT_MASK, PWRCOM, { BI, BDA } }, 3889{"bdnzla+", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDPA}},
2776{ "bfla-", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, { BI, BDMA } }, 3890{"bdnzla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDA}},
2777{ "bfla+", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, { BI, BDPA } }, 3891{"bdnla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PWRCOM, PPCVLE, {BDA}},
2778{ "bfla", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, { BI, BDA } }, 3892{"bdz-", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDM}},
2779{ "bbfla", BBO(16,BOF,1,1), BBOAT_MASK, PWRCOM, { BI, BDA } }, 3893{"bdz+", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDP}},
2780{ "bdzt-", BBO(16,BODZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3894{"bdz", BBO(16,BODZ,0,0), BBOATBI_MASK, COM, PPCVLE, {BD}},
2781{ "bdzt+", BBO(16,BODZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3895{"bdzl-", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDM}},
2782{ "bdzt", BBO(16,BODZT,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, 3896{"bdzl+", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDP}},
2783{ "bdztl-", BBO(16,BODZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3897{"bdzl", BBO(16,BODZ,0,1), BBOATBI_MASK, COM, PPCVLE, {BD}},
2784{ "bdztl+", BBO(16,BODZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3898{"bdza-", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDMA}},
2785{ "bdztl", BBO(16,BODZT,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, 3899{"bdza+", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, PPCVLE, {BDPA}},
2786{ "bdzta-", BBO(16,BODZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3900{"bdza", BBO(16,BODZ,1,0), BBOATBI_MASK, COM, PPCVLE, {BDA}},
2787{ "bdzta+", BBO(16,BODZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3901{"bdzla-", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDMA}},
2788{ "bdzta", BBO(16,BODZT,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, 3902{"bdzla+", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, PPCVLE, {BDPA}},
2789{ "bdztla-", BBO(16,BODZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3903{"bdzla", BBO(16,BODZ,1,1), BBOATBI_MASK, COM, PPCVLE, {BDA}},
2790{ "bdztla+", BBO(16,BODZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3904
2791{ "bdztla", BBO(16,BODZT,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, 3905{"bge-", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2792{ "bdzf-", BBO(16,BODZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3906{"bge+", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2793{ "bdzf+", BBO(16,BODZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3907{"bge", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2794{ "bdzf", BBO(16,BODZF,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, 3908{"bnl-", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2795{ "bdzfl-", BBO(16,BODZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, 3909{"bnl+", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2796{ "bdzfl+", BBO(16,BODZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, 3910{"bnl", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2797{ "bdzfl", BBO(16,BODZF,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, 3911{"bgel-", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2798{ "bdzfa-", BBO(16,BODZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3912{"bgel+", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2799{ "bdzfa+", BBO(16,BODZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3913{"bgel", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2800{ "bdzfa", BBO(16,BODZF,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, 3914{"bnll-", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2801{ "bdzfla-", BBO(16,BODZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, 3915{"bnll+", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2802{ "bdzfla+", BBO(16,BODZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, 3916{"bnll", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2803{ "bdzfla", BBO(16,BODZF,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, 3917{"bgea-", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2804{ "bc-", B(16,0,0), B_MASK, PPCCOM, { BOE, BI, BDM } }, 3918{"bgea+", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2805{ "bc+", B(16,0,0), B_MASK, PPCCOM, { BOE, BI, BDP } }, 3919{"bgea", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2806{ "bc", B(16,0,0), B_MASK, COM, { BO, BI, BD } }, 3920{"bnla-", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2807{ "bcl-", B(16,0,1), B_MASK, PPCCOM, { BOE, BI, BDM } }, 3921{"bnla+", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2808{ "bcl+", B(16,0,1), B_MASK, PPCCOM, { BOE, BI, BDP } }, 3922{"bnla", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2809{ "bcl", B(16,0,1), B_MASK, COM, { BO, BI, BD } }, 3923{"bgela-", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2810{ "bca-", B(16,1,0), B_MASK, PPCCOM, { BOE, BI, BDMA } }, 3924{"bgela+", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2811{ "bca+", B(16,1,0), B_MASK, PPCCOM, { BOE, BI, BDPA } }, 3925{"bgela", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2812{ "bca", B(16,1,0), B_MASK, COM, { BO, BI, BDA } }, 3926{"bnlla-", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2813{ "bcla-", B(16,1,1), B_MASK, PPCCOM, { BOE, BI, BDMA } }, 3927{"bnlla+", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2814{ "bcla+", B(16,1,1), B_MASK, PPCCOM, { BOE, BI, BDPA } }, 3928{"bnlla", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2815{ "bcla", B(16,1,1), B_MASK, COM, { BO, BI, BDA } }, 3929{"ble-", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2816 3930{"ble+", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2817{ "sc", SC(17,1,0), SC_MASK, PPC, { LEV } }, 3931{"ble", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2818{ "svc", SC(17,0,0), SC_MASK, POWER, { SVC_LEV, FL1, FL2 } }, 3932{"bng-", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2819{ "svcl", SC(17,0,1), SC_MASK, POWER, { SVC_LEV, FL1, FL2 } }, 3933{"bng+", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2820{ "svca", SC(17,1,0), SC_MASK, PWRCOM, { SV } }, 3934{"bng", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2821{ "svcla", SC(17,1,1), SC_MASK, POWER, { SV } }, 3935{"blel-", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2822 3936{"blel+", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2823{ "b", B(18,0,0), B_MASK, COM, { LI } }, 3937{"blel", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2824{ "bl", B(18,0,1), B_MASK, COM, { LI } }, 3938{"bngl-", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2825{ "ba", B(18,1,0), B_MASK, COM, { LIA } }, 3939{"bngl+", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2826{ "bla", B(18,1,1), B_MASK, COM, { LIA } }, 3940{"bngl", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2827 3941{"blea-", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2828{ "mcrf", XL(19,0), XLBB_MASK|(3 << 21)|(3 << 16), COM, { BF, BFA } }, 3942{"blea+", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2829 3943{"blea", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2830{ "blr", XLO(19,BOU,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } }, 3944{"bnga-", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2831{ "br", XLO(19,BOU,16,0), XLBOBIBB_MASK, PWRCOM, { 0 } }, 3945{"bnga+", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2832{ "blrl", XLO(19,BOU,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } }, 3946{"bnga", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2833{ "brl", XLO(19,BOU,16,1), XLBOBIBB_MASK, PWRCOM, { 0 } }, 3947{"blela-", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2834{ "bdnzlr", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } }, 3948{"blela+", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2835{ "bdnzlr-", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3949{"blela", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2836{ "bdnzlr-", XLO(19,BODNZM4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, 3950{"bngla-", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2837{ "bdnzlr+", XLO(19,BODNZP,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3951{"bngla+", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2838{ "bdnzlr+", XLO(19,BODNZP4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, 3952{"bngla", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2839{ "bdnzlrl", XLO(19,BODNZ,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } }, 3953{"bne-", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2840{ "bdnzlrl-",XLO(19,BODNZ,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3954{"bne+", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2841{ "bdnzlrl-",XLO(19,BODNZM4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, 3955{"bne", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2842{ "bdnzlrl+",XLO(19,BODNZP,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3956{"bnel-", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2843{ "bdnzlrl+",XLO(19,BODNZP4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, 3957{"bnel+", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2844{ "bdzlr", XLO(19,BODZ,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } }, 3958{"bnel", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2845{ "bdzlr-", XLO(19,BODZ,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3959{"bnea-", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2846{ "bdzlr-", XLO(19,BODZM4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, 3960{"bnea+", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2847{ "bdzlr+", XLO(19,BODZP,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3961{"bnea", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2848{ "bdzlr+", XLO(19,BODZP4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, 3962{"bnela-", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2849{ "bdzlrl", XLO(19,BODZ,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } }, 3963{"bnela+", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2850{ "bdzlrl-", XLO(19,BODZ,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3964{"bnela", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2851{ "bdzlrl-", XLO(19,BODZM4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, 3965{"bns-", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2852{ "bdzlrl+", XLO(19,BODZP,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, 3966{"bns+", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2853{ "bdzlrl+", XLO(19,BODZP4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, 3967{"bns", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2854{ "bltlr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 3968{"bnu-", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2855{ "bltlr-", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3969{"bnu+", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2856{ "bltlr-", XLOCB(19,BOTM4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 3970{"bnu", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BD}},
2857{ "bltlr+", XLOCB(19,BOTP,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3971{"bnsl-", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2858{ "bltlr+", XLOCB(19,BOTP4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 3972{"bnsl+", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2859{ "bltr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 3973{"bnsl", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2860{ "bltlrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 3974{"bnul-", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2861{ "bltlrl-", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3975{"bnul+", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2862{ "bltlrl-", XLOCB(19,BOTM4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 3976{"bnul", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BD}},
2863{ "bltlrl+", XLOCB(19,BOTP,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3977{"bnsa-", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2864{ "bltlrl+", XLOCB(19,BOTP4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 3978{"bnsa+", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2865{ "bltrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 3979{"bnsa", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2866{ "bgtlr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 3980{"bnua-", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2867{ "bgtlr-", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3981{"bnua+", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2868{ "bgtlr-", XLOCB(19,BOTM4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 3982{"bnua", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDA}},
2869{ "bgtlr+", XLOCB(19,BOTP,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3983{"bnsla-", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2870{ "bgtlr+", XLOCB(19,BOTP4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 3984{"bnsla+", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2871{ "bgtr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 3985{"bnsla", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2872{ "bgtlrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 3986{"bnula-", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2873{ "bgtlrl-", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3987{"bnula+", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2874{ "bgtlrl-", XLOCB(19,BOTM4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 3988{"bnula", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDA}},
2875{ "bgtlrl+", XLOCB(19,BOTP,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3989
2876{ "bgtlrl+", XLOCB(19,BOTP4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 3990{"blt-", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2877{ "bgtrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 3991{"blt+", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2878{ "beqlr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 3992{"blt", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2879{ "beqlr-", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3993{"bltl-", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2880{ "beqlr-", XLOCB(19,BOTM4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 3994{"bltl+", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2881{ "beqlr+", XLOCB(19,BOTP,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3995{"bltl", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2882{ "beqlr+", XLOCB(19,BOTP4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 3996{"blta-", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2883{ "beqr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 3997{"blta+", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2884{ "beqlrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 3998{"blta", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2885{ "beqlrl-", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 3999{"bltla-", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2886{ "beqlrl-", XLOCB(19,BOTM4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4000{"bltla+", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2887{ "beqlrl+", XLOCB(19,BOTP,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4001{"bltla", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2888{ "beqlrl+", XLOCB(19,BOTP4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4002{"bgt-", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2889{ "beqrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4003{"bgt+", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2890{ "bsolr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4004{"bgt", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2891{ "bsolr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4005{"bgtl-", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2892{ "bsolr-", XLOCB(19,BOTM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4006{"bgtl+", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2893{ "bsolr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4007{"bgtl", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2894{ "bsolr+", XLOCB(19,BOTP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4008{"bgta-", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2895{ "bsor", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 4009{"bgta+", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2896{ "bsolrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4010{"bgta", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2897{ "bsolrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4011{"bgtla-", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2898{ "bsolrl-", XLOCB(19,BOTM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4012{"bgtla+", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2899{ "bsolrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4013{"bgtla", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2900{ "bsolrl+", XLOCB(19,BOTP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4014{"beq-", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2901{ "bsorl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4015{"beq+", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2902{ "bunlr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4016{"beq", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2903{ "bunlr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4017{"beql-", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2904{ "bunlr-", XLOCB(19,BOTM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4018{"beql+", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2905{ "bunlr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4019{"beql", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2906{ "bunlr+", XLOCB(19,BOTP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4020{"beqa-", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2907{ "bunlrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4021{"beqa+", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2908{ "bunlrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4022{"beqa", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2909{ "bunlrl-", XLOCB(19,BOTM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4023{"beqla-", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2910{ "bunlrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4024{"beqla+", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2911{ "bunlrl+", XLOCB(19,BOTP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4025{"beqla", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2912{ "bgelr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4026{"bso-", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2913{ "bgelr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4027{"bso+", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2914{ "bgelr-", XLOCB(19,BOFM4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4028{"bso", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2915{ "bgelr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4029{"bun-", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2916{ "bgelr+", XLOCB(19,BOFP4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4030{"bun+", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2917{ "bger", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 4031{"bun", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BD}},
2918{ "bgelrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4032{"bsol-", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2919{ "bgelrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4033{"bsol+", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2920{ "bgelrl-", XLOCB(19,BOFM4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4034{"bsol", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, COM, PPCVLE, {CR, BD}},
2921{ "bgelrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4035{"bunl-", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDM}},
2922{ "bgelrl+", XLOCB(19,BOFP4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4036{"bunl+", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDP}},
2923{ "bgerl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4037{"bunl", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BD}},
2924{ "bnllr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4038{"bsoa-", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2925{ "bnllr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4039{"bsoa+", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2926{ "bnllr-", XLOCB(19,BOFM4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4040{"bsoa", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2927{ "bnllr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4041{"buna-", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2928{ "bnllr+", XLOCB(19,BOFP4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4042{"buna+", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2929{ "bnlr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 4043{"buna", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDA}},
2930{ "bnllrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4044{"bsola-", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2931{ "bnllrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4045{"bsola+", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2932{ "bnllrl-", XLOCB(19,BOFM4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4046{"bsola", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, COM, PPCVLE, {CR, BDA}},
2933{ "bnllrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4047{"bunla-", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDMA}},
2934{ "bnllrl+", XLOCB(19,BOFP4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4048{"bunla+", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDPA}},
2935{ "bnlrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4049{"bunla", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, PPCVLE, {CR, BDA}},
2936{ "blelr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4050
2937{ "blelr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4051{"bdnzf-", BBO(16,BODNZF,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2938{ "blelr-", XLOCB(19,BOFM4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4052{"bdnzf+", BBO(16,BODNZF,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2939{ "blelr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4053{"bdnzf", BBO(16,BODNZF,0,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2940{ "blelr+", XLOCB(19,BOFP4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4054{"bdnzfl-", BBO(16,BODNZF,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2941{ "bler", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 4055{"bdnzfl+", BBO(16,BODNZF,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2942{ "blelrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4056{"bdnzfl", BBO(16,BODNZF,0,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2943{ "blelrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4057{"bdnzfa-", BBO(16,BODNZF,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
2944{ "blelrl-", XLOCB(19,BOFM4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4058{"bdnzfa+", BBO(16,BODNZF,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
2945{ "blelrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4059{"bdnzfa", BBO(16,BODNZF,1,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2946{ "blelrl+", XLOCB(19,BOFP4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4060{"bdnzfla-", BBO(16,BODNZF,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
2947{ "blerl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4061{"bdnzfla+", BBO(16,BODNZF,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
2948{ "bnglr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4062{"bdnzfla", BBO(16,BODNZF,1,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2949{ "bnglr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4063{"bdzf-", BBO(16,BODZF,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2950{ "bnglr-", XLOCB(19,BOFM4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4064{"bdzf+", BBO(16,BODZF,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2951{ "bnglr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4065{"bdzf", BBO(16,BODZF,0,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2952{ "bnglr+", XLOCB(19,BOFP4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4066{"bdzfl-", BBO(16,BODZF,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2953{ "bngr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 4067{"bdzfl+", BBO(16,BODZF,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2954{ "bnglrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4068{"bdzfl", BBO(16,BODZF,0,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2955{ "bnglrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4069{"bdzfa-", BBO(16,BODZF,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
2956{ "bnglrl-", XLOCB(19,BOFM4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4070{"bdzfa+", BBO(16,BODZF,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
2957{ "bnglrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4071{"bdzfa", BBO(16,BODZF,1,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2958{ "bnglrl+", XLOCB(19,BOFP4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4072{"bdzfla-", BBO(16,BODZF,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
2959{ "bngrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4073{"bdzfla+", BBO(16,BODZF,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
2960{ "bnelr", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4074{"bdzfla", BBO(16,BODZF,1,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2961{ "bnelr-", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4075
2962{ "bnelr-", XLOCB(19,BOFM4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4076{"bf-", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDM}},
2963{ "bnelr+", XLOCB(19,BOFP,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4077{"bf+", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDP}},
2964{ "bnelr+", XLOCB(19,BOFP4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4078{"bf", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BD}},
2965{ "bner", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 4079{"bbf", BBO(16,BOF,0,0), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BD}},
2966{ "bnelrl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4080{"bfl-", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDM}},
2967{ "bnelrl-", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4081{"bfl+", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDP}},
2968{ "bnelrl-", XLOCB(19,BOFM4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4082{"bfl", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BD}},
2969{ "bnelrl+", XLOCB(19,BOFP,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4083{"bbfl", BBO(16,BOF,0,1), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BD}},
2970{ "bnelrl+", XLOCB(19,BOFP4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4084{"bfa-", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDMA}},
2971{ "bnerl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4085{"bfa+", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDPA}},
2972{ "bnslr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4086{"bfa", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2973{ "bnslr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4087{"bbfa", BBO(16,BOF,1,0), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BDA}},
2974{ "bnslr-", XLOCB(19,BOFM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4088{"bfla-", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDMA}},
2975{ "bnslr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4089{"bfla+", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDPA}},
2976{ "bnslr+", XLOCB(19,BOFP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4090{"bfla", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2977{ "bnsr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, 4091{"bbfla", BBO(16,BOF,1,1), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BDA}},
2978{ "bnslrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4092
2979{ "bnslrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4093{"bdnzt-", BBO(16,BODNZT,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2980{ "bnslrl-", XLOCB(19,BOFM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4094{"bdnzt+", BBO(16,BODNZT,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2981{ "bnslrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4095{"bdnzt", BBO(16,BODNZT,0,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2982{ "bnslrl+", XLOCB(19,BOFP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4096{"bdnztl-", BBO(16,BODNZT,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2983{ "bnsrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, 4097{"bdnztl+", BBO(16,BODNZT,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2984{ "bnulr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4098{"bdnztl", BBO(16,BODNZT,0,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2985{ "bnulr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4099{"bdnzta-", BBO(16,BODNZT,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
2986{ "bnulr-", XLOCB(19,BOFM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4100{"bdnzta+", BBO(16,BODNZT,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
2987{ "bnulr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4101{"bdnzta", BBO(16,BODNZT,1,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2988{ "bnulr+", XLOCB(19,BOFP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, 4102{"bdnztla-", BBO(16,BODNZT,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
2989{ "bnulrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4103{"bdnztla+", BBO(16,BODNZT,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
2990{ "bnulrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4104{"bdnztla", BBO(16,BODNZT,1,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
2991{ "bnulrl-", XLOCB(19,BOFM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4105{"bdzt-", BBO(16,BODZT,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2992{ "bnulrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4106{"bdzt+", BBO(16,BODZT,0,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2993{ "bnulrl+", XLOCB(19,BOFP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, 4107{"bdzt", BBO(16,BODZT,0,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2994{ "btlr", XLO(19,BOT,16,0), XLBOBB_MASK, PPCCOM, { BI } }, 4108{"bdztl-", BBO(16,BODZT,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDM}},
2995{ "btlr-", XLO(19,BOT,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4109{"bdztl+", BBO(16,BODZT,0,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDP}},
2996{ "btlr-", XLO(19,BOTM4,16,0), XLBOBB_MASK, POWER4, { BI } }, 4110{"bdztl", BBO(16,BODZT,0,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BD}},
2997{ "btlr+", XLO(19,BOTP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4111{"bdzta-", BBO(16,BODZT,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
2998{ "btlr+", XLO(19,BOTP4,16,0), XLBOBB_MASK, POWER4, { BI } }, 4112{"bdzta+", BBO(16,BODZT,1,0), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
2999{ "bbtr", XLO(19,BOT,16,0), XLBOBB_MASK, PWRCOM, { BI } }, 4113{"bdzta", BBO(16,BODZT,1,0), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
3000{ "btlrl", XLO(19,BOT,16,1), XLBOBB_MASK, PPCCOM, { BI } }, 4114{"bdztla-", BBO(16,BODZT,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDMA}},
3001{ "btlrl-", XLO(19,BOT,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4115{"bdztla+", BBO(16,BODZT,1,1), BBOY_MASK, PPCCOM, ISA_V2|PPCVLE, {BI, BDPA}},
3002{ "btlrl-", XLO(19,BOTM4,16,1), XLBOBB_MASK, POWER4, { BI } }, 4116{"bdztla", BBO(16,BODZT,1,1), BBOY_MASK, PPCCOM, PPCVLE, {BI, BDA}},
3003{ "btlrl+", XLO(19,BOTP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4117
3004{ "btlrl+", XLO(19,BOTP4,16,1), XLBOBB_MASK, POWER4, { BI } }, 4118{"bt-", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDM}},
3005{ "bbtrl", XLO(19,BOT,16,1), XLBOBB_MASK, PWRCOM, { BI } }, 4119{"bt+", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDP}},
3006{ "bflr", XLO(19,BOF,16,0), XLBOBB_MASK, PPCCOM, { BI } }, 4120{"bt", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BD}},
3007{ "bflr-", XLO(19,BOF,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4121{"bbt", BBO(16,BOT,0,0), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BD}},
3008{ "bflr-", XLO(19,BOFM4,16,0), XLBOBB_MASK, POWER4, { BI } }, 4122{"btl-", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDM}},
3009{ "bflr+", XLO(19,BOFP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4123{"btl+", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDP}},
3010{ "bflr+", XLO(19,BOFP4,16,0), XLBOBB_MASK, POWER4, { BI } }, 4124{"btl", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BD}},
3011{ "bbfr", XLO(19,BOF,16,0), XLBOBB_MASK, PWRCOM, { BI } }, 4125{"bbtl", BBO(16,BOT,0,1), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BD}},
3012{ "bflrl", XLO(19,BOF,16,1), XLBOBB_MASK, PPCCOM, { BI } }, 4126{"bta-", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDMA}},
3013{ "bflrl-", XLO(19,BOF,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4127{"bta+", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDPA}},
3014{ "bflrl-", XLO(19,BOFM4,16,1), XLBOBB_MASK, POWER4, { BI } }, 4128{"bta", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDA}},
3015{ "bflrl+", XLO(19,BOFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4129{"bbta", BBO(16,BOT,1,0), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BDA}},
3016{ "bflrl+", XLO(19,BOFP4,16,1), XLBOBB_MASK, POWER4, { BI } }, 4130{"btla-", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDMA}},
3017{ "bbfrl", XLO(19,BOF,16,1), XLBOBB_MASK, PWRCOM, { BI } }, 4131{"btla+", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDPA}},
3018{ "bdnztlr", XLO(19,BODNZT,16,0), XLBOBB_MASK, PPCCOM, { BI } }, 4132{"btla", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, PPCVLE, {BI, BDA}},
3019{ "bdnztlr-",XLO(19,BODNZT,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4133{"bbtla", BBO(16,BOT,1,1), BBOAT_MASK, PWRCOM, PPCVLE, {BI, BDA}},
3020{ "bdnztlr+",XLO(19,BODNZTP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4134
3021{ "bdnztlrl",XLO(19,BODNZT,16,1), XLBOBB_MASK, PPCCOM, { BI } }, 4135{"bc-", B(16,0,0), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDM}},
3022{ "bdnztlrl-",XLO(19,BODNZT,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4136{"bc+", B(16,0,0), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDP}},
3023{ "bdnztlrl+",XLO(19,BODNZTP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4137{"bc", B(16,0,0), B_MASK, COM, PPCVLE, {BO, BI, BD}},
3024{ "bdnzflr", XLO(19,BODNZF,16,0), XLBOBB_MASK, PPCCOM, { BI } }, 4138{"bcl-", B(16,0,1), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDM}},
3025{ "bdnzflr-",XLO(19,BODNZF,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4139{"bcl+", B(16,0,1), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDP}},
3026{ "bdnzflr+",XLO(19,BODNZFP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4140{"bcl", B(16,0,1), B_MASK, COM, PPCVLE, {BO, BI, BD}},
3027{ "bdnzflrl",XLO(19,BODNZF,16,1), XLBOBB_MASK, PPCCOM, { BI } }, 4141{"bca-", B(16,1,0), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDMA}},
3028{ "bdnzflrl-",XLO(19,BODNZF,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4142{"bca+", B(16,1,0), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDPA}},
3029{ "bdnzflrl+",XLO(19,BODNZFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4143{"bca", B(16,1,0), B_MASK, COM, PPCVLE, {BO, BI, BDA}},
3030{ "bdztlr", XLO(19,BODZT,16,0), XLBOBB_MASK, PPCCOM, { BI } }, 4144{"bcla-", B(16,1,1), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDMA}},
3031{ "bdztlr-", XLO(19,BODZT,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4145{"bcla+", B(16,1,1), B_MASK, PPCCOM, PPCVLE, {BOE, BI, BDPA}},
3032{ "bdztlr+", XLO(19,BODZTP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4146{"bcla", B(16,1,1), B_MASK, COM, PPCVLE, {BO, BI, BDA}},
3033{ "bdztlrl", XLO(19,BODZT,16,1), XLBOBB_MASK, PPCCOM, { BI } }, 4147
3034{ "bdztlrl-",XLO(19,BODZT,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4148{"svc", SC(17,0,0), SC_MASK, POWER, PPCVLE, {SVC_LEV, FL1, FL2}},
3035{ "bdztlrl+",XLO(19,BODZTP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4149{"svcl", SC(17,0,1), SC_MASK, POWER, PPCVLE, {SVC_LEV, FL1, FL2}},
3036{ "bdzflr", XLO(19,BODZF,16,0), XLBOBB_MASK, PPCCOM, { BI } }, 4150{"sc", SC(17,1,0), SC_MASK, PPC, PPCVLE, {LEV}},
3037{ "bdzflr-", XLO(19,BODZF,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4151{"svca", SC(17,1,0), SC_MASK, PWRCOM, PPCVLE, {SV}},
3038{ "bdzflr+", XLO(19,BODZFP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4152{"svcla", SC(17,1,1), SC_MASK, POWER, PPCVLE, {SV}},
3039{ "bdzflrl", XLO(19,BODZF,16,1), XLBOBB_MASK, PPCCOM, { BI } }, 4153
3040{ "bdzflrl-",XLO(19,BODZF,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4154{"b", B(18,0,0), B_MASK, COM, PPCVLE, {LI}},
3041{ "bdzflrl+",XLO(19,BODZFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4155{"bl", B(18,0,1), B_MASK, COM, PPCVLE, {LI}},
3042{ "bclr+", XLYLK(19,16,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4156{"ba", B(18,1,0), B_MASK, COM, PPCVLE, {LIA}},
3043{ "bclrl+", XLYLK(19,16,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4157{"bla", B(18,1,1), B_MASK, COM, PPCVLE, {LIA}},
3044{ "bclr-", XLYLK(19,16,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4158
3045{ "bclrl-", XLYLK(19,16,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4159{"mcrf", XL(19,0), XLBB_MASK|(3<<21)|(3<<16), COM, PPCVLE, {BF, BFA}},
3046{ "bclr", XLLK(19,16,0), XLBH_MASK, PPCCOM, { BO, BI, BH } }, 4160
3047{ "bclrl", XLLK(19,16,1), XLBH_MASK, PPCCOM, { BO, BI, BH } }, 4161{"addpcis", DX(19,2), DX_MASK, POWER9, PPCVLE, {RT, DXD}},
3048{ "bcr", XLLK(19,16,0), XLBB_MASK, PWRCOM, { BO, BI } }, 4162{"subpcis", DX(19,2), DX_MASK, POWER9, PPCVLE, {RT, NDXD}},
3049{ "bcrl", XLLK(19,16,1), XLBB_MASK, PWRCOM, { BO, BI } }, 4163
3050{ "bclre", XLLK(19,17,0), XLBB_MASK, BOOKE64, { BO, BI } }, 4164{"bdnzlr", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, PPCCOM, PPCVLE, {0}},
3051{ "bclrel", XLLK(19,17,1), XLBB_MASK, BOOKE64, { BO, BI } }, 4165{"bdnzlr-", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3052 4166{"bdnzlrl", XLO(19,BODNZ,16,1), XLBOBIBB_MASK, PPCCOM, PPCVLE, {0}},
3053{ "rfid", XL(19,18), 0xffffffff, PPC64, { 0 } }, 4167{"bdnzlrl-", XLO(19,BODNZ,16,1), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3054 4168{"bdnzlr+", XLO(19,BODNZP,16,0), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3055{ "crnot", XL(19,33), XL_MASK, PPCCOM, { BT, BA, BBA } }, 4169{"bdnzlrl+", XLO(19,BODNZP,16,1), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3056{ "crnor", XL(19,33), XL_MASK, COM, { BT, BA, BB } }, 4170{"bdzlr", XLO(19,BODZ,16,0), XLBOBIBB_MASK, PPCCOM, PPCVLE, {0}},
3057{ "rfmci", X(19,38), 0xffffffff, PPCRFMCI, { 0 } }, 4171{"bdzlr-", XLO(19,BODZ,16,0), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3058 4172{"bdzlrl", XLO(19,BODZ,16,1), XLBOBIBB_MASK, PPCCOM, PPCVLE, {0}},
3059{ "rfi", XL(19,50), 0xffffffff, COM, { 0 } }, 4173{"bdzlrl-", XLO(19,BODZ,16,1), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3060{ "rfci", XL(19,51), 0xffffffff, PPC403 | BOOKE, { 0 } }, 4174{"bdzlr+", XLO(19,BODZP,16,0), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3061 4175{"bdzlrl+", XLO(19,BODZP,16,1), XLBOBIBB_MASK, PPCCOM, ISA_V2|PPCVLE, {0}},
3062{ "rfsvc", XL(19,82), 0xffffffff, POWER, { 0 } }, 4176{"blr", XLO(19,BOU,16,0), XLBOBIBB_MASK, PPCCOM, PPCVLE, {0}},
3063 4177{"br", XLO(19,BOU,16,0), XLBOBIBB_MASK, PWRCOM, PPCVLE, {0}},
3064{ "crandc", XL(19,129), XL_MASK, COM, { BT, BA, BB } }, 4178{"blrl", XLO(19,BOU,16,1), XLBOBIBB_MASK, PPCCOM, PPCVLE, {0}},
3065 4179{"brl", XLO(19,BOU,16,1), XLBOBIBB_MASK, PWRCOM, PPCVLE, {0}},
3066{ "isync", XL(19,150), 0xffffffff, PPCCOM, { 0 } }, 4180{"bdnzlr-", XLO(19,BODNZM4,16,0), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3067{ "ics", XL(19,150), 0xffffffff, PWRCOM, { 0 } }, 4181{"bdnzlrl-", XLO(19,BODNZM4,16,1), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3068 4182{"bdnzlr+", XLO(19,BODNZP4,16,0), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3069{ "crclr", XL(19,193), XL_MASK, PPCCOM, { BT, BAT, BBA } }, 4183{"bdnzlrl+", XLO(19,BODNZP4,16,1), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3070{ "crxor", XL(19,193), XL_MASK, COM, { BT, BA, BB } }, 4184{"bdzlr-", XLO(19,BODZM4,16,0), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3071 4185{"bdzlrl-", XLO(19,BODZM4,16,1), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3072{ "crnand", XL(19,225), XL_MASK, COM, { BT, BA, BB } }, 4186{"bdzlr+", XLO(19,BODZP4,16,0), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3073 4187{"bdzlrl+", XLO(19,BODZP4,16,1), XLBOBIBB_MASK, ISA_V2, PPCVLE, {0}},
3074{ "crand", XL(19,257), XL_MASK, COM, { BT, BA, BB } }, 4188
3075 4189{"bgelr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3076{ "hrfid", XL(19,274), 0xffffffff, POWER5 | CELL, { 0 } }, 4190{"bgelr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3077 4191{"bger", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3078{ "crset", XL(19,289), XL_MASK, PPCCOM, { BT, BAT, BBA } }, 4192{"bnllr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3079{ "creqv", XL(19,289), XL_MASK, COM, { BT, BA, BB } }, 4193{"bnllr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3080 4194{"bnlr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3081{ "doze", XL(19,402), 0xffffffff, POWER6, { 0 } }, 4195{"bgelrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3082 4196{"bgelrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3083{ "crorc", XL(19,417), XL_MASK, COM, { BT, BA, BB } }, 4197{"bgerl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3084 4198{"bnllrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3085{ "nap", XL(19,434), 0xffffffff, POWER6, { 0 } }, 4199{"bnllrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3086 4200{"bnlrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3087{ "crmove", XL(19,449), XL_MASK, PPCCOM, { BT, BA, BBA } }, 4201{"blelr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3088{ "cror", XL(19,449), XL_MASK, COM, { BT, BA, BB } }, 4202{"blelr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3089 4203{"bler", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3090{ "sleep", XL(19,466), 0xffffffff, POWER6, { 0 } }, 4204{"bnglr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3091{ "rvwinkle", XL(19,498), 0xffffffff, POWER6, { 0 } }, 4205{"bnglr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3092 4206{"bngr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3093{ "bctr", XLO(19,BOU,528,0), XLBOBIBB_MASK, COM, { 0 } }, 4207{"blelrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3094{ "bctrl", XLO(19,BOU,528,1), XLBOBIBB_MASK, COM, { 0 } }, 4208{"blelrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3095{ "bltctr", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4209{"blerl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3096{ "bltctr-", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4210{"bnglrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3097{ "bltctr-", XLOCB(19,BOTM4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4211{"bnglrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3098{ "bltctr+", XLOCB(19,BOTP,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4212{"bngrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3099{ "bltctr+", XLOCB(19,BOTP4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4213{"bnelr", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3100{ "bltctrl", XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4214{"bnelr-", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3101{ "bltctrl-",XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4215{"bner", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3102{ "bltctrl-",XLOCB(19,BOTM4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4216{"bnelrl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3103{ "bltctrl+",XLOCB(19,BOTP,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4217{"bnelrl-", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3104{ "bltctrl+",XLOCB(19,BOTP4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4218{"bnerl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3105{ "bgtctr", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4219{"bnslr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3106{ "bgtctr-", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4220{"bnslr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3107{ "bgtctr-", XLOCB(19,BOTM4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4221{"bnsr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3108{ "bgtctr+", XLOCB(19,BOTP,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4222{"bnulr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3109{ "bgtctr+", XLOCB(19,BOTP4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4223{"bnulr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3110{ "bgtctrl", XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4224{"bnslrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3111{ "bgtctrl-",XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4225{"bnslrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3112{ "bgtctrl-",XLOCB(19,BOTM4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4226{"bnsrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3113{ "bgtctrl+",XLOCB(19,BOTP,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4227{"bnulrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3114{ "bgtctrl+",XLOCB(19,BOTP4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4228{"bnulrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3115{ "beqctr", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4229{"bgelr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3116{ "beqctr-", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4230{"bnllr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3117{ "beqctr-", XLOCB(19,BOTM4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4231{"bgelrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3118{ "beqctr+", XLOCB(19,BOTP,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4232{"bnllrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3119{ "beqctr+", XLOCB(19,BOTP4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4233{"blelr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3120{ "beqctrl", XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4234{"bnglr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3121{ "beqctrl-",XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4235{"blelrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3122{ "beqctrl-",XLOCB(19,BOTM4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4236{"bnglrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3123{ "beqctrl+",XLOCB(19,BOTP,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4237{"bnelr+", XLOCB(19,BOFP,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3124{ "beqctrl+",XLOCB(19,BOTP4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4238{"bnelrl+", XLOCB(19,BOFP,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3125{ "bsoctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4239{"bnslr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3126{ "bsoctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4240{"bnulr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3127{ "bsoctr-", XLOCB(19,BOTM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4241{"bnslrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3128{ "bsoctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4242{"bnulrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3129{ "bsoctr+", XLOCB(19,BOTP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4243{"bgelr-", XLOCB(19,BOFM4,CBLT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3130{ "bsoctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4244{"bnllr-", XLOCB(19,BOFM4,CBLT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3131{ "bsoctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4245{"bgelrl-", XLOCB(19,BOFM4,CBLT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3132{ "bsoctrl-",XLOCB(19,BOTM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4246{"bnllrl-", XLOCB(19,BOFM4,CBLT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3133{ "bsoctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4247{"blelr-", XLOCB(19,BOFM4,CBGT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3134{ "bsoctrl+",XLOCB(19,BOTP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4248{"bnglr-", XLOCB(19,BOFM4,CBGT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3135{ "bunctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4249{"blelrl-", XLOCB(19,BOFM4,CBGT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3136{ "bunctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4250{"bnglrl-", XLOCB(19,BOFM4,CBGT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3137{ "bunctr-", XLOCB(19,BOTM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4251{"bnelr-", XLOCB(19,BOFM4,CBEQ,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3138{ "bunctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4252{"bnelrl-", XLOCB(19,BOFM4,CBEQ,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3139{ "bunctr+", XLOCB(19,BOTP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4253{"bnslr-", XLOCB(19,BOFM4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3140{ "bunctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4254{"bnulr-", XLOCB(19,BOFM4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3141{ "bunctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4255{"bnslrl-", XLOCB(19,BOFM4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3142{ "bunctrl-",XLOCB(19,BOTM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4256{"bnulrl-", XLOCB(19,BOFM4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3143{ "bunctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4257{"bgelr+", XLOCB(19,BOFP4,CBLT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3144{ "bunctrl+",XLOCB(19,BOTP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4258{"bnllr+", XLOCB(19,BOFP4,CBLT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3145{ "bgectr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4259{"bgelrl+", XLOCB(19,BOFP4,CBLT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3146{ "bgectr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4260{"bnllrl+", XLOCB(19,BOFP4,CBLT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3147{ "bgectr-", XLOCB(19,BOFM4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4261{"blelr+", XLOCB(19,BOFP4,CBGT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3148{ "bgectr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4262{"bnglr+", XLOCB(19,BOFP4,CBGT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3149{ "bgectr+", XLOCB(19,BOFP4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4263{"blelrl+", XLOCB(19,BOFP4,CBGT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3150{ "bgectrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4264{"bnglrl+", XLOCB(19,BOFP4,CBGT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3151{ "bgectrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4265{"bnelr+", XLOCB(19,BOFP4,CBEQ,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3152{ "bgectrl-",XLOCB(19,BOFM4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4266{"bnelrl+", XLOCB(19,BOFP4,CBEQ,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3153{ "bgectrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4267{"bnslr+", XLOCB(19,BOFP4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3154{ "bgectrl+",XLOCB(19,BOFP4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4268{"bnulr+", XLOCB(19,BOFP4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3155{ "bnlctr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4269{"bnslrl+", XLOCB(19,BOFP4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3156{ "bnlctr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4270{"bnulrl+", XLOCB(19,BOFP4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3157{ "bnlctr-", XLOCB(19,BOFM4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4271{"bltlr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3158{ "bnlctr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4272{"bltlr-", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3159{ "bnlctr+", XLOCB(19,BOFP4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4273{"bltr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3160{ "bnlctrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4274{"bltlrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3161{ "bnlctrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4275{"bltlrl-", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3162{ "bnlctrl-",XLOCB(19,BOFM4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4276{"bltrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3163{ "bnlctrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4277{"bgtlr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3164{ "bnlctrl+",XLOCB(19,BOFP4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4278{"bgtlr-", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3165{ "blectr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4279{"bgtr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3166{ "blectr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4280{"bgtlrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3167{ "blectr-", XLOCB(19,BOFM4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4281{"bgtlrl-", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3168{ "blectr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4282{"bgtrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3169{ "blectr+", XLOCB(19,BOFP4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4283{"beqlr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3170{ "blectrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4284{"beqlr-", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3171{ "blectrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4285{"beqr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3172{ "blectrl-",XLOCB(19,BOFM4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4286{"beqlrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3173{ "blectrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4287{"beqlrl-", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3174{ "blectrl+",XLOCB(19,BOFP4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4288{"beqrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3175{ "bngctr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4289{"bsolr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3176{ "bngctr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4290{"bsolr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3177{ "bngctr-", XLOCB(19,BOFM4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4291{"bsor", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3178{ "bngctr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4292{"bunlr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3179{ "bngctr+", XLOCB(19,BOFP4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4293{"bunlr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3180{ "bngctrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4294{"bsolrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3181{ "bngctrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4295{"bsolrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3182{ "bngctrl-",XLOCB(19,BOFM4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4296{"bsorl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, PPCVLE, {CR}},
3183{ "bngctrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4297{"bunlrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3184{ "bngctrl+",XLOCB(19,BOFP4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4298{"bunlrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3185{ "bnectr", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4299{"bltlr+", XLOCB(19,BOTP,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3186{ "bnectr-", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4300{"bltlrl+", XLOCB(19,BOTP,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3187{ "bnectr-", XLOCB(19,BOFM4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4301{"bgtlr+", XLOCB(19,BOTP,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3188{ "bnectr+", XLOCB(19,BOFP,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4302{"bgtlrl+", XLOCB(19,BOTP,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3189{ "bnectr+", XLOCB(19,BOFP4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4303{"beqlr+", XLOCB(19,BOTP,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3190{ "bnectrl", XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4304{"beqlrl+", XLOCB(19,BOTP,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3191{ "bnectrl-",XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4305{"bsolr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3192{ "bnectrl-",XLOCB(19,BOFM4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4306{"bunlr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3193{ "bnectrl+",XLOCB(19,BOFP,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4307{"bsolrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3194{ "bnectrl+",XLOCB(19,BOFP4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4308{"bunlrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3195{ "bnsctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4309{"bltlr-", XLOCB(19,BOTM4,CBLT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3196{ "bnsctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4310{"bltlrl-", XLOCB(19,BOTM4,CBLT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3197{ "bnsctr-", XLOCB(19,BOFM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4311{"bgtlr-", XLOCB(19,BOTM4,CBGT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3198{ "bnsctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4312{"bgtlrl-", XLOCB(19,BOTM4,CBGT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3199{ "bnsctr+", XLOCB(19,BOFP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4313{"beqlr-", XLOCB(19,BOTM4,CBEQ,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3200{ "bnsctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4314{"beqlrl-", XLOCB(19,BOTM4,CBEQ,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3201{ "bnsctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4315{"bsolr-", XLOCB(19,BOTM4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3202{ "bnsctrl-",XLOCB(19,BOFM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4316{"bunlr-", XLOCB(19,BOTM4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3203{ "bnsctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4317{"bsolrl-", XLOCB(19,BOTM4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3204{ "bnsctrl+",XLOCB(19,BOFP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4318{"bunlrl-", XLOCB(19,BOTM4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3205{ "bnuctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, 4319{"bltlr+", XLOCB(19,BOTP4,CBLT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3206{ "bnuctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4320{"bltlrl+", XLOCB(19,BOTP4,CBLT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3207{ "bnuctr-", XLOCB(19,BOFM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4321{"bgtlr+", XLOCB(19,BOTP4,CBGT,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3208{ "bnuctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4322{"bgtlrl+", XLOCB(19,BOTP4,CBGT,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3209{ "bnuctr+", XLOCB(19,BOFP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, 4323{"beqlr+", XLOCB(19,BOTP4,CBEQ,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3210{ "bnuctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, 4324{"beqlrl+", XLOCB(19,BOTP4,CBEQ,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3211{ "bnuctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4325{"bsolr+", XLOCB(19,BOTP4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3212{ "bnuctrl-",XLOCB(19,BOFM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4326{"bunlr+", XLOCB(19,BOTP4,CBSO,16,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3213{ "bnuctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, 4327{"bsolrl+", XLOCB(19,BOTP4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3214{ "bnuctrl+",XLOCB(19,BOFP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, 4328{"bunlrl+", XLOCB(19,BOTP4,CBSO,16,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3215{ "btctr", XLO(19,BOT,528,0), XLBOBB_MASK, PPCCOM, { BI } }, 4329
3216{ "btctr-", XLO(19,BOT,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4330{"bdnzflr", XLO(19,BODNZF,16,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3217{ "btctr-", XLO(19,BOTM4,528,0), XLBOBB_MASK, POWER4, { BI } }, 4331{"bdnzflr-", XLO(19,BODNZF,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3218{ "btctr+", XLO(19,BOTP,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4332{"bdnzflrl", XLO(19,BODNZF,16,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3219{ "btctr+", XLO(19,BOTP4,528,0), XLBOBB_MASK, POWER4, { BI } }, 4333{"bdnzflrl-",XLO(19,BODNZF,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3220{ "btctrl", XLO(19,BOT,528,1), XLBOBB_MASK, PPCCOM, { BI } }, 4334{"bdnzflr+", XLO(19,BODNZFP,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3221{ "btctrl-", XLO(19,BOT,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4335{"bdnzflrl+",XLO(19,BODNZFP,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3222{ "btctrl-", XLO(19,BOTM4,528,1), XLBOBB_MASK, POWER4, { BI } }, 4336{"bdzflr", XLO(19,BODZF,16,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3223{ "btctrl+", XLO(19,BOTP,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4337{"bdzflr-", XLO(19,BODZF,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3224{ "btctrl+", XLO(19,BOTP4,528,1), XLBOBB_MASK, POWER4, { BI } }, 4338{"bdzflrl", XLO(19,BODZF,16,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3225{ "bfctr", XLO(19,BOF,528,0), XLBOBB_MASK, PPCCOM, { BI } }, 4339{"bdzflrl-", XLO(19,BODZF,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3226{ "bfctr-", XLO(19,BOF,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4340{"bdzflr+", XLO(19,BODZFP,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3227{ "bfctr-", XLO(19,BOFM4,528,0), XLBOBB_MASK, POWER4, { BI } }, 4341{"bdzflrl+", XLO(19,BODZFP,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3228{ "bfctr+", XLO(19,BOFP,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, 4342{"bflr", XLO(19,BOF,16,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3229{ "bfctr+", XLO(19,BOFP4,528,0), XLBOBB_MASK, POWER4, { BI } }, 4343{"bflr-", XLO(19,BOF,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3230{ "bfctrl", XLO(19,BOF,528,1), XLBOBB_MASK, PPCCOM, { BI } }, 4344{"bbfr", XLO(19,BOF,16,0), XLBOBB_MASK, PWRCOM, PPCVLE, {BI}},
3231{ "bfctrl-", XLO(19,BOF,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4345{"bflrl", XLO(19,BOF,16,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3232{ "bfctrl-", XLO(19,BOFM4,528,1), XLBOBB_MASK, POWER4, { BI } }, 4346{"bflrl-", XLO(19,BOF,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3233{ "bfctrl+", XLO(19,BOFP,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, 4347{"bbfrl", XLO(19,BOF,16,1), XLBOBB_MASK, PWRCOM, PPCVLE, {BI}},
3234{ "bfctrl+", XLO(19,BOFP4,528,1), XLBOBB_MASK, POWER4, { BI } }, 4348{"bflr+", XLO(19,BOFP,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3235{ "bcctr-", XLYLK(19,528,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4349{"bflrl+", XLO(19,BOFP,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3236{ "bcctr+", XLYLK(19,528,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4350{"bflr-", XLO(19,BOFM4,16,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3237{ "bcctrl-", XLYLK(19,528,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4351{"bflrl-", XLO(19,BOFM4,16,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3238{ "bcctrl+", XLYLK(19,528,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, 4352{"bflr+", XLO(19,BOFP4,16,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3239{ "bcctr", XLLK(19,528,0), XLBH_MASK, PPCCOM, { BO, BI, BH } }, 4353{"bflrl+", XLO(19,BOFP4,16,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3240{ "bcctrl", XLLK(19,528,1), XLBH_MASK, PPCCOM, { BO, BI, BH } }, 4354{"bdnztlr", XLO(19,BODNZT,16,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3241{ "bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, { BO, BI } }, 4355{"bdnztlr-", XLO(19,BODNZT,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3242{ "bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, { BO, BI } }, 4356{"bdnztlrl", XLO(19,BODNZT,16,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3243{ "bcctre", XLLK(19,529,0), XLYBB_MASK, BOOKE64, { BO, BI } }, 4357{"bdnztlrl-", XLO(19,BODNZT,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3244{ "bcctrel", XLLK(19,529,1), XLYBB_MASK, BOOKE64, { BO, BI } }, 4358{"bdnztlr+", XLO(19,BODNZTP,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3245 4359{"bdnztlrl+", XLO(19,BODNZTP,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3246{ "rlwimi", M(20,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, 4360{"bdztlr", XLO(19,BODZT,16,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3247{ "rlimi", M(20,0), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } }, 4361{"bdztlr-", XLO(19,BODZT,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3248 4362{"bdztlrl", XLO(19,BODZT,16,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3249{ "rlwimi.", M(20,1), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, 4363{"bdztlrl-", XLO(19,BODZT,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3250{ "rlimi.", M(20,1), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } }, 4364{"bdztlr+", XLO(19,BODZTP,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3251 4365{"bdztlrl+", XLO(19,BODZTP,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3252{ "rotlwi", MME(21,31,0), MMBME_MASK, PPCCOM, { RA, RS, SH } }, 4366{"btlr", XLO(19,BOT,16,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3253{ "clrlwi", MME(21,31,0), MSHME_MASK, PPCCOM, { RA, RS, MB } }, 4367{"btlr-", XLO(19,BOT,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3254{ "rlwinm", M(21,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, 4368{"bbtr", XLO(19,BOT,16,0), XLBOBB_MASK, PWRCOM, PPCVLE, {BI}},
3255{ "rlinm", M(21,0), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } }, 4369{"btlrl", XLO(19,BOT,16,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
3256{ "rotlwi.", MME(21,31,1), MMBME_MASK, PPCCOM, { RA,RS,SH } }, 4370{"btlrl-", XLO(19,BOT,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3257{ "clrlwi.", MME(21,31,1), MSHME_MASK, PPCCOM, { RA, RS, MB } }, 4371{"bbtrl", XLO(19,BOT,16,1), XLBOBB_MASK, PWRCOM, PPCVLE, {BI}},
3258{ "rlwinm.", M(21,1), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, 4372{"btlr+", XLO(19,BOTP,16,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3259{ "rlinm.", M(21,1), M_MASK, PWRCOM, { RA,RS,SH,MBE,ME } }, 4373{"btlrl+", XLO(19,BOTP,16,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
3260 4374{"btlr-", XLO(19,BOTM4,16,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3261{ "rlmi", M(22,0), M_MASK, M601, { RA,RS,RB,MBE,ME } }, 4375{"btlrl-", XLO(19,BOTM4,16,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3262{ "rlmi.", M(22,1), M_MASK, M601, { RA,RS,RB,MBE,ME } }, 4376{"btlr+", XLO(19,BOTP4,16,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3263 4377{"btlrl+", XLO(19,BOTP4,16,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
3264{ "be", B(22,0,0), B_MASK, BOOKE64, { LI } }, 4378
3265{ "bel", B(22,0,1), B_MASK, BOOKE64, { LI } }, 4379{"bclr-", XLYLK(19,16,0,0), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
3266{ "bea", B(22,1,0), B_MASK, BOOKE64, { LIA } }, 4380{"bclrl-", XLYLK(19,16,0,1), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
3267{ "bela", B(22,1,1), B_MASK, BOOKE64, { LIA } }, 4381{"bclr+", XLYLK(19,16,1,0), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
3268 4382{"bclrl+", XLYLK(19,16,1,1), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
3269{ "rotlw", MME(23,31,0), MMBME_MASK, PPCCOM, { RA, RS, RB } }, 4383{"bclr", XLLK(19,16,0), XLBH_MASK, PPCCOM, PPCVLE, {BO, BI, BH}},
3270{ "rlwnm", M(23,0), M_MASK, PPCCOM, { RA,RS,RB,MBE,ME } }, 4384{"bcr", XLLK(19,16,0), XLBB_MASK, PWRCOM, PPCVLE, {BO, BI}},
3271{ "rlnm", M(23,0), M_MASK, PWRCOM, { RA,RS,RB,MBE,ME } }, 4385{"bclrl", XLLK(19,16,1), XLBH_MASK, PPCCOM, PPCVLE, {BO, BI, BH}},
3272{ "rotlw.", MME(23,31,1), MMBME_MASK, PPCCOM, { RA, RS, RB } }, 4386{"bcrl", XLLK(19,16,1), XLBB_MASK, PWRCOM, PPCVLE, {BO, BI}},
3273{ "rlwnm.", M(23,1), M_MASK, PPCCOM, { RA,RS,RB,MBE,ME } }, 4387
3274{ "rlnm.", M(23,1), M_MASK, PWRCOM, { RA,RS,RB,MBE,ME } }, 4388{"rfid", XL(19,18), 0xffffffff, PPC64, PPCVLE, {0}},
3275 4389
3276{ "nop", OP(24), 0xffffffff, PPCCOM, { 0 } }, 4390{"crnot", XL(19,33), XL_MASK, PPCCOM, PPCVLE, {BT, BA, BBA}},
3277{ "ori", OP(24), OP_MASK, PPCCOM, { RA, RS, UI } }, 4391{"crnor", XL(19,33), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3278{ "oril", OP(24), OP_MASK, PWRCOM, { RA, RS, UI } }, 4392{"rfmci", X(19,38), 0xffffffff, PPCRFMCI|PPCA2|PPC476, PPCVLE, {0}},
3279 4393
3280{ "oris", OP(25), OP_MASK, PPCCOM, { RA, RS, UI } }, 4394{"rfdi", XL(19,39), 0xffffffff, E500MC, PPCVLE, {0}},
3281{ "oriu", OP(25), OP_MASK, PWRCOM, { RA, RS, UI } }, 4395{"rfi", XL(19,50), 0xffffffff, COM, PPCVLE, {0}},
3282 4396{"rfci", XL(19,51), 0xffffffff, PPC403|BOOKE|PPCE300|PPCA2|PPC476, PPCVLE, {0}},
3283{ "xori", OP(26), OP_MASK, PPCCOM, { RA, RS, UI } }, 4397
3284{ "xoril", OP(26), OP_MASK, PWRCOM, { RA, RS, UI } }, 4398{"rfsvc", XL(19,82), 0xffffffff, POWER, PPCVLE, {0}},
3285 4399
3286{ "xoris", OP(27), OP_MASK, PPCCOM, { RA, RS, UI } }, 4400{"rfgi", XL(19,102), 0xffffffff, E500MC|PPCA2, PPCVLE, {0}},
3287{ "xoriu", OP(27), OP_MASK, PWRCOM, { RA, RS, UI } }, 4401
3288 4402{"crandc", XL(19,129), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3289{ "andi.", OP(28), OP_MASK, PPCCOM, { RA, RS, UI } }, 4403
3290{ "andil.", OP(28), OP_MASK, PWRCOM, { RA, RS, UI } }, 4404{"rfebb", XL(19,146), XLS_MASK, POWER8, PPCVLE, {SXL}},
3291 4405
3292{ "andis.", OP(29), OP_MASK, PPCCOM, { RA, RS, UI } }, 4406{"isync", XL(19,150), 0xffffffff, PPCCOM, PPCVLE, {0}},
3293{ "andiu.", OP(29), OP_MASK, PWRCOM, { RA, RS, UI } }, 4407{"ics", XL(19,150), 0xffffffff, PWRCOM, PPCVLE, {0}},
3294 4408
3295{ "rotldi", MD(30,0,0), MDMB_MASK, PPC64, { RA, RS, SH6 } }, 4409{"crclr", XL(19,193), XL_MASK, PPCCOM, PPCVLE, {BT, BAT, BBA}},
3296{ "clrldi", MD(30,0,0), MDSH_MASK, PPC64, { RA, RS, MB6 } }, 4410{"crxor", XL(19,193), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3297{ "rldicl", MD(30,0,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, 4411
3298{ "rotldi.", MD(30,0,1), MDMB_MASK, PPC64, { RA, RS, SH6 } }, 4412{"dnh", X(19,198), X_MASK, E500MC, PPCVLE, {DUI, DUIS}},
3299{ "clrldi.", MD(30,0,1), MDSH_MASK, PPC64, { RA, RS, MB6 } }, 4413
3300{ "rldicl.", MD(30,0,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, 4414{"crnand", XL(19,225), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3301 4415
3302{ "rldicr", MD(30,1,0), MD_MASK, PPC64, { RA, RS, SH6, ME6 } }, 4416{"crand", XL(19,257), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3303{ "rldicr.", MD(30,1,1), MD_MASK, PPC64, { RA, RS, SH6, ME6 } }, 4417
3304 4418{"hrfid", XL(19,274), 0xffffffff, POWER5|CELL, PPC476|PPCVLE, {0}},
3305{ "rldic", MD(30,2,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, 4419
3306{ "rldic.", MD(30,2,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, 4420{"crset", XL(19,289), XL_MASK, PPCCOM, PPCVLE, {BT, BAT, BBA}},
3307 4421{"creqv", XL(19,289), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3308{ "rldimi", MD(30,3,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, 4422
3309{ "rldimi.", MD(30,3,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, 4423{"urfid", XL(19,306), 0xffffffff, POWER9, PPCVLE, {0}},
3310 4424{"stop", XL(19,370), 0xffffffff, POWER9, PPCVLE, {0}},
3311{ "rotld", MDS(30,8,0), MDSMB_MASK, PPC64, { RA, RS, RB } }, 4425
3312{ "rldcl", MDS(30,8,0), MDS_MASK, PPC64, { RA, RS, RB, MB6 } }, 4426{"doze", XL(19,402), 0xffffffff, POWER6, POWER9|PPCVLE, {0}},
3313{ "rotld.", MDS(30,8,1), MDSMB_MASK, PPC64, { RA, RS, RB } }, 4427
3314{ "rldcl.", MDS(30,8,1), MDS_MASK, PPC64, { RA, RS, RB, MB6 } }, 4428{"crorc", XL(19,417), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3315 4429
3316{ "rldcr", MDS(30,9,0), MDS_MASK, PPC64, { RA, RS, RB, ME6 } }, 4430{"nap", XL(19,434), 0xffffffff, POWER6, POWER9|PPCVLE, {0}},
3317{ "rldcr.", MDS(30,9,1), MDS_MASK, PPC64, { RA, RS, RB, ME6 } }, 4431
3318 4432{"crmove", XL(19,449), XL_MASK, PPCCOM, PPCVLE, {BT, BA, BBA}},
3319{ "cmpw", XOPL(31,0,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } }, 4433{"cror", XL(19,449), XL_MASK, COM, PPCVLE, {BT, BA, BB}},
3320{ "cmpd", XOPL(31,0,1), XCMPL_MASK, PPC64, { OBF, RA, RB } }, 4434
3321{ "cmp", X(31,0), XCMP_MASK, PPC, { BF, L, RA, RB } }, 4435{"sleep", XL(19,466), 0xffffffff, POWER6, POWER9|PPCVLE, {0}},
3322{ "cmp", X(31,0), XCMPL_MASK, PWRCOM, { BF, RA, RB } }, 4436{"rvwinkle", XL(19,498), 0xffffffff, POWER6, POWER9|PPCVLE, {0}},
3323 4437
3324{ "twlgt", XTO(31,4,TOLGT), XTO_MASK, PPCCOM, { RA, RB } }, 4438{"bctr", XLO(19,BOU,528,0), XLBOBIBB_MASK, COM, PPCVLE, {0}},
3325{ "tlgt", XTO(31,4,TOLGT), XTO_MASK, PWRCOM, { RA, RB } }, 4439{"bctrl", XLO(19,BOU,528,1), XLBOBIBB_MASK, COM, PPCVLE, {0}},
3326{ "twllt", XTO(31,4,TOLLT), XTO_MASK, PPCCOM, { RA, RB } }, 4440
3327{ "tllt", XTO(31,4,TOLLT), XTO_MASK, PWRCOM, { RA, RB } }, 4441{"bgectr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3328{ "tweq", XTO(31,4,TOEQ), XTO_MASK, PPCCOM, { RA, RB } }, 4442{"bgectr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3329{ "teq", XTO(31,4,TOEQ), XTO_MASK, PWRCOM, { RA, RB } }, 4443{"bnlctr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3330{ "twlge", XTO(31,4,TOLGE), XTO_MASK, PPCCOM, { RA, RB } }, 4444{"bnlctr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3331{ "tlge", XTO(31,4,TOLGE), XTO_MASK, PWRCOM, { RA, RB } }, 4445{"bgectrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3332{ "twlnl", XTO(31,4,TOLNL), XTO_MASK, PPCCOM, { RA, RB } }, 4446{"bgectrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3333{ "tlnl", XTO(31,4,TOLNL), XTO_MASK, PWRCOM, { RA, RB } }, 4447{"bnlctrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3334{ "twlle", XTO(31,4,TOLLE), XTO_MASK, PPCCOM, { RA, RB } }, 4448{"bnlctrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3335{ "tlle", XTO(31,4,TOLLE), XTO_MASK, PWRCOM, { RA, RB } }, 4449{"blectr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3336{ "twlng", XTO(31,4,TOLNG), XTO_MASK, PPCCOM, { RA, RB } }, 4450{"blectr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3337{ "tlng", XTO(31,4,TOLNG), XTO_MASK, PWRCOM, { RA, RB } }, 4451{"bngctr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3338{ "twgt", XTO(31,4,TOGT), XTO_MASK, PPCCOM, { RA, RB } }, 4452{"bngctr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3339{ "tgt", XTO(31,4,TOGT), XTO_MASK, PWRCOM, { RA, RB } }, 4453{"blectrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3340{ "twge", XTO(31,4,TOGE), XTO_MASK, PPCCOM, { RA, RB } }, 4454{"blectrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3341{ "tge", XTO(31,4,TOGE), XTO_MASK, PWRCOM, { RA, RB } }, 4455{"bngctrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3342{ "twnl", XTO(31,4,TONL), XTO_MASK, PPCCOM, { RA, RB } }, 4456{"bngctrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3343{ "tnl", XTO(31,4,TONL), XTO_MASK, PWRCOM, { RA, RB } }, 4457{"bnectr", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3344{ "twlt", XTO(31,4,TOLT), XTO_MASK, PPCCOM, { RA, RB } }, 4458{"bnectr-", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3345{ "tlt", XTO(31,4,TOLT), XTO_MASK, PWRCOM, { RA, RB } }, 4459{"bnectrl", XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3346{ "twle", XTO(31,4,TOLE), XTO_MASK, PPCCOM, { RA, RB } }, 4460{"bnectrl-",XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3347{ "tle", XTO(31,4,TOLE), XTO_MASK, PWRCOM, { RA, RB } }, 4461{"bnsctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3348{ "twng", XTO(31,4,TONG), XTO_MASK, PPCCOM, { RA, RB } }, 4462{"bnsctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3349{ "tng", XTO(31,4,TONG), XTO_MASK, PWRCOM, { RA, RB } }, 4463{"bnuctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3350{ "twne", XTO(31,4,TONE), XTO_MASK, PPCCOM, { RA, RB } }, 4464{"bnuctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3351{ "tne", XTO(31,4,TONE), XTO_MASK, PWRCOM, { RA, RB } }, 4465{"bnsctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3352{ "trap", XTO(31,4,TOU), 0xffffffff, PPCCOM, { 0 } }, 4466{"bnsctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3353{ "tw", X(31,4), X_MASK, PPCCOM, { TO, RA, RB } }, 4467{"bnuctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3354{ "t", X(31,4), X_MASK, PWRCOM, { TO, RA, RB } }, 4468{"bnuctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3355 4469{"bgectr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3356{ "subfc", XO(31,8,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, 4470{"bnlctr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3357{ "sf", XO(31,8,0,0), XO_MASK, PWRCOM, { RT, RA, RB } }, 4471{"bgectrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3358{ "subc", XO(31,8,0,0), XO_MASK, PPC, { RT, RB, RA } }, 4472{"bnlctrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3359{ "subfc.", XO(31,8,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, 4473{"blectr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3360{ "sf.", XO(31,8,0,1), XO_MASK, PWRCOM, { RT, RA, RB } }, 4474{"bngctr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3361{ "subc.", XO(31,8,0,1), XO_MASK, PPCCOM, { RT, RB, RA } }, 4475{"blectrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3362{ "subfco", XO(31,8,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, 4476{"bngctrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3363{ "sfo", XO(31,8,1,0), XO_MASK, PWRCOM, { RT, RA, RB } }, 4477{"bnectr+", XLOCB(19,BOFP,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3364{ "subco", XO(31,8,1,0), XO_MASK, PPC, { RT, RB, RA } }, 4478{"bnectrl+",XLOCB(19,BOFP,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3365{ "subfco.", XO(31,8,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, 4479{"bnsctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3366{ "sfo.", XO(31,8,1,1), XO_MASK, PWRCOM, { RT, RA, RB } }, 4480{"bnuctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3367{ "subco.", XO(31,8,1,1), XO_MASK, PPC, { RT, RB, RA } }, 4481{"bnsctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3368 4482{"bnuctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3369{ "mulhdu", XO(31,9,0,0), XO_MASK, PPC64, { RT, RA, RB } }, 4483{"bgectr-", XLOCB(19,BOFM4,CBLT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3370{ "mulhdu.", XO(31,9,0,1), XO_MASK, PPC64, { RT, RA, RB } }, 4484{"bnlctr-", XLOCB(19,BOFM4,CBLT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3371 4485{"bgectrl-",XLOCB(19,BOFM4,CBLT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3372{ "addc", XO(31,10,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, 4486{"bnlctrl-",XLOCB(19,BOFM4,CBLT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3373{ "a", XO(31,10,0,0), XO_MASK, PWRCOM, { RT, RA, RB } }, 4487{"blectr-", XLOCB(19,BOFM4,CBGT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3374{ "addc.", XO(31,10,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, 4488{"bngctr-", XLOCB(19,BOFM4,CBGT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3375{ "a.", XO(31,10,0,1), XO_MASK, PWRCOM, { RT, RA, RB } }, 4489{"blectrl-",XLOCB(19,BOFM4,CBGT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3376{ "addco", XO(31,10,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, 4490{"bngctrl-",XLOCB(19,BOFM4,CBGT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3377{ "ao", XO(31,10,1,0), XO_MASK, PWRCOM, { RT, RA, RB } }, 4491{"bnectr-", XLOCB(19,BOFM4,CBEQ,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3378{ "addco.", XO(31,10,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, 4492{"bnectrl-",XLOCB(19,BOFM4,CBEQ,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3379{ "ao.", XO(31,10,1,1), XO_MASK, PWRCOM, { RT, RA, RB } }, 4493{"bnsctr-", XLOCB(19,BOFM4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3380 4494{"bnuctr-", XLOCB(19,BOFM4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3381{ "mulhwu", XO(31,11,0,0), XO_MASK, PPC, { RT, RA, RB } }, 4495{"bnsctrl-",XLOCB(19,BOFM4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3382{ "mulhwu.", XO(31,11,0,1), XO_MASK, PPC, { RT, RA, RB } }, 4496{"bnuctrl-",XLOCB(19,BOFM4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3383 4497{"bgectr+", XLOCB(19,BOFP4,CBLT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3384{ "isellt", X(31,15), X_MASK, PPCISEL, { RT, RA, RB } }, 4498{"bnlctr+", XLOCB(19,BOFP4,CBLT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3385{ "iselgt", X(31,47), X_MASK, PPCISEL, { RT, RA, RB } }, 4499{"bgectrl+",XLOCB(19,BOFP4,CBLT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3386{ "iseleq", X(31,79), X_MASK, PPCISEL, { RT, RA, RB } }, 4500{"bnlctrl+",XLOCB(19,BOFP4,CBLT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3387{ "isel", XISEL(31,15), XISEL_MASK, PPCISEL, { RT, RA, RB, CRB } }, 4501{"blectr+", XLOCB(19,BOFP4,CBGT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3388 4502{"bngctr+", XLOCB(19,BOFP4,CBGT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3389{ "mfocrf", XFXM(31,19,0,1), XFXFXM_MASK, COM, { RT, FXM } }, 4503{"blectrl+",XLOCB(19,BOFP4,CBGT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3390{ "mfcr", X(31,19), XRARB_MASK, NOPOWER4 | COM, { RT } }, 4504{"bngctrl+",XLOCB(19,BOFP4,CBGT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3391{ "mfcr", X(31,19), XFXFXM_MASK, POWER4, { RT, FXM4 } }, 4505{"bnectr+", XLOCB(19,BOFP4,CBEQ,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3392 4506{"bnectrl+",XLOCB(19,BOFP4,CBEQ,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3393{ "lwarx", X(31,20), XEH_MASK, PPC, { RT, RA0, RB, EH } }, 4507{"bnsctr+", XLOCB(19,BOFP4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3394 4508{"bnuctr+", XLOCB(19,BOFP4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3395{ "ldx", X(31,21), X_MASK, PPC64, { RT, RA0, RB } }, 4509{"bnsctrl+",XLOCB(19,BOFP4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3396 4510{"bnuctrl+",XLOCB(19,BOFP4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3397{ "icbt", X(31,22), X_MASK, BOOKE|PPCE300, { CT, RA, RB } }, 4511{"bltctr", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3398{ "icbt", X(31,262), XRT_MASK, PPC403, { RA, RB } }, 4512{"bltctr-", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3399 4513{"bltctrl", XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3400{ "lwzx", X(31,23), X_MASK, PPCCOM, { RT, RA0, RB } }, 4514{"bltctrl-",XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3401{ "lx", X(31,23), X_MASK, PWRCOM, { RT, RA, RB } }, 4515{"bgtctr", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3402 4516{"bgtctr-", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3403{ "slw", XRC(31,24,0), X_MASK, PPCCOM, { RA, RS, RB } }, 4517{"bgtctrl", XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3404{ "sl", XRC(31,24,0), X_MASK, PWRCOM, { RA, RS, RB } }, 4518{"bgtctrl-",XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3405{ "slw.", XRC(31,24,1), X_MASK, PPCCOM, { RA, RS, RB } }, 4519{"beqctr", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3406{ "sl.", XRC(31,24,1), X_MASK, PWRCOM, { RA, RS, RB } }, 4520{"beqctr-", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3407 4521{"beqctrl", XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3408{ "cntlzw", XRC(31,26,0), XRB_MASK, PPCCOM, { RA, RS } }, 4522{"beqctrl-",XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3409{ "cntlz", XRC(31,26,0), XRB_MASK, PWRCOM, { RA, RS } }, 4523{"bsoctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3410{ "cntlzw.", XRC(31,26,1), XRB_MASK, PPCCOM, { RA, RS } }, 4524{"bsoctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3411{ "cntlz.", XRC(31,26,1), XRB_MASK, PWRCOM, { RA, RS } }, 4525{"bunctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3412 4526{"bunctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3413{ "sld", XRC(31,27,0), X_MASK, PPC64, { RA, RS, RB } }, 4527{"bsoctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3414{ "sld.", XRC(31,27,1), X_MASK, PPC64, { RA, RS, RB } }, 4528{"bsoctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3415 4529{"bunctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, PPCVLE, {CR}},
3416{ "and", XRC(31,28,0), X_MASK, COM, { RA, RS, RB } }, 4530{"bunctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3417{ "and.", XRC(31,28,1), X_MASK, COM, { RA, RS, RB } }, 4531{"bltctr+", XLOCB(19,BOTP,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3418 4532{"bltctrl+",XLOCB(19,BOTP,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3419{ "maskg", XRC(31,29,0), X_MASK, M601, { RA, RS, RB } }, 4533{"bgtctr+", XLOCB(19,BOTP,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3420{ "maskg.", XRC(31,29,1), X_MASK, M601, { RA, RS, RB } }, 4534{"bgtctrl+",XLOCB(19,BOTP,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3421 4535{"beqctr+", XLOCB(19,BOTP,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3422{ "icbte", X(31,30), X_MASK, BOOKE64, { CT, RA, RB } }, 4536{"beqctrl+",XLOCB(19,BOTP,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3423 4537{"bsoctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3424{ "lwzxe", X(31,31), X_MASK, BOOKE64, { RT, RA0, RB } }, 4538{"bunctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3425 4539{"bsoctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3426{ "cmplw", XOPL(31,32,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } }, 4540{"bunctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, ISA_V2|PPCVLE, {CR}},
3427{ "cmpld", XOPL(31,32,1), XCMPL_MASK, PPC64, { OBF, RA, RB } }, 4541{"bltctr-", XLOCB(19,BOTM4,CBLT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3428{ "cmpl", X(31,32), XCMP_MASK, PPC, { BF, L, RA, RB } }, 4542{"bltctrl-",XLOCB(19,BOTM4,CBLT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3429{ "cmpl", X(31,32), XCMPL_MASK, PWRCOM, { BF, RA, RB } }, 4543{"bgtctr-", XLOCB(19,BOTM4,CBGT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3430 4544{"bgtctrl-",XLOCB(19,BOTM4,CBGT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3431{ "subf", XO(31,40,0,0), XO_MASK, PPC, { RT, RA, RB } }, 4545{"beqctr-", XLOCB(19,BOTM4,CBEQ,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3432{ "sub", XO(31,40,0,0), XO_MASK, PPC, { RT, RB, RA } }, 4546{"beqctrl-",XLOCB(19,BOTM4,CBEQ,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3433{ "subf.", XO(31,40,0,1), XO_MASK, PPC, { RT, RA, RB } }, 4547{"bsoctr-", XLOCB(19,BOTM4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3434{ "sub.", XO(31,40,0,1), XO_MASK, PPC, { RT, RB, RA } }, 4548{"bunctr-", XLOCB(19,BOTM4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3435{ "subfo", XO(31,40,1,0), XO_MASK, PPC, { RT, RA, RB } }, 4549{"bsoctrl-",XLOCB(19,BOTM4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3436{ "subo", XO(31,40,1,0), XO_MASK, PPC, { RT, RB, RA } }, 4550{"bunctrl-",XLOCB(19,BOTM4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3437{ "subfo.", XO(31,40,1,1), XO_MASK, PPC, { RT, RA, RB } }, 4551{"bltctr+", XLOCB(19,BOTP4,CBLT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
3438{ "subo.", XO(31,40,1,1), XO_MASK, PPC, { RT, RB, RA } }, 4552{"bltctrl+",XLOCB(19,BOTP4,CBLT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4553{"bgtctr+", XLOCB(19,BOTP4,CBGT,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4554{"bgtctrl+",XLOCB(19,BOTP4,CBGT,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4555{"beqctr+", XLOCB(19,BOTP4,CBEQ,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4556{"beqctrl+",XLOCB(19,BOTP4,CBEQ,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4557{"bsoctr+", XLOCB(19,BOTP4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4558{"bunctr+", XLOCB(19,BOTP4,CBSO,528,0), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4559{"bsoctrl+",XLOCB(19,BOTP4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4560{"bunctrl+",XLOCB(19,BOTP4,CBSO,528,1), XLBOCBBB_MASK, ISA_V2, PPCVLE, {CR}},
4561
4562{"bfctr", XLO(19,BOF,528,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
4563{"bfctr-", XLO(19,BOF,528,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4564{"bfctrl", XLO(19,BOF,528,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
4565{"bfctrl-", XLO(19,BOF,528,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4566{"bfctr+", XLO(19,BOFP,528,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4567{"bfctrl+", XLO(19,BOFP,528,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4568{"bfctr-", XLO(19,BOFM4,528,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4569{"bfctrl-", XLO(19,BOFM4,528,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4570{"bfctr+", XLO(19,BOFP4,528,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4571{"bfctrl+", XLO(19,BOFP4,528,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4572{"btctr", XLO(19,BOT,528,0), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
4573{"btctr-", XLO(19,BOT,528,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4574{"btctrl", XLO(19,BOT,528,1), XLBOBB_MASK, PPCCOM, PPCVLE, {BI}},
4575{"btctrl-", XLO(19,BOT,528,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4576{"btctr+", XLO(19,BOTP,528,0), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4577{"btctrl+", XLO(19,BOTP,528,1), XLBOBB_MASK, PPCCOM, ISA_V2|PPCVLE, {BI}},
4578{"btctr-", XLO(19,BOTM4,528,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4579{"btctrl-", XLO(19,BOTM4,528,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4580{"btctr+", XLO(19,BOTP4,528,0), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4581{"btctrl+", XLO(19,BOTP4,528,1), XLBOBB_MASK, ISA_V2, PPCVLE, {BI}},
4582
4583{"bcctr-", XLYLK(19,528,0,0), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
4584{"bcctrl-", XLYLK(19,528,0,1), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
4585{"bcctr+", XLYLK(19,528,1,0), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
4586{"bcctrl+", XLYLK(19,528,1,1), XLYBB_MASK, PPCCOM, PPCVLE, {BOE, BI}},
4587{"bcctr", XLLK(19,528,0), XLBH_MASK, PPCCOM, PPCVLE, {BO, BI, BH}},
4588{"bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, PPCVLE, {BO, BI}},
4589{"bcctrl", XLLK(19,528,1), XLBH_MASK, PPCCOM, PPCVLE, {BO, BI, BH}},
4590{"bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, PPCVLE, {BO, BI}},
4591
4592{"bctar-", XLYLK(19,560,0,0), XLYBB_MASK, POWER8, PPCVLE, {BOE, BI}},
4593{"bctarl-", XLYLK(19,560,0,1), XLYBB_MASK, POWER8, PPCVLE, {BOE, BI}},
4594{"bctar+", XLYLK(19,560,1,0), XLYBB_MASK, POWER8, PPCVLE, {BOE, BI}},
4595{"bctarl+", XLYLK(19,560,1,1), XLYBB_MASK, POWER8, PPCVLE, {BOE, BI}},
4596{"bctar", XLLK(19,560,0), XLBH_MASK, POWER8, PPCVLE, {BO, BI, BH}},
4597{"bctarl", XLLK(19,560,1), XLBH_MASK, POWER8, PPCVLE, {BO, BI, BH}},
4598
4599{"rlwimi", M(20,0), M_MASK, PPCCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4600{"rlimi", M(20,0), M_MASK, PWRCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4601
4602{"rlwimi.", M(20,1), M_MASK, PPCCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4603{"rlimi.", M(20,1), M_MASK, PWRCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4604
4605{"rotlwi", MME(21,31,0), MMBME_MASK, PPCCOM, PPCVLE, {RA, RS, SH}},
4606{"clrlwi", MME(21,31,0), MSHME_MASK, PPCCOM, PPCVLE, {RA, RS, MB}},
4607{"rlwinm", M(21,0), M_MASK, PPCCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4608{"rlinm", M(21,0), M_MASK, PWRCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4609{"rotlwi.", MME(21,31,1), MMBME_MASK, PPCCOM, PPCVLE, {RA, RS, SH}},
4610{"clrlwi.", MME(21,31,1), MSHME_MASK, PPCCOM, PPCVLE, {RA, RS, MB}},
4611{"rlwinm.", M(21,1), M_MASK, PPCCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4612{"rlinm.", M(21,1), M_MASK, PWRCOM, PPCVLE, {RA, RS, SH, MBE, ME}},
4613
4614{"rlmi", M(22,0), M_MASK, M601, PPCVLE, {RA, RS, RB, MBE, ME}},
4615{"rlmi.", M(22,1), M_MASK, M601, PPCVLE, {RA, RS, RB, MBE, ME}},
4616
4617{"rotlw", MME(23,31,0), MMBME_MASK, PPCCOM, PPCVLE, {RA, RS, RB}},
4618{"rlwnm", M(23,0), M_MASK, PPCCOM, PPCVLE, {RA, RS, RB, MBE, ME}},
4619{"rlnm", M(23,0), M_MASK, PWRCOM, PPCVLE, {RA, RS, RB, MBE, ME}},
4620{"rotlw.", MME(23,31,1), MMBME_MASK, PPCCOM, PPCVLE, {RA, RS, RB}},
4621{"rlwnm.", M(23,1), M_MASK, PPCCOM, PPCVLE, {RA, RS, RB, MBE, ME}},
4622{"rlnm.", M(23,1), M_MASK, PWRCOM, PPCVLE, {RA, RS, RB, MBE, ME}},
4623
4624{"nop", OP(24), 0xffffffff, PPCCOM, PPCVLE, {0}},
4625{"ori", OP(24), OP_MASK, PPCCOM, PPCVLE, {RA, RS, UI}},
4626{"oril", OP(24), OP_MASK, PWRCOM, PPCVLE, {RA, RS, UI}},
4627
4628{"oris", OP(25), OP_MASK, PPCCOM, PPCVLE, {RA, RS, UI}},
4629{"oriu", OP(25), OP_MASK, PWRCOM, PPCVLE, {RA, RS, UI}},
4630
4631{"xnop", OP(26), 0xffffffff, PPCCOM, PPCVLE, {0}},
4632{"xori", OP(26), OP_MASK, PPCCOM, PPCVLE, {RA, RS, UI}},
4633{"xoril", OP(26), OP_MASK, PWRCOM, PPCVLE, {RA, RS, UI}},
4634
4635{"xoris", OP(27), OP_MASK, PPCCOM, PPCVLE, {RA, RS, UI}},
4636{"xoriu", OP(27), OP_MASK, PWRCOM, PPCVLE, {RA, RS, UI}},
4637
4638{"andi.", OP(28), OP_MASK, PPCCOM, PPCVLE, {RA, RS, UI}},
4639{"andil.", OP(28), OP_MASK, PWRCOM, PPCVLE, {RA, RS, UI}},
4640
4641{"andis.", OP(29), OP_MASK, PPCCOM, PPCVLE, {RA, RS, UI}},
4642{"andiu.", OP(29), OP_MASK, PWRCOM, PPCVLE, {RA, RS, UI}},
4643
4644{"rotldi", MD(30,0,0), MDMB_MASK, PPC64, PPCVLE, {RA, RS, SH6}},
4645{"clrldi", MD(30,0,0), MDSH_MASK, PPC64, PPCVLE, {RA, RS, MB6}},
4646{"rldicl", MD(30,0,0), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, MB6}},
4647{"rotldi.", MD(30,0,1), MDMB_MASK, PPC64, PPCVLE, {RA, RS, SH6}},
4648{"clrldi.", MD(30,0,1), MDSH_MASK, PPC64, PPCVLE, {RA, RS, MB6}},
4649{"rldicl.", MD(30,0,1), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, MB6}},
4650
4651{"rldicr", MD(30,1,0), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, ME6}},
4652{"rldicr.", MD(30,1,1), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, ME6}},
4653
4654{"rldic", MD(30,2,0), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, MB6}},
4655{"rldic.", MD(30,2,1), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, MB6}},
4656
4657{"rldimi", MD(30,3,0), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, MB6}},
4658{"rldimi.", MD(30,3,1), MD_MASK, PPC64, PPCVLE, {RA, RS, SH6, MB6}},
4659
4660{"rotld", MDS(30,8,0), MDSMB_MASK, PPC64, PPCVLE, {RA, RS, RB}},
4661{"rldcl", MDS(30,8,0), MDS_MASK, PPC64, PPCVLE, {RA, RS, RB, MB6}},
4662{"rotld.", MDS(30,8,1), MDSMB_MASK, PPC64, PPCVLE, {RA, RS, RB}},
4663{"rldcl.", MDS(30,8,1), MDS_MASK, PPC64, PPCVLE, {RA, RS, RB, MB6}},
4664
4665{"rldcr", MDS(30,9,0), MDS_MASK, PPC64, PPCVLE, {RA, RS, RB, ME6}},
4666{"rldcr.", MDS(30,9,1), MDS_MASK, PPC64, PPCVLE, {RA, RS, RB, ME6}},
4667
4668{"cmpw", XOPL(31,0,0), XCMPL_MASK, PPCCOM, 0, {OBF, RA, RB}},
4669{"cmpd", XOPL(31,0,1), XCMPL_MASK, PPC64, 0, {OBF, RA, RB}},
4670{"cmp", X(31,0), XCMP_MASK, PPC, 0, {BF, L32OPT, RA, RB}},
4671{"cmp", X(31,0), XCMPL_MASK, PWRCOM, PPC, {BF, RA, RB}},
4672
4673{"twlgt", XTO(31,4,TOLGT), XTO_MASK, PPCCOM, 0, {RA, RB}},
4674{"tlgt", XTO(31,4,TOLGT), XTO_MASK, PWRCOM, 0, {RA, RB}},
4675{"twllt", XTO(31,4,TOLLT), XTO_MASK, PPCCOM, 0, {RA, RB}},
4676{"tllt", XTO(31,4,TOLLT), XTO_MASK, PWRCOM, 0, {RA, RB}},
4677{"tweq", XTO(31,4,TOEQ), XTO_MASK, PPCCOM, 0, {RA, RB}},
4678{"teq", XTO(31,4,TOEQ), XTO_MASK, PWRCOM, 0, {RA, RB}},
4679{"twlge", XTO(31,4,TOLGE), XTO_MASK, PPCCOM, 0, {RA, RB}},
4680{"tlge", XTO(31,4,TOLGE), XTO_MASK, PWRCOM, 0, {RA, RB}},
4681{"twlnl", XTO(31,4,TOLNL), XTO_MASK, PPCCOM, 0, {RA, RB}},
4682{"tlnl", XTO(31,4,TOLNL), XTO_MASK, PWRCOM, 0, {RA, RB}},
4683{"twlle", XTO(31,4,TOLLE), XTO_MASK, PPCCOM, 0, {RA, RB}},
4684{"tlle", XTO(31,4,TOLLE), XTO_MASK, PWRCOM, 0, {RA, RB}},
4685{"twlng", XTO(31,4,TOLNG), XTO_MASK, PPCCOM, 0, {RA, RB}},
4686{"tlng", XTO(31,4,TOLNG), XTO_MASK, PWRCOM, 0, {RA, RB}},
4687{"twgt", XTO(31,4,TOGT), XTO_MASK, PPCCOM, 0, {RA, RB}},
4688{"tgt", XTO(31,4,TOGT), XTO_MASK, PWRCOM, 0, {RA, RB}},
4689{"twge", XTO(31,4,TOGE), XTO_MASK, PPCCOM, 0, {RA, RB}},
4690{"tge", XTO(31,4,TOGE), XTO_MASK, PWRCOM, 0, {RA, RB}},
4691{"twnl", XTO(31,4,TONL), XTO_MASK, PPCCOM, 0, {RA, RB}},
4692{"tnl", XTO(31,4,TONL), XTO_MASK, PWRCOM, 0, {RA, RB}},
4693{"twlt", XTO(31,4,TOLT), XTO_MASK, PPCCOM, 0, {RA, RB}},
4694{"tlt", XTO(31,4,TOLT), XTO_MASK, PWRCOM, 0, {RA, RB}},
4695{"twle", XTO(31,4,TOLE), XTO_MASK, PPCCOM, 0, {RA, RB}},
4696{"tle", XTO(31,4,TOLE), XTO_MASK, PWRCOM, 0, {RA, RB}},
4697{"twng", XTO(31,4,TONG), XTO_MASK, PPCCOM, 0, {RA, RB}},
4698{"tng", XTO(31,4,TONG), XTO_MASK, PWRCOM, 0, {RA, RB}},
4699{"twne", XTO(31,4,TONE), XTO_MASK, PPCCOM, 0, {RA, RB}},
4700{"tne", XTO(31,4,TONE), XTO_MASK, PWRCOM, 0, {RA, RB}},
4701{"trap", XTO(31,4,TOU), 0xffffffff, PPCCOM, 0, {0}},
4702{"twu", XTO(31,4,TOU), XTO_MASK, PPCCOM, 0, {RA, RB}},
4703{"tu", XTO(31,4,TOU), XTO_MASK, PWRCOM, 0, {RA, RB}},
4704{"tw", X(31,4), X_MASK, PPCCOM, 0, {TO, RA, RB}},
4705{"t", X(31,4), X_MASK, PWRCOM, 0, {TO, RA, RB}},
4706
4707{"lvsl", X(31,6), X_MASK, PPCVEC, 0, {VD, RA0, RB}},
4708{"lvebx", X(31,7), X_MASK, PPCVEC, 0, {VD, RA0, RB}},
4709{"lbfcmx", APU(31,7,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4710
4711{"subfc", XO(31,8,0,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4712{"sf", XO(31,8,0,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4713{"subc", XO(31,8,0,0), XO_MASK, PPCCOM, 0, {RT, RB, RA}},
4714{"subfc.", XO(31,8,0,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4715{"sf.", XO(31,8,0,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4716{"subc.", XO(31,8,0,1), XO_MASK, PPCCOM, 0, {RT, RB, RA}},
4717
4718{"mulhdu", XO(31,9,0,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
4719{"mulhdu.", XO(31,9,0,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
4720
4721{"addc", XO(31,10,0,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4722{"a", XO(31,10,0,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4723{"addc.", XO(31,10,0,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4724{"a.", XO(31,10,0,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4725
4726{"mulhwu", XO(31,11,0,0), XO_MASK, PPC, 0, {RT, RA, RB}},
4727{"mulhwu.", XO(31,11,0,1), XO_MASK, PPC, 0, {RT, RA, RB}},
4728
4729{"lxsiwzx", X(31,12), XX1_MASK, PPCVSX2, 0, {XT6, RA0, RB}},
4730
4731{"isellt", X(31,15), X_MASK, PPCISEL, 0, {RT, RA0, RB}},
4732
4733{"tlbilxlpid", XTO(31,18,0), XTO_MASK, E500MC|PPCA2, 0, {0}},
4734{"tlbilxpid", XTO(31,18,1), XTO_MASK, E500MC|PPCA2, 0, {0}},
4735{"tlbilxva", XTO(31,18,3), XTO_MASK, E500MC|PPCA2, 0, {RA0, RB}},
4736{"tlbilx", X(31,18), X_MASK, E500MC|PPCA2, 0, {T, RA0, RB}},
4737
4738{"mfcr", XFXM(31,19,0,0), XFXFXM_MASK, COM, 0, {RT, FXM4}},
4739{"mfocrf", XFXM(31,19,0,1), XFXFXM_MASK, COM, 0, {RT, FXM}},
4740
4741{"lwarx", X(31,20), XEH_MASK, PPC, 0, {RT, RA0, RB, EH}},
4742
4743{"ldx", X(31,21), X_MASK, PPC64, 0, {RT, RA0, RB}},
4744
4745{"icbt", X(31,22), X_MASK, BOOKE|PPCE300|PPCA2|PPC476, 0, {CT, RA0, RB}},
4746
4747{"lwzx", X(31,23), X_MASK, PPCCOM, 0, {RT, RA0, RB}},
4748{"lx", X(31,23), X_MASK, PWRCOM, 0, {RT, RA, RB}},
4749
4750{"slw", XRC(31,24,0), X_MASK, PPCCOM, 0, {RA, RS, RB}},
4751{"sl", XRC(31,24,0), X_MASK, PWRCOM, 0, {RA, RS, RB}},
4752{"slw.", XRC(31,24,1), X_MASK, PPCCOM, 0, {RA, RS, RB}},
4753{"sl.", XRC(31,24,1), X_MASK, PWRCOM, 0, {RA, RS, RB}},
4754
4755{"cntlzw", XRC(31,26,0), XRB_MASK, PPCCOM, 0, {RA, RS}},
4756{"cntlz", XRC(31,26,0), XRB_MASK, PWRCOM, 0, {RA, RS}},
4757{"cntlzw.", XRC(31,26,1), XRB_MASK, PPCCOM, 0, {RA, RS}},
4758{"cntlz.", XRC(31,26,1), XRB_MASK, PWRCOM, 0, {RA, RS}},
4759
4760{"sld", XRC(31,27,0), X_MASK, PPC64, 0, {RA, RS, RB}},
4761{"sld.", XRC(31,27,1), X_MASK, PPC64, 0, {RA, RS, RB}},
4762
4763{"and", XRC(31,28,0), X_MASK, COM, 0, {RA, RS, RB}},
4764{"and.", XRC(31,28,1), X_MASK, COM, 0, {RA, RS, RB}},
4765
4766{"maskg", XRC(31,29,0), X_MASK, M601, PPCA2, {RA, RS, RB}},
4767{"maskg.", XRC(31,29,1), X_MASK, M601, PPCA2, {RA, RS, RB}},
4768
4769{"ldepx", X(31,29), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
4770
4771{"waitasec", X(31,30), XRTRARB_MASK, POWER8, POWER9, {0}},
4772{"wait", X(31,30), XWC_MASK, POWER9, 0, {WC}},
4773
4774{"lwepx", X(31,31), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
4775
4776{"cmplw", XOPL(31,32,0), XCMPL_MASK, PPCCOM, 0, {OBF, RA, RB}},
4777{"cmpld", XOPL(31,32,1), XCMPL_MASK, PPC64, 0, {OBF, RA, RB}},
4778{"cmpl", X(31,32), XCMP_MASK, PPC, 0, {BF, L32OPT, RA, RB}},
4779{"cmpl", X(31,32), XCMPL_MASK, PWRCOM, PPC, {BF, RA, RB}},
4780
4781{"lvsr", X(31,38), X_MASK, PPCVEC, 0, {VD, RA0, RB}},
4782{"lvehx", X(31,39), X_MASK, PPCVEC, 0, {VD, RA0, RB}},
4783{"lhfcmx", APU(31,39,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4784
4785{"mviwsplt", X(31,46), X_MASK, PPCVEC2, 0, {VD, RA, RB}},
4786
4787{"iselgt", X(31,47), X_MASK, PPCISEL, 0, {RT, RA0, RB}},
4788
4789{"lvewx", X(31,71), X_MASK, PPCVEC, 0, {VD, RA0, RB}},
4790
4791{"addg6s", XO(31,74,0,0), XO_MASK, POWER6, 0, {RT, RA, RB}},
4792
4793{"lxsiwax", X(31,76), XX1_MASK, PPCVSX2, 0, {XT6, RA0, RB}},
4794
4795{"iseleq", X(31,79), X_MASK, PPCISEL, 0, {RT, RA0, RB}},
4796
4797{"isel", XISEL(31,15), XISEL_MASK, PPCISEL|TITAN, 0, {RT, RA0, RB, CRB}},
4798
4799{"subf", XO(31,40,0,0), XO_MASK, PPC, 0, {RT, RA, RB}},
4800{"sub", XO(31,40,0,0), XO_MASK, PPC, 0, {RT, RB, RA}},
4801{"subf.", XO(31,40,0,1), XO_MASK, PPC, 0, {RT, RA, RB}},
4802{"sub.", XO(31,40,0,1), XO_MASK, PPC, 0, {RT, RB, RA}},
4803
4804{"mfvsrd", X(31,51), XX1RB_MASK, PPCVSX2, 0, {RA, XS6}},
4805{"mffprd", X(31,51), XX1RB_MASK|1, PPCVSX2, 0, {RA, FRS}},
4806{"mfvrd", X(31,51)|1, XX1RB_MASK|1, PPCVSX2, 0, {RA, VS}},
4807{"eratilx", X(31,51), X_MASK, PPCA2, 0, {ERAT_T, RA, RB}},
4808
4809{"lbarx", X(31,52), XEH_MASK, POWER8|E6500, 0, {RT, RA0, RB, EH}},
4810
4811{"ldux", X(31,53), X_MASK, PPC64, 0, {RT, RAL, RB}},
4812
4813{"dcbst", X(31,54), XRT_MASK, PPC, 0, {RA0, RB}},
4814
4815{"lwzux", X(31,55), X_MASK, PPCCOM, 0, {RT, RAL, RB}},
4816{"lux", X(31,55), X_MASK, PWRCOM, 0, {RT, RA, RB}},
4817
4818{"cntlzd", XRC(31,58,0), XRB_MASK, PPC64, 0, {RA, RS}},
4819{"cntlzd.", XRC(31,58,1), XRB_MASK, PPC64, 0, {RA, RS}},
4820
4821{"andc", XRC(31,60,0), X_MASK, COM, 0, {RA, RS, RB}},
4822{"andc.", XRC(31,60,1), X_MASK, COM, 0, {RA, RS, RB}},
4823
4824{"waitrsv", X(31,62)|(1<<21), 0xffffffff, E500MC|PPCA2, 0, {0}},
4825{"waitimpl", X(31,62)|(2<<21), 0xffffffff, E500MC|PPCA2, 0, {0}},
4826{"wait", X(31,62), XWC_MASK, E500MC|PPCA2, 0, {WC}},
4827
4828{"dcbstep", XRT(31,63,0), XRT_MASK, E500MC|PPCA2, 0, {RA0, RB}},
4829
4830{"tdlgt", XTO(31,68,TOLGT), XTO_MASK, PPC64, 0, {RA, RB}},
4831{"tdllt", XTO(31,68,TOLLT), XTO_MASK, PPC64, 0, {RA, RB}},
4832{"tdeq", XTO(31,68,TOEQ), XTO_MASK, PPC64, 0, {RA, RB}},
4833{"tdlge", XTO(31,68,TOLGE), XTO_MASK, PPC64, 0, {RA, RB}},
4834{"tdlnl", XTO(31,68,TOLNL), XTO_MASK, PPC64, 0, {RA, RB}},
4835{"tdlle", XTO(31,68,TOLLE), XTO_MASK, PPC64, 0, {RA, RB}},
4836{"tdlng", XTO(31,68,TOLNG), XTO_MASK, PPC64, 0, {RA, RB}},
4837{"tdgt", XTO(31,68,TOGT), XTO_MASK, PPC64, 0, {RA, RB}},
4838{"tdge", XTO(31,68,TOGE), XTO_MASK, PPC64, 0, {RA, RB}},
4839{"tdnl", XTO(31,68,TONL), XTO_MASK, PPC64, 0, {RA, RB}},
4840{"tdlt", XTO(31,68,TOLT), XTO_MASK, PPC64, 0, {RA, RB}},
4841{"tdle", XTO(31,68,TOLE), XTO_MASK, PPC64, 0, {RA, RB}},
4842{"tdng", XTO(31,68,TONG), XTO_MASK, PPC64, 0, {RA, RB}},
4843{"tdne", XTO(31,68,TONE), XTO_MASK, PPC64, 0, {RA, RB}},
4844{"tdu", XTO(31,68,TOU), XTO_MASK, PPC64, 0, {RA, RB}},
4845{"td", X(31,68), X_MASK, PPC64, 0, {TO, RA, RB}},
4846
4847{"lwfcmx", APU(31,71,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4848{"mulhd", XO(31,73,0,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
4849{"mulhd.", XO(31,73,0,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
4850
4851{"mulhw", XO(31,75,0,0), XO_MASK, PPC, 0, {RT, RA, RB}},
4852{"mulhw.", XO(31,75,0,1), XO_MASK, PPC, 0, {RT, RA, RB}},
4853
4854{"dlmzb", XRC(31,78,0), X_MASK, PPC403|PPC440|TITAN, 0, {RA, RS, RB}},
4855{"dlmzb.", XRC(31,78,1), X_MASK, PPC403|PPC440|TITAN, 0, {RA, RS, RB}},
4856
4857{"mtsrd", X(31,82), XRB_MASK|(1<<20), PPC64, 0, {SR, RS}},
4858
4859{"mfmsr", X(31,83), XRARB_MASK, COM, 0, {RT}},
4860
4861{"ldarx", X(31,84), XEH_MASK, PPC64, 0, {RT, RA0, RB, EH}},
4862
4863{"dcbfl", XOPL(31,86,1), XRT_MASK, POWER5, PPC476, {RA0, RB}},
4864{"dcbf", X(31,86), XLRT_MASK, PPC, 0, {RA0, RB, L2OPT}},
4865
4866{"lbzx", X(31,87), X_MASK, COM, 0, {RT, RA0, RB}},
4867
4868{"lbepx", X(31,95), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
4869
4870{"dni", XRC(31,97,1), XRB_MASK, E6500, 0, {DUI, DCTL}},
4871
4872{"lvx", X(31,103), X_MASK, PPCVEC, 0, {VD, RA0, RB}},
4873{"lqfcmx", APU(31,103,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4874
4875{"neg", XO(31,104,0,0), XORB_MASK, COM, 0, {RT, RA}},
4876{"neg.", XO(31,104,0,1), XORB_MASK, COM, 0, {RT, RA}},
4877
4878{"mul", XO(31,107,0,0), XO_MASK, M601, 0, {RT, RA, RB}},
4879{"mul.", XO(31,107,0,1), XO_MASK, M601, 0, {RT, RA, RB}},
4880
4881{"mvidsplt", X(31,110), X_MASK, PPCVEC2, 0, {VD, RA, RB}},
4882
4883{"mtsrdin", X(31,114), XRA_MASK, PPC64, 0, {RS, RB}},
4884
4885{"mffprwz", X(31,115), XX1RB_MASK|1, PPCVSX2, 0, {RA, FRS}},
4886{"mfvrwz", X(31,115)|1, XX1RB_MASK|1, PPCVSX2, 0, {RA, VS}},
4887{"mfvsrwz", X(31,115), XX1RB_MASK, PPCVSX2, 0, {RA, XS6}},
4888
4889{"lharx", X(31,116), XEH_MASK, POWER8|E6500, 0, {RT, RA0, RB, EH}},
4890
4891{"clf", X(31,118), XTO_MASK, POWER, 0, {RA, RB}},
4892
4893{"lbzux", X(31,119), X_MASK, COM, 0, {RT, RAL, RB}},
4894
4895{"popcntb", X(31,122), XRB_MASK, POWER5, 0, {RA, RS}},
4896
4897{"not", XRC(31,124,0), X_MASK, COM, 0, {RA, RS, RBS}},
4898{"nor", XRC(31,124,0), X_MASK, COM, 0, {RA, RS, RB}},
4899{"not.", XRC(31,124,1), X_MASK, COM, 0, {RA, RS, RBS}},
4900{"nor.", XRC(31,124,1), X_MASK, COM, 0, {RA, RS, RB}},
4901
4902{"dcbfep", XRT(31,127,0), XRT_MASK, E500MC|PPCA2, 0, {RA0, RB}},
4903
4904{"setb", X(31,128), XRB_MASK|(3<<16), POWER9, 0, {RT, BFA}},
4905
4906{"wrtee", X(31,131), XRARB_MASK, PPC403|BOOKE|PPCA2|PPC476, 0, {RS}},
4907
4908{"dcbtstls", X(31,134), X_MASK, PPCCHLK|PPC476|TITAN, 0, {CT, RA0, RB}},
4909
4910{"stvebx", X(31,135), X_MASK, PPCVEC, 0, {VS, RA0, RB}},
4911{"stbfcmx", APU(31,135,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4912
4913{"subfe", XO(31,136,0,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4914{"sfe", XO(31,136,0,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4915{"subfe.", XO(31,136,0,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4916{"sfe.", XO(31,136,0,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4917
4918{"adde", XO(31,138,0,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4919{"ae", XO(31,138,0,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4920{"adde.", XO(31,138,0,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4921{"ae.", XO(31,138,0,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4922
4923{"stxsiwx", X(31,140), XX1_MASK, PPCVSX2, 0, {XS6, RA0, RB}},
4924
4925{"msgsndp", XRTRA(31,142,0,0), XRTRA_MASK, POWER8, 0, {RB}},
4926{"dcbtstlse", X(31,142), X_MASK, PPCCHLK, E500MC, {CT, RA0, RB}},
4927
4928{"mtcr", XFXM(31,144,0xff,0), XRARB_MASK, COM, 0, {RS}},
4929{"mtcrf", XFXM(31,144,0,0), XFXFXM_MASK, COM, 0, {FXM, RS}},
4930{"mtocrf", XFXM(31,144,0,1), XFXFXM_MASK, COM, 0, {FXM, RS}},
4931
4932{"mtmsr", X(31,146), XRLARB_MASK, COM, 0, {RS, A_L}},
4933
4934{"mtsle", X(31,147), XRTLRARB_MASK, POWER8, 0, {L}},
3439 4935
3440{ "ldux", X(31,53), X_MASK, PPC64, { RT, RAL, RB } }, 4936{"eratsx", XRC(31,147,0), X_MASK, PPCA2, 0, {RT, RA0, RB}},
4937{"eratsx.", XRC(31,147,1), X_MASK, PPCA2, 0, {RT, RA0, RB}},
3441 4938
3442{ "dcbst", X(31,54), XRT_MASK, PPC, { RA, RB } }, 4939{"stdx", X(31,149), X_MASK, PPC64, 0, {RS, RA0, RB}},
3443 4940
3444{ "lwzux", X(31,55), X_MASK, PPCCOM, { RT, RAL, RB } }, 4941{"stwcx.", XRC(31,150,1), X_MASK, PPC, 0, {RS, RA0, RB}},
3445{ "lux", X(31,55), X_MASK, PWRCOM, { RT, RA, RB } },
3446 4942
3447{ "dcbste", X(31,62), XRT_MASK, BOOKE64, { RA, RB } }, 4943{"stwx", X(31,151), X_MASK, PPCCOM, 0, {RS, RA0, RB}},
4944{"stx", X(31,151), X_MASK, PWRCOM, 0, {RS, RA, RB}},
3448 4945
3449{ "lwzuxe", X(31,63), X_MASK, BOOKE64, { RT, RAL, RB } }, 4946{"slq", XRC(31,152,0), X_MASK, M601, 0, {RA, RS, RB}},
4947{"slq.", XRC(31,152,1), X_MASK, M601, 0, {RA, RS, RB}},
3450 4948
3451{ "cntlzd", XRC(31,58,0), XRB_MASK, PPC64, { RA, RS } }, 4949{"sle", XRC(31,153,0), X_MASK, M601, 0, {RA, RS, RB}},
3452{ "cntlzd.", XRC(31,58,1), XRB_MASK, PPC64, { RA, RS } }, 4950{"sle.", XRC(31,153,1), X_MASK, M601, 0, {RA, RS, RB}},
3453 4951
3454{ "andc", XRC(31,60,0), X_MASK, COM, { RA, RS, RB } }, 4952{"prtyw", X(31,154), XRB_MASK, POWER6|PPCA2|PPC476, 0, {RA, RS}},
3455{ "andc.", XRC(31,60,1), X_MASK, COM, { RA, RS, RB } },
3456 4953
3457{ "tdlgt", XTO(31,68,TOLGT), XTO_MASK, PPC64, { RA, RB } }, 4954{"stdepx", X(31,157), X_MASK, E500MC|PPCA2, 0, {RS, RA0, RB}},
3458{ "tdllt", XTO(31,68,TOLLT), XTO_MASK, PPC64, { RA, RB } },
3459{ "tdeq", XTO(31,68,TOEQ), XTO_MASK, PPC64, { RA, RB } },
3460{ "tdlge", XTO(31,68,TOLGE), XTO_MASK, PPC64, { RA, RB } },
3461{ "tdlnl", XTO(31,68,TOLNL), XTO_MASK, PPC64, { RA, RB } },
3462{ "tdlle", XTO(31,68,TOLLE), XTO_MASK, PPC64, { RA, RB } },
3463{ "tdlng", XTO(31,68,TOLNG), XTO_MASK, PPC64, { RA, RB } },
3464{ "tdgt", XTO(31,68,TOGT), XTO_MASK, PPC64, { RA, RB } },
3465{ "tdge", XTO(31,68,TOGE), XTO_MASK, PPC64, { RA, RB } },
3466{ "tdnl", XTO(31,68,TONL), XTO_MASK, PPC64, { RA, RB } },
3467{ "tdlt", XTO(31,68,TOLT), XTO_MASK, PPC64, { RA, RB } },
3468{ "tdle", XTO(31,68,TOLE), XTO_MASK, PPC64, { RA, RB } },
3469{ "tdng", XTO(31,68,TONG), XTO_MASK, PPC64, { RA, RB } },
3470{ "tdne", XTO(31,68,TONE), XTO_MASK, PPC64, { RA, RB } },
3471{ "td", X(31,68), X_MASK, PPC64, { TO, RA, RB } },
3472 4955
3473{ "mulhd", XO(31,73,0,0), XO_MASK, PPC64, { RT, RA, RB } }, 4956{"stwepx", X(31,159), X_MASK, E500MC|PPCA2, 0, {RS, RA0, RB}},
3474{ "mulhd.", XO(31,73,0,1), XO_MASK, PPC64, { RT, RA, RB } },
3475 4957
3476{ "mulhw", XO(31,75,0,0), XO_MASK, PPC, { RT, RA, RB } }, 4958{"wrteei", X(31,163), XE_MASK, PPC403|BOOKE|PPCA2|PPC476, 0, {E}},
3477{ "mulhw.", XO(31,75,0,1), XO_MASK, PPC, { RT, RA, RB } },
3478 4959
3479{ "dlmzb", XRC(31,78,0), X_MASK, PPC403|PPC440, { RA, RS, RB } }, 4960{"dcbtls", X(31,166), X_MASK, PPCCHLK|PPC476|TITAN, 0, {CT, RA0, RB}},
3480{ "dlmzb.", XRC(31,78,1), X_MASK, PPC403|PPC440, { RA, RS, RB } },
3481 4961
3482{ "mtsrd", X(31,82), XRB_MASK|(1<<20), PPC64, { SR, RS } }, 4962{"stvehx", X(31,167), X_MASK, PPCVEC, 0, {VS, RA0, RB}},
4963{"sthfcmx", APU(31,167,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
3483 4964
3484{ "mfmsr", X(31,83), XRARB_MASK, COM, { RT } }, 4965{"addex", ZRC(31,170,0), Z2_MASK, POWER9, 0, {RT, RA, RB, CY}},
3485 4966
3486{ "ldarx", X(31,84), XEH_MASK, PPC64, { RT, RA0, RB, EH } }, 4967{"msgclrp", XRTRA(31,174,0,0), XRTRA_MASK, POWER8, 0, {RB}},
4968{"dcbtlse", X(31,174), X_MASK, PPCCHLK, E500MC, {CT, RA0, RB}},
3487 4969
3488{ "dcbfl", XOPL(31,86,1), XRT_MASK, POWER5, { RA, RB } }, 4970{"mtmsrd", X(31,178), XRLARB_MASK, PPC64, 0, {RS, A_L}},
3489{ "dcbf", X(31,86), XLRT_MASK, PPC, { RA, RB, XRT_L } },
3490 4971
3491{ "lbzx", X(31,87), X_MASK, COM, { RT, RA0, RB } }, 4972{"mtvsrd", X(31,179), XX1RB_MASK, PPCVSX2, 0, {XT6, RA}},
4973{"mtfprd", X(31,179), XX1RB_MASK|1, PPCVSX2, 0, {FRT, RA}},
4974{"mtvrd", X(31,179)|1, XX1RB_MASK|1, PPCVSX2, 0, {VD, RA}},
4975{"eratre", X(31,179), X_MASK, PPCA2, 0, {RT, RA, WS}},
3492 4976
3493{ "dcbfe", X(31,94), XRT_MASK, BOOKE64, { RA, RB } }, 4977{"stdux", X(31,181), X_MASK, PPC64, 0, {RS, RAS, RB}},
3494 4978
3495{ "lbzxe", X(31,95), X_MASK, BOOKE64, { RT, RA0, RB } }, 4979{"stqcx.", XRC(31,182,1), X_MASK, POWER8, 0, {RSQ, RA0, RB}},
4980{"wchkall", X(31,182), X_MASK, PPCA2, 0, {OBF}},
3496 4981
3497{ "neg", XO(31,104,0,0), XORB_MASK, COM, { RT, RA } }, 4982{"stwux", X(31,183), X_MASK, PPCCOM, 0, {RS, RAS, RB}},
3498{ "neg.", XO(31,104,0,1), XORB_MASK, COM, { RT, RA } }, 4983{"stux", X(31,183), X_MASK, PWRCOM, 0, {RS, RA0, RB}},
3499{ "nego", XO(31,104,1,0), XORB_MASK, COM, { RT, RA } },
3500{ "nego.", XO(31,104,1,1), XORB_MASK, COM, { RT, RA } },
3501 4984
3502{ "mul", XO(31,107,0,0), XO_MASK, M601, { RT, RA, RB } }, 4985{"sliq", XRC(31,184,0), X_MASK, M601, 0, {RA, RS, SH}},
3503{ "mul.", XO(31,107,0,1), XO_MASK, M601, { RT, RA, RB } }, 4986{"sliq.", XRC(31,184,1), X_MASK, M601, 0, {RA, RS, SH}},
3504{ "mulo", XO(31,107,1,0), XO_MASK, M601, { RT, RA, RB } },
3505{ "mulo.", XO(31,107,1,1), XO_MASK, M601, { RT, RA, RB } },
3506 4987
3507{ "mtsrdin", X(31,114), XRA_MASK, PPC64, { RS, RB } }, 4988{"prtyd", X(31,186), XRB_MASK, POWER6|PPCA2, 0, {RA, RS}},
3508 4989
3509{ "clf", X(31,118), XTO_MASK, POWER, { RA, RB } }, 4990{"cmprb", X(31,192), XCMP_MASK, POWER9, 0, {BF, L, RA, RB}},
3510 4991
3511{ "lbzux", X(31,119), X_MASK, COM, { RT, RAL, RB } }, 4992{"icblq.", XRC(31,198,1), X_MASK, E6500, 0, {CT, RA0, RB}},
3512 4993
3513{ "popcntb", X(31,122), XRB_MASK, POWER5, { RA, RS } }, 4994{"stvewx", X(31,199), X_MASK, PPCVEC, 0, {VS, RA0, RB}},
4995{"stwfcmx", APU(31,199,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
3514 4996
3515{ "not", XRC(31,124,0), X_MASK, COM, { RA, RS, RBS } }, 4997{"subfze", XO(31,200,0,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
3516{ "nor", XRC(31,124,0), X_MASK, COM, { RA, RS, RB } }, 4998{"sfze", XO(31,200,0,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
3517{ "not.", XRC(31,124,1), X_MASK, COM, { RA, RS, RBS } }, 4999{"subfze.", XO(31,200,0,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
3518{ "nor.", XRC(31,124,1), X_MASK, COM, { RA, RS, RB } }, 5000{"sfze.", XO(31,200,0,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
3519 5001
3520{ "lwarxe", X(31,126), X_MASK, BOOKE64, { RT, RA0, RB } }, 5002{"addze", XO(31,202,0,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
5003{"aze", XO(31,202,0,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
5004{"addze.", XO(31,202,0,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
5005{"aze.", XO(31,202,0,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
3521 5006
3522{ "lbzuxe", X(31,127), X_MASK, BOOKE64, { RT, RAL, RB } }, 5007{"msgsnd", XRTRA(31,206,0,0), XRTRA_MASK, E500MC|PPCA2|POWER8, 0, {RB}},
3523 5008
3524{ "wrtee", X(31,131), XRARB_MASK, PPC403 | BOOKE, { RS } }, 5009{"mtsr", X(31,210), XRB_MASK|(1<<20), COM, NON32, {SR, RS}},
3525 5010
3526{ "dcbtstls",X(31,134), X_MASK, PPCCHLK, { CT, RA, RB }}, 5011{"mtfprwa", X(31,211), XX1RB_MASK|1, PPCVSX2, 0, {FRT, RA}},
5012{"mtvrwa", X(31,211)|1, XX1RB_MASK|1, PPCVSX2, 0, {VD, RA}},
5013{"mtvsrwa", X(31,211), XX1RB_MASK, PPCVSX2, 0, {XT6, RA}},
5014{"eratwe", X(31,211), X_MASK, PPCA2, 0, {RS, RA, WS}},
3527 5015
3528{ "subfe", XO(31,136,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, 5016{"ldawx.", XRC(31,212,1), X_MASK, PPCA2, 0, {RT, RA0, RB}},
3529{ "sfe", XO(31,136,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
3530{ "subfe.", XO(31,136,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3531{ "sfe.", XO(31,136,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3532{ "subfeo", XO(31,136,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
3533{ "sfeo", XO(31,136,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
3534{ "subfeo.", XO(31,136,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3535{ "sfeo.", XO(31,136,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3536 5017
3537{ "adde", XO(31,138,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, 5018{"stdcx.", XRC(31,214,1), X_MASK, PPC64, 0, {RS, RA0, RB}},
3538{ "ae", XO(31,138,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
3539{ "adde.", XO(31,138,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3540{ "ae.", XO(31,138,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3541{ "addeo", XO(31,138,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
3542{ "aeo", XO(31,138,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
3543{ "addeo.", XO(31,138,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3544{ "aeo.", XO(31,138,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3545 5019
3546{ "dcbtstlse",X(31,142),X_MASK, PPCCHLK64, { CT, RA, RB }}, 5020{"stbx", X(31,215), X_MASK, COM, 0, {RS, RA0, RB}},
3547 5021
3548{ "mtocrf", XFXM(31,144,0,1), XFXFXM_MASK, COM, { FXM, RS } }, 5022{"sllq", XRC(31,216,0), X_MASK, M601, 0, {RA, RS, RB}},
3549{ "mtcr", XFXM(31,144,0xff,0), XRARB_MASK, COM, { RS }}, 5023{"sllq.", XRC(31,216,1), X_MASK, M601, 0, {RA, RS, RB}},
3550{ "mtcrf", X(31,144), XFXFXM_MASK, COM, { FXM, RS } },
3551 5024
3552{ "mtmsr", X(31,146), XRARB_MASK, COM, { RS } }, 5025{"sleq", XRC(31,217,0), X_MASK, M601, 0, {RA, RS, RB}},
5026{"sleq.", XRC(31,217,1), X_MASK, M601, 0, {RA, RS, RB}},
3553 5027
3554{ "stdx", X(31,149), X_MASK, PPC64, { RS, RA0, RB } }, 5028{"stbepx", X(31,223), X_MASK, E500MC|PPCA2, 0, {RS, RA0, RB}},
3555 5029
3556{ "stwcx.", XRC(31,150,1), X_MASK, PPC, { RS, RA0, RB } }, 5030{"cmpeqb", X(31,224), XCMPL_MASK, POWER9, 0, {BF, RA, RB}},
3557 5031
3558{ "stwx", X(31,151), X_MASK, PPCCOM, { RS, RA0, RB } }, 5032{"icblc", X(31,230), X_MASK, PPCCHLK|PPC476|TITAN, 0, {CT, RA0, RB}},
3559{ "stx", X(31,151), X_MASK, PWRCOM, { RS, RA, RB } },
3560 5033
3561{ "stwcxe.", XRC(31,158,1), X_MASK, BOOKE64, { RS, RA0, RB } }, 5034{"stvx", X(31,231), X_MASK, PPCVEC, 0, {VS, RA0, RB}},
5035{"stqfcmx", APU(31,231,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
3562 5036
3563{ "stwxe", X(31,159), X_MASK, BOOKE64, { RS, RA0, RB } }, 5037{"subfme", XO(31,232,0,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
5038{"sfme", XO(31,232,0,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
5039{"subfme.", XO(31,232,0,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
5040{"sfme.", XO(31,232,0,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
3564 5041
3565{ "slq", XRC(31,152,0), X_MASK, M601, { RA, RS, RB } }, 5042{"mulld", XO(31,233,0,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
3566{ "slq.", XRC(31,152,1), X_MASK, M601, { RA, RS, RB } }, 5043{"mulld.", XO(31,233,0,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
3567 5044
3568{ "sle", XRC(31,153,0), X_MASK, M601, { RA, RS, RB } }, 5045{"addme", XO(31,234,0,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
3569{ "sle.", XRC(31,153,1), X_MASK, M601, { RA, RS, RB } }, 5046{"ame", XO(31,234,0,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
5047{"addme.", XO(31,234,0,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
5048{"ame.", XO(31,234,0,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
3570 5049
3571{ "prtyw", X(31,154), XRB_MASK, POWER6, { RA, RS } }, 5050{"mullw", XO(31,235,0,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5051{"muls", XO(31,235,0,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
5052{"mullw.", XO(31,235,0,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5053{"muls.", XO(31,235,0,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
3572 5054
3573{ "wrteei", X(31,163), XE_MASK, PPC403 | BOOKE, { E } }, 5055{"icblce", X(31,238), X_MASK, PPCCHLK, E500MC|PPCA2, {CT, RA, RB}},
5056{"msgclr", XRTRA(31,238,0,0), XRTRA_MASK, E500MC|PPCA2|POWER8, 0, {RB}},
5057{"mtsrin", X(31,242), XRA_MASK, PPC, NON32, {RS, RB}},
5058{"mtsri", X(31,242), XRA_MASK, POWER, NON32, {RS, RB}},
3574 5059
3575{ "dcbtls", X(31,166), X_MASK, PPCCHLK, { CT, RA, RB }}, 5060{"mtfprwz", X(31,243), XX1RB_MASK|1, PPCVSX2, 0, {FRT, RA}},
3576{ "dcbtlse", X(31,174), X_MASK, PPCCHLK64, { CT, RA, RB }}, 5061{"mtvrwz", X(31,243)|1, XX1RB_MASK|1, PPCVSX2, 0, {VD, RA}},
5062{"mtvsrwz", X(31,243), XX1RB_MASK, PPCVSX2, 0, {XT6, RA}},
3577 5063
3578{ "mtmsrd", X(31,178), XRLARB_MASK, PPC64, { RS, MTMSRD_L } }, 5064{"dcbtstt", XRT(31,246,0x10), XRT_MASK, POWER7, 0, {RA0, RB}},
5065{"dcbtst", X(31,246), X_MASK, POWER4, DCBT_EO, {RA0, RB, CT}},
5066{"dcbtst", X(31,246), X_MASK, DCBT_EO, 0, {CT, RA0, RB}},
5067{"dcbtst", X(31,246), X_MASK, PPC, POWER4|DCBT_EO, {RA0, RB}},
3579 5068
3580{ "stdux", X(31,181), X_MASK, PPC64, { RS, RAS, RB } }, 5069{"stbux", X(31,247), X_MASK, COM, 0, {RS, RAS, RB}},
3581 5070
3582{ "stwux", X(31,183), X_MASK, PPCCOM, { RS, RAS, RB } }, 5071{"slliq", XRC(31,248,0), X_MASK, M601, 0, {RA, RS, SH}},
3583{ "stux", X(31,183), X_MASK, PWRCOM, { RS, RA0, RB } }, 5072{"slliq.", XRC(31,248,1), X_MASK, M601, 0, {RA, RS, SH}},
3584 5073
3585{ "sliq", XRC(31,184,0), X_MASK, M601, { RA, RS, SH } }, 5074{"bpermd", X(31,252), X_MASK, POWER7|PPCA2, 0, {RA, RS, RB}},
3586{ "sliq.", XRC(31,184,1), X_MASK, M601, { RA, RS, SH } },
3587 5075
3588{ "prtyd", X(31,186), XRB_MASK, POWER6, { RA, RS } }, 5076{"dcbtstep", XRT(31,255,0), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
3589 5077
3590{ "stwuxe", X(31,191), X_MASK, BOOKE64, { RS, RAS, RB } }, 5078{"mfdcrx", X(31,259), X_MASK, BOOKE|PPCA2|PPC476, TITAN, {RS, RA}},
5079{"mfdcrx.", XRC(31,259,1), X_MASK, PPCA2, 0, {RS, RA}},
3591 5080
3592{ "subfze", XO(31,200,0,0), XORB_MASK, PPCCOM, { RT, RA } }, 5081{"lvexbx", X(31,261), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
3593{ "sfze", XO(31,200,0,0), XORB_MASK, PWRCOM, { RT, RA } },
3594{ "subfze.", XO(31,200,0,1), XORB_MASK, PPCCOM, { RT, RA } },
3595{ "sfze.", XO(31,200,0,1), XORB_MASK, PWRCOM, { RT, RA } },
3596{ "subfzeo", XO(31,200,1,0), XORB_MASK, PPCCOM, { RT, RA } },
3597{ "sfzeo", XO(31,200,1,0), XORB_MASK, PWRCOM, { RT, RA } },
3598{ "subfzeo.",XO(31,200,1,1), XORB_MASK, PPCCOM, { RT, RA } },
3599{ "sfzeo.", XO(31,200,1,1), XORB_MASK, PWRCOM, { RT, RA } },
3600 5082
3601{ "addze", XO(31,202,0,0), XORB_MASK, PPCCOM, { RT, RA } }, 5083{"icbt", X(31,262), XRT_MASK, PPC403, 0, {RA, RB}},
3602{ "aze", XO(31,202,0,0), XORB_MASK, PWRCOM, { RT, RA } },
3603{ "addze.", XO(31,202,0,1), XORB_MASK, PPCCOM, { RT, RA } },
3604{ "aze.", XO(31,202,0,1), XORB_MASK, PWRCOM, { RT, RA } },
3605{ "addzeo", XO(31,202,1,0), XORB_MASK, PPCCOM, { RT, RA } },
3606{ "azeo", XO(31,202,1,0), XORB_MASK, PWRCOM, { RT, RA } },
3607{ "addzeo.", XO(31,202,1,1), XORB_MASK, PPCCOM, { RT, RA } },
3608{ "azeo.", XO(31,202,1,1), XORB_MASK, PWRCOM, { RT, RA } },
3609 5084
3610{ "mtsr", X(31,210), XRB_MASK|(1<<20), COM32, { SR, RS } }, 5085{"lvepxl", X(31,263), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
3611 5086
3612{ "stdcx.", XRC(31,214,1), X_MASK, PPC64, { RS, RA0, RB } }, 5087{"ldfcmx", APU(31,263,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
5088{"doz", XO(31,264,0,0), XO_MASK, M601, 0, {RT, RA, RB}},
5089{"doz.", XO(31,264,0,1), XO_MASK, M601, 0, {RT, RA, RB}},
3613 5090
3614{ "stbx", X(31,215), X_MASK, COM, { RS, RA0, RB } }, 5091{"modud", X(31,265), X_MASK, POWER9, 0, {RT, RA, RB}},
3615 5092
3616{ "sllq", XRC(31,216,0), X_MASK, M601, { RA, RS, RB } }, 5093{"add", XO(31,266,0,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
3617{ "sllq.", XRC(31,216,1), X_MASK, M601, { RA, RS, RB } }, 5094{"cax", XO(31,266,0,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
5095{"add.", XO(31,266,0,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5096{"cax.", XO(31,266,0,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
3618 5097
3619{ "sleq", XRC(31,217,0), X_MASK, M601, { RA, RS, RB } }, 5098{"moduw", X(31,267), X_MASK, POWER9, 0, {RT, RA, RB}},
3620{ "sleq.", XRC(31,217,1), X_MASK, M601, { RA, RS, RB } },
3621 5099
3622{ "stbxe", X(31,223), X_MASK, BOOKE64, { RS, RA0, RB } }, 5100{"lxvx", X(31,268), XX1_MASK|1<<6, PPCVSX3, 0, {XT6, RA0, RB}},
5101{"lxvl", X(31,269), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
3623 5102
3624{ "icblc", X(31,230), X_MASK, PPCCHLK, { CT, RA, RB }}, 5103{"ehpriv", X(31,270), 0xffffffff, E500MC|PPCA2, 0, {0}},
3625 5104
3626{ "subfme", XO(31,232,0,0), XORB_MASK, PPCCOM, { RT, RA } }, 5105{"tlbiel", X(31,274), X_MASK|1<<20,POWER9, PPC476, {RB, RSO, RIC, PRS, X_R}},
3627{ "sfme", XO(31,232,0,0), XORB_MASK, PWRCOM, { RT, RA } }, 5106{"tlbiel", X(31,274), XRTLRA_MASK, POWER4, POWER9|PPC476, {RB, LOPT}},
3628{ "subfme.", XO(31,232,0,1), XORB_MASK, PPCCOM, { RT, RA } },
3629{ "sfme.", XO(31,232,0,1), XORB_MASK, PWRCOM, { RT, RA } },
3630{ "subfmeo", XO(31,232,1,0), XORB_MASK, PPCCOM, { RT, RA } },
3631{ "sfmeo", XO(31,232,1,0), XORB_MASK, PWRCOM, { RT, RA } },
3632{ "subfmeo.",XO(31,232,1,1), XORB_MASK, PPCCOM, { RT, RA } },
3633{ "sfmeo.", XO(31,232,1,1), XORB_MASK, PWRCOM, { RT, RA } },
3634 5107
3635{ "mulld", XO(31,233,0,0), XO_MASK, PPC64, { RT, RA, RB } }, 5108{"mfapidi", X(31,275), X_MASK, BOOKE, E500|TITAN, {RT, RA}},
3636{ "mulld.", XO(31,233,0,1), XO_MASK, PPC64, { RT, RA, RB } },
3637{ "mulldo", XO(31,233,1,0), XO_MASK, PPC64, { RT, RA, RB } },
3638{ "mulldo.", XO(31,233,1,1), XO_MASK, PPC64, { RT, RA, RB } },
3639 5109
3640{ "addme", XO(31,234,0,0), XORB_MASK, PPCCOM, { RT, RA } }, 5110{"lqarx", X(31,276), XEH_MASK, POWER8, 0, {RTQ, RAX, RBX, EH}},
3641{ "ame", XO(31,234,0,0), XORB_MASK, PWRCOM, { RT, RA } },
3642{ "addme.", XO(31,234,0,1), XORB_MASK, PPCCOM, { RT, RA } },
3643{ "ame.", XO(31,234,0,1), XORB_MASK, PWRCOM, { RT, RA } },
3644{ "addmeo", XO(31,234,1,0), XORB_MASK, PPCCOM, { RT, RA } },
3645{ "ameo", XO(31,234,1,0), XORB_MASK, PWRCOM, { RT, RA } },
3646{ "addmeo.", XO(31,234,1,1), XORB_MASK, PPCCOM, { RT, RA } },
3647{ "ameo.", XO(31,234,1,1), XORB_MASK, PWRCOM, { RT, RA } },
3648 5111
3649{ "mullw", XO(31,235,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, 5112{"lscbx", XRC(31,277,0), X_MASK, M601, 0, {RT, RA, RB}},
3650{ "muls", XO(31,235,0,0), XO_MASK, PWRCOM, { RT, RA, RB } }, 5113{"lscbx.", XRC(31,277,1), X_MASK, M601, 0, {RT, RA, RB}},
3651{ "mullw.", XO(31,235,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3652{ "muls.", XO(31,235,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3653{ "mullwo", XO(31,235,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
3654{ "mulso", XO(31,235,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
3655{ "mullwo.", XO(31,235,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3656{ "mulso.", XO(31,235,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3657 5114
3658{ "icblce", X(31,238), X_MASK, PPCCHLK64, { CT, RA, RB }}, 5115{"dcbtt", XRT(31,278,0x10), XRT_MASK, POWER7, 0, {RA0, RB}},
3659{ "mtsrin", X(31,242), XRA_MASK, PPC32, { RS, RB } }, 5116{"dcbt", X(31,278), X_MASK, POWER4, DCBT_EO, {RA0, RB, CT}},
3660{ "mtsri", X(31,242), XRA_MASK, POWER32, { RS, RB } }, 5117{"dcbt", X(31,278), X_MASK, DCBT_EO, 0, {CT, RA0, RB}},
5118{"dcbt", X(31,278), X_MASK, PPC, POWER4|DCBT_EO, {RA0, RB}},
3661 5119
3662{ "dcbtst", X(31,246), X_MASK, PPC, { CT, RA, RB } }, 5120{"lhzx", X(31,279), X_MASK, COM, 0, {RT, RA0, RB}},
3663 5121
3664{ "stbux", X(31,247), X_MASK, COM, { RS, RAS, RB } }, 5122{"cdtbcd", X(31,282), XRB_MASK, POWER6, 0, {RA, RS}},
3665
3666{ "slliq", XRC(31,248,0), X_MASK, M601, { RA, RS, SH } },
3667{ "slliq.", XRC(31,248,1), X_MASK, M601, { RA, RS, SH } },
3668
3669{ "dcbtste", X(31,253), X_MASK, BOOKE64, { CT, RA, RB } },
3670
3671{ "stbuxe", X(31,255), X_MASK, BOOKE64, { RS, RAS, RB } },
3672
3673{ "mfdcrx", X(31,259), X_MASK, BOOKE, { RS, RA } },
3674
3675{ "doz", XO(31,264,0,0), XO_MASK, M601, { RT, RA, RB } },
3676{ "doz.", XO(31,264,0,1), XO_MASK, M601, { RT, RA, RB } },
3677{ "dozo", XO(31,264,1,0), XO_MASK, M601, { RT, RA, RB } },
3678{ "dozo.", XO(31,264,1,1), XO_MASK, M601, { RT, RA, RB } },
3679
3680{ "add", XO(31,266,0,0), XO_MASK, PPCCOM, { RT, RA, RB } },
3681{ "cax", XO(31,266,0,0), XO_MASK, PWRCOM, { RT, RA, RB } },
3682{ "add.", XO(31,266,0,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3683{ "cax.", XO(31,266,0,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3684{ "addo", XO(31,266,1,0), XO_MASK, PPCCOM, { RT, RA, RB } },
3685{ "caxo", XO(31,266,1,0), XO_MASK, PWRCOM, { RT, RA, RB } },
3686{ "addo.", XO(31,266,1,1), XO_MASK, PPCCOM, { RT, RA, RB } },
3687{ "caxo.", XO(31,266,1,1), XO_MASK, PWRCOM, { RT, RA, RB } },
3688
3689{ "tlbiel", X(31,274), XRTLRA_MASK, POWER4, { RB, L } },
3690
3691{ "mfapidi", X(31,275), X_MASK, BOOKE, { RT, RA } },
3692
3693{ "lscbx", XRC(31,277,0), X_MASK, M601, { RT, RA, RB } },
3694{ "lscbx.", XRC(31,277,1), X_MASK, M601, { RT, RA, RB } },
3695
3696{ "dcbt", X(31,278), X_MASK, PPC, { CT, RA, RB } },
3697
3698{ "lhzx", X(31,279), X_MASK, COM, { RT, RA0, RB } },
3699
3700{ "eqv", XRC(31,284,0), X_MASK, COM, { RA, RS, RB } },
3701{ "eqv.", XRC(31,284,1), X_MASK, COM, { RA, RS, RB } },
3702
3703{ "dcbte", X(31,286), X_MASK, BOOKE64, { CT, RA, RB } },
3704
3705{ "lhzxe", X(31,287), X_MASK, BOOKE64, { RT, RA0, RB } },
3706
3707{ "tlbie", X(31,306), XRTLRA_MASK, PPC, { RB, L } },
3708{ "tlbi", X(31,306), XRT_MASK, POWER, { RA0, RB } },
3709
3710{ "eciwx", X(31,310), X_MASK, PPC, { RT, RA, RB } },
3711
3712{ "lhzux", X(31,311), X_MASK, COM, { RT, RAL, RB } },
3713
3714{ "xor", XRC(31,316,0), X_MASK, COM, { RA, RS, RB } },
3715{ "xor.", XRC(31,316,1), X_MASK, COM, { RA, RS, RB } },
3716
3717{ "lhzuxe", X(31,319), X_MASK, BOOKE64, { RT, RAL, RB } },
3718
3719{ "mfexisr", XSPR(31,323,64), XSPR_MASK, PPC403, { RT } },
3720{ "mfexier", XSPR(31,323,66), XSPR_MASK, PPC403, { RT } },
3721{ "mfbr0", XSPR(31,323,128), XSPR_MASK, PPC403, { RT } },
3722{ "mfbr1", XSPR(31,323,129), XSPR_MASK, PPC403, { RT } },
3723{ "mfbr2", XSPR(31,323,130), XSPR_MASK, PPC403, { RT } },
3724{ "mfbr3", XSPR(31,323,131), XSPR_MASK, PPC403, { RT } },
3725{ "mfbr4", XSPR(31,323,132), XSPR_MASK, PPC403, { RT } },
3726{ "mfbr5", XSPR(31,323,133), XSPR_MASK, PPC403, { RT } },
3727{ "mfbr6", XSPR(31,323,134), XSPR_MASK, PPC403, { RT } },
3728{ "mfbr7", XSPR(31,323,135), XSPR_MASK, PPC403, { RT } },
3729{ "mfbear", XSPR(31,323,144), XSPR_MASK, PPC403, { RT } },
3730{ "mfbesr", XSPR(31,323,145), XSPR_MASK, PPC403, { RT } },
3731{ "mfiocr", XSPR(31,323,160), XSPR_MASK, PPC403, { RT } },
3732{ "mfdmacr0", XSPR(31,323,192), XSPR_MASK, PPC403, { RT } },
3733{ "mfdmact0", XSPR(31,323,193), XSPR_MASK, PPC403, { RT } },
3734{ "mfdmada0", XSPR(31,323,194), XSPR_MASK, PPC403, { RT } },
3735{ "mfdmasa0", XSPR(31,323,195), XSPR_MASK, PPC403, { RT } },
3736{ "mfdmacc0", XSPR(31,323,196), XSPR_MASK, PPC403, { RT } },
3737{ "mfdmacr1", XSPR(31,323,200), XSPR_MASK, PPC403, { RT } },
3738{ "mfdmact1", XSPR(31,323,201), XSPR_MASK, PPC403, { RT } },
3739{ "mfdmada1", XSPR(31,323,202), XSPR_MASK, PPC403, { RT } },
3740{ "mfdmasa1", XSPR(31,323,203), XSPR_MASK, PPC403, { RT } },
3741{ "mfdmacc1", XSPR(31,323,204), XSPR_MASK, PPC403, { RT } },
3742{ "mfdmacr2", XSPR(31,323,208), XSPR_MASK, PPC403, { RT } },
3743{ "mfdmact2", XSPR(31,323,209), XSPR_MASK, PPC403, { RT } },
3744{ "mfdmada2", XSPR(31,323,210), XSPR_MASK, PPC403, { RT } },
3745{ "mfdmasa2", XSPR(31,323,211), XSPR_MASK, PPC403, { RT } },
3746{ "mfdmacc2", XSPR(31,323,212), XSPR_MASK, PPC403, { RT } },
3747{ "mfdmacr3", XSPR(31,323,216), XSPR_MASK, PPC403, { RT } },
3748{ "mfdmact3", XSPR(31,323,217), XSPR_MASK, PPC403, { RT } },
3749{ "mfdmada3", XSPR(31,323,218), XSPR_MASK, PPC403, { RT } },
3750{ "mfdmasa3", XSPR(31,323,219), XSPR_MASK, PPC403, { RT } },
3751{ "mfdmacc3", XSPR(31,323,220), XSPR_MASK, PPC403, { RT } },
3752{ "mfdmasr", XSPR(31,323,224), XSPR_MASK, PPC403, { RT } },
3753{ "mfdcr", X(31,323), X_MASK, PPC403 | BOOKE, { RT, SPR } },
3754
3755{ "div", XO(31,331,0,0), XO_MASK, M601, { RT, RA, RB } },
3756{ "div.", XO(31,331,0,1), XO_MASK, M601, { RT, RA, RB } },
3757{ "divo", XO(31,331,1,0), XO_MASK, M601, { RT, RA, RB } },
3758{ "divo.", XO(31,331,1,1), XO_MASK, M601, { RT, RA, RB } },
3759
3760{ "mfpmr", X(31,334), X_MASK, PPCPMR, { RT, PMR }},
3761
3762{ "mfmq", XSPR(31,339,0), XSPR_MASK, M601, { RT } },
3763{ "mfxer", XSPR(31,339,1), XSPR_MASK, COM, { RT } },
3764{ "mfrtcu", XSPR(31,339,4), XSPR_MASK, COM, { RT } },
3765{ "mfrtcl", XSPR(31,339,5), XSPR_MASK, COM, { RT } },
3766{ "mfdec", XSPR(31,339,6), XSPR_MASK, MFDEC1, { RT } },
3767{ "mfdec", XSPR(31,339,22), XSPR_MASK, MFDEC2, { RT } },
3768{ "mflr", XSPR(31,339,8), XSPR_MASK, COM, { RT } },
3769{ "mfctr", XSPR(31,339,9), XSPR_MASK, COM, { RT } },
3770{ "mftid", XSPR(31,339,17), XSPR_MASK, POWER, { RT } },
3771{ "mfdsisr", XSPR(31,339,18), XSPR_MASK, COM, { RT } },
3772{ "mfdar", XSPR(31,339,19), XSPR_MASK, COM, { RT } },
3773{ "mfsdr0", XSPR(31,339,24), XSPR_MASK, POWER, { RT } },
3774{ "mfsdr1", XSPR(31,339,25), XSPR_MASK, COM, { RT } },
3775{ "mfsrr0", XSPR(31,339,26), XSPR_MASK, COM, { RT } },
3776{ "mfsrr1", XSPR(31,339,27), XSPR_MASK, COM, { RT } },
3777{ "mfcfar", XSPR(31,339,28), XSPR_MASK, POWER6, { RT } },
3778{ "mfpid", XSPR(31,339,48), XSPR_MASK, BOOKE, { RT } },
3779{ "mfpid", XSPR(31,339,945), XSPR_MASK, PPC403, { RT } },
3780{ "mfcsrr0", XSPR(31,339,58), XSPR_MASK, BOOKE, { RT } },
3781{ "mfcsrr1", XSPR(31,339,59), XSPR_MASK, BOOKE, { RT } },
3782{ "mfdear", XSPR(31,339,61), XSPR_MASK, BOOKE, { RT } },
3783{ "mfdear", XSPR(31,339,981), XSPR_MASK, PPC403, { RT } },
3784{ "mfesr", XSPR(31,339,62), XSPR_MASK, BOOKE, { RT } },
3785{ "mfesr", XSPR(31,339,980), XSPR_MASK, PPC403, { RT } },
3786{ "mfivpr", XSPR(31,339,63), XSPR_MASK, BOOKE, { RT } },
3787{ "mfcmpa", XSPR(31,339,144), XSPR_MASK, PPC860, { RT } },
3788{ "mfcmpb", XSPR(31,339,145), XSPR_MASK, PPC860, { RT } },
3789{ "mfcmpc", XSPR(31,339,146), XSPR_MASK, PPC860, { RT } },
3790{ "mfcmpd", XSPR(31,339,147), XSPR_MASK, PPC860, { RT } },
3791{ "mficr", XSPR(31,339,148), XSPR_MASK, PPC860, { RT } },
3792{ "mfder", XSPR(31,339,149), XSPR_MASK, PPC860, { RT } },
3793{ "mfcounta", XSPR(31,339,150), XSPR_MASK, PPC860, { RT } },
3794{ "mfcountb", XSPR(31,339,151), XSPR_MASK, PPC860, { RT } },
3795{ "mfcmpe", XSPR(31,339,152), XSPR_MASK, PPC860, { RT } },
3796{ "mfcmpf", XSPR(31,339,153), XSPR_MASK, PPC860, { RT } },
3797{ "mfcmpg", XSPR(31,339,154), XSPR_MASK, PPC860, { RT } },
3798{ "mfcmph", XSPR(31,339,155), XSPR_MASK, PPC860, { RT } },
3799{ "mflctrl1", XSPR(31,339,156), XSPR_MASK, PPC860, { RT } },
3800{ "mflctrl2", XSPR(31,339,157), XSPR_MASK, PPC860, { RT } },
3801{ "mfictrl", XSPR(31,339,158), XSPR_MASK, PPC860, { RT } },
3802{ "mfbar", XSPR(31,339,159), XSPR_MASK, PPC860, { RT } },
3803{ "mfvrsave", XSPR(31,339,256), XSPR_MASK, PPCVEC, { RT } },
3804{ "mfusprg0", XSPR(31,339,256), XSPR_MASK, BOOKE, { RT } },
3805{ "mftb", X(31,371), X_MASK, CLASSIC, { RT, TBR } },
3806{ "mftb", XSPR(31,339,268), XSPR_MASK, BOOKE, { RT } },
3807{ "mftbl", XSPR(31,371,268), XSPR_MASK, CLASSIC, { RT } },
3808{ "mftbl", XSPR(31,339,268), XSPR_MASK, BOOKE, { RT } },
3809{ "mftbu", XSPR(31,371,269), XSPR_MASK, CLASSIC, { RT } },
3810{ "mftbu", XSPR(31,339,269), XSPR_MASK, BOOKE, { RT } },
3811{ "mfsprg", XSPR(31,339,256), XSPRG_MASK, PPC, { RT, SPRG } },
3812{ "mfsprg0", XSPR(31,339,272), XSPR_MASK, PPC, { RT } },
3813{ "mfsprg1", XSPR(31,339,273), XSPR_MASK, PPC, { RT } },
3814{ "mfsprg2", XSPR(31,339,274), XSPR_MASK, PPC, { RT } },
3815{ "mfsprg3", XSPR(31,339,275), XSPR_MASK, PPC, { RT } },
3816{ "mfsprg4", XSPR(31,339,260), XSPR_MASK, PPC405 | BOOKE, { RT } },
3817{ "mfsprg5", XSPR(31,339,261), XSPR_MASK, PPC405 | BOOKE, { RT } },
3818{ "mfsprg6", XSPR(31,339,262), XSPR_MASK, PPC405 | BOOKE, { RT } },
3819{ "mfsprg7", XSPR(31,339,263), XSPR_MASK, PPC405 | BOOKE, { RT } },
3820{ "mfasr", XSPR(31,339,280), XSPR_MASK, PPC64, { RT } },
3821{ "mfear", XSPR(31,339,282), XSPR_MASK, PPC, { RT } },
3822{ "mfpir", XSPR(31,339,286), XSPR_MASK, BOOKE, { RT } },
3823{ "mfpvr", XSPR(31,339,287), XSPR_MASK, PPC, { RT } },
3824{ "mfdbsr", XSPR(31,339,304), XSPR_MASK, BOOKE, { RT } },
3825{ "mfdbsr", XSPR(31,339,1008), XSPR_MASK, PPC403, { RT } },
3826{ "mfdbcr0", XSPR(31,339,308), XSPR_MASK, BOOKE, { RT } },
3827{ "mfdbcr0", XSPR(31,339,1010), XSPR_MASK, PPC405, { RT } },
3828{ "mfdbcr1", XSPR(31,339,309), XSPR_MASK, BOOKE, { RT } },
3829{ "mfdbcr1", XSPR(31,339,957), XSPR_MASK, PPC405, { RT } },
3830{ "mfdbcr2", XSPR(31,339,310), XSPR_MASK, BOOKE, { RT } },
3831{ "mfiac1", XSPR(31,339,312), XSPR_MASK, BOOKE, { RT } },
3832{ "mfiac1", XSPR(31,339,1012), XSPR_MASK, PPC403, { RT } },
3833{ "mfiac2", XSPR(31,339,313), XSPR_MASK, BOOKE, { RT } },
3834{ "mfiac2", XSPR(31,339,1013), XSPR_MASK, PPC403, { RT } },
3835{ "mfiac3", XSPR(31,339,314), XSPR_MASK, BOOKE, { RT } },
3836{ "mfiac3", XSPR(31,339,948), XSPR_MASK, PPC405, { RT } },
3837{ "mfiac4", XSPR(31,339,315), XSPR_MASK, BOOKE, { RT } },
3838{ "mfiac4", XSPR(31,339,949), XSPR_MASK, PPC405, { RT } },
3839{ "mfdac1", XSPR(31,339,316), XSPR_MASK, BOOKE, { RT } },
3840{ "mfdac1", XSPR(31,339,1014), XSPR_MASK, PPC403, { RT } },
3841{ "mfdac2", XSPR(31,339,317), XSPR_MASK, BOOKE, { RT } },
3842{ "mfdac2", XSPR(31,339,1015), XSPR_MASK, PPC403, { RT } },
3843{ "mfdvc1", XSPR(31,339,318), XSPR_MASK, BOOKE, { RT } },
3844{ "mfdvc1", XSPR(31,339,950), XSPR_MASK, PPC405, { RT } },
3845{ "mfdvc2", XSPR(31,339,319), XSPR_MASK, BOOKE, { RT } },
3846{ "mfdvc2", XSPR(31,339,951), XSPR_MASK, PPC405, { RT } },
3847{ "mftsr", XSPR(31,339,336), XSPR_MASK, BOOKE, { RT } },
3848{ "mftsr", XSPR(31,339,984), XSPR_MASK, PPC403, { RT } },
3849{ "mftcr", XSPR(31,339,340), XSPR_MASK, BOOKE, { RT } },
3850{ "mftcr", XSPR(31,339,986), XSPR_MASK, PPC403, { RT } },
3851{ "mfivor0", XSPR(31,339,400), XSPR_MASK, BOOKE, { RT } },
3852{ "mfivor1", XSPR(31,339,401), XSPR_MASK, BOOKE, { RT } },
3853{ "mfivor2", XSPR(31,339,402), XSPR_MASK, BOOKE, { RT } },
3854{ "mfivor3", XSPR(31,339,403), XSPR_MASK, BOOKE, { RT } },
3855{ "mfivor4", XSPR(31,339,404), XSPR_MASK, BOOKE, { RT } },
3856{ "mfivor5", XSPR(31,339,405), XSPR_MASK, BOOKE, { RT } },
3857{ "mfivor6", XSPR(31,339,406), XSPR_MASK, BOOKE, { RT } },
3858{ "mfivor7", XSPR(31,339,407), XSPR_MASK, BOOKE, { RT } },
3859{ "mfivor8", XSPR(31,339,408), XSPR_MASK, BOOKE, { RT } },
3860{ "mfivor9", XSPR(31,339,409), XSPR_MASK, BOOKE, { RT } },
3861{ "mfivor10", XSPR(31,339,410), XSPR_MASK, BOOKE, { RT } },
3862{ "mfivor11", XSPR(31,339,411), XSPR_MASK, BOOKE, { RT } },
3863{ "mfivor12", XSPR(31,339,412), XSPR_MASK, BOOKE, { RT } },
3864{ "mfivor13", XSPR(31,339,413), XSPR_MASK, BOOKE, { RT } },
3865{ "mfivor14", XSPR(31,339,414), XSPR_MASK, BOOKE, { RT } },
3866{ "mfivor15", XSPR(31,339,415), XSPR_MASK, BOOKE, { RT } },
3867{ "mfspefscr", XSPR(31,339,512), XSPR_MASK, PPCSPE, { RT } },
3868{ "mfbbear", XSPR(31,339,513), XSPR_MASK, PPCBRLK, { RT } },
3869{ "mfbbtar", XSPR(31,339,514), XSPR_MASK, PPCBRLK, { RT } },
3870{ "mfivor32", XSPR(31,339,528), XSPR_MASK, PPCSPE, { RT } },
3871{ "mfivor33", XSPR(31,339,529), XSPR_MASK, PPCSPE, { RT } },
3872{ "mfivor34", XSPR(31,339,530), XSPR_MASK, PPCSPE, { RT } },
3873{ "mfivor35", XSPR(31,339,531), XSPR_MASK, PPCPMR, { RT } },
3874{ "mfibatu", XSPR(31,339,528), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
3875{ "mfibatl", XSPR(31,339,529), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
3876{ "mfdbatu", XSPR(31,339,536), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
3877{ "mfdbatl", XSPR(31,339,537), XSPRBAT_MASK, PPC, { RT, SPRBAT } },
3878{ "mfic_cst", XSPR(31,339,560), XSPR_MASK, PPC860, { RT } },
3879{ "mfic_adr", XSPR(31,339,561), XSPR_MASK, PPC860, { RT } },
3880{ "mfic_dat", XSPR(31,339,562), XSPR_MASK, PPC860, { RT } },
3881{ "mfdc_cst", XSPR(31,339,568), XSPR_MASK, PPC860, { RT } },
3882{ "mfdc_adr", XSPR(31,339,569), XSPR_MASK, PPC860, { RT } },
3883{ "mfmcsrr0", XSPR(31,339,570), XSPR_MASK, PPCRFMCI, { RT } },
3884{ "mfdc_dat", XSPR(31,339,570), XSPR_MASK, PPC860, { RT } },
3885{ "mfmcsrr1", XSPR(31,339,571), XSPR_MASK, PPCRFMCI, { RT } },
3886{ "mfmcsr", XSPR(31,339,572), XSPR_MASK, PPCRFMCI, { RT } },
3887{ "mfmcar", XSPR(31,339,573), XSPR_MASK, PPCRFMCI, { RT } },
3888{ "mfdpdr", XSPR(31,339,630), XSPR_MASK, PPC860, { RT } },
3889{ "mfdpir", XSPR(31,339,631), XSPR_MASK, PPC860, { RT } },
3890{ "mfimmr", XSPR(31,339,638), XSPR_MASK, PPC860, { RT } },
3891{ "mfmi_ctr", XSPR(31,339,784), XSPR_MASK, PPC860, { RT } },
3892{ "mfmi_ap", XSPR(31,339,786), XSPR_MASK, PPC860, { RT } },
3893{ "mfmi_epn", XSPR(31,339,787), XSPR_MASK, PPC860, { RT } },
3894{ "mfmi_twc", XSPR(31,339,789), XSPR_MASK, PPC860, { RT } },
3895{ "mfmi_rpn", XSPR(31,339,790), XSPR_MASK, PPC860, { RT } },
3896{ "mfmd_ctr", XSPR(31,339,792), XSPR_MASK, PPC860, { RT } },
3897{ "mfm_casid", XSPR(31,339,793), XSPR_MASK, PPC860, { RT } },
3898{ "mfmd_ap", XSPR(31,339,794), XSPR_MASK, PPC860, { RT } },
3899{ "mfmd_epn", XSPR(31,339,795), XSPR_MASK, PPC860, { RT } },
3900{ "mfmd_twb", XSPR(31,339,796), XSPR_MASK, PPC860, { RT } },
3901{ "mfmd_twc", XSPR(31,339,797), XSPR_MASK, PPC860, { RT } },
3902{ "mfmd_rpn", XSPR(31,339,798), XSPR_MASK, PPC860, { RT } },
3903{ "mfm_tw", XSPR(31,339,799), XSPR_MASK, PPC860, { RT } },
3904{ "mfmi_dbcam", XSPR(31,339,816), XSPR_MASK, PPC860, { RT } },
3905{ "mfmi_dbram0",XSPR(31,339,817), XSPR_MASK, PPC860, { RT } },
3906{ "mfmi_dbram1",XSPR(31,339,818), XSPR_MASK, PPC860, { RT } },
3907{ "mfmd_dbcam", XSPR(31,339,824), XSPR_MASK, PPC860, { RT } },
3908{ "mfmd_dbram0",XSPR(31,339,825), XSPR_MASK, PPC860, { RT } },
3909{ "mfmd_dbram1",XSPR(31,339,826), XSPR_MASK, PPC860, { RT } },
3910{ "mfummcr0", XSPR(31,339,936), XSPR_MASK, PPC750, { RT } },
3911{ "mfupmc1", XSPR(31,339,937), XSPR_MASK, PPC750, { RT } },
3912{ "mfupmc2", XSPR(31,339,938), XSPR_MASK, PPC750, { RT } },
3913{ "mfusia", XSPR(31,339,939), XSPR_MASK, PPC750, { RT } },
3914{ "mfummcr1", XSPR(31,339,940), XSPR_MASK, PPC750, { RT } },
3915{ "mfupmc3", XSPR(31,339,941), XSPR_MASK, PPC750, { RT } },
3916{ "mfupmc4", XSPR(31,339,942), XSPR_MASK, PPC750, { RT } },
3917{ "mfzpr", XSPR(31,339,944), XSPR_MASK, PPC403, { RT } },
3918{ "mfccr0", XSPR(31,339,947), XSPR_MASK, PPC405, { RT } },
3919{ "mfmmcr0", XSPR(31,339,952), XSPR_MASK, PPC750, { RT } },
3920{ "mfpmc1", XSPR(31,339,953), XSPR_MASK, PPC750, { RT } },
3921{ "mfsgr", XSPR(31,339,953), XSPR_MASK, PPC403, { RT } },
3922{ "mfpmc2", XSPR(31,339,954), XSPR_MASK, PPC750, { RT } },
3923{ "mfdcwr", XSPR(31,339,954), XSPR_MASK, PPC403, { RT } },
3924{ "mfsia", XSPR(31,339,955), XSPR_MASK, PPC750, { RT } },
3925{ "mfsler", XSPR(31,339,955), XSPR_MASK, PPC405, { RT } },
3926{ "mfmmcr1", XSPR(31,339,956), XSPR_MASK, PPC750, { RT } },
3927{ "mfsu0r", XSPR(31,339,956), XSPR_MASK, PPC405, { RT } },
3928{ "mfpmc3", XSPR(31,339,957), XSPR_MASK, PPC750, { RT } },
3929{ "mfpmc4", XSPR(31,339,958), XSPR_MASK, PPC750, { RT } },
3930{ "mficdbdr", XSPR(31,339,979), XSPR_MASK, PPC403, { RT } },
3931{ "mfevpr", XSPR(31,339,982), XSPR_MASK, PPC403, { RT } },
3932{ "mfcdbcr", XSPR(31,339,983), XSPR_MASK, PPC403, { RT } },
3933{ "mfpit", XSPR(31,339,987), XSPR_MASK, PPC403, { RT } },
3934{ "mftbhi", XSPR(31,339,988), XSPR_MASK, PPC403, { RT } },
3935{ "mftblo", XSPR(31,339,989), XSPR_MASK, PPC403, { RT } },
3936{ "mfsrr2", XSPR(31,339,990), XSPR_MASK, PPC403, { RT } },
3937{ "mfsrr3", XSPR(31,339,991), XSPR_MASK, PPC403, { RT } },
3938{ "mfl2cr", XSPR(31,339,1017), XSPR_MASK, PPC750, { RT } },
3939{ "mfdccr", XSPR(31,339,1018), XSPR_MASK, PPC403, { RT } },
3940{ "mficcr", XSPR(31,339,1019), XSPR_MASK, PPC403, { RT } },
3941{ "mfictc", XSPR(31,339,1019), XSPR_MASK, PPC750, { RT } },
3942{ "mfpbl1", XSPR(31,339,1020), XSPR_MASK, PPC403, { RT } },
3943{ "mfthrm1", XSPR(31,339,1020), XSPR_MASK, PPC750, { RT } },
3944{ "mfpbu1", XSPR(31,339,1021), XSPR_MASK, PPC403, { RT } },
3945{ "mfthrm2", XSPR(31,339,1021), XSPR_MASK, PPC750, { RT } },
3946{ "mfpbl2", XSPR(31,339,1022), XSPR_MASK, PPC403, { RT } },
3947{ "mfthrm3", XSPR(31,339,1022), XSPR_MASK, PPC750, { RT } },
3948{ "mfpbu2", XSPR(31,339,1023), XSPR_MASK, PPC403, { RT } },
3949{ "mfspr", X(31,339), X_MASK, COM, { RT, SPR } },
3950
3951{ "lwax", X(31,341), X_MASK, PPC64, { RT, RA0, RB } },
3952
3953{ "dst", XDSS(31,342,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
3954{ "dstt", XDSS(31,342,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
3955
3956{ "lhax", X(31,343), X_MASK, COM, { RT, RA0, RB } },
3957
3958{ "lhaxe", X(31,351), X_MASK, BOOKE64, { RT, RA0, RB } },
3959
3960{ "dstst", XDSS(31,374,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
3961{ "dststt", XDSS(31,374,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } },
3962
3963{ "dccci", X(31,454), XRT_MASK, PPC403|PPC440, { RA, RB } },
3964
3965{ "abs", XO(31,360,0,0), XORB_MASK, M601, { RT, RA } },
3966{ "abs.", XO(31,360,0,1), XORB_MASK, M601, { RT, RA } },
3967{ "abso", XO(31,360,1,0), XORB_MASK, M601, { RT, RA } },
3968{ "abso.", XO(31,360,1,1), XORB_MASK, M601, { RT, RA } },
3969
3970{ "divs", XO(31,363,0,0), XO_MASK, M601, { RT, RA, RB } },
3971{ "divs.", XO(31,363,0,1), XO_MASK, M601, { RT, RA, RB } },
3972{ "divso", XO(31,363,1,0), XO_MASK, M601, { RT, RA, RB } },
3973{ "divso.", XO(31,363,1,1), XO_MASK, M601, { RT, RA, RB } },
3974
3975{ "tlbia", X(31,370), 0xffffffff, PPC, { 0 } },
3976
3977{ "lwaux", X(31,373), X_MASK, PPC64, { RT, RAL, RB } },
3978
3979{ "lhaux", X(31,375), X_MASK, COM, { RT, RAL, RB } },
3980
3981{ "lhauxe", X(31,383), X_MASK, BOOKE64, { RT, RAL, RB } },
3982
3983{ "mtdcrx", X(31,387), X_MASK, BOOKE, { RA, RS } },
3984
3985{ "dcblc", X(31,390), X_MASK, PPCCHLK, { CT, RA, RB }},
3986
3987{ "subfe64", XO(31,392,0,0), XO_MASK, BOOKE64, { RT, RA, RB } },
3988{ "subfe64o",XO(31,392,1,0), XO_MASK, BOOKE64, { RT, RA, RB } },
3989
3990{ "adde64", XO(31,394,0,0), XO_MASK, BOOKE64, { RT, RA, RB } },
3991{ "adde64o", XO(31,394,1,0), XO_MASK, BOOKE64, { RT, RA, RB } },
3992
3993{ "dcblce", X(31,398), X_MASK, PPCCHLK64, { CT, RA, RB }},
3994
3995{ "slbmte", X(31,402), XRA_MASK, PPC64, { RS, RB } },
3996
3997{ "sthx", X(31,407), X_MASK, COM, { RS, RA0, RB } },
3998
3999{ "cmpb", X(31,508), X_MASK, POWER6, { RA, RS, RB } },
4000
4001{ "lfqx", X(31,791), X_MASK, POWER2, { FRT, RA, RB } },
4002
4003{ "lfdpx", X(31,791), X_MASK, POWER6, { FRT, RA, RB } },
4004
4005{ "lfqux", X(31,823), X_MASK, POWER2, { FRT, RA, RB } },
4006
4007{ "stfqx", X(31,919), X_MASK, POWER2, { FRS, RA, RB } },
4008
4009{ "stfdpx", X(31,919), X_MASK, POWER6, { FRS, RA, RB } },
4010
4011{ "stfqux", X(31,951), X_MASK, POWER2, { FRS, RA, RB } },
4012
4013{ "orc", XRC(31,412,0), X_MASK, COM, { RA, RS, RB } },
4014{ "orc.", XRC(31,412,1), X_MASK, COM, { RA, RS, RB } },
4015
4016{ "sradi", XS(31,413,0), XS_MASK, PPC64, { RA, RS, SH6 } },
4017{ "sradi.", XS(31,413,1), XS_MASK, PPC64, { RA, RS, SH6 } },
4018
4019{ "sthxe", X(31,415), X_MASK, BOOKE64, { RS, RA0, RB } },
4020
4021{ "slbie", X(31,434), XRTRA_MASK, PPC64, { RB } },
4022
4023{ "ecowx", X(31,438), X_MASK, PPC, { RT, RA, RB } },
4024
4025{ "sthux", X(31,439), X_MASK, COM, { RS, RAS, RB } },
4026
4027{ "sthuxe", X(31,447), X_MASK, BOOKE64, { RS, RAS, RB } },
4028
4029{ "mr", XRC(31,444,0), X_MASK, COM, { RA, RS, RBS } },
4030{ "or", XRC(31,444,0), X_MASK, COM, { RA, RS, RB } },
4031{ "mr.", XRC(31,444,1), X_MASK, COM, { RA, RS, RBS } },
4032{ "or.", XRC(31,444,1), X_MASK, COM, { RA, RS, RB } },
4033
4034{ "mtexisr", XSPR(31,451,64), XSPR_MASK, PPC403, { RS } },
4035{ "mtexier", XSPR(31,451,66), XSPR_MASK, PPC403, { RS } },
4036{ "mtbr0", XSPR(31,451,128), XSPR_MASK, PPC403, { RS } },
4037{ "mtbr1", XSPR(31,451,129), XSPR_MASK, PPC403, { RS } },
4038{ "mtbr2", XSPR(31,451,130), XSPR_MASK, PPC403, { RS } },
4039{ "mtbr3", XSPR(31,451,131), XSPR_MASK, PPC403, { RS } },
4040{ "mtbr4", XSPR(31,451,132), XSPR_MASK, PPC403, { RS } },
4041{ "mtbr5", XSPR(31,451,133), XSPR_MASK, PPC403, { RS } },
4042{ "mtbr6", XSPR(31,451,134), XSPR_MASK, PPC403, { RS } },
4043{ "mtbr7", XSPR(31,451,135), XSPR_MASK, PPC403, { RS } },
4044{ "mtbear", XSPR(31,451,144), XSPR_MASK, PPC403, { RS } },
4045{ "mtbesr", XSPR(31,451,145), XSPR_MASK, PPC403, { RS } },
4046{ "mtiocr", XSPR(31,451,160), XSPR_MASK, PPC403, { RS } },
4047{ "mtdmacr0", XSPR(31,451,192), XSPR_MASK, PPC403, { RS } },
4048{ "mtdmact0", XSPR(31,451,193), XSPR_MASK, PPC403, { RS } },
4049{ "mtdmada0", XSPR(31,451,194), XSPR_MASK, PPC403, { RS } },
4050{ "mtdmasa0", XSPR(31,451,195), XSPR_MASK, PPC403, { RS } },
4051{ "mtdmacc0", XSPR(31,451,196), XSPR_MASK, PPC403, { RS } },
4052{ "mtdmacr1", XSPR(31,451,200), XSPR_MASK, PPC403, { RS } },
4053{ "mtdmact1", XSPR(31,451,201), XSPR_MASK, PPC403, { RS } },
4054{ "mtdmada1", XSPR(31,451,202), XSPR_MASK, PPC403, { RS } },
4055{ "mtdmasa1", XSPR(31,451,203), XSPR_MASK, PPC403, { RS } },
4056{ "mtdmacc1", XSPR(31,451,204), XSPR_MASK, PPC403, { RS } },
4057{ "mtdmacr2", XSPR(31,451,208), XSPR_MASK, PPC403, { RS } },
4058{ "mtdmact2", XSPR(31,451,209), XSPR_MASK, PPC403, { RS } },
4059{ "mtdmada2", XSPR(31,451,210), XSPR_MASK, PPC403, { RS } },
4060{ "mtdmasa2", XSPR(31,451,211), XSPR_MASK, PPC403, { RS } },
4061{ "mtdmacc2", XSPR(31,451,212), XSPR_MASK, PPC403, { RS } },
4062{ "mtdmacr3", XSPR(31,451,216), XSPR_MASK, PPC403, { RS } },
4063{ "mtdmact3", XSPR(31,451,217), XSPR_MASK, PPC403, { RS } },
4064{ "mtdmada3", XSPR(31,451,218), XSPR_MASK, PPC403, { RS } },
4065{ "mtdmasa3", XSPR(31,451,219), XSPR_MASK, PPC403, { RS } },
4066{ "mtdmacc3", XSPR(31,451,220), XSPR_MASK, PPC403, { RS } },
4067{ "mtdmasr", XSPR(31,451,224), XSPR_MASK, PPC403, { RS } },
4068{ "mtdcr", X(31,451), X_MASK, PPC403 | BOOKE, { SPR, RS } },
4069
4070{ "subfze64",XO(31,456,0,0), XORB_MASK, BOOKE64, { RT, RA } },
4071{ "subfze64o",XO(31,456,1,0), XORB_MASK, BOOKE64, { RT, RA } },
4072
4073{ "divdu", XO(31,457,0,0), XO_MASK, PPC64, { RT, RA, RB } },
4074{ "divdu.", XO(31,457,0,1), XO_MASK, PPC64, { RT, RA, RB } },
4075{ "divduo", XO(31,457,1,0), XO_MASK, PPC64, { RT, RA, RB } },
4076{ "divduo.", XO(31,457,1,1), XO_MASK, PPC64, { RT, RA, RB } },
4077
4078{ "addze64", XO(31,458,0,0), XORB_MASK, BOOKE64, { RT, RA } },
4079{ "addze64o",XO(31,458,1,0), XORB_MASK, BOOKE64, { RT, RA } },
4080
4081{ "divwu", XO(31,459,0,0), XO_MASK, PPC, { RT, RA, RB } },
4082{ "divwu.", XO(31,459,0,1), XO_MASK, PPC, { RT, RA, RB } },
4083{ "divwuo", XO(31,459,1,0), XO_MASK, PPC, { RT, RA, RB } },
4084{ "divwuo.", XO(31,459,1,1), XO_MASK, PPC, { RT, RA, RB } },
4085
4086{ "mtmq", XSPR(31,467,0), XSPR_MASK, M601, { RS } },
4087{ "mtxer", XSPR(31,467,1), XSPR_MASK, COM, { RS } },
4088{ "mtlr", XSPR(31,467,8), XSPR_MASK, COM, { RS } },
4089{ "mtctr", XSPR(31,467,9), XSPR_MASK, COM, { RS } },
4090{ "mttid", XSPR(31,467,17), XSPR_MASK, POWER, { RS } },
4091{ "mtdsisr", XSPR(31,467,18), XSPR_MASK, COM, { RS } },
4092{ "mtdar", XSPR(31,467,19), XSPR_MASK, COM, { RS } },
4093{ "mtrtcu", XSPR(31,467,20), XSPR_MASK, COM, { RS } },
4094{ "mtrtcl", XSPR(31,467,21), XSPR_MASK, COM, { RS } },
4095{ "mtdec", XSPR(31,467,22), XSPR_MASK, COM, { RS } },
4096{ "mtsdr0", XSPR(31,467,24), XSPR_MASK, POWER, { RS } },
4097{ "mtsdr1", XSPR(31,467,25), XSPR_MASK, COM, { RS } },
4098{ "mtsrr0", XSPR(31,467,26), XSPR_MASK, COM, { RS } },
4099{ "mtsrr1", XSPR(31,467,27), XSPR_MASK, COM, { RS } },
4100{ "mtcfar", XSPR(31,467,28), XSPR_MASK, POWER6, { RS } },
4101{ "mtpid", XSPR(31,467,48), XSPR_MASK, BOOKE, { RS } },
4102{ "mtpid", XSPR(31,467,945), XSPR_MASK, PPC403, { RS } },
4103{ "mtdecar", XSPR(31,467,54), XSPR_MASK, BOOKE, { RS } },
4104{ "mtcsrr0", XSPR(31,467,58), XSPR_MASK, BOOKE, { RS } },
4105{ "mtcsrr1", XSPR(31,467,59), XSPR_MASK, BOOKE, { RS } },
4106{ "mtdear", XSPR(31,467,61), XSPR_MASK, BOOKE, { RS } },
4107{ "mtdear", XSPR(31,467,981), XSPR_MASK, PPC403, { RS } },
4108{ "mtesr", XSPR(31,467,62), XSPR_MASK, BOOKE, { RS } },
4109{ "mtesr", XSPR(31,467,980), XSPR_MASK, PPC403, { RS } },
4110{ "mtivpr", XSPR(31,467,63), XSPR_MASK, BOOKE, { RS } },
4111{ "mtcmpa", XSPR(31,467,144), XSPR_MASK, PPC860, { RS } },
4112{ "mtcmpb", XSPR(31,467,145), XSPR_MASK, PPC860, { RS } },
4113{ "mtcmpc", XSPR(31,467,146), XSPR_MASK, PPC860, { RS } },
4114{ "mtcmpd", XSPR(31,467,147), XSPR_MASK, PPC860, { RS } },
4115{ "mticr", XSPR(31,467,148), XSPR_MASK, PPC860, { RS } },
4116{ "mtder", XSPR(31,467,149), XSPR_MASK, PPC860, { RS } },
4117{ "mtcounta", XSPR(31,467,150), XSPR_MASK, PPC860, { RS } },
4118{ "mtcountb", XSPR(31,467,151), XSPR_MASK, PPC860, { RS } },
4119{ "mtcmpe", XSPR(31,467,152), XSPR_MASK, PPC860, { RS } },
4120{ "mtcmpf", XSPR(31,467,153), XSPR_MASK, PPC860, { RS } },
4121{ "mtcmpg", XSPR(31,467,154), XSPR_MASK, PPC860, { RS } },
4122{ "mtcmph", XSPR(31,467,155), XSPR_MASK, PPC860, { RS } },
4123{ "mtlctrl1", XSPR(31,467,156), XSPR_MASK, PPC860, { RS } },
4124{ "mtlctrl2", XSPR(31,467,157), XSPR_MASK, PPC860, { RS } },
4125{ "mtictrl", XSPR(31,467,158), XSPR_MASK, PPC860, { RS } },
4126{ "mtbar", XSPR(31,467,159), XSPR_MASK, PPC860, { RS } },
4127{ "mtvrsave", XSPR(31,467,256), XSPR_MASK, PPCVEC, { RS } },
4128{ "mtusprg0", XSPR(31,467,256), XSPR_MASK, BOOKE, { RS } },
4129{ "mtsprg", XSPR(31,467,256), XSPRG_MASK,PPC, { SPRG, RS } },
4130{ "mtsprg0", XSPR(31,467,272), XSPR_MASK, PPC, { RS } },
4131{ "mtsprg1", XSPR(31,467,273), XSPR_MASK, PPC, { RS } },
4132{ "mtsprg2", XSPR(31,467,274), XSPR_MASK, PPC, { RS } },
4133{ "mtsprg3", XSPR(31,467,275), XSPR_MASK, PPC, { RS } },
4134{ "mtsprg4", XSPR(31,467,276), XSPR_MASK, PPC405 | BOOKE, { RS } },
4135{ "mtsprg5", XSPR(31,467,277), XSPR_MASK, PPC405 | BOOKE, { RS } },
4136{ "mtsprg6", XSPR(31,467,278), XSPR_MASK, PPC405 | BOOKE, { RS } },
4137{ "mtsprg7", XSPR(31,467,279), XSPR_MASK, PPC405 | BOOKE, { RS } },
4138{ "mtasr", XSPR(31,467,280), XSPR_MASK, PPC64, { RS } },
4139{ "mtear", XSPR(31,467,282), XSPR_MASK, PPC, { RS } },
4140{ "mttbl", XSPR(31,467,284), XSPR_MASK, PPC, { RS } },
4141{ "mttbu", XSPR(31,467,285), XSPR_MASK, PPC, { RS } },
4142{ "mtdbsr", XSPR(31,467,304), XSPR_MASK, BOOKE, { RS } },
4143{ "mtdbsr", XSPR(31,467,1008), XSPR_MASK, PPC403, { RS } },
4144{ "mtdbcr0", XSPR(31,467,308), XSPR_MASK, BOOKE, { RS } },
4145{ "mtdbcr0", XSPR(31,467,1010), XSPR_MASK, PPC405, { RS } },
4146{ "mtdbcr1", XSPR(31,467,309), XSPR_MASK, BOOKE, { RS } },
4147{ "mtdbcr1", XSPR(31,467,957), XSPR_MASK, PPC405, { RS } },
4148{ "mtdbcr2", XSPR(31,467,310), XSPR_MASK, BOOKE, { RS } },
4149{ "mtiac1", XSPR(31,467,312), XSPR_MASK, BOOKE, { RS } },
4150{ "mtiac1", XSPR(31,467,1012), XSPR_MASK, PPC403, { RS } },
4151{ "mtiac2", XSPR(31,467,313), XSPR_MASK, BOOKE, { RS } },
4152{ "mtiac2", XSPR(31,467,1013), XSPR_MASK, PPC403, { RS } },
4153{ "mtiac3", XSPR(31,467,314), XSPR_MASK, BOOKE, { RS } },
4154{ "mtiac3", XSPR(31,467,948), XSPR_MASK, PPC405, { RS } },
4155{ "mtiac4", XSPR(31,467,315), XSPR_MASK, BOOKE, { RS } },
4156{ "mtiac4", XSPR(31,467,949), XSPR_MASK, PPC405, { RS } },
4157{ "mtdac1", XSPR(31,467,316), XSPR_MASK, BOOKE, { RS } },
4158{ "mtdac1", XSPR(31,467,1014), XSPR_MASK, PPC403, { RS } },
4159{ "mtdac2", XSPR(31,467,317), XSPR_MASK, BOOKE, { RS } },
4160{ "mtdac2", XSPR(31,467,1015), XSPR_MASK, PPC403, { RS } },
4161{ "mtdvc1", XSPR(31,467,318), XSPR_MASK, BOOKE, { RS } },
4162{ "mtdvc1", XSPR(31,467,950), XSPR_MASK, PPC405, { RS } },
4163{ "mtdvc2", XSPR(31,467,319), XSPR_MASK, BOOKE, { RS } },
4164{ "mtdvc2", XSPR(31,467,951), XSPR_MASK, PPC405, { RS } },
4165{ "mttsr", XSPR(31,467,336), XSPR_MASK, BOOKE, { RS } },
4166{ "mttsr", XSPR(31,467,984), XSPR_MASK, PPC403, { RS } },
4167{ "mttcr", XSPR(31,467,340), XSPR_MASK, BOOKE, { RS } },
4168{ "mttcr", XSPR(31,467,986), XSPR_MASK, PPC403, { RS } },
4169{ "mtivor0", XSPR(31,467,400), XSPR_MASK, BOOKE, { RS } },
4170{ "mtivor1", XSPR(31,467,401), XSPR_MASK, BOOKE, { RS } },
4171{ "mtivor2", XSPR(31,467,402), XSPR_MASK, BOOKE, { RS } },
4172{ "mtivor3", XSPR(31,467,403), XSPR_MASK, BOOKE, { RS } },
4173{ "mtivor4", XSPR(31,467,404), XSPR_MASK, BOOKE, { RS } },
4174{ "mtivor5", XSPR(31,467,405), XSPR_MASK, BOOKE, { RS } },
4175{ "mtivor6", XSPR(31,467,406), XSPR_MASK, BOOKE, { RS } },
4176{ "mtivor7", XSPR(31,467,407), XSPR_MASK, BOOKE, { RS } },
4177{ "mtivor8", XSPR(31,467,408), XSPR_MASK, BOOKE, { RS } },
4178{ "mtivor9", XSPR(31,467,409), XSPR_MASK, BOOKE, { RS } },
4179{ "mtivor10", XSPR(31,467,410), XSPR_MASK, BOOKE, { RS } },
4180{ "mtivor11", XSPR(31,467,411), XSPR_MASK, BOOKE, { RS } },
4181{ "mtivor12", XSPR(31,467,412), XSPR_MASK, BOOKE, { RS } },
4182{ "mtivor13", XSPR(31,467,413), XSPR_MASK, BOOKE, { RS } },
4183{ "mtivor14", XSPR(31,467,414), XSPR_MASK, BOOKE, { RS } },
4184{ "mtivor15", XSPR(31,467,415), XSPR_MASK, BOOKE, { RS } },
4185{ "mtspefscr", XSPR(31,467,512), XSPR_MASK, PPCSPE, { RS } },
4186{ "mtbbear", XSPR(31,467,513), XSPR_MASK, PPCBRLK, { RS } },
4187{ "mtbbtar", XSPR(31,467,514), XSPR_MASK, PPCBRLK, { RS } },
4188{ "mtivor32", XSPR(31,467,528), XSPR_MASK, PPCSPE, { RS } },
4189{ "mtivor33", XSPR(31,467,529), XSPR_MASK, PPCSPE, { RS } },
4190{ "mtivor34", XSPR(31,467,530), XSPR_MASK, PPCSPE, { RS } },
4191{ "mtivor35", XSPR(31,467,531), XSPR_MASK, PPCPMR, { RS } },
4192{ "mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
4193{ "mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
4194{ "mtdbatu", XSPR(31,467,536), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
4195{ "mtdbatl", XSPR(31,467,537), XSPRBAT_MASK, PPC, { SPRBAT, RS } },
4196{ "mtmcsrr0", XSPR(31,467,570), XSPR_MASK, PPCRFMCI, { RS } },
4197{ "mtmcsrr1", XSPR(31,467,571), XSPR_MASK, PPCRFMCI, { RS } },
4198{ "mtmcsr", XSPR(31,467,572), XSPR_MASK, PPCRFMCI, { RS } },
4199{ "mtummcr0", XSPR(31,467,936), XSPR_MASK, PPC750, { RS } },
4200{ "mtupmc1", XSPR(31,467,937), XSPR_MASK, PPC750, { RS } },
4201{ "mtupmc2", XSPR(31,467,938), XSPR_MASK, PPC750, { RS } },
4202{ "mtusia", XSPR(31,467,939), XSPR_MASK, PPC750, { RS } },
4203{ "mtummcr1", XSPR(31,467,940), XSPR_MASK, PPC750, { RS } },
4204{ "mtupmc3", XSPR(31,467,941), XSPR_MASK, PPC750, { RS } },
4205{ "mtupmc4", XSPR(31,467,942), XSPR_MASK, PPC750, { RS } },
4206{ "mtzpr", XSPR(31,467,944), XSPR_MASK, PPC403, { RS } },
4207{ "mtccr0", XSPR(31,467,947), XSPR_MASK, PPC405, { RS } },
4208{ "mtmmcr0", XSPR(31,467,952), XSPR_MASK, PPC750, { RS } },
4209{ "mtsgr", XSPR(31,467,953), XSPR_MASK, PPC403, { RS } },
4210{ "mtpmc1", XSPR(31,467,953), XSPR_MASK, PPC750, { RS } },
4211{ "mtdcwr", XSPR(31,467,954), XSPR_MASK, PPC403, { RS } },
4212{ "mtpmc2", XSPR(31,467,954), XSPR_MASK, PPC750, { RS } },
4213{ "mtsler", XSPR(31,467,955), XSPR_MASK, PPC405, { RS } },
4214{ "mtsia", XSPR(31,467,955), XSPR_MASK, PPC750, { RS } },
4215{ "mtsu0r", XSPR(31,467,956), XSPR_MASK, PPC405, { RS } },
4216{ "mtmmcr1", XSPR(31,467,956), XSPR_MASK, PPC750, { RS } },
4217{ "mtpmc3", XSPR(31,467,957), XSPR_MASK, PPC750, { RS } },
4218{ "mtpmc4", XSPR(31,467,958), XSPR_MASK, PPC750, { RS } },
4219{ "mticdbdr", XSPR(31,467,979), XSPR_MASK, PPC403, { RS } },
4220{ "mtevpr", XSPR(31,467,982), XSPR_MASK, PPC403, { RS } },
4221{ "mtcdbcr", XSPR(31,467,983), XSPR_MASK, PPC403, { RS } },
4222{ "mtpit", XSPR(31,467,987), XSPR_MASK, PPC403, { RS } },
4223{ "mttbhi", XSPR(31,467,988), XSPR_MASK, PPC403, { RS } },
4224{ "mttblo", XSPR(31,467,989), XSPR_MASK, PPC403, { RS } },
4225{ "mtsrr2", XSPR(31,467,990), XSPR_MASK, PPC403, { RS } },
4226{ "mtsrr3", XSPR(31,467,991), XSPR_MASK, PPC403, { RS } },
4227{ "mtl2cr", XSPR(31,467,1017), XSPR_MASK, PPC750, { RS } },
4228{ "mtdccr", XSPR(31,467,1018), XSPR_MASK, PPC403, { RS } },
4229{ "mticcr", XSPR(31,467,1019), XSPR_MASK, PPC403, { RS } },
4230{ "mtictc", XSPR(31,467,1019), XSPR_MASK, PPC750, { RS } },
4231{ "mtpbl1", XSPR(31,467,1020), XSPR_MASK, PPC403, { RS } },
4232{ "mtthrm1", XSPR(31,467,1020), XSPR_MASK, PPC750, { RS } },
4233{ "mtpbu1", XSPR(31,467,1021), XSPR_MASK, PPC403, { RS } },
4234{ "mtthrm2", XSPR(31,467,1021), XSPR_MASK, PPC750, { RS } },
4235{ "mtpbl2", XSPR(31,467,1022), XSPR_MASK, PPC403, { RS } },
4236{ "mtthrm3", XSPR(31,467,1022), XSPR_MASK, PPC750, { RS } },
4237{ "mtpbu2", XSPR(31,467,1023), XSPR_MASK, PPC403, { RS } },
4238{ "mtspr", X(31,467), X_MASK, COM, { SPR, RS } },
4239
4240{ "dcbi", X(31,470), XRT_MASK, PPC, { RA, RB } },
4241
4242{ "nand", XRC(31,476,0), X_MASK, COM, { RA, RS, RB } },
4243{ "nand.", XRC(31,476,1), X_MASK, COM, { RA, RS, RB } },
4244
4245{ "dcbie", X(31,478), XRT_MASK, BOOKE64, { RA, RB } },
4246
4247{ "dcread", X(31,486), X_MASK, PPC403|PPC440, { RT, RA, RB }},
4248
4249{ "mtpmr", X(31,462), X_MASK, PPCPMR, { PMR, RS }},
4250
4251{ "icbtls", X(31,486), X_MASK, PPCCHLK, { CT, RA, RB }},
4252
4253{ "nabs", XO(31,488,0,0), XORB_MASK, M601, { RT, RA } },
4254{ "subfme64",XO(31,488,0,0), XORB_MASK, BOOKE64, { RT, RA } },
4255{ "nabs.", XO(31,488,0,1), XORB_MASK, M601, { RT, RA } },
4256{ "nabso", XO(31,488,1,0), XORB_MASK, M601, { RT, RA } },
4257{ "subfme64o",XO(31,488,1,0), XORB_MASK, BOOKE64, { RT, RA } },
4258{ "nabso.", XO(31,488,1,1), XORB_MASK, M601, { RT, RA } },
4259
4260{ "divd", XO(31,489,0,0), XO_MASK, PPC64, { RT, RA, RB } },
4261{ "divd.", XO(31,489,0,1), XO_MASK, PPC64, { RT, RA, RB } },
4262{ "divdo", XO(31,489,1,0), XO_MASK, PPC64, { RT, RA, RB } },
4263{ "divdo.", XO(31,489,1,1), XO_MASK, PPC64, { RT, RA, RB } },
4264
4265{ "addme64", XO(31,490,0,0), XORB_MASK, BOOKE64, { RT, RA } },
4266{ "addme64o",XO(31,490,1,0), XORB_MASK, BOOKE64, { RT, RA } },
4267
4268{ "divw", XO(31,491,0,0), XO_MASK, PPC, { RT, RA, RB } },
4269{ "divw.", XO(31,491,0,1), XO_MASK, PPC, { RT, RA, RB } },
4270{ "divwo", XO(31,491,1,0), XO_MASK, PPC, { RT, RA, RB } },
4271{ "divwo.", XO(31,491,1,1), XO_MASK, PPC, { RT, RA, RB } },
4272 5123
4273{ "icbtlse", X(31,494), X_MASK, PPCCHLK64, { CT, RA, RB }}, 5124{"eqv", XRC(31,284,0), X_MASK, COM, 0, {RA, RS, RB}},
5125{"eqv.", XRC(31,284,1), X_MASK, COM, 0, {RA, RS, RB}},
4274 5126
4275{ "slbia", X(31,498), 0xffffffff, PPC64, { 0 } }, 5127{"lhepx", X(31,287), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
4276 5128
4277{ "cli", X(31,502), XRB_MASK, POWER, { RT, RA } }, 5129{"mfdcrux", X(31,291), X_MASK, PPC464, 0, {RS, RA}},
4278 5130
4279{ "stdcxe.", XRC(31,511,1), X_MASK, BOOKE64, { RS, RA, RB } }, 5131{"lvexhx", X(31,293), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
5132{"lvepx", X(31,295), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
4280 5133
4281{ "mcrxr", X(31,512), XRARB_MASK|(3<<21), COM, { BF } }, 5134{"lxvll", X(31,301), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
4282 5135
4283{ "bblels", X(31,518), X_MASK, PPCBRLK, { 0 }}, 5136{"mfbhrbe", X(31,302), X_MASK, POWER8, 0, {RT, BHRBE}},
4284{ "mcrxr64", X(31,544), XRARB_MASK|(3<<21), BOOKE64, { BF } }, 5137
5138{"tlbie", X(31,306), X_MASK|1<<20,POWER9, TITAN, {RB, RS, RIC, PRS, X_R}},
5139{"tlbie", X(31,306), XRA_MASK, POWER7, POWER9|TITAN, {RB, RS}},
5140{"tlbie", X(31,306), XRTLRA_MASK, PPC, E500|POWER7|TITAN, {RB, LOPT}},
5141{"tlbi", X(31,306), XRT_MASK, POWER, 0, {RA0, RB}},
5142
5143{"mfvsrld", X(31,307), XX1RB_MASK, PPCVSX3, 0, {RA, XS6}},
5144
5145{"ldmx", X(31,309), X_MASK, POWER9, 0, {RT, RA0, RB}},
5146
5147{"eciwx", X(31,310), X_MASK, PPC, E500|TITAN, {RT, RA0, RB}},
5148
5149{"lhzux", X(31,311), X_MASK, COM, 0, {RT, RAL, RB}},
5150
5151{"cbcdtd", X(31,314), XRB_MASK, POWER6, 0, {RA, RS}},
5152
5153{"xor", XRC(31,316,0), X_MASK, COM, 0, {RA, RS, RB}},
5154{"xor.", XRC(31,316,1), X_MASK, COM, 0, {RA, RS, RB}},
5155
5156{"dcbtep", XRT(31,319,0), X_MASK, E500MC|PPCA2, 0, {RT, RA0, RB}},
5157
5158{"mfexisr", XSPR(31,323, 64), XSPR_MASK, PPC403, 0, {RT}},
5159{"mfexier", XSPR(31,323, 66), XSPR_MASK, PPC403, 0, {RT}},
5160{"mfbr0", XSPR(31,323,128), XSPR_MASK, PPC403, 0, {RT}},
5161{"mfbr1", XSPR(31,323,129), XSPR_MASK, PPC403, 0, {RT}},
5162{"mfbr2", XSPR(31,323,130), XSPR_MASK, PPC403, 0, {RT}},
5163{"mfbr3", XSPR(31,323,131), XSPR_MASK, PPC403, 0, {RT}},
5164{"mfbr4", XSPR(31,323,132), XSPR_MASK, PPC403, 0, {RT}},
5165{"mfbr5", XSPR(31,323,133), XSPR_MASK, PPC403, 0, {RT}},
5166{"mfbr6", XSPR(31,323,134), XSPR_MASK, PPC403, 0, {RT}},
5167{"mfbr7", XSPR(31,323,135), XSPR_MASK, PPC403, 0, {RT}},
5168{"mfbear", XSPR(31,323,144), XSPR_MASK, PPC403, 0, {RT}},
5169{"mfbesr", XSPR(31,323,145), XSPR_MASK, PPC403, 0, {RT}},
5170{"mfiocr", XSPR(31,323,160), XSPR_MASK, PPC403, 0, {RT}},
5171{"mfdmacr0", XSPR(31,323,192), XSPR_MASK, PPC403, 0, {RT}},
5172{"mfdmact0", XSPR(31,323,193), XSPR_MASK, PPC403, 0, {RT}},
5173{"mfdmada0", XSPR(31,323,194), XSPR_MASK, PPC403, 0, {RT}},
5174{"mfdmasa0", XSPR(31,323,195), XSPR_MASK, PPC403, 0, {RT}},
5175{"mfdmacc0", XSPR(31,323,196), XSPR_MASK, PPC403, 0, {RT}},
5176{"mfdmacr1", XSPR(31,323,200), XSPR_MASK, PPC403, 0, {RT}},
5177{"mfdmact1", XSPR(31,323,201), XSPR_MASK, PPC403, 0, {RT}},
5178{"mfdmada1", XSPR(31,323,202), XSPR_MASK, PPC403, 0, {RT}},
5179{"mfdmasa1", XSPR(31,323,203), XSPR_MASK, PPC403, 0, {RT}},
5180{"mfdmacc1", XSPR(31,323,204), XSPR_MASK, PPC403, 0, {RT}},
5181{"mfdmacr2", XSPR(31,323,208), XSPR_MASK, PPC403, 0, {RT}},
5182{"mfdmact2", XSPR(31,323,209), XSPR_MASK, PPC403, 0, {RT}},
5183{"mfdmada2", XSPR(31,323,210), XSPR_MASK, PPC403, 0, {RT}},
5184{"mfdmasa2", XSPR(31,323,211), XSPR_MASK, PPC403, 0, {RT}},
5185{"mfdmacc2", XSPR(31,323,212), XSPR_MASK, PPC403, 0, {RT}},
5186{"mfdmacr3", XSPR(31,323,216), XSPR_MASK, PPC403, 0, {RT}},
5187{"mfdmact3", XSPR(31,323,217), XSPR_MASK, PPC403, 0, {RT}},
5188{"mfdmada3", XSPR(31,323,218), XSPR_MASK, PPC403, 0, {RT}},
5189{"mfdmasa3", XSPR(31,323,219), XSPR_MASK, PPC403, 0, {RT}},
5190{"mfdmacc3", XSPR(31,323,220), XSPR_MASK, PPC403, 0, {RT}},
5191{"mfdmasr", XSPR(31,323,224), XSPR_MASK, PPC403, 0, {RT}},
5192{"mfdcr", X(31,323), X_MASK, PPC403|BOOKE|PPCA2|PPC476, E500|TITAN, {RT, SPR}},
5193{"mfdcr.", XRC(31,323,1), X_MASK, PPCA2, 0, {RT, SPR}},
5194
5195{"lvexwx", X(31,325), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
5196
5197{"dcread", X(31,326), X_MASK, PPC476|TITAN, 0, {RT, RA0, RB}},
5198
5199{"div", XO(31,331,0,0), XO_MASK, M601, 0, {RT, RA, RB}},
5200{"div.", XO(31,331,0,1), XO_MASK, M601, 0, {RT, RA, RB}},
5201
5202{"lxvdsx", X(31,332), XX1_MASK, PPCVSX, 0, {XT6, RA0, RB}},
5203
5204{"mfpmr", X(31,334), X_MASK, PPCPMR|PPCE300, 0, {RT, PMR}},
5205{"mftmr", X(31,366), X_MASK, PPCTMR|E6500, 0, {RT, TMR}},
5206
5207{"slbsync", X(31,338), 0xffffffff, POWER9, 0, {0}},
5208
5209{"mfmq", XSPR(31,339, 0), XSPR_MASK, M601, 0, {RT}},
5210{"mfxer", XSPR(31,339, 1), XSPR_MASK, COM, 0, {RT}},
5211{"mfrtcu", XSPR(31,339, 4), XSPR_MASK, COM, TITAN, {RT}},
5212{"mfrtcl", XSPR(31,339, 5), XSPR_MASK, COM, TITAN, {RT}},
5213{"mfdec", XSPR(31,339, 6), XSPR_MASK, MFDEC1, 0, {RT}},
5214{"mflr", XSPR(31,339, 8), XSPR_MASK, COM, 0, {RT}},
5215{"mfctr", XSPR(31,339, 9), XSPR_MASK, COM, 0, {RT}},
5216{"mfdscr", XSPR(31,339, 17), XSPR_MASK, POWER6, 0, {RT}},
5217{"mftid", XSPR(31,339, 17), XSPR_MASK, POWER, 0, {RT}},
5218{"mfdsisr", XSPR(31,339, 18), XSPR_MASK, COM, TITAN, {RT}},
5219{"mfdar", XSPR(31,339, 19), XSPR_MASK, COM, TITAN, {RT}},
5220{"mfdec", XSPR(31,339, 22), XSPR_MASK, MFDEC2, MFDEC1, {RT}},
5221{"mfsdr0", XSPR(31,339, 24), XSPR_MASK, POWER, 0, {RT}},
5222{"mfsdr1", XSPR(31,339, 25), XSPR_MASK, COM, TITAN, {RT}},
5223{"mfsrr0", XSPR(31,339, 26), XSPR_MASK, COM, 0, {RT}},
5224{"mfsrr1", XSPR(31,339, 27), XSPR_MASK, COM, 0, {RT}},
5225{"mfcfar", XSPR(31,339, 28), XSPR_MASK, POWER6, 0, {RT}},
5226{"mfpid", XSPR(31,339, 48), XSPR_MASK, BOOKE, 0, {RT}},
5227{"mfcsrr0", XSPR(31,339, 58), XSPR_MASK, BOOKE, 0, {RT}},
5228{"mfcsrr1", XSPR(31,339, 59), XSPR_MASK, BOOKE, 0, {RT}},
5229{"mfdear", XSPR(31,339, 61), XSPR_MASK, BOOKE, 0, {RT}},
5230{"mfesr", XSPR(31,339, 62), XSPR_MASK, BOOKE, 0, {RT}},
5231{"mfivpr", XSPR(31,339, 63), XSPR_MASK, BOOKE, 0, {RT}},
5232{"mfctrl", XSPR(31,339,136), XSPR_MASK, POWER4, 0, {RT}},
5233{"mfcmpa", XSPR(31,339,144), XSPR_MASK, PPC860, 0, {RT}},
5234{"mfcmpb", XSPR(31,339,145), XSPR_MASK, PPC860, 0, {RT}},
5235{"mfcmpc", XSPR(31,339,146), XSPR_MASK, PPC860, 0, {RT}},
5236{"mfcmpd", XSPR(31,339,147), XSPR_MASK, PPC860, 0, {RT}},
5237{"mficr", XSPR(31,339,148), XSPR_MASK, PPC860, 0, {RT}},
5238{"mfder", XSPR(31,339,149), XSPR_MASK, PPC860, 0, {RT}},
5239{"mfcounta", XSPR(31,339,150), XSPR_MASK, PPC860, 0, {RT}},
5240{"mfcountb", XSPR(31,339,151), XSPR_MASK, PPC860, 0, {RT}},
5241{"mfcmpe", XSPR(31,339,152), XSPR_MASK, PPC860, 0, {RT}},
5242{"mfcmpf", XSPR(31,339,153), XSPR_MASK, PPC860, 0, {RT}},
5243{"mfcmpg", XSPR(31,339,154), XSPR_MASK, PPC860, 0, {RT}},
5244{"mfcmph", XSPR(31,339,155), XSPR_MASK, PPC860, 0, {RT}},
5245{"mflctrl1", XSPR(31,339,156), XSPR_MASK, PPC860, 0, {RT}},
5246{"mflctrl2", XSPR(31,339,157), XSPR_MASK, PPC860, 0, {RT}},
5247{"mfictrl", XSPR(31,339,158), XSPR_MASK, PPC860, 0, {RT}},
5248{"mfbar", XSPR(31,339,159), XSPR_MASK, PPC860, 0, {RT}},
5249{"mfvrsave", XSPR(31,339,256), XSPR_MASK, PPCVEC, 0, {RT}},
5250{"mfusprg0", XSPR(31,339,256), XSPR_MASK, BOOKE, 0, {RT}},
5251{"mfsprg", XSPR(31,339,256), XSPRG_MASK, PPC, 0, {RT, SPRG}},
5252{"mfsprg4", XSPR(31,339,260), XSPR_MASK, PPC405|BOOKE, 0, {RT}},
5253{"mfsprg5", XSPR(31,339,261), XSPR_MASK, PPC405|BOOKE, 0, {RT}},
5254{"mfsprg6", XSPR(31,339,262), XSPR_MASK, PPC405|BOOKE, 0, {RT}},
5255{"mfsprg7", XSPR(31,339,263), XSPR_MASK, PPC405|BOOKE, 0, {RT}},
5256{"mftbu", XSPR(31,339,269), XSPR_MASK, POWER4|BOOKE, 0, {RT}},
5257{"mftb", X(31,339), X_MASK, POWER4|BOOKE, 0, {RT, TBR}},
5258{"mftbl", XSPR(31,339,268), XSPR_MASK, POWER4|BOOKE, 0, {RT}},
5259{"mfsprg0", XSPR(31,339,272), XSPR_MASK, PPC, 0, {RT}},
5260{"mfsprg1", XSPR(31,339,273), XSPR_MASK, PPC, 0, {RT}},
5261{"mfsprg2", XSPR(31,339,274), XSPR_MASK, PPC, 0, {RT}},
5262{"mfsprg3", XSPR(31,339,275), XSPR_MASK, PPC, 0, {RT}},
5263{"mfasr", XSPR(31,339,280), XSPR_MASK, PPC64, 0, {RT}},
5264{"mfear", XSPR(31,339,282), XSPR_MASK, PPC, TITAN, {RT}},
5265{"mfpir", XSPR(31,339,286), XSPR_MASK, BOOKE, 0, {RT}},
5266{"mfpvr", XSPR(31,339,287), XSPR_MASK, PPC, 0, {RT}},
5267{"mfdbsr", XSPR(31,339,304), XSPR_MASK, BOOKE, 0, {RT}},
5268{"mfdbcr0", XSPR(31,339,308), XSPR_MASK, BOOKE, 0, {RT}},
5269{"mfdbcr1", XSPR(31,339,309), XSPR_MASK, BOOKE, 0, {RT}},
5270{"mfdbcr2", XSPR(31,339,310), XSPR_MASK, BOOKE, 0, {RT}},
5271{"mfiac1", XSPR(31,339,312), XSPR_MASK, BOOKE, 0, {RT}},
5272{"mfiac2", XSPR(31,339,313), XSPR_MASK, BOOKE, 0, {RT}},
5273{"mfiac3", XSPR(31,339,314), XSPR_MASK, BOOKE, 0, {RT}},
5274{"mfiac4", XSPR(31,339,315), XSPR_MASK, BOOKE, 0, {RT}},
5275{"mfdac1", XSPR(31,339,316), XSPR_MASK, BOOKE, 0, {RT}},
5276{"mfdac2", XSPR(31,339,317), XSPR_MASK, BOOKE, 0, {RT}},
5277{"mfdvc1", XSPR(31,339,318), XSPR_MASK, BOOKE, 0, {RT}},
5278{"mfdvc2", XSPR(31,339,319), XSPR_MASK, BOOKE, 0, {RT}},
5279{"mftsr", XSPR(31,339,336), XSPR_MASK, BOOKE, 0, {RT}},
5280{"mftcr", XSPR(31,339,340), XSPR_MASK, BOOKE, 0, {RT}},
5281{"mfivor0", XSPR(31,339,400), XSPR_MASK, BOOKE, 0, {RT}},
5282{"mfivor1", XSPR(31,339,401), XSPR_MASK, BOOKE, 0, {RT}},
5283{"mfivor2", XSPR(31,339,402), XSPR_MASK, BOOKE, 0, {RT}},
5284{"mfivor3", XSPR(31,339,403), XSPR_MASK, BOOKE, 0, {RT}},
5285{"mfivor4", XSPR(31,339,404), XSPR_MASK, BOOKE, 0, {RT}},
5286{"mfivor5", XSPR(31,339,405), XSPR_MASK, BOOKE, 0, {RT}},
5287{"mfivor6", XSPR(31,339,406), XSPR_MASK, BOOKE, 0, {RT}},
5288{"mfivor7", XSPR(31,339,407), XSPR_MASK, BOOKE, 0, {RT}},
5289{"mfivor8", XSPR(31,339,408), XSPR_MASK, BOOKE, 0, {RT}},
5290{"mfivor9", XSPR(31,339,409), XSPR_MASK, BOOKE, 0, {RT}},
5291{"mfivor10", XSPR(31,339,410), XSPR_MASK, BOOKE, 0, {RT}},
5292{"mfivor11", XSPR(31,339,411), XSPR_MASK, BOOKE, 0, {RT}},
5293{"mfivor12", XSPR(31,339,412), XSPR_MASK, BOOKE, 0, {RT}},
5294{"mfivor13", XSPR(31,339,413), XSPR_MASK, BOOKE, 0, {RT}},
5295{"mfivor14", XSPR(31,339,414), XSPR_MASK, BOOKE, 0, {RT}},
5296{"mfivor15", XSPR(31,339,415), XSPR_MASK, BOOKE, 0, {RT}},
5297{"mfspefscr", XSPR(31,339,512), XSPR_MASK, PPCSPE, 0, {RT}},
5298{"mfbbear", XSPR(31,339,513), XSPR_MASK, PPCBRLK, 0, {RT}},
5299{"mfbbtar", XSPR(31,339,514), XSPR_MASK, PPCBRLK, 0, {RT}},
5300{"mfivor32", XSPR(31,339,528), XSPR_MASK, PPCSPE, 0, {RT}},
5301{"mfibatu", XSPR(31,339,528), XSPRBAT_MASK, PPC, TITAN, {RT, SPRBAT}},
5302{"mfivor33", XSPR(31,339,529), XSPR_MASK, PPCSPE, 0, {RT}},
5303{"mfibatl", XSPR(31,339,529), XSPRBAT_MASK, PPC, TITAN, {RT, SPRBAT}},
5304{"mfivor34", XSPR(31,339,530), XSPR_MASK, PPCSPE, 0, {RT}},
5305{"mfivor35", XSPR(31,339,531), XSPR_MASK, PPCPMR, 0, {RT}},
5306{"mfdbatu", XSPR(31,339,536), XSPRBAT_MASK, PPC, TITAN, {RT, SPRBAT}},
5307{"mfdbatl", XSPR(31,339,537), XSPRBAT_MASK, PPC, TITAN, {RT, SPRBAT}},
5308{"mfic_cst", XSPR(31,339,560), XSPR_MASK, PPC860, 0, {RT}},
5309{"mfic_adr", XSPR(31,339,561), XSPR_MASK, PPC860, 0, {RT}},
5310{"mfic_dat", XSPR(31,339,562), XSPR_MASK, PPC860, 0, {RT}},
5311{"mfdc_cst", XSPR(31,339,568), XSPR_MASK, PPC860, 0, {RT}},
5312{"mfdc_adr", XSPR(31,339,569), XSPR_MASK, PPC860, 0, {RT}},
5313{"mfdc_dat", XSPR(31,339,570), XSPR_MASK, PPC860, 0, {RT}},
5314{"mfmcsrr0", XSPR(31,339,570), XSPR_MASK, PPCRFMCI, 0, {RT}},
5315{"mfmcsrr1", XSPR(31,339,571), XSPR_MASK, PPCRFMCI, 0, {RT}},
5316{"mfmcsr", XSPR(31,339,572), XSPR_MASK, PPCRFMCI, 0, {RT}},
5317{"mfmcar", XSPR(31,339,573), XSPR_MASK, PPCRFMCI, TITAN, {RT}},
5318{"mfdpdr", XSPR(31,339,630), XSPR_MASK, PPC860, 0, {RT}},
5319{"mfdpir", XSPR(31,339,631), XSPR_MASK, PPC860, 0, {RT}},
5320{"mfimmr", XSPR(31,339,638), XSPR_MASK, PPC860, 0, {RT}},
5321{"mfmi_ctr", XSPR(31,339,784), XSPR_MASK, PPC860, 0, {RT}},
5322{"mfmi_ap", XSPR(31,339,786), XSPR_MASK, PPC860, 0, {RT}},
5323{"mfmi_epn", XSPR(31,339,787), XSPR_MASK, PPC860, 0, {RT}},
5324{"mfmi_twc", XSPR(31,339,789), XSPR_MASK, PPC860, 0, {RT}},
5325{"mfmi_rpn", XSPR(31,339,790), XSPR_MASK, PPC860, 0, {RT}},
5326{"mfmd_ctr", XSPR(31,339,792), XSPR_MASK, PPC860, 0, {RT}},
5327{"mfm_casid", XSPR(31,339,793), XSPR_MASK, PPC860, 0, {RT}},
5328{"mfmd_ap", XSPR(31,339,794), XSPR_MASK, PPC860, 0, {RT}},
5329{"mfmd_epn", XSPR(31,339,795), XSPR_MASK, PPC860, 0, {RT}},
5330{"mfmd_twb", XSPR(31,339,796), XSPR_MASK, PPC860, 0, {RT}},
5331{"mfmd_twc", XSPR(31,339,797), XSPR_MASK, PPC860, 0, {RT}},
5332{"mfmd_rpn", XSPR(31,339,798), XSPR_MASK, PPC860, 0, {RT}},
5333{"mfm_tw", XSPR(31,339,799), XSPR_MASK, PPC860, 0, {RT}},
5334{"mfmi_dbcam", XSPR(31,339,816), XSPR_MASK, PPC860, 0, {RT}},
5335{"mfmi_dbram0", XSPR(31,339,817), XSPR_MASK, PPC860, 0, {RT}},
5336{"mfmi_dbram1", XSPR(31,339,818), XSPR_MASK, PPC860, 0, {RT}},
5337{"mfmd_dbcam", XSPR(31,339,824), XSPR_MASK, PPC860, 0, {RT}},
5338{"mfmd_dbram0", XSPR(31,339,825), XSPR_MASK, PPC860, 0, {RT}},
5339{"mfmd_dbram1", XSPR(31,339,826), XSPR_MASK, PPC860, 0, {RT}},
5340{"mfivndx", XSPR(31,339,880), XSPR_MASK, TITAN, 0, {RT}},
5341{"mfdvndx", XSPR(31,339,881), XSPR_MASK, TITAN, 0, {RT}},
5342{"mfivlim", XSPR(31,339,882), XSPR_MASK, TITAN, 0, {RT}},
5343{"mfdvlim", XSPR(31,339,883), XSPR_MASK, TITAN, 0, {RT}},
5344{"mfclcsr", XSPR(31,339,884), XSPR_MASK, TITAN, 0, {RT}},
5345{"mfccr1", XSPR(31,339,888), XSPR_MASK, TITAN, 0, {RT}},
5346{"mfppr", XSPR(31,339,896), XSPR_MASK, POWER7, 0, {RT}},
5347{"mfppr32", XSPR(31,339,898), XSPR_MASK, POWER7, 0, {RT}},
5348{"mfrstcfg", XSPR(31,339,923), XSPR_MASK, TITAN, 0, {RT}},
5349{"mfdcdbtrl", XSPR(31,339,924), XSPR_MASK, TITAN, 0, {RT}},
5350{"mfdcdbtrh", XSPR(31,339,925), XSPR_MASK, TITAN, 0, {RT}},
5351{"mficdbtr", XSPR(31,339,927), XSPR_MASK, TITAN, 0, {RT}},
5352{"mfummcr0", XSPR(31,339,936), XSPR_MASK, PPC750, 0, {RT}},
5353{"mfupmc1", XSPR(31,339,937), XSPR_MASK, PPC750, 0, {RT}},
5354{"mfupmc2", XSPR(31,339,938), XSPR_MASK, PPC750, 0, {RT}},
5355{"mfusia", XSPR(31,339,939), XSPR_MASK, PPC750, 0, {RT}},
5356{"mfummcr1", XSPR(31,339,940), XSPR_MASK, PPC750, 0, {RT}},
5357{"mfupmc3", XSPR(31,339,941), XSPR_MASK, PPC750, 0, {RT}},
5358{"mfupmc4", XSPR(31,339,942), XSPR_MASK, PPC750, 0, {RT}},
5359{"mfzpr", XSPR(31,339,944), XSPR_MASK, PPC403, 0, {RT}},
5360{"mfpid", XSPR(31,339,945), XSPR_MASK, PPC403, 0, {RT}},
5361{"mfmmucr", XSPR(31,339,946), XSPR_MASK, TITAN, 0, {RT}},
5362{"mfccr0", XSPR(31,339,947), XSPR_MASK, PPC405|TITAN, 0, {RT}},
5363{"mfiac3", XSPR(31,339,948), XSPR_MASK, PPC405, 0, {RT}},
5364{"mfiac4", XSPR(31,339,949), XSPR_MASK, PPC405, 0, {RT}},
5365{"mfdvc1", XSPR(31,339,950), XSPR_MASK, PPC405, 0, {RT}},
5366{"mfdvc2", XSPR(31,339,951), XSPR_MASK, PPC405, 0, {RT}},
5367{"mfmmcr0", XSPR(31,339,952), XSPR_MASK, PPC750, 0, {RT}},
5368{"mfpmc1", XSPR(31,339,953), XSPR_MASK, PPC750, 0, {RT}},
5369{"mfsgr", XSPR(31,339,953), XSPR_MASK, PPC403, 0, {RT}},
5370{"mfdcwr", XSPR(31,339,954), XSPR_MASK, PPC403, 0, {RT}},
5371{"mfpmc2", XSPR(31,339,954), XSPR_MASK, PPC750, 0, {RT}},
5372{"mfsia", XSPR(31,339,955), XSPR_MASK, PPC750, 0, {RT}},
5373{"mfsler", XSPR(31,339,955), XSPR_MASK, PPC405, 0, {RT}},
5374{"mfmmcr1", XSPR(31,339,956), XSPR_MASK, PPC750, 0, {RT}},
5375{"mfsu0r", XSPR(31,339,956), XSPR_MASK, PPC405, 0, {RT}},
5376{"mfdbcr1", XSPR(31,339,957), XSPR_MASK, PPC405, 0, {RT}},
5377{"mfpmc3", XSPR(31,339,957), XSPR_MASK, PPC750, 0, {RT}},
5378{"mfpmc4", XSPR(31,339,958), XSPR_MASK, PPC750, 0, {RT}},
5379{"mficdbdr", XSPR(31,339,979), XSPR_MASK, PPC403|TITAN, 0, {RT}},
5380{"mfesr", XSPR(31,339,980), XSPR_MASK, PPC403, 0, {RT}},
5381{"mfdear", XSPR(31,339,981), XSPR_MASK, PPC403, 0, {RT}},
5382{"mfevpr", XSPR(31,339,982), XSPR_MASK, PPC403, 0, {RT}},
5383{"mfcdbcr", XSPR(31,339,983), XSPR_MASK, PPC403, 0, {RT}},
5384{"mftsr", XSPR(31,339,984), XSPR_MASK, PPC403, 0, {RT}},
5385{"mftcr", XSPR(31,339,986), XSPR_MASK, PPC403, 0, {RT}},
5386{"mfpit", XSPR(31,339,987), XSPR_MASK, PPC403, 0, {RT}},
5387{"mftbhi", XSPR(31,339,988), XSPR_MASK, PPC403, 0, {RT}},
5388{"mftblo", XSPR(31,339,989), XSPR_MASK, PPC403, 0, {RT}},
5389{"mfsrr2", XSPR(31,339,990), XSPR_MASK, PPC403, 0, {RT}},
5390{"mfsrr3", XSPR(31,339,991), XSPR_MASK, PPC403, 0, {RT}},
5391{"mfdbsr", XSPR(31,339,1008), XSPR_MASK, PPC403, 0, {RT}},
5392{"mfdbcr0", XSPR(31,339,1010), XSPR_MASK, PPC405, 0, {RT}},
5393{"mfdbdr", XSPR(31,339,1011), XSPR_MASK, TITAN, 0, {RS}},
5394{"mfiac1", XSPR(31,339,1012), XSPR_MASK, PPC403, 0, {RT}},
5395{"mfiac2", XSPR(31,339,1013), XSPR_MASK, PPC403, 0, {RT}},
5396{"mfdac1", XSPR(31,339,1014), XSPR_MASK, PPC403, 0, {RT}},
5397{"mfdac2", XSPR(31,339,1015), XSPR_MASK, PPC403, 0, {RT}},
5398{"mfl2cr", XSPR(31,339,1017), XSPR_MASK, PPC750, 0, {RT}},
5399{"mfdccr", XSPR(31,339,1018), XSPR_MASK, PPC403, 0, {RT}},
5400{"mficcr", XSPR(31,339,1019), XSPR_MASK, PPC403, 0, {RT}},
5401{"mfictc", XSPR(31,339,1019), XSPR_MASK, PPC750, 0, {RT}},
5402{"mfpbl1", XSPR(31,339,1020), XSPR_MASK, PPC403, 0, {RT}},
5403{"mfthrm1", XSPR(31,339,1020), XSPR_MASK, PPC750, 0, {RT}},
5404{"mfpbu1", XSPR(31,339,1021), XSPR_MASK, PPC403, 0, {RT}},
5405{"mfthrm2", XSPR(31,339,1021), XSPR_MASK, PPC750, 0, {RT}},
5406{"mfpbl2", XSPR(31,339,1022), XSPR_MASK, PPC403, 0, {RT}},
5407{"mfthrm3", XSPR(31,339,1022), XSPR_MASK, PPC750, 0, {RT}},
5408{"mfpbu2", XSPR(31,339,1023), XSPR_MASK, PPC403, 0, {RT}},
5409{"mfspr", X(31,339), X_MASK, COM, 0, {RT, SPR}},
5410
5411{"lwax", X(31,341), X_MASK, PPC64, 0, {RT, RA0, RB}},
5412
5413{"dst", XDSS(31,342,0), XDSS_MASK, PPCVEC, 0, {RA, RB, STRM}},
5414
5415{"lhax", X(31,343), X_MASK, COM, 0, {RT, RA0, RB}},
5416
5417{"lvxl", X(31,359), X_MASK, PPCVEC, 0, {VD, RA0, RB}},
5418
5419{"abs", XO(31,360,0,0), XORB_MASK, M601, 0, {RT, RA}},
5420{"abs.", XO(31,360,0,1), XORB_MASK, M601, 0, {RT, RA}},
5421
5422{"divs", XO(31,363,0,0), XO_MASK, M601, 0, {RT, RA, RB}},
5423{"divs.", XO(31,363,0,1), XO_MASK, M601, 0, {RT, RA, RB}},
5424
5425{"lxvwsx", X(31,364), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
5426
5427{"tlbia", X(31,370), 0xffffffff, PPC, E500|TITAN, {0}},
5428
5429{"mftbu", XSPR(31,371,269), XSPR_MASK, PPC, NO371|POWER4, {RT}},
5430{"mftb", X(31,371), X_MASK, PPC, NO371|POWER4, {RT, TBR}},
5431{"mftbl", XSPR(31,371,268), XSPR_MASK, PPC, NO371|POWER4, {RT}},
5432
5433{"lwaux", X(31,373), X_MASK, PPC64, 0, {RT, RAL, RB}},
5434
5435{"dstst", XDSS(31,374,0), XDSS_MASK, PPCVEC, 0, {RA, RB, STRM}},
5436
5437{"lhaux", X(31,375), X_MASK, COM, 0, {RT, RAL, RB}},
5438
5439{"popcntw", X(31,378), XRB_MASK, POWER7|PPCA2, 0, {RA, RS}},
5440
5441{"mtdcrx", X(31,387), X_MASK, BOOKE|PPCA2|PPC476, TITAN, {RA, RS}},
5442{"mtdcrx.", XRC(31,387,1), X_MASK, PPCA2, 0, {RA, RS}},
5443
5444{"stvexbx", X(31,389), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
5445
5446{"dcblc", X(31,390), X_MASK, PPCCHLK|PPC476|TITAN, 0, {CT, RA0, RB}},
5447{"stdfcmx", APU(31,391,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
5448
5449{"divdeu", XO(31,393,0,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5450{"divdeu.", XO(31,393,0,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5451{"divweu", XO(31,395,0,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5452{"divweu.", XO(31,395,0,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5453
5454{"stxvx", X(31,396), XX1_MASK, PPCVSX3, 0, {XS6, RA0, RB}},
5455{"stxvl", X(31,397), XX1_MASK, PPCVSX3, 0, {XS6, RA0, RB}},
5456
5457{"dcblce", X(31,398), X_MASK, PPCCHLK, E500MC, {CT, RA, RB}},
5458
5459{"slbmte", X(31,402), XRA_MASK, PPC64, 0, {RS, RB}},
5460
5461{"mtvsrws", X(31,403), XX1RB_MASK, PPCVSX3, 0, {XT6, RA}},
5462
5463{"pbt.", XRC(31,404,1), X_MASK, POWER8, 0, {RS, RA0, RB}},
5464
5465{"icswx", XRC(31,406,0), X_MASK, POWER7|PPCA2, 0, {RS, RA, RB}},
5466{"icswx.", XRC(31,406,1), X_MASK, POWER7|PPCA2, 0, {RS, RA, RB}},
5467
5468{"sthx", X(31,407), X_MASK, COM, 0, {RS, RA0, RB}},
5469
5470{"orc", XRC(31,412,0), X_MASK, COM, 0, {RA, RS, RB}},
5471{"orc.", XRC(31,412,1), X_MASK, COM, 0, {RA, RS, RB}},
5472
5473{"sthepx", X(31,415), X_MASK, E500MC|PPCA2, 0, {RS, RA0, RB}},
5474
5475{"mtdcrux", X(31,419), X_MASK, PPC464, 0, {RA, RS}},
5476
5477{"stvexhx", X(31,421), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
5478
5479{"dcblq.", XRC(31,422,1), X_MASK, E6500, 0, {CT, RA0, RB}},
5480
5481{"divde", XO(31,425,0,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5482{"divde.", XO(31,425,0,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5483{"divwe", XO(31,427,0,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5484{"divwe.", XO(31,427,0,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
5485
5486{"stxvll", X(31,429), XX1_MASK, PPCVSX3, 0, {XS6, RA0, RB}},
5487
5488{"clrbhrb", X(31,430), 0xffffffff, POWER8, 0, {0}},
5489
5490{"slbie", X(31,434), XRTRA_MASK, PPC64, 0, {RB}},
5491
5492{"mtvsrdd", X(31,435), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
5493
5494{"ecowx", X(31,438), X_MASK, PPC, E500|TITAN, {RT, RA0, RB}},
5495
5496{"sthux", X(31,439), X_MASK, COM, 0, {RS, RAS, RB}},
5497
5498{"mdors", 0x7f9ce378, 0xffffffff, E500MC, 0, {0}},
5499
5500{"miso", 0x7f5ad378, 0xffffffff, E6500, 0, {0}},
5501
5502/* The "yield", "mdoio" and "mdoom" instructions are extended mnemonics for
5503 "or rX,rX,rX", with rX being r27, r29 and r30 respectively. */
5504{"yield", 0x7f7bdb78, 0xffffffff, POWER7, 0, {0}},
5505{"mdoio", 0x7fbdeb78, 0xffffffff, POWER7, 0, {0}},
5506{"mdoom", 0x7fdef378, 0xffffffff, POWER7, 0, {0}},
5507{"mr", XRC(31,444,0), X_MASK, COM, 0, {RA, RS, RBS}},
5508{"or", XRC(31,444,0), X_MASK, COM, 0, {RA, RS, RB}},
5509{"mr.", XRC(31,444,1), X_MASK, COM, 0, {RA, RS, RBS}},
5510{"or.", XRC(31,444,1), X_MASK, COM, 0, {RA, RS, RB}},
5511
5512{"mtexisr", XSPR(31,451, 64), XSPR_MASK, PPC403, 0, {RS}},
5513{"mtexier", XSPR(31,451, 66), XSPR_MASK, PPC403, 0, {RS}},
5514{"mtbr0", XSPR(31,451,128), XSPR_MASK, PPC403, 0, {RS}},
5515{"mtbr1", XSPR(31,451,129), XSPR_MASK, PPC403, 0, {RS}},
5516{"mtbr2", XSPR(31,451,130), XSPR_MASK, PPC403, 0, {RS}},
5517{"mtbr3", XSPR(31,451,131), XSPR_MASK, PPC403, 0, {RS}},
5518{"mtbr4", XSPR(31,451,132), XSPR_MASK, PPC403, 0, {RS}},
5519{"mtbr5", XSPR(31,451,133), XSPR_MASK, PPC403, 0, {RS}},
5520{"mtbr6", XSPR(31,451,134), XSPR_MASK, PPC403, 0, {RS}},
5521{"mtbr7", XSPR(31,451,135), XSPR_MASK, PPC403, 0, {RS}},
5522{"mtbear", XSPR(31,451,144), XSPR_MASK, PPC403, 0, {RS}},
5523{"mtbesr", XSPR(31,451,145), XSPR_MASK, PPC403, 0, {RS}},
5524{"mtiocr", XSPR(31,451,160), XSPR_MASK, PPC403, 0, {RS}},
5525{"mtdmacr0", XSPR(31,451,192), XSPR_MASK, PPC403, 0, {RS}},
5526{"mtdmact0", XSPR(31,451,193), XSPR_MASK, PPC403, 0, {RS}},
5527{"mtdmada0", XSPR(31,451,194), XSPR_MASK, PPC403, 0, {RS}},
5528{"mtdmasa0", XSPR(31,451,195), XSPR_MASK, PPC403, 0, {RS}},
5529{"mtdmacc0", XSPR(31,451,196), XSPR_MASK, PPC403, 0, {RS}},
5530{"mtdmacr1", XSPR(31,451,200), XSPR_MASK, PPC403, 0, {RS}},
5531{"mtdmact1", XSPR(31,451,201), XSPR_MASK, PPC403, 0, {RS}},
5532{"mtdmada1", XSPR(31,451,202), XSPR_MASK, PPC403, 0, {RS}},
5533{"mtdmasa1", XSPR(31,451,203), XSPR_MASK, PPC403, 0, {RS}},
5534{"mtdmacc1", XSPR(31,451,204), XSPR_MASK, PPC403, 0, {RS}},
5535{"mtdmacr2", XSPR(31,451,208), XSPR_MASK, PPC403, 0, {RS}},
5536{"mtdmact2", XSPR(31,451,209), XSPR_MASK, PPC403, 0, {RS}},
5537{"mtdmada2", XSPR(31,451,210), XSPR_MASK, PPC403, 0, {RS}},
5538{"mtdmasa2", XSPR(31,451,211), XSPR_MASK, PPC403, 0, {RS}},
5539{"mtdmacc2", XSPR(31,451,212), XSPR_MASK, PPC403, 0, {RS}},
5540{"mtdmacr3", XSPR(31,451,216), XSPR_MASK, PPC403, 0, {RS}},
5541{"mtdmact3", XSPR(31,451,217), XSPR_MASK, PPC403, 0, {RS}},
5542{"mtdmada3", XSPR(31,451,218), XSPR_MASK, PPC403, 0, {RS}},
5543{"mtdmasa3", XSPR(31,451,219), XSPR_MASK, PPC403, 0, {RS}},
5544{"mtdmacc3", XSPR(31,451,220), XSPR_MASK, PPC403, 0, {RS}},
5545{"mtdmasr", XSPR(31,451,224), XSPR_MASK, PPC403, 0, {RS}},
5546{"mtdcr", X(31,451), X_MASK, PPC403|BOOKE|PPCA2|PPC476, E500|TITAN, {SPR, RS}},
5547{"mtdcr.", XRC(31,451,1), X_MASK, PPCA2, 0, {SPR, RS}},
5548
5549{"stvexwx", X(31,453), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
5550
5551{"dccci", X(31,454), XRT_MASK, PPC403|PPC440|TITAN|PPCA2, 0, {RAOPT, RBOPT}},
5552{"dci", X(31,454), XRARB_MASK, PPCA2|PPC476, 0, {CT}},
5553
5554{"divdu", XO(31,457,0,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
5555{"divdu.", XO(31,457,0,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
5556
5557{"divwu", XO(31,459,0,0), XO_MASK, PPC, 0, {RT, RA, RB}},
5558{"divwu.", XO(31,459,0,1), XO_MASK, PPC, 0, {RT, RA, RB}},
5559
5560{"mtpmr", X(31,462), X_MASK, PPCPMR|PPCE300, 0, {PMR, RS}},
5561{"mttmr", X(31,494), X_MASK, PPCTMR|E6500, 0, {TMR, RS}},
5562
5563{"slbieg", X(31,466), XRA_MASK, POWER9, 0, {RS, RB}},
5564
5565{"mtmq", XSPR(31,467, 0), XSPR_MASK, M601, 0, {RS}},
5566{"mtxer", XSPR(31,467, 1), XSPR_MASK, COM, 0, {RS}},
5567{"mtlr", XSPR(31,467, 8), XSPR_MASK, COM, 0, {RS}},
5568{"mtctr", XSPR(31,467, 9), XSPR_MASK, COM, 0, {RS}},
5569{"mtdscr", XSPR(31,467, 17), XSPR_MASK, POWER6, 0, {RS}},
5570{"mttid", XSPR(31,467, 17), XSPR_MASK, POWER, 0, {RS}},
5571{"mtdsisr", XSPR(31,467, 18), XSPR_MASK, COM, TITAN, {RS}},
5572{"mtdar", XSPR(31,467, 19), XSPR_MASK, COM, TITAN, {RS}},
5573{"mtrtcu", XSPR(31,467, 20), XSPR_MASK, COM, TITAN, {RS}},
5574{"mtrtcl", XSPR(31,467, 21), XSPR_MASK, COM, TITAN, {RS}},
5575{"mtdec", XSPR(31,467, 22), XSPR_MASK, COM, 0, {RS}},
5576{"mtsdr0", XSPR(31,467, 24), XSPR_MASK, POWER, 0, {RS}},
5577{"mtsdr1", XSPR(31,467, 25), XSPR_MASK, COM, TITAN, {RS}},
5578{"mtsrr0", XSPR(31,467, 26), XSPR_MASK, COM, 0, {RS}},
5579{"mtsrr1", XSPR(31,467, 27), XSPR_MASK, COM, 0, {RS}},
5580{"mtcfar", XSPR(31,467, 28), XSPR_MASK, POWER6, 0, {RS}},
5581{"mtpid", XSPR(31,467, 48), XSPR_MASK, BOOKE, 0, {RS}},
5582{"mtdecar", XSPR(31,467, 54), XSPR_MASK, BOOKE, 0, {RS}},
5583{"mtcsrr0", XSPR(31,467, 58), XSPR_MASK, BOOKE, 0, {RS}},
5584{"mtcsrr1", XSPR(31,467, 59), XSPR_MASK, BOOKE, 0, {RS}},
5585{"mtdear", XSPR(31,467, 61), XSPR_MASK, BOOKE, 0, {RS}},
5586{"mtesr", XSPR(31,467, 62), XSPR_MASK, BOOKE, 0, {RS}},
5587{"mtivpr", XSPR(31,467, 63), XSPR_MASK, BOOKE, 0, {RS}},
5588{"mtcmpa", XSPR(31,467,144), XSPR_MASK, PPC860, 0, {RS}},
5589{"mtcmpb", XSPR(31,467,145), XSPR_MASK, PPC860, 0, {RS}},
5590{"mtcmpc", XSPR(31,467,146), XSPR_MASK, PPC860, 0, {RS}},
5591{"mtcmpd", XSPR(31,467,147), XSPR_MASK, PPC860, 0, {RS}},
5592{"mticr", XSPR(31,467,148), XSPR_MASK, PPC860, 0, {RS}},
5593{"mtder", XSPR(31,467,149), XSPR_MASK, PPC860, 0, {RS}},
5594{"mtcounta", XSPR(31,467,150), XSPR_MASK, PPC860, 0, {RS}},
5595{"mtcountb", XSPR(31,467,151), XSPR_MASK, PPC860, 0, {RS}},
5596{"mtctrl", XSPR(31,467,152), XSPR_MASK, POWER4, 0, {RS}},
5597{"mtcmpe", XSPR(31,467,152), XSPR_MASK, PPC860, 0, {RS}},
5598{"mtcmpf", XSPR(31,467,153), XSPR_MASK, PPC860, 0, {RS}},
5599{"mtcmpg", XSPR(31,467,154), XSPR_MASK, PPC860, 0, {RS}},
5600{"mtcmph", XSPR(31,467,155), XSPR_MASK, PPC860, 0, {RS}},
5601{"mtlctrl1", XSPR(31,467,156), XSPR_MASK, PPC860, 0, {RS}},
5602{"mtlctrl2", XSPR(31,467,157), XSPR_MASK, PPC860, 0, {RS}},
5603{"mtictrl", XSPR(31,467,158), XSPR_MASK, PPC860, 0, {RS}},
5604{"mtbar", XSPR(31,467,159), XSPR_MASK, PPC860, 0, {RS}},
5605{"mtvrsave", XSPR(31,467,256), XSPR_MASK, PPCVEC, 0, {RS}},
5606{"mtusprg0", XSPR(31,467,256), XSPR_MASK, BOOKE, 0, {RS}},
5607{"mtsprg", XSPR(31,467,256), XSPRG_MASK, PPC, 0, {SPRG, RS}},
5608{"mtsprg0", XSPR(31,467,272), XSPR_MASK, PPC, 0, {RS}},
5609{"mtsprg1", XSPR(31,467,273), XSPR_MASK, PPC, 0, {RS}},
5610{"mtsprg2", XSPR(31,467,274), XSPR_MASK, PPC, 0, {RS}},
5611{"mtsprg3", XSPR(31,467,275), XSPR_MASK, PPC, 0, {RS}},
5612{"mtsprg4", XSPR(31,467,276), XSPR_MASK, PPC405|BOOKE, 0, {RS}},
5613{"mtsprg5", XSPR(31,467,277), XSPR_MASK, PPC405|BOOKE, 0, {RS}},
5614{"mtsprg6", XSPR(31,467,278), XSPR_MASK, PPC405|BOOKE, 0, {RS}},
5615{"mtsprg7", XSPR(31,467,279), XSPR_MASK, PPC405|BOOKE, 0, {RS}},
5616{"mtasr", XSPR(31,467,280), XSPR_MASK, PPC64, 0, {RS}},
5617{"mtear", XSPR(31,467,282), XSPR_MASK, PPC, TITAN, {RS}},
5618{"mttbl", XSPR(31,467,284), XSPR_MASK, PPC, 0, {RS}},
5619{"mttbu", XSPR(31,467,285), XSPR_MASK, PPC, 0, {RS}},
5620{"mtdbsr", XSPR(31,467,304), XSPR_MASK, BOOKE, 0, {RS}},
5621{"mtdbcr0", XSPR(31,467,308), XSPR_MASK, BOOKE, 0, {RS}},
5622{"mtdbcr1", XSPR(31,467,309), XSPR_MASK, BOOKE, 0, {RS}},
5623{"mtdbcr2", XSPR(31,467,310), XSPR_MASK, BOOKE, 0, {RS}},
5624{"mtiac1", XSPR(31,467,312), XSPR_MASK, BOOKE, 0, {RS}},
5625{"mtiac2", XSPR(31,467,313), XSPR_MASK, BOOKE, 0, {RS}},
5626{"mtiac3", XSPR(31,467,314), XSPR_MASK, BOOKE, 0, {RS}},
5627{"mtiac4", XSPR(31,467,315), XSPR_MASK, BOOKE, 0, {RS}},
5628{"mtdac1", XSPR(31,467,316), XSPR_MASK, BOOKE, 0, {RS}},
5629{"mtdac2", XSPR(31,467,317), XSPR_MASK, BOOKE, 0, {RS}},
5630{"mtdvc1", XSPR(31,467,318), XSPR_MASK, BOOKE, 0, {RS}},
5631{"mtdvc2", XSPR(31,467,319), XSPR_MASK, BOOKE, 0, {RS}},
5632{"mttsr", XSPR(31,467,336), XSPR_MASK, BOOKE, 0, {RS}},
5633{"mttcr", XSPR(31,467,340), XSPR_MASK, BOOKE, 0, {RS}},
5634{"mtivor0", XSPR(31,467,400), XSPR_MASK, BOOKE, 0, {RS}},
5635{"mtivor1", XSPR(31,467,401), XSPR_MASK, BOOKE, 0, {RS}},
5636{"mtivor2", XSPR(31,467,402), XSPR_MASK, BOOKE, 0, {RS}},
5637{"mtivor3", XSPR(31,467,403), XSPR_MASK, BOOKE, 0, {RS}},
5638{"mtivor4", XSPR(31,467,404), XSPR_MASK, BOOKE, 0, {RS}},
5639{"mtivor5", XSPR(31,467,405), XSPR_MASK, BOOKE, 0, {RS}},
5640{"mtivor6", XSPR(31,467,406), XSPR_MASK, BOOKE, 0, {RS}},
5641{"mtivor7", XSPR(31,467,407), XSPR_MASK, BOOKE, 0, {RS}},
5642{"mtivor8", XSPR(31,467,408), XSPR_MASK, BOOKE, 0, {RS}},
5643{"mtivor9", XSPR(31,467,409), XSPR_MASK, BOOKE, 0, {RS}},
5644{"mtivor10", XSPR(31,467,410), XSPR_MASK, BOOKE, 0, {RS}},
5645{"mtivor11", XSPR(31,467,411), XSPR_MASK, BOOKE, 0, {RS}},
5646{"mtivor12", XSPR(31,467,412), XSPR_MASK, BOOKE, 0, {RS}},
5647{"mtivor13", XSPR(31,467,413), XSPR_MASK, BOOKE, 0, {RS}},
5648{"mtivor14", XSPR(31,467,414), XSPR_MASK, BOOKE, 0, {RS}},
5649{"mtivor15", XSPR(31,467,415), XSPR_MASK, BOOKE, 0, {RS}},
5650{"mtspefscr", XSPR(31,467,512), XSPR_MASK, PPCSPE, 0, {RS}},
5651{"mtbbear", XSPR(31,467,513), XSPR_MASK, PPCBRLK, 0, {RS}},
5652{"mtbbtar", XSPR(31,467,514), XSPR_MASK, PPCBRLK, 0, {RS}},
5653{"mtivor32", XSPR(31,467,528), XSPR_MASK, PPCSPE, 0, {RS}},
5654{"mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},
5655{"mtivor33", XSPR(31,467,529), XSPR_MASK, PPCSPE, 0, {RS}},
5656{"mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},
5657{"mtivor34", XSPR(31,467,530), XSPR_MASK, PPCSPE, 0, {RS}},
5658{"mtivor35", XSPR(31,467,531), XSPR_MASK, PPCPMR, 0, {RS}},
5659{"mtdbatu", XSPR(31,467,536), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},
5660{"mtdbatl", XSPR(31,467,537), XSPRBAT_MASK, PPC, TITAN, {SPRBAT, RS}},
5661{"mtmcsrr0", XSPR(31,467,570), XSPR_MASK, PPCRFMCI, 0, {RS}},
5662{"mtmcsrr1", XSPR(31,467,571), XSPR_MASK, PPCRFMCI, 0, {RS}},
5663{"mtmcsr", XSPR(31,467,572), XSPR_MASK, PPCRFMCI, 0, {RS}},
5664{"mtivndx", XSPR(31,467,880), XSPR_MASK, TITAN, 0, {RS}},
5665{"mtdvndx", XSPR(31,467,881), XSPR_MASK, TITAN, 0, {RS}},
5666{"mtivlim", XSPR(31,467,882), XSPR_MASK, TITAN, 0, {RS}},
5667{"mtdvlim", XSPR(31,467,883), XSPR_MASK, TITAN, 0, {RS}},
5668{"mtclcsr", XSPR(31,467,884), XSPR_MASK, TITAN, 0, {RS}},
5669{"mtccr1", XSPR(31,467,888), XSPR_MASK, TITAN, 0, {RS}},
5670{"mtppr", XSPR(31,467,896), XSPR_MASK, POWER7, 0, {RS}},
5671{"mtppr32", XSPR(31,467,898), XSPR_MASK, POWER7, 0, {RS}},
5672{"mtummcr0", XSPR(31,467,936), XSPR_MASK, PPC750, 0, {RS}},
5673{"mtupmc1", XSPR(31,467,937), XSPR_MASK, PPC750, 0, {RS}},
5674{"mtupmc2", XSPR(31,467,938), XSPR_MASK, PPC750, 0, {RS}},
5675{"mtusia", XSPR(31,467,939), XSPR_MASK, PPC750, 0, {RS}},
5676{"mtummcr1", XSPR(31,467,940), XSPR_MASK, PPC750, 0, {RS}},
5677{"mtupmc3", XSPR(31,467,941), XSPR_MASK, PPC750, 0, {RS}},
5678{"mtupmc4", XSPR(31,467,942), XSPR_MASK, PPC750, 0, {RS}},
5679{"mtzpr", XSPR(31,467,944), XSPR_MASK, PPC403, 0, {RS}},
5680{"mtpid", XSPR(31,467,945), XSPR_MASK, PPC403, 0, {RS}},
5681{"mtrmmucr", XSPR(31,467,946), XSPR_MASK, TITAN, 0, {RS}},
5682{"mtccr0", XSPR(31,467,947), XSPR_MASK, PPC405|TITAN, 0, {RS}},
5683{"mtiac3", XSPR(31,467,948), XSPR_MASK, PPC405, 0, {RS}},
5684{"mtiac4", XSPR(31,467,949), XSPR_MASK, PPC405, 0, {RS}},
5685{"mtdvc1", XSPR(31,467,950), XSPR_MASK, PPC405, 0, {RS}},
5686{"mtdvc2", XSPR(31,467,951), XSPR_MASK, PPC405, 0, {RS}},
5687{"mtmmcr0", XSPR(31,467,952), XSPR_MASK, PPC750, 0, {RS}},
5688{"mtpmc1", XSPR(31,467,953), XSPR_MASK, PPC750, 0, {RS}},
5689{"mtsgr", XSPR(31,467,953), XSPR_MASK, PPC403, 0, {RS}},
5690{"mtdcwr", XSPR(31,467,954), XSPR_MASK, PPC403, 0, {RS}},
5691{"mtpmc2", XSPR(31,467,954), XSPR_MASK, PPC750, 0, {RS}},
5692{"mtsia", XSPR(31,467,955), XSPR_MASK, PPC750, 0, {RS}},
5693{"mtsler", XSPR(31,467,955), XSPR_MASK, PPC405, 0, {RS}},
5694{"mtmmcr1", XSPR(31,467,956), XSPR_MASK, PPC750, 0, {RS}},
5695{"mtsu0r", XSPR(31,467,956), XSPR_MASK, PPC405, 0, {RS}},
5696{"mtdbcr1", XSPR(31,467,957), XSPR_MASK, PPC405, 0, {RS}},
5697{"mtpmc3", XSPR(31,467,957), XSPR_MASK, PPC750, 0, {RS}},
5698{"mtpmc4", XSPR(31,467,958), XSPR_MASK, PPC750, 0, {RS}},
5699{"mticdbdr", XSPR(31,467,979), XSPR_MASK, PPC403, 0, {RS}},
5700{"mtesr", XSPR(31,467,980), XSPR_MASK, PPC403, 0, {RS}},
5701{"mtdear", XSPR(31,467,981), XSPR_MASK, PPC403, 0, {RS}},
5702{"mtevpr", XSPR(31,467,982), XSPR_MASK, PPC403, 0, {RS}},
5703{"mtcdbcr", XSPR(31,467,983), XSPR_MASK, PPC403, 0, {RS}},
5704{"mttsr", XSPR(31,467,984), XSPR_MASK, PPC403, 0, {RS}},
5705{"mttcr", XSPR(31,467,986), XSPR_MASK, PPC403, 0, {RS}},
5706{"mtpit", XSPR(31,467,987), XSPR_MASK, PPC403, 0, {RS}},
5707{"mttbhi", XSPR(31,467,988), XSPR_MASK, PPC403, 0, {RS}},
5708{"mttblo", XSPR(31,467,989), XSPR_MASK, PPC403, 0, {RS}},
5709{"mtsrr2", XSPR(31,467,990), XSPR_MASK, PPC403, 0, {RS}},
5710{"mtsrr3", XSPR(31,467,991), XSPR_MASK, PPC403, 0, {RS}},
5711{"mtdbsr", XSPR(31,467,1008), XSPR_MASK, PPC403, 0, {RS}},
5712{"mtdbdr", XSPR(31,467,1011), XSPR_MASK, TITAN, 0, {RS}},
5713{"mtdbcr0", XSPR(31,467,1010), XSPR_MASK, PPC405, 0, {RS}},
5714{"mtiac1", XSPR(31,467,1012), XSPR_MASK, PPC403, 0, {RS}},
5715{"mtiac2", XSPR(31,467,1013), XSPR_MASK, PPC403, 0, {RS}},
5716{"mtdac1", XSPR(31,467,1014), XSPR_MASK, PPC403, 0, {RS}},
5717{"mtdac2", XSPR(31,467,1015), XSPR_MASK, PPC403, 0, {RS}},
5718{"mtl2cr", XSPR(31,467,1017), XSPR_MASK, PPC750, 0, {RS}},
5719{"mtdccr", XSPR(31,467,1018), XSPR_MASK, PPC403, 0, {RS}},
5720{"mticcr", XSPR(31,467,1019), XSPR_MASK, PPC403, 0, {RS}},
5721{"mtictc", XSPR(31,467,1019), XSPR_MASK, PPC750, 0, {RS}},
5722{"mtpbl1", XSPR(31,467,1020), XSPR_MASK, PPC403, 0, {RS}},
5723{"mtthrm1", XSPR(31,467,1020), XSPR_MASK, PPC750, 0, {RS}},
5724{"mtpbu1", XSPR(31,467,1021), XSPR_MASK, PPC403, 0, {RS}},
5725{"mtthrm2", XSPR(31,467,1021), XSPR_MASK, PPC750, 0, {RS}},
5726{"mtpbl2", XSPR(31,467,1022), XSPR_MASK, PPC403, 0, {RS}},
5727{"mtthrm3", XSPR(31,467,1022), XSPR_MASK, PPC750, 0, {RS}},
5728{"mtpbu2", XSPR(31,467,1023), XSPR_MASK, PPC403, 0, {RS}},
5729{"mtspr", X(31,467), X_MASK, COM, 0, {SPR, RS}},
5730
5731{"dcbi", X(31,470), XRT_MASK, PPC, 0, {RA0, RB}},
5732
5733{"nand", XRC(31,476,0), X_MASK, COM, 0, {RA, RS, RB}},
5734{"nand.", XRC(31,476,1), X_MASK, COM, 0, {RA, RS, RB}},
5735
5736{"dsn", X(31,483), XRT_MASK, E500MC, 0, {RA, RB}},
5737
5738{"dcread", X(31,486), X_MASK, PPC403|PPC440, PPCA2|PPC476, {RT, RA0, RB}},
5739
5740{"icbtls", X(31,486), X_MASK, PPCCHLK|PPC476|TITAN, 0, {CT, RA0, RB}},
5741
5742{"stvxl", X(31,487), X_MASK, PPCVEC, 0, {VS, RA0, RB}},
5743
5744{"nabs", XO(31,488,0,0), XORB_MASK, M601, 0, {RT, RA}},
5745{"nabs.", XO(31,488,0,1), XORB_MASK, M601, 0, {RT, RA}},
5746
5747{"divd", XO(31,489,0,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
5748{"divd.", XO(31,489,0,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
5749
5750{"divw", XO(31,491,0,0), XO_MASK, PPC, 0, {RT, RA, RB}},
5751{"divw.", XO(31,491,0,1), XO_MASK, PPC, 0, {RT, RA, RB}},
5752
5753{"icbtlse", X(31,494), X_MASK, PPCCHLK, E500MC, {CT, RA, RB}},
5754
5755{"slbia", X(31,498), 0xff1fffff, POWER6, 0, {IH}},
5756{"slbia", X(31,498), 0xffffffff, PPC64, POWER6, {0}},
5757
5758{"cli", X(31,502), XRB_MASK, POWER, 0, {RT, RA}},
5759
5760{"popcntd", X(31,506), XRB_MASK, POWER7|PPCA2, 0, {RA, RS}},
5761
5762{"cmpb", X(31,508), X_MASK, POWER6|PPCA2|PPC476, 0, {RA, RS, RB}},
5763
5764{"mcrxr", X(31,512), XBFRARB_MASK, COM, POWER7, {BF}},
5765
5766{"lbdcbx", X(31,514), X_MASK, E200Z4, 0, {RT, RA, RB}},
5767{"lbdx", X(31,515), X_MASK, E500MC, 0, {RT, RA, RB}},
4285 5768
4286{ "clcs", X(31,531), XRB_MASK, M601, { RT, RA } }, 5769{"bblels", X(31,518), X_MASK, PPCBRLK, 0, {0}},
4287 5770
4288{ "ldbrx", X(31,532), X_MASK, CELL, { RT, RA0, RB } }, 5771{"lvlx", X(31,519), X_MASK, CELL, 0, {VD, RA0, RB}},
5772{"lbfcmux", APU(31,519,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4289 5773
4290{ "lswx", X(31,533), X_MASK, PPCCOM, { RT, RA0, RB } }, 5774{"subfco", XO(31,8,1,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4291{ "lsx", X(31,533), X_MASK, PWRCOM, { RT, RA, RB } }, 5775{"sfo", XO(31,8,1,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
5776{"subco", XO(31,8,1,0), XO_MASK, PPCCOM, 0, {RT, RB, RA}},
5777{"subfco.", XO(31,8,1,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5778{"sfo.", XO(31,8,1,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
5779{"subco.", XO(31,8,1,1), XO_MASK, PPCCOM, 0, {RT, RB, RA}},
4292 5780
4293{ "lwbrx", X(31,534), X_MASK, PPCCOM, { RT, RA0, RB } }, 5781{"addco", XO(31,10,1,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4294{ "lbrx", X(31,534), X_MASK, PWRCOM, { RT, RA, RB } }, 5782{"ao", XO(31,10,1,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
5783{"addco.", XO(31,10,1,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5784{"ao.", XO(31,10,1,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4295 5785
4296{ "lfsx", X(31,535), X_MASK, COM, { FRT, RA0, RB } }, 5786{"lxsspx", X(31,524), XX1_MASK, PPCVSX2, 0, {XT6, RA0, RB}},
4297 5787
4298{ "srw", XRC(31,536,0), X_MASK, PPCCOM, { RA, RS, RB } }, 5788{"clcs", X(31,531), XRB_MASK, M601, 0, {RT, RA}},
4299{ "sr", XRC(31,536,0), X_MASK, PWRCOM, { RA, RS, RB } },
4300{ "srw.", XRC(31,536,1), X_MASK, PPCCOM, { RA, RS, RB } },
4301{ "sr.", XRC(31,536,1), X_MASK, PWRCOM, { RA, RS, RB } },
4302 5789
4303{ "rrib", XRC(31,537,0), X_MASK, M601, { RA, RS, RB } }, 5790{"ldbrx", X(31,532), X_MASK, CELL|POWER7|PPCA2, 0, {RT, RA0, RB}},
4304{ "rrib.", XRC(31,537,1), X_MASK, M601, { RA, RS, RB } },
4305 5791
4306{ "srd", XRC(31,539,0), X_MASK, PPC64, { RA, RS, RB } }, 5792{"lswx", X(31,533), X_MASK, PPCCOM, E500|E500MC, {RT, RAX, RBX}},
4307{ "srd.", XRC(31,539,1), X_MASK, PPC64, { RA, RS, RB } }, 5793{"lsx", X(31,533), X_MASK, PWRCOM, 0, {RT, RA, RB}},
4308 5794
4309{ "maskir", XRC(31,541,0), X_MASK, M601, { RA, RS, RB } }, 5795{"lwbrx", X(31,534), X_MASK, PPCCOM, 0, {RT, RA0, RB}},
4310{ "maskir.", XRC(31,541,1), X_MASK, M601, { RA, RS, RB } }, 5796{"lbrx", X(31,534), X_MASK, PWRCOM, 0, {RT, RA, RB}},
4311 5797
4312{ "lwbrxe", X(31,542), X_MASK, BOOKE64, { RT, RA0, RB } }, 5798{"lfsx", X(31,535), X_MASK, COM, PPCEFS, {FRT, RA0, RB}},
4313 5799
4314{ "lfsxe", X(31,543), X_MASK, BOOKE64, { FRT, RA0, RB } }, 5800{"srw", XRC(31,536,0), X_MASK, PPCCOM, 0, {RA, RS, RB}},
5801{"sr", XRC(31,536,0), X_MASK, PWRCOM, 0, {RA, RS, RB}},
5802{"srw.", XRC(31,536,1), X_MASK, PPCCOM, 0, {RA, RS, RB}},
5803{"sr.", XRC(31,536,1), X_MASK, PWRCOM, 0, {RA, RS, RB}},
4315 5804
4316{ "bbelr", X(31,550), X_MASK, PPCBRLK, { 0 }}, 5805{"rrib", XRC(31,537,0), X_MASK, M601, 0, {RA, RS, RB}},
5806{"rrib.", XRC(31,537,1), X_MASK, M601, 0, {RA, RS, RB}},
4317 5807
4318{ "tlbsync", X(31,566), 0xffffffff, PPC, { 0 } }, 5808{"cnttzw", XRC(31,538,0), XRB_MASK, POWER9, 0, {RA, RS}},
5809{"cnttzw.", XRC(31,538,1), XRB_MASK, POWER9, 0, {RA, RS}},
4319 5810
4320{ "lfsux", X(31,567), X_MASK, COM, { FRT, RAS, RB } }, 5811{"srd", XRC(31,539,0), X_MASK, PPC64, 0, {RA, RS, RB}},
5812{"srd.", XRC(31,539,1), X_MASK, PPC64, 0, {RA, RS, RB}},
4321 5813
4322{ "lfsuxe", X(31,575), X_MASK, BOOKE64, { FRT, RAS, RB } }, 5814{"maskir", XRC(31,541,0), X_MASK, M601, 0, {RA, RS, RB}},
5815{"maskir.", XRC(31,541,1), X_MASK, M601, 0, {RA, RS, RB}},
4323 5816
4324{ "mfsr", X(31,595), XRB_MASK|(1<<20), COM32, { RT, SR } }, 5817{"lhdcbx", X(31,546), X_MASK, E200Z4, 0, {RT, RA, RB}},
5818{"lhdx", X(31,547), X_MASK, E500MC, 0, {RT, RA, RB}},
4325 5819
4326{ "lswi", X(31,597), X_MASK, PPCCOM, { RT, RA0, NB } }, 5820{"lvtrx", X(31,549), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
4327{ "lsi", X(31,597), X_MASK, PWRCOM, { RT, RA0, NB } },
4328 5821
4329{ "lwsync", XSYNC(31,598,1), 0xffffffff, PPC, { 0 } }, 5822{"bbelr", X(31,550), X_MASK, PPCBRLK, 0, {0}},
4330{ "ptesync", XSYNC(31,598,2), 0xffffffff, PPC64, { 0 } },
4331{ "msync", X(31,598), 0xffffffff, BOOKE, { 0 } },
4332{ "sync", X(31,598), XSYNC_MASK, PPCCOM, { LS } },
4333{ "dcs", X(31,598), 0xffffffff, PWRCOM, { 0 } },
4334 5823
4335{ "lfdx", X(31,599), X_MASK, COM, { FRT, RA0, RB } }, 5824{"lvrx", X(31,551), X_MASK, CELL, 0, {VD, RA0, RB}},
5825{"lhfcmux", APU(31,551,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4336 5826
4337{ "lfdxe", X(31,607), X_MASK, BOOKE64, { FRT, RA0, RB } }, 5827{"subfo", XO(31,40,1,0), XO_MASK, PPC, 0, {RT, RA, RB}},
5828{"subo", XO(31,40,1,0), XO_MASK, PPC, 0, {RT, RB, RA}},
5829{"subfo.", XO(31,40,1,1), XO_MASK, PPC, 0, {RT, RA, RB}},
5830{"subo.", XO(31,40,1,1), XO_MASK, PPC, 0, {RT, RB, RA}},
4338 5831
4339{ "mffgpr", XRC(31,607,0), XRA_MASK, POWER6, { FRT, RB } }, 5832{"tlbsync", X(31,566), 0xffffffff, PPC, 0, {0}},
4340 5833
4341{ "mfsri", X(31,627), X_MASK, PWRCOM, { RT, RA, RB } }, 5834{"lfsux", X(31,567), X_MASK, COM, PPCEFS, {FRT, RAS, RB}},
4342 5835
4343{ "dclst", X(31,630), XRB_MASK, PWRCOM, { RS, RA } }, 5836{"cnttzd", XRC(31,570,0), XRB_MASK, POWER9, 0, {RA, RS}},
5837{"cnttzd.", XRC(31,570,1), XRB_MASK, POWER9, 0, {RA, RS}},
4344 5838
4345{ "lfdux", X(31,631), X_MASK, COM, { FRT, RAS, RB } }, 5839{"mcrxrx", X(31,576), XBFRARB_MASK, POWER9, 0, {BF}},
4346 5840
4347{ "lfduxe", X(31,639), X_MASK, BOOKE64, { FRT, RAS, RB } }, 5841{"lwdcbx", X(31,578), X_MASK, E200Z4, 0, {RT, RA, RB}},
5842{"lwdx", X(31,579), X_MASK, E500MC, 0, {RT, RA, RB}},
4348 5843
4349{ "mfsrin", X(31,659), XRA_MASK, PPC32, { RT, RB } }, 5844{"lvtlx", X(31,581), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
4350 5845
4351{ "stdbrx", X(31,660), X_MASK, CELL, { RS, RA0, RB } }, 5846{"lwat", X(31,582), X_MASK, POWER9, 0, {RT, RA0, FC}},
4352 5847
4353{ "stswx", X(31,661), X_MASK, PPCCOM, { RS, RA0, RB } }, 5848{"lwfcmux", APU(31,583,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4354{ "stsx", X(31,661), X_MASK, PWRCOM, { RS, RA0, RB } },
4355 5849
4356{ "stwbrx", X(31,662), X_MASK, PPCCOM, { RS, RA0, RB } }, 5850{"lxsdx", X(31,588), XX1_MASK, PPCVSX, 0, {XT6, RA0, RB}},
4357{ "stbrx", X(31,662), X_MASK, PWRCOM, { RS, RA0, RB } },
4358 5851
4359{ "stfsx", X(31,663), X_MASK, COM, { FRS, RA0, RB } }, 5852{"mfsr", X(31,595), XRB_MASK|(1<<20), COM, NON32, {RT, SR}},
4360 5853
4361{ "srq", XRC(31,664,0), X_MASK, M601, { RA, RS, RB } }, 5854{"lswi", X(31,597), X_MASK, PPCCOM, E500|E500MC, {RT, RAX, NBI}},
4362{ "srq.", XRC(31,664,1), X_MASK, M601, { RA, RS, RB } }, 5855{"lsi", X(31,597), X_MASK, PWRCOM, 0, {RT, RA0, NB}},
4363 5856
4364{ "sre", XRC(31,665,0), X_MASK, M601, { RA, RS, RB } }, 5857{"hwsync", XSYNC(31,598,0), 0xffffffff, POWER4, BOOKE|PPC476, {0}},
4365{ "sre.", XRC(31,665,1), X_MASK, M601, { RA, RS, RB } }, 5858{"lwsync", XSYNC(31,598,1), 0xffffffff, PPC, E500, {0}},
5859{"ptesync", XSYNC(31,598,2), 0xffffffff, PPC64, 0, {0}},
5860{"sync", X(31,598), XSYNCLE_MASK, E6500, 0, {LS, ESYNC}},
5861{"sync", X(31,598), XSYNC_MASK, PPCCOM, BOOKE|PPC476, {LS}},
5862{"msync", X(31,598), 0xffffffff, BOOKE|PPCA2|PPC476, 0, {0}},
5863{"sync", X(31,598), 0xffffffff, BOOKE|PPC476, E6500, {0}},
5864{"lwsync", X(31,598), 0xffffffff, E500, 0, {0}},
5865{"dcs", X(31,598), 0xffffffff, PWRCOM, 0, {0}},
4366 5866
4367{ "stwbrxe", X(31,670), X_MASK, BOOKE64, { RS, RA0, RB } }, 5867{"lfdx", X(31,599), X_MASK, COM, PPCEFS, {FRT, RA0, RB}},
4368 5868
4369{ "stfsxe", X(31,671), X_MASK, BOOKE64, { FRS, RA0, RB } }, 5869{"mffgpr", XRC(31,607,0), XRA_MASK, POWER6, POWER7, {FRT, RB}},
5870{"lfdepx", X(31,607), X_MASK, E500MC|PPCA2, 0, {FRT, RA0, RB}},
4370 5871
4371{ "stfsux", X(31,695), X_MASK, COM, { FRS, RAS, RB } }, 5872{"lddx", X(31,611), X_MASK, E500MC, 0, {RT, RA, RB}},
4372 5873
4373{ "sriq", XRC(31,696,0), X_MASK, M601, { RA, RS, SH } }, 5874{"lvswx", X(31,613), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
4374{ "sriq.", XRC(31,696,1), X_MASK, M601, { RA, RS, SH } },
4375 5875
4376{ "stfsuxe", X(31,703), X_MASK, BOOKE64, { FRS, RAS, RB } }, 5876{"ldat", X(31,614), X_MASK, POWER9, 0, {RT, RA0, FC}},
4377 5877
4378{ "stswi", X(31,725), X_MASK, PPCCOM, { RS, RA0, NB } }, 5878{"lqfcmux", APU(31,615,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4379{ "stsi", X(31,725), X_MASK, PWRCOM, { RS, RA0, NB } },
4380 5879
4381{ "stfdx", X(31,727), X_MASK, COM, { FRS, RA0, RB } }, 5880{"nego", XO(31,104,1,0), XORB_MASK, COM, 0, {RT, RA}},
5881{"nego.", XO(31,104,1,1), XORB_MASK, COM, 0, {RT, RA}},
4382 5882
4383{ "srlq", XRC(31,728,0), X_MASK, M601, { RA, RS, RB } }, 5883{"mulo", XO(31,107,1,0), XO_MASK, M601, 0, {RT, RA, RB}},
4384{ "srlq.", XRC(31,728,1), X_MASK, M601, { RA, RS, RB } }, 5884{"mulo.", XO(31,107,1,1), XO_MASK, M601, 0, {RT, RA, RB}},
4385 5885
4386{ "sreq", XRC(31,729,0), X_MASK, M601, { RA, RS, RB } }, 5886{"mfsri", X(31,627), X_MASK, M601, 0, {RT, RA, RB}},
4387{ "sreq.", XRC(31,729,1), X_MASK, M601, { RA, RS, RB } },
4388 5887
4389{ "stfdxe", X(31,735), X_MASK, BOOKE64, { FRS, RA0, RB } }, 5888{"dclst", X(31,630), XRB_MASK, M601, 0, {RS, RA}},
4390 5889
4391{ "mftgpr", XRC(31,735,0), XRA_MASK, POWER6, { RT, FRB } }, 5890{"lfdux", X(31,631), X_MASK, COM, PPCEFS, {FRT, RAS, RB}},
4392 5891
4393{ "dcba", X(31,758), XRT_MASK, PPC405 | BOOKE, { RA, RB } }, 5892{"stbdcbx", X(31,642), X_MASK, E200Z4, 0, {RS, RA, RB}},
5893{"stbdx", X(31,643), X_MASK, E500MC, 0, {RS, RA, RB}},
4394 5894
4395{ "stfdux", X(31,759), X_MASK, COM, { FRS, RAS, RB } }, 5895{"stvlx", X(31,647), X_MASK, CELL, 0, {VS, RA0, RB}},
5896{"stbfcmux", APU(31,647,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4396 5897
4397{ "srliq", XRC(31,760,0), X_MASK, M601, { RA, RS, SH } }, 5898{"stxsspx", X(31,652), XX1_MASK, PPCVSX2, 0, {XS6, RA0, RB}},
4398{ "srliq.", XRC(31,760,1), X_MASK, M601, { RA, RS, SH } },
4399 5899
4400{ "dcbae", X(31,766), XRT_MASK, BOOKE64, { RA, RB } }, 5900{"tbegin.", XRC(31,654,1), XRTLRARB_MASK, PPCHTM, 0, {HTM_R}},
4401 5901
4402{ "stfduxe", X(31,767), X_MASK, BOOKE64, { FRS, RAS, RB } }, 5902{"subfeo", XO(31,136,1,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5903{"sfeo", XO(31,136,1,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
5904{"subfeo.", XO(31,136,1,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5905{"sfeo.", XO(31,136,1,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4403 5906
4404{ "tlbivax", X(31,786), XRT_MASK, BOOKE, { RA, RB } }, 5907{"addeo", XO(31,138,1,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
4405{ "tlbivaxe",X(31,787), XRT_MASK, BOOKE64, { RA, RB } }, 5908{"aeo", XO(31,138,1,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
5909{"addeo.", XO(31,138,1,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
5910{"aeo.", XO(31,138,1,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4406 5911
4407{ "lwzcix", X(31,789), X_MASK, POWER6, { RT, RA0, RB } }, 5912{"mfsrin", X(31,659), XRA_MASK, PPC, NON32, {RT, RB}},
4408 5913
4409{ "lhbrx", X(31,790), X_MASK, COM, { RT, RA0, RB } }, 5914{"stdbrx", X(31,660), X_MASK, CELL|POWER7|PPCA2, 0, {RS, RA0, RB}},
4410 5915
4411{ "sraw", XRC(31,792,0), X_MASK, PPCCOM, { RA, RS, RB } }, 5916{"stswx", X(31,661), X_MASK, PPCCOM, E500|E500MC, {RS, RA0, RB}},
4412{ "sra", XRC(31,792,0), X_MASK, PWRCOM, { RA, RS, RB } }, 5917{"stsx", X(31,661), X_MASK, PWRCOM, 0, {RS, RA0, RB}},
4413{ "sraw.", XRC(31,792,1), X_MASK, PPCCOM, { RA, RS, RB } },
4414{ "sra.", XRC(31,792,1), X_MASK, PWRCOM, { RA, RS, RB } },
4415 5918
4416{ "srad", XRC(31,794,0), X_MASK, PPC64, { RA, RS, RB } }, 5919{"stwbrx", X(31,662), X_MASK, PPCCOM, 0, {RS, RA0, RB}},
4417{ "srad.", XRC(31,794,1), X_MASK, PPC64, { RA, RS, RB } }, 5920{"stbrx", X(31,662), X_MASK, PWRCOM, 0, {RS, RA0, RB}},
4418 5921
4419{ "lhbrxe", X(31,798), X_MASK, BOOKE64, { RT, RA0, RB } }, 5922{"stfsx", X(31,663), X_MASK, COM, PPCEFS, {FRS, RA0, RB}},
4420 5923
4421{ "ldxe", X(31,799), X_MASK, BOOKE64, { RT, RA0, RB } }, 5924{"srq", XRC(31,664,0), X_MASK, M601, 0, {RA, RS, RB}},
4422{ "lduxe", X(31,831), X_MASK, BOOKE64, { RT, RA0, RB } }, 5925{"srq.", XRC(31,664,1), X_MASK, M601, 0, {RA, RS, RB}},
4423 5926
4424{ "rac", X(31,818), X_MASK, PWRCOM, { RT, RA, RB } }, 5927{"sre", XRC(31,665,0), X_MASK, M601, 0, {RA, RS, RB}},
5928{"sre.", XRC(31,665,1), X_MASK, M601, 0, {RA, RS, RB}},
4425 5929
4426{ "lhzcix", X(31,821), X_MASK, POWER6, { RT, RA0, RB } }, 5930{"sthdcbx", X(31,674), X_MASK, E200Z4, 0, {RS, RA, RB}},
5931{"sthdx", X(31,675), X_MASK, E500MC, 0, {RS, RA, RB}},
4427 5932
4428{ "dss", XDSS(31,822,0), XDSS_MASK, PPCVEC, { STRM } }, 5933{"stvfrx", X(31,677), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
4429{ "dssall", XDSS(31,822,1), XDSS_MASK, PPCVEC, { 0 } },
4430 5934
4431{ "srawi", XRC(31,824,0), X_MASK, PPCCOM, { RA, RS, SH } }, 5935{"stvrx", X(31,679), X_MASK, CELL, 0, {VS, RA0, RB}},
4432{ "srai", XRC(31,824,0), X_MASK, PWRCOM, { RA, RS, SH } }, 5936{"sthfcmux", APU(31,679,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4433{ "srawi.", XRC(31,824,1), X_MASK, PPCCOM, { RA, RS, SH } },
4434{ "srai.", XRC(31,824,1), X_MASK, PWRCOM, { RA, RS, SH } },
4435 5937
4436{ "slbmfev", X(31,851), XRA_MASK, PPC64, { RT, RB } }, 5938{"tendall.", XRC(31,686,1)|(1<<25), XRTRARB_MASK, PPCHTM, 0, {0}},
5939{"tend.", XRC(31,686,1), XRTARARB_MASK, PPCHTM, 0, {HTM_A}},
4437 5940
4438{ "lbzcix", X(31,853), X_MASK, POWER6, { RT, RA0, RB } }, 5941{"stbcx.", XRC(31,694,1), X_MASK, POWER8|E6500, 0, {RS, RA0, RB}},
4439 5942
4440{ "mbar", X(31,854), X_MASK, BOOKE, { MO } }, 5943{"stfsux", X(31,695), X_MASK, COM, PPCEFS, {FRS, RAS, RB}},
4441{ "eieio", X(31,854), 0xffffffff, PPC, { 0 } },
4442 5944
4443{ "lfiwax", X(31,855), X_MASK, POWER6, { FRT, RA0, RB } }, 5945{"sriq", XRC(31,696,0), X_MASK, M601, 0, {RA, RS, SH}},
5946{"sriq.", XRC(31,696,1), X_MASK, M601, 0, {RA, RS, SH}},
4444 5947
4445{ "ldcix", X(31,885), X_MASK, POWER6, { RT, RA0, RB } }, 5948{"stwdcbx", X(31,706), X_MASK, E200Z4, 0, {RS, RA, RB}},
5949{"stwdx", X(31,707), X_MASK, E500MC, 0, {RS, RA, RB}},
4446 5950
4447{ "tlbsx", XRC(31,914,0), X_MASK, PPC403|BOOKE, { RTO, RA, RB } }, 5951{"stvflx", X(31,709), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
4448{ "tlbsx.", XRC(31,914,1), X_MASK, PPC403|BOOKE, { RTO, RA, RB } },
4449{ "tlbsxe", XRC(31,915,0), X_MASK, BOOKE64, { RA, RB } },
4450{ "tlbsxe.", XRC(31,915,1), X_MASK, BOOKE64, { RA, RB } },
4451 5952
4452{ "slbmfee", X(31,915), XRA_MASK, PPC64, { RT, RB } }, 5953{"stwat", X(31,710), X_MASK, POWER9, 0, {RS, RA0, FC}},
4453 5954
4454{ "stwcix", X(31,917), X_MASK, POWER6, { RS, RA0, RB } }, 5955{"stwfcmux", APU(31,711,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4455 5956
4456{ "sthbrx", X(31,918), X_MASK, COM, { RS, RA0, RB } }, 5957{"stxsdx", X(31,716), XX1_MASK, PPCVSX, 0, {XS6, RA0, RB}},
4457 5958
4458{ "sraq", XRC(31,920,0), X_MASK, M601, { RA, RS, RB } }, 5959{"tcheck", X(31,718), XRTBFRARB_MASK, PPCHTM, 0, {BF}},
4459{ "sraq.", XRC(31,920,1), X_MASK, M601, { RA, RS, RB } },
4460 5960
4461{ "srea", XRC(31,921,0), X_MASK, M601, { RA, RS, RB } }, 5961{"subfzeo", XO(31,200,1,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
4462{ "srea.", XRC(31,921,1), X_MASK, M601, { RA, RS, RB } }, 5962{"sfzeo", XO(31,200,1,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
5963{"subfzeo.", XO(31,200,1,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
5964{"sfzeo.", XO(31,200,1,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
4463 5965
4464{ "extsh", XRC(31,922,0), XRB_MASK, PPCCOM, { RA, RS } }, 5966{"addzeo", XO(31,202,1,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
4465{ "exts", XRC(31,922,0), XRB_MASK, PWRCOM, { RA, RS } }, 5967{"azeo", XO(31,202,1,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
4466{ "extsh.", XRC(31,922,1), XRB_MASK, PPCCOM, { RA, RS } }, 5968{"addzeo.", XO(31,202,1,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
4467{ "exts.", XRC(31,922,1), XRB_MASK, PWRCOM, { RA, RS } }, 5969{"azeo.", XO(31,202,1,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
4468 5970
4469{ "sthbrxe", X(31,926), X_MASK, BOOKE64, { RS, RA0, RB } }, 5971{"stswi", X(31,725), X_MASK, PPCCOM, E500|E500MC, {RS, RA0, NB}},
5972{"stsi", X(31,725), X_MASK, PWRCOM, 0, {RS, RA0, NB}},
4470 5973
4471{ "stdxe", X(31,927), X_MASK, BOOKE64, { RS, RA0, RB } }, 5974{"sthcx.", XRC(31,726,1), X_MASK, POWER8|E6500, 0, {RS, RA0, RB}},
4472 5975
4473{ "tlbrehi", XTLB(31,946,0), XTLB_MASK, PPC403, { RT, RA } }, 5976{"stfdx", X(31,727), X_MASK, COM, PPCEFS, {FRS, RA0, RB}},
4474{ "tlbrelo", XTLB(31,946,1), XTLB_MASK, PPC403, { RT, RA } },
4475{ "tlbre", X(31,946), X_MASK, PPC403|BOOKE, { RSO, RAOPT, SHO } },
4476 5977
4477{ "sthcix", X(31,949), X_MASK, POWER6, { RS, RA0, RB } }, 5978{"srlq", XRC(31,728,0), X_MASK, M601, 0, {RA, RS, RB}},
5979{"srlq.", XRC(31,728,1), X_MASK, M601, 0, {RA, RS, RB}},
4478 5980
4479{ "sraiq", XRC(31,952,0), X_MASK, M601, { RA, RS, SH } }, 5981{"sreq", XRC(31,729,0), X_MASK, M601, 0, {RA, RS, RB}},
4480{ "sraiq.", XRC(31,952,1), X_MASK, M601, { RA, RS, SH } }, 5982{"sreq.", XRC(31,729,1), X_MASK, M601, 0, {RA, RS, RB}},
4481 5983
4482{ "extsb", XRC(31,954,0), XRB_MASK, PPC, { RA, RS} }, 5984{"mftgpr", XRC(31,735,0), XRA_MASK, POWER6, POWER7, {RT, FRB}},
4483{ "extsb.", XRC(31,954,1), XRB_MASK, PPC, { RA, RS} }, 5985{"stfdepx", X(31,735), X_MASK, E500MC|PPCA2, 0, {FRS, RA0, RB}},
4484 5986
4485{ "stduxe", X(31,959), X_MASK, BOOKE64, { RS, RAS, RB } }, 5987{"stddx", X(31,739), X_MASK, E500MC, 0, {RS, RA, RB}},
4486 5988
4487{ "iccci", X(31,966), XRT_MASK, PPC403|PPC440, { RA, RB } }, 5989{"stvswx", X(31,741), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
4488 5990
4489{ "tlbwehi", XTLB(31,978,0), XTLB_MASK, PPC403, { RT, RA } }, 5991{"stdat", X(31,742), X_MASK, POWER9, 0, {RS, RA0, FC}},
4490{ "tlbwelo", XTLB(31,978,1), XTLB_MASK, PPC403, { RT, RA } },
4491{ "tlbwe", X(31,978), X_MASK, PPC403|BOOKE, { RSO, RAOPT, SHO } },
4492{ "tlbld", X(31,978), XRTRA_MASK, PPC, { RB } },
4493 5992
4494{ "stbcix", X(31,981), X_MASK, POWER6, { RS, RA0, RB } }, 5993{"stqfcmux", APU(31,743,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4495 5994
4496{ "icbi", X(31,982), XRT_MASK, PPC, { RA, RB } }, 5995{"subfmeo", XO(31,232,1,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
5996{"sfmeo", XO(31,232,1,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
5997{"subfmeo.", XO(31,232,1,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
5998{"sfmeo.", XO(31,232,1,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
4497 5999
4498{ "stfiwx", X(31,983), X_MASK, PPC, { FRS, RA0, RB } }, 6000{"mulldo", XO(31,233,1,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
6001{"mulldo.", XO(31,233,1,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
4499 6002
4500{ "extsw", XRC(31,986,0), XRB_MASK, PPC64 | BOOKE64,{ RA, RS } }, 6003{"addmeo", XO(31,234,1,0), XORB_MASK, PPCCOM, 0, {RT, RA}},
4501{ "extsw.", XRC(31,986,1), XRB_MASK, PPC64, { RA, RS } }, 6004{"ameo", XO(31,234,1,0), XORB_MASK, PWRCOM, 0, {RT, RA}},
6005{"addmeo.", XO(31,234,1,1), XORB_MASK, PPCCOM, 0, {RT, RA}},
6006{"ameo.", XO(31,234,1,1), XORB_MASK, PWRCOM, 0, {RT, RA}},
4502 6007
4503{ "icread", X(31,998), XRT_MASK, PPC403|PPC440, { RA, RB } }, 6008{"mullwo", XO(31,235,1,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
6009{"mulso", XO(31,235,1,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
6010{"mullwo.", XO(31,235,1,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
6011{"mulso.", XO(31,235,1,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4504 6012
4505{ "icbie", X(31,990), XRT_MASK, BOOKE64, { RA, RB } }, 6013{"tsuspend.", XRCL(31,750,0,1), XRTRARB_MASK,PPCHTM, 0, {0}},
4506{ "stfiwxe", X(31,991), X_MASK, BOOKE64, { FRS, RA0, RB } }, 6014{"tresume.", XRCL(31,750,1,1), XRTRARB_MASK,PPCHTM, 0, {0}},
6015{"tsr.", XRC(31,750,1), XRTLRARB_MASK,PPCHTM, 0, {L}},
4507 6016
4508{ "tlbli", X(31,1010), XRTRA_MASK, PPC, { RB } }, 6017{"darn", X(31,755), XLRAND_MASK, POWER9, 0, {RT, LRAND}},
4509 6018
4510{ "stdcix", X(31,1013), X_MASK, POWER6, { RS, RA0, RB } }, 6019{"dcba", X(31,758), XRT_MASK, PPC405|PPC7450|BOOKE|PPCA2|PPC476, 0, {RA0, RB}},
6020{"dcbal", XOPL(31,758,1), XRT_MASK, E500MC, 0, {RA0, RB}},
4511 6021
4512{ "dcbzl", XOPL(31,1014,1), XRT_MASK,POWER4, { RA, RB } }, 6022{"stfdux", X(31,759), X_MASK, COM, PPCEFS, {FRS, RAS, RB}},
4513{ "dcbz", X(31,1014), XRT_MASK, PPC, { RA, RB } },
4514{ "dclz", X(31,1014), XRT_MASK, PPC, { RA, RB } },
4515 6023
4516{ "dcbze", X(31,1022), XRT_MASK, BOOKE64, { RA, RB } }, 6024{"srliq", XRC(31,760,0), X_MASK, M601, 0, {RA, RS, SH}},
6025{"srliq.", XRC(31,760,1), X_MASK, M601, 0, {RA, RS, SH}},
4517 6026
4518{ "lvebx", X(31, 7), X_MASK, PPCVEC, { VD, RA, RB } }, 6027{"lvsm", X(31,773), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
4519{ "lvehx", X(31, 39), X_MASK, PPCVEC, { VD, RA, RB } },
4520{ "lvewx", X(31, 71), X_MASK, PPCVEC, { VD, RA, RB } },
4521{ "lvsl", X(31, 6), X_MASK, PPCVEC, { VD, RA, RB } },
4522{ "lvsr", X(31, 38), X_MASK, PPCVEC, { VD, RA, RB } },
4523{ "lvx", X(31, 103), X_MASK, PPCVEC, { VD, RA, RB } },
4524{ "lvxl", X(31, 359), X_MASK, PPCVEC, { VD, RA, RB } },
4525{ "stvebx", X(31, 135), X_MASK, PPCVEC, { VS, RA, RB } },
4526{ "stvehx", X(31, 167), X_MASK, PPCVEC, { VS, RA, RB } },
4527{ "stvewx", X(31, 199), X_MASK, PPCVEC, { VS, RA, RB } },
4528{ "stvx", X(31, 231), X_MASK, PPCVEC, { VS, RA, RB } },
4529{ "stvxl", X(31, 487), X_MASK, PPCVEC, { VS, RA, RB } },
4530 6028
4531/* New load/store left/right index vector instructions that are in the Cell only. */ 6029{"copy", XOPL(31,774,1), XRT_MASK, POWER9, 0, {RA0, RB}},
4532{ "lvlx", X(31, 519), X_MASK, CELL, { VD, RA0, RB } },
4533{ "lvlxl", X(31, 775), X_MASK, CELL, { VD, RA0, RB } },
4534{ "lvrx", X(31, 551), X_MASK, CELL, { VD, RA0, RB } },
4535{ "lvrxl", X(31, 807), X_MASK, CELL, { VD, RA0, RB } },
4536{ "stvlx", X(31, 647), X_MASK, CELL, { VS, RA0, RB } },
4537{ "stvlxl", X(31, 903), X_MASK, CELL, { VS, RA0, RB } },
4538{ "stvrx", X(31, 679), X_MASK, CELL, { VS, RA0, RB } },
4539{ "stvrxl", X(31, 935), X_MASK, CELL, { VS, RA0, RB } },
4540 6030
4541{ "lwz", OP(32), OP_MASK, PPCCOM, { RT, D, RA0 } }, 6031{"stvepxl", X(31,775), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
4542{ "l", OP(32), OP_MASK, PWRCOM, { RT, D, RA0 } }, 6032{"lvlxl", X(31,775), X_MASK, CELL, 0, {VD, RA0, RB}},
6033{"ldfcmux", APU(31,775,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4543 6034
4544{ "lwzu", OP(33), OP_MASK, PPCCOM, { RT, D, RAL } }, 6035{"dozo", XO(31,264,1,0), XO_MASK, M601, 0, {RT, RA, RB}},
4545{ "lu", OP(33), OP_MASK, PWRCOM, { RT, D, RA0 } }, 6036{"dozo.", XO(31,264,1,1), XO_MASK, M601, 0, {RT, RA, RB}},
4546 6037
4547{ "lbz", OP(34), OP_MASK, COM, { RT, D, RA0 } }, 6038{"addo", XO(31,266,1,0), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
6039{"caxo", XO(31,266,1,0), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
6040{"addo.", XO(31,266,1,1), XO_MASK, PPCCOM, 0, {RT, RA, RB}},
6041{"caxo.", XO(31,266,1,1), XO_MASK, PWRCOM, 0, {RT, RA, RB}},
4548 6042
4549{ "lbzu", OP(35), OP_MASK, COM, { RT, D, RAL } }, 6043{"modsd", X(31,777), X_MASK, POWER9, 0, {RT, RA, RB}},
6044{"modsw", X(31,779), X_MASK, POWER9, 0, {RT, RA, RB}},
4550 6045
4551{ "stw", OP(36), OP_MASK, PPCCOM, { RS, D, RA0 } }, 6046{"lxvw4x", X(31,780), XX1_MASK, PPCVSX, 0, {XT6, RA0, RB}},
4552{ "st", OP(36), OP_MASK, PWRCOM, { RS, D, RA0 } }, 6047{"lxsibzx", X(31,781), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
4553 6048
4554{ "stwu", OP(37), OP_MASK, PPCCOM, { RS, D, RAS } }, 6049{"tabortwc.", XRC(31,782,1), X_MASK, PPCHTM, 0, {TO, RA, RB}},
4555{ "stu", OP(37), OP_MASK, PWRCOM, { RS, D, RA0 } },
4556 6050
4557{ "stb", OP(38), OP_MASK, COM, { RS, D, RA0 } }, 6051{"tlbivax", X(31,786), XRT_MASK, BOOKE|PPCA2|PPC476, 0, {RA0, RB}},
4558 6052
4559{ "stbu", OP(39), OP_MASK, COM, { RS, D, RAS } }, 6053{"lwzcix", X(31,789), X_MASK, POWER6, 0, {RT, RA0, RB}},
4560 6054
4561{ "lhz", OP(40), OP_MASK, COM, { RT, D, RA0 } }, 6055{"lhbrx", X(31,790), X_MASK, COM, 0, {RT, RA0, RB}},
4562 6056
4563{ "lhzu", OP(41), OP_MASK, COM, { RT, D, RAL } }, 6057{"lfdpx", X(31,791), X_MASK, POWER6, POWER7, {FRTp, RA0, RB}},
6058{"lfqx", X(31,791), X_MASK, POWER2, 0, {FRT, RA, RB}},
4564 6059
4565{ "lha", OP(42), OP_MASK, COM, { RT, D, RA0 } }, 6060{"sraw", XRC(31,792,0), X_MASK, PPCCOM, 0, {RA, RS, RB}},
6061{"sra", XRC(31,792,0), X_MASK, PWRCOM, 0, {RA, RS, RB}},
6062{"sraw.", XRC(31,792,1), X_MASK, PPCCOM, 0, {RA, RS, RB}},
6063{"sra.", XRC(31,792,1), X_MASK, PWRCOM, 0, {RA, RS, RB}},
4566 6064
4567{ "lhau", OP(43), OP_MASK, COM, { RT, D, RAL } }, 6065{"srad", XRC(31,794,0), X_MASK, PPC64, 0, {RA, RS, RB}},
6066{"srad.", XRC(31,794,1), X_MASK, PPC64, 0, {RA, RS, RB}},
4568 6067
4569{ "sth", OP(44), OP_MASK, COM, { RS, D, RA0 } }, 6068{"lfddx", X(31,803), X_MASK, E500MC, 0, {FRT, RA, RB}},
4570 6069
4571{ "sthu", OP(45), OP_MASK, COM, { RS, D, RAS } }, 6070{"lvtrxl", X(31,805), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
6071{"stvepx", X(31,807), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
6072{"lvrxl", X(31,807), X_MASK, CELL, 0, {VD, RA0, RB}},
4572 6073
4573{ "lmw", OP(46), OP_MASK, PPCCOM, { RT, D, RAM } }, 6074{"lxvh8x", X(31,812), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
4574{ "lm", OP(46), OP_MASK, PWRCOM, { RT, D, RA0 } }, 6075{"lxsihzx", X(31,813), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
4575 6076
4576{ "stmw", OP(47), OP_MASK, PPCCOM, { RS, D, RA0 } }, 6077{"tabortdc.", XRC(31,814,1), X_MASK, PPCHTM, 0, {TO, RA, RB}},
4577{ "stm", OP(47), OP_MASK, PWRCOM, { RS, D, RA0 } },
4578 6078
4579{ "lfs", OP(48), OP_MASK, COM, { FRT, D, RA0 } }, 6079{"rac", X(31,818), X_MASK, M601, 0, {RT, RA, RB}},
4580 6080
4581{ "lfsu", OP(49), OP_MASK, COM, { FRT, D, RAS } }, 6081{"erativax", X(31,819), X_MASK, PPCA2, 0, {RS, RA0, RB}},
4582 6082
4583{ "lfd", OP(50), OP_MASK, COM, { FRT, D, RA0 } }, 6083{"lhzcix", X(31,821), X_MASK, POWER6, 0, {RT, RA0, RB}},
4584 6084
4585{ "lfdu", OP(51), OP_MASK, COM, { FRT, D, RAS } }, 6085{"dss", XDSS(31,822,0), XDSS_MASK, PPCVEC, 0, {STRM}},
4586 6086
4587{ "stfs", OP(52), OP_MASK, COM, { FRS, D, RA0 } }, 6087{"lfqux", X(31,823), X_MASK, POWER2, 0, {FRT, RA, RB}},
4588 6088
4589{ "stfsu", OP(53), OP_MASK, COM, { FRS, D, RAS } }, 6089{"srawi", XRC(31,824,0), X_MASK, PPCCOM, 0, {RA, RS, SH}},
6090{"srai", XRC(31,824,0), X_MASK, PWRCOM, 0, {RA, RS, SH}},
6091{"srawi.", XRC(31,824,1), X_MASK, PPCCOM, 0, {RA, RS, SH}},
6092{"srai.", XRC(31,824,1), X_MASK, PWRCOM, 0, {RA, RS, SH}},
4590 6093
4591{ "stfd", OP(54), OP_MASK, COM, { FRS, D, RA0 } }, 6094{"sradi", XS(31,413,0), XS_MASK, PPC64, 0, {RA, RS, SH6}},
6095{"sradi.", XS(31,413,1), XS_MASK, PPC64, 0, {RA, RS, SH6}},
4592 6096
4593{ "stfdu", OP(55), OP_MASK, COM, { FRS, D, RAS } }, 6097{"lvtlxl", X(31,837), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
4594 6098
4595{ "lq", OP(56), OP_MASK, POWER4, { RTQ, DQ, RAQ } }, 6099{"cpabort", X(31,838), XRTRARB_MASK,POWER9, 0, {0}},
4596 6100
4597{ "lfq", OP(56), OP_MASK, POWER2, { FRT, D, RA0 } }, 6101{"divo", XO(31,331,1,0), XO_MASK, M601, 0, {RT, RA, RB}},
6102{"divo.", XO(31,331,1,1), XO_MASK, M601, 0, {RT, RA, RB}},
4598 6103
4599{ "lfqu", OP(57), OP_MASK, POWER2, { FRT, D, RA0 } }, 6104{"lxvd2x", X(31,844), XX1_MASK, PPCVSX, 0, {XT6, RA0, RB}},
6105{"lxvx", X(31,844), XX1_MASK, POWER8, POWER9|PPCVSX3, {XT6, RA0, RB}},
4600 6106
4601{ "lfdp", OP(57), OP_MASK, POWER6, { FRT, D, RA0 } }, 6107{"tabortwci.", XRC(31,846,1), X_MASK, PPCHTM, 0, {TO, RA, HTM_SI}},
4602 6108
4603{ "lbze", DEO(58,0), DE_MASK, BOOKE64, { RT, DE, RA0 } }, 6109{"tlbsrx.", XRC(31,850,1), XRT_MASK, PPCA2, 0, {RA0, RB}},
4604{ "lbzue", DEO(58,1), DE_MASK, BOOKE64, { RT, DE, RAL } },
4605{ "lhze", DEO(58,2), DE_MASK, BOOKE64, { RT, DE, RA0 } },
4606{ "lhzue", DEO(58,3), DE_MASK, BOOKE64, { RT, DE, RAL } },
4607{ "lhae", DEO(58,4), DE_MASK, BOOKE64, { RT, DE, RA0 } },
4608{ "lhaue", DEO(58,5), DE_MASK, BOOKE64, { RT, DE, RAL } },
4609{ "lwze", DEO(58,6), DE_MASK, BOOKE64, { RT, DE, RA0 } },
4610{ "lwzue", DEO(58,7), DE_MASK, BOOKE64, { RT, DE, RAL } },
4611{ "stbe", DEO(58,8), DE_MASK, BOOKE64, { RS, DE, RA0 } },
4612{ "stbue", DEO(58,9), DE_MASK, BOOKE64, { RS, DE, RAS } },
4613{ "sthe", DEO(58,10), DE_MASK, BOOKE64, { RS, DE, RA0 } },
4614{ "sthue", DEO(58,11), DE_MASK, BOOKE64, { RS, DE, RAS } },
4615{ "stwe", DEO(58,14), DE_MASK, BOOKE64, { RS, DE, RA0 } },
4616{ "stwue", DEO(58,15), DE_MASK, BOOKE64, { RS, DE, RAS } },
4617 6110
4618{ "ld", DSO(58,0), DS_MASK, PPC64, { RT, DS, RA0 } }, 6111{"slbiag", X(31,850), XRARB_MASK, POWER9, 0, {RS}},
6112{"slbmfev", X(31,851), XRLA_MASK, POWER9, 0, {RT, RB, A_L}},
6113{"slbmfev", X(31,851), XRA_MASK, PPC64, POWER9, {RT, RB}},
4619 6114
4620{ "ldu", DSO(58,1), DS_MASK, PPC64, { RT, DS, RAL } }, 6115{"lbzcix", X(31,853), X_MASK, POWER6, 0, {RT, RA0, RB}},
4621 6116
4622{ "lwa", DSO(58,2), DS_MASK, PPC64, { RT, DS, RA0 } }, 6117{"eieio", X(31,854), 0xffffffff, PPC, BOOKE|PPCA2|PPC476, {0}},
6118{"mbar", X(31,854), X_MASK, BOOKE|PPCA2|PPC476, 0, {MO}},
6119{"eieio", XMBAR(31,854,1),0xffffffff, E500, 0, {0}},
6120{"eieio", X(31,854), 0xffffffff, PPCA2|PPC476, 0, {0}},
4623 6121
4624{ "dadd", XRC(59,2,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6122{"lfiwax", X(31,855), X_MASK, POWER6|PPCA2|PPC476, 0, {FRT, RA0, RB}},
4625{ "dadd.", XRC(59,2,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4626 6123
4627{ "dqua", ZRC(59,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 6124{"lvswxl", X(31,869), X_MASK, PPCVEC2, 0, {VD, RA0, RB}},
4628{ "dqua.", ZRC(59,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4629 6125
4630{ "fdivs", A(59,18,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 6126{"abso", XO(31,360,1,0), XORB_MASK, M601, 0, {RT, RA}},
4631{ "fdivs.", A(59,18,1), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 6127{"abso.", XO(31,360,1,1), XORB_MASK, M601, 0, {RT, RA}},
4632 6128
4633{ "fsubs", A(59,20,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 6129{"divso", XO(31,363,1,0), XO_MASK, M601, 0, {RT, RA, RB}},
4634{ "fsubs.", A(59,20,1), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 6130{"divso.", XO(31,363,1,1), XO_MASK, M601, 0, {RT, RA, RB}},
4635 6131
4636{ "fadds", A(59,21,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, 6132{"lxvb16x", X(31,876), XX1_MASK, PPCVSX3, 0, {XT6, RA0, RB}},
4637{ "fadds.", A(59,21,1), AFRC_MASK, PPC, { FRT, FRA, FRB } },
4638 6133
4639{ "fsqrts", A(59,22,0), AFRAFRC_MASK, PPC, { FRT, FRB } }, 6134{"tabortdci.", XRC(31,878,1), X_MASK, PPCHTM, 0, {TO, RA, HTM_SI}},
4640{ "fsqrts.", A(59,22,1), AFRAFRC_MASK, PPC, { FRT, FRB } },
4641 6135
4642{ "fres", A(59,24,0), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } }, 6136{"rmieg", X(31,882), XRTRA_MASK, POWER9, 0, {RB}},
4643{ "fres.", A(59,24,1), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } },
4644 6137
4645{ "fmuls", A(59,25,0), AFRB_MASK, PPC, { FRT, FRA, FRC } }, 6138{"ldcix", X(31,885), X_MASK, POWER6, 0, {RT, RA0, RB}},
4646{ "fmuls.", A(59,25,1), AFRB_MASK, PPC, { FRT, FRA, FRC } },
4647 6139
4648{ "frsqrtes", A(59,26,0), AFRALFRC_MASK,POWER5, { FRT, FRB, A_L } }, 6140{"msgsync", X(31,886), 0xffffffff, POWER9, 0, {0}},
4649{ "frsqrtes.",A(59,26,1), AFRALFRC_MASK,POWER5, { FRT, FRB, A_L } },
4650 6141
4651{ "fmsubs", A(59,28,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6142{"lfiwzx", X(31,887), X_MASK, POWER7|PPCA2, 0, {FRT, RA0, RB}},
4652{ "fmsubs.", A(59,28,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4653 6143
4654{ "fmadds", A(59,29,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6144{"extswsli", XS(31,445,0), XS_MASK, POWER9, 0, {RA, RS, SH6}},
4655{ "fmadds.", A(59,29,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6145{"extswsli.", XS(31,445,1), XS_MASK, POWER9, 0, {RA, RS, SH6}},
4656 6146
4657{ "fnmsubs", A(59,30,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6147{"paste.", XRCL(31,902,1,1),XRT_MASK, POWER9, 0, {RA0, RB}},
4658{ "fnmsubs.",A(59,30,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } },
4659 6148
4660{ "fnmadds", A(59,31,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6149{"stvlxl", X(31,903), X_MASK, CELL, 0, {VS, RA0, RB}},
4661{ "fnmadds.",A(59,31,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6150{"stdfcmux", APU(31,903,0), APU_MASK, PPC405, 0, {FCRT, RA, RB}},
4662 6151
4663{ "dmul", XRC(59,34,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6152{"divdeuo", XO(31,393,1,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
4664{ "dmul.", XRC(59,34,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 6153{"divdeuo.", XO(31,393,1,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
6154{"divweuo", XO(31,395,1,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
6155{"divweuo.", XO(31,395,1,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
4665 6156
4666{ "drrnd", ZRC(59,35,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 6157{"stxvw4x", X(31,908), XX1_MASK, PPCVSX, 0, {XS6, RA0, RB}},
4667{ "drrnd.", ZRC(59,35,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 6158{"stxsibx", X(31,909), XX1_MASK, PPCVSX3, 0, {XS6, RA0, RB}},
4668 6159
4669{ "dscli", ZRC(59,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 6160{"tabort.", XRC(31,910,1), XRTRB_MASK, PPCHTM, 0, {RA}},
4670{ "dscli.", ZRC(59,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4671 6161
4672{ "dquai", ZRC(59,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, 6162{"tlbsx", XRC(31,914,0), X_MASK, PPC403|BOOKE|PPCA2|PPC476, 0, {RTO, RA0, RB}},
4673{ "dquai.", ZRC(59,67,1), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, 6163{"tlbsx.", XRC(31,914,1), X_MASK, PPC403|BOOKE|PPCA2|PPC476, 0, {RTO, RA0, RB}},
4674 6164
4675{ "dscri", ZRC(59,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 6165{"slbmfee", X(31,915), XRLA_MASK, POWER9, 0, {RT, RB, A_L}},
4676{ "dscri.", ZRC(59,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 6166{"slbmfee", X(31,915), XRA_MASK, PPC64, POWER9, {RT, RB}},
4677 6167
4678{ "drintx", ZRC(59,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 6168{"stwcix", X(31,917), X_MASK, POWER6, 0, {RS, RA0, RB}},
4679{ "drintx.", ZRC(59,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4680 6169
4681{ "dcmpo", X(59,130), X_MASK, POWER6, { BF, FRA, FRB } }, 6170{"sthbrx", X(31,918), X_MASK, COM, 0, {RS, RA0, RB}},
4682 6171
4683{ "dtstex", X(59,162), X_MASK, POWER6, { BF, FRA, FRB } }, 6172{"stfdpx", X(31,919), X_MASK, POWER6, POWER7, {FRSp, RA0, RB}},
4684{ "dtstdc", Z(59,194), Z_MASK, POWER6, { BF, FRA, DCM } }, 6173{"stfqx", X(31,919), X_MASK, POWER2, 0, {FRS, RA0, RB}},
4685{ "dtstdg", Z(59,226), Z_MASK, POWER6, { BF, FRA, DGM } },
4686 6174
4687{ "drintn", ZRC(59,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 6175{"sraq", XRC(31,920,0), X_MASK, M601, 0, {RA, RS, RB}},
4688{ "drintn.", ZRC(59,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 6176{"sraq.", XRC(31,920,1), X_MASK, M601, 0, {RA, RS, RB}},
4689 6177
4690{ "dctdp", XRC(59,258,0), X_MASK, POWER6, { FRT, FRB } }, 6178{"srea", XRC(31,921,0), X_MASK, M601, 0, {RA, RS, RB}},
4691{ "dctdp.", XRC(59,258,1), X_MASK, POWER6, { FRT, FRB } }, 6179{"srea.", XRC(31,921,1), X_MASK, M601, 0, {RA, RS, RB}},
4692 6180
4693{ "dctfix", XRC(59,290,0), X_MASK, POWER6, { FRT, FRB } }, 6181{"extsh", XRC(31,922,0), XRB_MASK, PPCCOM, 0, {RA, RS}},
4694{ "dctfix.", XRC(59,290,1), X_MASK, POWER6, { FRT, FRB } }, 6182{"exts", XRC(31,922,0), XRB_MASK, PWRCOM, 0, {RA, RS}},
6183{"extsh.", XRC(31,922,1), XRB_MASK, PPCCOM, 0, {RA, RS}},
6184{"exts.", XRC(31,922,1), XRB_MASK, PWRCOM, 0, {RA, RS}},
4695 6185
4696{ "ddedpd", XRC(59,322,0), X_MASK, POWER6, { SP, FRT, FRB } }, 6186{"stfddx", X(31,931), X_MASK, E500MC, 0, {FRS, RA, RB}},
4697{ "ddedpd.", XRC(59,322,1), X_MASK, POWER6, { SP, FRT, FRB } },
4698 6187
4699{ "dxex", XRC(59,354,0), X_MASK, POWER6, { FRT, FRB } }, 6188{"stvfrxl", X(31,933), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
4700{ "dxex.", XRC(59,354,1), X_MASK, POWER6, { FRT, FRB } },
4701 6189
4702{ "dsub", XRC(59,514,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6190{"wclrone", XOPL2(31,934,2),XRT_MASK, PPCA2, 0, {RA0, RB}},
4703{ "dsub.", XRC(59,514,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 6191{"wclrall", X(31,934), XRARB_MASK, PPCA2, 0, {L2}},
6192{"wclr", X(31,934), X_MASK, PPCA2, 0, {L2, RA0, RB}},
4704 6193
4705{ "ddiv", XRC(59,546,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6194{"stvrxl", X(31,935), X_MASK, CELL, 0, {VS, RA0, RB}},
4706{ "ddiv.", XRC(59,546,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4707 6195
4708{ "dcmpu", X(59,642), X_MASK, POWER6, { BF, FRA, FRB } }, 6196{"divdeo", XO(31,425,1,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
6197{"divdeo.", XO(31,425,1,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
6198{"divweo", XO(31,427,1,0), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
6199{"divweo.", XO(31,427,1,1), XO_MASK, POWER7|PPCA2, 0, {RT, RA, RB}},
4709 6200
4710{ "dtstsf", X(59,674), X_MASK, POWER6, { BF, FRA, FRB } }, 6201{"stxvh8x", X(31,940), XX1_MASK, PPCVSX3, 0, {XS6, RA0, RB}},
6202{"stxsihx", X(31,941), XX1_MASK, PPCVSX3, 0, {XS6, RA0, RB}},
4711 6203
4712{ "drsp", XRC(59,770,0), X_MASK, POWER6, { FRT, FRB } }, 6204{"treclaim.", XRC(31,942,1), XRTRB_MASK, PPCHTM, 0, {RA}},
4713{ "drsp.", XRC(59,770,1), X_MASK, POWER6, { FRT, FRB } },
4714 6205
4715{ "dcffix", XRC(59,802,0), X_MASK, POWER6, { FRT, FRB } }, 6206{"tlbrehi", XTLB(31,946,0), XTLB_MASK, PPC403, PPCA2, {RT, RA}},
4716{ "dcffix.", XRC(59,802,1), X_MASK, POWER6, { FRT, FRB } }, 6207{"tlbrelo", XTLB(31,946,1), XTLB_MASK, PPC403, PPCA2, {RT, RA}},
6208{"tlbre", X(31,946), X_MASK, PPC403|BOOKE|PPCA2|PPC476, 0, {RSO, RAOPT, SHO}},
4717 6209
4718{ "denbcd", XRC(59,834,0), X_MASK, POWER6, { S, FRT, FRB } }, 6210{"sthcix", X(31,949), X_MASK, POWER6, 0, {RS, RA0, RB}},
4719{ "denbcd.", XRC(59,834,1), X_MASK, POWER6, { S, FRT, FRB } },
4720 6211
4721{ "diex", XRC(59,866,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6212{"icswepx", XRC(31,950,0), X_MASK, PPCA2, 0, {RS, RA, RB}},
4722{ "diex.", XRC(59,866,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 6213{"icswepx.", XRC(31,950,1), X_MASK, PPCA2, 0, {RS, RA, RB}},
4723 6214
4724{ "stfq", OP(60), OP_MASK, POWER2, { FRS, D, RA } }, 6215{"stfqux", X(31,951), X_MASK, POWER2, 0, {FRS, RA, RB}},
4725 6216
4726{ "stfqu", OP(61), OP_MASK, POWER2, { FRS, D, RA } }, 6217{"sraiq", XRC(31,952,0), X_MASK, M601, 0, {RA, RS, SH}},
6218{"sraiq.", XRC(31,952,1), X_MASK, M601, 0, {RA, RS, SH}},
4727 6219
4728{ "stfdp", OP(61), OP_MASK, POWER6, { FRT, D, RA0 } }, 6220{"extsb", XRC(31,954,0), XRB_MASK, PPC, 0, {RA, RS}},
6221{"extsb.", XRC(31,954,1), XRB_MASK, PPC, 0, {RA, RS}},
4729 6222
4730{ "lde", DEO(62,0), DE_MASK, BOOKE64, { RT, DES, RA0 } }, 6223{"stvflxl", X(31,965), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
4731{ "ldue", DEO(62,1), DE_MASK, BOOKE64, { RT, DES, RA0 } },
4732{ "lfse", DEO(62,4), DE_MASK, BOOKE64, { FRT, DES, RA0 } },
4733{ "lfsue", DEO(62,5), DE_MASK, BOOKE64, { FRT, DES, RAS } },
4734{ "lfde", DEO(62,6), DE_MASK, BOOKE64, { FRT, DES, RA0 } },
4735{ "lfdue", DEO(62,7), DE_MASK, BOOKE64, { FRT, DES, RAS } },
4736{ "stde", DEO(62,8), DE_MASK, BOOKE64, { RS, DES, RA0 } },
4737{ "stdue", DEO(62,9), DE_MASK, BOOKE64, { RS, DES, RAS } },
4738{ "stfse", DEO(62,12), DE_MASK, BOOKE64, { FRS, DES, RA0 } },
4739{ "stfsue", DEO(62,13), DE_MASK, BOOKE64, { FRS, DES, RAS } },
4740{ "stfde", DEO(62,14), DE_MASK, BOOKE64, { FRS, DES, RA0 } },
4741{ "stfdue", DEO(62,15), DE_MASK, BOOKE64, { FRS, DES, RAS } },
4742 6224
4743{ "std", DSO(62,0), DS_MASK, PPC64, { RS, DS, RA0 } }, 6225{"iccci", X(31,966), XRT_MASK, PPC403|PPC440|TITAN|PPCA2, 0, {RAOPT, RBOPT}},
6226{"ici", X(31,966), XRARB_MASK, PPCA2|PPC476, 0, {CT}},
4744 6227
4745{ "stdu", DSO(62,1), DS_MASK, PPC64, { RS, DS, RAS } }, 6228{"divduo", XO(31,457,1,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
6229{"divduo.", XO(31,457,1,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
4746 6230
4747{ "stq", DSO(62,2), DS_MASK, POWER4, { RSQ, DS, RA0 } }, 6231{"divwuo", XO(31,459,1,0), XO_MASK, PPC, 0, {RT, RA, RB}},
6232{"divwuo.", XO(31,459,1,1), XO_MASK, PPC, 0, {RT, RA, RB}},
4748 6233
4749{ "fcmpu", X(63,0), X_MASK|(3<<21), COM, { BF, FRA, FRB } }, 6234{"stxvd2x", X(31,972), XX1_MASK, PPCVSX, 0, {XS6, RA0, RB}},
6235{"stxvx", X(31,972), XX1_MASK, POWER8, POWER9|PPCVSX3, {XS6, RA0, RB}},
4750 6236
4751{ "daddq", XRC(63,2,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6237{"tlbld", X(31,978), XRTRA_MASK, PPC, PPC403|BOOKE|PPCA2|PPC476, {RB}},
4752{ "daddq.", XRC(63,2,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 6238{"tlbwehi", XTLB(31,978,0), XTLB_MASK, PPC403, 0, {RT, RA}},
6239{"tlbwelo", XTLB(31,978,1), XTLB_MASK, PPC403, 0, {RT, RA}},
6240{"tlbwe", X(31,978), X_MASK, PPC403|BOOKE|PPCA2|PPC476, 0, {RSO, RAOPT, SHO}},
4753 6241
4754{ "dquaq", ZRC(63,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 6242{"slbfee.", XRC(31,979,1), XRA_MASK, POWER6, 0, {RT, RB}},
4755{ "dquaq.", ZRC(63,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4756 6243
4757{ "fcpsgn", XRC(63,8,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6244{"stbcix", X(31,981), X_MASK, POWER6, 0, {RS, RA0, RB}},
4758{ "fcpsgn.", XRC(63,8,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4759 6245
4760{ "frsp", XRC(63,12,0), XRA_MASK, COM, { FRT, FRB } }, 6246{"icbi", X(31,982), XRT_MASK, PPC, 0, {RA0, RB}},
4761{ "frsp.", XRC(63,12,1), XRA_MASK, COM, { FRT, FRB } },
4762 6247
4763{ "fctiw", XRC(63,14,0), XRA_MASK, PPCCOM, { FRT, FRB } }, 6248{"stfiwx", X(31,983), X_MASK, PPC, PPCEFS, {FRS, RA0, RB}},
4764{ "fcir", XRC(63,14,0), XRA_MASK, POWER2, { FRT, FRB } },
4765{ "fctiw.", XRC(63,14,1), XRA_MASK, PPCCOM, { FRT, FRB } },
4766{ "fcir.", XRC(63,14,1), XRA_MASK, POWER2, { FRT, FRB } },
4767 6249
4768{ "fctiwz", XRC(63,15,0), XRA_MASK, PPCCOM, { FRT, FRB } }, 6250{"extsw", XRC(31,986,0), XRB_MASK, PPC64, 0, {RA, RS}},
4769{ "fcirz", XRC(63,15,0), XRA_MASK, POWER2, { FRT, FRB } }, 6251{"extsw.", XRC(31,986,1), XRB_MASK, PPC64, 0, {RA, RS}},
4770{ "fctiwz.", XRC(63,15,1), XRA_MASK, PPCCOM, { FRT, FRB } },
4771{ "fcirz.", XRC(63,15,1), XRA_MASK, POWER2, { FRT, FRB } },
4772 6252
4773{ "fdiv", A(63,18,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, 6253{"icbiep", XRT(31,991,0), XRT_MASK, E500MC|PPCA2, 0, {RA0, RB}},
4774{ "fd", A(63,18,0), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
4775{ "fdiv.", A(63,18,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
4776{ "fd.", A(63,18,1), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
4777 6254
4778{ "fsub", A(63,20,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, 6255{"stvswxl", X(31,997), X_MASK, PPCVEC2, 0, {VS, RA0, RB}},
4779{ "fs", A(63,20,0), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
4780{ "fsub.", A(63,20,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
4781{ "fs.", A(63,20,1), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
4782 6256
4783{ "fadd", A(63,21,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, 6257{"icread", X(31,998), XRT_MASK, PPC403|PPC440|PPC476|TITAN, 0, {RA0, RB}},
4784{ "fa", A(63,21,0), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
4785{ "fadd.", A(63,21,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } },
4786{ "fa.", A(63,21,1), AFRC_MASK, PWRCOM, { FRT, FRA, FRB } },
4787 6258
4788{ "fsqrt", A(63,22,0), AFRAFRC_MASK, PPCPWR2, { FRT, FRB } }, 6259{"nabso", XO(31,488,1,0), XORB_MASK, M601, 0, {RT, RA}},
4789{ "fsqrt.", A(63,22,1), AFRAFRC_MASK, PPCPWR2, { FRT, FRB } }, 6260{"nabso.", XO(31,488,1,1), XORB_MASK, M601, 0, {RT, RA}},
4790 6261
4791{ "fsel", A(63,23,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6262{"divdo", XO(31,489,1,0), XO_MASK, PPC64, 0, {RT, RA, RB}},
4792{ "fsel.", A(63,23,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, 6263{"divdo.", XO(31,489,1,1), XO_MASK, PPC64, 0, {RT, RA, RB}},
4793 6264
4794{ "fre", A(63,24,0), AFRALFRC_MASK, POWER5, { FRT, FRB, A_L } }, 6265{"divwo", XO(31,491,1,0), XO_MASK, PPC, 0, {RT, RA, RB}},
4795{ "fre.", A(63,24,1), AFRALFRC_MASK, POWER5, { FRT, FRB, A_L } }, 6266{"divwo.", XO(31,491,1,1), XO_MASK, PPC, 0, {RT, RA, RB}},
4796 6267
4797{ "fmul", A(63,25,0), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } }, 6268{"stxvb16x", X(31,1004), XX1_MASK, PPCVSX3, 0, {XS6, RA0, RB}},
4798{ "fm", A(63,25,0), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } },
4799{ "fmul.", A(63,25,1), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } },
4800{ "fm.", A(63,25,1), AFRB_MASK, PWRCOM, { FRT, FRA, FRC } },
4801 6269
4802{ "frsqrte", A(63,26,0), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } }, 6270{"trechkpt.", XRC(31,1006,1), XRTRARB_MASK,PPCHTM, 0, {0}},
4803{ "frsqrte.",A(63,26,1), AFRALFRC_MASK, PPC, { FRT, FRB, A_L } },
4804 6271
4805{ "fmsub", A(63,28,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, 6272{"tlbli", X(31,1010), XRTRA_MASK, PPC, TITAN, {RB}},
4806{ "fms", A(63,28,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
4807{ "fmsub.", A(63,28,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
4808{ "fms.", A(63,28,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
4809 6273
4810{ "fmadd", A(63,29,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, 6274{"stdcix", X(31,1013), X_MASK, POWER6, 0, {RS, RA0, RB}},
4811{ "fma", A(63,29,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
4812{ "fmadd.", A(63,29,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
4813{ "fma.", A(63,29,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
4814 6275
4815{ "fnmsub", A(63,30,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, 6276{"dcbz", X(31,1014), XRT_MASK, PPC, 0, {RA0, RB}},
4816{ "fnms", A(63,30,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } }, 6277{"dclz", X(31,1014), XRT_MASK, PPC, 0, {RA0, RB}},
4817{ "fnmsub.", A(63,30,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
4818{ "fnms.", A(63,30,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
4819 6278
4820{ "fnmadd", A(63,31,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, 6279{"dcbzep", XRT(31,1023,0), XRT_MASK, E500MC|PPCA2, 0, {RA0, RB}},
4821{ "fnma", A(63,31,0), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
4822{ "fnmadd.", A(63,31,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } },
4823{ "fnma.", A(63,31,1), A_MASK, PWRCOM, { FRT,FRA,FRC,FRB } },
4824 6280
4825{ "fcmpo", X(63,32), X_MASK|(3<<21), COM, { BF, FRA, FRB } }, 6281{"dcbzl", XOPL(31,1014,1), XRT_MASK, POWER4|E500MC, PPC476, {RA0, RB}},
4826 6282
4827{ "dmulq", XRC(63,34,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6283{"cctpl", 0x7c210b78, 0xffffffff, CELL, 0, {0}},
4828{ "dmulq.", XRC(63,34,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 6284{"cctpm", 0x7c421378, 0xffffffff, CELL, 0, {0}},
6285{"cctph", 0x7c631b78, 0xffffffff, CELL, 0, {0}},
4829 6286
4830{ "drrndq", ZRC(63,35,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 6287{"dstt", XDSS(31,342,1), XDSS_MASK, PPCVEC, 0, {RA, RB, STRM}},
4831{ "drrndq.", ZRC(63,35,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, 6288{"dststt", XDSS(31,374,1), XDSS_MASK, PPCVEC, 0, {RA, RB, STRM}},
6289{"dssall", XDSS(31,822,1), XDSS_MASK, PPCVEC, 0, {0}},
4832 6290
4833{ "mtfsb1", XRC(63,38,0), XRARB_MASK, COM, { BT } }, 6291{"db8cyc", 0x7f9ce378, 0xffffffff, CELL, 0, {0}},
4834{ "mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, { BT } }, 6292{"db10cyc", 0x7fbdeb78, 0xffffffff, CELL, 0, {0}},
6293{"db12cyc", 0x7fdef378, 0xffffffff, CELL, 0, {0}},
6294{"db16cyc", 0x7ffffb78, 0xffffffff, CELL, 0, {0}},
4835 6295
4836{ "fneg", XRC(63,40,0), XRA_MASK, COM, { FRT, FRB } }, 6296{"lwz", OP(32), OP_MASK, PPCCOM, PPCVLE, {RT, D, RA0}},
4837{ "fneg.", XRC(63,40,1), XRA_MASK, COM, { FRT, FRB } }, 6297{"l", OP(32), OP_MASK, PWRCOM, PPCVLE, {RT, D, RA0}},
4838 6298
4839{ "mcrfs", X(63,64), XRB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } }, 6299{"lwzu", OP(33), OP_MASK, PPCCOM, PPCVLE, {RT, D, RAL}},
6300{"lu", OP(33), OP_MASK, PWRCOM, PPCVLE, {RT, D, RA0}},
4840 6301
4841{ "dscliq", ZRC(63,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 6302{"lbz", OP(34), OP_MASK, COM, PPCVLE, {RT, D, RA0}},
4842{ "dscliq.", ZRC(63,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4843 6303
4844{ "dquaiq", ZRC(63,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, 6304{"lbzu", OP(35), OP_MASK, COM, PPCVLE, {RT, D, RAL}},
4845{ "dquaiq.", ZRC(63,67,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } },
4846 6305
4847{ "mtfsb0", XRC(63,70,0), XRARB_MASK, COM, { BT } }, 6306{"stw", OP(36), OP_MASK, PPCCOM, PPCVLE, {RS, D, RA0}},
4848{ "mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, { BT } }, 6307{"st", OP(36), OP_MASK, PWRCOM, PPCVLE, {RS, D, RA0}},
4849 6308
4850{ "fmr", XRC(63,72,0), XRA_MASK, COM, { FRT, FRB } }, 6309{"stwu", OP(37), OP_MASK, PPCCOM, PPCVLE, {RS, D, RAS}},
4851{ "fmr.", XRC(63,72,1), XRA_MASK, COM, { FRT, FRB } }, 6310{"stu", OP(37), OP_MASK, PWRCOM, PPCVLE, {RS, D, RA0}},
4852 6311
4853{ "dscriq", ZRC(63,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, 6312{"stb", OP(38), OP_MASK, COM, PPCVLE, {RS, D, RA0}},
4854{ "dscriq.", ZRC(63,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } },
4855 6313
4856{ "drintxq", ZRC(63,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 6314{"stbu", OP(39), OP_MASK, COM, PPCVLE, {RS, D, RAS}},
4857{ "drintxq.",ZRC(63,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4858 6315
4859{ "dcmpoq", X(63,130), X_MASK, POWER6, { BF, FRA, FRB } }, 6316{"lhz", OP(40), OP_MASK, COM, PPCVLE, {RT, D, RA0}},
4860 6317
4861{ "mtfsfi", XRC(63,134,0), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } }, 6318{"lhzu", OP(41), OP_MASK, COM, PPCVLE, {RT, D, RAL}},
4862{ "mtfsfi.", XRC(63,134,1), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } },
4863 6319
4864{ "fnabs", XRC(63,136,0), XRA_MASK, COM, { FRT, FRB } }, 6320{"lha", OP(42), OP_MASK, COM, PPCVLE, {RT, D, RA0}},
4865{ "fnabs.", XRC(63,136,1), XRA_MASK, COM, { FRT, FRB } },
4866 6321
4867{ "dtstexq", X(63,162), X_MASK, POWER6, { BF, FRA, FRB } }, 6322{"lhau", OP(43), OP_MASK, COM, PPCVLE, {RT, D, RAL}},
4868{ "dtstdcq", Z(63,194), Z_MASK, POWER6, { BF, FRA, DCM } },
4869{ "dtstdgq", Z(63,226), Z_MASK, POWER6, { BF, FRA, DGM } },
4870 6323
4871{ "drintnq", ZRC(63,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, 6324{"sth", OP(44), OP_MASK, COM, PPCVLE, {RS, D, RA0}},
4872{ "drintnq.",ZRC(63,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } },
4873 6325
4874{ "dctqpq", XRC(63,258,0), X_MASK, POWER6, { FRT, FRB } }, 6326{"sthu", OP(45), OP_MASK, COM, PPCVLE, {RS, D, RAS}},
4875{ "dctqpq.", XRC(63,258,1), X_MASK, POWER6, { FRT, FRB } },
4876 6327
4877{ "fabs", XRC(63,264,0), XRA_MASK, COM, { FRT, FRB } }, 6328{"lmw", OP(46), OP_MASK, PPCCOM, PPCVLE, {RT, D, RAM}},
4878{ "fabs.", XRC(63,264,1), XRA_MASK, COM, { FRT, FRB } }, 6329{"lm", OP(46), OP_MASK, PWRCOM, PPCVLE, {RT, D, RA0}},
4879 6330
4880{ "dctfixq", XRC(63,290,0), X_MASK, POWER6, { FRT, FRB } }, 6331{"stmw", OP(47), OP_MASK, PPCCOM, PPCVLE, {RS, D, RA0}},
4881{ "dctfixq.",XRC(63,290,1), X_MASK, POWER6, { FRT, FRB } }, 6332{"stm", OP(47), OP_MASK, PWRCOM, PPCVLE, {RS, D, RA0}},
4882 6333
4883{ "ddedpdq", XRC(63,322,0), X_MASK, POWER6, { SP, FRT, FRB } }, 6334{"lfs", OP(48), OP_MASK, COM, PPCEFS|PPCVLE, {FRT, D, RA0}},
4884{ "ddedpdq.",XRC(63,322,1), X_MASK, POWER6, { SP, FRT, FRB } },
4885 6335
4886{ "dxexq", XRC(63,354,0), X_MASK, POWER6, { FRT, FRB } }, 6336{"lfsu", OP(49), OP_MASK, COM, PPCEFS|PPCVLE, {FRT, D, RAS}},
4887{ "dxexq.", XRC(63,354,1), X_MASK, POWER6, { FRT, FRB } },
4888 6337
4889{ "frin", XRC(63,392,0), XRA_MASK, POWER5, { FRT, FRB } }, 6338{"lfd", OP(50), OP_MASK, COM, PPCEFS|PPCVLE, {FRT, D, RA0}},
4890{ "frin.", XRC(63,392,1), XRA_MASK, POWER5, { FRT, FRB } },
4891{ "friz", XRC(63,424,0), XRA_MASK, POWER5, { FRT, FRB } },
4892{ "friz.", XRC(63,424,1), XRA_MASK, POWER5, { FRT, FRB } },
4893{ "frip", XRC(63,456,0), XRA_MASK, POWER5, { FRT, FRB } },
4894{ "frip.", XRC(63,456,1), XRA_MASK, POWER5, { FRT, FRB } },
4895{ "frim", XRC(63,488,0), XRA_MASK, POWER5, { FRT, FRB } },
4896{ "frim.", XRC(63,488,1), XRA_MASK, POWER5, { FRT, FRB } },
4897 6339
4898{ "dsubq", XRC(63,514,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6340{"lfdu", OP(51), OP_MASK, COM, PPCEFS|PPCVLE, {FRT, D, RAS}},
4899{ "dsubq.", XRC(63,514,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4900 6341
4901{ "ddivq", XRC(63,546,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6342{"stfs", OP(52), OP_MASK, COM, PPCEFS|PPCVLE, {FRS, D, RA0}},
4902{ "ddivq.", XRC(63,546,1), X_MASK, POWER6, { FRT, FRA, FRB } },
4903 6343
4904{ "mffs", XRC(63,583,0), XRARB_MASK, COM, { FRT } }, 6344{"stfsu", OP(53), OP_MASK, COM, PPCEFS|PPCVLE, {FRS, D, RAS}},
4905{ "mffs.", XRC(63,583,1), XRARB_MASK, COM, { FRT } },
4906 6345
4907{ "dcmpuq", X(63,642), X_MASK, POWER6, { BF, FRA, FRB } }, 6346{"stfd", OP(54), OP_MASK, COM, PPCEFS|PPCVLE, {FRS, D, RA0}},
4908 6347
4909{ "dtstsfq", X(63,674), X_MASK, POWER6, { BF, FRA, FRB } }, 6348{"stfdu", OP(55), OP_MASK, COM, PPCEFS|PPCVLE, {FRS, D, RAS}},
4910 6349
4911{ "mtfsf", XFL(63,711,0), XFL_MASK, COM, { FLM, FRB } }, 6350{"lq", OP(56), OP_MASK, POWER4, PPC476|PPCVLE, {RTQ, DQ, RAQ}},
4912{ "mtfsf.", XFL(63,711,1), XFL_MASK, COM, { FLM, FRB } }, 6351{"psq_l", OP(56), OP_MASK, PPCPS, PPCVLE, {FRT,PSD,RA,PSW,PSQ}},
6352{"lfq", OP(56), OP_MASK, POWER2, PPCVLE, {FRT, D, RA0}},
4913 6353
4914{ "drdpq", XRC(63,770,0), X_MASK, POWER6, { FRT, FRB } }, 6354{"lxsd", DSO(57,2), DS_MASK, PPCVSX3, PPCVLE, {VD, DS, RA0}},
4915{ "drdpq.", XRC(63,770,1), X_MASK, POWER6, { FRT, FRB } }, 6355{"lxssp", DSO(57,3), DS_MASK, PPCVSX3, PPCVLE, {VD, DS, RA0}},
6356{"lfdp", OP(57), OP_MASK, POWER6, POWER7|PPCVLE, {FRTp, DS, RA0}},
6357{"psq_lu", OP(57), OP_MASK, PPCPS, PPCVLE, {FRT,PSD,RA,PSW,PSQ}},
6358{"lfqu", OP(57), OP_MASK, POWER2, PPCVLE, {FRT, D, RA0}},
4916 6359
4917{ "dcffixq", XRC(63,802,0), X_MASK, POWER6, { FRT, FRB } }, 6360{"ld", DSO(58,0), DS_MASK, PPC64, PPCVLE, {RT, DS, RA0}},
4918{ "dcffixq.",XRC(63,802,1), X_MASK, POWER6, { FRT, FRB } }, 6361{"ldu", DSO(58,1), DS_MASK, PPC64, PPCVLE, {RT, DS, RAL}},
6362{"lwa", DSO(58,2), DS_MASK, PPC64, PPCVLE, {RT, DS, RA0}},
4919 6363
4920{ "fctid", XRC(63,814,0), XRA_MASK, PPC64, { FRT, FRB } }, 6364{"dadd", XRC(59,2,0), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
4921{ "fctid.", XRC(63,814,1), XRA_MASK, PPC64, { FRT, FRB } }, 6365{"dadd.", XRC(59,2,1), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
4922 6366
4923{ "fctidz", XRC(63,815,0), XRA_MASK, PPC64, { FRT, FRB } }, 6367{"dqua", ZRC(59,3,0), Z2_MASK, POWER6, PPCVLE, {FRT,FRA,FRB,RMC}},
4924{ "fctidz.", XRC(63,815,1), XRA_MASK, PPC64, { FRT, FRB } }, 6368{"dqua.", ZRC(59,3,1), Z2_MASK, POWER6, PPCVLE, {FRT,FRA,FRB,RMC}},
4925 6369
4926{ "denbcdq", XRC(63,834,0), X_MASK, POWER6, { S, FRT, FRB } }, 6370{"fdivs", A(59,18,0), AFRC_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
4927{ "denbcdq.",XRC(63,834,1), X_MASK, POWER6, { S, FRT, FRB } }, 6371{"fdivs.", A(59,18,1), AFRC_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
4928 6372
4929{ "fcfid", XRC(63,846,0), XRA_MASK, PPC64, { FRT, FRB } }, 6373{"fsubs", A(59,20,0), AFRC_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
4930{ "fcfid.", XRC(63,846,1), XRA_MASK, PPC64, { FRT, FRB } }, 6374{"fsubs.", A(59,20,1), AFRC_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
4931 6375
4932{ "diexq", XRC(63,866,0), X_MASK, POWER6, { FRT, FRA, FRB } }, 6376{"fadds", A(59,21,0), AFRC_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
4933{ "diexq.", XRC(63,866,1), X_MASK, POWER6, { FRT, FRA, FRB } }, 6377{"fadds.", A(59,21,1), AFRC_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
4934 6378
6379{"fsqrts", A(59,22,0), AFRAFRC_MASK, PPC, TITAN|PPCVLE, {FRT, FRB}},
6380{"fsqrts.", A(59,22,1), AFRAFRC_MASK, PPC, TITAN|PPCVLE, {FRT, FRB}},
6381
6382{"fres", A(59,24,0), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6383{"fres", A(59,24,0), AFRALFRC_MASK, PPC, POWER7|PPCVLE, {FRT, FRB, A_L}},
6384{"fres.", A(59,24,1), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6385{"fres.", A(59,24,1), AFRALFRC_MASK, PPC, POWER7|PPCVLE, {FRT, FRB, A_L}},
6386
6387{"fmuls", A(59,25,0), AFRB_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC}},
6388{"fmuls.", A(59,25,1), AFRB_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC}},
6389
6390{"frsqrtes", A(59,26,0), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6391{"frsqrtes", A(59,26,0), AFRALFRC_MASK, POWER5, POWER7|PPCVLE, {FRT, FRB, A_L}},
6392{"frsqrtes.", A(59,26,1), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6393{"frsqrtes.", A(59,26,1), AFRALFRC_MASK, POWER5, POWER7|PPCVLE, {FRT, FRB, A_L}},
6394
6395{"fmsubs", A(59,28,0), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6396{"fmsubs.", A(59,28,1), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6397
6398{"fmadds", A(59,29,0), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6399{"fmadds.", A(59,29,1), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6400
6401{"fnmsubs", A(59,30,0), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6402{"fnmsubs.", A(59,30,1), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6403
6404{"fnmadds", A(59,31,0), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6405{"fnmadds.", A(59,31,1), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6406
6407{"dmul", XRC(59,34,0), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6408{"dmul.", XRC(59,34,1), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6409
6410{"drrnd", ZRC(59,35,0), Z2_MASK, POWER6, PPCVLE, {FRT, FRA, FRB, RMC}},
6411{"drrnd.", ZRC(59,35,1), Z2_MASK, POWER6, PPCVLE, {FRT, FRA, FRB, RMC}},
6412
6413{"dscli", ZRC(59,66,0), Z_MASK, POWER6, PPCVLE, {FRT, FRA, SH16}},
6414{"dscli.", ZRC(59,66,1), Z_MASK, POWER6, PPCVLE, {FRT, FRA, SH16}},
6415
6416{"dquai", ZRC(59,67,0), Z2_MASK, POWER6, PPCVLE, {TE, FRT,FRB,RMC}},
6417{"dquai.", ZRC(59,67,1), Z2_MASK, POWER6, PPCVLE, {TE, FRT,FRB,RMC}},
6418
6419{"dscri", ZRC(59,98,0), Z_MASK, POWER6, PPCVLE, {FRT, FRA, SH16}},
6420{"dscri.", ZRC(59,98,1), Z_MASK, POWER6, PPCVLE, {FRT, FRA, SH16}},
6421
6422{"drintx", ZRC(59,99,0), Z2_MASK, POWER6, PPCVLE, {R, FRT, FRB, RMC}},
6423{"drintx.", ZRC(59,99,1), Z2_MASK, POWER6, PPCVLE, {R, FRT, FRB, RMC}},
6424
6425{"dcmpo", X(59,130), X_MASK, POWER6, PPCVLE, {BF, FRA, FRB}},
6426
6427{"dtstex", X(59,162), X_MASK, POWER6, PPCVLE, {BF, FRA, FRB}},
6428{"dtstdc", Z(59,194), Z_MASK, POWER6, PPCVLE, {BF, FRA, DCM}},
6429{"dtstdg", Z(59,226), Z_MASK, POWER6, PPCVLE, {BF, FRA, DGM}},
6430
6431{"drintn", ZRC(59,227,0), Z2_MASK, POWER6, PPCVLE, {R, FRT, FRB, RMC}},
6432{"drintn.", ZRC(59,227,1), Z2_MASK, POWER6, PPCVLE, {R, FRT, FRB, RMC}},
6433
6434{"dctdp", XRC(59,258,0), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6435{"dctdp.", XRC(59,258,1), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6436
6437{"dctfix", XRC(59,290,0), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6438{"dctfix.", XRC(59,290,1), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6439
6440{"ddedpd", XRC(59,322,0), X_MASK, POWER6, PPCVLE, {SP, FRT, FRB}},
6441{"ddedpd.", XRC(59,322,1), X_MASK, POWER6, PPCVLE, {SP, FRT, FRB}},
6442
6443{"dxex", XRC(59,354,0), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6444{"dxex.", XRC(59,354,1), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6445
6446{"dsub", XRC(59,514,0), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6447{"dsub.", XRC(59,514,1), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6448
6449{"ddiv", XRC(59,546,0), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6450{"ddiv.", XRC(59,546,1), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6451
6452{"dcmpu", X(59,642), X_MASK, POWER6, PPCVLE, {BF, FRA, FRB}},
6453
6454{"dtstsf", X(59,674), X_MASK, POWER6, PPCVLE, {BF, FRA, FRB}},
6455{"dtstsfi", X(59,675), X_MASK|1<<22,POWER9, PPCVLE, {BF, UIM6, FRB}},
6456
6457{"drsp", XRC(59,770,0), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6458{"drsp.", XRC(59,770,1), X_MASK, POWER6, PPCVLE, {FRT, FRB}},
6459
6460{"dcffix", XRC(59,802,0), X_MASK|FRA_MASK, POWER7, PPCVLE, {FRT, FRB}},
6461{"dcffix.", XRC(59,802,1), X_MASK|FRA_MASK, POWER7, PPCVLE, {FRT, FRB}},
6462
6463{"denbcd", XRC(59,834,0), X_MASK, POWER6, PPCVLE, {S, FRT, FRB}},
6464{"denbcd.", XRC(59,834,1), X_MASK, POWER6, PPCVLE, {S, FRT, FRB}},
6465
6466{"fcfids", XRC(59,846,0), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6467{"fcfids.", XRC(59,846,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6468
6469{"diex", XRC(59,866,0), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6470{"diex.", XRC(59,866,1), X_MASK, POWER6, PPCVLE, {FRT, FRA, FRB}},
6471
6472{"fcfidus", XRC(59,974,0), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6473{"fcfidus.", XRC(59,974,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6474
6475{"xsaddsp", XX3(60,0), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6476{"xsmaddasp", XX3(60,1), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6477{"xxsldwi", XX3(60,2), XX3SHW_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6, SHW}},
6478{"xscmpeqdp", XX3(60,3), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6479{"xsrsqrtesp", XX2(60,10), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6480{"xssqrtsp", XX2(60,11), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6481{"xxsel", XX4(60,3), XX4_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6, XC6}},
6482{"xssubsp", XX3(60,8), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6483{"xsmaddmsp", XX3(60,9), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6484{"xxspltd", XX3(60,10), XX3DM_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6S, DMEX}},
6485{"xxmrghd", XX3(60,10), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6486{"xxswapd", XX3(60,10)|(2<<8), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6S}},
6487{"xxmrgld", XX3(60,10)|(3<<8), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6488{"xxpermdi", XX3(60,10), XX3DM_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6, DM}},
6489{"xscmpgtdp", XX3(60,11), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6490{"xsresp", XX2(60,26), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6491{"xsmulsp", XX3(60,16), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6492{"xsmsubasp", XX3(60,17), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6493{"xxmrghw", XX3(60,18), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6494{"xscmpgedp", XX3(60,19), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6495{"xsdivsp", XX3(60,24), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6496{"xsmsubmsp", XX3(60,25), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6497{"xxperm", XX3(60,26), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6498{"xsadddp", XX3(60,32), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6499{"xsmaddadp", XX3(60,33), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6500{"xscmpudp", XX3(60,35), XX3BF_MASK, PPCVSX, PPCVLE, {BF, XA6, XB6}},
6501{"xscvdpuxws", XX2(60,72), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6502{"xsrdpi", XX2(60,73), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6503{"xsrsqrtedp", XX2(60,74), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6504{"xssqrtdp", XX2(60,75), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6505{"xssubdp", XX3(60,40), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6506{"xsmaddmdp", XX3(60,41), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6507{"xscmpodp", XX3(60,43), XX3BF_MASK, PPCVSX, PPCVLE, {BF, XA6, XB6}},
6508{"xscvdpsxws", XX2(60,88), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6509{"xsrdpiz", XX2(60,89), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6510{"xsredp", XX2(60,90), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6511{"xsmuldp", XX3(60,48), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6512{"xsmsubadp", XX3(60,49), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6513{"xxmrglw", XX3(60,50), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6514{"xsrdpip", XX2(60,105), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6515{"xstsqrtdp", XX2(60,106), XX2BF_MASK, PPCVSX, PPCVLE, {BF, XB6}},
6516{"xsrdpic", XX2(60,107), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6517{"xsdivdp", XX3(60,56), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6518{"xsmsubmdp", XX3(60,57), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6519{"xxpermr", XX3(60,58), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6520{"xscmpexpdp", XX3(60,59), XX3BF_MASK, PPCVSX3, PPCVLE, {BF, XA6, XB6}},
6521{"xsrdpim", XX2(60,121), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6522{"xstdivdp", XX3(60,61), XX3BF_MASK, PPCVSX, PPCVLE, {BF, XA6, XB6}},
6523{"xvaddsp", XX3(60,64), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6524{"xvmaddasp", XX3(60,65), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6525{"xvcmpeqsp", XX3RC(60,67,0), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6526{"xvcmpeqsp.", XX3RC(60,67,1), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6527{"xvcvspuxws", XX2(60,136), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6528{"xvrspi", XX2(60,137), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6529{"xvrsqrtesp", XX2(60,138), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6530{"xvsqrtsp", XX2(60,139), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6531{"xvsubsp", XX3(60,72), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6532{"xvmaddmsp", XX3(60,73), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6533{"xvcmpgtsp", XX3RC(60,75,0), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6534{"xvcmpgtsp.", XX3RC(60,75,1), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6535{"xvcvspsxws", XX2(60,152), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6536{"xvrspiz", XX2(60,153), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6537{"xvresp", XX2(60,154), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6538{"xvmulsp", XX3(60,80), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6539{"xvmsubasp", XX3(60,81), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6540{"xxspltw", XX2(60,164), XX2UIM_MASK, PPCVSX, PPCVLE, {XT6, XB6, UIM}},
6541{"xxextractuw", XX2(60,165), XX2UIM4_MASK, PPCVSX3, PPCVLE, {XT6, XB6, UIMM4}},
6542{"xvcmpgesp", XX3RC(60,83,0), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6543{"xvcmpgesp.", XX3RC(60,83,1), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6544{"xvcvuxwsp", XX2(60,168), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6545{"xvrspip", XX2(60,169), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6546{"xvtsqrtsp", XX2(60,170), XX2BF_MASK, PPCVSX, PPCVLE, {BF, XB6}},
6547{"xvrspic", XX2(60,171), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6548{"xvdivsp", XX3(60,88), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6549{"xvmsubmsp", XX3(60,89), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6550{"xxspltib", X(60,360), XX1_MASK|3<<19, PPCVSX3, PPCVLE, {XT6, IMM8}},
6551{"xxinsertw", XX2(60,181), XX2UIM4_MASK, PPCVSX3, PPCVLE, {XT6, XB6, UIMM4}},
6552{"xvcvsxwsp", XX2(60,184), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6553{"xvrspim", XX2(60,185), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6554{"xvtdivsp", XX3(60,93), XX3BF_MASK, PPCVSX, PPCVLE, {BF, XA6, XB6}},
6555{"xvadddp", XX3(60,96), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6556{"xvmaddadp", XX3(60,97), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6557{"xvcmpeqdp", XX3RC(60,99,0), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6558{"xvcmpeqdp.", XX3RC(60,99,1), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6559{"xvcvdpuxws", XX2(60,200), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6560{"xvrdpi", XX2(60,201), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6561{"xvrsqrtedp", XX2(60,202), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6562{"xvsqrtdp", XX2(60,203), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6563{"xvsubdp", XX3(60,104), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6564{"xvmaddmdp", XX3(60,105), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6565{"xvcmpgtdp", XX3RC(60,107,0), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6566{"xvcmpgtdp.", XX3RC(60,107,1), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6567{"xvcvdpsxws", XX2(60,216), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6568{"xvrdpiz", XX2(60,217), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6569{"xvredp", XX2(60,218), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6570{"xvmuldp", XX3(60,112), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6571{"xvmsubadp", XX3(60,113), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6572{"xvcmpgedp", XX3RC(60,115,0), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6573{"xvcmpgedp.", XX3RC(60,115,1), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6574{"xvcvuxwdp", XX2(60,232), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6575{"xvrdpip", XX2(60,233), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6576{"xvtsqrtdp", XX2(60,234), XX2BF_MASK, PPCVSX, PPCVLE, {BF, XB6}},
6577{"xvrdpic", XX2(60,235), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6578{"xvdivdp", XX3(60,120), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6579{"xvmsubmdp", XX3(60,121), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6580{"xvcvsxwdp", XX2(60,248), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6581{"xvrdpim", XX2(60,249), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6582{"xvtdivdp", XX3(60,125), XX3BF_MASK, PPCVSX, PPCVLE, {BF, XA6, XB6}},
6583{"xsmaxcdp", XX3(60,128), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6584{"xsnmaddasp", XX3(60,129), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6585{"xxland", XX3(60,130), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6586{"xscvdpsp", XX2(60,265), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6587{"xscvdpspn", XX2(60,267), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6588{"xsmincdp", XX3(60,136), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6589{"xsnmaddmsp", XX3(60,137), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6590{"xxlandc", XX3(60,138), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6591{"xsrsp", XX2(60,281), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6592{"xsmaxjdp", XX3(60,144), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6593{"xsnmsubasp", XX3(60,145), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6594{"xxlor", XX3(60,146), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6595{"xscvuxdsp", XX2(60,296), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6596{"xststdcsp", XX2(60,298), XX2BFD_MASK, PPCVSX3, PPCVLE, {BF, XB6, DCMX}},
6597{"xsminjdp", XX3(60,152), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6598{"xsnmsubmsp", XX3(60,153), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6599{"xxlxor", XX3(60,154), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6600{"xscvsxdsp", XX2(60,312), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6601{"xsmaxdp", XX3(60,160), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6602{"xsnmaddadp", XX3(60,161), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6603{"xxlnor", XX3(60,162), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6604{"xscvdpuxds", XX2(60,328), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6605{"xscvspdp", XX2(60,329), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6606{"xscvspdpn", XX2(60,331), XX2_MASK, PPCVSX2, PPCVLE, {XT6, XB6}},
6607{"xsmindp", XX3(60,168), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6608{"xsnmaddmdp", XX3(60,169), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6609{"xxlorc", XX3(60,170), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6610{"xscvdpsxds", XX2(60,344), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6611{"xsabsdp", XX2(60,345), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6612{"xsxexpdp", XX2VA(60,347,0),XX2_MASK|1, PPCVSX3, PPCVLE, {RT, XB6}},
6613{"xsxsigdp", XX2VA(60,347,1),XX2_MASK|1, PPCVSX3, PPCVLE, {RT, XB6}},
6614{"xscvhpdp", XX2VA(60,347,16),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6615{"xscvdphp", XX2VA(60,347,17),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6616{"xscpsgndp", XX3(60,176), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6617{"xsnmsubadp", XX3(60,177), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6618{"xxlnand", XX3(60,178), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6619{"xscvuxddp", XX2(60,360), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6620{"xsnabsdp", XX2(60,361), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6621{"xststdcdp", XX2(60,362), XX2BFD_MASK, PPCVSX3, PPCVLE, {BF, XB6, DCMX}},
6622{"xsnmsubmdp", XX3(60,185), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6623{"xxleqv", XX3(60,186), XX3_MASK, PPCVSX2, PPCVLE, {XT6, XA6, XB6}},
6624{"xscvsxddp", XX2(60,376), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6625{"xsnegdp", XX2(60,377), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6626{"xvmaxsp", XX3(60,192), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6627{"xvnmaddasp", XX3(60,193), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6628{"xvcvspuxds", XX2(60,392), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6629{"xvcvdpsp", XX2(60,393), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6630{"xvminsp", XX3(60,200), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6631{"xvnmaddmsp", XX3(60,201), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6632{"xvcvspsxds", XX2(60,408), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6633{"xvabssp", XX2(60,409), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6634{"xvmovsp", XX3(60,208), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6S}},
6635{"xvcpsgnsp", XX3(60,208), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6636{"xvnmsubasp", XX3(60,209), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6637{"xvcvuxdsp", XX2(60,424), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6638{"xvnabssp", XX2(60,425), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6639{"xvtstdcsp", XX2(60,426), XX2DCMXS_MASK, PPCVSX3, PPCVLE, {XT6, XB6, DCMXS}},
6640{"xviexpsp", XX3(60,216), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6641{"xvnmsubmsp", XX3(60,217), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6642{"xvcvsxdsp", XX2(60,440), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6643{"xvnegsp", XX2(60,441), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6644{"xvmaxdp", XX3(60,224), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6645{"xvnmaddadp", XX3(60,225), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6646{"xvcvdpuxds", XX2(60,456), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6647{"xvcvspdp", XX2(60,457), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6648{"xsiexpdp", X(60,918), XX1_MASK, PPCVSX3, PPCVLE, {XT6, RA, RB}},
6649{"xvmindp", XX3(60,232), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6650{"xvnmaddmdp", XX3(60,233), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6651{"xvcvdpsxds", XX2(60,472), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6652{"xvabsdp", XX2(60,473), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6653{"xvxexpdp", XX2VA(60,475,0),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6654{"xvxsigdp", XX2VA(60,475,1),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6655{"xxbrh", XX2VA(60,475,7),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6656{"xvxexpsp", XX2VA(60,475,8),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6657{"xvxsigsp", XX2VA(60,475,9),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6658{"xxbrw", XX2VA(60,475,15),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6659{"xxbrd", XX2VA(60,475,23),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6660{"xvcvhpsp", XX2VA(60,475,24),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6661{"xvcvsphp", XX2VA(60,475,25),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6662{"xxbrq", XX2VA(60,475,31),XX2_MASK, PPCVSX3, PPCVLE, {XT6, XB6}},
6663{"xvmovdp", XX3(60,240), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6S}},
6664{"xvcpsgndp", XX3(60,240), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6665{"xvnmsubadp", XX3(60,241), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6666{"xvcvuxddp", XX2(60,488), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6667{"xvnabsdp", XX2(60,489), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6668{"xvtstdcdp", XX2(60,490), XX2DCMXS_MASK, PPCVSX3, PPCVLE, {XT6, XB6, DCMXS}},
6669{"xviexpdp", XX3(60,248), XX3_MASK, PPCVSX3, PPCVLE, {XT6, XA6, XB6}},
6670{"xvnmsubmdp", XX3(60,249), XX3_MASK, PPCVSX, PPCVLE, {XT6, XA6, XB6}},
6671{"xvcvsxddp", XX2(60,504), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6672{"xvnegdp", XX2(60,505), XX2_MASK, PPCVSX, PPCVLE, {XT6, XB6}},
6673
6674{"psq_st", OP(60), OP_MASK, PPCPS, PPCVLE, {FRS,PSD,RA,PSW,PSQ}},
6675{"stfq", OP(60), OP_MASK, POWER2, PPCVLE, {FRS, D, RA}},
6676
6677{"lxv", DQX(61,1), DQX_MASK, PPCVSX3, PPCVLE, {XTQ6, DQ, RA0}},
6678{"stxv", DQX(61,5), DQX_MASK, PPCVSX3, PPCVLE, {XSQ6, DQ, RA0}},
6679{"stxsd", DSO(61,2), DS_MASK, PPCVSX3, PPCVLE, {VS, DS, RA0}},
6680{"stxssp", DSO(61,3), DS_MASK, PPCVSX3, PPCVLE, {VS, DS, RA0}},
6681{"stfdp", OP(61), OP_MASK, POWER6, POWER7|PPCVLE, {FRSp, DS, RA0}},
6682{"psq_stu", OP(61), OP_MASK, PPCPS, PPCVLE, {FRS,PSD,RA,PSW,PSQ}},
6683{"stfqu", OP(61), OP_MASK, POWER2, PPCVLE, {FRS, D, RA}},
6684
6685{"std", DSO(62,0), DS_MASK, PPC64, PPCVLE, {RS, DS, RA0}},
6686{"stdu", DSO(62,1), DS_MASK, PPC64, PPCVLE, {RS, DS, RAS}},
6687{"stq", DSO(62,2), DS_MASK, POWER4, PPC476|PPCVLE, {RSQ, DS, RA0}},
6688
6689{"fcmpu", X(63,0), XBF_MASK, COM, PPCEFS|PPCVLE, {BF, FRA, FRB}},
6690
6691{"daddq", XRC(63,2,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6692{"daddq.", XRC(63,2,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6693
6694{"dquaq", ZRC(63,3,0), Z2_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp, RMC}},
6695{"dquaq.", ZRC(63,3,1), Z2_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp, RMC}},
6696
6697{"xsaddqp", XRC(63,4,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6698{"xsaddqpo", XRC(63,4,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6699
6700{"xsrqpi", ZRC(63,5,0), Z2_MASK, PPCVSX3, PPCVLE, {R, VD, VB, RMC}},
6701{"xsrqpix", ZRC(63,5,1), Z2_MASK, PPCVSX3, PPCVLE, {R, VD, VB, RMC}},
6702
6703{"fcpsgn", XRC(63,8,0), X_MASK, POWER6|PPCA2|PPC476, PPCVLE, {FRT, FRA, FRB}},
6704{"fcpsgn.", XRC(63,8,1), X_MASK, POWER6|PPCA2|PPC476, PPCVLE, {FRT, FRA, FRB}},
6705
6706{"frsp", XRC(63,12,0), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6707{"frsp.", XRC(63,12,1), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6708
6709{"fctiw", XRC(63,14,0), XRA_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRB}},
6710{"fcir", XRC(63,14,0), XRA_MASK, PWR2COM, PPCVLE, {FRT, FRB}},
6711{"fctiw.", XRC(63,14,1), XRA_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRB}},
6712{"fcir.", XRC(63,14,1), XRA_MASK, PWR2COM, PPCVLE, {FRT, FRB}},
6713
6714{"fctiwz", XRC(63,15,0), XRA_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRB}},
6715{"fcirz", XRC(63,15,0), XRA_MASK, PWR2COM, PPCVLE, {FRT, FRB}},
6716{"fctiwz.", XRC(63,15,1), XRA_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRB}},
6717{"fcirz.", XRC(63,15,1), XRA_MASK, PWR2COM, PPCVLE, {FRT, FRB}},
6718
6719{"fdiv", A(63,18,0), AFRC_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
6720{"fd", A(63,18,0), AFRC_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRB}},
6721{"fdiv.", A(63,18,1), AFRC_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
6722{"fd.", A(63,18,1), AFRC_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRB}},
6723
6724{"fsub", A(63,20,0), AFRC_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
6725{"fs", A(63,20,0), AFRC_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRB}},
6726{"fsub.", A(63,20,1), AFRC_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
6727{"fs.", A(63,20,1), AFRC_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRB}},
6728
6729{"fadd", A(63,21,0), AFRC_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
6730{"fa", A(63,21,0), AFRC_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRB}},
6731{"fadd.", A(63,21,1), AFRC_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRB}},
6732{"fa.", A(63,21,1), AFRC_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRB}},
6733
6734{"fsqrt", A(63,22,0), AFRAFRC_MASK, PPCPWR2, TITAN|PPCVLE, {FRT, FRB}},
6735{"fsqrt.", A(63,22,1), AFRAFRC_MASK, PPCPWR2, TITAN|PPCVLE, {FRT, FRB}},
6736
6737{"fsel", A(63,23,0), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6738{"fsel.", A(63,23,1), A_MASK, PPC, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6739
6740{"fre", A(63,24,0), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6741{"fre", A(63,24,0), AFRALFRC_MASK, POWER5, POWER7|PPCVLE, {FRT, FRB, A_L}},
6742{"fre.", A(63,24,1), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6743{"fre.", A(63,24,1), AFRALFRC_MASK, POWER5, POWER7|PPCVLE, {FRT, FRB, A_L}},
6744
6745{"fmul", A(63,25,0), AFRB_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC}},
6746{"fm", A(63,25,0), AFRB_MASK, PWRCOM, PPCVLE|PPCVLE, {FRT, FRA, FRC}},
6747{"fmul.", A(63,25,1), AFRB_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC}},
6748{"fm.", A(63,25,1), AFRB_MASK, PWRCOM, PPCVLE|PPCVLE, {FRT, FRA, FRC}},
6749
6750{"frsqrte", A(63,26,0), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6751{"frsqrte", A(63,26,0), AFRALFRC_MASK, PPC, POWER7|PPCVLE, {FRT, FRB, A_L}},
6752{"frsqrte.", A(63,26,1), AFRAFRC_MASK, POWER7, PPCVLE, {FRT, FRB}},
6753{"frsqrte.", A(63,26,1), AFRALFRC_MASK, PPC, POWER7|PPCVLE, {FRT, FRB, A_L}},
6754
6755{"fmsub", A(63,28,0), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6756{"fms", A(63,28,0), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6757{"fmsub.", A(63,28,1), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6758{"fms.", A(63,28,1), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6759
6760{"fmadd", A(63,29,0), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6761{"fma", A(63,29,0), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6762{"fmadd.", A(63,29,1), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6763{"fma.", A(63,29,1), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6764
6765{"fnmsub", A(63,30,0), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6766{"fnms", A(63,30,0), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6767{"fnmsub.", A(63,30,1), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6768{"fnms.", A(63,30,1), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6769
6770{"fnmadd", A(63,31,0), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6771{"fnma", A(63,31,0), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6772{"fnmadd.", A(63,31,1), A_MASK, PPCCOM, PPCEFS|PPCVLE, {FRT, FRA, FRC, FRB}},
6773{"fnma.", A(63,31,1), A_MASK, PWRCOM, PPCVLE, {FRT, FRA, FRC, FRB}},
6774
6775{"fcmpo", X(63,32), XBF_MASK, COM, PPCEFS|PPCVLE, {BF, FRA, FRB}},
6776
6777{"dmulq", XRC(63,34,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6778{"dmulq.", XRC(63,34,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6779
6780{"drrndq", ZRC(63,35,0), Z2_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp, RMC}},
6781{"drrndq.", ZRC(63,35,1), Z2_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp, RMC}},
6782
6783{"xsmulqp", XRC(63,36,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6784{"xsmulqpo", XRC(63,36,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6785
6786{"xsrqpxp", Z(63,37), Z2_MASK, PPCVSX3, PPCVLE, {R, VD, VB, RMC}},
6787
6788{"mtfsb1", XRC(63,38,0), XRARB_MASK, COM, PPCVLE, {BT}},
6789{"mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, PPCVLE, {BT}},
6790
6791{"fneg", XRC(63,40,0), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6792{"fneg.", XRC(63,40,1), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6793
6794{"mcrfs", X(63,64), XRB_MASK|(3<<21)|(3<<16), COM, PPCVLE, {BF, BFA}},
6795
6796{"dscliq", ZRC(63,66,0), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}},
6797{"dscliq.", ZRC(63,66,1), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}},
6798
6799{"dquaiq", ZRC(63,67,0), Z2_MASK, POWER6, PPCVLE, {TE, FRTp, FRBp, RMC}},
6800{"dquaiq.", ZRC(63,67,1), Z2_MASK, POWER6, PPCVLE, {TE, FRTp, FRBp, RMC}},
6801
6802{"mtfsb0", XRC(63,70,0), XRARB_MASK, COM, PPCVLE, {BT}},
6803{"mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, PPCVLE, {BT}},
6804
6805{"fmr", XRC(63,72,0), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6806{"fmr.", XRC(63,72,1), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6807
6808{"dscriq", ZRC(63,98,0), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}},
6809{"dscriq.", ZRC(63,98,1), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}},
6810
6811{"drintxq", ZRC(63,99,0), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}},
6812{"drintxq.", ZRC(63,99,1), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}},
6813
6814{"xscpsgnqp", X(63,100), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6815
6816{"ftdiv", X(63,128), XBF_MASK, POWER7, PPCVLE, {BF, FRA, FRB}},
6817
6818{"dcmpoq", X(63,130), X_MASK, POWER6, PPCVLE, {BF, FRAp, FRBp}},
6819
6820{"xscmpoqp", X(63,132), XBF_MASK, PPCVSX3, PPCVLE, {BF, VA, VB}},
6821
6822{"mtfsfi", XRC(63,134,0), XWRA_MASK|(3<<21)|(1<<11), POWER6|PPCA2|PPC476, PPCVLE, {BFF, U, W}},
6823{"mtfsfi", XRC(63,134,0), XRA_MASK|(3<<21)|(1<<11), COM, POWER6|PPCA2|PPC476|PPCVLE, {BFF, U}},
6824{"mtfsfi.", XRC(63,134,1), XWRA_MASK|(3<<21)|(1<<11), POWER6|PPCA2|PPC476, PPCVLE, {BFF, U, W}},
6825{"mtfsfi.", XRC(63,134,1), XRA_MASK|(3<<21)|(1<<11), COM, POWER6|PPCA2|PPC476|PPCVLE, {BFF, U}},
6826
6827{"fnabs", XRC(63,136,0), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6828{"fnabs.", XRC(63,136,1), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6829
6830{"fctiwu", XRC(63,142,0), XRA_MASK, POWER7, PPCVLE, {FRT, FRB}},
6831{"fctiwu.", XRC(63,142,1), XRA_MASK, POWER7, PPCVLE, {FRT, FRB}},
6832{"fctiwuz", XRC(63,143,0), XRA_MASK, POWER7, PPCVLE, {FRT, FRB}},
6833{"fctiwuz.", XRC(63,143,1), XRA_MASK, POWER7, PPCVLE, {FRT, FRB}},
6834
6835{"ftsqrt", X(63,160), XBF_MASK|FRA_MASK, POWER7, PPCVLE, {BF, FRB}},
6836
6837{"dtstexq", X(63,162), X_MASK, POWER6, PPCVLE, {BF, FRAp, FRBp}},
6838
6839{"xscmpexpqp", X(63,164), XBF_MASK, PPCVSX3, PPCVLE, {BF, VA, VB}},
6840
6841{"dtstdcq", Z(63,194), Z_MASK, POWER6, PPCVLE, {BF, FRAp, DCM}},
6842{"dtstdgq", Z(63,226), Z_MASK, POWER6, PPCVLE, {BF, FRAp, DGM}},
6843
6844{"drintnq", ZRC(63,227,0), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}},
6845{"drintnq.", ZRC(63,227,1), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}},
6846
6847{"dctqpq", XRC(63,258,0), X_MASK, POWER6, PPCVLE, {FRTp, FRB}},
6848{"dctqpq.", XRC(63,258,1), X_MASK, POWER6, PPCVLE, {FRTp, FRB}},
6849
6850{"fabs", XRC(63,264,0), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6851{"fabs.", XRC(63,264,1), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}},
6852
6853{"dctfixq", XRC(63,290,0), X_MASK, POWER6, PPCVLE, {FRT, FRBp}},
6854{"dctfixq.", XRC(63,290,1), X_MASK, POWER6, PPCVLE, {FRT, FRBp}},
6855
6856{"ddedpdq", XRC(63,322,0), X_MASK, POWER6, PPCVLE, {SP, FRTp, FRBp}},
6857{"ddedpdq.", XRC(63,322,1), X_MASK, POWER6, PPCVLE, {SP, FRTp, FRBp}},
6858
6859{"dxexq", XRC(63,354,0), X_MASK, POWER6, PPCVLE, {FRT, FRBp}},
6860{"dxexq.", XRC(63,354,1), X_MASK, POWER6, PPCVLE, {FRT, FRBp}},
6861
6862{"xsmaddqp", XRC(63,388,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6863{"xsmaddqpo", XRC(63,388,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6864
6865{"frin", XRC(63,392,0), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6866{"frin.", XRC(63,392,1), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6867
6868{"xsmsubqp", XRC(63,420,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6869{"xsmsubqpo", XRC(63,420,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6870
6871{"friz", XRC(63,424,0), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6872{"friz.", XRC(63,424,1), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6873
6874{"xsnmaddqp", XRC(63,452,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6875{"xsnmaddqpo", XRC(63,452,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6876
6877{"frip", XRC(63,456,0), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6878{"frip.", XRC(63,456,1), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6879
6880{"xsnmsubqp", XRC(63,484,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6881{"xsnmsubqpo", XRC(63,484,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6882
6883{"frim", XRC(63,488,0), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6884{"frim.", XRC(63,488,1), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}},
6885
6886{"dsubq", XRC(63,514,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6887{"dsubq.", XRC(63,514,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6888
6889{"xssubqp", XRC(63,516,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6890{"xssubqpo", XRC(63,516,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6891
6892{"ddivq", XRC(63,546,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6893{"ddivq.", XRC(63,546,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}},
6894
6895{"xsdivqp", XRC(63,548,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6896{"xsdivqpo", XRC(63,548,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6897
6898{"mffs", XRC(63,583,0), XRARB_MASK, COM, PPCEFS|PPCVLE, {FRT}},
6899{"mffs.", XRC(63,583,1), XRARB_MASK, COM, PPCEFS|PPCVLE, {FRT}},
6900
6901{"mffsce", XMMF(63,583,0,1), XMMF_MASK|RB_MASK, POWER9, PPCVLE, {FRT}},
6902{"mffscdrn", XMMF(63,583,2,4), XMMF_MASK, POWER9, PPCVLE, {FRT, FRB}},
6903{"mffscdrni", XMMF(63,583,2,5), XMMF_MASK|(3<<14), POWER9, PPCVLE, {FRT, DRM}},
6904{"mffscrn", XMMF(63,583,2,6), XMMF_MASK, POWER9, PPCVLE, {FRT, FRB}},
6905{"mffscrni", XMMF(63,583,2,7), XMMF_MASK|(7<<13), POWER9, PPCVLE, {FRT, RM}},
6906{"mffsl", XMMF(63,583,3,0), XMMF_MASK|RB_MASK, POWER9, PPCVLE, {FRT}},
6907
6908{"dcmpuq", X(63,642), X_MASK, POWER6, PPCVLE, {BF, FRAp, FRBp}},
6909
6910{"xscmpuqp", X(63,644), XBF_MASK, PPCVSX3, PPCVLE, {BF, VA, VB}},
6911
6912{"dtstsfq", X(63,674), X_MASK, POWER6, PPCVLE, {BF, FRA, FRBp}},
6913{"dtstsfiq", X(63,675), X_MASK|1<<22,POWER9, PPCVLE, {BF, UIM6, FRBp}},
6914
6915{"xststdcqp", X(63,708), X_MASK, PPCVSX3, PPCVLE, {BF, VB, DCMX}},
6916
6917{"mtfsf", XFL(63,711,0), XFL_MASK, POWER6|PPCA2|PPC476, PPCVLE, {FLM, FRB, XFL_L, W}},
6918{"mtfsf", XFL(63,711,0), XFL_MASK, COM, POWER6|PPCA2|PPC476|PPCEFS|PPCVLE, {FLM, FRB}},
6919{"mtfsf.", XFL(63,711,1), XFL_MASK, POWER6|PPCA2|PPC476, PPCVLE, {FLM, FRB, XFL_L, W}},
6920{"mtfsf.", XFL(63,711,1), XFL_MASK, COM, POWER6|PPCA2|PPC476|PPCEFS|PPCVLE, {FLM, FRB}},
6921
6922{"drdpq", XRC(63,770,0), X_MASK, POWER6, PPCVLE, {FRTp, FRBp}},
6923{"drdpq.", XRC(63,770,1), X_MASK, POWER6, PPCVLE, {FRTp, FRBp}},
6924
6925{"dcffixq", XRC(63,802,0), X_MASK, POWER6, PPCVLE, {FRTp, FRB}},
6926{"dcffixq.", XRC(63,802,1), X_MASK, POWER6, PPCVLE, {FRTp, FRB}},
6927
6928{"xsabsqp", XVA(63,804,0), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6929{"xsxexpqp", XVA(63,804,2), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6930{"xsnabsqp", XVA(63,804,8), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6931{"xsnegqp", XVA(63,804,16), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6932{"xsxsigqp", XVA(63,804,18), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6933{"xssqrtqp", XVARC(63,804,27,0), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6934{"xssqrtqpo", XVARC(63,804,27,1), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6935
6936{"fctid", XRC(63,814,0), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}},
6937{"fctid", XRC(63,814,0), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}},
6938{"fctid.", XRC(63,814,1), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}},
6939{"fctid.", XRC(63,814,1), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}},
6940
6941{"fctidz", XRC(63,815,0), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}},
6942{"fctidz", XRC(63,815,0), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}},
6943{"fctidz.", XRC(63,815,1), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}},
6944{"fctidz.", XRC(63,815,1), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}},
6945
6946{"denbcdq", XRC(63,834,0), X_MASK, POWER6, PPCVLE, {S, FRTp, FRBp}},
6947{"denbcdq.", XRC(63,834,1), X_MASK, POWER6, PPCVLE, {S, FRTp, FRBp}},
6948
6949{"xscvqpuwz", XVA(63,836,1), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6950{"xscvudqp", XVA(63,836,2), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6951{"xscvqpswz", XVA(63,836,9), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6952{"xscvsdqp", XVA(63,836,10), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6953{"xscvqpudz", XVA(63,836,17), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6954{"xscvqpdp", XVARC(63,836,20,0), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6955{"xscvqpdpo", XVARC(63,836,20,1), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6956{"xscvdpqp", XVA(63,836,22), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6957{"xscvqpsdz", XVA(63,836,25), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}},
6958
6959{"fmrgow", X(63,838), X_MASK, PPCVSX2, PPCVLE, {FRT, FRA, FRB}},
6960
6961{"fcfid", XRC(63,846,0), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}},
6962{"fcfid", XRC(63,846,0), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}},
6963{"fcfid.", XRC(63,846,1), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}},
6964{"fcfid.", XRC(63,846,1), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}},
6965
6966{"diexq", XRC(63,866,0), X_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp}},
6967{"diexq.", XRC(63,866,1), X_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp}},
6968
6969{"xsiexpqp", X(63,868), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}},
6970
6971{"fctidu", XRC(63,942,0), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6972{"fctidu.", XRC(63,942,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6973
6974{"fctiduz", XRC(63,943,0), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6975{"fctiduz.", XRC(63,943,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6976
6977{"fmrgew", X(63,966), X_MASK, PPCVSX2, PPCVLE, {FRT, FRA, FRB}},
6978
6979{"fcfidu", XRC(63,974,0), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6980{"fcfidu.", XRC(63,974,1), XRA_MASK, POWER7|PPCA2, PPCVLE, {FRT, FRB}},
6981};
6982
6983const int powerpc_num_opcodes =
6984 sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]);
6985
6986/* The VLE opcode table.
6987
6988 The format of this opcode table is the same as the main opcode table. */
6989
6990const struct powerpc_opcode vle_opcodes[] = {
6991{"se_illegal", C(0), C_MASK, PPCVLE, 0, {}},
6992{"se_isync", C(1), C_MASK, PPCVLE, 0, {}},
6993{"se_sc", C(2), C_MASK, PPCVLE, 0, {}},
6994{"se_blr", C_LK(2,0), C_LK_MASK, PPCVLE, 0, {}},
6995{"se_blrl", C_LK(2,1), C_LK_MASK, PPCVLE, 0, {}},
6996{"se_bctr", C_LK(3,0), C_LK_MASK, PPCVLE, 0, {}},
6997{"se_bctrl", C_LK(3,1), C_LK_MASK, PPCVLE, 0, {}},
6998{"se_rfi", C(8), C_MASK, PPCVLE, 0, {}},
6999{"se_rfci", C(9), C_MASK, PPCVLE, 0, {}},
7000{"se_rfdi", C(10), C_MASK, PPCVLE, 0, {}},
7001{"se_rfmci", C(11), C_MASK, PPCRFMCI|PPCVLE, 0, {}},
7002{"se_not", SE_R(0,2), SE_R_MASK, PPCVLE, 0, {RX}},
7003{"se_neg", SE_R(0,3), SE_R_MASK, PPCVLE, 0, {RX}},
7004{"se_mflr", SE_R(0,8), SE_R_MASK, PPCVLE, 0, {RX}},
7005{"se_mtlr", SE_R(0,9), SE_R_MASK, PPCVLE, 0, {RX}},
7006{"se_mfctr", SE_R(0,10), SE_R_MASK, PPCVLE, 0, {RX}},
7007{"se_mtctr", SE_R(0,11), SE_R_MASK, PPCVLE, 0, {RX}},
7008{"se_extzb", SE_R(0,12), SE_R_MASK, PPCVLE, 0, {RX}},
7009{"se_extsb", SE_R(0,13), SE_R_MASK, PPCVLE, 0, {RX}},
7010{"se_extzh", SE_R(0,14), SE_R_MASK, PPCVLE, 0, {RX}},
7011{"se_extsh", SE_R(0,15), SE_R_MASK, PPCVLE, 0, {RX}},
7012{"se_mr", SE_RR(0,1), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7013{"se_mtar", SE_RR(0,2), SE_RR_MASK, PPCVLE, 0, {ARX, RY}},
7014{"se_mfar", SE_RR(0,3), SE_RR_MASK, PPCVLE, 0, {RX, ARY}},
7015{"se_add", SE_RR(1,0), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7016{"se_mullw", SE_RR(1,1), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7017{"se_sub", SE_RR(1,2), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7018{"se_subf", SE_RR(1,3), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7019{"se_cmp", SE_RR(3,0), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7020{"se_cmpl", SE_RR(3,1), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7021{"se_cmph", SE_RR(3,2), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7022{"se_cmphl", SE_RR(3,3), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7023
7024{"e_cmpi", SCI8BF(6,0,21), SCI8BF_MASK, PPCVLE, 0, {CRD32, RA, SCLSCI8}},
7025{"e_cmpwi", SCI8BF(6,0,21), SCI8BF_MASK, PPCVLE, 0, {CRD32, RA, SCLSCI8}},
7026{"e_cmpli", SCI8BF(6,1,21), SCI8BF_MASK, PPCVLE, 0, {CRD32, RA, SCLSCI8}},
7027{"e_cmplwi", SCI8BF(6,1,21), SCI8BF_MASK, PPCVLE, 0, {CRD32, RA, SCLSCI8}},
7028{"e_addi", SCI8(6,16), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8}},
7029{"e_subi", SCI8(6,16), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8N}},
7030{"e_addi.", SCI8(6,17), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8}},
7031{"e_addic", SCI8(6,18), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8}},
7032{"e_subic", SCI8(6,18), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8N}},
7033{"e_addic.", SCI8(6,19), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8}},
7034{"e_subic.", SCI8(6,19), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8N}},
7035{"e_mulli", SCI8(6,20), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8}},
7036{"e_subfic", SCI8(6,22), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8}},
7037{"e_subfic.", SCI8(6,23), SCI8_MASK, PPCVLE, 0, {RT, RA, SCLSCI8}},
7038{"e_andi", SCI8(6,24), SCI8_MASK, PPCVLE, 0, {RA, RS, SCLSCI8}},
7039{"e_andi.", SCI8(6,25), SCI8_MASK, PPCVLE, 0, {RA, RS, SCLSCI8}},
7040{"e_nop", SCI8(6,26), 0xffffffff, PPCVLE, 0, {0}},
7041{"e_ori", SCI8(6,26), SCI8_MASK, PPCVLE, 0, {RA, RS, SCLSCI8}},
7042{"e_ori.", SCI8(6,27), SCI8_MASK, PPCVLE, 0, {RA, RS, SCLSCI8}},
7043{"e_xori", SCI8(6,28), SCI8_MASK, PPCVLE, 0, {RA, RS, SCLSCI8}},
7044{"e_xori.", SCI8(6,29), SCI8_MASK, PPCVLE, 0, {RA, RS, SCLSCI8}},
7045{"e_lbzu", OPVUP(6,0), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7046{"e_lhau", OPVUP(6,3), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7047{"e_lhzu", OPVUP(6,1), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7048{"e_lmw", OPVUP(6,8), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7049{"e_lwzu", OPVUP(6,2), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7050{"e_stbu", OPVUP(6,4), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7051{"e_sthu", OPVUP(6,5), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7052{"e_stwu", OPVUP(6,6), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7053{"e_stmw", OPVUP(6,9), OPVUP_MASK, PPCVLE, 0, {RT, D8, RA0}},
7054{"e_ldmvgprw", OPVUPRT(6,16,0),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7055{"e_stmvgprw", OPVUPRT(6,17,0),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7056{"e_ldmvsprw", OPVUPRT(6,16,1),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7057{"e_stmvsprw", OPVUPRT(6,17,1),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7058{"e_ldmvsrrw", OPVUPRT(6,16,4),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7059{"e_stmvsrrw", OPVUPRT(6,17,4),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7060{"e_ldmvcsrrw", OPVUPRT(6,16,5),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7061{"e_stmvcsrrw", OPVUPRT(6,17,5),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7062{"e_ldmvdsrrw", OPVUPRT(6,16,6),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7063{"e_stmvdsrrw", OPVUPRT(6,17,6),OPVUPRT_MASK, PPCVLE, 0, {D8, RA0}},
7064{"e_add16i", OP(7), OP_MASK, PPCVLE, 0, {RT, RA, SI}},
7065{"e_la", OP(7), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7066{"e_sub16i", OP(7), OP_MASK, PPCVLE, 0, {RT, RA, NSI}},
7067
7068{"se_addi", SE_IM5(8,0), SE_IM5_MASK, PPCVLE, 0, {RX, OIMM5}},
7069{"se_cmpli", SE_IM5(8,1), SE_IM5_MASK, PPCVLE, 0, {RX, OIMM5}},
7070{"se_subi", SE_IM5(9,0), SE_IM5_MASK, PPCVLE, 0, {RX, OIMM5}},
7071{"se_subi.", SE_IM5(9,1), SE_IM5_MASK, PPCVLE, 0, {RX, OIMM5}},
7072{"se_cmpi", SE_IM5(10,1), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7073{"se_bmaski", SE_IM5(11,0), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7074{"se_andi", SE_IM5(11,1), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7075
7076{"e_lbz", OP(12), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7077{"e_stb", OP(13), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7078{"e_lha", OP(14), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7079
7080{"se_srw", SE_RR(16,0), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7081{"se_sraw", SE_RR(16,1), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7082{"se_slw", SE_RR(16,2), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7083{"se_nop", SE_RR(17,0), 0xffff, PPCVLE, 0, {0}},
7084{"se_or", SE_RR(17,0), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7085{"se_andc", SE_RR(17,1), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7086{"se_and", SE_RR(17,2), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7087{"se_and.", SE_RR(17,3), SE_RR_MASK, PPCVLE, 0, {RX, RY}},
7088{"se_li", IM7(9), IM7_MASK, PPCVLE, 0, {RX, UI7}},
7089
7090{"e_lwz", OP(20), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7091{"e_stw", OP(21), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7092{"e_lhz", OP(22), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7093{"e_sth", OP(23), OP_MASK, PPCVLE, 0, {RT, D, RA0}},
7094
7095{"se_bclri", SE_IM5(24,0), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7096{"se_bgeni", SE_IM5(24,1), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7097{"se_bseti", SE_IM5(25,0), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7098{"se_btsti", SE_IM5(25,1), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7099{"se_srwi", SE_IM5(26,0), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7100{"se_srawi", SE_IM5(26,1), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7101{"se_slwi", SE_IM5(27,0), SE_IM5_MASK, PPCVLE, 0, {RX, UI5}},
7102
7103{"e_lis", I16L(28,28), I16L_MASK, PPCVLE, 0, {RD, VLEUIMML}},
7104{"e_and2is.", I16L(28,29), I16L_MASK, PPCVLE, 0, {RD, VLEUIMML}},
7105{"e_or2is", I16L(28,26), I16L_MASK, PPCVLE, 0, {RD, VLEUIMML}},
7106{"e_and2i.", I16L(28,25), I16L_MASK, PPCVLE, 0, {RD, VLEUIMML}},
7107{"e_or2i", I16L(28,24), I16L_MASK, PPCVLE, 0, {RD, VLEUIMML}},
7108{"e_cmphl16i", IA16(28,23), IA16_MASK, PPCVLE, 0, {RA, VLEUIMM}},
7109{"e_cmph16i", IA16(28,22), IA16_MASK, PPCVLE, 0, {RA, VLESIMM}},
7110{"e_cmpl16i", I16A(28,21), I16A_MASK, PPCVLE, 0, {RA, VLEUIMM}},
7111{"e_mull2i", I16A(28,20), I16A_MASK, PPCVLE, 0, {RA, VLESIMM}},
7112{"e_cmp16i", IA16(28,19), IA16_MASK, PPCVLE, 0, {RA, VLESIMM}},
7113{"e_sub2is", I16A(28,18), I16A_MASK, PPCVLE, 0, {RA, VLENSIMM}},
7114{"e_add2is", I16A(28,18), I16A_MASK, PPCVLE, 0, {RA, VLESIMM}},
7115{"e_sub2i.", I16A(28,17), I16A_MASK, PPCVLE, 0, {RA, VLENSIMM}},
7116{"e_add2i.", I16A(28,17), I16A_MASK, PPCVLE, 0, {RA, VLESIMM}},
7117{"e_li", LI20(28,0), LI20_MASK, PPCVLE, 0, {RT, IMM20}},
7118{"e_rlwimi", M(29,0), M_MASK, PPCVLE, 0, {RA, RS, SH, MB, ME}},
7119{"e_rlwinm", M(29,1), M_MASK, PPCVLE, 0, {RA, RT, SH, MBE, ME}},
7120{"e_b", BD24(30,0,0), BD24_MASK, PPCVLE, 0, {B24}},
7121{"e_bl", BD24(30,0,1), BD24_MASK, PPCVLE, 0, {B24}},
7122{"e_bdnz", EBD15(30,8,BO32DNZ,0), EBD15_MASK, PPCVLE, 0, {B15}},
7123{"e_bdnzl", EBD15(30,8,BO32DNZ,1), EBD15_MASK, PPCVLE, 0, {B15}},
7124{"e_bdz", EBD15(30,8,BO32DZ,0), EBD15_MASK, PPCVLE, 0, {B15}},
7125{"e_bdzl", EBD15(30,8,BO32DZ,1), EBD15_MASK, PPCVLE, 0, {B15}},
7126{"e_bge", EBD15BI(30,8,BO32F,CBLT,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7127{"e_bgel", EBD15BI(30,8,BO32F,CBLT,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7128{"e_bnl", EBD15BI(30,8,BO32F,CBLT,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7129{"e_bnll", EBD15BI(30,8,BO32F,CBLT,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7130{"e_blt", EBD15BI(30,8,BO32T,CBLT,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7131{"e_bltl", EBD15BI(30,8,BO32T,CBLT,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7132{"e_bgt", EBD15BI(30,8,BO32T,CBGT,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7133{"e_bgtl", EBD15BI(30,8,BO32T,CBGT,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7134{"e_ble", EBD15BI(30,8,BO32F,CBGT,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7135{"e_blel", EBD15BI(30,8,BO32F,CBGT,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7136{"e_bng", EBD15BI(30,8,BO32F,CBGT,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7137{"e_bngl", EBD15BI(30,8,BO32F,CBGT,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7138{"e_bne", EBD15BI(30,8,BO32F,CBEQ,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7139{"e_bnel", EBD15BI(30,8,BO32F,CBEQ,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7140{"e_beq", EBD15BI(30,8,BO32T,CBEQ,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7141{"e_beql", EBD15BI(30,8,BO32T,CBEQ,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7142{"e_bso", EBD15BI(30,8,BO32T,CBSO,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7143{"e_bsol", EBD15BI(30,8,BO32T,CBSO,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7144{"e_bun", EBD15BI(30,8,BO32T,CBSO,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7145{"e_bunl", EBD15BI(30,8,BO32T,CBSO,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7146{"e_bns", EBD15BI(30,8,BO32F,CBSO,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7147{"e_bnsl", EBD15BI(30,8,BO32F,CBSO,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7148{"e_bnu", EBD15BI(30,8,BO32F,CBSO,0), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7149{"e_bnul", EBD15BI(30,8,BO32F,CBSO,1), EBD15BI_MASK, PPCVLE, 0, {CRS,B15}},
7150{"e_bc", BD15(30,8,0), BD15_MASK, PPCVLE, 0, {BO32, BI32, B15}},
7151{"e_bcl", BD15(30,8,1), BD15_MASK, PPCVLE, 0, {BO32, BI32, B15}},
7152
7153{"e_bf", EBD15(30,8,BO32F,0), EBD15_MASK, PPCVLE, 0, {BI32,B15}},
7154{"e_bfl", EBD15(30,8,BO32F,1), EBD15_MASK, PPCVLE, 0, {BI32,B15}},
7155{"e_bt", EBD15(30,8,BO32T,0), EBD15_MASK, PPCVLE, 0, {BI32,B15}},
7156{"e_btl", EBD15(30,8,BO32T,1), EBD15_MASK, PPCVLE, 0, {BI32,B15}},
7157
7158{"e_cmph", X(31,14), X_MASK, PPCVLE, 0, {CRD, RA, RB}},
7159{"e_cmphl", X(31,46), X_MASK, PPCVLE, 0, {CRD, RA, RB}},
7160{"e_crandc", XL(31,129), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7161{"e_crnand", XL(31,225), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7162{"e_crnot", XL(31,33), XL_MASK, PPCVLE, 0, {BT, BA, BBA}},
7163{"e_crnor", XL(31,33), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7164{"e_crclr", XL(31,193), XL_MASK, PPCVLE, 0, {BT, BAT, BBA}},
7165{"e_crxor", XL(31,193), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7166{"e_mcrf", XL(31,16), XL_MASK, PPCVLE, 0, {CRD, CR}},
7167{"e_slwi", EX(31,112), EX_MASK, PPCVLE, 0, {RA, RS, SH}},
7168{"e_slwi.", EX(31,113), EX_MASK, PPCVLE, 0, {RA, RS, SH}},
7169
7170{"e_crand", XL(31,257), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7171
7172{"e_rlw", EX(31,560), EX_MASK, PPCVLE, 0, {RA, RS, RB}},
7173{"e_rlw.", EX(31,561), EX_MASK, PPCVLE, 0, {RA, RS, RB}},
7174
7175{"e_crset", XL(31,289), XL_MASK, PPCVLE, 0, {BT, BAT, BBA}},
7176{"e_creqv", XL(31,289), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7177
7178{"e_rlwi", EX(31,624), EX_MASK, PPCVLE, 0, {RA, RS, SH}},
7179{"e_rlwi.", EX(31,625), EX_MASK, PPCVLE, 0, {RA, RS, SH}},
7180
7181{"e_crorc", XL(31,417), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7182
7183{"e_crmove", XL(31,449), XL_MASK, PPCVLE, 0, {BT, BA, BBA}},
7184{"e_cror", XL(31,449), XL_MASK, PPCVLE, 0, {BT, BA, BB}},
7185
7186{"mtmas1", XSPR(31,467,625), XSPR_MASK, PPCVLE, 0, {RS}},
7187
7188{"e_srwi", EX(31,1136), EX_MASK, PPCVLE, 0, {RA, RS, SH}},
7189{"e_srwi.", EX(31,1137), EX_MASK, PPCVLE, 0, {RA, RS, SH}},
7190
7191{"se_lbz", SD4(8), SD4_MASK, PPCVLE, 0, {RZ, SE_SD, RX}},
7192
7193{"se_stb", SD4(9), SD4_MASK, PPCVLE, 0, {RZ, SE_SD, RX}},
7194
7195{"se_lhz", SD4(10), SD4_MASK, PPCVLE, 0, {RZ, SE_SDH, RX}},
7196
7197{"se_sth", SD4(11), SD4_MASK, PPCVLE, 0, {RZ, SE_SDH, RX}},
7198
7199{"se_lwz", SD4(12), SD4_MASK, PPCVLE, 0, {RZ, SE_SDW, RX}},
7200
7201{"se_stw", SD4(13), SD4_MASK, PPCVLE, 0, {RZ, SE_SDW, RX}},
7202
7203{"se_bge", EBD8IO(28,0,0), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7204{"se_bnl", EBD8IO(28,0,0), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7205{"se_ble", EBD8IO(28,0,1), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7206{"se_bng", EBD8IO(28,0,1), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7207{"se_bne", EBD8IO(28,0,2), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7208{"se_bns", EBD8IO(28,0,3), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7209{"se_bnu", EBD8IO(28,0,3), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7210{"se_bf", EBD8IO(28,0,0), EBD8IO2_MASK, PPCVLE, 0, {BI16, B8}},
7211{"se_blt", EBD8IO(28,1,0), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7212{"se_bgt", EBD8IO(28,1,1), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7213{"se_beq", EBD8IO(28,1,2), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7214{"se_bso", EBD8IO(28,1,3), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7215{"se_bun", EBD8IO(28,1,3), EBD8IO3_MASK, PPCVLE, 0, {B8}},
7216{"se_bt", EBD8IO(28,1,0), EBD8IO2_MASK, PPCVLE, 0, {BI16, B8}},
7217{"se_bc", BD8IO(28), BD8IO_MASK, PPCVLE, 0, {BO16, BI16, B8}},
7218{"se_b", BD8(58,0,0), BD8_MASK, PPCVLE, 0, {B8}},
7219{"se_bl", BD8(58,0,1), BD8_MASK, PPCVLE, 0, {B8}},
4935}; 7220};
4936 7221
4937const int powerpc_num_opcodes = ARRAY_SIZE(powerpc_opcodes); 7222const int vle_num_opcodes =
7223 sizeof (vle_opcodes) / sizeof (vle_opcodes[0]);
4938 7224
4939/* The macro table. This is only used by the assembler. */ 7225/* The macro table. This is only used by the assembler. */
4940 7226
@@ -4949,45 +7235,58 @@ const int powerpc_num_opcodes = ARRAY_SIZE(powerpc_opcodes);
4949 support extracting the whole word (32 bits in this case). */ 7235 support extracting the whole word (32 bits in this case). */
4950 7236
4951const struct powerpc_macro powerpc_macros[] = { 7237const struct powerpc_macro powerpc_macros[] = {
4952{ "extldi", 4, PPC64, "rldicr %0,%1,%3,(%2)-1" }, 7238{"extldi", 4, PPC64, "rldicr %0,%1,%3,(%2)-1"},
4953{ "extldi.", 4, PPC64, "rldicr. %0,%1,%3,(%2)-1" }, 7239{"extldi.", 4, PPC64, "rldicr. %0,%1,%3,(%2)-1"},
4954{ "extrdi", 4, PPC64, "rldicl %0,%1,(%2)+(%3),64-(%2)" }, 7240{"extrdi", 4, PPC64, "rldicl %0,%1,((%2)+(%3))&((%2)+(%3)<>64),64-(%2)"},
4955{ "extrdi.", 4, PPC64, "rldicl. %0,%1,(%2)+(%3),64-(%2)" }, 7241{"extrdi.", 4, PPC64, "rldicl. %0,%1,((%2)+(%3))&((%2)+(%3)<>64),64-(%2)"},
4956{ "insrdi", 4, PPC64, "rldimi %0,%1,64-((%2)+(%3)),%3" }, 7242{"insrdi", 4, PPC64, "rldimi %0,%1,64-((%2)+(%3)),%3"},
4957{ "insrdi.", 4, PPC64, "rldimi. %0,%1,64-((%2)+(%3)),%3" }, 7243{"insrdi.", 4, PPC64, "rldimi. %0,%1,64-((%2)+(%3)),%3"},
4958{ "rotrdi", 3, PPC64, "rldicl %0,%1,(-(%2)!63)&((%2)|63),0" }, 7244{"rotrdi", 3, PPC64, "rldicl %0,%1,(-(%2)!63)&((%2)|63),0"},
4959{ "rotrdi.", 3, PPC64, "rldicl. %0,%1,(-(%2)!63)&((%2)|63),0" }, 7245{"rotrdi.", 3, PPC64, "rldicl. %0,%1,(-(%2)!63)&((%2)|63),0"},
4960{ "sldi", 3, PPC64, "rldicr %0,%1,%2,63-(%2)" }, 7246{"sldi", 3, PPC64, "rldicr %0,%1,%2,63-(%2)"},
4961{ "sldi.", 3, PPC64, "rldicr. %0,%1,%2,63-(%2)" }, 7247{"sldi.", 3, PPC64, "rldicr. %0,%1,%2,63-(%2)"},
4962{ "srdi", 3, PPC64, "rldicl %0,%1,(-(%2)!63)&((%2)|63),%2" }, 7248{"srdi", 3, PPC64, "rldicl %0,%1,(-(%2)!63)&((%2)|63),%2"},
4963{ "srdi.", 3, PPC64, "rldicl. %0,%1,(-(%2)!63)&((%2)|63),%2" }, 7249{"srdi.", 3, PPC64, "rldicl. %0,%1,(-(%2)!63)&((%2)|63),%2"},
4964{ "clrrdi", 3, PPC64, "rldicr %0,%1,0,63-(%2)" }, 7250{"clrrdi", 3, PPC64, "rldicr %0,%1,0,63-(%2)"},
4965{ "clrrdi.", 3, PPC64, "rldicr. %0,%1,0,63-(%2)" }, 7251{"clrrdi.", 3, PPC64, "rldicr. %0,%1,0,63-(%2)"},
4966{ "clrlsldi",4, PPC64, "rldic %0,%1,%3,(%2)-(%3)" }, 7252{"clrlsldi", 4, PPC64, "rldic %0,%1,%3,(%2)-(%3)"},
4967{ "clrlsldi.",4, PPC64, "rldic. %0,%1,%3,(%2)-(%3)" }, 7253{"clrlsldi.",4, PPC64, "rldic. %0,%1,%3,(%2)-(%3)"},
4968 7254
4969{ "extlwi", 4, PPCCOM, "rlwinm %0,%1,%3,0,(%2)-1" }, 7255{"extlwi", 4, PPCCOM, "rlwinm %0,%1,%3,0,(%2)-1"},
4970{ "extlwi.", 4, PPCCOM, "rlwinm. %0,%1,%3,0,(%2)-1" }, 7256{"extlwi.", 4, PPCCOM, "rlwinm. %0,%1,%3,0,(%2)-1"},
4971{ "extrwi", 4, PPCCOM, "rlwinm %0,%1,((%2)+(%3))&((%2)+(%3)<>32),32-(%2),31" }, 7257{"extrwi", 4, PPCCOM, "rlwinm %0,%1,((%2)+(%3))&((%2)+(%3)<>32),32-(%2),31"},
4972{ "extrwi.", 4, PPCCOM, "rlwinm. %0,%1,((%2)+(%3))&((%2)+(%3)<>32),32-(%2),31" }, 7258{"extrwi.", 4, PPCCOM, "rlwinm. %0,%1,((%2)+(%3))&((%2)+(%3)<>32),32-(%2),31"},
4973{ "inslwi", 4, PPCCOM, "rlwimi %0,%1,(-(%3)!31)&((%3)|31),%3,(%2)+(%3)-1" }, 7259{"inslwi", 4, PPCCOM, "rlwimi %0,%1,(-(%3)!31)&((%3)|31),%3,(%2)+(%3)-1"},
4974{ "inslwi.", 4, PPCCOM, "rlwimi. %0,%1,(-(%3)!31)&((%3)|31),%3,(%2)+(%3)-1"}, 7260{"inslwi.", 4, PPCCOM, "rlwimi. %0,%1,(-(%3)!31)&((%3)|31),%3,(%2)+(%3)-1"},
4975{ "insrwi", 4, PPCCOM, "rlwimi %0,%1,32-((%2)+(%3)),%3,(%2)+(%3)-1" }, 7261{"insrwi", 4, PPCCOM, "rlwimi %0,%1,32-((%2)+(%3)),%3,(%2)+(%3)-1"},
4976{ "insrwi.", 4, PPCCOM, "rlwimi. %0,%1,32-((%2)+(%3)),%3,(%2)+(%3)-1"}, 7262{"insrwi.", 4, PPCCOM, "rlwimi. %0,%1,32-((%2)+(%3)),%3,(%2)+(%3)-1"},
4977{ "rotrwi", 3, PPCCOM, "rlwinm %0,%1,(-(%2)!31)&((%2)|31),0,31" }, 7263{"rotrwi", 3, PPCCOM, "rlwinm %0,%1,(-(%2)!31)&((%2)|31),0,31"},
4978{ "rotrwi.", 3, PPCCOM, "rlwinm. %0,%1,(-(%2)!31)&((%2)|31),0,31" }, 7264{"rotrwi.", 3, PPCCOM, "rlwinm. %0,%1,(-(%2)!31)&((%2)|31),0,31"},
4979{ "slwi", 3, PPCCOM, "rlwinm %0,%1,%2,0,31-(%2)" }, 7265{"slwi", 3, PPCCOM, "rlwinm %0,%1,%2,0,31-(%2)"},
4980{ "sli", 3, PWRCOM, "rlinm %0,%1,%2,0,31-(%2)" }, 7266{"sli", 3, PWRCOM, "rlinm %0,%1,%2,0,31-(%2)"},
4981{ "slwi.", 3, PPCCOM, "rlwinm. %0,%1,%2,0,31-(%2)" }, 7267{"slwi.", 3, PPCCOM, "rlwinm. %0,%1,%2,0,31-(%2)"},
4982{ "sli.", 3, PWRCOM, "rlinm. %0,%1,%2,0,31-(%2)" }, 7268{"sli.", 3, PWRCOM, "rlinm. %0,%1,%2,0,31-(%2)"},
4983{ "srwi", 3, PPCCOM, "rlwinm %0,%1,(-(%2)!31)&((%2)|31),%2,31" }, 7269{"srwi", 3, PPCCOM, "rlwinm %0,%1,(-(%2)!31)&((%2)|31),%2,31"},
4984{ "sri", 3, PWRCOM, "rlinm %0,%1,(-(%2)!31)&((%2)|31),%2,31" }, 7270{"sri", 3, PWRCOM, "rlinm %0,%1,(-(%2)!31)&((%2)|31),%2,31"},
4985{ "srwi.", 3, PPCCOM, "rlwinm. %0,%1,(-(%2)!31)&((%2)|31),%2,31" }, 7271{"srwi.", 3, PPCCOM, "rlwinm. %0,%1,(-(%2)!31)&((%2)|31),%2,31"},
4986{ "sri.", 3, PWRCOM, "rlinm. %0,%1,(-(%2)!31)&((%2)|31),%2,31" }, 7272{"sri.", 3, PWRCOM, "rlinm. %0,%1,(-(%2)!31)&((%2)|31),%2,31"},
4987{ "clrrwi", 3, PPCCOM, "rlwinm %0,%1,0,0,31-(%2)" }, 7273{"clrrwi", 3, PPCCOM, "rlwinm %0,%1,0,0,31-(%2)"},
4988{ "clrrwi.", 3, PPCCOM, "rlwinm. %0,%1,0,0,31-(%2)" }, 7274{"clrrwi.", 3, PPCCOM, "rlwinm. %0,%1,0,0,31-(%2)"},
4989{ "clrlslwi",4, PPCCOM, "rlwinm %0,%1,%3,(%2)-(%3),31-(%3)" }, 7275{"clrlslwi", 4, PPCCOM, "rlwinm %0,%1,%3,(%2)-(%3),31-(%3)"},
4990{ "clrlslwi.",4, PPCCOM, "rlwinm. %0,%1,%3,(%2)-(%3),31-(%3)" }, 7276{"clrlslwi.",4, PPCCOM, "rlwinm. %0,%1,%3,(%2)-(%3),31-(%3)"},
7277
7278{"e_extlwi", 4, PPCVLE, "e_rlwinm %0,%1,%3,0,(%2)-1"},
7279{"e_extrwi", 4, PPCVLE, "e_rlwinm %0,%1,((%2)+(%3))&((%2)+(%3)<>32),32-(%2),31"},
7280{"e_inslwi", 4, PPCVLE, "e_rlwimi %0,%1,(-(%3)!31)&((%3)|31),%3,(%2)+(%3)-1"},
7281{"e_insrwi", 4, PPCVLE, "e_rlwimi %0,%1,32-((%2)+(%3)),%3,(%2)+(%3)-1"},
7282{"e_rotlwi", 3, PPCVLE, "e_rlwinm %0,%1,%2,0,31"},
7283{"e_rotrwi", 3, PPCVLE, "e_rlwinm %0,%1,(-(%2)!31)&((%2)|31),0,31"},
7284{"e_slwi", 3, PPCVLE, "e_rlwinm %0,%1,%2,0,31-(%2)"},
7285{"e_srwi", 3, PPCVLE, "e_rlwinm %0,%1,(-(%2)!31)&((%2)|31),%2,31"},
7286{"e_clrlwi", 3, PPCVLE, "e_rlwinm %0,%1,0,%2,31"},
7287{"e_clrrwi", 3, PPCVLE, "e_rlwinm %0,%1,0,0,31-(%2)"},
7288{"e_clrlslwi",4, PPCVLE, "e_rlwinm %0,%1,%3,(%2)-(%3),31-(%3)"},
4991}; 7289};
4992 7290
4993const int powerpc_num_macros = ARRAY_SIZE(powerpc_macros); 7291const int powerpc_num_macros =
7292 sizeof (powerpc_macros) / sizeof (powerpc_macros[0]);
diff --git a/arch/powerpc/xmon/ppc.h b/arch/powerpc/xmon/ppc.h
index 110df96354b4..d00f33dcf192 100644
--- a/arch/powerpc/xmon/ppc.h
+++ b/arch/powerpc/xmon/ppc.h
@@ -1,6 +1,5 @@
1/* ppc.h -- Header file for PowerPC opcode table 1/* ppc.h -- Header file for PowerPC opcode table
2 Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 2 Copyright (C) 1994-2016 Free Software Foundation, Inc.
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor, Cygnus Support 3 Written by Ian Lance Taylor, Cygnus Support
5 4
6This file is part of GDB, GAS, and the GNU binutils. 5This file is part of GDB, GAS, and the GNU binutils.
@@ -22,6 +21,12 @@ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, US
22#ifndef PPC_H 21#ifndef PPC_H
23#define PPC_H 22#define PPC_H
24 23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef uint64_t ppc_cpu_t;
29
25/* The opcode table is an array of struct powerpc_opcode. */ 30/* The opcode table is an array of struct powerpc_opcode. */
26 31
27struct powerpc_opcode 32struct powerpc_opcode
@@ -42,7 +47,12 @@ struct powerpc_opcode
42 /* One bit flags for the opcode. These are used to indicate which 47 /* One bit flags for the opcode. These are used to indicate which
43 specific processors support the instructions. The defined values 48 specific processors support the instructions. The defined values
44 are listed below. */ 49 are listed below. */
45 unsigned long flags; 50 ppc_cpu_t flags;
51
52 /* One bit flags for the opcode. These are used to indicate which
53 specific processors no longer support the instructions. The defined
54 values are listed below. */
55 ppc_cpu_t deprecated;
46 56
47 /* An array of operand codes. Each code is an index into the 57 /* An array of operand codes. Each code is an index into the
48 operand table. They appear in the order which the operands must 58 operand table. They appear in the order which the operands must
@@ -55,6 +65,8 @@ struct powerpc_opcode
55 instructions. */ 65 instructions. */
56extern const struct powerpc_opcode powerpc_opcodes[]; 66extern const struct powerpc_opcode powerpc_opcodes[];
57extern const int powerpc_num_opcodes; 67extern const int powerpc_num_opcodes;
68extern const struct powerpc_opcode vle_opcodes[];
69extern const int vle_num_opcodes;
58 70
59/* Values defined for the flags field of a struct powerpc_opcode. */ 71/* Values defined for the flags field of a struct powerpc_opcode. */
60 72
@@ -67,106 +79,178 @@ extern const int powerpc_num_opcodes;
67/* Opcode is defined for the POWER2 (Rios 2) architecture. */ 79/* Opcode is defined for the POWER2 (Rios 2) architecture. */
68#define PPC_OPCODE_POWER2 4 80#define PPC_OPCODE_POWER2 4
69 81
70/* Opcode is only defined on 32 bit architectures. */
71#define PPC_OPCODE_32 8
72
73/* Opcode is only defined on 64 bit architectures. */
74#define PPC_OPCODE_64 0x10
75
76/* Opcode is supported by the Motorola PowerPC 601 processor. The 601 82/* Opcode is supported by the Motorola PowerPC 601 processor. The 601
77 is assumed to support all PowerPC (PPC_OPCODE_PPC) instructions, 83 is assumed to support all PowerPC (PPC_OPCODE_PPC) instructions,
78 but it also supports many additional POWER instructions. */ 84 but it also supports many additional POWER instructions. */
79#define PPC_OPCODE_601 0x20 85#define PPC_OPCODE_601 8
80 86
81/* Opcode is supported in both the Power and PowerPC architectures 87/* Opcode is supported in both the Power and PowerPC architectures
82 (ie, compiler's -mcpu=common or assembler's -mcom). */ 88 (ie, compiler's -mcpu=common or assembler's -mcom). More than just
83#define PPC_OPCODE_COMMON 0x40 89 the intersection of PPC_OPCODE_PPC with the union of PPC_OPCODE_POWER
90 and PPC_OPCODE_POWER2 because many instructions changed mnemonics
91 between POWER and POWERPC. */
92#define PPC_OPCODE_COMMON 0x10
84 93
85/* Opcode is supported for any Power or PowerPC platform (this is 94/* Opcode is supported for any Power or PowerPC platform (this is
86 for the assembler's -many option, and it eliminates duplicates). */ 95 for the assembler's -many option, and it eliminates duplicates). */
87#define PPC_OPCODE_ANY 0x80 96#define PPC_OPCODE_ANY 0x20
97
98/* Opcode is only defined on 64 bit architectures. */
99#define PPC_OPCODE_64 0x40
88 100
89/* Opcode is supported as part of the 64-bit bridge. */ 101/* Opcode is supported as part of the 64-bit bridge. */
90#define PPC_OPCODE_64_BRIDGE 0x100 102#define PPC_OPCODE_64_BRIDGE 0x80
91 103
92/* Opcode is supported by Altivec Vector Unit */ 104/* Opcode is supported by Altivec Vector Unit */
93#define PPC_OPCODE_ALTIVEC 0x200 105#define PPC_OPCODE_ALTIVEC 0x100
94 106
95/* Opcode is supported by PowerPC 403 processor. */ 107/* Opcode is supported by PowerPC 403 processor. */
96#define PPC_OPCODE_403 0x400 108#define PPC_OPCODE_403 0x200
97 109
98/* Opcode is supported by PowerPC BookE processor. */ 110/* Opcode is supported by PowerPC BookE processor. */
99#define PPC_OPCODE_BOOKE 0x800 111#define PPC_OPCODE_BOOKE 0x400
100
101/* Opcode is only supported by 64-bit PowerPC BookE processor. */
102#define PPC_OPCODE_BOOKE64 0x1000
103 112
104/* Opcode is supported by PowerPC 440 processor. */ 113/* Opcode is supported by PowerPC 440 processor. */
105#define PPC_OPCODE_440 0x2000 114#define PPC_OPCODE_440 0x800
106 115
107/* Opcode is only supported by Power4 architecture. */ 116/* Opcode is only supported by Power4 architecture. */
108#define PPC_OPCODE_POWER4 0x4000 117#define PPC_OPCODE_POWER4 0x1000
109
110/* Opcode isn't supported by Power4 architecture. */
111#define PPC_OPCODE_NOPOWER4 0x8000
112 118
113/* Opcode is only supported by POWERPC Classic architecture. */ 119/* Opcode is only supported by Power7 architecture. */
114#define PPC_OPCODE_CLASSIC 0x10000 120#define PPC_OPCODE_POWER7 0x2000
115 121
116/* Opcode is only supported by e500x2 Core. */ 122/* Opcode is only supported by e500x2 Core. */
117#define PPC_OPCODE_SPE 0x20000 123#define PPC_OPCODE_SPE 0x4000
118 124
119/* Opcode is supported by e500x2 Integer select APU. */ 125/* Opcode is supported by e500x2 Integer select APU. */
120#define PPC_OPCODE_ISEL 0x40000 126#define PPC_OPCODE_ISEL 0x8000
121 127
122/* Opcode is an e500 SPE floating point instruction. */ 128/* Opcode is an e500 SPE floating point instruction. */
123#define PPC_OPCODE_EFS 0x80000 129#define PPC_OPCODE_EFS 0x10000
124 130
125/* Opcode is supported by branch locking APU. */ 131/* Opcode is supported by branch locking APU. */
126#define PPC_OPCODE_BRLOCK 0x100000 132#define PPC_OPCODE_BRLOCK 0x20000
127 133
128/* Opcode is supported by performance monitor APU. */ 134/* Opcode is supported by performance monitor APU. */
129#define PPC_OPCODE_PMR 0x200000 135#define PPC_OPCODE_PMR 0x40000
130 136
131/* Opcode is supported by cache locking APU. */ 137/* Opcode is supported by cache locking APU. */
132#define PPC_OPCODE_CACHELCK 0x400000 138#define PPC_OPCODE_CACHELCK 0x80000
133 139
134/* Opcode is supported by machine check APU. */ 140/* Opcode is supported by machine check APU. */
135#define PPC_OPCODE_RFMCI 0x800000 141#define PPC_OPCODE_RFMCI 0x100000
136 142
137/* Opcode is only supported by Power5 architecture. */ 143/* Opcode is only supported by Power5 architecture. */
138#define PPC_OPCODE_POWER5 0x1000000 144#define PPC_OPCODE_POWER5 0x200000
139 145
140/* Opcode is supported by PowerPC e300 family. */ 146/* Opcode is supported by PowerPC e300 family. */
141#define PPC_OPCODE_E300 0x2000000 147#define PPC_OPCODE_E300 0x400000
142 148
143/* Opcode is only supported by Power6 architecture. */ 149/* Opcode is only supported by Power6 architecture. */
144#define PPC_OPCODE_POWER6 0x4000000 150#define PPC_OPCODE_POWER6 0x800000
145 151
146/* Opcode is only supported by PowerPC Cell family. */ 152/* Opcode is only supported by PowerPC Cell family. */
147#define PPC_OPCODE_CELL 0x8000000 153#define PPC_OPCODE_CELL 0x1000000
154
155/* Opcode is supported by CPUs with paired singles support. */
156#define PPC_OPCODE_PPCPS 0x2000000
157
158/* Opcode is supported by Power E500MC */
159#define PPC_OPCODE_E500MC 0x4000000
160
161/* Opcode is supported by PowerPC 405 processor. */
162#define PPC_OPCODE_405 0x8000000
163
164/* Opcode is supported by Vector-Scalar (VSX) Unit */
165#define PPC_OPCODE_VSX 0x10000000
166
167/* Opcode is supported by A2. */
168#define PPC_OPCODE_A2 0x20000000
169
170/* Opcode is supported by PowerPC 476 processor. */
171#define PPC_OPCODE_476 0x40000000
172
173/* Opcode is supported by AppliedMicro Titan core */
174#define PPC_OPCODE_TITAN 0x80000000
175
176/* Opcode which is supported by the e500 family */
177#define PPC_OPCODE_E500 0x100000000ull
178
179/* Opcode is supported by Extended Altivec Vector Unit */
180#define PPC_OPCODE_ALTIVEC2 0x200000000ull
181
182/* Opcode is supported by Power E6500 */
183#define PPC_OPCODE_E6500 0x400000000ull
184
185/* Opcode is supported by Thread management APU */
186#define PPC_OPCODE_TMR 0x800000000ull
187
188/* Opcode which is supported by the VLE extension. */
189#define PPC_OPCODE_VLE 0x1000000000ull
190
191/* Opcode is only supported by Power8 architecture. */
192#define PPC_OPCODE_POWER8 0x2000000000ull
193
194/* Opcode which is supported by the Hardware Transactional Memory extension. */
195/* Currently, this is the same as the POWER8 mask. If another cpu comes out
196 that isn't a superset of POWER8, we can define this to its own mask. */
197#define PPC_OPCODE_HTM PPC_OPCODE_POWER8
198
199/* Opcode is supported by ppc750cl. */
200#define PPC_OPCODE_750 0x4000000000ull
201
202/* Opcode is supported by ppc7450. */
203#define PPC_OPCODE_7450 0x8000000000ull
204
205/* Opcode is supported by ppc821/850/860. */
206#define PPC_OPCODE_860 0x10000000000ull
207
208/* Opcode is only supported by Power9 architecture. */
209#define PPC_OPCODE_POWER9 0x20000000000ull
210
211/* Opcode is supported by Vector-Scalar (VSX) Unit from ISA 2.08. */
212#define PPC_OPCODE_VSX3 0x40000000000ull
213
214 /* Opcode is supported by e200z4. */
215#define PPC_OPCODE_E200Z4 0x80000000000ull
148 216
149/* A macro to extract the major opcode from an instruction. */ 217/* A macro to extract the major opcode from an instruction. */
150#define PPC_OP(i) (((i) >> 26) & 0x3f) 218#define PPC_OP(i) (((i) >> 26) & 0x3f)
219
220/* A macro to determine if the instruction is a 2-byte VLE insn. */
221#define PPC_OP_SE_VLE(m) ((m) <= 0xffff)
222
223/* A macro to extract the major opcode from a VLE instruction. */
224#define VLE_OP(i,m) (((i) >> ((m) <= 0xffff ? 10 : 26)) & 0x3f)
225
226/* A macro to convert a VLE opcode to a VLE opcode segment. */
227#define VLE_OP_TO_SEG(i) ((i) >> 1)
151 228
152/* The operands table is an array of struct powerpc_operand. */ 229/* The operands table is an array of struct powerpc_operand. */
153 230
154struct powerpc_operand 231struct powerpc_operand
155{ 232{
156 /* The number of bits in the operand. */ 233 /* A bitmask of bits in the operand. */
157 int bits; 234 unsigned int bitm;
158 235
159 /* How far the operand is left shifted in the instruction. */ 236 /* The shift operation to be applied to the operand. No shift
237 is made if this is zero. For positive values, the operand
238 is shifted left by SHIFT. For negative values, the operand
239 is shifted right by -SHIFT. Use PPC_OPSHIFT_INV to indicate
240 that BITM and SHIFT cannot be used to determine where the
241 operand goes in the insn. */
160 int shift; 242 int shift;
161 243
162 /* Insertion function. This is used by the assembler. To insert an 244 /* Insertion function. This is used by the assembler. To insert an
163 operand value into an instruction, check this field. 245 operand value into an instruction, check this field.
164 246
165 If it is NULL, execute 247 If it is NULL, execute
166 i |= (op & ((1 << o->bits) - 1)) << o->shift; 248 if (o->shift >= 0)
249 i |= (op & o->bitm) << o->shift;
250 else
251 i |= (op & o->bitm) >> -o->shift;
167 (i is the instruction which we are filling in, o is a pointer to 252 (i is the instruction which we are filling in, o is a pointer to
168 this structure, and op is the opcode value; this assumes twos 253 this structure, and op is the operand value).
169 complement arithmetic).
170 254
171 If this field is not NULL, then simply call it with the 255 If this field is not NULL, then simply call it with the
172 instruction and the operand value. It will return the new value 256 instruction and the operand value. It will return the new value
@@ -176,18 +260,20 @@ struct powerpc_operand
176 operand value is legal, *ERRMSG will be unchanged (most operands 260 operand value is legal, *ERRMSG will be unchanged (most operands
177 can accept any value). */ 261 can accept any value). */
178 unsigned long (*insert) 262 unsigned long (*insert)
179 (unsigned long instruction, long op, int dialect, const char **errmsg); 263 (unsigned long instruction, long op, ppc_cpu_t dialect, const char **errmsg);
180 264
181 /* Extraction function. This is used by the disassembler. To 265 /* Extraction function. This is used by the disassembler. To
182 extract this operand type from an instruction, check this field. 266 extract this operand type from an instruction, check this field.
183 267
184 If it is NULL, compute 268 If it is NULL, compute
185 op = ((i) >> o->shift) & ((1 << o->bits) - 1); 269 if (o->shift >= 0)
186 if ((o->flags & PPC_OPERAND_SIGNED) != 0 270 op = (i >> o->shift) & o->bitm;
187 && (op & (1 << (o->bits - 1))) != 0) 271 else
188 op -= 1 << o->bits; 272 op = (i << -o->shift) & o->bitm;
273 if ((o->flags & PPC_OPERAND_SIGNED) != 0)
274 sign_extend (op);
189 (i is the instruction, o is a pointer to this structure, and op 275 (i is the instruction, o is a pointer to this structure, and op
190 is the result; this assumes twos complement arithmetic). 276 is the result).
191 277
192 If this field is not NULL, then simply call it with the 278 If this field is not NULL, then simply call it with the
193 instruction value. It will return the value of the operand. If 279 instruction value. It will return the value of the operand. If
@@ -195,7 +281,7 @@ struct powerpc_operand
195 non-zero if this operand type can not actually be extracted from 281 non-zero if this operand type can not actually be extracted from
196 this operand (i.e., the instruction does not match). If the 282 this operand (i.e., the instruction does not match). If the
197 operand is valid, *INVALID will not be changed. */ 283 operand is valid, *INVALID will not be changed. */
198 long (*extract) (unsigned long instruction, int dialect, int *invalid); 284 long (*extract) (unsigned long instruction, ppc_cpu_t dialect, int *invalid);
199 285
200 /* One bit syntax flags. */ 286 /* One bit syntax flags. */
201 unsigned long flags; 287 unsigned long flags;
@@ -205,17 +291,23 @@ struct powerpc_operand
205 the operands field of the powerpc_opcodes table. */ 291 the operands field of the powerpc_opcodes table. */
206 292
207extern const struct powerpc_operand powerpc_operands[]; 293extern const struct powerpc_operand powerpc_operands[];
294extern const unsigned int num_powerpc_operands;
295
296/* Use with the shift field of a struct powerpc_operand to indicate
297 that BITM and SHIFT cannot be used to determine where the operand
298 goes in the insn. */
299#define PPC_OPSHIFT_INV (-1U << 31)
208 300
209/* Values defined for the flags field of a struct powerpc_operand. */ 301/* Values defined for the flags field of a struct powerpc_operand. */
210 302
211/* This operand takes signed values. */ 303/* This operand takes signed values. */
212#define PPC_OPERAND_SIGNED (01) 304#define PPC_OPERAND_SIGNED (0x1)
213 305
214/* This operand takes signed values, but also accepts a full positive 306/* This operand takes signed values, but also accepts a full positive
215 range of values when running in 32 bit mode. That is, if bits is 307 range of values when running in 32 bit mode. That is, if bits is
216 16, it takes any value from -0x8000 to 0xffff. In 64 bit mode, 308 16, it takes any value from -0x8000 to 0xffff. In 64 bit mode,
217 this flag is ignored. */ 309 this flag is ignored. */
218#define PPC_OPERAND_SIGNOPT (02) 310#define PPC_OPERAND_SIGNOPT (0x2)
219 311
220/* This operand does not actually exist in the assembler input. This 312/* This operand does not actually exist in the assembler input. This
221 is used to support extended mnemonics such as mr, for which two 313 is used to support extended mnemonics such as mr, for which two
@@ -223,14 +315,14 @@ extern const struct powerpc_operand powerpc_operands[];
223 insert function with any op value. The disassembler should call 315 insert function with any op value. The disassembler should call
224 the extract function, ignore the return value, and check the value 316 the extract function, ignore the return value, and check the value
225 placed in the valid argument. */ 317 placed in the valid argument. */
226#define PPC_OPERAND_FAKE (04) 318#define PPC_OPERAND_FAKE (0x4)
227 319
228/* The next operand should be wrapped in parentheses rather than 320/* The next operand should be wrapped in parentheses rather than
229 separated from this one by a comma. This is used for the load and 321 separated from this one by a comma. This is used for the load and
230 store instructions which want their operands to look like 322 store instructions which want their operands to look like
231 reg,displacement(reg) 323 reg,displacement(reg)
232 */ 324 */
233#define PPC_OPERAND_PARENS (010) 325#define PPC_OPERAND_PARENS (0x8)
234 326
235/* This operand may use the symbolic names for the CR fields, which 327/* This operand may use the symbolic names for the CR fields, which
236 are 328 are
@@ -239,26 +331,26 @@ extern const struct powerpc_operand powerpc_operands[];
239 cr4 4 cr5 5 cr6 6 cr7 7 331 cr4 4 cr5 5 cr6 6 cr7 7
240 These may be combined arithmetically, as in cr2*4+gt. These are 332 These may be combined arithmetically, as in cr2*4+gt. These are
241 only supported on the PowerPC, not the POWER. */ 333 only supported on the PowerPC, not the POWER. */
242#define PPC_OPERAND_CR (020) 334#define PPC_OPERAND_CR_BIT (0x10)
243 335
244/* This operand names a register. The disassembler uses this to print 336/* This operand names a register. The disassembler uses this to print
245 register names with a leading 'r'. */ 337 register names with a leading 'r'. */
246#define PPC_OPERAND_GPR (040) 338#define PPC_OPERAND_GPR (0x20)
247 339
248/* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */ 340/* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */
249#define PPC_OPERAND_GPR_0 (0100) 341#define PPC_OPERAND_GPR_0 (0x40)
250 342
251/* This operand names a floating point register. The disassembler 343/* This operand names a floating point register. The disassembler
252 prints these with a leading 'f'. */ 344 prints these with a leading 'f'. */
253#define PPC_OPERAND_FPR (0200) 345#define PPC_OPERAND_FPR (0x80)
254 346
255/* This operand is a relative branch displacement. The disassembler 347/* This operand is a relative branch displacement. The disassembler
256 prints these symbolically if possible. */ 348 prints these symbolically if possible. */
257#define PPC_OPERAND_RELATIVE (0400) 349#define PPC_OPERAND_RELATIVE (0x100)
258 350
259/* This operand is an absolute branch address. The disassembler 351/* This operand is an absolute branch address. The disassembler
260 prints these symbolically if possible. */ 352 prints these symbolically if possible. */
261#define PPC_OPERAND_ABSOLUTE (01000) 353#define PPC_OPERAND_ABSOLUTE (0x200)
262 354
263/* This operand is optional, and is zero if omitted. This is used for 355/* This operand is optional, and is zero if omitted. This is used for
264 example, in the optional BF field in the comparison instructions. The 356 example, in the optional BF field in the comparison instructions. The
@@ -266,7 +358,7 @@ extern const struct powerpc_operand powerpc_operands[];
266 and the number of operands remaining for the opcode, and decide 358 and the number of operands remaining for the opcode, and decide
267 whether this operand is present or not. The disassembler should 359 whether this operand is present or not. The disassembler should
268 print this operand out only if it is not zero. */ 360 print this operand out only if it is not zero. */
269#define PPC_OPERAND_OPTIONAL (02000) 361#define PPC_OPERAND_OPTIONAL (0x400)
270 362
271/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand 363/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand
272 is omitted, then for the next operand use this operand value plus 364 is omitted, then for the next operand use this operand value plus
@@ -274,24 +366,48 @@ extern const struct powerpc_operand powerpc_operands[];
274 hack is needed because the Power rotate instructions can take 366 hack is needed because the Power rotate instructions can take
275 either 4 or 5 operands. The disassembler should print this operand 367 either 4 or 5 operands. The disassembler should print this operand
276 out regardless of the PPC_OPERAND_OPTIONAL field. */ 368 out regardless of the PPC_OPERAND_OPTIONAL field. */
277#define PPC_OPERAND_NEXT (04000) 369#define PPC_OPERAND_NEXT (0x800)
278 370
279/* This operand should be regarded as a negative number for the 371/* This operand should be regarded as a negative number for the
280 purposes of overflow checking (i.e., the normal most negative 372 purposes of overflow checking (i.e., the normal most negative
281 number is disallowed and one more than the normal most positive 373 number is disallowed and one more than the normal most positive
282 number is allowed). This flag will only be set for a signed 374 number is allowed). This flag will only be set for a signed
283 operand. */ 375 operand. */
284#define PPC_OPERAND_NEGATIVE (010000) 376#define PPC_OPERAND_NEGATIVE (0x1000)
285 377
286/* This operand names a vector unit register. The disassembler 378/* This operand names a vector unit register. The disassembler
287 prints these with a leading 'v'. */ 379 prints these with a leading 'v'. */
288#define PPC_OPERAND_VR (020000) 380#define PPC_OPERAND_VR (0x2000)
289 381
290/* This operand is for the DS field in a DS form instruction. */ 382/* This operand is for the DS field in a DS form instruction. */
291#define PPC_OPERAND_DS (040000) 383#define PPC_OPERAND_DS (0x4000)
292 384
293/* This operand is for the DQ field in a DQ form instruction. */ 385/* This operand is for the DQ field in a DQ form instruction. */
294#define PPC_OPERAND_DQ (0100000) 386#define PPC_OPERAND_DQ (0x8000)
387
388/* Valid range of operand is 0..n rather than 0..n-1. */
389#define PPC_OPERAND_PLUS1 (0x10000)
390
391/* Xilinx APU and FSL related operands */
392#define PPC_OPERAND_FSL (0x20000)
393#define PPC_OPERAND_FCR (0x40000)
394#define PPC_OPERAND_UDI (0x80000)
395
396/* This operand names a vector-scalar unit register. The disassembler
397 prints these with a leading 'vs'. */
398#define PPC_OPERAND_VSR (0x100000)
399
400/* This is a CR FIELD that does not use symbolic names. */
401#define PPC_OPERAND_CR_REG (0x200000)
402
403/* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand
404 is omitted, then the value it should use for the operand is stored
405 in the SHIFT field of the immediatly following operand field. */
406#define PPC_OPERAND_OPTIONAL_VALUE (0x400000)
407
408/* This flag is only used with PPC_OPERAND_OPTIONAL. The operand is
409 only optional when generating 32-bit code. */
410#define PPC_OPERAND_OPTIONAL32 (0x800000)
295 411
296/* The POWER and PowerPC assemblers use a few macros. We keep them 412/* The POWER and PowerPC assemblers use a few macros. We keep them
297 with the operands table for simplicity. The macro table is an 413 with the operands table for simplicity. The macro table is an
@@ -308,7 +424,7 @@ struct powerpc_macro
308 /* One bit flags for the opcode. These are used to indicate which 424 /* One bit flags for the opcode. These are used to indicate which
309 specific processors support the instructions. The values are the 425 specific processors support the instructions. The values are the
310 same as those for the struct powerpc_opcode flags field. */ 426 same as those for the struct powerpc_opcode flags field. */
311 unsigned long flags; 427 ppc_cpu_t flags;
312 428
313 /* A format string to turn the macro into a normal instruction. 429 /* A format string to turn the macro into a normal instruction.
314 Each %N in the string is replaced with operand number N (zero 430 Each %N in the string is replaced with operand number N (zero
@@ -319,4 +435,18 @@ struct powerpc_macro
319extern const struct powerpc_macro powerpc_macros[]; 435extern const struct powerpc_macro powerpc_macros[];
320extern const int powerpc_num_macros; 436extern const int powerpc_num_macros;
321 437
438extern ppc_cpu_t ppc_parse_cpu (ppc_cpu_t, ppc_cpu_t *, const char *);
439
440static inline long
441ppc_optional_operand_value (const struct powerpc_operand *operand)
442{
443 if ((operand->flags & PPC_OPERAND_OPTIONAL_VALUE) != 0)
444 return (operand+1)->shift;
445 return 0;
446}
447
448#ifdef __cplusplus
449}
450#endif
451
322#endif /* PPC_H */ 452#endif /* PPC_H */
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 5720236d0266..26fa03fc9f3c 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -212,6 +212,10 @@ Commands:\n\
212 "\ 212 "\
213 C checksum\n\ 213 C checksum\n\
214 d dump bytes\n\ 214 d dump bytes\n\
215 d1 dump 1 byte values\n\
216 d2 dump 2 byte values\n\
217 d4 dump 4 byte values\n\
218 d8 dump 8 byte values\n\
215 di dump instructions\n\ 219 di dump instructions\n\
216 df dump float values\n\ 220 df dump float values\n\
217 dd dump double values\n\ 221 dd dump double values\n\
@@ -2334,9 +2338,42 @@ static void dump_pacas(void)
2334} 2338}
2335#endif 2339#endif
2336 2340
2341static void dump_by_size(unsigned long addr, long count, int size)
2342{
2343 unsigned char temp[16];
2344 int i, j;
2345 u64 val;
2346
2347 count = ALIGN(count, 16);
2348
2349 for (i = 0; i < count; i += 16, addr += 16) {
2350 printf(REG, addr);
2351
2352 if (mread(addr, temp, 16) != 16) {
2353 printf("\nFaulted reading %d bytes from 0x"REG"\n", 16, addr);
2354 return;
2355 }
2356
2357 for (j = 0; j < 16; j += size) {
2358 putchar(' ');
2359 switch (size) {
2360 case 1: val = temp[j]; break;
2361 case 2: val = *(u16 *)&temp[j]; break;
2362 case 4: val = *(u32 *)&temp[j]; break;
2363 case 8: val = *(u64 *)&temp[j]; break;
2364 default: val = 0;
2365 }
2366
2367 printf("%0*lx", size * 2, val);
2368 }
2369 printf("\n");
2370 }
2371}
2372
2337static void 2373static void
2338dump(void) 2374dump(void)
2339{ 2375{
2376 static char last[] = { "d?\n" };
2340 int c; 2377 int c;
2341 2378
2342 c = inchar(); 2379 c = inchar();
@@ -2350,8 +2387,9 @@ dump(void)
2350 } 2387 }
2351#endif 2388#endif
2352 2389
2353 if ((isxdigit(c) && c != 'f' && c != 'd') || c == '\n') 2390 if (c == '\n')
2354 termch = c; 2391 termch = c;
2392
2355 scanhex((void *)&adrs); 2393 scanhex((void *)&adrs);
2356 if (termch != '\n') 2394 if (termch != '\n')
2357 termch = 0; 2395 termch = 0;
@@ -2383,9 +2421,23 @@ dump(void)
2383 ndump = 64; 2421 ndump = 64;
2384 else if (ndump > MAX_DUMP) 2422 else if (ndump > MAX_DUMP)
2385 ndump = MAX_DUMP; 2423 ndump = MAX_DUMP;
2386 prdump(adrs, ndump); 2424
2425 switch (c) {
2426 case '8':
2427 case '4':
2428 case '2':
2429 case '1':
2430 ndump = ALIGN(ndump, 16);
2431 dump_by_size(adrs, ndump, c - '0');
2432 last[1] = c;
2433 last_cmd = last;
2434 break;
2435 default:
2436 prdump(adrs, ndump);
2437 last_cmd = "d\n";
2438 }
2439
2387 adrs += ndump; 2440 adrs += ndump;
2388 last_cmd = "d\n";
2389 } 2441 }
2390} 2442}
2391 2443
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index ad0118fbce90..c74ae9ce8dc4 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -345,8 +345,6 @@ SECTIONS
345 DISCARDS 345 DISCARDS
346 /DISCARD/ : { 346 /DISCARD/ : {
347 *(.eh_frame) 347 *(.eh_frame)
348 *(__func_stack_frame_non_standard)
349 *(__unreachable)
350 } 348 }
351} 349}
352 350
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 90d112a3063a..5edfd9c49044 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -21,6 +21,7 @@
21#include <linux/platform_data/x86/pmc_atom.h> 21#include <linux/platform_data/x86/pmc_atom.h>
22#include <linux/pm_domain.h> 22#include <linux/pm_domain.h>
23#include <linux/pm_runtime.h> 23#include <linux/pm_runtime.h>
24#include <linux/pwm.h>
24#include <linux/delay.h> 25#include <linux/delay.h>
25 26
26#include "internal.h" 27#include "internal.h"
@@ -154,6 +155,18 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
154 writel(0, pdata->mmio_base + LPSS_I2C_ENABLE); 155 writel(0, pdata->mmio_base + LPSS_I2C_ENABLE);
155} 156}
156 157
158/* BSW PWM used for backlight control by the i915 driver */
159static struct pwm_lookup bsw_pwm_lookup[] = {
160 PWM_LOOKUP_WITH_MODULE("80862288:00", 0, "0000:00:02.0",
161 "pwm_backlight", 0, PWM_POLARITY_NORMAL,
162 "pwm-lpss-platform"),
163};
164
165static void bsw_pwm_setup(struct lpss_private_data *pdata)
166{
167 pwm_add_table(bsw_pwm_lookup, ARRAY_SIZE(bsw_pwm_lookup));
168}
169
157static const struct lpss_device_desc lpt_dev_desc = { 170static const struct lpss_device_desc lpt_dev_desc = {
158 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR, 171 .flags = LPSS_CLK | LPSS_CLK_GATE | LPSS_CLK_DIVIDER | LPSS_LTR,
159 .prv_offset = 0x800, 172 .prv_offset = 0x800,
@@ -191,6 +204,7 @@ static const struct lpss_device_desc byt_pwm_dev_desc = {
191 204
192static const struct lpss_device_desc bsw_pwm_dev_desc = { 205static const struct lpss_device_desc bsw_pwm_dev_desc = {
193 .flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY, 206 .flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
207 .setup = bsw_pwm_setup,
194}; 208};
195 209
196static const struct lpss_device_desc byt_uart_dev_desc = { 210static const struct lpss_device_desc byt_uart_dev_desc = {
diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 718f832a5c71..0007b792827b 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -325,6 +325,9 @@ static const struct file_operations dma_buf_fops = {
325 .llseek = dma_buf_llseek, 325 .llseek = dma_buf_llseek,
326 .poll = dma_buf_poll, 326 .poll = dma_buf_poll,
327 .unlocked_ioctl = dma_buf_ioctl, 327 .unlocked_ioctl = dma_buf_ioctl,
328#ifdef CONFIG_COMPAT
329 .compat_ioctl = dma_buf_ioctl,
330#endif
328}; 331};
329 332
330/* 333/*
diff --git a/drivers/gpu/drm/ast/ast_dram_tables.h b/drivers/gpu/drm/ast/ast_dram_tables.h
index cc04539c0ff3..1d9c4e75d303 100644
--- a/drivers/gpu/drm/ast/ast_dram_tables.h
+++ b/drivers/gpu/drm/ast/ast_dram_tables.h
@@ -141,4 +141,66 @@ static const struct ast_dramstruct ast2100_dram_table_data[] = {
141 { 0xffff, 0xffffffff }, 141 { 0xffff, 0xffffffff },
142}; 142};
143 143
144/*
145 * AST2500 DRAM settings modules
146 */
147#define REGTBL_NUM 17
148#define REGIDX_010 0
149#define REGIDX_014 1
150#define REGIDX_018 2
151#define REGIDX_020 3
152#define REGIDX_024 4
153#define REGIDX_02C 5
154#define REGIDX_030 6
155#define REGIDX_214 7
156#define REGIDX_2E0 8
157#define REGIDX_2E4 9
158#define REGIDX_2E8 10
159#define REGIDX_2EC 11
160#define REGIDX_2F0 12
161#define REGIDX_2F4 13
162#define REGIDX_2F8 14
163#define REGIDX_RFC 15
164#define REGIDX_PLL 16
165
166static const u32 ast2500_ddr3_1600_timing_table[REGTBL_NUM] = {
167 0x64604D38, /* 0x010 */
168 0x29690599, /* 0x014 */
169 0x00000300, /* 0x018 */
170 0x00000000, /* 0x020 */
171 0x00000000, /* 0x024 */
172 0x02181E70, /* 0x02C */
173 0x00000040, /* 0x030 */
174 0x00000024, /* 0x214 */
175 0x02001300, /* 0x2E0 */
176 0x0E0000A0, /* 0x2E4 */
177 0x000E001B, /* 0x2E8 */
178 0x35B8C105, /* 0x2EC */
179 0x08090408, /* 0x2F0 */
180 0x9B000800, /* 0x2F4 */
181 0x0E400A00, /* 0x2F8 */
182 0x9971452F, /* tRFC */
183 0x000071C1 /* PLL */
184};
185
186static const u32 ast2500_ddr4_1600_timing_table[REGTBL_NUM] = {
187 0x63604E37, /* 0x010 */
188 0xE97AFA99, /* 0x014 */
189 0x00019000, /* 0x018 */
190 0x08000000, /* 0x020 */
191 0x00000400, /* 0x024 */
192 0x00000410, /* 0x02C */
193 0x00000101, /* 0x030 */
194 0x00000024, /* 0x214 */
195 0x03002900, /* 0x2E0 */
196 0x0E0000A0, /* 0x2E4 */
197 0x000E001C, /* 0x2E8 */
198 0x35B8C106, /* 0x2EC */
199 0x08080607, /* 0x2F0 */
200 0x9B000900, /* 0x2F4 */
201 0x0E400A00, /* 0x2F8 */
202 0x99714545, /* tRFC */
203 0x000071C1 /* PLL */
204};
205
144#endif 206#endif
diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
index 5a8fa1c85229..8880f0b62e9c 100644
--- a/drivers/gpu/drm/ast/ast_drv.h
+++ b/drivers/gpu/drm/ast/ast_drv.h
@@ -65,6 +65,7 @@ enum ast_chip {
65 AST2150, 65 AST2150,
66 AST2300, 66 AST2300,
67 AST2400, 67 AST2400,
68 AST2500,
68 AST1180, 69 AST1180,
69}; 70};
70 71
@@ -81,6 +82,7 @@ enum ast_tx_chip {
81#define AST_DRAM_1Gx32 3 82#define AST_DRAM_1Gx32 3
82#define AST_DRAM_2Gx16 6 83#define AST_DRAM_2Gx16 6
83#define AST_DRAM_4Gx16 7 84#define AST_DRAM_4Gx16 7
85#define AST_DRAM_8Gx16 8
84 86
85struct ast_fbdev; 87struct ast_fbdev;
86 88
@@ -114,7 +116,11 @@ struct ast_private {
114 struct ttm_bo_kmap_obj cache_kmap; 116 struct ttm_bo_kmap_obj cache_kmap;
115 int next_cursor; 117 int next_cursor;
116 bool support_wide_screen; 118 bool support_wide_screen;
117 bool DisableP2A; 119 enum {
120 ast_use_p2a,
121 ast_use_dt,
122 ast_use_defaults
123 } config_mode;
118 124
119 enum ast_tx_chip tx_chip_type; 125 enum ast_tx_chip tx_chip_type;
120 u8 dp501_maxclk; 126 u8 dp501_maxclk;
@@ -301,8 +307,8 @@ struct ast_vbios_dclk_info {
301}; 307};
302 308
303struct ast_vbios_mode_info { 309struct ast_vbios_mode_info {
304 struct ast_vbios_stdtable *std_table; 310 const struct ast_vbios_stdtable *std_table;
305 struct ast_vbios_enhtable *enh_table; 311 const struct ast_vbios_enhtable *enh_table;
306}; 312};
307 313
308extern int ast_mode_init(struct drm_device *dev); 314extern int ast_mode_init(struct drm_device *dev);
diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 993909430736..262c2c0e43b4 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -32,8 +32,6 @@
32#include <drm/drm_fb_helper.h> 32#include <drm/drm_fb_helper.h>
33#include <drm/drm_crtc_helper.h> 33#include <drm/drm_crtc_helper.h>
34 34
35#include "ast_dram_tables.h"
36
37void ast_set_index_reg_mask(struct ast_private *ast, 35void ast_set_index_reg_mask(struct ast_private *ast,
38 uint32_t base, uint8_t index, 36 uint32_t base, uint8_t index,
39 uint8_t mask, uint8_t val) 37 uint8_t mask, uint8_t val)
@@ -62,30 +60,99 @@ uint8_t ast_get_index_reg_mask(struct ast_private *ast,
62 return ret; 60 return ret;
63} 61}
64 62
63static void ast_detect_config_mode(struct drm_device *dev, u32 *scu_rev)
64{
65 struct device_node *np = dev->pdev->dev.of_node;
66 struct ast_private *ast = dev->dev_private;
67 uint32_t data, jregd0, jregd1;
68
69 /* Defaults */
70 ast->config_mode = ast_use_defaults;
71 *scu_rev = 0xffffffff;
72
73 /* Check if we have device-tree properties */
74 if (np && !of_property_read_u32(np, "aspeed,scu-revision-id",
75 scu_rev)) {
76 /* We do, disable P2A access */
77 ast->config_mode = ast_use_dt;
78 DRM_INFO("Using device-tree for configuration\n");
79 return;
80 }
81
82 /* Not all families have a P2A bridge */
83 if (dev->pdev->device != PCI_CHIP_AST2000)
84 return;
85
86 /*
87 * The BMC will set SCU 0x40 D[12] to 1 if the P2 bridge
88 * is disabled. We force using P2A if VGA only mode bit
89 * is set D[7]
90 */
91 jregd0 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
92 jregd1 = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd1, 0xff);
93 if (!(jregd0 & 0x80) || !(jregd1 & 0x10)) {
94 /* Double check it's actually working */
95 data = ast_read32(ast, 0xf004);
96 if (data != 0xFFFFFFFF) {
97 /* P2A works, grab silicon revision */
98 ast->config_mode = ast_use_p2a;
99
100 DRM_INFO("Using P2A bridge for configuration\n");
101
102 /* Read SCU7c (silicon revision register) */
103 ast_write32(ast, 0xf004, 0x1e6e0000);
104 ast_write32(ast, 0xf000, 0x1);
105 *scu_rev = ast_read32(ast, 0x1207c);
106 return;
107 }
108 }
109
110 /* We have a P2A bridge but it's disabled */
111 DRM_INFO("P2A bridge disabled, using default configuration\n");
112}
65 113
66static int ast_detect_chip(struct drm_device *dev, bool *need_post) 114static int ast_detect_chip(struct drm_device *dev, bool *need_post)
67{ 115{
68 struct ast_private *ast = dev->dev_private; 116 struct ast_private *ast = dev->dev_private;
69 uint32_t data, jreg; 117 uint32_t jreg, scu_rev;
118
119 /*
120 * If VGA isn't enabled, we need to enable now or subsequent
121 * access to the scratch registers will fail. We also inform
122 * our caller that it needs to POST the chip
123 * (Assumption: VGA not enabled -> need to POST)
124 */
125 if (!ast_is_vga_enabled(dev)) {
126 ast_enable_vga(dev);
127 DRM_INFO("VGA not enabled on entry, requesting chip POST\n");
128 *need_post = true;
129 } else
130 *need_post = false;
131
132
133 /* Enable extended register access */
134 ast_enable_mmio(dev);
70 ast_open_key(ast); 135 ast_open_key(ast);
71 136
137 /* Find out whether P2A works or whether to use device-tree */
138 ast_detect_config_mode(dev, &scu_rev);
139
140 /* Identify chipset */
72 if (dev->pdev->device == PCI_CHIP_AST1180) { 141 if (dev->pdev->device == PCI_CHIP_AST1180) {
73 ast->chip = AST1100; 142 ast->chip = AST1100;
74 DRM_INFO("AST 1180 detected\n"); 143 DRM_INFO("AST 1180 detected\n");
75 } else { 144 } else {
76 if (dev->pdev->revision >= 0x30) { 145 if (dev->pdev->revision >= 0x40) {
146 ast->chip = AST2500;
147 DRM_INFO("AST 2500 detected\n");
148 } else if (dev->pdev->revision >= 0x30) {
77 ast->chip = AST2400; 149 ast->chip = AST2400;
78 DRM_INFO("AST 2400 detected\n"); 150 DRM_INFO("AST 2400 detected\n");
79 } else if (dev->pdev->revision >= 0x20) { 151 } else if (dev->pdev->revision >= 0x20) {
80 ast->chip = AST2300; 152 ast->chip = AST2300;
81 DRM_INFO("AST 2300 detected\n"); 153 DRM_INFO("AST 2300 detected\n");
82 } else if (dev->pdev->revision >= 0x10) { 154 } else if (dev->pdev->revision >= 0x10) {
83 uint32_t data; 155 switch (scu_rev & 0x0300) {
84 ast_write32(ast, 0xf004, 0x1e6e0000);
85 ast_write32(ast, 0xf000, 0x1);
86
87 data = ast_read32(ast, 0x1207c);
88 switch (data & 0x0300) {
89 case 0x0200: 156 case 0x0200:
90 ast->chip = AST1100; 157 ast->chip = AST1100;
91 DRM_INFO("AST 1100 detected\n"); 158 DRM_INFO("AST 1100 detected\n");
@@ -110,26 +177,6 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
110 } 177 }
111 } 178 }
112 179
113 /*
114 * If VGA isn't enabled, we need to enable now or subsequent
115 * access to the scratch registers will fail. We also inform
116 * our caller that it needs to POST the chip
117 * (Assumption: VGA not enabled -> need to POST)
118 */
119 if (!ast_is_vga_enabled(dev)) {
120 ast_enable_vga(dev);
121 ast_enable_mmio(dev);
122 DRM_INFO("VGA not enabled on entry, requesting chip POST\n");
123 *need_post = true;
124 } else
125 *need_post = false;
126
127 /* Check P2A Access */
128 ast->DisableP2A = true;
129 data = ast_read32(ast, 0xf004);
130 if (data != 0xFFFFFFFF)
131 ast->DisableP2A = false;
132
133 /* Check if we support wide screen */ 180 /* Check if we support wide screen */
134 switch (ast->chip) { 181 switch (ast->chip) {
135 case AST1180: 182 case AST1180:
@@ -146,17 +193,15 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
146 ast->support_wide_screen = true; 193 ast->support_wide_screen = true;
147 else { 194 else {
148 ast->support_wide_screen = false; 195 ast->support_wide_screen = false;
149 if (ast->DisableP2A == false) { 196 if (ast->chip == AST2300 &&
150 /* Read SCU7c (silicon revision register) */ 197 (scu_rev & 0x300) == 0x0) /* ast1300 */
151 ast_write32(ast, 0xf004, 0x1e6e0000); 198 ast->support_wide_screen = true;
152 ast_write32(ast, 0xf000, 0x1); 199 if (ast->chip == AST2400 &&
153 data = ast_read32(ast, 0x1207c); 200 (scu_rev & 0x300) == 0x100) /* ast1400 */
154 data &= 0x300; 201 ast->support_wide_screen = true;
155 if (ast->chip == AST2300 && data == 0x0) /* ast1300 */ 202 if (ast->chip == AST2500 &&
156 ast->support_wide_screen = true; 203 scu_rev == 0x100) /* ast2510 */
157 if (ast->chip == AST2400 && data == 0x100) /* ast1400 */ 204 ast->support_wide_screen = true;
158 ast->support_wide_screen = true;
159 }
160 } 205 }
161 break; 206 break;
162 } 207 }
@@ -220,85 +265,121 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
220 265
221static int ast_get_dram_info(struct drm_device *dev) 266static int ast_get_dram_info(struct drm_device *dev)
222{ 267{
268 struct device_node *np = dev->pdev->dev.of_node;
223 struct ast_private *ast = dev->dev_private; 269 struct ast_private *ast = dev->dev_private;
224 uint32_t data, data2; 270 uint32_t mcr_cfg, mcr_scu_mpll, mcr_scu_strap;
225 uint32_t denum, num, div, ref_pll; 271 uint32_t denum, num, div, ref_pll, dsel;
226 272
227 if (ast->DisableP2A) 273 switch (ast->config_mode) {
228 { 274 case ast_use_dt:
229 ast->dram_bus_width = 16; 275 /*
230 ast->dram_type = AST_DRAM_1Gx16; 276 * If some properties are missing, use reasonable
231 ast->mclk = 396; 277 * defaults for AST2400
232 } 278 */
233 else 279 if (of_property_read_u32(np, "aspeed,mcr-configuration",
234 { 280 &mcr_cfg))
281 mcr_cfg = 0x00000577;
282 if (of_property_read_u32(np, "aspeed,mcr-scu-mpll",
283 &mcr_scu_mpll))
284 mcr_scu_mpll = 0x000050C0;
285 if (of_property_read_u32(np, "aspeed,mcr-scu-strap",
286 &mcr_scu_strap))
287 mcr_scu_strap = 0;
288 break;
289 case ast_use_p2a:
235 ast_write32(ast, 0xf004, 0x1e6e0000); 290 ast_write32(ast, 0xf004, 0x1e6e0000);
236 ast_write32(ast, 0xf000, 0x1); 291 ast_write32(ast, 0xf000, 0x1);
237 data = ast_read32(ast, 0x10004); 292 mcr_cfg = ast_read32(ast, 0x10004);
238 293 mcr_scu_mpll = ast_read32(ast, 0x10120);
239 if (data & 0x40) 294 mcr_scu_strap = ast_read32(ast, 0x10170);
240 ast->dram_bus_width = 16; 295 break;
296 case ast_use_defaults:
297 default:
298 ast->dram_bus_width = 16;
299 ast->dram_type = AST_DRAM_1Gx16;
300 if (ast->chip == AST2500)
301 ast->mclk = 800;
241 else 302 else
242 ast->dram_bus_width = 32; 303 ast->mclk = 396;
243 304 return 0;
244 if (ast->chip == AST2300 || ast->chip == AST2400) { 305 }
245 switch (data & 0x03) {
246 case 0:
247 ast->dram_type = AST_DRAM_512Mx16;
248 break;
249 default:
250 case 1:
251 ast->dram_type = AST_DRAM_1Gx16;
252 break;
253 case 2:
254 ast->dram_type = AST_DRAM_2Gx16;
255 break;
256 case 3:
257 ast->dram_type = AST_DRAM_4Gx16;
258 break;
259 }
260 } else {
261 switch (data & 0x0c) {
262 case 0:
263 case 4:
264 ast->dram_type = AST_DRAM_512Mx16;
265 break;
266 case 8:
267 if (data & 0x40)
268 ast->dram_type = AST_DRAM_1Gx16;
269 else
270 ast->dram_type = AST_DRAM_512Mx32;
271 break;
272 case 0xc:
273 ast->dram_type = AST_DRAM_1Gx32;
274 break;
275 }
276 }
277 306
278 data = ast_read32(ast, 0x10120); 307 if (mcr_cfg & 0x40)
279 data2 = ast_read32(ast, 0x10170); 308 ast->dram_bus_width = 16;
280 if (data2 & 0x2000) 309 else
281 ref_pll = 14318; 310 ast->dram_bus_width = 32;
282 else
283 ref_pll = 12000;
284 311
285 denum = data & 0x1f; 312 if (ast->chip == AST2500) {
286 num = (data & 0x3fe0) >> 5; 313 switch (mcr_cfg & 0x03) {
287 data = (data & 0xc000) >> 14; 314 case 0:
288 switch (data) { 315 ast->dram_type = AST_DRAM_1Gx16;
289 case 3:
290 div = 0x4;
291 break; 316 break;
292 case 2: 317 default:
293 case 1: 318 case 1:
294 div = 0x2; 319 ast->dram_type = AST_DRAM_2Gx16;
320 break;
321 case 2:
322 ast->dram_type = AST_DRAM_4Gx16;
323 break;
324 case 3:
325 ast->dram_type = AST_DRAM_8Gx16;
326 break;
327 }
328 } else if (ast->chip == AST2300 || ast->chip == AST2400) {
329 switch (mcr_cfg & 0x03) {
330 case 0:
331 ast->dram_type = AST_DRAM_512Mx16;
295 break; 332 break;
296 default: 333 default:
297 div = 0x1; 334 case 1:
335 ast->dram_type = AST_DRAM_1Gx16;
336 break;
337 case 2:
338 ast->dram_type = AST_DRAM_2Gx16;
339 break;
340 case 3:
341 ast->dram_type = AST_DRAM_4Gx16;
342 break;
343 }
344 } else {
345 switch (mcr_cfg & 0x0c) {
346 case 0:
347 case 4:
348 ast->dram_type = AST_DRAM_512Mx16;
349 break;
350 case 8:
351 if (mcr_cfg & 0x40)
352 ast->dram_type = AST_DRAM_1Gx16;
353 else
354 ast->dram_type = AST_DRAM_512Mx32;
355 break;
356 case 0xc:
357 ast->dram_type = AST_DRAM_1Gx32;
298 break; 358 break;
299 } 359 }
300 ast->mclk = ref_pll * (num + 2) / (denum + 2) * (div * 1000);
301 } 360 }
361
362 if (mcr_scu_strap & 0x2000)
363 ref_pll = 14318;
364 else
365 ref_pll = 12000;
366
367 denum = mcr_scu_mpll & 0x1f;
368 num = (mcr_scu_mpll & 0x3fe0) >> 5;
369 dsel = (mcr_scu_mpll & 0xc000) >> 14;
370 switch (dsel) {
371 case 3:
372 div = 0x4;
373 break;
374 case 2:
375 case 1:
376 div = 0x2;
377 break;
378 default:
379 div = 0x1;
380 break;
381 }
382 ast->mclk = ref_pll * (num + 2) / ((denum + 2) * (div * 1000));
302 return 0; 383 return 0;
303} 384}
304 385
@@ -437,17 +518,19 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
437 518
438 ast_detect_chip(dev, &need_post); 519 ast_detect_chip(dev, &need_post);
439 520
521 if (need_post)
522 ast_post_gpu(dev);
523
440 if (ast->chip != AST1180) { 524 if (ast->chip != AST1180) {
441 ret = ast_get_dram_info(dev); 525 ret = ast_get_dram_info(dev);
442 if (ret) 526 if (ret)
443 goto out_free; 527 goto out_free;
444 ast->vram_size = ast_get_vram_info(dev); 528 ast->vram_size = ast_get_vram_info(dev);
445 DRM_INFO("dram %d %d %d %08x\n", ast->mclk, ast->dram_type, ast->dram_bus_width, ast->vram_size); 529 DRM_INFO("dram MCLK=%u Mhz type=%d bus_width=%d size=%08x\n",
530 ast->mclk, ast->dram_type,
531 ast->dram_bus_width, ast->vram_size);
446 } 532 }
447 533
448 if (need_post)
449 ast_post_gpu(dev);
450
451 ret = ast_mm_init(ast); 534 ret = ast_mm_init(ast);
452 if (ret) 535 if (ret)
453 goto out_free; 536 goto out_free;
@@ -465,6 +548,7 @@ int ast_driver_load(struct drm_device *dev, unsigned long flags)
465 ast->chip == AST2200 || 548 ast->chip == AST2200 ||
466 ast->chip == AST2300 || 549 ast->chip == AST2300 ||
467 ast->chip == AST2400 || 550 ast->chip == AST2400 ||
551 ast->chip == AST2500 ||
468 ast->chip == AST1180) { 552 ast->chip == AST1180) {
469 dev->mode_config.max_width = 1920; 553 dev->mode_config.max_width = 1920;
470 dev->mode_config.max_height = 2048; 554 dev->mode_config.max_height = 2048;
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 606cb40f6c7c..47b78e52691c 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -81,9 +81,9 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
81 struct ast_private *ast = crtc->dev->dev_private; 81 struct ast_private *ast = crtc->dev->dev_private;
82 const struct drm_framebuffer *fb = crtc->primary->fb; 82 const struct drm_framebuffer *fb = crtc->primary->fb;
83 u32 refresh_rate_index = 0, mode_id, color_index, refresh_rate; 83 u32 refresh_rate_index = 0, mode_id, color_index, refresh_rate;
84 const struct ast_vbios_enhtable *best = NULL;
84 u32 hborder, vborder; 85 u32 hborder, vborder;
85 bool check_sync; 86 bool check_sync;
86 struct ast_vbios_enhtable *best = NULL;
87 87
88 switch (fb->format->cpp[0] * 8) { 88 switch (fb->format->cpp[0] * 8) {
89 case 8: 89 case 8:
@@ -147,7 +147,7 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo
147 refresh_rate = drm_mode_vrefresh(mode); 147 refresh_rate = drm_mode_vrefresh(mode);
148 check_sync = vbios_mode->enh_table->flags & WideScreenMode; 148 check_sync = vbios_mode->enh_table->flags & WideScreenMode;
149 do { 149 do {
150 struct ast_vbios_enhtable *loop = vbios_mode->enh_table; 150 const struct ast_vbios_enhtable *loop = vbios_mode->enh_table;
151 151
152 while (loop->refresh_rate != 0xff) { 152 while (loop->refresh_rate != 0xff) {
153 if ((check_sync) && 153 if ((check_sync) &&
@@ -227,7 +227,7 @@ static void ast_set_std_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
227 struct ast_vbios_mode_info *vbios_mode) 227 struct ast_vbios_mode_info *vbios_mode)
228{ 228{
229 struct ast_private *ast = crtc->dev->dev_private; 229 struct ast_private *ast = crtc->dev->dev_private;
230 struct ast_vbios_stdtable *stdtable; 230 const struct ast_vbios_stdtable *stdtable;
231 u32 i; 231 u32 i;
232 u8 jreg; 232 u8 jreg;
233 233
@@ -273,7 +273,11 @@ static void ast_set_crtc_reg(struct drm_crtc *crtc, struct drm_display_mode *mod
273{ 273{
274 struct ast_private *ast = crtc->dev->dev_private; 274 struct ast_private *ast = crtc->dev->dev_private;
275 u8 jreg05 = 0, jreg07 = 0, jreg09 = 0, jregAC = 0, jregAD = 0, jregAE = 0; 275 u8 jreg05 = 0, jreg07 = 0, jreg09 = 0, jregAC = 0, jregAD = 0, jregAE = 0;
276 u16 temp; 276 u16 temp, precache = 0;
277
278 if ((ast->chip == AST2500) &&
279 (vbios_mode->enh_table->flags & AST2500PreCatchCRT))
280 precache = 40;
277 281
278 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x11, 0x7f, 0x00); 282 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x11, 0x7f, 0x00);
279 283
@@ -299,12 +303,12 @@ static void ast_set_crtc_reg(struct drm_crtc *crtc, struct drm_display_mode *mod
299 jregAD |= 0x01; /* HBE D[5] */ 303 jregAD |= 0x01; /* HBE D[5] */
300 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x03, 0xE0, (temp & 0x1f)); 304 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x03, 0xE0, (temp & 0x1f));
301 305
302 temp = (mode->crtc_hsync_start >> 3) - 1; 306 temp = ((mode->crtc_hsync_start-precache) >> 3) - 1;
303 if (temp & 0x100) 307 if (temp & 0x100)
304 jregAC |= 0x40; /* HRS D[5] */ 308 jregAC |= 0x40; /* HRS D[5] */
305 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x04, 0x00, temp); 309 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x04, 0x00, temp);
306 310
307 temp = ((mode->crtc_hsync_end >> 3) - 1) & 0x3f; 311 temp = (((mode->crtc_hsync_end-precache) >> 3) - 1) & 0x3f;
308 if (temp & 0x20) 312 if (temp & 0x20)
309 jregAD |= 0x04; /* HRE D[5] */ 313 jregAD |= 0x04; /* HRE D[5] */
310 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x05, 0x60, (u8)((temp & 0x1f) | jreg05)); 314 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x05, 0x60, (u8)((temp & 0x1f) | jreg05));
@@ -365,6 +369,11 @@ static void ast_set_crtc_reg(struct drm_crtc *crtc, struct drm_display_mode *mod
365 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x09, 0xdf, jreg09); 369 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x09, 0xdf, jreg09);
366 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xAE, 0x00, (jregAE | 0x80)); 370 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xAE, 0x00, (jregAE | 0x80));
367 371
372 if (precache)
373 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0x3f, 0x80);
374 else
375 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0x3f, 0x00);
376
368 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x11, 0x7f, 0x80); 377 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0x11, 0x7f, 0x80);
369} 378}
370 379
@@ -384,14 +393,18 @@ static void ast_set_dclk_reg(struct drm_device *dev, struct drm_display_mode *mo
384 struct ast_vbios_mode_info *vbios_mode) 393 struct ast_vbios_mode_info *vbios_mode)
385{ 394{
386 struct ast_private *ast = dev->dev_private; 395 struct ast_private *ast = dev->dev_private;
387 struct ast_vbios_dclk_info *clk_info; 396 const struct ast_vbios_dclk_info *clk_info;
388 397
389 clk_info = &dclk_table[vbios_mode->enh_table->dclk_index]; 398 if (ast->chip == AST2500)
399 clk_info = &dclk_table_ast2500[vbios_mode->enh_table->dclk_index];
400 else
401 clk_info = &dclk_table[vbios_mode->enh_table->dclk_index];
390 402
391 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xc0, 0x00, clk_info->param1); 403 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xc0, 0x00, clk_info->param1);
392 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xc1, 0x00, clk_info->param2); 404 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xc1, 0x00, clk_info->param2);
393 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xbb, 0x0f, 405 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xbb, 0x0f,
394 (clk_info->param3 & 0x80) | ((clk_info->param3 & 0x3) << 4)); 406 (clk_info->param3 & 0xc0) |
407 ((clk_info->param3 & 0x3) << 4));
395} 408}
396 409
397static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode, 410static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode,
@@ -425,7 +438,8 @@ static void ast_set_ext_reg(struct drm_crtc *crtc, struct drm_display_mode *mode
425 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa8, 0xfd, jregA8); 438 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa8, 0xfd, jregA8);
426 439
427 /* Set Threshold */ 440 /* Set Threshold */
428 if (ast->chip == AST2300 || ast->chip == AST2400) { 441 if (ast->chip == AST2300 || ast->chip == AST2400 ||
442 ast->chip == AST2500) {
429 ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa7, 0x78); 443 ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa7, 0x78);
430 ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa6, 0x60); 444 ast_set_index_reg(ast, AST_IO_CRTC_PORT, 0xa6, 0x60);
431 } else if (ast->chip == AST2100 || 445 } else if (ast->chip == AST2100 ||
@@ -800,7 +814,9 @@ static int ast_mode_valid(struct drm_connector *connector,
800 if ((mode->hdisplay == 1600) && (mode->vdisplay == 900)) 814 if ((mode->hdisplay == 1600) && (mode->vdisplay == 900))
801 return MODE_OK; 815 return MODE_OK;
802 816
803 if ((ast->chip == AST2100) || (ast->chip == AST2200) || (ast->chip == AST2300) || (ast->chip == AST2400) || (ast->chip == AST1180)) { 817 if ((ast->chip == AST2100) || (ast->chip == AST2200) ||
818 (ast->chip == AST2300) || (ast->chip == AST2400) ||
819 (ast->chip == AST2500) || (ast->chip == AST1180)) {
804 if ((mode->hdisplay == 1920) && (mode->vdisplay == 1080)) 820 if ((mode->hdisplay == 1920) && (mode->vdisplay == 1080))
805 return MODE_OK; 821 return MODE_OK;
806 822
diff --git a/drivers/gpu/drm/ast/ast_post.c b/drivers/gpu/drm/ast/ast_post.c
index 5331ee1df086..f7d421359d56 100644
--- a/drivers/gpu/drm/ast/ast_post.c
+++ b/drivers/gpu/drm/ast/ast_post.c
@@ -31,7 +31,8 @@
31 31
32#include "ast_dram_tables.h" 32#include "ast_dram_tables.h"
33 33
34static void ast_init_dram_2300(struct drm_device *dev); 34static void ast_post_chip_2300(struct drm_device *dev);
35static void ast_post_chip_2500(struct drm_device *dev);
35 36
36void ast_enable_vga(struct drm_device *dev) 37void ast_enable_vga(struct drm_device *dev)
37{ 38{
@@ -58,13 +59,9 @@ bool ast_is_vga_enabled(struct drm_device *dev)
58 /* TODO 1180 */ 59 /* TODO 1180 */
59 } else { 60 } else {
60 ch = ast_io_read8(ast, AST_IO_VGA_ENABLE_PORT); 61 ch = ast_io_read8(ast, AST_IO_VGA_ENABLE_PORT);
61 if (ch) { 62 return !!(ch & 0x01);
62 ast_open_key(ast);
63 ch = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff);
64 return ch & 0x04;
65 }
66 } 63 }
67 return 0; 64 return false;
68} 65}
69 66
70static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff }; 67static const u8 extreginfo[] = { 0x0f, 0x04, 0x1c, 0xff };
@@ -79,10 +76,11 @@ ast_set_def_ext_reg(struct drm_device *dev)
79 const u8 *ext_reg_info; 76 const u8 *ext_reg_info;
80 77
81 /* reset scratch */ 78 /* reset scratch */
82 for (i = 0x81; i <= 0x8f; i++) 79 for (i = 0x81; i <= 0x9f; i++)
83 ast_set_index_reg(ast, AST_IO_CRTC_PORT, i, 0x00); 80 ast_set_index_reg(ast, AST_IO_CRTC_PORT, i, 0x00);
84 81
85 if (ast->chip == AST2300 || ast->chip == AST2400) { 82 if (ast->chip == AST2300 || ast->chip == AST2400 ||
83 ast->chip == AST2500) {
86 if (dev->pdev->revision >= 0x20) 84 if (dev->pdev->revision >= 0x20)
87 ext_reg_info = extreginfo_ast2300; 85 ext_reg_info = extreginfo_ast2300;
88 else 86 else
@@ -106,7 +104,8 @@ ast_set_def_ext_reg(struct drm_device *dev)
106 104
107 /* Enable RAMDAC for A1 */ 105 /* Enable RAMDAC for A1 */
108 reg = 0x04; 106 reg = 0x04;
109 if (ast->chip == AST2300 || ast->chip == AST2400) 107 if (ast->chip == AST2300 || ast->chip == AST2400 ||
108 ast->chip == AST2500)
110 reg |= 0x20; 109 reg |= 0x20;
111 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff, reg); 110 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xb6, 0xff, reg);
112} 111}
@@ -375,21 +374,20 @@ void ast_post_gpu(struct drm_device *dev)
375 pci_write_config_dword(ast->dev->pdev, 0x04, reg); 374 pci_write_config_dword(ast->dev->pdev, 0x04, reg);
376 375
377 ast_enable_vga(dev); 376 ast_enable_vga(dev);
378 ast_enable_mmio(dev);
379 ast_open_key(ast); 377 ast_open_key(ast);
378 ast_enable_mmio(dev);
380 ast_set_def_ext_reg(dev); 379 ast_set_def_ext_reg(dev);
381 380
382 if (ast->DisableP2A == false) 381 if (ast->config_mode == ast_use_p2a) {
383 { 382 if (ast->chip == AST2500)
384 if (ast->chip == AST2300 || ast->chip == AST2400) 383 ast_post_chip_2500(dev);
385 ast_init_dram_2300(dev); 384 else if (ast->chip == AST2300 || ast->chip == AST2400)
385 ast_post_chip_2300(dev);
386 else 386 else
387 ast_init_dram_reg(dev); 387 ast_init_dram_reg(dev);
388 388
389 ast_init_3rdtx(dev); 389 ast_init_3rdtx(dev);
390 } 390 } else {
391 else
392 {
393 if (ast->tx_chip_type != AST_TX_NONE) 391 if (ast->tx_chip_type != AST_TX_NONE)
394 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xcf, 0x80); /* Enable DVO */ 392 ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xa3, 0xcf, 0x80); /* Enable DVO */
395 } 393 }
@@ -448,85 +446,70 @@ static const u32 pattern[8] = {
448 0x7C61D253 446 0x7C61D253
449}; 447};
450 448
451static int mmc_test_burst(struct ast_private *ast, u32 datagen) 449static bool mmc_test(struct ast_private *ast, u32 datagen, u8 test_ctl)
452{ 450{
453 u32 data, timeout; 451 u32 data, timeout;
454 452
455 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 453 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
456 ast_moutdwm(ast, 0x1e6e0070, 0x000000c1 | (datagen << 3)); 454 ast_moutdwm(ast, 0x1e6e0070, (datagen << 3) | test_ctl);
457 timeout = 0; 455 timeout = 0;
458 do { 456 do {
459 data = ast_mindwm(ast, 0x1e6e0070) & 0x3000; 457 data = ast_mindwm(ast, 0x1e6e0070) & 0x3000;
460 if (data & 0x2000) { 458 if (data & 0x2000)
461 return 0; 459 return false;
462 }
463 if (++timeout > TIMEOUT) { 460 if (++timeout > TIMEOUT) {
464 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 461 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
465 return 0; 462 return false;
466 } 463 }
467 } while (!data); 464 } while (!data);
468 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 465 ast_moutdwm(ast, 0x1e6e0070, 0x0);
469 return 1; 466 return true;
470} 467}
471 468
472static int mmc_test_burst2(struct ast_private *ast, u32 datagen) 469static u32 mmc_test2(struct ast_private *ast, u32 datagen, u8 test_ctl)
473{ 470{
474 u32 data, timeout; 471 u32 data, timeout;
475 472
476 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 473 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
477 ast_moutdwm(ast, 0x1e6e0070, 0x00000041 | (datagen << 3)); 474 ast_moutdwm(ast, 0x1e6e0070, (datagen << 3) | test_ctl);
478 timeout = 0; 475 timeout = 0;
479 do { 476 do {
480 data = ast_mindwm(ast, 0x1e6e0070) & 0x1000; 477 data = ast_mindwm(ast, 0x1e6e0070) & 0x1000;
481 if (++timeout > TIMEOUT) { 478 if (++timeout > TIMEOUT) {
482 ast_moutdwm(ast, 0x1e6e0070, 0x0); 479 ast_moutdwm(ast, 0x1e6e0070, 0x0);
483 return -1; 480 return 0xffffffff;
484 } 481 }
485 } while (!data); 482 } while (!data);
486 data = ast_mindwm(ast, 0x1e6e0078); 483 data = ast_mindwm(ast, 0x1e6e0078);
487 data = (data | (data >> 16)) & 0xffff; 484 data = (data | (data >> 16)) & 0xffff;
488 ast_moutdwm(ast, 0x1e6e0070, 0x0); 485 ast_moutdwm(ast, 0x1e6e0070, 0x00000000);
489 return data; 486 return data;
490} 487}
491 488
492static int mmc_test_single(struct ast_private *ast, u32 datagen) 489
490static bool mmc_test_burst(struct ast_private *ast, u32 datagen)
493{ 491{
494 u32 data, timeout; 492 return mmc_test(ast, datagen, 0xc1);
493}
495 494
496 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 495static u32 mmc_test_burst2(struct ast_private *ast, u32 datagen)
497 ast_moutdwm(ast, 0x1e6e0070, 0x000000c5 | (datagen << 3)); 496{
498 timeout = 0; 497 return mmc_test2(ast, datagen, 0x41);
499 do {
500 data = ast_mindwm(ast, 0x1e6e0070) & 0x3000;
501 if (data & 0x2000)
502 return 0;
503 if (++timeout > TIMEOUT) {
504 ast_moutdwm(ast, 0x1e6e0070, 0x0);
505 return 0;
506 }
507 } while (!data);
508 ast_moutdwm(ast, 0x1e6e0070, 0x0);
509 return 1;
510} 498}
511 499
512static int mmc_test_single2(struct ast_private *ast, u32 datagen) 500static bool mmc_test_single(struct ast_private *ast, u32 datagen)
513{ 501{
514 u32 data, timeout; 502 return mmc_test(ast, datagen, 0xc5);
503}
515 504
516 ast_moutdwm(ast, 0x1e6e0070, 0x00000000); 505static u32 mmc_test_single2(struct ast_private *ast, u32 datagen)
517 ast_moutdwm(ast, 0x1e6e0070, 0x00000005 | (datagen << 3)); 506{
518 timeout = 0; 507 return mmc_test2(ast, datagen, 0x05);
519 do { 508}
520 data = ast_mindwm(ast, 0x1e6e0070) & 0x1000; 509
521 if (++timeout > TIMEOUT) { 510static bool mmc_test_single_2500(struct ast_private *ast, u32 datagen)
522 ast_moutdwm(ast, 0x1e6e0070, 0x0); 511{
523 return -1; 512 return mmc_test(ast, datagen, 0x85);
524 }
525 } while (!data);
526 data = ast_mindwm(ast, 0x1e6e0078);
527 data = (data | (data >> 16)) & 0xffff;
528 ast_moutdwm(ast, 0x1e6e0070, 0x0);
529 return data;
530} 513}
531 514
532static int cbr_test(struct ast_private *ast) 515static int cbr_test(struct ast_private *ast)
@@ -604,16 +587,16 @@ static u32 cbr_scan2(struct ast_private *ast)
604 return data2; 587 return data2;
605} 588}
606 589
607static u32 cbr_test3(struct ast_private *ast) 590static bool cbr_test3(struct ast_private *ast)
608{ 591{
609 if (!mmc_test_burst(ast, 0)) 592 if (!mmc_test_burst(ast, 0))
610 return 0; 593 return false;
611 if (!mmc_test_single(ast, 0)) 594 if (!mmc_test_single(ast, 0))
612 return 0; 595 return false;
613 return 1; 596 return true;
614} 597}
615 598
616static u32 cbr_scan3(struct ast_private *ast) 599static bool cbr_scan3(struct ast_private *ast)
617{ 600{
618 u32 patcnt, loop; 601 u32 patcnt, loop;
619 602
@@ -624,9 +607,9 @@ static u32 cbr_scan3(struct ast_private *ast)
624 break; 607 break;
625 } 608 }
626 if (loop == 2) 609 if (loop == 2)
627 return 0; 610 return false;
628 } 611 }
629 return 1; 612 return true;
630} 613}
631 614
632static bool finetuneDQI_L(struct ast_private *ast, struct ast2300_dram_param *param) 615static bool finetuneDQI_L(struct ast_private *ast, struct ast2300_dram_param *param)
@@ -1612,7 +1595,7 @@ ddr2_init_start:
1612 1595
1613} 1596}
1614 1597
1615static void ast_init_dram_2300(struct drm_device *dev) 1598static void ast_post_chip_2300(struct drm_device *dev)
1616{ 1599{
1617 struct ast_private *ast = dev->dev_private; 1600 struct ast_private *ast = dev->dev_private;
1618 struct ast2300_dram_param param; 1601 struct ast2300_dram_param param;
@@ -1638,12 +1621,44 @@ static void ast_init_dram_2300(struct drm_device *dev)
1638 temp |= 0x73; 1621 temp |= 0x73;
1639 ast_write32(ast, 0x12008, temp); 1622 ast_write32(ast, 0x12008, temp);
1640 1623
1624 param.dram_freq = 396;
1641 param.dram_type = AST_DDR3; 1625 param.dram_type = AST_DDR3;
1626 temp = ast_mindwm(ast, 0x1e6e2070);
1642 if (temp & 0x01000000) 1627 if (temp & 0x01000000)
1643 param.dram_type = AST_DDR2; 1628 param.dram_type = AST_DDR2;
1644 param.dram_chipid = ast->dram_type; 1629 switch (temp & 0x18000000) {
1645 param.dram_freq = ast->mclk; 1630 case 0:
1646 param.vram_size = ast->vram_size; 1631 param.dram_chipid = AST_DRAM_512Mx16;
1632 break;
1633 default:
1634 case 0x08000000:
1635 param.dram_chipid = AST_DRAM_1Gx16;
1636 break;
1637 case 0x10000000:
1638 param.dram_chipid = AST_DRAM_2Gx16;
1639 break;
1640 case 0x18000000:
1641 param.dram_chipid = AST_DRAM_4Gx16;
1642 break;
1643 }
1644 switch (temp & 0x0c) {
1645 default:
1646 case 0x00:
1647 param.vram_size = AST_VIDMEM_SIZE_8M;
1648 break;
1649
1650 case 0x04:
1651 param.vram_size = AST_VIDMEM_SIZE_16M;
1652 break;
1653
1654 case 0x08:
1655 param.vram_size = AST_VIDMEM_SIZE_32M;
1656 break;
1657
1658 case 0x0c:
1659 param.vram_size = AST_VIDMEM_SIZE_64M;
1660 break;
1661 }
1647 1662
1648 if (param.dram_type == AST_DDR3) { 1663 if (param.dram_type == AST_DDR3) {
1649 get_ddr3_info(ast, &param); 1664 get_ddr3_info(ast, &param);
@@ -1663,3 +1678,404 @@ static void ast_init_dram_2300(struct drm_device *dev)
1663 } while ((reg & 0x40) == 0); 1678 } while ((reg & 0x40) == 0);
1664} 1679}
1665 1680
1681static bool cbr_test_2500(struct ast_private *ast)
1682{
1683 ast_moutdwm(ast, 0x1E6E0074, 0x0000FFFF);
1684 ast_moutdwm(ast, 0x1E6E007C, 0xFF00FF00);
1685 if (!mmc_test_burst(ast, 0))
1686 return false;
1687 if (!mmc_test_single_2500(ast, 0))
1688 return false;
1689 return true;
1690}
1691
1692static bool ddr_test_2500(struct ast_private *ast)
1693{
1694 ast_moutdwm(ast, 0x1E6E0074, 0x0000FFFF);
1695 ast_moutdwm(ast, 0x1E6E007C, 0xFF00FF00);
1696 if (!mmc_test_burst(ast, 0))
1697 return false;
1698 if (!mmc_test_burst(ast, 1))
1699 return false;
1700 if (!mmc_test_burst(ast, 2))
1701 return false;
1702 if (!mmc_test_burst(ast, 3))
1703 return false;
1704 if (!mmc_test_single_2500(ast, 0))
1705 return false;
1706 return true;
1707}
1708
1709static void ddr_init_common_2500(struct ast_private *ast)
1710{
1711 ast_moutdwm(ast, 0x1E6E0034, 0x00020080);
1712 ast_moutdwm(ast, 0x1E6E0008, 0x2003000F);
1713 ast_moutdwm(ast, 0x1E6E0038, 0x00000FFF);
1714 ast_moutdwm(ast, 0x1E6E0040, 0x88448844);
1715 ast_moutdwm(ast, 0x1E6E0044, 0x24422288);
1716 ast_moutdwm(ast, 0x1E6E0048, 0x22222222);
1717 ast_moutdwm(ast, 0x1E6E004C, 0x22222222);
1718 ast_moutdwm(ast, 0x1E6E0050, 0x80000000);
1719 ast_moutdwm(ast, 0x1E6E0208, 0x00000000);
1720 ast_moutdwm(ast, 0x1E6E0218, 0x00000000);
1721 ast_moutdwm(ast, 0x1E6E0220, 0x00000000);
1722 ast_moutdwm(ast, 0x1E6E0228, 0x00000000);
1723 ast_moutdwm(ast, 0x1E6E0230, 0x00000000);
1724 ast_moutdwm(ast, 0x1E6E02A8, 0x00000000);
1725 ast_moutdwm(ast, 0x1E6E02B0, 0x00000000);
1726 ast_moutdwm(ast, 0x1E6E0240, 0x86000000);
1727 ast_moutdwm(ast, 0x1E6E0244, 0x00008600);
1728 ast_moutdwm(ast, 0x1E6E0248, 0x80000000);
1729 ast_moutdwm(ast, 0x1E6E024C, 0x80808080);
1730}
1731
1732static void ddr_phy_init_2500(struct ast_private *ast)
1733{
1734 u32 data, pass, timecnt;
1735
1736 pass = 0;
1737 ast_moutdwm(ast, 0x1E6E0060, 0x00000005);
1738 while (!pass) {
1739 for (timecnt = 0; timecnt < TIMEOUT; timecnt++) {
1740 data = ast_mindwm(ast, 0x1E6E0060) & 0x1;
1741 if (!data)
1742 break;
1743 }
1744 if (timecnt != TIMEOUT) {
1745 data = ast_mindwm(ast, 0x1E6E0300) & 0x000A0000;
1746 if (!data)
1747 pass = 1;
1748 }
1749 if (!pass) {
1750 ast_moutdwm(ast, 0x1E6E0060, 0x00000000);
1751 udelay(10); /* delay 10 us */
1752 ast_moutdwm(ast, 0x1E6E0060, 0x00000005);
1753 }
1754 }
1755
1756 ast_moutdwm(ast, 0x1E6E0060, 0x00000006);
1757}
1758
1759/*
1760 * Check DRAM Size
1761 * 1Gb : 0x80000000 ~ 0x87FFFFFF
1762 * 2Gb : 0x80000000 ~ 0x8FFFFFFF
1763 * 4Gb : 0x80000000 ~ 0x9FFFFFFF
1764 * 8Gb : 0x80000000 ~ 0xBFFFFFFF
1765 */
1766static void check_dram_size_2500(struct ast_private *ast, u32 tRFC)
1767{
1768 u32 reg_04, reg_14;
1769
1770 reg_04 = ast_mindwm(ast, 0x1E6E0004) & 0xfffffffc;
1771 reg_14 = ast_mindwm(ast, 0x1E6E0014) & 0xffffff00;
1772
1773 ast_moutdwm(ast, 0xA0100000, 0x41424344);
1774 ast_moutdwm(ast, 0x90100000, 0x35363738);
1775 ast_moutdwm(ast, 0x88100000, 0x292A2B2C);
1776 ast_moutdwm(ast, 0x80100000, 0x1D1E1F10);
1777
1778 /* Check 8Gbit */
1779 if (ast_mindwm(ast, 0xA0100000) == 0x41424344) {
1780 reg_04 |= 0x03;
1781 reg_14 |= (tRFC >> 24) & 0xFF;
1782 /* Check 4Gbit */
1783 } else if (ast_mindwm(ast, 0x90100000) == 0x35363738) {
1784 reg_04 |= 0x02;
1785 reg_14 |= (tRFC >> 16) & 0xFF;
1786 /* Check 2Gbit */
1787 } else if (ast_mindwm(ast, 0x88100000) == 0x292A2B2C) {
1788 reg_04 |= 0x01;
1789 reg_14 |= (tRFC >> 8) & 0xFF;
1790 } else {
1791 reg_14 |= tRFC & 0xFF;
1792 }
1793 ast_moutdwm(ast, 0x1E6E0004, reg_04);
1794 ast_moutdwm(ast, 0x1E6E0014, reg_14);
1795}
1796
1797static void enable_cache_2500(struct ast_private *ast)
1798{
1799 u32 reg_04, data;
1800
1801 reg_04 = ast_mindwm(ast, 0x1E6E0004);
1802 ast_moutdwm(ast, 0x1E6E0004, reg_04 | 0x1000);
1803
1804 do
1805 data = ast_mindwm(ast, 0x1E6E0004);
1806 while (!(data & 0x80000));
1807 ast_moutdwm(ast, 0x1E6E0004, reg_04 | 0x400);
1808}
1809
1810static void set_mpll_2500(struct ast_private *ast)
1811{
1812 u32 addr, data, param;
1813
1814 /* Reset MMC */
1815 ast_moutdwm(ast, 0x1E6E0000, 0xFC600309);
1816 ast_moutdwm(ast, 0x1E6E0034, 0x00020080);
1817 for (addr = 0x1e6e0004; addr < 0x1e6e0090;) {
1818 ast_moutdwm(ast, addr, 0x0);
1819 addr += 4;
1820 }
1821 ast_moutdwm(ast, 0x1E6E0034, 0x00020000);
1822
1823 ast_moutdwm(ast, 0x1E6E2000, 0x1688A8A8);
1824 data = ast_mindwm(ast, 0x1E6E2070) & 0x00800000;
1825 if (data) {
1826 /* CLKIN = 25MHz */
1827 param = 0x930023E0;
1828 ast_moutdwm(ast, 0x1E6E2160, 0x00011320);
1829 } else {
1830 /* CLKIN = 24MHz */
1831 param = 0x93002400;
1832 }
1833 ast_moutdwm(ast, 0x1E6E2020, param);
1834 udelay(100);
1835}
1836
1837static void reset_mmc_2500(struct ast_private *ast)
1838{
1839 ast_moutdwm(ast, 0x1E78505C, 0x00000004);
1840 ast_moutdwm(ast, 0x1E785044, 0x00000001);
1841 ast_moutdwm(ast, 0x1E785048, 0x00004755);
1842 ast_moutdwm(ast, 0x1E78504C, 0x00000013);
1843 mdelay(100);
1844 ast_moutdwm(ast, 0x1E785054, 0x00000077);
1845 ast_moutdwm(ast, 0x1E6E0000, 0xFC600309);
1846}
1847
1848static void ddr3_init_2500(struct ast_private *ast, const u32 *ddr_table)
1849{
1850
1851 ast_moutdwm(ast, 0x1E6E0004, 0x00000303);
1852 ast_moutdwm(ast, 0x1E6E0010, ddr_table[REGIDX_010]);
1853 ast_moutdwm(ast, 0x1E6E0014, ddr_table[REGIDX_014]);
1854 ast_moutdwm(ast, 0x1E6E0018, ddr_table[REGIDX_018]);
1855 ast_moutdwm(ast, 0x1E6E0020, ddr_table[REGIDX_020]); /* MODEREG4/6 */
1856 ast_moutdwm(ast, 0x1E6E0024, ddr_table[REGIDX_024]); /* MODEREG5 */
1857 ast_moutdwm(ast, 0x1E6E002C, ddr_table[REGIDX_02C] | 0x100); /* MODEREG0/2 */
1858 ast_moutdwm(ast, 0x1E6E0030, ddr_table[REGIDX_030]); /* MODEREG1/3 */
1859
1860 /* DDR PHY Setting */
1861 ast_moutdwm(ast, 0x1E6E0200, 0x02492AAE);
1862 ast_moutdwm(ast, 0x1E6E0204, 0x00001001);
1863 ast_moutdwm(ast, 0x1E6E020C, 0x55E00B0B);
1864 ast_moutdwm(ast, 0x1E6E0210, 0x20000000);
1865 ast_moutdwm(ast, 0x1E6E0214, ddr_table[REGIDX_214]);
1866 ast_moutdwm(ast, 0x1E6E02E0, ddr_table[REGIDX_2E0]);
1867 ast_moutdwm(ast, 0x1E6E02E4, ddr_table[REGIDX_2E4]);
1868 ast_moutdwm(ast, 0x1E6E02E8, ddr_table[REGIDX_2E8]);
1869 ast_moutdwm(ast, 0x1E6E02EC, ddr_table[REGIDX_2EC]);
1870 ast_moutdwm(ast, 0x1E6E02F0, ddr_table[REGIDX_2F0]);
1871 ast_moutdwm(ast, 0x1E6E02F4, ddr_table[REGIDX_2F4]);
1872 ast_moutdwm(ast, 0x1E6E02F8, ddr_table[REGIDX_2F8]);
1873 ast_moutdwm(ast, 0x1E6E0290, 0x00100008);
1874 ast_moutdwm(ast, 0x1E6E02C0, 0x00000006);
1875
1876 /* Controller Setting */
1877 ast_moutdwm(ast, 0x1E6E0034, 0x00020091);
1878
1879 /* Wait DDR PHY init done */
1880 ddr_phy_init_2500(ast);
1881
1882 ast_moutdwm(ast, 0x1E6E0120, ddr_table[REGIDX_PLL]);
1883 ast_moutdwm(ast, 0x1E6E000C, 0x42AA5C81);
1884 ast_moutdwm(ast, 0x1E6E0034, 0x0001AF93);
1885
1886 check_dram_size_2500(ast, ddr_table[REGIDX_RFC]);
1887 enable_cache_2500(ast);
1888 ast_moutdwm(ast, 0x1E6E001C, 0x00000008);
1889 ast_moutdwm(ast, 0x1E6E0038, 0xFFFFFF00);
1890}
1891
1892static void ddr4_init_2500(struct ast_private *ast, const u32 *ddr_table)
1893{
1894 u32 data, data2, pass, retrycnt;
1895 u32 ddr_vref, phy_vref;
1896 u32 min_ddr_vref = 0, min_phy_vref = 0;
1897 u32 max_ddr_vref = 0, max_phy_vref = 0;
1898
1899 ast_moutdwm(ast, 0x1E6E0004, 0x00000313);
1900 ast_moutdwm(ast, 0x1E6E0010, ddr_table[REGIDX_010]);
1901 ast_moutdwm(ast, 0x1E6E0014, ddr_table[REGIDX_014]);
1902 ast_moutdwm(ast, 0x1E6E0018, ddr_table[REGIDX_018]);
1903 ast_moutdwm(ast, 0x1E6E0020, ddr_table[REGIDX_020]); /* MODEREG4/6 */
1904 ast_moutdwm(ast, 0x1E6E0024, ddr_table[REGIDX_024]); /* MODEREG5 */
1905 ast_moutdwm(ast, 0x1E6E002C, ddr_table[REGIDX_02C] | 0x100); /* MODEREG0/2 */
1906 ast_moutdwm(ast, 0x1E6E0030, ddr_table[REGIDX_030]); /* MODEREG1/3 */
1907
1908 /* DDR PHY Setting */
1909 ast_moutdwm(ast, 0x1E6E0200, 0x42492AAE);
1910 ast_moutdwm(ast, 0x1E6E0204, 0x09002000);
1911 ast_moutdwm(ast, 0x1E6E020C, 0x55E00B0B);
1912 ast_moutdwm(ast, 0x1E6E0210, 0x20000000);
1913 ast_moutdwm(ast, 0x1E6E0214, ddr_table[REGIDX_214]);
1914 ast_moutdwm(ast, 0x1E6E02E0, ddr_table[REGIDX_2E0]);
1915 ast_moutdwm(ast, 0x1E6E02E4, ddr_table[REGIDX_2E4]);
1916 ast_moutdwm(ast, 0x1E6E02E8, ddr_table[REGIDX_2E8]);
1917 ast_moutdwm(ast, 0x1E6E02EC, ddr_table[REGIDX_2EC]);
1918 ast_moutdwm(ast, 0x1E6E02F0, ddr_table[REGIDX_2F0]);
1919 ast_moutdwm(ast, 0x1E6E02F4, ddr_table[REGIDX_2F4]);
1920 ast_moutdwm(ast, 0x1E6E02F8, ddr_table[REGIDX_2F8]);
1921 ast_moutdwm(ast, 0x1E6E0290, 0x00100008);
1922 ast_moutdwm(ast, 0x1E6E02C4, 0x3C183C3C);
1923 ast_moutdwm(ast, 0x1E6E02C8, 0x00631E0E);
1924
1925 /* Controller Setting */
1926 ast_moutdwm(ast, 0x1E6E0034, 0x0001A991);
1927
1928 /* Train PHY Vref first */
1929 pass = 0;
1930
1931 for (retrycnt = 0; retrycnt < 4 && pass == 0; retrycnt++) {
1932 max_phy_vref = 0x0;
1933 pass = 0;
1934 ast_moutdwm(ast, 0x1E6E02C0, 0x00001C06);
1935 for (phy_vref = 0x40; phy_vref < 0x80; phy_vref++) {
1936 ast_moutdwm(ast, 0x1E6E000C, 0x00000000);
1937 ast_moutdwm(ast, 0x1E6E0060, 0x00000000);
1938 ast_moutdwm(ast, 0x1E6E02CC, phy_vref | (phy_vref << 8));
1939 /* Fire DFI Init */
1940 ddr_phy_init_2500(ast);
1941 ast_moutdwm(ast, 0x1E6E000C, 0x00005C01);
1942 if (cbr_test_2500(ast)) {
1943 pass++;
1944 data = ast_mindwm(ast, 0x1E6E03D0);
1945 data2 = data >> 8;
1946 data = data & 0xff;
1947 if (data > data2)
1948 data = data2;
1949 if (max_phy_vref < data) {
1950 max_phy_vref = data;
1951 min_phy_vref = phy_vref;
1952 }
1953 } else if (pass > 0)
1954 break;
1955 }
1956 }
1957 ast_moutdwm(ast, 0x1E6E02CC, min_phy_vref | (min_phy_vref << 8));
1958
1959 /* Train DDR Vref next */
1960 pass = 0;
1961
1962 for (retrycnt = 0; retrycnt < 4 && pass == 0; retrycnt++) {
1963 min_ddr_vref = 0xFF;
1964 max_ddr_vref = 0x0;
1965 pass = 0;
1966 for (ddr_vref = 0x00; ddr_vref < 0x40; ddr_vref++) {
1967 ast_moutdwm(ast, 0x1E6E000C, 0x00000000);
1968 ast_moutdwm(ast, 0x1E6E0060, 0x00000000);
1969 ast_moutdwm(ast, 0x1E6E02C0, 0x00000006 | (ddr_vref << 8));
1970 /* Fire DFI Init */
1971 ddr_phy_init_2500(ast);
1972 ast_moutdwm(ast, 0x1E6E000C, 0x00005C01);
1973 if (cbr_test_2500(ast)) {
1974 pass++;
1975 if (min_ddr_vref > ddr_vref)
1976 min_ddr_vref = ddr_vref;
1977 if (max_ddr_vref < ddr_vref)
1978 max_ddr_vref = ddr_vref;
1979 } else if (pass != 0)
1980 break;
1981 }
1982 }
1983
1984 ast_moutdwm(ast, 0x1E6E000C, 0x00000000);
1985 ast_moutdwm(ast, 0x1E6E0060, 0x00000000);
1986 ddr_vref = (min_ddr_vref + max_ddr_vref + 1) >> 1;
1987 ast_moutdwm(ast, 0x1E6E02C0, 0x00000006 | (ddr_vref << 8));
1988
1989 /* Wait DDR PHY init done */
1990 ddr_phy_init_2500(ast);
1991
1992 ast_moutdwm(ast, 0x1E6E0120, ddr_table[REGIDX_PLL]);
1993 ast_moutdwm(ast, 0x1E6E000C, 0x42AA5C81);
1994 ast_moutdwm(ast, 0x1E6E0034, 0x0001AF93);
1995
1996 check_dram_size_2500(ast, ddr_table[REGIDX_RFC]);
1997 enable_cache_2500(ast);
1998 ast_moutdwm(ast, 0x1E6E001C, 0x00000008);
1999 ast_moutdwm(ast, 0x1E6E0038, 0xFFFFFF00);
2000}
2001
2002static bool ast_dram_init_2500(struct ast_private *ast)
2003{
2004 u32 data;
2005 u32 max_tries = 5;
2006
2007 do {
2008 if (max_tries-- == 0)
2009 return false;
2010 set_mpll_2500(ast);
2011 reset_mmc_2500(ast);
2012 ddr_init_common_2500(ast);
2013
2014 data = ast_mindwm(ast, 0x1E6E2070);
2015 if (data & 0x01000000)
2016 ddr4_init_2500(ast, ast2500_ddr4_1600_timing_table);
2017 else
2018 ddr3_init_2500(ast, ast2500_ddr3_1600_timing_table);
2019 } while (!ddr_test_2500(ast));
2020
2021 ast_moutdwm(ast, 0x1E6E2040, ast_mindwm(ast, 0x1E6E2040) | 0x41);
2022
2023 /* Patch code */
2024 data = ast_mindwm(ast, 0x1E6E200C) & 0xF9FFFFFF;
2025 ast_moutdwm(ast, 0x1E6E200C, data | 0x10000000);
2026
2027 return true;
2028}
2029
2030void ast_post_chip_2500(struct drm_device *dev)
2031{
2032 struct ast_private *ast = dev->dev_private;
2033 u32 temp;
2034 u8 reg;
2035
2036 reg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
2037 if ((reg & 0x80) == 0) {/* vga only */
2038 /* Clear bus lock condition */
2039 ast_moutdwm(ast, 0x1e600000, 0xAEED1A03);
2040 ast_moutdwm(ast, 0x1e600084, 0x00010000);
2041 ast_moutdwm(ast, 0x1e600088, 0x00000000);
2042 ast_moutdwm(ast, 0x1e6e2000, 0x1688A8A8);
2043 ast_write32(ast, 0xf004, 0x1e6e0000);
2044 ast_write32(ast, 0xf000, 0x1);
2045 ast_write32(ast, 0x12000, 0x1688a8a8);
2046 while (ast_read32(ast, 0x12000) != 0x1)
2047 ;
2048
2049 ast_write32(ast, 0x10000, 0xfc600309);
2050 while (ast_read32(ast, 0x10000) != 0x1)
2051 ;
2052
2053 /* Slow down CPU/AHB CLK in VGA only mode */
2054 temp = ast_read32(ast, 0x12008);
2055 temp |= 0x73;
2056 ast_write32(ast, 0x12008, temp);
2057
2058 /* Reset USB port to patch USB unknown device issue */
2059 ast_moutdwm(ast, 0x1e6e2090, 0x20000000);
2060 temp = ast_mindwm(ast, 0x1e6e2094);
2061 temp |= 0x00004000;
2062 ast_moutdwm(ast, 0x1e6e2094, temp);
2063 temp = ast_mindwm(ast, 0x1e6e2070);
2064 if (temp & 0x00800000) {
2065 ast_moutdwm(ast, 0x1e6e207c, 0x00800000);
2066 mdelay(100);
2067 ast_moutdwm(ast, 0x1e6e2070, 0x00800000);
2068 }
2069
2070 if (!ast_dram_init_2500(ast))
2071 DRM_ERROR("DRAM init failed !\n");
2072
2073 temp = ast_mindwm(ast, 0x1e6e2040);
2074 ast_moutdwm(ast, 0x1e6e2040, temp | 0x40);
2075 }
2076
2077 /* wait ready */
2078 do {
2079 reg = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xd0, 0xff);
2080 } while ((reg & 0x40) == 0);
2081}
diff --git a/drivers/gpu/drm/ast/ast_tables.h b/drivers/gpu/drm/ast/ast_tables.h
index 3608d5aa7451..5f4c2e833a65 100644
--- a/drivers/gpu/drm/ast/ast_tables.h
+++ b/drivers/gpu/drm/ast/ast_tables.h
@@ -47,6 +47,7 @@
47#define SyncPN (PVSync | NHSync) 47#define SyncPN (PVSync | NHSync)
48#define SyncNP (NVSync | PHSync) 48#define SyncNP (NVSync | PHSync)
49#define SyncNN (NVSync | NHSync) 49#define SyncNN (NVSync | NHSync)
50#define AST2500PreCatchCRT 0x00004000
50 51
51/* DCLK Index */ 52/* DCLK Index */
52#define VCLK25_175 0x00 53#define VCLK25_175 0x00
@@ -78,37 +79,67 @@
78#define VCLK97_75 0x19 79#define VCLK97_75 0x19
79#define VCLK118_25 0x1A 80#define VCLK118_25 0x1A
80 81
81static struct ast_vbios_dclk_info dclk_table[] = { 82static const struct ast_vbios_dclk_info dclk_table[] = {
82 {0x2C, 0xE7, 0x03}, /* 00: VCLK25_175 */ 83 {0x2C, 0xE7, 0x03}, /* 00: VCLK25_175 */
83 {0x95, 0x62, 0x03}, /* 01: VCLK28_322 */ 84 {0x95, 0x62, 0x03}, /* 01: VCLK28_322 */
84 {0x67, 0x63, 0x01}, /* 02: VCLK31_5 */ 85 {0x67, 0x63, 0x01}, /* 02: VCLK31_5 */
85 {0x76, 0x63, 0x01}, /* 03: VCLK36 */ 86 {0x76, 0x63, 0x01}, /* 03: VCLK36 */
86 {0xEE, 0x67, 0x01}, /* 04: VCLK40 */ 87 {0xEE, 0x67, 0x01}, /* 04: VCLK40 */
87 {0x82, 0x62, 0x01}, /* 05: VCLK49_5 */ 88 {0x82, 0x62, 0x01}, /* 05: VCLK49_5 */
88 {0xC6, 0x64, 0x01}, /* 06: VCLK50 */ 89 {0xC6, 0x64, 0x01}, /* 06: VCLK50 */
89 {0x94, 0x62, 0x01}, /* 07: VCLK56_25 */ 90 {0x94, 0x62, 0x01}, /* 07: VCLK56_25 */
90 {0x80, 0x64, 0x00}, /* 08: VCLK65 */ 91 {0x80, 0x64, 0x00}, /* 08: VCLK65 */
91 {0x7B, 0x63, 0x00}, /* 09: VCLK75 */ 92 {0x7B, 0x63, 0x00}, /* 09: VCLK75 */
92 {0x67, 0x62, 0x00}, /* 0A: VCLK78_75 */ 93 {0x67, 0x62, 0x00}, /* 0A: VCLK78_75 */
93 {0x7C, 0x62, 0x00}, /* 0B: VCLK94_5 */ 94 {0x7C, 0x62, 0x00}, /* 0B: VCLK94_5 */
94 {0x8E, 0x62, 0x00}, /* 0C: VCLK108 */ 95 {0x8E, 0x62, 0x00}, /* 0C: VCLK108 */
95 {0x85, 0x24, 0x00}, /* 0D: VCLK135 */ 96 {0x85, 0x24, 0x00}, /* 0D: VCLK135 */
96 {0x67, 0x22, 0x00}, /* 0E: VCLK157_5 */ 97 {0x67, 0x22, 0x00}, /* 0E: VCLK157_5 */
97 {0x6A, 0x22, 0x00}, /* 0F: VCLK162 */ 98 {0x6A, 0x22, 0x00}, /* 0F: VCLK162 */
98 {0x4d, 0x4c, 0x80}, /* 10: VCLK154 */ 99 {0x4d, 0x4c, 0x80}, /* 10: VCLK154 */
99 {0xa7, 0x78, 0x80}, /* 11: VCLK83.5 */ 100 {0xa7, 0x78, 0x80}, /* 11: VCLK83.5 */
100 {0x28, 0x49, 0x80}, /* 12: VCLK106.5 */ 101 {0x28, 0x49, 0x80}, /* 12: VCLK106.5 */
101 {0x37, 0x49, 0x80}, /* 13: VCLK146.25 */ 102 {0x37, 0x49, 0x80}, /* 13: VCLK146.25 */
102 {0x1f, 0x45, 0x80}, /* 14: VCLK148.5 */ 103 {0x1f, 0x45, 0x80}, /* 14: VCLK148.5 */
103 {0x47, 0x6c, 0x80}, /* 15: VCLK71 */ 104 {0x47, 0x6c, 0x80}, /* 15: VCLK71 */
104 {0x25, 0x65, 0x80}, /* 16: VCLK88.75 */ 105 {0x25, 0x65, 0x80}, /* 16: VCLK88.75 */
105 {0x77, 0x58, 0x80}, /* 17: VCLK119 */ 106 {0x77, 0x58, 0x80}, /* 17: VCLK119 */
106 {0x32, 0x67, 0x80}, /* 18: VCLK85_5 */ 107 {0x32, 0x67, 0x80}, /* 18: VCLK85_5 */
107 {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */ 108 {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */
108 {0x3b, 0x2c, 0x81}, /* 1A: VCLK118_25 */ 109 {0x3b, 0x2c, 0x81}, /* 1A: VCLK118_25 */
109}; 110};
110 111
111static struct ast_vbios_stdtable vbios_stdtable[] = { 112static const struct ast_vbios_dclk_info dclk_table_ast2500[] = {
113 {0x2C, 0xE7, 0x03}, /* 00: VCLK25_175 */
114 {0x95, 0x62, 0x03}, /* 01: VCLK28_322 */
115 {0x67, 0x63, 0x01}, /* 02: VCLK31_5 */
116 {0x76, 0x63, 0x01}, /* 03: VCLK36 */
117 {0xEE, 0x67, 0x01}, /* 04: VCLK40 */
118 {0x82, 0x62, 0x01}, /* 05: VCLK49_5 */
119 {0xC6, 0x64, 0x01}, /* 06: VCLK50 */
120 {0x94, 0x62, 0x01}, /* 07: VCLK56_25 */
121 {0x80, 0x64, 0x00}, /* 08: VCLK65 */
122 {0x7B, 0x63, 0x00}, /* 09: VCLK75 */
123 {0x67, 0x62, 0x00}, /* 0A: VCLK78_75 */
124 {0x7C, 0x62, 0x00}, /* 0B: VCLK94_5 */
125 {0x8E, 0x62, 0x00}, /* 0C: VCLK108 */
126 {0x85, 0x24, 0x00}, /* 0D: VCLK135 */
127 {0x67, 0x22, 0x00}, /* 0E: VCLK157_5 */
128 {0x6A, 0x22, 0x00}, /* 0F: VCLK162 */
129 {0x4d, 0x4c, 0x80}, /* 10: VCLK154 */
130 {0xa7, 0x78, 0x80}, /* 11: VCLK83.5 */
131 {0x28, 0x49, 0x80}, /* 12: VCLK106.5 */
132 {0x37, 0x49, 0x80}, /* 13: VCLK146.25 */
133 {0x1f, 0x45, 0x80}, /* 14: VCLK148.5 */
134 {0x47, 0x6c, 0x80}, /* 15: VCLK71 */
135 {0x25, 0x65, 0x80}, /* 16: VCLK88.75 */
136 {0x58, 0x01, 0x42}, /* 17: VCLK119 */
137 {0x32, 0x67, 0x80}, /* 18: VCLK85_5 */
138 {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */
139 {0x44, 0x20, 0x43}, /* 1A: VCLK118_25 */
140};
141
142static const struct ast_vbios_stdtable vbios_stdtable[] = {
112 /* MD_2_3_400 */ 143 /* MD_2_3_400 */
113 { 144 {
114 0x67, 145 0x67,
@@ -181,21 +212,21 @@ static struct ast_vbios_stdtable vbios_stdtable[] = {
181 }, 212 },
182}; 213};
183 214
184static struct ast_vbios_enhtable res_640x480[] = { 215static const struct ast_vbios_enhtable res_640x480[] = {
185 { 800, 640, 8, 96, 525, 480, 2, 2, VCLK25_175, /* 60Hz */ 216 { 800, 640, 8, 96, 525, 480, 2, 2, VCLK25_175, /* 60Hz */
186 (SyncNN | HBorder | VBorder | Charx8Dot), 60, 1, 0x2E }, 217 (SyncNN | HBorder | VBorder | Charx8Dot), 60, 1, 0x2E },
187 { 832, 640, 16, 40, 520, 480, 1, 3, VCLK31_5, /* 72Hz */ 218 { 832, 640, 16, 40, 520, 480, 1, 3, VCLK31_5, /* 72Hz */
188 (SyncNN | HBorder | VBorder | Charx8Dot), 72, 2, 0x2E }, 219 (SyncNN | HBorder | VBorder | Charx8Dot), 72, 2, 0x2E },
189 { 840, 640, 16, 64, 500, 480, 1, 3, VCLK31_5, /* 75Hz */ 220 { 840, 640, 16, 64, 500, 480, 1, 3, VCLK31_5, /* 75Hz */
190 (SyncNN | Charx8Dot) , 75, 3, 0x2E }, 221 (SyncNN | Charx8Dot) , 75, 3, 0x2E },
191 { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36, /* 85Hz */ 222 { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36, /* 85Hz */
192 (SyncNN | Charx8Dot) , 85, 4, 0x2E }, 223 (SyncNN | Charx8Dot) , 85, 4, 0x2E },
193 { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36, /* end */ 224 { 832, 640, 56, 56, 509, 480, 1, 3, VCLK36, /* end */
194 (SyncNN | Charx8Dot) , 0xFF, 4, 0x2E }, 225 (SyncNN | Charx8Dot) , 0xFF, 4, 0x2E },
195}; 226};
196 227
197static struct ast_vbios_enhtable res_800x600[] = { 228static const struct ast_vbios_enhtable res_800x600[] = {
198 {1024, 800, 24, 72, 625, 600, 1, 2, VCLK36, /* 56Hz */ 229 {1024, 800, 24, 72, 625, 600, 1, 2, VCLK36, /* 56Hz */
199 (SyncPP | Charx8Dot), 56, 1, 0x30 }, 230 (SyncPP | Charx8Dot), 56, 1, 0x30 },
200 {1056, 800, 40, 128, 628, 600, 1, 4, VCLK40, /* 60Hz */ 231 {1056, 800, 40, 128, 628, 600, 1, 4, VCLK40, /* 60Hz */
201 (SyncPP | Charx8Dot), 60, 2, 0x30 }, 232 (SyncPP | Charx8Dot), 60, 2, 0x30 },
@@ -210,7 +241,7 @@ static struct ast_vbios_enhtable res_800x600[] = {
210}; 241};
211 242
212 243
213static struct ast_vbios_enhtable res_1024x768[] = { 244static const struct ast_vbios_enhtable res_1024x768[] = {
214 {1344, 1024, 24, 136, 806, 768, 3, 6, VCLK65, /* 60Hz */ 245 {1344, 1024, 24, 136, 806, 768, 3, 6, VCLK65, /* 60Hz */
215 (SyncNN | Charx8Dot), 60, 1, 0x31 }, 246 (SyncNN | Charx8Dot), 60, 1, 0x31 },
216 {1328, 1024, 24, 136, 806, 768, 3, 6, VCLK75, /* 70Hz */ 247 {1328, 1024, 24, 136, 806, 768, 3, 6, VCLK75, /* 70Hz */
@@ -223,7 +254,7 @@ static struct ast_vbios_enhtable res_1024x768[] = {
223 (SyncPP | Charx8Dot), 0xFF, 4, 0x31 }, 254 (SyncPP | Charx8Dot), 0xFF, 4, 0x31 },
224}; 255};
225 256
226static struct ast_vbios_enhtable res_1280x1024[] = { 257static const struct ast_vbios_enhtable res_1280x1024[] = {
227 {1688, 1280, 48, 112, 1066, 1024, 1, 3, VCLK108, /* 60Hz */ 258 {1688, 1280, 48, 112, 1066, 1024, 1, 3, VCLK108, /* 60Hz */
228 (SyncPP | Charx8Dot), 60, 1, 0x32 }, 259 (SyncPP | Charx8Dot), 60, 1, 0x32 },
229 {1688, 1280, 16, 144, 1066, 1024, 1, 3, VCLK135, /* 75Hz */ 260 {1688, 1280, 16, 144, 1066, 1024, 1, 3, VCLK135, /* 75Hz */
@@ -234,7 +265,7 @@ static struct ast_vbios_enhtable res_1280x1024[] = {
234 (SyncPP | Charx8Dot), 0xFF, 3, 0x32 }, 265 (SyncPP | Charx8Dot), 0xFF, 3, 0x32 },
235}; 266};
236 267
237static struct ast_vbios_enhtable res_1600x1200[] = { 268static const struct ast_vbios_enhtable res_1600x1200[] = {
238 {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162, /* 60Hz */ 269 {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162, /* 60Hz */
239 (SyncPP | Charx8Dot), 60, 1, 0x33 }, 270 (SyncPP | Charx8Dot), 60, 1, 0x33 },
240 {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162, /* end */ 271 {2160, 1600, 64, 192, 1250, 1200, 1, 3, VCLK162, /* end */
@@ -242,34 +273,39 @@ static struct ast_vbios_enhtable res_1600x1200[] = {
242}; 273};
243 274
244/* 16:9 */ 275/* 16:9 */
245static struct ast_vbios_enhtable res_1360x768[] = { 276static const struct ast_vbios_enhtable res_1360x768[] = {
246 {1792, 1360, 64,112, 795, 768, 3, 6, VCLK85_5, /* 60Hz */ 277 {1792, 1360, 64, 112, 795, 768, 3, 6, VCLK85_5, /* 60Hz */
247 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x39 }, 278 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x39 },
248 {1792, 1360, 64,112, 795, 768, 3, 6, VCLK85_5, /* end */ 279 {1792, 1360, 64, 112, 795, 768, 3, 6, VCLK85_5, /* end */
249 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x39 }, 280 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
281 AST2500PreCatchCRT), 0xFF, 1, 0x39 },
250}; 282};
251 283
252static struct ast_vbios_enhtable res_1600x900[] = { 284static const struct ast_vbios_enhtable res_1600x900[] = {
253 {1760, 1600, 48, 32, 926, 900, 3, 5, VCLK97_75, /* 60Hz CVT RB */ 285 {1760, 1600, 48, 32, 926, 900, 3, 5, VCLK97_75, /* 60Hz CVT RB */
254 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x3A }, 286 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
255 {2112, 1600, 88,168, 934, 900, 3, 5, VCLK118_25, /* 60Hz CVT */ 287 AST2500PreCatchCRT), 60, 1, 0x3A },
288 {2112, 1600, 88, 168, 934, 900, 3, 5, VCLK118_25, /* 60Hz CVT */
256 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x3A }, 289 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x3A },
257 {2112, 1600, 88,168, 934, 900, 3, 5, VCLK118_25, /* 60Hz CVT */ 290 {2112, 1600, 88, 168, 934, 900, 3, 5, VCLK118_25, /* 60Hz CVT */
258 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x3A }, 291 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x3A },
259}; 292};
260 293
261static struct ast_vbios_enhtable res_1920x1080[] = { 294static const struct ast_vbios_enhtable res_1920x1080[] = {
262 {2200, 1920, 88, 44, 1125, 1080, 4, 5, VCLK148_5, /* 60Hz */ 295 {2200, 1920, 88, 44, 1125, 1080, 4, 5, VCLK148_5, /* 60Hz */
263 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x38 }, 296 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
297 AST2500PreCatchCRT), 60, 1, 0x38 },
264 {2200, 1920, 88, 44, 1125, 1080, 4, 5, VCLK148_5, /* 60Hz */ 298 {2200, 1920, 88, 44, 1125, 1080, 4, 5, VCLK148_5, /* 60Hz */
265 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x38 }, 299 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
300 AST2500PreCatchCRT), 0xFF, 1, 0x38 },
266}; 301};
267 302
268 303
269/* 16:10 */ 304/* 16:10 */
270static struct ast_vbios_enhtable res_1280x800[] = { 305static const struct ast_vbios_enhtable res_1280x800[] = {
271 {1440, 1280, 48, 32, 823, 800, 3, 6, VCLK71, /* 60Hz RB */ 306 {1440, 1280, 48, 32, 823, 800, 3, 6, VCLK71, /* 60Hz RB */
272 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x35 }, 307 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
308 AST2500PreCatchCRT), 60, 1, 0x35 },
273 {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */ 309 {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */
274 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x35 }, 310 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x35 },
275 {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */ 311 {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */
@@ -277,29 +313,33 @@ static struct ast_vbios_enhtable res_1280x800[] = {
277 313
278}; 314};
279 315
280static struct ast_vbios_enhtable res_1440x900[] = { 316static const struct ast_vbios_enhtable res_1440x900[] = {
281 {1600, 1440, 48, 32, 926, 900, 3, 6, VCLK88_75, /* 60Hz RB */ 317 {1600, 1440, 48, 32, 926, 900, 3, 6, VCLK88_75, /* 60Hz RB */
282 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x36 }, 318 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
319 AST2500PreCatchCRT), 60, 1, 0x36 },
283 {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */ 320 {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */
284 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x36 }, 321 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x36 },
285 {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */ 322 {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */
286 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x36 }, 323 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x36 },
287}; 324};
288 325
289static struct ast_vbios_enhtable res_1680x1050[] = { 326static const struct ast_vbios_enhtable res_1680x1050[] = {
290 {1840, 1680, 48, 32, 1080, 1050, 3, 6, VCLK119, /* 60Hz RB */ 327 {1840, 1680, 48, 32, 1080, 1050, 3, 6, VCLK119, /* 60Hz RB */
291 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x37 }, 328 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
329 AST2500PreCatchCRT), 60, 1, 0x37 },
292 {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ 330 {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */
293 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x37 }, 331 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x37 },
294 {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ 332 {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */
295 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x37 }, 333 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x37 },
296}; 334};
297 335
298static struct ast_vbios_enhtable res_1920x1200[] = { 336static const struct ast_vbios_enhtable res_1920x1200[] = {
299 {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz RB*/ 337 {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz RB*/
300 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x34 }, 338 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
301 {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz RB */ 339 AST2500PreCatchCRT), 60, 1, 0x34 },
302 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x34 }, 340 {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz RB */
341 (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
342 AST2500PreCatchCRT), 0xFF, 1, 0x34 },
303}; 343};
304 344
305#endif 345#endif
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index ad31b3eb408f..0e4eb845cbb0 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -24,6 +24,7 @@ config ROCKCHIP_ANALOGIX_DP
24config ROCKCHIP_CDN_DP 24config ROCKCHIP_CDN_DP
25 tristate "Rockchip cdn DP" 25 tristate "Rockchip cdn DP"
26 depends on DRM_ROCKCHIP 26 depends on DRM_ROCKCHIP
27 depends on EXTCON
27 select SND_SOC_HDMI_CODEC if SND_SOC 28 select SND_SOC_HDMI_CODEC if SND_SOC
28 help 29 help
29 This selects support for Rockchip SoC specific extensions 30 This selects support for Rockchip SoC specific extensions
diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c
index 9ab67a670885..fd79a70b8552 100644
--- a/drivers/gpu/drm/rockchip/cdn-dp-core.c
+++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c
@@ -111,7 +111,7 @@ static int cdn_dp_clk_enable(struct cdn_dp_device *dp)
111 ret = pm_runtime_get_sync(dp->dev); 111 ret = pm_runtime_get_sync(dp->dev);
112 if (ret < 0) { 112 if (ret < 0) {
113 DRM_DEV_ERROR(dp->dev, "cannot get pm runtime %d\n", ret); 113 DRM_DEV_ERROR(dp->dev, "cannot get pm runtime %d\n", ret);
114 goto err_pclk; 114 goto err_pm_runtime_get;
115 } 115 }
116 116
117 reset_control_assert(dp->core_rst); 117 reset_control_assert(dp->core_rst);
@@ -133,6 +133,8 @@ static int cdn_dp_clk_enable(struct cdn_dp_device *dp)
133 return 0; 133 return 0;
134 134
135err_set_rate: 135err_set_rate:
136 pm_runtime_put(dp->dev);
137err_pm_runtime_get:
136 clk_disable_unprepare(dp->core_clk); 138 clk_disable_unprepare(dp->core_clk);
137err_core_clk: 139err_core_clk:
138 clk_disable_unprepare(dp->pclk); 140 clk_disable_unprepare(dp->pclk);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 541a5887dd6c..d08f26973d0b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -199,9 +199,14 @@ static const struct drm_ioctl_desc vmw_ioctls[] = {
199 VMW_IOCTL_DEF(VMW_PRESENT_READBACK, 199 VMW_IOCTL_DEF(VMW_PRESENT_READBACK,
200 vmw_present_readback_ioctl, 200 vmw_present_readback_ioctl,
201 DRM_MASTER | DRM_AUTH), 201 DRM_MASTER | DRM_AUTH),
202 /*
203 * The permissions of the below ioctl are overridden in
204 * vmw_generic_ioctl(). We require either
205 * DRM_MASTER or capable(CAP_SYS_ADMIN).
206 */
202 VMW_IOCTL_DEF(VMW_UPDATE_LAYOUT, 207 VMW_IOCTL_DEF(VMW_UPDATE_LAYOUT,
203 vmw_kms_update_layout_ioctl, 208 vmw_kms_update_layout_ioctl,
204 DRM_MASTER | DRM_CONTROL_ALLOW), 209 DRM_RENDER_ALLOW),
205 VMW_IOCTL_DEF(VMW_CREATE_SHADER, 210 VMW_IOCTL_DEF(VMW_CREATE_SHADER,
206 vmw_shader_define_ioctl, 211 vmw_shader_define_ioctl,
207 DRM_AUTH | DRM_RENDER_ALLOW), 212 DRM_AUTH | DRM_RENDER_ALLOW),
@@ -1123,6 +1128,10 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd,
1123 1128
1124 return (long) vmw_execbuf_ioctl(dev, arg, file_priv, 1129 return (long) vmw_execbuf_ioctl(dev, arg, file_priv,
1125 _IOC_SIZE(cmd)); 1130 _IOC_SIZE(cmd));
1131 } else if (nr == DRM_COMMAND_BASE + DRM_VMW_UPDATE_LAYOUT) {
1132 if (!drm_is_current_master(file_priv) &&
1133 !capable(CAP_SYS_ADMIN))
1134 return -EACCES;
1126 } 1135 }
1127 1136
1128 if (unlikely(ioctl->cmd != cmd)) 1137 if (unlikely(ioctl->cmd != cmd))
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 1e59a486bba8..59ff4197173a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -41,9 +41,9 @@
41#include <drm/ttm/ttm_module.h> 41#include <drm/ttm/ttm_module.h>
42#include "vmwgfx_fence.h" 42#include "vmwgfx_fence.h"
43 43
44#define VMWGFX_DRIVER_DATE "20160210" 44#define VMWGFX_DRIVER_DATE "20170221"
45#define VMWGFX_DRIVER_MAJOR 2 45#define VMWGFX_DRIVER_MAJOR 2
46#define VMWGFX_DRIVER_MINOR 11 46#define VMWGFX_DRIVER_MINOR 12
47#define VMWGFX_DRIVER_PATCHLEVEL 0 47#define VMWGFX_DRIVER_PATCHLEVEL 0
48#define VMWGFX_FILE_PAGE_OFFSET 0x00100000 48#define VMWGFX_FILE_PAGE_OFFSET 0x00100000
49#define VMWGFX_FIFO_STATIC_SIZE (1024*1024) 49#define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index 1d08ba381098..d646ac931663 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -159,7 +159,7 @@ static void zx_vl_rsz_setup(struct zx_plane *zplane, uint32_t format,
159 void __iomem *rsz = zplane->rsz; 159 void __iomem *rsz = zplane->rsz;
160 u32 src_chroma_w = src_w; 160 u32 src_chroma_w = src_w;
161 u32 src_chroma_h = src_h; 161 u32 src_chroma_h = src_h;
162 u32 fmt; 162 int fmt;
163 163
164 /* Set up source and destination resolution */ 164 /* Set up source and destination resolution */
165 zx_writel(rsz + RSZ_SRC_CFG, RSZ_VER(src_h - 1) | RSZ_HOR(src_w - 1)); 165 zx_writel(rsz + RSZ_SRC_CFG, RSZ_VER(src_h - 1) | RSZ_HOR(src_w - 1));
@@ -203,7 +203,7 @@ static void zx_vl_plane_atomic_update(struct drm_plane *plane,
203 u32 src_x, src_y, src_w, src_h; 203 u32 src_x, src_y, src_w, src_h;
204 u32 dst_x, dst_y, dst_w, dst_h; 204 u32 dst_x, dst_y, dst_w, dst_h;
205 uint32_t format; 205 uint32_t format;
206 u32 fmt; 206 int fmt;
207 int num_planes; 207 int num_planes;
208 int i; 208 int i;
209 209
diff --git a/drivers/input/rmi4/rmi_f30.c b/drivers/input/rmi4/rmi_f30.c
index 3422464af229..198678613382 100644
--- a/drivers/input/rmi4/rmi_f30.c
+++ b/drivers/input/rmi4/rmi_f30.c
@@ -258,9 +258,10 @@ static int rmi_f30_map_gpios(struct rmi_function *fn,
258 258
259 /* 259 /*
260 * Buttonpad could be also inferred from f30->has_mech_mouse_btns, 260 * Buttonpad could be also inferred from f30->has_mech_mouse_btns,
261 * but I am not sure, so use only the pdata info. 261 * but I am not sure, so use only the pdata info and the number of
262 * mapped buttons.
262 */ 263 */
263 if (pdata->f30_data.buttonpad) 264 if (pdata->f30_data.buttonpad || (button - BTN_LEFT == 1))
264 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 265 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
265 266
266 return 0; 267 return 0;
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index a9145aa7f36a..8d456dc6c5bf 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -29,7 +29,6 @@ struct led_pwm_data {
29 unsigned int active_low; 29 unsigned int active_low;
30 unsigned int period; 30 unsigned int period;
31 int duty; 31 int duty;
32 bool can_sleep;
33}; 32};
34 33
35struct led_pwm_priv { 34struct led_pwm_priv {
@@ -49,8 +48,8 @@ static void __led_pwm_set(struct led_pwm_data *led_dat)
49 pwm_enable(led_dat->pwm); 48 pwm_enable(led_dat->pwm);
50} 49}
51 50
52static void led_pwm_set(struct led_classdev *led_cdev, 51static int led_pwm_set(struct led_classdev *led_cdev,
53 enum led_brightness brightness) 52 enum led_brightness brightness)
54{ 53{
55 struct led_pwm_data *led_dat = 54 struct led_pwm_data *led_dat =
56 container_of(led_cdev, struct led_pwm_data, cdev); 55 container_of(led_cdev, struct led_pwm_data, cdev);
@@ -66,12 +65,7 @@ static void led_pwm_set(struct led_classdev *led_cdev,
66 led_dat->duty = duty; 65 led_dat->duty = duty;
67 66
68 __led_pwm_set(led_dat); 67 __led_pwm_set(led_dat);
69}
70 68
71static int led_pwm_set_blocking(struct led_classdev *led_cdev,
72 enum led_brightness brightness)
73{
74 led_pwm_set(led_cdev, brightness);
75 return 0; 69 return 0;
76} 70}
77 71
@@ -112,11 +106,7 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv,
112 return ret; 106 return ret;
113 } 107 }
114 108
115 led_data->can_sleep = pwm_can_sleep(led_data->pwm); 109 led_data->cdev.brightness_set_blocking = led_pwm_set;
116 if (!led_data->can_sleep)
117 led_data->cdev.brightness_set = led_pwm_set;
118 else
119 led_data->cdev.brightness_set_blocking = led_pwm_set_blocking;
120 110
121 /* 111 /*
122 * FIXME: pwm_apply_args() should be removed when switching to the 112 * FIXME: pwm_apply_args() should be removed when switching to the
diff --git a/drivers/misc/cxl/cxl.h b/drivers/misc/cxl/cxl.h
index 6c722d96b775..79e60ec70bd3 100644
--- a/drivers/misc/cxl/cxl.h
+++ b/drivers/misc/cxl/cxl.h
@@ -418,8 +418,9 @@ struct cxl_afu {
418 struct dentry *debugfs; 418 struct dentry *debugfs;
419 struct mutex contexts_lock; 419 struct mutex contexts_lock;
420 spinlock_t afu_cntl_lock; 420 spinlock_t afu_cntl_lock;
421 /* Used to block access to AFU config space while deconfigured */ 421
422 struct rw_semaphore configured_rwsem; 422 /* -1: AFU deconfigured/locked, >= 0: number of readers */
423 atomic_t configured_state;
423 424
424 /* AFU error buffer fields and bin attribute for sysfs */ 425 /* AFU error buffer fields and bin attribute for sysfs */
425 u64 eb_len, eb_offset; 426 u64 eb_len, eb_offset;
diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c
index 2a6bf1d0a3a4..cc1706a92ace 100644
--- a/drivers/misc/cxl/main.c
+++ b/drivers/misc/cxl/main.c
@@ -268,8 +268,7 @@ struct cxl_afu *cxl_alloc_afu(struct cxl *adapter, int slice)
268 idr_init(&afu->contexts_idr); 268 idr_init(&afu->contexts_idr);
269 mutex_init(&afu->contexts_lock); 269 mutex_init(&afu->contexts_lock);
270 spin_lock_init(&afu->afu_cntl_lock); 270 spin_lock_init(&afu->afu_cntl_lock);
271 init_rwsem(&afu->configured_rwsem); 271 atomic_set(&afu->configured_state, -1);
272 down_write(&afu->configured_rwsem);
273 afu->prefault_mode = CXL_PREFAULT_NONE; 272 afu->prefault_mode = CXL_PREFAULT_NONE;
274 afu->irqs_max = afu->adapter->user_irqs; 273 afu->irqs_max = afu->adapter->user_irqs;
275 274
diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
index cca938845ffd..91f645992c94 100644
--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -1129,7 +1129,7 @@ static int pci_configure_afu(struct cxl_afu *afu, struct cxl *adapter, struct pc
1129 if ((rc = cxl_native_register_psl_irq(afu))) 1129 if ((rc = cxl_native_register_psl_irq(afu)))
1130 goto err2; 1130 goto err2;
1131 1131
1132 up_write(&afu->configured_rwsem); 1132 atomic_set(&afu->configured_state, 0);
1133 return 0; 1133 return 0;
1134 1134
1135err2: 1135err2:
@@ -1142,7 +1142,14 @@ err1:
1142 1142
1143static void pci_deconfigure_afu(struct cxl_afu *afu) 1143static void pci_deconfigure_afu(struct cxl_afu *afu)
1144{ 1144{
1145 down_write(&afu->configured_rwsem); 1145 /*
1146 * It's okay to deconfigure when AFU is already locked, otherwise wait
1147 * until there are no readers
1148 */
1149 if (atomic_read(&afu->configured_state) != -1) {
1150 while (atomic_cmpxchg(&afu->configured_state, 0, -1) != -1)
1151 schedule();
1152 }
1146 cxl_native_release_psl_irq(afu); 1153 cxl_native_release_psl_irq(afu);
1147 if (afu->adapter->native->sl_ops->release_serr_irq) 1154 if (afu->adapter->native->sl_ops->release_serr_irq)
1148 afu->adapter->native->sl_ops->release_serr_irq(afu); 1155 afu->adapter->native->sl_ops->release_serr_irq(afu);
diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index 639a343b7836..512a4897dbf6 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -83,6 +83,16 @@ static inline struct cxl_afu *pci_bus_to_afu(struct pci_bus *bus)
83 return phb ? phb->private_data : NULL; 83 return phb ? phb->private_data : NULL;
84} 84}
85 85
86static void cxl_afu_configured_put(struct cxl_afu *afu)
87{
88 atomic_dec_if_positive(&afu->configured_state);
89}
90
91static bool cxl_afu_configured_get(struct cxl_afu *afu)
92{
93 return atomic_inc_unless_negative(&afu->configured_state);
94}
95
86static inline int cxl_pcie_config_info(struct pci_bus *bus, unsigned int devfn, 96static inline int cxl_pcie_config_info(struct pci_bus *bus, unsigned int devfn,
87 struct cxl_afu *afu, int *_record) 97 struct cxl_afu *afu, int *_record)
88{ 98{
@@ -107,7 +117,7 @@ static int cxl_pcie_read_config(struct pci_bus *bus, unsigned int devfn,
107 117
108 afu = pci_bus_to_afu(bus); 118 afu = pci_bus_to_afu(bus);
109 /* Grab a reader lock on afu. */ 119 /* Grab a reader lock on afu. */
110 if (afu == NULL || !down_read_trylock(&afu->configured_rwsem)) 120 if (afu == NULL || !cxl_afu_configured_get(afu))
111 return PCIBIOS_DEVICE_NOT_FOUND; 121 return PCIBIOS_DEVICE_NOT_FOUND;
112 122
113 rc = cxl_pcie_config_info(bus, devfn, afu, &record); 123 rc = cxl_pcie_config_info(bus, devfn, afu, &record);
@@ -132,7 +142,7 @@ static int cxl_pcie_read_config(struct pci_bus *bus, unsigned int devfn,
132 } 142 }
133 143
134out: 144out:
135 up_read(&afu->configured_rwsem); 145 cxl_afu_configured_put(afu);
136 return rc ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL; 146 return rc ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
137} 147}
138 148
@@ -144,7 +154,7 @@ static int cxl_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
144 154
145 afu = pci_bus_to_afu(bus); 155 afu = pci_bus_to_afu(bus);
146 /* Grab a reader lock on afu. */ 156 /* Grab a reader lock on afu. */
147 if (afu == NULL || !down_read_trylock(&afu->configured_rwsem)) 157 if (afu == NULL || !cxl_afu_configured_get(afu))
148 return PCIBIOS_DEVICE_NOT_FOUND; 158 return PCIBIOS_DEVICE_NOT_FOUND;
149 159
150 rc = cxl_pcie_config_info(bus, devfn, afu, &record); 160 rc = cxl_pcie_config_info(bus, devfn, afu, &record);
@@ -166,7 +176,7 @@ static int cxl_pcie_write_config(struct pci_bus *bus, unsigned int devfn,
166 } 176 }
167 177
168out: 178out:
169 up_read(&afu->configured_rwsem); 179 cxl_afu_configured_put(afu);
170 return rc ? PCIBIOS_SET_FAILED : PCIBIOS_SUCCESSFUL; 180 return rc ? PCIBIOS_SET_FAILED : PCIBIOS_SUCCESSFUL;
171} 181}
172 182
diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index d2961ef39a3a..7c203198b582 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -35,9 +35,11 @@ static void pnv_php_register(struct device_node *dn);
35static void pnv_php_unregister_one(struct device_node *dn); 35static void pnv_php_unregister_one(struct device_node *dn);
36static void pnv_php_unregister(struct device_node *dn); 36static void pnv_php_unregister(struct device_node *dn);
37 37
38static void pnv_php_disable_irq(struct pnv_php_slot *php_slot) 38static void pnv_php_disable_irq(struct pnv_php_slot *php_slot,
39 bool disable_device)
39{ 40{
40 struct pci_dev *pdev = php_slot->pdev; 41 struct pci_dev *pdev = php_slot->pdev;
42 int irq = php_slot->irq;
41 u16 ctrl; 43 u16 ctrl;
42 44
43 if (php_slot->irq > 0) { 45 if (php_slot->irq > 0) {
@@ -56,10 +58,14 @@ static void pnv_php_disable_irq(struct pnv_php_slot *php_slot)
56 php_slot->wq = NULL; 58 php_slot->wq = NULL;
57 } 59 }
58 60
59 if (pdev->msix_enabled) 61 if (disable_device || irq > 0) {
60 pci_disable_msix(pdev); 62 if (pdev->msix_enabled)
61 else if (pdev->msi_enabled) 63 pci_disable_msix(pdev);
62 pci_disable_msi(pdev); 64 else if (pdev->msi_enabled)
65 pci_disable_msi(pdev);
66
67 pci_disable_device(pdev);
68 }
63} 69}
64 70
65static void pnv_php_free_slot(struct kref *kref) 71static void pnv_php_free_slot(struct kref *kref)
@@ -68,7 +74,7 @@ static void pnv_php_free_slot(struct kref *kref)
68 struct pnv_php_slot, kref); 74 struct pnv_php_slot, kref);
69 75
70 WARN_ON(!list_empty(&php_slot->children)); 76 WARN_ON(!list_empty(&php_slot->children));
71 pnv_php_disable_irq(php_slot); 77 pnv_php_disable_irq(php_slot, false);
72 kfree(php_slot->name); 78 kfree(php_slot->name);
73 kfree(php_slot); 79 kfree(php_slot);
74} 80}
@@ -76,7 +82,7 @@ static void pnv_php_free_slot(struct kref *kref)
76static inline void pnv_php_put_slot(struct pnv_php_slot *php_slot) 82static inline void pnv_php_put_slot(struct pnv_php_slot *php_slot)
77{ 83{
78 84
79 if (WARN_ON(!php_slot)) 85 if (!php_slot)
80 return; 86 return;
81 87
82 kref_put(&php_slot->kref, pnv_php_free_slot); 88 kref_put(&php_slot->kref, pnv_php_free_slot);
@@ -430,9 +436,21 @@ static int pnv_php_enable(struct pnv_php_slot *php_slot, bool rescan)
430 if (ret) 436 if (ret)
431 return ret; 437 return ret;
432 438
433 /* Proceed if there have nothing behind the slot */ 439 /*
434 if (presence == OPAL_PCI_SLOT_EMPTY) 440 * Proceed if there have nothing behind the slot. However,
441 * we should leave the slot in registered state at the
442 * beginning. Otherwise, the PCI devices inserted afterwards
443 * won't be probed and populated.
444 */
445 if (presence == OPAL_PCI_SLOT_EMPTY) {
446 if (!php_slot->power_state_check) {
447 php_slot->power_state_check = true;
448
449 return 0;
450 }
451
435 goto scan; 452 goto scan;
453 }
436 454
437 /* 455 /*
438 * If the power supply to the slot is off, we can't detect 456 * If the power supply to the slot is off, we can't detect
@@ -705,10 +723,15 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data)
705 if (sts & PCI_EXP_SLTSTA_DLLSC) { 723 if (sts & PCI_EXP_SLTSTA_DLLSC) {
706 pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lsts); 724 pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &lsts);
707 added = !!(lsts & PCI_EXP_LNKSTA_DLLLA); 725 added = !!(lsts & PCI_EXP_LNKSTA_DLLLA);
708 } else if (sts & PCI_EXP_SLTSTA_PDC) { 726 } else if (!(php_slot->flags & PNV_PHP_FLAG_BROKEN_PDC) &&
727 (sts & PCI_EXP_SLTSTA_PDC)) {
709 ret = pnv_pci_get_presence_state(php_slot->id, &presence); 728 ret = pnv_pci_get_presence_state(php_slot->id, &presence);
710 if (!ret) 729 if (ret) {
730 dev_warn(&pdev->dev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n",
731 php_slot->name, ret, sts);
711 return IRQ_HANDLED; 732 return IRQ_HANDLED;
733 }
734
712 added = !!(presence == OPAL_PCI_SLOT_PRESENT); 735 added = !!(presence == OPAL_PCI_SLOT_PRESENT);
713 } else { 736 } else {
714 return IRQ_NONE; 737 return IRQ_NONE;
@@ -752,6 +775,7 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data)
752static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq) 775static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
753{ 776{
754 struct pci_dev *pdev = php_slot->pdev; 777 struct pci_dev *pdev = php_slot->pdev;
778 u32 broken_pdc = 0;
755 u16 sts, ctrl; 779 u16 sts, ctrl;
756 int ret; 780 int ret;
757 781
@@ -759,29 +783,44 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
759 php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name); 783 php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name);
760 if (!php_slot->wq) { 784 if (!php_slot->wq) {
761 dev_warn(&pdev->dev, "Cannot alloc workqueue\n"); 785 dev_warn(&pdev->dev, "Cannot alloc workqueue\n");
762 pnv_php_disable_irq(php_slot); 786 pnv_php_disable_irq(php_slot, true);
763 return; 787 return;
764 } 788 }
765 789
790 /* Check PDC (Presence Detection Change) is broken or not */
791 ret = of_property_read_u32(php_slot->dn, "ibm,slot-broken-pdc",
792 &broken_pdc);
793 if (!ret && broken_pdc)
794 php_slot->flags |= PNV_PHP_FLAG_BROKEN_PDC;
795
766 /* Clear pending interrupts */ 796 /* Clear pending interrupts */
767 pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &sts); 797 pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &sts);
768 sts |= (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC); 798 if (php_slot->flags & PNV_PHP_FLAG_BROKEN_PDC)
799 sts |= PCI_EXP_SLTSTA_DLLSC;
800 else
801 sts |= (PCI_EXP_SLTSTA_PDC | PCI_EXP_SLTSTA_DLLSC);
769 pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, sts); 802 pcie_capability_write_word(pdev, PCI_EXP_SLTSTA, sts);
770 803
771 /* Request the interrupt */ 804 /* Request the interrupt */
772 ret = request_irq(irq, pnv_php_interrupt, IRQF_SHARED, 805 ret = request_irq(irq, pnv_php_interrupt, IRQF_SHARED,
773 php_slot->name, php_slot); 806 php_slot->name, php_slot);
774 if (ret) { 807 if (ret) {
775 pnv_php_disable_irq(php_slot); 808 pnv_php_disable_irq(php_slot, true);
776 dev_warn(&pdev->dev, "Error %d enabling IRQ %d\n", ret, irq); 809 dev_warn(&pdev->dev, "Error %d enabling IRQ %d\n", ret, irq);
777 return; 810 return;
778 } 811 }
779 812
780 /* Enable the interrupts */ 813 /* Enable the interrupts */
781 pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &ctrl); 814 pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &ctrl);
782 ctrl |= (PCI_EXP_SLTCTL_HPIE | 815 if (php_slot->flags & PNV_PHP_FLAG_BROKEN_PDC) {
783 PCI_EXP_SLTCTL_PDCE | 816 ctrl &= ~PCI_EXP_SLTCTL_PDCE;
784 PCI_EXP_SLTCTL_DLLSCE); 817 ctrl |= (PCI_EXP_SLTCTL_HPIE |
818 PCI_EXP_SLTCTL_DLLSCE);
819 } else {
820 ctrl |= (PCI_EXP_SLTCTL_HPIE |
821 PCI_EXP_SLTCTL_PDCE |
822 PCI_EXP_SLTCTL_DLLSCE);
823 }
785 pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, ctrl); 824 pcie_capability_write_word(pdev, PCI_EXP_SLTCTL, ctrl);
786 825
787 /* The interrupt is initialized successfully when @irq is valid */ 826 /* The interrupt is initialized successfully when @irq is valid */
@@ -793,6 +832,14 @@ static void pnv_php_enable_irq(struct pnv_php_slot *php_slot)
793 struct pci_dev *pdev = php_slot->pdev; 832 struct pci_dev *pdev = php_slot->pdev;
794 int irq, ret; 833 int irq, ret;
795 834
835 /*
836 * The MSI/MSIx interrupt might have been occupied by other
837 * drivers. Don't populate the surprise hotplug capability
838 * in that case.
839 */
840 if (pci_dev_msi_enabled(pdev))
841 return;
842
796 ret = pci_enable_device(pdev); 843 ret = pci_enable_device(pdev);
797 if (ret) { 844 if (ret) {
798 dev_warn(&pdev->dev, "Error %d enabling device\n", ret); 845 dev_warn(&pdev->dev, "Error %d enabling device\n", ret);
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 2d0cfaa6d84c..42e37c20b361 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -76,7 +76,9 @@ config PWM_ATMEL_TCB
76 76
77config PWM_BCM_IPROC 77config PWM_BCM_IPROC
78 tristate "iProc PWM support" 78 tristate "iProc PWM support"
79 depends on ARCH_BCM_IPROC 79 depends on ARCH_BCM_IPROC || COMPILE_TEST
80 depends on COMMON_CLK
81 default ARCH_BCM_IPROC
80 help 82 help
81 Generic PWM framework driver for Broadcom iProc PWM block. This 83 Generic PWM framework driver for Broadcom iProc PWM block. This
82 block is used in Broadcom iProc SoC's. 84 block is used in Broadcom iProc SoC's.
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 172ef8245811..a0860b30bd93 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -137,9 +137,14 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
137{ 137{
138 struct pwm_device *pwm; 138 struct pwm_device *pwm;
139 139
140 /* check, whether the driver supports a third cell for flags */
140 if (pc->of_pwm_n_cells < 3) 141 if (pc->of_pwm_n_cells < 3)
141 return ERR_PTR(-EINVAL); 142 return ERR_PTR(-EINVAL);
142 143
144 /* flags in the third cell are optional */
145 if (args->args_count < 2)
146 return ERR_PTR(-EINVAL);
147
143 if (args->args[0] >= pc->npwm) 148 if (args->args[0] >= pc->npwm)
144 return ERR_PTR(-EINVAL); 149 return ERR_PTR(-EINVAL);
145 150
@@ -148,11 +153,10 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
148 return pwm; 153 return pwm;
149 154
150 pwm->args.period = args->args[1]; 155 pwm->args.period = args->args[1];
156 pwm->args.polarity = PWM_POLARITY_NORMAL;
151 157
152 if (args->args[2] & PWM_POLARITY_INVERTED) 158 if (args->args_count > 2 && args->args[2] & PWM_POLARITY_INVERTED)
153 pwm->args.polarity = PWM_POLARITY_INVERSED; 159 pwm->args.polarity = PWM_POLARITY_INVERSED;
154 else
155 pwm->args.polarity = PWM_POLARITY_NORMAL;
156 160
157 return pwm; 161 return pwm;
158} 162}
@@ -163,9 +167,14 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
163{ 167{
164 struct pwm_device *pwm; 168 struct pwm_device *pwm;
165 169
170 /* sanity check driver support */
166 if (pc->of_pwm_n_cells < 2) 171 if (pc->of_pwm_n_cells < 2)
167 return ERR_PTR(-EINVAL); 172 return ERR_PTR(-EINVAL);
168 173
174 /* all cells are required */
175 if (args->args_count != pc->of_pwm_n_cells)
176 return ERR_PTR(-EINVAL);
177
169 if (args->args[0] >= pc->npwm) 178 if (args->args[0] >= pc->npwm)
170 return ERR_PTR(-EINVAL); 179 return ERR_PTR(-EINVAL);
171 180
@@ -663,24 +672,17 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
663 err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index, 672 err = of_parse_phandle_with_args(np, "pwms", "#pwm-cells", index,
664 &args); 673 &args);
665 if (err) { 674 if (err) {
666 pr_debug("%s(): can't parse \"pwms\" property\n", __func__); 675 pr_err("%s(): can't parse \"pwms\" property\n", __func__);
667 return ERR_PTR(err); 676 return ERR_PTR(err);
668 } 677 }
669 678
670 pc = of_node_to_pwmchip(args.np); 679 pc = of_node_to_pwmchip(args.np);
671 if (IS_ERR(pc)) { 680 if (IS_ERR(pc)) {
672 pr_debug("%s(): PWM chip not found\n", __func__); 681 pr_err("%s(): PWM chip not found\n", __func__);
673 pwm = ERR_CAST(pc); 682 pwm = ERR_CAST(pc);
674 goto put; 683 goto put;
675 } 684 }
676 685
677 if (args.args_count != pc->of_pwm_n_cells) {
678 pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
679 args.np->full_name);
680 pwm = ERR_PTR(-EINVAL);
681 goto put;
682 }
683
684 pwm = pc->of_xlate(pc, &args); 686 pwm = pc->of_xlate(pc, &args);
685 if (IS_ERR(pwm)) 687 if (IS_ERR(pwm))
686 goto put; 688 goto put;
@@ -757,12 +759,13 @@ void pwm_remove_table(struct pwm_lookup *table, size_t num)
757 */ 759 */
758struct pwm_device *pwm_get(struct device *dev, const char *con_id) 760struct pwm_device *pwm_get(struct device *dev, const char *con_id)
759{ 761{
760 struct pwm_device *pwm = ERR_PTR(-EPROBE_DEFER);
761 const char *dev_id = dev ? dev_name(dev) : NULL; 762 const char *dev_id = dev ? dev_name(dev) : NULL;
762 struct pwm_chip *chip = NULL; 763 struct pwm_device *pwm;
764 struct pwm_chip *chip;
763 unsigned int best = 0; 765 unsigned int best = 0;
764 struct pwm_lookup *p, *chosen = NULL; 766 struct pwm_lookup *p, *chosen = NULL;
765 unsigned int match; 767 unsigned int match;
768 int err;
766 769
767 /* look up via DT first */ 770 /* look up via DT first */
768 if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node) 771 if (IS_ENABLED(CONFIG_OF) && dev && dev->of_node)
@@ -817,24 +820,35 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
817 } 820 }
818 } 821 }
819 822
820 if (!chosen) { 823 mutex_unlock(&pwm_lookup_lock);
821 pwm = ERR_PTR(-ENODEV); 824
822 goto out; 825 if (!chosen)
823 } 826 return ERR_PTR(-ENODEV);
824 827
825 chip = pwmchip_find_by_name(chosen->provider); 828 chip = pwmchip_find_by_name(chosen->provider);
829
830 /*
831 * If the lookup entry specifies a module, load the module and retry
832 * the PWM chip lookup. This can be used to work around driver load
833 * ordering issues if driver's can't be made to properly support the
834 * deferred probe mechanism.
835 */
836 if (!chip && chosen->module) {
837 err = request_module(chosen->module);
838 if (err == 0)
839 chip = pwmchip_find_by_name(chosen->provider);
840 }
841
826 if (!chip) 842 if (!chip)
827 goto out; 843 return ERR_PTR(-EPROBE_DEFER);
828 844
829 pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id); 845 pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id);
830 if (IS_ERR(pwm)) 846 if (IS_ERR(pwm))
831 goto out; 847 return pwm;
832 848
833 pwm->args.period = chosen->period; 849 pwm->args.period = chosen->period;
834 pwm->args.polarity = chosen->polarity; 850 pwm->args.polarity = chosen->polarity;
835 851
836out:
837 mutex_unlock(&pwm_lookup_lock);
838 return pwm; 852 return pwm;
839} 853}
840EXPORT_SYMBOL_GPL(pwm_get); 854EXPORT_SYMBOL_GPL(pwm_get);
@@ -960,18 +974,6 @@ void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
960} 974}
961EXPORT_SYMBOL_GPL(devm_pwm_put); 975EXPORT_SYMBOL_GPL(devm_pwm_put);
962 976
963/**
964 * pwm_can_sleep() - report whether PWM access will sleep
965 * @pwm: PWM device
966 *
967 * Returns: True if accessing the PWM can sleep, false otherwise.
968 */
969bool pwm_can_sleep(struct pwm_device *pwm)
970{
971 return true;
972}
973EXPORT_SYMBOL_GPL(pwm_can_sleep);
974
975#ifdef CONFIG_DEBUG_FS 977#ifdef CONFIG_DEBUG_FS
976static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s) 978static void pwm_dbg_show(struct pwm_chip *chip, struct seq_file *s)
977{ 979{
diff --git a/drivers/pwm/pwm-atmel-hlcdc.c b/drivers/pwm/pwm-atmel-hlcdc.c
index 14fc011faa32..999187277ea5 100644
--- a/drivers/pwm/pwm-atmel-hlcdc.c
+++ b/drivers/pwm/pwm-atmel-hlcdc.c
@@ -270,7 +270,6 @@ static int atmel_hlcdc_pwm_probe(struct platform_device *pdev)
270 chip->chip.npwm = 1; 270 chip->chip.npwm = 1;
271 chip->chip.of_xlate = of_pwm_xlate_with_flags; 271 chip->chip.of_xlate = of_pwm_xlate_with_flags;
272 chip->chip.of_pwm_n_cells = 3; 272 chip->chip.of_pwm_n_cells = 3;
273 chip->chip.can_sleep = 1;
274 273
275 ret = pwmchip_add_with_polarity(&chip->chip, PWM_POLARITY_INVERSED); 274 ret = pwmchip_add_with_polarity(&chip->chip, PWM_POLARITY_INVERSED);
276 if (ret) { 275 if (ret) {
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index e6b8b1b7e6ba..67a7023be5c2 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -385,7 +385,6 @@ static int atmel_pwm_probe(struct platform_device *pdev)
385 385
386 atmel_pwm->chip.base = -1; 386 atmel_pwm->chip.base = -1;
387 atmel_pwm->chip.npwm = 4; 387 atmel_pwm->chip.npwm = 4;
388 atmel_pwm->chip.can_sleep = true;
389 atmel_pwm->config = data->config; 388 atmel_pwm->config = data->config;
390 atmel_pwm->updated_pwms = 0; 389 atmel_pwm->updated_pwms = 0;
391 mutex_init(&atmel_pwm->isr_lock); 390 mutex_init(&atmel_pwm->isr_lock);
diff --git a/drivers/pwm/pwm-bcm-kona.c b/drivers/pwm/pwm-bcm-kona.c
index c63418322023..09a95aeb3a70 100644
--- a/drivers/pwm/pwm-bcm-kona.c
+++ b/drivers/pwm/pwm-bcm-kona.c
@@ -276,7 +276,6 @@ static int kona_pwmc_probe(struct platform_device *pdev)
276 kp->chip.npwm = 6; 276 kp->chip.npwm = 6;
277 kp->chip.of_xlate = of_pwm_xlate_with_flags; 277 kp->chip.of_xlate = of_pwm_xlate_with_flags;
278 kp->chip.of_pwm_n_cells = 3; 278 kp->chip.of_pwm_n_cells = 3;
279 kp->chip.can_sleep = true;
280 279
281 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 280 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
282 kp->base = devm_ioremap_resource(&pdev->dev, res); 281 kp->base = devm_ioremap_resource(&pdev->dev, res);
diff --git a/drivers/pwm/pwm-berlin.c b/drivers/pwm/pwm-berlin.c
index 01339c152ab0..771859aca4be 100644
--- a/drivers/pwm/pwm-berlin.c
+++ b/drivers/pwm/pwm-berlin.c
@@ -206,7 +206,6 @@ static int berlin_pwm_probe(struct platform_device *pdev)
206 pwm->chip.ops = &berlin_pwm_ops; 206 pwm->chip.ops = &berlin_pwm_ops;
207 pwm->chip.base = -1; 207 pwm->chip.base = -1;
208 pwm->chip.npwm = 4; 208 pwm->chip.npwm = 4;
209 pwm->chip.can_sleep = true;
210 pwm->chip.of_xlate = of_pwm_xlate_with_flags; 209 pwm->chip.of_xlate = of_pwm_xlate_with_flags;
211 pwm->chip.of_pwm_n_cells = 3; 210 pwm->chip.of_pwm_n_cells = 3;
212 211
diff --git a/drivers/pwm/pwm-bfin.c b/drivers/pwm/pwm-bfin.c
index 7631ef194de7..d2ed0a2a18e8 100644
--- a/drivers/pwm/pwm-bfin.c
+++ b/drivers/pwm/pwm-bfin.c
@@ -103,7 +103,7 @@ static void bfin_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
103 disable_gptimer(priv->pin); 103 disable_gptimer(priv->pin);
104} 104}
105 105
106static struct pwm_ops bfin_pwm_ops = { 106static const struct pwm_ops bfin_pwm_ops = {
107 .request = bfin_pwm_request, 107 .request = bfin_pwm_request,
108 .free = bfin_pwm_free, 108 .free = bfin_pwm_free,
109 .config = bfin_pwm_config, 109 .config = bfin_pwm_config,
diff --git a/drivers/pwm/pwm-brcmstb.c b/drivers/pwm/pwm-brcmstb.c
index 5d5adee16886..8063cffa1c96 100644
--- a/drivers/pwm/pwm-brcmstb.c
+++ b/drivers/pwm/pwm-brcmstb.c
@@ -270,7 +270,6 @@ static int brcmstb_pwm_probe(struct platform_device *pdev)
270 p->chip.ops = &brcmstb_pwm_ops; 270 p->chip.ops = &brcmstb_pwm_ops;
271 p->chip.base = -1; 271 p->chip.base = -1;
272 p->chip.npwm = 2; 272 p->chip.npwm = 2;
273 p->chip.can_sleep = true;
274 273
275 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 274 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
276 p->base = devm_ioremap_resource(&pdev->dev, res); 275 p->base = devm_ioremap_resource(&pdev->dev, res);
diff --git a/drivers/pwm/pwm-fsl-ftm.c b/drivers/pwm/pwm-fsl-ftm.c
index fad968eb75f6..557b4ea16796 100644
--- a/drivers/pwm/pwm-fsl-ftm.c
+++ b/drivers/pwm/pwm-fsl-ftm.c
@@ -446,7 +446,6 @@ static int fsl_pwm_probe(struct platform_device *pdev)
446 fpc->chip.of_pwm_n_cells = 3; 446 fpc->chip.of_pwm_n_cells = 3;
447 fpc->chip.base = -1; 447 fpc->chip.base = -1;
448 fpc->chip.npwm = 8; 448 fpc->chip.npwm = 8;
449 fpc->chip.can_sleep = true;
450 449
451 ret = pwmchip_add(&fpc->chip); 450 ret = pwmchip_add(&fpc->chip);
452 if (ret < 0) { 451 if (ret < 0) {
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index d600fd5cd4ba..2ba5c3a398ff 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -38,6 +38,7 @@
38#define MX3_PWMCR_DOZEEN (1 << 24) 38#define MX3_PWMCR_DOZEEN (1 << 24)
39#define MX3_PWMCR_WAITEN (1 << 23) 39#define MX3_PWMCR_WAITEN (1 << 23)
40#define MX3_PWMCR_DBGEN (1 << 22) 40#define MX3_PWMCR_DBGEN (1 << 22)
41#define MX3_PWMCR_POUTC (1 << 18)
41#define MX3_PWMCR_CLKSRC_IPG_HIGH (2 << 16) 42#define MX3_PWMCR_CLKSRC_IPG_HIGH (2 << 16)
42#define MX3_PWMCR_CLKSRC_IPG (1 << 16) 43#define MX3_PWMCR_CLKSRC_IPG (1 << 16)
43#define MX3_PWMCR_SWR (1 << 3) 44#define MX3_PWMCR_SWR (1 << 3)
@@ -49,15 +50,10 @@
49 50
50struct imx_chip { 51struct imx_chip {
51 struct clk *clk_per; 52 struct clk *clk_per;
52 struct clk *clk_ipg;
53 53
54 void __iomem *mmio_base; 54 void __iomem *mmio_base;
55 55
56 struct pwm_chip chip; 56 struct pwm_chip chip;
57
58 int (*config)(struct pwm_chip *chip,
59 struct pwm_device *pwm, int duty_ns, int period_ns);
60 void (*set_enable)(struct pwm_chip *chip, bool enable);
61}; 57};
62 58
63#define to_imx_chip(chip) container_of(chip, struct imx_chip, chip) 59#define to_imx_chip(chip) container_of(chip, struct imx_chip, chip)
@@ -91,176 +87,170 @@ static int imx_pwm_config_v1(struct pwm_chip *chip,
91 return 0; 87 return 0;
92} 88}
93 89
94static void imx_pwm_set_enable_v1(struct pwm_chip *chip, bool enable) 90static int imx_pwm_enable_v1(struct pwm_chip *chip, struct pwm_device *pwm)
95{ 91{
96 struct imx_chip *imx = to_imx_chip(chip); 92 struct imx_chip *imx = to_imx_chip(chip);
97 u32 val; 93 u32 val;
94 int ret;
98 95
99 val = readl(imx->mmio_base + MX1_PWMC); 96 ret = clk_prepare_enable(imx->clk_per);
100 97 if (ret < 0)
101 if (enable) 98 return ret;
102 val |= MX1_PWMC_EN;
103 else
104 val &= ~MX1_PWMC_EN;
105 99
100 val = readl(imx->mmio_base + MX1_PWMC);
101 val |= MX1_PWMC_EN;
106 writel(val, imx->mmio_base + MX1_PWMC); 102 writel(val, imx->mmio_base + MX1_PWMC);
107}
108
109static int imx_pwm_config_v2(struct pwm_chip *chip,
110 struct pwm_device *pwm, int duty_ns, int period_ns)
111{
112 struct imx_chip *imx = to_imx_chip(chip);
113 struct device *dev = chip->dev;
114 unsigned long long c;
115 unsigned long period_cycles, duty_cycles, prescale;
116 unsigned int period_ms;
117 bool enable = pwm_is_enabled(pwm);
118 int wait_count = 0, fifoav;
119 u32 cr, sr;
120
121 /*
122 * i.MX PWMv2 has a 4-word sample FIFO.
123 * In order to avoid FIFO overflow issue, we do software reset
124 * to clear all sample FIFO if the controller is disabled or
125 * wait for a full PWM cycle to get a relinquished FIFO slot
126 * when the controller is enabled and the FIFO is fully loaded.
127 */
128 if (enable) {
129 sr = readl(imx->mmio_base + MX3_PWMSR);
130 fifoav = sr & MX3_PWMSR_FIFOAV_MASK;
131 if (fifoav == MX3_PWMSR_FIFOAV_4WORDS) {
132 period_ms = DIV_ROUND_UP(pwm_get_period(pwm),
133 NSEC_PER_MSEC);
134 msleep(period_ms);
135
136 sr = readl(imx->mmio_base + MX3_PWMSR);
137 if (fifoav == (sr & MX3_PWMSR_FIFOAV_MASK))
138 dev_warn(dev, "there is no free FIFO slot\n");
139 }
140 } else {
141 writel(MX3_PWMCR_SWR, imx->mmio_base + MX3_PWMCR);
142 do {
143 usleep_range(200, 1000);
144 cr = readl(imx->mmio_base + MX3_PWMCR);
145 } while ((cr & MX3_PWMCR_SWR) &&
146 (wait_count++ < MX3_PWM_SWR_LOOP));
147
148 if (cr & MX3_PWMCR_SWR)
149 dev_warn(dev, "software reset timeout\n");
150 }
151
152 c = clk_get_rate(imx->clk_per);
153 c = c * period_ns;
154 do_div(c, 1000000000);
155 period_cycles = c;
156
157 prescale = period_cycles / 0x10000 + 1;
158
159 period_cycles /= prescale;
160 c = (unsigned long long)period_cycles * duty_ns;
161 do_div(c, period_ns);
162 duty_cycles = c;
163
164 /*
165 * according to imx pwm RM, the real period value should be
166 * PERIOD value in PWMPR plus 2.
167 */
168 if (period_cycles > 2)
169 period_cycles -= 2;
170 else
171 period_cycles = 0;
172
173 writel(duty_cycles, imx->mmio_base + MX3_PWMSAR);
174 writel(period_cycles, imx->mmio_base + MX3_PWMPR);
175
176 cr = MX3_PWMCR_PRESCALER(prescale) |
177 MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
178 MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH;
179
180 if (enable)
181 cr |= MX3_PWMCR_EN;
182
183 writel(cr, imx->mmio_base + MX3_PWMCR);
184 103
185 return 0; 104 return 0;
186} 105}
187 106
188static void imx_pwm_set_enable_v2(struct pwm_chip *chip, bool enable) 107static void imx_pwm_disable_v1(struct pwm_chip *chip, struct pwm_device *pwm)
189{ 108{
190 struct imx_chip *imx = to_imx_chip(chip); 109 struct imx_chip *imx = to_imx_chip(chip);
191 u32 val; 110 u32 val;
192 111
193 val = readl(imx->mmio_base + MX3_PWMCR); 112 val = readl(imx->mmio_base + MX1_PWMC);
194 113 val &= ~MX1_PWMC_EN;
195 if (enable) 114 writel(val, imx->mmio_base + MX1_PWMC);
196 val |= MX3_PWMCR_EN;
197 else
198 val &= ~MX3_PWMCR_EN;
199 115
200 writel(val, imx->mmio_base + MX3_PWMCR); 116 clk_disable_unprepare(imx->clk_per);
201} 117}
202 118
203static int imx_pwm_config(struct pwm_chip *chip, 119static void imx_pwm_sw_reset(struct pwm_chip *chip)
204 struct pwm_device *pwm, int duty_ns, int period_ns)
205{ 120{
206 struct imx_chip *imx = to_imx_chip(chip); 121 struct imx_chip *imx = to_imx_chip(chip);
207 int ret; 122 struct device *dev = chip->dev;
208 123 int wait_count = 0;
209 ret = clk_prepare_enable(imx->clk_ipg); 124 u32 cr;
210 if (ret) 125
211 return ret; 126 writel(MX3_PWMCR_SWR, imx->mmio_base + MX3_PWMCR);
127 do {
128 usleep_range(200, 1000);
129 cr = readl(imx->mmio_base + MX3_PWMCR);
130 } while ((cr & MX3_PWMCR_SWR) &&
131 (wait_count++ < MX3_PWM_SWR_LOOP));
132
133 if (cr & MX3_PWMCR_SWR)
134 dev_warn(dev, "software reset timeout\n");
135}
212 136
213 ret = imx->config(chip, pwm, duty_ns, period_ns); 137static void imx_pwm_wait_fifo_slot(struct pwm_chip *chip,
138 struct pwm_device *pwm)
139{
140 struct imx_chip *imx = to_imx_chip(chip);
141 struct device *dev = chip->dev;
142 unsigned int period_ms;
143 int fifoav;
144 u32 sr;
214 145
215 clk_disable_unprepare(imx->clk_ipg); 146 sr = readl(imx->mmio_base + MX3_PWMSR);
147 fifoav = sr & MX3_PWMSR_FIFOAV_MASK;
148 if (fifoav == MX3_PWMSR_FIFOAV_4WORDS) {
149 period_ms = DIV_ROUND_UP(pwm_get_period(pwm),
150 NSEC_PER_MSEC);
151 msleep(period_ms);
216 152
217 return ret; 153 sr = readl(imx->mmio_base + MX3_PWMSR);
154 if (fifoav == (sr & MX3_PWMSR_FIFOAV_MASK))
155 dev_warn(dev, "there is no free FIFO slot\n");
156 }
218} 157}
219 158
220static int imx_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm) 159static int imx_pwm_apply_v2(struct pwm_chip *chip, struct pwm_device *pwm,
160 struct pwm_state *state)
221{ 161{
162 unsigned long period_cycles, duty_cycles, prescale;
222 struct imx_chip *imx = to_imx_chip(chip); 163 struct imx_chip *imx = to_imx_chip(chip);
164 struct pwm_state cstate;
165 unsigned long long c;
223 int ret; 166 int ret;
167 u32 cr;
168
169 pwm_get_state(pwm, &cstate);
170
171 if (state->enabled) {
172 c = clk_get_rate(imx->clk_per);
173 c *= state->period;
174
175 do_div(c, 1000000000);
176 period_cycles = c;
177
178 prescale = period_cycles / 0x10000 + 1;
179
180 period_cycles /= prescale;
181 c = (unsigned long long)period_cycles * state->duty_cycle;
182 do_div(c, state->period);
183 duty_cycles = c;
184
185 /*
186 * according to imx pwm RM, the real period value should be
187 * PERIOD value in PWMPR plus 2.
188 */
189 if (period_cycles > 2)
190 period_cycles -= 2;
191 else
192 period_cycles = 0;
193
194 /*
195 * Wait for a free FIFO slot if the PWM is already enabled, and
196 * flush the FIFO if the PWM was disabled and is about to be
197 * enabled.
198 */
199 if (cstate.enabled) {
200 imx_pwm_wait_fifo_slot(chip, pwm);
201 } else {
202 ret = clk_prepare_enable(imx->clk_per);
203 if (ret)
204 return ret;
205
206 imx_pwm_sw_reset(chip);
207 }
224 208
225 ret = clk_prepare_enable(imx->clk_per); 209 writel(duty_cycles, imx->mmio_base + MX3_PWMSAR);
226 if (ret) 210 writel(period_cycles, imx->mmio_base + MX3_PWMPR);
227 return ret;
228 211
229 imx->set_enable(chip, true); 212 cr = MX3_PWMCR_PRESCALER(prescale) |
213 MX3_PWMCR_DOZEEN | MX3_PWMCR_WAITEN |
214 MX3_PWMCR_DBGEN | MX3_PWMCR_CLKSRC_IPG_HIGH |
215 MX3_PWMCR_EN;
230 216
231 return 0; 217 if (state->polarity == PWM_POLARITY_INVERSED)
232} 218 cr |= MX3_PWMCR_POUTC;
233 219
234static void imx_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 220 writel(cr, imx->mmio_base + MX3_PWMCR);
235{ 221 } else if (cstate.enabled) {
236 struct imx_chip *imx = to_imx_chip(chip); 222 writel(0, imx->mmio_base + MX3_PWMCR);
237 223
238 imx->set_enable(chip, false); 224 clk_disable_unprepare(imx->clk_per);
225 }
239 226
240 clk_disable_unprepare(imx->clk_per); 227 return 0;
241} 228}
242 229
243static struct pwm_ops imx_pwm_ops = { 230static const struct pwm_ops imx_pwm_ops_v1 = {
244 .enable = imx_pwm_enable, 231 .enable = imx_pwm_enable_v1,
245 .disable = imx_pwm_disable, 232 .disable = imx_pwm_disable_v1,
246 .config = imx_pwm_config, 233 .config = imx_pwm_config_v1,
234 .owner = THIS_MODULE,
235};
236
237static const struct pwm_ops imx_pwm_ops_v2 = {
238 .apply = imx_pwm_apply_v2,
247 .owner = THIS_MODULE, 239 .owner = THIS_MODULE,
248}; 240};
249 241
250struct imx_pwm_data { 242struct imx_pwm_data {
251 int (*config)(struct pwm_chip *chip, 243 bool polarity_supported;
252 struct pwm_device *pwm, int duty_ns, int period_ns); 244 const struct pwm_ops *ops;
253 void (*set_enable)(struct pwm_chip *chip, bool enable);
254}; 245};
255 246
256static struct imx_pwm_data imx_pwm_data_v1 = { 247static struct imx_pwm_data imx_pwm_data_v1 = {
257 .config = imx_pwm_config_v1, 248 .ops = &imx_pwm_ops_v1,
258 .set_enable = imx_pwm_set_enable_v1,
259}; 249};
260 250
261static struct imx_pwm_data imx_pwm_data_v2 = { 251static struct imx_pwm_data imx_pwm_data_v2 = {
262 .config = imx_pwm_config_v2, 252 .polarity_supported = true,
263 .set_enable = imx_pwm_set_enable_v2, 253 .ops = &imx_pwm_ops_v2,
264}; 254};
265 255
266static const struct of_device_id imx_pwm_dt_ids[] = { 256static const struct of_device_id imx_pwm_dt_ids[] = {
@@ -282,6 +272,8 @@ static int imx_pwm_probe(struct platform_device *pdev)
282 if (!of_id) 272 if (!of_id)
283 return -ENODEV; 273 return -ENODEV;
284 274
275 data = of_id->data;
276
285 imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL); 277 imx = devm_kzalloc(&pdev->dev, sizeof(*imx), GFP_KERNEL);
286 if (imx == NULL) 278 if (imx == NULL)
287 return -ENOMEM; 279 return -ENOMEM;
@@ -293,28 +285,22 @@ static int imx_pwm_probe(struct platform_device *pdev)
293 return PTR_ERR(imx->clk_per); 285 return PTR_ERR(imx->clk_per);
294 } 286 }
295 287
296 imx->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); 288 imx->chip.ops = data->ops;
297 if (IS_ERR(imx->clk_ipg)) {
298 dev_err(&pdev->dev, "getting ipg clock failed with %ld\n",
299 PTR_ERR(imx->clk_ipg));
300 return PTR_ERR(imx->clk_ipg);
301 }
302
303 imx->chip.ops = &imx_pwm_ops;
304 imx->chip.dev = &pdev->dev; 289 imx->chip.dev = &pdev->dev;
305 imx->chip.base = -1; 290 imx->chip.base = -1;
306 imx->chip.npwm = 1; 291 imx->chip.npwm = 1;
307 imx->chip.can_sleep = true; 292
293 if (data->polarity_supported) {
294 dev_dbg(&pdev->dev, "PWM supports output inversion\n");
295 imx->chip.of_xlate = of_pwm_xlate_with_flags;
296 imx->chip.of_pwm_n_cells = 3;
297 }
308 298
309 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 299 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
310 imx->mmio_base = devm_ioremap_resource(&pdev->dev, r); 300 imx->mmio_base = devm_ioremap_resource(&pdev->dev, r);
311 if (IS_ERR(imx->mmio_base)) 301 if (IS_ERR(imx->mmio_base))
312 return PTR_ERR(imx->mmio_base); 302 return PTR_ERR(imx->mmio_base);
313 303
314 data = of_id->data;
315 imx->config = data->config;
316 imx->set_enable = data->set_enable;
317
318 ret = pwmchip_add(&imx->chip); 304 ret = pwmchip_add(&imx->chip);
319 if (ret < 0) 305 if (ret < 0)
320 return ret; 306 return ret;
diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c
index 872ea76a4f19..52584e9962ed 100644
--- a/drivers/pwm/pwm-lp3943.c
+++ b/drivers/pwm/pwm-lp3943.c
@@ -278,7 +278,6 @@ static int lp3943_pwm_probe(struct platform_device *pdev)
278 lp3943_pwm->chip.dev = &pdev->dev; 278 lp3943_pwm->chip.dev = &pdev->dev;
279 lp3943_pwm->chip.ops = &lp3943_pwm_ops; 279 lp3943_pwm->chip.ops = &lp3943_pwm_ops;
280 lp3943_pwm->chip.npwm = LP3943_NUM_PWMS; 280 lp3943_pwm->chip.npwm = LP3943_NUM_PWMS;
281 lp3943_pwm->chip.can_sleep = true;
282 281
283 platform_set_drvdata(pdev, lp3943_pwm); 282 platform_set_drvdata(pdev, lp3943_pwm);
284 283
diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c
index 3622f093490e..053088b9b66e 100644
--- a/drivers/pwm/pwm-lpss-pci.c
+++ b/drivers/pwm/pwm-lpss-pci.c
@@ -17,6 +17,27 @@
17 17
18#include "pwm-lpss.h" 18#include "pwm-lpss.h"
19 19
20/* BayTrail */
21static const struct pwm_lpss_boardinfo pwm_lpss_byt_info = {
22 .clk_rate = 25000000,
23 .npwm = 1,
24 .base_unit_bits = 16,
25};
26
27/* Braswell */
28static const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
29 .clk_rate = 19200000,
30 .npwm = 1,
31 .base_unit_bits = 16,
32};
33
34/* Broxton */
35static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
36 .clk_rate = 19200000,
37 .npwm = 4,
38 .base_unit_bits = 22,
39};
40
20static int pwm_lpss_probe_pci(struct pci_dev *pdev, 41static int pwm_lpss_probe_pci(struct pci_dev *pdev,
21 const struct pci_device_id *id) 42 const struct pci_device_id *id)
22{ 43{
@@ -80,6 +101,7 @@ static const struct pci_device_id pwm_lpss_pci_ids[] = {
80 { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info}, 101 { PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info},
81 { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info}, 102 { PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
82 { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info}, 103 { PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
104 { PCI_VDEVICE(INTEL, 0x31c8), (unsigned long)&pwm_lpss_bxt_info},
83 { PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info}, 105 { PCI_VDEVICE(INTEL, 0x5ac8), (unsigned long)&pwm_lpss_bxt_info},
84 { }, 106 { },
85}; 107};
diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c
index 54433fc6d1a4..b22b6fdadb9a 100644
--- a/drivers/pwm/pwm-lpss-platform.c
+++ b/drivers/pwm/pwm-lpss-platform.c
@@ -18,6 +18,27 @@
18 18
19#include "pwm-lpss.h" 19#include "pwm-lpss.h"
20 20
21/* BayTrail */
22static const struct pwm_lpss_boardinfo pwm_lpss_byt_info = {
23 .clk_rate = 25000000,
24 .npwm = 1,
25 .base_unit_bits = 16,
26};
27
28/* Braswell */
29static const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
30 .clk_rate = 19200000,
31 .npwm = 1,
32 .base_unit_bits = 16,
33};
34
35/* Broxton */
36static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
37 .clk_rate = 19200000,
38 .npwm = 4,
39 .base_unit_bits = 22,
40};
41
21static int pwm_lpss_probe_platform(struct platform_device *pdev) 42static int pwm_lpss_probe_platform(struct platform_device *pdev)
22{ 43{
23 const struct pwm_lpss_boardinfo *info; 44 const struct pwm_lpss_boardinfo *info;
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
index 72c0bce5a75c..689d2c1cbead 100644
--- a/drivers/pwm/pwm-lpss.c
+++ b/drivers/pwm/pwm-lpss.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/iopoll.h>
18#include <linux/kernel.h> 19#include <linux/kernel.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/pm_runtime.h> 21#include <linux/pm_runtime.h>
@@ -37,30 +38,6 @@ struct pwm_lpss_chip {
37 const struct pwm_lpss_boardinfo *info; 38 const struct pwm_lpss_boardinfo *info;
38}; 39};
39 40
40/* BayTrail */
41const struct pwm_lpss_boardinfo pwm_lpss_byt_info = {
42 .clk_rate = 25000000,
43 .npwm = 1,
44 .base_unit_bits = 16,
45};
46EXPORT_SYMBOL_GPL(pwm_lpss_byt_info);
47
48/* Braswell */
49const struct pwm_lpss_boardinfo pwm_lpss_bsw_info = {
50 .clk_rate = 19200000,
51 .npwm = 1,
52 .base_unit_bits = 16,
53};
54EXPORT_SYMBOL_GPL(pwm_lpss_bsw_info);
55
56/* Broxton */
57const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
58 .clk_rate = 19200000,
59 .npwm = 4,
60 .base_unit_bits = 22,
61};
62EXPORT_SYMBOL_GPL(pwm_lpss_bxt_info);
63
64static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip) 41static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip)
65{ 42{
66 return container_of(chip, struct pwm_lpss_chip, chip); 43 return container_of(chip, struct pwm_lpss_chip, chip);
@@ -80,17 +57,42 @@ static inline void pwm_lpss_write(const struct pwm_device *pwm, u32 value)
80 writel(value, lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM); 57 writel(value, lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM);
81} 58}
82 59
83static void pwm_lpss_update(struct pwm_device *pwm) 60static int pwm_lpss_update(struct pwm_device *pwm)
84{ 61{
62 struct pwm_lpss_chip *lpwm = to_lpwm(pwm->chip);
63 const void __iomem *addr = lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM;
64 const unsigned int ms = 500 * USEC_PER_MSEC;
65 u32 val;
66 int err;
67
85 pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE); 68 pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE);
86 /* Give it some time to propagate */ 69
87 usleep_range(10, 50); 70 /*
71 * PWM Configuration register has SW_UPDATE bit that is set when a new
72 * configuration is written to the register. The bit is automatically
73 * cleared at the start of the next output cycle by the IP block.
74 *
75 * If one writes a new configuration to the register while it still has
76 * the bit enabled, PWM may freeze. That is, while one can still write
77 * to the register, it won't have an effect. Thus, we try to sleep long
78 * enough that the bit gets cleared and make sure the bit is not
79 * enabled while we update the configuration.
80 */
81 err = readl_poll_timeout(addr, val, !(val & PWM_SW_UPDATE), 40, ms);
82 if (err)
83 dev_err(pwm->chip->dev, "PWM_SW_UPDATE was not cleared\n");
84
85 return err;
88} 86}
89 87
90static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm, 88static inline int pwm_lpss_is_updating(struct pwm_device *pwm)
91 int duty_ns, int period_ns) 89{
90 return (pwm_lpss_read(pwm) & PWM_SW_UPDATE) ? -EBUSY : 0;
91}
92
93static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm,
94 int duty_ns, int period_ns)
92{ 95{
93 struct pwm_lpss_chip *lpwm = to_lpwm(chip);
94 unsigned long long on_time_div; 96 unsigned long long on_time_div;
95 unsigned long c = lpwm->info->clk_rate, base_unit_range; 97 unsigned long c = lpwm->info->clk_rate, base_unit_range;
96 unsigned long long base_unit, freq = NSEC_PER_SEC; 98 unsigned long long base_unit, freq = NSEC_PER_SEC;
@@ -102,62 +104,62 @@ static int pwm_lpss_config(struct pwm_chip *chip, struct pwm_device *pwm,
102 * The equation is: 104 * The equation is:
103 * base_unit = round(base_unit_range * freq / c) 105 * base_unit = round(base_unit_range * freq / c)
104 */ 106 */
105 base_unit_range = BIT(lpwm->info->base_unit_bits); 107 base_unit_range = BIT(lpwm->info->base_unit_bits) - 1;
106 freq *= base_unit_range; 108 freq *= base_unit_range;
107 109
108 base_unit = DIV_ROUND_CLOSEST_ULL(freq, c); 110 base_unit = DIV_ROUND_CLOSEST_ULL(freq, c);
109 111
110 if (duty_ns <= 0)
111 duty_ns = 1;
112 on_time_div = 255ULL * duty_ns; 112 on_time_div = 255ULL * duty_ns;
113 do_div(on_time_div, period_ns); 113 do_div(on_time_div, period_ns);
114 on_time_div = 255ULL - on_time_div; 114 on_time_div = 255ULL - on_time_div;
115 115
116 pm_runtime_get_sync(chip->dev);
117
118 ctrl = pwm_lpss_read(pwm); 116 ctrl = pwm_lpss_read(pwm);
119 ctrl &= ~PWM_ON_TIME_DIV_MASK; 117 ctrl &= ~PWM_ON_TIME_DIV_MASK;
120 ctrl &= ~((base_unit_range - 1) << PWM_BASE_UNIT_SHIFT); 118 ctrl &= ~(base_unit_range << PWM_BASE_UNIT_SHIFT);
121 base_unit &= (base_unit_range - 1); 119 base_unit &= base_unit_range;
122 ctrl |= (u32) base_unit << PWM_BASE_UNIT_SHIFT; 120 ctrl |= (u32) base_unit << PWM_BASE_UNIT_SHIFT;
123 ctrl |= on_time_div; 121 ctrl |= on_time_div;
124 pwm_lpss_write(pwm, ctrl); 122 pwm_lpss_write(pwm, ctrl);
125
126 /*
127 * If the PWM is already enabled we need to notify the hardware
128 * about the change by setting PWM_SW_UPDATE.
129 */
130 if (pwm_is_enabled(pwm))
131 pwm_lpss_update(pwm);
132
133 pm_runtime_put(chip->dev);
134
135 return 0;
136} 123}
137 124
138static int pwm_lpss_enable(struct pwm_chip *chip, struct pwm_device *pwm) 125static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm,
126 struct pwm_state *state)
139{ 127{
140 pm_runtime_get_sync(chip->dev); 128 struct pwm_lpss_chip *lpwm = to_lpwm(chip);
129 int ret;
141 130
142 /* 131 if (state->enabled) {
143 * Hardware must first see PWM_SW_UPDATE before the PWM can be 132 if (!pwm_is_enabled(pwm)) {
144 * enabled. 133 pm_runtime_get_sync(chip->dev);
145 */ 134 ret = pwm_lpss_is_updating(pwm);
146 pwm_lpss_update(pwm); 135 if (ret) {
147 pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE); 136 pm_runtime_put(chip->dev);
148 return 0; 137 return ret;
149} 138 }
139 pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period);
140 ret = pwm_lpss_update(pwm);
141 if (ret) {
142 pm_runtime_put(chip->dev);
143 return ret;
144 }
145 pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE);
146 } else {
147 ret = pwm_lpss_is_updating(pwm);
148 if (ret)
149 return ret;
150 pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period);
151 return pwm_lpss_update(pwm);
152 }
153 } else if (pwm_is_enabled(pwm)) {
154 pwm_lpss_write(pwm, pwm_lpss_read(pwm) & ~PWM_ENABLE);
155 pm_runtime_put(chip->dev);
156 }
150 157
151static void pwm_lpss_disable(struct pwm_chip *chip, struct pwm_device *pwm) 158 return 0;
152{
153 pwm_lpss_write(pwm, pwm_lpss_read(pwm) & ~PWM_ENABLE);
154 pm_runtime_put(chip->dev);
155} 159}
156 160
157static const struct pwm_ops pwm_lpss_ops = { 161static const struct pwm_ops pwm_lpss_ops = {
158 .config = pwm_lpss_config, 162 .apply = pwm_lpss_apply,
159 .enable = pwm_lpss_enable,
160 .disable = pwm_lpss_disable,
161 .owner = THIS_MODULE, 163 .owner = THIS_MODULE,
162}; 164};
163 165
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
index 04766e0d41aa..c94cd7c2695d 100644
--- a/drivers/pwm/pwm-lpss.h
+++ b/drivers/pwm/pwm-lpss.h
@@ -24,10 +24,6 @@ struct pwm_lpss_boardinfo {
24 unsigned long base_unit_bits; 24 unsigned long base_unit_bits;
25}; 25};
26 26
27extern const struct pwm_lpss_boardinfo pwm_lpss_byt_info;
28extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info;
29extern const struct pwm_lpss_boardinfo pwm_lpss_bxt_info;
30
31struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r, 27struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
32 const struct pwm_lpss_boardinfo *info); 28 const struct pwm_lpss_boardinfo *info);
33int pwm_lpss_remove(struct pwm_lpss_chip *lpwm); 29int pwm_lpss_remove(struct pwm_lpss_chip *lpwm);
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
index 9a596324ebef..a6017ad9926c 100644
--- a/drivers/pwm/pwm-mxs.c
+++ b/drivers/pwm/pwm-mxs.c
@@ -151,7 +151,7 @@ static int mxs_pwm_probe(struct platform_device *pdev)
151 mxs->chip.dev = &pdev->dev; 151 mxs->chip.dev = &pdev->dev;
152 mxs->chip.ops = &mxs_pwm_ops; 152 mxs->chip.ops = &mxs_pwm_ops;
153 mxs->chip.base = -1; 153 mxs->chip.base = -1;
154 mxs->chip.can_sleep = true; 154
155 ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm); 155 ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm);
156 if (ret < 0) { 156 if (ret < 0) {
157 dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret); 157 dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret);
diff --git a/drivers/pwm/pwm-pca9685.c b/drivers/pwm/pwm-pca9685.c
index 117fccf7934a..0cfb3571a732 100644
--- a/drivers/pwm/pwm-pca9685.c
+++ b/drivers/pwm/pwm-pca9685.c
@@ -20,8 +20,10 @@
20 */ 20 */
21 21
22#include <linux/acpi.h> 22#include <linux/acpi.h>
23#include <linux/gpio/driver.h>
23#include <linux/i2c.h> 24#include <linux/i2c.h>
24#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/mutex.h>
25#include <linux/platform_device.h> 27#include <linux/platform_device.h>
26#include <linux/property.h> 28#include <linux/property.h>
27#include <linux/pwm.h> 29#include <linux/pwm.h>
@@ -65,7 +67,6 @@
65#define PCA9685_MAXCHAN 0x10 67#define PCA9685_MAXCHAN 0x10
66 68
67#define LED_FULL (1 << 4) 69#define LED_FULL (1 << 4)
68#define MODE1_RESTART (1 << 7)
69#define MODE1_SLEEP (1 << 4) 70#define MODE1_SLEEP (1 << 4)
70#define MODE2_INVRT (1 << 4) 71#define MODE2_INVRT (1 << 4)
71#define MODE2_OUTDRV (1 << 2) 72#define MODE2_OUTDRV (1 << 2)
@@ -81,6 +82,10 @@ struct pca9685 {
81 int active_cnt; 82 int active_cnt;
82 int duty_ns; 83 int duty_ns;
83 int period_ns; 84 int period_ns;
85#if IS_ENABLED(CONFIG_GPIOLIB)
86 struct mutex lock;
87 struct gpio_chip gpio;
88#endif
84}; 89};
85 90
86static inline struct pca9685 *to_pca(struct pwm_chip *chip) 91static inline struct pca9685 *to_pca(struct pwm_chip *chip)
@@ -88,6 +93,151 @@ static inline struct pca9685 *to_pca(struct pwm_chip *chip)
88 return container_of(chip, struct pca9685, chip); 93 return container_of(chip, struct pca9685, chip);
89} 94}
90 95
96#if IS_ENABLED(CONFIG_GPIOLIB)
97static int pca9685_pwm_gpio_request(struct gpio_chip *gpio, unsigned int offset)
98{
99 struct pca9685 *pca = gpiochip_get_data(gpio);
100 struct pwm_device *pwm;
101
102 mutex_lock(&pca->lock);
103
104 pwm = &pca->chip.pwms[offset];
105
106 if (pwm->flags & (PWMF_REQUESTED | PWMF_EXPORTED)) {
107 mutex_unlock(&pca->lock);
108 return -EBUSY;
109 }
110
111 pwm_set_chip_data(pwm, (void *)1);
112
113 mutex_unlock(&pca->lock);
114 return 0;
115}
116
117static void pca9685_pwm_gpio_free(struct gpio_chip *gpio, unsigned int offset)
118{
119 struct pca9685 *pca = gpiochip_get_data(gpio);
120 struct pwm_device *pwm;
121
122 mutex_lock(&pca->lock);
123 pwm = &pca->chip.pwms[offset];
124 pwm_set_chip_data(pwm, NULL);
125 mutex_unlock(&pca->lock);
126}
127
128static bool pca9685_pwm_is_gpio(struct pca9685 *pca, struct pwm_device *pwm)
129{
130 bool is_gpio = false;
131
132 mutex_lock(&pca->lock);
133
134 if (pwm->hwpwm >= PCA9685_MAXCHAN) {
135 unsigned int i;
136
137 /*
138 * Check if any of the GPIOs are requested and in that case
139 * prevent using the "all LEDs" channel.
140 */
141 for (i = 0; i < pca->gpio.ngpio; i++)
142 if (gpiochip_is_requested(&pca->gpio, i)) {
143 is_gpio = true;
144 break;
145 }
146 } else if (pwm_get_chip_data(pwm)) {
147 is_gpio = true;
148 }
149
150 mutex_unlock(&pca->lock);
151 return is_gpio;
152}
153
154static int pca9685_pwm_gpio_get(struct gpio_chip *gpio, unsigned int offset)
155{
156 struct pca9685 *pca = gpiochip_get_data(gpio);
157 struct pwm_device *pwm = &pca->chip.pwms[offset];
158 unsigned int value;
159
160 regmap_read(pca->regmap, LED_N_ON_H(pwm->hwpwm), &value);
161
162 return value & LED_FULL;
163}
164
165static void pca9685_pwm_gpio_set(struct gpio_chip *gpio, unsigned int offset,
166 int value)
167{
168 struct pca9685 *pca = gpiochip_get_data(gpio);
169 struct pwm_device *pwm = &pca->chip.pwms[offset];
170 unsigned int on = value ? LED_FULL : 0;
171
172 /* Clear both OFF registers */
173 regmap_write(pca->regmap, LED_N_OFF_L(pwm->hwpwm), 0);
174 regmap_write(pca->regmap, LED_N_OFF_H(pwm->hwpwm), 0);
175
176 /* Set the full ON bit */
177 regmap_write(pca->regmap, LED_N_ON_H(pwm->hwpwm), on);
178}
179
180static int pca9685_pwm_gpio_get_direction(struct gpio_chip *chip,
181 unsigned int offset)
182{
183 /* Always out */
184 return 0;
185}
186
187static int pca9685_pwm_gpio_direction_input(struct gpio_chip *gpio,
188 unsigned int offset)
189{
190 return -EINVAL;
191}
192
193static int pca9685_pwm_gpio_direction_output(struct gpio_chip *gpio,
194 unsigned int offset, int value)
195{
196 pca9685_pwm_gpio_set(gpio, offset, value);
197
198 return 0;
199}
200
201/*
202 * The PCA9685 has a bit for turning the PWM output full off or on. Some
203 * boards like Intel Galileo actually uses these as normal GPIOs so we
204 * expose a GPIO chip here which can exclusively take over the underlying
205 * PWM channel.
206 */
207static int pca9685_pwm_gpio_probe(struct pca9685 *pca)
208{
209 struct device *dev = pca->chip.dev;
210
211 mutex_init(&pca->lock);
212
213 pca->gpio.label = dev_name(dev);
214 pca->gpio.parent = dev;
215 pca->gpio.request = pca9685_pwm_gpio_request;
216 pca->gpio.free = pca9685_pwm_gpio_free;
217 pca->gpio.get_direction = pca9685_pwm_gpio_get_direction;
218 pca->gpio.direction_input = pca9685_pwm_gpio_direction_input;
219 pca->gpio.direction_output = pca9685_pwm_gpio_direction_output;
220 pca->gpio.get = pca9685_pwm_gpio_get;
221 pca->gpio.set = pca9685_pwm_gpio_set;
222 pca->gpio.base = -1;
223 pca->gpio.ngpio = PCA9685_MAXCHAN;
224 pca->gpio.can_sleep = true;
225
226 return devm_gpiochip_add_data(dev, &pca->gpio, pca);
227}
228#else
229static inline bool pca9685_pwm_is_gpio(struct pca9685 *pca,
230 struct pwm_device *pwm)
231{
232 return false;
233}
234
235static inline int pca9685_pwm_gpio_probe(struct pca9685 *pca)
236{
237 return 0;
238}
239#endif
240
91static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, 241static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
92 int duty_ns, int period_ns) 242 int duty_ns, int period_ns)
93{ 243{
@@ -117,16 +267,6 @@ static int pca9685_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
117 udelay(500); 267 udelay(500);
118 268
119 pca->period_ns = period_ns; 269 pca->period_ns = period_ns;
120
121 /*
122 * If the duty cycle did not change, restart PWM with
123 * the same duty cycle to period ratio and return.
124 */
125 if (duty_ns == pca->duty_ns) {
126 regmap_update_bits(pca->regmap, PCA9685_MODE1,
127 MODE1_RESTART, 0x1);
128 return 0;
129 }
130 } else { 270 } else {
131 dev_err(chip->dev, 271 dev_err(chip->dev,
132 "prescaler not set: period out of bounds!\n"); 272 "prescaler not set: period out of bounds!\n");
@@ -264,6 +404,9 @@ static int pca9685_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
264{ 404{
265 struct pca9685 *pca = to_pca(chip); 405 struct pca9685 *pca = to_pca(chip);
266 406
407 if (pca9685_pwm_is_gpio(pca, pwm))
408 return -EBUSY;
409
267 if (pca->active_cnt++ == 0) 410 if (pca->active_cnt++ == 0)
268 return regmap_update_bits(pca->regmap, PCA9685_MODE1, 411 return regmap_update_bits(pca->regmap, PCA9685_MODE1,
269 MODE1_SLEEP, 0x0); 412 MODE1_SLEEP, 0x0);
@@ -343,9 +486,16 @@ static int pca9685_pwm_probe(struct i2c_client *client,
343 486
344 pca->chip.dev = &client->dev; 487 pca->chip.dev = &client->dev;
345 pca->chip.base = -1; 488 pca->chip.base = -1;
346 pca->chip.can_sleep = true;
347 489
348 return pwmchip_add(&pca->chip); 490 ret = pwmchip_add(&pca->chip);
491 if (ret < 0)
492 return ret;
493
494 ret = pca9685_pwm_gpio_probe(pca);
495 if (ret < 0)
496 pwmchip_remove(&pca->chip);
497
498 return ret;
349} 499}
350 500
351static int pca9685_pwm_remove(struct i2c_client *client) 501static int pca9685_pwm_remove(struct i2c_client *client)
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c
index 58b709f29130..4143a46684d2 100644
--- a/drivers/pwm/pwm-pxa.c
+++ b/drivers/pwm/pwm-pxa.c
@@ -118,7 +118,7 @@ static void pxa_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
118 clk_disable_unprepare(pc->clk); 118 clk_disable_unprepare(pc->clk);
119} 119}
120 120
121static struct pwm_ops pxa_pwm_ops = { 121static const struct pwm_ops pxa_pwm_ops = {
122 .config = pxa_pwm_config, 122 .config = pxa_pwm_config,
123 .enable = pxa_pwm_enable, 123 .enable = pxa_pwm_enable,
124 .disable = pxa_pwm_disable, 124 .disable = pxa_pwm_disable,
diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c
index dd82dc840af9..2b7c31c9d1ab 100644
--- a/drivers/pwm/pwm-sti.c
+++ b/drivers/pwm/pwm-sti.c
@@ -635,7 +635,6 @@ skip_cpt:
635 pc->chip.ops = &sti_pwm_ops; 635 pc->chip.ops = &sti_pwm_ops;
636 pc->chip.base = -1; 636 pc->chip.base = -1;
637 pc->chip.npwm = pc->cdata->pwm_num_devs; 637 pc->chip.npwm = pc->cdata->pwm_num_devs;
638 pc->chip.can_sleep = true;
639 638
640 ret = pwmchip_add(&pc->chip); 639 ret = pwmchip_add(&pc->chip);
641 if (ret < 0) { 640 if (ret < 0) {
diff --git a/drivers/pwm/pwm-sun4i.c b/drivers/pwm/pwm-sun4i.c
index b0803f6c64d9..1284ffa05921 100644
--- a/drivers/pwm/pwm-sun4i.c
+++ b/drivers/pwm/pwm-sun4i.c
@@ -340,7 +340,6 @@ static int sun4i_pwm_probe(struct platform_device *pdev)
340 pwm->chip.ops = &sun4i_pwm_ops; 340 pwm->chip.ops = &sun4i_pwm_ops;
341 pwm->chip.base = -1; 341 pwm->chip.base = -1;
342 pwm->chip.npwm = pwm->data->npwm; 342 pwm->chip.npwm = pwm->data->npwm;
343 pwm->chip.can_sleep = true;
344 pwm->chip.of_xlate = of_pwm_xlate_with_flags; 343 pwm->chip.of_xlate = of_pwm_xlate_with_flags;
345 pwm->chip.of_pwm_n_cells = 3; 344 pwm->chip.of_pwm_n_cells = 3;
346 345
diff --git a/drivers/pwm/pwm-twl-led.c b/drivers/pwm/pwm-twl-led.c
index b964470025c5..21eff991d0e3 100644
--- a/drivers/pwm/pwm-twl-led.c
+++ b/drivers/pwm/pwm-twl-led.c
@@ -303,7 +303,6 @@ static int twl_pwmled_probe(struct platform_device *pdev)
303 303
304 twl->chip.dev = &pdev->dev; 304 twl->chip.dev = &pdev->dev;
305 twl->chip.base = -1; 305 twl->chip.base = -1;
306 twl->chip.can_sleep = true;
307 306
308 mutex_init(&twl->mutex); 307 mutex_init(&twl->mutex);
309 308
diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
index 7a993b056638..9de617b76680 100644
--- a/drivers/pwm/pwm-twl.c
+++ b/drivers/pwm/pwm-twl.c
@@ -323,7 +323,6 @@ static int twl_pwm_probe(struct platform_device *pdev)
323 twl->chip.dev = &pdev->dev; 323 twl->chip.dev = &pdev->dev;
324 twl->chip.base = -1; 324 twl->chip.base = -1;
325 twl->chip.npwm = 2; 325 twl->chip.npwm = 2;
326 twl->chip.can_sleep = true;
327 326
328 mutex_init(&twl->mutex); 327 mutex_init(&twl->mutex);
329 328
diff --git a/drivers/pwm/pwm-vt8500.c b/drivers/pwm/pwm-vt8500.c
index cdb58fd4619d..8141a4984126 100644
--- a/drivers/pwm/pwm-vt8500.c
+++ b/drivers/pwm/pwm-vt8500.c
@@ -184,7 +184,7 @@ static int vt8500_pwm_set_polarity(struct pwm_chip *chip,
184 return 0; 184 return 0;
185} 185}
186 186
187static struct pwm_ops vt8500_pwm_ops = { 187static const struct pwm_ops vt8500_pwm_ops = {
188 .enable = vt8500_pwm_enable, 188 .enable = vt8500_pwm_enable,
189 .disable = vt8500_pwm_disable, 189 .disable = vt8500_pwm_disable,
190 .config = vt8500_pwm_config, 190 .config = vt8500_pwm_config,
diff --git a/drivers/staging/greybus/pwm.c b/drivers/staging/greybus/pwm.c
index c4bf3298ba07..f0404bc37123 100644
--- a/drivers/staging/greybus/pwm.c
+++ b/drivers/staging/greybus/pwm.c
@@ -284,7 +284,6 @@ static int gb_pwm_probe(struct gbphy_device *gbphy_dev,
284 pwm->ops = &gb_pwm_ops; 284 pwm->ops = &gb_pwm_ops;
285 pwm->base = -1; /* Allocate base dynamically */ 285 pwm->base = -1; /* Allocate base dynamically */
286 pwm->npwm = pwmc->pwm_max + 1; 286 pwm->npwm = pwmc->pwm_max + 1;
287 pwm->can_sleep = true; /* FIXME */
288 287
289 ret = pwmchip_add(pwm); 288 ret = pwmchip_add(pwm);
290 if (ret) { 289 if (ret) {
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index c2c056cc7ea5..776b34396144 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -245,6 +245,15 @@ config RCAR_THERMAL
245 Enable this to plug the R-Car thermal sensor driver into the Linux 245 Enable this to plug the R-Car thermal sensor driver into the Linux
246 thermal framework. 246 thermal framework.
247 247
248config RCAR_GEN3_THERMAL
249 tristate "Renesas R-Car Gen3 thermal driver"
250 depends on ARCH_RENESAS || COMPILE_TEST
251 depends on HAS_IOMEM
252 depends on OF
253 help
254 Enable this to plug the R-Car Gen3 thermal sensor driver into the Linux
255 thermal framework.
256
248config KIRKWOOD_THERMAL 257config KIRKWOOD_THERMAL
249 tristate "Temperature sensor on Marvell Kirkwood SoCs" 258 tristate "Temperature sensor on Marvell Kirkwood SoCs"
250 depends on MACH_KIRKWOOD || COMPILE_TEST 259 depends on MACH_KIRKWOOD || COMPILE_TEST
@@ -436,4 +445,12 @@ depends on (ARCH_QCOM && OF) || COMPILE_TEST
436source "drivers/thermal/qcom/Kconfig" 445source "drivers/thermal/qcom/Kconfig"
437endmenu 446endmenu
438 447
448config ZX2967_THERMAL
449 tristate "Thermal sensors on zx2967 SoC"
450 depends on ARCH_ZX || COMPILE_TEST
451 help
452 Enable the zx2967 thermal sensors driver, which supports
453 the primitive temperature sensor embedded in zx2967 SoCs.
454 This sensor generates the real time die temperature.
455
439endif 456endif
diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
index 6a3d7b573036..7adae2029355 100644
--- a/drivers/thermal/Makefile
+++ b/drivers/thermal/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_QCOM_SPMI_TEMP_ALARM) += qcom-spmi-temp-alarm.o
31obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o 31obj-$(CONFIG_SPEAR_THERMAL) += spear_thermal.o
32obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o 32obj-$(CONFIG_ROCKCHIP_THERMAL) += rockchip_thermal.o
33obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o 33obj-$(CONFIG_RCAR_THERMAL) += rcar_thermal.o
34obj-$(CONFIG_RCAR_GEN3_THERMAL) += rcar_gen3_thermal.o
34obj-$(CONFIG_KIRKWOOD_THERMAL) += kirkwood_thermal.o 35obj-$(CONFIG_KIRKWOOD_THERMAL) += kirkwood_thermal.o
35obj-y += samsung/ 36obj-y += samsung/
36obj-$(CONFIG_DOVE_THERMAL) += dove_thermal.o 37obj-$(CONFIG_DOVE_THERMAL) += dove_thermal.o
@@ -56,3 +57,4 @@ obj-$(CONFIG_TEGRA_SOCTHERM) += tegra/
56obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o 57obj-$(CONFIG_HISI_THERMAL) += hisi_thermal.o
57obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o 58obj-$(CONFIG_MTK_THERMAL) += mtk_thermal.o
58obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o 59obj-$(CONFIG_GENERIC_ADC_THERMAL) += thermal-generic-adc.o
60obj-$(CONFIG_ZX2967_THERMAL) += zx2967_thermal.o
diff --git a/drivers/thermal/clock_cooling.c b/drivers/thermal/clock_cooling.c
index ed5dd0e88657..56711c25584d 100644
--- a/drivers/thermal/clock_cooling.c
+++ b/drivers/thermal/clock_cooling.c
@@ -65,42 +65,7 @@ struct clock_cooling_device {
65}; 65};
66#define to_clock_cooling_device(x) \ 66#define to_clock_cooling_device(x) \
67 container_of(x, struct clock_cooling_device, clk_rate_change_nb) 67 container_of(x, struct clock_cooling_device, clk_rate_change_nb)
68static DEFINE_IDR(clock_idr); 68static DEFINE_IDA(clock_ida);
69static DEFINE_MUTEX(cooling_clock_lock);
70
71/**
72 * clock_cooling_get_idr - function to get an unique id.
73 * @id: int * value generated by this function.
74 *
75 * This function will populate @id with an unique
76 * id, using the idr API.
77 *
78 * Return: 0 on success, an error code on failure.
79 */
80static int clock_cooling_get_idr(int *id)
81{
82 int ret;
83
84 mutex_lock(&cooling_clock_lock);
85 ret = idr_alloc(&clock_idr, NULL, 0, 0, GFP_KERNEL);
86 mutex_unlock(&cooling_clock_lock);
87 if (unlikely(ret < 0))
88 return ret;
89 *id = ret;
90
91 return 0;
92}
93
94/**
95 * release_idr - function to free the unique id.
96 * @id: int value representing the unique id.
97 */
98static void release_idr(int id)
99{
100 mutex_lock(&cooling_clock_lock);
101 idr_remove(&clock_idr, id);
102 mutex_unlock(&cooling_clock_lock);
103}
104 69
105/* Below code defines functions to be used for clock as cooling device */ 70/* Below code defines functions to be used for clock as cooling device */
106 71
@@ -432,16 +397,17 @@ clock_cooling_register(struct device *dev, const char *clock_name)
432 if (IS_ERR(ccdev->clk)) 397 if (IS_ERR(ccdev->clk))
433 return ERR_CAST(ccdev->clk); 398 return ERR_CAST(ccdev->clk);
434 399
435 ret = clock_cooling_get_idr(&ccdev->id); 400 ret = ida_simple_get(&clock_ida, 0, 0, GFP_KERNEL);
436 if (ret) 401 if (ret < 0)
437 return ERR_PTR(-EINVAL); 402 return ERR_PTR(ret);
403 ccdev->id = ret;
438 404
439 snprintf(dev_name, sizeof(dev_name), "thermal-clock-%d", ccdev->id); 405 snprintf(dev_name, sizeof(dev_name), "thermal-clock-%d", ccdev->id);
440 406
441 cdev = thermal_cooling_device_register(dev_name, ccdev, 407 cdev = thermal_cooling_device_register(dev_name, ccdev,
442 &clock_cooling_ops); 408 &clock_cooling_ops);
443 if (IS_ERR(cdev)) { 409 if (IS_ERR(cdev)) {
444 release_idr(ccdev->id); 410 ida_simple_remove(&clock_ida, ccdev->id);
445 return ERR_PTR(-EINVAL); 411 return ERR_PTR(-EINVAL);
446 } 412 }
447 ccdev->cdev = cdev; 413 ccdev->cdev = cdev;
@@ -450,7 +416,7 @@ clock_cooling_register(struct device *dev, const char *clock_name)
450 /* Assuming someone has already filled the opp table for this device */ 416 /* Assuming someone has already filled the opp table for this device */
451 ret = dev_pm_opp_init_cpufreq_table(dev, &ccdev->freq_table); 417 ret = dev_pm_opp_init_cpufreq_table(dev, &ccdev->freq_table);
452 if (ret) { 418 if (ret) {
453 release_idr(ccdev->id); 419 ida_simple_remove(&clock_ida, ccdev->id);
454 return ERR_PTR(ret); 420 return ERR_PTR(ret);
455 } 421 }
456 ccdev->clock_state = 0; 422 ccdev->clock_state = 0;
@@ -481,6 +447,6 @@ void clock_cooling_unregister(struct thermal_cooling_device *cdev)
481 dev_pm_opp_free_cpufreq_table(ccdev->dev, &ccdev->freq_table); 447 dev_pm_opp_free_cpufreq_table(ccdev->dev, &ccdev->freq_table);
482 448
483 thermal_cooling_device_unregister(ccdev->cdev); 449 thermal_cooling_device_unregister(ccdev->cdev);
484 release_idr(ccdev->id); 450 ida_simple_remove(&clock_ida, ccdev->id);
485} 451}
486EXPORT_SYMBOL_GPL(clock_cooling_unregister); 452EXPORT_SYMBOL_GPL(clock_cooling_unregister);
diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index 85fdbf762fa0..91048eeca28b 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -26,6 +26,7 @@
26#include <linux/thermal.h> 26#include <linux/thermal.h>
27#include <linux/cpufreq.h> 27#include <linux/cpufreq.h>
28#include <linux/err.h> 28#include <linux/err.h>
29#include <linux/idr.h>
29#include <linux/pm_opp.h> 30#include <linux/pm_opp.h>
30#include <linux/slab.h> 31#include <linux/slab.h>
31#include <linux/cpu.h> 32#include <linux/cpu.h>
@@ -104,50 +105,13 @@ struct cpufreq_cooling_device {
104 struct device *cpu_dev; 105 struct device *cpu_dev;
105 get_static_t plat_get_static_power; 106 get_static_t plat_get_static_power;
106}; 107};
107static DEFINE_IDR(cpufreq_idr); 108static DEFINE_IDA(cpufreq_ida);
108static DEFINE_MUTEX(cooling_cpufreq_lock);
109 109
110static unsigned int cpufreq_dev_count; 110static unsigned int cpufreq_dev_count;
111 111
112static DEFINE_MUTEX(cooling_list_lock); 112static DEFINE_MUTEX(cooling_list_lock);
113static LIST_HEAD(cpufreq_dev_list); 113static LIST_HEAD(cpufreq_dev_list);
114 114
115/**
116 * get_idr - function to get a unique id.
117 * @idr: struct idr * handle used to create a id.
118 * @id: int * value generated by this function.
119 *
120 * This function will populate @id with an unique
121 * id, using the idr API.
122 *
123 * Return: 0 on success, an error code on failure.
124 */
125static int get_idr(struct idr *idr, int *id)
126{
127 int ret;
128
129 mutex_lock(&cooling_cpufreq_lock);
130 ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
131 mutex_unlock(&cooling_cpufreq_lock);
132 if (unlikely(ret < 0))
133 return ret;
134 *id = ret;
135
136 return 0;
137}
138
139/**
140 * release_idr - function to free the unique id.
141 * @idr: struct idr * handle used for creating the id.
142 * @id: int value representing the unique id.
143 */
144static void release_idr(struct idr *idr, int id)
145{
146 mutex_lock(&cooling_cpufreq_lock);
147 idr_remove(idr, id);
148 mutex_unlock(&cooling_cpufreq_lock);
149}
150
151/* Below code defines functions to be used for cpufreq as cooling device */ 115/* Below code defines functions to be used for cpufreq as cooling device */
152 116
153/** 117/**
@@ -645,31 +609,39 @@ static int cpufreq_state2power(struct thermal_cooling_device *cdev,
645 unsigned long state, u32 *power) 609 unsigned long state, u32 *power)
646{ 610{
647 unsigned int freq, num_cpus; 611 unsigned int freq, num_cpus;
648 cpumask_t cpumask; 612 cpumask_var_t cpumask;
649 u32 static_power, dynamic_power; 613 u32 static_power, dynamic_power;
650 int ret; 614 int ret;
651 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; 615 struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
652 616
653 cpumask_and(&cpumask, &cpufreq_device->allowed_cpus, cpu_online_mask); 617 if (!alloc_cpumask_var(&cpumask, GFP_KERNEL))
654 num_cpus = cpumask_weight(&cpumask); 618 return -ENOMEM;
619
620 cpumask_and(cpumask, &cpufreq_device->allowed_cpus, cpu_online_mask);
621 num_cpus = cpumask_weight(cpumask);
655 622
656 /* None of our cpus are online, so no power */ 623 /* None of our cpus are online, so no power */
657 if (num_cpus == 0) { 624 if (num_cpus == 0) {
658 *power = 0; 625 *power = 0;
659 return 0; 626 ret = 0;
627 goto out;
660 } 628 }
661 629
662 freq = cpufreq_device->freq_table[state]; 630 freq = cpufreq_device->freq_table[state];
663 if (!freq) 631 if (!freq) {
664 return -EINVAL; 632 ret = -EINVAL;
633 goto out;
634 }
665 635
666 dynamic_power = cpu_freq_to_power(cpufreq_device, freq) * num_cpus; 636 dynamic_power = cpu_freq_to_power(cpufreq_device, freq) * num_cpus;
667 ret = get_static_power(cpufreq_device, tz, freq, &static_power); 637 ret = get_static_power(cpufreq_device, tz, freq, &static_power);
668 if (ret) 638 if (ret)
669 return ret; 639 goto out;
670 640
671 *power = static_power + dynamic_power; 641 *power = static_power + dynamic_power;
672 return 0; 642out:
643 free_cpumask_var(cpumask);
644 return ret;
673} 645}
674 646
675/** 647/**
@@ -795,16 +767,20 @@ __cpufreq_cooling_register(struct device_node *np,
795 struct cpufreq_cooling_device *cpufreq_dev; 767 struct cpufreq_cooling_device *cpufreq_dev;
796 char dev_name[THERMAL_NAME_LENGTH]; 768 char dev_name[THERMAL_NAME_LENGTH];
797 struct cpufreq_frequency_table *pos, *table; 769 struct cpufreq_frequency_table *pos, *table;
798 struct cpumask temp_mask; 770 cpumask_var_t temp_mask;
799 unsigned int freq, i, num_cpus; 771 unsigned int freq, i, num_cpus;
800 int ret; 772 int ret;
801 struct thermal_cooling_device_ops *cooling_ops; 773 struct thermal_cooling_device_ops *cooling_ops;
802 774
803 cpumask_and(&temp_mask, clip_cpus, cpu_online_mask); 775 if (!alloc_cpumask_var(&temp_mask, GFP_KERNEL))
804 policy = cpufreq_cpu_get(cpumask_first(&temp_mask)); 776 return ERR_PTR(-ENOMEM);
777
778 cpumask_and(temp_mask, clip_cpus, cpu_online_mask);
779 policy = cpufreq_cpu_get(cpumask_first(temp_mask));
805 if (!policy) { 780 if (!policy) {
806 pr_debug("%s: CPUFreq policy not found\n", __func__); 781 pr_debug("%s: CPUFreq policy not found\n", __func__);
807 return ERR_PTR(-EPROBE_DEFER); 782 cool_dev = ERR_PTR(-EPROBE_DEFER);
783 goto free_cpumask;
808 } 784 }
809 785
810 table = policy->freq_table; 786 table = policy->freq_table;
@@ -867,11 +843,12 @@ __cpufreq_cooling_register(struct device_node *np,
867 cooling_ops = &cpufreq_cooling_ops; 843 cooling_ops = &cpufreq_cooling_ops;
868 } 844 }
869 845
870 ret = get_idr(&cpufreq_idr, &cpufreq_dev->id); 846 ret = ida_simple_get(&cpufreq_ida, 0, 0, GFP_KERNEL);
871 if (ret) { 847 if (ret < 0) {
872 cool_dev = ERR_PTR(ret); 848 cool_dev = ERR_PTR(ret);
873 goto free_power_table; 849 goto free_power_table;
874 } 850 }
851 cpufreq_dev->id = ret;
875 852
876 /* Fill freq-table in descending order of frequencies */ 853 /* Fill freq-table in descending order of frequencies */
877 for (i = 0, freq = -1; i <= cpufreq_dev->max_level; i++) { 854 for (i = 0, freq = -1; i <= cpufreq_dev->max_level; i++) {
@@ -891,27 +868,24 @@ __cpufreq_cooling_register(struct device_node *np,
891 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev, 868 cool_dev = thermal_of_cooling_device_register(np, dev_name, cpufreq_dev,
892 cooling_ops); 869 cooling_ops);
893 if (IS_ERR(cool_dev)) 870 if (IS_ERR(cool_dev))
894 goto remove_idr; 871 goto remove_ida;
895 872
896 cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0]; 873 cpufreq_dev->clipped_freq = cpufreq_dev->freq_table[0];
897 cpufreq_dev->cool_dev = cool_dev; 874 cpufreq_dev->cool_dev = cool_dev;
898 875
899 mutex_lock(&cooling_cpufreq_lock);
900
901 mutex_lock(&cooling_list_lock); 876 mutex_lock(&cooling_list_lock);
902 list_add(&cpufreq_dev->node, &cpufreq_dev_list); 877 list_add(&cpufreq_dev->node, &cpufreq_dev_list);
903 mutex_unlock(&cooling_list_lock);
904 878
905 /* Register the notifier for first cpufreq cooling device */ 879 /* Register the notifier for first cpufreq cooling device */
906 if (!cpufreq_dev_count++) 880 if (!cpufreq_dev_count++)
907 cpufreq_register_notifier(&thermal_cpufreq_notifier_block, 881 cpufreq_register_notifier(&thermal_cpufreq_notifier_block,
908 CPUFREQ_POLICY_NOTIFIER); 882 CPUFREQ_POLICY_NOTIFIER);
909 mutex_unlock(&cooling_cpufreq_lock); 883 mutex_unlock(&cooling_list_lock);
910 884
911 goto put_policy; 885 goto put_policy;
912 886
913remove_idr: 887remove_ida:
914 release_idr(&cpufreq_idr, cpufreq_dev->id); 888 ida_simple_remove(&cpufreq_ida, cpufreq_dev->id);
915free_power_table: 889free_power_table:
916 kfree(cpufreq_dev->dyn_power_table); 890 kfree(cpufreq_dev->dyn_power_table);
917free_table: 891free_table:
@@ -924,7 +898,8 @@ free_cdev:
924 kfree(cpufreq_dev); 898 kfree(cpufreq_dev);
925put_policy: 899put_policy:
926 cpufreq_cpu_put(policy); 900 cpufreq_cpu_put(policy);
927 901free_cpumask:
902 free_cpumask_var(temp_mask);
928 return cool_dev; 903 return cool_dev;
929} 904}
930 905
@@ -1052,20 +1027,17 @@ void cpufreq_cooling_unregister(struct thermal_cooling_device *cdev)
1052 1027
1053 cpufreq_dev = cdev->devdata; 1028 cpufreq_dev = cdev->devdata;
1054 1029
1030 mutex_lock(&cooling_list_lock);
1055 /* Unregister the notifier for the last cpufreq cooling device */ 1031 /* Unregister the notifier for the last cpufreq cooling device */
1056 mutex_lock(&cooling_cpufreq_lock);
1057 if (!--cpufreq_dev_count) 1032 if (!--cpufreq_dev_count)
1058 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block, 1033 cpufreq_unregister_notifier(&thermal_cpufreq_notifier_block,
1059 CPUFREQ_POLICY_NOTIFIER); 1034 CPUFREQ_POLICY_NOTIFIER);
1060 1035
1061 mutex_lock(&cooling_list_lock);
1062 list_del(&cpufreq_dev->node); 1036 list_del(&cpufreq_dev->node);
1063 mutex_unlock(&cooling_list_lock); 1037 mutex_unlock(&cooling_list_lock);
1064 1038
1065 mutex_unlock(&cooling_cpufreq_lock);
1066
1067 thermal_cooling_device_unregister(cpufreq_dev->cool_dev); 1039 thermal_cooling_device_unregister(cpufreq_dev->cool_dev);
1068 release_idr(&cpufreq_idr, cpufreq_dev->id); 1040 ida_simple_remove(&cpufreq_ida, cpufreq_dev->id);
1069 kfree(cpufreq_dev->dyn_power_table); 1041 kfree(cpufreq_dev->dyn_power_table);
1070 kfree(cpufreq_dev->time_in_idle_timestamp); 1042 kfree(cpufreq_dev->time_in_idle_timestamp);
1071 kfree(cpufreq_dev->time_in_idle); 1043 kfree(cpufreq_dev->time_in_idle);
diff --git a/drivers/thermal/devfreq_cooling.c b/drivers/thermal/devfreq_cooling.c
index ba7a5cd994dc..7743a78d4723 100644
--- a/drivers/thermal/devfreq_cooling.c
+++ b/drivers/thermal/devfreq_cooling.c
@@ -21,14 +21,14 @@
21#include <linux/devfreq.h> 21#include <linux/devfreq.h>
22#include <linux/devfreq_cooling.h> 22#include <linux/devfreq_cooling.h>
23#include <linux/export.h> 23#include <linux/export.h>
24#include <linux/idr.h>
24#include <linux/slab.h> 25#include <linux/slab.h>
25#include <linux/pm_opp.h> 26#include <linux/pm_opp.h>
26#include <linux/thermal.h> 27#include <linux/thermal.h>
27 28
28#include <trace/events/thermal.h> 29#include <trace/events/thermal.h>
29 30
30static DEFINE_MUTEX(devfreq_lock); 31static DEFINE_IDA(devfreq_ida);
31static DEFINE_IDR(devfreq_idr);
32 32
33/** 33/**
34 * struct devfreq_cooling_device - Devfreq cooling device 34 * struct devfreq_cooling_device - Devfreq cooling device
@@ -58,42 +58,6 @@ struct devfreq_cooling_device {
58}; 58};
59 59
60/** 60/**
61 * get_idr - function to get a unique id.
62 * @idr: struct idr * handle used to create a id.
63 * @id: int * value generated by this function.
64 *
65 * This function will populate @id with an unique
66 * id, using the idr API.
67 *
68 * Return: 0 on success, an error code on failure.
69 */
70static int get_idr(struct idr *idr, int *id)
71{
72 int ret;
73
74 mutex_lock(&devfreq_lock);
75 ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
76 mutex_unlock(&devfreq_lock);
77 if (unlikely(ret < 0))
78 return ret;
79 *id = ret;
80
81 return 0;
82}
83
84/**
85 * release_idr - function to free the unique id.
86 * @idr: struct idr * handle used for creating the id.
87 * @id: int value representing the unique id.
88 */
89static void release_idr(struct idr *idr, int id)
90{
91 mutex_lock(&devfreq_lock);
92 idr_remove(idr, id);
93 mutex_unlock(&devfreq_lock);
94}
95
96/**
97 * partition_enable_opps() - disable all opps above a given state 61 * partition_enable_opps() - disable all opps above a given state
98 * @dfc: Pointer to devfreq we are operating on 62 * @dfc: Pointer to devfreq we are operating on
99 * @cdev_state: cooling device state we're setting 63 * @cdev_state: cooling device state we're setting
@@ -489,9 +453,10 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
489 if (err) 453 if (err)
490 goto free_dfc; 454 goto free_dfc;
491 455
492 err = get_idr(&devfreq_idr, &dfc->id); 456 err = ida_simple_get(&devfreq_ida, 0, 0, GFP_KERNEL);
493 if (err) 457 if (err < 0)
494 goto free_tables; 458 goto free_tables;
459 dfc->id = err;
495 460
496 snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id); 461 snprintf(dev_name, sizeof(dev_name), "thermal-devfreq-%d", dfc->id);
497 462
@@ -502,15 +467,15 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
502 dev_err(df->dev.parent, 467 dev_err(df->dev.parent,
503 "Failed to register devfreq cooling device (%d)\n", 468 "Failed to register devfreq cooling device (%d)\n",
504 err); 469 err);
505 goto release_idr; 470 goto release_ida;
506 } 471 }
507 472
508 dfc->cdev = cdev; 473 dfc->cdev = cdev;
509 474
510 return cdev; 475 return cdev;
511 476
512release_idr: 477release_ida:
513 release_idr(&devfreq_idr, dfc->id); 478 ida_simple_remove(&devfreq_ida, dfc->id);
514free_tables: 479free_tables:
515 kfree(dfc->power_table); 480 kfree(dfc->power_table);
516 kfree(dfc->freq_table); 481 kfree(dfc->freq_table);
@@ -558,7 +523,7 @@ void devfreq_cooling_unregister(struct thermal_cooling_device *cdev)
558 dfc = cdev->devdata; 523 dfc = cdev->devdata;
559 524
560 thermal_cooling_device_unregister(dfc->cdev); 525 thermal_cooling_device_unregister(dfc->cdev);
561 release_idr(&devfreq_idr, dfc->id); 526 ida_simple_remove(&devfreq_ida, dfc->id);
562 kfree(dfc->power_table); 527 kfree(dfc->power_table);
563 kfree(dfc->freq_table); 528 kfree(dfc->freq_table);
564 529
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 06912f0602b7..fb648a45754e 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -489,6 +489,10 @@ static int imx_thermal_probe(struct platform_device *pdev)
489 data->tempmon = map; 489 data->tempmon = map;
490 490
491 data->socdata = of_device_get_match_data(&pdev->dev); 491 data->socdata = of_device_get_match_data(&pdev->dev);
492 if (!data->socdata) {
493 dev_err(&pdev->dev, "no device match found\n");
494 return -ENODEV;
495 }
492 496
493 /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */ 497 /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */
494 if (data->socdata->version == TEMPMON_IMX6SX) { 498 if (data->socdata->version == TEMPMON_IMX6SX) {
diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index df64692e9e64..a47103a659fa 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -461,16 +461,13 @@ static void poll_pkg_cstate(struct work_struct *dummy)
461{ 461{
462 static u64 msr_last; 462 static u64 msr_last;
463 static u64 tsc_last; 463 static u64 tsc_last;
464 static unsigned long jiffies_last;
465 464
466 u64 msr_now; 465 u64 msr_now;
467 unsigned long jiffies_now;
468 u64 tsc_now; 466 u64 tsc_now;
469 u64 val64; 467 u64 val64;
470 468
471 msr_now = pkg_state_counter(); 469 msr_now = pkg_state_counter();
472 tsc_now = rdtsc(); 470 tsc_now = rdtsc();
473 jiffies_now = jiffies;
474 471
475 /* calculate pkg cstate vs tsc ratio */ 472 /* calculate pkg cstate vs tsc ratio */
476 if (!msr_last || !tsc_last) 473 if (!msr_last || !tsc_last)
@@ -485,7 +482,6 @@ static void poll_pkg_cstate(struct work_struct *dummy)
485 482
486 /* update record */ 483 /* update record */
487 msr_last = msr_now; 484 msr_last = msr_now;
488 jiffies_last = jiffies_now;
489 tsc_last = tsc_now; 485 tsc_last = tsc_now;
490 486
491 if (true == clamping) 487 if (true == clamping)
diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index 34169c32d495..1aff7fde54b1 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -183,37 +183,37 @@ struct mtk_thermal {
183}; 183};
184 184
185/* MT8173 thermal sensor data */ 185/* MT8173 thermal sensor data */
186const int mt8173_bank_data[MT8173_NUM_ZONES][3] = { 186static const int mt8173_bank_data[MT8173_NUM_ZONES][3] = {
187 { MT8173_TS2, MT8173_TS3 }, 187 { MT8173_TS2, MT8173_TS3 },
188 { MT8173_TS2, MT8173_TS4 }, 188 { MT8173_TS2, MT8173_TS4 },
189 { MT8173_TS1, MT8173_TS2, MT8173_TSABB }, 189 { MT8173_TS1, MT8173_TS2, MT8173_TSABB },
190 { MT8173_TS2 }, 190 { MT8173_TS2 },
191}; 191};
192 192
193const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = { 193static const int mt8173_msr[MT8173_NUM_SENSORS_PER_ZONE] = {
194 TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2 194 TEMP_MSR0, TEMP_MSR1, TEMP_MSR2, TEMP_MSR2
195}; 195};
196 196
197const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = { 197static const int mt8173_adcpnp[MT8173_NUM_SENSORS_PER_ZONE] = {
198 TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2, TEMP_ADCPNP3 198 TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2, TEMP_ADCPNP3
199}; 199};
200 200
201const int mt8173_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 }; 201static const int mt8173_mux_values[MT8173_NUM_SENSORS] = { 0, 1, 2, 3, 16 };
202 202
203/* MT2701 thermal sensor data */ 203/* MT2701 thermal sensor data */
204const int mt2701_bank_data[MT2701_NUM_SENSORS] = { 204static const int mt2701_bank_data[MT2701_NUM_SENSORS] = {
205 MT2701_TS1, MT2701_TS2, MT2701_TSABB 205 MT2701_TS1, MT2701_TS2, MT2701_TSABB
206}; 206};
207 207
208const int mt2701_msr[MT2701_NUM_SENSORS_PER_ZONE] = { 208static const int mt2701_msr[MT2701_NUM_SENSORS_PER_ZONE] = {
209 TEMP_MSR0, TEMP_MSR1, TEMP_MSR2 209 TEMP_MSR0, TEMP_MSR1, TEMP_MSR2
210}; 210};
211 211
212const int mt2701_adcpnp[MT2701_NUM_SENSORS_PER_ZONE] = { 212static const int mt2701_adcpnp[MT2701_NUM_SENSORS_PER_ZONE] = {
213 TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2 213 TEMP_ADCPNP0, TEMP_ADCPNP1, TEMP_ADCPNP2
214}; 214};
215 215
216const int mt2701_mux_values[MT2701_NUM_SENSORS] = { 0, 1, 16 }; 216static const int mt2701_mux_values[MT2701_NUM_SENSORS] = { 0, 1, 16 };
217 217
218/** 218/**
219 * The MT8173 thermal controller has four banks. Each bank can read up to 219 * The MT8173 thermal controller has four banks. Each bank can read up to
diff --git a/drivers/thermal/rcar_gen3_thermal.c b/drivers/thermal/rcar_gen3_thermal.c
new file mode 100644
index 000000000000..d33c845244b1
--- /dev/null
+++ b/drivers/thermal/rcar_gen3_thermal.c
@@ -0,0 +1,335 @@
1/*
2 * R-Car Gen3 THS thermal sensor driver
3 * Based on rcar_thermal.c and work from Hien Dang and Khiem Nguyen.
4 *
5 * Copyright (C) 2016 Renesas Electronics Corporation.
6 * Copyright (C) 2016 Sang Engineering
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 */
18#include <linux/delay.h>
19#include <linux/err.h>
20#include <linux/interrupt.h>
21#include <linux/io.h>
22#include <linux/module.h>
23#include <linux/mutex.h>
24#include <linux/of_device.h>
25#include <linux/platform_device.h>
26#include <linux/pm_runtime.h>
27#include <linux/thermal.h>
28
29/* Register offsets */
30#define REG_GEN3_IRQSTR 0x04
31#define REG_GEN3_IRQMSK 0x08
32#define REG_GEN3_IRQCTL 0x0C
33#define REG_GEN3_IRQEN 0x10
34#define REG_GEN3_IRQTEMP1 0x14
35#define REG_GEN3_IRQTEMP2 0x18
36#define REG_GEN3_IRQTEMP3 0x1C
37#define REG_GEN3_CTSR 0x20
38#define REG_GEN3_THCTR 0x20
39#define REG_GEN3_TEMP 0x28
40#define REG_GEN3_THCODE1 0x50
41#define REG_GEN3_THCODE2 0x54
42#define REG_GEN3_THCODE3 0x58
43
44/* CTSR bits */
45#define CTSR_PONM BIT(8)
46#define CTSR_AOUT BIT(7)
47#define CTSR_THBGR BIT(5)
48#define CTSR_VMEN BIT(4)
49#define CTSR_VMST BIT(1)
50#define CTSR_THSST BIT(0)
51
52/* THCTR bits */
53#define THCTR_PONM BIT(6)
54#define THCTR_THSST BIT(0)
55
56#define CTEMP_MASK 0xFFF
57
58#define MCELSIUS(temp) ((temp) * 1000)
59#define GEN3_FUSE_MASK 0xFFF
60
61#define TSC_MAX_NUM 3
62
63/* Structure for thermal temperature calculation */
64struct equation_coefs {
65 int a1;
66 int b1;
67 int a2;
68 int b2;
69};
70
71struct rcar_gen3_thermal_tsc {
72 void __iomem *base;
73 struct thermal_zone_device *zone;
74 struct equation_coefs coef;
75 struct mutex lock;
76};
77
78struct rcar_gen3_thermal_priv {
79 struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
80};
81
82struct rcar_gen3_thermal_data {
83 void (*thermal_init)(struct rcar_gen3_thermal_tsc *tsc);
84};
85
86static inline u32 rcar_gen3_thermal_read(struct rcar_gen3_thermal_tsc *tsc,
87 u32 reg)
88{
89 return ioread32(tsc->base + reg);
90}
91
92static inline void rcar_gen3_thermal_write(struct rcar_gen3_thermal_tsc *tsc,
93 u32 reg, u32 data)
94{
95 iowrite32(data, tsc->base + reg);
96}
97
98/*
99 * Linear approximation for temperature
100 *
101 * [reg] = [temp] * a + b => [temp] = ([reg] - b) / a
102 *
103 * The constants a and b are calculated using two triplets of int values PTAT
104 * and THCODE. PTAT and THCODE can either be read from hardware or use hard
105 * coded values from driver. The formula to calculate a and b are taken from
106 * BSP and sparsely documented and understood.
107 *
108 * Examining the linear formula and the formula used to calculate constants a
109 * and b while knowing that the span for PTAT and THCODE values are between
110 * 0x000 and 0xfff the largest integer possible is 0xfff * 0xfff == 0xffe001.
111 * Integer also needs to be signed so that leaves 7 bits for binary
112 * fixed point scaling.
113 */
114
115#define FIXPT_SHIFT 7
116#define FIXPT_INT(_x) ((_x) << FIXPT_SHIFT)
117#define FIXPT_DIV(_a, _b) DIV_ROUND_CLOSEST(((_a) << FIXPT_SHIFT), (_b))
118#define FIXPT_TO_MCELSIUS(_x) ((_x) * 1000 >> FIXPT_SHIFT)
119
120#define RCAR3_THERMAL_GRAN 500 /* mili Celsius */
121
122/* no idea where these constants come from */
123#define TJ_1 96
124#define TJ_3 -41
125
126static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef,
127 int *ptat, int *thcode)
128{
129 int tj_2;
130
131 /* TODO: Find documentation and document constant calculation formula */
132
133 /*
134 * Division is not scaled in BSP and if scaled it might overflow
135 * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled
136 */
137 tj_2 = (FIXPT_INT((ptat[1] - ptat[2]) * 137)
138 / (ptat[0] - ptat[2])) - FIXPT_INT(41);
139
140 coef->a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]),
141 tj_2 - FIXPT_INT(TJ_3));
142 coef->b1 = FIXPT_INT(thcode[2]) - coef->a1 * TJ_3;
143
144 coef->a2 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[0]),
145 tj_2 - FIXPT_INT(TJ_1));
146 coef->b2 = FIXPT_INT(thcode[0]) - coef->a2 * TJ_1;
147}
148
149static int rcar_gen3_thermal_round(int temp)
150{
151 int result, round_offs;
152
153 round_offs = temp >= 0 ? RCAR3_THERMAL_GRAN / 2 :
154 -RCAR3_THERMAL_GRAN / 2;
155 result = (temp + round_offs) / RCAR3_THERMAL_GRAN;
156 return result * RCAR3_THERMAL_GRAN;
157}
158
159static int rcar_gen3_thermal_get_temp(void *devdata, int *temp)
160{
161 struct rcar_gen3_thermal_tsc *tsc = devdata;
162 int mcelsius, val1, val2;
163 u32 reg;
164
165 /* Read register and convert to mili Celsius */
166 mutex_lock(&tsc->lock);
167
168 reg = rcar_gen3_thermal_read(tsc, REG_GEN3_TEMP) & CTEMP_MASK;
169
170 val1 = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b1, tsc->coef.a1);
171 val2 = FIXPT_DIV(FIXPT_INT(reg) - tsc->coef.b2, tsc->coef.a2);
172 mcelsius = FIXPT_TO_MCELSIUS((val1 + val2) / 2);
173
174 mutex_unlock(&tsc->lock);
175
176 /* Make sure we are inside specifications */
177 if ((mcelsius < MCELSIUS(-40)) || (mcelsius > MCELSIUS(125)))
178 return -EIO;
179
180 /* Round value to device granularity setting */
181 *temp = rcar_gen3_thermal_round(mcelsius);
182
183 return 0;
184}
185
186static struct thermal_zone_of_device_ops rcar_gen3_tz_of_ops = {
187 .get_temp = rcar_gen3_thermal_get_temp,
188};
189
190static void r8a7795_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
191{
192 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_THBGR);
193 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, 0x0);
194
195 usleep_range(1000, 2000);
196
197 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR, CTSR_PONM);
198 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F);
199 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR,
200 CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN);
201
202 usleep_range(100, 200);
203
204 rcar_gen3_thermal_write(tsc, REG_GEN3_CTSR,
205 CTSR_PONM | CTSR_AOUT | CTSR_THBGR | CTSR_VMEN |
206 CTSR_VMST | CTSR_THSST);
207
208 usleep_range(1000, 2000);
209}
210
211static void r8a7796_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
212{
213 u32 reg_val;
214
215 reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR);
216 reg_val &= ~THCTR_PONM;
217 rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val);
218
219 usleep_range(1000, 2000);
220
221 rcar_gen3_thermal_write(tsc, REG_GEN3_IRQCTL, 0x3F);
222 reg_val = rcar_gen3_thermal_read(tsc, REG_GEN3_THCTR);
223 reg_val |= THCTR_THSST;
224 rcar_gen3_thermal_write(tsc, REG_GEN3_THCTR, reg_val);
225}
226
227static const struct rcar_gen3_thermal_data r8a7795_data = {
228 .thermal_init = r8a7795_thermal_init,
229};
230
231static const struct rcar_gen3_thermal_data r8a7796_data = {
232 .thermal_init = r8a7796_thermal_init,
233};
234
235static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
236 { .compatible = "renesas,r8a7795-thermal", .data = &r8a7795_data},
237 { .compatible = "renesas,r8a7796-thermal", .data = &r8a7796_data},
238 {},
239};
240MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids);
241
242static int rcar_gen3_thermal_remove(struct platform_device *pdev)
243{
244 struct device *dev = &pdev->dev;
245
246 pm_runtime_put(dev);
247 pm_runtime_disable(dev);
248
249 return 0;
250}
251
252static int rcar_gen3_thermal_probe(struct platform_device *pdev)
253{
254 struct rcar_gen3_thermal_priv *priv;
255 struct device *dev = &pdev->dev;
256 struct resource *res;
257 struct thermal_zone_device *zone;
258 int ret, i;
259 const struct rcar_gen3_thermal_data *match_data =
260 of_device_get_match_data(dev);
261
262 /* default values if FUSEs are missing */
263 /* TODO: Read values from hardware on supported platforms */
264 int ptat[3] = { 2351, 1509, 435 };
265 int thcode[TSC_MAX_NUM][3] = {
266 { 3248, 2800, 2221 },
267 { 3245, 2795, 2216 },
268 { 3250, 2805, 2237 },
269 };
270
271 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
272 if (!priv)
273 return -ENOMEM;
274
275 platform_set_drvdata(pdev, priv);
276
277 pm_runtime_enable(dev);
278 pm_runtime_get_sync(dev);
279
280 for (i = 0; i < TSC_MAX_NUM; i++) {
281 struct rcar_gen3_thermal_tsc *tsc;
282
283 tsc = devm_kzalloc(dev, sizeof(*tsc), GFP_KERNEL);
284 if (!tsc) {
285 ret = -ENOMEM;
286 goto error_unregister;
287 }
288
289 res = platform_get_resource(pdev, IORESOURCE_MEM, i);
290 if (!res)
291 break;
292
293 tsc->base = devm_ioremap_resource(dev, res);
294 if (IS_ERR(tsc->base)) {
295 ret = PTR_ERR(tsc->base);
296 goto error_unregister;
297 }
298
299 priv->tscs[i] = tsc;
300 mutex_init(&tsc->lock);
301
302 match_data->thermal_init(tsc);
303 rcar_gen3_thermal_calc_coefs(&tsc->coef, ptat, thcode[i]);
304
305 zone = devm_thermal_zone_of_sensor_register(dev, i, tsc,
306 &rcar_gen3_tz_of_ops);
307 if (IS_ERR(zone)) {
308 dev_err(dev, "Can't register thermal zone\n");
309 ret = PTR_ERR(zone);
310 goto error_unregister;
311 }
312 tsc->zone = zone;
313 }
314
315 return 0;
316
317error_unregister:
318 rcar_gen3_thermal_remove(pdev);
319
320 return ret;
321}
322
323static struct platform_driver rcar_gen3_thermal_driver = {
324 .driver = {
325 .name = "rcar_gen3_thermal",
326 .of_match_table = rcar_gen3_thermal_dt_ids,
327 },
328 .probe = rcar_gen3_thermal_probe,
329 .remove = rcar_gen3_thermal_remove,
330};
331module_platform_driver(rcar_gen3_thermal_driver);
332
333MODULE_LICENSE("GPL v2");
334MODULE_DESCRIPTION("R-Car Gen3 THS thermal sensor driver");
335MODULE_AUTHOR("Wolfram Sang <wsa+renesas@sang-engineering.com>");
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index ad1186dd6132..7b8ef09d2b3c 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -1168,7 +1168,6 @@ static int exynos_of_sensor_conf(struct device_node *np,
1168 pdata->default_temp_offset = (u8)value; 1168 pdata->default_temp_offset = (u8)value;
1169 1169
1170 of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type); 1170 of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
1171 of_property_read_u32(np, "samsung,tmu_cal_mode", &pdata->cal_mode);
1172 1171
1173 of_node_put(np); 1172 of_node_put(np);
1174 return 0; 1173 return 0;
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
index 440c7140b660..5149c2a3030c 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -70,7 +70,6 @@ struct exynos_tmu_platform_data {
70 70
71 enum soc_type type; 71 enum soc_type type;
72 u32 cal_type; 72 u32 cal_type;
73 u32 cal_mode;
74}; 73};
75 74
76#endif /* _EXYNOS_TMU_H */ 75#endif /* _EXYNOS_TMU_H */
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 655591316a88..11f0675cb7e5 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -36,9 +36,8 @@ MODULE_AUTHOR("Zhang Rui");
36MODULE_DESCRIPTION("Generic thermal management sysfs support"); 36MODULE_DESCRIPTION("Generic thermal management sysfs support");
37MODULE_LICENSE("GPL v2"); 37MODULE_LICENSE("GPL v2");
38 38
39static DEFINE_IDR(thermal_tz_idr); 39static DEFINE_IDA(thermal_tz_ida);
40static DEFINE_IDR(thermal_cdev_idr); 40static DEFINE_IDA(thermal_cdev_ida);
41static DEFINE_MUTEX(thermal_idr_lock);
42 41
43static LIST_HEAD(thermal_tz_list); 42static LIST_HEAD(thermal_tz_list);
44static LIST_HEAD(thermal_cdev_list); 43static LIST_HEAD(thermal_cdev_list);
@@ -589,29 +588,6 @@ void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz,
589 * - thermal zone devices lifecycle: registration, unregistration, 588 * - thermal zone devices lifecycle: registration, unregistration,
590 * binding, and unbinding. 589 * binding, and unbinding.
591 */ 590 */
592static int get_idr(struct idr *idr, struct mutex *lock, int *id)
593{
594 int ret;
595
596 if (lock)
597 mutex_lock(lock);
598 ret = idr_alloc(idr, NULL, 0, 0, GFP_KERNEL);
599 if (lock)
600 mutex_unlock(lock);
601 if (unlikely(ret < 0))
602 return ret;
603 *id = ret;
604 return 0;
605}
606
607static void release_idr(struct idr *idr, struct mutex *lock, int id)
608{
609 if (lock)
610 mutex_lock(lock);
611 idr_remove(idr, id);
612 if (lock)
613 mutex_unlock(lock);
614}
615 591
616/** 592/**
617 * thermal_zone_bind_cooling_device() - bind a cooling device to a thermal zone 593 * thermal_zone_bind_cooling_device() - bind a cooling device to a thermal zone
@@ -685,15 +661,16 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
685 dev->target = THERMAL_NO_TARGET; 661 dev->target = THERMAL_NO_TARGET;
686 dev->weight = weight; 662 dev->weight = weight;
687 663
688 result = get_idr(&tz->idr, &tz->lock, &dev->id); 664 result = ida_simple_get(&tz->ida, 0, 0, GFP_KERNEL);
689 if (result) 665 if (result < 0)
690 goto free_mem; 666 goto free_mem;
691 667
668 dev->id = result;
692 sprintf(dev->name, "cdev%d", dev->id); 669 sprintf(dev->name, "cdev%d", dev->id);
693 result = 670 result =
694 sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name); 671 sysfs_create_link(&tz->device.kobj, &cdev->device.kobj, dev->name);
695 if (result) 672 if (result)
696 goto release_idr; 673 goto release_ida;
697 674
698 sprintf(dev->attr_name, "cdev%d_trip_point", dev->id); 675 sprintf(dev->attr_name, "cdev%d_trip_point", dev->id);
699 sysfs_attr_init(&dev->attr.attr); 676 sysfs_attr_init(&dev->attr.attr);
@@ -737,8 +714,8 @@ remove_trip_file:
737 device_remove_file(&tz->device, &dev->attr); 714 device_remove_file(&tz->device, &dev->attr);
738remove_symbol_link: 715remove_symbol_link:
739 sysfs_remove_link(&tz->device.kobj, dev->name); 716 sysfs_remove_link(&tz->device.kobj, dev->name);
740release_idr: 717release_ida:
741 release_idr(&tz->idr, &tz->lock, dev->id); 718 ida_simple_remove(&tz->ida, dev->id);
742free_mem: 719free_mem:
743 kfree(dev); 720 kfree(dev);
744 return result; 721 return result;
@@ -785,7 +762,7 @@ unbind:
785 device_remove_file(&tz->device, &pos->weight_attr); 762 device_remove_file(&tz->device, &pos->weight_attr);
786 device_remove_file(&tz->device, &pos->attr); 763 device_remove_file(&tz->device, &pos->attr);
787 sysfs_remove_link(&tz->device.kobj, pos->name); 764 sysfs_remove_link(&tz->device.kobj, pos->name);
788 release_idr(&tz->idr, &tz->lock, pos->id); 765 ida_simple_remove(&tz->ida, pos->id);
789 kfree(pos); 766 kfree(pos);
790 return 0; 767 return 0;
791} 768}
@@ -925,12 +902,13 @@ __thermal_cooling_device_register(struct device_node *np,
925 if (!cdev) 902 if (!cdev)
926 return ERR_PTR(-ENOMEM); 903 return ERR_PTR(-ENOMEM);
927 904
928 result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id); 905 result = ida_simple_get(&thermal_cdev_ida, 0, 0, GFP_KERNEL);
929 if (result) { 906 if (result < 0) {
930 kfree(cdev); 907 kfree(cdev);
931 return ERR_PTR(result); 908 return ERR_PTR(result);
932 } 909 }
933 910
911 cdev->id = result;
934 strlcpy(cdev->type, type ? : "", sizeof(cdev->type)); 912 strlcpy(cdev->type, type ? : "", sizeof(cdev->type));
935 mutex_init(&cdev->lock); 913 mutex_init(&cdev->lock);
936 INIT_LIST_HEAD(&cdev->thermal_instances); 914 INIT_LIST_HEAD(&cdev->thermal_instances);
@@ -943,7 +921,7 @@ __thermal_cooling_device_register(struct device_node *np,
943 dev_set_name(&cdev->device, "cooling_device%d", cdev->id); 921 dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
944 result = device_register(&cdev->device); 922 result = device_register(&cdev->device);
945 if (result) { 923 if (result) {
946 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); 924 ida_simple_remove(&thermal_cdev_ida, cdev->id);
947 kfree(cdev); 925 kfree(cdev);
948 return ERR_PTR(result); 926 return ERR_PTR(result);
949 } 927 }
@@ -1070,7 +1048,7 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
1070 1048
1071 mutex_unlock(&thermal_list_lock); 1049 mutex_unlock(&thermal_list_lock);
1072 1050
1073 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); 1051 ida_simple_remove(&thermal_cdev_ida, cdev->id);
1074 device_unregister(&cdev->device); 1052 device_unregister(&cdev->device);
1075} 1053}
1076EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister); 1054EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);
@@ -1172,14 +1150,15 @@ thermal_zone_device_register(const char *type, int trips, int mask,
1172 return ERR_PTR(-ENOMEM); 1150 return ERR_PTR(-ENOMEM);
1173 1151
1174 INIT_LIST_HEAD(&tz->thermal_instances); 1152 INIT_LIST_HEAD(&tz->thermal_instances);
1175 idr_init(&tz->idr); 1153 ida_init(&tz->ida);
1176 mutex_init(&tz->lock); 1154 mutex_init(&tz->lock);
1177 result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id); 1155 result = ida_simple_get(&thermal_tz_ida, 0, 0, GFP_KERNEL);
1178 if (result) { 1156 if (result < 0) {
1179 kfree(tz); 1157 kfree(tz);
1180 return ERR_PTR(result); 1158 return ERR_PTR(result);
1181 } 1159 }
1182 1160
1161 tz->id = result;
1183 strlcpy(tz->type, type, sizeof(tz->type)); 1162 strlcpy(tz->type, type, sizeof(tz->type));
1184 tz->ops = ops; 1163 tz->ops = ops;
1185 tz->tzp = tzp; 1164 tz->tzp = tzp;
@@ -1201,7 +1180,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
1201 dev_set_name(&tz->device, "thermal_zone%d", tz->id); 1180 dev_set_name(&tz->device, "thermal_zone%d", tz->id);
1202 result = device_register(&tz->device); 1181 result = device_register(&tz->device);
1203 if (result) { 1182 if (result) {
1204 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 1183 ida_simple_remove(&thermal_tz_ida, tz->id);
1205 kfree(tz); 1184 kfree(tz);
1206 return ERR_PTR(result); 1185 return ERR_PTR(result);
1207 } 1186 }
@@ -1255,7 +1234,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
1255 return tz; 1234 return tz;
1256 1235
1257unregister: 1236unregister:
1258 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 1237 ida_simple_remove(&thermal_tz_ida, tz->id);
1259 device_unregister(&tz->device); 1238 device_unregister(&tz->device);
1260 return ERR_PTR(result); 1239 return ERR_PTR(result);
1261} 1240}
@@ -1313,8 +1292,8 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
1313 thermal_set_governor(tz, NULL); 1292 thermal_set_governor(tz, NULL);
1314 1293
1315 thermal_remove_hwmon_sysfs(tz); 1294 thermal_remove_hwmon_sysfs(tz);
1316 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 1295 ida_simple_remove(&thermal_tz_ida, tz->id);
1317 idr_destroy(&tz->idr); 1296 ida_destroy(&tz->ida);
1318 mutex_destroy(&tz->lock); 1297 mutex_destroy(&tz->lock);
1319 device_unregister(&tz->device); 1298 device_unregister(&tz->device);
1320} 1299}
@@ -1514,9 +1493,8 @@ unregister_class:
1514unregister_governors: 1493unregister_governors:
1515 thermal_unregister_governors(); 1494 thermal_unregister_governors();
1516error: 1495error:
1517 idr_destroy(&thermal_tz_idr); 1496 ida_destroy(&thermal_tz_ida);
1518 idr_destroy(&thermal_cdev_idr); 1497 ida_destroy(&thermal_cdev_ida);
1519 mutex_destroy(&thermal_idr_lock);
1520 mutex_destroy(&thermal_list_lock); 1498 mutex_destroy(&thermal_list_lock);
1521 mutex_destroy(&thermal_governor_lock); 1499 mutex_destroy(&thermal_governor_lock);
1522 return result; 1500 return result;
@@ -1529,9 +1507,8 @@ static void __exit thermal_exit(void)
1529 genetlink_exit(); 1507 genetlink_exit();
1530 class_unregister(&thermal_class); 1508 class_unregister(&thermal_class);
1531 thermal_unregister_governors(); 1509 thermal_unregister_governors();
1532 idr_destroy(&thermal_tz_idr); 1510 ida_destroy(&thermal_tz_ida);
1533 idr_destroy(&thermal_cdev_idr); 1511 ida_destroy(&thermal_cdev_ida);
1534 mutex_destroy(&thermal_idr_lock);
1535 mutex_destroy(&thermal_list_lock); 1512 mutex_destroy(&thermal_list_lock);
1536 mutex_destroy(&thermal_governor_lock); 1513 mutex_destroy(&thermal_governor_lock);
1537} 1514}
diff --git a/drivers/thermal/ti-soc-thermal/Kconfig b/drivers/thermal/ti-soc-thermal/Kconfig
index ea8283f08aa6..fe0e877f84d0 100644
--- a/drivers/thermal/ti-soc-thermal/Kconfig
+++ b/drivers/thermal/ti-soc-thermal/Kconfig
@@ -11,7 +11,6 @@ config TI_SOC_THERMAL
11config TI_THERMAL 11config TI_THERMAL
12 bool "Texas Instruments SoCs thermal framework support" 12 bool "Texas Instruments SoCs thermal framework support"
13 depends on TI_SOC_THERMAL 13 depends on TI_SOC_THERMAL
14 depends on CPU_THERMAL
15 help 14 help
16 If you say yes here you want to get support for generic thermal 15 If you say yes here you want to get support for generic thermal
17 framework for the Texas Instruments on die bandgap temperature sensor. 16 framework for the Texas Instruments on die bandgap temperature sensor.
diff --git a/drivers/thermal/ti-soc-thermal/dra752-bandgap.h b/drivers/thermal/ti-soc-thermal/dra752-bandgap.h
index 6b0f2b1160f7..a31e4b5e82cd 100644
--- a/drivers/thermal/ti-soc-thermal/dra752-bandgap.h
+++ b/drivers/thermal/ti-soc-thermal/dra752-bandgap.h
@@ -54,7 +54,6 @@
54#define DRA752_STD_FUSE_OPP_BGAP_CORE_OFFSET 0x8 54#define DRA752_STD_FUSE_OPP_BGAP_CORE_OFFSET 0x8
55#define DRA752_TEMP_SENSOR_CORE_OFFSET 0x154 55#define DRA752_TEMP_SENSOR_CORE_OFFSET 0x154
56#define DRA752_BANDGAP_THRESHOLD_CORE_OFFSET 0x1ac 56#define DRA752_BANDGAP_THRESHOLD_CORE_OFFSET 0x1ac
57#define DRA752_BANDGAP_TSHUT_CORE_OFFSET 0x1b8
58#define DRA752_BANDGAP_CUMUL_DTEMP_CORE_OFFSET 0x1c4 57#define DRA752_BANDGAP_CUMUL_DTEMP_CORE_OFFSET 0x1c4
59#define DRA752_DTEMP_CORE_0_OFFSET 0x208 58#define DRA752_DTEMP_CORE_0_OFFSET 0x208
60#define DRA752_DTEMP_CORE_1_OFFSET 0x20c 59#define DRA752_DTEMP_CORE_1_OFFSET 0x20c
@@ -66,7 +65,6 @@
66#define DRA752_STD_FUSE_OPP_BGAP_IVA_OFFSET 0x388 65#define DRA752_STD_FUSE_OPP_BGAP_IVA_OFFSET 0x388
67#define DRA752_TEMP_SENSOR_IVA_OFFSET 0x398 66#define DRA752_TEMP_SENSOR_IVA_OFFSET 0x398
68#define DRA752_BANDGAP_THRESHOLD_IVA_OFFSET 0x3a4 67#define DRA752_BANDGAP_THRESHOLD_IVA_OFFSET 0x3a4
69#define DRA752_BANDGAP_TSHUT_IVA_OFFSET 0x3ac
70#define DRA752_BANDGAP_CUMUL_DTEMP_IVA_OFFSET 0x3b4 68#define DRA752_BANDGAP_CUMUL_DTEMP_IVA_OFFSET 0x3b4
71#define DRA752_DTEMP_IVA_0_OFFSET 0x3d0 69#define DRA752_DTEMP_IVA_0_OFFSET 0x3d0
72#define DRA752_DTEMP_IVA_1_OFFSET 0x3d4 70#define DRA752_DTEMP_IVA_1_OFFSET 0x3d4
@@ -78,7 +76,6 @@
78#define DRA752_STD_FUSE_OPP_BGAP_MPU_OFFSET 0x4 76#define DRA752_STD_FUSE_OPP_BGAP_MPU_OFFSET 0x4
79#define DRA752_TEMP_SENSOR_MPU_OFFSET 0x14c 77#define DRA752_TEMP_SENSOR_MPU_OFFSET 0x14c
80#define DRA752_BANDGAP_THRESHOLD_MPU_OFFSET 0x1a4 78#define DRA752_BANDGAP_THRESHOLD_MPU_OFFSET 0x1a4
81#define DRA752_BANDGAP_TSHUT_MPU_OFFSET 0x1b0
82#define DRA752_BANDGAP_CUMUL_DTEMP_MPU_OFFSET 0x1bc 79#define DRA752_BANDGAP_CUMUL_DTEMP_MPU_OFFSET 0x1bc
83#define DRA752_DTEMP_MPU_0_OFFSET 0x1e0 80#define DRA752_DTEMP_MPU_0_OFFSET 0x1e0
84#define DRA752_DTEMP_MPU_1_OFFSET 0x1e4 81#define DRA752_DTEMP_MPU_1_OFFSET 0x1e4
@@ -90,7 +87,6 @@
90#define DRA752_STD_FUSE_OPP_BGAP_DSPEVE_OFFSET 0x384 87#define DRA752_STD_FUSE_OPP_BGAP_DSPEVE_OFFSET 0x384
91#define DRA752_TEMP_SENSOR_DSPEVE_OFFSET 0x394 88#define DRA752_TEMP_SENSOR_DSPEVE_OFFSET 0x394
92#define DRA752_BANDGAP_THRESHOLD_DSPEVE_OFFSET 0x3a0 89#define DRA752_BANDGAP_THRESHOLD_DSPEVE_OFFSET 0x3a0
93#define DRA752_BANDGAP_TSHUT_DSPEVE_OFFSET 0x3a8
94#define DRA752_BANDGAP_CUMUL_DTEMP_DSPEVE_OFFSET 0x3b0 90#define DRA752_BANDGAP_CUMUL_DTEMP_DSPEVE_OFFSET 0x3b0
95#define DRA752_DTEMP_DSPEVE_0_OFFSET 0x3bc 91#define DRA752_DTEMP_DSPEVE_0_OFFSET 0x3bc
96#define DRA752_DTEMP_DSPEVE_1_OFFSET 0x3c0 92#define DRA752_DTEMP_DSPEVE_1_OFFSET 0x3c0
@@ -102,7 +98,6 @@
102#define DRA752_STD_FUSE_OPP_BGAP_GPU_OFFSET 0x0 98#define DRA752_STD_FUSE_OPP_BGAP_GPU_OFFSET 0x0
103#define DRA752_TEMP_SENSOR_GPU_OFFSET 0x150 99#define DRA752_TEMP_SENSOR_GPU_OFFSET 0x150
104#define DRA752_BANDGAP_THRESHOLD_GPU_OFFSET 0x1a8 100#define DRA752_BANDGAP_THRESHOLD_GPU_OFFSET 0x1a8
105#define DRA752_BANDGAP_TSHUT_GPU_OFFSET 0x1b4
106#define DRA752_BANDGAP_CUMUL_DTEMP_GPU_OFFSET 0x1c0 101#define DRA752_BANDGAP_CUMUL_DTEMP_GPU_OFFSET 0x1c0
107#define DRA752_DTEMP_GPU_0_OFFSET 0x1f4 102#define DRA752_DTEMP_GPU_0_OFFSET 0x1f4
108#define DRA752_DTEMP_GPU_1_OFFSET 0x1f8 103#define DRA752_DTEMP_GPU_1_OFFSET 0x1f8
@@ -173,10 +168,6 @@
173#define DRA752_BANDGAP_THRESHOLD_HOT_MASK (0x3ff << 16) 168#define DRA752_BANDGAP_THRESHOLD_HOT_MASK (0x3ff << 16)
174#define DRA752_BANDGAP_THRESHOLD_COLD_MASK (0x3ff << 0) 169#define DRA752_BANDGAP_THRESHOLD_COLD_MASK (0x3ff << 0)
175 170
176/* DRA752.TSHUT_THRESHOLD */
177#define DRA752_TSHUT_THRESHOLD_MUXCTRL_MASK BIT(31)
178#define DRA752_TSHUT_THRESHOLD_HOT_MASK (0x3ff << 16)
179#define DRA752_TSHUT_THRESHOLD_COLD_MASK (0x3ff << 0)
180 171
181/* DRA752.BANDGAP_CUMUL_DTEMP_CORE */ 172/* DRA752.BANDGAP_CUMUL_DTEMP_CORE */
182#define DRA752_BANDGAP_CUMUL_DTEMP_CORE_MASK (0xffffffff << 0) 173#define DRA752_BANDGAP_CUMUL_DTEMP_CORE_MASK (0xffffffff << 0)
@@ -216,8 +207,6 @@
216#define DRA752_GPU_MAX_TEMP 125000 207#define DRA752_GPU_MAX_TEMP 125000
217#define DRA752_GPU_HYST_VAL 5000 208#define DRA752_GPU_HYST_VAL 5000
218/* interrupts thresholds */ 209/* interrupts thresholds */
219#define DRA752_GPU_TSHUT_HOT 915
220#define DRA752_GPU_TSHUT_COLD 900
221#define DRA752_GPU_T_HOT 800 210#define DRA752_GPU_T_HOT 800
222#define DRA752_GPU_T_COLD 795 211#define DRA752_GPU_T_COLD 795
223 212
@@ -230,8 +219,6 @@
230#define DRA752_MPU_MAX_TEMP 125000 219#define DRA752_MPU_MAX_TEMP 125000
231#define DRA752_MPU_HYST_VAL 5000 220#define DRA752_MPU_HYST_VAL 5000
232/* interrupts thresholds */ 221/* interrupts thresholds */
233#define DRA752_MPU_TSHUT_HOT 915
234#define DRA752_MPU_TSHUT_COLD 900
235#define DRA752_MPU_T_HOT 800 222#define DRA752_MPU_T_HOT 800
236#define DRA752_MPU_T_COLD 795 223#define DRA752_MPU_T_COLD 795
237 224
@@ -244,8 +231,6 @@
244#define DRA752_CORE_MAX_TEMP 125000 231#define DRA752_CORE_MAX_TEMP 125000
245#define DRA752_CORE_HYST_VAL 5000 232#define DRA752_CORE_HYST_VAL 5000
246/* interrupts thresholds */ 233/* interrupts thresholds */
247#define DRA752_CORE_TSHUT_HOT 915
248#define DRA752_CORE_TSHUT_COLD 900
249#define DRA752_CORE_T_HOT 800 234#define DRA752_CORE_T_HOT 800
250#define DRA752_CORE_T_COLD 795 235#define DRA752_CORE_T_COLD 795
251 236
@@ -258,8 +243,6 @@
258#define DRA752_DSPEVE_MAX_TEMP 125000 243#define DRA752_DSPEVE_MAX_TEMP 125000
259#define DRA752_DSPEVE_HYST_VAL 5000 244#define DRA752_DSPEVE_HYST_VAL 5000
260/* interrupts thresholds */ 245/* interrupts thresholds */
261#define DRA752_DSPEVE_TSHUT_HOT 915
262#define DRA752_DSPEVE_TSHUT_COLD 900
263#define DRA752_DSPEVE_T_HOT 800 246#define DRA752_DSPEVE_T_HOT 800
264#define DRA752_DSPEVE_T_COLD 795 247#define DRA752_DSPEVE_T_COLD 795
265 248
@@ -272,8 +255,6 @@
272#define DRA752_IVA_MAX_TEMP 125000 255#define DRA752_IVA_MAX_TEMP 125000
273#define DRA752_IVA_HYST_VAL 5000 256#define DRA752_IVA_HYST_VAL 5000
274/* interrupts thresholds */ 257/* interrupts thresholds */
275#define DRA752_IVA_TSHUT_HOT 915
276#define DRA752_IVA_TSHUT_COLD 900
277#define DRA752_IVA_T_HOT 800 258#define DRA752_IVA_T_HOT 800
278#define DRA752_IVA_T_COLD 795 259#define DRA752_IVA_T_COLD 795
279 260
diff --git a/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c b/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
index 58b5c6694cd4..118d7d847715 100644
--- a/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
+++ b/drivers/thermal/ti-soc-thermal/dra752-thermal-data.c
@@ -49,9 +49,6 @@ dra752_core_temp_sensor_registers = {
49 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_CORE_OFFSET, 49 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_CORE_OFFSET,
50 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK, 50 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK,
51 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK, 51 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK,
52 .tshut_threshold = DRA752_BANDGAP_TSHUT_CORE_OFFSET,
53 .tshut_hot_mask = DRA752_TSHUT_THRESHOLD_HOT_MASK,
54 .tshut_cold_mask = DRA752_TSHUT_THRESHOLD_COLD_MASK,
55 .bgap_status = DRA752_BANDGAP_STATUS_1_OFFSET, 52 .bgap_status = DRA752_BANDGAP_STATUS_1_OFFSET,
56 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK, 53 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK,
57 .status_hot_mask = DRA752_BANDGAP_STATUS_1_HOT_CORE_MASK, 54 .status_hot_mask = DRA752_BANDGAP_STATUS_1_HOT_CORE_MASK,
@@ -85,9 +82,6 @@ dra752_iva_temp_sensor_registers = {
85 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_IVA_OFFSET, 82 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_IVA_OFFSET,
86 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK, 83 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK,
87 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK, 84 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK,
88 .tshut_threshold = DRA752_BANDGAP_TSHUT_IVA_OFFSET,
89 .tshut_hot_mask = DRA752_TSHUT_THRESHOLD_HOT_MASK,
90 .tshut_cold_mask = DRA752_TSHUT_THRESHOLD_COLD_MASK,
91 .bgap_status = DRA752_BANDGAP_STATUS_2_OFFSET, 85 .bgap_status = DRA752_BANDGAP_STATUS_2_OFFSET,
92 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK, 86 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK,
93 .status_hot_mask = DRA752_BANDGAP_STATUS_2_HOT_IVA_MASK, 87 .status_hot_mask = DRA752_BANDGAP_STATUS_2_HOT_IVA_MASK,
@@ -121,9 +115,6 @@ dra752_mpu_temp_sensor_registers = {
121 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_MPU_OFFSET, 115 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_MPU_OFFSET,
122 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK, 116 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK,
123 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK, 117 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK,
124 .tshut_threshold = DRA752_BANDGAP_TSHUT_MPU_OFFSET,
125 .tshut_hot_mask = DRA752_TSHUT_THRESHOLD_HOT_MASK,
126 .tshut_cold_mask = DRA752_TSHUT_THRESHOLD_COLD_MASK,
127 .bgap_status = DRA752_BANDGAP_STATUS_1_OFFSET, 118 .bgap_status = DRA752_BANDGAP_STATUS_1_OFFSET,
128 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK, 119 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK,
129 .status_hot_mask = DRA752_BANDGAP_STATUS_1_HOT_MPU_MASK, 120 .status_hot_mask = DRA752_BANDGAP_STATUS_1_HOT_MPU_MASK,
@@ -157,9 +148,6 @@ dra752_dspeve_temp_sensor_registers = {
157 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_DSPEVE_OFFSET, 148 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_DSPEVE_OFFSET,
158 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK, 149 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK,
159 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK, 150 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK,
160 .tshut_threshold = DRA752_BANDGAP_TSHUT_DSPEVE_OFFSET,
161 .tshut_hot_mask = DRA752_TSHUT_THRESHOLD_HOT_MASK,
162 .tshut_cold_mask = DRA752_TSHUT_THRESHOLD_COLD_MASK,
163 .bgap_status = DRA752_BANDGAP_STATUS_2_OFFSET, 151 .bgap_status = DRA752_BANDGAP_STATUS_2_OFFSET,
164 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK, 152 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK,
165 .status_hot_mask = DRA752_BANDGAP_STATUS_2_HOT_DSPEVE_MASK, 153 .status_hot_mask = DRA752_BANDGAP_STATUS_2_HOT_DSPEVE_MASK,
@@ -193,9 +181,6 @@ dra752_gpu_temp_sensor_registers = {
193 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_GPU_OFFSET, 181 .bgap_threshold = DRA752_BANDGAP_THRESHOLD_GPU_OFFSET,
194 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK, 182 .threshold_thot_mask = DRA752_BANDGAP_THRESHOLD_HOT_MASK,
195 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK, 183 .threshold_tcold_mask = DRA752_BANDGAP_THRESHOLD_COLD_MASK,
196 .tshut_threshold = DRA752_BANDGAP_TSHUT_GPU_OFFSET,
197 .tshut_hot_mask = DRA752_TSHUT_THRESHOLD_HOT_MASK,
198 .tshut_cold_mask = DRA752_TSHUT_THRESHOLD_COLD_MASK,
199 .bgap_status = DRA752_BANDGAP_STATUS_1_OFFSET, 184 .bgap_status = DRA752_BANDGAP_STATUS_1_OFFSET,
200 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK, 185 .status_bgap_alert_mask = DRA752_BANDGAP_STATUS_1_ALERT_MASK,
201 .status_hot_mask = DRA752_BANDGAP_STATUS_1_HOT_GPU_MASK, 186 .status_hot_mask = DRA752_BANDGAP_STATUS_1_HOT_GPU_MASK,
@@ -211,8 +196,6 @@ dra752_gpu_temp_sensor_registers = {
211 196
212/* Thresholds and limits for DRA752 MPU temperature sensor */ 197/* Thresholds and limits for DRA752 MPU temperature sensor */
213static struct temp_sensor_data dra752_mpu_temp_sensor_data = { 198static struct temp_sensor_data dra752_mpu_temp_sensor_data = {
214 .tshut_hot = DRA752_MPU_TSHUT_HOT,
215 .tshut_cold = DRA752_MPU_TSHUT_COLD,
216 .t_hot = DRA752_MPU_T_HOT, 199 .t_hot = DRA752_MPU_T_HOT,
217 .t_cold = DRA752_MPU_T_COLD, 200 .t_cold = DRA752_MPU_T_COLD,
218 .min_freq = DRA752_MPU_MIN_FREQ, 201 .min_freq = DRA752_MPU_MIN_FREQ,
@@ -226,8 +209,6 @@ static struct temp_sensor_data dra752_mpu_temp_sensor_data = {
226 209
227/* Thresholds and limits for DRA752 GPU temperature sensor */ 210/* Thresholds and limits for DRA752 GPU temperature sensor */
228static struct temp_sensor_data dra752_gpu_temp_sensor_data = { 211static struct temp_sensor_data dra752_gpu_temp_sensor_data = {
229 .tshut_hot = DRA752_GPU_TSHUT_HOT,
230 .tshut_cold = DRA752_GPU_TSHUT_COLD,
231 .t_hot = DRA752_GPU_T_HOT, 212 .t_hot = DRA752_GPU_T_HOT,
232 .t_cold = DRA752_GPU_T_COLD, 213 .t_cold = DRA752_GPU_T_COLD,
233 .min_freq = DRA752_GPU_MIN_FREQ, 214 .min_freq = DRA752_GPU_MIN_FREQ,
@@ -241,8 +222,6 @@ static struct temp_sensor_data dra752_gpu_temp_sensor_data = {
241 222
242/* Thresholds and limits for DRA752 CORE temperature sensor */ 223/* Thresholds and limits for DRA752 CORE temperature sensor */
243static struct temp_sensor_data dra752_core_temp_sensor_data = { 224static struct temp_sensor_data dra752_core_temp_sensor_data = {
244 .tshut_hot = DRA752_CORE_TSHUT_HOT,
245 .tshut_cold = DRA752_CORE_TSHUT_COLD,
246 .t_hot = DRA752_CORE_T_HOT, 225 .t_hot = DRA752_CORE_T_HOT,
247 .t_cold = DRA752_CORE_T_COLD, 226 .t_cold = DRA752_CORE_T_COLD,
248 .min_freq = DRA752_CORE_MIN_FREQ, 227 .min_freq = DRA752_CORE_MIN_FREQ,
@@ -256,8 +235,6 @@ static struct temp_sensor_data dra752_core_temp_sensor_data = {
256 235
257/* Thresholds and limits for DRA752 DSPEVE temperature sensor */ 236/* Thresholds and limits for DRA752 DSPEVE temperature sensor */
258static struct temp_sensor_data dra752_dspeve_temp_sensor_data = { 237static struct temp_sensor_data dra752_dspeve_temp_sensor_data = {
259 .tshut_hot = DRA752_DSPEVE_TSHUT_HOT,
260 .tshut_cold = DRA752_DSPEVE_TSHUT_COLD,
261 .t_hot = DRA752_DSPEVE_T_HOT, 238 .t_hot = DRA752_DSPEVE_T_HOT,
262 .t_cold = DRA752_DSPEVE_T_COLD, 239 .t_cold = DRA752_DSPEVE_T_COLD,
263 .min_freq = DRA752_DSPEVE_MIN_FREQ, 240 .min_freq = DRA752_DSPEVE_MIN_FREQ,
@@ -271,8 +248,6 @@ static struct temp_sensor_data dra752_dspeve_temp_sensor_data = {
271 248
272/* Thresholds and limits for DRA752 IVA temperature sensor */ 249/* Thresholds and limits for DRA752 IVA temperature sensor */
273static struct temp_sensor_data dra752_iva_temp_sensor_data = { 250static struct temp_sensor_data dra752_iva_temp_sensor_data = {
274 .tshut_hot = DRA752_IVA_TSHUT_HOT,
275 .tshut_cold = DRA752_IVA_TSHUT_COLD,
276 .t_hot = DRA752_IVA_T_HOT, 251 .t_hot = DRA752_IVA_T_HOT,
277 .t_cold = DRA752_IVA_T_COLD, 252 .t_cold = DRA752_IVA_T_COLD,
278 .min_freq = DRA752_IVA_MIN_FREQ, 253 .min_freq = DRA752_IVA_MIN_FREQ,
@@ -416,8 +391,7 @@ int dra752_adc_to_temp[DRA752_ADC_END_VALUE - DRA752_ADC_START_VALUE + 1] = {
416 391
417/* DRA752 data */ 392/* DRA752 data */
418const struct ti_bandgap_data dra752_data = { 393const struct ti_bandgap_data dra752_data = {
419 .features = TI_BANDGAP_FEATURE_TSHUT_CONFIG | 394 .features = TI_BANDGAP_FEATURE_FREEZE_BIT |
420 TI_BANDGAP_FEATURE_FREEZE_BIT |
421 TI_BANDGAP_FEATURE_TALERT | 395 TI_BANDGAP_FEATURE_TALERT |
422 TI_BANDGAP_FEATURE_COUNTER_DELAY | 396 TI_BANDGAP_FEATURE_COUNTER_DELAY |
423 TI_BANDGAP_FEATURE_HISTORY_BUFFER | 397 TI_BANDGAP_FEATURE_HISTORY_BUFFER |
diff --git a/drivers/thermal/zx2967_thermal.c b/drivers/thermal/zx2967_thermal.c
new file mode 100644
index 000000000000..a5670ad2cfc8
--- /dev/null
+++ b/drivers/thermal/zx2967_thermal.c
@@ -0,0 +1,258 @@
1/*
2 * ZTE's zx2967 family thermal sensor driver
3 *
4 * Copyright (C) 2017 ZTE Ltd.
5 *
6 * Author: Baoyou Xie <baoyou.xie@linaro.org>
7 *
8 * License terms: GNU General Public License (GPL) version 2
9 */
10
11#include <linux/clk.h>
12#include <linux/device.h>
13#include <linux/err.h>
14#include <linux/iopoll.h>
15#include <linux/module.h>
16#include <linux/platform_device.h>
17#include <linux/thermal.h>
18
19/* Power Mode: 0->low 1->high */
20#define ZX2967_THERMAL_POWER_MODE 0
21#define ZX2967_POWER_MODE_LOW 0
22#define ZX2967_POWER_MODE_HIGH 1
23
24/* DCF Control Register */
25#define ZX2967_THERMAL_DCF 0x4
26#define ZX2967_DCF_EN BIT(1)
27#define ZX2967_DCF_FREEZE BIT(0)
28
29/* Selection Register */
30#define ZX2967_THERMAL_SEL 0x8
31
32/* Control Register */
33#define ZX2967_THERMAL_CTRL 0x10
34
35#define ZX2967_THERMAL_READY BIT(12)
36#define ZX2967_THERMAL_TEMP_MASK GENMASK(11, 0)
37#define ZX2967_THERMAL_ID_MASK 0x18
38#define ZX2967_THERMAL_ID 0x10
39
40#define ZX2967_GET_TEMP_TIMEOUT_US (100 * 1024)
41
42/**
43 * struct zx2967_thermal_priv - zx2967 thermal sensor private structure
44 * @tzd: struct thermal_zone_device where the sensor is registered
45 * @lock: prevents read sensor in parallel
46 * @clk_topcrm: topcrm clk structure
47 * @clk_apb: apb clk structure
48 * @regs: pointer to base address of the thermal sensor
49 */
50
51struct zx2967_thermal_priv {
52 struct thermal_zone_device *tzd;
53 struct mutex lock;
54 struct clk *clk_topcrm;
55 struct clk *clk_apb;
56 void __iomem *regs;
57 struct device *dev;
58};
59
60static int zx2967_thermal_get_temp(void *data, int *temp)
61{
62 void __iomem *regs;
63 struct zx2967_thermal_priv *priv = data;
64 u32 val;
65 int ret;
66
67 if (!priv->tzd)
68 return -EAGAIN;
69
70 regs = priv->regs;
71 mutex_lock(&priv->lock);
72 writel_relaxed(ZX2967_POWER_MODE_LOW,
73 regs + ZX2967_THERMAL_POWER_MODE);
74 writel_relaxed(ZX2967_DCF_EN, regs + ZX2967_THERMAL_DCF);
75
76 val = readl_relaxed(regs + ZX2967_THERMAL_SEL);
77 val &= ~ZX2967_THERMAL_ID_MASK;
78 val |= ZX2967_THERMAL_ID;
79 writel_relaxed(val, regs + ZX2967_THERMAL_SEL);
80
81 /*
82 * Must wait for a while, surely it's a bit odd.
83 * otherwise temperature value we got has a few deviation, even if
84 * the THERMAL_READY bit is set.
85 */
86 usleep_range(100, 300);
87 ret = readx_poll_timeout(readl, regs + ZX2967_THERMAL_CTRL,
88 val, val & ZX2967_THERMAL_READY, 300,
89 ZX2967_GET_TEMP_TIMEOUT_US);
90 if (ret) {
91 dev_err(priv->dev, "Thermal sensor data timeout\n");
92 goto unlock;
93 }
94
95 writel_relaxed(ZX2967_DCF_FREEZE | ZX2967_DCF_EN,
96 regs + ZX2967_THERMAL_DCF);
97 val = readl_relaxed(regs + ZX2967_THERMAL_CTRL)
98 & ZX2967_THERMAL_TEMP_MASK;
99 writel_relaxed(ZX2967_POWER_MODE_HIGH,
100 regs + ZX2967_THERMAL_POWER_MODE);
101
102 /*
103 * Calculate temperature
104 * In dts, slope is multiplied by 1000.
105 */
106 *temp = DIV_ROUND_CLOSEST(((s32)val + priv->tzd->tzp->offset) * 1000,
107 priv->tzd->tzp->slope);
108
109unlock:
110 mutex_unlock(&priv->lock);
111 return ret;
112}
113
114static struct thermal_zone_of_device_ops zx2967_of_thermal_ops = {
115 .get_temp = zx2967_thermal_get_temp,
116};
117
118static int zx2967_thermal_probe(struct platform_device *pdev)
119{
120 struct zx2967_thermal_priv *priv;
121 struct resource *res;
122 int ret;
123
124 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
125 if (!priv)
126 return -ENOMEM;
127
128 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
129 priv->regs = devm_ioremap_resource(&pdev->dev, res);
130 if (IS_ERR(priv->regs))
131 return PTR_ERR(priv->regs);
132
133 priv->clk_topcrm = devm_clk_get(&pdev->dev, "topcrm");
134 if (IS_ERR(priv->clk_topcrm)) {
135 ret = PTR_ERR(priv->clk_topcrm);
136 dev_err(&pdev->dev, "failed to get topcrm clock: %d\n", ret);
137 return ret;
138 }
139
140 ret = clk_prepare_enable(priv->clk_topcrm);
141 if (ret) {
142 dev_err(&pdev->dev, "failed to enable topcrm clock: %d\n",
143 ret);
144 return ret;
145 }
146
147 priv->clk_apb = devm_clk_get(&pdev->dev, "apb");
148 if (IS_ERR(priv->clk_apb)) {
149 ret = PTR_ERR(priv->clk_apb);
150 dev_err(&pdev->dev, "failed to get apb clock: %d\n", ret);
151 goto disable_clk_topcrm;
152 }
153
154 ret = clk_prepare_enable(priv->clk_apb);
155 if (ret) {
156 dev_err(&pdev->dev, "failed to enable apb clock: %d\n",
157 ret);
158 goto disable_clk_topcrm;
159 }
160
161 mutex_init(&priv->lock);
162 priv->tzd = thermal_zone_of_sensor_register(&pdev->dev,
163 0, priv, &zx2967_of_thermal_ops);
164
165 if (IS_ERR(priv->tzd)) {
166 ret = PTR_ERR(priv->tzd);
167 dev_err(&pdev->dev, "failed to register sensor: %d\n", ret);
168 goto disable_clk_all;
169 }
170
171 if (priv->tzd->tzp->slope == 0) {
172 thermal_zone_of_sensor_unregister(&pdev->dev, priv->tzd);
173 dev_err(&pdev->dev, "coefficients of sensor is invalid\n");
174 ret = -EINVAL;
175 goto disable_clk_all;
176 }
177
178 priv->dev = &pdev->dev;
179 platform_set_drvdata(pdev, priv);
180
181 return 0;
182
183disable_clk_all:
184 clk_disable_unprepare(priv->clk_apb);
185disable_clk_topcrm:
186 clk_disable_unprepare(priv->clk_topcrm);
187 return ret;
188}
189
190static int zx2967_thermal_exit(struct platform_device *pdev)
191{
192 struct zx2967_thermal_priv *priv = platform_get_drvdata(pdev);
193
194 thermal_zone_of_sensor_unregister(&pdev->dev, priv->tzd);
195 clk_disable_unprepare(priv->clk_topcrm);
196 clk_disable_unprepare(priv->clk_apb);
197
198 return 0;
199}
200
201static const struct of_device_id zx2967_thermal_id_table[] = {
202 { .compatible = "zte,zx296718-thermal" },
203 {}
204};
205MODULE_DEVICE_TABLE(of, zx2967_thermal_id_table);
206
207#ifdef CONFIG_PM_SLEEP
208static int zx2967_thermal_suspend(struct device *dev)
209{
210 struct platform_device *pdev = to_platform_device(dev);
211 struct zx2967_thermal_priv *priv = platform_get_drvdata(pdev);
212
213 if (priv && priv->clk_topcrm)
214 clk_disable_unprepare(priv->clk_topcrm);
215
216 if (priv && priv->clk_apb)
217 clk_disable_unprepare(priv->clk_apb);
218
219 return 0;
220}
221
222static int zx2967_thermal_resume(struct device *dev)
223{
224 struct platform_device *pdev = to_platform_device(dev);
225 struct zx2967_thermal_priv *priv = platform_get_drvdata(pdev);
226 int error;
227
228 error = clk_prepare_enable(priv->clk_topcrm);
229 if (error)
230 return error;
231
232 error = clk_prepare_enable(priv->clk_apb);
233 if (error) {
234 clk_disable_unprepare(priv->clk_topcrm);
235 return error;
236 }
237
238 return 0;
239}
240#endif
241
242static SIMPLE_DEV_PM_OPS(zx2967_thermal_pm_ops,
243 zx2967_thermal_suspend, zx2967_thermal_resume);
244
245static struct platform_driver zx2967_thermal_driver = {
246 .probe = zx2967_thermal_probe,
247 .remove = zx2967_thermal_exit,
248 .driver = {
249 .name = "zx2967_thermal",
250 .of_match_table = zx2967_thermal_id_table,
251 .pm = &zx2967_thermal_pm_ops,
252 },
253};
254module_platform_driver(zx2967_thermal_driver);
255
256MODULE_AUTHOR("Baoyou Xie <baoyou.xie@linaro.org>");
257MODULE_DESCRIPTION("ZTE zx2967 thermal driver");
258MODULE_LICENSE("GPL v2");
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index f73ee9534d83..0339daf4ca02 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -249,7 +249,8 @@ static int f2fs_write_meta_page(struct page *page,
249 dec_page_count(sbi, F2FS_DIRTY_META); 249 dec_page_count(sbi, F2FS_DIRTY_META);
250 250
251 if (wbc->for_reclaim) 251 if (wbc->for_reclaim)
252 f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, META, WRITE); 252 f2fs_submit_merged_bio_cond(sbi, page->mapping->host,
253 0, page->index, META, WRITE);
253 254
254 unlock_page(page); 255 unlock_page(page);
255 256
@@ -493,6 +494,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
493#ifdef CONFIG_F2FS_FAULT_INJECTION 494#ifdef CONFIG_F2FS_FAULT_INJECTION
494 if (time_to_inject(sbi, FAULT_ORPHAN)) { 495 if (time_to_inject(sbi, FAULT_ORPHAN)) {
495 spin_unlock(&im->ino_lock); 496 spin_unlock(&im->ino_lock);
497 f2fs_show_injection_info(FAULT_ORPHAN);
496 return -ENOSPC; 498 return -ENOSPC;
497 } 499 }
498#endif 500#endif
@@ -681,8 +683,7 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
681 return -EINVAL; 683 return -EINVAL;
682 } 684 }
683 685
684 crc = le32_to_cpu(*((__le32 *)((unsigned char *)*cp_block 686 crc = cur_cp_crc(*cp_block);
685 + crc_offset)));
686 if (!f2fs_crc_valid(sbi, crc, *cp_block, crc_offset)) { 687 if (!f2fs_crc_valid(sbi, crc, *cp_block, crc_offset)) {
687 f2fs_msg(sbi->sb, KERN_WARNING, "invalid crc value"); 688 f2fs_msg(sbi->sb, KERN_WARNING, "invalid crc value");
688 return -EINVAL; 689 return -EINVAL;
@@ -891,7 +892,7 @@ retry:
891 F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA)); 892 F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA));
892 return 0; 893 return 0;
893 } 894 }
894 fi = list_entry(head->next, struct f2fs_inode_info, dirty_list); 895 fi = list_first_entry(head, struct f2fs_inode_info, dirty_list);
895 inode = igrab(&fi->vfs_inode); 896 inode = igrab(&fi->vfs_inode);
896 spin_unlock(&sbi->inode_lock[type]); 897 spin_unlock(&sbi->inode_lock[type]);
897 if (inode) { 898 if (inode) {
@@ -924,7 +925,7 @@ int f2fs_sync_inode_meta(struct f2fs_sb_info *sbi)
924 spin_unlock(&sbi->inode_lock[DIRTY_META]); 925 spin_unlock(&sbi->inode_lock[DIRTY_META]);
925 return 0; 926 return 0;
926 } 927 }
927 fi = list_entry(head->next, struct f2fs_inode_info, 928 fi = list_first_entry(head, struct f2fs_inode_info,
928 gdirty_list); 929 gdirty_list);
929 inode = igrab(&fi->vfs_inode); 930 inode = igrab(&fi->vfs_inode);
930 spin_unlock(&sbi->inode_lock[DIRTY_META]); 931 spin_unlock(&sbi->inode_lock[DIRTY_META]);
@@ -998,8 +999,6 @@ out:
998static void unblock_operations(struct f2fs_sb_info *sbi) 999static void unblock_operations(struct f2fs_sb_info *sbi)
999{ 1000{
1000 up_write(&sbi->node_write); 1001 up_write(&sbi->node_write);
1001
1002 build_free_nids(sbi, false);
1003 f2fs_unlock_all(sbi); 1002 f2fs_unlock_all(sbi);
1004} 1003}
1005 1004
@@ -1025,6 +1024,10 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1025 1024
1026 spin_lock(&sbi->cp_lock); 1025 spin_lock(&sbi->cp_lock);
1027 1026
1027 if (cpc->reason == CP_UMOUNT && ckpt->cp_pack_total_block_count >
1028 sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks)
1029 disable_nat_bits(sbi, false);
1030
1028 if (cpc->reason == CP_UMOUNT) 1031 if (cpc->reason == CP_UMOUNT)
1029 __set_ckpt_flags(ckpt, CP_UMOUNT_FLAG); 1032 __set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
1030 else 1033 else
@@ -1137,6 +1140,28 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1137 1140
1138 start_blk = __start_cp_next_addr(sbi); 1141 start_blk = __start_cp_next_addr(sbi);
1139 1142
1143 /* write nat bits */
1144 if (enabled_nat_bits(sbi, cpc)) {
1145 __u64 cp_ver = cur_cp_version(ckpt);
1146 unsigned int i;
1147 block_t blk;
1148
1149 cp_ver |= ((__u64)crc32 << 32);
1150 *(__le64 *)nm_i->nat_bits = cpu_to_le64(cp_ver);
1151
1152 blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks;
1153 for (i = 0; i < nm_i->nat_bits_blocks; i++)
1154 update_meta_page(sbi, nm_i->nat_bits +
1155 (i << F2FS_BLKSIZE_BITS), blk + i);
1156
1157 /* Flush all the NAT BITS pages */
1158 while (get_pages(sbi, F2FS_DIRTY_META)) {
1159 sync_meta_pages(sbi, META, LONG_MAX);
1160 if (unlikely(f2fs_cp_error(sbi)))
1161 return -EIO;
1162 }
1163 }
1164
1140 /* need to wait for end_io results */ 1165 /* need to wait for end_io results */
1141 wait_on_all_pages_writeback(sbi); 1166 wait_on_all_pages_writeback(sbi);
1142 if (unlikely(f2fs_cp_error(sbi))) 1167 if (unlikely(f2fs_cp_error(sbi)))
@@ -1248,15 +1273,20 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1248 f2fs_flush_merged_bios(sbi); 1273 f2fs_flush_merged_bios(sbi);
1249 1274
1250 /* this is the case of multiple fstrims without any changes */ 1275 /* this is the case of multiple fstrims without any changes */
1251 if (cpc->reason == CP_DISCARD && !is_sbi_flag_set(sbi, SBI_IS_DIRTY)) { 1276 if (cpc->reason == CP_DISCARD) {
1252 f2fs_bug_on(sbi, NM_I(sbi)->dirty_nat_cnt); 1277 if (!exist_trim_candidates(sbi, cpc)) {
1253 f2fs_bug_on(sbi, SIT_I(sbi)->dirty_sentries); 1278 unblock_operations(sbi);
1254 f2fs_bug_on(sbi, prefree_segments(sbi)); 1279 goto out;
1255 flush_sit_entries(sbi, cpc); 1280 }
1256 clear_prefree_segments(sbi, cpc); 1281
1257 f2fs_wait_all_discard_bio(sbi); 1282 if (NM_I(sbi)->dirty_nat_cnt == 0 &&
1258 unblock_operations(sbi); 1283 SIT_I(sbi)->dirty_sentries == 0 &&
1259 goto out; 1284 prefree_segments(sbi) == 0) {
1285 flush_sit_entries(sbi, cpc);
1286 clear_prefree_segments(sbi, cpc);
1287 unblock_operations(sbi);
1288 goto out;
1289 }
1260 } 1290 }
1261 1291
1262 /* 1292 /*
@@ -1268,17 +1298,15 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1268 ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver); 1298 ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver);
1269 1299
1270 /* write cached NAT/SIT entries to NAT/SIT area */ 1300 /* write cached NAT/SIT entries to NAT/SIT area */
1271 flush_nat_entries(sbi); 1301 flush_nat_entries(sbi, cpc);
1272 flush_sit_entries(sbi, cpc); 1302 flush_sit_entries(sbi, cpc);
1273 1303
1274 /* unlock all the fs_lock[] in do_checkpoint() */ 1304 /* unlock all the fs_lock[] in do_checkpoint() */
1275 err = do_checkpoint(sbi, cpc); 1305 err = do_checkpoint(sbi, cpc);
1276 if (err) { 1306 if (err)
1277 release_discard_addrs(sbi); 1307 release_discard_addrs(sbi);
1278 } else { 1308 else
1279 clear_prefree_segments(sbi, cpc); 1309 clear_prefree_segments(sbi, cpc);
1280 f2fs_wait_all_discard_bio(sbi);
1281 }
1282 1310
1283 unblock_operations(sbi); 1311 unblock_operations(sbi);
1284 stat_inc_cp_count(sbi->stat_info); 1312 stat_inc_cp_count(sbi->stat_info);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9ac262564fa6..1375fef11146 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -55,8 +55,10 @@ static void f2fs_read_end_io(struct bio *bio)
55 int i; 55 int i;
56 56
57#ifdef CONFIG_F2FS_FAULT_INJECTION 57#ifdef CONFIG_F2FS_FAULT_INJECTION
58 if (time_to_inject(F2FS_P_SB(bio->bi_io_vec->bv_page), FAULT_IO)) 58 if (time_to_inject(F2FS_P_SB(bio->bi_io_vec->bv_page), FAULT_IO)) {
59 f2fs_show_injection_info(FAULT_IO);
59 bio->bi_error = -EIO; 60 bio->bi_error = -EIO;
61 }
60#endif 62#endif
61 63
62 if (f2fs_bio_encrypted(bio)) { 64 if (f2fs_bio_encrypted(bio)) {
@@ -93,6 +95,17 @@ static void f2fs_write_end_io(struct bio *bio)
93 struct page *page = bvec->bv_page; 95 struct page *page = bvec->bv_page;
94 enum count_type type = WB_DATA_TYPE(page); 96 enum count_type type = WB_DATA_TYPE(page);
95 97
98 if (IS_DUMMY_WRITTEN_PAGE(page)) {
99 set_page_private(page, (unsigned long)NULL);
100 ClearPagePrivate(page);
101 unlock_page(page);
102 mempool_free(page, sbi->write_io_dummy);
103
104 if (unlikely(bio->bi_error))
105 f2fs_stop_checkpoint(sbi, true);
106 continue;
107 }
108
96 fscrypt_pullback_bio_page(&page, true); 109 fscrypt_pullback_bio_page(&page, true);
97 110
98 if (unlikely(bio->bi_error)) { 111 if (unlikely(bio->bi_error)) {
@@ -171,10 +184,46 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi,
171 struct bio *bio, enum page_type type) 184 struct bio *bio, enum page_type type)
172{ 185{
173 if (!is_read_io(bio_op(bio))) { 186 if (!is_read_io(bio_op(bio))) {
187 unsigned int start;
188
174 if (f2fs_sb_mounted_blkzoned(sbi->sb) && 189 if (f2fs_sb_mounted_blkzoned(sbi->sb) &&
175 current->plug && (type == DATA || type == NODE)) 190 current->plug && (type == DATA || type == NODE))
176 blk_finish_plug(current->plug); 191 blk_finish_plug(current->plug);
192
193 if (type != DATA && type != NODE)
194 goto submit_io;
195
196 start = bio->bi_iter.bi_size >> F2FS_BLKSIZE_BITS;
197 start %= F2FS_IO_SIZE(sbi);
198
199 if (start == 0)
200 goto submit_io;
201
202 /* fill dummy pages */
203 for (; start < F2FS_IO_SIZE(sbi); start++) {
204 struct page *page =
205 mempool_alloc(sbi->write_io_dummy,
206 GFP_NOIO | __GFP_ZERO | __GFP_NOFAIL);
207 f2fs_bug_on(sbi, !page);
208
209 SetPagePrivate(page);
210 set_page_private(page, (unsigned long)DUMMY_WRITTEN_PAGE);
211 lock_page(page);
212 if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE)
213 f2fs_bug_on(sbi, 1);
214 }
215 /*
216 * In the NODE case, we lose next block address chain. So, we
217 * need to do checkpoint in f2fs_sync_file.
218 */
219 if (type == NODE)
220 set_sbi_flag(sbi, SBI_NEED_CP);
177 } 221 }
222submit_io:
223 if (is_read_io(bio_op(bio)))
224 trace_f2fs_submit_read_bio(sbi->sb, type, bio);
225 else
226 trace_f2fs_submit_write_bio(sbi->sb, type, bio);
178 submit_bio(bio); 227 submit_bio(bio);
179} 228}
180 229
@@ -185,19 +234,19 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
185 if (!io->bio) 234 if (!io->bio)
186 return; 235 return;
187 236
237 bio_set_op_attrs(io->bio, fio->op, fio->op_flags);
238
188 if (is_read_io(fio->op)) 239 if (is_read_io(fio->op))
189 trace_f2fs_submit_read_bio(io->sbi->sb, fio, io->bio); 240 trace_f2fs_prepare_read_bio(io->sbi->sb, fio->type, io->bio);
190 else 241 else
191 trace_f2fs_submit_write_bio(io->sbi->sb, fio, io->bio); 242 trace_f2fs_prepare_write_bio(io->sbi->sb, fio->type, io->bio);
192
193 bio_set_op_attrs(io->bio, fio->op, fio->op_flags);
194 243
195 __submit_bio(io->sbi, io->bio, fio->type); 244 __submit_bio(io->sbi, io->bio, fio->type);
196 io->bio = NULL; 245 io->bio = NULL;
197} 246}
198 247
199static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode, 248static bool __has_merged_page(struct f2fs_bio_info *io,
200 struct page *page, nid_t ino) 249 struct inode *inode, nid_t ino, pgoff_t idx)
201{ 250{
202 struct bio_vec *bvec; 251 struct bio_vec *bvec;
203 struct page *target; 252 struct page *target;
@@ -206,7 +255,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
206 if (!io->bio) 255 if (!io->bio)
207 return false; 256 return false;
208 257
209 if (!inode && !page && !ino) 258 if (!inode && !ino)
210 return true; 259 return true;
211 260
212 bio_for_each_segment_all(bvec, io->bio, i) { 261 bio_for_each_segment_all(bvec, io->bio, i) {
@@ -216,10 +265,11 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
216 else 265 else
217 target = fscrypt_control_page(bvec->bv_page); 266 target = fscrypt_control_page(bvec->bv_page);
218 267
268 if (idx != target->index)
269 continue;
270
219 if (inode && inode == target->mapping->host) 271 if (inode && inode == target->mapping->host)
220 return true; 272 return true;
221 if (page && page == target)
222 return true;
223 if (ino && ino == ino_of_node(target)) 273 if (ino && ino == ino_of_node(target))
224 return true; 274 return true;
225 } 275 }
@@ -228,22 +278,21 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
228} 278}
229 279
230static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode, 280static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
231 struct page *page, nid_t ino, 281 nid_t ino, pgoff_t idx, enum page_type type)
232 enum page_type type)
233{ 282{
234 enum page_type btype = PAGE_TYPE_OF_BIO(type); 283 enum page_type btype = PAGE_TYPE_OF_BIO(type);
235 struct f2fs_bio_info *io = &sbi->write_io[btype]; 284 struct f2fs_bio_info *io = &sbi->write_io[btype];
236 bool ret; 285 bool ret;
237 286
238 down_read(&io->io_rwsem); 287 down_read(&io->io_rwsem);
239 ret = __has_merged_page(io, inode, page, ino); 288 ret = __has_merged_page(io, inode, ino, idx);
240 up_read(&io->io_rwsem); 289 up_read(&io->io_rwsem);
241 return ret; 290 return ret;
242} 291}
243 292
244static void __f2fs_submit_merged_bio(struct f2fs_sb_info *sbi, 293static void __f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
245 struct inode *inode, struct page *page, 294 struct inode *inode, nid_t ino, pgoff_t idx,
246 nid_t ino, enum page_type type, int rw) 295 enum page_type type, int rw)
247{ 296{
248 enum page_type btype = PAGE_TYPE_OF_BIO(type); 297 enum page_type btype = PAGE_TYPE_OF_BIO(type);
249 struct f2fs_bio_info *io; 298 struct f2fs_bio_info *io;
@@ -252,16 +301,16 @@ static void __f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
252 301
253 down_write(&io->io_rwsem); 302 down_write(&io->io_rwsem);
254 303
255 if (!__has_merged_page(io, inode, page, ino)) 304 if (!__has_merged_page(io, inode, ino, idx))
256 goto out; 305 goto out;
257 306
258 /* change META to META_FLUSH in the checkpoint procedure */ 307 /* change META to META_FLUSH in the checkpoint procedure */
259 if (type >= META_FLUSH) { 308 if (type >= META_FLUSH) {
260 io->fio.type = META_FLUSH; 309 io->fio.type = META_FLUSH;
261 io->fio.op = REQ_OP_WRITE; 310 io->fio.op = REQ_OP_WRITE;
262 io->fio.op_flags = REQ_PREFLUSH | REQ_META | REQ_PRIO; 311 io->fio.op_flags = REQ_META | REQ_PRIO;
263 if (!test_opt(sbi, NOBARRIER)) 312 if (!test_opt(sbi, NOBARRIER))
264 io->fio.op_flags |= REQ_FUA; 313 io->fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
265 } 314 }
266 __submit_merged_bio(io); 315 __submit_merged_bio(io);
267out: 316out:
@@ -271,15 +320,15 @@ out:
271void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi, enum page_type type, 320void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi, enum page_type type,
272 int rw) 321 int rw)
273{ 322{
274 __f2fs_submit_merged_bio(sbi, NULL, NULL, 0, type, rw); 323 __f2fs_submit_merged_bio(sbi, NULL, 0, 0, type, rw);
275} 324}
276 325
277void f2fs_submit_merged_bio_cond(struct f2fs_sb_info *sbi, 326void f2fs_submit_merged_bio_cond(struct f2fs_sb_info *sbi,
278 struct inode *inode, struct page *page, 327 struct inode *inode, nid_t ino, pgoff_t idx,
279 nid_t ino, enum page_type type, int rw) 328 enum page_type type, int rw)
280{ 329{
281 if (has_merged_page(sbi, inode, page, ino, type)) 330 if (has_merged_page(sbi, inode, ino, idx, type))
282 __f2fs_submit_merged_bio(sbi, inode, page, ino, type, rw); 331 __f2fs_submit_merged_bio(sbi, inode, ino, idx, type, rw);
283} 332}
284 333
285void f2fs_flush_merged_bios(struct f2fs_sb_info *sbi) 334void f2fs_flush_merged_bios(struct f2fs_sb_info *sbi)
@@ -315,13 +364,14 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
315 return 0; 364 return 0;
316} 365}
317 366
318void f2fs_submit_page_mbio(struct f2fs_io_info *fio) 367int f2fs_submit_page_mbio(struct f2fs_io_info *fio)
319{ 368{
320 struct f2fs_sb_info *sbi = fio->sbi; 369 struct f2fs_sb_info *sbi = fio->sbi;
321 enum page_type btype = PAGE_TYPE_OF_BIO(fio->type); 370 enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
322 struct f2fs_bio_info *io; 371 struct f2fs_bio_info *io;
323 bool is_read = is_read_io(fio->op); 372 bool is_read = is_read_io(fio->op);
324 struct page *bio_page; 373 struct page *bio_page;
374 int err = 0;
325 375
326 io = is_read ? &sbi->read_io : &sbi->write_io[btype]; 376 io = is_read ? &sbi->read_io : &sbi->write_io[btype];
327 377
@@ -331,6 +381,9 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
331 381
332 bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page; 382 bio_page = fio->encrypted_page ? fio->encrypted_page : fio->page;
333 383
384 /* set submitted = 1 as a return value */
385 fio->submitted = 1;
386
334 if (!is_read) 387 if (!is_read)
335 inc_page_count(sbi, WB_DATA_TYPE(bio_page)); 388 inc_page_count(sbi, WB_DATA_TYPE(bio_page));
336 389
@@ -342,6 +395,13 @@ void f2fs_submit_page_mbio(struct f2fs_io_info *fio)
342 __submit_merged_bio(io); 395 __submit_merged_bio(io);
343alloc_new: 396alloc_new:
344 if (io->bio == NULL) { 397 if (io->bio == NULL) {
398 if ((fio->type == DATA || fio->type == NODE) &&
399 fio->new_blkaddr & F2FS_IO_SIZE_MASK(sbi)) {
400 err = -EAGAIN;
401 if (!is_read)
402 dec_page_count(sbi, WB_DATA_TYPE(bio_page));
403 goto out_fail;
404 }
345 io->bio = __bio_alloc(sbi, fio->new_blkaddr, 405 io->bio = __bio_alloc(sbi, fio->new_blkaddr,
346 BIO_MAX_PAGES, is_read); 406 BIO_MAX_PAGES, is_read);
347 io->fio = *fio; 407 io->fio = *fio;
@@ -355,9 +415,10 @@ alloc_new:
355 415
356 io->last_block_in_bio = fio->new_blkaddr; 416 io->last_block_in_bio = fio->new_blkaddr;
357 f2fs_trace_ios(fio, 0); 417 f2fs_trace_ios(fio, 0);
358 418out_fail:
359 up_write(&io->io_rwsem); 419 up_write(&io->io_rwsem);
360 trace_f2fs_submit_page_mbio(fio->page, fio); 420 trace_f2fs_submit_page_mbio(fio->page, fio);
421 return err;
361} 422}
362 423
363static void __set_data_blkaddr(struct dnode_of_data *dn) 424static void __set_data_blkaddr(struct dnode_of_data *dn)
@@ -453,7 +514,7 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
453 514
454int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index) 515int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index)
455{ 516{
456 struct extent_info ei; 517 struct extent_info ei = {0,0,0};
457 struct inode *inode = dn->inode; 518 struct inode *inode = dn->inode;
458 519
459 if (f2fs_lookup_extent_cache(inode, index, &ei)) { 520 if (f2fs_lookup_extent_cache(inode, index, &ei)) {
@@ -470,7 +531,7 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index,
470 struct address_space *mapping = inode->i_mapping; 531 struct address_space *mapping = inode->i_mapping;
471 struct dnode_of_data dn; 532 struct dnode_of_data dn;
472 struct page *page; 533 struct page *page;
473 struct extent_info ei; 534 struct extent_info ei = {0,0,0};
474 int err; 535 int err;
475 struct f2fs_io_info fio = { 536 struct f2fs_io_info fio = {
476 .sbi = F2FS_I_SB(inode), 537 .sbi = F2FS_I_SB(inode),
@@ -694,6 +755,9 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
694 struct f2fs_map_blocks map; 755 struct f2fs_map_blocks map;
695 int err = 0; 756 int err = 0;
696 757
758 if (is_inode_flag_set(inode, FI_NO_PREALLOC))
759 return 0;
760
697 map.m_lblk = F2FS_BLK_ALIGN(iocb->ki_pos); 761 map.m_lblk = F2FS_BLK_ALIGN(iocb->ki_pos);
698 map.m_len = F2FS_BYTES_TO_BLK(iocb->ki_pos + iov_iter_count(from)); 762 map.m_len = F2FS_BYTES_TO_BLK(iocb->ki_pos + iov_iter_count(from));
699 if (map.m_len > map.m_lblk) 763 if (map.m_len > map.m_lblk)
@@ -742,7 +806,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
742 int err = 0, ofs = 1; 806 int err = 0, ofs = 1;
743 unsigned int ofs_in_node, last_ofs_in_node; 807 unsigned int ofs_in_node, last_ofs_in_node;
744 blkcnt_t prealloc; 808 blkcnt_t prealloc;
745 struct extent_info ei; 809 struct extent_info ei = {0,0,0};
746 block_t blkaddr; 810 block_t blkaddr;
747 811
748 if (!maxblocks) 812 if (!maxblocks)
@@ -806,7 +870,7 @@ next_block:
806 } 870 }
807 if (err) 871 if (err)
808 goto sync_out; 872 goto sync_out;
809 map->m_flags = F2FS_MAP_NEW; 873 map->m_flags |= F2FS_MAP_NEW;
810 blkaddr = dn.data_blkaddr; 874 blkaddr = dn.data_blkaddr;
811 } else { 875 } else {
812 if (flag == F2FS_GET_BLOCK_BMAP) { 876 if (flag == F2FS_GET_BLOCK_BMAP) {
@@ -906,7 +970,7 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
906 if (!err) { 970 if (!err) {
907 map_bh(bh, inode->i_sb, map.m_pblk); 971 map_bh(bh, inode->i_sb, map.m_pblk);
908 bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags; 972 bh->b_state = (bh->b_state & ~F2FS_MAP_FLAGS) | map.m_flags;
909 bh->b_size = map.m_len << inode->i_blkbits; 973 bh->b_size = (u64)map.m_len << inode->i_blkbits;
910 } 974 }
911 return err; 975 return err;
912} 976}
@@ -1088,7 +1152,7 @@ static int f2fs_mpage_readpages(struct address_space *mapping,
1088 1152
1089 prefetchw(&page->flags); 1153 prefetchw(&page->flags);
1090 if (pages) { 1154 if (pages) {
1091 page = list_entry(pages->prev, struct page, lru); 1155 page = list_last_entry(pages, struct page, lru);
1092 list_del(&page->lru); 1156 list_del(&page->lru);
1093 if (add_to_page_cache_lru(page, mapping, 1157 if (add_to_page_cache_lru(page, mapping,
1094 page->index, 1158 page->index,
@@ -1207,7 +1271,7 @@ static int f2fs_read_data_pages(struct file *file,
1207 struct list_head *pages, unsigned nr_pages) 1271 struct list_head *pages, unsigned nr_pages)
1208{ 1272{
1209 struct inode *inode = file->f_mapping->host; 1273 struct inode *inode = file->f_mapping->host;
1210 struct page *page = list_entry(pages->prev, struct page, lru); 1274 struct page *page = list_last_entry(pages, struct page, lru);
1211 1275
1212 trace_f2fs_readpages(inode, page, nr_pages); 1276 trace_f2fs_readpages(inode, page, nr_pages);
1213 1277
@@ -1288,8 +1352,8 @@ out_writepage:
1288 return err; 1352 return err;
1289} 1353}
1290 1354
1291static int f2fs_write_data_page(struct page *page, 1355static int __write_data_page(struct page *page, bool *submitted,
1292 struct writeback_control *wbc) 1356 struct writeback_control *wbc)
1293{ 1357{
1294 struct inode *inode = page->mapping->host; 1358 struct inode *inode = page->mapping->host;
1295 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 1359 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -1307,6 +1371,7 @@ static int f2fs_write_data_page(struct page *page,
1307 .op_flags = wbc_to_write_flags(wbc), 1371 .op_flags = wbc_to_write_flags(wbc),
1308 .page = page, 1372 .page = page,
1309 .encrypted_page = NULL, 1373 .encrypted_page = NULL,
1374 .submitted = false,
1310 }; 1375 };
1311 1376
1312 trace_f2fs_writepage(page, DATA); 1377 trace_f2fs_writepage(page, DATA);
@@ -1352,9 +1417,12 @@ write:
1352 goto redirty_out; 1417 goto redirty_out;
1353 1418
1354 err = -EAGAIN; 1419 err = -EAGAIN;
1355 f2fs_lock_op(sbi); 1420 if (f2fs_has_inline_data(inode)) {
1356 if (f2fs_has_inline_data(inode))
1357 err = f2fs_write_inline_data(inode, page); 1421 err = f2fs_write_inline_data(inode, page);
1422 if (!err)
1423 goto out;
1424 }
1425 f2fs_lock_op(sbi);
1358 if (err == -EAGAIN) 1426 if (err == -EAGAIN)
1359 err = do_write_data_page(&fio); 1427 err = do_write_data_page(&fio);
1360 if (F2FS_I(inode)->last_disk_size < psize) 1428 if (F2FS_I(inode)->last_disk_size < psize)
@@ -1370,15 +1438,22 @@ out:
1370 ClearPageUptodate(page); 1438 ClearPageUptodate(page);
1371 1439
1372 if (wbc->for_reclaim) { 1440 if (wbc->for_reclaim) {
1373 f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, DATA, WRITE); 1441 f2fs_submit_merged_bio_cond(sbi, inode, 0, page->index,
1442 DATA, WRITE);
1374 remove_dirty_inode(inode); 1443 remove_dirty_inode(inode);
1444 submitted = NULL;
1375 } 1445 }
1376 1446
1377 unlock_page(page); 1447 unlock_page(page);
1378 f2fs_balance_fs(sbi, need_balance_fs); 1448 f2fs_balance_fs(sbi, need_balance_fs);
1379 1449
1380 if (unlikely(f2fs_cp_error(sbi))) 1450 if (unlikely(f2fs_cp_error(sbi))) {
1381 f2fs_submit_merged_bio(sbi, DATA, WRITE); 1451 f2fs_submit_merged_bio(sbi, DATA, WRITE);
1452 submitted = NULL;
1453 }
1454
1455 if (submitted)
1456 *submitted = fio.submitted;
1382 1457
1383 return 0; 1458 return 0;
1384 1459
@@ -1390,6 +1465,12 @@ redirty_out:
1390 return err; 1465 return err;
1391} 1466}
1392 1467
1468static int f2fs_write_data_page(struct page *page,
1469 struct writeback_control *wbc)
1470{
1471 return __write_data_page(page, NULL, wbc);
1472}
1473
1393/* 1474/*
1394 * This function was copied from write_cche_pages from mm/page-writeback.c. 1475 * This function was copied from write_cche_pages from mm/page-writeback.c.
1395 * The major change is making write step of cold data page separately from 1476 * The major change is making write step of cold data page separately from
@@ -1406,10 +1487,10 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
1406 pgoff_t index; 1487 pgoff_t index;
1407 pgoff_t end; /* Inclusive */ 1488 pgoff_t end; /* Inclusive */
1408 pgoff_t done_index; 1489 pgoff_t done_index;
1490 pgoff_t last_idx = ULONG_MAX;
1409 int cycled; 1491 int cycled;
1410 int range_whole = 0; 1492 int range_whole = 0;
1411 int tag; 1493 int tag;
1412 int nwritten = 0;
1413 1494
1414 pagevec_init(&pvec, 0); 1495 pagevec_init(&pvec, 0);
1415 1496
@@ -1446,6 +1527,7 @@ retry:
1446 1527
1447 for (i = 0; i < nr_pages; i++) { 1528 for (i = 0; i < nr_pages; i++) {
1448 struct page *page = pvec.pages[i]; 1529 struct page *page = pvec.pages[i];
1530 bool submitted = false;
1449 1531
1450 if (page->index > end) { 1532 if (page->index > end) {
1451 done = 1; 1533 done = 1;
@@ -1479,7 +1561,7 @@ continue_unlock:
1479 if (!clear_page_dirty_for_io(page)) 1561 if (!clear_page_dirty_for_io(page))
1480 goto continue_unlock; 1562 goto continue_unlock;
1481 1563
1482 ret = mapping->a_ops->writepage(page, wbc); 1564 ret = __write_data_page(page, &submitted, wbc);
1483 if (unlikely(ret)) { 1565 if (unlikely(ret)) {
1484 /* 1566 /*
1485 * keep nr_to_write, since vfs uses this to 1567 * keep nr_to_write, since vfs uses this to
@@ -1493,8 +1575,8 @@ continue_unlock:
1493 done_index = page->index + 1; 1575 done_index = page->index + 1;
1494 done = 1; 1576 done = 1;
1495 break; 1577 break;
1496 } else { 1578 } else if (submitted) {
1497 nwritten++; 1579 last_idx = page->index;
1498 } 1580 }
1499 1581
1500 if (--wbc->nr_to_write <= 0 && 1582 if (--wbc->nr_to_write <= 0 &&
@@ -1516,9 +1598,9 @@ continue_unlock:
1516 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) 1598 if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
1517 mapping->writeback_index = done_index; 1599 mapping->writeback_index = done_index;
1518 1600
1519 if (nwritten) 1601 if (last_idx != ULONG_MAX)
1520 f2fs_submit_merged_bio_cond(F2FS_M_SB(mapping), mapping->host, 1602 f2fs_submit_merged_bio_cond(F2FS_M_SB(mapping), mapping->host,
1521 NULL, 0, DATA, WRITE); 1603 0, last_idx, DATA, WRITE);
1522 1604
1523 return ret; 1605 return ret;
1524} 1606}
@@ -1591,14 +1673,15 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
1591 struct dnode_of_data dn; 1673 struct dnode_of_data dn;
1592 struct page *ipage; 1674 struct page *ipage;
1593 bool locked = false; 1675 bool locked = false;
1594 struct extent_info ei; 1676 struct extent_info ei = {0,0,0};
1595 int err = 0; 1677 int err = 0;
1596 1678
1597 /* 1679 /*
1598 * we already allocated all the blocks, so we don't need to get 1680 * we already allocated all the blocks, so we don't need to get
1599 * the block addresses when there is no need to fill the page. 1681 * the block addresses when there is no need to fill the page.
1600 */ 1682 */
1601 if (!f2fs_has_inline_data(inode) && len == PAGE_SIZE) 1683 if (!f2fs_has_inline_data(inode) && len == PAGE_SIZE &&
1684 !is_inode_flag_set(inode, FI_NO_PREALLOC))
1602 return 0; 1685 return 0;
1603 1686
1604 if (f2fs_has_inline_data(inode) || 1687 if (f2fs_has_inline_data(inode) ||
@@ -1682,7 +1765,12 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
1682 goto fail; 1765 goto fail;
1683 } 1766 }
1684repeat: 1767repeat:
1685 page = grab_cache_page_write_begin(mapping, index, flags); 1768 /*
1769 * Do not use grab_cache_page_write_begin() to avoid deadlock due to
1770 * wait_for_stable_page. Will wait that below with our IO control.
1771 */
1772 page = pagecache_get_page(mapping, index,
1773 FGP_LOCK | FGP_WRITE | FGP_CREAT, GFP_NOFS);
1686 if (!page) { 1774 if (!page) {
1687 err = -ENOMEM; 1775 err = -ENOMEM;
1688 goto fail; 1776 goto fail;
@@ -1715,6 +1803,11 @@ repeat:
1715 if (len == PAGE_SIZE || PageUptodate(page)) 1803 if (len == PAGE_SIZE || PageUptodate(page))
1716 return 0; 1804 return 0;
1717 1805
1806 if (!(pos & (PAGE_SIZE - 1)) && (pos + len) >= i_size_read(inode)) {
1807 zero_user_segment(page, len, PAGE_SIZE);
1808 return 0;
1809 }
1810
1718 if (blkaddr == NEW_ADDR) { 1811 if (blkaddr == NEW_ADDR) {
1719 zero_user_segment(page, 0, PAGE_SIZE); 1812 zero_user_segment(page, 0, PAGE_SIZE);
1720 SetPageUptodate(page); 1813 SetPageUptodate(page);
@@ -1768,7 +1861,7 @@ static int f2fs_write_end(struct file *file,
1768 * let generic_perform_write() try to copy data again through copied=0. 1861 * let generic_perform_write() try to copy data again through copied=0.
1769 */ 1862 */
1770 if (!PageUptodate(page)) { 1863 if (!PageUptodate(page)) {
1771 if (unlikely(copied != PAGE_SIZE)) 1864 if (unlikely(copied != len))
1772 copied = 0; 1865 copied = 0;
1773 else 1866 else
1774 SetPageUptodate(page); 1867 SetPageUptodate(page);
@@ -1917,7 +2010,7 @@ static int f2fs_set_data_page_dirty(struct page *page)
1917 if (!PageUptodate(page)) 2010 if (!PageUptodate(page))
1918 SetPageUptodate(page); 2011 SetPageUptodate(page);
1919 2012
1920 if (f2fs_is_atomic_file(inode)) { 2013 if (f2fs_is_atomic_file(inode) && !f2fs_is_commit_atomic_write(inode)) {
1921 if (!IS_ATOMIC_WRITTEN_PAGE(page)) { 2014 if (!IS_ATOMIC_WRITTEN_PAGE(page)) {
1922 register_inmem_page(inode, page); 2015 register_inmem_page(inode, page);
1923 return 1; 2016 return 1;
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index fbd5184140d0..a77df377e2e8 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -50,8 +50,16 @@ static void update_general_status(struct f2fs_sb_info *sbi)
50 si->ndirty_files = sbi->ndirty_inode[FILE_INODE]; 50 si->ndirty_files = sbi->ndirty_inode[FILE_INODE];
51 si->ndirty_all = sbi->ndirty_inode[DIRTY_META]; 51 si->ndirty_all = sbi->ndirty_inode[DIRTY_META];
52 si->inmem_pages = get_pages(sbi, F2FS_INMEM_PAGES); 52 si->inmem_pages = get_pages(sbi, F2FS_INMEM_PAGES);
53 si->aw_cnt = atomic_read(&sbi->aw_cnt);
54 si->max_aw_cnt = atomic_read(&sbi->max_aw_cnt);
53 si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA); 55 si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA);
54 si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA); 56 si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA);
57 if (SM_I(sbi) && SM_I(sbi)->fcc_info)
58 si->nr_flush =
59 atomic_read(&SM_I(sbi)->fcc_info->submit_flush);
60 if (SM_I(sbi) && SM_I(sbi)->dcc_info)
61 si->nr_discard =
62 atomic_read(&SM_I(sbi)->dcc_info->submit_discard);
55 si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg; 63 si->total_count = (int)sbi->user_block_count / sbi->blocks_per_seg;
56 si->rsvd_segs = reserved_segments(sbi); 64 si->rsvd_segs = reserved_segments(sbi);
57 si->overp_segs = overprovision_segments(sbi); 65 si->overp_segs = overprovision_segments(sbi);
@@ -62,6 +70,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
62 si->inline_xattr = atomic_read(&sbi->inline_xattr); 70 si->inline_xattr = atomic_read(&sbi->inline_xattr);
63 si->inline_inode = atomic_read(&sbi->inline_inode); 71 si->inline_inode = atomic_read(&sbi->inline_inode);
64 si->inline_dir = atomic_read(&sbi->inline_dir); 72 si->inline_dir = atomic_read(&sbi->inline_dir);
73 si->append = sbi->im[APPEND_INO].ino_num;
74 si->update = sbi->im[UPDATE_INO].ino_num;
65 si->orphans = sbi->im[ORPHAN_INO].ino_num; 75 si->orphans = sbi->im[ORPHAN_INO].ino_num;
66 si->utilization = utilization(sbi); 76 si->utilization = utilization(sbi);
67 77
@@ -183,6 +193,9 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
183 /* build nm */ 193 /* build nm */
184 si->base_mem += sizeof(struct f2fs_nm_info); 194 si->base_mem += sizeof(struct f2fs_nm_info);
185 si->base_mem += __bitmap_size(sbi, NAT_BITMAP); 195 si->base_mem += __bitmap_size(sbi, NAT_BITMAP);
196 si->base_mem += (NM_I(sbi)->nat_bits_blocks << F2FS_BLKSIZE_BITS);
197 si->base_mem += NM_I(sbi)->nat_blocks * NAT_ENTRY_BITMAP_SIZE;
198 si->base_mem += NM_I(sbi)->nat_blocks / 8;
186 199
187get_cache: 200get_cache:
188 si->cache_mem = 0; 201 si->cache_mem = 0;
@@ -192,8 +205,10 @@ get_cache:
192 si->cache_mem += sizeof(struct f2fs_gc_kthread); 205 si->cache_mem += sizeof(struct f2fs_gc_kthread);
193 206
194 /* build merge flush thread */ 207 /* build merge flush thread */
195 if (SM_I(sbi)->cmd_control_info) 208 if (SM_I(sbi)->fcc_info)
196 si->cache_mem += sizeof(struct flush_cmd_control); 209 si->cache_mem += sizeof(struct flush_cmd_control);
210 if (SM_I(sbi)->dcc_info)
211 si->cache_mem += sizeof(struct discard_cmd_control);
197 212
198 /* free nids */ 213 /* free nids */
199 si->cache_mem += (NM_I(sbi)->nid_cnt[FREE_NID_LIST] + 214 si->cache_mem += (NM_I(sbi)->nid_cnt[FREE_NID_LIST] +
@@ -254,8 +269,8 @@ static int stat_show(struct seq_file *s, void *v)
254 si->inline_inode); 269 si->inline_inode);
255 seq_printf(s, " - Inline_dentry Inode: %u\n", 270 seq_printf(s, " - Inline_dentry Inode: %u\n",
256 si->inline_dir); 271 si->inline_dir);
257 seq_printf(s, " - Orphan Inode: %u\n", 272 seq_printf(s, " - Orphan/Append/Update Inode: %u, %u, %u\n",
258 si->orphans); 273 si->orphans, si->append, si->update);
259 seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n", 274 seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n",
260 si->main_area_segs, si->main_area_sections, 275 si->main_area_segs, si->main_area_sections,
261 si->main_area_zones); 276 si->main_area_zones);
@@ -314,8 +329,11 @@ static int stat_show(struct seq_file *s, void *v)
314 seq_printf(s, " - Inner Struct Count: tree: %d(%d), node: %d\n", 329 seq_printf(s, " - Inner Struct Count: tree: %d(%d), node: %d\n",
315 si->ext_tree, si->zombie_tree, si->ext_node); 330 si->ext_tree, si->zombie_tree, si->ext_node);
316 seq_puts(s, "\nBalancing F2FS Async:\n"); 331 seq_puts(s, "\nBalancing F2FS Async:\n");
317 seq_printf(s, " - inmem: %4d, wb_cp_data: %4d, wb_data: %4d\n", 332 seq_printf(s, " - IO (CP: %4d, Data: %4d, Flush: %4d, Discard: %4d)\n",
318 si->inmem_pages, si->nr_wb_cp_data, si->nr_wb_data); 333 si->nr_wb_cp_data, si->nr_wb_data,
334 si->nr_flush, si->nr_discard);
335 seq_printf(s, " - inmem: %4d, atomic IO: %4d (Max. %4d)\n",
336 si->inmem_pages, si->aw_cnt, si->max_aw_cnt);
319 seq_printf(s, " - nodes: %4d in %4d\n", 337 seq_printf(s, " - nodes: %4d in %4d\n",
320 si->ndirty_node, si->node_pages); 338 si->ndirty_node, si->node_pages);
321 seq_printf(s, " - dents: %4d in dirs:%4d (%4d)\n", 339 seq_printf(s, " - dents: %4d in dirs:%4d (%4d)\n",
@@ -414,6 +432,9 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
414 atomic_set(&sbi->inline_dir, 0); 432 atomic_set(&sbi->inline_dir, 0);
415 atomic_set(&sbi->inplace_count, 0); 433 atomic_set(&sbi->inplace_count, 0);
416 434
435 atomic_set(&sbi->aw_cnt, 0);
436 atomic_set(&sbi->max_aw_cnt, 0);
437
417 mutex_lock(&f2fs_stat_mutex); 438 mutex_lock(&f2fs_stat_mutex);
418 list_add_tail(&si->stat_list, &f2fs_stat_list); 439 list_add_tail(&si->stat_list, &f2fs_stat_list);
419 mutex_unlock(&f2fs_stat_mutex); 440 mutex_unlock(&f2fs_stat_mutex);
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 18607fc5240d..4650c9b85de7 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -207,9 +207,13 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
207 f2fs_put_page(dentry_page, 0); 207 f2fs_put_page(dentry_page, 0);
208 } 208 }
209 209
210 if (!de && room && F2FS_I(dir)->chash != namehash) { 210 /* This is to increase the speed of f2fs_create */
211 F2FS_I(dir)->chash = namehash; 211 if (!de && room) {
212 F2FS_I(dir)->clevel = level; 212 F2FS_I(dir)->task = current;
213 if (F2FS_I(dir)->chash != namehash) {
214 F2FS_I(dir)->chash = namehash;
215 F2FS_I(dir)->clevel = level;
216 }
213 } 217 }
214 218
215 return de; 219 return de;
@@ -548,8 +552,10 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
548 552
549start: 553start:
550#ifdef CONFIG_F2FS_FAULT_INJECTION 554#ifdef CONFIG_F2FS_FAULT_INJECTION
551 if (time_to_inject(F2FS_I_SB(dir), FAULT_DIR_DEPTH)) 555 if (time_to_inject(F2FS_I_SB(dir), FAULT_DIR_DEPTH)) {
556 f2fs_show_injection_info(FAULT_DIR_DEPTH);
552 return -ENOSPC; 557 return -ENOSPC;
558 }
553#endif 559#endif
554 if (unlikely(current_depth == MAX_DIR_HASH_DEPTH)) 560 if (unlikely(current_depth == MAX_DIR_HASH_DEPTH))
555 return -ENOSPC; 561 return -ENOSPC;
@@ -646,14 +652,34 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name,
646 struct inode *inode, nid_t ino, umode_t mode) 652 struct inode *inode, nid_t ino, umode_t mode)
647{ 653{
648 struct fscrypt_name fname; 654 struct fscrypt_name fname;
655 struct page *page = NULL;
656 struct f2fs_dir_entry *de = NULL;
649 int err; 657 int err;
650 658
651 err = fscrypt_setup_filename(dir, name, 0, &fname); 659 err = fscrypt_setup_filename(dir, name, 0, &fname);
652 if (err) 660 if (err)
653 return err; 661 return err;
654 662
655 err = __f2fs_do_add_link(dir, &fname, inode, ino, mode); 663 /*
656 664 * An immature stakable filesystem shows a race condition between lookup
665 * and create. If we have same task when doing lookup and create, it's
666 * definitely fine as expected by VFS normally. Otherwise, let's just
667 * verify on-disk dentry one more time, which guarantees filesystem
668 * consistency more.
669 */
670 if (current != F2FS_I(dir)->task) {
671 de = __f2fs_find_entry(dir, &fname, &page);
672 F2FS_I(dir)->task = NULL;
673 }
674 if (de) {
675 f2fs_dentry_kunmap(dir, page);
676 f2fs_put_page(page, 0);
677 err = -EEXIST;
678 } else if (IS_ERR(page)) {
679 err = PTR_ERR(page);
680 } else {
681 err = __f2fs_do_add_link(dir, &fname, inode, ino, mode);
682 }
657 fscrypt_free_filename(&fname); 683 fscrypt_free_filename(&fname);
658 return err; 684 return err;
659} 685}
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index 4db44da7ef69..c6934f014e0f 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -77,7 +77,7 @@ static struct extent_tree *__grab_extent_tree(struct inode *inode)
77 struct extent_tree *et; 77 struct extent_tree *et;
78 nid_t ino = inode->i_ino; 78 nid_t ino = inode->i_ino;
79 79
80 down_write(&sbi->extent_tree_lock); 80 mutex_lock(&sbi->extent_tree_lock);
81 et = radix_tree_lookup(&sbi->extent_tree_root, ino); 81 et = radix_tree_lookup(&sbi->extent_tree_root, ino);
82 if (!et) { 82 if (!et) {
83 et = f2fs_kmem_cache_alloc(extent_tree_slab, GFP_NOFS); 83 et = f2fs_kmem_cache_alloc(extent_tree_slab, GFP_NOFS);
@@ -94,7 +94,7 @@ static struct extent_tree *__grab_extent_tree(struct inode *inode)
94 atomic_dec(&sbi->total_zombie_tree); 94 atomic_dec(&sbi->total_zombie_tree);
95 list_del_init(&et->list); 95 list_del_init(&et->list);
96 } 96 }
97 up_write(&sbi->extent_tree_lock); 97 mutex_unlock(&sbi->extent_tree_lock);
98 98
99 /* never died until evict_inode */ 99 /* never died until evict_inode */
100 F2FS_I(inode)->extent_tree = et; 100 F2FS_I(inode)->extent_tree = et;
@@ -311,28 +311,24 @@ static struct extent_node *__lookup_extent_tree_ret(struct extent_tree *et,
311 tmp_node = parent; 311 tmp_node = parent;
312 if (parent && fofs > en->ei.fofs) 312 if (parent && fofs > en->ei.fofs)
313 tmp_node = rb_next(parent); 313 tmp_node = rb_next(parent);
314 *next_ex = tmp_node ? 314 *next_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
315 rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
316 315
317 tmp_node = parent; 316 tmp_node = parent;
318 if (parent && fofs < en->ei.fofs) 317 if (parent && fofs < en->ei.fofs)
319 tmp_node = rb_prev(parent); 318 tmp_node = rb_prev(parent);
320 *prev_ex = tmp_node ? 319 *prev_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
321 rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
322 return NULL; 320 return NULL;
323 321
324lookup_neighbors: 322lookup_neighbors:
325 if (fofs == en->ei.fofs) { 323 if (fofs == en->ei.fofs) {
326 /* lookup prev node for merging backward later */ 324 /* lookup prev node for merging backward later */
327 tmp_node = rb_prev(&en->rb_node); 325 tmp_node = rb_prev(&en->rb_node);
328 *prev_ex = tmp_node ? 326 *prev_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
329 rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
330 } 327 }
331 if (fofs == en->ei.fofs + en->ei.len - 1) { 328 if (fofs == en->ei.fofs + en->ei.len - 1) {
332 /* lookup next node for merging frontward later */ 329 /* lookup next node for merging frontward later */
333 tmp_node = rb_next(&en->rb_node); 330 tmp_node = rb_next(&en->rb_node);
334 *next_ex = tmp_node ? 331 *next_ex = rb_entry_safe(tmp_node, struct extent_node, rb_node);
335 rb_entry(tmp_node, struct extent_node, rb_node) : NULL;
336 } 332 }
337 return en; 333 return en;
338} 334}
@@ -352,11 +348,12 @@ static struct extent_node *__try_merge_extent_node(struct inode *inode,
352 } 348 }
353 349
354 if (next_ex && __is_front_mergeable(ei, &next_ex->ei)) { 350 if (next_ex && __is_front_mergeable(ei, &next_ex->ei)) {
355 if (en)
356 __release_extent_node(sbi, et, prev_ex);
357 next_ex->ei.fofs = ei->fofs; 351 next_ex->ei.fofs = ei->fofs;
358 next_ex->ei.blk = ei->blk; 352 next_ex->ei.blk = ei->blk;
359 next_ex->ei.len += ei->len; 353 next_ex->ei.len += ei->len;
354 if (en)
355 __release_extent_node(sbi, et, prev_ex);
356
360 en = next_ex; 357 en = next_ex;
361 } 358 }
362 359
@@ -416,7 +413,7 @@ do_insert:
416 return en; 413 return en;
417} 414}
418 415
419static unsigned int f2fs_update_extent_tree_range(struct inode *inode, 416static void f2fs_update_extent_tree_range(struct inode *inode,
420 pgoff_t fofs, block_t blkaddr, unsigned int len) 417 pgoff_t fofs, block_t blkaddr, unsigned int len)
421{ 418{
422 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 419 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -429,7 +426,7 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
429 unsigned int pos = (unsigned int)fofs; 426 unsigned int pos = (unsigned int)fofs;
430 427
431 if (!et) 428 if (!et)
432 return false; 429 return;
433 430
434 trace_f2fs_update_extent_tree_range(inode, fofs, blkaddr, len); 431 trace_f2fs_update_extent_tree_range(inode, fofs, blkaddr, len);
435 432
@@ -437,7 +434,7 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
437 434
438 if (is_inode_flag_set(inode, FI_NO_EXTENT)) { 435 if (is_inode_flag_set(inode, FI_NO_EXTENT)) {
439 write_unlock(&et->lock); 436 write_unlock(&et->lock);
440 return false; 437 return;
441 } 438 }
442 439
443 prev = et->largest; 440 prev = et->largest;
@@ -492,9 +489,8 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
492 if (!next_en) { 489 if (!next_en) {
493 struct rb_node *node = rb_next(&en->rb_node); 490 struct rb_node *node = rb_next(&en->rb_node);
494 491
495 next_en = node ? 492 next_en = rb_entry_safe(node, struct extent_node,
496 rb_entry(node, struct extent_node, rb_node) 493 rb_node);
497 : NULL;
498 } 494 }
499 495
500 if (parts) 496 if (parts)
@@ -535,8 +531,6 @@ static unsigned int f2fs_update_extent_tree_range(struct inode *inode,
535 __free_extent_tree(sbi, et); 531 __free_extent_tree(sbi, et);
536 532
537 write_unlock(&et->lock); 533 write_unlock(&et->lock);
538
539 return !__is_extent_same(&prev, &et->largest);
540} 534}
541 535
542unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink) 536unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
@@ -552,7 +546,7 @@ unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
552 if (!atomic_read(&sbi->total_zombie_tree)) 546 if (!atomic_read(&sbi->total_zombie_tree))
553 goto free_node; 547 goto free_node;
554 548
555 if (!down_write_trylock(&sbi->extent_tree_lock)) 549 if (!mutex_trylock(&sbi->extent_tree_lock))
556 goto out; 550 goto out;
557 551
558 /* 1. remove unreferenced extent tree */ 552 /* 1. remove unreferenced extent tree */
@@ -574,11 +568,11 @@ unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink)
574 goto unlock_out; 568 goto unlock_out;
575 cond_resched(); 569 cond_resched();
576 } 570 }
577 up_write(&sbi->extent_tree_lock); 571 mutex_unlock(&sbi->extent_tree_lock);
578 572
579free_node: 573free_node:
580 /* 2. remove LRU extent entries */ 574 /* 2. remove LRU extent entries */
581 if (!down_write_trylock(&sbi->extent_tree_lock)) 575 if (!mutex_trylock(&sbi->extent_tree_lock))
582 goto out; 576 goto out;
583 577
584 remained = nr_shrink - (node_cnt + tree_cnt); 578 remained = nr_shrink - (node_cnt + tree_cnt);
@@ -608,7 +602,7 @@ free_node:
608 spin_unlock(&sbi->extent_lock); 602 spin_unlock(&sbi->extent_lock);
609 603
610unlock_out: 604unlock_out:
611 up_write(&sbi->extent_tree_lock); 605 mutex_unlock(&sbi->extent_tree_lock);
612out: 606out:
613 trace_f2fs_shrink_extent_tree(sbi, node_cnt, tree_cnt); 607 trace_f2fs_shrink_extent_tree(sbi, node_cnt, tree_cnt);
614 608
@@ -655,10 +649,10 @@ void f2fs_destroy_extent_tree(struct inode *inode)
655 649
656 if (inode->i_nlink && !is_bad_inode(inode) && 650 if (inode->i_nlink && !is_bad_inode(inode) &&
657 atomic_read(&et->node_cnt)) { 651 atomic_read(&et->node_cnt)) {
658 down_write(&sbi->extent_tree_lock); 652 mutex_lock(&sbi->extent_tree_lock);
659 list_add_tail(&et->list, &sbi->zombie_list); 653 list_add_tail(&et->list, &sbi->zombie_list);
660 atomic_inc(&sbi->total_zombie_tree); 654 atomic_inc(&sbi->total_zombie_tree);
661 up_write(&sbi->extent_tree_lock); 655 mutex_unlock(&sbi->extent_tree_lock);
662 return; 656 return;
663 } 657 }
664 658
@@ -666,12 +660,12 @@ void f2fs_destroy_extent_tree(struct inode *inode)
666 node_cnt = f2fs_destroy_extent_node(inode); 660 node_cnt = f2fs_destroy_extent_node(inode);
667 661
668 /* delete extent tree entry in radix tree */ 662 /* delete extent tree entry in radix tree */
669 down_write(&sbi->extent_tree_lock); 663 mutex_lock(&sbi->extent_tree_lock);
670 f2fs_bug_on(sbi, atomic_read(&et->node_cnt)); 664 f2fs_bug_on(sbi, atomic_read(&et->node_cnt));
671 radix_tree_delete(&sbi->extent_tree_root, inode->i_ino); 665 radix_tree_delete(&sbi->extent_tree_root, inode->i_ino);
672 kmem_cache_free(extent_tree_slab, et); 666 kmem_cache_free(extent_tree_slab, et);
673 atomic_dec(&sbi->total_ext_tree); 667 atomic_dec(&sbi->total_ext_tree);
674 up_write(&sbi->extent_tree_lock); 668 mutex_unlock(&sbi->extent_tree_lock);
675 669
676 F2FS_I(inode)->extent_tree = NULL; 670 F2FS_I(inode)->extent_tree = NULL;
677 671
@@ -718,7 +712,7 @@ void f2fs_update_extent_cache_range(struct dnode_of_data *dn,
718void init_extent_cache_info(struct f2fs_sb_info *sbi) 712void init_extent_cache_info(struct f2fs_sb_info *sbi)
719{ 713{
720 INIT_RADIX_TREE(&sbi->extent_tree_root, GFP_NOIO); 714 INIT_RADIX_TREE(&sbi->extent_tree_root, GFP_NOIO);
721 init_rwsem(&sbi->extent_tree_lock); 715 mutex_init(&sbi->extent_tree_lock);
722 INIT_LIST_HEAD(&sbi->extent_list); 716 INIT_LIST_HEAD(&sbi->extent_list);
723 spin_lock_init(&sbi->extent_lock); 717 spin_lock_init(&sbi->extent_lock);
724 atomic_set(&sbi->total_ext_tree, 0); 718 atomic_set(&sbi->total_ext_tree, 0);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 069fc7277d8d..d1483136fed6 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -112,9 +112,9 @@ struct f2fs_mount_info {
112#define F2FS_HAS_FEATURE(sb, mask) \ 112#define F2FS_HAS_FEATURE(sb, mask) \
113 ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0) 113 ((F2FS_SB(sb)->raw_super->feature & cpu_to_le32(mask)) != 0)
114#define F2FS_SET_FEATURE(sb, mask) \ 114#define F2FS_SET_FEATURE(sb, mask) \
115 F2FS_SB(sb)->raw_super->feature |= cpu_to_le32(mask) 115 (F2FS_SB(sb)->raw_super->feature |= cpu_to_le32(mask))
116#define F2FS_CLEAR_FEATURE(sb, mask) \ 116#define F2FS_CLEAR_FEATURE(sb, mask) \
117 F2FS_SB(sb)->raw_super->feature &= ~cpu_to_le32(mask) 117 (F2FS_SB(sb)->raw_super->feature &= ~cpu_to_le32(mask))
118 118
119/* 119/*
120 * For checkpoint manager 120 * For checkpoint manager
@@ -132,11 +132,14 @@ enum {
132 CP_DISCARD, 132 CP_DISCARD,
133}; 133};
134 134
135#define DEF_BATCHED_TRIM_SECTIONS 2 135#define DEF_BATCHED_TRIM_SECTIONS 2048
136#define BATCHED_TRIM_SEGMENTS(sbi) \ 136#define BATCHED_TRIM_SEGMENTS(sbi) \
137 (SM_I(sbi)->trim_sections * (sbi)->segs_per_sec) 137 (SM_I(sbi)->trim_sections * (sbi)->segs_per_sec)
138#define BATCHED_TRIM_BLOCKS(sbi) \ 138#define BATCHED_TRIM_BLOCKS(sbi) \
139 (BATCHED_TRIM_SEGMENTS(sbi) << (sbi)->log_blocks_per_seg) 139 (BATCHED_TRIM_SEGMENTS(sbi) << (sbi)->log_blocks_per_seg)
140#define MAX_DISCARD_BLOCKS(sbi) \
141 ((1 << (sbi)->log_blocks_per_seg) * (sbi)->segs_per_sec)
142#define DISCARD_ISSUE_RATE 8
140#define DEF_CP_INTERVAL 60 /* 60 secs */ 143#define DEF_CP_INTERVAL 60 /* 60 secs */
141#define DEF_IDLE_INTERVAL 5 /* 5 secs */ 144#define DEF_IDLE_INTERVAL 5 /* 5 secs */
142 145
@@ -185,11 +188,30 @@ struct discard_entry {
185 int len; /* # of consecutive blocks of the discard */ 188 int len; /* # of consecutive blocks of the discard */
186}; 189};
187 190
188struct bio_entry { 191enum {
189 struct list_head list; 192 D_PREP,
190 struct bio *bio; 193 D_SUBMIT,
191 struct completion event; 194 D_DONE,
192 int error; 195};
196
197struct discard_cmd {
198 struct list_head list; /* command list */
199 struct completion wait; /* compleation */
200 block_t lstart; /* logical start address */
201 block_t len; /* length */
202 struct bio *bio; /* bio */
203 int state; /* state */
204};
205
206struct discard_cmd_control {
207 struct task_struct *f2fs_issue_discard; /* discard thread */
208 struct list_head discard_entry_list; /* 4KB discard entry list */
209 int nr_discards; /* # of discards in the list */
210 struct list_head discard_cmd_list; /* discard cmd list */
211 wait_queue_head_t discard_wait_queue; /* waiting queue for wake-up */
212 struct mutex cmd_lock;
213 int max_discards; /* max. discards to be issued */
214 atomic_t submit_discard; /* # of issued discard */
193}; 215};
194 216
195/* for the list of fsync inodes, used only during recovery */ 217/* for the list of fsync inodes, used only during recovery */
@@ -214,6 +236,7 @@ struct fsync_inode_entry {
214static inline int update_nats_in_cursum(struct f2fs_journal *journal, int i) 236static inline int update_nats_in_cursum(struct f2fs_journal *journal, int i)
215{ 237{
216 int before = nats_in_cursum(journal); 238 int before = nats_in_cursum(journal);
239
217 journal->n_nats = cpu_to_le16(before + i); 240 journal->n_nats = cpu_to_le16(before + i);
218 return before; 241 return before;
219} 242}
@@ -221,6 +244,7 @@ static inline int update_nats_in_cursum(struct f2fs_journal *journal, int i)
221static inline int update_sits_in_cursum(struct f2fs_journal *journal, int i) 244static inline int update_sits_in_cursum(struct f2fs_journal *journal, int i)
222{ 245{
223 int before = sits_in_cursum(journal); 246 int before = sits_in_cursum(journal);
247
224 journal->n_sits = cpu_to_le16(before + i); 248 journal->n_sits = cpu_to_le16(before + i);
225 return before; 249 return before;
226} 250}
@@ -306,12 +330,14 @@ static inline void make_dentry_ptr(struct inode *inode,
306 330
307 if (type == 1) { 331 if (type == 1) {
308 struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src; 332 struct f2fs_dentry_block *t = (struct f2fs_dentry_block *)src;
333
309 d->max = NR_DENTRY_IN_BLOCK; 334 d->max = NR_DENTRY_IN_BLOCK;
310 d->bitmap = &t->dentry_bitmap; 335 d->bitmap = &t->dentry_bitmap;
311 d->dentry = t->dentry; 336 d->dentry = t->dentry;
312 d->filename = t->filename; 337 d->filename = t->filename;
313 } else { 338 } else {
314 struct f2fs_inline_dentry *t = (struct f2fs_inline_dentry *)src; 339 struct f2fs_inline_dentry *t = (struct f2fs_inline_dentry *)src;
340
315 d->max = NR_INLINE_DENTRY; 341 d->max = NR_INLINE_DENTRY;
316 d->bitmap = &t->dentry_bitmap; 342 d->bitmap = &t->dentry_bitmap;
317 d->dentry = t->dentry; 343 d->dentry = t->dentry;
@@ -438,8 +464,8 @@ struct f2fs_inode_info {
438 atomic_t dirty_pages; /* # of dirty pages */ 464 atomic_t dirty_pages; /* # of dirty pages */
439 f2fs_hash_t chash; /* hash value of given file name */ 465 f2fs_hash_t chash; /* hash value of given file name */
440 unsigned int clevel; /* maximum level of given file name */ 466 unsigned int clevel; /* maximum level of given file name */
467 struct task_struct *task; /* lookup and create consistency */
441 nid_t i_xattr_nid; /* node id that contains xattrs */ 468 nid_t i_xattr_nid; /* node id that contains xattrs */
442 unsigned long long xattr_ver; /* cp version of xattr modification */
443 loff_t last_disk_size; /* lastly written file size */ 469 loff_t last_disk_size; /* lastly written file size */
444 470
445 struct list_head dirty_list; /* dirty list for dirs and files */ 471 struct list_head dirty_list; /* dirty list for dirs and files */
@@ -474,13 +500,6 @@ static inline void set_extent_info(struct extent_info *ei, unsigned int fofs,
474 ei->len = len; 500 ei->len = len;
475} 501}
476 502
477static inline bool __is_extent_same(struct extent_info *ei1,
478 struct extent_info *ei2)
479{
480 return (ei1->fofs == ei2->fofs && ei1->blk == ei2->blk &&
481 ei1->len == ei2->len);
482}
483
484static inline bool __is_extent_mergeable(struct extent_info *back, 503static inline bool __is_extent_mergeable(struct extent_info *back,
485 struct extent_info *front) 504 struct extent_info *front)
486{ 505{
@@ -500,7 +519,7 @@ static inline bool __is_front_mergeable(struct extent_info *cur,
500 return __is_extent_mergeable(cur, front); 519 return __is_extent_mergeable(cur, front);
501} 520}
502 521
503extern void f2fs_mark_inode_dirty_sync(struct inode *, bool); 522extern void f2fs_mark_inode_dirty_sync(struct inode *inode, bool sync);
504static inline void __try_update_largest_extent(struct inode *inode, 523static inline void __try_update_largest_extent(struct inode *inode,
505 struct extent_tree *et, struct extent_node *en) 524 struct extent_tree *et, struct extent_node *en)
506{ 525{
@@ -532,6 +551,7 @@ struct f2fs_nm_info {
532 struct list_head nat_entries; /* cached nat entry list (clean) */ 551 struct list_head nat_entries; /* cached nat entry list (clean) */
533 unsigned int nat_cnt; /* the # of cached nat entries */ 552 unsigned int nat_cnt; /* the # of cached nat entries */
534 unsigned int dirty_nat_cnt; /* total num of nat entries in set */ 553 unsigned int dirty_nat_cnt; /* total num of nat entries in set */
554 unsigned int nat_blocks; /* # of nat blocks */
535 555
536 /* free node ids management */ 556 /* free node ids management */
537 struct radix_tree_root free_nid_root;/* root of the free_nid cache */ 557 struct radix_tree_root free_nid_root;/* root of the free_nid cache */
@@ -539,9 +559,19 @@ struct f2fs_nm_info {
539 unsigned int nid_cnt[MAX_NID_LIST]; /* the number of free node id */ 559 unsigned int nid_cnt[MAX_NID_LIST]; /* the number of free node id */
540 spinlock_t nid_list_lock; /* protect nid lists ops */ 560 spinlock_t nid_list_lock; /* protect nid lists ops */
541 struct mutex build_lock; /* lock for build free nids */ 561 struct mutex build_lock; /* lock for build free nids */
562 unsigned char (*free_nid_bitmap)[NAT_ENTRY_BITMAP_SIZE];
563 unsigned char *nat_block_bitmap;
542 564
543 /* for checkpoint */ 565 /* for checkpoint */
544 char *nat_bitmap; /* NAT bitmap pointer */ 566 char *nat_bitmap; /* NAT bitmap pointer */
567
568 unsigned int nat_bits_blocks; /* # of nat bits blocks */
569 unsigned char *nat_bits; /* NAT bits blocks */
570 unsigned char *full_nat_bits; /* full NAT pages */
571 unsigned char *empty_nat_bits; /* empty NAT pages */
572#ifdef CONFIG_F2FS_CHECK_FS
573 char *nat_bitmap_mir; /* NAT bitmap mirror */
574#endif
545 int bitmap_size; /* bitmap size */ 575 int bitmap_size; /* bitmap size */
546}; 576};
547 577
@@ -632,12 +662,6 @@ struct f2fs_sm_info {
632 /* a threshold to reclaim prefree segments */ 662 /* a threshold to reclaim prefree segments */
633 unsigned int rec_prefree_segments; 663 unsigned int rec_prefree_segments;
634 664
635 /* for small discard management */
636 struct list_head discard_list; /* 4KB discard list */
637 struct list_head wait_list; /* linked with issued discard bio */
638 int nr_discards; /* # of discards in the list */
639 int max_discards; /* max. discards to be issued */
640
641 /* for batched trimming */ 665 /* for batched trimming */
642 unsigned int trim_sections; /* # of sections to trim */ 666 unsigned int trim_sections; /* # of sections to trim */
643 667
@@ -648,8 +672,10 @@ struct f2fs_sm_info {
648 unsigned int min_fsync_blocks; /* threshold for fsync */ 672 unsigned int min_fsync_blocks; /* threshold for fsync */
649 673
650 /* for flush command control */ 674 /* for flush command control */
651 struct flush_cmd_control *cmd_control_info; 675 struct flush_cmd_control *fcc_info;
652 676
677 /* for discard command control */
678 struct discard_cmd_control *dcc_info;
653}; 679};
654 680
655/* 681/*
@@ -708,6 +734,7 @@ struct f2fs_io_info {
708 block_t old_blkaddr; /* old block address before Cow */ 734 block_t old_blkaddr; /* old block address before Cow */
709 struct page *page; /* page to be written */ 735 struct page *page; /* page to be written */
710 struct page *encrypted_page; /* encrypted page */ 736 struct page *encrypted_page; /* encrypted page */
737 bool submitted; /* indicate IO submission */
711}; 738};
712 739
713#define is_read_io(rw) (rw == READ) 740#define is_read_io(rw) (rw == READ)
@@ -787,6 +814,8 @@ struct f2fs_sb_info {
787 struct f2fs_bio_info read_io; /* for read bios */ 814 struct f2fs_bio_info read_io; /* for read bios */
788 struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */ 815 struct f2fs_bio_info write_io[NR_PAGE_TYPE]; /* for write bios */
789 struct mutex wio_mutex[NODE + 1]; /* bio ordering for NODE/DATA */ 816 struct mutex wio_mutex[NODE + 1]; /* bio ordering for NODE/DATA */
817 int write_io_size_bits; /* Write IO size bits */
818 mempool_t *write_io_dummy; /* Dummy pages */
790 819
791 /* for checkpoint */ 820 /* for checkpoint */
792 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ 821 struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */
@@ -811,7 +840,7 @@ struct f2fs_sb_info {
811 840
812 /* for extent tree cache */ 841 /* for extent tree cache */
813 struct radix_tree_root extent_tree_root;/* cache extent cache entries */ 842 struct radix_tree_root extent_tree_root;/* cache extent cache entries */
814 struct rw_semaphore extent_tree_lock; /* locking extent radix tree */ 843 struct mutex extent_tree_lock; /* locking extent radix tree */
815 struct list_head extent_list; /* lru list for shrinker */ 844 struct list_head extent_list; /* lru list for shrinker */
816 spinlock_t extent_lock; /* locking extent lru list */ 845 spinlock_t extent_lock; /* locking extent lru list */
817 atomic_t total_ext_tree; /* extent tree count */ 846 atomic_t total_ext_tree; /* extent tree count */
@@ -858,6 +887,9 @@ struct f2fs_sb_info {
858 struct f2fs_gc_kthread *gc_thread; /* GC thread */ 887 struct f2fs_gc_kthread *gc_thread; /* GC thread */
859 unsigned int cur_victim_sec; /* current victim section num */ 888 unsigned int cur_victim_sec; /* current victim section num */
860 889
890 /* threshold for converting bg victims for fg */
891 u64 fggc_threshold;
892
861 /* maximum # of trials to find a victim segment for SSR and GC */ 893 /* maximum # of trials to find a victim segment for SSR and GC */
862 unsigned int max_victim_search; 894 unsigned int max_victim_search;
863 895
@@ -877,6 +909,8 @@ struct f2fs_sb_info {
877 atomic_t inline_xattr; /* # of inline_xattr inodes */ 909 atomic_t inline_xattr; /* # of inline_xattr inodes */
878 atomic_t inline_inode; /* # of inline_data inodes */ 910 atomic_t inline_inode; /* # of inline_data inodes */
879 atomic_t inline_dir; /* # of inline_dentry inodes */ 911 atomic_t inline_dir; /* # of inline_dentry inodes */
912 atomic_t aw_cnt; /* # of atomic writes */
913 atomic_t max_aw_cnt; /* max # of atomic writes */
880 int bg_gc; /* background gc calls */ 914 int bg_gc; /* background gc calls */
881 unsigned int ndirty_inode[NR_INODE_TYPE]; /* # of dirty inodes */ 915 unsigned int ndirty_inode[NR_INODE_TYPE]; /* # of dirty inodes */
882#endif 916#endif
@@ -908,6 +942,10 @@ struct f2fs_sb_info {
908}; 942};
909 943
910#ifdef CONFIG_F2FS_FAULT_INJECTION 944#ifdef CONFIG_F2FS_FAULT_INJECTION
945#define f2fs_show_injection_info(type) \
946 printk("%sF2FS-fs : inject %s in %s of %pF\n", \
947 KERN_INFO, fault_name[type], \
948 __func__, __builtin_return_address(0))
911static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type) 949static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
912{ 950{
913 struct f2fs_fault_info *ffi = &sbi->fault_info; 951 struct f2fs_fault_info *ffi = &sbi->fault_info;
@@ -921,10 +959,6 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
921 atomic_inc(&ffi->inject_ops); 959 atomic_inc(&ffi->inject_ops);
922 if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) { 960 if (atomic_read(&ffi->inject_ops) >= ffi->inject_rate) {
923 atomic_set(&ffi->inject_ops, 0); 961 atomic_set(&ffi->inject_ops, 0);
924 printk("%sF2FS-fs : inject %s in %pF\n",
925 KERN_INFO,
926 fault_name[type],
927 __builtin_return_address(0));
928 return true; 962 return true;
929 } 963 }
930 return false; 964 return false;
@@ -1089,6 +1123,12 @@ static inline unsigned long long cur_cp_version(struct f2fs_checkpoint *cp)
1089 return le64_to_cpu(cp->checkpoint_ver); 1123 return le64_to_cpu(cp->checkpoint_ver);
1090} 1124}
1091 1125
1126static inline __u64 cur_cp_crc(struct f2fs_checkpoint *cp)
1127{
1128 size_t crc_offset = le32_to_cpu(cp->checksum_offset);
1129 return le32_to_cpu(*((__le32 *)((unsigned char *)cp + crc_offset)));
1130}
1131
1092static inline bool __is_set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f) 1132static inline bool __is_set_ckpt_flags(struct f2fs_checkpoint *cp, unsigned int f)
1093{ 1133{
1094 unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags); 1134 unsigned int ckpt_flags = le32_to_cpu(cp->ckpt_flags);
@@ -1133,6 +1173,27 @@ static inline void clear_ckpt_flags(struct f2fs_sb_info *sbi, unsigned int f)
1133 spin_unlock(&sbi->cp_lock); 1173 spin_unlock(&sbi->cp_lock);
1134} 1174}
1135 1175
1176static inline void disable_nat_bits(struct f2fs_sb_info *sbi, bool lock)
1177{
1178 set_sbi_flag(sbi, SBI_NEED_FSCK);
1179
1180 if (lock)
1181 spin_lock(&sbi->cp_lock);
1182 __clear_ckpt_flags(F2FS_CKPT(sbi), CP_NAT_BITS_FLAG);
1183 kfree(NM_I(sbi)->nat_bits);
1184 NM_I(sbi)->nat_bits = NULL;
1185 if (lock)
1186 spin_unlock(&sbi->cp_lock);
1187}
1188
1189static inline bool enabled_nat_bits(struct f2fs_sb_info *sbi,
1190 struct cp_control *cpc)
1191{
1192 bool set = is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG);
1193
1194 return (cpc) ? (cpc->reason == CP_UMOUNT) && set : set;
1195}
1196
1136static inline void f2fs_lock_op(struct f2fs_sb_info *sbi) 1197static inline void f2fs_lock_op(struct f2fs_sb_info *sbi)
1137{ 1198{
1138 down_read(&sbi->cp_rwsem); 1199 down_read(&sbi->cp_rwsem);
@@ -1212,8 +1273,10 @@ static inline bool inc_valid_block_count(struct f2fs_sb_info *sbi,
1212 blkcnt_t diff; 1273 blkcnt_t diff;
1213 1274
1214#ifdef CONFIG_F2FS_FAULT_INJECTION 1275#ifdef CONFIG_F2FS_FAULT_INJECTION
1215 if (time_to_inject(sbi, FAULT_BLOCK)) 1276 if (time_to_inject(sbi, FAULT_BLOCK)) {
1277 f2fs_show_injection_info(FAULT_BLOCK);
1216 return false; 1278 return false;
1279 }
1217#endif 1280#endif
1218 /* 1281 /*
1219 * let's increase this in prior to actual block count change in order 1282 * let's increase this in prior to actual block count change in order
@@ -1449,11 +1512,14 @@ static inline struct page *f2fs_grab_cache_page(struct address_space *mapping,
1449{ 1512{
1450#ifdef CONFIG_F2FS_FAULT_INJECTION 1513#ifdef CONFIG_F2FS_FAULT_INJECTION
1451 struct page *page = find_lock_page(mapping, index); 1514 struct page *page = find_lock_page(mapping, index);
1515
1452 if (page) 1516 if (page)
1453 return page; 1517 return page;
1454 1518
1455 if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC)) 1519 if (time_to_inject(F2FS_M_SB(mapping), FAULT_PAGE_ALLOC)) {
1520 f2fs_show_injection_info(FAULT_PAGE_ALLOC);
1456 return NULL; 1521 return NULL;
1522 }
1457#endif 1523#endif
1458 if (!for_write) 1524 if (!for_write)
1459 return grab_cache_page(mapping, index); 1525 return grab_cache_page(mapping, index);
@@ -1532,6 +1598,7 @@ static inline void f2fs_radix_tree_insert(struct radix_tree_root *root,
1532static inline bool IS_INODE(struct page *page) 1598static inline bool IS_INODE(struct page *page)
1533{ 1599{
1534 struct f2fs_node *p = F2FS_NODE(page); 1600 struct f2fs_node *p = F2FS_NODE(page);
1601
1535 return RAW_IS_INODE(p); 1602 return RAW_IS_INODE(p);
1536} 1603}
1537 1604
@@ -1545,6 +1612,7 @@ static inline block_t datablock_addr(struct page *node_page,
1545{ 1612{
1546 struct f2fs_node *raw_node; 1613 struct f2fs_node *raw_node;
1547 __le32 *addr_array; 1614 __le32 *addr_array;
1615
1548 raw_node = F2FS_NODE(node_page); 1616 raw_node = F2FS_NODE(node_page);
1549 addr_array = blkaddr_in_node(raw_node); 1617 addr_array = blkaddr_in_node(raw_node);
1550 return le32_to_cpu(addr_array[offset]); 1618 return le32_to_cpu(addr_array[offset]);
@@ -1628,6 +1696,7 @@ enum {
1628 FI_UPDATE_WRITE, /* inode has in-place-update data */ 1696 FI_UPDATE_WRITE, /* inode has in-place-update data */
1629 FI_NEED_IPU, /* used for ipu per file */ 1697 FI_NEED_IPU, /* used for ipu per file */
1630 FI_ATOMIC_FILE, /* indicate atomic file */ 1698 FI_ATOMIC_FILE, /* indicate atomic file */
1699 FI_ATOMIC_COMMIT, /* indicate the state of atomical committing */
1631 FI_VOLATILE_FILE, /* indicate volatile file */ 1700 FI_VOLATILE_FILE, /* indicate volatile file */
1632 FI_FIRST_BLOCK_WRITTEN, /* indicate #0 data block was written */ 1701 FI_FIRST_BLOCK_WRITTEN, /* indicate #0 data block was written */
1633 FI_DROP_CACHE, /* drop dirty page cache */ 1702 FI_DROP_CACHE, /* drop dirty page cache */
@@ -1635,6 +1704,7 @@ enum {
1635 FI_INLINE_DOTS, /* indicate inline dot dentries */ 1704 FI_INLINE_DOTS, /* indicate inline dot dentries */
1636 FI_DO_DEFRAG, /* indicate defragment is running */ 1705 FI_DO_DEFRAG, /* indicate defragment is running */
1637 FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */ 1706 FI_DIRTY_FILE, /* indicate regular/symlink has dirty pages */
1707 FI_NO_PREALLOC, /* indicate skipped preallocated blocks */
1638}; 1708};
1639 1709
1640static inline void __mark_inode_dirty_flag(struct inode *inode, 1710static inline void __mark_inode_dirty_flag(struct inode *inode,
@@ -1779,6 +1849,7 @@ static inline unsigned int addrs_per_inode(struct inode *inode)
1779static inline void *inline_xattr_addr(struct page *page) 1849static inline void *inline_xattr_addr(struct page *page)
1780{ 1850{
1781 struct f2fs_inode *ri = F2FS_INODE(page); 1851 struct f2fs_inode *ri = F2FS_INODE(page);
1852
1782 return (void *)&(ri->i_addr[DEF_ADDRS_PER_INODE - 1853 return (void *)&(ri->i_addr[DEF_ADDRS_PER_INODE -
1783 F2FS_INLINE_XATTR_ADDRS]); 1854 F2FS_INLINE_XATTR_ADDRS]);
1784} 1855}
@@ -1817,6 +1888,11 @@ static inline bool f2fs_is_atomic_file(struct inode *inode)
1817 return is_inode_flag_set(inode, FI_ATOMIC_FILE); 1888 return is_inode_flag_set(inode, FI_ATOMIC_FILE);
1818} 1889}
1819 1890
1891static inline bool f2fs_is_commit_atomic_write(struct inode *inode)
1892{
1893 return is_inode_flag_set(inode, FI_ATOMIC_COMMIT);
1894}
1895
1820static inline bool f2fs_is_volatile_file(struct inode *inode) 1896static inline bool f2fs_is_volatile_file(struct inode *inode)
1821{ 1897{
1822 return is_inode_flag_set(inode, FI_VOLATILE_FILE); 1898 return is_inode_flag_set(inode, FI_VOLATILE_FILE);
@@ -1835,6 +1911,7 @@ static inline bool f2fs_is_drop_cache(struct inode *inode)
1835static inline void *inline_data_addr(struct page *page) 1911static inline void *inline_data_addr(struct page *page)
1836{ 1912{
1837 struct f2fs_inode *ri = F2FS_INODE(page); 1913 struct f2fs_inode *ri = F2FS_INODE(page);
1914
1838 return (void *)&(ri->i_addr[1]); 1915 return (void *)&(ri->i_addr[1]);
1839} 1916}
1840 1917
@@ -1918,8 +1995,10 @@ static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
1918 size_t size, gfp_t flags) 1995 size_t size, gfp_t flags)
1919{ 1996{
1920#ifdef CONFIG_F2FS_FAULT_INJECTION 1997#ifdef CONFIG_F2FS_FAULT_INJECTION
1921 if (time_to_inject(sbi, FAULT_KMALLOC)) 1998 if (time_to_inject(sbi, FAULT_KMALLOC)) {
1999 f2fs_show_injection_info(FAULT_KMALLOC);
1922 return NULL; 2000 return NULL;
2001 }
1923#endif 2002#endif
1924 return kmalloc(size, flags); 2003 return kmalloc(size, flags);
1925} 2004}
@@ -1957,29 +2036,30 @@ static inline void *f2fs_kvzalloc(size_t size, gfp_t flags)
1957/* 2036/*
1958 * file.c 2037 * file.c
1959 */ 2038 */
1960int f2fs_sync_file(struct file *, loff_t, loff_t, int); 2039int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
1961void truncate_data_blocks(struct dnode_of_data *); 2040void truncate_data_blocks(struct dnode_of_data *dn);
1962int truncate_blocks(struct inode *, u64, bool); 2041int truncate_blocks(struct inode *inode, u64 from, bool lock);
1963int f2fs_truncate(struct inode *); 2042int f2fs_truncate(struct inode *inode);
1964int f2fs_getattr(struct vfsmount *, struct dentry *, struct kstat *); 2043int f2fs_getattr(struct vfsmount *mnt, struct dentry *dentry,
1965int f2fs_setattr(struct dentry *, struct iattr *); 2044 struct kstat *stat);
1966int truncate_hole(struct inode *, pgoff_t, pgoff_t); 2045int f2fs_setattr(struct dentry *dentry, struct iattr *attr);
1967int truncate_data_blocks_range(struct dnode_of_data *, int); 2046int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end);
1968long f2fs_ioctl(struct file *, unsigned int, unsigned long); 2047int truncate_data_blocks_range(struct dnode_of_data *dn, int count);
1969long f2fs_compat_ioctl(struct file *, unsigned int, unsigned long); 2048long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
2049long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1970 2050
1971/* 2051/*
1972 * inode.c 2052 * inode.c
1973 */ 2053 */
1974void f2fs_set_inode_flags(struct inode *); 2054void f2fs_set_inode_flags(struct inode *inode);
1975struct inode *f2fs_iget(struct super_block *, unsigned long); 2055struct inode *f2fs_iget(struct super_block *sb, unsigned long ino);
1976struct inode *f2fs_iget_retry(struct super_block *, unsigned long); 2056struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino);
1977int try_to_free_nats(struct f2fs_sb_info *, int); 2057int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink);
1978int update_inode(struct inode *, struct page *); 2058int update_inode(struct inode *inode, struct page *node_page);
1979int update_inode_page(struct inode *); 2059int update_inode_page(struct inode *inode);
1980int f2fs_write_inode(struct inode *, struct writeback_control *); 2060int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc);
1981void f2fs_evict_inode(struct inode *); 2061void f2fs_evict_inode(struct inode *inode);
1982void handle_failed_inode(struct inode *); 2062void handle_failed_inode(struct inode *inode);
1983 2063
1984/* 2064/*
1985 * namei.c 2065 * namei.c
@@ -1989,40 +2069,47 @@ struct dentry *f2fs_get_parent(struct dentry *child);
1989/* 2069/*
1990 * dir.c 2070 * dir.c
1991 */ 2071 */
1992void set_de_type(struct f2fs_dir_entry *, umode_t); 2072void set_de_type(struct f2fs_dir_entry *de, umode_t mode);
1993unsigned char get_de_type(struct f2fs_dir_entry *); 2073unsigned char get_de_type(struct f2fs_dir_entry *de);
1994struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *, 2074struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname,
1995 f2fs_hash_t, int *, struct f2fs_dentry_ptr *); 2075 f2fs_hash_t namehash, int *max_slots,
1996int f2fs_fill_dentries(struct dir_context *, struct f2fs_dentry_ptr *, 2076 struct f2fs_dentry_ptr *d);
1997 unsigned int, struct fscrypt_str *); 2077int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
1998void do_make_empty_dir(struct inode *, struct inode *, 2078 unsigned int start_pos, struct fscrypt_str *fstr);
1999 struct f2fs_dentry_ptr *); 2079void do_make_empty_dir(struct inode *inode, struct inode *parent,
2000struct page *init_inode_metadata(struct inode *, struct inode *, 2080 struct f2fs_dentry_ptr *d);
2001 const struct qstr *, const struct qstr *, struct page *); 2081struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
2002void update_parent_metadata(struct inode *, struct inode *, unsigned int); 2082 const struct qstr *new_name,
2003int room_for_filename(const void *, int, int); 2083 const struct qstr *orig_name, struct page *dpage);
2004void f2fs_drop_nlink(struct inode *, struct inode *); 2084void update_parent_metadata(struct inode *dir, struct inode *inode,
2005struct f2fs_dir_entry *__f2fs_find_entry(struct inode *, struct fscrypt_name *, 2085 unsigned int current_depth);
2006 struct page **); 2086int room_for_filename(const void *bitmap, int slots, int max_slots);
2007struct f2fs_dir_entry *f2fs_find_entry(struct inode *, const struct qstr *, 2087void f2fs_drop_nlink(struct inode *dir, struct inode *inode);
2008 struct page **); 2088struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
2009struct f2fs_dir_entry *f2fs_parent_dir(struct inode *, struct page **); 2089 struct fscrypt_name *fname, struct page **res_page);
2010ino_t f2fs_inode_by_name(struct inode *, const struct qstr *, struct page **); 2090struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,
2011void f2fs_set_link(struct inode *, struct f2fs_dir_entry *, 2091 const struct qstr *child, struct page **res_page);
2012 struct page *, struct inode *); 2092struct f2fs_dir_entry *f2fs_parent_dir(struct inode *dir, struct page **p);
2013int update_dent_inode(struct inode *, struct inode *, const struct qstr *); 2093ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr,
2014void f2fs_update_dentry(nid_t ino, umode_t mode, struct f2fs_dentry_ptr *, 2094 struct page **page);
2015 const struct qstr *, f2fs_hash_t , unsigned int); 2095void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de,
2016int f2fs_add_regular_entry(struct inode *, const struct qstr *, 2096 struct page *page, struct inode *inode);
2017 const struct qstr *, struct inode *, nid_t, umode_t); 2097int update_dent_inode(struct inode *inode, struct inode *to,
2018int __f2fs_do_add_link(struct inode *, struct fscrypt_name*, struct inode *, 2098 const struct qstr *name);
2019 nid_t, umode_t); 2099void f2fs_update_dentry(nid_t ino, umode_t mode, struct f2fs_dentry_ptr *d,
2020int __f2fs_add_link(struct inode *, const struct qstr *, struct inode *, nid_t, 2100 const struct qstr *name, f2fs_hash_t name_hash,
2021 umode_t); 2101 unsigned int bit_pos);
2022void f2fs_delete_entry(struct f2fs_dir_entry *, struct page *, struct inode *, 2102int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
2023 struct inode *); 2103 const struct qstr *orig_name,
2024int f2fs_do_tmpfile(struct inode *, struct inode *); 2104 struct inode *inode, nid_t ino, umode_t mode);
2025bool f2fs_empty_dir(struct inode *); 2105int __f2fs_do_add_link(struct inode *dir, struct fscrypt_name *fname,
2106 struct inode *inode, nid_t ino, umode_t mode);
2107int __f2fs_add_link(struct inode *dir, const struct qstr *name,
2108 struct inode *inode, nid_t ino, umode_t mode);
2109void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
2110 struct inode *dir, struct inode *inode);
2111int f2fs_do_tmpfile(struct inode *inode, struct inode *dir);
2112bool f2fs_empty_dir(struct inode *dir);
2026 2113
2027static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode) 2114static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
2028{ 2115{
@@ -2033,18 +2120,18 @@ static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
2033/* 2120/*
2034 * super.c 2121 * super.c
2035 */ 2122 */
2036int f2fs_inode_dirtied(struct inode *, bool); 2123int f2fs_inode_dirtied(struct inode *inode, bool sync);
2037void f2fs_inode_synced(struct inode *); 2124void f2fs_inode_synced(struct inode *inode);
2038int f2fs_commit_super(struct f2fs_sb_info *, bool); 2125int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover);
2039int f2fs_sync_fs(struct super_block *, int); 2126int f2fs_sync_fs(struct super_block *sb, int sync);
2040extern __printf(3, 4) 2127extern __printf(3, 4)
2041void f2fs_msg(struct super_block *, const char *, const char *, ...); 2128void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...);
2042int sanity_check_ckpt(struct f2fs_sb_info *sbi); 2129int sanity_check_ckpt(struct f2fs_sb_info *sbi);
2043 2130
2044/* 2131/*
2045 * hash.c 2132 * hash.c
2046 */ 2133 */
2047f2fs_hash_t f2fs_dentry_hash(const struct qstr *); 2134f2fs_hash_t f2fs_dentry_hash(const struct qstr *name_info);
2048 2135
2049/* 2136/*
2050 * node.c 2137 * node.c
@@ -2052,163 +2139,183 @@ f2fs_hash_t f2fs_dentry_hash(const struct qstr *);
2052struct dnode_of_data; 2139struct dnode_of_data;
2053struct node_info; 2140struct node_info;
2054 2141
2055bool available_free_memory(struct f2fs_sb_info *, int); 2142bool available_free_memory(struct f2fs_sb_info *sbi, int type);
2056int need_dentry_mark(struct f2fs_sb_info *, nid_t); 2143int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid);
2057bool is_checkpointed_node(struct f2fs_sb_info *, nid_t); 2144bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid);
2058bool need_inode_block_update(struct f2fs_sb_info *, nid_t); 2145bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino);
2059void get_node_info(struct f2fs_sb_info *, nid_t, struct node_info *); 2146void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni);
2060pgoff_t get_next_page_offset(struct dnode_of_data *, pgoff_t); 2147pgoff_t get_next_page_offset(struct dnode_of_data *dn, pgoff_t pgofs);
2061int get_dnode_of_data(struct dnode_of_data *, pgoff_t, int); 2148int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode);
2062int truncate_inode_blocks(struct inode *, pgoff_t); 2149int truncate_inode_blocks(struct inode *inode, pgoff_t from);
2063int truncate_xattr_node(struct inode *, struct page *); 2150int truncate_xattr_node(struct inode *inode, struct page *page);
2064int wait_on_node_pages_writeback(struct f2fs_sb_info *, nid_t); 2151int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino);
2065int remove_inode_page(struct inode *); 2152int remove_inode_page(struct inode *inode);
2066struct page *new_inode_page(struct inode *); 2153struct page *new_inode_page(struct inode *inode);
2067struct page *new_node_page(struct dnode_of_data *, unsigned int, struct page *); 2154struct page *new_node_page(struct dnode_of_data *dn,
2068void ra_node_page(struct f2fs_sb_info *, nid_t); 2155 unsigned int ofs, struct page *ipage);
2069struct page *get_node_page(struct f2fs_sb_info *, pgoff_t); 2156void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid);
2070struct page *get_node_page_ra(struct page *, int); 2157struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid);
2071void move_node_page(struct page *, int); 2158struct page *get_node_page_ra(struct page *parent, int start);
2072int fsync_node_pages(struct f2fs_sb_info *, struct inode *, 2159void move_node_page(struct page *node_page, int gc_type);
2073 struct writeback_control *, bool); 2160int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
2074int sync_node_pages(struct f2fs_sb_info *, struct writeback_control *); 2161 struct writeback_control *wbc, bool atomic);
2075void build_free_nids(struct f2fs_sb_info *, bool); 2162int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc);
2076bool alloc_nid(struct f2fs_sb_info *, nid_t *); 2163void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount);
2077void alloc_nid_done(struct f2fs_sb_info *, nid_t); 2164bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid);
2078void alloc_nid_failed(struct f2fs_sb_info *, nid_t); 2165void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid);
2079int try_to_free_nids(struct f2fs_sb_info *, int); 2166void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid);
2080void recover_inline_xattr(struct inode *, struct page *); 2167int try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink);
2081void recover_xattr_data(struct inode *, struct page *, block_t); 2168void recover_inline_xattr(struct inode *inode, struct page *page);
2082int recover_inode_page(struct f2fs_sb_info *, struct page *); 2169int recover_xattr_data(struct inode *inode, struct page *page,
2083int restore_node_summary(struct f2fs_sb_info *, unsigned int, 2170 block_t blkaddr);
2084 struct f2fs_summary_block *); 2171int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page);
2085void flush_nat_entries(struct f2fs_sb_info *); 2172int restore_node_summary(struct f2fs_sb_info *sbi,
2086int build_node_manager(struct f2fs_sb_info *); 2173 unsigned int segno, struct f2fs_summary_block *sum);
2087void destroy_node_manager(struct f2fs_sb_info *); 2174void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
2175int build_node_manager(struct f2fs_sb_info *sbi);
2176void destroy_node_manager(struct f2fs_sb_info *sbi);
2088int __init create_node_manager_caches(void); 2177int __init create_node_manager_caches(void);
2089void destroy_node_manager_caches(void); 2178void destroy_node_manager_caches(void);
2090 2179
2091/* 2180/*
2092 * segment.c 2181 * segment.c
2093 */ 2182 */
2094void register_inmem_page(struct inode *, struct page *); 2183void register_inmem_page(struct inode *inode, struct page *page);
2095void drop_inmem_pages(struct inode *); 2184void drop_inmem_pages(struct inode *inode);
2096int commit_inmem_pages(struct inode *); 2185int commit_inmem_pages(struct inode *inode);
2097void f2fs_balance_fs(struct f2fs_sb_info *, bool); 2186void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need);
2098void f2fs_balance_fs_bg(struct f2fs_sb_info *); 2187void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi);
2099int f2fs_issue_flush(struct f2fs_sb_info *); 2188int f2fs_issue_flush(struct f2fs_sb_info *sbi);
2100int create_flush_cmd_control(struct f2fs_sb_info *); 2189int create_flush_cmd_control(struct f2fs_sb_info *sbi);
2101void destroy_flush_cmd_control(struct f2fs_sb_info *, bool); 2190void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free);
2102void invalidate_blocks(struct f2fs_sb_info *, block_t); 2191void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
2103bool is_checkpointed_data(struct f2fs_sb_info *, block_t); 2192bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
2104void refresh_sit_entry(struct f2fs_sb_info *, block_t, block_t); 2193void refresh_sit_entry(struct f2fs_sb_info *sbi, block_t old, block_t new);
2105void f2fs_wait_all_discard_bio(struct f2fs_sb_info *); 2194void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr);
2106void clear_prefree_segments(struct f2fs_sb_info *, struct cp_control *); 2195void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc);
2107void release_discard_addrs(struct f2fs_sb_info *); 2196void release_discard_addrs(struct f2fs_sb_info *sbi);
2108int npages_for_summary_flush(struct f2fs_sb_info *, bool); 2197int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra);
2109void allocate_new_segments(struct f2fs_sb_info *); 2198void allocate_new_segments(struct f2fs_sb_info *sbi);
2110int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *); 2199int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range);
2111struct page *get_sum_page(struct f2fs_sb_info *, unsigned int); 2200bool exist_trim_candidates(struct f2fs_sb_info *sbi, struct cp_control *cpc);
2112void update_meta_page(struct f2fs_sb_info *, void *, block_t); 2201struct page *get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno);
2113void write_meta_page(struct f2fs_sb_info *, struct page *); 2202void update_meta_page(struct f2fs_sb_info *sbi, void *src, block_t blk_addr);
2114void write_node_page(unsigned int, struct f2fs_io_info *); 2203void write_meta_page(struct f2fs_sb_info *sbi, struct page *page);
2115void write_data_page(struct dnode_of_data *, struct f2fs_io_info *); 2204void write_node_page(unsigned int nid, struct f2fs_io_info *fio);
2116void rewrite_data_page(struct f2fs_io_info *); 2205void write_data_page(struct dnode_of_data *dn, struct f2fs_io_info *fio);
2117void __f2fs_replace_block(struct f2fs_sb_info *, struct f2fs_summary *, 2206void rewrite_data_page(struct f2fs_io_info *fio);
2118 block_t, block_t, bool, bool); 2207void __f2fs_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
2119void f2fs_replace_block(struct f2fs_sb_info *, struct dnode_of_data *, 2208 block_t old_blkaddr, block_t new_blkaddr,
2120 block_t, block_t, unsigned char, bool, bool); 2209 bool recover_curseg, bool recover_newaddr);
2121void allocate_data_block(struct f2fs_sb_info *, struct page *, 2210void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
2122 block_t, block_t *, struct f2fs_summary *, int); 2211 block_t old_addr, block_t new_addr,
2123void f2fs_wait_on_page_writeback(struct page *, enum page_type, bool); 2212 unsigned char version, bool recover_curseg,
2124void f2fs_wait_on_encrypted_page_writeback(struct f2fs_sb_info *, block_t); 2213 bool recover_newaddr);
2125void write_data_summaries(struct f2fs_sb_info *, block_t); 2214void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
2126void write_node_summaries(struct f2fs_sb_info *, block_t); 2215 block_t old_blkaddr, block_t *new_blkaddr,
2127int lookup_journal_in_cursum(struct f2fs_journal *, int, unsigned int, int); 2216 struct f2fs_summary *sum, int type);
2128void flush_sit_entries(struct f2fs_sb_info *, struct cp_control *); 2217void f2fs_wait_on_page_writeback(struct page *page,
2129int build_segment_manager(struct f2fs_sb_info *); 2218 enum page_type type, bool ordered);
2130void destroy_segment_manager(struct f2fs_sb_info *); 2219void f2fs_wait_on_encrypted_page_writeback(struct f2fs_sb_info *sbi,
2220 block_t blkaddr);
2221void write_data_summaries(struct f2fs_sb_info *sbi, block_t start_blk);
2222void write_node_summaries(struct f2fs_sb_info *sbi, block_t start_blk);
2223int lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
2224 unsigned int val, int alloc);
2225void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
2226int build_segment_manager(struct f2fs_sb_info *sbi);
2227void destroy_segment_manager(struct f2fs_sb_info *sbi);
2131int __init create_segment_manager_caches(void); 2228int __init create_segment_manager_caches(void);
2132void destroy_segment_manager_caches(void); 2229void destroy_segment_manager_caches(void);
2133 2230
2134/* 2231/*
2135 * checkpoint.c 2232 * checkpoint.c
2136 */ 2233 */
2137void f2fs_stop_checkpoint(struct f2fs_sb_info *, bool); 2234void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io);
2138struct page *grab_meta_page(struct f2fs_sb_info *, pgoff_t); 2235struct page *grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
2139struct page *get_meta_page(struct f2fs_sb_info *, pgoff_t); 2236struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
2140struct page *get_tmp_page(struct f2fs_sb_info *, pgoff_t); 2237struct page *get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index);
2141bool is_valid_blkaddr(struct f2fs_sb_info *, block_t, int); 2238bool is_valid_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr, int type);
2142int ra_meta_pages(struct f2fs_sb_info *, block_t, int, int, bool); 2239int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
2143void ra_meta_pages_cond(struct f2fs_sb_info *, pgoff_t); 2240 int type, bool sync);
2144long sync_meta_pages(struct f2fs_sb_info *, enum page_type, long); 2241void ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index);
2145void add_ino_entry(struct f2fs_sb_info *, nid_t, int type); 2242long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
2146void remove_ino_entry(struct f2fs_sb_info *, nid_t, int type); 2243 long nr_to_write);
2147void release_ino_entry(struct f2fs_sb_info *, bool); 2244void add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
2148bool exist_written_data(struct f2fs_sb_info *, nid_t, int); 2245void remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
2149int f2fs_sync_inode_meta(struct f2fs_sb_info *); 2246void release_ino_entry(struct f2fs_sb_info *sbi, bool all);
2150int acquire_orphan_inode(struct f2fs_sb_info *); 2247bool exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode);
2151void release_orphan_inode(struct f2fs_sb_info *); 2248int f2fs_sync_inode_meta(struct f2fs_sb_info *sbi);
2152void add_orphan_inode(struct inode *); 2249int acquire_orphan_inode(struct f2fs_sb_info *sbi);
2153void remove_orphan_inode(struct f2fs_sb_info *, nid_t); 2250void release_orphan_inode(struct f2fs_sb_info *sbi);
2154int recover_orphan_inodes(struct f2fs_sb_info *); 2251void add_orphan_inode(struct inode *inode);
2155int get_valid_checkpoint(struct f2fs_sb_info *); 2252void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino);
2156void update_dirty_page(struct inode *, struct page *); 2253int recover_orphan_inodes(struct f2fs_sb_info *sbi);
2157void remove_dirty_inode(struct inode *); 2254int get_valid_checkpoint(struct f2fs_sb_info *sbi);
2158int sync_dirty_inodes(struct f2fs_sb_info *, enum inode_type); 2255void update_dirty_page(struct inode *inode, struct page *page);
2159int write_checkpoint(struct f2fs_sb_info *, struct cp_control *); 2256void remove_dirty_inode(struct inode *inode);
2160void init_ino_entry_info(struct f2fs_sb_info *); 2257int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type);
2258int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc);
2259void init_ino_entry_info(struct f2fs_sb_info *sbi);
2161int __init create_checkpoint_caches(void); 2260int __init create_checkpoint_caches(void);
2162void destroy_checkpoint_caches(void); 2261void destroy_checkpoint_caches(void);
2163 2262
2164/* 2263/*
2165 * data.c 2264 * data.c
2166 */ 2265 */
2167void f2fs_submit_merged_bio(struct f2fs_sb_info *, enum page_type, int); 2266void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi, enum page_type type,
2168void f2fs_submit_merged_bio_cond(struct f2fs_sb_info *, struct inode *, 2267 int rw);
2169 struct page *, nid_t, enum page_type, int); 2268void f2fs_submit_merged_bio_cond(struct f2fs_sb_info *sbi,
2170void f2fs_flush_merged_bios(struct f2fs_sb_info *); 2269 struct inode *inode, nid_t ino, pgoff_t idx,
2171int f2fs_submit_page_bio(struct f2fs_io_info *); 2270 enum page_type type, int rw);
2172void f2fs_submit_page_mbio(struct f2fs_io_info *); 2271void f2fs_flush_merged_bios(struct f2fs_sb_info *sbi);
2173struct block_device *f2fs_target_device(struct f2fs_sb_info *, 2272int f2fs_submit_page_bio(struct f2fs_io_info *fio);
2174 block_t, struct bio *); 2273int f2fs_submit_page_mbio(struct f2fs_io_info *fio);
2175int f2fs_target_device_index(struct f2fs_sb_info *, block_t); 2274struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
2176void set_data_blkaddr(struct dnode_of_data *); 2275 block_t blk_addr, struct bio *bio);
2177void f2fs_update_data_blkaddr(struct dnode_of_data *, block_t); 2276int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr);
2178int reserve_new_blocks(struct dnode_of_data *, blkcnt_t); 2277void set_data_blkaddr(struct dnode_of_data *dn);
2179int reserve_new_block(struct dnode_of_data *); 2278void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);
2180int f2fs_get_block(struct dnode_of_data *, pgoff_t); 2279int reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
2181int f2fs_preallocate_blocks(struct kiocb *, struct iov_iter *); 2280int reserve_new_block(struct dnode_of_data *dn);
2182int f2fs_reserve_block(struct dnode_of_data *, pgoff_t); 2281int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index);
2183struct page *get_read_data_page(struct inode *, pgoff_t, int, bool); 2282int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from);
2184struct page *find_data_page(struct inode *, pgoff_t); 2283int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index);
2185struct page *get_lock_data_page(struct inode *, pgoff_t, bool); 2284struct page *get_read_data_page(struct inode *inode, pgoff_t index,
2186struct page *get_new_data_page(struct inode *, struct page *, pgoff_t, bool); 2285 int op_flags, bool for_write);
2187int do_write_data_page(struct f2fs_io_info *); 2286struct page *find_data_page(struct inode *inode, pgoff_t index);
2188int f2fs_map_blocks(struct inode *, struct f2fs_map_blocks *, int, int); 2287struct page *get_lock_data_page(struct inode *inode, pgoff_t index,
2189int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *, u64, u64); 2288 bool for_write);
2190void f2fs_set_page_dirty_nobuffers(struct page *); 2289struct page *get_new_data_page(struct inode *inode,
2191void f2fs_invalidate_page(struct page *, unsigned int, unsigned int); 2290 struct page *ipage, pgoff_t index, bool new_i_size);
2192int f2fs_release_page(struct page *, gfp_t); 2291int do_write_data_page(struct f2fs_io_info *fio);
2292int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
2293 int create, int flag);
2294int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
2295 u64 start, u64 len);
2296void f2fs_set_page_dirty_nobuffers(struct page *page);
2297void f2fs_invalidate_page(struct page *page, unsigned int offset,
2298 unsigned int length);
2299int f2fs_release_page(struct page *page, gfp_t wait);
2193#ifdef CONFIG_MIGRATION 2300#ifdef CONFIG_MIGRATION
2194int f2fs_migrate_page(struct address_space *, struct page *, struct page *, 2301int f2fs_migrate_page(struct address_space *mapping, struct page *newpage,
2195 enum migrate_mode); 2302 struct page *page, enum migrate_mode mode);
2196#endif 2303#endif
2197 2304
2198/* 2305/*
2199 * gc.c 2306 * gc.c
2200 */ 2307 */
2201int start_gc_thread(struct f2fs_sb_info *); 2308int start_gc_thread(struct f2fs_sb_info *sbi);
2202void stop_gc_thread(struct f2fs_sb_info *); 2309void stop_gc_thread(struct f2fs_sb_info *sbi);
2203block_t start_bidx_of_node(unsigned int, struct inode *); 2310block_t start_bidx_of_node(unsigned int node_ofs, struct inode *inode);
2204int f2fs_gc(struct f2fs_sb_info *, bool, bool); 2311int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, bool background);
2205void build_gc_manager(struct f2fs_sb_info *); 2312void build_gc_manager(struct f2fs_sb_info *sbi);
2206 2313
2207/* 2314/*
2208 * recovery.c 2315 * recovery.c
2209 */ 2316 */
2210int recover_fsync_data(struct f2fs_sb_info *, bool); 2317int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only);
2211bool space_for_roll_forward(struct f2fs_sb_info *); 2318bool space_for_roll_forward(struct f2fs_sb_info *sbi);
2212 2319
2213/* 2320/*
2214 * debug.c 2321 * debug.c
@@ -2227,8 +2334,9 @@ struct f2fs_stat_info {
2227 unsigned int ndirty_dirs, ndirty_files, ndirty_all; 2334 unsigned int ndirty_dirs, ndirty_files, ndirty_all;
2228 int nats, dirty_nats, sits, dirty_sits, free_nids, alloc_nids; 2335 int nats, dirty_nats, sits, dirty_sits, free_nids, alloc_nids;
2229 int total_count, utilization; 2336 int total_count, utilization;
2230 int bg_gc, nr_wb_cp_data, nr_wb_data; 2337 int bg_gc, nr_wb_cp_data, nr_wb_data, nr_flush, nr_discard;
2231 int inline_xattr, inline_inode, inline_dir, orphans; 2338 int inline_xattr, inline_inode, inline_dir, append, update, orphans;
2339 int aw_cnt, max_aw_cnt;
2232 unsigned int valid_count, valid_node_count, valid_inode_count, discard_blks; 2340 unsigned int valid_count, valid_node_count, valid_inode_count, discard_blks;
2233 unsigned int bimodal, avg_vblocks; 2341 unsigned int bimodal, avg_vblocks;
2234 int util_free, util_valid, util_invalid; 2342 int util_free, util_valid, util_invalid;
@@ -2300,6 +2408,17 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
2300 ((sbi)->block_count[(curseg)->alloc_type]++) 2408 ((sbi)->block_count[(curseg)->alloc_type]++)
2301#define stat_inc_inplace_blocks(sbi) \ 2409#define stat_inc_inplace_blocks(sbi) \
2302 (atomic_inc(&(sbi)->inplace_count)) 2410 (atomic_inc(&(sbi)->inplace_count))
2411#define stat_inc_atomic_write(inode) \
2412 (atomic_inc(&F2FS_I_SB(inode)->aw_cnt))
2413#define stat_dec_atomic_write(inode) \
2414 (atomic_dec(&F2FS_I_SB(inode)->aw_cnt))
2415#define stat_update_max_atomic_write(inode) \
2416 do { \
2417 int cur = atomic_read(&F2FS_I_SB(inode)->aw_cnt); \
2418 int max = atomic_read(&F2FS_I_SB(inode)->max_aw_cnt); \
2419 if (cur > max) \
2420 atomic_set(&F2FS_I_SB(inode)->max_aw_cnt, cur); \
2421 } while (0)
2303#define stat_inc_seg_count(sbi, type, gc_type) \ 2422#define stat_inc_seg_count(sbi, type, gc_type) \
2304 do { \ 2423 do { \
2305 struct f2fs_stat_info *si = F2FS_STAT(sbi); \ 2424 struct f2fs_stat_info *si = F2FS_STAT(sbi); \
@@ -2332,8 +2451,8 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
2332 si->bg_node_blks += (gc_type == BG_GC) ? (blks) : 0; \ 2451 si->bg_node_blks += (gc_type == BG_GC) ? (blks) : 0; \
2333 } while (0) 2452 } while (0)
2334 2453
2335int f2fs_build_stats(struct f2fs_sb_info *); 2454int f2fs_build_stats(struct f2fs_sb_info *sbi);
2336void f2fs_destroy_stats(struct f2fs_sb_info *); 2455void f2fs_destroy_stats(struct f2fs_sb_info *sbi);
2337int __init f2fs_create_root_stats(void); 2456int __init f2fs_create_root_stats(void);
2338void f2fs_destroy_root_stats(void); 2457void f2fs_destroy_root_stats(void);
2339#else 2458#else
@@ -2353,6 +2472,9 @@ void f2fs_destroy_root_stats(void);
2353#define stat_dec_inline_inode(inode) 2472#define stat_dec_inline_inode(inode)
2354#define stat_inc_inline_dir(inode) 2473#define stat_inc_inline_dir(inode)
2355#define stat_dec_inline_dir(inode) 2474#define stat_dec_inline_dir(inode)
2475#define stat_inc_atomic_write(inode)
2476#define stat_dec_atomic_write(inode)
2477#define stat_update_max_atomic_write(inode)
2356#define stat_inc_seg_type(sbi, curseg) 2478#define stat_inc_seg_type(sbi, curseg)
2357#define stat_inc_block_count(sbi, curseg) 2479#define stat_inc_block_count(sbi, curseg)
2358#define stat_inc_inplace_blocks(sbi) 2480#define stat_inc_inplace_blocks(sbi)
@@ -2382,49 +2504,55 @@ extern struct kmem_cache *inode_entry_slab;
2382/* 2504/*
2383 * inline.c 2505 * inline.c
2384 */ 2506 */
2385bool f2fs_may_inline_data(struct inode *); 2507bool f2fs_may_inline_data(struct inode *inode);
2386bool f2fs_may_inline_dentry(struct inode *); 2508bool f2fs_may_inline_dentry(struct inode *inode);
2387void read_inline_data(struct page *, struct page *); 2509void read_inline_data(struct page *page, struct page *ipage);
2388bool truncate_inline_inode(struct page *, u64); 2510bool truncate_inline_inode(struct page *ipage, u64 from);
2389int f2fs_read_inline_data(struct inode *, struct page *); 2511int f2fs_read_inline_data(struct inode *inode, struct page *page);
2390int f2fs_convert_inline_page(struct dnode_of_data *, struct page *); 2512int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page);
2391int f2fs_convert_inline_inode(struct inode *); 2513int f2fs_convert_inline_inode(struct inode *inode);
2392int f2fs_write_inline_data(struct inode *, struct page *); 2514int f2fs_write_inline_data(struct inode *inode, struct page *page);
2393bool recover_inline_data(struct inode *, struct page *); 2515bool recover_inline_data(struct inode *inode, struct page *npage);
2394struct f2fs_dir_entry *find_in_inline_dir(struct inode *, 2516struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
2395 struct fscrypt_name *, struct page **); 2517 struct fscrypt_name *fname, struct page **res_page);
2396int make_empty_inline_dir(struct inode *inode, struct inode *, struct page *); 2518int make_empty_inline_dir(struct inode *inode, struct inode *parent,
2397int f2fs_add_inline_entry(struct inode *, const struct qstr *, 2519 struct page *ipage);
2398 const struct qstr *, struct inode *, nid_t, umode_t); 2520int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
2399void f2fs_delete_inline_entry(struct f2fs_dir_entry *, struct page *, 2521 const struct qstr *orig_name,
2400 struct inode *, struct inode *); 2522 struct inode *inode, nid_t ino, umode_t mode);
2401bool f2fs_empty_inline_dir(struct inode *); 2523void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
2402int f2fs_read_inline_dir(struct file *, struct dir_context *, 2524 struct inode *dir, struct inode *inode);
2403 struct fscrypt_str *); 2525bool f2fs_empty_inline_dir(struct inode *dir);
2404int f2fs_inline_data_fiemap(struct inode *, 2526int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
2405 struct fiemap_extent_info *, __u64, __u64); 2527 struct fscrypt_str *fstr);
2528int f2fs_inline_data_fiemap(struct inode *inode,
2529 struct fiemap_extent_info *fieinfo,
2530 __u64 start, __u64 len);
2406 2531
2407/* 2532/*
2408 * shrinker.c 2533 * shrinker.c
2409 */ 2534 */
2410unsigned long f2fs_shrink_count(struct shrinker *, struct shrink_control *); 2535unsigned long f2fs_shrink_count(struct shrinker *shrink,
2411unsigned long f2fs_shrink_scan(struct shrinker *, struct shrink_control *); 2536 struct shrink_control *sc);
2412void f2fs_join_shrinker(struct f2fs_sb_info *); 2537unsigned long f2fs_shrink_scan(struct shrinker *shrink,
2413void f2fs_leave_shrinker(struct f2fs_sb_info *); 2538 struct shrink_control *sc);
2539void f2fs_join_shrinker(struct f2fs_sb_info *sbi);
2540void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);
2414 2541
2415/* 2542/*
2416 * extent_cache.c 2543 * extent_cache.c
2417 */ 2544 */
2418unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *, int); 2545unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink);
2419bool f2fs_init_extent_tree(struct inode *, struct f2fs_extent *); 2546bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext);
2420void f2fs_drop_extent_tree(struct inode *); 2547void f2fs_drop_extent_tree(struct inode *inode);
2421unsigned int f2fs_destroy_extent_node(struct inode *); 2548unsigned int f2fs_destroy_extent_node(struct inode *inode);
2422void f2fs_destroy_extent_tree(struct inode *); 2549void f2fs_destroy_extent_tree(struct inode *inode);
2423bool f2fs_lookup_extent_cache(struct inode *, pgoff_t, struct extent_info *); 2550bool f2fs_lookup_extent_cache(struct inode *inode, pgoff_t pgofs,
2424void f2fs_update_extent_cache(struct dnode_of_data *); 2551 struct extent_info *ei);
2552void f2fs_update_extent_cache(struct dnode_of_data *dn);
2425void f2fs_update_extent_cache_range(struct dnode_of_data *dn, 2553void f2fs_update_extent_cache_range(struct dnode_of_data *dn,
2426 pgoff_t, block_t, unsigned int); 2554 pgoff_t fofs, block_t blkaddr, unsigned int len);
2427void init_extent_cache_info(struct f2fs_sb_info *); 2555void init_extent_cache_info(struct f2fs_sb_info *sbi);
2428int __init create_extent_cache(void); 2556int __init create_extent_cache(void);
2429void destroy_extent_cache(void); 2557void destroy_extent_cache(void);
2430 2558
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 1edc86e874e3..78e65288f2b2 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -20,6 +20,7 @@
20#include <linux/uaccess.h> 20#include <linux/uaccess.h>
21#include <linux/mount.h> 21#include <linux/mount.h>
22#include <linux/pagevec.h> 22#include <linux/pagevec.h>
23#include <linux/uio.h>
23#include <linux/uuid.h> 24#include <linux/uuid.h>
24#include <linux/file.h> 25#include <linux/file.h>
25 26
@@ -140,8 +141,6 @@ static inline bool need_do_checkpoint(struct inode *inode)
140 need_cp = true; 141 need_cp = true;
141 else if (!is_checkpointed_node(sbi, F2FS_I(inode)->i_pino)) 142 else if (!is_checkpointed_node(sbi, F2FS_I(inode)->i_pino))
142 need_cp = true; 143 need_cp = true;
143 else if (F2FS_I(inode)->xattr_ver == cur_cp_version(F2FS_CKPT(sbi)))
144 need_cp = true;
145 else if (test_opt(sbi, FASTBOOT)) 144 else if (test_opt(sbi, FASTBOOT))
146 need_cp = true; 145 need_cp = true;
147 else if (sbi->active_logs == 2) 146 else if (sbi->active_logs == 2)
@@ -167,7 +166,6 @@ static void try_to_fix_pino(struct inode *inode)
167 nid_t pino; 166 nid_t pino;
168 167
169 down_write(&fi->i_sem); 168 down_write(&fi->i_sem);
170 fi->xattr_ver = 0;
171 if (file_wrong_pino(inode) && inode->i_nlink == 1 && 169 if (file_wrong_pino(inode) && inode->i_nlink == 1 &&
172 get_parent_ino(inode, &pino)) { 170 get_parent_ino(inode, &pino)) {
173 f2fs_i_pino_write(inode, pino); 171 f2fs_i_pino_write(inode, pino);
@@ -276,7 +274,8 @@ sync_nodes:
276flush_out: 274flush_out:
277 remove_ino_entry(sbi, ino, UPDATE_INO); 275 remove_ino_entry(sbi, ino, UPDATE_INO);
278 clear_inode_flag(inode, FI_UPDATE_WRITE); 276 clear_inode_flag(inode, FI_UPDATE_WRITE);
279 ret = f2fs_issue_flush(sbi); 277 if (!atomic)
278 ret = f2fs_issue_flush(sbi);
280 f2fs_update_time(sbi, REQ_TIME); 279 f2fs_update_time(sbi, REQ_TIME);
281out: 280out:
282 trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret); 281 trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
@@ -567,8 +566,9 @@ int truncate_blocks(struct inode *inode, u64 from, bool lock)
567 } 566 }
568 567
569 if (f2fs_has_inline_data(inode)) { 568 if (f2fs_has_inline_data(inode)) {
570 if (truncate_inline_inode(ipage, from)) 569 truncate_inline_inode(ipage, from);
571 set_page_dirty(ipage); 570 if (from == 0)
571 clear_inode_flag(inode, FI_DATA_EXIST);
572 f2fs_put_page(ipage, 1); 572 f2fs_put_page(ipage, 1);
573 truncate_page = true; 573 truncate_page = true;
574 goto out; 574 goto out;
@@ -1541,6 +1541,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
1541 if (ret) 1541 if (ret)
1542 clear_inode_flag(inode, FI_ATOMIC_FILE); 1542 clear_inode_flag(inode, FI_ATOMIC_FILE);
1543out: 1543out:
1544 stat_inc_atomic_write(inode);
1545 stat_update_max_atomic_write(inode);
1544 inode_unlock(inode); 1546 inode_unlock(inode);
1545 mnt_drop_write_file(filp); 1547 mnt_drop_write_file(filp);
1546 return ret; 1548 return ret;
@@ -1564,15 +1566,18 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
1564 goto err_out; 1566 goto err_out;
1565 1567
1566 if (f2fs_is_atomic_file(inode)) { 1568 if (f2fs_is_atomic_file(inode)) {
1567 clear_inode_flag(inode, FI_ATOMIC_FILE);
1568 ret = commit_inmem_pages(inode); 1569 ret = commit_inmem_pages(inode);
1569 if (ret) { 1570 if (ret)
1570 set_inode_flag(inode, FI_ATOMIC_FILE);
1571 goto err_out; 1571 goto err_out;
1572
1573 ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
1574 if (!ret) {
1575 clear_inode_flag(inode, FI_ATOMIC_FILE);
1576 stat_dec_atomic_write(inode);
1572 } 1577 }
1578 } else {
1579 ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
1573 } 1580 }
1574
1575 ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
1576err_out: 1581err_out:
1577 inode_unlock(inode); 1582 inode_unlock(inode);
1578 mnt_drop_write_file(filp); 1583 mnt_drop_write_file(filp);
@@ -1870,7 +1875,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
1870{ 1875{
1871 struct inode *inode = file_inode(filp); 1876 struct inode *inode = file_inode(filp);
1872 struct f2fs_map_blocks map = { .m_next_pgofs = NULL }; 1877 struct f2fs_map_blocks map = { .m_next_pgofs = NULL };
1873 struct extent_info ei; 1878 struct extent_info ei = {0,0,0};
1874 pgoff_t pg_start, pg_end; 1879 pgoff_t pg_start, pg_end;
1875 unsigned int blk_per_seg = sbi->blocks_per_seg; 1880 unsigned int blk_per_seg = sbi->blocks_per_seg;
1876 unsigned int total = 0, sec_num; 1881 unsigned int total = 0, sec_num;
@@ -2250,8 +2255,12 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
2250 inode_lock(inode); 2255 inode_lock(inode);
2251 ret = generic_write_checks(iocb, from); 2256 ret = generic_write_checks(iocb, from);
2252 if (ret > 0) { 2257 if (ret > 0) {
2253 int err = f2fs_preallocate_blocks(iocb, from); 2258 int err;
2259
2260 if (iov_iter_fault_in_readable(from, iov_iter_count(from)))
2261 set_inode_flag(inode, FI_NO_PREALLOC);
2254 2262
2263 err = f2fs_preallocate_blocks(iocb, from);
2255 if (err) { 2264 if (err) {
2256 inode_unlock(inode); 2265 inode_unlock(inode);
2257 return err; 2266 return err;
@@ -2259,6 +2268,7 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
2259 blk_start_plug(&plug); 2268 blk_start_plug(&plug);
2260 ret = __generic_file_write_iter(iocb, from); 2269 ret = __generic_file_write_iter(iocb, from);
2261 blk_finish_plug(&plug); 2270 blk_finish_plug(&plug);
2271 clear_inode_flag(inode, FI_NO_PREALLOC);
2262 } 2272 }
2263 inode_unlock(inode); 2273 inode_unlock(inode);
2264 2274
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 88bfc3dff496..418fd9881646 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -48,8 +48,10 @@ static int gc_thread_func(void *data)
48 } 48 }
49 49
50#ifdef CONFIG_F2FS_FAULT_INJECTION 50#ifdef CONFIG_F2FS_FAULT_INJECTION
51 if (time_to_inject(sbi, FAULT_CHECKPOINT)) 51 if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
52 f2fs_show_injection_info(FAULT_CHECKPOINT);
52 f2fs_stop_checkpoint(sbi, false); 53 f2fs_stop_checkpoint(sbi, false);
54 }
53#endif 55#endif
54 56
55 /* 57 /*
@@ -166,7 +168,8 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
166 p->ofs_unit = sbi->segs_per_sec; 168 p->ofs_unit = sbi->segs_per_sec;
167 } 169 }
168 170
169 if (p->max_search > sbi->max_victim_search) 171 /* we need to check every dirty segments in the FG_GC case */
172 if (gc_type != FG_GC && p->max_search > sbi->max_victim_search)
170 p->max_search = sbi->max_victim_search; 173 p->max_search = sbi->max_victim_search;
171 174
172 p->offset = sbi->last_victim[p->gc_mode]; 175 p->offset = sbi->last_victim[p->gc_mode];
@@ -199,6 +202,10 @@ static unsigned int check_bg_victims(struct f2fs_sb_info *sbi)
199 for_each_set_bit(secno, dirty_i->victim_secmap, MAIN_SECS(sbi)) { 202 for_each_set_bit(secno, dirty_i->victim_secmap, MAIN_SECS(sbi)) {
200 if (sec_usage_check(sbi, secno)) 203 if (sec_usage_check(sbi, secno))
201 continue; 204 continue;
205
206 if (no_fggc_candidate(sbi, secno))
207 continue;
208
202 clear_bit(secno, dirty_i->victim_secmap); 209 clear_bit(secno, dirty_i->victim_secmap);
203 return secno * sbi->segs_per_sec; 210 return secno * sbi->segs_per_sec;
204 } 211 }
@@ -237,6 +244,16 @@ static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno)
237 return UINT_MAX - ((100 * (100 - u) * age) / (100 + u)); 244 return UINT_MAX - ((100 * (100 - u) * age) / (100 + u));
238} 245}
239 246
247static unsigned int get_greedy_cost(struct f2fs_sb_info *sbi,
248 unsigned int segno)
249{
250 unsigned int valid_blocks =
251 get_valid_blocks(sbi, segno, sbi->segs_per_sec);
252
253 return IS_DATASEG(get_seg_entry(sbi, segno)->type) ?
254 valid_blocks * 2 : valid_blocks;
255}
256
240static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi, 257static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi,
241 unsigned int segno, struct victim_sel_policy *p) 258 unsigned int segno, struct victim_sel_policy *p)
242{ 259{
@@ -245,7 +262,7 @@ static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi,
245 262
246 /* alloc_mode == LFS */ 263 /* alloc_mode == LFS */
247 if (p->gc_mode == GC_GREEDY) 264 if (p->gc_mode == GC_GREEDY)
248 return get_valid_blocks(sbi, segno, sbi->segs_per_sec); 265 return get_greedy_cost(sbi, segno);
249 else 266 else
250 return get_cb_cost(sbi, segno); 267 return get_cb_cost(sbi, segno);
251} 268}
@@ -322,13 +339,15 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
322 nsearched++; 339 nsearched++;
323 } 340 }
324 341
325
326 secno = GET_SECNO(sbi, segno); 342 secno = GET_SECNO(sbi, segno);
327 343
328 if (sec_usage_check(sbi, secno)) 344 if (sec_usage_check(sbi, secno))
329 goto next; 345 goto next;
330 if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap)) 346 if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap))
331 goto next; 347 goto next;
348 if (gc_type == FG_GC && p.alloc_mode == LFS &&
349 no_fggc_candidate(sbi, secno))
350 goto next;
332 351
333 cost = get_gc_cost(sbi, segno, &p); 352 cost = get_gc_cost(sbi, segno, &p);
334 353
@@ -569,6 +588,9 @@ static void move_encrypted_block(struct inode *inode, block_t bidx,
569 if (!check_valid_map(F2FS_I_SB(inode), segno, off)) 588 if (!check_valid_map(F2FS_I_SB(inode), segno, off))
570 goto out; 589 goto out;
571 590
591 if (f2fs_is_atomic_file(inode))
592 goto out;
593
572 set_new_dnode(&dn, inode, NULL, NULL, 0); 594 set_new_dnode(&dn, inode, NULL, NULL, 0);
573 err = get_dnode_of_data(&dn, bidx, LOOKUP_NODE); 595 err = get_dnode_of_data(&dn, bidx, LOOKUP_NODE);
574 if (err) 596 if (err)
@@ -661,6 +683,9 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
661 if (!check_valid_map(F2FS_I_SB(inode), segno, off)) 683 if (!check_valid_map(F2FS_I_SB(inode), segno, off))
662 goto out; 684 goto out;
663 685
686 if (f2fs_is_atomic_file(inode))
687 goto out;
688
664 if (gc_type == BG_GC) { 689 if (gc_type == BG_GC) {
665 if (PageWriteback(page)) 690 if (PageWriteback(page))
666 goto out; 691 goto out;
@@ -921,8 +946,6 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, bool background)
921 946
922 cpc.reason = __get_cp_reason(sbi); 947 cpc.reason = __get_cp_reason(sbi);
923gc_more: 948gc_more:
924 segno = NULL_SEGNO;
925
926 if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE))) 949 if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE)))
927 goto stop; 950 goto stop;
928 if (unlikely(f2fs_cp_error(sbi))) { 951 if (unlikely(f2fs_cp_error(sbi))) {
@@ -930,30 +953,23 @@ gc_more:
930 goto stop; 953 goto stop;
931 } 954 }
932 955
933 if (gc_type == BG_GC && has_not_enough_free_secs(sbi, sec_freed, 0)) { 956 if (gc_type == BG_GC && has_not_enough_free_secs(sbi, 0, 0)) {
934 gc_type = FG_GC;
935 /* 957 /*
936 * If there is no victim and no prefree segment but still not 958 * For example, if there are many prefree_segments below given
937 * enough free sections, we should flush dent/node blocks and do 959 * threshold, we can make them free by checkpoint. Then, we
938 * garbage collections. 960 * secure free segments which doesn't need fggc any more.
939 */ 961 */
940 if (__get_victim(sbi, &segno, gc_type) || 962 ret = write_checkpoint(sbi, &cpc);
941 prefree_segments(sbi)) { 963 if (ret)
942 ret = write_checkpoint(sbi, &cpc); 964 goto stop;
943 if (ret) 965 if (has_not_enough_free_secs(sbi, 0, 0))
944 goto stop; 966 gc_type = FG_GC;
945 segno = NULL_SEGNO;
946 } else if (has_not_enough_free_secs(sbi, 0, 0)) {
947 ret = write_checkpoint(sbi, &cpc);
948 if (ret)
949 goto stop;
950 }
951 } else if (gc_type == BG_GC && !background) {
952 /* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
953 goto stop;
954 } 967 }
955 968
956 if (segno == NULL_SEGNO && !__get_victim(sbi, &segno, gc_type)) 969 /* f2fs_balance_fs doesn't need to do BG_GC in critical path. */
970 if (gc_type == BG_GC && !background)
971 goto stop;
972 if (!__get_victim(sbi, &segno, gc_type))
957 goto stop; 973 goto stop;
958 ret = 0; 974 ret = 0;
959 975
@@ -983,5 +999,16 @@ stop:
983 999
984void build_gc_manager(struct f2fs_sb_info *sbi) 1000void build_gc_manager(struct f2fs_sb_info *sbi)
985{ 1001{
1002 u64 main_count, resv_count, ovp_count, blocks_per_sec;
1003
986 DIRTY_I(sbi)->v_ops = &default_v_ops; 1004 DIRTY_I(sbi)->v_ops = &default_v_ops;
1005
1006 /* threshold of # of valid blocks in a section for victims of FG_GC */
1007 main_count = SM_I(sbi)->main_segments << sbi->log_blocks_per_seg;
1008 resv_count = SM_I(sbi)->reserved_segments << sbi->log_blocks_per_seg;
1009 ovp_count = SM_I(sbi)->ovp_segments << sbi->log_blocks_per_seg;
1010 blocks_per_sec = sbi->blocks_per_seg * sbi->segs_per_sec;
1011
1012 sbi->fggc_threshold = div64_u64((main_count - ovp_count) * blocks_per_sec,
1013 (main_count - resv_count));
987} 1014}
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index af06bda51a54..24bb8213d974 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -373,8 +373,10 @@ void f2fs_evict_inode(struct inode *inode)
373 goto no_delete; 373 goto no_delete;
374 374
375#ifdef CONFIG_F2FS_FAULT_INJECTION 375#ifdef CONFIG_F2FS_FAULT_INJECTION
376 if (time_to_inject(sbi, FAULT_EVICT_INODE)) 376 if (time_to_inject(sbi, FAULT_EVICT_INODE)) {
377 f2fs_show_injection_info(FAULT_EVICT_INODE);
377 goto no_delete; 378 goto no_delete;
379 }
378#endif 380#endif
379 381
380 remove_ino_entry(sbi, inode->i_ino, APPEND_INO); 382 remove_ino_entry(sbi, inode->i_ino, APPEND_INO);
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 11cabcadb1a3..98f00a3a7f50 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -321,9 +321,9 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
321 if (err) 321 if (err)
322 goto err_out; 322 goto err_out;
323 } 323 }
324 if (!IS_ERR(inode) && f2fs_encrypted_inode(dir) && 324 if (f2fs_encrypted_inode(dir) &&
325 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && 325 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
326 !fscrypt_has_permitted_context(dir, inode)) { 326 !fscrypt_has_permitted_context(dir, inode)) {
327 bool nokey = f2fs_encrypted_inode(inode) && 327 bool nokey = f2fs_encrypted_inode(inode) &&
328 !fscrypt_has_encryption_key(inode); 328 !fscrypt_has_encryption_key(inode);
329 err = nokey ? -ENOKEY : -EPERM; 329 err = nokey ? -ENOKEY : -EPERM;
@@ -663,6 +663,12 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
663 bool is_old_inline = f2fs_has_inline_dentry(old_dir); 663 bool is_old_inline = f2fs_has_inline_dentry(old_dir);
664 int err = -ENOENT; 664 int err = -ENOENT;
665 665
666 if ((f2fs_encrypted_inode(old_dir) &&
667 !fscrypt_has_encryption_key(old_dir)) ||
668 (f2fs_encrypted_inode(new_dir) &&
669 !fscrypt_has_encryption_key(new_dir)))
670 return -ENOKEY;
671
666 if ((old_dir != new_dir) && f2fs_encrypted_inode(new_dir) && 672 if ((old_dir != new_dir) && f2fs_encrypted_inode(new_dir) &&
667 !fscrypt_has_permitted_context(new_dir, old_inode)) { 673 !fscrypt_has_permitted_context(new_dir, old_inode)) {
668 err = -EPERM; 674 err = -EPERM;
@@ -843,6 +849,12 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
843 int old_nlink = 0, new_nlink = 0; 849 int old_nlink = 0, new_nlink = 0;
844 int err = -ENOENT; 850 int err = -ENOENT;
845 851
852 if ((f2fs_encrypted_inode(old_dir) &&
853 !fscrypt_has_encryption_key(old_dir)) ||
854 (f2fs_encrypted_inode(new_dir) &&
855 !fscrypt_has_encryption_key(new_dir)))
856 return -ENOKEY;
857
846 if ((f2fs_encrypted_inode(old_dir) || f2fs_encrypted_inode(new_dir)) && 858 if ((f2fs_encrypted_inode(old_dir) || f2fs_encrypted_inode(new_dir)) &&
847 (old_dir != new_dir) && 859 (old_dir != new_dir) &&
848 (!fscrypt_has_permitted_context(new_dir, old_inode) || 860 (!fscrypt_has_permitted_context(new_dir, old_inode) ||
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index b9078fdb3743..94967171dee8 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -245,12 +245,24 @@ bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
245 return need_update; 245 return need_update;
246} 246}
247 247
248static struct nat_entry *grab_nat_entry(struct f2fs_nm_info *nm_i, nid_t nid) 248static struct nat_entry *grab_nat_entry(struct f2fs_nm_info *nm_i, nid_t nid,
249 bool no_fail)
249{ 250{
250 struct nat_entry *new; 251 struct nat_entry *new;
251 252
252 new = f2fs_kmem_cache_alloc(nat_entry_slab, GFP_NOFS); 253 if (no_fail) {
253 f2fs_radix_tree_insert(&nm_i->nat_root, nid, new); 254 new = f2fs_kmem_cache_alloc(nat_entry_slab, GFP_NOFS);
255 f2fs_radix_tree_insert(&nm_i->nat_root, nid, new);
256 } else {
257 new = kmem_cache_alloc(nat_entry_slab, GFP_NOFS);
258 if (!new)
259 return NULL;
260 if (radix_tree_insert(&nm_i->nat_root, nid, new)) {
261 kmem_cache_free(nat_entry_slab, new);
262 return NULL;
263 }
264 }
265
254 memset(new, 0, sizeof(struct nat_entry)); 266 memset(new, 0, sizeof(struct nat_entry));
255 nat_set_nid(new, nid); 267 nat_set_nid(new, nid);
256 nat_reset_flag(new); 268 nat_reset_flag(new);
@@ -267,8 +279,9 @@ static void cache_nat_entry(struct f2fs_sb_info *sbi, nid_t nid,
267 279
268 e = __lookup_nat_cache(nm_i, nid); 280 e = __lookup_nat_cache(nm_i, nid);
269 if (!e) { 281 if (!e) {
270 e = grab_nat_entry(nm_i, nid); 282 e = grab_nat_entry(nm_i, nid, false);
271 node_info_from_raw_nat(&e->ni, ne); 283 if (e)
284 node_info_from_raw_nat(&e->ni, ne);
272 } else { 285 } else {
273 f2fs_bug_on(sbi, nat_get_ino(e) != le32_to_cpu(ne->ino) || 286 f2fs_bug_on(sbi, nat_get_ino(e) != le32_to_cpu(ne->ino) ||
274 nat_get_blkaddr(e) != 287 nat_get_blkaddr(e) !=
@@ -286,7 +299,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni,
286 down_write(&nm_i->nat_tree_lock); 299 down_write(&nm_i->nat_tree_lock);
287 e = __lookup_nat_cache(nm_i, ni->nid); 300 e = __lookup_nat_cache(nm_i, ni->nid);
288 if (!e) { 301 if (!e) {
289 e = grab_nat_entry(nm_i, ni->nid); 302 e = grab_nat_entry(nm_i, ni->nid, true);
290 copy_node_info(&e->ni, ni); 303 copy_node_info(&e->ni, ni);
291 f2fs_bug_on(sbi, ni->blk_addr == NEW_ADDR); 304 f2fs_bug_on(sbi, ni->blk_addr == NEW_ADDR);
292 } else if (new_blkaddr == NEW_ADDR) { 305 } else if (new_blkaddr == NEW_ADDR) {
@@ -325,6 +338,9 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni,
325 set_nat_flag(e, IS_CHECKPOINTED, false); 338 set_nat_flag(e, IS_CHECKPOINTED, false);
326 __set_nat_cache_dirty(nm_i, e); 339 __set_nat_cache_dirty(nm_i, e);
327 340
341 if (enabled_nat_bits(sbi, NULL) && new_blkaddr == NEW_ADDR)
342 clear_bit_le(NAT_BLOCK_OFFSET(ni->nid), nm_i->empty_nat_bits);
343
328 /* update fsync_mark if its inode nat entry is still alive */ 344 /* update fsync_mark if its inode nat entry is still alive */
329 if (ni->nid != ni->ino) 345 if (ni->nid != ni->ino)
330 e = __lookup_nat_cache(nm_i, ni->ino); 346 e = __lookup_nat_cache(nm_i, ni->ino);
@@ -958,9 +974,6 @@ int truncate_xattr_node(struct inode *inode, struct page *page)
958 974
959 f2fs_i_xnid_write(inode, 0); 975 f2fs_i_xnid_write(inode, 0);
960 976
961 /* need to do checkpoint during fsync */
962 F2FS_I(inode)->xattr_ver = cur_cp_version(F2FS_CKPT(sbi));
963
964 set_new_dnode(&dn, inode, page, npage, nid); 977 set_new_dnode(&dn, inode, page, npage, nid);
965 978
966 if (page) 979 if (page)
@@ -1018,7 +1031,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
1018 unsigned int ofs, struct page *ipage) 1031 unsigned int ofs, struct page *ipage)
1019{ 1032{
1020 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode); 1033 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
1021 struct node_info old_ni, new_ni; 1034 struct node_info new_ni;
1022 struct page *page; 1035 struct page *page;
1023 int err; 1036 int err;
1024 1037
@@ -1033,13 +1046,15 @@ struct page *new_node_page(struct dnode_of_data *dn,
1033 err = -ENOSPC; 1046 err = -ENOSPC;
1034 goto fail; 1047 goto fail;
1035 } 1048 }
1036 1049#ifdef CONFIG_F2FS_CHECK_FS
1037 get_node_info(sbi, dn->nid, &old_ni); 1050 get_node_info(sbi, dn->nid, &new_ni);
1038 1051 f2fs_bug_on(sbi, new_ni.blk_addr != NULL_ADDR);
1039 /* Reinitialize old_ni with new node page */ 1052#endif
1040 f2fs_bug_on(sbi, old_ni.blk_addr != NULL_ADDR); 1053 new_ni.nid = dn->nid;
1041 new_ni = old_ni;
1042 new_ni.ino = dn->inode->i_ino; 1054 new_ni.ino = dn->inode->i_ino;
1055 new_ni.blk_addr = NULL_ADDR;
1056 new_ni.flag = 0;
1057 new_ni.version = 0;
1043 set_node_addr(sbi, &new_ni, NEW_ADDR, false); 1058 set_node_addr(sbi, &new_ni, NEW_ADDR, false);
1044 1059
1045 f2fs_wait_on_page_writeback(page, NODE, true); 1060 f2fs_wait_on_page_writeback(page, NODE, true);
@@ -1305,16 +1320,99 @@ continue_unlock:
1305 return last_page; 1320 return last_page;
1306} 1321}
1307 1322
1323static int __write_node_page(struct page *page, bool atomic, bool *submitted,
1324 struct writeback_control *wbc)
1325{
1326 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
1327 nid_t nid;
1328 struct node_info ni;
1329 struct f2fs_io_info fio = {
1330 .sbi = sbi,
1331 .type = NODE,
1332 .op = REQ_OP_WRITE,
1333 .op_flags = wbc_to_write_flags(wbc),
1334 .page = page,
1335 .encrypted_page = NULL,
1336 .submitted = false,
1337 };
1338
1339 trace_f2fs_writepage(page, NODE);
1340
1341 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
1342 goto redirty_out;
1343 if (unlikely(f2fs_cp_error(sbi)))
1344 goto redirty_out;
1345
1346 /* get old block addr of this node page */
1347 nid = nid_of_node(page);
1348 f2fs_bug_on(sbi, page->index != nid);
1349
1350 if (wbc->for_reclaim) {
1351 if (!down_read_trylock(&sbi->node_write))
1352 goto redirty_out;
1353 } else {
1354 down_read(&sbi->node_write);
1355 }
1356
1357 get_node_info(sbi, nid, &ni);
1358
1359 /* This page is already truncated */
1360 if (unlikely(ni.blk_addr == NULL_ADDR)) {
1361 ClearPageUptodate(page);
1362 dec_page_count(sbi, F2FS_DIRTY_NODES);
1363 up_read(&sbi->node_write);
1364 unlock_page(page);
1365 return 0;
1366 }
1367
1368 if (atomic && !test_opt(sbi, NOBARRIER))
1369 fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
1370
1371 set_page_writeback(page);
1372 fio.old_blkaddr = ni.blk_addr;
1373 write_node_page(nid, &fio);
1374 set_node_addr(sbi, &ni, fio.new_blkaddr, is_fsync_dnode(page));
1375 dec_page_count(sbi, F2FS_DIRTY_NODES);
1376 up_read(&sbi->node_write);
1377
1378 if (wbc->for_reclaim) {
1379 f2fs_submit_merged_bio_cond(sbi, page->mapping->host, 0,
1380 page->index, NODE, WRITE);
1381 submitted = NULL;
1382 }
1383
1384 unlock_page(page);
1385
1386 if (unlikely(f2fs_cp_error(sbi))) {
1387 f2fs_submit_merged_bio(sbi, NODE, WRITE);
1388 submitted = NULL;
1389 }
1390 if (submitted)
1391 *submitted = fio.submitted;
1392
1393 return 0;
1394
1395redirty_out:
1396 redirty_page_for_writepage(wbc, page);
1397 return AOP_WRITEPAGE_ACTIVATE;
1398}
1399
1400static int f2fs_write_node_page(struct page *page,
1401 struct writeback_control *wbc)
1402{
1403 return __write_node_page(page, false, NULL, wbc);
1404}
1405
1308int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, 1406int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
1309 struct writeback_control *wbc, bool atomic) 1407 struct writeback_control *wbc, bool atomic)
1310{ 1408{
1311 pgoff_t index, end; 1409 pgoff_t index, end;
1410 pgoff_t last_idx = ULONG_MAX;
1312 struct pagevec pvec; 1411 struct pagevec pvec;
1313 int ret = 0; 1412 int ret = 0;
1314 struct page *last_page = NULL; 1413 struct page *last_page = NULL;
1315 bool marked = false; 1414 bool marked = false;
1316 nid_t ino = inode->i_ino; 1415 nid_t ino = inode->i_ino;
1317 int nwritten = 0;
1318 1416
1319 if (atomic) { 1417 if (atomic) {
1320 last_page = last_fsync_dnode(sbi, ino); 1418 last_page = last_fsync_dnode(sbi, ino);
@@ -1336,6 +1434,7 @@ retry:
1336 1434
1337 for (i = 0; i < nr_pages; i++) { 1435 for (i = 0; i < nr_pages; i++) {
1338 struct page *page = pvec.pages[i]; 1436 struct page *page = pvec.pages[i];
1437 bool submitted = false;
1339 1438
1340 if (unlikely(f2fs_cp_error(sbi))) { 1439 if (unlikely(f2fs_cp_error(sbi))) {
1341 f2fs_put_page(last_page, 0); 1440 f2fs_put_page(last_page, 0);
@@ -1384,13 +1483,15 @@ continue_unlock:
1384 if (!clear_page_dirty_for_io(page)) 1483 if (!clear_page_dirty_for_io(page))
1385 goto continue_unlock; 1484 goto continue_unlock;
1386 1485
1387 ret = NODE_MAPPING(sbi)->a_ops->writepage(page, wbc); 1486 ret = __write_node_page(page, atomic &&
1487 page == last_page,
1488 &submitted, wbc);
1388 if (ret) { 1489 if (ret) {
1389 unlock_page(page); 1490 unlock_page(page);
1390 f2fs_put_page(last_page, 0); 1491 f2fs_put_page(last_page, 0);
1391 break; 1492 break;
1392 } else { 1493 } else if (submitted) {
1393 nwritten++; 1494 last_idx = page->index;
1394 } 1495 }
1395 1496
1396 if (page == last_page) { 1497 if (page == last_page) {
@@ -1416,8 +1517,9 @@ continue_unlock:
1416 goto retry; 1517 goto retry;
1417 } 1518 }
1418out: 1519out:
1419 if (nwritten) 1520 if (last_idx != ULONG_MAX)
1420 f2fs_submit_merged_bio_cond(sbi, NULL, NULL, ino, NODE, WRITE); 1521 f2fs_submit_merged_bio_cond(sbi, NULL, ino, last_idx,
1522 NODE, WRITE);
1421 return ret ? -EIO: 0; 1523 return ret ? -EIO: 0;
1422} 1524}
1423 1525
@@ -1445,6 +1547,7 @@ next_step:
1445 1547
1446 for (i = 0; i < nr_pages; i++) { 1548 for (i = 0; i < nr_pages; i++) {
1447 struct page *page = pvec.pages[i]; 1549 struct page *page = pvec.pages[i];
1550 bool submitted = false;
1448 1551
1449 if (unlikely(f2fs_cp_error(sbi))) { 1552 if (unlikely(f2fs_cp_error(sbi))) {
1450 pagevec_release(&pvec); 1553 pagevec_release(&pvec);
@@ -1498,9 +1601,10 @@ continue_unlock:
1498 set_fsync_mark(page, 0); 1601 set_fsync_mark(page, 0);
1499 set_dentry_mark(page, 0); 1602 set_dentry_mark(page, 0);
1500 1603
1501 if (NODE_MAPPING(sbi)->a_ops->writepage(page, wbc)) 1604 ret = __write_node_page(page, false, &submitted, wbc);
1605 if (ret)
1502 unlock_page(page); 1606 unlock_page(page);
1503 else 1607 else if (submitted)
1504 nwritten++; 1608 nwritten++;
1505 1609
1506 if (--wbc->nr_to_write == 0) 1610 if (--wbc->nr_to_write == 0)
@@ -1564,72 +1668,6 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
1564 return ret; 1668 return ret;
1565} 1669}
1566 1670
1567static int f2fs_write_node_page(struct page *page,
1568 struct writeback_control *wbc)
1569{
1570 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
1571 nid_t nid;
1572 struct node_info ni;
1573 struct f2fs_io_info fio = {
1574 .sbi = sbi,
1575 .type = NODE,
1576 .op = REQ_OP_WRITE,
1577 .op_flags = wbc_to_write_flags(wbc),
1578 .page = page,
1579 .encrypted_page = NULL,
1580 };
1581
1582 trace_f2fs_writepage(page, NODE);
1583
1584 if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
1585 goto redirty_out;
1586 if (unlikely(f2fs_cp_error(sbi)))
1587 goto redirty_out;
1588
1589 /* get old block addr of this node page */
1590 nid = nid_of_node(page);
1591 f2fs_bug_on(sbi, page->index != nid);
1592
1593 if (wbc->for_reclaim) {
1594 if (!down_read_trylock(&sbi->node_write))
1595 goto redirty_out;
1596 } else {
1597 down_read(&sbi->node_write);
1598 }
1599
1600 get_node_info(sbi, nid, &ni);
1601
1602 /* This page is already truncated */
1603 if (unlikely(ni.blk_addr == NULL_ADDR)) {
1604 ClearPageUptodate(page);
1605 dec_page_count(sbi, F2FS_DIRTY_NODES);
1606 up_read(&sbi->node_write);
1607 unlock_page(page);
1608 return 0;
1609 }
1610
1611 set_page_writeback(page);
1612 fio.old_blkaddr = ni.blk_addr;
1613 write_node_page(nid, &fio);
1614 set_node_addr(sbi, &ni, fio.new_blkaddr, is_fsync_dnode(page));
1615 dec_page_count(sbi, F2FS_DIRTY_NODES);
1616 up_read(&sbi->node_write);
1617
1618 if (wbc->for_reclaim)
1619 f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, NODE, WRITE);
1620
1621 unlock_page(page);
1622
1623 if (unlikely(f2fs_cp_error(sbi)))
1624 f2fs_submit_merged_bio(sbi, NODE, WRITE);
1625
1626 return 0;
1627
1628redirty_out:
1629 redirty_page_for_writepage(wbc, page);
1630 return AOP_WRITEPAGE_ACTIVATE;
1631}
1632
1633static int f2fs_write_node_pages(struct address_space *mapping, 1671static int f2fs_write_node_pages(struct address_space *mapping,
1634 struct writeback_control *wbc) 1672 struct writeback_control *wbc)
1635{ 1673{
@@ -1727,7 +1765,8 @@ static void __remove_nid_from_list(struct f2fs_sb_info *sbi,
1727 radix_tree_delete(&nm_i->free_nid_root, i->nid); 1765 radix_tree_delete(&nm_i->free_nid_root, i->nid);
1728} 1766}
1729 1767
1730static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build) 1768/* return if the nid is recognized as free */
1769static bool add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
1731{ 1770{
1732 struct f2fs_nm_info *nm_i = NM_I(sbi); 1771 struct f2fs_nm_info *nm_i = NM_I(sbi);
1733 struct free_nid *i; 1772 struct free_nid *i;
@@ -1736,14 +1775,14 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
1736 1775
1737 /* 0 nid should not be used */ 1776 /* 0 nid should not be used */
1738 if (unlikely(nid == 0)) 1777 if (unlikely(nid == 0))
1739 return 0; 1778 return false;
1740 1779
1741 if (build) { 1780 if (build) {
1742 /* do not add allocated nids */ 1781 /* do not add allocated nids */
1743 ne = __lookup_nat_cache(nm_i, nid); 1782 ne = __lookup_nat_cache(nm_i, nid);
1744 if (ne && (!get_nat_flag(ne, IS_CHECKPOINTED) || 1783 if (ne && (!get_nat_flag(ne, IS_CHECKPOINTED) ||
1745 nat_get_blkaddr(ne) != NULL_ADDR)) 1784 nat_get_blkaddr(ne) != NULL_ADDR))
1746 return 0; 1785 return false;
1747 } 1786 }
1748 1787
1749 i = f2fs_kmem_cache_alloc(free_nid_slab, GFP_NOFS); 1788 i = f2fs_kmem_cache_alloc(free_nid_slab, GFP_NOFS);
@@ -1752,7 +1791,7 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
1752 1791
1753 if (radix_tree_preload(GFP_NOFS)) { 1792 if (radix_tree_preload(GFP_NOFS)) {
1754 kmem_cache_free(free_nid_slab, i); 1793 kmem_cache_free(free_nid_slab, i);
1755 return 0; 1794 return true;
1756 } 1795 }
1757 1796
1758 spin_lock(&nm_i->nid_list_lock); 1797 spin_lock(&nm_i->nid_list_lock);
@@ -1761,9 +1800,9 @@ static int add_free_nid(struct f2fs_sb_info *sbi, nid_t nid, bool build)
1761 radix_tree_preload_end(); 1800 radix_tree_preload_end();
1762 if (err) { 1801 if (err) {
1763 kmem_cache_free(free_nid_slab, i); 1802 kmem_cache_free(free_nid_slab, i);
1764 return 0; 1803 return true;
1765 } 1804 }
1766 return 1; 1805 return true;
1767} 1806}
1768 1807
1769static void remove_free_nid(struct f2fs_sb_info *sbi, nid_t nid) 1808static void remove_free_nid(struct f2fs_sb_info *sbi, nid_t nid)
@@ -1784,17 +1823,36 @@ static void remove_free_nid(struct f2fs_sb_info *sbi, nid_t nid)
1784 kmem_cache_free(free_nid_slab, i); 1823 kmem_cache_free(free_nid_slab, i);
1785} 1824}
1786 1825
1826void update_free_nid_bitmap(struct f2fs_sb_info *sbi, nid_t nid, bool set)
1827{
1828 struct f2fs_nm_info *nm_i = NM_I(sbi);
1829 unsigned int nat_ofs = NAT_BLOCK_OFFSET(nid);
1830 unsigned int nid_ofs = nid - START_NID(nid);
1831
1832 if (!test_bit_le(nat_ofs, nm_i->nat_block_bitmap))
1833 return;
1834
1835 if (set)
1836 set_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs]);
1837 else
1838 clear_bit_le(nid_ofs, nm_i->free_nid_bitmap[nat_ofs]);
1839}
1840
1787static void scan_nat_page(struct f2fs_sb_info *sbi, 1841static void scan_nat_page(struct f2fs_sb_info *sbi,
1788 struct page *nat_page, nid_t start_nid) 1842 struct page *nat_page, nid_t start_nid)
1789{ 1843{
1790 struct f2fs_nm_info *nm_i = NM_I(sbi); 1844 struct f2fs_nm_info *nm_i = NM_I(sbi);
1791 struct f2fs_nat_block *nat_blk = page_address(nat_page); 1845 struct f2fs_nat_block *nat_blk = page_address(nat_page);
1792 block_t blk_addr; 1846 block_t blk_addr;
1847 unsigned int nat_ofs = NAT_BLOCK_OFFSET(start_nid);
1793 int i; 1848 int i;
1794 1849
1850 set_bit_le(nat_ofs, nm_i->nat_block_bitmap);
1851
1795 i = start_nid % NAT_ENTRY_PER_BLOCK; 1852 i = start_nid % NAT_ENTRY_PER_BLOCK;
1796 1853
1797 for (; i < NAT_ENTRY_PER_BLOCK; i++, start_nid++) { 1854 for (; i < NAT_ENTRY_PER_BLOCK; i++, start_nid++) {
1855 bool freed = false;
1798 1856
1799 if (unlikely(start_nid >= nm_i->max_nid)) 1857 if (unlikely(start_nid >= nm_i->max_nid))
1800 break; 1858 break;
@@ -1802,11 +1860,106 @@ static void scan_nat_page(struct f2fs_sb_info *sbi,
1802 blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr); 1860 blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr);
1803 f2fs_bug_on(sbi, blk_addr == NEW_ADDR); 1861 f2fs_bug_on(sbi, blk_addr == NEW_ADDR);
1804 if (blk_addr == NULL_ADDR) 1862 if (blk_addr == NULL_ADDR)
1805 add_free_nid(sbi, start_nid, true); 1863 freed = add_free_nid(sbi, start_nid, true);
1864 update_free_nid_bitmap(sbi, start_nid, freed);
1865 }
1866}
1867
1868static void scan_free_nid_bits(struct f2fs_sb_info *sbi)
1869{
1870 struct f2fs_nm_info *nm_i = NM_I(sbi);
1871 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
1872 struct f2fs_journal *journal = curseg->journal;
1873 unsigned int i, idx;
1874
1875 down_read(&nm_i->nat_tree_lock);
1876
1877 for (i = 0; i < nm_i->nat_blocks; i++) {
1878 if (!test_bit_le(i, nm_i->nat_block_bitmap))
1879 continue;
1880 for (idx = 0; idx < NAT_ENTRY_PER_BLOCK; idx++) {
1881 nid_t nid;
1882
1883 if (!test_bit_le(idx, nm_i->free_nid_bitmap[i]))
1884 continue;
1885
1886 nid = i * NAT_ENTRY_PER_BLOCK + idx;
1887 add_free_nid(sbi, nid, true);
1888
1889 if (nm_i->nid_cnt[FREE_NID_LIST] >= MAX_FREE_NIDS)
1890 goto out;
1891 }
1892 }
1893out:
1894 down_read(&curseg->journal_rwsem);
1895 for (i = 0; i < nats_in_cursum(journal); i++) {
1896 block_t addr;
1897 nid_t nid;
1898
1899 addr = le32_to_cpu(nat_in_journal(journal, i).block_addr);
1900 nid = le32_to_cpu(nid_in_journal(journal, i));
1901 if (addr == NULL_ADDR)
1902 add_free_nid(sbi, nid, true);
1903 else
1904 remove_free_nid(sbi, nid);
1806 } 1905 }
1906 up_read(&curseg->journal_rwsem);
1907 up_read(&nm_i->nat_tree_lock);
1807} 1908}
1808 1909
1809static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync) 1910static int scan_nat_bits(struct f2fs_sb_info *sbi)
1911{
1912 struct f2fs_nm_info *nm_i = NM_I(sbi);
1913 struct page *page;
1914 unsigned int i = 0;
1915 nid_t nid;
1916
1917 if (!enabled_nat_bits(sbi, NULL))
1918 return -EAGAIN;
1919
1920 down_read(&nm_i->nat_tree_lock);
1921check_empty:
1922 i = find_next_bit_le(nm_i->empty_nat_bits, nm_i->nat_blocks, i);
1923 if (i >= nm_i->nat_blocks) {
1924 i = 0;
1925 goto check_partial;
1926 }
1927
1928 for (nid = i * NAT_ENTRY_PER_BLOCK; nid < (i + 1) * NAT_ENTRY_PER_BLOCK;
1929 nid++) {
1930 if (unlikely(nid >= nm_i->max_nid))
1931 break;
1932 add_free_nid(sbi, nid, true);
1933 }
1934
1935 if (nm_i->nid_cnt[FREE_NID_LIST] >= MAX_FREE_NIDS)
1936 goto out;
1937 i++;
1938 goto check_empty;
1939
1940check_partial:
1941 i = find_next_zero_bit_le(nm_i->full_nat_bits, nm_i->nat_blocks, i);
1942 if (i >= nm_i->nat_blocks) {
1943 disable_nat_bits(sbi, true);
1944 up_read(&nm_i->nat_tree_lock);
1945 return -EINVAL;
1946 }
1947
1948 nid = i * NAT_ENTRY_PER_BLOCK;
1949 page = get_current_nat_page(sbi, nid);
1950 scan_nat_page(sbi, page, nid);
1951 f2fs_put_page(page, 1);
1952
1953 if (nm_i->nid_cnt[FREE_NID_LIST] < MAX_FREE_NIDS) {
1954 i++;
1955 goto check_partial;
1956 }
1957out:
1958 up_read(&nm_i->nat_tree_lock);
1959 return 0;
1960}
1961
1962static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
1810{ 1963{
1811 struct f2fs_nm_info *nm_i = NM_I(sbi); 1964 struct f2fs_nm_info *nm_i = NM_I(sbi);
1812 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); 1965 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
@@ -1821,6 +1974,29 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync)
1821 if (!sync && !available_free_memory(sbi, FREE_NIDS)) 1974 if (!sync && !available_free_memory(sbi, FREE_NIDS))
1822 return; 1975 return;
1823 1976
1977 if (!mount) {
1978 /* try to find free nids in free_nid_bitmap */
1979 scan_free_nid_bits(sbi);
1980
1981 if (nm_i->nid_cnt[FREE_NID_LIST])
1982 return;
1983
1984 /* try to find free nids with nat_bits */
1985 if (!scan_nat_bits(sbi) && nm_i->nid_cnt[FREE_NID_LIST])
1986 return;
1987 }
1988
1989 /* find next valid candidate */
1990 if (enabled_nat_bits(sbi, NULL)) {
1991 int idx = find_next_zero_bit_le(nm_i->full_nat_bits,
1992 nm_i->nat_blocks, 0);
1993
1994 if (idx >= nm_i->nat_blocks)
1995 set_sbi_flag(sbi, SBI_NEED_FSCK);
1996 else
1997 nid = idx * NAT_ENTRY_PER_BLOCK;
1998 }
1999
1824 /* readahead nat pages to be scanned */ 2000 /* readahead nat pages to be scanned */
1825 ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES, 2001 ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES,
1826 META_NAT, true); 2002 META_NAT, true);
@@ -1863,10 +2039,10 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync)
1863 nm_i->ra_nid_pages, META_NAT, false); 2039 nm_i->ra_nid_pages, META_NAT, false);
1864} 2040}
1865 2041
1866void build_free_nids(struct f2fs_sb_info *sbi, bool sync) 2042void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
1867{ 2043{
1868 mutex_lock(&NM_I(sbi)->build_lock); 2044 mutex_lock(&NM_I(sbi)->build_lock);
1869 __build_free_nids(sbi, sync); 2045 __build_free_nids(sbi, sync, mount);
1870 mutex_unlock(&NM_I(sbi)->build_lock); 2046 mutex_unlock(&NM_I(sbi)->build_lock);
1871} 2047}
1872 2048
@@ -1881,8 +2057,10 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
1881 struct free_nid *i = NULL; 2057 struct free_nid *i = NULL;
1882retry: 2058retry:
1883#ifdef CONFIG_F2FS_FAULT_INJECTION 2059#ifdef CONFIG_F2FS_FAULT_INJECTION
1884 if (time_to_inject(sbi, FAULT_ALLOC_NID)) 2060 if (time_to_inject(sbi, FAULT_ALLOC_NID)) {
2061 f2fs_show_injection_info(FAULT_ALLOC_NID);
1885 return false; 2062 return false;
2063 }
1886#endif 2064#endif
1887 spin_lock(&nm_i->nid_list_lock); 2065 spin_lock(&nm_i->nid_list_lock);
1888 2066
@@ -1902,13 +2080,16 @@ retry:
1902 i->state = NID_ALLOC; 2080 i->state = NID_ALLOC;
1903 __insert_nid_to_list(sbi, i, ALLOC_NID_LIST, false); 2081 __insert_nid_to_list(sbi, i, ALLOC_NID_LIST, false);
1904 nm_i->available_nids--; 2082 nm_i->available_nids--;
2083
2084 update_free_nid_bitmap(sbi, *nid, false);
2085
1905 spin_unlock(&nm_i->nid_list_lock); 2086 spin_unlock(&nm_i->nid_list_lock);
1906 return true; 2087 return true;
1907 } 2088 }
1908 spin_unlock(&nm_i->nid_list_lock); 2089 spin_unlock(&nm_i->nid_list_lock);
1909 2090
1910 /* Let's scan nat pages and its caches to get free nids */ 2091 /* Let's scan nat pages and its caches to get free nids */
1911 build_free_nids(sbi, true); 2092 build_free_nids(sbi, true, false);
1912 goto retry; 2093 goto retry;
1913} 2094}
1914 2095
@@ -1956,6 +2137,8 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
1956 2137
1957 nm_i->available_nids++; 2138 nm_i->available_nids++;
1958 2139
2140 update_free_nid_bitmap(sbi, nid, true);
2141
1959 spin_unlock(&nm_i->nid_list_lock); 2142 spin_unlock(&nm_i->nid_list_lock);
1960 2143
1961 if (need_free) 2144 if (need_free)
@@ -2018,18 +2201,18 @@ update_inode:
2018 f2fs_put_page(ipage, 1); 2201 f2fs_put_page(ipage, 1);
2019} 2202}
2020 2203
2021void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) 2204int recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr)
2022{ 2205{
2023 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 2206 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
2024 nid_t prev_xnid = F2FS_I(inode)->i_xattr_nid; 2207 nid_t prev_xnid = F2FS_I(inode)->i_xattr_nid;
2025 nid_t new_xnid = nid_of_node(page); 2208 nid_t new_xnid = nid_of_node(page);
2026 struct node_info ni; 2209 struct node_info ni;
2210 struct page *xpage;
2027 2211
2028 /* 1: invalidate the previous xattr nid */
2029 if (!prev_xnid) 2212 if (!prev_xnid)
2030 goto recover_xnid; 2213 goto recover_xnid;
2031 2214
2032 /* Deallocate node address */ 2215 /* 1: invalidate the previous xattr nid */
2033 get_node_info(sbi, prev_xnid, &ni); 2216 get_node_info(sbi, prev_xnid, &ni);
2034 f2fs_bug_on(sbi, ni.blk_addr == NULL_ADDR); 2217 f2fs_bug_on(sbi, ni.blk_addr == NULL_ADDR);
2035 invalidate_blocks(sbi, ni.blk_addr); 2218 invalidate_blocks(sbi, ni.blk_addr);
@@ -2037,19 +2220,27 @@ void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr)
2037 set_node_addr(sbi, &ni, NULL_ADDR, false); 2220 set_node_addr(sbi, &ni, NULL_ADDR, false);
2038 2221
2039recover_xnid: 2222recover_xnid:
2040 /* 2: allocate new xattr nid */ 2223 /* 2: update xattr nid in inode */
2224 remove_free_nid(sbi, new_xnid);
2225 f2fs_i_xnid_write(inode, new_xnid);
2041 if (unlikely(!inc_valid_node_count(sbi, inode))) 2226 if (unlikely(!inc_valid_node_count(sbi, inode)))
2042 f2fs_bug_on(sbi, 1); 2227 f2fs_bug_on(sbi, 1);
2228 update_inode_page(inode);
2229
2230 /* 3: update and set xattr node page dirty */
2231 xpage = grab_cache_page(NODE_MAPPING(sbi), new_xnid);
2232 if (!xpage)
2233 return -ENOMEM;
2234
2235 memcpy(F2FS_NODE(xpage), F2FS_NODE(page), PAGE_SIZE);
2043 2236
2044 remove_free_nid(sbi, new_xnid);
2045 get_node_info(sbi, new_xnid, &ni); 2237 get_node_info(sbi, new_xnid, &ni);
2046 ni.ino = inode->i_ino; 2238 ni.ino = inode->i_ino;
2047 set_node_addr(sbi, &ni, NEW_ADDR, false); 2239 set_node_addr(sbi, &ni, NEW_ADDR, false);
2048 f2fs_i_xnid_write(inode, new_xnid); 2240 set_page_dirty(xpage);
2241 f2fs_put_page(xpage, 1);
2049 2242
2050 /* 3: update xattr blkaddr */ 2243 return 0;
2051 refresh_sit_entry(sbi, NEW_ADDR, blkaddr);
2052 set_node_addr(sbi, &ni, blkaddr, false);
2053} 2244}
2054 2245
2055int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) 2246int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
@@ -2152,7 +2343,7 @@ static void remove_nats_in_journal(struct f2fs_sb_info *sbi)
2152 2343
2153 ne = __lookup_nat_cache(nm_i, nid); 2344 ne = __lookup_nat_cache(nm_i, nid);
2154 if (!ne) { 2345 if (!ne) {
2155 ne = grab_nat_entry(nm_i, nid); 2346 ne = grab_nat_entry(nm_i, nid, true);
2156 node_info_from_raw_nat(&ne->ni, &raw_ne); 2347 node_info_from_raw_nat(&ne->ni, &raw_ne);
2157 } 2348 }
2158 2349
@@ -2192,8 +2383,39 @@ add_out:
2192 list_add_tail(&nes->set_list, head); 2383 list_add_tail(&nes->set_list, head);
2193} 2384}
2194 2385
2386void __update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid,
2387 struct page *page)
2388{
2389 struct f2fs_nm_info *nm_i = NM_I(sbi);
2390 unsigned int nat_index = start_nid / NAT_ENTRY_PER_BLOCK;
2391 struct f2fs_nat_block *nat_blk = page_address(page);
2392 int valid = 0;
2393 int i;
2394
2395 if (!enabled_nat_bits(sbi, NULL))
2396 return;
2397
2398 for (i = 0; i < NAT_ENTRY_PER_BLOCK; i++) {
2399 if (start_nid == 0 && i == 0)
2400 valid++;
2401 if (nat_blk->entries[i].block_addr)
2402 valid++;
2403 }
2404 if (valid == 0) {
2405 set_bit_le(nat_index, nm_i->empty_nat_bits);
2406 clear_bit_le(nat_index, nm_i->full_nat_bits);
2407 return;
2408 }
2409
2410 clear_bit_le(nat_index, nm_i->empty_nat_bits);
2411 if (valid == NAT_ENTRY_PER_BLOCK)
2412 set_bit_le(nat_index, nm_i->full_nat_bits);
2413 else
2414 clear_bit_le(nat_index, nm_i->full_nat_bits);
2415}
2416
2195static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, 2417static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
2196 struct nat_entry_set *set) 2418 struct nat_entry_set *set, struct cp_control *cpc)
2197{ 2419{
2198 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); 2420 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
2199 struct f2fs_journal *journal = curseg->journal; 2421 struct f2fs_journal *journal = curseg->journal;
@@ -2208,7 +2430,8 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
2208 * #1, flush nat entries to journal in current hot data summary block. 2430 * #1, flush nat entries to journal in current hot data summary block.
2209 * #2, flush nat entries to nat page. 2431 * #2, flush nat entries to nat page.
2210 */ 2432 */
2211 if (!__has_cursum_space(journal, set->entry_cnt, NAT_JOURNAL)) 2433 if (enabled_nat_bits(sbi, cpc) ||
2434 !__has_cursum_space(journal, set->entry_cnt, NAT_JOURNAL))
2212 to_journal = false; 2435 to_journal = false;
2213 2436
2214 if (to_journal) { 2437 if (to_journal) {
@@ -2244,14 +2467,21 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
2244 add_free_nid(sbi, nid, false); 2467 add_free_nid(sbi, nid, false);
2245 spin_lock(&NM_I(sbi)->nid_list_lock); 2468 spin_lock(&NM_I(sbi)->nid_list_lock);
2246 NM_I(sbi)->available_nids++; 2469 NM_I(sbi)->available_nids++;
2470 update_free_nid_bitmap(sbi, nid, true);
2471 spin_unlock(&NM_I(sbi)->nid_list_lock);
2472 } else {
2473 spin_lock(&NM_I(sbi)->nid_list_lock);
2474 update_free_nid_bitmap(sbi, nid, false);
2247 spin_unlock(&NM_I(sbi)->nid_list_lock); 2475 spin_unlock(&NM_I(sbi)->nid_list_lock);
2248 } 2476 }
2249 } 2477 }
2250 2478
2251 if (to_journal) 2479 if (to_journal) {
2252 up_write(&curseg->journal_rwsem); 2480 up_write(&curseg->journal_rwsem);
2253 else 2481 } else {
2482 __update_nat_bits(sbi, start_nid, page);
2254 f2fs_put_page(page, 1); 2483 f2fs_put_page(page, 1);
2484 }
2255 2485
2256 f2fs_bug_on(sbi, set->entry_cnt); 2486 f2fs_bug_on(sbi, set->entry_cnt);
2257 2487
@@ -2262,7 +2492,7 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
2262/* 2492/*
2263 * This function is called during the checkpointing process. 2493 * This function is called during the checkpointing process.
2264 */ 2494 */
2265void flush_nat_entries(struct f2fs_sb_info *sbi) 2495void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
2266{ 2496{
2267 struct f2fs_nm_info *nm_i = NM_I(sbi); 2497 struct f2fs_nm_info *nm_i = NM_I(sbi);
2268 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); 2498 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
@@ -2283,7 +2513,8 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
2283 * entries, remove all entries from journal and merge them 2513 * entries, remove all entries from journal and merge them
2284 * into nat entry set. 2514 * into nat entry set.
2285 */ 2515 */
2286 if (!__has_cursum_space(journal, nm_i->dirty_nat_cnt, NAT_JOURNAL)) 2516 if (enabled_nat_bits(sbi, cpc) ||
2517 !__has_cursum_space(journal, nm_i->dirty_nat_cnt, NAT_JOURNAL))
2287 remove_nats_in_journal(sbi); 2518 remove_nats_in_journal(sbi);
2288 2519
2289 while ((found = __gang_lookup_nat_set(nm_i, 2520 while ((found = __gang_lookup_nat_set(nm_i,
@@ -2297,27 +2528,69 @@ void flush_nat_entries(struct f2fs_sb_info *sbi)
2297 2528
2298 /* flush dirty nats in nat entry set */ 2529 /* flush dirty nats in nat entry set */
2299 list_for_each_entry_safe(set, tmp, &sets, set_list) 2530 list_for_each_entry_safe(set, tmp, &sets, set_list)
2300 __flush_nat_entry_set(sbi, set); 2531 __flush_nat_entry_set(sbi, set, cpc);
2301 2532
2302 up_write(&nm_i->nat_tree_lock); 2533 up_write(&nm_i->nat_tree_lock);
2303 2534
2304 f2fs_bug_on(sbi, nm_i->dirty_nat_cnt); 2535 f2fs_bug_on(sbi, nm_i->dirty_nat_cnt);
2305} 2536}
2306 2537
2538static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
2539{
2540 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
2541 struct f2fs_nm_info *nm_i = NM_I(sbi);
2542 unsigned int nat_bits_bytes = nm_i->nat_blocks / BITS_PER_BYTE;
2543 unsigned int i;
2544 __u64 cp_ver = cur_cp_version(ckpt);
2545 block_t nat_bits_addr;
2546
2547 if (!enabled_nat_bits(sbi, NULL))
2548 return 0;
2549
2550 nm_i->nat_bits_blocks = F2FS_BYTES_TO_BLK((nat_bits_bytes << 1) + 8 +
2551 F2FS_BLKSIZE - 1);
2552 nm_i->nat_bits = kzalloc(nm_i->nat_bits_blocks << F2FS_BLKSIZE_BITS,
2553 GFP_KERNEL);
2554 if (!nm_i->nat_bits)
2555 return -ENOMEM;
2556
2557 nat_bits_addr = __start_cp_addr(sbi) + sbi->blocks_per_seg -
2558 nm_i->nat_bits_blocks;
2559 for (i = 0; i < nm_i->nat_bits_blocks; i++) {
2560 struct page *page = get_meta_page(sbi, nat_bits_addr++);
2561
2562 memcpy(nm_i->nat_bits + (i << F2FS_BLKSIZE_BITS),
2563 page_address(page), F2FS_BLKSIZE);
2564 f2fs_put_page(page, 1);
2565 }
2566
2567 cp_ver |= (cur_cp_crc(ckpt) << 32);
2568 if (cpu_to_le64(cp_ver) != *(__le64 *)nm_i->nat_bits) {
2569 disable_nat_bits(sbi, true);
2570 return 0;
2571 }
2572
2573 nm_i->full_nat_bits = nm_i->nat_bits + 8;
2574 nm_i->empty_nat_bits = nm_i->full_nat_bits + nat_bits_bytes;
2575
2576 f2fs_msg(sbi->sb, KERN_NOTICE, "Found nat_bits in checkpoint");
2577 return 0;
2578}
2579
2307static int init_node_manager(struct f2fs_sb_info *sbi) 2580static int init_node_manager(struct f2fs_sb_info *sbi)
2308{ 2581{
2309 struct f2fs_super_block *sb_raw = F2FS_RAW_SUPER(sbi); 2582 struct f2fs_super_block *sb_raw = F2FS_RAW_SUPER(sbi);
2310 struct f2fs_nm_info *nm_i = NM_I(sbi); 2583 struct f2fs_nm_info *nm_i = NM_I(sbi);
2311 unsigned char *version_bitmap; 2584 unsigned char *version_bitmap;
2312 unsigned int nat_segs, nat_blocks; 2585 unsigned int nat_segs;
2586 int err;
2313 2587
2314 nm_i->nat_blkaddr = le32_to_cpu(sb_raw->nat_blkaddr); 2588 nm_i->nat_blkaddr = le32_to_cpu(sb_raw->nat_blkaddr);
2315 2589
2316 /* segment_count_nat includes pair segment so divide to 2. */ 2590 /* segment_count_nat includes pair segment so divide to 2. */
2317 nat_segs = le32_to_cpu(sb_raw->segment_count_nat) >> 1; 2591 nat_segs = le32_to_cpu(sb_raw->segment_count_nat) >> 1;
2318 nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg); 2592 nm_i->nat_blocks = nat_segs << le32_to_cpu(sb_raw->log_blocks_per_seg);
2319 2593 nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nm_i->nat_blocks;
2320 nm_i->max_nid = NAT_ENTRY_PER_BLOCK * nat_blocks;
2321 2594
2322 /* not used nids: 0, node, meta, (and root counted as valid node) */ 2595 /* not used nids: 0, node, meta, (and root counted as valid node) */
2323 nm_i->available_nids = nm_i->max_nid - sbi->total_valid_node_count - 2596 nm_i->available_nids = nm_i->max_nid - sbi->total_valid_node_count -
@@ -2350,6 +2623,34 @@ static int init_node_manager(struct f2fs_sb_info *sbi)
2350 GFP_KERNEL); 2623 GFP_KERNEL);
2351 if (!nm_i->nat_bitmap) 2624 if (!nm_i->nat_bitmap)
2352 return -ENOMEM; 2625 return -ENOMEM;
2626
2627 err = __get_nat_bitmaps(sbi);
2628 if (err)
2629 return err;
2630
2631#ifdef CONFIG_F2FS_CHECK_FS
2632 nm_i->nat_bitmap_mir = kmemdup(version_bitmap, nm_i->bitmap_size,
2633 GFP_KERNEL);
2634 if (!nm_i->nat_bitmap_mir)
2635 return -ENOMEM;
2636#endif
2637
2638 return 0;
2639}
2640
2641int init_free_nid_cache(struct f2fs_sb_info *sbi)
2642{
2643 struct f2fs_nm_info *nm_i = NM_I(sbi);
2644
2645 nm_i->free_nid_bitmap = f2fs_kvzalloc(nm_i->nat_blocks *
2646 NAT_ENTRY_BITMAP_SIZE, GFP_KERNEL);
2647 if (!nm_i->free_nid_bitmap)
2648 return -ENOMEM;
2649
2650 nm_i->nat_block_bitmap = f2fs_kvzalloc(nm_i->nat_blocks / 8,
2651 GFP_KERNEL);
2652 if (!nm_i->nat_block_bitmap)
2653 return -ENOMEM;
2353 return 0; 2654 return 0;
2354} 2655}
2355 2656
@@ -2365,7 +2666,11 @@ int build_node_manager(struct f2fs_sb_info *sbi)
2365 if (err) 2666 if (err)
2366 return err; 2667 return err;
2367 2668
2368 build_free_nids(sbi, true); 2669 err = init_free_nid_cache(sbi);
2670 if (err)
2671 return err;
2672
2673 build_free_nids(sbi, true, true);
2369 return 0; 2674 return 0;
2370} 2675}
2371 2676
@@ -2423,7 +2728,14 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
2423 } 2728 }
2424 up_write(&nm_i->nat_tree_lock); 2729 up_write(&nm_i->nat_tree_lock);
2425 2730
2731 kvfree(nm_i->nat_block_bitmap);
2732 kvfree(nm_i->free_nid_bitmap);
2733
2426 kfree(nm_i->nat_bitmap); 2734 kfree(nm_i->nat_bitmap);
2735 kfree(nm_i->nat_bits);
2736#ifdef CONFIG_F2FS_CHECK_FS
2737 kfree(nm_i->nat_bitmap_mir);
2738#endif
2427 sbi->nm_info = NULL; 2739 sbi->nm_info = NULL;
2428 kfree(nm_i); 2740 kfree(nm_i);
2429} 2741}
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index e7997e240366..2f9603fa85a5 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -174,7 +174,7 @@ static inline void next_free_nid(struct f2fs_sb_info *sbi, nid_t *nid)
174 spin_unlock(&nm_i->nid_list_lock); 174 spin_unlock(&nm_i->nid_list_lock);
175 return; 175 return;
176 } 176 }
177 fnid = list_entry(nm_i->nid_list[FREE_NID_LIST].next, 177 fnid = list_first_entry(&nm_i->nid_list[FREE_NID_LIST],
178 struct free_nid, list); 178 struct free_nid, list);
179 *nid = fnid->nid; 179 *nid = fnid->nid;
180 spin_unlock(&nm_i->nid_list_lock); 180 spin_unlock(&nm_i->nid_list_lock);
@@ -186,6 +186,12 @@ static inline void next_free_nid(struct f2fs_sb_info *sbi, nid_t *nid)
186static inline void get_nat_bitmap(struct f2fs_sb_info *sbi, void *addr) 186static inline void get_nat_bitmap(struct f2fs_sb_info *sbi, void *addr)
187{ 187{
188 struct f2fs_nm_info *nm_i = NM_I(sbi); 188 struct f2fs_nm_info *nm_i = NM_I(sbi);
189
190#ifdef CONFIG_F2FS_CHECK_FS
191 if (memcmp(nm_i->nat_bitmap, nm_i->nat_bitmap_mir,
192 nm_i->bitmap_size))
193 f2fs_bug_on(sbi, 1);
194#endif
189 memcpy(addr, nm_i->nat_bitmap, nm_i->bitmap_size); 195 memcpy(addr, nm_i->nat_bitmap, nm_i->bitmap_size);
190} 196}
191 197
@@ -228,6 +234,9 @@ static inline void set_to_next_nat(struct f2fs_nm_info *nm_i, nid_t start_nid)
228 unsigned int block_off = NAT_BLOCK_OFFSET(start_nid); 234 unsigned int block_off = NAT_BLOCK_OFFSET(start_nid);
229 235
230 f2fs_change_bit(block_off, nm_i->nat_bitmap); 236 f2fs_change_bit(block_off, nm_i->nat_bitmap);
237#ifdef CONFIG_F2FS_CHECK_FS
238 f2fs_change_bit(block_off, nm_i->nat_bitmap_mir);
239#endif
231} 240}
232 241
233static inline nid_t ino_of_node(struct page *node_page) 242static inline nid_t ino_of_node(struct page *node_page)
@@ -291,14 +300,11 @@ static inline void fill_node_footer_blkaddr(struct page *page, block_t blkaddr)
291{ 300{
292 struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page)); 301 struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
293 struct f2fs_node *rn = F2FS_NODE(page); 302 struct f2fs_node *rn = F2FS_NODE(page);
294 size_t crc_offset = le32_to_cpu(ckpt->checksum_offset); 303 __u64 cp_ver = cur_cp_version(ckpt);
295 __u64 cp_ver = le64_to_cpu(ckpt->checkpoint_ver); 304
305 if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
306 cp_ver |= (cur_cp_crc(ckpt) << 32);
296 307
297 if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG)) {
298 __u64 crc = le32_to_cpu(*((__le32 *)
299 ((unsigned char *)ckpt + crc_offset)));
300 cp_ver |= (crc << 32);
301 }
302 rn->footer.cp_ver = cpu_to_le64(cp_ver); 308 rn->footer.cp_ver = cpu_to_le64(cp_ver);
303 rn->footer.next_blkaddr = cpu_to_le32(blkaddr); 309 rn->footer.next_blkaddr = cpu_to_le32(blkaddr);
304} 310}
@@ -306,14 +312,11 @@ static inline void fill_node_footer_blkaddr(struct page *page, block_t blkaddr)
306static inline bool is_recoverable_dnode(struct page *page) 312static inline bool is_recoverable_dnode(struct page *page)
307{ 313{
308 struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page)); 314 struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
309 size_t crc_offset = le32_to_cpu(ckpt->checksum_offset);
310 __u64 cp_ver = cur_cp_version(ckpt); 315 __u64 cp_ver = cur_cp_version(ckpt);
311 316
312 if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG)) { 317 if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
313 __u64 crc = le32_to_cpu(*((__le32 *) 318 cp_ver |= (cur_cp_crc(ckpt) << 32);
314 ((unsigned char *)ckpt + crc_offset))); 319
315 cp_ver |= (crc << 32);
316 }
317 return cp_ver == cpver_of_node(page); 320 return cp_ver == cpver_of_node(page);
318} 321}
319 322
@@ -343,7 +346,7 @@ static inline bool IS_DNODE(struct page *node_page)
343 unsigned int ofs = ofs_of_node(node_page); 346 unsigned int ofs = ofs_of_node(node_page);
344 347
345 if (f2fs_has_xattr_block(ofs)) 348 if (f2fs_has_xattr_block(ofs))
346 return false; 349 return true;
347 350
348 if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK || 351 if (ofs == 3 || ofs == 4 + NIDS_PER_BLOCK ||
349 ofs == 5 + 2 * NIDS_PER_BLOCK) 352 ofs == 5 + 2 * NIDS_PER_BLOCK)
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 981a9584b62f..d025aa83fb5b 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -378,11 +378,9 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
378 if (IS_INODE(page)) { 378 if (IS_INODE(page)) {
379 recover_inline_xattr(inode, page); 379 recover_inline_xattr(inode, page);
380 } else if (f2fs_has_xattr_block(ofs_of_node(page))) { 380 } else if (f2fs_has_xattr_block(ofs_of_node(page))) {
381 /* 381 err = recover_xattr_data(inode, page, blkaddr);
382 * Deprecated; xattr blocks should be found from cold log. 382 if (!err)
383 * But, we should remain this for backward compatibility. 383 recovered++;
384 */
385 recover_xattr_data(inode, page, blkaddr);
386 goto out; 384 goto out;
387 } 385 }
388 386
@@ -428,8 +426,9 @@ retry_dn:
428 } 426 }
429 427
430 if (!file_keep_isize(inode) && 428 if (!file_keep_isize(inode) &&
431 (i_size_read(inode) <= (start << PAGE_SHIFT))) 429 (i_size_read(inode) <= ((loff_t)start << PAGE_SHIFT)))
432 f2fs_i_size_write(inode, (start + 1) << PAGE_SHIFT); 430 f2fs_i_size_write(inode,
431 (loff_t)(start + 1) << PAGE_SHIFT);
433 432
434 /* 433 /*
435 * dest is reserved block, invalidate src block 434 * dest is reserved block, invalidate src block
@@ -552,10 +551,8 @@ next:
552 551
553int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) 552int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
554{ 553{
555 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_WARM_NODE);
556 struct list_head inode_list; 554 struct list_head inode_list;
557 struct list_head dir_list; 555 struct list_head dir_list;
558 block_t blkaddr;
559 int err; 556 int err;
560 int ret = 0; 557 int ret = 0;
561 bool need_writecp = false; 558 bool need_writecp = false;
@@ -571,8 +568,6 @@ int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
571 /* prevent checkpoint */ 568 /* prevent checkpoint */
572 mutex_lock(&sbi->cp_mutex); 569 mutex_lock(&sbi->cp_mutex);
573 570
574 blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
575
576 /* step #1: find fsynced inode numbers */ 571 /* step #1: find fsynced inode numbers */
577 err = find_fsync_dnodes(sbi, &inode_list); 572 err = find_fsync_dnodes(sbi, &inode_list);
578 if (err || list_empty(&inode_list)) 573 if (err || list_empty(&inode_list))
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0d8802453758..4bd7a8b19332 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -26,7 +26,7 @@
26#define __reverse_ffz(x) __reverse_ffs(~(x)) 26#define __reverse_ffz(x) __reverse_ffs(~(x))
27 27
28static struct kmem_cache *discard_entry_slab; 28static struct kmem_cache *discard_entry_slab;
29static struct kmem_cache *bio_entry_slab; 29static struct kmem_cache *discard_cmd_slab;
30static struct kmem_cache *sit_entry_set_slab; 30static struct kmem_cache *sit_entry_set_slab;
31static struct kmem_cache *inmem_entry_slab; 31static struct kmem_cache *inmem_entry_slab;
32 32
@@ -242,11 +242,12 @@ void drop_inmem_pages(struct inode *inode)
242{ 242{
243 struct f2fs_inode_info *fi = F2FS_I(inode); 243 struct f2fs_inode_info *fi = F2FS_I(inode);
244 244
245 clear_inode_flag(inode, FI_ATOMIC_FILE);
246
247 mutex_lock(&fi->inmem_lock); 245 mutex_lock(&fi->inmem_lock);
248 __revoke_inmem_pages(inode, &fi->inmem_pages, true, false); 246 __revoke_inmem_pages(inode, &fi->inmem_pages, true, false);
249 mutex_unlock(&fi->inmem_lock); 247 mutex_unlock(&fi->inmem_lock);
248
249 clear_inode_flag(inode, FI_ATOMIC_FILE);
250 stat_dec_atomic_write(inode);
250} 251}
251 252
252static int __commit_inmem_pages(struct inode *inode, 253static int __commit_inmem_pages(struct inode *inode,
@@ -262,7 +263,7 @@ static int __commit_inmem_pages(struct inode *inode,
262 .op_flags = REQ_SYNC | REQ_PRIO, 263 .op_flags = REQ_SYNC | REQ_PRIO,
263 .encrypted_page = NULL, 264 .encrypted_page = NULL,
264 }; 265 };
265 bool submit_bio = false; 266 pgoff_t last_idx = ULONG_MAX;
266 int err = 0; 267 int err = 0;
267 268
268 list_for_each_entry_safe(cur, tmp, &fi->inmem_pages, list) { 269 list_for_each_entry_safe(cur, tmp, &fi->inmem_pages, list) {
@@ -288,15 +289,15 @@ static int __commit_inmem_pages(struct inode *inode,
288 289
289 /* record old blkaddr for revoking */ 290 /* record old blkaddr for revoking */
290 cur->old_addr = fio.old_blkaddr; 291 cur->old_addr = fio.old_blkaddr;
291 292 last_idx = page->index;
292 submit_bio = true;
293 } 293 }
294 unlock_page(page); 294 unlock_page(page);
295 list_move_tail(&cur->list, revoke_list); 295 list_move_tail(&cur->list, revoke_list);
296 } 296 }
297 297
298 if (submit_bio) 298 if (last_idx != ULONG_MAX)
299 f2fs_submit_merged_bio_cond(sbi, inode, NULL, 0, DATA, WRITE); 299 f2fs_submit_merged_bio_cond(sbi, inode, 0, last_idx,
300 DATA, WRITE);
300 301
301 if (!err) 302 if (!err)
302 __revoke_inmem_pages(inode, revoke_list, false, false); 303 __revoke_inmem_pages(inode, revoke_list, false, false);
@@ -315,6 +316,8 @@ int commit_inmem_pages(struct inode *inode)
315 f2fs_balance_fs(sbi, true); 316 f2fs_balance_fs(sbi, true);
316 f2fs_lock_op(sbi); 317 f2fs_lock_op(sbi);
317 318
319 set_inode_flag(inode, FI_ATOMIC_COMMIT);
320
318 mutex_lock(&fi->inmem_lock); 321 mutex_lock(&fi->inmem_lock);
319 err = __commit_inmem_pages(inode, &revoke_list); 322 err = __commit_inmem_pages(inode, &revoke_list);
320 if (err) { 323 if (err) {
@@ -336,6 +339,8 @@ int commit_inmem_pages(struct inode *inode)
336 } 339 }
337 mutex_unlock(&fi->inmem_lock); 340 mutex_unlock(&fi->inmem_lock);
338 341
342 clear_inode_flag(inode, FI_ATOMIC_COMMIT);
343
339 f2fs_unlock_op(sbi); 344 f2fs_unlock_op(sbi);
340 return err; 345 return err;
341} 346}
@@ -347,8 +352,10 @@ int commit_inmem_pages(struct inode *inode)
347void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) 352void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
348{ 353{
349#ifdef CONFIG_F2FS_FAULT_INJECTION 354#ifdef CONFIG_F2FS_FAULT_INJECTION
350 if (time_to_inject(sbi, FAULT_CHECKPOINT)) 355 if (time_to_inject(sbi, FAULT_CHECKPOINT)) {
356 f2fs_show_injection_info(FAULT_CHECKPOINT);
351 f2fs_stop_checkpoint(sbi, false); 357 f2fs_stop_checkpoint(sbi, false);
358 }
352#endif 359#endif
353 360
354 if (!need) 361 if (!need)
@@ -381,7 +388,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
381 if (!available_free_memory(sbi, FREE_NIDS)) 388 if (!available_free_memory(sbi, FREE_NIDS))
382 try_to_free_nids(sbi, MAX_FREE_NIDS); 389 try_to_free_nids(sbi, MAX_FREE_NIDS);
383 else 390 else
384 build_free_nids(sbi, false); 391 build_free_nids(sbi, false, false);
385 392
386 if (!is_idle(sbi)) 393 if (!is_idle(sbi))
387 return; 394 return;
@@ -423,6 +430,9 @@ static int submit_flush_wait(struct f2fs_sb_info *sbi)
423 430
424 if (sbi->s_ndevs && !ret) { 431 if (sbi->s_ndevs && !ret) {
425 for (i = 1; i < sbi->s_ndevs; i++) { 432 for (i = 1; i < sbi->s_ndevs; i++) {
433 trace_f2fs_issue_flush(FDEV(i).bdev,
434 test_opt(sbi, NOBARRIER),
435 test_opt(sbi, FLUSH_MERGE));
426 ret = __submit_flush_wait(FDEV(i).bdev); 436 ret = __submit_flush_wait(FDEV(i).bdev);
427 if (ret) 437 if (ret)
428 break; 438 break;
@@ -434,7 +444,7 @@ static int submit_flush_wait(struct f2fs_sb_info *sbi)
434static int issue_flush_thread(void *data) 444static int issue_flush_thread(void *data)
435{ 445{
436 struct f2fs_sb_info *sbi = data; 446 struct f2fs_sb_info *sbi = data;
437 struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; 447 struct flush_cmd_control *fcc = SM_I(sbi)->fcc_info;
438 wait_queue_head_t *q = &fcc->flush_wait_queue; 448 wait_queue_head_t *q = &fcc->flush_wait_queue;
439repeat: 449repeat:
440 if (kthread_should_stop()) 450 if (kthread_should_stop())
@@ -463,16 +473,16 @@ repeat:
463 473
464int f2fs_issue_flush(struct f2fs_sb_info *sbi) 474int f2fs_issue_flush(struct f2fs_sb_info *sbi)
465{ 475{
466 struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; 476 struct flush_cmd_control *fcc = SM_I(sbi)->fcc_info;
467 struct flush_cmd cmd; 477 struct flush_cmd cmd;
468 478
469 trace_f2fs_issue_flush(sbi->sb, test_opt(sbi, NOBARRIER),
470 test_opt(sbi, FLUSH_MERGE));
471
472 if (test_opt(sbi, NOBARRIER)) 479 if (test_opt(sbi, NOBARRIER))
473 return 0; 480 return 0;
474 481
475 if (!test_opt(sbi, FLUSH_MERGE) || !atomic_read(&fcc->submit_flush)) { 482 if (!test_opt(sbi, FLUSH_MERGE))
483 return submit_flush_wait(sbi);
484
485 if (!atomic_read(&fcc->submit_flush)) {
476 int ret; 486 int ret;
477 487
478 atomic_inc(&fcc->submit_flush); 488 atomic_inc(&fcc->submit_flush);
@@ -506,8 +516,8 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
506 struct flush_cmd_control *fcc; 516 struct flush_cmd_control *fcc;
507 int err = 0; 517 int err = 0;
508 518
509 if (SM_I(sbi)->cmd_control_info) { 519 if (SM_I(sbi)->fcc_info) {
510 fcc = SM_I(sbi)->cmd_control_info; 520 fcc = SM_I(sbi)->fcc_info;
511 goto init_thread; 521 goto init_thread;
512 } 522 }
513 523
@@ -517,14 +527,14 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
517 atomic_set(&fcc->submit_flush, 0); 527 atomic_set(&fcc->submit_flush, 0);
518 init_waitqueue_head(&fcc->flush_wait_queue); 528 init_waitqueue_head(&fcc->flush_wait_queue);
519 init_llist_head(&fcc->issue_list); 529 init_llist_head(&fcc->issue_list);
520 SM_I(sbi)->cmd_control_info = fcc; 530 SM_I(sbi)->fcc_info = fcc;
521init_thread: 531init_thread:
522 fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, 532 fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi,
523 "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); 533 "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev));
524 if (IS_ERR(fcc->f2fs_issue_flush)) { 534 if (IS_ERR(fcc->f2fs_issue_flush)) {
525 err = PTR_ERR(fcc->f2fs_issue_flush); 535 err = PTR_ERR(fcc->f2fs_issue_flush);
526 kfree(fcc); 536 kfree(fcc);
527 SM_I(sbi)->cmd_control_info = NULL; 537 SM_I(sbi)->fcc_info = NULL;
528 return err; 538 return err;
529 } 539 }
530 540
@@ -533,7 +543,7 @@ init_thread:
533 543
534void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free) 544void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free)
535{ 545{
536 struct flush_cmd_control *fcc = SM_I(sbi)->cmd_control_info; 546 struct flush_cmd_control *fcc = SM_I(sbi)->fcc_info;
537 547
538 if (fcc && fcc->f2fs_issue_flush) { 548 if (fcc && fcc->f2fs_issue_flush) {
539 struct task_struct *flush_thread = fcc->f2fs_issue_flush; 549 struct task_struct *flush_thread = fcc->f2fs_issue_flush;
@@ -543,7 +553,7 @@ void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free)
543 } 553 }
544 if (free) { 554 if (free) {
545 kfree(fcc); 555 kfree(fcc);
546 SM_I(sbi)->cmd_control_info = NULL; 556 SM_I(sbi)->fcc_info = NULL;
547 } 557 }
548} 558}
549 559
@@ -623,60 +633,144 @@ static void locate_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno)
623 mutex_unlock(&dirty_i->seglist_lock); 633 mutex_unlock(&dirty_i->seglist_lock);
624} 634}
625 635
626static struct bio_entry *__add_bio_entry(struct f2fs_sb_info *sbi, 636static void __add_discard_cmd(struct f2fs_sb_info *sbi,
627 struct bio *bio) 637 struct bio *bio, block_t lstart, block_t len)
628{ 638{
629 struct list_head *wait_list = &(SM_I(sbi)->wait_list); 639 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
630 struct bio_entry *be = f2fs_kmem_cache_alloc(bio_entry_slab, GFP_NOFS); 640 struct list_head *cmd_list = &(dcc->discard_cmd_list);
641 struct discard_cmd *dc;
631 642
632 INIT_LIST_HEAD(&be->list); 643 dc = f2fs_kmem_cache_alloc(discard_cmd_slab, GFP_NOFS);
633 be->bio = bio; 644 INIT_LIST_HEAD(&dc->list);
634 init_completion(&be->event); 645 dc->bio = bio;
635 list_add_tail(&be->list, wait_list); 646 bio->bi_private = dc;
647 dc->lstart = lstart;
648 dc->len = len;
649 dc->state = D_PREP;
650 init_completion(&dc->wait);
636 651
637 return be; 652 mutex_lock(&dcc->cmd_lock);
653 list_add_tail(&dc->list, cmd_list);
654 mutex_unlock(&dcc->cmd_lock);
638} 655}
639 656
640void f2fs_wait_all_discard_bio(struct f2fs_sb_info *sbi) 657static void __remove_discard_cmd(struct f2fs_sb_info *sbi, struct discard_cmd *dc)
641{ 658{
642 struct list_head *wait_list = &(SM_I(sbi)->wait_list); 659 int err = dc->bio->bi_error;
643 struct bio_entry *be, *tmp;
644 660
645 list_for_each_entry_safe(be, tmp, wait_list, list) { 661 if (dc->state == D_DONE)
646 struct bio *bio = be->bio; 662 atomic_dec(&(SM_I(sbi)->dcc_info->submit_discard));
647 int err;
648 663
649 wait_for_completion_io(&be->event); 664 if (err == -EOPNOTSUPP)
650 err = be->error; 665 err = 0;
651 if (err == -EOPNOTSUPP)
652 err = 0;
653 666
654 if (err) 667 if (err)
655 f2fs_msg(sbi->sb, KERN_INFO, 668 f2fs_msg(sbi->sb, KERN_INFO,
656 "Issue discard failed, ret: %d", err); 669 "Issue discard failed, ret: %d", err);
670 bio_put(dc->bio);
671 list_del(&dc->list);
672 kmem_cache_free(discard_cmd_slab, dc);
673}
674
675/* This should be covered by global mutex, &sit_i->sentry_lock */
676void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
677{
678 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
679 struct list_head *wait_list = &(dcc->discard_cmd_list);
680 struct discard_cmd *dc, *tmp;
681 struct blk_plug plug;
682
683 mutex_lock(&dcc->cmd_lock);
657 684
658 bio_put(bio); 685 blk_start_plug(&plug);
659 list_del(&be->list); 686
660 kmem_cache_free(bio_entry_slab, be); 687 list_for_each_entry_safe(dc, tmp, wait_list, list) {
688
689 if (blkaddr == NULL_ADDR) {
690 if (dc->state == D_PREP) {
691 dc->state = D_SUBMIT;
692 submit_bio(dc->bio);
693 atomic_inc(&dcc->submit_discard);
694 }
695 continue;
696 }
697
698 if (dc->lstart <= blkaddr && blkaddr < dc->lstart + dc->len) {
699 if (dc->state == D_SUBMIT)
700 wait_for_completion_io(&dc->wait);
701 else
702 __remove_discard_cmd(sbi, dc);
703 }
704 }
705 blk_finish_plug(&plug);
706
707 /* this comes from f2fs_put_super */
708 if (blkaddr == NULL_ADDR) {
709 list_for_each_entry_safe(dc, tmp, wait_list, list) {
710 wait_for_completion_io(&dc->wait);
711 __remove_discard_cmd(sbi, dc);
712 }
661 } 713 }
714 mutex_unlock(&dcc->cmd_lock);
715}
716
717static void f2fs_submit_discard_endio(struct bio *bio)
718{
719 struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
720
721 complete(&dc->wait);
722 dc->state = D_DONE;
662} 723}
663 724
664static void f2fs_submit_bio_wait_endio(struct bio *bio) 725static int issue_discard_thread(void *data)
665{ 726{
666 struct bio_entry *be = (struct bio_entry *)bio->bi_private; 727 struct f2fs_sb_info *sbi = data;
728 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
729 wait_queue_head_t *q = &dcc->discard_wait_queue;
730 struct list_head *cmd_list = &dcc->discard_cmd_list;
731 struct discard_cmd *dc, *tmp;
732 struct blk_plug plug;
733 int iter = 0;
734repeat:
735 if (kthread_should_stop())
736 return 0;
737
738 blk_start_plug(&plug);
739
740 mutex_lock(&dcc->cmd_lock);
741 list_for_each_entry_safe(dc, tmp, cmd_list, list) {
742 if (dc->state == D_PREP) {
743 dc->state = D_SUBMIT;
744 submit_bio(dc->bio);
745 atomic_inc(&dcc->submit_discard);
746 if (iter++ > DISCARD_ISSUE_RATE)
747 break;
748 } else if (dc->state == D_DONE) {
749 __remove_discard_cmd(sbi, dc);
750 }
751 }
752 mutex_unlock(&dcc->cmd_lock);
753
754 blk_finish_plug(&plug);
755
756 iter = 0;
757 congestion_wait(BLK_RW_SYNC, HZ/50);
667 758
668 be->error = bio->bi_error; 759 wait_event_interruptible(*q,
669 complete(&be->event); 760 kthread_should_stop() || !list_empty(&dcc->discard_cmd_list));
761 goto repeat;
670} 762}
671 763
764
672/* this function is copied from blkdev_issue_discard from block/blk-lib.c */ 765/* this function is copied from blkdev_issue_discard from block/blk-lib.c */
673static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi, 766static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
674 struct block_device *bdev, block_t blkstart, block_t blklen) 767 struct block_device *bdev, block_t blkstart, block_t blklen)
675{ 768{
676 struct bio *bio = NULL; 769 struct bio *bio = NULL;
770 block_t lblkstart = blkstart;
677 int err; 771 int err;
678 772
679 trace_f2fs_issue_discard(sbi->sb, blkstart, blklen); 773 trace_f2fs_issue_discard(bdev, blkstart, blklen);
680 774
681 if (sbi->s_ndevs) { 775 if (sbi->s_ndevs) {
682 int devi = f2fs_target_device_index(sbi, blkstart); 776 int devi = f2fs_target_device_index(sbi, blkstart);
@@ -688,14 +782,12 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
688 SECTOR_FROM_BLOCK(blklen), 782 SECTOR_FROM_BLOCK(blklen),
689 GFP_NOFS, 0, &bio); 783 GFP_NOFS, 0, &bio);
690 if (!err && bio) { 784 if (!err && bio) {
691 struct bio_entry *be = __add_bio_entry(sbi, bio); 785 bio->bi_end_io = f2fs_submit_discard_endio;
692
693 bio->bi_private = be;
694 bio->bi_end_io = f2fs_submit_bio_wait_endio;
695 bio->bi_opf |= REQ_SYNC; 786 bio->bi_opf |= REQ_SYNC;
696 submit_bio(bio);
697 }
698 787
788 __add_discard_cmd(sbi, bio, lblkstart, blklen);
789 wake_up(&SM_I(sbi)->dcc_info->discard_wait_queue);
790 }
699 return err; 791 return err;
700} 792}
701 793
@@ -703,24 +795,13 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
703static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi, 795static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
704 struct block_device *bdev, block_t blkstart, block_t blklen) 796 struct block_device *bdev, block_t blkstart, block_t blklen)
705{ 797{
706 sector_t nr_sects = SECTOR_FROM_BLOCK(blklen); 798 sector_t sector, nr_sects;
707 sector_t sector;
708 int devi = 0; 799 int devi = 0;
709 800
710 if (sbi->s_ndevs) { 801 if (sbi->s_ndevs) {
711 devi = f2fs_target_device_index(sbi, blkstart); 802 devi = f2fs_target_device_index(sbi, blkstart);
712 blkstart -= FDEV(devi).start_blk; 803 blkstart -= FDEV(devi).start_blk;
713 } 804 }
714 sector = SECTOR_FROM_BLOCK(blkstart);
715
716 if (sector & (bdev_zone_sectors(bdev) - 1) ||
717 nr_sects != bdev_zone_sectors(bdev)) {
718 f2fs_msg(sbi->sb, KERN_INFO,
719 "(%d) %s: Unaligned discard attempted (block %x + %x)",
720 devi, sbi->s_ndevs ? FDEV(devi).path: "",
721 blkstart, blklen);
722 return -EIO;
723 }
724 805
725 /* 806 /*
726 * We need to know the type of the zone: for conventional zones, 807 * We need to know the type of the zone: for conventional zones,
@@ -735,7 +816,18 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
735 return __f2fs_issue_discard_async(sbi, bdev, blkstart, blklen); 816 return __f2fs_issue_discard_async(sbi, bdev, blkstart, blklen);
736 case BLK_ZONE_TYPE_SEQWRITE_REQ: 817 case BLK_ZONE_TYPE_SEQWRITE_REQ:
737 case BLK_ZONE_TYPE_SEQWRITE_PREF: 818 case BLK_ZONE_TYPE_SEQWRITE_PREF:
738 trace_f2fs_issue_reset_zone(sbi->sb, blkstart); 819 sector = SECTOR_FROM_BLOCK(blkstart);
820 nr_sects = SECTOR_FROM_BLOCK(blklen);
821
822 if (sector & (bdev_zone_sectors(bdev) - 1) ||
823 nr_sects != bdev_zone_sectors(bdev)) {
824 f2fs_msg(sbi->sb, KERN_INFO,
825 "(%d) %s: Unaligned discard attempted (block %x + %x)",
826 devi, sbi->s_ndevs ? FDEV(devi).path: "",
827 blkstart, blklen);
828 return -EIO;
829 }
830 trace_f2fs_issue_reset_zone(bdev, blkstart);
739 return blkdev_reset_zones(bdev, sector, 831 return blkdev_reset_zones(bdev, sector,
740 nr_sects, GFP_NOFS); 832 nr_sects, GFP_NOFS);
741 default: 833 default:
@@ -800,13 +892,14 @@ static void __add_discard_entry(struct f2fs_sb_info *sbi,
800 struct cp_control *cpc, struct seg_entry *se, 892 struct cp_control *cpc, struct seg_entry *se,
801 unsigned int start, unsigned int end) 893 unsigned int start, unsigned int end)
802{ 894{
803 struct list_head *head = &SM_I(sbi)->discard_list; 895 struct list_head *head = &SM_I(sbi)->dcc_info->discard_entry_list;
804 struct discard_entry *new, *last; 896 struct discard_entry *new, *last;
805 897
806 if (!list_empty(head)) { 898 if (!list_empty(head)) {
807 last = list_last_entry(head, struct discard_entry, list); 899 last = list_last_entry(head, struct discard_entry, list);
808 if (START_BLOCK(sbi, cpc->trim_start) + start == 900 if (START_BLOCK(sbi, cpc->trim_start) + start ==
809 last->blkaddr + last->len) { 901 last->blkaddr + last->len &&
902 last->len < MAX_DISCARD_BLOCKS(sbi)) {
810 last->len += end - start; 903 last->len += end - start;
811 goto done; 904 goto done;
812 } 905 }
@@ -818,10 +911,11 @@ static void __add_discard_entry(struct f2fs_sb_info *sbi,
818 new->len = end - start; 911 new->len = end - start;
819 list_add_tail(&new->list, head); 912 list_add_tail(&new->list, head);
820done: 913done:
821 SM_I(sbi)->nr_discards += end - start; 914 SM_I(sbi)->dcc_info->nr_discards += end - start;
822} 915}
823 916
824static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) 917static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
918 bool check_only)
825{ 919{
826 int entries = SIT_VBLOCK_MAP_SIZE / sizeof(unsigned long); 920 int entries = SIT_VBLOCK_MAP_SIZE / sizeof(unsigned long);
827 int max_blocks = sbi->blocks_per_seg; 921 int max_blocks = sbi->blocks_per_seg;
@@ -835,12 +929,13 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
835 int i; 929 int i;
836 930
837 if (se->valid_blocks == max_blocks || !f2fs_discard_en(sbi)) 931 if (se->valid_blocks == max_blocks || !f2fs_discard_en(sbi))
838 return; 932 return false;
839 933
840 if (!force) { 934 if (!force) {
841 if (!test_opt(sbi, DISCARD) || !se->valid_blocks || 935 if (!test_opt(sbi, DISCARD) || !se->valid_blocks ||
842 SM_I(sbi)->nr_discards >= SM_I(sbi)->max_discards) 936 SM_I(sbi)->dcc_info->nr_discards >=
843 return; 937 SM_I(sbi)->dcc_info->max_discards)
938 return false;
844 } 939 }
845 940
846 /* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */ 941 /* SIT_VBLOCK_MAP_SIZE should be multiple of sizeof(unsigned long) */
@@ -848,7 +943,8 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
848 dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] : 943 dmap[i] = force ? ~ckpt_map[i] & ~discard_map[i] :
849 (cur_map[i] ^ ckpt_map[i]) & ckpt_map[i]; 944 (cur_map[i] ^ ckpt_map[i]) & ckpt_map[i];
850 945
851 while (force || SM_I(sbi)->nr_discards <= SM_I(sbi)->max_discards) { 946 while (force || SM_I(sbi)->dcc_info->nr_discards <=
947 SM_I(sbi)->dcc_info->max_discards) {
852 start = __find_rev_next_bit(dmap, max_blocks, end + 1); 948 start = __find_rev_next_bit(dmap, max_blocks, end + 1);
853 if (start >= max_blocks) 949 if (start >= max_blocks)
854 break; 950 break;
@@ -858,13 +954,17 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
858 && (end - start) < cpc->trim_minlen) 954 && (end - start) < cpc->trim_minlen)
859 continue; 955 continue;
860 956
957 if (check_only)
958 return true;
959
861 __add_discard_entry(sbi, cpc, se, start, end); 960 __add_discard_entry(sbi, cpc, se, start, end);
862 } 961 }
962 return false;
863} 963}
864 964
865void release_discard_addrs(struct f2fs_sb_info *sbi) 965void release_discard_addrs(struct f2fs_sb_info *sbi)
866{ 966{
867 struct list_head *head = &(SM_I(sbi)->discard_list); 967 struct list_head *head = &(SM_I(sbi)->dcc_info->discard_entry_list);
868 struct discard_entry *entry, *this; 968 struct discard_entry *entry, *this;
869 969
870 /* drop caches */ 970 /* drop caches */
@@ -890,17 +990,14 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)
890 990
891void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc) 991void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
892{ 992{
893 struct list_head *head = &(SM_I(sbi)->discard_list); 993 struct list_head *head = &(SM_I(sbi)->dcc_info->discard_entry_list);
894 struct discard_entry *entry, *this; 994 struct discard_entry *entry, *this;
895 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); 995 struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
896 struct blk_plug plug;
897 unsigned long *prefree_map = dirty_i->dirty_segmap[PRE]; 996 unsigned long *prefree_map = dirty_i->dirty_segmap[PRE];
898 unsigned int start = 0, end = -1; 997 unsigned int start = 0, end = -1;
899 unsigned int secno, start_segno; 998 unsigned int secno, start_segno;
900 bool force = (cpc->reason == CP_DISCARD); 999 bool force = (cpc->reason == CP_DISCARD);
901 1000
902 blk_start_plug(&plug);
903
904 mutex_lock(&dirty_i->seglist_lock); 1001 mutex_lock(&dirty_i->seglist_lock);
905 1002
906 while (1) { 1003 while (1) {
@@ -916,9 +1013,13 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
916 1013
917 dirty_i->nr_dirty[PRE] -= end - start; 1014 dirty_i->nr_dirty[PRE] -= end - start;
918 1015
919 if (force || !test_opt(sbi, DISCARD)) 1016 if (!test_opt(sbi, DISCARD))
920 continue; 1017 continue;
921 1018
1019 if (force && start >= cpc->trim_start &&
1020 (end - 1) <= cpc->trim_end)
1021 continue;
1022
922 if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) { 1023 if (!test_opt(sbi, LFS) || sbi->segs_per_sec == 1) {
923 f2fs_issue_discard(sbi, START_BLOCK(sbi, start), 1024 f2fs_issue_discard(sbi, START_BLOCK(sbi, start),
924 (end - start) << sbi->log_blocks_per_seg); 1025 (end - start) << sbi->log_blocks_per_seg);
@@ -935,6 +1036,8 @@ next:
935 start = start_segno + sbi->segs_per_sec; 1036 start = start_segno + sbi->segs_per_sec;
936 if (start < end) 1037 if (start < end)
937 goto next; 1038 goto next;
1039 else
1040 end = start - 1;
938 } 1041 }
939 mutex_unlock(&dirty_i->seglist_lock); 1042 mutex_unlock(&dirty_i->seglist_lock);
940 1043
@@ -946,11 +1049,62 @@ next:
946 cpc->trimmed += entry->len; 1049 cpc->trimmed += entry->len;
947skip: 1050skip:
948 list_del(&entry->list); 1051 list_del(&entry->list);
949 SM_I(sbi)->nr_discards -= entry->len; 1052 SM_I(sbi)->dcc_info->nr_discards -= entry->len;
950 kmem_cache_free(discard_entry_slab, entry); 1053 kmem_cache_free(discard_entry_slab, entry);
951 } 1054 }
1055}
952 1056
953 blk_finish_plug(&plug); 1057static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
1058{
1059 dev_t dev = sbi->sb->s_bdev->bd_dev;
1060 struct discard_cmd_control *dcc;
1061 int err = 0;
1062
1063 if (SM_I(sbi)->dcc_info) {
1064 dcc = SM_I(sbi)->dcc_info;
1065 goto init_thread;
1066 }
1067
1068 dcc = kzalloc(sizeof(struct discard_cmd_control), GFP_KERNEL);
1069 if (!dcc)
1070 return -ENOMEM;
1071
1072 INIT_LIST_HEAD(&dcc->discard_entry_list);
1073 INIT_LIST_HEAD(&dcc->discard_cmd_list);
1074 mutex_init(&dcc->cmd_lock);
1075 atomic_set(&dcc->submit_discard, 0);
1076 dcc->nr_discards = 0;
1077 dcc->max_discards = 0;
1078
1079 init_waitqueue_head(&dcc->discard_wait_queue);
1080 SM_I(sbi)->dcc_info = dcc;
1081init_thread:
1082 dcc->f2fs_issue_discard = kthread_run(issue_discard_thread, sbi,
1083 "f2fs_discard-%u:%u", MAJOR(dev), MINOR(dev));
1084 if (IS_ERR(dcc->f2fs_issue_discard)) {
1085 err = PTR_ERR(dcc->f2fs_issue_discard);
1086 kfree(dcc);
1087 SM_I(sbi)->dcc_info = NULL;
1088 return err;
1089 }
1090
1091 return err;
1092}
1093
1094static void destroy_discard_cmd_control(struct f2fs_sb_info *sbi, bool free)
1095{
1096 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
1097
1098 if (dcc && dcc->f2fs_issue_discard) {
1099 struct task_struct *discard_thread = dcc->f2fs_issue_discard;
1100
1101 dcc->f2fs_issue_discard = NULL;
1102 kthread_stop(discard_thread);
1103 }
1104 if (free) {
1105 kfree(dcc);
1106 SM_I(sbi)->dcc_info = NULL;
1107 }
954} 1108}
955 1109
956static bool __mark_sit_entry_dirty(struct f2fs_sb_info *sbi, unsigned int segno) 1110static bool __mark_sit_entry_dirty(struct f2fs_sb_info *sbi, unsigned int segno)
@@ -995,14 +1149,32 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
995 1149
996 /* Update valid block bitmap */ 1150 /* Update valid block bitmap */
997 if (del > 0) { 1151 if (del > 0) {
998 if (f2fs_test_and_set_bit(offset, se->cur_valid_map)) 1152 if (f2fs_test_and_set_bit(offset, se->cur_valid_map)) {
1153#ifdef CONFIG_F2FS_CHECK_FS
1154 if (f2fs_test_and_set_bit(offset,
1155 se->cur_valid_map_mir))
1156 f2fs_bug_on(sbi, 1);
1157 else
1158 WARN_ON(1);
1159#else
999 f2fs_bug_on(sbi, 1); 1160 f2fs_bug_on(sbi, 1);
1161#endif
1162 }
1000 if (f2fs_discard_en(sbi) && 1163 if (f2fs_discard_en(sbi) &&
1001 !f2fs_test_and_set_bit(offset, se->discard_map)) 1164 !f2fs_test_and_set_bit(offset, se->discard_map))
1002 sbi->discard_blks--; 1165 sbi->discard_blks--;
1003 } else { 1166 } else {
1004 if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map)) 1167 if (!f2fs_test_and_clear_bit(offset, se->cur_valid_map)) {
1168#ifdef CONFIG_F2FS_CHECK_FS
1169 if (!f2fs_test_and_clear_bit(offset,
1170 se->cur_valid_map_mir))
1171 f2fs_bug_on(sbi, 1);
1172 else
1173 WARN_ON(1);
1174#else
1005 f2fs_bug_on(sbi, 1); 1175 f2fs_bug_on(sbi, 1);
1176#endif
1177 }
1006 if (f2fs_discard_en(sbi) && 1178 if (f2fs_discard_en(sbi) &&
1007 f2fs_test_and_clear_bit(offset, se->discard_map)) 1179 f2fs_test_and_clear_bit(offset, se->discard_map))
1008 sbi->discard_blks++; 1180 sbi->discard_blks++;
@@ -1167,17 +1339,6 @@ static void write_current_sum_page(struct f2fs_sb_info *sbi,
1167 f2fs_put_page(page, 1); 1339 f2fs_put_page(page, 1);
1168} 1340}
1169 1341
1170static int is_next_segment_free(struct f2fs_sb_info *sbi, int type)
1171{
1172 struct curseg_info *curseg = CURSEG_I(sbi, type);
1173 unsigned int segno = curseg->segno + 1;
1174 struct free_segmap_info *free_i = FREE_I(sbi);
1175
1176 if (segno < MAIN_SEGS(sbi) && segno % sbi->segs_per_sec)
1177 return !test_bit(segno, free_i->free_segmap);
1178 return 0;
1179}
1180
1181/* 1342/*
1182 * Find a new segment from the free segments bitmap to right order 1343 * Find a new segment from the free segments bitmap to right order
1183 * This function should be returned with success, otherwise BUG 1344 * This function should be returned with success, otherwise BUG
@@ -1382,16 +1543,39 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type)
1382{ 1543{
1383 struct curseg_info *curseg = CURSEG_I(sbi, type); 1544 struct curseg_info *curseg = CURSEG_I(sbi, type);
1384 const struct victim_selection *v_ops = DIRTY_I(sbi)->v_ops; 1545 const struct victim_selection *v_ops = DIRTY_I(sbi)->v_ops;
1546 int i, cnt;
1547 bool reversed = false;
1548
1549 /* need_SSR() already forces to do this */
1550 if (v_ops->get_victim(sbi, &(curseg)->next_segno, BG_GC, type, SSR))
1551 return 1;
1385 1552
1386 if (IS_NODESEG(type) || !has_not_enough_free_secs(sbi, 0, 0)) 1553 /* For node segments, let's do SSR more intensively */
1387 return v_ops->get_victim(sbi, 1554 if (IS_NODESEG(type)) {
1388 &(curseg)->next_segno, BG_GC, type, SSR); 1555 if (type >= CURSEG_WARM_NODE) {
1556 reversed = true;
1557 i = CURSEG_COLD_NODE;
1558 } else {
1559 i = CURSEG_HOT_NODE;
1560 }
1561 cnt = NR_CURSEG_NODE_TYPE;
1562 } else {
1563 if (type >= CURSEG_WARM_DATA) {
1564 reversed = true;
1565 i = CURSEG_COLD_DATA;
1566 } else {
1567 i = CURSEG_HOT_DATA;
1568 }
1569 cnt = NR_CURSEG_DATA_TYPE;
1570 }
1389 1571
1390 /* For data segments, let's do SSR more intensively */ 1572 for (; cnt-- > 0; reversed ? i-- : i++) {
1391 for (; type >= CURSEG_HOT_DATA; type--) 1573 if (i == type)
1574 continue;
1392 if (v_ops->get_victim(sbi, &(curseg)->next_segno, 1575 if (v_ops->get_victim(sbi, &(curseg)->next_segno,
1393 BG_GC, type, SSR)) 1576 BG_GC, i, SSR))
1394 return 1; 1577 return 1;
1578 }
1395 return 0; 1579 return 0;
1396} 1580}
1397 1581
@@ -1402,20 +1586,17 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type)
1402static void allocate_segment_by_default(struct f2fs_sb_info *sbi, 1586static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
1403 int type, bool force) 1587 int type, bool force)
1404{ 1588{
1405 struct curseg_info *curseg = CURSEG_I(sbi, type);
1406
1407 if (force) 1589 if (force)
1408 new_curseg(sbi, type, true); 1590 new_curseg(sbi, type, true);
1409 else if (type == CURSEG_WARM_NODE) 1591 else if (!is_set_ckpt_flags(sbi, CP_CRC_RECOVERY_FLAG) &&
1410 new_curseg(sbi, type, false); 1592 type == CURSEG_WARM_NODE)
1411 else if (curseg->alloc_type == LFS && is_next_segment_free(sbi, type))
1412 new_curseg(sbi, type, false); 1593 new_curseg(sbi, type, false);
1413 else if (need_SSR(sbi) && get_ssr_segment(sbi, type)) 1594 else if (need_SSR(sbi) && get_ssr_segment(sbi, type))
1414 change_curseg(sbi, type, true); 1595 change_curseg(sbi, type, true);
1415 else 1596 else
1416 new_curseg(sbi, type, false); 1597 new_curseg(sbi, type, false);
1417 1598
1418 stat_inc_seg_type(sbi, curseg); 1599 stat_inc_seg_type(sbi, CURSEG_I(sbi, type));
1419} 1600}
1420 1601
1421void allocate_new_segments(struct f2fs_sb_info *sbi) 1602void allocate_new_segments(struct f2fs_sb_info *sbi)
@@ -1424,9 +1605,6 @@ void allocate_new_segments(struct f2fs_sb_info *sbi)
1424 unsigned int old_segno; 1605 unsigned int old_segno;
1425 int i; 1606 int i;
1426 1607
1427 if (test_opt(sbi, LFS))
1428 return;
1429
1430 for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) { 1608 for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
1431 curseg = CURSEG_I(sbi, i); 1609 curseg = CURSEG_I(sbi, i);
1432 old_segno = curseg->segno; 1610 old_segno = curseg->segno;
@@ -1439,6 +1617,24 @@ static const struct segment_allocation default_salloc_ops = {
1439 .allocate_segment = allocate_segment_by_default, 1617 .allocate_segment = allocate_segment_by_default,
1440}; 1618};
1441 1619
1620bool exist_trim_candidates(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1621{
1622 __u64 trim_start = cpc->trim_start;
1623 bool has_candidate = false;
1624
1625 mutex_lock(&SIT_I(sbi)->sentry_lock);
1626 for (; cpc->trim_start <= cpc->trim_end; cpc->trim_start++) {
1627 if (add_discard_addrs(sbi, cpc, true)) {
1628 has_candidate = true;
1629 break;
1630 }
1631 }
1632 mutex_unlock(&SIT_I(sbi)->sentry_lock);
1633
1634 cpc->trim_start = trim_start;
1635 return has_candidate;
1636}
1637
1442int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range) 1638int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
1443{ 1639{
1444 __u64 start = F2FS_BYTES_TO_BLK(range->start); 1640 __u64 start = F2FS_BYTES_TO_BLK(range->start);
@@ -1573,6 +1769,8 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
1573 1769
1574 *new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg); 1770 *new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
1575 1771
1772 f2fs_wait_discard_bio(sbi, *new_blkaddr);
1773
1576 /* 1774 /*
1577 * __add_sum_entry should be resided under the curseg_mutex 1775 * __add_sum_entry should be resided under the curseg_mutex
1578 * because, this function updates a summary entry in the 1776 * because, this function updates a summary entry in the
@@ -1584,14 +1782,15 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
1584 1782
1585 stat_inc_block_count(sbi, curseg); 1783 stat_inc_block_count(sbi, curseg);
1586 1784
1587 if (!__has_curseg_space(sbi, type))
1588 sit_i->s_ops->allocate_segment(sbi, type, false);
1589 /* 1785 /*
1590 * SIT information should be updated before segment allocation, 1786 * SIT information should be updated before segment allocation,
1591 * since SSR needs latest valid block information. 1787 * since SSR needs latest valid block information.
1592 */ 1788 */
1593 refresh_sit_entry(sbi, old_blkaddr, *new_blkaddr); 1789 refresh_sit_entry(sbi, old_blkaddr, *new_blkaddr);
1594 1790
1791 if (!__has_curseg_space(sbi, type))
1792 sit_i->s_ops->allocate_segment(sbi, type, false);
1793
1595 mutex_unlock(&sit_i->sentry_lock); 1794 mutex_unlock(&sit_i->sentry_lock);
1596 1795
1597 if (page && IS_NODESEG(type)) 1796 if (page && IS_NODESEG(type))
@@ -1603,15 +1802,20 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
1603static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio) 1802static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
1604{ 1803{
1605 int type = __get_segment_type(fio->page, fio->type); 1804 int type = __get_segment_type(fio->page, fio->type);
1805 int err;
1606 1806
1607 if (fio->type == NODE || fio->type == DATA) 1807 if (fio->type == NODE || fio->type == DATA)
1608 mutex_lock(&fio->sbi->wio_mutex[fio->type]); 1808 mutex_lock(&fio->sbi->wio_mutex[fio->type]);
1609 1809reallocate:
1610 allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr, 1810 allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr,
1611 &fio->new_blkaddr, sum, type); 1811 &fio->new_blkaddr, sum, type);
1612 1812
1613 /* writeout dirty page into bdev */ 1813 /* writeout dirty page into bdev */
1614 f2fs_submit_page_mbio(fio); 1814 err = f2fs_submit_page_mbio(fio);
1815 if (err == -EAGAIN) {
1816 fio->old_blkaddr = fio->new_blkaddr;
1817 goto reallocate;
1818 }
1615 1819
1616 if (fio->type == NODE || fio->type == DATA) 1820 if (fio->type == NODE || fio->type == DATA)
1617 mutex_unlock(&fio->sbi->wio_mutex[fio->type]); 1821 mutex_unlock(&fio->sbi->wio_mutex[fio->type]);
@@ -1753,7 +1957,8 @@ void f2fs_wait_on_page_writeback(struct page *page,
1753 if (PageWriteback(page)) { 1957 if (PageWriteback(page)) {
1754 struct f2fs_sb_info *sbi = F2FS_P_SB(page); 1958 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
1755 1959
1756 f2fs_submit_merged_bio_cond(sbi, NULL, page, 0, type, WRITE); 1960 f2fs_submit_merged_bio_cond(sbi, page->mapping->host,
1961 0, page->index, type, WRITE);
1757 if (ordered) 1962 if (ordered)
1758 wait_on_page_writeback(page); 1963 wait_on_page_writeback(page);
1759 else 1964 else
@@ -2228,7 +2433,7 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
2228 /* add discard candidates */ 2433 /* add discard candidates */
2229 if (cpc->reason != CP_DISCARD) { 2434 if (cpc->reason != CP_DISCARD) {
2230 cpc->trim_start = segno; 2435 cpc->trim_start = segno;
2231 add_discard_addrs(sbi, cpc); 2436 add_discard_addrs(sbi, cpc, false);
2232 } 2437 }
2233 2438
2234 if (to_journal) { 2439 if (to_journal) {
@@ -2263,8 +2468,12 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
2263 f2fs_bug_on(sbi, sit_i->dirty_sentries); 2468 f2fs_bug_on(sbi, sit_i->dirty_sentries);
2264out: 2469out:
2265 if (cpc->reason == CP_DISCARD) { 2470 if (cpc->reason == CP_DISCARD) {
2471 __u64 trim_start = cpc->trim_start;
2472
2266 for (; cpc->trim_start <= cpc->trim_end; cpc->trim_start++) 2473 for (; cpc->trim_start <= cpc->trim_end; cpc->trim_start++)
2267 add_discard_addrs(sbi, cpc); 2474 add_discard_addrs(sbi, cpc, false);
2475
2476 cpc->trim_start = trim_start;
2268 } 2477 }
2269 mutex_unlock(&sit_i->sentry_lock); 2478 mutex_unlock(&sit_i->sentry_lock);
2270 2479
@@ -2276,7 +2485,7 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
2276 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); 2485 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
2277 struct sit_info *sit_i; 2486 struct sit_info *sit_i;
2278 unsigned int sit_segs, start; 2487 unsigned int sit_segs, start;
2279 char *src_bitmap, *dst_bitmap; 2488 char *src_bitmap;
2280 unsigned int bitmap_size; 2489 unsigned int bitmap_size;
2281 2490
2282 /* allocate memory for SIT information */ 2491 /* allocate memory for SIT information */
@@ -2305,6 +2514,13 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
2305 !sit_i->sentries[start].ckpt_valid_map) 2514 !sit_i->sentries[start].ckpt_valid_map)
2306 return -ENOMEM; 2515 return -ENOMEM;
2307 2516
2517#ifdef CONFIG_F2FS_CHECK_FS
2518 sit_i->sentries[start].cur_valid_map_mir
2519 = kzalloc(SIT_VBLOCK_MAP_SIZE, GFP_KERNEL);
2520 if (!sit_i->sentries[start].cur_valid_map_mir)
2521 return -ENOMEM;
2522#endif
2523
2308 if (f2fs_discard_en(sbi)) { 2524 if (f2fs_discard_en(sbi)) {
2309 sit_i->sentries[start].discard_map 2525 sit_i->sentries[start].discard_map
2310 = kzalloc(SIT_VBLOCK_MAP_SIZE, GFP_KERNEL); 2526 = kzalloc(SIT_VBLOCK_MAP_SIZE, GFP_KERNEL);
@@ -2331,17 +2547,22 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
2331 bitmap_size = __bitmap_size(sbi, SIT_BITMAP); 2547 bitmap_size = __bitmap_size(sbi, SIT_BITMAP);
2332 src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP); 2548 src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP);
2333 2549
2334 dst_bitmap = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL); 2550 sit_i->sit_bitmap = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL);
2335 if (!dst_bitmap) 2551 if (!sit_i->sit_bitmap)
2336 return -ENOMEM; 2552 return -ENOMEM;
2337 2553
2554#ifdef CONFIG_F2FS_CHECK_FS
2555 sit_i->sit_bitmap_mir = kmemdup(src_bitmap, bitmap_size, GFP_KERNEL);
2556 if (!sit_i->sit_bitmap_mir)
2557 return -ENOMEM;
2558#endif
2559
2338 /* init SIT information */ 2560 /* init SIT information */
2339 sit_i->s_ops = &default_salloc_ops; 2561 sit_i->s_ops = &default_salloc_ops;
2340 2562
2341 sit_i->sit_base_addr = le32_to_cpu(raw_super->sit_blkaddr); 2563 sit_i->sit_base_addr = le32_to_cpu(raw_super->sit_blkaddr);
2342 sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg; 2564 sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg;
2343 sit_i->written_valid_blocks = 0; 2565 sit_i->written_valid_blocks = 0;
2344 sit_i->sit_bitmap = dst_bitmap;
2345 sit_i->bitmap_size = bitmap_size; 2566 sit_i->bitmap_size = bitmap_size;
2346 sit_i->dirty_sentries = 0; 2567 sit_i->dirty_sentries = 0;
2347 sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK; 2568 sit_i->sents_per_block = SIT_ENTRY_PER_BLOCK;
@@ -2626,11 +2847,6 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
2626 sm_info->min_ipu_util = DEF_MIN_IPU_UTIL; 2847 sm_info->min_ipu_util = DEF_MIN_IPU_UTIL;
2627 sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS; 2848 sm_info->min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS;
2628 2849
2629 INIT_LIST_HEAD(&sm_info->discard_list);
2630 INIT_LIST_HEAD(&sm_info->wait_list);
2631 sm_info->nr_discards = 0;
2632 sm_info->max_discards = 0;
2633
2634 sm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS; 2850 sm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS;
2635 2851
2636 INIT_LIST_HEAD(&sm_info->sit_entry_set); 2852 INIT_LIST_HEAD(&sm_info->sit_entry_set);
@@ -2641,6 +2857,10 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
2641 return err; 2857 return err;
2642 } 2858 }
2643 2859
2860 err = create_discard_cmd_control(sbi);
2861 if (err)
2862 return err;
2863
2644 err = build_sit_info(sbi); 2864 err = build_sit_info(sbi);
2645 if (err) 2865 if (err)
2646 return err; 2866 return err;
@@ -2734,6 +2954,9 @@ static void destroy_sit_info(struct f2fs_sb_info *sbi)
2734 if (sit_i->sentries) { 2954 if (sit_i->sentries) {
2735 for (start = 0; start < MAIN_SEGS(sbi); start++) { 2955 for (start = 0; start < MAIN_SEGS(sbi); start++) {
2736 kfree(sit_i->sentries[start].cur_valid_map); 2956 kfree(sit_i->sentries[start].cur_valid_map);
2957#ifdef CONFIG_F2FS_CHECK_FS
2958 kfree(sit_i->sentries[start].cur_valid_map_mir);
2959#endif
2737 kfree(sit_i->sentries[start].ckpt_valid_map); 2960 kfree(sit_i->sentries[start].ckpt_valid_map);
2738 kfree(sit_i->sentries[start].discard_map); 2961 kfree(sit_i->sentries[start].discard_map);
2739 } 2962 }
@@ -2746,6 +2969,9 @@ static void destroy_sit_info(struct f2fs_sb_info *sbi)
2746 2969
2747 SM_I(sbi)->sit_info = NULL; 2970 SM_I(sbi)->sit_info = NULL;
2748 kfree(sit_i->sit_bitmap); 2971 kfree(sit_i->sit_bitmap);
2972#ifdef CONFIG_F2FS_CHECK_FS
2973 kfree(sit_i->sit_bitmap_mir);
2974#endif
2749 kfree(sit_i); 2975 kfree(sit_i);
2750} 2976}
2751 2977
@@ -2756,6 +2982,7 @@ void destroy_segment_manager(struct f2fs_sb_info *sbi)
2756 if (!sm_info) 2982 if (!sm_info)
2757 return; 2983 return;
2758 destroy_flush_cmd_control(sbi, true); 2984 destroy_flush_cmd_control(sbi, true);
2985 destroy_discard_cmd_control(sbi, true);
2759 destroy_dirty_segmap(sbi); 2986 destroy_dirty_segmap(sbi);
2760 destroy_curseg(sbi); 2987 destroy_curseg(sbi);
2761 destroy_free_segmap(sbi); 2988 destroy_free_segmap(sbi);
@@ -2771,15 +2998,15 @@ int __init create_segment_manager_caches(void)
2771 if (!discard_entry_slab) 2998 if (!discard_entry_slab)
2772 goto fail; 2999 goto fail;
2773 3000
2774 bio_entry_slab = f2fs_kmem_cache_create("bio_entry", 3001 discard_cmd_slab = f2fs_kmem_cache_create("discard_cmd",
2775 sizeof(struct bio_entry)); 3002 sizeof(struct discard_cmd));
2776 if (!bio_entry_slab) 3003 if (!discard_cmd_slab)
2777 goto destroy_discard_entry; 3004 goto destroy_discard_entry;
2778 3005
2779 sit_entry_set_slab = f2fs_kmem_cache_create("sit_entry_set", 3006 sit_entry_set_slab = f2fs_kmem_cache_create("sit_entry_set",
2780 sizeof(struct sit_entry_set)); 3007 sizeof(struct sit_entry_set));
2781 if (!sit_entry_set_slab) 3008 if (!sit_entry_set_slab)
2782 goto destroy_bio_entry; 3009 goto destroy_discard_cmd;
2783 3010
2784 inmem_entry_slab = f2fs_kmem_cache_create("inmem_page_entry", 3011 inmem_entry_slab = f2fs_kmem_cache_create("inmem_page_entry",
2785 sizeof(struct inmem_pages)); 3012 sizeof(struct inmem_pages));
@@ -2789,8 +3016,8 @@ int __init create_segment_manager_caches(void)
2789 3016
2790destroy_sit_entry_set: 3017destroy_sit_entry_set:
2791 kmem_cache_destroy(sit_entry_set_slab); 3018 kmem_cache_destroy(sit_entry_set_slab);
2792destroy_bio_entry: 3019destroy_discard_cmd:
2793 kmem_cache_destroy(bio_entry_slab); 3020 kmem_cache_destroy(discard_cmd_slab);
2794destroy_discard_entry: 3021destroy_discard_entry:
2795 kmem_cache_destroy(discard_entry_slab); 3022 kmem_cache_destroy(discard_entry_slab);
2796fail: 3023fail:
@@ -2800,7 +3027,7 @@ fail:
2800void destroy_segment_manager_caches(void) 3027void destroy_segment_manager_caches(void)
2801{ 3028{
2802 kmem_cache_destroy(sit_entry_set_slab); 3029 kmem_cache_destroy(sit_entry_set_slab);
2803 kmem_cache_destroy(bio_entry_slab); 3030 kmem_cache_destroy(discard_cmd_slab);
2804 kmem_cache_destroy(discard_entry_slab); 3031 kmem_cache_destroy(discard_entry_slab);
2805 kmem_cache_destroy(inmem_entry_slab); 3032 kmem_cache_destroy(inmem_entry_slab);
2806} 3033}
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index 9d44ce83acb2..5e8ad4280a50 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -164,6 +164,9 @@ struct seg_entry {
164 unsigned int ckpt_valid_blocks:10; /* # of valid blocks last cp */ 164 unsigned int ckpt_valid_blocks:10; /* # of valid blocks last cp */
165 unsigned int padding:6; /* padding */ 165 unsigned int padding:6; /* padding */
166 unsigned char *cur_valid_map; /* validity bitmap of blocks */ 166 unsigned char *cur_valid_map; /* validity bitmap of blocks */
167#ifdef CONFIG_F2FS_CHECK_FS
168 unsigned char *cur_valid_map_mir; /* mirror of current valid bitmap */
169#endif
167 /* 170 /*
168 * # of valid blocks and the validity bitmap stored in the the last 171 * # of valid blocks and the validity bitmap stored in the the last
169 * checkpoint pack. This information is used by the SSR mode. 172 * checkpoint pack. This information is used by the SSR mode.
@@ -186,9 +189,12 @@ struct segment_allocation {
186 * the page is atomically written, and it is in inmem_pages list. 189 * the page is atomically written, and it is in inmem_pages list.
187 */ 190 */
188#define ATOMIC_WRITTEN_PAGE ((unsigned long)-1) 191#define ATOMIC_WRITTEN_PAGE ((unsigned long)-1)
192#define DUMMY_WRITTEN_PAGE ((unsigned long)-2)
189 193
190#define IS_ATOMIC_WRITTEN_PAGE(page) \ 194#define IS_ATOMIC_WRITTEN_PAGE(page) \
191 (page_private(page) == (unsigned long)ATOMIC_WRITTEN_PAGE) 195 (page_private(page) == (unsigned long)ATOMIC_WRITTEN_PAGE)
196#define IS_DUMMY_WRITTEN_PAGE(page) \
197 (page_private(page) == (unsigned long)DUMMY_WRITTEN_PAGE)
192 198
193struct inmem_pages { 199struct inmem_pages {
194 struct list_head list; 200 struct list_head list;
@@ -203,6 +209,9 @@ struct sit_info {
203 block_t sit_blocks; /* # of blocks used by SIT area */ 209 block_t sit_blocks; /* # of blocks used by SIT area */
204 block_t written_valid_blocks; /* # of valid blocks in main area */ 210 block_t written_valid_blocks; /* # of valid blocks in main area */
205 char *sit_bitmap; /* SIT bitmap pointer */ 211 char *sit_bitmap; /* SIT bitmap pointer */
212#ifdef CONFIG_F2FS_CHECK_FS
213 char *sit_bitmap_mir; /* SIT bitmap mirror */
214#endif
206 unsigned int bitmap_size; /* SIT bitmap size */ 215 unsigned int bitmap_size; /* SIT bitmap size */
207 216
208 unsigned long *tmp_map; /* bitmap for temporal use */ 217 unsigned long *tmp_map; /* bitmap for temporal use */
@@ -317,6 +326,9 @@ static inline void seg_info_from_raw_sit(struct seg_entry *se,
317 se->ckpt_valid_blocks = GET_SIT_VBLOCKS(rs); 326 se->ckpt_valid_blocks = GET_SIT_VBLOCKS(rs);
318 memcpy(se->cur_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE); 327 memcpy(se->cur_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
319 memcpy(se->ckpt_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE); 328 memcpy(se->ckpt_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
329#ifdef CONFIG_F2FS_CHECK_FS
330 memcpy(se->cur_valid_map_mir, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
331#endif
320 se->type = GET_SIT_TYPE(rs); 332 se->type = GET_SIT_TYPE(rs);
321 se->mtime = le64_to_cpu(rs->mtime); 333 se->mtime = le64_to_cpu(rs->mtime);
322} 334}
@@ -414,6 +426,12 @@ static inline void get_sit_bitmap(struct f2fs_sb_info *sbi,
414 void *dst_addr) 426 void *dst_addr)
415{ 427{
416 struct sit_info *sit_i = SIT_I(sbi); 428 struct sit_info *sit_i = SIT_I(sbi);
429
430#ifdef CONFIG_F2FS_CHECK_FS
431 if (memcmp(sit_i->sit_bitmap, sit_i->sit_bitmap_mir,
432 sit_i->bitmap_size))
433 f2fs_bug_on(sbi, 1);
434#endif
417 memcpy(dst_addr, sit_i->sit_bitmap, sit_i->bitmap_size); 435 memcpy(dst_addr, sit_i->sit_bitmap, sit_i->bitmap_size);
418} 436}
419 437
@@ -634,6 +652,12 @@ static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,
634 652
635 check_seg_range(sbi, start); 653 check_seg_range(sbi, start);
636 654
655#ifdef CONFIG_F2FS_CHECK_FS
656 if (f2fs_test_bit(offset, sit_i->sit_bitmap) !=
657 f2fs_test_bit(offset, sit_i->sit_bitmap_mir))
658 f2fs_bug_on(sbi, 1);
659#endif
660
637 /* calculate sit block address */ 661 /* calculate sit block address */
638 if (f2fs_test_bit(offset, sit_i->sit_bitmap)) 662 if (f2fs_test_bit(offset, sit_i->sit_bitmap))
639 blk_addr += sit_i->sit_blocks; 663 blk_addr += sit_i->sit_blocks;
@@ -659,6 +683,9 @@ static inline void set_to_next_sit(struct sit_info *sit_i, unsigned int start)
659 unsigned int block_off = SIT_BLOCK_OFFSET(start); 683 unsigned int block_off = SIT_BLOCK_OFFSET(start);
660 684
661 f2fs_change_bit(block_off, sit_i->sit_bitmap); 685 f2fs_change_bit(block_off, sit_i->sit_bitmap);
686#ifdef CONFIG_F2FS_CHECK_FS
687 f2fs_change_bit(block_off, sit_i->sit_bitmap_mir);
688#endif
662} 689}
663 690
664static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi) 691static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
@@ -689,6 +716,15 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
689 - (base + 1) + type; 716 - (base + 1) + type;
690} 717}
691 718
719static inline bool no_fggc_candidate(struct f2fs_sb_info *sbi,
720 unsigned int secno)
721{
722 if (get_valid_blocks(sbi, secno, sbi->segs_per_sec) >=
723 sbi->fggc_threshold)
724 return true;
725 return false;
726}
727
692static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno) 728static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno)
693{ 729{
694 if (IS_CURSEC(sbi, secno) || (sbi->cur_victim_sec == secno)) 730 if (IS_CURSEC(sbi, secno) || (sbi->cur_victim_sec == secno))
@@ -700,8 +736,8 @@ static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno)
700 * It is very important to gather dirty pages and write at once, so that we can 736 * It is very important to gather dirty pages and write at once, so that we can
701 * submit a big bio without interfering other data writes. 737 * submit a big bio without interfering other data writes.
702 * By default, 512 pages for directory data, 738 * By default, 512 pages for directory data,
703 * 512 pages (2MB) * 3 for three types of nodes, and 739 * 512 pages (2MB) * 8 for nodes, and
704 * max_bio_blocks for meta are set. 740 * 256 pages * 8 for meta are set.
705 */ 741 */
706static inline int nr_pages_to_skip(struct f2fs_sb_info *sbi, int type) 742static inline int nr_pages_to_skip(struct f2fs_sb_info *sbi, int type)
707{ 743{
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a831303bb777..96fe8ed73100 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -89,6 +89,7 @@ enum {
89 Opt_active_logs, 89 Opt_active_logs,
90 Opt_disable_ext_identify, 90 Opt_disable_ext_identify,
91 Opt_inline_xattr, 91 Opt_inline_xattr,
92 Opt_noinline_xattr,
92 Opt_inline_data, 93 Opt_inline_data,
93 Opt_inline_dentry, 94 Opt_inline_dentry,
94 Opt_noinline_dentry, 95 Opt_noinline_dentry,
@@ -101,6 +102,7 @@ enum {
101 Opt_noinline_data, 102 Opt_noinline_data,
102 Opt_data_flush, 103 Opt_data_flush,
103 Opt_mode, 104 Opt_mode,
105 Opt_io_size_bits,
104 Opt_fault_injection, 106 Opt_fault_injection,
105 Opt_lazytime, 107 Opt_lazytime,
106 Opt_nolazytime, 108 Opt_nolazytime,
@@ -121,6 +123,7 @@ static match_table_t f2fs_tokens = {
121 {Opt_active_logs, "active_logs=%u"}, 123 {Opt_active_logs, "active_logs=%u"},
122 {Opt_disable_ext_identify, "disable_ext_identify"}, 124 {Opt_disable_ext_identify, "disable_ext_identify"},
123 {Opt_inline_xattr, "inline_xattr"}, 125 {Opt_inline_xattr, "inline_xattr"},
126 {Opt_noinline_xattr, "noinline_xattr"},
124 {Opt_inline_data, "inline_data"}, 127 {Opt_inline_data, "inline_data"},
125 {Opt_inline_dentry, "inline_dentry"}, 128 {Opt_inline_dentry, "inline_dentry"},
126 {Opt_noinline_dentry, "noinline_dentry"}, 129 {Opt_noinline_dentry, "noinline_dentry"},
@@ -133,6 +136,7 @@ static match_table_t f2fs_tokens = {
133 {Opt_noinline_data, "noinline_data"}, 136 {Opt_noinline_data, "noinline_data"},
134 {Opt_data_flush, "data_flush"}, 137 {Opt_data_flush, "data_flush"},
135 {Opt_mode, "mode=%s"}, 138 {Opt_mode, "mode=%s"},
139 {Opt_io_size_bits, "io_bits=%u"},
136 {Opt_fault_injection, "fault_injection=%u"}, 140 {Opt_fault_injection, "fault_injection=%u"},
137 {Opt_lazytime, "lazytime"}, 141 {Opt_lazytime, "lazytime"},
138 {Opt_nolazytime, "nolazytime"}, 142 {Opt_nolazytime, "nolazytime"},
@@ -143,6 +147,7 @@ static match_table_t f2fs_tokens = {
143enum { 147enum {
144 GC_THREAD, /* struct f2fs_gc_thread */ 148 GC_THREAD, /* struct f2fs_gc_thread */
145 SM_INFO, /* struct f2fs_sm_info */ 149 SM_INFO, /* struct f2fs_sm_info */
150 DCC_INFO, /* struct discard_cmd_control */
146 NM_INFO, /* struct f2fs_nm_info */ 151 NM_INFO, /* struct f2fs_nm_info */
147 F2FS_SBI, /* struct f2fs_sb_info */ 152 F2FS_SBI, /* struct f2fs_sb_info */
148#ifdef CONFIG_F2FS_FAULT_INJECTION 153#ifdef CONFIG_F2FS_FAULT_INJECTION
@@ -166,6 +171,8 @@ static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)
166 return (unsigned char *)sbi->gc_thread; 171 return (unsigned char *)sbi->gc_thread;
167 else if (struct_type == SM_INFO) 172 else if (struct_type == SM_INFO)
168 return (unsigned char *)SM_I(sbi); 173 return (unsigned char *)SM_I(sbi);
174 else if (struct_type == DCC_INFO)
175 return (unsigned char *)SM_I(sbi)->dcc_info;
169 else if (struct_type == NM_INFO) 176 else if (struct_type == NM_INFO)
170 return (unsigned char *)NM_I(sbi); 177 return (unsigned char *)NM_I(sbi);
171 else if (struct_type == F2FS_SBI) 178 else if (struct_type == F2FS_SBI)
@@ -281,7 +288,7 @@ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_max_sleep_time, max_sleep_time);
281F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time); 288F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time);
282F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle); 289F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle);
283F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments); 290F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
284F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, max_small_discards, max_discards); 291F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards);
285F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections); 292F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections);
286F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy); 293F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);
287F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util); 294F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util);
@@ -439,6 +446,9 @@ static int parse_options(struct super_block *sb, char *options)
439 case Opt_inline_xattr: 446 case Opt_inline_xattr:
440 set_opt(sbi, INLINE_XATTR); 447 set_opt(sbi, INLINE_XATTR);
441 break; 448 break;
449 case Opt_noinline_xattr:
450 clear_opt(sbi, INLINE_XATTR);
451 break;
442#else 452#else
443 case Opt_user_xattr: 453 case Opt_user_xattr:
444 f2fs_msg(sb, KERN_INFO, 454 f2fs_msg(sb, KERN_INFO,
@@ -452,6 +462,10 @@ static int parse_options(struct super_block *sb, char *options)
452 f2fs_msg(sb, KERN_INFO, 462 f2fs_msg(sb, KERN_INFO,
453 "inline_xattr options not supported"); 463 "inline_xattr options not supported");
454 break; 464 break;
465 case Opt_noinline_xattr:
466 f2fs_msg(sb, KERN_INFO,
467 "noinline_xattr options not supported");
468 break;
455#endif 469#endif
456#ifdef CONFIG_F2FS_FS_POSIX_ACL 470#ifdef CONFIG_F2FS_FS_POSIX_ACL
457 case Opt_acl: 471 case Opt_acl:
@@ -535,11 +549,23 @@ static int parse_options(struct super_block *sb, char *options)
535 } 549 }
536 kfree(name); 550 kfree(name);
537 break; 551 break;
552 case Opt_io_size_bits:
553 if (args->from && match_int(args, &arg))
554 return -EINVAL;
555 if (arg > __ilog2_u32(BIO_MAX_PAGES)) {
556 f2fs_msg(sb, KERN_WARNING,
557 "Not support %d, larger than %d",
558 1 << arg, BIO_MAX_PAGES);
559 return -EINVAL;
560 }
561 sbi->write_io_size_bits = arg;
562 break;
538 case Opt_fault_injection: 563 case Opt_fault_injection:
539 if (args->from && match_int(args, &arg)) 564 if (args->from && match_int(args, &arg))
540 return -EINVAL; 565 return -EINVAL;
541#ifdef CONFIG_F2FS_FAULT_INJECTION 566#ifdef CONFIG_F2FS_FAULT_INJECTION
542 f2fs_build_fault_attr(sbi, arg); 567 f2fs_build_fault_attr(sbi, arg);
568 set_opt(sbi, FAULT_INJECTION);
543#else 569#else
544 f2fs_msg(sb, KERN_INFO, 570 f2fs_msg(sb, KERN_INFO,
545 "FAULT_INJECTION was not selected"); 571 "FAULT_INJECTION was not selected");
@@ -558,6 +584,13 @@ static int parse_options(struct super_block *sb, char *options)
558 return -EINVAL; 584 return -EINVAL;
559 } 585 }
560 } 586 }
587
588 if (F2FS_IO_SIZE_BITS(sbi) && !test_opt(sbi, LFS)) {
589 f2fs_msg(sb, KERN_ERR,
590 "Should set mode=lfs with %uKB-sized IO",
591 F2FS_IO_SIZE_KB(sbi));
592 return -EINVAL;
593 }
561 return 0; 594 return 0;
562} 595}
563 596
@@ -591,6 +624,7 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
591 624
592static int f2fs_drop_inode(struct inode *inode) 625static int f2fs_drop_inode(struct inode *inode)
593{ 626{
627 int ret;
594 /* 628 /*
595 * This is to avoid a deadlock condition like below. 629 * This is to avoid a deadlock condition like below.
596 * writeback_single_inode(inode) 630 * writeback_single_inode(inode)
@@ -623,10 +657,12 @@ static int f2fs_drop_inode(struct inode *inode)
623 spin_lock(&inode->i_lock); 657 spin_lock(&inode->i_lock);
624 atomic_dec(&inode->i_count); 658 atomic_dec(&inode->i_count);
625 } 659 }
660 trace_f2fs_drop_inode(inode, 0);
626 return 0; 661 return 0;
627 } 662 }
628 663 ret = generic_drop_inode(inode);
629 return generic_drop_inode(inode); 664 trace_f2fs_drop_inode(inode, ret);
665 return ret;
630} 666}
631 667
632int f2fs_inode_dirtied(struct inode *inode, bool sync) 668int f2fs_inode_dirtied(struct inode *inode, bool sync)
@@ -750,6 +786,9 @@ static void f2fs_put_super(struct super_block *sb)
750 write_checkpoint(sbi, &cpc); 786 write_checkpoint(sbi, &cpc);
751 } 787 }
752 788
789 /* be sure to wait for any on-going discard commands */
790 f2fs_wait_discard_bio(sbi, NULL_ADDR);
791
753 /* write_checkpoint can update stat informaion */ 792 /* write_checkpoint can update stat informaion */
754 f2fs_destroy_stats(sbi); 793 f2fs_destroy_stats(sbi);
755 794
@@ -782,7 +821,7 @@ static void f2fs_put_super(struct super_block *sb)
782 kfree(sbi->raw_super); 821 kfree(sbi->raw_super);
783 822
784 destroy_device_list(sbi); 823 destroy_device_list(sbi);
785 824 mempool_destroy(sbi->write_io_dummy);
786 destroy_percpu_info(sbi); 825 destroy_percpu_info(sbi);
787 kfree(sbi); 826 kfree(sbi);
788} 827}
@@ -882,6 +921,8 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
882 seq_puts(seq, ",nouser_xattr"); 921 seq_puts(seq, ",nouser_xattr");
883 if (test_opt(sbi, INLINE_XATTR)) 922 if (test_opt(sbi, INLINE_XATTR))
884 seq_puts(seq, ",inline_xattr"); 923 seq_puts(seq, ",inline_xattr");
924 else
925 seq_puts(seq, ",noinline_xattr");
885#endif 926#endif
886#ifdef CONFIG_F2FS_FS_POSIX_ACL 927#ifdef CONFIG_F2FS_FS_POSIX_ACL
887 if (test_opt(sbi, POSIX_ACL)) 928 if (test_opt(sbi, POSIX_ACL))
@@ -918,6 +959,12 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
918 else if (test_opt(sbi, LFS)) 959 else if (test_opt(sbi, LFS))
919 seq_puts(seq, "lfs"); 960 seq_puts(seq, "lfs");
920 seq_printf(seq, ",active_logs=%u", sbi->active_logs); 961 seq_printf(seq, ",active_logs=%u", sbi->active_logs);
962 if (F2FS_IO_SIZE_BITS(sbi))
963 seq_printf(seq, ",io_size=%uKB", F2FS_IO_SIZE_KB(sbi));
964#ifdef CONFIG_F2FS_FAULT_INJECTION
965 if (test_opt(sbi, FAULT_INJECTION))
966 seq_puts(seq, ",fault_injection");
967#endif
921 968
922 return 0; 969 return 0;
923} 970}
@@ -995,6 +1042,7 @@ static void default_options(struct f2fs_sb_info *sbi)
995 sbi->active_logs = NR_CURSEG_TYPE; 1042 sbi->active_logs = NR_CURSEG_TYPE;
996 1043
997 set_opt(sbi, BG_GC); 1044 set_opt(sbi, BG_GC);
1045 set_opt(sbi, INLINE_XATTR);
998 set_opt(sbi, INLINE_DATA); 1046 set_opt(sbi, INLINE_DATA);
999 set_opt(sbi, INLINE_DENTRY); 1047 set_opt(sbi, INLINE_DENTRY);
1000 set_opt(sbi, EXTENT_CACHE); 1048 set_opt(sbi, EXTENT_CACHE);
@@ -1686,36 +1734,55 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover)
1686static int f2fs_scan_devices(struct f2fs_sb_info *sbi) 1734static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
1687{ 1735{
1688 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); 1736 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
1737 unsigned int max_devices = MAX_DEVICES;
1689 int i; 1738 int i;
1690 1739
1691 for (i = 0; i < MAX_DEVICES; i++) { 1740 /* Initialize single device information */
1692 if (!RDEV(i).path[0]) 1741 if (!RDEV(0).path[0]) {
1742 if (!bdev_is_zoned(sbi->sb->s_bdev))
1693 return 0; 1743 return 0;
1744 max_devices = 1;
1745 }
1694 1746
1695 if (i == 0) { 1747 /*
1696 sbi->devs = kzalloc(sizeof(struct f2fs_dev_info) * 1748 * Initialize multiple devices information, or single
1697 MAX_DEVICES, GFP_KERNEL); 1749 * zoned block device information.
1698 if (!sbi->devs) 1750 */
1699 return -ENOMEM; 1751 sbi->devs = kcalloc(max_devices, sizeof(struct f2fs_dev_info),
1700 } 1752 GFP_KERNEL);
1753 if (!sbi->devs)
1754 return -ENOMEM;
1701 1755
1702 memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN); 1756 for (i = 0; i < max_devices; i++) {
1703 FDEV(i).total_segments = le32_to_cpu(RDEV(i).total_segments);
1704 if (i == 0) {
1705 FDEV(i).start_blk = 0;
1706 FDEV(i).end_blk = FDEV(i).start_blk +
1707 (FDEV(i).total_segments <<
1708 sbi->log_blocks_per_seg) - 1 +
1709 le32_to_cpu(raw_super->segment0_blkaddr);
1710 } else {
1711 FDEV(i).start_blk = FDEV(i - 1).end_blk + 1;
1712 FDEV(i).end_blk = FDEV(i).start_blk +
1713 (FDEV(i).total_segments <<
1714 sbi->log_blocks_per_seg) - 1;
1715 }
1716 1757
1717 FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path, 1758 if (i > 0 && !RDEV(i).path[0])
1759 break;
1760
1761 if (max_devices == 1) {
1762 /* Single zoned block device mount */
1763 FDEV(0).bdev =
1764 blkdev_get_by_dev(sbi->sb->s_bdev->bd_dev,
1765 sbi->sb->s_mode, sbi->sb->s_type);
1766 } else {
1767 /* Multi-device mount */
1768 memcpy(FDEV(i).path, RDEV(i).path, MAX_PATH_LEN);
1769 FDEV(i).total_segments =
1770 le32_to_cpu(RDEV(i).total_segments);
1771 if (i == 0) {
1772 FDEV(i).start_blk = 0;
1773 FDEV(i).end_blk = FDEV(i).start_blk +
1774 (FDEV(i).total_segments <<
1775 sbi->log_blocks_per_seg) - 1 +
1776 le32_to_cpu(raw_super->segment0_blkaddr);
1777 } else {
1778 FDEV(i).start_blk = FDEV(i - 1).end_blk + 1;
1779 FDEV(i).end_blk = FDEV(i).start_blk +
1780 (FDEV(i).total_segments <<
1781 sbi->log_blocks_per_seg) - 1;
1782 }
1783 FDEV(i).bdev = blkdev_get_by_path(FDEV(i).path,
1718 sbi->sb->s_mode, sbi->sb->s_type); 1784 sbi->sb->s_mode, sbi->sb->s_type);
1785 }
1719 if (IS_ERR(FDEV(i).bdev)) 1786 if (IS_ERR(FDEV(i).bdev))
1720 return PTR_ERR(FDEV(i).bdev); 1787 return PTR_ERR(FDEV(i).bdev);
1721 1788
@@ -1735,6 +1802,8 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
1735 "Failed to initialize F2FS blkzone information"); 1802 "Failed to initialize F2FS blkzone information");
1736 return -EINVAL; 1803 return -EINVAL;
1737 } 1804 }
1805 if (max_devices == 1)
1806 break;
1738 f2fs_msg(sbi->sb, KERN_INFO, 1807 f2fs_msg(sbi->sb, KERN_INFO,
1739 "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)", 1808 "Mount Device [%2d]: %20s, %8u, %8x - %8x (zone: %s)",
1740 i, FDEV(i).path, 1809 i, FDEV(i).path,
@@ -1751,6 +1820,8 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
1751 FDEV(i).total_segments, 1820 FDEV(i).total_segments,
1752 FDEV(i).start_blk, FDEV(i).end_blk); 1821 FDEV(i).start_blk, FDEV(i).end_blk);
1753 } 1822 }
1823 f2fs_msg(sbi->sb, KERN_INFO,
1824 "IO Block Size: %8d KB", F2FS_IO_SIZE_KB(sbi));
1754 return 0; 1825 return 0;
1755} 1826}
1756 1827
@@ -1868,12 +1939,19 @@ try_onemore:
1868 if (err) 1939 if (err)
1869 goto free_options; 1940 goto free_options;
1870 1941
1942 if (F2FS_IO_SIZE(sbi) > 1) {
1943 sbi->write_io_dummy =
1944 mempool_create_page_pool(2 * (F2FS_IO_SIZE(sbi) - 1), 0);
1945 if (!sbi->write_io_dummy)
1946 goto free_options;
1947 }
1948
1871 /* get an inode for meta space */ 1949 /* get an inode for meta space */
1872 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi)); 1950 sbi->meta_inode = f2fs_iget(sb, F2FS_META_INO(sbi));
1873 if (IS_ERR(sbi->meta_inode)) { 1951 if (IS_ERR(sbi->meta_inode)) {
1874 f2fs_msg(sb, KERN_ERR, "Failed to read F2FS meta data inode"); 1952 f2fs_msg(sb, KERN_ERR, "Failed to read F2FS meta data inode");
1875 err = PTR_ERR(sbi->meta_inode); 1953 err = PTR_ERR(sbi->meta_inode);
1876 goto free_options; 1954 goto free_io_dummy;
1877 } 1955 }
1878 1956
1879 err = get_valid_checkpoint(sbi); 1957 err = get_valid_checkpoint(sbi);
@@ -2048,6 +2126,8 @@ skip_recovery:
2048 sbi->valid_super_block ? 1 : 2, err); 2126 sbi->valid_super_block ? 1 : 2, err);
2049 } 2127 }
2050 2128
2129 f2fs_msg(sbi->sb, KERN_NOTICE, "Mounted with checkpoint version = %llx",
2130 cur_cp_version(F2FS_CKPT(sbi)));
2051 f2fs_update_time(sbi, CP_TIME); 2131 f2fs_update_time(sbi, CP_TIME);
2052 f2fs_update_time(sbi, REQ_TIME); 2132 f2fs_update_time(sbi, REQ_TIME);
2053 return 0; 2133 return 0;
@@ -2091,6 +2171,8 @@ free_devices:
2091free_meta_inode: 2171free_meta_inode:
2092 make_bad_inode(sbi->meta_inode); 2172 make_bad_inode(sbi->meta_inode);
2093 iput(sbi->meta_inode); 2173 iput(sbi->meta_inode);
2174free_io_dummy:
2175 mempool_destroy(sbi->write_io_dummy);
2094free_options: 2176free_options:
2095 destroy_percpu_info(sbi); 2177 destroy_percpu_info(sbi);
2096 kfree(options); 2178 kfree(options);
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index c47ce2f330a1..7298a4488f7f 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -217,6 +217,112 @@ static struct f2fs_xattr_entry *__find_xattr(void *base_addr, int index,
217 return entry; 217 return entry;
218} 218}
219 219
220static struct f2fs_xattr_entry *__find_inline_xattr(void *base_addr,
221 void **last_addr, int index,
222 size_t len, const char *name)
223{
224 struct f2fs_xattr_entry *entry;
225 unsigned int inline_size = F2FS_INLINE_XATTR_ADDRS << 2;
226
227 list_for_each_xattr(entry, base_addr) {
228 if ((void *)entry + sizeof(__u32) > base_addr + inline_size ||
229 (void *)XATTR_NEXT_ENTRY(entry) + sizeof(__u32) >
230 base_addr + inline_size) {
231 *last_addr = entry;
232 return NULL;
233 }
234 if (entry->e_name_index != index)
235 continue;
236 if (entry->e_name_len != len)
237 continue;
238 if (!memcmp(entry->e_name, name, len))
239 break;
240 }
241 return entry;
242}
243
244static int lookup_all_xattrs(struct inode *inode, struct page *ipage,
245 unsigned int index, unsigned int len,
246 const char *name, struct f2fs_xattr_entry **xe,
247 void **base_addr)
248{
249 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
250 void *cur_addr, *txattr_addr, *last_addr = NULL;
251 nid_t xnid = F2FS_I(inode)->i_xattr_nid;
252 unsigned int size = xnid ? VALID_XATTR_BLOCK_SIZE : 0;
253 unsigned int inline_size = 0;
254 int err = 0;
255
256 inline_size = inline_xattr_size(inode);
257
258 if (!size && !inline_size)
259 return -ENODATA;
260
261 txattr_addr = kzalloc(inline_size + size + sizeof(__u32),
262 GFP_F2FS_ZERO);
263 if (!txattr_addr)
264 return -ENOMEM;
265
266 /* read from inline xattr */
267 if (inline_size) {
268 struct page *page = NULL;
269 void *inline_addr;
270
271 if (ipage) {
272 inline_addr = inline_xattr_addr(ipage);
273 } else {
274 page = get_node_page(sbi, inode->i_ino);
275 if (IS_ERR(page)) {
276 err = PTR_ERR(page);
277 goto out;
278 }
279 inline_addr = inline_xattr_addr(page);
280 }
281 memcpy(txattr_addr, inline_addr, inline_size);
282 f2fs_put_page(page, 1);
283
284 *xe = __find_inline_xattr(txattr_addr, &last_addr,
285 index, len, name);
286 if (*xe)
287 goto check;
288 }
289
290 /* read from xattr node block */
291 if (xnid) {
292 struct page *xpage;
293 void *xattr_addr;
294
295 /* The inode already has an extended attribute block. */
296 xpage = get_node_page(sbi, xnid);
297 if (IS_ERR(xpage)) {
298 err = PTR_ERR(xpage);
299 goto out;
300 }
301
302 xattr_addr = page_address(xpage);
303 memcpy(txattr_addr + inline_size, xattr_addr, size);
304 f2fs_put_page(xpage, 1);
305 }
306
307 if (last_addr)
308 cur_addr = XATTR_HDR(last_addr) - 1;
309 else
310 cur_addr = txattr_addr;
311
312 *xe = __find_xattr(cur_addr, index, len, name);
313check:
314 if (IS_XATTR_LAST_ENTRY(*xe)) {
315 err = -ENODATA;
316 goto out;
317 }
318
319 *base_addr = txattr_addr;
320 return 0;
321out:
322 kzfree(txattr_addr);
323 return err;
324}
325
220static int read_all_xattrs(struct inode *inode, struct page *ipage, 326static int read_all_xattrs(struct inode *inode, struct page *ipage,
221 void **base_addr) 327 void **base_addr)
222{ 328{
@@ -348,23 +454,20 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
348 } 454 }
349 455
350 xattr_addr = page_address(xpage); 456 xattr_addr = page_address(xpage);
351 memcpy(xattr_addr, txattr_addr + inline_size, PAGE_SIZE - 457 memcpy(xattr_addr, txattr_addr + inline_size, MAX_XATTR_BLOCK_SIZE);
352 sizeof(struct node_footer));
353 set_page_dirty(xpage); 458 set_page_dirty(xpage);
354 f2fs_put_page(xpage, 1); 459 f2fs_put_page(xpage, 1);
355 460
356 /* need to checkpoint during fsync */
357 F2FS_I(inode)->xattr_ver = cur_cp_version(F2FS_CKPT(sbi));
358 return 0; 461 return 0;
359} 462}
360 463
361int f2fs_getxattr(struct inode *inode, int index, const char *name, 464int f2fs_getxattr(struct inode *inode, int index, const char *name,
362 void *buffer, size_t buffer_size, struct page *ipage) 465 void *buffer, size_t buffer_size, struct page *ipage)
363{ 466{
364 struct f2fs_xattr_entry *entry; 467 struct f2fs_xattr_entry *entry = NULL;
365 void *base_addr;
366 int error = 0; 468 int error = 0;
367 size_t size, len; 469 unsigned int size, len;
470 void *base_addr = NULL;
368 471
369 if (name == NULL) 472 if (name == NULL)
370 return -EINVAL; 473 return -EINVAL;
@@ -373,21 +476,16 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
373 if (len > F2FS_NAME_LEN) 476 if (len > F2FS_NAME_LEN)
374 return -ERANGE; 477 return -ERANGE;
375 478
376 error = read_all_xattrs(inode, ipage, &base_addr); 479 error = lookup_all_xattrs(inode, ipage, index, len, name,
480 &entry, &base_addr);
377 if (error) 481 if (error)
378 return error; 482 return error;
379 483
380 entry = __find_xattr(base_addr, index, len, name);
381 if (IS_XATTR_LAST_ENTRY(entry)) {
382 error = -ENODATA;
383 goto cleanup;
384 }
385
386 size = le16_to_cpu(entry->e_value_size); 484 size = le16_to_cpu(entry->e_value_size);
387 485
388 if (buffer && size > buffer_size) { 486 if (buffer && size > buffer_size) {
389 error = -ERANGE; 487 error = -ERANGE;
390 goto cleanup; 488 goto out;
391 } 489 }
392 490
393 if (buffer) { 491 if (buffer) {
@@ -395,8 +493,7 @@ int f2fs_getxattr(struct inode *inode, int index, const char *name,
395 memcpy(buffer, pval, size); 493 memcpy(buffer, pval, size);
396 } 494 }
397 error = size; 495 error = size;
398 496out:
399cleanup:
400 kzfree(base_addr); 497 kzfree(base_addr);
401 return error; 498 return error;
402} 499}
@@ -445,6 +542,13 @@ cleanup:
445 return error; 542 return error;
446} 543}
447 544
545static bool f2fs_xattr_value_same(struct f2fs_xattr_entry *entry,
546 const void *value, size_t size)
547{
548 void *pval = entry->e_name + entry->e_name_len;
549 return (entry->e_value_size == size) && !memcmp(pval, value, size);
550}
551
448static int __f2fs_setxattr(struct inode *inode, int index, 552static int __f2fs_setxattr(struct inode *inode, int index,
449 const char *name, const void *value, size_t size, 553 const char *name, const void *value, size_t size,
450 struct page *ipage, int flags) 554 struct page *ipage, int flags)
@@ -479,12 +583,17 @@ static int __f2fs_setxattr(struct inode *inode, int index,
479 583
480 found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1; 584 found = IS_XATTR_LAST_ENTRY(here) ? 0 : 1;
481 585
482 if ((flags & XATTR_REPLACE) && !found) { 586 if (found) {
587 if ((flags & XATTR_CREATE)) {
588 error = -EEXIST;
589 goto exit;
590 }
591
592 if (f2fs_xattr_value_same(here, value, size))
593 goto exit;
594 } else if ((flags & XATTR_REPLACE)) {
483 error = -ENODATA; 595 error = -ENODATA;
484 goto exit; 596 goto exit;
485 } else if ((flags & XATTR_CREATE) && found) {
486 error = -EEXIST;
487 goto exit;
488 } 597 }
489 598
490 last = here; 599 last = here;
diff --git a/fs/f2fs/xattr.h b/fs/f2fs/xattr.h
index f990de20cdcd..d5a94928c116 100644
--- a/fs/f2fs/xattr.h
+++ b/fs/f2fs/xattr.h
@@ -72,9 +72,10 @@ struct f2fs_xattr_entry {
72 for (entry = XATTR_FIRST_ENTRY(addr);\ 72 for (entry = XATTR_FIRST_ENTRY(addr);\
73 !IS_XATTR_LAST_ENTRY(entry);\ 73 !IS_XATTR_LAST_ENTRY(entry);\
74 entry = XATTR_NEXT_ENTRY(entry)) 74 entry = XATTR_NEXT_ENTRY(entry))
75 75#define MAX_XATTR_BLOCK_SIZE (PAGE_SIZE - sizeof(struct node_footer))
76#define MIN_OFFSET(i) XATTR_ALIGN(inline_xattr_size(i) + PAGE_SIZE - \ 76#define VALID_XATTR_BLOCK_SIZE (MAX_XATTR_BLOCK_SIZE - sizeof(__u32))
77 sizeof(struct node_footer) - sizeof(__u32)) 77#define MIN_OFFSET(i) XATTR_ALIGN(inline_xattr_size(i) + \
78 VALID_XATTR_BLOCK_SIZE)
78 79
79#define MAX_VALUE_LEN(i) (MIN_OFFSET(i) - \ 80#define MAX_VALUE_LEN(i) (MIN_OFFSET(i) - \
80 sizeof(struct f2fs_xattr_header) - \ 81 sizeof(struct f2fs_xattr_header) - \
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c
index 6de15709d024..2ae676f93e6b 100644
--- a/fs/nfs/cache_lib.c
+++ b/fs/nfs/cache_lib.c
@@ -141,8 +141,7 @@ int nfs_cache_register_net(struct net *net, struct cache_detail *cd)
141 141
142void nfs_cache_unregister_sb(struct super_block *sb, struct cache_detail *cd) 142void nfs_cache_unregister_sb(struct super_block *sb, struct cache_detail *cd)
143{ 143{
144 if (cd->u.pipefs.dir) 144 sunrpc_cache_unregister_pipefs(cd);
145 sunrpc_cache_unregister_pipefs(cd);
146} 145}
147 146
148void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd) 147void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd)
diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index fd0284c1dc32..d051fc3583a9 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -83,23 +83,15 @@ static __be32 *read_buf(struct xdr_stream *xdr, size_t nbytes)
83 return p; 83 return p;
84} 84}
85 85
86static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len, const char **str) 86static __be32 decode_string(struct xdr_stream *xdr, unsigned int *len,
87 const char **str, size_t maxlen)
87{ 88{
88 __be32 *p; 89 ssize_t err;
89
90 p = read_buf(xdr, 4);
91 if (unlikely(p == NULL))
92 return htonl(NFS4ERR_RESOURCE);
93 *len = ntohl(*p);
94
95 if (*len != 0) {
96 p = read_buf(xdr, *len);
97 if (unlikely(p == NULL))
98 return htonl(NFS4ERR_RESOURCE);
99 *str = (const char *)p;
100 } else
101 *str = NULL;
102 90
91 err = xdr_stream_decode_opaque_inline(xdr, (void **)str, maxlen);
92 if (err < 0)
93 return cpu_to_be32(NFS4ERR_RESOURCE);
94 *len = err;
103 return 0; 95 return 0;
104} 96}
105 97
@@ -162,15 +154,9 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
162 __be32 *p; 154 __be32 *p;
163 __be32 status; 155 __be32 status;
164 156
165 status = decode_string(xdr, &hdr->taglen, &hdr->tag); 157 status = decode_string(xdr, &hdr->taglen, &hdr->tag, CB_OP_TAGLEN_MAXSZ);
166 if (unlikely(status != 0)) 158 if (unlikely(status != 0))
167 return status; 159 return status;
168 /* We do not like overly long tags! */
169 if (hdr->taglen > CB_OP_TAGLEN_MAXSZ) {
170 printk("NFS: NFSv4 CALLBACK %s: client sent tag of length %u\n",
171 __func__, hdr->taglen);
172 return htonl(NFS4ERR_RESOURCE);
173 }
174 p = read_buf(xdr, 12); 160 p = read_buf(xdr, 12);
175 if (unlikely(p == NULL)) 161 if (unlikely(p == NULL))
176 return htonl(NFS4ERR_RESOURCE); 162 return htonl(NFS4ERR_RESOURCE);
@@ -582,12 +568,8 @@ out:
582 568
583static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 569static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
584{ 570{
585 __be32 *p; 571 if (unlikely(xdr_stream_encode_opaque(xdr, str, len) < 0))
586 572 return cpu_to_be32(NFS4ERR_RESOURCE);
587 p = xdr_reserve_space(xdr, 4 + len);
588 if (unlikely(p == NULL))
589 return htonl(NFS4ERR_RESOURCE);
590 xdr_encode_opaque(p, str, len);
591 return 0; 573 return 0;
592} 574}
593 575
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index fad81041f5ab..fb499a3f21b5 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2002,6 +2002,29 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
2002} 2002}
2003EXPORT_SYMBOL_GPL(nfs_link); 2003EXPORT_SYMBOL_GPL(nfs_link);
2004 2004
2005static void
2006nfs_complete_rename(struct rpc_task *task, struct nfs_renamedata *data)
2007{
2008 struct dentry *old_dentry = data->old_dentry;
2009 struct dentry *new_dentry = data->new_dentry;
2010 struct inode *old_inode = d_inode(old_dentry);
2011 struct inode *new_inode = d_inode(new_dentry);
2012
2013 nfs_mark_for_revalidate(old_inode);
2014
2015 switch (task->tk_status) {
2016 case 0:
2017 if (new_inode != NULL)
2018 nfs_drop_nlink(new_inode);
2019 d_move(old_dentry, new_dentry);
2020 nfs_set_verifier(new_dentry,
2021 nfs_save_change_attribute(data->new_dir));
2022 break;
2023 case -ENOENT:
2024 nfs_dentry_handle_enoent(old_dentry);
2025 }
2026}
2027
2005/* 2028/*
2006 * RENAME 2029 * RENAME
2007 * FIXME: Some nfsds, like the Linux user space nfsd, may generate a 2030 * FIXME: Some nfsds, like the Linux user space nfsd, may generate a
@@ -2084,7 +2107,8 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2084 if (new_inode != NULL) 2107 if (new_inode != NULL)
2085 NFS_PROTO(new_inode)->return_delegation(new_inode); 2108 NFS_PROTO(new_inode)->return_delegation(new_inode);
2086 2109
2087 task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry, NULL); 2110 task = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry,
2111 nfs_complete_rename);
2088 if (IS_ERR(task)) { 2112 if (IS_ERR(task)) {
2089 error = PTR_ERR(task); 2113 error = PTR_ERR(task);
2090 goto out; 2114 goto out;
@@ -2094,21 +2118,11 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2094 if (error == 0) 2118 if (error == 0)
2095 error = task->tk_status; 2119 error = task->tk_status;
2096 rpc_put_task(task); 2120 rpc_put_task(task);
2097 nfs_mark_for_revalidate(old_inode);
2098out: 2121out:
2099 if (rehash) 2122 if (rehash)
2100 d_rehash(rehash); 2123 d_rehash(rehash);
2101 trace_nfs_rename_exit(old_dir, old_dentry, 2124 trace_nfs_rename_exit(old_dir, old_dentry,
2102 new_dir, new_dentry, error); 2125 new_dir, new_dentry, error);
2103 if (!error) {
2104 if (new_inode != NULL)
2105 nfs_drop_nlink(new_inode);
2106 d_move(old_dentry, new_dentry);
2107 nfs_set_verifier(new_dentry,
2108 nfs_save_change_attribute(new_dir));
2109 } else if (error == -ENOENT)
2110 nfs_dentry_handle_enoent(old_dentry);
2111
2112 /* new dentry created? */ 2126 /* new dentry created? */
2113 if (dentry) 2127 if (dentry)
2114 dput(dentry); 2128 dput(dentry);
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index 18f98e08544d..44347f4bdc15 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -305,7 +305,7 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)
305 } 305 }
306 hdr->pgio_done_cb = filelayout_read_done_cb; 306 hdr->pgio_done_cb = filelayout_read_done_cb;
307 307
308 if (nfs41_setup_sequence(hdr->ds_clp->cl_session, 308 if (nfs4_setup_sequence(hdr->ds_clp,
309 &hdr->args.seq_args, 309 &hdr->args.seq_args,
310 &hdr->res.seq_res, 310 &hdr->res.seq_res,
311 task)) 311 task))
@@ -403,7 +403,7 @@ static void filelayout_write_prepare(struct rpc_task *task, void *data)
403 rpc_exit(task, 0); 403 rpc_exit(task, 0);
404 return; 404 return;
405 } 405 }
406 if (nfs41_setup_sequence(hdr->ds_clp->cl_session, 406 if (nfs4_setup_sequence(hdr->ds_clp,
407 &hdr->args.seq_args, 407 &hdr->args.seq_args,
408 &hdr->res.seq_res, 408 &hdr->res.seq_res,
409 task)) 409 task))
@@ -438,7 +438,7 @@ static void filelayout_commit_prepare(struct rpc_task *task, void *data)
438{ 438{
439 struct nfs_commit_data *wdata = data; 439 struct nfs_commit_data *wdata = data;
440 440
441 nfs41_setup_sequence(wdata->ds_clp->cl_session, 441 nfs4_setup_sequence(wdata->ds_clp,
442 &wdata->args.seq_args, 442 &wdata->args.seq_args,
443 &wdata->res.seq_res, 443 &wdata->res.seq_res,
444 task); 444 task);
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index d6acc688df7e..42dedf2d625f 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1053,9 +1053,6 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
1053 struct nfs_client *mds_client = mds_server->nfs_client; 1053 struct nfs_client *mds_client = mds_server->nfs_client;
1054 struct nfs4_slot_table *tbl = &clp->cl_session->fc_slot_table; 1054 struct nfs4_slot_table *tbl = &clp->cl_session->fc_slot_table;
1055 1055
1056 if (task->tk_status >= 0)
1057 return 0;
1058
1059 switch (task->tk_status) { 1056 switch (task->tk_status) {
1060 /* MDS state errors */ 1057 /* MDS state errors */
1061 case -NFS4ERR_DELEG_REVOKED: 1058 case -NFS4ERR_DELEG_REVOKED:
@@ -1157,9 +1154,6 @@ static int ff_layout_async_handle_error_v3(struct rpc_task *task,
1157{ 1154{
1158 struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx); 1155 struct nfs4_deviceid_node *devid = FF_LAYOUT_DEVID_NODE(lseg, idx);
1159 1156
1160 if (task->tk_status >= 0)
1161 return 0;
1162
1163 switch (task->tk_status) { 1157 switch (task->tk_status) {
1164 /* File access problems. Don't mark the device as unavailable */ 1158 /* File access problems. Don't mark the device as unavailable */
1165 case -EACCES: 1159 case -EACCES:
@@ -1195,6 +1189,13 @@ static int ff_layout_async_handle_error(struct rpc_task *task,
1195{ 1189{
1196 int vers = clp->cl_nfs_mod->rpc_vers->number; 1190 int vers = clp->cl_nfs_mod->rpc_vers->number;
1197 1191
1192 if (task->tk_status >= 0)
1193 return 0;
1194
1195 /* Handle the case of an invalid layout segment */
1196 if (!pnfs_is_valid_lseg(lseg))
1197 return -NFS4ERR_RESET_TO_PNFS;
1198
1198 switch (vers) { 1199 switch (vers) {
1199 case 3: 1200 case 3:
1200 return ff_layout_async_handle_error_v3(task, lseg, idx); 1201 return ff_layout_async_handle_error_v3(task, lseg, idx);
@@ -1384,30 +1385,14 @@ static void ff_layout_read_prepare_v3(struct rpc_task *task, void *data)
1384 rpc_call_start(task); 1385 rpc_call_start(task);
1385} 1386}
1386 1387
1387static int ff_layout_setup_sequence(struct nfs_client *ds_clp,
1388 struct nfs4_sequence_args *args,
1389 struct nfs4_sequence_res *res,
1390 struct rpc_task *task)
1391{
1392 if (ds_clp->cl_session)
1393 return nfs41_setup_sequence(ds_clp->cl_session,
1394 args,
1395 res,
1396 task);
1397 return nfs40_setup_sequence(ds_clp->cl_slot_tbl,
1398 args,
1399 res,
1400 task);
1401}
1402
1403static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data) 1388static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data)
1404{ 1389{
1405 struct nfs_pgio_header *hdr = data; 1390 struct nfs_pgio_header *hdr = data;
1406 1391
1407 if (ff_layout_setup_sequence(hdr->ds_clp, 1392 if (nfs4_setup_sequence(hdr->ds_clp,
1408 &hdr->args.seq_args, 1393 &hdr->args.seq_args,
1409 &hdr->res.seq_res, 1394 &hdr->res.seq_res,
1410 task)) 1395 task))
1411 return; 1396 return;
1412 1397
1413 if (ff_layout_read_prepare_common(task, hdr)) 1398 if (ff_layout_read_prepare_common(task, hdr))
@@ -1578,10 +1563,10 @@ static void ff_layout_write_prepare_v4(struct rpc_task *task, void *data)
1578{ 1563{
1579 struct nfs_pgio_header *hdr = data; 1564 struct nfs_pgio_header *hdr = data;
1580 1565
1581 if (ff_layout_setup_sequence(hdr->ds_clp, 1566 if (nfs4_setup_sequence(hdr->ds_clp,
1582 &hdr->args.seq_args, 1567 &hdr->args.seq_args,
1583 &hdr->res.seq_res, 1568 &hdr->res.seq_res,
1584 task)) 1569 task))
1585 return; 1570 return;
1586 1571
1587 if (ff_layout_write_prepare_common(task, hdr)) 1572 if (ff_layout_write_prepare_common(task, hdr))
@@ -1667,10 +1652,10 @@ static void ff_layout_commit_prepare_v4(struct rpc_task *task, void *data)
1667{ 1652{
1668 struct nfs_commit_data *wdata = data; 1653 struct nfs_commit_data *wdata = data;
1669 1654
1670 if (ff_layout_setup_sequence(wdata->ds_clp, 1655 if (nfs4_setup_sequence(wdata->ds_clp,
1671 &wdata->args.seq_args, 1656 &wdata->args.seq_args,
1672 &wdata->res.seq_res, 1657 &wdata->res.seq_res,
1673 task)) 1658 task))
1674 return; 1659 return;
1675 ff_layout_commit_prepare_common(task, data); 1660 ff_layout_commit_prepare_common(task, data);
1676} 1661}
@@ -1965,10 +1950,7 @@ static int ff_layout_encode_ioerr(struct xdr_stream *xdr,
1965static void 1950static void
1966encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) 1951encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
1967{ 1952{
1968 __be32 *p; 1953 WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
1969
1970 p = xdr_reserve_space(xdr, len);
1971 xdr_encode_opaque_fixed(p, buf, len);
1972} 1954}
1973 1955
1974static void 1956static void
@@ -2092,7 +2074,7 @@ ff_layout_free_layoutreturn(struct nfs4_xdr_opaque_data *args)
2092 kfree(ff_args); 2074 kfree(ff_args);
2093} 2075}
2094 2076
2095const struct nfs4_xdr_opaque_ops layoutreturn_ops = { 2077static const struct nfs4_xdr_opaque_ops layoutreturn_ops = {
2096 .encode = ff_layout_encode_layoutreturn, 2078 .encode = ff_layout_encode_layoutreturn,
2097 .free = ff_layout_free_layoutreturn, 2079 .free = ff_layout_free_layoutreturn,
2098}; 2080};
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index d12ff9385f49..1e486c73ec94 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -12,6 +12,7 @@
12#include "nfs42.h" 12#include "nfs42.h"
13#include "iostat.h" 13#include "iostat.h"
14#include "pnfs.h" 14#include "pnfs.h"
15#include "nfs4session.h"
15#include "internal.h" 16#include "internal.h"
16 17
17#define NFSDBG_FACILITY NFSDBG_PROC 18#define NFSDBG_FACILITY NFSDBG_PROC
@@ -128,30 +129,26 @@ out_unlock:
128 return err; 129 return err;
129} 130}
130 131
131static ssize_t _nfs42_proc_copy(struct file *src, loff_t pos_src, 132static ssize_t _nfs42_proc_copy(struct file *src,
132 struct nfs_lock_context *src_lock, 133 struct nfs_lock_context *src_lock,
133 struct file *dst, loff_t pos_dst, 134 struct file *dst,
134 struct nfs_lock_context *dst_lock, 135 struct nfs_lock_context *dst_lock,
135 size_t count) 136 struct nfs42_copy_args *args,
137 struct nfs42_copy_res *res)
136{ 138{
137 struct nfs42_copy_args args = {
138 .src_fh = NFS_FH(file_inode(src)),
139 .src_pos = pos_src,
140 .dst_fh = NFS_FH(file_inode(dst)),
141 .dst_pos = pos_dst,
142 .count = count,
143 };
144 struct nfs42_copy_res res;
145 struct rpc_message msg = { 139 struct rpc_message msg = {
146 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY], 140 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY],
147 .rpc_argp = &args, 141 .rpc_argp = args,
148 .rpc_resp = &res, 142 .rpc_resp = res,
149 }; 143 };
150 struct inode *dst_inode = file_inode(dst); 144 struct inode *dst_inode = file_inode(dst);
151 struct nfs_server *server = NFS_SERVER(dst_inode); 145 struct nfs_server *server = NFS_SERVER(dst_inode);
146 loff_t pos_src = args->src_pos;
147 loff_t pos_dst = args->dst_pos;
148 size_t count = args->count;
152 int status; 149 int status;
153 150
154 status = nfs4_set_rw_stateid(&args.src_stateid, src_lock->open_context, 151 status = nfs4_set_rw_stateid(&args->src_stateid, src_lock->open_context,
155 src_lock, FMODE_READ); 152 src_lock, FMODE_READ);
156 if (status) 153 if (status)
157 return status; 154 return status;
@@ -161,7 +158,7 @@ static ssize_t _nfs42_proc_copy(struct file *src, loff_t pos_src,
161 if (status) 158 if (status)
162 return status; 159 return status;
163 160
164 status = nfs4_set_rw_stateid(&args.dst_stateid, dst_lock->open_context, 161 status = nfs4_set_rw_stateid(&args->dst_stateid, dst_lock->open_context,
165 dst_lock, FMODE_WRITE); 162 dst_lock, FMODE_WRITE);
166 if (status) 163 if (status)
167 return status; 164 return status;
@@ -171,22 +168,22 @@ static ssize_t _nfs42_proc_copy(struct file *src, loff_t pos_src,
171 return status; 168 return status;
172 169
173 status = nfs4_call_sync(server->client, server, &msg, 170 status = nfs4_call_sync(server->client, server, &msg,
174 &args.seq_args, &res.seq_res, 0); 171 &args->seq_args, &res->seq_res, 0);
175 if (status == -ENOTSUPP) 172 if (status == -ENOTSUPP)
176 server->caps &= ~NFS_CAP_COPY; 173 server->caps &= ~NFS_CAP_COPY;
177 if (status) 174 if (status)
178 return status; 175 return status;
179 176
180 if (res.write_res.verifier.committed != NFS_FILE_SYNC) { 177 if (res->write_res.verifier.committed != NFS_FILE_SYNC) {
181 status = nfs_commit_file(dst, &res.write_res.verifier.verifier); 178 status = nfs_commit_file(dst, &res->write_res.verifier.verifier);
182 if (status) 179 if (status)
183 return status; 180 return status;
184 } 181 }
185 182
186 truncate_pagecache_range(dst_inode, pos_dst, 183 truncate_pagecache_range(dst_inode, pos_dst,
187 pos_dst + res.write_res.count); 184 pos_dst + res->write_res.count);
188 185
189 return res.write_res.count; 186 return res->write_res.count;
190} 187}
191 188
192ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, 189ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
@@ -196,8 +193,22 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
196 struct nfs_server *server = NFS_SERVER(file_inode(dst)); 193 struct nfs_server *server = NFS_SERVER(file_inode(dst));
197 struct nfs_lock_context *src_lock; 194 struct nfs_lock_context *src_lock;
198 struct nfs_lock_context *dst_lock; 195 struct nfs_lock_context *dst_lock;
199 struct nfs4_exception src_exception = { }; 196 struct nfs42_copy_args args = {
200 struct nfs4_exception dst_exception = { }; 197 .src_fh = NFS_FH(file_inode(src)),
198 .src_pos = pos_src,
199 .dst_fh = NFS_FH(file_inode(dst)),
200 .dst_pos = pos_dst,
201 .count = count,
202 };
203 struct nfs42_copy_res res;
204 struct nfs4_exception src_exception = {
205 .inode = file_inode(src),
206 .stateid = &args.src_stateid,
207 };
208 struct nfs4_exception dst_exception = {
209 .inode = file_inode(dst),
210 .stateid = &args.dst_stateid,
211 };
201 ssize_t err, err2; 212 ssize_t err, err2;
202 213
203 if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY)) 214 if (!nfs_server_capable(file_inode(dst), NFS_CAP_COPY))
@@ -207,7 +218,6 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
207 if (IS_ERR(src_lock)) 218 if (IS_ERR(src_lock))
208 return PTR_ERR(src_lock); 219 return PTR_ERR(src_lock);
209 220
210 src_exception.inode = file_inode(src);
211 src_exception.state = src_lock->open_context->state; 221 src_exception.state = src_lock->open_context->state;
212 222
213 dst_lock = nfs_get_lock_context(nfs_file_open_context(dst)); 223 dst_lock = nfs_get_lock_context(nfs_file_open_context(dst));
@@ -216,15 +226,17 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src,
216 goto out_put_src_lock; 226 goto out_put_src_lock;
217 } 227 }
218 228
219 dst_exception.inode = file_inode(dst);
220 dst_exception.state = dst_lock->open_context->state; 229 dst_exception.state = dst_lock->open_context->state;
221 230
222 do { 231 do {
223 inode_lock(file_inode(dst)); 232 inode_lock(file_inode(dst));
224 err = _nfs42_proc_copy(src, pos_src, src_lock, 233 err = _nfs42_proc_copy(src, src_lock,
225 dst, pos_dst, dst_lock, count); 234 dst, dst_lock,
235 &args, &res);
226 inode_unlock(file_inode(dst)); 236 inode_unlock(file_inode(dst));
227 237
238 if (err >= 0)
239 break;
228 if (err == -ENOTSUPP) { 240 if (err == -ENOTSUPP) {
229 err = -EOPNOTSUPP; 241 err = -EOPNOTSUPP;
230 break; 242 break;
@@ -331,9 +343,8 @@ nfs42_layoutstat_prepare(struct rpc_task *task, void *calldata)
331 } 343 }
332 nfs4_stateid_copy(&data->args.stateid, &lo->plh_stateid); 344 nfs4_stateid_copy(&data->args.stateid, &lo->plh_stateid);
333 spin_unlock(&inode->i_lock); 345 spin_unlock(&inode->i_lock);
334 nfs41_setup_sequence(nfs4_get_session(server), &data->args.seq_args, 346 nfs4_setup_sequence(server->nfs_client, &data->args.seq_args,
335 &data->res.seq_res, task); 347 &data->res.seq_res, task);
336
337} 348}
338 349
339static void 350static void
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index 665165833660..af285cc27ccf 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -273,14 +273,6 @@ extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
273 fmode_t fmode); 273 fmode_t fmode);
274 274
275#if defined(CONFIG_NFS_V4_1) 275#if defined(CONFIG_NFS_V4_1)
276static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server)
277{
278 return server->nfs_client->cl_session;
279}
280
281extern int nfs41_setup_sequence(struct nfs4_session *session,
282 struct nfs4_sequence_args *args, struct nfs4_sequence_res *res,
283 struct rpc_task *task);
284extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *); 276extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *);
285extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *); 277extern int nfs4_proc_create_session(struct nfs_client *, struct rpc_cred *);
286extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *); 278extern int nfs4_proc_destroy_session(struct nfs4_session *, struct rpc_cred *);
@@ -357,11 +349,6 @@ nfs4_state_protect_write(struct nfs_client *clp, struct rpc_clnt **clntp,
357 hdr->args.stable = NFS_FILE_SYNC; 349 hdr->args.stable = NFS_FILE_SYNC;
358} 350}
359#else /* CONFIG_NFS_v4_1 */ 351#else /* CONFIG_NFS_v4_1 */
360static inline struct nfs4_session *nfs4_get_session(const struct nfs_server *server)
361{
362 return NULL;
363}
364
365static inline bool 352static inline bool
366is_ds_only_client(struct nfs_client *clp) 353is_ds_only_client(struct nfs_client *clp)
367{ 354{
@@ -466,7 +453,7 @@ extern void nfs_increment_open_seqid(int status, struct nfs_seqid *seqid);
466extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid); 453extern void nfs_increment_lock_seqid(int status, struct nfs_seqid *seqid);
467extern void nfs_release_seqid(struct nfs_seqid *seqid); 454extern void nfs_release_seqid(struct nfs_seqid *seqid);
468extern void nfs_free_seqid(struct nfs_seqid *seqid); 455extern void nfs_free_seqid(struct nfs_seqid *seqid);
469extern int nfs40_setup_sequence(struct nfs4_slot_table *tbl, 456extern int nfs4_setup_sequence(const struct nfs_client *client,
470 struct nfs4_sequence_args *args, 457 struct nfs4_sequence_args *args,
471 struct nfs4_sequence_res *res, 458 struct nfs4_sequence_res *res,
472 struct rpc_task *task); 459 struct rpc_task *task);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 0a0eaecf9676..1b183686c6d4 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -577,12 +577,7 @@ nfs4_async_handle_error(struct rpc_task *task, struct nfs_server *server,
577static bool _nfs4_is_integrity_protected(struct nfs_client *clp) 577static bool _nfs4_is_integrity_protected(struct nfs_client *clp)
578{ 578{
579 rpc_authflavor_t flavor = clp->cl_rpcclient->cl_auth->au_flavor; 579 rpc_authflavor_t flavor = clp->cl_rpcclient->cl_auth->au_flavor;
580 580 return (flavor == RPC_AUTH_GSS_KRB5I) || (flavor == RPC_AUTH_GSS_KRB5P);
581 if (flavor == RPC_AUTH_GSS_KRB5I ||
582 flavor == RPC_AUTH_GSS_KRB5P)
583 return true;
584
585 return false;
586} 581}
587 582
588static void do_renew_lease(struct nfs_client *clp, unsigned long timestamp) 583static void do_renew_lease(struct nfs_client *clp, unsigned long timestamp)
@@ -622,48 +617,6 @@ static void nfs4_set_sequence_privileged(struct nfs4_sequence_args *args)
622 args->sa_privileged = 1; 617 args->sa_privileged = 1;
623} 618}
624 619
625int nfs40_setup_sequence(struct nfs4_slot_table *tbl,
626 struct nfs4_sequence_args *args,
627 struct nfs4_sequence_res *res,
628 struct rpc_task *task)
629{
630 struct nfs4_slot *slot;
631
632 /* slot already allocated? */
633 if (res->sr_slot != NULL)
634 goto out_start;
635
636 spin_lock(&tbl->slot_tbl_lock);
637 if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged)
638 goto out_sleep;
639
640 slot = nfs4_alloc_slot(tbl);
641 if (IS_ERR(slot)) {
642 if (slot == ERR_PTR(-ENOMEM))
643 task->tk_timeout = HZ >> 2;
644 goto out_sleep;
645 }
646 spin_unlock(&tbl->slot_tbl_lock);
647
648 slot->privileged = args->sa_privileged ? 1 : 0;
649 args->sa_slot = slot;
650 res->sr_slot = slot;
651
652out_start:
653 rpc_call_start(task);
654 return 0;
655
656out_sleep:
657 if (args->sa_privileged)
658 rpc_sleep_on_priority(&tbl->slot_tbl_waitq, task,
659 NULL, RPC_PRIORITY_PRIVILEGED);
660 else
661 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
662 spin_unlock(&tbl->slot_tbl_lock);
663 return -EAGAIN;
664}
665EXPORT_SYMBOL_GPL(nfs40_setup_sequence);
666
667static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res) 620static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
668{ 621{
669 struct nfs4_slot *slot = res->sr_slot; 622 struct nfs4_slot *slot = res->sr_slot;
@@ -815,10 +768,6 @@ static int nfs41_sequence_process(struct rpc_task *task,
815 case -NFS4ERR_SEQ_FALSE_RETRY: 768 case -NFS4ERR_SEQ_FALSE_RETRY:
816 ++slot->seq_nr; 769 ++slot->seq_nr;
817 goto retry_nowait; 770 goto retry_nowait;
818 case -NFS4ERR_DEADSESSION:
819 case -NFS4ERR_BADSESSION:
820 nfs4_schedule_session_recovery(session, res->sr_status);
821 goto retry_nowait;
822 default: 771 default:
823 /* Just update the slot sequence no. */ 772 /* Just update the slot sequence no. */
824 slot->seq_done = 1; 773 slot->seq_done = 1;
@@ -882,101 +831,14 @@ int nfs4_sequence_done(struct rpc_task *task, struct nfs4_sequence_res *res)
882} 831}
883EXPORT_SYMBOL_GPL(nfs4_sequence_done); 832EXPORT_SYMBOL_GPL(nfs4_sequence_done);
884 833
885int nfs41_setup_sequence(struct nfs4_session *session,
886 struct nfs4_sequence_args *args,
887 struct nfs4_sequence_res *res,
888 struct rpc_task *task)
889{
890 struct nfs4_slot *slot;
891 struct nfs4_slot_table *tbl;
892
893 dprintk("--> %s\n", __func__);
894 /* slot already allocated? */
895 if (res->sr_slot != NULL)
896 goto out_success;
897
898 tbl = &session->fc_slot_table;
899
900 task->tk_timeout = 0;
901
902 spin_lock(&tbl->slot_tbl_lock);
903 if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state) &&
904 !args->sa_privileged) {
905 /* The state manager will wait until the slot table is empty */
906 dprintk("%s session is draining\n", __func__);
907 goto out_sleep;
908 }
909
910 slot = nfs4_alloc_slot(tbl);
911 if (IS_ERR(slot)) {
912 /* If out of memory, try again in 1/4 second */
913 if (slot == ERR_PTR(-ENOMEM))
914 task->tk_timeout = HZ >> 2;
915 dprintk("<-- %s: no free slots\n", __func__);
916 goto out_sleep;
917 }
918 spin_unlock(&tbl->slot_tbl_lock);
919
920 slot->privileged = args->sa_privileged ? 1 : 0;
921 args->sa_slot = slot;
922
923 dprintk("<-- %s slotid=%u seqid=%u\n", __func__,
924 slot->slot_nr, slot->seq_nr);
925
926 res->sr_slot = slot;
927 res->sr_timestamp = jiffies;
928 res->sr_status_flags = 0;
929 /*
930 * sr_status is only set in decode_sequence, and so will remain
931 * set to 1 if an rpc level failure occurs.
932 */
933 res->sr_status = 1;
934 trace_nfs4_setup_sequence(session, args);
935out_success:
936 rpc_call_start(task);
937 return 0;
938out_sleep:
939 /* Privileged tasks are queued with top priority */
940 if (args->sa_privileged)
941 rpc_sleep_on_priority(&tbl->slot_tbl_waitq, task,
942 NULL, RPC_PRIORITY_PRIVILEGED);
943 else
944 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
945 spin_unlock(&tbl->slot_tbl_lock);
946 return -EAGAIN;
947}
948EXPORT_SYMBOL_GPL(nfs41_setup_sequence);
949
950static int nfs4_setup_sequence(const struct nfs_server *server,
951 struct nfs4_sequence_args *args,
952 struct nfs4_sequence_res *res,
953 struct rpc_task *task)
954{
955 struct nfs4_session *session = nfs4_get_session(server);
956 int ret = 0;
957
958 if (!session)
959 return nfs40_setup_sequence(server->nfs_client->cl_slot_tbl,
960 args, res, task);
961
962 dprintk("--> %s clp %p session %p sr_slot %u\n",
963 __func__, session->clp, session, res->sr_slot ?
964 res->sr_slot->slot_nr : NFS4_NO_SLOT);
965
966 ret = nfs41_setup_sequence(session, args, res, task);
967
968 dprintk("<-- %s status=%d\n", __func__, ret);
969 return ret;
970}
971
972static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata) 834static void nfs41_call_sync_prepare(struct rpc_task *task, void *calldata)
973{ 835{
974 struct nfs4_call_sync_data *data = calldata; 836 struct nfs4_call_sync_data *data = calldata;
975 struct nfs4_session *session = nfs4_get_session(data->seq_server);
976 837
977 dprintk("--> %s data->seq_server %p\n", __func__, data->seq_server); 838 dprintk("--> %s data->seq_server %p\n", __func__, data->seq_server);
978 839
979 nfs41_setup_sequence(session, data->seq_args, data->seq_res, task); 840 nfs4_setup_sequence(data->seq_server->nfs_client,
841 data->seq_args, data->seq_res, task);
980} 842}
981 843
982static void nfs41_call_sync_done(struct rpc_task *task, void *calldata) 844static void nfs41_call_sync_done(struct rpc_task *task, void *calldata)
@@ -993,15 +855,6 @@ static const struct rpc_call_ops nfs41_call_sync_ops = {
993 855
994#else /* !CONFIG_NFS_V4_1 */ 856#else /* !CONFIG_NFS_V4_1 */
995 857
996static int nfs4_setup_sequence(const struct nfs_server *server,
997 struct nfs4_sequence_args *args,
998 struct nfs4_sequence_res *res,
999 struct rpc_task *task)
1000{
1001 return nfs40_setup_sequence(server->nfs_client->cl_slot_tbl,
1002 args, res, task);
1003}
1004
1005static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res) 858static int nfs4_sequence_process(struct rpc_task *task, struct nfs4_sequence_res *res)
1006{ 859{
1007 return nfs40_sequence_done(task, res); 860 return nfs40_sequence_done(task, res);
@@ -1022,10 +875,68 @@ EXPORT_SYMBOL_GPL(nfs4_sequence_done);
1022 875
1023#endif /* !CONFIG_NFS_V4_1 */ 876#endif /* !CONFIG_NFS_V4_1 */
1024 877
878int nfs4_setup_sequence(const struct nfs_client *client,
879 struct nfs4_sequence_args *args,
880 struct nfs4_sequence_res *res,
881 struct rpc_task *task)
882{
883 struct nfs4_session *session = nfs4_get_session(client);
884 struct nfs4_slot_table *tbl = client->cl_slot_tbl;
885 struct nfs4_slot *slot;
886
887 /* slot already allocated? */
888 if (res->sr_slot != NULL)
889 goto out_start;
890
891 if (session) {
892 tbl = &session->fc_slot_table;
893 task->tk_timeout = 0;
894 }
895
896 spin_lock(&tbl->slot_tbl_lock);
897 /* The state manager will wait until the slot table is empty */
898 if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged)
899 goto out_sleep;
900
901 slot = nfs4_alloc_slot(tbl);
902 if (IS_ERR(slot)) {
903 /* Try again in 1/4 second */
904 if (slot == ERR_PTR(-ENOMEM))
905 task->tk_timeout = HZ >> 2;
906 goto out_sleep;
907 }
908 spin_unlock(&tbl->slot_tbl_lock);
909
910 slot->privileged = args->sa_privileged ? 1 : 0;
911 args->sa_slot = slot;
912
913 res->sr_slot = slot;
914 if (session) {
915 res->sr_timestamp = jiffies;
916 res->sr_status_flags = 0;
917 res->sr_status = 1;
918 }
919
920 trace_nfs4_setup_sequence(session, args);
921out_start:
922 rpc_call_start(task);
923 return 0;
924
925out_sleep:
926 if (args->sa_privileged)
927 rpc_sleep_on_priority(&tbl->slot_tbl_waitq, task,
928 NULL, RPC_PRIORITY_PRIVILEGED);
929 else
930 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
931 spin_unlock(&tbl->slot_tbl_lock);
932 return -EAGAIN;
933}
934EXPORT_SYMBOL_GPL(nfs4_setup_sequence);
935
1025static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata) 936static void nfs40_call_sync_prepare(struct rpc_task *task, void *calldata)
1026{ 937{
1027 struct nfs4_call_sync_data *data = calldata; 938 struct nfs4_call_sync_data *data = calldata;
1028 nfs4_setup_sequence(data->seq_server, 939 nfs4_setup_sequence(data->seq_server->nfs_client,
1029 data->seq_args, data->seq_res, task); 940 data->seq_args, data->seq_res, task);
1030} 941}
1031 942
@@ -1330,14 +1241,6 @@ static void nfs4_opendata_put(struct nfs4_opendata *p)
1330 kref_put(&p->kref, nfs4_opendata_free); 1241 kref_put(&p->kref, nfs4_opendata_free);
1331} 1242}
1332 1243
1333static int nfs4_wait_for_completion_rpc_task(struct rpc_task *task)
1334{
1335 int ret;
1336
1337 ret = rpc_wait_for_completion_task(task);
1338 return ret;
1339}
1340
1341static bool nfs4_mode_match_open_stateid(struct nfs4_state *state, 1244static bool nfs4_mode_match_open_stateid(struct nfs4_state *state,
1342 fmode_t fmode) 1245 fmode_t fmode)
1343{ 1246{
@@ -1732,17 +1635,15 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
1732 int ret; 1635 int ret;
1733 1636
1734 if (!data->rpc_done) { 1637 if (!data->rpc_done) {
1735 if (data->rpc_status) { 1638 if (data->rpc_status)
1736 ret = data->rpc_status; 1639 return ERR_PTR(data->rpc_status);
1737 goto err;
1738 }
1739 /* cached opens have already been processed */ 1640 /* cached opens have already been processed */
1740 goto update; 1641 goto update;
1741 } 1642 }
1742 1643
1743 ret = nfs_refresh_inode(inode, &data->f_attr); 1644 ret = nfs_refresh_inode(inode, &data->f_attr);
1744 if (ret) 1645 if (ret)
1745 goto err; 1646 return ERR_PTR(ret);
1746 1647
1747 if (data->o_res.delegation_type != 0) 1648 if (data->o_res.delegation_type != 0)
1748 nfs4_opendata_check_deleg(data, state); 1649 nfs4_opendata_check_deleg(data, state);
@@ -1752,9 +1653,6 @@ update:
1752 atomic_inc(&state->count); 1653 atomic_inc(&state->count);
1753 1654
1754 return state; 1655 return state;
1755err:
1756 return ERR_PTR(ret);
1757
1758} 1656}
1759 1657
1760static struct nfs4_state * 1658static struct nfs4_state *
@@ -2048,8 +1946,8 @@ static void nfs4_open_confirm_prepare(struct rpc_task *task, void *calldata)
2048{ 1946{
2049 struct nfs4_opendata *data = calldata; 1947 struct nfs4_opendata *data = calldata;
2050 1948
2051 nfs40_setup_sequence(data->o_arg.server->nfs_client->cl_slot_tbl, 1949 nfs4_setup_sequence(data->o_arg.server->nfs_client,
2052 &data->c_arg.seq_args, &data->c_res.seq_res, task); 1950 &data->c_arg.seq_args, &data->c_res.seq_res, task);
2053} 1951}
2054 1952
2055static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata) 1953static void nfs4_open_confirm_done(struct rpc_task *task, void *calldata)
@@ -2124,7 +2022,7 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
2124 task = rpc_run_task(&task_setup_data); 2022 task = rpc_run_task(&task_setup_data);
2125 if (IS_ERR(task)) 2023 if (IS_ERR(task))
2126 return PTR_ERR(task); 2024 return PTR_ERR(task);
2127 status = nfs4_wait_for_completion_rpc_task(task); 2025 status = rpc_wait_for_completion_task(task);
2128 if (status != 0) { 2026 if (status != 0) {
2129 data->cancelled = 1; 2027 data->cancelled = 1;
2130 smp_wmb(); 2028 smp_wmb();
@@ -2172,7 +2070,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
2172 nfs_copy_fh(&data->o_res.fh, data->o_arg.fh); 2070 nfs_copy_fh(&data->o_res.fh, data->o_arg.fh);
2173 } 2071 }
2174 data->timestamp = jiffies; 2072 data->timestamp = jiffies;
2175 if (nfs4_setup_sequence(data->o_arg.server, 2073 if (nfs4_setup_sequence(data->o_arg.server->nfs_client,
2176 &data->o_arg.seq_args, 2074 &data->o_arg.seq_args,
2177 &data->o_res.seq_res, 2075 &data->o_res.seq_res,
2178 task) != 0) 2076 task) != 0)
@@ -2289,15 +2187,15 @@ static int nfs4_run_open_task(struct nfs4_opendata *data, int isrecover)
2289 data->is_recover = 1; 2187 data->is_recover = 1;
2290 } 2188 }
2291 task = rpc_run_task(&task_setup_data); 2189 task = rpc_run_task(&task_setup_data);
2292 if (IS_ERR(task)) 2190 if (IS_ERR(task))
2293 return PTR_ERR(task); 2191 return PTR_ERR(task);
2294 status = nfs4_wait_for_completion_rpc_task(task); 2192 status = rpc_wait_for_completion_task(task);
2295 if (status != 0) { 2193 if (status != 0) {
2296 data->cancelled = 1; 2194 data->cancelled = 1;
2297 smp_wmb(); 2195 smp_wmb();
2298 } else 2196 } else
2299 status = data->rpc_status; 2197 status = data->rpc_status;
2300 rpc_put_task(task); 2198 rpc_put_task(task);
2301 2199
2302 return status; 2200 return status;
2303} 2201}
@@ -2306,7 +2204,7 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
2306{ 2204{
2307 struct inode *dir = d_inode(data->dir); 2205 struct inode *dir = d_inode(data->dir);
2308 struct nfs_openres *o_res = &data->o_res; 2206 struct nfs_openres *o_res = &data->o_res;
2309 int status; 2207 int status;
2310 2208
2311 status = nfs4_run_open_task(data, 1); 2209 status = nfs4_run_open_task(data, 1);
2312 if (status != 0 || !data->rpc_done) 2210 if (status != 0 || !data->rpc_done)
@@ -2314,11 +2212,8 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
2314 2212
2315 nfs_fattr_map_and_free_names(NFS_SERVER(dir), &data->f_attr); 2213 nfs_fattr_map_and_free_names(NFS_SERVER(dir), &data->f_attr);
2316 2214
2317 if (o_res->rflags & NFS4_OPEN_RESULT_CONFIRM) { 2215 if (o_res->rflags & NFS4_OPEN_RESULT_CONFIRM)
2318 status = _nfs4_proc_open_confirm(data); 2216 status = _nfs4_proc_open_confirm(data);
2319 if (status != 0)
2320 return status;
2321 }
2322 2217
2323 return status; 2218 return status;
2324} 2219}
@@ -2412,11 +2307,6 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
2412 return 0; 2307 return 0;
2413} 2308}
2414 2309
2415static int nfs4_recover_expired_lease(struct nfs_server *server)
2416{
2417 return nfs4_client_recover_expired_lease(server->nfs_client);
2418}
2419
2420/* 2310/*
2421 * OPEN_EXPIRED: 2311 * OPEN_EXPIRED:
2422 * reclaim state on the server after a network partition. 2312 * reclaim state on the server after a network partition.
@@ -2730,6 +2620,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
2730 ret = PTR_ERR(state); 2620 ret = PTR_ERR(state);
2731 if (IS_ERR(state)) 2621 if (IS_ERR(state))
2732 goto out; 2622 goto out;
2623 ctx->state = state;
2733 if (server->caps & NFS_CAP_POSIX_LOCK) 2624 if (server->caps & NFS_CAP_POSIX_LOCK)
2734 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); 2625 set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
2735 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK) 2626 if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK)
@@ -2755,7 +2646,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
2755 if (ret != 0) 2646 if (ret != 0)
2756 goto out; 2647 goto out;
2757 2648
2758 ctx->state = state;
2759 if (d_inode(dentry) == state->inode) { 2649 if (d_inode(dentry) == state->inode) {
2760 nfs_inode_attach_open_context(ctx); 2650 nfs_inode_attach_open_context(ctx);
2761 if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) 2651 if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
@@ -2794,7 +2684,7 @@ static int _nfs4_do_open(struct inode *dir,
2794 dprintk("nfs4_do_open: nfs4_get_state_owner failed!\n"); 2684 dprintk("nfs4_do_open: nfs4_get_state_owner failed!\n");
2795 goto out_err; 2685 goto out_err;
2796 } 2686 }
2797 status = nfs4_recover_expired_lease(server); 2687 status = nfs4_client_recover_expired_lease(server->nfs_client);
2798 if (status != 0) 2688 if (status != 0)
2799 goto err_put_state_owner; 2689 goto err_put_state_owner;
2800 if (d_really_is_positive(dentry)) 2690 if (d_really_is_positive(dentry))
@@ -2940,12 +2830,12 @@ static int _nfs4_do_setattr(struct inode *inode,
2940 struct nfs_open_context *ctx) 2830 struct nfs_open_context *ctx)
2941{ 2831{
2942 struct nfs_server *server = NFS_SERVER(inode); 2832 struct nfs_server *server = NFS_SERVER(inode);
2943 struct rpc_message msg = { 2833 struct rpc_message msg = {
2944 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR], 2834 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR],
2945 .rpc_argp = arg, 2835 .rpc_argp = arg,
2946 .rpc_resp = res, 2836 .rpc_resp = res,
2947 .rpc_cred = cred, 2837 .rpc_cred = cred,
2948 }; 2838 };
2949 struct rpc_cred *delegation_cred = NULL; 2839 struct rpc_cred *delegation_cred = NULL;
2950 unsigned long timestamp = jiffies; 2840 unsigned long timestamp = jiffies;
2951 fmode_t fmode; 2841 fmode_t fmode;
@@ -2993,18 +2883,18 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
2993{ 2883{
2994 struct nfs_server *server = NFS_SERVER(inode); 2884 struct nfs_server *server = NFS_SERVER(inode);
2995 struct nfs4_state *state = ctx ? ctx->state : NULL; 2885 struct nfs4_state *state = ctx ? ctx->state : NULL;
2996 struct nfs_setattrargs arg = { 2886 struct nfs_setattrargs arg = {
2997 .fh = NFS_FH(inode), 2887 .fh = NFS_FH(inode),
2998 .iap = sattr, 2888 .iap = sattr,
2999 .server = server, 2889 .server = server,
3000 .bitmask = server->attr_bitmask, 2890 .bitmask = server->attr_bitmask,
3001 .label = ilabel, 2891 .label = ilabel,
3002 }; 2892 };
3003 struct nfs_setattrres res = { 2893 struct nfs_setattrres res = {
3004 .fattr = fattr, 2894 .fattr = fattr,
3005 .label = olabel, 2895 .label = olabel,
3006 .server = server, 2896 .server = server,
3007 }; 2897 };
3008 struct nfs4_exception exception = { 2898 struct nfs4_exception exception = {
3009 .state = state, 2899 .state = state,
3010 .inode = inode, 2900 .inode = inode,
@@ -3118,7 +3008,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
3118 } 3008 }
3119 } 3009 }
3120 3010
3121 /* hmm. we are done with the inode, and in the process of freeing 3011 /* hmm. we are done with the inode, and in the process of freeing
3122 * the state_owner. we keep this around to process errors 3012 * the state_owner. we keep this around to process errors
3123 */ 3013 */
3124 switch (task->tk_status) { 3014 switch (task->tk_status) {
@@ -3234,7 +3124,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
3234 else if (calldata->arg.bitmask == NULL) 3124 else if (calldata->arg.bitmask == NULL)
3235 calldata->res.fattr = NULL; 3125 calldata->res.fattr = NULL;
3236 calldata->timestamp = jiffies; 3126 calldata->timestamp = jiffies;
3237 if (nfs4_setup_sequence(NFS_SERVER(inode), 3127 if (nfs4_setup_sequence(NFS_SERVER(inode)->nfs_client,
3238 &calldata->arg.seq_args, 3128 &calldata->arg.seq_args,
3239 &calldata->res.seq_res, 3129 &calldata->res.seq_res,
3240 task) != 0) 3130 task) != 0)
@@ -3522,16 +3412,11 @@ static int nfs4_lookup_root_sec(struct nfs_server *server, struct nfs_fh *fhandl
3522 .pseudoflavor = flavor, 3412 .pseudoflavor = flavor,
3523 }; 3413 };
3524 struct rpc_auth *auth; 3414 struct rpc_auth *auth;
3525 int ret;
3526 3415
3527 auth = rpcauth_create(&auth_args, server->client); 3416 auth = rpcauth_create(&auth_args, server->client);
3528 if (IS_ERR(auth)) { 3417 if (IS_ERR(auth))
3529 ret = -EACCES; 3418 return -EACCES;
3530 goto out; 3419 return nfs4_lookup_root(server, fhandle, info);
3531 }
3532 ret = nfs4_lookup_root(server, fhandle, info);
3533out:
3534 return ret;
3535} 3420}
3536 3421
3537/* 3422/*
@@ -4114,7 +3999,7 @@ static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
4114 3999
4115static void nfs4_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data) 4000static void nfs4_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data)
4116{ 4001{
4117 nfs4_setup_sequence(NFS_SB(data->dentry->d_sb), 4002 nfs4_setup_sequence(NFS_SB(data->dentry->d_sb)->nfs_client,
4118 &data->args.seq_args, 4003 &data->args.seq_args,
4119 &data->res.seq_res, 4004 &data->res.seq_res,
4120 task); 4005 task);
@@ -4148,7 +4033,7 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg, struct inode *dir)
4148 4033
4149static void nfs4_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data) 4034static void nfs4_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data)
4150{ 4035{
4151 nfs4_setup_sequence(NFS_SERVER(data->old_dir), 4036 nfs4_setup_sequence(NFS_SERVER(data->old_dir)->nfs_client,
4152 &data->args.seq_args, 4037 &data->args.seq_args,
4153 &data->res.seq_res, 4038 &data->res.seq_res,
4154 task); 4039 task);
@@ -4723,7 +4608,7 @@ static void nfs4_proc_read_setup(struct nfs_pgio_header *hdr,
4723static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task, 4608static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task,
4724 struct nfs_pgio_header *hdr) 4609 struct nfs_pgio_header *hdr)
4725{ 4610{
4726 if (nfs4_setup_sequence(NFS_SERVER(hdr->inode), 4611 if (nfs4_setup_sequence(NFS_SERVER(hdr->inode)->nfs_client,
4727 &hdr->args.seq_args, 4612 &hdr->args.seq_args,
4728 &hdr->res.seq_res, 4613 &hdr->res.seq_res,
4729 task)) 4614 task))
@@ -4822,7 +4707,7 @@ static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr,
4822 4707
4823static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data) 4708static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
4824{ 4709{
4825 nfs4_setup_sequence(NFS_SERVER(data->inode), 4710 nfs4_setup_sequence(NFS_SERVER(data->inode)->nfs_client,
4826 &data->args.seq_args, 4711 &data->args.seq_args,
4827 &data->res.seq_res, 4712 &data->res.seq_res,
4828 task); 4713 task);
@@ -4975,8 +4860,8 @@ static int buf_to_pages_noslab(const void *buf, size_t buflen,
4975 if (newpage == NULL) 4860 if (newpage == NULL)
4976 goto unwind; 4861 goto unwind;
4977 memcpy(page_address(newpage), buf, len); 4862 memcpy(page_address(newpage), buf, len);
4978 buf += len; 4863 buf += len;
4979 buflen -= len; 4864 buflen -= len;
4980 *pages++ = newpage; 4865 *pages++ = newpage;
4981 rc++; 4866 rc++;
4982 } while (buflen != 0); 4867 } while (buflen != 0);
@@ -5069,7 +4954,7 @@ out:
5069 */ 4954 */
5070static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t buflen) 4955static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t buflen)
5071{ 4956{
5072 struct page *pages[NFS4ACL_MAXPAGES] = {NULL, }; 4957 struct page *pages[NFS4ACL_MAXPAGES + 1] = {NULL, };
5073 struct nfs_getaclargs args = { 4958 struct nfs_getaclargs args = {
5074 .fh = NFS_FH(inode), 4959 .fh = NFS_FH(inode),
5075 .acl_pages = pages, 4960 .acl_pages = pages,
@@ -5083,13 +4968,9 @@ static ssize_t __nfs4_get_acl_uncached(struct inode *inode, void *buf, size_t bu
5083 .rpc_argp = &args, 4968 .rpc_argp = &args,
5084 .rpc_resp = &res, 4969 .rpc_resp = &res,
5085 }; 4970 };
5086 unsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE); 4971 unsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE) + 1;
5087 int ret = -ENOMEM, i; 4972 int ret = -ENOMEM, i;
5088 4973
5089 /* As long as we're doing a round trip to the server anyway,
5090 * let's be prepared for a page of acl data. */
5091 if (npages == 0)
5092 npages = 1;
5093 if (npages > ARRAY_SIZE(pages)) 4974 if (npages > ARRAY_SIZE(pages))
5094 return -ERANGE; 4975 return -ERANGE;
5095 4976
@@ -5299,8 +5180,8 @@ static int _nfs4_do_set_security_label(struct inode *inode,
5299 struct nfs_server *server = NFS_SERVER(inode); 5180 struct nfs_server *server = NFS_SERVER(inode);
5300 const u32 bitmask[3] = { 0, 0, FATTR4_WORD2_SECURITY_LABEL }; 5181 const u32 bitmask[3] = { 0, 0, FATTR4_WORD2_SECURITY_LABEL };
5301 struct nfs_setattrargs arg = { 5182 struct nfs_setattrargs arg = {
5302 .fh = NFS_FH(inode), 5183 .fh = NFS_FH(inode),
5303 .iap = &sattr, 5184 .iap = &sattr,
5304 .server = server, 5185 .server = server,
5305 .bitmask = bitmask, 5186 .bitmask = bitmask,
5306 .label = ilabel, 5187 .label = ilabel,
@@ -5311,9 +5192,9 @@ static int _nfs4_do_set_security_label(struct inode *inode,
5311 .server = server, 5192 .server = server,
5312 }; 5193 };
5313 struct rpc_message msg = { 5194 struct rpc_message msg = {
5314 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR], 5195 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETATTR],
5315 .rpc_argp = &arg, 5196 .rpc_argp = &arg,
5316 .rpc_resp = &res, 5197 .rpc_resp = &res,
5317 }; 5198 };
5318 int status; 5199 int status;
5319 5200
@@ -5747,7 +5628,7 @@ static void nfs4_delegreturn_prepare(struct rpc_task *task, void *data)
5747 if (!d_data->lr.roc && nfs4_wait_on_layoutreturn(d_data->inode, task)) 5628 if (!d_data->lr.roc && nfs4_wait_on_layoutreturn(d_data->inode, task))
5748 return; 5629 return;
5749 5630
5750 nfs4_setup_sequence(d_data->res.server, 5631 nfs4_setup_sequence(d_data->res.server->nfs_client,
5751 &d_data->args.seq_args, 5632 &d_data->args.seq_args,
5752 &d_data->res.seq_res, 5633 &d_data->res.seq_res,
5753 task); 5634 task);
@@ -5817,7 +5698,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
5817 return PTR_ERR(task); 5698 return PTR_ERR(task);
5818 if (!issync) 5699 if (!issync)
5819 goto out; 5700 goto out;
5820 status = nfs4_wait_for_completion_rpc_task(task); 5701 status = rpc_wait_for_completion_task(task);
5821 if (status != 0) 5702 if (status != 0)
5822 goto out; 5703 goto out;
5823 status = data->rpc_status; 5704 status = data->rpc_status;
@@ -5859,8 +5740,8 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
5859 }; 5740 };
5860 struct rpc_message msg = { 5741 struct rpc_message msg = {
5861 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKT], 5742 .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LOCKT],
5862 .rpc_argp = &arg, 5743 .rpc_argp = &arg,
5863 .rpc_resp = &res, 5744 .rpc_resp = &res,
5864 .rpc_cred = state->owner->so_cred, 5745 .rpc_cred = state->owner->so_cred,
5865 }; 5746 };
5866 struct nfs4_lock_state *lsp; 5747 struct nfs4_lock_state *lsp;
@@ -5989,7 +5870,7 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data)
5989 goto out_no_action; 5870 goto out_no_action;
5990 } 5871 }
5991 calldata->timestamp = jiffies; 5872 calldata->timestamp = jiffies;
5992 if (nfs4_setup_sequence(calldata->server, 5873 if (nfs4_setup_sequence(calldata->server->nfs_client,
5993 &calldata->arg.seq_args, 5874 &calldata->arg.seq_args,
5994 &calldata->res.seq_res, 5875 &calldata->res.seq_res,
5995 task) != 0) 5876 task) != 0)
@@ -6087,7 +5968,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
6087 status = PTR_ERR(task); 5968 status = PTR_ERR(task);
6088 if (IS_ERR(task)) 5969 if (IS_ERR(task))
6089 goto out; 5970 goto out;
6090 status = nfs4_wait_for_completion_rpc_task(task); 5971 status = rpc_wait_for_completion_task(task);
6091 rpc_put_task(task); 5972 rpc_put_task(task);
6092out: 5973out:
6093 request->fl_flags = fl_flags; 5974 request->fl_flags = fl_flags;
@@ -6174,7 +6055,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
6174 goto out_release_open_seqid; 6055 goto out_release_open_seqid;
6175 } 6056 }
6176 data->timestamp = jiffies; 6057 data->timestamp = jiffies;
6177 if (nfs4_setup_sequence(data->server, 6058 if (nfs4_setup_sequence(data->server->nfs_client,
6178 &data->arg.seq_args, 6059 &data->arg.seq_args,
6179 &data->res.seq_res, 6060 &data->res.seq_res,
6180 task) == 0) 6061 task) == 0)
@@ -6314,7 +6195,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
6314 task = rpc_run_task(&task_setup_data); 6195 task = rpc_run_task(&task_setup_data);
6315 if (IS_ERR(task)) 6196 if (IS_ERR(task))
6316 return PTR_ERR(task); 6197 return PTR_ERR(task);
6317 ret = nfs4_wait_for_completion_rpc_task(task); 6198 ret = rpc_wait_for_completion_task(task);
6318 if (ret == 0) { 6199 if (ret == 0) {
6319 ret = data->rpc_status; 6200 ret = data->rpc_status;
6320 if (ret) 6201 if (ret)
@@ -6393,8 +6274,7 @@ static int nfs41_lock_expired(struct nfs4_state *state, struct file_lock *reques
6393 if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) || 6274 if (test_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags) ||
6394 test_bit(NFS_LOCK_LOST, &lsp->ls_flags)) 6275 test_bit(NFS_LOCK_LOST, &lsp->ls_flags))
6395 return 0; 6276 return 0;
6396 status = nfs4_lock_expired(state, request); 6277 return nfs4_lock_expired(state, request);
6397 return status;
6398} 6278}
6399#endif 6279#endif
6400 6280
@@ -6640,8 +6520,8 @@ static void nfs4_release_lockowner_prepare(struct rpc_task *task, void *calldata
6640{ 6520{
6641 struct nfs_release_lockowner_data *data = calldata; 6521 struct nfs_release_lockowner_data *data = calldata;
6642 struct nfs_server *server = data->server; 6522 struct nfs_server *server = data->server;
6643 nfs40_setup_sequence(server->nfs_client->cl_slot_tbl, 6523 nfs4_setup_sequence(server->nfs_client, &data->args.seq_args,
6644 &data->args.seq_args, &data->res.seq_res, task); 6524 &data->res.seq_res, task);
6645 data->args.lock_owner.clientid = server->nfs_client->cl_clientid; 6525 data->args.lock_owner.clientid = server->nfs_client->cl_clientid;
6646 data->timestamp = jiffies; 6526 data->timestamp = jiffies;
6647} 6527}
@@ -7232,11 +7112,9 @@ static bool
7232nfs41_same_server_scope(struct nfs41_server_scope *a, 7112nfs41_same_server_scope(struct nfs41_server_scope *a,
7233 struct nfs41_server_scope *b) 7113 struct nfs41_server_scope *b)
7234{ 7114{
7235 if (a->server_scope_sz == b->server_scope_sz && 7115 if (a->server_scope_sz != b->server_scope_sz)
7236 memcmp(a->server_scope, b->server_scope, a->server_scope_sz) == 0) 7116 return false;
7237 return true; 7117 return memcmp(a->server_scope, b->server_scope, a->server_scope_sz) == 0;
7238
7239 return false;
7240} 7118}
7241 7119
7242static void 7120static void
@@ -7831,7 +7709,7 @@ static void nfs4_get_lease_time_prepare(struct rpc_task *task,
7831 dprintk("--> %s\n", __func__); 7709 dprintk("--> %s\n", __func__);
7832 /* just setup sequence, do not trigger session recovery 7710 /* just setup sequence, do not trigger session recovery
7833 since we're invoked within one */ 7711 since we're invoked within one */
7834 nfs41_setup_sequence(data->clp->cl_session, 7712 nfs4_setup_sequence(data->clp,
7835 &data->args->la_seq_args, 7713 &data->args->la_seq_args,
7836 &data->res->lr_seq_res, 7714 &data->res->lr_seq_res,
7837 task); 7715 task);
@@ -8202,7 +8080,7 @@ static void nfs41_sequence_prepare(struct rpc_task *task, void *data)
8202 args = task->tk_msg.rpc_argp; 8080 args = task->tk_msg.rpc_argp;
8203 res = task->tk_msg.rpc_resp; 8081 res = task->tk_msg.rpc_resp;
8204 8082
8205 nfs41_setup_sequence(clp->cl_session, args, res, task); 8083 nfs4_setup_sequence(clp, args, res, task);
8206} 8084}
8207 8085
8208static const struct rpc_call_ops nfs41_sequence_ops = { 8086static const struct rpc_call_ops nfs41_sequence_ops = {
@@ -8290,7 +8168,7 @@ static void nfs4_reclaim_complete_prepare(struct rpc_task *task, void *data)
8290{ 8168{
8291 struct nfs4_reclaim_complete_data *calldata = data; 8169 struct nfs4_reclaim_complete_data *calldata = data;
8292 8170
8293 nfs41_setup_sequence(calldata->clp->cl_session, 8171 nfs4_setup_sequence(calldata->clp,
8294 &calldata->arg.seq_args, 8172 &calldata->arg.seq_args,
8295 &calldata->res.seq_res, 8173 &calldata->res.seq_res,
8296 task); 8174 task);
@@ -8382,7 +8260,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp,
8382 status = PTR_ERR(task); 8260 status = PTR_ERR(task);
8383 goto out; 8261 goto out;
8384 } 8262 }
8385 status = nfs4_wait_for_completion_rpc_task(task); 8263 status = rpc_wait_for_completion_task(task);
8386 if (status == 0) 8264 if (status == 0)
8387 status = task->tk_status; 8265 status = task->tk_status;
8388 rpc_put_task(task); 8266 rpc_put_task(task);
@@ -8397,10 +8275,9 @@ nfs4_layoutget_prepare(struct rpc_task *task, void *calldata)
8397{ 8275{
8398 struct nfs4_layoutget *lgp = calldata; 8276 struct nfs4_layoutget *lgp = calldata;
8399 struct nfs_server *server = NFS_SERVER(lgp->args.inode); 8277 struct nfs_server *server = NFS_SERVER(lgp->args.inode);
8400 struct nfs4_session *session = nfs4_get_session(server);
8401 8278
8402 dprintk("--> %s\n", __func__); 8279 dprintk("--> %s\n", __func__);
8403 nfs41_setup_sequence(session, &lgp->args.seq_args, 8280 nfs4_setup_sequence(server->nfs_client, &lgp->args.seq_args,
8404 &lgp->res.seq_res, task); 8281 &lgp->res.seq_res, task);
8405 dprintk("<-- %s\n", __func__); 8282 dprintk("<-- %s\n", __func__);
8406} 8283}
@@ -8615,7 +8492,7 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
8615 task = rpc_run_task(&task_setup_data); 8492 task = rpc_run_task(&task_setup_data);
8616 if (IS_ERR(task)) 8493 if (IS_ERR(task))
8617 return ERR_CAST(task); 8494 return ERR_CAST(task);
8618 status = nfs4_wait_for_completion_rpc_task(task); 8495 status = rpc_wait_for_completion_task(task);
8619 if (status == 0) { 8496 if (status == 0) {
8620 status = nfs4_layoutget_handle_exception(task, lgp, &exception); 8497 status = nfs4_layoutget_handle_exception(task, lgp, &exception);
8621 *timeout = exception.timeout; 8498 *timeout = exception.timeout;
@@ -8644,7 +8521,7 @@ nfs4_layoutreturn_prepare(struct rpc_task *task, void *calldata)
8644 struct nfs4_layoutreturn *lrp = calldata; 8521 struct nfs4_layoutreturn *lrp = calldata;
8645 8522
8646 dprintk("--> %s\n", __func__); 8523 dprintk("--> %s\n", __func__);
8647 nfs41_setup_sequence(lrp->clp->cl_session, 8524 nfs4_setup_sequence(lrp->clp,
8648 &lrp->args.seq_args, 8525 &lrp->args.seq_args,
8649 &lrp->res.seq_res, 8526 &lrp->res.seq_res,
8650 task); 8527 task);
@@ -8794,9 +8671,8 @@ static void nfs4_layoutcommit_prepare(struct rpc_task *task, void *calldata)
8794{ 8671{
8795 struct nfs4_layoutcommit_data *data = calldata; 8672 struct nfs4_layoutcommit_data *data = calldata;
8796 struct nfs_server *server = NFS_SERVER(data->args.inode); 8673 struct nfs_server *server = NFS_SERVER(data->args.inode);
8797 struct nfs4_session *session = nfs4_get_session(server);
8798 8674
8799 nfs41_setup_sequence(session, 8675 nfs4_setup_sequence(server->nfs_client,
8800 &data->args.seq_args, 8676 &data->args.seq_args,
8801 &data->res.seq_res, 8677 &data->res.seq_res,
8802 task); 8678 task);
@@ -9120,7 +8996,7 @@ struct nfs_free_stateid_data {
9120static void nfs41_free_stateid_prepare(struct rpc_task *task, void *calldata) 8996static void nfs41_free_stateid_prepare(struct rpc_task *task, void *calldata)
9121{ 8997{
9122 struct nfs_free_stateid_data *data = calldata; 8998 struct nfs_free_stateid_data *data = calldata;
9123 nfs41_setup_sequence(nfs4_get_session(data->server), 8999 nfs4_setup_sequence(data->server->nfs_client,
9124 &data->args.seq_args, 9000 &data->args.seq_args,
9125 &data->res.seq_res, 9001 &data->res.seq_res,
9126 task); 9002 task);
@@ -9232,10 +9108,8 @@ static bool nfs41_match_stateid(const nfs4_stateid *s1,
9232 9108
9233 if (s1->seqid == s2->seqid) 9109 if (s1->seqid == s2->seqid)
9234 return true; 9110 return true;
9235 if (s1->seqid == 0 || s2->seqid == 0)
9236 return true;
9237 9111
9238 return false; 9112 return s1->seqid == 0 || s2->seqid == 0;
9239} 9113}
9240 9114
9241#endif /* CONFIG_NFS_V4_1 */ 9115#endif /* CONFIG_NFS_V4_1 */
diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c
index 82e77198d17e..1f8c2ae43a8d 100644
--- a/fs/nfs/nfs4renewd.c
+++ b/fs/nfs/nfs4renewd.c
@@ -153,7 +153,7 @@ void nfs4_set_lease_period(struct nfs_client *clp,
153 spin_unlock(&clp->cl_lock); 153 spin_unlock(&clp->cl_lock);
154 154
155 /* Cap maximum reconnect timeout at 1/2 lease period */ 155 /* Cap maximum reconnect timeout at 1/2 lease period */
156 rpc_cap_max_reconnect_timeout(clp->cl_rpcclient, lease >> 1); 156 rpc_set_connect_timeout(clp->cl_rpcclient, lease, lease >> 1);
157} 157}
158 158
159/* 159/*
diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h
index dae385500005..dfae4880eacb 100644
--- a/fs/nfs/nfs4session.h
+++ b/fs/nfs/nfs4session.h
@@ -103,6 +103,11 @@ static inline bool nfs4_test_locked_slot(const struct nfs4_slot_table *tbl,
103 return !!test_bit(slotid, tbl->used_slots); 103 return !!test_bit(slotid, tbl->used_slots);
104} 104}
105 105
106static inline struct nfs4_session *nfs4_get_session(const struct nfs_client *clp)
107{
108 return clp->cl_session;
109}
110
106#if defined(CONFIG_NFS_V4_1) 111#if defined(CONFIG_NFS_V4_1)
107extern void nfs41_set_target_slotid(struct nfs4_slot_table *tbl, 112extern void nfs41_set_target_slotid(struct nfs4_slot_table *tbl,
108 u32 target_highest_slotid); 113 u32 target_highest_slotid);
@@ -170,6 +175,8 @@ static inline int nfs4_has_persistent_session(const struct nfs_client *clp)
170 return 0; 175 return 0;
171} 176}
172 177
178#define nfs_session_id_hash(session) (0)
179
173#endif /* defined(CONFIG_NFS_V4_1) */ 180#endif /* defined(CONFIG_NFS_V4_1) */
174#endif /* IS_ENABLED(CONFIG_NFS_V4) */ 181#endif /* IS_ENABLED(CONFIG_NFS_V4) */
175#endif /* __LINUX_FS_NFS_NFS4SESSION_H */ 182#endif /* __LINUX_FS_NFS_NFS4SESSION_H */
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index daeb94e3acd4..8156bad6b441 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -868,7 +868,7 @@ static struct nfs4_lock_state *nfs4_get_lock_state(struct nfs4_state *state, fl_
868 868
869 for(;;) { 869 for(;;) {
870 spin_lock(&state->state_lock); 870 spin_lock(&state->state_lock);
871 lsp = __nfs4_find_lock_state(state, owner, 0); 871 lsp = __nfs4_find_lock_state(state, owner, NULL);
872 if (lsp != NULL) 872 if (lsp != NULL)
873 break; 873 break;
874 if (new != NULL) { 874 if (new != NULL) {
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index cfb8f7ce5cf6..845d0eadefc9 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -241,38 +241,6 @@ DEFINE_NFS4_CLIENTID_EVENT(nfs4_bind_conn_to_session);
241DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence); 241DEFINE_NFS4_CLIENTID_EVENT(nfs4_sequence);
242DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete); 242DEFINE_NFS4_CLIENTID_EVENT(nfs4_reclaim_complete);
243 243
244TRACE_EVENT(nfs4_setup_sequence,
245 TP_PROTO(
246 const struct nfs4_session *session,
247 const struct nfs4_sequence_args *args
248 ),
249 TP_ARGS(session, args),
250
251 TP_STRUCT__entry(
252 __field(unsigned int, session)
253 __field(unsigned int, slot_nr)
254 __field(unsigned int, seq_nr)
255 __field(unsigned int, highest_used_slotid)
256 ),
257
258 TP_fast_assign(
259 const struct nfs4_slot *sa_slot = args->sa_slot;
260 __entry->session = nfs_session_id_hash(&session->sess_id);
261 __entry->slot_nr = sa_slot->slot_nr;
262 __entry->seq_nr = sa_slot->seq_nr;
263 __entry->highest_used_slotid =
264 sa_slot->table->highest_used_slotid;
265 ),
266 TP_printk(
267 "session=0x%08x slot_nr=%u seq_nr=%u "
268 "highest_used_slotid=%u",
269 __entry->session,
270 __entry->slot_nr,
271 __entry->seq_nr,
272 __entry->highest_used_slotid
273 )
274);
275
276#define show_nfs4_sequence_status_flags(status) \ 244#define show_nfs4_sequence_status_flags(status) \
277 __print_flags((unsigned long)status, "|", \ 245 __print_flags((unsigned long)status, "|", \
278 { SEQ4_STATUS_CB_PATH_DOWN, "CB_PATH_DOWN" }, \ 246 { SEQ4_STATUS_CB_PATH_DOWN, "CB_PATH_DOWN" }, \
@@ -382,6 +350,38 @@ TRACE_EVENT(nfs4_cb_sequence,
382); 350);
383#endif /* CONFIG_NFS_V4_1 */ 351#endif /* CONFIG_NFS_V4_1 */
384 352
353TRACE_EVENT(nfs4_setup_sequence,
354 TP_PROTO(
355 const struct nfs4_session *session,
356 const struct nfs4_sequence_args *args
357 ),
358 TP_ARGS(session, args),
359
360 TP_STRUCT__entry(
361 __field(unsigned int, session)
362 __field(unsigned int, slot_nr)
363 __field(unsigned int, seq_nr)
364 __field(unsigned int, highest_used_slotid)
365 ),
366
367 TP_fast_assign(
368 const struct nfs4_slot *sa_slot = args->sa_slot;
369 __entry->session = session ? nfs_session_id_hash(&session->sess_id) : 0;
370 __entry->slot_nr = sa_slot->slot_nr;
371 __entry->seq_nr = sa_slot->seq_nr;
372 __entry->highest_used_slotid =
373 sa_slot->table->highest_used_slotid;
374 ),
375 TP_printk(
376 "session=0x%08x slot_nr=%u seq_nr=%u "
377 "highest_used_slotid=%u",
378 __entry->session,
379 __entry->slot_nr,
380 __entry->seq_nr,
381 __entry->highest_used_slotid
382 )
383);
384
385DECLARE_EVENT_CLASS(nfs4_open_event, 385DECLARE_EVENT_CLASS(nfs4_open_event,
386 TP_PROTO( 386 TP_PROTO(
387 const struct nfs_open_context *ctx, 387 const struct nfs_open_context *ctx,
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index e9255cb453e6..f0369e362753 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -169,8 +169,10 @@ static int nfs4_stat_to_errno(int);
169 open_owner_id_maxsz + \ 169 open_owner_id_maxsz + \
170 encode_opentype_maxsz + \ 170 encode_opentype_maxsz + \
171 encode_claim_null_maxsz) 171 encode_claim_null_maxsz)
172#define decode_space_limit_maxsz (3)
172#define decode_ace_maxsz (3 + nfs4_owner_maxsz) 173#define decode_ace_maxsz (3 + nfs4_owner_maxsz)
173#define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \ 174#define decode_delegation_maxsz (1 + decode_stateid_maxsz + 1 + \
175 decode_space_limit_maxsz + \
174 decode_ace_maxsz) 176 decode_ace_maxsz)
175#define decode_change_info_maxsz (5) 177#define decode_change_info_maxsz (5)
176#define decode_open_maxsz (op_decode_hdr_maxsz + \ 178#define decode_open_maxsz (op_decode_hdr_maxsz + \
@@ -924,34 +926,22 @@ static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
924 926
925static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len) 927static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
926{ 928{
927 __be32 *p; 929 WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
928
929 p = xdr_reserve_space(xdr, len);
930 xdr_encode_opaque_fixed(p, buf, len);
931} 930}
932 931
933static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str) 932static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
934{ 933{
935 __be32 *p; 934 WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0);
936
937 p = reserve_space(xdr, 4 + len);
938 xdr_encode_opaque(p, str, len);
939} 935}
940 936
941static void encode_uint32(struct xdr_stream *xdr, u32 n) 937static void encode_uint32(struct xdr_stream *xdr, u32 n)
942{ 938{
943 __be32 *p; 939 WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0);
944
945 p = reserve_space(xdr, 4);
946 *p = cpu_to_be32(n);
947} 940}
948 941
949static void encode_uint64(struct xdr_stream *xdr, u64 n) 942static void encode_uint64(struct xdr_stream *xdr, u64 n)
950{ 943{
951 __be32 *p; 944 WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0);
952
953 p = reserve_space(xdr, 8);
954 xdr_encode_hyper(p, n);
955} 945}
956 946
957static void encode_nfs4_seqid(struct xdr_stream *xdr, 947static void encode_nfs4_seqid(struct xdr_stream *xdr,
@@ -2524,7 +2514,7 @@ static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
2524 encode_compound_hdr(xdr, req, &hdr); 2514 encode_compound_hdr(xdr, req, &hdr);
2525 encode_sequence(xdr, &args->seq_args, &hdr); 2515 encode_sequence(xdr, &args->seq_args, &hdr);
2526 encode_putfh(xdr, args->fh, &hdr); 2516 encode_putfh(xdr, args->fh, &hdr);
2527 replen = hdr.replen + op_decode_hdr_maxsz + 1; 2517 replen = hdr.replen + op_decode_hdr_maxsz;
2528 encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr); 2518 encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr);
2529 2519
2530 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, 2520 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
@@ -3062,20 +3052,15 @@ static void print_overflow_msg(const char *func, const struct xdr_stream *xdr)
3062 3052
3063static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string) 3053static int decode_opaque_inline(struct xdr_stream *xdr, unsigned int *len, char **string)
3064{ 3054{
3065 __be32 *p; 3055 ssize_t ret = xdr_stream_decode_opaque_inline(xdr, (void **)string,
3066 3056 NFS4_OPAQUE_LIMIT);
3067 p = xdr_inline_decode(xdr, 4); 3057 if (unlikely(ret < 0)) {
3068 if (unlikely(!p)) 3058 if (ret == -EBADMSG)
3069 goto out_overflow; 3059 print_overflow_msg(__func__, xdr);
3070 *len = be32_to_cpup(p); 3060 return -EIO;
3071 p = xdr_inline_decode(xdr, *len); 3061 }
3072 if (unlikely(!p)) 3062 *len = ret;
3073 goto out_overflow;
3074 *string = (char *)p;
3075 return 0; 3063 return 0;
3076out_overflow:
3077 print_overflow_msg(__func__, xdr);
3078 return -EIO;
3079} 3064}
3080 3065
3081static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr) 3066static int decode_compound_hdr(struct xdr_stream *xdr, struct compound_hdr *hdr)
@@ -3142,7 +3127,7 @@ static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected)
3142} 3127}
3143 3128
3144/* Dummy routine */ 3129/* Dummy routine */
3145static int decode_ace(struct xdr_stream *xdr, void *ace, struct nfs_client *clp) 3130static int decode_ace(struct xdr_stream *xdr, void *ace)
3146{ 3131{
3147 __be32 *p; 3132 __be32 *p;
3148 unsigned int strlen; 3133 unsigned int strlen;
@@ -3890,45 +3875,50 @@ out_overflow:
3890 return -EIO; 3875 return -EIO;
3891} 3876}
3892 3877
3878static ssize_t decode_nfs4_string(struct xdr_stream *xdr,
3879 struct nfs4_string *name, gfp_t gfp_flags)
3880{
3881 ssize_t ret;
3882
3883 ret = xdr_stream_decode_string_dup(xdr, &name->data,
3884 XDR_MAX_NETOBJ, gfp_flags);
3885 name->len = 0;
3886 if (ret > 0)
3887 name->len = ret;
3888 return ret;
3889}
3890
3893static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, 3891static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap,
3894 const struct nfs_server *server, kuid_t *uid, 3892 const struct nfs_server *server, kuid_t *uid,
3895 struct nfs4_string *owner_name) 3893 struct nfs4_string *owner_name)
3896{ 3894{
3897 uint32_t len; 3895 ssize_t len;
3898 __be32 *p; 3896 char *p;
3899 int ret = 0;
3900 3897
3901 *uid = make_kuid(&init_user_ns, -2); 3898 *uid = make_kuid(&init_user_ns, -2);
3902 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U))) 3899 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER - 1U)))
3903 return -EIO; 3900 return -EIO;
3904 if (likely(bitmap[1] & FATTR4_WORD1_OWNER)) { 3901 if (!(bitmap[1] & FATTR4_WORD1_OWNER))
3905 p = xdr_inline_decode(xdr, 4); 3902 return 0;
3906 if (unlikely(!p)) 3903 bitmap[1] &= ~FATTR4_WORD1_OWNER;
3907 goto out_overflow; 3904
3908 len = be32_to_cpup(p); 3905 if (owner_name != NULL) {
3909 p = xdr_inline_decode(xdr, len); 3906 len = decode_nfs4_string(xdr, owner_name, GFP_NOWAIT);
3910 if (unlikely(!p)) 3907 if (len <= 0)
3911 goto out_overflow; 3908 goto out;
3912 if (owner_name != NULL) { 3909 dprintk("%s: name=%s\n", __func__, owner_name->data);
3913 owner_name->data = kmemdup(p, len, GFP_NOWAIT); 3910 return NFS_ATTR_FATTR_OWNER_NAME;
3914 if (owner_name->data != NULL) { 3911 } else {
3915 owner_name->len = len; 3912 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
3916 ret = NFS_ATTR_FATTR_OWNER_NAME; 3913 XDR_MAX_NETOBJ);
3917 } 3914 if (len <= 0 || nfs_map_name_to_uid(server, p, len, uid) != 0)
3918 } else if (len < XDR_MAX_NETOBJ) { 3915 goto out;
3919 if (nfs_map_name_to_uid(server, (char *)p, len, uid) == 0) 3916 dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid));
3920 ret = NFS_ATTR_FATTR_OWNER; 3917 return NFS_ATTR_FATTR_OWNER;
3921 else
3922 dprintk("%s: nfs_map_name_to_uid failed!\n",
3923 __func__);
3924 } else
3925 dprintk("%s: name too long (%u)!\n",
3926 __func__, len);
3927 bitmap[1] &= ~FATTR4_WORD1_OWNER;
3928 } 3918 }
3929 dprintk("%s: uid=%d\n", __func__, (int)from_kuid(&init_user_ns, *uid)); 3919out:
3930 return ret; 3920 if (len != -EBADMSG)
3931out_overflow: 3921 return 0;
3932 print_overflow_msg(__func__, xdr); 3922 print_overflow_msg(__func__, xdr);
3933 return -EIO; 3923 return -EIO;
3934} 3924}
@@ -3937,41 +3927,33 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap,
3937 const struct nfs_server *server, kgid_t *gid, 3927 const struct nfs_server *server, kgid_t *gid,
3938 struct nfs4_string *group_name) 3928 struct nfs4_string *group_name)
3939{ 3929{
3940 uint32_t len; 3930 ssize_t len;
3941 __be32 *p; 3931 char *p;
3942 int ret = 0;
3943 3932
3944 *gid = make_kgid(&init_user_ns, -2); 3933 *gid = make_kgid(&init_user_ns, -2);
3945 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U))) 3934 if (unlikely(bitmap[1] & (FATTR4_WORD1_OWNER_GROUP - 1U)))
3946 return -EIO; 3935 return -EIO;
3947 if (likely(bitmap[1] & FATTR4_WORD1_OWNER_GROUP)) { 3936 if (!(bitmap[1] & FATTR4_WORD1_OWNER_GROUP))
3948 p = xdr_inline_decode(xdr, 4); 3937 return 0;
3949 if (unlikely(!p)) 3938 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
3950 goto out_overflow; 3939
3951 len = be32_to_cpup(p); 3940 if (group_name != NULL) {
3952 p = xdr_inline_decode(xdr, len); 3941 len = decode_nfs4_string(xdr, group_name, GFP_NOWAIT);
3953 if (unlikely(!p)) 3942 if (len <= 0)
3954 goto out_overflow; 3943 goto out;
3955 if (group_name != NULL) { 3944 dprintk("%s: name=%s\n", __func__, group_name->data);
3956 group_name->data = kmemdup(p, len, GFP_NOWAIT); 3945 return NFS_ATTR_FATTR_OWNER_NAME;
3957 if (group_name->data != NULL) { 3946 } else {
3958 group_name->len = len; 3947 len = xdr_stream_decode_opaque_inline(xdr, (void **)&p,
3959 ret = NFS_ATTR_FATTR_GROUP_NAME; 3948 XDR_MAX_NETOBJ);
3960 } 3949 if (len <= 0 || nfs_map_group_to_gid(server, p, len, gid) != 0)
3961 } else if (len < XDR_MAX_NETOBJ) { 3950 goto out;
3962 if (nfs_map_group_to_gid(server, (char *)p, len, gid) == 0) 3951 dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid));
3963 ret = NFS_ATTR_FATTR_GROUP; 3952 return NFS_ATTR_FATTR_GROUP;
3964 else
3965 dprintk("%s: nfs_map_group_to_gid failed!\n",
3966 __func__);
3967 } else
3968 dprintk("%s: name too long (%u)!\n",
3969 __func__, len);
3970 bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP;
3971 } 3953 }
3972 dprintk("%s: gid=%d\n", __func__, (int)from_kgid(&init_user_ns, *gid)); 3954out:
3973 return ret; 3955 if (len != -EBADMSG)
3974out_overflow: 3956 return 0;
3975 print_overflow_msg(__func__, xdr); 3957 print_overflow_msg(__func__, xdr);
3976 return -EIO; 3958 return -EIO;
3977} 3959}
@@ -4294,15 +4276,12 @@ out_overflow:
4294 4276
4295static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len) 4277static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
4296{ 4278{
4297 __be32 *p; 4279 ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
4298 4280 if (unlikely(ret < 0)) {
4299 p = xdr_inline_decode(xdr, len); 4281 print_overflow_msg(__func__, xdr);
4300 if (likely(p)) { 4282 return -EIO;
4301 memcpy(buf, p, len);
4302 return 0;
4303 } 4283 }
4304 print_overflow_msg(__func__, xdr); 4284 return 0;
4305 return -EIO;
4306} 4285}
4307 4286
4308static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid) 4287static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
@@ -5093,7 +5072,7 @@ static int decode_rw_delegation(struct xdr_stream *xdr,
5093 if (decode_space_limit(xdr, &res->pagemod_limit) < 0) 5072 if (decode_space_limit(xdr, &res->pagemod_limit) < 0)
5094 return -EIO; 5073 return -EIO;
5095 } 5074 }
5096 return decode_ace(xdr, NULL, res->server->nfs_client); 5075 return decode_ace(xdr, NULL);
5097out_overflow: 5076out_overflow:
5098 print_overflow_msg(__func__, xdr); 5077 print_overflow_msg(__func__, xdr);
5099 return -EIO; 5078 return -EIO;
@@ -5660,8 +5639,6 @@ static int decode_exchange_id(struct xdr_stream *xdr,
5660 status = decode_opaque_inline(xdr, &dummy, &dummy_str); 5639 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5661 if (unlikely(status)) 5640 if (unlikely(status))
5662 return status; 5641 return status;
5663 if (unlikely(dummy > NFS4_OPAQUE_LIMIT))
5664 return -EIO;
5665 memcpy(res->server_owner->major_id, dummy_str, dummy); 5642 memcpy(res->server_owner->major_id, dummy_str, dummy);
5666 res->server_owner->major_id_sz = dummy; 5643 res->server_owner->major_id_sz = dummy;
5667 5644
@@ -5669,8 +5646,6 @@ static int decode_exchange_id(struct xdr_stream *xdr,
5669 status = decode_opaque_inline(xdr, &dummy, &dummy_str); 5646 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5670 if (unlikely(status)) 5647 if (unlikely(status))
5671 return status; 5648 return status;
5672 if (unlikely(dummy > NFS4_OPAQUE_LIMIT))
5673 return -EIO;
5674 memcpy(res->server_scope->server_scope, dummy_str, dummy); 5649 memcpy(res->server_scope->server_scope, dummy_str, dummy);
5675 res->server_scope->server_scope_sz = dummy; 5650 res->server_scope->server_scope_sz = dummy;
5676 5651
@@ -5685,16 +5660,12 @@ static int decode_exchange_id(struct xdr_stream *xdr,
5685 status = decode_opaque_inline(xdr, &dummy, &dummy_str); 5660 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5686 if (unlikely(status)) 5661 if (unlikely(status))
5687 return status; 5662 return status;
5688 if (unlikely(dummy > NFS4_OPAQUE_LIMIT))
5689 return -EIO;
5690 memcpy(res->impl_id->domain, dummy_str, dummy); 5663 memcpy(res->impl_id->domain, dummy_str, dummy);
5691 5664
5692 /* nii_name */ 5665 /* nii_name */
5693 status = decode_opaque_inline(xdr, &dummy, &dummy_str); 5666 status = decode_opaque_inline(xdr, &dummy, &dummy_str);
5694 if (unlikely(status)) 5667 if (unlikely(status))
5695 return status; 5668 return status;
5696 if (unlikely(dummy > NFS4_OPAQUE_LIMIT))
5697 return -EIO;
5698 memcpy(res->impl_id->name, dummy_str, dummy); 5669 memcpy(res->impl_id->name, dummy_str, dummy);
5699 5670
5700 /* nii_date */ 5671 /* nii_date */
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 6bca17883b93..54e0f9f2dd94 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -531,39 +531,32 @@ static void nfs_show_mountd_netid(struct seq_file *m, struct nfs_server *nfss,
531 int showdefaults) 531 int showdefaults)
532{ 532{
533 struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address; 533 struct sockaddr *sap = (struct sockaddr *) &nfss->mountd_address;
534 char *proto = NULL;
534 535
535 seq_printf(m, ",mountproto=");
536 switch (sap->sa_family) { 536 switch (sap->sa_family) {
537 case AF_INET: 537 case AF_INET:
538 switch (nfss->mountd_protocol) { 538 switch (nfss->mountd_protocol) {
539 case IPPROTO_UDP: 539 case IPPROTO_UDP:
540 seq_printf(m, RPCBIND_NETID_UDP); 540 proto = RPCBIND_NETID_UDP;
541 break; 541 break;
542 case IPPROTO_TCP: 542 case IPPROTO_TCP:
543 seq_printf(m, RPCBIND_NETID_TCP); 543 proto = RPCBIND_NETID_TCP;
544 break; 544 break;
545 default:
546 if (showdefaults)
547 seq_printf(m, "auto");
548 } 545 }
549 break; 546 break;
550 case AF_INET6: 547 case AF_INET6:
551 switch (nfss->mountd_protocol) { 548 switch (nfss->mountd_protocol) {
552 case IPPROTO_UDP: 549 case IPPROTO_UDP:
553 seq_printf(m, RPCBIND_NETID_UDP6); 550 proto = RPCBIND_NETID_UDP6;
554 break; 551 break;
555 case IPPROTO_TCP: 552 case IPPROTO_TCP:
556 seq_printf(m, RPCBIND_NETID_TCP6); 553 proto = RPCBIND_NETID_TCP6;
557 break; 554 break;
558 default:
559 if (showdefaults)
560 seq_printf(m, "auto");
561 } 555 }
562 break; 556 break;
563 default:
564 if (showdefaults)
565 seq_printf(m, "auto");
566 } 557 }
558 if (proto || showdefaults)
559 seq_printf(m, ",mountproto=%s", proto ?: "auto");
567} 560}
568 561
569static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss, 562static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 006068526542..e75b056f46f4 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1785,7 +1785,7 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data)
1785 if (status < 0) { 1785 if (status < 0) {
1786 nfs_context_set_write_error(req->wb_context, status); 1786 nfs_context_set_write_error(req->wb_context, status);
1787 nfs_inode_remove_request(req); 1787 nfs_inode_remove_request(req);
1788 dprintk(", error = %d\n", status); 1788 dprintk_cont(", error = %d\n", status);
1789 goto next; 1789 goto next;
1790 } 1790 }
1791 1791
@@ -1794,11 +1794,11 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data)
1794 if (!nfs_write_verifier_cmp(&req->wb_verf, &data->verf.verifier)) { 1794 if (!nfs_write_verifier_cmp(&req->wb_verf, &data->verf.verifier)) {
1795 /* We have a match */ 1795 /* We have a match */
1796 nfs_inode_remove_request(req); 1796 nfs_inode_remove_request(req);
1797 dprintk(" OK\n"); 1797 dprintk_cont(" OK\n");
1798 goto next; 1798 goto next;
1799 } 1799 }
1800 /* We have a mismatch. Write the page again */ 1800 /* We have a mismatch. Write the page again */
1801 dprintk(" mismatch\n"); 1801 dprintk_cont(" mismatch\n");
1802 nfs_mark_request_dirty(req); 1802 nfs_mark_request_dirty(req);
1803 set_bit(NFS_CONTEXT_RESEND_WRITES, &req->wb_context->flags); 1803 set_bit(NFS_CONTEXT_RESEND_WRITES, &req->wb_context->flags);
1804 next: 1804 next:
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index 76e28c229805..0efef9cf014f 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -200,8 +200,8 @@
200#ifdef CONFIG_STACK_VALIDATION 200#ifdef CONFIG_STACK_VALIDATION
201#define annotate_unreachable() ({ \ 201#define annotate_unreachable() ({ \
202 asm("%c0:\t\n" \ 202 asm("%c0:\t\n" \
203 ".pushsection __unreachable, \"a\"\t\n" \ 203 ".pushsection .discard.unreachable\t\n" \
204 ".long %c0b\t\n" \ 204 ".long %c0b - .\t\n" \
205 ".popsection\t\n" : : "i" (__LINE__)); \ 205 ".popsection\t\n" : : "i" (__LINE__)); \
206}) 206})
207#else 207#else
diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h
index cea41a124a80..e2d239ed4c60 100644
--- a/include/linux/f2fs_fs.h
+++ b/include/linux/f2fs_fs.h
@@ -36,6 +36,12 @@
36#define F2FS_NODE_INO(sbi) (sbi->node_ino_num) 36#define F2FS_NODE_INO(sbi) (sbi->node_ino_num)
37#define F2FS_META_INO(sbi) (sbi->meta_ino_num) 37#define F2FS_META_INO(sbi) (sbi->meta_ino_num)
38 38
39#define F2FS_IO_SIZE(sbi) (1 << (sbi)->write_io_size_bits) /* Blocks */
40#define F2FS_IO_SIZE_KB(sbi) (1 << ((sbi)->write_io_size_bits + 2)) /* KB */
41#define F2FS_IO_SIZE_BYTES(sbi) (1 << ((sbi)->write_io_size_bits + 12)) /* B */
42#define F2FS_IO_SIZE_BITS(sbi) ((sbi)->write_io_size_bits) /* power of 2 */
43#define F2FS_IO_SIZE_MASK(sbi) (F2FS_IO_SIZE(sbi) - 1)
44
39/* This flag is used by node and meta inodes, and by recovery */ 45/* This flag is used by node and meta inodes, and by recovery */
40#define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO) 46#define GFP_F2FS_ZERO (GFP_NOFS | __GFP_ZERO)
41#define GFP_F2FS_HIGH_ZERO (GFP_NOFS | __GFP_ZERO | __GFP_HIGHMEM) 47#define GFP_F2FS_HIGH_ZERO (GFP_NOFS | __GFP_ZERO | __GFP_HIGHMEM)
@@ -108,6 +114,7 @@ struct f2fs_super_block {
108/* 114/*
109 * For checkpoint 115 * For checkpoint
110 */ 116 */
117#define CP_NAT_BITS_FLAG 0x00000080
111#define CP_CRC_RECOVERY_FLAG 0x00000040 118#define CP_CRC_RECOVERY_FLAG 0x00000040
112#define CP_FASTBOOT_FLAG 0x00000020 119#define CP_FASTBOOT_FLAG 0x00000020
113#define CP_FSCK_FLAG 0x00000010 120#define CP_FSCK_FLAG 0x00000010
@@ -272,6 +279,7 @@ struct f2fs_node {
272 * For NAT entries 279 * For NAT entries
273 */ 280 */
274#define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry)) 281#define NAT_ENTRY_PER_BLOCK (PAGE_SIZE / sizeof(struct f2fs_nat_entry))
282#define NAT_ENTRY_BITMAP_SIZE ((NAT_ENTRY_PER_BLOCK + 7) / 8)
275 283
276struct f2fs_nat_entry { 284struct f2fs_nat_entry {
277 __u8 version; /* latest version of cached nat entry */ 285 __u8 version; /* latest version of cached nat entry */
diff --git a/include/linux/frame.h b/include/linux/frame.h
index e6baaba3f1ae..d772c61c31da 100644
--- a/include/linux/frame.h
+++ b/include/linux/frame.h
@@ -11,7 +11,7 @@
11 * For more information, see tools/objtool/Documentation/stack-validation.txt. 11 * For more information, see tools/objtool/Documentation/stack-validation.txt.
12 */ 12 */
13#define STACK_FRAME_NON_STANDARD(func) \ 13#define STACK_FRAME_NON_STANDARD(func) \
14 static void __used __section(__func_stack_frame_non_standard) \ 14 static void __used __section(.discard.func_stack_frame_non_standard) \
15 *__func_stack_frame_non_standard_##func = func 15 *__func_stack_frame_non_standard_##func = func
16 16
17#else /* !CONFIG_STACK_VALIDATION */ 17#else /* !CONFIG_STACK_VALIDATION */
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index c15373894a42..b37dee3acaba 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -355,7 +355,8 @@ static inline int nlm_privileged_requester(const struct svc_rqst *rqstp)
355static inline int nlm_compare_locks(const struct file_lock *fl1, 355static inline int nlm_compare_locks(const struct file_lock *fl1,
356 const struct file_lock *fl2) 356 const struct file_lock *fl2)
357{ 357{
358 return fl1->fl_pid == fl2->fl_pid 358 return file_inode(fl1->fl_file) == file_inode(fl2->fl_file)
359 && fl1->fl_pid == fl2->fl_pid
359 && fl1->fl_owner == fl2->fl_owner 360 && fl1->fl_owner == fl2->fl_owner
360 && fl1->fl_start == fl2->fl_start 361 && fl1->fl_start == fl2->fl_start
361 && fl1->fl_end == fl2->fl_end 362 && fl1->fl_end == fl2->fl_end
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 2c6c5114c089..08fad7c6a471 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -287,8 +287,6 @@ struct pwm_ops {
287 * @pwms: array of PWM devices allocated by the framework 287 * @pwms: array of PWM devices allocated by the framework
288 * @of_xlate: request a PWM device given a device tree PWM specifier 288 * @of_xlate: request a PWM device given a device tree PWM specifier
289 * @of_pwm_n_cells: number of cells expected in the device tree PWM specifier 289 * @of_pwm_n_cells: number of cells expected in the device tree PWM specifier
290 * @can_sleep: must be true if the .config(), .enable() or .disable()
291 * operations may sleep
292 */ 290 */
293struct pwm_chip { 291struct pwm_chip {
294 struct device *dev; 292 struct device *dev;
@@ -302,7 +300,6 @@ struct pwm_chip {
302 struct pwm_device * (*of_xlate)(struct pwm_chip *pc, 300 struct pwm_device * (*of_xlate)(struct pwm_chip *pc,
303 const struct of_phandle_args *args); 301 const struct of_phandle_args *args);
304 unsigned int of_pwm_n_cells; 302 unsigned int of_pwm_n_cells;
305 bool can_sleep;
306}; 303};
307 304
308/** 305/**
@@ -451,8 +448,6 @@ struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id);
451struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np, 448struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
452 const char *con_id); 449 const char *con_id);
453void devm_pwm_put(struct device *dev, struct pwm_device *pwm); 450void devm_pwm_put(struct device *dev, struct pwm_device *pwm);
454
455bool pwm_can_sleep(struct pwm_device *pwm);
456#else 451#else
457static inline struct pwm_device *pwm_request(int pwm_id, const char *label) 452static inline struct pwm_device *pwm_request(int pwm_id, const char *label)
458{ 453{
@@ -566,11 +561,6 @@ static inline struct pwm_device *devm_of_pwm_get(struct device *dev,
566static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm) 561static inline void devm_pwm_put(struct device *dev, struct pwm_device *pwm)
567{ 562{
568} 563}
569
570static inline bool pwm_can_sleep(struct pwm_device *pwm)
571{
572 return false;
573}
574#endif 564#endif
575 565
576static inline void pwm_apply_args(struct pwm_device *pwm) 566static inline void pwm_apply_args(struct pwm_device *pwm)
@@ -613,18 +603,25 @@ struct pwm_lookup {
613 const char *con_id; 603 const char *con_id;
614 unsigned int period; 604 unsigned int period;
615 enum pwm_polarity polarity; 605 enum pwm_polarity polarity;
606 const char *module; /* optional, may be NULL */
616}; 607};
617 608
618#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \ 609#define PWM_LOOKUP_WITH_MODULE(_provider, _index, _dev_id, _con_id, \
619 { \ 610 _period, _polarity, _module) \
620 .provider = _provider, \ 611 { \
621 .index = _index, \ 612 .provider = _provider, \
622 .dev_id = _dev_id, \ 613 .index = _index, \
623 .con_id = _con_id, \ 614 .dev_id = _dev_id, \
624 .period = _period, \ 615 .con_id = _con_id, \
625 .polarity = _polarity \ 616 .period = _period, \
617 .polarity = _polarity, \
618 .module = _module, \
626 } 619 }
627 620
621#define PWM_LOOKUP(_provider, _index, _dev_id, _con_id, _period, _polarity) \
622 PWM_LOOKUP_WITH_MODULE(_provider, _index, _dev_id, _con_id, _period, \
623 _polarity, NULL)
624
628#if IS_ENABLED(CONFIG_PWM) 625#if IS_ENABLED(CONFIG_PWM)
629void pwm_add_table(struct pwm_lookup *table, size_t num); 626void pwm_add_table(struct pwm_lookup *table, size_t num);
630void pwm_remove_table(struct pwm_lookup *table, size_t num); 627void pwm_remove_table(struct pwm_lookup *table, size_t num);
diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h
index b1bc62ba20a2..8fd3504946ad 100644
--- a/include/linux/sunrpc/auth.h
+++ b/include/linux/sunrpc/auth.h
@@ -32,6 +32,7 @@
32 */ 32 */
33#define UNX_MAXNODENAME __NEW_UTS_LEN 33#define UNX_MAXNODENAME __NEW_UTS_LEN
34#define UNX_CALLSLACK (21 + XDR_QUADLEN(UNX_MAXNODENAME)) 34#define UNX_CALLSLACK (21 + XDR_QUADLEN(UNX_MAXNODENAME))
35#define UNX_NGROUPS 16
35 36
36struct rpcsec_gss_info; 37struct rpcsec_gss_info;
37 38
@@ -63,9 +64,6 @@ struct rpc_cred {
63 struct rcu_head cr_rcu; 64 struct rcu_head cr_rcu;
64 struct rpc_auth * cr_auth; 65 struct rpc_auth * cr_auth;
65 const struct rpc_credops *cr_ops; 66 const struct rpc_credops *cr_ops;
66#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
67 unsigned long cr_magic; /* 0x0f4aa4f0 */
68#endif
69 unsigned long cr_expire; /* when to gc */ 67 unsigned long cr_expire; /* when to gc */
70 unsigned long cr_flags; /* various flags */ 68 unsigned long cr_flags; /* various flags */
71 atomic_t cr_count; /* ref count */ 69 atomic_t cr_count; /* ref count */
@@ -79,8 +77,6 @@ struct rpc_cred {
79#define RPCAUTH_CRED_HASHED 2 77#define RPCAUTH_CRED_HASHED 2
80#define RPCAUTH_CRED_NEGATIVE 3 78#define RPCAUTH_CRED_NEGATIVE 3
81 79
82#define RPCAUTH_CRED_MAGIC 0x0f4aa4f0
83
84/* rpc_auth au_flags */ 80/* rpc_auth au_flags */
85#define RPCAUTH_AUTH_NO_CRKEY_TIMEOUT 0x0001 /* underlying cred has no key timeout */ 81#define RPCAUTH_AUTH_NO_CRKEY_TIMEOUT 0x0001 /* underlying cred has no key timeout */
86 82
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index 20d157a518a7..270bad0e1bed 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -63,15 +63,6 @@ struct cache_head {
63 63
64#define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */ 64#define CACHE_NEW_EXPIRY 120 /* keep new things pending confirmation for 120 seconds */
65 65
66struct cache_detail_procfs {
67 struct proc_dir_entry *proc_ent;
68 struct proc_dir_entry *flush_ent, *channel_ent, *content_ent;
69};
70
71struct cache_detail_pipefs {
72 struct dentry *dir;
73};
74
75struct cache_detail { 66struct cache_detail {
76 struct module * owner; 67 struct module * owner;
77 int hash_size; 68 int hash_size;
@@ -123,9 +114,9 @@ struct cache_detail {
123 time_t last_warn; /* when we last warned about no readers */ 114 time_t last_warn; /* when we last warned about no readers */
124 115
125 union { 116 union {
126 struct cache_detail_procfs procfs; 117 struct proc_dir_entry *procfs;
127 struct cache_detail_pipefs pipefs; 118 struct dentry *pipefs;
128 } u; 119 };
129 struct net *net; 120 struct net *net;
130}; 121};
131 122
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 333ad11b3dd9..6095ecba0dde 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -182,7 +182,6 @@ int rpc_protocol(struct rpc_clnt *);
182struct net * rpc_net_ns(struct rpc_clnt *); 182struct net * rpc_net_ns(struct rpc_clnt *);
183size_t rpc_max_payload(struct rpc_clnt *); 183size_t rpc_max_payload(struct rpc_clnt *);
184size_t rpc_max_bc_payload(struct rpc_clnt *); 184size_t rpc_max_bc_payload(struct rpc_clnt *);
185unsigned long rpc_get_timeout(struct rpc_clnt *clnt);
186void rpc_force_rebind(struct rpc_clnt *); 185void rpc_force_rebind(struct rpc_clnt *);
187size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); 186size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
188const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); 187const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
@@ -202,8 +201,9 @@ int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *,
202 struct rpc_xprt *, 201 struct rpc_xprt *,
203 void *), 202 void *),
204 void *data); 203 void *data);
205void rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt, 204void rpc_set_connect_timeout(struct rpc_clnt *clnt,
206 unsigned long timeo); 205 unsigned long connect_timeout,
206 unsigned long reconnect_timeout);
207 207
208int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *, 208int rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *,
209 struct rpc_xprt_switch *, 209 struct rpc_xprt_switch *,
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index 59a7889e15db..8da0f37f3bdc 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -20,33 +20,55 @@ extern unsigned int nfsd_debug;
20extern unsigned int nlm_debug; 20extern unsigned int nlm_debug;
21#endif 21#endif
22 22
23#define dprintk(args...) dfprintk(FACILITY, ## args) 23#define dprintk(fmt, ...) \
24#define dprintk_rcu(args...) dfprintk_rcu(FACILITY, ## args) 24 dfprintk(FACILITY, fmt, ##__VA_ARGS__)
25#define dprintk_cont(fmt, ...) \
26 dfprintk_cont(FACILITY, fmt, ##__VA_ARGS__)
27#define dprintk_rcu(fmt, ...) \
28 dfprintk_rcu(FACILITY, fmt, ##__VA_ARGS__)
29#define dprintk_rcu_cont(fmt, ...) \
30 dfprintk_rcu_cont(FACILITY, fmt, ##__VA_ARGS__)
25 31
26#undef ifdebug 32#undef ifdebug
27#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 33#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
28# define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac)) 34# define ifdebug(fac) if (unlikely(rpc_debug & RPCDBG_##fac))
29 35
30# define dfprintk(fac, args...) \ 36# define dfprintk(fac, fmt, ...) \
31 do { \ 37do { \
32 ifdebug(fac) \ 38 ifdebug(fac) \
33 printk(KERN_DEFAULT args); \ 39 printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \
34 } while (0) 40} while (0)
35 41
36# define dfprintk_rcu(fac, args...) \ 42# define dfprintk_cont(fac, fmt, ...) \
37 do { \ 43do { \
38 ifdebug(fac) { \ 44 ifdebug(fac) \
39 rcu_read_lock(); \ 45 printk(KERN_CONT fmt, ##__VA_ARGS__); \
40 printk(KERN_DEFAULT args); \ 46} while (0)
41 rcu_read_unlock(); \ 47
42 } \ 48# define dfprintk_rcu(fac, fmt, ...) \
43 } while (0) 49do { \
50 ifdebug(fac) { \
51 rcu_read_lock(); \
52 printk(KERN_DEFAULT fmt, ##__VA_ARGS__); \
53 rcu_read_unlock(); \
54 } \
55} while (0)
56
57# define dfprintk_rcu_cont(fac, fmt, ...) \
58do { \
59 ifdebug(fac) { \
60 rcu_read_lock(); \
61 printk(KERN_CONT fmt, ##__VA_ARGS__); \
62 rcu_read_unlock(); \
63 } \
64} while (0)
44 65
45# define RPC_IFDEBUG(x) x 66# define RPC_IFDEBUG(x) x
46#else 67#else
47# define ifdebug(fac) if (0) 68# define ifdebug(fac) if (0)
48# define dfprintk(fac, args...) do {} while (0) 69# define dfprintk(fac, fmt, ...) do {} while (0)
49# define dfprintk_rcu(fac, args...) do {} while (0) 70# define dfprintk_cont(fac, fmt, ...) do {} while (0)
71# define dfprintk_rcu(fac, fmt, ...) do {} while (0)
50# define RPC_IFDEBUG(x) 72# define RPC_IFDEBUG(x)
51#endif 73#endif
52 74
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 56c48c884a24..054c8cde18f3 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -242,6 +242,185 @@ extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len);
242extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); 242extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len);
243extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data); 243extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data);
244 244
245ssize_t xdr_stream_decode_string_dup(struct xdr_stream *xdr, char **str,
246 size_t maxlen, gfp_t gfp_flags);
247/**
248 * xdr_align_size - Calculate padded size of an object
249 * @n: Size of an object being XDR encoded (in bytes)
250 *
251 * Return value:
252 * Size (in bytes) of the object including xdr padding
253 */
254static inline size_t
255xdr_align_size(size_t n)
256{
257 const size_t mask = sizeof(__u32) - 1;
258
259 return (n + mask) & ~mask;
260}
261
262/**
263 * xdr_stream_encode_u32 - Encode a 32-bit integer
264 * @xdr: pointer to xdr_stream
265 * @n: integer to encode
266 *
267 * Return values:
268 * On success, returns length in bytes of XDR buffer consumed
269 * %-EMSGSIZE on XDR buffer overflow
270 */
271static inline ssize_t
272xdr_stream_encode_u32(struct xdr_stream *xdr, __u32 n)
273{
274 const size_t len = sizeof(n);
275 __be32 *p = xdr_reserve_space(xdr, len);
276
277 if (unlikely(!p))
278 return -EMSGSIZE;
279 *p = cpu_to_be32(n);
280 return len;
281}
282
283/**
284 * xdr_stream_encode_u64 - Encode a 64-bit integer
285 * @xdr: pointer to xdr_stream
286 * @n: 64-bit integer to encode
287 *
288 * Return values:
289 * On success, returns length in bytes of XDR buffer consumed
290 * %-EMSGSIZE on XDR buffer overflow
291 */
292static inline ssize_t
293xdr_stream_encode_u64(struct xdr_stream *xdr, __u64 n)
294{
295 const size_t len = sizeof(n);
296 __be32 *p = xdr_reserve_space(xdr, len);
297
298 if (unlikely(!p))
299 return -EMSGSIZE;
300 xdr_encode_hyper(p, n);
301 return len;
302}
303
304/**
305 * xdr_stream_encode_opaque_fixed - Encode fixed length opaque xdr data
306 * @xdr: pointer to xdr_stream
307 * @ptr: pointer to opaque data object
308 * @len: size of object pointed to by @ptr
309 *
310 * Return values:
311 * On success, returns length in bytes of XDR buffer consumed
312 * %-EMSGSIZE on XDR buffer overflow
313 */
314static inline ssize_t
315xdr_stream_encode_opaque_fixed(struct xdr_stream *xdr, const void *ptr, size_t len)
316{
317 __be32 *p = xdr_reserve_space(xdr, len);
318
319 if (unlikely(!p))
320 return -EMSGSIZE;
321 xdr_encode_opaque_fixed(p, ptr, len);
322 return xdr_align_size(len);
323}
324
325/**
326 * xdr_stream_encode_opaque - Encode variable length opaque xdr data
327 * @xdr: pointer to xdr_stream
328 * @ptr: pointer to opaque data object
329 * @len: size of object pointed to by @ptr
330 *
331 * Return values:
332 * On success, returns length in bytes of XDR buffer consumed
333 * %-EMSGSIZE on XDR buffer overflow
334 */
335static inline ssize_t
336xdr_stream_encode_opaque(struct xdr_stream *xdr, const void *ptr, size_t len)
337{
338 size_t count = sizeof(__u32) + xdr_align_size(len);
339 __be32 *p = xdr_reserve_space(xdr, count);
340
341 if (unlikely(!p))
342 return -EMSGSIZE;
343 xdr_encode_opaque(p, ptr, len);
344 return count;
345}
346
347/**
348 * xdr_stream_decode_u32 - Decode a 32-bit integer
349 * @xdr: pointer to xdr_stream
350 * @ptr: location to store integer
351 *
352 * Return values:
353 * %0 on success
354 * %-EBADMSG on XDR buffer overflow
355 */
356static inline ssize_t
357xdr_stream_decode_u32(struct xdr_stream *xdr, __u32 *ptr)
358{
359 const size_t count = sizeof(*ptr);
360 __be32 *p = xdr_inline_decode(xdr, count);
361
362 if (unlikely(!p))
363 return -EBADMSG;
364 *ptr = be32_to_cpup(p);
365 return 0;
366}
367
368/**
369 * xdr_stream_decode_opaque_fixed - Decode fixed length opaque xdr data
370 * @xdr: pointer to xdr_stream
371 * @ptr: location to store data
372 * @len: size of buffer pointed to by @ptr
373 *
374 * Return values:
375 * On success, returns size of object stored in @ptr
376 * %-EBADMSG on XDR buffer overflow
377 */
378static inline ssize_t
379xdr_stream_decode_opaque_fixed(struct xdr_stream *xdr, void *ptr, size_t len)
380{
381 __be32 *p = xdr_inline_decode(xdr, len);
382
383 if (unlikely(!p))
384 return -EBADMSG;
385 xdr_decode_opaque_fixed(p, ptr, len);
386 return len;
387}
388
389/**
390 * xdr_stream_decode_opaque_inline - Decode variable length opaque xdr data
391 * @xdr: pointer to xdr_stream
392 * @ptr: location to store pointer to opaque data
393 * @maxlen: maximum acceptable object size
394 *
395 * Note: the pointer stored in @ptr cannot be assumed valid after the XDR
396 * buffer has been destroyed, or even after calling xdr_inline_decode()
397 * on @xdr. It is therefore expected that the object it points to should
398 * be processed immediately.
399 *
400 * Return values:
401 * On success, returns size of object stored in *@ptr
402 * %-EBADMSG on XDR buffer overflow
403 * %-EMSGSIZE if the size of the object would exceed @maxlen
404 */
405static inline ssize_t
406xdr_stream_decode_opaque_inline(struct xdr_stream *xdr, void **ptr, size_t maxlen)
407{
408 __be32 *p;
409 __u32 len;
410
411 *ptr = NULL;
412 if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0))
413 return -EBADMSG;
414 if (len != 0) {
415 p = xdr_inline_decode(xdr, len);
416 if (unlikely(!p))
417 return -EBADMSG;
418 if (unlikely(len > maxlen))
419 return -EMSGSIZE;
420 *ptr = p;
421 }
422 return len;
423}
245#endif /* __KERNEL__ */ 424#endif /* __KERNEL__ */
246 425
247#endif /* _SUNRPC_XDR_H_ */ 426#endif /* _SUNRPC_XDR_H_ */
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index a5da60b24d83..eab1c749e192 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -137,6 +137,9 @@ struct rpc_xprt_ops {
137 void (*release_request)(struct rpc_task *task); 137 void (*release_request)(struct rpc_task *task);
138 void (*close)(struct rpc_xprt *xprt); 138 void (*close)(struct rpc_xprt *xprt);
139 void (*destroy)(struct rpc_xprt *xprt); 139 void (*destroy)(struct rpc_xprt *xprt);
140 void (*set_connect_timeout)(struct rpc_xprt *xprt,
141 unsigned long connect_timeout,
142 unsigned long reconnect_timeout);
140 void (*print_stats)(struct rpc_xprt *xprt, struct seq_file *seq); 143 void (*print_stats)(struct rpc_xprt *xprt, struct seq_file *seq);
141 int (*enable_swap)(struct rpc_xprt *xprt); 144 int (*enable_swap)(struct rpc_xprt *xprt);
142 void (*disable_swap)(struct rpc_xprt *xprt); 145 void (*disable_swap)(struct rpc_xprt *xprt);
@@ -221,6 +224,7 @@ struct rpc_xprt {
221 struct timer_list timer; 224 struct timer_list timer;
222 unsigned long last_used, 225 unsigned long last_used,
223 idle_timeout, 226 idle_timeout,
227 connect_timeout,
224 max_reconnect_timeout; 228 max_reconnect_timeout;
225 229
226 /* 230 /*
diff --git a/include/linux/sunrpc/xprtsock.h b/include/linux/sunrpc/xprtsock.h
index bef3fb0abb8f..c9959d7e3579 100644
--- a/include/linux/sunrpc/xprtsock.h
+++ b/include/linux/sunrpc/xprtsock.h
@@ -55,6 +55,8 @@ struct sock_xprt {
55 size_t rcvsize, 55 size_t rcvsize,
56 sndsize; 56 sndsize;
57 57
58 struct rpc_timeout tcp_timeout;
59
58 /* 60 /*
59 * Saved socket callback addresses 61 * Saved socket callback addresses
60 */ 62 */
@@ -81,6 +83,7 @@ struct sock_xprt {
81 83
82#define XPRT_SOCK_CONNECTING 1U 84#define XPRT_SOCK_CONNECTING 1U
83#define XPRT_SOCK_DATA_READY (2) 85#define XPRT_SOCK_DATA_READY (2)
86#define XPRT_SOCK_UPD_TIMEOUT (3)
84 87
85#endif /* __KERNEL__ */ 88#endif /* __KERNEL__ */
86 89
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index e275e98bdceb..dab11f97e1c6 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -194,7 +194,7 @@ struct thermal_attr {
194 * @governor: pointer to the governor for this thermal zone 194 * @governor: pointer to the governor for this thermal zone
195 * @governor_data: private pointer for governor data 195 * @governor_data: private pointer for governor data
196 * @thermal_instances: list of &struct thermal_instance of this thermal zone 196 * @thermal_instances: list of &struct thermal_instance of this thermal zone
197 * @idr: &struct idr to generate unique id for this zone's cooling 197 * @ida: &struct ida to generate unique id for this zone's cooling
198 * devices 198 * devices
199 * @lock: lock to protect thermal_instances list 199 * @lock: lock to protect thermal_instances list
200 * @node: node in thermal_tz_list (in thermal_core.c) 200 * @node: node in thermal_tz_list (in thermal_core.c)
@@ -227,7 +227,7 @@ struct thermal_zone_device {
227 struct thermal_governor *governor; 227 struct thermal_governor *governor;
228 void *governor_data; 228 void *governor_data;
229 struct list_head thermal_instances; 229 struct list_head thermal_instances;
230 struct idr idr; 230 struct ida ida;
231 struct mutex lock; 231 struct mutex lock;
232 struct list_head node; 232 struct list_head node;
233 struct delayed_work poll_queue; 233 struct delayed_work poll_queue;
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 01b3c9869a0d..c80fcad0a6c9 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -6,8 +6,8 @@
6 6
7#include <linux/tracepoint.h> 7#include <linux/tracepoint.h>
8 8
9#define show_dev(entry) MAJOR(entry->dev), MINOR(entry->dev) 9#define show_dev(dev) MAJOR(dev), MINOR(dev)
10#define show_dev_ino(entry) show_dev(entry), (unsigned long)entry->ino 10#define show_dev_ino(entry) show_dev(entry->dev), (unsigned long)entry->ino
11 11
12TRACE_DEFINE_ENUM(NODE); 12TRACE_DEFINE_ENUM(NODE);
13TRACE_DEFINE_ENUM(DATA); 13TRACE_DEFINE_ENUM(DATA);
@@ -55,25 +55,35 @@ TRACE_DEFINE_ENUM(CP_DISCARD);
55 { IPU, "IN-PLACE" }, \ 55 { IPU, "IN-PLACE" }, \
56 { OPU, "OUT-OF-PLACE" }) 56 { OPU, "OUT-OF-PLACE" })
57 57
58#define F2FS_BIO_FLAG_MASK(t) (t & (REQ_RAHEAD | REQ_PREFLUSH | REQ_FUA)) 58#define F2FS_OP_FLAGS (REQ_RAHEAD | REQ_SYNC | REQ_PREFLUSH | REQ_META |\
59#define F2FS_BIO_EXTRA_MASK(t) (t & (REQ_META | REQ_PRIO)) 59 REQ_PRIO)
60 60#define F2FS_BIO_FLAG_MASK(t) (t & F2FS_OP_FLAGS)
61#define show_bio_type(op_flags) show_bio_op_flags(op_flags), \ 61
62 show_bio_extra(op_flags) 62#define show_bio_type(op,op_flags) show_bio_op(op), \
63 show_bio_op_flags(op_flags)
64
65#define show_bio_op(op) \
66 __print_symbolic(op, \
67 { REQ_OP_READ, "READ" }, \
68 { REQ_OP_WRITE, "WRITE" }, \
69 { REQ_OP_FLUSH, "FLUSH" }, \
70 { REQ_OP_DISCARD, "DISCARD" }, \
71 { REQ_OP_ZONE_REPORT, "ZONE_REPORT" }, \
72 { REQ_OP_SECURE_ERASE, "SECURE_ERASE" }, \
73 { REQ_OP_ZONE_RESET, "ZONE_RESET" }, \
74 { REQ_OP_WRITE_SAME, "WRITE_SAME" }, \
75 { REQ_OP_WRITE_ZEROES, "WRITE_ZEROES" })
63 76
64#define show_bio_op_flags(flags) \ 77#define show_bio_op_flags(flags) \
65 __print_symbolic(F2FS_BIO_FLAG_MASK(flags), \ 78 __print_symbolic(F2FS_BIO_FLAG_MASK(flags), \
66 { 0, "WRITE" }, \ 79 { REQ_RAHEAD, "(RA)" }, \
67 { REQ_RAHEAD, "READAHEAD" }, \ 80 { REQ_SYNC, "(S)" }, \
68 { REQ_SYNC, "REQ_SYNC" }, \ 81 { REQ_SYNC | REQ_PRIO, "(SP)" }, \
69 { REQ_PREFLUSH, "REQ_PREFLUSH" }, \
70 { REQ_FUA, "REQ_FUA" })
71
72#define show_bio_extra(type) \
73 __print_symbolic(F2FS_BIO_EXTRA_MASK(type), \
74 { REQ_META, "(M)" }, \ 82 { REQ_META, "(M)" }, \
75 { REQ_PRIO, "(P)" }, \
76 { REQ_META | REQ_PRIO, "(MP)" }, \ 83 { REQ_META | REQ_PRIO, "(MP)" }, \
84 { REQ_SYNC | REQ_PREFLUSH , "(SF)" }, \
85 { REQ_SYNC | REQ_META | REQ_PRIO, "(SMP)" }, \
86 { REQ_PREFLUSH | REQ_META | REQ_PRIO, "(FMP)" }, \
77 { 0, " \b" }) 87 { 0, " \b" })
78 88
79#define show_data_type(type) \ 89#define show_data_type(type) \
@@ -235,7 +245,7 @@ TRACE_EVENT(f2fs_sync_fs,
235 ), 245 ),
236 246
237 TP_printk("dev = (%d,%d), superblock is %s, wait = %d", 247 TP_printk("dev = (%d,%d), superblock is %s, wait = %d",
238 show_dev(__entry), 248 show_dev(__entry->dev),
239 __entry->dirty ? "dirty" : "not dirty", 249 __entry->dirty ? "dirty" : "not dirty",
240 __entry->wait) 250 __entry->wait)
241); 251);
@@ -305,6 +315,13 @@ DEFINE_EVENT(f2fs__inode_exit, f2fs_unlink_exit,
305 TP_ARGS(inode, ret) 315 TP_ARGS(inode, ret)
306); 316);
307 317
318DEFINE_EVENT(f2fs__inode_exit, f2fs_drop_inode,
319
320 TP_PROTO(struct inode *inode, int ret),
321
322 TP_ARGS(inode, ret)
323);
324
308DEFINE_EVENT(f2fs__inode, f2fs_truncate, 325DEFINE_EVENT(f2fs__inode, f2fs_truncate,
309 326
310 TP_PROTO(struct inode *inode), 327 TP_PROTO(struct inode *inode),
@@ -534,7 +551,7 @@ TRACE_EVENT(f2fs_background_gc,
534 ), 551 ),
535 552
536 TP_printk("dev = (%d,%d), wait_ms = %ld, prefree = %u, free = %u", 553 TP_printk("dev = (%d,%d), wait_ms = %ld, prefree = %u, free = %u",
537 show_dev(__entry), 554 show_dev(__entry->dev),
538 __entry->wait_ms, 555 __entry->wait_ms,
539 __entry->prefree, 556 __entry->prefree,
540 __entry->free) 557 __entry->free)
@@ -555,6 +572,7 @@ TRACE_EVENT(f2fs_get_victim,
555 __field(int, alloc_mode) 572 __field(int, alloc_mode)
556 __field(int, gc_mode) 573 __field(int, gc_mode)
557 __field(unsigned int, victim) 574 __field(unsigned int, victim)
575 __field(unsigned int, cost)
558 __field(unsigned int, ofs_unit) 576 __field(unsigned int, ofs_unit)
559 __field(unsigned int, pre_victim) 577 __field(unsigned int, pre_victim)
560 __field(unsigned int, prefree) 578 __field(unsigned int, prefree)
@@ -568,20 +586,23 @@ TRACE_EVENT(f2fs_get_victim,
568 __entry->alloc_mode = p->alloc_mode; 586 __entry->alloc_mode = p->alloc_mode;
569 __entry->gc_mode = p->gc_mode; 587 __entry->gc_mode = p->gc_mode;
570 __entry->victim = p->min_segno; 588 __entry->victim = p->min_segno;
589 __entry->cost = p->min_cost;
571 __entry->ofs_unit = p->ofs_unit; 590 __entry->ofs_unit = p->ofs_unit;
572 __entry->pre_victim = pre_victim; 591 __entry->pre_victim = pre_victim;
573 __entry->prefree = prefree; 592 __entry->prefree = prefree;
574 __entry->free = free; 593 __entry->free = free;
575 ), 594 ),
576 595
577 TP_printk("dev = (%d,%d), type = %s, policy = (%s, %s, %s), victim = %u " 596 TP_printk("dev = (%d,%d), type = %s, policy = (%s, %s, %s), "
578 "ofs_unit = %u, pre_victim_secno = %d, prefree = %u, free = %u", 597 "victim = %u, cost = %u, ofs_unit = %u, "
579 show_dev(__entry), 598 "pre_victim_secno = %d, prefree = %u, free = %u",
599 show_dev(__entry->dev),
580 show_data_type(__entry->type), 600 show_data_type(__entry->type),
581 show_gc_type(__entry->gc_type), 601 show_gc_type(__entry->gc_type),
582 show_alloc_mode(__entry->alloc_mode), 602 show_alloc_mode(__entry->alloc_mode),
583 show_victim_policy(__entry->gc_mode), 603 show_victim_policy(__entry->gc_mode),
584 __entry->victim, 604 __entry->victim,
605 __entry->cost,
585 __entry->ofs_unit, 606 __entry->ofs_unit,
586 (int)__entry->pre_victim, 607 (int)__entry->pre_victim,
587 __entry->prefree, 608 __entry->prefree,
@@ -713,7 +734,7 @@ TRACE_EVENT(f2fs_reserve_new_blocks,
713 ), 734 ),
714 735
715 TP_printk("dev = (%d,%d), nid = %u, ofs_in_node = %u, count = %llu", 736 TP_printk("dev = (%d,%d), nid = %u, ofs_in_node = %u, count = %llu",
716 show_dev(__entry), 737 show_dev(__entry->dev),
717 (unsigned int)__entry->nid, 738 (unsigned int)__entry->nid,
718 __entry->ofs_in_node, 739 __entry->ofs_in_node,
719 (unsigned long long)__entry->count) 740 (unsigned long long)__entry->count)
@@ -753,7 +774,7 @@ DECLARE_EVENT_CLASS(f2fs__submit_page_bio,
753 (unsigned long)__entry->index, 774 (unsigned long)__entry->index,
754 (unsigned long long)__entry->old_blkaddr, 775 (unsigned long long)__entry->old_blkaddr,
755 (unsigned long long)__entry->new_blkaddr, 776 (unsigned long long)__entry->new_blkaddr,
756 show_bio_type(__entry->op_flags), 777 show_bio_type(__entry->op, __entry->op_flags),
757 show_block_type(__entry->type)) 778 show_block_type(__entry->type))
758); 779);
759 780
@@ -775,15 +796,15 @@ DEFINE_EVENT_CONDITION(f2fs__submit_page_bio, f2fs_submit_page_mbio,
775 TP_CONDITION(page->mapping) 796 TP_CONDITION(page->mapping)
776); 797);
777 798
778DECLARE_EVENT_CLASS(f2fs__submit_bio, 799DECLARE_EVENT_CLASS(f2fs__bio,
779 800
780 TP_PROTO(struct super_block *sb, struct f2fs_io_info *fio, 801 TP_PROTO(struct super_block *sb, int type, struct bio *bio),
781 struct bio *bio),
782 802
783 TP_ARGS(sb, fio, bio), 803 TP_ARGS(sb, type, bio),
784 804
785 TP_STRUCT__entry( 805 TP_STRUCT__entry(
786 __field(dev_t, dev) 806 __field(dev_t, dev)
807 __field(dev_t, target)
787 __field(int, op) 808 __field(int, op)
788 __field(int, op_flags) 809 __field(int, op_flags)
789 __field(int, type) 810 __field(int, type)
@@ -793,37 +814,55 @@ DECLARE_EVENT_CLASS(f2fs__submit_bio,
793 814
794 TP_fast_assign( 815 TP_fast_assign(
795 __entry->dev = sb->s_dev; 816 __entry->dev = sb->s_dev;
796 __entry->op = fio->op; 817 __entry->target = bio->bi_bdev->bd_dev;
797 __entry->op_flags = fio->op_flags; 818 __entry->op = bio_op(bio);
798 __entry->type = fio->type; 819 __entry->op_flags = bio->bi_opf;
820 __entry->type = type;
799 __entry->sector = bio->bi_iter.bi_sector; 821 __entry->sector = bio->bi_iter.bi_sector;
800 __entry->size = bio->bi_iter.bi_size; 822 __entry->size = bio->bi_iter.bi_size;
801 ), 823 ),
802 824
803 TP_printk("dev = (%d,%d), rw = %s%s, %s, sector = %lld, size = %u", 825 TP_printk("dev = (%d,%d)/(%d,%d), rw = %s%s, %s, sector = %lld, size = %u",
804 show_dev(__entry), 826 show_dev(__entry->target),
805 show_bio_type(__entry->op_flags), 827 show_dev(__entry->dev),
828 show_bio_type(__entry->op, __entry->op_flags),
806 show_block_type(__entry->type), 829 show_block_type(__entry->type),
807 (unsigned long long)__entry->sector, 830 (unsigned long long)__entry->sector,
808 __entry->size) 831 __entry->size)
809); 832);
810 833
811DEFINE_EVENT_CONDITION(f2fs__submit_bio, f2fs_submit_write_bio, 834DEFINE_EVENT_CONDITION(f2fs__bio, f2fs_prepare_write_bio,
835
836 TP_PROTO(struct super_block *sb, int type, struct bio *bio),
837
838 TP_ARGS(sb, type, bio),
839
840 TP_CONDITION(bio)
841);
842
843DEFINE_EVENT_CONDITION(f2fs__bio, f2fs_prepare_read_bio,
812 844
813 TP_PROTO(struct super_block *sb, struct f2fs_io_info *fio, 845 TP_PROTO(struct super_block *sb, int type, struct bio *bio),
814 struct bio *bio),
815 846
816 TP_ARGS(sb, fio, bio), 847 TP_ARGS(sb, type, bio),
817 848
818 TP_CONDITION(bio) 849 TP_CONDITION(bio)
819); 850);
820 851
821DEFINE_EVENT_CONDITION(f2fs__submit_bio, f2fs_submit_read_bio, 852DEFINE_EVENT_CONDITION(f2fs__bio, f2fs_submit_read_bio,
822 853
823 TP_PROTO(struct super_block *sb, struct f2fs_io_info *fio, 854 TP_PROTO(struct super_block *sb, int type, struct bio *bio),
824 struct bio *bio),
825 855
826 TP_ARGS(sb, fio, bio), 856 TP_ARGS(sb, type, bio),
857
858 TP_CONDITION(bio)
859);
860
861DEFINE_EVENT_CONDITION(f2fs__bio, f2fs_submit_write_bio,
862
863 TP_PROTO(struct super_block *sb, int type, struct bio *bio),
864
865 TP_ARGS(sb, type, bio),
827 866
828 TP_CONDITION(bio) 867 TP_CONDITION(bio)
829); 868);
@@ -1082,16 +1121,16 @@ TRACE_EVENT(f2fs_write_checkpoint,
1082 ), 1121 ),
1083 1122
1084 TP_printk("dev = (%d,%d), checkpoint for %s, state = %s", 1123 TP_printk("dev = (%d,%d), checkpoint for %s, state = %s",
1085 show_dev(__entry), 1124 show_dev(__entry->dev),
1086 show_cpreason(__entry->reason), 1125 show_cpreason(__entry->reason),
1087 __entry->msg) 1126 __entry->msg)
1088); 1127);
1089 1128
1090TRACE_EVENT(f2fs_issue_discard, 1129TRACE_EVENT(f2fs_issue_discard,
1091 1130
1092 TP_PROTO(struct super_block *sb, block_t blkstart, block_t blklen), 1131 TP_PROTO(struct block_device *dev, block_t blkstart, block_t blklen),
1093 1132
1094 TP_ARGS(sb, blkstart, blklen), 1133 TP_ARGS(dev, blkstart, blklen),
1095 1134
1096 TP_STRUCT__entry( 1135 TP_STRUCT__entry(
1097 __field(dev_t, dev) 1136 __field(dev_t, dev)
@@ -1100,22 +1139,22 @@ TRACE_EVENT(f2fs_issue_discard,
1100 ), 1139 ),
1101 1140
1102 TP_fast_assign( 1141 TP_fast_assign(
1103 __entry->dev = sb->s_dev; 1142 __entry->dev = dev->bd_dev;
1104 __entry->blkstart = blkstart; 1143 __entry->blkstart = blkstart;
1105 __entry->blklen = blklen; 1144 __entry->blklen = blklen;
1106 ), 1145 ),
1107 1146
1108 TP_printk("dev = (%d,%d), blkstart = 0x%llx, blklen = 0x%llx", 1147 TP_printk("dev = (%d,%d), blkstart = 0x%llx, blklen = 0x%llx",
1109 show_dev(__entry), 1148 show_dev(__entry->dev),
1110 (unsigned long long)__entry->blkstart, 1149 (unsigned long long)__entry->blkstart,
1111 (unsigned long long)__entry->blklen) 1150 (unsigned long long)__entry->blklen)
1112); 1151);
1113 1152
1114TRACE_EVENT(f2fs_issue_reset_zone, 1153TRACE_EVENT(f2fs_issue_reset_zone,
1115 1154
1116 TP_PROTO(struct super_block *sb, block_t blkstart), 1155 TP_PROTO(struct block_device *dev, block_t blkstart),
1117 1156
1118 TP_ARGS(sb, blkstart), 1157 TP_ARGS(dev, blkstart),
1119 1158
1120 TP_STRUCT__entry( 1159 TP_STRUCT__entry(
1121 __field(dev_t, dev) 1160 __field(dev_t, dev)
@@ -1123,21 +1162,21 @@ TRACE_EVENT(f2fs_issue_reset_zone,
1123 ), 1162 ),
1124 1163
1125 TP_fast_assign( 1164 TP_fast_assign(
1126 __entry->dev = sb->s_dev; 1165 __entry->dev = dev->bd_dev;
1127 __entry->blkstart = blkstart; 1166 __entry->blkstart = blkstart;
1128 ), 1167 ),
1129 1168
1130 TP_printk("dev = (%d,%d), reset zone at block = 0x%llx", 1169 TP_printk("dev = (%d,%d), reset zone at block = 0x%llx",
1131 show_dev(__entry), 1170 show_dev(__entry->dev),
1132 (unsigned long long)__entry->blkstart) 1171 (unsigned long long)__entry->blkstart)
1133); 1172);
1134 1173
1135TRACE_EVENT(f2fs_issue_flush, 1174TRACE_EVENT(f2fs_issue_flush,
1136 1175
1137 TP_PROTO(struct super_block *sb, unsigned int nobarrier, 1176 TP_PROTO(struct block_device *dev, unsigned int nobarrier,
1138 unsigned int flush_merge), 1177 unsigned int flush_merge),
1139 1178
1140 TP_ARGS(sb, nobarrier, flush_merge), 1179 TP_ARGS(dev, nobarrier, flush_merge),
1141 1180
1142 TP_STRUCT__entry( 1181 TP_STRUCT__entry(
1143 __field(dev_t, dev) 1182 __field(dev_t, dev)
@@ -1146,13 +1185,13 @@ TRACE_EVENT(f2fs_issue_flush,
1146 ), 1185 ),
1147 1186
1148 TP_fast_assign( 1187 TP_fast_assign(
1149 __entry->dev = sb->s_dev; 1188 __entry->dev = dev->bd_dev;
1150 __entry->nobarrier = nobarrier; 1189 __entry->nobarrier = nobarrier;
1151 __entry->flush_merge = flush_merge; 1190 __entry->flush_merge = flush_merge;
1152 ), 1191 ),
1153 1192
1154 TP_printk("dev = (%d,%d), %s %s", 1193 TP_printk("dev = (%d,%d), %s %s",
1155 show_dev(__entry), 1194 show_dev(__entry->dev),
1156 __entry->nobarrier ? "skip (nobarrier)" : "issue", 1195 __entry->nobarrier ? "skip (nobarrier)" : "issue",
1157 __entry->flush_merge ? " with flush_merge" : "") 1196 __entry->flush_merge ? " with flush_merge" : "")
1158); 1197);
@@ -1267,7 +1306,7 @@ TRACE_EVENT(f2fs_shrink_extent_tree,
1267 ), 1306 ),
1268 1307
1269 TP_printk("dev = (%d,%d), shrunk: node_cnt = %u, tree_cnt = %u", 1308 TP_printk("dev = (%d,%d), shrunk: node_cnt = %u, tree_cnt = %u",
1270 show_dev(__entry), 1309 show_dev(__entry->dev),
1271 __entry->node_cnt, 1310 __entry->node_cnt,
1272 __entry->tree_cnt) 1311 __entry->tree_cnt)
1273); 1312);
@@ -1314,7 +1353,7 @@ DECLARE_EVENT_CLASS(f2fs_sync_dirty_inodes,
1314 ), 1353 ),
1315 1354
1316 TP_printk("dev = (%d,%d), %s, dirty count = %lld", 1355 TP_printk("dev = (%d,%d), %s, dirty count = %lld",
1317 show_dev(__entry), 1356 show_dev(__entry->dev),
1318 show_file_type(__entry->type), 1357 show_file_type(__entry->type),
1319 __entry->count) 1358 __entry->count)
1320); 1359);
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 2bff63a73cf8..a1ee933e3029 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -464,8 +464,10 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
464 * Note that the cred_unused list must be time-ordered. 464 * Note that the cred_unused list must be time-ordered.
465 */ 465 */
466 if (time_in_range(cred->cr_expire, expired, jiffies) && 466 if (time_in_range(cred->cr_expire, expired, jiffies) &&
467 test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) 467 test_bit(RPCAUTH_CRED_HASHED, &cred->cr_flags) != 0) {
468 freed = SHRINK_STOP;
468 break; 469 break;
470 }
469 471
470 list_del_init(&cred->cr_lru); 472 list_del_init(&cred->cr_lru);
471 number_cred_unused--; 473 number_cred_unused--;
@@ -520,7 +522,7 @@ static unsigned long
520rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc) 522rpcauth_cache_shrink_count(struct shrinker *shrink, struct shrink_control *sc)
521 523
522{ 524{
523 return (number_cred_unused / 100) * sysctl_vfs_cache_pressure; 525 return number_cred_unused * sysctl_vfs_cache_pressure / 100;
524} 526}
525 527
526static void 528static void
@@ -646,9 +648,6 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct auth_cred *acred,
646 cred->cr_auth = auth; 648 cred->cr_auth = auth;
647 cred->cr_ops = ops; 649 cred->cr_ops = ops;
648 cred->cr_expire = jiffies; 650 cred->cr_expire = jiffies;
649#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
650 cred->cr_magic = RPCAUTH_CRED_MAGIC;
651#endif
652 cred->cr_uid = acred->uid; 651 cred->cr_uid = acred->uid;
653} 652}
654EXPORT_SYMBOL_GPL(rpcauth_init_cred); 653EXPORT_SYMBOL_GPL(rpcauth_init_cred);
@@ -876,8 +875,12 @@ int __init rpcauth_init_module(void)
876 err = rpc_init_generic_auth(); 875 err = rpc_init_generic_auth();
877 if (err < 0) 876 if (err < 0)
878 goto out2; 877 goto out2;
879 register_shrinker(&rpc_cred_shrinker); 878 err = register_shrinker(&rpc_cred_shrinker);
879 if (err < 0)
880 goto out3;
880 return 0; 881 return 0;
882out3:
883 rpc_destroy_generic_auth();
881out2: 884out2:
882 rpc_destroy_authunix(); 885 rpc_destroy_authunix();
883out1: 886out1:
diff --git a/net/sunrpc/auth_null.c b/net/sunrpc/auth_null.c
index 4d17376b2acb..5f3d527dff65 100644
--- a/net/sunrpc/auth_null.c
+++ b/net/sunrpc/auth_null.c
@@ -139,7 +139,4 @@ struct rpc_cred null_cred = {
139 .cr_ops = &null_credops, 139 .cr_ops = &null_credops,
140 .cr_count = ATOMIC_INIT(1), 140 .cr_count = ATOMIC_INIT(1),
141 .cr_flags = 1UL << RPCAUTH_CRED_UPTODATE, 141 .cr_flags = 1UL << RPCAUTH_CRED_UPTODATE,
142#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
143 .cr_magic = RPCAUTH_CRED_MAGIC,
144#endif
145}; 142};
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 306fc0f54596..82337e1ec9cd 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -14,12 +14,10 @@
14#include <linux/sunrpc/auth.h> 14#include <linux/sunrpc/auth.h>
15#include <linux/user_namespace.h> 15#include <linux/user_namespace.h>
16 16
17#define NFS_NGROUPS 16
18
19struct unx_cred { 17struct unx_cred {
20 struct rpc_cred uc_base; 18 struct rpc_cred uc_base;
21 kgid_t uc_gid; 19 kgid_t uc_gid;
22 kgid_t uc_gids[NFS_NGROUPS]; 20 kgid_t uc_gids[UNX_NGROUPS];
23}; 21};
24#define uc_uid uc_base.cr_uid 22#define uc_uid uc_base.cr_uid
25 23
@@ -82,13 +80,13 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t
82 80
83 if (acred->group_info != NULL) 81 if (acred->group_info != NULL)
84 groups = acred->group_info->ngroups; 82 groups = acred->group_info->ngroups;
85 if (groups > NFS_NGROUPS) 83 if (groups > UNX_NGROUPS)
86 groups = NFS_NGROUPS; 84 groups = UNX_NGROUPS;
87 85
88 cred->uc_gid = acred->gid; 86 cred->uc_gid = acred->gid;
89 for (i = 0; i < groups; i++) 87 for (i = 0; i < groups; i++)
90 cred->uc_gids[i] = acred->group_info->gid[i]; 88 cred->uc_gids[i] = acred->group_info->gid[i];
91 if (i < NFS_NGROUPS) 89 if (i < UNX_NGROUPS)
92 cred->uc_gids[i] = INVALID_GID; 90 cred->uc_gids[i] = INVALID_GID;
93 91
94 return &cred->uc_base; 92 return &cred->uc_base;
@@ -132,12 +130,12 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags)
132 130
133 if (acred->group_info != NULL) 131 if (acred->group_info != NULL)
134 groups = acred->group_info->ngroups; 132 groups = acred->group_info->ngroups;
135 if (groups > NFS_NGROUPS) 133 if (groups > UNX_NGROUPS)
136 groups = NFS_NGROUPS; 134 groups = UNX_NGROUPS;
137 for (i = 0; i < groups ; i++) 135 for (i = 0; i < groups ; i++)
138 if (!gid_eq(cred->uc_gids[i], acred->group_info->gid[i])) 136 if (!gid_eq(cred->uc_gids[i], acred->group_info->gid[i]))
139 return 0; 137 return 0;
140 if (groups < NFS_NGROUPS && gid_valid(cred->uc_gids[groups])) 138 if (groups < UNX_NGROUPS && gid_valid(cred->uc_gids[groups]))
141 return 0; 139 return 0;
142 return 1; 140 return 1;
143} 141}
@@ -166,7 +164,7 @@ unx_marshal(struct rpc_task *task, __be32 *p)
166 *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid)); 164 *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid));
167 *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid)); 165 *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid));
168 hold = p++; 166 hold = p++;
169 for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++) 167 for (i = 0; i < UNX_NGROUPS && gid_valid(cred->uc_gids[i]); i++)
170 *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i])); 168 *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i]));
171 *hold = htonl(p - hold - 1); /* gid array length */ 169 *hold = htonl(p - hold - 1); /* gid array length */
172 *base = htonl((p - base - 1) << 2); /* cred length */ 170 *base = htonl((p - base - 1) << 2); /* cred length */
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index d8639da06d9c..79d55d949d9a 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -728,7 +728,7 @@ void cache_clean_deferred(void *owner)
728/* 728/*
729 * communicate with user-space 729 * communicate with user-space
730 * 730 *
731 * We have a magic /proc file - /proc/sunrpc/<cachename>/channel. 731 * We have a magic /proc file - /proc/net/rpc/<cachename>/channel.
732 * On read, you get a full request, or block. 732 * On read, you get a full request, or block.
733 * On write, an update request is processed. 733 * On write, an update request is processed.
734 * Poll works if anything to read, and always allows write. 734 * Poll works if anything to read, and always allows write.
@@ -1283,7 +1283,7 @@ EXPORT_SYMBOL_GPL(qword_get);
1283 1283
1284 1284
1285/* 1285/*
1286 * support /proc/sunrpc/cache/$CACHENAME/content 1286 * support /proc/net/rpc/$CACHENAME/content
1287 * as a seqfile. 1287 * as a seqfile.
1288 * We call ->cache_show passing NULL for the item to 1288 * We call ->cache_show passing NULL for the item to
1289 * get a header, then pass each real item in the cache 1289 * get a header, then pass each real item in the cache
@@ -1438,20 +1438,11 @@ static ssize_t read_flush(struct file *file, char __user *buf,
1438 struct cache_detail *cd) 1438 struct cache_detail *cd)
1439{ 1439{
1440 char tbuf[22]; 1440 char tbuf[22];
1441 unsigned long p = *ppos;
1442 size_t len; 1441 size_t len;
1443 1442
1444 snprintf(tbuf, sizeof(tbuf), "%lu\n", convert_to_wallclock(cd->flush_time)); 1443 len = snprintf(tbuf, sizeof(tbuf), "%lu\n",
1445 len = strlen(tbuf); 1444 convert_to_wallclock(cd->flush_time));
1446 if (p >= len) 1445 return simple_read_from_buffer(buf, count, ppos, tbuf, len);
1447 return 0;
1448 len -= p;
1449 if (len > count)
1450 len = count;
1451 if (copy_to_user(buf, (void*)(tbuf+p), len))
1452 return -EFAULT;
1453 *ppos += len;
1454 return len;
1455} 1446}
1456 1447
1457static ssize_t write_flush(struct file *file, const char __user *buf, 1448static ssize_t write_flush(struct file *file, const char __user *buf,
@@ -1611,21 +1602,12 @@ static const struct file_operations cache_flush_operations_procfs = {
1611 .llseek = no_llseek, 1602 .llseek = no_llseek,
1612}; 1603};
1613 1604
1614static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net) 1605static void remove_cache_proc_entries(struct cache_detail *cd)
1615{ 1606{
1616 struct sunrpc_net *sn; 1607 if (cd->procfs) {
1617 1608 proc_remove(cd->procfs);
1618 if (cd->u.procfs.proc_ent == NULL) 1609 cd->procfs = NULL;
1619 return; 1610 }
1620 if (cd->u.procfs.flush_ent)
1621 remove_proc_entry("flush", cd->u.procfs.proc_ent);
1622 if (cd->u.procfs.channel_ent)
1623 remove_proc_entry("channel", cd->u.procfs.proc_ent);
1624 if (cd->u.procfs.content_ent)
1625 remove_proc_entry("content", cd->u.procfs.proc_ent);
1626 cd->u.procfs.proc_ent = NULL;
1627 sn = net_generic(net, sunrpc_net_id);
1628 remove_proc_entry(cd->name, sn->proc_net_rpc);
1629} 1611}
1630 1612
1631#ifdef CONFIG_PROC_FS 1613#ifdef CONFIG_PROC_FS
@@ -1635,38 +1617,30 @@ static int create_cache_proc_entries(struct cache_detail *cd, struct net *net)
1635 struct sunrpc_net *sn; 1617 struct sunrpc_net *sn;
1636 1618
1637 sn = net_generic(net, sunrpc_net_id); 1619 sn = net_generic(net, sunrpc_net_id);
1638 cd->u.procfs.proc_ent = proc_mkdir(cd->name, sn->proc_net_rpc); 1620 cd->procfs = proc_mkdir(cd->name, sn->proc_net_rpc);
1639 if (cd->u.procfs.proc_ent == NULL) 1621 if (cd->procfs == NULL)
1640 goto out_nomem; 1622 goto out_nomem;
1641 cd->u.procfs.channel_ent = NULL;
1642 cd->u.procfs.content_ent = NULL;
1643 1623
1644 p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR, 1624 p = proc_create_data("flush", S_IFREG|S_IRUSR|S_IWUSR,
1645 cd->u.procfs.proc_ent, 1625 cd->procfs, &cache_flush_operations_procfs, cd);
1646 &cache_flush_operations_procfs, cd);
1647 cd->u.procfs.flush_ent = p;
1648 if (p == NULL) 1626 if (p == NULL)
1649 goto out_nomem; 1627 goto out_nomem;
1650 1628
1651 if (cd->cache_request || cd->cache_parse) { 1629 if (cd->cache_request || cd->cache_parse) {
1652 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR, 1630 p = proc_create_data("channel", S_IFREG|S_IRUSR|S_IWUSR,
1653 cd->u.procfs.proc_ent, 1631 cd->procfs, &cache_file_operations_procfs, cd);
1654 &cache_file_operations_procfs, cd);
1655 cd->u.procfs.channel_ent = p;
1656 if (p == NULL) 1632 if (p == NULL)
1657 goto out_nomem; 1633 goto out_nomem;
1658 } 1634 }
1659 if (cd->cache_show) { 1635 if (cd->cache_show) {
1660 p = proc_create_data("content", S_IFREG|S_IRUSR, 1636 p = proc_create_data("content", S_IFREG|S_IRUSR,
1661 cd->u.procfs.proc_ent, 1637 cd->procfs, &content_file_operations_procfs, cd);
1662 &content_file_operations_procfs, cd);
1663 cd->u.procfs.content_ent = p;
1664 if (p == NULL) 1638 if (p == NULL)
1665 goto out_nomem; 1639 goto out_nomem;
1666 } 1640 }
1667 return 0; 1641 return 0;
1668out_nomem: 1642out_nomem:
1669 remove_cache_proc_entries(cd, net); 1643 remove_cache_proc_entries(cd);
1670 return -ENOMEM; 1644 return -ENOMEM;
1671} 1645}
1672#else /* CONFIG_PROC_FS */ 1646#else /* CONFIG_PROC_FS */
@@ -1695,7 +1669,7 @@ EXPORT_SYMBOL_GPL(cache_register_net);
1695 1669
1696void cache_unregister_net(struct cache_detail *cd, struct net *net) 1670void cache_unregister_net(struct cache_detail *cd, struct net *net)
1697{ 1671{
1698 remove_cache_proc_entries(cd, net); 1672 remove_cache_proc_entries(cd);
1699 sunrpc_destroy_cache_detail(cd); 1673 sunrpc_destroy_cache_detail(cd);
1700} 1674}
1701EXPORT_SYMBOL_GPL(cache_unregister_net); 1675EXPORT_SYMBOL_GPL(cache_unregister_net);
@@ -1854,15 +1828,17 @@ int sunrpc_cache_register_pipefs(struct dentry *parent,
1854 struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd); 1828 struct dentry *dir = rpc_create_cache_dir(parent, name, umode, cd);
1855 if (IS_ERR(dir)) 1829 if (IS_ERR(dir))
1856 return PTR_ERR(dir); 1830 return PTR_ERR(dir);
1857 cd->u.pipefs.dir = dir; 1831 cd->pipefs = dir;
1858 return 0; 1832 return 0;
1859} 1833}
1860EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs); 1834EXPORT_SYMBOL_GPL(sunrpc_cache_register_pipefs);
1861 1835
1862void sunrpc_cache_unregister_pipefs(struct cache_detail *cd) 1836void sunrpc_cache_unregister_pipefs(struct cache_detail *cd)
1863{ 1837{
1864 rpc_remove_cache_dir(cd->u.pipefs.dir); 1838 if (cd->pipefs) {
1865 cd->u.pipefs.dir = NULL; 1839 rpc_remove_cache_dir(cd->pipefs);
1840 cd->pipefs = NULL;
1841 }
1866} 1842}
1867EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs); 1843EXPORT_SYMBOL_GPL(sunrpc_cache_unregister_pipefs);
1868 1844
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 1dc9f3bac099..52da3ce54bb5 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1453,21 +1453,6 @@ size_t rpc_max_bc_payload(struct rpc_clnt *clnt)
1453EXPORT_SYMBOL_GPL(rpc_max_bc_payload); 1453EXPORT_SYMBOL_GPL(rpc_max_bc_payload);
1454 1454
1455/** 1455/**
1456 * rpc_get_timeout - Get timeout for transport in units of HZ
1457 * @clnt: RPC client to query
1458 */
1459unsigned long rpc_get_timeout(struct rpc_clnt *clnt)
1460{
1461 unsigned long ret;
1462
1463 rcu_read_lock();
1464 ret = rcu_dereference(clnt->cl_xprt)->timeout->to_initval;
1465 rcu_read_unlock();
1466 return ret;
1467}
1468EXPORT_SYMBOL_GPL(rpc_get_timeout);
1469
1470/**
1471 * rpc_force_rebind - force transport to check that remote port is unchanged 1456 * rpc_force_rebind - force transport to check that remote port is unchanged
1472 * @clnt: client to rebind 1457 * @clnt: client to rebind
1473 * 1458 *
@@ -2699,6 +2684,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
2699{ 2684{
2700 struct rpc_xprt_switch *xps; 2685 struct rpc_xprt_switch *xps;
2701 struct rpc_xprt *xprt; 2686 struct rpc_xprt *xprt;
2687 unsigned long connect_timeout;
2702 unsigned long reconnect_timeout; 2688 unsigned long reconnect_timeout;
2703 unsigned char resvport; 2689 unsigned char resvport;
2704 int ret = 0; 2690 int ret = 0;
@@ -2711,6 +2697,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
2711 return -EAGAIN; 2697 return -EAGAIN;
2712 } 2698 }
2713 resvport = xprt->resvport; 2699 resvport = xprt->resvport;
2700 connect_timeout = xprt->connect_timeout;
2714 reconnect_timeout = xprt->max_reconnect_timeout; 2701 reconnect_timeout = xprt->max_reconnect_timeout;
2715 rcu_read_unlock(); 2702 rcu_read_unlock();
2716 2703
@@ -2720,7 +2707,10 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
2720 goto out_put_switch; 2707 goto out_put_switch;
2721 } 2708 }
2722 xprt->resvport = resvport; 2709 xprt->resvport = resvport;
2723 xprt->max_reconnect_timeout = reconnect_timeout; 2710 if (xprt->ops->set_connect_timeout != NULL)
2711 xprt->ops->set_connect_timeout(xprt,
2712 connect_timeout,
2713 reconnect_timeout);
2724 2714
2725 rpc_xprt_switch_set_roundrobin(xps); 2715 rpc_xprt_switch_set_roundrobin(xps);
2726 if (setup) { 2716 if (setup) {
@@ -2737,26 +2727,39 @@ out_put_switch:
2737} 2727}
2738EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt); 2728EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt);
2739 2729
2730struct connect_timeout_data {
2731 unsigned long connect_timeout;
2732 unsigned long reconnect_timeout;
2733};
2734
2740static int 2735static int
2741rpc_xprt_cap_max_reconnect_timeout(struct rpc_clnt *clnt, 2736rpc_xprt_set_connect_timeout(struct rpc_clnt *clnt,
2742 struct rpc_xprt *xprt, 2737 struct rpc_xprt *xprt,
2743 void *data) 2738 void *data)
2744{ 2739{
2745 unsigned long timeout = *((unsigned long *)data); 2740 struct connect_timeout_data *timeo = data;
2746 2741
2747 if (timeout < xprt->max_reconnect_timeout) 2742 if (xprt->ops->set_connect_timeout)
2748 xprt->max_reconnect_timeout = timeout; 2743 xprt->ops->set_connect_timeout(xprt,
2744 timeo->connect_timeout,
2745 timeo->reconnect_timeout);
2749 return 0; 2746 return 0;
2750} 2747}
2751 2748
2752void 2749void
2753rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt, unsigned long timeo) 2750rpc_set_connect_timeout(struct rpc_clnt *clnt,
2751 unsigned long connect_timeout,
2752 unsigned long reconnect_timeout)
2754{ 2753{
2754 struct connect_timeout_data timeout = {
2755 .connect_timeout = connect_timeout,
2756 .reconnect_timeout = reconnect_timeout,
2757 };
2755 rpc_clnt_iterate_for_each_xprt(clnt, 2758 rpc_clnt_iterate_for_each_xprt(clnt,
2756 rpc_xprt_cap_max_reconnect_timeout, 2759 rpc_xprt_set_connect_timeout,
2757 &timeo); 2760 &timeout);
2758} 2761}
2759EXPORT_SYMBOL_GPL(rpc_cap_max_reconnect_timeout); 2762EXPORT_SYMBOL_GPL(rpc_set_connect_timeout);
2760 2763
2761void rpc_clnt_xprt_switch_put(struct rpc_clnt *clnt) 2764void rpc_clnt_xprt_switch_put(struct rpc_clnt *clnt)
2762{ 2765{
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index e7b4d93566df..c8fd0b6c1618 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -16,11 +16,6 @@ static struct dentry *rpc_xprt_dir;
16 16
17unsigned int rpc_inject_disconnect; 17unsigned int rpc_inject_disconnect;
18 18
19struct rpc_clnt_iter {
20 struct rpc_clnt *clnt;
21 loff_t pos;
22};
23
24static int 19static int
25tasks_show(struct seq_file *f, void *v) 20tasks_show(struct seq_file *f, void *v)
26{ 21{
@@ -47,12 +42,10 @@ static void *
47tasks_start(struct seq_file *f, loff_t *ppos) 42tasks_start(struct seq_file *f, loff_t *ppos)
48 __acquires(&clnt->cl_lock) 43 __acquires(&clnt->cl_lock)
49{ 44{
50 struct rpc_clnt_iter *iter = f->private; 45 struct rpc_clnt *clnt = f->private;
51 loff_t pos = *ppos; 46 loff_t pos = *ppos;
52 struct rpc_clnt *clnt = iter->clnt;
53 struct rpc_task *task; 47 struct rpc_task *task;
54 48
55 iter->pos = pos + 1;
56 spin_lock(&clnt->cl_lock); 49 spin_lock(&clnt->cl_lock);
57 list_for_each_entry(task, &clnt->cl_tasks, tk_task) 50 list_for_each_entry(task, &clnt->cl_tasks, tk_task)
58 if (pos-- == 0) 51 if (pos-- == 0)
@@ -63,12 +56,10 @@ tasks_start(struct seq_file *f, loff_t *ppos)
63static void * 56static void *
64tasks_next(struct seq_file *f, void *v, loff_t *pos) 57tasks_next(struct seq_file *f, void *v, loff_t *pos)
65{ 58{
66 struct rpc_clnt_iter *iter = f->private; 59 struct rpc_clnt *clnt = f->private;
67 struct rpc_clnt *clnt = iter->clnt;
68 struct rpc_task *task = v; 60 struct rpc_task *task = v;
69 struct list_head *next = task->tk_task.next; 61 struct list_head *next = task->tk_task.next;
70 62
71 ++iter->pos;
72 ++*pos; 63 ++*pos;
73 64
74 /* If there's another task on list, return it */ 65 /* If there's another task on list, return it */
@@ -81,9 +72,7 @@ static void
81tasks_stop(struct seq_file *f, void *v) 72tasks_stop(struct seq_file *f, void *v)
82 __releases(&clnt->cl_lock) 73 __releases(&clnt->cl_lock)
83{ 74{
84 struct rpc_clnt_iter *iter = f->private; 75 struct rpc_clnt *clnt = f->private;
85 struct rpc_clnt *clnt = iter->clnt;
86
87 spin_unlock(&clnt->cl_lock); 76 spin_unlock(&clnt->cl_lock);
88} 77}
89 78
@@ -96,17 +85,13 @@ static const struct seq_operations tasks_seq_operations = {
96 85
97static int tasks_open(struct inode *inode, struct file *filp) 86static int tasks_open(struct inode *inode, struct file *filp)
98{ 87{
99 int ret = seq_open_private(filp, &tasks_seq_operations, 88 int ret = seq_open(filp, &tasks_seq_operations);
100 sizeof(struct rpc_clnt_iter));
101
102 if (!ret) { 89 if (!ret) {
103 struct seq_file *seq = filp->private_data; 90 struct seq_file *seq = filp->private_data;
104 struct rpc_clnt_iter *iter = seq->private; 91 struct rpc_clnt *clnt = seq->private = inode->i_private;
105
106 iter->clnt = inode->i_private;
107 92
108 if (!atomic_inc_not_zero(&iter->clnt->cl_count)) { 93 if (!atomic_inc_not_zero(&clnt->cl_count)) {
109 seq_release_private(inode, filp); 94 seq_release(inode, filp);
110 ret = -EINVAL; 95 ret = -EINVAL;
111 } 96 }
112 } 97 }
@@ -118,10 +103,10 @@ static int
118tasks_release(struct inode *inode, struct file *filp) 103tasks_release(struct inode *inode, struct file *filp)
119{ 104{
120 struct seq_file *seq = filp->private_data; 105 struct seq_file *seq = filp->private_data;
121 struct rpc_clnt_iter *iter = seq->private; 106 struct rpc_clnt *clnt = seq->private;
122 107
123 rpc_release_client(iter->clnt); 108 rpc_release_client(clnt);
124 return seq_release_private(inode, filp); 109 return seq_release(inode, filp);
125} 110}
126 111
127static const struct file_operations tasks_fops = { 112static const struct file_operations tasks_fops = {
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 64af4f034de6..f81eaa8e0888 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -403,7 +403,7 @@ svcauth_unix_info_release(struct svc_xprt *xpt)
403/**************************************************************************** 403/****************************************************************************
404 * auth.unix.gid cache 404 * auth.unix.gid cache
405 * simple cache to map a UID to a list of GIDs 405 * simple cache to map a UID to a list of GIDs
406 * because AUTH_UNIX aka AUTH_SYS has a max of 16 406 * because AUTH_UNIX aka AUTH_SYS has a max of UNX_NGROUPS
407 */ 407 */
408#define GID_HASHBITS 8 408#define GID_HASHBITS 8
409#define GID_HASHMAX (1<<GID_HASHBITS) 409#define GID_HASHMAX (1<<GID_HASHBITS)
@@ -810,7 +810,7 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp)
810 cred->cr_uid = make_kuid(&init_user_ns, svc_getnl(argv)); /* uid */ 810 cred->cr_uid = make_kuid(&init_user_ns, svc_getnl(argv)); /* uid */
811 cred->cr_gid = make_kgid(&init_user_ns, svc_getnl(argv)); /* gid */ 811 cred->cr_gid = make_kgid(&init_user_ns, svc_getnl(argv)); /* gid */
812 slen = svc_getnl(argv); /* gids length */ 812 slen = svc_getnl(argv); /* gids length */
813 if (slen > 16 || (len -= (slen + 2)*4) < 0) 813 if (slen > UNX_NGROUPS || (len -= (slen + 2)*4) < 0)
814 goto badcred; 814 goto badcred;
815 cred->cr_group_info = groups_alloc(slen); 815 cred->cr_group_info = groups_alloc(slen);
816 if (cred->cr_group_info == NULL) 816 if (cred->cr_group_info == NULL)
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 7f1071e103ca..1f7082144e01 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1518,3 +1518,37 @@ out:
1518} 1518}
1519EXPORT_SYMBOL_GPL(xdr_process_buf); 1519EXPORT_SYMBOL_GPL(xdr_process_buf);
1520 1520
1521/**
1522 * xdr_stream_decode_string_dup - Decode and duplicate variable length string
1523 * @xdr: pointer to xdr_stream
1524 * @str: location to store pointer to string
1525 * @maxlen: maximum acceptable string length
1526 * @gfp_flags: GFP mask to use
1527 *
1528 * Return values:
1529 * On success, returns length of NUL-terminated string stored in *@ptr
1530 * %-EBADMSG on XDR buffer overflow
1531 * %-EMSGSIZE if the size of the string would exceed @maxlen
1532 * %-ENOMEM on memory allocation failure
1533 */
1534ssize_t xdr_stream_decode_string_dup(struct xdr_stream *xdr, char **str,
1535 size_t maxlen, gfp_t gfp_flags)
1536{
1537 void *p;
1538 ssize_t ret;
1539
1540 ret = xdr_stream_decode_opaque_inline(xdr, &p, maxlen);
1541 if (ret > 0) {
1542 char *s = kmalloc(ret + 1, gfp_flags);
1543 if (s != NULL) {
1544 memcpy(s, p, ret);
1545 s[ret] = '\0';
1546 *str = s;
1547 return strlen(s);
1548 }
1549 ret = -ENOMEM;
1550 }
1551 *str = NULL;
1552 return ret;
1553}
1554EXPORT_SYMBOL_GPL(xdr_stream_decode_string_dup);
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 9a6be030ca7d..b530a2852ba8 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -897,13 +897,11 @@ static void xprt_timer(struct rpc_task *task)
897 return; 897 return;
898 dprintk("RPC: %5u xprt_timer\n", task->tk_pid); 898 dprintk("RPC: %5u xprt_timer\n", task->tk_pid);
899 899
900 spin_lock_bh(&xprt->transport_lock);
901 if (!req->rq_reply_bytes_recvd) { 900 if (!req->rq_reply_bytes_recvd) {
902 if (xprt->ops->timer) 901 if (xprt->ops->timer)
903 xprt->ops->timer(xprt, task); 902 xprt->ops->timer(xprt, task);
904 } else 903 } else
905 task->tk_status = 0; 904 task->tk_status = 0;
906 spin_unlock_bh(&xprt->transport_lock);
907} 905}
908 906
909/** 907/**
diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
index 1ebb09e1ac4f..59e64025ed96 100644
--- a/net/sunrpc/xprtrdma/fmr_ops.c
+++ b/net/sunrpc/xprtrdma/fmr_ops.c
@@ -310,10 +310,7 @@ fmr_op_unmap_safe(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
310 struct rpcrdma_mw *mw; 310 struct rpcrdma_mw *mw;
311 311
312 while (!list_empty(&req->rl_registered)) { 312 while (!list_empty(&req->rl_registered)) {
313 mw = list_first_entry(&req->rl_registered, 313 mw = rpcrdma_pop_mw(&req->rl_registered);
314 struct rpcrdma_mw, mw_list);
315 list_del_init(&mw->mw_list);
316
317 if (sync) 314 if (sync)
318 fmr_op_recover_mr(mw); 315 fmr_op_recover_mr(mw);
319 else 316 else
diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
index 47bed5333c7f..f81dd93176c0 100644
--- a/net/sunrpc/xprtrdma/frwr_ops.c
+++ b/net/sunrpc/xprtrdma/frwr_ops.c
@@ -466,8 +466,8 @@ frwr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
466 struct ib_send_wr *first, **prev, *last, *bad_wr; 466 struct ib_send_wr *first, **prev, *last, *bad_wr;
467 struct rpcrdma_rep *rep = req->rl_reply; 467 struct rpcrdma_rep *rep = req->rl_reply;
468 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 468 struct rpcrdma_ia *ia = &r_xprt->rx_ia;
469 struct rpcrdma_mw *mw, *tmp;
470 struct rpcrdma_frmr *f; 469 struct rpcrdma_frmr *f;
470 struct rpcrdma_mw *mw;
471 int count, rc; 471 int count, rc;
472 472
473 dprintk("RPC: %s: req %p\n", __func__, req); 473 dprintk("RPC: %s: req %p\n", __func__, req);
@@ -534,10 +534,10 @@ frwr_op_unmap_sync(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
534 * them to the free MW list. 534 * them to the free MW list.
535 */ 535 */
536unmap: 536unmap:
537 list_for_each_entry_safe(mw, tmp, &req->rl_registered, mw_list) { 537 while (!list_empty(&req->rl_registered)) {
538 mw = rpcrdma_pop_mw(&req->rl_registered);
538 dprintk("RPC: %s: DMA unmapping frmr %p\n", 539 dprintk("RPC: %s: DMA unmapping frmr %p\n",
539 __func__, &mw->frmr); 540 __func__, &mw->frmr);
540 list_del_init(&mw->mw_list);
541 ib_dma_unmap_sg(ia->ri_device, 541 ib_dma_unmap_sg(ia->ri_device,
542 mw->mw_sg, mw->mw_nents, mw->mw_dir); 542 mw->mw_sg, mw->mw_nents, mw->mw_dir);
543 rpcrdma_put_mw(r_xprt, mw); 543 rpcrdma_put_mw(r_xprt, mw);
@@ -571,10 +571,7 @@ frwr_op_unmap_safe(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
571 struct rpcrdma_mw *mw; 571 struct rpcrdma_mw *mw;
572 572
573 while (!list_empty(&req->rl_registered)) { 573 while (!list_empty(&req->rl_registered)) {
574 mw = list_first_entry(&req->rl_registered, 574 mw = rpcrdma_pop_mw(&req->rl_registered);
575 struct rpcrdma_mw, mw_list);
576 list_del_init(&mw->mw_list);
577
578 if (sync) 575 if (sync)
579 frwr_op_recover_mr(mw); 576 frwr_op_recover_mr(mw);
580 else 577 else
diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c
index c52e0f2ffe52..a044be2d6ad7 100644
--- a/net/sunrpc/xprtrdma/rpc_rdma.c
+++ b/net/sunrpc/xprtrdma/rpc_rdma.c
@@ -125,14 +125,34 @@ void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *r_xprt)
125/* The client can send a request inline as long as the RPCRDMA header 125/* The client can send a request inline as long as the RPCRDMA header
126 * plus the RPC call fit under the transport's inline limit. If the 126 * plus the RPC call fit under the transport's inline limit. If the
127 * combined call message size exceeds that limit, the client must use 127 * combined call message size exceeds that limit, the client must use
128 * the read chunk list for this operation. 128 * a Read chunk for this operation.
129 *
130 * A Read chunk is also required if sending the RPC call inline would
131 * exceed this device's max_sge limit.
129 */ 132 */
130static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt, 133static bool rpcrdma_args_inline(struct rpcrdma_xprt *r_xprt,
131 struct rpc_rqst *rqst) 134 struct rpc_rqst *rqst)
132{ 135{
133 struct rpcrdma_ia *ia = &r_xprt->rx_ia; 136 struct xdr_buf *xdr = &rqst->rq_snd_buf;
137 unsigned int count, remaining, offset;
138
139 if (xdr->len > r_xprt->rx_ia.ri_max_inline_write)
140 return false;
141
142 if (xdr->page_len) {
143 remaining = xdr->page_len;
144 offset = xdr->page_base & ~PAGE_MASK;
145 count = 0;
146 while (remaining) {
147 remaining -= min_t(unsigned int,
148 PAGE_SIZE - offset, remaining);
149 offset = 0;
150 if (++count > r_xprt->rx_ia.ri_max_send_sges)
151 return false;
152 }
153 }
134 154
135 return rqst->rq_snd_buf.len <= ia->ri_max_inline_write; 155 return true;
136} 156}
137 157
138/* The client can't know how large the actual reply will be. Thus it 158/* The client can't know how large the actual reply will be. Thus it
@@ -186,9 +206,9 @@ rpcrdma_convert_kvec(struct kvec *vec, struct rpcrdma_mr_seg *seg, int n)
186 */ 206 */
187 207
188static int 208static int
189rpcrdma_convert_iovs(struct xdr_buf *xdrbuf, unsigned int pos, 209rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
190 enum rpcrdma_chunktype type, struct rpcrdma_mr_seg *seg, 210 unsigned int pos, enum rpcrdma_chunktype type,
191 bool reminv_expected) 211 struct rpcrdma_mr_seg *seg)
192{ 212{
193 int len, n, p, page_base; 213 int len, n, p, page_base;
194 struct page **ppages; 214 struct page **ppages;
@@ -226,22 +246,21 @@ rpcrdma_convert_iovs(struct xdr_buf *xdrbuf, unsigned int pos,
226 if (len && n == RPCRDMA_MAX_SEGS) 246 if (len && n == RPCRDMA_MAX_SEGS)
227 goto out_overflow; 247 goto out_overflow;
228 248
229 /* When encoding the read list, the tail is always sent inline */ 249 /* When encoding a Read chunk, the tail iovec contains an
230 if (type == rpcrdma_readch) 250 * XDR pad and may be omitted.
251 */
252 if (type == rpcrdma_readch && r_xprt->rx_ia.ri_implicit_roundup)
231 return n; 253 return n;
232 254
233 /* When encoding the Write list, some servers need to see an extra 255 /* When encoding a Write chunk, some servers need to see an
234 * segment for odd-length Write chunks. The upper layer provides 256 * extra segment for non-XDR-aligned Write chunks. The upper
235 * space in the tail iovec for this purpose. 257 * layer provides space in the tail iovec that may be used
258 * for this purpose.
236 */ 259 */
237 if (type == rpcrdma_writech && reminv_expected) 260 if (type == rpcrdma_writech && r_xprt->rx_ia.ri_implicit_roundup)
238 return n; 261 return n;
239 262
240 if (xdrbuf->tail[0].iov_len) { 263 if (xdrbuf->tail[0].iov_len) {
241 /* the rpcrdma protocol allows us to omit any trailing
242 * xdr pad bytes, saving the server an RDMA operation. */
243 if (xdrbuf->tail[0].iov_len < 4 && xprt_rdma_pad_optimize)
244 return n;
245 n = rpcrdma_convert_kvec(&xdrbuf->tail[0], seg, n); 264 n = rpcrdma_convert_kvec(&xdrbuf->tail[0], seg, n);
246 if (n == RPCRDMA_MAX_SEGS) 265 if (n == RPCRDMA_MAX_SEGS)
247 goto out_overflow; 266 goto out_overflow;
@@ -293,7 +312,8 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt,
293 if (rtype == rpcrdma_areadch) 312 if (rtype == rpcrdma_areadch)
294 pos = 0; 313 pos = 0;
295 seg = req->rl_segments; 314 seg = req->rl_segments;
296 nsegs = rpcrdma_convert_iovs(&rqst->rq_snd_buf, pos, rtype, seg, false); 315 nsegs = rpcrdma_convert_iovs(r_xprt, &rqst->rq_snd_buf, pos,
316 rtype, seg);
297 if (nsegs < 0) 317 if (nsegs < 0)
298 return ERR_PTR(nsegs); 318 return ERR_PTR(nsegs);
299 319
@@ -302,7 +322,7 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt,
302 false, &mw); 322 false, &mw);
303 if (n < 0) 323 if (n < 0)
304 return ERR_PTR(n); 324 return ERR_PTR(n);
305 list_add(&mw->mw_list, &req->rl_registered); 325 rpcrdma_push_mw(mw, &req->rl_registered);
306 326
307 *iptr++ = xdr_one; /* item present */ 327 *iptr++ = xdr_one; /* item present */
308 328
@@ -355,10 +375,9 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
355 } 375 }
356 376
357 seg = req->rl_segments; 377 seg = req->rl_segments;
358 nsegs = rpcrdma_convert_iovs(&rqst->rq_rcv_buf, 378 nsegs = rpcrdma_convert_iovs(r_xprt, &rqst->rq_rcv_buf,
359 rqst->rq_rcv_buf.head[0].iov_len, 379 rqst->rq_rcv_buf.head[0].iov_len,
360 wtype, seg, 380 wtype, seg);
361 r_xprt->rx_ia.ri_reminv_expected);
362 if (nsegs < 0) 381 if (nsegs < 0)
363 return ERR_PTR(nsegs); 382 return ERR_PTR(nsegs);
364 383
@@ -371,7 +390,7 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
371 true, &mw); 390 true, &mw);
372 if (n < 0) 391 if (n < 0)
373 return ERR_PTR(n); 392 return ERR_PTR(n);
374 list_add(&mw->mw_list, &req->rl_registered); 393 rpcrdma_push_mw(mw, &req->rl_registered);
375 394
376 iptr = xdr_encode_rdma_segment(iptr, mw); 395 iptr = xdr_encode_rdma_segment(iptr, mw);
377 396
@@ -423,8 +442,7 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt,
423 } 442 }
424 443
425 seg = req->rl_segments; 444 seg = req->rl_segments;
426 nsegs = rpcrdma_convert_iovs(&rqst->rq_rcv_buf, 0, wtype, seg, 445 nsegs = rpcrdma_convert_iovs(r_xprt, &rqst->rq_rcv_buf, 0, wtype, seg);
427 r_xprt->rx_ia.ri_reminv_expected);
428 if (nsegs < 0) 446 if (nsegs < 0)
429 return ERR_PTR(nsegs); 447 return ERR_PTR(nsegs);
430 448
@@ -437,7 +455,7 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt,
437 true, &mw); 455 true, &mw);
438 if (n < 0) 456 if (n < 0)
439 return ERR_PTR(n); 457 return ERR_PTR(n);
440 list_add(&mw->mw_list, &req->rl_registered); 458 rpcrdma_push_mw(mw, &req->rl_registered);
441 459
442 iptr = xdr_encode_rdma_segment(iptr, mw); 460 iptr = xdr_encode_rdma_segment(iptr, mw);
443 461
@@ -741,13 +759,13 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst)
741 iptr = headerp->rm_body.rm_chunks; 759 iptr = headerp->rm_body.rm_chunks;
742 iptr = rpcrdma_encode_read_list(r_xprt, req, rqst, iptr, rtype); 760 iptr = rpcrdma_encode_read_list(r_xprt, req, rqst, iptr, rtype);
743 if (IS_ERR(iptr)) 761 if (IS_ERR(iptr))
744 goto out_unmap; 762 goto out_err;
745 iptr = rpcrdma_encode_write_list(r_xprt, req, rqst, iptr, wtype); 763 iptr = rpcrdma_encode_write_list(r_xprt, req, rqst, iptr, wtype);
746 if (IS_ERR(iptr)) 764 if (IS_ERR(iptr))
747 goto out_unmap; 765 goto out_err;
748 iptr = rpcrdma_encode_reply_chunk(r_xprt, req, rqst, iptr, wtype); 766 iptr = rpcrdma_encode_reply_chunk(r_xprt, req, rqst, iptr, wtype);
749 if (IS_ERR(iptr)) 767 if (IS_ERR(iptr))
750 goto out_unmap; 768 goto out_err;
751 hdrlen = (unsigned char *)iptr - (unsigned char *)headerp; 769 hdrlen = (unsigned char *)iptr - (unsigned char *)headerp;
752 770
753 dprintk("RPC: %5u %s: %s/%s: hdrlen %zd rpclen %zd\n", 771 dprintk("RPC: %5u %s: %s/%s: hdrlen %zd rpclen %zd\n",
@@ -758,12 +776,14 @@ rpcrdma_marshal_req(struct rpc_rqst *rqst)
758 if (!rpcrdma_prepare_send_sges(&r_xprt->rx_ia, req, hdrlen, 776 if (!rpcrdma_prepare_send_sges(&r_xprt->rx_ia, req, hdrlen,
759 &rqst->rq_snd_buf, rtype)) { 777 &rqst->rq_snd_buf, rtype)) {
760 iptr = ERR_PTR(-EIO); 778 iptr = ERR_PTR(-EIO);
761 goto out_unmap; 779 goto out_err;
762 } 780 }
763 return 0; 781 return 0;
764 782
765out_unmap: 783out_err:
766 r_xprt->rx_ia.ri_ops->ro_unmap_safe(r_xprt, req, false); 784 pr_err("rpcrdma: rpcrdma_marshal_req failed, status %ld\n",
785 PTR_ERR(iptr));
786 r_xprt->rx_stats.failed_marshal_count++;
767 return PTR_ERR(iptr); 787 return PTR_ERR(iptr);
768} 788}
769 789
diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 534c178d2a7e..c717f5410776 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -67,7 +67,7 @@ unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE;
67static unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE; 67static unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE;
68static unsigned int xprt_rdma_inline_write_padding; 68static unsigned int xprt_rdma_inline_write_padding;
69static unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRMR; 69static unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRMR;
70 int xprt_rdma_pad_optimize = 1; 70 int xprt_rdma_pad_optimize = 0;
71 71
72#if IS_ENABLED(CONFIG_SUNRPC_DEBUG) 72#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
73 73
@@ -709,10 +709,6 @@ xprt_rdma_send_request(struct rpc_task *task)
709 return 0; 709 return 0;
710 710
711failed_marshal: 711failed_marshal:
712 dprintk("RPC: %s: rpcrdma_marshal_req failed, status %i\n",
713 __func__, rc);
714 if (rc == -EIO)
715 r_xprt->rx_stats.failed_marshal_count++;
716 if (rc != -ENOTCONN) 712 if (rc != -ENOTCONN)
717 return rc; 713 return rc;
718drop_connection: 714drop_connection:
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index 11d07748f699..81cd31acf690 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -54,6 +54,7 @@
54#include <linux/sunrpc/svc_rdma.h> 54#include <linux/sunrpc/svc_rdma.h>
55#include <asm/bitops.h> 55#include <asm/bitops.h>
56#include <linux/module.h> /* try_module_get()/module_put() */ 56#include <linux/module.h> /* try_module_get()/module_put() */
57#include <rdma/ib_cm.h>
57 58
58#include "xprt_rdma.h" 59#include "xprt_rdma.h"
59 60
@@ -208,6 +209,7 @@ rpcrdma_update_connect_private(struct rpcrdma_xprt *r_xprt,
208 209
209 /* Default settings for RPC-over-RDMA Version One */ 210 /* Default settings for RPC-over-RDMA Version One */
210 r_xprt->rx_ia.ri_reminv_expected = false; 211 r_xprt->rx_ia.ri_reminv_expected = false;
212 r_xprt->rx_ia.ri_implicit_roundup = xprt_rdma_pad_optimize;
211 rsize = RPCRDMA_V1_DEF_INLINE_SIZE; 213 rsize = RPCRDMA_V1_DEF_INLINE_SIZE;
212 wsize = RPCRDMA_V1_DEF_INLINE_SIZE; 214 wsize = RPCRDMA_V1_DEF_INLINE_SIZE;
213 215
@@ -215,6 +217,7 @@ rpcrdma_update_connect_private(struct rpcrdma_xprt *r_xprt,
215 pmsg->cp_magic == rpcrdma_cmp_magic && 217 pmsg->cp_magic == rpcrdma_cmp_magic &&
216 pmsg->cp_version == RPCRDMA_CMP_VERSION) { 218 pmsg->cp_version == RPCRDMA_CMP_VERSION) {
217 r_xprt->rx_ia.ri_reminv_expected = true; 219 r_xprt->rx_ia.ri_reminv_expected = true;
220 r_xprt->rx_ia.ri_implicit_roundup = true;
218 rsize = rpcrdma_decode_buffer_size(pmsg->cp_send_size); 221 rsize = rpcrdma_decode_buffer_size(pmsg->cp_send_size);
219 wsize = rpcrdma_decode_buffer_size(pmsg->cp_recv_size); 222 wsize = rpcrdma_decode_buffer_size(pmsg->cp_recv_size);
220 } 223 }
@@ -277,7 +280,14 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
277 connstate = -ENETDOWN; 280 connstate = -ENETDOWN;
278 goto connected; 281 goto connected;
279 case RDMA_CM_EVENT_REJECTED: 282 case RDMA_CM_EVENT_REJECTED:
283#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
284 pr_info("rpcrdma: connection to %pIS:%u on %s rejected: %s\n",
285 sap, rpc_get_port(sap), ia->ri_device->name,
286 rdma_reject_msg(id, event->status));
287#endif
280 connstate = -ECONNREFUSED; 288 connstate = -ECONNREFUSED;
289 if (event->status == IB_CM_REJ_STALE_CONN)
290 connstate = -EAGAIN;
281 goto connected; 291 goto connected;
282 case RDMA_CM_EVENT_DISCONNECTED: 292 case RDMA_CM_EVENT_DISCONNECTED:
283 connstate = -ECONNABORTED; 293 connstate = -ECONNABORTED;
@@ -486,18 +496,19 @@ rpcrdma_ia_close(struct rpcrdma_ia *ia)
486 */ 496 */
487int 497int
488rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia, 498rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
489 struct rpcrdma_create_data_internal *cdata) 499 struct rpcrdma_create_data_internal *cdata)
490{ 500{
491 struct rpcrdma_connect_private *pmsg = &ep->rep_cm_private; 501 struct rpcrdma_connect_private *pmsg = &ep->rep_cm_private;
502 unsigned int max_qp_wr, max_sge;
492 struct ib_cq *sendcq, *recvcq; 503 struct ib_cq *sendcq, *recvcq;
493 unsigned int max_qp_wr;
494 int rc; 504 int rc;
495 505
496 if (ia->ri_device->attrs.max_sge < RPCRDMA_MAX_SEND_SGES) { 506 max_sge = min(ia->ri_device->attrs.max_sge, RPCRDMA_MAX_SEND_SGES);
497 dprintk("RPC: %s: insufficient sge's available\n", 507 if (max_sge < RPCRDMA_MIN_SEND_SGES) {
498 __func__); 508 pr_warn("rpcrdma: HCA provides only %d send SGEs\n", max_sge);
499 return -ENOMEM; 509 return -ENOMEM;
500 } 510 }
511 ia->ri_max_send_sges = max_sge - RPCRDMA_MIN_SEND_SGES;
501 512
502 if (ia->ri_device->attrs.max_qp_wr <= RPCRDMA_BACKWARD_WRS) { 513 if (ia->ri_device->attrs.max_qp_wr <= RPCRDMA_BACKWARD_WRS) {
503 dprintk("RPC: %s: insufficient wqe's available\n", 514 dprintk("RPC: %s: insufficient wqe's available\n",
@@ -522,7 +533,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
522 ep->rep_attr.cap.max_recv_wr = cdata->max_requests; 533 ep->rep_attr.cap.max_recv_wr = cdata->max_requests;
523 ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS; 534 ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
524 ep->rep_attr.cap.max_recv_wr += 1; /* drain cqe */ 535 ep->rep_attr.cap.max_recv_wr += 1; /* drain cqe */
525 ep->rep_attr.cap.max_send_sge = RPCRDMA_MAX_SEND_SGES; 536 ep->rep_attr.cap.max_send_sge = max_sge;
526 ep->rep_attr.cap.max_recv_sge = 1; 537 ep->rep_attr.cap.max_recv_sge = 1;
527 ep->rep_attr.cap.max_inline_data = 0; 538 ep->rep_attr.cap.max_inline_data = 0;
528 ep->rep_attr.sq_sig_type = IB_SIGNAL_REQ_WR; 539 ep->rep_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
@@ -640,20 +651,21 @@ rpcrdma_ep_destroy(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
640int 651int
641rpcrdma_ep_connect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia) 652rpcrdma_ep_connect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
642{ 653{
654 struct rpcrdma_xprt *r_xprt = container_of(ia, struct rpcrdma_xprt,
655 rx_ia);
643 struct rdma_cm_id *id, *old; 656 struct rdma_cm_id *id, *old;
657 struct sockaddr *sap;
658 unsigned int extras;
644 int rc = 0; 659 int rc = 0;
645 int retry_count = 0;
646 660
647 if (ep->rep_connected != 0) { 661 if (ep->rep_connected != 0) {
648 struct rpcrdma_xprt *xprt;
649retry: 662retry:
650 dprintk("RPC: %s: reconnecting...\n", __func__); 663 dprintk("RPC: %s: reconnecting...\n", __func__);
651 664
652 rpcrdma_ep_disconnect(ep, ia); 665 rpcrdma_ep_disconnect(ep, ia);
653 666
654 xprt = container_of(ia, struct rpcrdma_xprt, rx_ia); 667 sap = (struct sockaddr *)&r_xprt->rx_data.addr;
655 id = rpcrdma_create_id(xprt, ia, 668 id = rpcrdma_create_id(r_xprt, ia, sap);
656 (struct sockaddr *)&xprt->rx_data.addr);
657 if (IS_ERR(id)) { 669 if (IS_ERR(id)) {
658 rc = -EHOSTUNREACH; 670 rc = -EHOSTUNREACH;
659 goto out; 671 goto out;
@@ -708,51 +720,18 @@ retry:
708 } 720 }
709 721
710 wait_event_interruptible(ep->rep_connect_wait, ep->rep_connected != 0); 722 wait_event_interruptible(ep->rep_connect_wait, ep->rep_connected != 0);
711
712 /*
713 * Check state. A non-peer reject indicates no listener
714 * (ECONNREFUSED), which may be a transient state. All
715 * others indicate a transport condition which has already
716 * undergone a best-effort.
717 */
718 if (ep->rep_connected == -ECONNREFUSED &&
719 ++retry_count <= RDMA_CONNECT_RETRY_MAX) {
720 dprintk("RPC: %s: non-peer_reject, retry\n", __func__);
721 goto retry;
722 }
723 if (ep->rep_connected <= 0) { 723 if (ep->rep_connected <= 0) {
724 /* Sometimes, the only way to reliably connect to remote 724 if (ep->rep_connected == -EAGAIN)
725 * CMs is to use same nonzero values for ORD and IRD. */
726 if (retry_count++ <= RDMA_CONNECT_RETRY_MAX + 1 &&
727 (ep->rep_remote_cma.responder_resources == 0 ||
728 ep->rep_remote_cma.initiator_depth !=
729 ep->rep_remote_cma.responder_resources)) {
730 if (ep->rep_remote_cma.responder_resources == 0)
731 ep->rep_remote_cma.responder_resources = 1;
732 ep->rep_remote_cma.initiator_depth =
733 ep->rep_remote_cma.responder_resources;
734 goto retry; 725 goto retry;
735 }
736 rc = ep->rep_connected; 726 rc = ep->rep_connected;
737 } else { 727 goto out;
738 struct rpcrdma_xprt *r_xprt;
739 unsigned int extras;
740
741 dprintk("RPC: %s: connected\n", __func__);
742
743 r_xprt = container_of(ia, struct rpcrdma_xprt, rx_ia);
744 extras = r_xprt->rx_buf.rb_bc_srv_max_requests;
745
746 if (extras) {
747 rc = rpcrdma_ep_post_extra_recv(r_xprt, extras);
748 if (rc) {
749 pr_warn("%s: rpcrdma_ep_post_extra_recv: %i\n",
750 __func__, rc);
751 rc = 0;
752 }
753 }
754 } 728 }
755 729
730 dprintk("RPC: %s: connected\n", __func__);
731 extras = r_xprt->rx_buf.rb_bc_srv_max_requests;
732 if (extras)
733 rpcrdma_ep_post_extra_recv(r_xprt, extras);
734
756out: 735out:
757 if (rc) 736 if (rc)
758 ep->rep_connected = rc; 737 ep->rep_connected = rc;
@@ -797,9 +776,7 @@ rpcrdma_mr_recovery_worker(struct work_struct *work)
797 776
798 spin_lock(&buf->rb_recovery_lock); 777 spin_lock(&buf->rb_recovery_lock);
799 while (!list_empty(&buf->rb_stale_mrs)) { 778 while (!list_empty(&buf->rb_stale_mrs)) {
800 mw = list_first_entry(&buf->rb_stale_mrs, 779 mw = rpcrdma_pop_mw(&buf->rb_stale_mrs);
801 struct rpcrdma_mw, mw_list);
802 list_del_init(&mw->mw_list);
803 spin_unlock(&buf->rb_recovery_lock); 780 spin_unlock(&buf->rb_recovery_lock);
804 781
805 dprintk("RPC: %s: recovering MR %p\n", __func__, mw); 782 dprintk("RPC: %s: recovering MR %p\n", __func__, mw);
@@ -817,7 +794,7 @@ rpcrdma_defer_mr_recovery(struct rpcrdma_mw *mw)
817 struct rpcrdma_buffer *buf = &r_xprt->rx_buf; 794 struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
818 795
819 spin_lock(&buf->rb_recovery_lock); 796 spin_lock(&buf->rb_recovery_lock);
820 list_add(&mw->mw_list, &buf->rb_stale_mrs); 797 rpcrdma_push_mw(mw, &buf->rb_stale_mrs);
821 spin_unlock(&buf->rb_recovery_lock); 798 spin_unlock(&buf->rb_recovery_lock);
822 799
823 schedule_delayed_work(&buf->rb_recovery_worker, 0); 800 schedule_delayed_work(&buf->rb_recovery_worker, 0);
@@ -1093,11 +1070,8 @@ rpcrdma_get_mw(struct rpcrdma_xprt *r_xprt)
1093 struct rpcrdma_mw *mw = NULL; 1070 struct rpcrdma_mw *mw = NULL;
1094 1071
1095 spin_lock(&buf->rb_mwlock); 1072 spin_lock(&buf->rb_mwlock);
1096 if (!list_empty(&buf->rb_mws)) { 1073 if (!list_empty(&buf->rb_mws))
1097 mw = list_first_entry(&buf->rb_mws, 1074 mw = rpcrdma_pop_mw(&buf->rb_mws);
1098 struct rpcrdma_mw, mw_list);
1099 list_del_init(&mw->mw_list);
1100 }
1101 spin_unlock(&buf->rb_mwlock); 1075 spin_unlock(&buf->rb_mwlock);
1102 1076
1103 if (!mw) 1077 if (!mw)
@@ -1120,7 +1094,7 @@ rpcrdma_put_mw(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mw *mw)
1120 struct rpcrdma_buffer *buf = &r_xprt->rx_buf; 1094 struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
1121 1095
1122 spin_lock(&buf->rb_mwlock); 1096 spin_lock(&buf->rb_mwlock);
1123 list_add_tail(&mw->mw_list, &buf->rb_mws); 1097 rpcrdma_push_mw(mw, &buf->rb_mws);
1124 spin_unlock(&buf->rb_mwlock); 1098 spin_unlock(&buf->rb_mwlock);
1125} 1099}
1126 1100
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
index e35efd4ac1e4..171a35116de9 100644
--- a/net/sunrpc/xprtrdma/xprt_rdma.h
+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
@@ -74,7 +74,9 @@ struct rpcrdma_ia {
74 unsigned int ri_max_frmr_depth; 74 unsigned int ri_max_frmr_depth;
75 unsigned int ri_max_inline_write; 75 unsigned int ri_max_inline_write;
76 unsigned int ri_max_inline_read; 76 unsigned int ri_max_inline_read;
77 unsigned int ri_max_send_sges;
77 bool ri_reminv_expected; 78 bool ri_reminv_expected;
79 bool ri_implicit_roundup;
78 enum ib_mr_type ri_mrtype; 80 enum ib_mr_type ri_mrtype;
79 struct ib_qp_attr ri_qp_attr; 81 struct ib_qp_attr ri_qp_attr;
80 struct ib_qp_init_attr ri_qp_init_attr; 82 struct ib_qp_init_attr ri_qp_init_attr;
@@ -303,15 +305,19 @@ struct rpcrdma_mr_seg { /* chunk descriptors */
303 char *mr_offset; /* kva if no page, else offset */ 305 char *mr_offset; /* kva if no page, else offset */
304}; 306};
305 307
306/* Reserve enough Send SGEs to send a maximum size inline request: 308/* The Send SGE array is provisioned to send a maximum size
309 * inline request:
307 * - RPC-over-RDMA header 310 * - RPC-over-RDMA header
308 * - xdr_buf head iovec 311 * - xdr_buf head iovec
309 * - RPCRDMA_MAX_INLINE bytes, possibly unaligned, in pages 312 * - RPCRDMA_MAX_INLINE bytes, in pages
310 * - xdr_buf tail iovec 313 * - xdr_buf tail iovec
314 *
315 * The actual number of array elements consumed by each RPC
316 * depends on the device's max_sge limit.
311 */ 317 */
312enum { 318enum {
313 RPCRDMA_MAX_SEND_PAGES = PAGE_SIZE + RPCRDMA_MAX_INLINE - 1, 319 RPCRDMA_MIN_SEND_SGES = 3,
314 RPCRDMA_MAX_PAGE_SGES = (RPCRDMA_MAX_SEND_PAGES >> PAGE_SHIFT) + 1, 320 RPCRDMA_MAX_PAGE_SGES = RPCRDMA_MAX_INLINE >> PAGE_SHIFT,
315 RPCRDMA_MAX_SEND_SGES = 1 + 1 + RPCRDMA_MAX_PAGE_SGES + 1, 321 RPCRDMA_MAX_SEND_SGES = 1 + 1 + RPCRDMA_MAX_PAGE_SGES + 1,
316}; 322};
317 323
@@ -348,6 +354,22 @@ rpcr_to_rdmar(struct rpc_rqst *rqst)
348 return rqst->rq_xprtdata; 354 return rqst->rq_xprtdata;
349} 355}
350 356
357static inline void
358rpcrdma_push_mw(struct rpcrdma_mw *mw, struct list_head *list)
359{
360 list_add_tail(&mw->mw_list, list);
361}
362
363static inline struct rpcrdma_mw *
364rpcrdma_pop_mw(struct list_head *list)
365{
366 struct rpcrdma_mw *mw;
367
368 mw = list_first_entry(list, struct rpcrdma_mw, mw_list);
369 list_del(&mw->mw_list);
370 return mw;
371}
372
351/* 373/*
352 * struct rpcrdma_buffer -- holds list/queue of pre-registered memory for 374 * struct rpcrdma_buffer -- holds list/queue of pre-registered memory for
353 * inline requests/replies, and client/server credits. 375 * inline requests/replies, and client/server credits.
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 956c7bce80d1..16aff8ddc16f 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -52,6 +52,8 @@
52#include "sunrpc.h" 52#include "sunrpc.h"
53 53
54static void xs_close(struct rpc_xprt *xprt); 54static void xs_close(struct rpc_xprt *xprt);
55static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt,
56 struct socket *sock);
55 57
56/* 58/*
57 * xprtsock tunables 59 * xprtsock tunables
@@ -666,6 +668,9 @@ static int xs_tcp_send_request(struct rpc_task *task)
666 if (task->tk_flags & RPC_TASK_SENT) 668 if (task->tk_flags & RPC_TASK_SENT)
667 zerocopy = false; 669 zerocopy = false;
668 670
671 if (test_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state))
672 xs_tcp_set_socket_timeouts(xprt, transport->sock);
673
669 /* Continue transmitting the packet/record. We must be careful 674 /* Continue transmitting the packet/record. We must be careful
670 * to cope with writespace callbacks arriving _after_ we have 675 * to cope with writespace callbacks arriving _after_ we have
671 * called sendmsg(). */ 676 * called sendmsg(). */
@@ -1734,7 +1739,9 @@ static void xs_udp_set_buffer_size(struct rpc_xprt *xprt, size_t sndsize, size_t
1734 */ 1739 */
1735static void xs_udp_timer(struct rpc_xprt *xprt, struct rpc_task *task) 1740static void xs_udp_timer(struct rpc_xprt *xprt, struct rpc_task *task)
1736{ 1741{
1742 spin_lock_bh(&xprt->transport_lock);
1737 xprt_adjust_cwnd(xprt, task, -ETIMEDOUT); 1743 xprt_adjust_cwnd(xprt, task, -ETIMEDOUT);
1744 spin_unlock_bh(&xprt->transport_lock);
1738} 1745}
1739 1746
1740static unsigned short xs_get_random_port(void) 1747static unsigned short xs_get_random_port(void)
@@ -2235,6 +2242,66 @@ static void xs_tcp_shutdown(struct rpc_xprt *xprt)
2235 xs_reset_transport(transport); 2242 xs_reset_transport(transport);
2236} 2243}
2237 2244
2245static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt,
2246 struct socket *sock)
2247{
2248 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
2249 unsigned int keepidle;
2250 unsigned int keepcnt;
2251 unsigned int opt_on = 1;
2252 unsigned int timeo;
2253
2254 spin_lock_bh(&xprt->transport_lock);
2255 keepidle = DIV_ROUND_UP(xprt->timeout->to_initval, HZ);
2256 keepcnt = xprt->timeout->to_retries + 1;
2257 timeo = jiffies_to_msecs(xprt->timeout->to_initval) *
2258 (xprt->timeout->to_retries + 1);
2259 clear_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state);
2260 spin_unlock_bh(&xprt->transport_lock);
2261
2262 /* TCP Keepalive options */
2263 kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
2264 (char *)&opt_on, sizeof(opt_on));
2265 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE,
2266 (char *)&keepidle, sizeof(keepidle));
2267 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL,
2268 (char *)&keepidle, sizeof(keepidle));
2269 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT,
2270 (char *)&keepcnt, sizeof(keepcnt));
2271
2272 /* TCP user timeout (see RFC5482) */
2273 kernel_setsockopt(sock, SOL_TCP, TCP_USER_TIMEOUT,
2274 (char *)&timeo, sizeof(timeo));
2275}
2276
2277static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt,
2278 unsigned long connect_timeout,
2279 unsigned long reconnect_timeout)
2280{
2281 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
2282 struct rpc_timeout to;
2283 unsigned long initval;
2284
2285 spin_lock_bh(&xprt->transport_lock);
2286 if (reconnect_timeout < xprt->max_reconnect_timeout)
2287 xprt->max_reconnect_timeout = reconnect_timeout;
2288 if (connect_timeout < xprt->connect_timeout) {
2289 memcpy(&to, xprt->timeout, sizeof(to));
2290 initval = DIV_ROUND_UP(connect_timeout, to.to_retries + 1);
2291 /* Arbitrary lower limit */
2292 if (initval < XS_TCP_INIT_REEST_TO << 1)
2293 initval = XS_TCP_INIT_REEST_TO << 1;
2294 to.to_initval = initval;
2295 to.to_maxval = initval;
2296 memcpy(&transport->tcp_timeout, &to,
2297 sizeof(transport->tcp_timeout));
2298 xprt->timeout = &transport->tcp_timeout;
2299 xprt->connect_timeout = connect_timeout;
2300 }
2301 set_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state);
2302 spin_unlock_bh(&xprt->transport_lock);
2303}
2304
2238static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) 2305static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
2239{ 2306{
2240 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); 2307 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
@@ -2242,22 +2309,8 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
2242 2309
2243 if (!transport->inet) { 2310 if (!transport->inet) {
2244 struct sock *sk = sock->sk; 2311 struct sock *sk = sock->sk;
2245 unsigned int keepidle = xprt->timeout->to_initval / HZ;
2246 unsigned int keepcnt = xprt->timeout->to_retries + 1;
2247 unsigned int opt_on = 1;
2248 unsigned int timeo;
2249 unsigned int addr_pref = IPV6_PREFER_SRC_PUBLIC; 2312 unsigned int addr_pref = IPV6_PREFER_SRC_PUBLIC;
2250 2313
2251 /* TCP Keepalive options */
2252 kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
2253 (char *)&opt_on, sizeof(opt_on));
2254 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPIDLE,
2255 (char *)&keepidle, sizeof(keepidle));
2256 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPINTVL,
2257 (char *)&keepidle, sizeof(keepidle));
2258 kernel_setsockopt(sock, SOL_TCP, TCP_KEEPCNT,
2259 (char *)&keepcnt, sizeof(keepcnt));
2260
2261 /* Avoid temporary address, they are bad for long-lived 2314 /* Avoid temporary address, they are bad for long-lived
2262 * connections such as NFS mounts. 2315 * connections such as NFS mounts.
2263 * RFC4941, section 3.6 suggests that: 2316 * RFC4941, section 3.6 suggests that:
@@ -2268,11 +2321,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
2268 kernel_setsockopt(sock, SOL_IPV6, IPV6_ADDR_PREFERENCES, 2321 kernel_setsockopt(sock, SOL_IPV6, IPV6_ADDR_PREFERENCES,
2269 (char *)&addr_pref, sizeof(addr_pref)); 2322 (char *)&addr_pref, sizeof(addr_pref));
2270 2323
2271 /* TCP user timeout (see RFC5482) */ 2324 xs_tcp_set_socket_timeouts(xprt, sock);
2272 timeo = jiffies_to_msecs(xprt->timeout->to_initval) *
2273 (xprt->timeout->to_retries + 1);
2274 kernel_setsockopt(sock, SOL_TCP, TCP_USER_TIMEOUT,
2275 (char *)&timeo, sizeof(timeo));
2276 2325
2277 write_lock_bh(&sk->sk_callback_lock); 2326 write_lock_bh(&sk->sk_callback_lock);
2278 2327
@@ -2721,6 +2770,7 @@ static struct rpc_xprt_ops xs_tcp_ops = {
2721 .set_retrans_timeout = xprt_set_retrans_timeout_def, 2770 .set_retrans_timeout = xprt_set_retrans_timeout_def,
2722 .close = xs_tcp_shutdown, 2771 .close = xs_tcp_shutdown,
2723 .destroy = xs_destroy, 2772 .destroy = xs_destroy,
2773 .set_connect_timeout = xs_tcp_set_connect_timeout,
2724 .print_stats = xs_tcp_print_stats, 2774 .print_stats = xs_tcp_print_stats,
2725 .enable_swap = xs_enable_swap, 2775 .enable_swap = xs_enable_swap,
2726 .disable_swap = xs_disable_swap, 2776 .disable_swap = xs_disable_swap,
@@ -3007,6 +3057,8 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
3007 xprt->timeout = &xs_tcp_default_timeout; 3057 xprt->timeout = &xs_tcp_default_timeout;
3008 3058
3009 xprt->max_reconnect_timeout = xprt->timeout->to_maxval; 3059 xprt->max_reconnect_timeout = xprt->timeout->to_maxval;
3060 xprt->connect_timeout = xprt->timeout->to_initval *
3061 (xprt->timeout->to_retries + 1);
3010 3062
3011 INIT_WORK(&transport->recv_worker, xs_tcp_data_receive_workfn); 3063 INIT_WORK(&transport->recv_worker, xs_tcp_data_receive_workfn);
3012 INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_setup_socket); 3064 INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_setup_socket);
@@ -3209,7 +3261,9 @@ static int param_set_uint_minmax(const char *val,
3209 if (!val) 3261 if (!val)
3210 return -EINVAL; 3262 return -EINVAL;
3211 ret = kstrtouint(val, 0, &num); 3263 ret = kstrtouint(val, 0, &num);
3212 if (ret == -EINVAL || num < min || num > max) 3264 if (ret)
3265 return ret;
3266 if (num < min || num > max)
3213 return -EINVAL; 3267 return -EINVAL;
3214 *((unsigned int *)kp->arg) = num; 3268 *((unsigned int *)kp->arg) = num;
3215 return 0; 3269 return 0;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 4dedd0d3d3a7..30d752a4a6a6 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -854,6 +854,7 @@ static const char *const section_white_list[] =
854 ".cmem*", /* EZchip */ 854 ".cmem*", /* EZchip */
855 ".fmt_slot*", /* EZchip */ 855 ".fmt_slot*", /* EZchip */
856 ".gnu.lto*", 856 ".gnu.lto*",
857 ".discard.*",
857 NULL 858 NULL
858}; 859};
859 860
diff --git a/scripts/module-common.lds b/scripts/module-common.lds
index 73a2c7da0e55..cf7e52e4781b 100644
--- a/scripts/module-common.lds
+++ b/scripts/module-common.lds
@@ -4,7 +4,10 @@
4 * combine them automatically. 4 * combine them automatically.
5 */ 5 */
6SECTIONS { 6SECTIONS {
7 /DISCARD/ : { *(.discard) } 7 /DISCARD/ : {
8 *(.discard)
9 *(.discard.*)
10 }
8 11
9 __ksymtab 0 : { *(SORT(___ksymtab+*)) } 12 __ksymtab 0 : { *(SORT(___ksymtab+*)) }
10 __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) } 13 __ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
diff --git a/sound/core/seq/seq_fifo.c b/sound/core/seq/seq_fifo.c
index 1d5acbe0c08b..86240d02b530 100644
--- a/sound/core/seq/seq_fifo.c
+++ b/sound/core/seq/seq_fifo.c
@@ -135,6 +135,7 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f,
135 f->tail = cell; 135 f->tail = cell;
136 if (f->head == NULL) 136 if (f->head == NULL)
137 f->head = cell; 137 f->head = cell;
138 cell->next = NULL;
138 f->cells++; 139 f->cells++;
139 spin_unlock_irqrestore(&f->lock, flags); 140 spin_unlock_irqrestore(&f->lock, flags);
140 141
@@ -214,6 +215,8 @@ void snd_seq_fifo_cell_putback(struct snd_seq_fifo *f,
214 spin_lock_irqsave(&f->lock, flags); 215 spin_lock_irqsave(&f->lock, flags);
215 cell->next = f->head; 216 cell->next = f->head;
216 f->head = cell; 217 f->head = cell;
218 if (!f->tail)
219 f->tail = cell;
217 f->cells++; 220 f->cells++;
218 spin_unlock_irqrestore(&f->lock, flags); 221 spin_unlock_irqrestore(&f->lock, flags);
219 } 222 }
diff --git a/sound/core/timer.c b/sound/core/timer.c
index fc144f43faa6..ad153149b231 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -1702,9 +1702,21 @@ static int snd_timer_user_params(struct file *file,
1702 return -EBADFD; 1702 return -EBADFD;
1703 if (copy_from_user(&params, _params, sizeof(params))) 1703 if (copy_from_user(&params, _params, sizeof(params)))
1704 return -EFAULT; 1704 return -EFAULT;
1705 if (!(t->hw.flags & SNDRV_TIMER_HW_SLAVE) && params.ticks < 1) { 1705 if (!(t->hw.flags & SNDRV_TIMER_HW_SLAVE)) {
1706 err = -EINVAL; 1706 u64 resolution;
1707 goto _end; 1707
1708 if (params.ticks < 1) {
1709 err = -EINVAL;
1710 goto _end;
1711 }
1712
1713 /* Don't allow resolution less than 1ms */
1714 resolution = snd_timer_resolution(tu->timeri);
1715 resolution *= params.ticks;
1716 if (resolution < 1000000) {
1717 err = -EINVAL;
1718 goto _end;
1719 }
1708 } 1720 }
1709 if (params.queue_size > 0 && 1721 if (params.queue_size > 0 &&
1710 (params.queue_size < 32 || params.queue_size > 1024)) { 1722 (params.queue_size < 32 || params.queue_size > 1024)) {
diff --git a/sound/pci/ctxfi/cthw20k1.c b/sound/pci/ctxfi/cthw20k1.c
index 9667cbfb0ca2..ab4cdab5cfa5 100644
--- a/sound/pci/ctxfi/cthw20k1.c
+++ b/sound/pci/ctxfi/cthw20k1.c
@@ -27,12 +27,6 @@
27#include "cthw20k1.h" 27#include "cthw20k1.h"
28#include "ct20k1reg.h" 28#include "ct20k1reg.h"
29 29
30#if BITS_PER_LONG == 32
31#define CT_XFI_DMA_MASK DMA_BIT_MASK(32) /* 32 bit PTE */
32#else
33#define CT_XFI_DMA_MASK DMA_BIT_MASK(64) /* 64 bit PTE */
34#endif
35
36struct hw20k1 { 30struct hw20k1 {
37 struct hw hw; 31 struct hw hw;
38 spinlock_t reg_20k1_lock; 32 spinlock_t reg_20k1_lock;
@@ -1904,19 +1898,18 @@ static int hw_card_start(struct hw *hw)
1904{ 1898{
1905 int err; 1899 int err;
1906 struct pci_dev *pci = hw->pci; 1900 struct pci_dev *pci = hw->pci;
1901 const unsigned int dma_bits = BITS_PER_LONG;
1907 1902
1908 err = pci_enable_device(pci); 1903 err = pci_enable_device(pci);
1909 if (err < 0) 1904 if (err < 0)
1910 return err; 1905 return err;
1911 1906
1912 /* Set DMA transfer mask */ 1907 /* Set DMA transfer mask */
1913 if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 || 1908 if (dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
1914 dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) { 1909 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
1915 dev_err(hw->card->dev, 1910 } else {
1916 "architecture does not support PCI busmaster DMA with mask 0x%llx\n", 1911 dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
1917 CT_XFI_DMA_MASK); 1912 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
1918 err = -ENXIO;
1919 goto error1;
1920 } 1913 }
1921 1914
1922 if (!hw->io_base) { 1915 if (!hw->io_base) {
diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c
index 6414ecf93efa..18ee7768b7c4 100644
--- a/sound/pci/ctxfi/cthw20k2.c
+++ b/sound/pci/ctxfi/cthw20k2.c
@@ -26,12 +26,6 @@
26#include "cthw20k2.h" 26#include "cthw20k2.h"
27#include "ct20k2reg.h" 27#include "ct20k2reg.h"
28 28
29#if BITS_PER_LONG == 32
30#define CT_XFI_DMA_MASK DMA_BIT_MASK(32) /* 32 bit PTE */
31#else
32#define CT_XFI_DMA_MASK DMA_BIT_MASK(64) /* 64 bit PTE */
33#endif
34
35struct hw20k2 { 29struct hw20k2 {
36 struct hw hw; 30 struct hw hw;
37 /* for i2c */ 31 /* for i2c */
@@ -2029,19 +2023,18 @@ static int hw_card_start(struct hw *hw)
2029 int err = 0; 2023 int err = 0;
2030 struct pci_dev *pci = hw->pci; 2024 struct pci_dev *pci = hw->pci;
2031 unsigned int gctl; 2025 unsigned int gctl;
2026 const unsigned int dma_bits = BITS_PER_LONG;
2032 2027
2033 err = pci_enable_device(pci); 2028 err = pci_enable_device(pci);
2034 if (err < 0) 2029 if (err < 0)
2035 return err; 2030 return err;
2036 2031
2037 /* Set DMA transfer mask */ 2032 /* Set DMA transfer mask */
2038 if (dma_set_mask(&pci->dev, CT_XFI_DMA_MASK) < 0 || 2033 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) {
2039 dma_set_coherent_mask(&pci->dev, CT_XFI_DMA_MASK) < 0) { 2034 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits));
2040 dev_err(hw->card->dev, 2035 } else {
2041 "architecture does not support PCI busmaster DMA with mask 0x%llx\n", 2036 dma_set_mask(&pci->dev, DMA_BIT_MASK(32));
2042 CT_XFI_DMA_MASK); 2037 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32));
2043 err = -ENXIO;
2044 goto error1;
2045 } 2038 }
2046 2039
2047 if (!hw->io_base) { 2040 if (!hw->io_base) {
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 16108f0eb688..c8256a89375a 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -2255,6 +2255,9 @@ static const struct pci_device_id azx_ids[] = {
2255 /* Broxton-T */ 2255 /* Broxton-T */
2256 { PCI_DEVICE(0x8086, 0x1a98), 2256 { PCI_DEVICE(0x8086, 0x1a98),
2257 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_BROXTON }, 2257 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_BROXTON },
2258 /* Gemini-Lake */
2259 { PCI_DEVICE(0x8086, 0x3198),
2260 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_BROXTON },
2258 /* Haswell */ 2261 /* Haswell */
2259 { PCI_DEVICE(0x8086, 0x0a0c), 2262 { PCI_DEVICE(0x8086, 0x0a0c),
2260 .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL }, 2263 .driver_data = AZX_DRIVER_HDMI | AZX_DCAPS_INTEL_HASWELL },
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index fd5efa72a68b..1461ef8eb749 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -3800,6 +3800,7 @@ HDA_CODEC_ENTRY(0x80862808, "Broadwell HDMI", patch_i915_hsw_hdmi),
3800HDA_CODEC_ENTRY(0x80862809, "Skylake HDMI", patch_i915_hsw_hdmi), 3800HDA_CODEC_ENTRY(0x80862809, "Skylake HDMI", patch_i915_hsw_hdmi),
3801HDA_CODEC_ENTRY(0x8086280a, "Broxton HDMI", patch_i915_hsw_hdmi), 3801HDA_CODEC_ENTRY(0x8086280a, "Broxton HDMI", patch_i915_hsw_hdmi),
3802HDA_CODEC_ENTRY(0x8086280b, "Kabylake HDMI", patch_i915_hsw_hdmi), 3802HDA_CODEC_ENTRY(0x8086280b, "Kabylake HDMI", patch_i915_hsw_hdmi),
3803HDA_CODEC_ENTRY(0x8086280d, "Geminilake HDMI", patch_i915_hsw_hdmi),
3803HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi), 3804HDA_CODEC_ENTRY(0x80862880, "CedarTrail HDMI", patch_generic_hdmi),
3804HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi), 3805HDA_CODEC_ENTRY(0x80862882, "Valleyview2 HDMI", patch_i915_byt_hdmi),
3805HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_i915_byt_hdmi), 3806HDA_CODEC_ENTRY(0x80862883, "Braswell HDMI", patch_i915_byt_hdmi),
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 73a00460b5c1..4e112221d825 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5606,6 +5606,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5606 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE), 5606 SND_PCI_QUIRK(0x1028, 0x0725, "Dell Inspiron 3162", ALC255_FIXUP_DELL_SPK_NOISE),
5607 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE), 5607 SND_PCI_QUIRK(0x1028, 0x075b, "Dell XPS 13 9360", ALC256_FIXUP_DELL_XPS_13_HEADPHONE_NOISE),
5608 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME), 5608 SND_PCI_QUIRK(0x1028, 0x075d, "Dell AIO", ALC298_FIXUP_SPK_VOLUME),
5609 SND_PCI_QUIRK(0x1028, 0x0798, "Dell Inspiron 17 7000 Gaming", ALC256_FIXUP_DELL_INSPIRON_7559_SUBWOOFER),
5609 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 5610 SND_PCI_QUIRK(0x1028, 0x164a, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
5610 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE), 5611 SND_PCI_QUIRK(0x1028, 0x164b, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE),
5611 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2), 5612 SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
@@ -5724,6 +5725,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5724 SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460), 5725 SND_PCI_QUIRK(0x17aa, 0x2233, "Thinkpad", ALC292_FIXUP_TPT460),
5725 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), 5726 SND_PCI_QUIRK(0x17aa, 0x30bb, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
5726 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY), 5727 SND_PCI_QUIRK(0x17aa, 0x30e2, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
5728 SND_PCI_QUIRK(0x17aa, 0x3112, "ThinkCentre AIO", ALC233_FIXUP_LENOVO_LINE2_MIC_HOTKEY),
5727 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI), 5729 SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
5728 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC), 5730 SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
5729 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP), 5731 SND_PCI_QUIRK(0x17aa, 0x3978, "IdeaPad Y410P", ALC269_FIXUP_NO_SHUTUP),
diff --git a/tools/objtool/builtin-check.c b/tools/objtool/builtin-check.c
index 5fc52ee3264c..4cfdbb5b6967 100644
--- a/tools/objtool/builtin-check.c
+++ b/tools/objtool/builtin-check.c
@@ -339,13 +339,13 @@ static int add_dead_ends(struct objtool_file *file)
339 struct instruction *insn; 339 struct instruction *insn;
340 bool found; 340 bool found;
341 341
342 sec = find_section_by_name(file->elf, ".rela__unreachable"); 342 sec = find_section_by_name(file->elf, ".rela.discard.unreachable");
343 if (!sec) 343 if (!sec)
344 return 0; 344 return 0;
345 345
346 list_for_each_entry(rela, &sec->rela_list, list) { 346 list_for_each_entry(rela, &sec->rela_list, list) {
347 if (rela->sym->type != STT_SECTION) { 347 if (rela->sym->type != STT_SECTION) {
348 WARN("unexpected relocation symbol type in .rela__unreachable"); 348 WARN("unexpected relocation symbol type in %s", sec->name);
349 return -1; 349 return -1;
350 } 350 }
351 insn = find_insn(file, rela->sym->sec, rela->addend); 351 insn = find_insn(file, rela->sym->sec, rela->addend);
@@ -1272,7 +1272,7 @@ int cmd_check(int argc, const char **argv)
1272 1272
1273 INIT_LIST_HEAD(&file.insn_list); 1273 INIT_LIST_HEAD(&file.insn_list);
1274 hash_init(file.insn_hash); 1274 hash_init(file.insn_hash);
1275 file.whitelist = find_section_by_name(file.elf, "__func_stack_frame_non_standard"); 1275 file.whitelist = find_section_by_name(file.elf, ".discard.func_stack_frame_non_standard");
1276 file.rodata = find_section_by_name(file.elf, ".rodata"); 1276 file.rodata = find_section_by_name(file.elf, ".rodata");
1277 file.ignore_unreachables = false; 1277 file.ignore_unreachables = false;
1278 file.c_file = find_section_by_name(file.elf, ".comment"); 1278 file.c_file = find_section_by_name(file.elf, ".comment");