From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530597623801297.2126325552913; Mon, 2 Jul 2018 23:00:23 -0700 (PDT) Received: from localhost ([::1]:37932 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEMI-00047m-3u for importer@patchew.org; Tue, 03 Jul 2018 02:00:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKL-0002k3-RU for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKK-0006gQ-UG for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:13 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:56551) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKK-0006YG-8o; Tue, 03 Jul 2018 01:58:12 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM41slCz9s2R; Tue, 3 Jul 2018 15:58:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597488; bh=SrepHO9KNwqXwd7eVND8YUbfNl1DPbSo9/VXR730ClU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PiGW+pW/T0l6wnpDxkBERlCmP3n/+nPyhHWIN4C4Md3qJ/EvgffEqHrecePOHubgj IP7iHKdhKEqtfpDPndOcf9E9SgeU/r68gYW2TFgWDn5UICKQqvnB/hO+jeuOYX5Jdp yrZlN+gOZXsS0gwYyLj/HzbD5c0t+60WsME8PwA8= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:30 +1000 Message-Id: <20180703055804.13449-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 01/35] mac_dbdma: only dump commands for debug enabled channels X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Mark Cave-Ayland , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland This enables us to apply the same filter in DEBUG_DBDMA_CHANMASK to the DBDMA command execution debug output. Signed-off-by: Mark Cave-Ayland Signed-off-by: David Gibson --- hw/misc/macio/mac_dbdma.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/hw/misc/macio/mac_dbdma.c b/hw/misc/macio/mac_dbdma.c index 1b2a69b3ef..87ae246d37 100644 --- a/hw/misc/macio/mac_dbdma.c +++ b/hw/misc/macio/mac_dbdma.c @@ -71,18 +71,19 @@ static DBDMAState *dbdma_from_ch(DBDMA_channel *ch) } =20 #if DEBUG_DBDMA -static void dump_dbdma_cmd(dbdma_cmd *cmd) +static void dump_dbdma_cmd(DBDMA_channel *ch, dbdma_cmd *cmd) { - printf("dbdma_cmd %p\n", cmd); - printf(" req_count 0x%04x\n", le16_to_cpu(cmd->req_count)); - printf(" command 0x%04x\n", le16_to_cpu(cmd->command)); - printf(" phy_addr 0x%08x\n", le32_to_cpu(cmd->phy_addr)); - printf(" cmd_dep 0x%08x\n", le32_to_cpu(cmd->cmd_dep)); - printf(" res_count 0x%04x\n", le16_to_cpu(cmd->res_count)); - printf(" xfer_status 0x%04x\n", le16_to_cpu(cmd->xfer_status)); + DBDMA_DPRINTFCH(ch, "dbdma_cmd %p\n", cmd); + DBDMA_DPRINTFCH(ch, " req_count 0x%04x\n", le16_to_cpu(cmd->req_cou= nt)); + DBDMA_DPRINTFCH(ch, " command 0x%04x\n", le16_to_cpu(cmd->command)); + DBDMA_DPRINTFCH(ch, " phy_addr 0x%08x\n", le32_to_cpu(cmd->phy_addr= )); + DBDMA_DPRINTFCH(ch, " cmd_dep 0x%08x\n", le32_to_cpu(cmd->cmd_dep)); + DBDMA_DPRINTFCH(ch, " res_count 0x%04x\n", le16_to_cpu(cmd->res_cou= nt)); + DBDMA_DPRINTFCH(ch, " xfer_status 0x%04x\n", + le16_to_cpu(cmd->xfer_status)); } #else -static void dump_dbdma_cmd(dbdma_cmd *cmd) +static void dump_dbdma_cmd(DBDMA_channel *ch, dbdma_cmd *cmd) { } #endif @@ -448,7 +449,7 @@ static void channel_run(DBDMA_channel *ch) uint32_t phy_addr; =20 DBDMA_DPRINTFCH(ch, "channel_run\n"); - dump_dbdma_cmd(current); + dump_dbdma_cmd(ch, current); =20 /* clear WAKE flag at command fetch */ =20 --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598020187120.37018985964016; Mon, 2 Jul 2018 23:07:00 -0700 (PDT) Received: from localhost ([::1]:37977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faESf-0000qQ-Hw for importer@patchew.org; Tue, 03 Jul 2018 02:06:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKP-0002li-VX for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKM-0006nn-6V for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:17 -0400 Received: from ozlabs.org ([203.11.71.1]:55627) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKL-0006Zo-Pm; Tue, 03 Jul 2018 01:58:14 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM45hCkz9s3Z; Tue, 3 Jul 2018 15:58:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597488; bh=P/kr59FPH5rB6ywxNXcevVlGV+feZLLJV+bnC51zdVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ug9f1YcI6cV5LcfVH0Am7UzmBRVFOvwSk0KK+TcHypwMMNj3B5FH6UIfQM6+E/Rg0 s6+elaZQa3SoZrLt5d6TJkr+mhayuum4IvBQjrnB7bQxN1afWpvbeIJPVFLmVppsx6 fIBtvkVcIkB8PRzOiCcqVrVyF7LZwzgREqsA1kQM= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:31 +1000 Message-Id: <20180703055804.13449-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 02/35] mac_newworld: always enable disable_direct_reg3_writes for ADB machines X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Mark Cave-Ayland , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland Commit 84051eb400 "adb: add property to disable direct reg 3 writes" added a workaround for MacOS 9 incorrectly setting the mouse address during boot of PMU machines. Further testing has shown that since fb6649f172 "adb: fix read reg 3 byte ordering" this can still sometimes happen with the CUDA mac99 machine, so let's enable this workaround for all New World machines using ADB for no= w. Signed-off-by: Mark Cave-Ayland Signed-off-by: David Gibson --- hw/ppc/mac_newworld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index ff715ffffd..2b13fcdde5 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -407,11 +407,11 @@ static void ppc_core99_init(MachineState *machine) =20 adb_bus =3D qdev_get_child_bus(dev, "adb.0"); dev =3D qdev_create(adb_bus, TYPE_ADB_KEYBOARD); - qdev_prop_set_bit(dev, "disable-direct-reg3-writes", has_pmu); + qdev_prop_set_bit(dev, "disable-direct-reg3-writes", true); qdev_init_nofail(dev); =20 dev =3D qdev_create(adb_bus, TYPE_ADB_MOUSE); - qdev_prop_set_bit(dev, "disable-direct-reg3-writes", has_pmu); + qdev_prop_set_bit(dev, "disable-direct-reg3-writes", true); qdev_init_nofail(dev); } =20 --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530597817290429.9742295140916; Mon, 2 Jul 2018 23:03:37 -0700 (PDT) Received: from localhost ([::1]:37954 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEPY-0006bW-Fm for importer@patchew.org; Tue, 03 Jul 2018 02:03:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39486) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKM-0002k4-0b for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKK-0006gX-Ub for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:14 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:53199) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKK-0006YO-DD; Tue, 03 Jul 2018 01:58:12 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM43P48z9s3C; Tue, 3 Jul 2018 15:58:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597488; bh=Q2bcvvDzxsEabP0OhAwepliYAxLNoIwCQZn1il18nDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=brwI1mzpcaEx4DG8deEld3+XRhWNgGCKc/o40YQnZ51IVXDFNzQIKaXxQVv50UFX/ PNRcB/4d+rqoZ/JGvyS+sVLJ4+PLD35FSJG+1jbnDMDe08iAno0Dh21TgImsPyYA6B dq7PvpQfeIPpaNpljjlpi6ra9sjK0IVwgPMW85YE= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:32 +1000 Message-Id: <20180703055804.13449-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 03/35] sam460ex: Fix sam460ex device tree when booting the Linux kernel X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, Guenter Roeck , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Guenter Roeck sam460ex (or at least this emulation) does not support the "ibm,cpm" power management. As a result, Linux crashes when trying to access it. Remove its device tree node. Also, if/when we boot the Linux kernel directly, serial port clock frequencies in the device tree file will be unset, and serial port initialization will fail. Add valid frequency values to the serial ports to be able to use it. Also set valid values for the other clock nodes otherwise set by u-boot. Signed-off-by: Guenter Roeck Reviewed-by: BALATON Zoltan Signed-off-by: David Gibson --- hw/ppc/sam460ex.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index bdc53d2603..33ea51816c 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -37,6 +37,8 @@ #include "hw/i2c/smbus.h" #include "hw/usb/hcd-ehci.h" =20 +#include + #define BINARY_DEVICE_TREE_FILE "canyonlands.dtb" #define UBOOT_FILENAME "u-boot-sam460-20100605.bin" /* to extract the official U-Boot bin from the updater: */ @@ -67,6 +69,10 @@ */ =20 #define CPU_FREQ 1150000000 +#define PLB_FREQ 230000000 +#define OPB_FREQ 115000000 +#define EBC_FREQ 115000000 +#define UART_FREQ 11059200 #define SDRAM_NR_BANKS 4 =20 /* FIXME: See u-boot.git 8ac41e, also fix in ppc440_uc.c */ @@ -255,6 +261,7 @@ static int sam460ex_load_device_tree(hwaddr addr, void *fdt; uint32_t tb_freq =3D CPU_FREQ; uint32_t clock_freq =3D CPU_FREQ; + int offset; =20 filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FI= LE); if (!filename) { @@ -308,6 +315,27 @@ static int sam460ex_load_device_tree(hwaddr addr, qemu_fdt_setprop_cell(fdt, "/cpus/cpu@0", "timebase-frequency", tb_freq); =20 + /* Remove cpm node if it exists (it is not emulated) */ + offset =3D fdt_path_offset(fdt, "/cpm"); + if (offset >=3D 0) { + fdt_nop_node(fdt, offset); + } + + /* set serial port clocks */ + offset =3D fdt_node_offset_by_compatible(fdt, -1, "ns16550"); + while (offset >=3D 0) { + fdt_setprop_cell(fdt, offset, "clock-frequency", UART_FREQ); + offset =3D fdt_node_offset_by_compatible(fdt, offset, "ns16550"); + } + + /* some more clocks */ + qemu_fdt_setprop_cell(fdt, "/plb", "clock-frequency", + PLB_FREQ); + qemu_fdt_setprop_cell(fdt, "/plb/opb", "clock-frequency", + OPB_FREQ); + qemu_fdt_setprop_cell(fdt, "/plb/opb/ebc", "clock-frequency", + EBC_FREQ); + rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); g_free(fdt); ret =3D fdt_size; --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598707611225.60460173322156; Mon, 2 Jul 2018 23:18:27 -0700 (PDT) Received: from localhost ([::1]:38040 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEdr-00026u-Em for importer@patchew.org; Tue, 03 Jul 2018 02:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKQ-0002ll-2W for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKO-0006tb-L1 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:18 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:53373) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKN-0006k9-UQ; Tue, 03 Jul 2018 01:58:16 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM60qTHz9s3x; Tue, 3 Jul 2018 15:58:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597490; bh=GximJRpwxcsc74Jnq3W/G6vuDxz1Yd8YHqECha/DDn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4B7t0MH9Y7NxyaBOswtLx6B6xj52Xu8ATGcwU/IAe7YC/374gKcD0v0j06TWoZJI 7N8Xs4j/hYeymCLssGmZa+hbAwLiODcVYN0/MxZPEFm0vhHET9ws0/tEKiah0zH312 O2qBejMQdSjFPXbenwrjuZSmZVxlQvLNqWmdcRXg= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:33 +1000 Message-Id: <20180703055804.13449-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 04/35] ppc/xics: introduce ICP DeviceRealize and DeviceReset handlers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater This changes the ICP realize and reset handlers in DeviceRealize and DeviceReset handlers. parent handlers are now called from the inheriting classes which is a cleaner object pattern. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 10 ---------- hw/intc/xics_kvm.c | 34 +++++++++++++++++++++++++++------- hw/intc/xics_pnv.c | 15 +++++++++++++-- include/hw/ppc/xics.h | 5 +++-- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index e73e623e3b..063491f387 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -294,7 +294,6 @@ static const VMStateDescription vmstate_icp_server =3D { static void icp_reset(void *dev) { ICPState *icp =3D ICP(dev); - ICPStateClass *icpc =3D ICP_GET_CLASS(icp); =20 icp->xirr =3D 0; icp->pending_priority =3D 0xff; @@ -302,16 +301,11 @@ static void icp_reset(void *dev) =20 /* Make all outputs are deasserted */ qemu_set_irq(icp->output, 0); - - if (icpc->reset) { - icpc->reset(icp); - } } =20 static void icp_realize(DeviceState *dev, Error **errp) { ICPState *icp =3D ICP(dev); - ICPStateClass *icpc =3D ICP_GET_CLASS(dev); PowerPCCPU *cpu; CPUPPCState *env; Object *obj; @@ -351,10 +345,6 @@ static void icp_realize(DeviceState *dev, Error **errp) return; } =20 - if (icpc->realize) { - icpc->realize(icp, errp); - } - qemu_register_reset(icp_reset, dev); vmstate_register(NULL, icp->cs->cpu_index, &vmstate_icp_server, icp); } diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 8dba2f84e7..f511e50a80 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -114,22 +114,38 @@ static int icp_set_kvm_state(ICPState *icp, int versi= on_id) return 0; } =20 -static void icp_kvm_reset(ICPState *icp) +static void icp_kvm_reset(DeviceState *dev) { - icp_set_kvm_state(icp, 1); + ICPStateClass *icpc =3D ICP_GET_CLASS(dev); + + icpc->parent_reset(dev); + + icp_set_kvm_state(ICP(dev), 1); } =20 -static void icp_kvm_realize(ICPState *icp, Error **errp) +static void icp_kvm_realize(DeviceState *dev, Error **errp) { - CPUState *cs =3D icp->cs; + ICPState *icp =3D ICP(dev); + ICPStateClass *icpc =3D ICP_GET_CLASS(icp); + Error *local_err =3D NULL; + CPUState *cs; KVMEnabledICP *enabled_icp; - unsigned long vcpu_id =3D kvm_arch_vcpu_id(cs); + unsigned long vcpu_id; int ret; =20 if (kernel_xics_fd =3D=3D -1) { abort(); } =20 + icpc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + cs =3D icp->cs; + vcpu_id =3D kvm_arch_vcpu_id(cs); + /* * If we are reusing a parked vCPU fd corresponding to the CPU * which was hot-removed earlier we don't have to renable @@ -154,12 +170,16 @@ static void icp_kvm_realize(ICPState *icp, Error **er= rp) =20 static void icp_kvm_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc =3D DEVICE_CLASS(klass); ICPStateClass *icpc =3D ICP_CLASS(klass); =20 + device_class_set_parent_realize(dc, icp_kvm_realize, + &icpc->parent_realize); + device_class_set_parent_reset(dc, icp_kvm_reset, + &icpc->parent_reset); + icpc->pre_save =3D icp_get_kvm_state; icpc->post_load =3D icp_set_kvm_state; - icpc->realize =3D icp_kvm_realize; - icpc->reset =3D icp_kvm_reset; icpc->synchronize_state =3D icp_synchronize_state; } =20 diff --git a/hw/intc/xics_pnv.c b/hw/intc/xics_pnv.c index c87de2189c..fa48505f36 100644 --- a/hw/intc/xics_pnv.c +++ b/hw/intc/xics_pnv.c @@ -18,6 +18,7 @@ */ =20 #include "qemu/osdep.h" +#include "qapi/error.h" #include "sysemu/sysemu.h" #include "qemu/log.h" #include "hw/ppc/xics.h" @@ -158,9 +159,18 @@ static const MemoryRegionOps pnv_icp_ops =3D { }, }; =20 -static void pnv_icp_realize(ICPState *icp, Error **errp) +static void pnv_icp_realize(DeviceState *dev, Error **errp) { + ICPState *icp =3D ICP(dev); PnvICPState *pnv_icp =3D PNV_ICP(icp); + ICPStateClass *icpc =3D ICP_GET_CLASS(icp); + Error *local_err =3D NULL; + + icpc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 memory_region_init_io(&pnv_icp->mmio, OBJECT(icp), &pnv_icp_ops, icp, "icp-thread", 0x1000); @@ -171,7 +181,8 @@ static void pnv_icp_class_init(ObjectClass *klass, void= *data) DeviceClass *dc =3D DEVICE_CLASS(klass); ICPStateClass *icpc =3D ICP_CLASS(klass); =20 - icpc->realize =3D pnv_icp_realize; + device_class_set_parent_realize(dc, pnv_icp_realize, + &icpc->parent_realize); dc->desc =3D "PowerNV ICP"; } =20 diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 6cebff47a7..4b04b295a7 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -65,10 +65,11 @@ typedef struct XICSFabric XICSFabric; struct ICPStateClass { DeviceClass parent_class; =20 - void (*realize)(ICPState *icp, Error **errp); + DeviceRealize parent_realize; + DeviceReset parent_reset; + void (*pre_save)(ICPState *icp); int (*post_load)(ICPState *icp, int version_id); - void (*reset)(ICPState *icp); void (*synchronize_state)(ICPState *icp); }; =20 --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598184468716.9760648072289; Mon, 2 Jul 2018 23:09:44 -0700 (PDT) Received: from localhost ([::1]:37989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEVT-00033f-Hp for importer@patchew.org; Tue, 03 Jul 2018 02:09:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKP-0002lX-So for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKO-0006sy-3x for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:17 -0400 Received: from ozlabs.org ([203.11.71.1]:53929) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKN-0006ie-F1; Tue, 03 Jul 2018 01:58:16 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM55j23z9s47; Tue, 3 Jul 2018 15:58:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597489; bh=BGRo2Zq1oxU7IIBKCeAnCP2UaipZODTx41HKR8QmLtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TEOcTPQhFBTNtkGMk4aItn4VtCbEQHMVJQm8xXhg4Yc9hGVsh/2E28096dQdLZwJG Mli2KlpH2Sa3iYchwibdlCVtsJSiHqm7wv3uwq8wDsxv6olI5M6sLr3Myw7ZVnUGcG gwENHwAjmjwrlL1qEYVqMCx5FtoZP7rXYW5VGYOA= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:34 +1000 Message-Id: <20180703055804.13449-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 05/35] ppc/xics: introduce a parent_realize in ICSStateClass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater This makes possible to move the common ICSState code of the realize handlers in the ics-base class. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 37 ++++++++++++++++++++++--------------- hw/intc/xics_kvm.c | 20 +++++++++++++++----- include/hw/ppc/xics.h | 3 ++- 3 files changed, 39 insertions(+), 21 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 063491f387..d6066d561f 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -618,30 +618,31 @@ static void ics_simple_initfn(Object *obj) ics->offset =3D XICS_IRQ_BASE; } =20 -static void ics_simple_realize(ICSState *ics, Error **errp) +static void ics_simple_realize(DeviceState *dev, Error **errp) { - if (!ics->nr_irqs) { - error_setg(errp, "Number of interrupts needs to be greater 0"); + ICSState *ics =3D ICS_SIMPLE(dev); + ICSStateClass *icsc =3D ICS_BASE_GET_CLASS(ics); + Error *local_err =3D NULL; + + icsc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); return; } - ics->irqs =3D g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); + ics->qirqs =3D qemu_allocate_irqs(ics_simple_set_irq, ics, ics->nr_irq= s); =20 qemu_register_reset(ics_simple_reset, ics); } =20 -static Property ics_simple_properties[] =3D { - DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0), - DEFINE_PROP_END_OF_LIST(), -}; - static void ics_simple_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); ICSStateClass *isc =3D ICS_BASE_CLASS(klass); =20 - isc->realize =3D ics_simple_realize; - dc->props =3D ics_simple_properties; + device_class_set_parent_realize(dc, ics_simple_realize, + &isc->parent_realize); + dc->vmsd =3D &vmstate_ics_simple; isc->reject =3D ics_simple_reject; isc->resend =3D ics_simple_resend; @@ -659,7 +660,6 @@ static const TypeInfo ics_simple_info =3D { =20 static void ics_base_realize(DeviceState *dev, Error **errp) { - ICSStateClass *icsc =3D ICS_BASE_GET_CLASS(dev); ICSState *ics =3D ICS_BASE(dev); Object *obj; Error *err =3D NULL; @@ -672,17 +672,24 @@ static void ics_base_realize(DeviceState *dev, Error = **errp) } ics->xics =3D XICS_FABRIC(obj); =20 - - if (icsc->realize) { - icsc->realize(ics, errp); + if (!ics->nr_irqs) { + error_setg(errp, "Number of interrupts needs to be greater 0"); + return; } + ics->irqs =3D g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); } =20 +static Property ics_base_properties[] =3D { + DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0), + DEFINE_PROP_END_OF_LIST(), +}; + static void ics_base_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->realize =3D ics_base_realize; + dc->props =3D ics_base_properties; } =20 static const TypeInfo ics_base_info =3D { diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index f511e50a80..1f27eb4979 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -345,13 +345,17 @@ static void ics_kvm_reset(void *dev) ics_set_kvm_state(ics, 1); } =20 -static void ics_kvm_realize(ICSState *ics, Error **errp) +static void ics_kvm_realize(DeviceState *dev, Error **errp) { - if (!ics->nr_irqs) { - error_setg(errp, "Number of interrupts needs to be greater 0"); + ICSState *ics =3D ICS_KVM(dev); + ICSStateClass *icsc =3D ICS_BASE_GET_CLASS(ics); + Error *local_err =3D NULL; + + icsc->parent_realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); return; } - ics->irqs =3D g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); ics->qirqs =3D qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs); =20 qemu_register_reset(ics_kvm_reset, ics); @@ -360,8 +364,14 @@ static void ics_kvm_realize(ICSState *ics, Error **err= p) static void ics_kvm_class_init(ObjectClass *klass, void *data) { ICSStateClass *icsc =3D ICS_BASE_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + + /* + * Use device_class_set_parent_realize() when ics-kvm inherits + * directly from ics-base and not from ics-simple anymore. + */ + dc->realize =3D ics_kvm_realize; =20 - icsc->realize =3D ics_kvm_realize; icsc->pre_save =3D ics_get_kvm_state; icsc->post_load =3D ics_set_kvm_state; icsc->synchronize_state =3D ics_synchronize_state; diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 4b04b295a7..44e96e6400 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -115,7 +115,8 @@ struct PnvICPState { struct ICSStateClass { DeviceClass parent_class; =20 - void (*realize)(ICSState *s, Error **errp); + DeviceRealize parent_realize; + void (*pre_save)(ICSState *s); int (*post_load)(ICSState *s, int version_id); void (*reject)(ICSState *s, uint32_t irq); --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598018446337.38549779060224; Mon, 2 Jul 2018 23:06:58 -0700 (PDT) Received: from localhost ([::1]:37975 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faESe-0000o5-PW for importer@patchew.org; Tue, 03 Jul 2018 02:06:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39584) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKP-0002lf-V6 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKM-0006oZ-AA for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:18 -0400 Received: from ozlabs.org ([203.11.71.1]:57047) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKL-0006ao-Ue; Tue, 03 Jul 2018 01:58:14 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM53QkJz9s3R; Tue, 3 Jul 2018 15:58:08 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597489; bh=DOqBhdC+m10afR6VSYTFtjep80y945oJj0ot5jPnkhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eo9RUAztVD51LmEwzmp+sSEEKKnEc6duxKnWE3XVSY3c/4M821CGSA4S44V4OrePp jUP03JZKGU9Xr93zAeDPZq/Wi3Z7Ml6OYubvyu156IpOSOGS+YjQxcHMTzgzD5D4hx LAMLcVRKuSq6KSzFjoJCKzv6e+BMdvE2kLjyBvi8= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:35 +1000 Message-Id: <20180703055804.13449-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 06/35] ppc/xics: move the instance_init handler under the ics-base class X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index d6066d561f..83340770f7 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -611,13 +611,6 @@ static const VMStateDescription vmstate_ics_simple =3D= { }, }; =20 -static void ics_simple_initfn(Object *obj) -{ - ICSState *ics =3D ICS_SIMPLE(obj); - - ics->offset =3D XICS_IRQ_BASE; -} - static void ics_simple_realize(DeviceState *dev, Error **errp) { ICSState *ics =3D ICS_SIMPLE(dev); @@ -655,7 +648,6 @@ static const TypeInfo ics_simple_info =3D { .instance_size =3D sizeof(ICSState), .class_init =3D ics_simple_class_init, .class_size =3D sizeof(ICSStateClass), - .instance_init =3D ics_simple_initfn, }; =20 static void ics_base_realize(DeviceState *dev, Error **errp) @@ -679,6 +671,13 @@ static void ics_base_realize(DeviceState *dev, Error *= *errp) ics->irqs =3D g_malloc0(ics->nr_irqs * sizeof(ICSIRQState)); } =20 +static void ics_base_instance_init(Object *obj) +{ + ICSState *ics =3D ICS_BASE(obj); + + ics->offset =3D XICS_IRQ_BASE; +} + static Property ics_base_properties[] =3D { DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0), DEFINE_PROP_END_OF_LIST(), @@ -697,6 +696,7 @@ static const TypeInfo ics_base_info =3D { .parent =3D TYPE_DEVICE, .abstract =3D true, .instance_size =3D sizeof(ICSState), + .instance_init =3D ics_base_instance_init, .class_init =3D ics_base_class_init, .class_size =3D sizeof(ICSStateClass), }; --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598510453270.8132418639709; Mon, 2 Jul 2018 23:15:10 -0700 (PDT) Received: from localhost ([::1]:38022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEaj-00082w-Iq for importer@patchew.org; Tue, 03 Jul 2018 02:15:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKQ-0002mP-Go for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKO-0006tk-Tj for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:18 -0400 Received: from ozlabs.org ([203.11.71.1]:58165) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKO-0006nw-9e; Tue, 03 Jul 2018 01:58:16 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM71Tmqz9s4b; Tue, 3 Jul 2018 15:58:09 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597491; bh=BFS+CaF6e/fPU1/AdTgciCz0H8UI/GWeYHQ8r8Hc9n8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JAHcwkHh53XUo9uYp6dQ37guyRQ2uzkL8nOJseMq4JTz/LNTcdKkuw1PDoX8JUi+4 FGLwEwezeL+AMgpzYkWWRKJo+zQTa0W3rcEuPOfNpFLeB4JPxCD/al82hYhCSoed7j V7jeVfhUiqexWSD4Y2F3/c1vNI7tG15JL6ENbloU= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:36 +1000 Message-Id: <20180703055804.13449-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 07/35] ppx/xics: introduce a parent_reset in ICSStateClass X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater Just like for the realize handlers, this makes possible to move the common ICSState code of the reset handlers in the ics-base class. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 45 ++++++++++++++++++++++++++++--------------- hw/intc/xics_kvm.c | 26 ++++++++++--------------- include/hw/ppc/xics.h | 1 + 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 83340770f7..8cfe223153 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -537,23 +537,16 @@ static void ics_simple_eoi(ICSState *ics, uint32_t nr) } } =20 -static void ics_simple_reset(void *dev) +static void ics_simple_reset(DeviceState *dev) { - ICSState *ics =3D ICS_SIMPLE(dev); - int i; - uint8_t flags[ics->nr_irqs]; + ICSStateClass *icsc =3D ICS_BASE_GET_CLASS(dev); =20 - for (i =3D 0; i < ics->nr_irqs; i++) { - flags[i] =3D ics->irqs[i].flags; - } - - memset(ics->irqs, 0, sizeof(ICSIRQState) * ics->nr_irqs); + icsc->parent_reset(dev); +} =20 - for (i =3D 0; i < ics->nr_irqs; i++) { - ics->irqs[i].priority =3D 0xff; - ics->irqs[i].saved_priority =3D 0xff; - ics->irqs[i].flags =3D flags[i]; - } +static void ics_simple_reset_handler(void *dev) +{ + ics_simple_reset(dev); } =20 static int ics_simple_dispatch_pre_save(void *opaque) @@ -625,7 +618,7 @@ static void ics_simple_realize(DeviceState *dev, Error = **errp) =20 ics->qirqs =3D qemu_allocate_irqs(ics_simple_set_irq, ics, ics->nr_irq= s); =20 - qemu_register_reset(ics_simple_reset, ics); + qemu_register_reset(ics_simple_reset_handler, ics); } =20 static void ics_simple_class_init(ObjectClass *klass, void *data) @@ -635,6 +628,8 @@ static void ics_simple_class_init(ObjectClass *klass, v= oid *data) =20 device_class_set_parent_realize(dc, ics_simple_realize, &isc->parent_realize); + device_class_set_parent_reset(dc, ics_simple_reset, + &isc->parent_reset); =20 dc->vmsd =3D &vmstate_ics_simple; isc->reject =3D ics_simple_reject; @@ -650,6 +645,25 @@ static const TypeInfo ics_simple_info =3D { .class_size =3D sizeof(ICSStateClass), }; =20 +static void ics_base_reset(DeviceState *dev) +{ + ICSState *ics =3D ICS_BASE(dev); + int i; + uint8_t flags[ics->nr_irqs]; + + for (i =3D 0; i < ics->nr_irqs; i++) { + flags[i] =3D ics->irqs[i].flags; + } + + memset(ics->irqs, 0, sizeof(ICSIRQState) * ics->nr_irqs); + + for (i =3D 0; i < ics->nr_irqs; i++) { + ics->irqs[i].priority =3D 0xff; + ics->irqs[i].saved_priority =3D 0xff; + ics->irqs[i].flags =3D flags[i]; + } +} + static void ics_base_realize(DeviceState *dev, Error **errp) { ICSState *ics =3D ICS_BASE(dev); @@ -689,6 +703,7 @@ static void ics_base_class_init(ObjectClass *klass, voi= d *data) =20 dc->realize =3D ics_base_realize; dc->props =3D ics_base_properties; + dc->reset =3D ics_base_reset; } =20 static const TypeInfo ics_base_info =3D { diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 1f27eb4979..b314eb7d16 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -324,25 +324,18 @@ static void ics_kvm_set_irq(void *opaque, int srcno, = int val) } } =20 -static void ics_kvm_reset(void *dev) +static void ics_kvm_reset(DeviceState *dev) { - ICSState *ics =3D ICS_SIMPLE(dev); - int i; - uint8_t flags[ics->nr_irqs]; - - for (i =3D 0; i < ics->nr_irqs; i++) { - flags[i] =3D ics->irqs[i].flags; - } + ICSStateClass *icsc =3D ICS_BASE_GET_CLASS(dev); =20 - memset(ics->irqs, 0, sizeof(ICSIRQState) * ics->nr_irqs); + icsc->parent_reset(dev); =20 - for (i =3D 0; i < ics->nr_irqs; i++) { - ics->irqs[i].priority =3D 0xff; - ics->irqs[i].saved_priority =3D 0xff; - ics->irqs[i].flags =3D flags[i]; - } + ics_set_kvm_state(ICS_KVM(dev), 1); +} =20 - ics_set_kvm_state(ics, 1); +static void ics_kvm_reset_handler(void *dev) +{ + ics_kvm_reset(dev); } =20 static void ics_kvm_realize(DeviceState *dev, Error **errp) @@ -358,7 +351,7 @@ static void ics_kvm_realize(DeviceState *dev, Error **e= rrp) } ics->qirqs =3D qemu_allocate_irqs(ics_kvm_set_irq, ics, ics->nr_irqs); =20 - qemu_register_reset(ics_kvm_reset, ics); + qemu_register_reset(ics_kvm_reset_handler, ics); } =20 static void ics_kvm_class_init(ObjectClass *klass, void *data) @@ -371,6 +364,7 @@ static void ics_kvm_class_init(ObjectClass *klass, void= *data) * directly from ics-base and not from ics-simple anymore. */ dc->realize =3D ics_kvm_realize; + dc->reset =3D ics_kvm_reset; =20 icsc->pre_save =3D ics_get_kvm_state; icsc->post_load =3D ics_set_kvm_state; diff --git a/include/hw/ppc/xics.h b/include/hw/ppc/xics.h index 44e96e6400..6ac8a9392d 100644 --- a/include/hw/ppc/xics.h +++ b/include/hw/ppc/xics.h @@ -116,6 +116,7 @@ struct ICSStateClass { DeviceClass parent_class; =20 DeviceRealize parent_realize; + DeviceReset parent_reset; =20 void (*pre_save)(ICSState *s); int (*post_load)(ICSState *s, int version_id); --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598358673157.58366010160375; Mon, 2 Jul 2018 23:12:38 -0700 (PDT) Received: from localhost ([::1]:38006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEY8-0005PG-0L for importer@patchew.org; Tue, 03 Jul 2018 02:12:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKP-0002lc-Tl for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKO-0006sm-0U for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:17 -0400 Received: from ozlabs.org ([203.11.71.1]:44967) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKN-0006ii-Bx; Tue, 03 Jul 2018 01:58:15 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM62lZNz9s3q; Tue, 3 Jul 2018 15:58:09 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597490; bh=sxWlmrMLca6oYJsZjl8wE7a8HF9UUO/OPjaEHXgh4qE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f88nlfbPbWEnF/x5bc61d90zccbIyw3QKR4lBEU33Yr5poEA4dvtl7KsvaY9eGXEy iVfaO04xVQNjFrKnj/GMCuVPn0EYWurqwEjelFO4HGO0ggx8g3Ml7CG4581q+mmocg vsnuzxluXtIkrzbvVdDojPiD7UfEhW8WxaScoGXU= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:37 +1000 Message-Id: <20180703055804.13449-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 08/35] ppc/xics: move the vmstate structures under the ics-base class X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics.c | 112 ++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/hw/intc/xics.c b/hw/intc/xics.c index 8cfe223153..b9f1a3c972 100644 --- a/hw/intc/xics.c +++ b/hw/intc/xics.c @@ -549,61 +549,6 @@ static void ics_simple_reset_handler(void *dev) ics_simple_reset(dev); } =20 -static int ics_simple_dispatch_pre_save(void *opaque) -{ - ICSState *ics =3D opaque; - ICSStateClass *info =3D ICS_BASE_GET_CLASS(ics); - - if (info->pre_save) { - info->pre_save(ics); - } - - return 0; -} - -static int ics_simple_dispatch_post_load(void *opaque, int version_id) -{ - ICSState *ics =3D opaque; - ICSStateClass *info =3D ICS_BASE_GET_CLASS(ics); - - if (info->post_load) { - return info->post_load(ics, version_id); - } - - return 0; -} - -static const VMStateDescription vmstate_ics_simple_irq =3D { - .name =3D "ics/irq", - .version_id =3D 2, - .minimum_version_id =3D 1, - .fields =3D (VMStateField[]) { - VMSTATE_UINT32(server, ICSIRQState), - VMSTATE_UINT8(priority, ICSIRQState), - VMSTATE_UINT8(saved_priority, ICSIRQState), - VMSTATE_UINT8(status, ICSIRQState), - VMSTATE_UINT8(flags, ICSIRQState), - VMSTATE_END_OF_LIST() - }, -}; - -static const VMStateDescription vmstate_ics_simple =3D { - .name =3D "ics", - .version_id =3D 1, - .minimum_version_id =3D 1, - .pre_save =3D ics_simple_dispatch_pre_save, - .post_load =3D ics_simple_dispatch_post_load, - .fields =3D (VMStateField[]) { - /* Sanity check */ - VMSTATE_UINT32_EQUAL(nr_irqs, ICSState, NULL), - - VMSTATE_STRUCT_VARRAY_POINTER_UINT32(irqs, ICSState, nr_irqs, - vmstate_ics_simple_irq, - ICSIRQState), - VMSTATE_END_OF_LIST() - }, -}; - static void ics_simple_realize(DeviceState *dev, Error **errp) { ICSState *ics =3D ICS_SIMPLE(dev); @@ -631,7 +576,6 @@ static void ics_simple_class_init(ObjectClass *klass, v= oid *data) device_class_set_parent_reset(dc, ics_simple_reset, &isc->parent_reset); =20 - dc->vmsd =3D &vmstate_ics_simple; isc->reject =3D ics_simple_reject; isc->resend =3D ics_simple_resend; isc->eoi =3D ics_simple_eoi; @@ -692,6 +636,61 @@ static void ics_base_instance_init(Object *obj) ics->offset =3D XICS_IRQ_BASE; } =20 +static int ics_base_dispatch_pre_save(void *opaque) +{ + ICSState *ics =3D opaque; + ICSStateClass *info =3D ICS_BASE_GET_CLASS(ics); + + if (info->pre_save) { + info->pre_save(ics); + } + + return 0; +} + +static int ics_base_dispatch_post_load(void *opaque, int version_id) +{ + ICSState *ics =3D opaque; + ICSStateClass *info =3D ICS_BASE_GET_CLASS(ics); + + if (info->post_load) { + return info->post_load(ics, version_id); + } + + return 0; +} + +static const VMStateDescription vmstate_ics_base_irq =3D { + .name =3D "ics/irq", + .version_id =3D 2, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(server, ICSIRQState), + VMSTATE_UINT8(priority, ICSIRQState), + VMSTATE_UINT8(saved_priority, ICSIRQState), + VMSTATE_UINT8(status, ICSIRQState), + VMSTATE_UINT8(flags, ICSIRQState), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_ics_base =3D { + .name =3D "ics", + .version_id =3D 1, + .minimum_version_id =3D 1, + .pre_save =3D ics_base_dispatch_pre_save, + .post_load =3D ics_base_dispatch_post_load, + .fields =3D (VMStateField[]) { + /* Sanity check */ + VMSTATE_UINT32_EQUAL(nr_irqs, ICSState, NULL), + + VMSTATE_STRUCT_VARRAY_POINTER_UINT32(irqs, ICSState, nr_irqs, + vmstate_ics_base_irq, + ICSIRQState), + VMSTATE_END_OF_LIST() + }, +}; + static Property ics_base_properties[] =3D { DEFINE_PROP_UINT32("nr-irqs", ICSState, nr_irqs, 0), DEFINE_PROP_END_OF_LIST(), @@ -704,6 +703,7 @@ static void ics_base_class_init(ObjectClass *klass, voi= d *data) dc->realize =3D ics_base_realize; dc->props =3D ics_base_properties; dc->reset =3D ics_base_reset; + dc->vmsd =3D &vmstate_ics_base; } =20 static const TypeInfo ics_base_info =3D { --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530597829701368.5446175761891; Mon, 2 Jul 2018 23:03:49 -0700 (PDT) Received: from localhost ([::1]:37955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEPl-0006kv-1r for importer@patchew.org; Tue, 03 Jul 2018 02:03:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKP-0002ld-Tv for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKO-0006tL-FE for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:17 -0400 Received: from ozlabs.org ([203.11.71.1]:40695) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKO-0006n2-3U; Tue, 03 Jul 2018 01:58:16 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM65wkYz9s4Z; Tue, 3 Jul 2018 15:58:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597490; bh=i6D/IYJQIEZ41jVnAbw/TRdTC+Q1gHkg0B9CsZK6EWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJsNaaYCy1A4JY+oRyem0bIVYJKWsHvJK06bSfkqiEo4ot8HxkLa1vHAeLz0voxih vBVkB36b2YQSDBGvOcOHN/odyJSv9JaeFGFoT/IJKF5+7Tg+r+Kira3o+zVCdDKT9x Zcr+wEFjjEacJ3wu83snuOc+MSIpLFDQP3Dwo3zk= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:38 +1000 Message-Id: <20180703055804.13449-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 09/35] ppc/xics: rework the ICS classes inheritance tree X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater With the previous changes, we can now let the ICS_KVM class inherit directly from ICS_BASE class and not from the intermediate ICS_SIMPLE. It makes the class hierarchy much cleaner. What is left in the top classes is the low level interface to access the KVM XICS device in ICS_KVM and the XICS emulating handlers in ICS_SIMPLE. This should not break migration compatibility. Signed-off-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics_kvm.c | 12 +++++------- hw/ppc/spapr.c | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index b314eb7d16..30c3769a20 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -359,12 +359,10 @@ static void ics_kvm_class_init(ObjectClass *klass, vo= id *data) ICSStateClass *icsc =3D ICS_BASE_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); =20 - /* - * Use device_class_set_parent_realize() when ics-kvm inherits - * directly from ics-base and not from ics-simple anymore. - */ - dc->realize =3D ics_kvm_realize; - dc->reset =3D ics_kvm_reset; + device_class_set_parent_realize(dc, ics_kvm_realize, + &icsc->parent_realize); + device_class_set_parent_reset(dc, ics_kvm_reset, + &icsc->parent_reset); =20 icsc->pre_save =3D ics_get_kvm_state; icsc->post_load =3D ics_set_kvm_state; @@ -373,7 +371,7 @@ static void ics_kvm_class_init(ObjectClass *klass, void= *data) =20 static const TypeInfo ics_kvm_info =3D { .name =3D TYPE_ICS_KVM, - .parent =3D TYPE_ICS_SIMPLE, + .parent =3D TYPE_ICS_BASE, .instance_size =3D sizeof(ICSState), .class_init =3D ics_kvm_class_init, }; diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b32b971a14..b2baec026f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -137,7 +137,7 @@ static ICSState *spapr_ics_create(sPAPRMachineState *sp= apr, goto error; } =20 - return ICS_SIMPLE(obj); + return ICS_BASE(obj); =20 error: error_propagate(errp, local_err); --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153059763272798.5025602472931; Mon, 2 Jul 2018 23:00:32 -0700 (PDT) Received: from localhost ([::1]:37933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEMT-0004Iv-3q for importer@patchew.org; Tue, 03 Jul 2018 02:00:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKP-0002le-U0 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKO-0006tS-IZ for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:17 -0400 Received: from ozlabs.org ([203.11.71.1]:46349) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKO-0006o3-6R; Tue, 03 Jul 2018 01:58:16 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM72dvhz9s4V; Tue, 3 Jul 2018 15:58:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597491; bh=ivJ6wD9+TJGcw96XjfUFgo91G6jq6KGDjeMQuw2yN+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pJ1T6wWIGZrRUCKrYOSrzw/4yxmLI/y7uP7aPeMbwktSZqN7WLR4OO2Eip9Zyg6fO wdtvRWO6797AATYMq47fC9zNtosD1h43SJdasUv8WW7t9Km0gsSRNi6zy1/xWfsENb m199jNoxJU4eyjjRsvmqam56SIdZJpAz72ZywJuo= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:39 +1000 Message-Id: <20180703055804.13449-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 10/35] ppc/pnv: fix pnv_core_realize() error handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: C=C3=A9dric Le Goater commit d35aefa9ae15 ("ppc/pnv: introduce a new intc_create() operation to the chip model") changed the object link in the pnv_core_realize() routine but a return was forgotten in case of error, which can lead to more problems afterwards (segv) Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Gibson --- hw/ppc/pnv_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index a9f129fc2c..9750464bf4 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -150,6 +150,7 @@ static void pnv_core_realize(DeviceState *dev, Error **= errp) if (!chip) { error_propagate(errp, local_err); error_prepend(errp, "required link 'chip' not found: "); + return; } =20 pc->threads =3D g_new(PowerPCCPU *, cc->nr_threads); --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598181257309.9626423176659; Mon, 2 Jul 2018 23:09:41 -0700 (PDT) Received: from localhost ([::1]:37988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEVQ-00033T-CG for importer@patchew.org; Tue, 03 Jul 2018 02:09:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKQ-0002mO-Fr for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKP-0006uJ-E2 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:18 -0400 Received: from ozlabs.org ([203.11.71.1]:33461) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKP-0006qT-1i; Tue, 03 Jul 2018 01:58:17 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM76lx8z9s8k; Tue, 3 Jul 2018 15:58:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597491; bh=uKJtkisTiKinECKXdYDXNin0kYLXxvzpO5mjwqT/BP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f8Iran+GJlRMkaXAmXEUvlBLe9S5dIbC6JD7wUoWqHy1zlw6G5Jy2ghFatq8yxSB9 PwrzKHNvS6RROIf59/Q5w6LR6RbHbAxbS+qxEFBLVpsxCLsam4RrEHjZ2xIow081VG Q6X6Z+7RQXh9jAnq9pxhlaMlANZmKPVscrCyTh1U= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:40 +1000 Message-Id: <20180703055804.13449-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 11/35] target/ppc: Add do_unaligned_access hook X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This allows faults from MO_ALIGN to have the same effect as from gen_check_align. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/excp_helper.c | 18 +++++++++++++++++- target/ppc/internal.h | 5 +++++ target/ppc/translate_init.inc.c | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index c092fbead0..d6e97a90e0 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -22,7 +22,7 @@ #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/cpu_ldst.h" - +#include "internal.h" #include "helper_regs.h" =20 //#define DEBUG_OP @@ -1198,3 +1198,19 @@ void helper_book3s_msgsnd(target_ulong rb) qemu_mutex_unlock_iothread(); } #endif + +void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr) +{ + CPUPPCState *env =3D cs->env_ptr; + uint32_t insn; + + /* Restore state and reload the insn we executed, for filling in DSISR= . */ + cpu_restore_state(cs, retaddr, true); + insn =3D cpu_ldl_code(env, env->nip); + + cs->exception_index =3D POWERPC_EXCP_ALIGN; + env->error_code =3D insn & 0x03FF0000; + cpu_loop_exit(cs); +} diff --git a/target/ppc/internal.h b/target/ppc/internal.h index 1f441c6483..a9bcadff42 100644 --- a/target/ppc/internal.h +++ b/target/ppc/internal.h @@ -252,4 +252,9 @@ static inline void putVSR(int n, ppc_vsr_t *vsr, CPUPPC= State *env) void helper_compute_fprf_float16(CPUPPCState *env, float16 arg); void helper_compute_fprf_float32(CPUPPCState *env, float32 arg); void helper_compute_fprf_float128(CPUPPCState *env, float128 arg); + +/* Raise a data fault alignment exception for the specified virtual addres= s */ +void ppc_cpu_do_unaligned_access(CPUState *cs, vaddr addr, + MMUAccessType access_type, + int mmu_idx, uintptr_t retaddr); #endif /* PPC_INTERNAL_H */ diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 76d6f3fd5e..7813b1b004 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10457,6 +10457,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) cc->set_pc =3D ppc_cpu_set_pc; cc->gdb_read_register =3D ppc_cpu_gdb_read_register; cc->gdb_write_register =3D ppc_cpu_gdb_write_register; + cc->do_unaligned_access =3D ppc_cpu_do_unaligned_access; #ifdef CONFIG_USER_ONLY cc->handle_mmu_fault =3D ppc_cpu_handle_mmu_fault; #else --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530597863119676.1222985902677; Mon, 2 Jul 2018 23:04:23 -0700 (PDT) Received: from localhost ([::1]:37957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEQI-000799-A8 for importer@patchew.org; Tue, 03 Jul 2018 02:04:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKU-0002r3-Ru for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKR-0006wh-Lt for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:22 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:38415) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKQ-0006td-T6; Tue, 03 Jul 2018 01:58:19 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM83gLbz9s8f; Tue, 3 Jul 2018 15:58:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597492; bh=pBgLmf8ySdtTV2Y4yNdwR4wXy7YFYYyGwDZs/oPOOdU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKC7DNEHEBkO6EWIYyCgWCGNbAaJMytAZHSolGwdUQLPABba4D7UJRVQ4ABqwiQXU Yv+BtBRcDxFEtmHYq4SKub1cLV2p5alpxVGoSkurcVgl0MEQzvCbvg2IjeiHg7/MHW u8xJOQ1NjoQu/ecS0sfVdzTEtwu42qw+3j/cexWU= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:41 +1000 Message-Id: <20180703055804.13449-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 12/35] target/ppc: Use atomic load for LQ and LQARX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Section 1.4 of the Power ISA v3.0B states that both of these instructions are single-copy atomic. As we cannot (yet) issue 128-bit loads within TCG, use the generic helpers provided. Since TCG cannot (yet) return a 128-bit value, add a slot within CPUPPCState for returning the high half of a 128-bit return value. This solution is preferred to the helper assigning to architectural registers directly, as it avoids clobbering all TCG live values. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/cpu.h | 3 ++ target/ppc/helper.h | 5 +++ target/ppc/mem_helper.c | 20 ++++++++- target/ppc/translate.c | 91 ++++++++++++++++++++++++++++++----------- 4 files changed, 94 insertions(+), 25 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index c7f3fb6b73..973cf44cda 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1015,6 +1015,9 @@ struct CPUPPCState { /* Next instruction pointer */ target_ulong nip; =20 + /* High part of 128-bit helper return. */ + uint64_t retxh; + int access_type; /* when a memory exception occurs, the access type is stored here */ =20 diff --git a/target/ppc/helper.h b/target/ppc/helper.h index d751f0e219..3f451a5d7e 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -799,3 +799,8 @@ DEF_HELPER_4(dscliq, void, env, fprp, fprp, i32) =20 DEF_HELPER_1(tbegin, void, env) DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, env) + +#if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) +DEF_HELPER_FLAGS_3(lq_le_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) +DEF_HELPER_FLAGS_3(lq_be_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) +#endif diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index a34e604db3..44a8f3445a 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -21,9 +21,9 @@ #include "exec/exec-all.h" #include "qemu/host-utils.h" #include "exec/helper-proto.h" - #include "helper_regs.h" #include "exec/cpu_ldst.h" +#include "tcg.h" #include "internal.h" =20 //#define DEBUG_OP @@ -215,6 +215,24 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulo= ng addr, uint32_t reg, return i; } =20 +#if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) +uint64_t helper_lq_le_parallel(CPUPPCState *env, target_ulong addr, + uint32_t opidx) +{ + Int128 ret =3D helper_atomic_ldo_le_mmu(env, addr, opidx, GETPC()); + env->retxh =3D int128_gethi(ret); + return int128_getlo(ret); +} + +uint64_t helper_lq_be_parallel(CPUPPCState *env, target_ulong addr, + uint32_t opidx) +{ + Int128 ret =3D helper_atomic_ldo_be_mmu(env, addr, opidx, GETPC()); + env->retxh =3D int128_gethi(ret); + return int128_getlo(ret); +} +#endif + /*************************************************************************= ****/ /* Altivec extension helpers */ #if defined(HOST_WORDS_BIGENDIAN) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 3a215a1dc6..0923cc24e3 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -2607,7 +2607,7 @@ static void gen_ld(DisasContext *ctx) static void gen_lq(DisasContext *ctx) { int ra, rd; - TCGv EA; + TCGv EA, hi, lo; =20 /* lq is a legal user mode instruction starting in ISA 2.07 */ bool legal_in_user_mode =3D (ctx->insns_flags2 & PPC2_LSQ_ISA207) !=3D= 0; @@ -2633,16 +2633,35 @@ static void gen_lq(DisasContext *ctx) EA =3D tcg_temp_new(); gen_addr_imm_index(ctx, EA, 0x0F); =20 - /* We only need to swap high and low halves. gen_qemu_ld64_i64 does - necessary 64-bit byteswap already. */ - if (unlikely(ctx->le_mode)) { - gen_qemu_ld64_i64(ctx, cpu_gpr[rd + 1], EA); + /* Note that the low part is always in RD+1, even in LE mode. */ + lo =3D cpu_gpr[rd + 1]; + hi =3D cpu_gpr[rd]; + + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { +#ifdef CONFIG_ATOMIC128 + TCGv_i32 oi =3D tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); + gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); + gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + } + tcg_temp_free_i32(oi); + tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); +#else + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp =3D DISAS_NORETURN; +#endif + } else if (ctx->le_mode) { + tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ); gen_addr_add(ctx, EA, EA, 8); - gen_qemu_ld64_i64(ctx, cpu_gpr[rd], EA); + tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_LEQ); } else { - gen_qemu_ld64_i64(ctx, cpu_gpr[rd], EA); + tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_BEQ); gen_addr_add(ctx, EA, EA, 8); - gen_qemu_ld64_i64(ctx, cpu_gpr[rd + 1], EA); + tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_BEQ); } tcg_temp_free(EA); } @@ -3236,9 +3255,8 @@ STCX(stdcx_, DEF_MEMOP(MO_Q)) /* lqarx */ static void gen_lqarx(DisasContext *ctx) { - TCGv EA; int rd =3D rD(ctx->opcode); - TCGv gpr1, gpr2; + TCGv EA, hi, lo; =20 if (unlikely((rd & 1) || (rd =3D=3D rA(ctx->opcode)) || (rd =3D=3D rB(ctx->opcode)))) { @@ -3247,24 +3265,49 @@ static void gen_lqarx(DisasContext *ctx) } =20 gen_set_access_type(ctx, ACCESS_RES); - EA =3D tcg_temp_local_new(); + EA =3D tcg_temp_new(); gen_addr_reg_index(ctx, EA); - gen_check_align(ctx, EA, 15); - if (unlikely(ctx->le_mode)) { - gpr1 =3D cpu_gpr[rd+1]; - gpr2 =3D cpu_gpr[rd]; + + /* Note that the low part is always in RD+1, even in LE mode. */ + lo =3D cpu_gpr[rd + 1]; + hi =3D cpu_gpr[rd]; + + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { +#ifdef CONFIG_ATOMIC128 + TCGv_i32 oi =3D tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ | MO_ALIGN_16, + ctx->mem_idx)); + gen_helper_lq_le_parallel(lo, cpu_env, EA, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ | MO_ALIGN_16, + ctx->mem_idx)); + gen_helper_lq_be_parallel(lo, cpu_env, EA, oi); + } + tcg_temp_free_i32(oi); + tcg_gen_ld_i64(hi, cpu_env, offsetof(CPUPPCState, retxh)); +#else + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp =3D DISAS_NORETURN; + tcg_temp_free(EA); + return; +#endif + } else if (ctx->le_mode) { + tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_LEQ | MO_ALIGN_16); + tcg_gen_mov_tl(cpu_reserve, EA); + gen_addr_add(ctx, EA, EA, 8); + tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_LEQ); } else { - gpr1 =3D cpu_gpr[rd]; - gpr2 =3D cpu_gpr[rd+1]; + tcg_gen_qemu_ld_i64(hi, EA, ctx->mem_idx, MO_BEQ | MO_ALIGN_16); + tcg_gen_mov_tl(cpu_reserve, EA); + gen_addr_add(ctx, EA, EA, 8); + tcg_gen_qemu_ld_i64(lo, EA, ctx->mem_idx, MO_BEQ); } - tcg_gen_qemu_ld_i64(gpr1, EA, ctx->mem_idx, DEF_MEMOP(MO_Q)); - tcg_gen_mov_tl(cpu_reserve, EA); - gen_addr_add(ctx, EA, EA, 8); - tcg_gen_qemu_ld_i64(gpr2, EA, ctx->mem_idx, DEF_MEMOP(MO_Q)); - - tcg_gen_st_tl(gpr1, cpu_env, offsetof(CPUPPCState, reserve_val)); - tcg_gen_st_tl(gpr2, cpu_env, offsetof(CPUPPCState, reserve_val2)); tcg_temp_free(EA); + + tcg_gen_st_tl(hi, cpu_env, offsetof(CPUPPCState, reserve_val)); + tcg_gen_st_tl(lo, cpu_env, offsetof(CPUPPCState, reserve_val2)); } =20 /* stqcx. */ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598534914990.7398653555292; Mon, 2 Jul 2018 23:15:34 -0700 (PDT) Received: from localhost ([::1]:38024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEb8-0008PG-3i for importer@patchew.org; Tue, 03 Jul 2018 02:15:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKT-0002pU-Mb for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKR-0006wZ-L4 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:21 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:46609) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKQ-0006tQ-Pz; Tue, 03 Jul 2018 01:58:19 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM820J3z9s5c; Tue, 3 Jul 2018 15:58:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597492; bh=+op4qHd5DWt9QN8eRmYhE6PDypEs4nGq0DdaqcdC1sE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miNqF7eRHl5VoUaTsto9Sz4MTyboshlVvw1uO2yTyQZCCz9Y+s1ELJsotqCcwSJvy +kapJBwIcbeLZbEzPWVakQq3OQRrNcxajLB5WJ6VmFnaOEUvLEyYPV1+85WXxPAdIe LGF3c2YeGvDXpCN/jOd4FTHQBgOX/89jSCaI2oVI= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:42 +1000 Message-Id: <20180703055804.13449-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 13/35] target/ppc: Use atomic store for STQ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Section 1.4 of the Power ISA v3.0B states that this insn is single-copy atomic. As we cannot (yet) issue 128-bit stores within TCG, use the generic helpers provided. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/helper.h | 4 ++++ target/ppc/mem_helper.c | 14 ++++++++++++++ target/ppc/translate.c | 35 +++++++++++++++++++++++++++-------- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index 3f451a5d7e..cbc1228570 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -803,4 +803,8 @@ DEF_HELPER_FLAGS_1(fixup_thrm, TCG_CALL_NO_RWG, void, e= nv) #if defined(TARGET_PPC64) && defined(CONFIG_ATOMIC128) DEF_HELPER_FLAGS_3(lq_le_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) DEF_HELPER_FLAGS_3(lq_be_parallel, TCG_CALL_NO_WG, i64, env, tl, i32) +DEF_HELPER_FLAGS_5(stq_le_parallel, TCG_CALL_NO_WG, + void, env, tl, i64, i64, i32) +DEF_HELPER_FLAGS_5(stq_be_parallel, TCG_CALL_NO_WG, + void, env, tl, i64, i64, i32) #endif diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 44a8f3445a..57e301edc3 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -231,6 +231,20 @@ uint64_t helper_lq_be_parallel(CPUPPCState *env, targe= t_ulong addr, env->retxh =3D int128_gethi(ret); return int128_getlo(ret); } + +void helper_stq_le_parallel(CPUPPCState *env, target_ulong addr, + uint64_t lo, uint64_t hi, uint32_t opidx) +{ + Int128 val =3D int128_make128(lo, hi); + helper_atomic_sto_le_mmu(env, addr, val, opidx, GETPC()); +} + +void helper_stq_be_parallel(CPUPPCState *env, target_ulong addr, + uint64_t lo, uint64_t hi, uint32_t opidx) +{ + Int128 val =3D int128_make128(lo, hi); + helper_atomic_sto_be_mmu(env, addr, val, opidx, GETPC()); +} #endif =20 /*************************************************************************= ****/ diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 0923cc24e3..3d63a62269 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -2760,6 +2760,7 @@ static void gen_std(DisasContext *ctx) if ((ctx->opcode & 0x3) =3D=3D 0x2) { /* stq */ bool legal_in_user_mode =3D (ctx->insns_flags2 & PPC2_LSQ_ISA207) = !=3D 0; bool le_is_supported =3D (ctx->insns_flags2 & PPC2_LSQ_ISA207) != =3D 0; + TCGv hi, lo; =20 if (!(ctx->insns_flags & PPC_64BX)) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); @@ -2783,20 +2784,38 @@ static void gen_std(DisasContext *ctx) EA =3D tcg_temp_new(); gen_addr_imm_index(ctx, EA, 0x03); =20 - /* We only need to swap high and low halves. gen_qemu_st64_i64 does - necessary 64-bit byteswap already. */ - if (unlikely(ctx->le_mode)) { - gen_qemu_st64_i64(ctx, cpu_gpr[rs + 1], EA); + /* Note that the low part is always in RS+1, even in LE mode. */ + lo =3D cpu_gpr[rs + 1]; + hi =3D cpu_gpr[rs]; + + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { +#ifdef CONFIG_ATOMIC128 + TCGv_i32 oi =3D tcg_temp_new_i32(); + if (ctx->le_mode) { + tcg_gen_movi_i32(oi, make_memop_idx(MO_LEQ, ctx->mem_idx)); + gen_helper_stq_le_parallel(cpu_env, EA, lo, hi, oi); + } else { + tcg_gen_movi_i32(oi, make_memop_idx(MO_BEQ, ctx->mem_idx)); + gen_helper_stq_be_parallel(cpu_env, EA, lo, hi, oi); + } + tcg_temp_free_i32(oi); +#else + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp =3D DISAS_NORETURN; +#endif + } else if (ctx->le_mode) { + tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_LEQ); gen_addr_add(ctx, EA, EA, 8); - gen_qemu_st64_i64(ctx, cpu_gpr[rs], EA); + tcg_gen_qemu_st_i64(hi, EA, ctx->mem_idx, MO_LEQ); } else { - gen_qemu_st64_i64(ctx, cpu_gpr[rs], EA); + tcg_gen_qemu_st_i64(hi, EA, ctx->mem_idx, MO_BEQ); gen_addr_add(ctx, EA, EA, 8); - gen_qemu_st64_i64(ctx, cpu_gpr[rs + 1], EA); + tcg_gen_qemu_st_i64(lo, EA, ctx->mem_idx, MO_BEQ); } tcg_temp_free(EA); } else { - /* std / stdu*/ + /* std / stdu */ if (Rc(ctx->opcode)) { if (unlikely(rA(ctx->opcode) =3D=3D 0)) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598369532359.2350923669293; Mon, 2 Jul 2018 23:12:49 -0700 (PDT) Received: from localhost ([::1]:38009 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEYS-0005lw-F5 for importer@patchew.org; Tue, 03 Jul 2018 02:12:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKR-0002nS-Mt for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKP-0006uq-VA for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:19 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:47075) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKP-0006qC-8K; Tue, 03 Jul 2018 01:58:17 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM73zhZz9s5b; Tue, 3 Jul 2018 15:58:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597491; bh=kZx9LNmQBYgUEikG2hSfR4qFM7Z4BSVR8Ym0xAxE+yI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mc+eH5R/rCB1wthQB11CymSH3PFa90brvozKXiVRVmewau/CYoCL7+OCyOmhdFOdg Xh/+X+mouZPLdXaZc2TfQBol33gtiD2HYlXgdzeOcyI8zJxDUnstwEIj6kSxyDyjH4 B5/55mrbwRUKxHDGI/F3c8ztVzIPh2wVyPtEE3qc= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:43 +1000 Message-Id: <20180703055804.13449-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 14/35] target/ppc: Use atomic cmpxchg for STQCX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson When running in a parallel context, we must use a helper in order to perform the 128-bit atomic operation. When running in a serial context, do the compare before the store. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/helper.h | 2 + target/ppc/mem_helper.c | 38 +++++++++++++++++ target/ppc/translate.c | 93 ++++++++++++++++++++++++++--------------- 3 files changed, 100 insertions(+), 33 deletions(-) diff --git a/target/ppc/helper.h b/target/ppc/helper.h index cbc1228570..5706c2497f 100644 --- a/target/ppc/helper.h +++ b/target/ppc/helper.h @@ -807,4 +807,6 @@ DEF_HELPER_FLAGS_5(stq_le_parallel, TCG_CALL_NO_WG, void, env, tl, i64, i64, i32) DEF_HELPER_FLAGS_5(stq_be_parallel, TCG_CALL_NO_WG, void, env, tl, i64, i64, i32) +DEF_HELPER_5(stqcx_le_parallel, i32, env, tl, i64, i64, i32) +DEF_HELPER_5(stqcx_be_parallel, i32, env, tl, i64, i64, i32) #endif diff --git a/target/ppc/mem_helper.c b/target/ppc/mem_helper.c index 57e301edc3..8f0d86d104 100644 --- a/target/ppc/mem_helper.c +++ b/target/ppc/mem_helper.c @@ -245,6 +245,44 @@ void helper_stq_be_parallel(CPUPPCState *env, target_u= long addr, Int128 val =3D int128_make128(lo, hi); helper_atomic_sto_be_mmu(env, addr, val, opidx, GETPC()); } + +uint32_t helper_stqcx_le_parallel(CPUPPCState *env, target_ulong addr, + uint64_t new_lo, uint64_t new_hi, + uint32_t opidx) +{ + bool success =3D false; + + if (likely(addr =3D=3D env->reserve_addr)) { + Int128 oldv, cmpv, newv; + + cmpv =3D int128_make128(env->reserve_val2, env->reserve_val); + newv =3D int128_make128(new_lo, new_hi); + oldv =3D helper_atomic_cmpxchgo_le_mmu(env, addr, cmpv, newv, + opidx, GETPC()); + success =3D int128_eq(oldv, cmpv); + } + env->reserve_addr =3D -1; + return env->so + success * CRF_EQ_BIT; +} + +uint32_t helper_stqcx_be_parallel(CPUPPCState *env, target_ulong addr, + uint64_t new_lo, uint64_t new_hi, + uint32_t opidx) +{ + bool success =3D false; + + if (likely(addr =3D=3D env->reserve_addr)) { + Int128 oldv, cmpv, newv; + + cmpv =3D int128_make128(env->reserve_val2, env->reserve_val); + newv =3D int128_make128(new_lo, new_hi); + oldv =3D helper_atomic_cmpxchgo_be_mmu(env, addr, cmpv, newv, + opidx, GETPC()); + success =3D int128_eq(oldv, cmpv); + } + env->reserve_addr =3D -1; + return env->so + success * CRF_EQ_BIT; +} #endif =20 /*************************************************************************= ****/ diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 3d63a62269..c7b9d226eb 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3332,50 +3332,77 @@ static void gen_lqarx(DisasContext *ctx) /* stqcx. */ static void gen_stqcx_(DisasContext *ctx) { - TCGv EA; - int reg =3D rS(ctx->opcode); - int len =3D 16; -#if !defined(CONFIG_USER_ONLY) - TCGLabel *l1; - TCGv gpr1, gpr2; -#endif + int rs =3D rS(ctx->opcode); + TCGv EA, hi, lo; =20 - if (unlikely((rD(ctx->opcode) & 1))) { + if (unlikely(rs & 1)) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); return; } + gen_set_access_type(ctx, ACCESS_RES); - EA =3D tcg_temp_local_new(); + EA =3D tcg_temp_new(); gen_addr_reg_index(ctx, EA); - if (len > 1) { - gen_check_align(ctx, EA, (len) - 1); - } =20 -#if defined(CONFIG_USER_ONLY) - gen_conditional_store(ctx, EA, reg, 16); -#else - tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so); - l1 =3D gen_new_label(); - tcg_gen_brcond_tl(TCG_COND_NE, EA, cpu_reserve, l1); - tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], CRF_EQ); + /* Note that the low part is always in RS+1, even in LE mode. */ + lo =3D cpu_gpr[rs + 1]; + hi =3D cpu_gpr[rs]; =20 - if (unlikely(ctx->le_mode)) { - gpr1 =3D cpu_gpr[reg + 1]; - gpr2 =3D cpu_gpr[reg]; + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + TCGv_i32 oi =3D tcg_const_i32(DEF_MEMOP(MO_Q) | MO_ALIGN_16); +#ifdef CONFIG_ATOMIC128 + if (ctx->le_mode) { + gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, EA, lo, hi, = oi); + } else { + gen_helper_stqcx_le_parallel(cpu_crf[0], cpu_env, EA, lo, hi, = oi); + } +#else + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp =3D DISAS_NORETURN; +#endif + tcg_temp_free(EA); + tcg_temp_free_i32(oi); } else { - gpr1 =3D cpu_gpr[reg]; - gpr2 =3D cpu_gpr[reg + 1]; - } - tcg_gen_qemu_st_tl(gpr1, EA, ctx->mem_idx, DEF_MEMOP(MO_Q)); - gen_addr_add(ctx, EA, EA, 8); - tcg_gen_qemu_st_tl(gpr2, EA, ctx->mem_idx, DEF_MEMOP(MO_Q)); + TCGLabel *lab_fail =3D gen_new_label(); + TCGLabel *lab_over =3D gen_new_label(); + TCGv_i64 t0 =3D tcg_temp_new_i64(); + TCGv_i64 t1 =3D tcg_temp_new_i64(); =20 - gen_set_label(l1); - tcg_gen_movi_tl(cpu_reserve, -1); -#endif - tcg_temp_free(EA); -} + tcg_gen_brcond_tl(TCG_COND_NE, EA, cpu_reserve, lab_fail); + tcg_temp_free(EA); + + gen_qemu_ld64_i64(ctx, t0, cpu_reserve); + tcg_gen_ld_i64(t1, cpu_env, (ctx->le_mode + ? offsetof(CPUPPCState, reserve_val2) + : offsetof(CPUPPCState, reserve_val))= ); + tcg_gen_brcond_i64(TCG_COND_NE, t0, t1, lab_fail); + + tcg_gen_addi_i64(t0, cpu_reserve, 8); + gen_qemu_ld64_i64(ctx, t0, t0); + tcg_gen_ld_i64(t1, cpu_env, (ctx->le_mode + ? offsetof(CPUPPCState, reserve_val) + : offsetof(CPUPPCState, reserve_val2)= )); + tcg_gen_brcond_i64(TCG_COND_NE, t0, t1, lab_fail); + + /* Success */ + gen_qemu_st64_i64(ctx, ctx->le_mode ? lo : hi, cpu_reserve); + tcg_gen_addi_i64(t0, cpu_reserve, 8); + gen_qemu_st64_i64(ctx, ctx->le_mode ? hi : lo, t0); + + tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so); + tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], CRF_EQ); + tcg_gen_br(lab_over); =20 + gen_set_label(lab_fail); + tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so); + + gen_set_label(lab_over); + tcg_gen_movi_tl(cpu_reserve, -1); + tcg_temp_free_i64(t0); + tcg_temp_free_i64(t1); + } +} #endif /* defined(TARGET_PPC64) */ =20 /* sync */ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598958464707.654099295664; Mon, 2 Jul 2018 23:22:38 -0700 (PDT) Received: from localhost ([::1]:38072 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEhx-0005XN-IZ for importer@patchew.org; Tue, 03 Jul 2018 02:22:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKV-0002rC-P7 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKS-0006xs-IT for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:23 -0400 Received: from ozlabs.org ([203.11.71.1]:48151) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKR-0006uF-P6; Tue, 03 Jul 2018 01:58:20 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM95kgWz9s9y; Tue, 3 Jul 2018 15:58:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597493; bh=b9K6lgAlIlXGzW0zb2bBBQrlnAX0Fz3I1exeWmRL6qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BiZ3C1T91IVzidnguaTAMzKkEVb63YvVUJuEIFDVFTeAAJGT/O1EURTIl2tufHags wax2xynIWN/Oc4Ugbb+sR5Z6MP9Ae6mmGofKX5soAgikNGAym0WFtzcBnyF+09XhuK v8kTfrJektBuTaIcTnIgpZyCs4r5zlh65bAyeeLc= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:44 +1000 Message-Id: <20180703055804.13449-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 15/35] target/ppc: Remove POWERPC_EXCP_STCX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Always use the gen_conditional_store implementation that uses atomic_cmpxchg. Make sure and clear reserve_addr across most interrupts crossing the cpu_loop. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- linux-user/ppc/cpu_loop.c | 121 +++++++------------------------------- target/ppc/cpu.h | 5 -- target/ppc/translate.c | 14 ----- 3 files changed, 22 insertions(+), 118 deletions(-) diff --git a/linux-user/ppc/cpu_loop.c b/linux-user/ppc/cpu_loop.c index 2fb516cb00..133a87f349 100644 --- a/linux-user/ppc/cpu_loop.c +++ b/linux-user/ppc/cpu_loop.c @@ -65,99 +65,23 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32= _t val) return -1; } =20 -static int do_store_exclusive(CPUPPCState *env) -{ - target_ulong addr; - target_ulong page_addr; - target_ulong val, val2 __attribute__((unused)) =3D 0; - int flags; - int segv =3D 0; - - addr =3D env->reserve_ea; - page_addr =3D addr & TARGET_PAGE_MASK; - start_exclusive(); - mmap_lock(); - flags =3D page_get_flags(page_addr); - if ((flags & PAGE_READ) =3D=3D 0) { - segv =3D 1; - } else { - int reg =3D env->reserve_info & 0x1f; - int size =3D env->reserve_info >> 5; - int stored =3D 0; - - if (addr =3D=3D env->reserve_addr) { - switch (size) { - case 1: segv =3D get_user_u8(val, addr); break; - case 2: segv =3D get_user_u16(val, addr); break; - case 4: segv =3D get_user_u32(val, addr); break; -#if defined(TARGET_PPC64) - case 8: segv =3D get_user_u64(val, addr); break; - case 16: { - segv =3D get_user_u64(val, addr); - if (!segv) { - segv =3D get_user_u64(val2, addr + 8); - } - break; - } -#endif - default: abort(); - } - if (!segv && val =3D=3D env->reserve_val) { - val =3D env->gpr[reg]; - switch (size) { - case 1: segv =3D put_user_u8(val, addr); break; - case 2: segv =3D put_user_u16(val, addr); break; - case 4: segv =3D put_user_u32(val, addr); break; -#if defined(TARGET_PPC64) - case 8: segv =3D put_user_u64(val, addr); break; - case 16: { - if (val2 =3D=3D env->reserve_val2) { - if (msr_le) { - val2 =3D val; - val =3D env->gpr[reg+1]; - } else { - val2 =3D env->gpr[reg+1]; - } - segv =3D put_user_u64(val, addr); - if (!segv) { - segv =3D put_user_u64(val2, addr + 8); - } - } - break; - } -#endif - default: abort(); - } - if (!segv) { - stored =3D 1; - } - } - } - env->crf[0] =3D (stored << 1) | xer_so; - env->reserve_addr =3D (target_ulong)-1; - } - if (!segv) { - env->nip +=3D 4; - } - mmap_unlock(); - end_exclusive(); - return segv; -} - void cpu_loop(CPUPPCState *env) { CPUState *cs =3D CPU(ppc_env_get_cpu(env)); target_siginfo_t info; - int trapnr; + int trapnr, sig; target_ulong ret; =20 for(;;) { + bool arch_interrupt; + cpu_exec_start(cs); trapnr =3D cpu_exec(cs); cpu_exec_end(cs); process_queued_cpu_work(cs); =20 - switch(trapnr) { + arch_interrupt =3D true; + switch (trapnr) { case POWERPC_EXCP_NONE: /* Just go on */ break; @@ -524,26 +448,15 @@ void cpu_loop(CPUPPCState *env) } env->gpr[3] =3D ret; break; - case POWERPC_EXCP_STCX: - if (do_store_exclusive(env)) { - info.si_signo =3D TARGET_SIGSEGV; + case EXCP_DEBUG: + sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); + if (sig) { + info.si_signo =3D sig; info.si_errno =3D 0; - info.si_code =3D TARGET_SEGV_MAPERR; - info._sifields._sigfault._addr =3D env->nip; + info.si_code =3D TARGET_TRAP_BRKPT; queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } - break; - case EXCP_DEBUG: - { - int sig; - - sig =3D gdb_handlesig(cs, TARGET_SIGTRAP); - if (sig) { - info.si_signo =3D sig; - info.si_errno =3D 0; - info.si_code =3D TARGET_TRAP_BRKPT; - queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); - } + } else { + arch_interrupt =3D false; } break; case EXCP_INTERRUPT: @@ -551,12 +464,22 @@ void cpu_loop(CPUPPCState *env) break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); + arch_interrupt =3D false; break; default: cpu_abort(cs, "Unknown exception 0x%x. Aborting\n", trapnr); break; } process_pending_signals(env); + + /* Most of the traps imply a transition through kernel mode, + * which implies an REI instruction has been executed. Which + * means that RX and LOCK_ADDR should be cleared. But there + * are a few exceptions for traps internal to QEMU. + */ + if (arch_interrupt) { + env->reserve_addr =3D -1; + } } } =20 diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 973cf44cda..4edcf62cf7 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -196,7 +196,6 @@ enum { /* QEMU exceptions: special cases we want to stop translation = */ POWERPC_EXCP_SYNC =3D 0x202, /* context synchronizing instruct= ion */ POWERPC_EXCP_SYSCALL_USER =3D 0x203, /* System call in user mode only = */ - POWERPC_EXCP_STCX =3D 0x204 /* Conditional stores in user mode= */ }; =20 /* Exceptions error codes = */ @@ -994,10 +993,6 @@ struct CPUPPCState { /* Reservation value */ target_ulong reserve_val; target_ulong reserve_val2; - /* Reservation store address */ - target_ulong reserve_ea; - /* Reserved store source register and size */ - target_ulong reserve_info; =20 /* Those ones are used in supervisor mode only */ /* machine state register */ diff --git a/target/ppc/translate.c b/target/ppc/translate.c index c7b9d226eb..03e8c5df03 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3201,19 +3201,6 @@ ST_ATOMIC(stwat, DEF_MEMOP(MO_UL), i32, trunc_tl_i32) ST_ATOMIC(stdat, DEF_MEMOP(MO_Q), i64, mov_i64) #endif =20 -#if defined(CONFIG_USER_ONLY) -static void gen_conditional_store(DisasContext *ctx, TCGv EA, - int reg, int memop) -{ - TCGv t0 =3D tcg_temp_new(); - - tcg_gen_st_tl(EA, cpu_env, offsetof(CPUPPCState, reserve_ea)); - tcg_gen_movi_tl(t0, (MEMOP_GET_SIZE(memop) << 5) | reg); - tcg_gen_st_tl(t0, cpu_env, offsetof(CPUPPCState, reserve_info)); - tcg_temp_free(t0); - gen_exception_err(ctx, POWERPC_EXCP_STCX, 0); -} -#else static void gen_conditional_store(DisasContext *ctx, TCGv EA, int reg, int memop) { @@ -3244,7 +3231,6 @@ static void gen_conditional_store(DisasContext *ctx, = TCGv EA, gen_set_label(l2); tcg_gen_movi_tl(cpu_reserve, -1); } -#endif =20 #define STCX(name, memop) \ static void gen_##name(DisasContext *ctx) \ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598020242521.1518557069777; Mon, 2 Jul 2018 23:07:00 -0700 (PDT) Received: from localhost ([::1]:37976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faESg-0000ow-2I for importer@patchew.org; Tue, 03 Jul 2018 02:06:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKU-0002pt-3c for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKS-0006xV-B2 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:22 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:56759) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKR-0006ty-PB; Tue, 03 Jul 2018 01:58:20 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM92HsWz9sBb; Tue, 3 Jul 2018 15:58:11 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597493; bh=56GIdrD5g+BR6+2TQKBJx3WZ9W4j3UkpY4pjY0N6cZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FXkkjx29b7g1IxcwuGqYyW1kE9UhUFIbmRejtgsYyjTZ7+TOhGoUY/mow9LWq/EI+ l9SCRPzMYLNKK9wVTf85194doV8UHkW+7OQWOWpVU1jRvjeSi4OEGXF2V/74wVIdaY EHq1c3ww6p+JukIg/2lcOaIfPoDeiXMk7YtmKAoc= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:45 +1000 Message-Id: <20180703055804.13449-17-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 16/35] target/ppc: Tidy gen_conditional_store X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Leave only the minimal amount of code within the STCX macro, moving the rest of the code into gen_conditional_store. Remove the explicit call to gen_check_align; the matching LDAX will have already checked alignment, and we verify the same address. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 03e8c5df03..e751072404 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3201,14 +3201,17 @@ ST_ATOMIC(stwat, DEF_MEMOP(MO_UL), i32, trunc_tl_i3= 2) ST_ATOMIC(stdat, DEF_MEMOP(MO_Q), i64, mov_i64) #endif =20 -static void gen_conditional_store(DisasContext *ctx, TCGv EA, - int reg, int memop) +static void gen_conditional_store(DisasContext *ctx, TCGMemOp memop) { TCGLabel *l1 =3D gen_new_label(); TCGLabel *l2 =3D gen_new_label(); - TCGv t0; + TCGv t0 =3D tcg_temp_new(); + int reg =3D rS(ctx->opcode); =20 - tcg_gen_brcond_tl(TCG_COND_NE, EA, cpu_reserve, l1); + gen_set_access_type(ctx, ACCESS_RES); + gen_addr_reg_index(ctx, t0); + tcg_gen_brcond_tl(TCG_COND_NE, t0, cpu_reserve, l1); + tcg_temp_free(t0); =20 t0 =3D tcg_temp_new(); tcg_gen_atomic_cmpxchg_tl(t0, cpu_reserve, cpu_reserve_val, @@ -3232,19 +3235,10 @@ static void gen_conditional_store(DisasContext *ctx= , TCGv EA, tcg_gen_movi_tl(cpu_reserve, -1); } =20 -#define STCX(name, memop) \ -static void gen_##name(DisasContext *ctx) \ -{ \ - TCGv t0; \ - int len =3D MEMOP_GET_SIZE(memop); \ - gen_set_access_type(ctx, ACCESS_RES); \ - t0 =3D tcg_temp_local_new(); \ - gen_addr_reg_index(ctx, t0); \ - if (len > 1) { \ - gen_check_align(ctx, t0, (len) - 1); \ - } \ - gen_conditional_store(ctx, t0, rS(ctx->opcode), memop); \ - tcg_temp_free(t0); \ +#define STCX(name, memop) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + gen_conditional_store(ctx, memop); \ } =20 STCX(stbcx_, DEF_MEMOP(MO_UB)) --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530597630170682.0288310929366; Mon, 2 Jul 2018 23:00:30 -0700 (PDT) Received: from localhost ([::1]:37934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEMX-0004MU-Di for importer@patchew.org; Tue, 03 Jul 2018 02:00:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKT-0002pS-Md for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKS-0006x1-0q for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:21 -0400 Received: from ozlabs.org ([203.11.71.1]:41219) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKR-0006tz-Jc; Tue, 03 Jul 2018 01:58:19 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM94Y0Bz9s9T; Tue, 3 Jul 2018 15:58:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597493; bh=jQ+D44/6jbdI34RwZC4Q7pAZmq+H1BaA5lJmD7EFNgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QcFArCdXduJQnmhMmaW8S3ClL1fpk6OwWHH7Ao3RRXk5oMEDjMIMdZRTUHPxgCWHD hcieqOttoGAyOk4eVtEcRW/0XmhKabvD27rz4vCoJrOMr0Sq3HhCx2FF65nZLezFRo sUK4/1Z6K3N9adCXBbSK6Ed8efR5Nrpxq+pmWHik= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:46 +1000 Message-Id: <20180703055804.13449-18-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 17/35] target/ppc: Split out gen_load_locked X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Leave only the minimal amount of code within the LDAR macro, moving the rest of the code into gen_load_locked. Use MO_ALIGN and remove the explicit call to gen_check_align. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index e751072404..f48fcbeefb 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3070,23 +3070,24 @@ static void gen_isync(DisasContext *ctx) =20 #define MEMOP_GET_SIZE(x) (1 << ((x) & MO_SIZE)) =20 -#define LARX(name, memop) \ -static void gen_##name(DisasContext *ctx) \ -{ \ - TCGv t0; \ - TCGv gpr =3D cpu_gpr[rD(ctx->opcode)]; \ - int len =3D MEMOP_GET_SIZE(memop); \ - gen_set_access_type(ctx, ACCESS_RES); \ - t0 =3D tcg_temp_local_new(); \ - gen_addr_reg_index(ctx, t0); \ - if ((len) > 1) { \ - gen_check_align(ctx, t0, (len)-1); \ - } \ - tcg_gen_qemu_ld_tl(gpr, t0, ctx->mem_idx, memop); \ - tcg_gen_mov_tl(cpu_reserve, t0); \ - tcg_gen_mov_tl(cpu_reserve_val, gpr); \ - tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); \ - tcg_temp_free(t0); \ +static void gen_load_locked(DisasContext *ctx, TCGMemOp memop) +{ + TCGv gpr =3D cpu_gpr[rD(ctx->opcode)]; + TCGv t0 =3D tcg_temp_new(); + + gen_set_access_type(ctx, ACCESS_RES); + gen_addr_reg_index(ctx, t0); + tcg_gen_qemu_ld_tl(gpr, t0, ctx->mem_idx, memop | MO_ALIGN); + tcg_gen_mov_tl(cpu_reserve, t0); + tcg_gen_mov_tl(cpu_reserve_val, gpr); + tcg_gen_mb(TCG_MO_ALL | TCG_BAR_LDAQ); + tcg_temp_free(t0); +} + +#define LARX(name, memop) \ +static void gen_##name(DisasContext *ctx) \ +{ \ + gen_load_locked(ctx, memop); \ } =20 /* lwarx */ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598200998469.69133838958237; Mon, 2 Jul 2018 23:10:00 -0700 (PDT) Received: from localhost ([::1]:37990 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEVk-0003KJ-5B for importer@patchew.org; Tue, 03 Jul 2018 02:10:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKW-0002rG-Mu for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKT-0006yn-PD for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:24 -0400 Received: from ozlabs.org ([203.11.71.1]:46381) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKS-0006um-Vy; Tue, 03 Jul 2018 01:58:21 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM96KkZz9s9G; Tue, 3 Jul 2018 15:58:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597493; bh=82ysa0rNFDy/kfS7HaxFjTLARUbZmvxjdH6OTbl17BM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N9pkRrvfVc5BBktEXEI6go+Y311we8KEUjf1qp1Ee01Yq1UtD/iAP6Ie0N04Uvjvb qgV4ACqutqeRcNDTa8ltHPYfH2R5xJGXHcCQ046rVzVFppgn+a6F/AhAqKALbL8IY7 FBOuC/xVQEnkUVP7o3PVpjWE7jehN6MgoxQ9lmwg= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:47 +1000 Message-Id: <20180703055804.13449-19-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 18/35] target/ppc: Split out gen_ld_atomic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Move the guts of LD_ATOMIC to a function. Use foo_tl for the operations instead of foo_i32 or foo_i64 specifically. Use MO_ALIGN instead of an explicit call to gen_check_align. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 105 ++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index f48fcbeefb..361b178db8 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3095,61 +3095,60 @@ LARX(lbarx, DEF_MEMOP(MO_UB)) LARX(lharx, DEF_MEMOP(MO_UW)) LARX(lwarx, DEF_MEMOP(MO_UL)) =20 -#define LD_ATOMIC(name, memop, tp, op, eop) \ -static void gen_##name(DisasContext *ctx) \ -{ \ - int len =3D MEMOP_GET_SIZE(memop); \ - uint32_t gpr_FC =3D FC(ctx->opcode); \ - TCGv EA =3D tcg_temp_local_new(); \ - TCGv_##tp t0, t1; \ - \ - gen_addr_register(ctx, EA); \ - if (len > 1) { \ - gen_check_align(ctx, EA, len - 1); \ - } \ - t0 =3D tcg_temp_new_##tp(); \ - t1 =3D tcg_temp_new_##tp(); \ - tcg_gen_##op(t0, cpu_gpr[rD(ctx->opcode) + 1]); \ - \ - switch (gpr_FC) { \ - case 0: /* Fetch and add */ \ - tcg_gen_atomic_fetch_add_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 1: /* Fetch and xor */ \ - tcg_gen_atomic_fetch_xor_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 2: /* Fetch and or */ \ - tcg_gen_atomic_fetch_or_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 3: /* Fetch and 'and' */ \ - tcg_gen_atomic_fetch_and_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 8: /* Swap */ \ - tcg_gen_atomic_xchg_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 4: /* Fetch and max unsigned */ \ - case 5: /* Fetch and max signed */ \ - case 6: /* Fetch and min unsigned */ \ - case 7: /* Fetch and min signed */ \ - case 16: /* compare and swap not equal */ \ - case 24: /* Fetch and increment bounded */ \ - case 25: /* Fetch and increment equal */ \ - case 28: /* Fetch and decrement bounded */ \ - gen_invalid(ctx); \ - break; \ - default: \ - /* invoke data storage error handler */ \ - gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL); \ - } \ - tcg_gen_##eop(cpu_gpr[rD(ctx->opcode)], t1); \ - tcg_temp_free_##tp(t0); \ - tcg_temp_free_##tp(t1); \ - tcg_temp_free(EA); \ +static void gen_ld_atomic(DisasContext *ctx, TCGMemOp memop) +{ + uint32_t gpr_FC =3D FC(ctx->opcode); + TCGv EA =3D tcg_temp_new(); + TCGv src, dst; + + gen_addr_register(ctx, EA); + dst =3D cpu_gpr[rD(ctx->opcode)]; + src =3D cpu_gpr[rD(ctx->opcode) + 1]; + + memop |=3D MO_ALIGN; + switch (gpr_FC) { + case 0: /* Fetch and add */ + tcg_gen_atomic_fetch_add_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 1: /* Fetch and xor */ + tcg_gen_atomic_fetch_xor_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 2: /* Fetch and or */ + tcg_gen_atomic_fetch_or_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 3: /* Fetch and 'and' */ + tcg_gen_atomic_fetch_and_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 8: /* Swap */ + tcg_gen_atomic_xchg_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 4: /* Fetch and max unsigned */ + case 5: /* Fetch and max signed */ + case 6: /* Fetch and min unsigned */ + case 7: /* Fetch and min signed */ + case 16: /* compare and swap not equal */ + case 24: /* Fetch and increment bounded */ + case 25: /* Fetch and increment equal */ + case 28: /* Fetch and decrement bounded */ + gen_invalid(ctx); + break; + default: + /* invoke data storage error handler */ + gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL); + } + tcg_temp_free(EA); } =20 -LD_ATOMIC(lwat, DEF_MEMOP(MO_UL), i32, trunc_tl_i32, extu_i32_tl) -#if defined(TARGET_PPC64) -LD_ATOMIC(ldat, DEF_MEMOP(MO_Q), i64, mov_i64, mov_i64) +static void gen_lwat(DisasContext *ctx) +{ + gen_ld_atomic(ctx, DEF_MEMOP(MO_UL)); +} + +#ifdef TARGET_PPC64 +static void gen_ldat(DisasContext *ctx) +{ + gen_ld_atomic(ctx, DEF_MEMOP(MO_Q)); +} #endif =20 #define ST_ATOMIC(name, memop, tp, op) \ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153059895014721.699241762479232; Mon, 2 Jul 2018 23:22:30 -0700 (PDT) Received: from localhost ([::1]:38070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEhp-0005Rl-90 for importer@patchew.org; Tue, 03 Jul 2018 02:22:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKW-0002rF-Gm for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKT-0006yv-T0 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:24 -0400 Received: from ozlabs.org ([203.11.71.1]:52583) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKT-0006vi-3I; Tue, 03 Jul 2018 01:58:21 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMB0MTbz9sBJ; Tue, 3 Jul 2018 15:58:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597494; bh=aVS2gFIN8wMUj6HW1raMgi+7caIQqex88I1ycTzdwzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUmh7uHzDW3ExlUbWYNSoaHvFNw3CvRy+i1T0NTNPRSt9OJkOG6LVjEw0Y0EbXdXo x0u94iUbGUe3GY52iiykUaukh+Npsy/D3iez78nClX+RW82eFfOXkUFZ7ePqRGLCVD GuIPNh7+FPOshqUlNWmnB9zjo0jvbOjmYuONSMoo= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:48 +1000 Message-Id: <20180703055804.13449-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 19/35] target/ppc: Split out gen_st_atomic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Move the guts of ST_ATOMIC to a function. Use foo_tl for the operations instead of foo_i32 or foo_i64 specifically. Use MO_ALIGN instead of an explicit call to gen_check_align. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 97 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 361b178db8..53ca8f0114 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3151,54 +3151,55 @@ static void gen_ldat(DisasContext *ctx) } #endif =20 -#define ST_ATOMIC(name, memop, tp, op) \ -static void gen_##name(DisasContext *ctx) \ -{ \ - int len =3D MEMOP_GET_SIZE(memop); \ - uint32_t gpr_FC =3D FC(ctx->opcode); \ - TCGv EA =3D tcg_temp_local_new(); \ - TCGv_##tp t0, t1; \ - \ - gen_addr_register(ctx, EA); \ - if (len > 1) { \ - gen_check_align(ctx, EA, len - 1); \ - } \ - t0 =3D tcg_temp_new_##tp(); \ - t1 =3D tcg_temp_new_##tp(); \ - tcg_gen_##op(t0, cpu_gpr[rD(ctx->opcode) + 1]); \ - \ - switch (gpr_FC) { \ - case 0: /* add and Store */ \ - tcg_gen_atomic_add_fetch_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 1: /* xor and Store */ \ - tcg_gen_atomic_xor_fetch_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 2: /* Or and Store */ \ - tcg_gen_atomic_or_fetch_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 3: /* 'and' and Store */ \ - tcg_gen_atomic_and_fetch_##tp(t1, EA, t0, ctx->mem_idx, memop); \ - break; \ - case 4: /* Store max unsigned */ \ - case 5: /* Store max signed */ \ - case 6: /* Store min unsigned */ \ - case 7: /* Store min signed */ \ - case 24: /* Store twin */ \ - gen_invalid(ctx); \ - break; \ - default: \ - /* invoke data storage error handler */ \ - gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL); \ - } \ - tcg_temp_free_##tp(t0); \ - tcg_temp_free_##tp(t1); \ - tcg_temp_free(EA); \ -} - -ST_ATOMIC(stwat, DEF_MEMOP(MO_UL), i32, trunc_tl_i32) -#if defined(TARGET_PPC64) -ST_ATOMIC(stdat, DEF_MEMOP(MO_Q), i64, mov_i64) +static void gen_st_atomic(DisasContext *ctx, TCGMemOp memop) +{ + uint32_t gpr_FC =3D FC(ctx->opcode); + TCGv EA =3D tcg_temp_new(); + TCGv src, discard; + + gen_addr_register(ctx, EA); + src =3D cpu_gpr[rD(ctx->opcode)]; + discard =3D tcg_temp_new(); + + memop |=3D MO_ALIGN; + switch (gpr_FC) { + case 0: /* add and Store */ + tcg_gen_atomic_add_fetch_tl(discard, EA, src, ctx->mem_idx, memop); + break; + case 1: /* xor and Store */ + tcg_gen_atomic_xor_fetch_tl(discard, EA, src, ctx->mem_idx, memop); + break; + case 2: /* Or and Store */ + tcg_gen_atomic_or_fetch_tl(discard, EA, src, ctx->mem_idx, memop); + break; + case 3: /* 'and' and Store */ + tcg_gen_atomic_and_fetch_tl(discard, EA, src, ctx->mem_idx, memop); + break; + case 4: /* Store max unsigned */ + case 5: /* Store max signed */ + case 6: /* Store min unsigned */ + case 7: /* Store min signed */ + case 24: /* Store twin */ + gen_invalid(ctx); + break; + default: + /* invoke data storage error handler */ + gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL); + } + tcg_temp_free(discard); + tcg_temp_free(EA); +} + +static void gen_stwat(DisasContext *ctx) +{ + gen_st_atomic(ctx, DEF_MEMOP(MO_UL)); +} + +#ifdef TARGET_PPC64 +static void gen_stdat(DisasContext *ctx) +{ + gen_st_atomic(ctx, DEF_MEMOP(MO_Q)); +} #endif =20 static void gen_conditional_store(DisasContext *ctx, TCGMemOp memop) --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530597831936489.33054087540756; Mon, 2 Jul 2018 23:03:51 -0700 (PDT) Received: from localhost ([::1]:37956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEPn-0006oO-6Z for importer@patchew.org; Tue, 03 Jul 2018 02:03:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKU-0002qE-8l for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKS-0006xc-CS for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:22 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:44505) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKR-0006tp-NB; Tue, 03 Jul 2018 01:58:20 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYM85BWyz9s78; Tue, 3 Jul 2018 15:58:12 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597492; bh=/tGRmhjXbAUf/n5ke5eecw2i4jfxDvsr5FNtGq//Rqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dsl25rdQOG4G8tXG1eJzqvKhlG/NQpstUuxqtR3qeBXsxDJrh5CLa/AZc9iadhkk1 Hux5BW6J04Sp9EWF9zX6TCx761QxOXz239OsprLiLHJSfRMFUfiGGY4H9mmvrsnqrM vjlMdb+KioqjVy/jgunaumCasajL7cZwKgL4gFqw= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:49 +1000 Message-Id: <20180703055804.13449-21-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 20/35] target/ppc: Use MO_ALIGN for EXIWX and ECOWX X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson This avoids the need for gen_check_align entirely. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 53ca8f0114..c2a28be6d7 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -2388,23 +2388,6 @@ static inline void gen_addr_add(DisasContext *ctx, T= CGv ret, TCGv arg1, } } =20 -static inline void gen_check_align(DisasContext *ctx, TCGv EA, int mask) -{ - TCGLabel *l1 =3D gen_new_label(); - TCGv t0 =3D tcg_temp_new(); - TCGv_i32 t1, t2; - tcg_gen_andi_tl(t0, EA, mask); - tcg_gen_brcondi_tl(TCG_COND_EQ, t0, 0, l1); - t1 =3D tcg_const_i32(POWERPC_EXCP_ALIGN); - t2 =3D tcg_const_i32(ctx->opcode & 0x03FF0000); - gen_update_nip(ctx, ctx->base.pc_next - 4); - gen_helper_raise_exception_err(cpu_env, t1, t2); - tcg_temp_free_i32(t1); - tcg_temp_free_i32(t2); - gen_set_label(l1); - tcg_temp_free(t0); -} - static inline void gen_align_no_le(DisasContext *ctx) { gen_exception_err(ctx, POWERPC_EXCP_ALIGN, @@ -4706,8 +4689,8 @@ static void gen_eciwx(DisasContext *ctx) gen_set_access_type(ctx, ACCESS_EXT); t0 =3D tcg_temp_new(); gen_addr_reg_index(ctx, t0); - gen_check_align(ctx, t0, 0x03); - gen_qemu_ld32u(ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_qemu_ld_tl(cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx, + DEF_MEMOP(MO_UL | MO_ALIGN)); tcg_temp_free(t0); } =20 @@ -4719,8 +4702,8 @@ static void gen_ecowx(DisasContext *ctx) gen_set_access_type(ctx, ACCESS_EXT); t0 =3D tcg_temp_new(); gen_addr_reg_index(ctx, t0); - gen_check_align(ctx, t0, 0x03); - gen_qemu_st32(ctx, cpu_gpr[rD(ctx->opcode)], t0); + tcg_gen_qemu_st_tl(cpu_gpr[rD(ctx->opcode)], t0, ctx->mem_idx, + DEF_MEMOP(MO_UL | MO_ALIGN)); tcg_temp_free(t0); } =20 --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598427787838.9600274614667; Mon, 2 Jul 2018 23:13:47 -0700 (PDT) Received: from localhost ([::1]:38011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEZO-0006ol-Tf for importer@patchew.org; Tue, 03 Jul 2018 02:13:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKZ-0002uj-Ro for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKV-00070i-5P for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from ozlabs.org ([203.11.71.1]:54425) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKU-0006y7-Mf; Tue, 03 Jul 2018 01:58:23 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMC0K50z9sBk; Tue, 3 Jul 2018 15:58:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597495; bh=K5siGL/TPnZ2c+RHbEMCenbhb5lOhB7Qo5pf7b3L9wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBsaun2ttV6N3/Wk63rulA7YCyb1Za+/H7KwAyQX7I7npmBuLPbq26ejLsR1+mzBG Ca8Azu3LfePn/qwWwNhw9e7witpdVJBe7ZB2h7oYddf5hgPi1y2VTFOKg6nTaopZgz 85lXz6/TJsaHeAfgLtz2DB9tXEaSmjZd9N8OTjyA= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:50 +1000 Message-Id: <20180703055804.13449-22-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 21/35] target/ppc: Use atomic min/max helpers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson These operations were previously unimplemented for ppc. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index c2a28be6d7..79285b6698 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3102,13 +3102,21 @@ static void gen_ld_atomic(DisasContext *ctx, TCGMem= Op memop) case 3: /* Fetch and 'and' */ tcg_gen_atomic_fetch_and_tl(dst, EA, src, ctx->mem_idx, memop); break; - case 8: /* Swap */ - tcg_gen_atomic_xchg_tl(dst, EA, src, ctx->mem_idx, memop); - break; case 4: /* Fetch and max unsigned */ + tcg_gen_atomic_fetch_umax_tl(dst, EA, src, ctx->mem_idx, memop); + break; case 5: /* Fetch and max signed */ + tcg_gen_atomic_fetch_smax_tl(dst, EA, src, ctx->mem_idx, memop); + break; case 6: /* Fetch and min unsigned */ + tcg_gen_atomic_fetch_umin_tl(dst, EA, src, ctx->mem_idx, memop); + break; case 7: /* Fetch and min signed */ + tcg_gen_atomic_fetch_smin_tl(dst, EA, src, ctx->mem_idx, memop); + break; + case 8: /* Swap */ + tcg_gen_atomic_xchg_tl(dst, EA, src, ctx->mem_idx, memop); + break; case 16: /* compare and swap not equal */ case 24: /* Fetch and increment bounded */ case 25: /* Fetch and increment equal */ @@ -3159,9 +3167,17 @@ static void gen_st_atomic(DisasContext *ctx, TCGMemO= p memop) tcg_gen_atomic_and_fetch_tl(discard, EA, src, ctx->mem_idx, memop); break; case 4: /* Store max unsigned */ + tcg_gen_atomic_umax_fetch_tl(discard, EA, src, ctx->mem_idx, memop= ); + break; case 5: /* Store max signed */ + tcg_gen_atomic_smax_fetch_tl(discard, EA, src, ctx->mem_idx, memop= ); + break; case 6: /* Store min unsigned */ + tcg_gen_atomic_umin_fetch_tl(discard, EA, src, ctx->mem_idx, memop= ); + break; case 7: /* Store min signed */ + tcg_gen_atomic_smin_fetch_tl(discard, EA, src, ctx->mem_idx, memop= ); + break; case 24: /* Store twin */ gen_invalid(ctx); break; --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598079741486.37700968296394; Mon, 2 Jul 2018 23:07:59 -0700 (PDT) Received: from localhost ([::1]:37978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faETm-0001hi-Un for importer@patchew.org; Tue, 03 Jul 2018 02:07:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKY-0002sV-2w for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKV-00071s-OZ for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:26 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:32831) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKU-0006xx-RN; Tue, 03 Jul 2018 01:58:23 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMB634yz9sBs; Tue, 3 Jul 2018 15:58:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597494; bh=kcbHI7VcKyE/gHvFWADW0Ha5EEQDj1GjzAloZ1A66+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bKJl9wGCrpK10Bu4U+74/gkjflrifElgT2bGO6L8OGX57rRfp3eT6uDZTSvcNP8pf gGs3zGsqO3pK1duLOr3aJRdxd/26xszLHluqby9JvWQGejcfk74xE+TgkXsz8nnuHM 6eHD35q/+ISLTmqXNt6zCFzfs1DFdH0GtOfeh84I= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:51 +1000 Message-Id: <20180703055804.13449-23-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 22/35] target/ppc: Implement the rest of gen_ld_atomic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson These cases were stubbed out. For now, implement them only within a serial context, forcing parallel execution to synchronize. It would be possible to implement these with cmpxchg loops, if we care. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 83 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 79285b6698..597a37d3ec 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3078,16 +3078,45 @@ LARX(lbarx, DEF_MEMOP(MO_UB)) LARX(lharx, DEF_MEMOP(MO_UW)) LARX(lwarx, DEF_MEMOP(MO_UL)) =20 +static void gen_fetch_inc_conditional(DisasContext *ctx, TCGMemOp memop, + TCGv EA, TCGCond cond, int addend) +{ + TCGv t =3D tcg_temp_new(); + TCGv t2 =3D tcg_temp_new(); + TCGv u =3D tcg_temp_new(); + + tcg_gen_qemu_ld_tl(t, EA, ctx->mem_idx, memop); + tcg_gen_addi_tl(t2, EA, MEMOP_GET_SIZE(memop)); + tcg_gen_qemu_ld_tl(t2, t2, ctx->mem_idx, memop); + tcg_gen_addi_tl(u, t, addend); + + /* E.g. for fetch and increment bounded... */ + /* mem(EA,s) =3D (t !=3D t2 ? u =3D t + 1 : t) */ + tcg_gen_movcond_tl(cond, u, t, t2, u, t); + tcg_gen_qemu_st_tl(u, EA, ctx->mem_idx, memop); + + /* RT =3D (t !=3D t2 ? t : u =3D 1<<(s*8-1)) */ + tcg_gen_movi_tl(u, 1 << (MEMOP_GET_SIZE(memop) * 8 - 1)); + tcg_gen_movcond_tl(cond, cpu_gpr[rD(ctx->opcode)], t, t2, t, u); + + tcg_temp_free(t); + tcg_temp_free(t2); + tcg_temp_free(u); +} + static void gen_ld_atomic(DisasContext *ctx, TCGMemOp memop) { uint32_t gpr_FC =3D FC(ctx->opcode); TCGv EA =3D tcg_temp_new(); + int rt =3D rD(ctx->opcode); + bool need_serial; TCGv src, dst; =20 gen_addr_register(ctx, EA); - dst =3D cpu_gpr[rD(ctx->opcode)]; - src =3D cpu_gpr[rD(ctx->opcode) + 1]; + dst =3D cpu_gpr[rt]; + src =3D cpu_gpr[(rt + 1) & 31]; =20 + need_serial =3D false; memop |=3D MO_ALIGN; switch (gpr_FC) { case 0: /* Fetch and add */ @@ -3117,17 +3146,63 @@ static void gen_ld_atomic(DisasContext *ctx, TCGMem= Op memop) case 8: /* Swap */ tcg_gen_atomic_xchg_tl(dst, EA, src, ctx->mem_idx, memop); break; - case 16: /* compare and swap not equal */ + + case 16: /* Compare and swap not equal */ + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + need_serial =3D true; + } else { + TCGv t0 =3D tcg_temp_new(); + TCGv t1 =3D tcg_temp_new(); + + tcg_gen_qemu_ld_tl(t0, EA, ctx->mem_idx, memop); + if ((memop & MO_SIZE) =3D=3D MO_64 || TARGET_LONG_BITS =3D=3D = 32) { + tcg_gen_mov_tl(t1, src); + } else { + tcg_gen_ext32u_tl(t1, src); + } + tcg_gen_movcond_tl(TCG_COND_NE, t1, t0, t1, + cpu_gpr[(rt + 2) & 31], t0); + tcg_gen_qemu_st_tl(t1, EA, ctx->mem_idx, memop); + tcg_gen_mov_tl(dst, t0); + + tcg_temp_free(t0); + tcg_temp_free(t1); + } + break; + case 24: /* Fetch and increment bounded */ + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + need_serial =3D true; + } else { + gen_fetch_inc_conditional(ctx, memop, EA, TCG_COND_NE, 1); + } + break; case 25: /* Fetch and increment equal */ + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + need_serial =3D true; + } else { + gen_fetch_inc_conditional(ctx, memop, EA, TCG_COND_EQ, 1); + } + break; case 28: /* Fetch and decrement bounded */ - gen_invalid(ctx); + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + need_serial =3D true; + } else { + gen_fetch_inc_conditional(ctx, memop, EA, TCG_COND_NE, -1); + } break; + default: /* invoke data storage error handler */ gen_exception_err(ctx, POWERPC_EXCP_DSI, POWERPC_EXCP_INVAL); } tcg_temp_free(EA); + + if (need_serial) { + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp =3D DISAS_NORETURN; + } } =20 static void gen_lwat(DisasContext *ctx) --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598369719472.25689045542777; Mon, 2 Jul 2018 23:12:49 -0700 (PDT) Received: from localhost ([::1]:38008 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEYS-0005lq-SZ for importer@patchew.org; Tue, 03 Jul 2018 02:12:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKZ-0002u7-Eu for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKU-000706-Ov for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from ozlabs.org ([203.11.71.1]:34269) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKU-0006x0-84; Tue, 03 Jul 2018 01:58:22 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMB31vvz9sBZ; Tue, 3 Jul 2018 15:58:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597494; bh=9JmbGYpkXqRuPWSZNnzwgmJeArXiZC0b10euIj5kODY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1BA6V6qXHH6pVerB8bNyZqAdVVdyF6WtVLwQArnJXip77sf6GuN7PqXX0CnX1ZEm 4OY8+apjQzCkcawfcny1DvzpdU2gFdT0eaCOutIuzt9Ng8gMKSiFcpPDNlfEAWWSm6 uf8TuvfeFZ08beVITjsK0zW1JYsB+88aihC2evzo= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:52 +1000 Message-Id: <20180703055804.13449-24-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 23/35] target/ppc: Implement the rest of gen_st_atomic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Richard Henderson , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson The store twin case was stubbed out. For now, implement it only within a serial context, forcing parallel execution to synchronize. It would be possible to implement with a cmpxchg loop, if we care, but the loose alignment requirements (simply no crossing 32-byte boundary) might send us back to the serial context anyway. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 597a37d3ec..e120f2ed0b 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -3254,7 +3254,31 @@ static void gen_st_atomic(DisasContext *ctx, TCGMemO= p memop) tcg_gen_atomic_smin_fetch_tl(discard, EA, src, ctx->mem_idx, memop= ); break; case 24: /* Store twin */ - gen_invalid(ctx); + if (tb_cflags(ctx->base.tb) & CF_PARALLEL) { + /* Restart with exclusive lock. */ + gen_helper_exit_atomic(cpu_env); + ctx->base.is_jmp =3D DISAS_NORETURN; + } else { + TCGv t =3D tcg_temp_new(); + TCGv t2 =3D tcg_temp_new(); + TCGv s =3D tcg_temp_new(); + TCGv s2 =3D tcg_temp_new(); + TCGv ea_plus_s =3D tcg_temp_new(); + + tcg_gen_qemu_ld_tl(t, EA, ctx->mem_idx, memop); + tcg_gen_addi_tl(ea_plus_s, EA, MEMOP_GET_SIZE(memop)); + tcg_gen_qemu_ld_tl(t2, ea_plus_s, ctx->mem_idx, memop); + tcg_gen_movcond_tl(TCG_COND_EQ, s, t, t2, src, t); + tcg_gen_movcond_tl(TCG_COND_EQ, s2, t, t2, src, t2); + tcg_gen_qemu_st_tl(s, EA, ctx->mem_idx, memop); + tcg_gen_qemu_st_tl(s2, ea_plus_s, ctx->mem_idx, memop); + + tcg_temp_free(ea_plus_s); + tcg_temp_free(s2); + tcg_temp_free(s); + tcg_temp_free(t2); + tcg_temp_free(t); + } break; default: /* invoke data storage error handler */ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530599129604168.45644042564925; Mon, 2 Jul 2018 23:25:29 -0700 (PDT) Received: from localhost ([::1]:38090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEkd-000819-P6 for importer@patchew.org; Tue, 03 Jul 2018 02:25:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKZ-0002tZ-6l for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKU-000707-RH for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from ozlabs.org ([203.11.71.1]:60631) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKU-0006x6-5V; Tue, 03 Jul 2018 01:58:22 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMB4n6Tz9sBr; Tue, 3 Jul 2018 15:58:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597494; bh=R3JFOmTGoiKEtvzTZVqZcIkXcRYR7egn46W/BiEKJYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KaSzsVnp1f4UHsKjtbJFP86I8nspRDC1Wh1uJDtCDtSSAtQpPTiYHkBy8HMKxWHB3 q9RTqr/eeNoUpQYrIAlkTpcJUJA+Qs3f3bsFVOMMo1BjTMNNFblyDFxjLuRuabmZKv iE366ov+bycmG9A3QNQC1sjduzGXV4d6ZyJ/yaQo= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:53 +1000 Message-Id: <20180703055804.13449-25-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 24/35] fpu_helper.c: fix setting FPSCR[FI] bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle , qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: John Arbuckle The FPSCR[FI] bit indicates if the last floating point instruction had a re= sult that was rounded. Each consecutive floating point instruction is suppo= se to set this bit to the correct value. What currently happens is this bit= is not set as often as it should be. I have verified that this is the beha= vior of a real PowerPC 950. This patch fixes that problem by deciding to se= t this bit after each floating point instruction. https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-envi= ronments-for-32-e3087633.html Page 63 in table 2-4 is where the description of this bit can be found. Signed-off-by: John Arbuckle Signed-off-by: David Gibson --- target/ppc/fpu_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 7714bfe0f9..8675d931b6 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -274,6 +274,7 @@ static inline void float_inexact_excp(CPUPPCState *env) { CPUState *cs =3D CPU(ppc_env_get_cpu(env)); =20 + env->fpscr |=3D 1 << FPSCR_FI; env->fpscr |=3D 1 << FPSCR_XX; /* Update the floating-point exception summary */ env->fpscr |=3D FP_FX; @@ -533,6 +534,7 @@ static void do_float_check_status(CPUPPCState *env, uin= tptr_t raddr) { CPUState *cs =3D CPU(ppc_env_get_cpu(env)); int status =3D get_float_exception_flags(&env->fp_status); + bool inexact_happened =3D false; =20 if (status & float_flag_divbyzero) { float_zero_divide_excp(env, raddr); @@ -542,6 +544,12 @@ static void do_float_check_status(CPUPPCState *env, ui= ntptr_t raddr) float_underflow_excp(env); } else if (status & float_flag_inexact) { float_inexact_excp(env); + inexact_happened =3D true; + } + + /* if the inexact flag was not set */ + if (inexact_happened =3D=3D false) { + env->fpscr &=3D ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */ } =20 if (cs->exception_index =3D=3D POWERPC_EXCP_PROGRAM && --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153059878718156.62258089843385; Mon, 2 Jul 2018 23:19:47 -0700 (PDT) Received: from localhost ([::1]:38044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEfC-0003DF-An for importer@patchew.org; Tue, 03 Jul 2018 02:19:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKX-0002rN-Er for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKV-00071h-Ma for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:25 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:55841) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKV-0006yE-4j; Tue, 03 Jul 2018 01:58:23 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMC2CdVz9sBj; Tue, 3 Jul 2018 15:58:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597495; bh=Wbs3Jkl+TBF8h/D21iitJfLJVFVC5t4NK6I/mkzkB/I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxtmQaI+2vrrZz1kAVQ7dIK2gh7wJm33HYQp2TaP5QNfBtOfbPLkI39itaXuKkNZr OD5jzgqcjdDFR1BT+sYP+083LaWPWMQOgukumybAW5tHGgyxKI8jU/Izmq/+MJWQF8 ZoTUj4OWkjcjm2APQpCBDfFZRaGMAykZf3gkga2Y= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:54 +1000 Message-Id: <20180703055804.13449-26-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 25/35] hw/ppc: Give sam46ex its own config option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" At present the Sam460ex board is activated by the general CONFIG_PPC4XX option. However that includes the board for both ppc-softmmu and (deprecated) ppcemb-softmmu builds. As Sam460ex is developed, that would require adding more things into ppcemb-softmmu, which we don't want to do. Signed-off-by: David Gibson --- default-configs/ppc-softmmu.mak | 1 + hw/ppc/Makefile.objs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.= mak index 851b4afc21..475120bda2 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -22,6 +22,7 @@ CONFIG_OPENPIC_KVM=3D$(call land,$(CONFIG_E500),$(CONFIG_= KVM)) CONFIG_PLATFORM_BUS=3Dy CONFIG_ETSEC=3Dy # For Sam460ex +CONFIG_SAM460EX=3Dy CONFIG_USB_EHCI_SYSBUS=3Dy CONFIG_SM501=3Dy CONFIG_IDE_SII3112=3Dy diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs index 86d82a6ec3..bcab6323b7 100644 --- a/hw/ppc/Makefile.objs +++ b/hw/ppc/Makefile.objs @@ -14,7 +14,8 @@ obj-$(CONFIG_PSERIES) +=3D spapr_rtas_ddw.o # PowerPC 4xx boards obj-y +=3D ppc4xx_devs.o ppc405_uc.o obj-$(CONFIG_PPC4XX) +=3D ppc4xx_pci.o ppc405_boards.o -obj-$(CONFIG_PPC4XX) +=3D ppc440_bamboo.o ppc440_pcix.o ppc440_uc.o sam460= ex.o +obj-$(CONFIG_PPC4XX) +=3D ppc440_bamboo.o ppc440_pcix.o ppc440_uc.o +obj-$(CONFIG_SAM460EX) +=3D sam460ex.o # PReP obj-$(CONFIG_PREP) +=3D prep.o obj-$(CONFIG_PREP) +=3D prep_systemio.o --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530599285913204.2945105038857; Mon, 2 Jul 2018 23:28:05 -0700 (PDT) Received: from localhost ([::1]:38116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEnF-0002Dn-6K for importer@patchew.org; Tue, 03 Jul 2018 02:28:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39986) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKa-0002wC-Va for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKX-00074E-46 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:28 -0400 Received: from ozlabs.org ([203.11.71.1]:58901) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKW-0006zK-AC; Tue, 03 Jul 2018 01:58:24 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMC5FM1z9sBx; Tue, 3 Jul 2018 15:58:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597495; bh=SanStL4cjuefK88wyH6rEb228QIIllWzaLEyB1ETyuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mk0n9CCMgs+SIeEaX4HHcNKDyF6m+P9QnnEjks20phbj6dttgGrgl9X7lfK3iFWZf 8pxQEI3eIZY5BiV3R067BAd2h56Qai/wOONQFyoeLulgRyiOJjRqLzK7c7xck05SoC bjLuIhxZxeE8YwlxzZDG9DQVHqdC1J2RkHmOLaNc= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:55 +1000 Message-Id: <20180703055804.13449-27-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 26/35] ppc4xx_i2c: Rewrite to model hardware more closely X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Rewrite to make it closer to how real device works so that guest OS drivers can access I2C devices. Previously this was only a hack to allow U-Boot to get past accessing SPD EEPROMs but to support other I2C devices and allow guests to access them we need to model real device more properly. Signed-off-by: BALATON Zoltan Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/i2c/ppc4xx_i2c.c | 299 +++++++++++++++++++----------------- include/hw/i2c/ppc4xx_i2c.h | 3 +- 2 files changed, 159 insertions(+), 143 deletions(-) diff --git a/hw/i2c/ppc4xx_i2c.c b/hw/i2c/ppc4xx_i2c.c index fca80d695a..d6dfafab31 100644 --- a/hw/i2c/ppc4xx_i2c.c +++ b/hw/i2c/ppc4xx_i2c.c @@ -34,16 +34,50 @@ =20 #define PPC4xx_I2C_MEM_SIZE 18 =20 +enum { + IIC_MDBUF =3D 0, + /* IIC_SDBUF =3D 2, */ + IIC_LMADR =3D 4, + IIC_HMADR, + IIC_CNTL, + IIC_MDCNTL, + IIC_STS, + IIC_EXTSTS, + IIC_LSADR, + IIC_HSADR, + IIC_CLKDIV, + IIC_INTRMSK, + IIC_XFRCNT, + IIC_XTCNTLSS, + IIC_DIRECTCNTL + /* IIC_INTR */ +}; + #define IIC_CNTL_PT (1 << 0) #define IIC_CNTL_READ (1 << 1) #define IIC_CNTL_CHT (1 << 2) #define IIC_CNTL_RPST (1 << 3) +#define IIC_CNTL_AMD (1 << 6) +#define IIC_CNTL_HMT (1 << 7) + +#define IIC_MDCNTL_EINT (1 << 2) +#define IIC_MDCNTL_ESM (1 << 3) +#define IIC_MDCNTL_FMDB (1 << 6) =20 #define IIC_STS_PT (1 << 0) +#define IIC_STS_IRQA (1 << 1) #define IIC_STS_ERR (1 << 2) +#define IIC_STS_MDBF (1 << 4) #define IIC_STS_MDBS (1 << 5) =20 #define IIC_EXTSTS_XFRA (1 << 0) +#define IIC_EXTSTS_BCS_FREE (4 << 4) +#define IIC_EXTSTS_BCS_BUSY (5 << 4) + +#define IIC_INTRMSK_EIMTC (1 << 0) +#define IIC_INTRMSK_EITA (1 << 1) +#define IIC_INTRMSK_EIIC (1 << 2) +#define IIC_INTRMSK_EIHE (1 << 3) =20 #define IIC_XTCNTLSS_SRST (1 << 0) =20 @@ -56,130 +90,83 @@ static void ppc4xx_i2c_reset(DeviceState *s) { PPC4xxI2CState *i2c =3D PPC4xx_I2C(s); =20 - /* FIXME: Should also reset bus? - *if (s->address !=3D ADDR_RESET) { - * i2c_end_transfer(s->bus); - *} - */ - - i2c->mdata =3D 0; - i2c->lmadr =3D 0; - i2c->hmadr =3D 0; + i2c->mdidx =3D -1; + memset(i2c->mdata, 0, ARRAY_SIZE(i2c->mdata)); + /* [hl][ms]addr are not affected by reset */ i2c->cntl =3D 0; i2c->mdcntl =3D 0; i2c->sts =3D 0; - i2c->extsts =3D 0x8f; - i2c->lsadr =3D 0; - i2c->hsadr =3D 0; + i2c->extsts =3D IIC_EXTSTS_BCS_FREE; i2c->clkdiv =3D 0; i2c->intrmsk =3D 0; i2c->xfrcnt =3D 0; i2c->xtcntlss =3D 0; - i2c->directcntl =3D 0xf; -} - -static inline bool ppc4xx_i2c_is_master(PPC4xxI2CState *i2c) -{ - return true; + i2c->directcntl =3D 0xf; /* all non-reserved bits set */ } =20 static uint64_t ppc4xx_i2c_readb(void *opaque, hwaddr addr, unsigned int s= ize) { PPC4xxI2CState *i2c =3D PPC4xx_I2C(opaque); uint64_t ret; + int i; =20 switch (addr) { - case 0: - ret =3D i2c->mdata; - if (ppc4xx_i2c_is_master(i2c)) { + case IIC_MDBUF: + if (i2c->mdidx < 0) { ret =3D 0xff; - - if (!(i2c->sts & IIC_STS_MDBS)) { - qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Trying to read " - "without starting transfer\n", - TYPE_PPC4xx_I2C, __func__); - } else { - int pending =3D (i2c->cntl >> 4) & 3; - - /* get the next byte */ - int byte =3D i2c_recv(i2c->bus); - - if (byte < 0) { - qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: read failed " - "for device 0x%02x\n", TYPE_PPC4xx_I2C, - __func__, i2c->lmadr); - ret =3D 0xff; - } else { - ret =3D byte; - /* Raise interrupt if enabled */ - /*ppc4xx_i2c_raise_interrupt(i2c)*/; - } - - if (!pending) { - i2c->sts &=3D ~IIC_STS_MDBS; - /*i2c_end_transfer(i2c->bus);*/ - /*} else if (i2c->cntl & (IIC_CNTL_RPST | IIC_CNTL_CHT)) {= */ - } else if (pending) { - /* current smbus implementation doesn't like - multibyte xfer repeated start */ - i2c_end_transfer(i2c->bus); - if (i2c_start_transfer(i2c->bus, i2c->lmadr >> 1, 1)) { - /* if non zero is returned, the adress is not vali= d */ - i2c->sts &=3D ~IIC_STS_PT; - i2c->sts |=3D IIC_STS_ERR; - i2c->extsts |=3D IIC_EXTSTS_XFRA; - } else { - /*i2c->sts |=3D IIC_STS_PT;*/ - i2c->sts |=3D IIC_STS_MDBS; - i2c->sts &=3D ~IIC_STS_ERR; - i2c->extsts =3D 0; - } - } - pending--; - i2c->cntl =3D (i2c->cntl & 0xcf) | (pending << 4); - } - } else { - qemu_log_mask(LOG_UNIMP, "[%s]%s: slave mode not implemented\n= ", - TYPE_PPC4xx_I2C, __func__); + break; + } + ret =3D i2c->mdata[0]; + if (i2c->mdidx =3D=3D 3) { + i2c->sts &=3D ~IIC_STS_MDBF; + } else if (i2c->mdidx =3D=3D 0) { + i2c->sts &=3D ~IIC_STS_MDBS; + } + for (i =3D 0; i < i2c->mdidx; i++) { + i2c->mdata[i] =3D i2c->mdata[i + 1]; + } + if (i2c->mdidx >=3D 0) { + i2c->mdidx--; } break; - case 4: + case IIC_LMADR: ret =3D i2c->lmadr; break; - case 5: + case IIC_HMADR: ret =3D i2c->hmadr; break; - case 6: + case IIC_CNTL: ret =3D i2c->cntl; break; - case 7: + case IIC_MDCNTL: ret =3D i2c->mdcntl; break; - case 8: + case IIC_STS: ret =3D i2c->sts; break; - case 9: - ret =3D i2c->extsts; + case IIC_EXTSTS: + ret =3D i2c_bus_busy(i2c->bus) ? + IIC_EXTSTS_BCS_BUSY : IIC_EXTSTS_BCS_FREE; break; - case 10: + case IIC_LSADR: ret =3D i2c->lsadr; break; - case 11: + case IIC_HSADR: ret =3D i2c->hsadr; break; - case 12: + case IIC_CLKDIV: ret =3D i2c->clkdiv; break; - case 13: + case IIC_INTRMSK: ret =3D i2c->intrmsk; break; - case 14: + case IIC_XFRCNT: ret =3D i2c->xfrcnt; break; - case 15: + case IIC_XTCNTLSS: ret =3D i2c->xtcntlss; break; - case 16: + case IIC_DIRECTCNTL: ret =3D i2c->directcntl; break; default: @@ -202,99 +189,127 @@ static void ppc4xx_i2c_writeb(void *opaque, hwaddr a= ddr, uint64_t value, PPC4xxI2CState *i2c =3D opaque; =20 switch (addr) { - case 0: - i2c->mdata =3D value; - if (!i2c_bus_busy(i2c->bus)) { - /* assume we start a write transfer */ - if (i2c_start_transfer(i2c->bus, i2c->lmadr >> 1, 0)) { - /* if non zero is returned, the adress is not valid */ - i2c->sts &=3D ~IIC_STS_PT; - i2c->sts |=3D IIC_STS_ERR; - i2c->extsts |=3D IIC_EXTSTS_XFRA; - } else { - i2c->sts |=3D IIC_STS_PT; - i2c->sts &=3D ~IIC_STS_ERR; - i2c->extsts =3D 0; - } + case IIC_MDBUF: + if (i2c->mdidx >=3D 3) { + break; } - if (i2c_bus_busy(i2c->bus)) { - if (i2c_send(i2c->bus, i2c->mdata)) { - /* if the target return non zero then end the transfer */ - i2c->sts &=3D ~IIC_STS_PT; - i2c->sts |=3D IIC_STS_ERR; - i2c->extsts |=3D IIC_EXTSTS_XFRA; - i2c_end_transfer(i2c->bus); - } + i2c->mdata[++i2c->mdidx] =3D value; + if (i2c->mdidx =3D=3D 3) { + i2c->sts |=3D IIC_STS_MDBF; + } else if (i2c->mdidx =3D=3D 0) { + i2c->sts |=3D IIC_STS_MDBS; } break; - case 4: + case IIC_LMADR: i2c->lmadr =3D value; - if (i2c_bus_busy(i2c->bus)) { - i2c_end_transfer(i2c->bus); - } break; - case 5: + case IIC_HMADR: i2c->hmadr =3D value; break; - case 6: - i2c->cntl =3D value; - if (i2c->cntl & IIC_CNTL_PT) { - if (i2c->cntl & IIC_CNTL_READ) { - if (i2c_bus_busy(i2c->bus)) { - /* end previous transfer */ - i2c->sts &=3D ~IIC_STS_PT; - i2c_end_transfer(i2c->bus); + case IIC_CNTL: + i2c->cntl =3D value & ~IIC_CNTL_PT; + if (value & IIC_CNTL_AMD) { + qemu_log_mask(LOG_UNIMP, "%s: only 7 bit addresses supported\n= ", + __func__); + } + if (value & IIC_CNTL_HMT && i2c_bus_busy(i2c->bus)) { + i2c_end_transfer(i2c->bus); + if (i2c->mdcntl & IIC_MDCNTL_EINT && + i2c->intrmsk & IIC_INTRMSK_EIHE) { + i2c->sts |=3D IIC_STS_IRQA; + qemu_irq_raise(i2c->irq); + } + } else if (value & IIC_CNTL_PT) { + int recv =3D (value & IIC_CNTL_READ) >> 1; + int tct =3D value >> 4 & 3; + int i; + + if (recv && (i2c->lmadr >> 1) >=3D 0x50 && (i2c->lmadr >> 1) <= 0x58) { + /* smbus emulation does not like multi byte reads w/o rest= art */ + value |=3D IIC_CNTL_RPST; + } + + for (i =3D 0; i <=3D tct; i++) { + if (!i2c_bus_busy(i2c->bus)) { + i2c->extsts =3D IIC_EXTSTS_BCS_FREE; + if (i2c_start_transfer(i2c->bus, i2c->lmadr >> 1, recv= )) { + i2c->sts |=3D IIC_STS_ERR; + i2c->extsts |=3D IIC_EXTSTS_XFRA; + break; + } else { + i2c->sts &=3D ~IIC_STS_ERR; + } } - if (i2c_start_transfer(i2c->bus, i2c->lmadr >> 1, 1)) { - /* if non zero is returned, the adress is not valid */ - i2c->sts &=3D ~IIC_STS_PT; + if (!(i2c->sts & IIC_STS_ERR) && + i2c_send_recv(i2c->bus, &i2c->mdata[i], !recv)) { i2c->sts |=3D IIC_STS_ERR; i2c->extsts |=3D IIC_EXTSTS_XFRA; - } else { - /*i2c->sts |=3D IIC_STS_PT;*/ - i2c->sts |=3D IIC_STS_MDBS; - i2c->sts &=3D ~IIC_STS_ERR; - i2c->extsts =3D 0; + break; + } + if (value & IIC_CNTL_RPST || !(value & IIC_CNTL_CHT)) { + i2c_end_transfer(i2c->bus); } - } else { - /* we actually already did the write transfer... */ - i2c->sts &=3D ~IIC_STS_PT; + } + i2c->xfrcnt =3D i; + i2c->mdidx =3D i - 1; + if (recv && i2c->mdidx >=3D 0) { + i2c->sts |=3D IIC_STS_MDBS; + } + if (recv && i2c->mdidx =3D=3D 3) { + i2c->sts |=3D IIC_STS_MDBF; + } + if (i && i2c->mdcntl & IIC_MDCNTL_EINT && + i2c->intrmsk & IIC_INTRMSK_EIMTC) { + i2c->sts |=3D IIC_STS_IRQA; + qemu_irq_raise(i2c->irq); } } break; - case 7: - i2c->mdcntl =3D value & 0xdf; + case IIC_MDCNTL: + i2c->mdcntl =3D value & 0x3d; + if (value & IIC_MDCNTL_ESM) { + qemu_log_mask(LOG_UNIMP, "%s: slave mode not implemented\n", + __func__); + } + if (value & IIC_MDCNTL_FMDB) { + i2c->mdidx =3D -1; + memset(i2c->mdata, 0, ARRAY_SIZE(i2c->mdata)); + i2c->sts &=3D ~(IIC_STS_MDBF | IIC_STS_MDBS); + } break; - case 8: - i2c->sts &=3D ~(value & 0xa); + case IIC_STS: + i2c->sts &=3D ~(value & 0x0a); + if (value & IIC_STS_IRQA && i2c->mdcntl & IIC_MDCNTL_EINT) { + qemu_irq_lower(i2c->irq); + } break; - case 9: + case IIC_EXTSTS: i2c->extsts &=3D ~(value & 0x8f); break; - case 10: + case IIC_LSADR: i2c->lsadr =3D value; break; - case 11: + case IIC_HSADR: i2c->hsadr =3D value; break; - case 12: + case IIC_CLKDIV: i2c->clkdiv =3D value; break; - case 13: + case IIC_INTRMSK: i2c->intrmsk =3D value; break; - case 14: + case IIC_XFRCNT: i2c->xfrcnt =3D value & 0x77; break; - case 15: + case IIC_XTCNTLSS: + i2c->xtcntlss &=3D ~(value & 0xf0); if (value & IIC_XTCNTLSS_SRST) { /* Is it actually a full reset? U-Boot sets some regs before */ ppc4xx_i2c_reset(DEVICE(i2c)); break; } - i2c->xtcntlss =3D value; break; - case 16: + case IIC_DIRECTCNTL: i2c->directcntl =3D value & (IIC_DIRECTCNTL_SDAC & IIC_DIRECTCNTL_= SCLC); i2c->directcntl |=3D (value & IIC_DIRECTCNTL_SCLC ? 1 : 0); bitbang_i2c_set(i2c->bitbang, BITBANG_I2C_SCL, diff --git a/include/hw/i2c/ppc4xx_i2c.h b/include/hw/i2c/ppc4xx_i2c.h index ea6c8e1a58..0891a9c948 100644 --- a/include/hw/i2c/ppc4xx_i2c.h +++ b/include/hw/i2c/ppc4xx_i2c.h @@ -46,7 +46,8 @@ typedef struct PPC4xxI2CState { qemu_irq irq; MemoryRegion iomem; bitbang_i2c_interface *bitbang; - uint8_t mdata; + int mdidx; + uint8_t mdata[4]; uint8_t lmadr; uint8_t hmadr; uint8_t cntl; --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598247007156.06877049745924; Mon, 2 Jul 2018 23:10:47 -0700 (PDT) Received: from localhost ([::1]:37996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEWU-00044t-8z for importer@patchew.org; Tue, 03 Jul 2018 02:10:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKY-0002sv-HE for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKW-00072f-7X for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:26 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:35507) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKV-0006yO-CA; Tue, 03 Jul 2018 01:58:24 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMC32slz9sBt; Tue, 3 Jul 2018 15:58:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597495; bh=nith9nKuXdbyko6bChCbi3C3URiTtG0WAv5vsboNjHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cnvuah31JERQ+29S+Ng5SdL+Stuc4kTKQKT8qlUUf3TaoKRbqfDTpbLYaWO0j24rG 1iMCwcv1B9Nhtb+d1X9FyCBeiJ1ucq87r0KlQ2N3SevG/dZZEyfjTJKbfDeuOoXsCk /gFW0OXQKpZQnT4ZH5RWPKYMQDVke2wqjKbAnNv8= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:56 +1000 Message-Id: <20180703055804.13449-28-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 27/35] hw/timer: Add basic M41T80 emulation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Basic emulation of the M41T80 serial (I2C) RTC chip. Only getting time of day is implemented. Setting time and RTC alarm are not supported. Signed-off-by: BALATON Zoltan Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- MAINTAINERS | 1 + default-configs/ppc-softmmu.mak | 1 + hw/timer/Makefile.objs | 1 + hw/timer/m41t80.c | 117 ++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 hw/timer/m41t80.c diff --git a/MAINTAINERS b/MAINTAINERS index 42a1892d6a..6630d691d1 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -851,6 +851,7 @@ M: BALATON Zoltan L: qemu-ppc@nongnu.org S: Maintained F: hw/ide/sii3112.c +F: hw/timer/m41t80.c =20 SH4 Machines ------------ diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.= mak index 475120bda2..7e1a3d8135 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -28,6 +28,7 @@ CONFIG_SM501=3Dy CONFIG_IDE_SII3112=3Dy CONFIG_I2C=3Dy CONFIG_BITBANG_I2C=3Dy +CONFIG_M41T80=3Dy =20 # For Macs CONFIG_MAC=3Dy diff --git a/hw/timer/Makefile.objs b/hw/timer/Makefile.objs index 8b27a4b7ef..e16b2b913c 100644 --- a/hw/timer/Makefile.objs +++ b/hw/timer/Makefile.objs @@ -6,6 +6,7 @@ common-obj-$(CONFIG_CADENCE) +=3D cadence_ttc.o common-obj-$(CONFIG_DS1338) +=3D ds1338.o common-obj-$(CONFIG_HPET) +=3D hpet.o common-obj-$(CONFIG_I8254) +=3D i8254_common.o i8254.o +common-obj-$(CONFIG_M41T80) +=3D m41t80.o common-obj-$(CONFIG_M48T59) +=3D m48t59.o ifeq ($(CONFIG_ISA_BUS),y) common-obj-$(CONFIG_M48T59) +=3D m48t59-isa.o diff --git a/hw/timer/m41t80.c b/hw/timer/m41t80.c new file mode 100644 index 0000000000..734d7d95fc --- /dev/null +++ b/hw/timer/m41t80.c @@ -0,0 +1,117 @@ +/* + * M41T80 serial rtc emulation + * + * Copyright (c) 2018 BALATON Zoltan + * + * This work is licensed under the GNU GPL license version 2 or later. + * + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/timer.h" +#include "qemu/bcd.h" +#include "hw/i2c/i2c.h" + +#define TYPE_M41T80 "m41t80" +#define M41T80(obj) OBJECT_CHECK(M41t80State, (obj), TYPE_M41T80) + +typedef struct M41t80State { + I2CSlave parent_obj; + int8_t addr; +} M41t80State; + +static void m41t80_realize(DeviceState *dev, Error **errp) +{ + M41t80State *s =3D M41T80(dev); + + s->addr =3D -1; +} + +static int m41t80_send(I2CSlave *i2c, uint8_t data) +{ + M41t80State *s =3D M41T80(i2c); + + if (s->addr < 0) { + s->addr =3D data; + } else { + s->addr++; + } + return 0; +} + +static int m41t80_recv(I2CSlave *i2c) +{ + M41t80State *s =3D M41T80(i2c); + struct tm now; + qemu_timeval tv; + + if (s->addr < 0) { + s->addr =3D 0; + } + if (s->addr >=3D 1 && s->addr <=3D 7) { + qemu_get_timedate(&now, -1); + } + switch (s->addr++) { + case 0: + qemu_gettimeofday(&tv); + return to_bcd(tv.tv_usec / 10000); + case 1: + return to_bcd(now.tm_sec); + case 2: + return to_bcd(now.tm_min); + case 3: + return to_bcd(now.tm_hour); + case 4: + return to_bcd(now.tm_wday); + case 5: + return to_bcd(now.tm_mday); + case 6: + return to_bcd(now.tm_mon + 1); + case 7: + return to_bcd(now.tm_year % 100); + case 8 ... 19: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented register: %d\n", + __func__, s->addr - 1); + return 0; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid register: %d\n", + __func__, s->addr - 1); + return 0; + } +} + +static int m41t80_event(I2CSlave *i2c, enum i2c_event event) +{ + M41t80State *s =3D M41T80(i2c); + + if (event =3D=3D I2C_START_SEND) { + s->addr =3D -1; + } + return 0; +} + +static void m41t80_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + I2CSlaveClass *sc =3D I2C_SLAVE_CLASS(klass); + + dc->realize =3D m41t80_realize; + sc->send =3D m41t80_send; + sc->recv =3D m41t80_recv; + sc->event =3D m41t80_event; +} + +static const TypeInfo m41t80_info =3D { + .name =3D TYPE_M41T80, + .parent =3D TYPE_I2C_SLAVE, + .instance_size =3D sizeof(M41t80State), + .class_init =3D m41t80_class_init, +}; + +static void m41t80_register_types(void) +{ + type_register_static(&m41t80_info); +} + +type_init(m41t80_register_types) --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530599140280397.0645507769282; Mon, 2 Jul 2018 23:25:40 -0700 (PDT) Received: from localhost ([::1]:38091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEkl-00088v-CU for importer@patchew.org; Tue, 03 Jul 2018 02:25:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKb-0002ww-H7 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKZ-00078o-MD for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:29 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:52689) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKZ-00073N-7e; Tue, 03 Jul 2018 01:58:27 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMD5X3fz9sCF; Tue, 3 Jul 2018 15:58:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597496; bh=zvZc5rKax/YD/ZnOnmUUUb0vWzCpITpkT6c0MXXFQBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i8x2KGfcmE0CE3z/Yp46cjCYzJTCKZDdXY/zBik+1gc2yaTAwv7ORwRfrog7qdsbf AJFIa1NVi0I3htb6mLz1Q4QFE3rjc+50mCUmtKmuNl5Fq77SGbn/l9Z3A6oxaLxEEj HEifU5n4iYuQKzN9Ov29mFiMQRUzrETLavsuSnLk= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:57 +1000 Message-Id: <20180703055804.13449-29-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 28/35] sam460ex: Add RTC device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan The Sam460ex has an M41T80 serial RTC chip on I2C bus 0 at address 0x68. Signed-off-by: BALATON Zoltan Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/ppc/sam460ex.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 33ea51816c..a03d12d1dc 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -485,6 +485,7 @@ static void sam460ex_init(MachineState *machine) object_property_set_bool(OBJECT(dev), true, "realized", NULL); smbus_eeprom_init(i2c[0]->bus, 8, smbus_eeprom_buf, smbus_eeprom_size); g_free(smbus_eeprom_buf); + i2c_create_slave(i2c[0]->bus, "m41t80", 0x68); =20 dev =3D sysbus_create_simple(TYPE_PPC4xx_I2C, 0x4ef600800, uic[0][3]); i2c[1] =3D PPC4xx_I2C(dev); --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530599394125923.444537790878; Mon, 2 Jul 2018 23:29:54 -0700 (PDT) Received: from localhost ([::1]:38130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEoz-0003cP-Cj for importer@patchew.org; Tue, 03 Jul 2018 02:29:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKc-0002xx-2t for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKY-00076x-Jz for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:30 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:52265) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKX-000712-RJ; Tue, 03 Jul 2018 01:58:26 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMD15rKz9sCJ; Tue, 3 Jul 2018 15:58:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597496; bh=WTI7rZH2s3nixEqIQC0v0kGjQwjCVazLV7BKjI5+XFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+qTpMLAWlECzMdiPi9gkw78HeVJD1iZH1kep6KtuZITUlHRbTcWswtzsjWtDzvQC HsKYo3Zpudak07GGvI/GdQj6WJyA2JNSTKuK6E4gzyvB1fMaeQ7J/AE7VlK3nP0h+m kLX0C88BFcL9MOzqQtqTqarTyymrfQDIRWPdgO8s= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:58 +1000 Message-Id: <20180703055804.13449-30-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 29/35] ppc440_uc: Basic emulation of PPC440 DMA controller X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan PPC440 SoCs such as the AMCC 460EX have a DMA controller which is used by AmigaOS on the sam460ex. Implement the parts used by AmigaOS so it can get further booting on the sam460ex machine. Signed-off-by: BALATON Zoltan Signed-off-by: David Gibson --- hw/ppc/ppc440.h | 1 + hw/ppc/ppc440_uc.c | 222 +++++++++++++++++++++++++++++++++++++++++++++ hw/ppc/sam460ex.c | 3 + 3 files changed, 226 insertions(+) diff --git a/hw/ppc/ppc440.h b/hw/ppc/ppc440.h index ad27db12e4..7cef936125 100644 --- a/hw/ppc/ppc440.h +++ b/hw/ppc/ppc440.h @@ -21,6 +21,7 @@ void ppc440_sdram_init(CPUPPCState *env, int nbanks, hwaddr *ram_bases, hwaddr *ram_sizes, int do_init); void ppc4xx_ahb_init(CPUPPCState *env); +void ppc4xx_dma_init(CPUPPCState *env, int dcr_base); void ppc460ex_pcie_init(CPUPPCState *env); =20 #endif /* PPC440_H */ diff --git a/hw/ppc/ppc440_uc.c b/hw/ppc/ppc440_uc.c index 123f4ac09d..32802d741b 100644 --- a/hw/ppc/ppc440_uc.c +++ b/hw/ppc/ppc440_uc.c @@ -13,6 +13,7 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qemu/log.h" #include "cpu.h" #include "hw/hw.h" #include "exec/address-spaces.h" @@ -802,6 +803,227 @@ void ppc4xx_ahb_init(CPUPPCState *env) qemu_register_reset(ppc4xx_ahb_reset, ahb); } =20 +/*************************************************************************= ****/ +/* DMA controller */ + +#define DMA0_CR_CE (1 << 31) +#define DMA0_CR_PW (1 << 26 | 1 << 25) +#define DMA0_CR_DAI (1 << 24) +#define DMA0_CR_SAI (1 << 23) +#define DMA0_CR_DEC (1 << 2) + +enum { + DMA0_CR =3D 0x00, + DMA0_CT, + DMA0_SAH, + DMA0_SAL, + DMA0_DAH, + DMA0_DAL, + DMA0_SGH, + DMA0_SGL, + + DMA0_SR =3D 0x20, + DMA0_SGC =3D 0x23, + DMA0_SLP =3D 0x25, + DMA0_POL =3D 0x26, +}; + +typedef struct { + uint32_t cr; + uint32_t ct; + uint64_t sa; + uint64_t da; + uint64_t sg; +} PPC4xxDmaChnl; + +typedef struct { + int base; + PPC4xxDmaChnl ch[4]; + uint32_t sr; +} PPC4xxDmaState; + +static uint32_t dcr_read_dma(void *opaque, int dcrn) +{ + PPC4xxDmaState *dma =3D opaque; + uint32_t val =3D 0; + int addr =3D dcrn - dma->base; + int chnl =3D addr / 8; + + switch (addr) { + case 0x00 ... 0x1f: + switch (addr % 8) { + case DMA0_CR: + val =3D dma->ch[chnl].cr; + break; + case DMA0_CT: + val =3D dma->ch[chnl].ct; + break; + case DMA0_SAH: + val =3D dma->ch[chnl].sa >> 32; + break; + case DMA0_SAL: + val =3D dma->ch[chnl].sa; + break; + case DMA0_DAH: + val =3D dma->ch[chnl].da >> 32; + break; + case DMA0_DAL: + val =3D dma->ch[chnl].da; + break; + case DMA0_SGH: + val =3D dma->ch[chnl].sg >> 32; + break; + case DMA0_SGL: + val =3D dma->ch[chnl].sg; + break; + } + break; + case DMA0_SR: + val =3D dma->sr; + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented register %x (%d, %x)\n= ", + __func__, dcrn, chnl, addr); + } + + return val; +} + +static void dcr_write_dma(void *opaque, int dcrn, uint32_t val) +{ + PPC4xxDmaState *dma =3D opaque; + int addr =3D dcrn - dma->base; + int chnl =3D addr / 8; + + switch (addr) { + case 0x00 ... 0x1f: + switch (addr % 8) { + case DMA0_CR: + dma->ch[chnl].cr =3D val; + if (val & DMA0_CR_CE) { + int count =3D dma->ch[chnl].ct & 0xffff; + + if (count) { + int width, i, sidx, didx; + uint8_t *rptr, *wptr; + hwaddr rlen, wlen; + + sidx =3D didx =3D 0; + width =3D 1 << ((val & DMA0_CR_PW) >> 25); + rptr =3D cpu_physical_memory_map(dma->ch[chnl].sa, &rl= en, 0); + wptr =3D cpu_physical_memory_map(dma->ch[chnl].da, &wl= en, 1); + if (rptr && wptr) { + if (!(val & DMA0_CR_DEC) && + val & DMA0_CR_SAI && val & DMA0_CR_DAI) { + /* optimise common case */ + memmove(wptr, rptr, count * width); + sidx =3D didx =3D count * width; + } else { + /* do it the slow way */ + for (sidx =3D didx =3D i =3D 0; i < count; i++= ) { + uint64_t v =3D ldn_le_p(rptr + sidx, width= ); + stn_le_p(wptr + didx, width, v); + if (val & DMA0_CR_SAI) { + sidx +=3D width; + } + if (val & DMA0_CR_DAI) { + didx +=3D width; + } + } + } + } + if (wptr) { + cpu_physical_memory_unmap(wptr, wlen, 1, didx); + } + if (wptr) { + cpu_physical_memory_unmap(rptr, rlen, 0, sidx); + } + } + } + break; + case DMA0_CT: + dma->ch[chnl].ct =3D val; + break; + case DMA0_SAH: + dma->ch[chnl].sa &=3D 0xffffffffULL; + dma->ch[chnl].sa |=3D (uint64_t)val << 32; + break; + case DMA0_SAL: + dma->ch[chnl].sa &=3D 0xffffffff00000000ULL; + dma->ch[chnl].sa |=3D val; + break; + case DMA0_DAH: + dma->ch[chnl].da &=3D 0xffffffffULL; + dma->ch[chnl].da |=3D (uint64_t)val << 32; + break; + case DMA0_DAL: + dma->ch[chnl].da &=3D 0xffffffff00000000ULL; + dma->ch[chnl].da |=3D val; + break; + case DMA0_SGH: + dma->ch[chnl].sg &=3D 0xffffffffULL; + dma->ch[chnl].sg |=3D (uint64_t)val << 32; + break; + case DMA0_SGL: + dma->ch[chnl].sg &=3D 0xffffffff00000000ULL; + dma->ch[chnl].sg |=3D val; + break; + } + break; + case DMA0_SR: + dma->sr &=3D ~val; + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: unimplemented register %x (%d, %x)\n= ", + __func__, dcrn, chnl, addr); + } +} + +static void ppc4xx_dma_reset(void *opaque) +{ + PPC4xxDmaState *dma =3D opaque; + int dma_base =3D dma->base; + + memset(dma, 0, sizeof(*dma)); + dma->base =3D dma_base; +} + +void ppc4xx_dma_init(CPUPPCState *env, int dcr_base) +{ + PPC4xxDmaState *dma; + int i; + + dma =3D g_malloc0(sizeof(*dma)); + dma->base =3D dcr_base; + qemu_register_reset(&ppc4xx_dma_reset, dma); + for (i =3D 0; i < 4; i++) { + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_CR, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_CT, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_SAH, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_SAL, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_DAH, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_DAL, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_SGH, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + i * 8 + DMA0_SGL, + dma, &dcr_read_dma, &dcr_write_dma); + } + ppc_dcr_register(env, dcr_base + DMA0_SR, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + DMA0_SGC, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + DMA0_SLP, + dma, &dcr_read_dma, &dcr_write_dma); + ppc_dcr_register(env, dcr_base + DMA0_POL, + dma, &dcr_read_dma, &dcr_write_dma); +} + /*************************************************************************= ****/ /* PCI Express controller */ /* FIXME: This is not complete and does not work, only implemented partial= ly diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index a03d12d1dc..80c888c3ef 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -505,6 +505,9 @@ static void sam460ex_init(MachineState *machine) /* MAL */ ppc4xx_mal_init(env, 4, 16, &uic[2][3]); =20 + /* DMA */ + ppc4xx_dma_init(env, 0x200); + /* 256K of L2 cache as memory */ ppc4xx_l2sram_init(env); /* FIXME: remove this after fixing l2sram mapping in ppc440_uc.c? */ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598983807352.01419620890977; Mon, 2 Jul 2018 23:23:03 -0700 (PDT) Received: from localhost ([::1]:38074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEiN-0005u1-0s for importer@patchew.org; Tue, 03 Jul 2018 02:23:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40168) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKf-00032T-G5 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKa-0007A8-BQ for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:33 -0400 Received: from ozlabs.org ([203.11.71.1]:54741) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKZ-00074u-Fv; Tue, 03 Jul 2018 01:58:28 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMD6ldMz9sC3; Tue, 3 Jul 2018 15:58:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597496; bh=v5NN2gbLXuPij3ieoipV27WuA7ERCrEMrSVgDnu/wnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mklAmQcmsGt5QHvnoXgyu2fg5/XgfrqxDQ/9KAfIuZyaYiXm6SEnsbudbPGH+F3ke Vm9GWHpA4C+kOelHh63dYgKYG/3Yet6bpa+d7QtB1Y+xKpf+BHSh93WwWTuu7wG00z jBatr3nO1xuYhzMitmXMEEsqlHj/AR7tN6rAUHYo= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:57:59 +1000 Message-Id: <20180703055804.13449-31-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 30/35] target/ppc/kvm: get rid of kvm_get_fallback_smmu_info() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz Now that we're checking our MMU configuration is supported by KVM, rather than adjusting it to KVM, it doesn't really make sense to have a fallback for kvm_get_smmu_info(). If KVM is too old or buggy to provide the details, we should rather treat this as an error. This patch thus adds error reporting to kvm_get_smmu_info() and get rid of the fallback code. QEMU will now terminate if KVM fails to provide MMU details. This may break some very old setups, but the simplification is worth the sacrifice. Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- target/ppc/kvm.c | 117 ++++++++--------------------------------------- 1 file changed, 20 insertions(+), 97 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 4df4ff6cbf..b6000f12b9 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -248,107 +248,25 @@ static int kvm_booke206_tlb_init(PowerPCCPU *cpu) =20 =20 #if defined(TARGET_PPC64) -static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, - struct kvm_ppc_smmu_info *info) +static void kvm_get_smmu_info(PowerPCCPU *cpu, struct kvm_ppc_smmu_info *i= nfo, + Error **errp) { - CPUPPCState *env =3D &cpu->env; CPUState *cs =3D CPU(cpu); + int ret; =20 - memset(info, 0, sizeof(*info)); - - /* We don't have the new KVM_PPC_GET_SMMU_INFO ioctl, so - * need to "guess" what the supported page sizes are. - * - * For that to work we make a few assumptions: - * - * - Check whether we are running "PR" KVM which only supports 4K - * and 16M pages, but supports them regardless of the backing - * store characteritics. We also don't support 1T segments. - * - * This is safe as if HV KVM ever supports that capability or PR - * KVM grows supports for more page/segment sizes, those versions - * will have implemented KVM_CAP_PPC_GET_SMMU_INFO and thus we - * will not hit this fallback - * - * - Else we are running HV KVM. This means we only support page - * sizes that fit in the backing store. Additionally we only - * advertize 64K pages if the processor is ARCH 2.06 and we assume - * P7 encodings for the SLB and hash table. Here too, we assume - * support for any newer processor will mean a kernel that - * implements KVM_CAP_PPC_GET_SMMU_INFO and thus doesn't hit - * this fallback. - */ - if (kvmppc_is_pr(cs->kvm_state)) { - /* No flags */ - info->flags =3D 0; - info->slb_size =3D 64; - - /* Standard 4k base page size segment */ - info->sps[0].page_shift =3D 12; - info->sps[0].slb_enc =3D 0; - info->sps[0].enc[0].page_shift =3D 12; - info->sps[0].enc[0].pte_enc =3D 0; - - /* Standard 16M large page size segment */ - info->sps[1].page_shift =3D 24; - info->sps[1].slb_enc =3D SLB_VSID_L; - info->sps[1].enc[0].page_shift =3D 24; - info->sps[1].enc[0].pte_enc =3D 0; - } else { - int i =3D 0; - - /* HV KVM has backing store size restrictions */ - info->flags =3D KVM_PPC_PAGE_SIZES_REAL; - - if (ppc_hash64_has(cpu, PPC_HASH64_1TSEG)) { - info->flags |=3D KVM_PPC_1T_SEGMENTS; - } - - if (env->mmu_model =3D=3D POWERPC_MMU_2_06 || - env->mmu_model =3D=3D POWERPC_MMU_2_07) { - info->slb_size =3D 32; - } else { - info->slb_size =3D 64; - } - - /* Standard 4k base page size segment */ - info->sps[i].page_shift =3D 12; - info->sps[i].slb_enc =3D 0; - info->sps[i].enc[0].page_shift =3D 12; - info->sps[i].enc[0].pte_enc =3D 0; - i++; - - /* 64K on MMU 2.06 and later */ - if (env->mmu_model =3D=3D POWERPC_MMU_2_06 || - env->mmu_model =3D=3D POWERPC_MMU_2_07) { - info->sps[i].page_shift =3D 16; - info->sps[i].slb_enc =3D 0x110; - info->sps[i].enc[0].page_shift =3D 16; - info->sps[i].enc[0].pte_enc =3D 1; - i++; - } - - /* Standard 16M large page size segment */ - info->sps[i].page_shift =3D 24; - info->sps[i].slb_enc =3D SLB_VSID_L; - info->sps[i].enc[0].page_shift =3D 24; - info->sps[i].enc[0].pte_enc =3D 0; + if (!kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { + error_setg(errp, "KVM doesn't expose the MMU features it supports"= ); + error_append_hint(errp, "Consider switching to a newer KVM\n"); + return; } -} - -static void kvm_get_smmu_info(PowerPCCPU *cpu, struct kvm_ppc_smmu_info *i= nfo) -{ - CPUState *cs =3D CPU(cpu); - int ret; =20 - if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { - ret =3D kvm_vm_ioctl(cs->kvm_state, KVM_PPC_GET_SMMU_INFO, info); - if (ret =3D=3D 0) { - return; - } + ret =3D kvm_vm_ioctl(cs->kvm_state, KVM_PPC_GET_SMMU_INFO, info); + if (ret =3D=3D 0) { + return; } =20 - kvm_get_fallback_smmu_info(cpu, info); + error_setg_errno(errp, -ret, + "KVM failed to provide the MMU features it supports"); } =20 struct ppc_radix_page_info *kvm_get_radix_page_info(void) @@ -415,7 +333,7 @@ bool kvmppc_hpt_needs_host_contiguous_pages(void) return false; } =20 - kvm_get_smmu_info(cpu, &smmu_info); + kvm_get_smmu_info(cpu, &smmu_info, &error_fatal); return !!(smmu_info.flags & KVM_PPC_PAGE_SIZES_REAL); } =20 @@ -423,13 +341,18 @@ void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) { struct kvm_ppc_smmu_info smmu_info; int iq, ik, jq, jk; + Error *local_err =3D NULL; =20 /* For now, we only have anything to check on hash64 MMUs */ if (!cpu->hash64_opts || !kvm_enabled()) { return; } =20 - kvm_get_smmu_info(cpu, &smmu_info); + kvm_get_smmu_info(cpu, &smmu_info, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } =20 if (ppc_hash64_has(cpu, PPC_HASH64_1TSEG) && !(smmu_info.flags & KVM_PPC_1T_SEGMENTS)) { @@ -2168,7 +2091,7 @@ uint64_t kvmppc_rma_size(uint64_t current_size, unsig= ned int hash_shift) =20 /* Find the largest hardware supported page size that's less than * or equal to the (logical) backing page size of guest RAM */ - kvm_get_smmu_info(POWERPC_CPU(first_cpu), &info); + kvm_get_smmu_info(POWERPC_CPU(first_cpu), &info, &error_fatal); rampagesize =3D qemu_getrampagesize(); best_page_shift =3D 0; =20 --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598756153585.8986852577887; Mon, 2 Jul 2018 23:19:16 -0700 (PDT) Received: from localhost ([::1]:38043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEeg-0002nJ-Jo for importer@patchew.org; Tue, 03 Jul 2018 02:19:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKb-0002xh-Tg for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKZ-00077Z-15 for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:29 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:48813) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKY-00072n-GD; Tue, 03 Jul 2018 01:58:26 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMD4FtWz9sCL; Tue, 3 Jul 2018 15:58:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597496; bh=boZmdavtZD3aZg9vJjGzx4qBUzbn5duBMrsj5NJAGZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBny5P/W+0HK75vD5d0/0IBPDOONPsxKlCuBtQseezLWVaw3SIYES/c+DBEQ4k2/Y 8Z2RRoG4qbvwAbt3qyOyhEiaiDLCvu56MVOjb9lO8HhVLW/XI+1rk2WXVnjjkYlvuj NdKkWHLCUCZiNWQcGSQob4/WzMyQMPZXdcosKyKE= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:58:00 +1000 Message-Id: <20180703055804.13449-32-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 31/35] target/ppc/kvm: don't pass cpu to kvm_get_smmu_info() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz In a future patch the machine code will need to retrieve the MMU information from KVM during machine initialization before the CPUs are created. Actually, KVM_PPC_GET_SMMU_INFO is a VM class ioctl, and thus, we don't need to have a CPU object around. We just need for KVM to be initialized and use the kvm_state global. This patch just does that. Signed-off-by: Greg Kurz Signed-off-by: David Gibson --- target/ppc/kvm.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index b6000f12b9..9211ee2ee1 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -248,19 +248,19 @@ static int kvm_booke206_tlb_init(PowerPCCPU *cpu) =20 =20 #if defined(TARGET_PPC64) -static void kvm_get_smmu_info(PowerPCCPU *cpu, struct kvm_ppc_smmu_info *i= nfo, - Error **errp) +static void kvm_get_smmu_info(struct kvm_ppc_smmu_info *info, Error **errp) { - CPUState *cs =3D CPU(cpu); int ret; =20 - if (!kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { + assert(kvm_state !=3D NULL); + + if (!kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { error_setg(errp, "KVM doesn't expose the MMU features it supports"= ); error_append_hint(errp, "Consider switching to a newer KVM\n"); return; } =20 - ret =3D kvm_vm_ioctl(cs->kvm_state, KVM_PPC_GET_SMMU_INFO, info); + ret =3D kvm_vm_ioctl(kvm_state, KVM_PPC_GET_SMMU_INFO, info); if (ret =3D=3D 0) { return; } @@ -326,14 +326,13 @@ target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, =20 bool kvmppc_hpt_needs_host_contiguous_pages(void) { - PowerPCCPU *cpu =3D POWERPC_CPU(first_cpu); static struct kvm_ppc_smmu_info smmu_info; =20 if (!kvm_enabled()) { return false; } =20 - kvm_get_smmu_info(cpu, &smmu_info, &error_fatal); + kvm_get_smmu_info(&smmu_info, &error_fatal); return !!(smmu_info.flags & KVM_PPC_PAGE_SIZES_REAL); } =20 @@ -348,7 +347,7 @@ void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) return; } =20 - kvm_get_smmu_info(cpu, &smmu_info, &local_err); + kvm_get_smmu_info(&smmu_info, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -2091,7 +2090,7 @@ uint64_t kvmppc_rma_size(uint64_t current_size, unsig= ned int hash_shift) =20 /* Find the largest hardware supported page size that's less than * or equal to the (logical) backing page size of guest RAM */ - kvm_get_smmu_info(POWERPC_CPU(first_cpu), &info, &error_fatal); + kvm_get_smmu_info(&info, &error_fatal); rampagesize =3D qemu_getrampagesize(); best_page_shift =3D 0; =20 --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598621823333.16589459538807; Mon, 2 Jul 2018 23:17:01 -0700 (PDT) Received: from localhost ([::1]:38033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEcX-0001As-47 for importer@patchew.org; Tue, 03 Jul 2018 02:17:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKZ-0002tq-8U for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKX-00074V-8m for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:27 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:45301) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKW-0006zW-FJ; Tue, 03 Jul 2018 01:58:25 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMC5v9wz9sBv; Tue, 3 Jul 2018 15:58:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597495; bh=kuimQuFCvCqpTQzqklxWS5psJ8vIds8YGAfMgmDXhME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MtyUBpTI9Ie721C/ydr/9rXg1EG1cifAKUJJhSuVAQ/srEuuVwmEJ3nuUBsEACpl7 W6rX2l4ZgsY4AcOXoSRDsCGo7KGx3BIgy6//WbNl5T4VVVhCg0vjZB69c5ROXUxlzl JItnKu8MYg7PrDWY6Mq0Pk6CkeWuKcIGUdTyoUE0= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:58:01 +1000 Message-Id: <20180703055804.13449-33-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 32/35] spapr: compute default value of "hpt-max-page-size" later X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz It is currently not possible to run a pseries-2.12 or older machine with HV KVM. QEMU prints the following and exits right away. qemu-system-ppc64: KVM doesn't support for base page shift 34 The "hpt-max-page-size" capability was recently added to spapr to hide host configuration details from HPT mode guests. Its default value for newer machine types is 64k. For backwards compatibility, pseries-2.12 and older machine types need a different value. This is handled as usual in a class init function. The default value is 16G, ie, all page sizes supported by POWER7 and newer CPUs, but HV KVM requires guest pages to be hpa contiguous as well as gpa contiguous. The default value is the page size used to back the guest RAM in this case. Unfortunately kvmppc_hpt_needs_host_contiguous_pages()->kvm_enabled() is called way before KVM init and returns false, even if the user requested KVM. We thus end up selecting 16G, which isn't supported by HV KVM. The default value must be set during machine init, because we can safely assume that KVM is initialized at this point. We fix this by moving the logic to default_caps_with_cpu(). Since the user cannot pass cap-hpt-max-page-size=3D0, we set the default to 0 in the pseries-2.12 class init function and use that as a flag to do the real work. Signed-off-by: Greg Kurz Reviewed-by: Eduardo Habkost Signed-off-by: David Gibson --- hw/ppc/spapr.c | 13 ++++++------- hw/ppc/spapr_caps.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b2baec026f..062d9dc346 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4095,17 +4095,16 @@ static void spapr_machine_2_12_instance_options(Mac= hineState *machine) static void spapr_machine_2_12_class_options(MachineClass *mc) { sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); - uint8_t mps; =20 spapr_machine_3_0_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_12); =20 - if (kvmppc_hpt_needs_host_contiguous_pages()) { - mps =3D ctz64(qemu_getrampagesize()); - } else { - mps =3D 34; /* allow everything up to 16GiB, i.e. everything */ - } - smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D mps; + /* We depend on kvm_enabled() to choose a default value for the + * hpt-max-page-size capability. Of course we can't do it here + * because this is too early and the HW accelerator isn't initialzed + * yet. Postpone this to machine init (see default_caps_with_cpu()). + */ + smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D 0; } =20 DEFINE_SPAPR_MACHINE(2_12, "2.12", false); diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 62663ebdf5..aa605cea91 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -465,6 +465,19 @@ static sPAPRCapabilities default_caps_with_cpu(sPAPRMa= chineState *spapr, caps.caps[SPAPR_CAP_IBS] =3D SPAPR_CAP_BROKEN; } =20 + /* This is for pseries-2.12 and older */ + if (smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D=3D 0) { + uint8_t mps; + + if (kvmppc_hpt_needs_host_contiguous_pages()) { + mps =3D ctz64(qemu_getrampagesize()); + } else { + mps =3D 34; /* allow everything up to 16GiB, i.e. everything */ + } + + caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D mps; + } + return caps; } =20 --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 153059881030571.54527470383323; Mon, 2 Jul 2018 23:20:10 -0700 (PDT) Received: from localhost ([::1]:38048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEfU-0003SJ-Fx for importer@patchew.org; Tue, 03 Jul 2018 02:20:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKa-0002vV-8Z for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKY-000761-5o for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:28 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:49525) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKX-00070u-LL; Tue, 03 Jul 2018 01:58:26 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMD0RZ4z9sCH; Tue, 3 Jul 2018 15:58:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597496; bh=w+qJZ/HvtwFBLiJASBhY6y83IoI0CiwlYPH0IrMV13U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pw6Td5bMnfApvdgn5Muj+cHk+Pzhzho76hNWPioN7GLaJEW5s3JfBFKoLEgpOn5Ox AIB80eYZBaxhBXpxFvNcNv/ei7OvpIgiaxtdCL5Lxnvc19l69D6yAxty0kJopmVpdH VTU9YySqONvTacKeHiuwxOQ/h6mFvsozVaEzGvCo= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:58:02 +1000 Message-Id: <20180703055804.13449-34-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 33/35] target/ppc: set is_jmp on ppc_tr_breakpoint_check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, "Emilio G. Cota" , qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" The use of GDB breakpoints was broken by b0c2d52 ("target/ppc: convert to TranslatorOps", 2018-02-16). Fix it by setting is_jmp, so that we break from the translation loop as originally intended. Tested-by: Mark Cave-Ayland Reported-by: Mark Cave-Ayland Signed-off-by: Emilio G. Cota Signed-off-by: David Gibson --- target/ppc/translate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index e120f2ed0b..65c8cc94e7 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7482,6 +7482,7 @@ static bool ppc_tr_breakpoint_check(DisasContextBase = *dcbase, CPUState *cs, DisasContext *ctx =3D container_of(dcbase, DisasContext, base); =20 gen_debug_exception(ctx); + dcbase->is_jmp =3D DISAS_NORETURN; /* The address covered by the breakpoint must be included in [tb->pc, tb->pc + tb->size) in order to for it to be properly cleared -- thus we increment the PC here so that --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530598551530705.5886275926389; Mon, 2 Jul 2018 23:15:51 -0700 (PDT) Received: from localhost ([::1]:38030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEbO-0000Gg-Jb for importer@patchew.org; Tue, 03 Jul 2018 02:15:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKb-0002wG-0y for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKY-00076V-DB for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:28 -0400 Received: from ozlabs.org ([203.11.71.1]:35063) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKX-00071Z-Uo; Tue, 03 Jul 2018 01:58:26 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMD1lsdz9sC7; Tue, 3 Jul 2018 15:58:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597496; bh=qMoYBT3owSKVOG4/9A+iznCQCBdNL3iK6qWdcZoh68g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FJawAaYqcKWctuvMUacqrfUjDCSzcvpPatDrdYhzqM1AU+zJEwMOhXDMxFI8CzMuv pP3tMQGo8Yh4JshqRJy0EuXbYFA4eGZVR1t4jRMB9Q1m5ScsGS7i3gq0QK1+7f3nWu etgUInuUmJRiqs0iE0J6PasMBPi1B+tP8XJj8+as= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:58:03 +1000 Message-Id: <20180703055804.13449-35-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 34/35] target/ppc: Relax reserved bitmask of indexed store instructions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan The PPC440 User Manual says that if bit 31 is set, the contents of CR[CR0] are undefined for indexed store instructions but this form is not invalid. Other PPC variants confirming to recent ISA where this bit may be reserved should ignore reserved bits and not raise invalid instruction exception. In particular, MorphOS has an stwx instruction with bit 31 set and fails to boot currently because of this. With this patch it gets further. Signed-off-by: David Gibson --- target/ppc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 65c8cc94e7..9eaa10b421 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7054,7 +7054,7 @@ GEN_HANDLER(stop##u, opc, 0xFF, 0xFF, 0x00000000, typ= e), #define GEN_STUX(name, stop, opc2, opc3, type) = \ GEN_HANDLER(name##ux, 0x1F, opc2, opc3, 0x00000001, type), #define GEN_STX_E(name, stop, opc2, opc3, type, type2, chk) = \ -GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000001, type, type2), +GEN_HANDLER_E(name##x, 0x1F, opc2, opc3, 0x00000000, type, type2), #define GEN_STS(name, stop, op, type) = \ GEN_ST(name, stop, op | 0x20, type) = \ GEN_STU(name, stop, op | 0x21, type) = \ --=20 2.17.1 From nobody Tue Nov 4 15:31:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530599268254898.3160706327976; Mon, 2 Jul 2018 23:27:48 -0700 (PDT) Received: from localhost ([::1]:38114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEmx-0001ze-FG for importer@patchew.org; Tue, 03 Jul 2018 02:27:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faEKb-0002xV-SN for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faEKY-00077N-RY for qemu-devel@nongnu.org; Tue, 03 Jul 2018 01:58:29 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:53073) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1faEKY-00072d-BW; Tue, 03 Jul 2018 01:58:26 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41KYMD2t3pz9sCK; Tue, 3 Jul 2018 15:58:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1530597496; bh=jmSGDHpcQQst40GbmaGgCkBj/QnQuBSVBA13ilbwqTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Amnw4vSOp3WrXzfcKijXerkmKYykGfRWBKWzF3bZOeCCob/bAtIPL0LyVg/FxDgz9 +xIiLqLt2GZ0i4D749FIeZd165ldPIuNc1bQ/Pg9vm1OKfFunC2ID1QUX1L1LO+jOn 9aYmJIfiHHykAXjA++ClyjQ3OgE2ZngNVSNo3G48= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 3 Jul 2018 15:58:04 +1000 Message-Id: <20180703055804.13449-36-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703055804.13449-1-david@gibson.dropbear.id.au> References: <20180703055804.13449-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 35/35] ppc: Include vga cirrus card into the compiling process X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Sebastian Bauer , mdroth@linux.vnet.ibm.com, agraf@suse.de, aik@ozlabs.ru, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Sebastian Bauer Drivers for this card exists on PPC-based AmigaOS guests so it is useful to allow users to emulate the graphics card for PPC machines. As cirrus vga is currently preferred over std(vga) in absence of any user choice, this change also sets the default display of spapr machines to std as otherwise qemu refuses to start these machines. Not specifying an explicit graphics mode is for instance done by 'make check'. Signed-off-by: Sebastian Bauer Signed-off-by: David Gibson --- default-configs/ppc-softmmu.mak | 1 + hw/ppc/spapr.c | 1 + 2 files changed, 2 insertions(+) diff --git a/default-configs/ppc-softmmu.mak b/default-configs/ppc-softmmu.= mak index 7e1a3d8135..6f12bf84f0 100644 --- a/default-configs/ppc-softmmu.mak +++ b/default-configs/ppc-softmmu.mak @@ -29,6 +29,7 @@ CONFIG_IDE_SII3112=3Dy CONFIG_I2C=3Dy CONFIG_BITBANG_I2C=3Dy CONFIG_M41T80=3Dy +CONFIG_VGA_CIRRUS=3Dy =20 # For Macs CONFIG_MAC=3Dy diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 062d9dc346..6e8723d3ba 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3962,6 +3962,7 @@ static void spapr_machine_class_init(ObjectClass *oc,= void *data) mc->no_parallel =3D 1; mc->default_boot_order =3D ""; mc->default_ram_size =3D 512 * M_BYTE; + mc->default_display =3D "std"; mc->kvm_type =3D spapr_kvm_type; machine_class_allow_dynamic_sysbus_dev(mc, TYPE_SPAPR_PCI_HOST_BRIDGE); mc->pci_allow_0_address =3D true; --=20 2.17.1